void WebCoreClass::resumeUpload(DesuraId id, const char* key, WebCore::Misc::ResumeUploadInfo &info) { TiXmlDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["action"] = "resumeupload"; post["key"] = key; TiXmlNode *uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc); TiXmlNode* mNode = uNode->FirstChild("mcf"); if (!mNode) throw gcException(ERR_BADXML); gcString complete; XML::GetChild("complete", complete, mNode); if (complete == "1") throw gcException(ERR_COMPLETED); XML::GetChild("date", info.szDate, mNode); XML::GetChild("filehash", info.szHash, mNode); XML::GetChild("filesize", info.size, mNode); XML::GetChild("filesizeup", info.upsize, mNode); }
void WebCoreClass::resumeUpload(DesuraId id, const char* key, WebCore::Misc::ResumeUploadInfo &info) { XML::gcXMLDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["action"] = "resumeupload"; post["key"] = key; auto uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc); auto iNode = uNode.FirstChildElement("mcf"); if (!iNode.IsValid()) throw gcException(ERR_BADXML); gcString complete; iNode.GetChild("complete", complete); if (complete == "1") throw gcException(ERR_COMPLETED); iNode.GetChild("date", info.szDate); iNode.GetChild("filehash", info.szHash); iNode.GetChild("filesize", info.size); iNode.GetChild("filesizeup", info.upsize); }
void WebCoreClass::newUpload(DesuraId id, const char* hash, uint64 fileSize, char **key) { gcString size("{0}", fileSize); TiXmlDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["action"] = "newupload"; post["filehash"] = hash; post["filesize"] = size; TiXmlNode *uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc); TiXmlNode* iNode = uNode->FirstChild("mcf"); if (!iNode) throw gcException(ERR_BADXML); TiXmlElement* cEl = iNode->ToElement(); if (cEl) { const char* text = cEl->Attribute("key"); if (!text) throw gcException(ERR_BADXML); Safe::strcpy(key, text, 255); } }
void WebCoreClass::newUpload(DesuraId id, const char* hash, uint64 fileSize, char **key) { gcString size("{0}", fileSize); XML::gcXMLDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["action"] = "newupload"; post["filehash"] = hash; post["filesize"] = size; auto uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc); auto iNode = uNode.FirstChildElement("mcf"); if (!iNode.IsValid()) throw gcException(ERR_BADXML); if (key) { const std::string text = iNode.GetAtt("key"); if (text.empty()) throw gcException(ERR_BADXML); Safe::strcpy(key, text.c_str(), text.size()); } }
void UpdateInfoForm::setInfo(DesuraId id, bool launch) { m_bLaunch = launch; m_uiInternId = id; m_cbReminder->Enable(m_bLaunch); m_cbReminder->Show(m_bLaunch); UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id ); if (!item) { Warning("Cant find item for update form.\n"); return; } if (item->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(item->getIcon()))) setIcon(item->getIcon()); m_cbReminder->SetValue(m_bLaunch && item->getOptions() & UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE); SetLabel(gcWString(L"{0} {1}", Managers::GetString(L"#UI_TITLE"), item->getName())); m_ieBrowser->loadUrl(gcWString(L"http://www.desura.com/{0}/{1}/changelog", id.getTypeString(), item->getShortName())); }
bool UpdateThreadOld::pollUpdates() { if (!m_pWebCore || !m_pUser) return false; updateBuildVer(); std::map<std::string, std::string> post; #ifdef DESURA_NONGPL_BUILD post["appid"] = gcString("{0}", m_iAppId); post["build"] = gcString("{0}", m_iAppVersion); #endif for (uint32 x=0; x< m_pUser->getItemManager()->getCount(); x++) { UserCore::Item::ItemInfoI* item = m_pUser->getItemManager()->getItemInfo(x); if (!item) continue; if (!(item->getStatus() & UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER) || (item->getStatus()&UserCore::Item::ItemInfoI::STATUS_ONACCOUNT)) continue; DesuraId id = item->getId(); if (id.getType() == DesuraId::TYPE_LINK) continue; gcString key("updates[{0}][{1}]", id.getTypeString().c_str(), id.getItem()); post[key] = "1"; } TiXmlDocument doc; try { m_pWebCore->getUpdatePoll(doc, post); } catch (gcException &e) { Warning(gcString("Update poll failed: {0}\n", e)); return false; } parseXML(doc); #ifdef WIN32 checkFreeSpace(); #endif m_hHttpHandle->cleanPostInfo(); m_hHttpHandle->cleanUp(); m_hHttpHandle->clearCookies(); return true; }
void WebCoreClass::updateAccountItem(DesuraId id, bool add) { TiXmlDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["action"] = add?"add":"delete"; postToServer(getUpdateAccountUrl(), "iteminstall", post, doc); }
void WebCoreClass::getDownloadProviders(DesuraId id, XML::gcXMLDocument &xmlDocument, MCFBranch mcfBranch, MCFBuild mcfBuild) { PostMap postData; postData["siteareaid"] = id.getItem(); postData["sitearea"] = id.getTypeString(); postData["branch"] = (size_t) mcfBranch; if (mcfBuild != 0) postData["build"] = (size_t) mcfBuild; postToServer(getMCFDownloadUrl(), "itemdownloadurl", postData, xmlDocument); }
void WebCoreClass::getItemInfo(DesuraId id, TiXmlDocument &doc, MCFBranch mcfBranch, MCFBuild mcfBuild) { PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); if (mcfBuild != 0) post["build"] = mcfBuild; if (mcfBranch != 0) { if (mcfBranch.isGlobal()) post["branchglobal"] = mcfBranch; else post["branch"] = mcfBranch; } postToServer(getItemInfoUrl(), "iteminfo", post, doc); }
gcString WebCoreClass::getCDKey(DesuraId id, MCFBranch branch) { TiXmlDocument doc; PostMap post; post["siteareaid"] = id.getItem(); post["sitearea"] = id.getTypeString(); post["branch"] = (size_t)branch; #ifdef WIN32 post["token"] = UTIL::WIN::getRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\MachineGuid", true); #else post["token"] = "todo"; #endif TiXmlNode* root = postToServer(getCDKeyUrl(), "cdkey", post, doc); TiXmlElement* key = root->FirstChildElement("key"); if (!key) throw gcException(ERR_BADXML); return key->GetText(); }
void MCF::getDownloadProviders(const char* url, MCFCore::Misc::UserCookies *pCookies, bool *unauthed, bool local) { if (!pCookies) throw gcException(ERR_INVALID, "Cookies are null (getDownloadProviders)"); HttpHandle wc(url); pCookies->set(wc); DesuraId id = m_sHeader->getDesuraId(); gcString type = id.getTypeString(); wc->addPostText("siteareaid", id.getItem()); wc->addPostText("sitearea", type.c_str()); wc->addPostText("branch", m_sHeader->getBranch()); MCFBuild build = m_sHeader->getBuild(); if (build != 0) wc->addPostText("build", build); if (local) wc->addPostText("local", "yes"); wc->postWeb(); if (wc->getDataSize() == 0) throw gcException(ERR_BADRESPONSE); TiXmlDocument doc; doc.SetCondenseWhiteSpace(false); XML::loadBuffer(doc, const_cast<char*>(wc->getData()), wc->getDataSize()); TiXmlNode *uNode = doc.FirstChild("itemdownloadurl"); if (!uNode) throw gcException(ERR_BADXML); TiXmlNode* sNode = uNode->FirstChild("status"); if (!sNode) throw gcException(ERR_BADXML); uint32 status = 0; TiXmlElement* sEl = sNode->ToElement(); if (sEl) { const char* statStr = sEl->Attribute("code"); if (statStr) status = atoi(statStr); else throw gcException(ERR_BADXML); } else { throw gcException(ERR_BADXML); } if (status != 0) throw gcException(ERR_BADSTATUS, status, gcString("Status: {0}", sEl->GetText())); TiXmlNode* iNode = uNode->FirstChild("item"); if (!iNode) { throw gcException(ERR_BADXML); } TiXmlNode* mNode = iNode->FirstChild("mcf"); if (!mNode) { throw gcException(ERR_BADXML); } TiXmlElement *melNode = mNode->ToElement(); if (melNode) { const char* build = melNode->Attribute("build"); const char* branch = melNode->Attribute("branch"); //Debug(gcString("MCF: R: {0}.{1} G: {2}.{3}\n", m_sHeader->getBranch(), m_sHeader->getBuild(), build, branch)); if (build) m_sHeader->setBuild(MCFBuild::BuildFromInt(atoi(build))); if (branch) m_sHeader->setBranch(MCFBranch::BranchFromInt(atoi(branch))); } safe_delete(m_pFileAuth); char *szAuthCode = NULL; XML::GetChild("authhash", szAuthCode, mNode); if (!szAuthCode) throw gcException(ERR_BADXML); m_pFileAuth = new Misc::GetFile_s; memset(m_pFileAuth, 0, sizeof(Misc::GetFile_s)); Safe::strncpy(m_pFileAuth->authhash, 33, szAuthCode, 33); char buff[10]; Safe::snprintf(buff, 10, "%d", pCookies->getUserId()); size_t size = Safe::strlen(buff, 10); memcpy(m_pFileAuth->authkey, buff, size); safe_delete(szAuthCode); TiXmlNode* urlNode = mNode->FirstChild("urls"); if (!urlNode) throw gcException(ERR_BADXML); char * szAuthed = NULL; XML::GetChild("authed", szAuthed, mNode); if (unauthed && szAuthed) { *unauthed = (atoi(szAuthed) == 0); } safe_delete(szAuthed); #ifdef DEBUG #if 0 m_vProviderList.clear(); m_vProviderList.push_back(new MCFCore::Misc::DownloadProvider("localhost", "mcf://10.0.0.121:62001", "", "")); return; #endif #endif TiXmlElement* pChild = urlNode->FirstChildElement("url"); while (pChild) { MCFCore::Misc::DownloadProvider* temp = new MCFCore::Misc::DownloadProvider(pChild); m_vProviderList.push_back(temp); pChild = pChild->NextSiblingElement(); } if (m_vProviderList.size() == 0) throw gcException(ERR_ZEROSIZE); }