void NewVersionDlg::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); int iTotalTextLength = ctlDetails.GetWindowTextLength(); ctlDetails.SetSel(iTotalTextLength, iTotalTextLength); BeginWaitCursor(); CString sResult; CWebAccess webAccess; webAccess.Get("www.milow.net/site/projects/parnrar/pnrVersions.xml", sResult); if (sResult != "") { MSXML::IXMLDOMDocumentPtr domVersions; if (CoCreateInstance( MSXML::CLSID_DOMDocument, 0, CLSCTX_INPROC_SERVER, MSXML::IID_IXMLDOMDocument, (void**)&domVersions ) != S_OK) { ctlDetails.ReplaceSel("Error: Failed to create DOMDocument object"); goto CLEANUP; } domVersions->loadXML(sResult.GetBuffer(0)); CString sXml = static_cast<char *>(domVersions->xml); if (sXml == "") { ctlDetails.ReplaceSel("Error: Failed to download version information"); goto CLEANUP; } MSXML::IXMLDOMElementPtr eVer = domVersions->selectSingleNode("/Versions/Version"); CString sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number"))); if (sVer == theApp.GetMyVersion()) { ctlDetails.ReplaceSel("You are currently running the latest version of Par-N-Rar"); goto CLEANUP; } //Get all info about later versions CString sText = "You are currently running v" + theApp.GetMyVersion(); sText += "\n"; sText += "The latest version is v" + sVer; sText += "\n\n"; MSXML::IXMLDOMNodeListPtr nlVersions = domVersions->selectNodes( "/Versions/Version"); for (long l=0; l<nlVersions->length; l++) { eVer = nlVersions->Getitem(l); sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number"))); if (sVer == theApp.GetMyVersion()) break; sText += "****************************************************\nVersion " + sVer; sText += ": \n"; sText += static_cast<char *>(eVer->text); sText += "\n\n"; } ctlDetails.ReplaceSel(sText); } CLEANUP: Resize(); EndWaitCursor(); }
bool NZBFile::ParseNZB(IUnknown* nzb) { MSXML::IXMLDOMDocumentPtr doc = nzb; MSXML::IXMLDOMNodePtr root = doc->documentElement; MSXML::IXMLDOMNodePtr node = root->selectSingleNode("/nzb/head/meta[@type='password']"); if (node) { _bstr_t password(node->Gettext()); m_szPassword = strdup(password); } MSXML::IXMLDOMNodeListPtr fileList = root->selectNodes("/nzb/file"); for (int i = 0; i < fileList->Getlength(); i++) { node = fileList->Getitem(i); MSXML::IXMLDOMNodePtr attribute = node->Getattributes()->getNamedItem("subject"); if (!attribute) return false; _bstr_t subject(attribute->Gettext()); FileInfo* pFileInfo = new FileInfo(); pFileInfo->SetSubject(subject); attribute = node->Getattributes()->getNamedItem("date"); if (attribute) { _bstr_t date(attribute->Gettext()); pFileInfo->SetTime(atoi(date)); } MSXML::IXMLDOMNodeListPtr groupList = node->selectNodes("groups/group"); for (int g = 0; g < groupList->Getlength(); g++) { MSXML::IXMLDOMNodePtr node = groupList->Getitem(g); _bstr_t group = node->Gettext(); pFileInfo->GetGroups()->push_back(strdup((const char*)group)); } MSXML::IXMLDOMNodeListPtr segmentList = node->selectNodes("segments/segment"); for (int g = 0; g < segmentList->Getlength(); g++) { MSXML::IXMLDOMNodePtr node = segmentList->Getitem(g); _bstr_t id = node->Gettext(); char szId[2048]; snprintf(szId, 2048, "<%s>", (const char*)id); MSXML::IXMLDOMNodePtr attribute = node->Getattributes()->getNamedItem("number"); if (!attribute) return false; _bstr_t number(attribute->Gettext()); attribute = node->Getattributes()->getNamedItem("bytes"); if (!attribute) return false; _bstr_t bytes(attribute->Gettext()); int partNumber = atoi(number); int lsize = atoi(bytes); if (partNumber > 0) { ArticleInfo* pArticle = new ArticleInfo(); pArticle->SetPartNumber(partNumber); pArticle->SetMessageID(szId); pArticle->SetSize(lsize); AddArticle(pFileInfo, pArticle); } } AddFileInfo(pFileInfo); } return true; }