Exemple #1
0
bool CrpcBase::rpcObj(CXmlNodePtr param, const char *name, rpcObject *rpcObj)
{
	cvs::string fnd;
	CXmlNodePtr val;

	val = param->Clone();
	if(!strcmp(val->GetName(),"param")) 
		val->GetChild();
	if(!strcmp(val->GetName(),"struct"))
	{
		if(name)
		{
			cvs::sprintf(fnd,64,"member[@name='%s']",name);
			if(!val->Lookup(fnd.c_str()))
				return false;
			if(!val->XPathResultNext())
				return false;
		}
		else
			val->GetChild();
		val->GetChild("value");
	}
	if(strcmp(val->GetName(),"value"))
		return false;
	if(!val->GetChild())
		return false;
	if(strcmp(val->GetName(),"struct"))
		return false;
	return rpcObj->Marshall(val);
}
Exemple #2
0
bool CrpcBase::rpcInt(CXmlNodePtr param, const char *name, int& value)
{
	cvs::string fnd;
	CXmlNodePtr val;

	val = param->Clone();
	if(!strcmp(val->GetName(),"param")) 
		val->GetChild();
	if(!strcmp(val->GetName(),"struct"))
	{
		if(name)
		{
			cvs::sprintf(fnd,64,"member[@name='%s']",name);
			if(!val->Lookup(fnd.c_str()))
				return false;
			if(!val->XPathResultNext())
				return false;
		}
		else
			val->GetChild();
		val->GetChild("value");
	}
	if(strcmp(val->GetName(),"value"))
		return false;
	if(!val->GetChild())
		return false;
	if(strcmp(val->GetName(),"i4"))
		return false;
	value = atoi(val->GetValue());
	return true;
}
Exemple #3
0
bool CrpcBase::rpcArray(CXmlNodePtr param, const char *name, CXmlNodePtr& node)
{
	CXmlNodePtr val = param->Clone();

	if(!strcmp(val->GetName(),"param"))
		val->GetChild();
	if(!strcmp(val->GetName(),"array"))
		return false;

	if(!node)
	{
		if(!val->GetChild())
			return false;
		if(!strcmp(val->GetName(),"data"))
			return false;
		node = val->Clone();
		return true;
	}
	else
	{
		if(!node->GetParent()) return false;
		if(!node->GetSibling()) return false;
		if(!strcmp(node->GetName(),"data"))
			return false;
		if(!node->GetChild()) return false;
		return true;
	}
}
Exemple #4
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, rpcObject *obj)
{
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);

	return obj->Marshall(param);
}
Exemple #5
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, const char *value)
{
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);
	param->NewNode("string",value);
	return true;
}
Exemple #6
0
bool CrpcBase::addParam(CXmlNodePtr params, const char *name, int value)
{
	char tmp[32];
	snprintf(tmp,sizeof(tmp),"%d",value);
	CXmlNodePtr param = params->Clone();

	if(!strcmp(param->GetName(),"params"))
		param->NewNode("param", NULL);
	else if(!strcmp(param->GetName(),"struct"))
	{
		param->NewNode("member", NULL);
		if(name)
			param->NewNode("name",name,false);
	}
	param->NewNode("value",NULL);
	param->NewNode("i4",tmp);
	return true;
}
Exemple #7
0
void CInfoPanel::LoaderThread()
{
	m_news.clear();
	CHttpSocket sock;
	cvs::string xml;
	CXmlTree tree;
	size_t len;

	if(!sock.create("http://march-hare.com"))
	{
		xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need assistance?  Click here for our professional support options!</subject><author>&quot;March Hare Support&quot; &lt;[email protected]&gt;</author><url>http://store.march-hare.com/s.nl?sc=2&amp;category=2</url></message>\n</messages>";
		len=xml.length();
	}
	else if(!sock.request("GET","/cvspro/prods-pre.asp?register=advert"))
	{
		xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need help NOW?  Click here for our professional support options!</subject><author>&quot;March Hare Support&quot; &lt;[email protected]&gt;</author><url>http://store.march-hare.com/s.nl?sc=2&amp;category=2</url></message>\n</messages>";
		len=xml.length();
	}
	if(sock.responseCode()!=200)
	{
		xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need help? Need integration?  Need training?  Click here for our professional support options!</subject><author>&quot;March Hare Support&quot; &lt;[email protected]&gt;</author><url>http://store.march-hare.com/s.nl?sc=2&amp;category=2</url></message>\n</messages>";
		len=xml.length();
	}
	else
	{
		cvs::string xml = sock.responseData(len);
	}
	if(!tree.ParseXmlFromMemory(xml.c_str()))
		return;
	CXmlNodePtr node = tree.GetRoot();
	if(strcmp(node->GetName(),"messages"))
		return;
	if(!node->GetChild("message"))
		return;

	do
	{
		news_t n;
		n.subject = node->GetNodeValue("subject");
		n.author = node->GetNodeValue("author");
		n.url = node->GetNodeValue("url");
		m_news.push_back(n);
	} while(node->GetSibling("message"));

	if(!m_hItemFont)
	{
		HFONT hFont = (HFONT)SendMessage(m_hListWnd,WM_GETFONT,0,0);
		if(!hFont) hFont=GetStockFont(DEFAULT_GUI_FONT);

		LOGFONT lf = {0};
		GetObject(hFont,sizeof(lf),&lf);
		lf.lfUnderline=true;
		m_hItemFont = CreateFontIndirect(&lf);
	}

	ListView_DeleteAllItems(m_hListWnd);
	ListView_DeleteColumn(m_hListWnd,1);
	LVCOLUMN lvc={0};
	lvc.mask=LVCF_WIDTH|LVCF_TEXT;
	lvc.cx=500;
	lvc.pszText=_T("Title");
	ListView_InsertColumn(m_hListWnd,0,&lvc);
	lvc.mask=LVCF_WIDTH|LVCF_TEXT;
	lvc.cx=300;
	lvc.pszText=_T("Author");
	ListView_InsertColumn(m_hListWnd,1,&lvc);

	for(size_t n=0; n<m_news.size(); n++)
	{
		LVITEM lvi = {0};
		cvs::wide wnews(m_news[n].subject.c_str());
		cvs::wide wauth(m_news[n].author.c_str());
		lvi.mask=LVIF_TEXT|LVIF_PARAM;
		lvi.iItem=(int)n;
		lvi.pszText=(LPWSTR)(const wchar_t*)wnews;
		lvi.lParam=(LPARAM)&m_news[n];
		int iItem = ListView_InsertItem(m_hListWnd,&lvi);
		ListView_SetItemText(m_hListWnd,iItem,1,(LPWSTR)(const wchar_t*)wauth);
	}
	m_bLoaded = true;
}