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; }
//returns : ERROR_OK, ERROR_INTEGRITY, ERROR_FREE_SPACE void extractFileToDir(LauncherProperties * props, WCHAR ** resultFile) { WCHAR * fileName = NULL; int64t * fileLength = NULL; DWORD crc = 0; writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Extracting file ...", 1); readStringWithDebugW( props, & fileName, "file name"); fileLength = newint64_t(0, 0); readBigNumberWithDebug( props, fileLength, "file length "); readNumberWithDebug( props, &crc, "CRC32"); if(!isOK(props)) return; if(fileName!=NULL) { DWORD i=0; WCHAR * dir; resolveString(props, &fileName); for(i=0;i<getLengthW(fileName);i++) { if(fileName[i]==L'/') { fileName[i]=L'\\'; } } dir = getParentDirectory(fileName); writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " ... extract to directory = ", 0); writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, dir, 1); checkFreeSpace(props, dir, fileLength); FREE(dir); if(isOK(props)) { writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " ... starting data extraction", 1); writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " ... output file is ", 0); writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, fileName, 1); extractDataToFile(props, fileName, fileLength, crc); writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " ... extraction finished", 1); *resultFile = fileName; } else { writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " ... data extraction canceled", 1); } } else { writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Error! File name can`t be null. Seems to be integrity error!", 1); *resultFile = NULL; props -> status = ERROR_INTEGRITY; } FREE(fileLength); return; }