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; }
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); }
static void set_acl(CXmlNodePtr base) { CXmlNodePtr acl, acl_to_set = NULL; acl = fileattr_find(base,"acl"); while(acl) { const char *user = fileattr_getvalue(acl,"@user"); const char *branch = fileattr_getvalue(acl,"@branch"); const char *merge = fileattr_getvalue(acl,"@merge"); if(((!user && !parms.user) || (user && parms.user && !usercmp(user,parms.user))) && ((!branch && !parms.branch) || (branch && parms.branch && !strcmp(branch,parms.branch))) && ((!merge && !parms.merge) || (merge && parms.merge && !strcmp(merge,parms.merge)))) { acl_to_set = acl; break; } acl = fileattr_next(acl); } if(acl_to_set) fileattr_batch_delete(acl_to_set); if(!parms.del) { char *parm = xstrdup(parms.access); char *acc = parm?strtok(parm,","):NULL; base->NewNode("acl"); fileattr_modified(); if(parms.user) base->NewAttribute("user",parms.user); if(parms.branch) base->NewAttribute("branch",parms.branch); if(parms.merge) base->NewAttribute("merge",parms.merge); if(parms.priority && atoi(parms.priority)) base->NewAttribute("priority",parms.priority); if(parms.message) base->NewNode("message",parms.message,false); base->NewNode("modified_by",getcaller(),false); base->NewNode("modified_date",current_date,false); while(acc) { int deny=0; if(!strncmp(acc,"no",2) && strcmp(acc,"none")) { deny=1; acc+=2; } if(!strcmp(acc,"all")) set_attrs(base,"all",deny,parms.noinherit); else if(!strcmp(acc,"none")) set_attrs(base,"all",!deny,parms.noinherit); else if(!strcmp(acc,"read")) set_attrs(base,"read",deny,parms.noinherit); else if(!strcmp(acc,"write")) set_attrs(base,"write",deny,parms.noinherit); else if(!strcmp(acc,"create")) set_attrs(base,"create",deny,parms.noinherit); else if(!strcmp(acc,"tag")) set_attrs(base,"tag",deny,parms.noinherit); else if(!strcmp(acc,"control")) set_attrs(base,"control",deny,parms.noinherit); else error(1,0,"Invalid access control attribute '%s'",acc); acc = strtok(NULL,","); } base->GetParent(); fileattr_prune(base); xfree(parm); } else { if(acl_to_set) fileattr_prune(acl_to_set); } }
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; } }
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>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&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>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&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>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&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; }