void GatherInfoTask::doTask() { auto pUser = getUserCore(); if (!pUser) return; try { uint32 flags = UserCore::Item::ItemInfoI::STATUS_DELETED; if (m_bAddToAccount) flags = UserCore::Item::ItemInfoI::STATUS_ONACCOUNT; pUser->getItemManager()->retrieveItemInfo(getItemId(), flags); if (m_bAddToAccount) { //if we just removed this item from account it will be in a hidden deleted status auto info = pUser->getItemManager()->findItemInfo(getItemId()); if (info) info->delSFlag(UserCore::Item::ItemInfoI::STATUS_DELETED); } } catch(gcException &e) { Warning("Failed to gather item info in task: {0}\n", e); } }
void UploadResumeThread::doRun() { assert(m_pUpInfo); getWebCore()->resumeUpload(getItemId(), m_szKey.c_str(), *m_pUpInfo); const char* localFilePath = getUploadManager()->findUpload(m_szKey.c_str()); gcString sLocalFP(localFilePath); if (localFilePath && validFile(localFilePath)) { onCompleteStrEvent(sLocalFP); return; } //gona try and search for the file in the data/mods/id folder const char* appDataPath = getUserCore()->getAppDataPath(); gcString searchPath("{0}{1}{2}", appDataPath, DIRS_STR, getItemId().getFolderPathExtension()); gcString sNull("NULL"); if (doSearch(searchPath.c_str())) return; if (getUserCore()->isAdmin()) { searchPath = gcString("{0}{1}temp{1}", appDataPath, DIRS_STR); if (doSearch(searchPath.c_str())) return; } onCompleteStrEvent(sNull); }
void UploadInfoPage::onResume() { UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(getItemId()); if (!item && !GetUserCore()->isAdmin()) { Close(); return; } m_tbItemFile->SetLabel( Managers::GetString(L"#UDF_RESUMEDIR")); m_butUpload->Enable(false); m_tbItemFile->Enable(false); m_butFile->Enable(false); m_bResume = true; safe_delete(m_pUpInfo); m_pUpInfo = new WebCore::Misc::ResumeUploadInfo(); m_pResumeThread = GetThreadManager()->newUploadResumeThread(getItemId(), m_szKey.c_str(), m_pUpInfo); *m_pResumeThread->getErrorEvent() += guiDelegate(this, &UploadInfoPage::onError); *m_pResumeThread->getCompleteStringEvent() += guiDelegate(this, &UploadInfoPage::onResumeCompleteCB); m_pResumeThread->start(); Show(); Raise(); }
void MigrateStandaloneTask::doTask() { auto wildc = gcRefPtr<WildcardManager>::create(); wildc->onNeedSpecialEvent += delegate(&getUserCore()->getNeedWildCardEvent()); for (size_t x=0; x<m_vFileList.size(); x++) { AutoDelFile adf(m_vFileList[x]); XML::gcXMLDocument doc(m_vFileList[x].getFullPath().c_str()); if (!doc.IsValid()) continue; auto root = doc.GetRoot("game"); if (!root.IsValid()) continue; gcString path; gcString id; uint32 branch = -1; uint32 build = -1; root.GetChild("path", path); root.GetChild("id", id); root.GetChild("branch", branch); root.GetChild("build", build); if (id == "" || !UTIL::FS::isValidFolder(path)) continue; DesuraId itemId(id.c_str(), "games"); auto info = getUserCore()->getItemManager()->findItemInfo(itemId); if (!info || info->isInstalled()) continue; try { getUserCore()->getCIPManager()->updateItem(itemId, path); getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc); } catch (...) { continue; } info = getUserCore()->getItemManager()->findItemInfo(itemId); auto realInfo = gcRefPtr<UserCore::Item::ItemInfo>::dyn_cast(info); if (!realInfo) continue; realInfo->migrateStandalone(MCFBranch::BranchFromInt(branch), MCFBuild::BuildFromInt(build)); } }
void CDKProgress::dispose() { auto userCore = GetUserCore(); if (m_bOutstandingRequest && userCore) userCore->getCDKeyManager()->cancelRequest(getItemId(), m_ProgressProxy); }
void DescriptorFrame::addProcesstoServer(Qedo::ProcessData process,wxTreeItemId itemId,int iter) { std::vector <Qedo::HomeInstanceData> homes = process.homes; std::vector <Qedo::HomeInstanceData> ::iterator home_iter; wxTreeItemId apId; wxTreeItemId item_dest_id; // first adding after reading cad file if (itemId==rootId) { // Destination node is kown if (iskown(process.dest.node.c_str())) { item_dest_id = getItemId(process.dest.node.c_str()); apId = server_ctrl_->AppendItem(item_dest_id, _T("Processcollocation"), -1,-1,NULL); // Destination node is unkown } else { wxString tmp_string=process.dest.node.c_str(); tmp_string.append("(unkown)"); item_dest_id = server_ctrl_->AppendItem(rootId, tmp_string,-1,-1,NULL); server_ctrl_->SetItemBold(item_dest_id,TRUE); apId = server_ctrl_->AppendItem(item_dest_id, _T("Processcollocation"), -1,-1,NULL); } // if a destination node selected } else { apId = server_ctrl_->AppendItem(itemId, _T("Processcollocation"), -1,-1,NULL); item_dest_id=itemId; } // add homes of processcollocation for(home_iter = homes.begin(); home_iter != homes.end(); home_iter++) { addHometoServer(*home_iter,apId,-1); } // if processcollocation have no hostcollocation // then add to DestinationInfo if (!(iter==-1)) { DestinationInfo delist; delist.itemid=apId; delist.iter=iter; delist.node=getNode(item_dest_id); delist.typ=processcollocation; DestinationInfoList.push_back(delist); } }
void DescriptorFrame::addHomeplacement() { std::vector <Qedo::HomeInstanceData> ::iterator home_iter; int itercounter=-1; for(home_iter = homedatas.begin(); home_iter != homedatas.end(); home_iter++) { itercounter++; if ((*home_iter).dest.specified) { wxTreeItemId itemid = getItemId((*home_iter).dest.node.c_str()); addHometoServer(*home_iter,itemid,itercounter); server_ctrl_->Refresh(); server_ctrl_->Expand(rootId); } if (!(*home_iter).dest.specified) { addHometoComponent(*home_iter,rootId2,itercounter); component_list_->Refresh(); component_list_->Expand(rootId2); } } }
QVariant PartConditionModel::data(const QModelIndex &index, int role) const { if(index.column() == ColumnId && (role == Qt::EditRole || role == Qt::DisplayRole)){ return getItemId(index.row()); } return SimpleSqlTableModel::data(index, role); }
bool GatherInfoTask::checkNullBranch(UserCore::Item::BranchInfoI* branchInfo) { if (branchInfo) return true; if (!getUserCore()->getItemManager()->isKnownBranch(getMcfBranch(), getItemId())) throw gcException(ERR_BADITEM, "Branch is invalid or user doesnt have permissions to install branch."); if (!m_bFirstTime || HasAnyFlags(m_uiFlags, GI_FLAG_TEST)) throw gcException(ERR_UNSUPPORTEDPLATFORM, 1, "This branch is not supported on this platform"); m_bFirstTime = false; bool res = false; if (!m_bCanceled && m_pGIHH) res = m_pGIHH->showPlatformError(); if (!res) { completeStage(); } else { m_uiMcfBranch = MCFBranch::BranchFromInt(0); checkRequirements(); } return false; }
bool VSCheckMcfDownload::doTask(gcString &path) { UserCore::MCFManager *mm = UserCore::GetMCFManager(); path = mm->getMcfPath(getItemId(), getMcfBranch(), getMcfBuild()); return checkMcf(path); }
void UploadPrepThread::doRun() { UTIL::FS::Path path = UTIL::FS::PathWithFile(m_szFile); if (!UTIL::FS::isValidFile(path)) throw gcException(ERR_INVALIDFILE); McfHandle mcfHandle;; bool validMcf = false; mcfHandle->setFile(m_szFile.c_str()); mcfHandle->parseMCF(); MCFCore::MCFHeaderI* mcfHead = mcfHandle->getHeader(); DesuraId mcfId = mcfHead->getDesuraId(); DesuraId itemId = getItemId(); validMcf = (mcfHead->isValid() && (!mcfId.isOk() || mcfId == itemId)); if (!validMcf) throw gcException(ERR_INVALIDMCF); std::string hash = UTIL::MISC::hashFile(path.getFullPath().c_str()); uint64 fileSize = UTIL::FS::getFileSize(path); char* key = NULL; try { getWebCore()->newUpload(getItemId(), hash.c_str(), fileSize, &key); } catch (gcException &) { safe_delete(key); throw; } getUploadManager()->addUpload(getItemId(), key, m_szFile.c_str()); m_szKey = gcString(key); safe_delete(key); onCompleteStrEvent(m_szKey); }
void VerifyServiceTask::refreshInfo() { if (m_bRefreshedInfo) return; m_bRefreshedInfo = true; getUserCore()->getItemManager()->retrieveItemInfo(getItemId()); }
String Toolbar::toString() const { String s ("TB:"); for (int i = 0; i < getNumItems(); ++i) s << getItemId(i) << ' '; return s.trimEnd(); }
void CDKInfo::onButtonClicked(wxCommandEvent& event) { if (event.GetId() == m_butClose->GetId()) { GetParent()->Close(); } else if (event.GetId() == m_imgCopyAll->GetId() || (m_vSplitKey.size() == 0 && event.GetId() == m_imgCopyPart->GetId())) { if (wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(m_tbCdKey->GetValue())); wxTheClipboard->Close(); } m_tbCdKey->SetSelection(-1,-1); } else if (event.GetId() == m_imgCopyPart->GetId()) { SplitInfo *info = m_vSplitKey[m_uiCurIndex]; m_uiCurIndex++; if (m_uiCurIndex >= m_vSplitKey.size()) m_uiCurIndex = 0; if (wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(info->text)); wxTheClipboard->Close(); } m_tbCdKey->SetSelection(info->start,info->end); gcString label(Managers::GetString("#CDK_COPYPART")); if (m_uiCurIndex != 0) label = gcString(Managers::GetString("#CDK_COPYPART_X"), m_uiCurIndex+1); m_imgCopyPart->SetToolTip(label); } else if (m_butLaunch && m_butLaunch->GetId() == event.GetId()) { g_pMainApp->handleInternalLink(getItemId(), ACTION_LAUNCH, FormatArgs("cdkey", std::string("exe=") + m_szExe)); GetParent()->Close(); } else if (m_butActivate && m_butActivate->GetId() == event.GetId()) { UserCore::Item::ItemInfoI* info = getItemInfo(); if (info && info->isLaunchable()) info->addSFlag(UserCore::Item::ItemInfoI::STATUS_LAUNCHED); #ifdef WIN32 UTIL::WIN::runAs("steam://open/activateproduct"); #endif } }
void UploadInfoPage::initUpload(const char* path, uint64 start) { Show(false); UploadMCFForm* temp = dynamic_cast<UploadMCFForm*>(GetParent()); uint32 hash = GetUploadMng()->addUpload(getItemId(), m_szKey.c_str(), path); if (temp) temp->showProg(hash, start); }
void LaunchItemDialog::onButtonPressed(wxCommandEvent& event) { if (event.GetId() == m_butLaunch->GetId()) { g_pMainApp->handleInternalLink(getItemId(), ACTION_LAUNCH); Close(); } else if (event.GetId() == m_butCancel->GetId()) { Close(); } }
void CreateMCFThread::waitForItemInfo() { m_pUserCore->getItemManager()->retrieveItemInfoAsync(getItemId()); size_t count = 0; while (!isStopped() && !getItemInfo() && count < 100) { count++; gcSleep(500); } }
bool SGEquipCard::selfCanAdv() { bool ret = true; bool flag = true; //读取将要转生这个装备卡牌 SGEquipmentDataModel *model = SGStaticDataManager::shareStatic()->getEquipById(getItemId()); //装备的需要材料组id int materialDependId = model->getMaterialDependencyId(); //根据装备datamodel里的MaterialDependency获取依赖材料的数据 //=-1标示已经到最顶级 if(materialDependId ==-1) return false; SGMaterialDependencyDataModel *depend = SGStaticDataManager::shareStatic()->getMaterialDependencyById(materialDependId); CCString *condition = depend->getMaterialDependCondition(); //每个条件 materialId:materialNum CCArray *conditionGroup = split(condition->getCString(), ";"); //切分每个分组条件,将内部的条件再次进行切分 for (int i = 0; i < conditionGroup->count(); i++) { CCString *temp = static_cast<CCString *>(conditionGroup->objectAtIndex(i)); //冒号切分 CCArray *tempConditon = split(temp->getCString(), ","); //需要的材料id int materialId = static_cast<CCString *>(tempConditon->objectAtIndex(0))->intValue(); //需要的材料的数量 int needMaterialNum = static_cast<CCString *>(tempConditon->objectAtIndex(1))->intValue(); SGMaterialCard *materialCard = SGPlayerInfo::sharePlayerInfo()->getMaterialCardByItemId(materialId); if(materialCard) { if(materialCard->getMaterialCurrNum() < needMaterialNum) { ret = false; break; } } else { ret = false; break; } } return ret; }
void InstallCheckTask::doRun() { WildcardManager wildc = WildcardManager(); wildc.onNeedSpecialEvent += delegate(&onNeedWCEvent); wildc.onNeedSpecialEvent += delegate(getUserCore()->getNeedWildCardEvent()); getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, &wildc); uint32 prog = 0; onCompleteEvent(prog); getItemHandle()->completeStage(false); }
void CDKProgress::run() { if (!m_ProgressProxy) m_ProgressProxy = gcRefPtr<CDKProgressProxy>::create(this); auto userCore = GetUserCore(); if (!userCore) return; userCore->getCDKeyManager()->getCDKeyForCurrentBranch(getItemId(), m_ProgressProxy); m_bOutstandingRequest = true; }
void DescriptorFrame::addHosttoServer(Qedo::HostData host,wxTreeItemId itemId,int iter) { std::vector <Qedo::ProcessData> processes=host.processes; std::vector <Qedo::ProcessData> ::iterator process_iter; wxTreeItemId apId_tmp; wxTreeItemId item_dest_id; // first adding after reading cad file if (itemId==rootId) { if (iskown(host.dest.node.c_str())) { item_dest_id = getItemId(host.dest.node.c_str()); wxTreeItemId apId = server_ctrl_->AppendItem(item_dest_id, _T("Hostcollocation"), -1,-1,NULL); apId_tmp=apId; } else { wxString tmp_string=host.dest.node.c_str(); tmp_string.append("(unkown)"); item_dest_id = server_ctrl_->AppendItem(rootId, tmp_string,-1,-1,NULL); server_ctrl_->SetItemBold(item_dest_id,TRUE); wxTreeItemId apId = server_ctrl_->AppendItem(item_dest_id, _T("Hostcollocation"), -1,-1,NULL); apId_tmp=apId; } } else { apId_tmp = server_ctrl_->AppendItem(itemId, _T("Hostcollocation"),-1,-1,NULL); item_dest_id=itemId; } // put hostcollocation to DestinationInfo DestinationInfo deli1; deli1.itemid=apId_tmp; deli1.node=getNode(item_dest_id); deli1.iter=iter; deli1.typ=hostcollocation; DestinationInfoList.push_back(deli1); // add processcollocation for(process_iter = processes.begin(); process_iter != processes.end(); process_iter++) { addProcesstoServer(*process_iter,apId_tmp,-1); } }
void ToolManager::addJSTool(gcRefPtr<UserCore::Item::ItemInfo> item, uint32 branchId, gcString name, gcString exe, gcString args, gcString res) { if (!item) return; auto branch = item->getBranchById(branchId); if (!branch) return; auto realBranch = gcRefPtr<UserCore::Item::BranchInfo>::dyn_cast(branch); if (!realBranch) return; bool found = false; gcRefPtr<JSToolInfo> jsinfo; BaseManager<ToolInfo>::for_each([&](gcRefPtr<ToolInfo> info) { auto temp = gcRefPtr<JSToolInfo>::dyn_cast(info); if (!temp) return; if (item->getId() == temp->getItemId() && name == info->getName() && temp->getBranchId() == branchId) { jsinfo = temp; found = true; } }); if (found) { if (!jsinfo->isRealyInstalled()) jsinfo->setExePath(exe.c_str()); return; } DesuraId toolId(m_iLastCustomToolId, DesuraId::TYPE_TOOL); m_iLastCustomToolId--; auto tool = gcRefPtr<JSToolInfo>::create(item->getId(), realBranch->getBranchId(), toolId, name, exe, args, res); realBranch->addJSTool(toolId); addItem(tool); }
void ToolManager::addJSTool(UserCore::Item::ItemInfo* item, uint32 branchId, gcString name, gcString exe, gcString args, gcString res) { if (!item) return; UserCore::Item::BranchInfoI* branch = item->getBranchById(branchId); if (!branch) return; UserCore::Item::BranchInfo* realBranch = dynamic_cast<UserCore::Item::BranchInfo*>(branch); if (!realBranch) return; bool found = false; JSToolInfo* jsinfo = nullptr; BaseManager<ToolInfo>::for_each([&](ToolInfo* info) { auto temp = dynamic_cast<JSToolInfo*>(info); if (!temp) return; if (item->getId() == temp->getItemId() && name == info->getName() && temp->getBranchId() == branchId) { jsinfo = temp; found = true; } }); if (found) { if (!jsinfo->isRealyInstalled()) jsinfo->setExePath(exe.c_str()); return; } DesuraId toolId(m_iLastCustomToolId, DesuraId::TYPE_TOOL); m_iLastCustomToolId--; JSToolInfo* tool = new JSToolInfo(item->getId(), realBranch->getBranchId(), toolId, name, exe, args, res); realBranch->addJSTool(toolId); addItem(tool); }
gcString VSCheckMcf::downloadMCFHeader() { if (isStopped()) return ""; auto mm = getUserCore()->getInternal()->getMCFManager(); gcString path = mm->getMcfPath(getItemId(), getMcfBranch(), getMcfBuild()); if (path == "") path = mm->newMcfPath(getItemId(), getMcfBranch(), getMcfBuild()); m_hTempMcf->setHeader(getItemId(), getMcfBranch(), getMcfBuild()); try { auto dp = std::make_shared<MCFDownloadProviders>(getWebCore(), getUserCore()->getUserId()); MCFDownloadProviders::forceLoad(m_hTempMcf, dp); m_hTempMcf->dlHeaderFromWeb(); } catch (gcException &except) { onErrorEvent(except); return ""; } m_hTempMcf->setFile(path.c_str()); m_hTempMcf->markFiles(m_hTempMcf.handle(), false, false, false, false); m_hTempMcf->saveMCFHeader(); if (isStopped()) return ""; m_hTempMcf = McfHandle(); return path; }
void CDKeyTask::doTask() { if (!getItemInfo() || !getWebCore()) { CDKeyEventInfo<gcException> cdei; cdei.task = this; cdei.t = gcException(ERR_NULLHANDLE, "Item info or web core are null"); cdei.id = getItemId(); onErrorEvent(cdei); return; } MCFBranch branch = getItemInfo()->getInstalledBranch(); try { gcString key = getWebCore()->getCDKey(getItemId(), branch); CDKeyEventInfo<gcString> cdei; cdei.task = this; cdei.t = key; cdei.id = getItemId(); onCompleteEvent(cdei); } catch (gcException &e) { CDKeyEventInfo<gcException> cdei; cdei.task = this; cdei.t = e; cdei.id = getItemId(); onErrorEvent(cdei); } }
void CreateMCFThread::retrieveBranchList(std::vector<UserCore::Item::BranchInfo*> &outList) { TiXmlDocument doc; getWebCore()->getItemInfo(getItemId(), doc, MCFBranch(), MCFBuild()); TiXmlNode *uNode = doc.FirstChild("iteminfo"); if (!uNode) throw gcException(ERR_BADXML); XML::for_each_child("platform", uNode->FirstChildElement("platforms"), [this, &outList](TiXmlElement* platform) { this->processGames(outList, platform); }); }
void UploadInfoPage::initUpload(const char* path) { if (m_pUpInfo) { fileValidation(path); } else { m_pPrepThread = GetThreadManager()->newUploadPrepThread(getItemId(), path); *m_pPrepThread->getErrorEvent() += guiDelegate(this, &UploadInfoPage::onError); *m_pPrepThread->getCompleteStringEvent() += guiDelegate(this, &UploadInfoPage::onComplete); m_pPrepThread->start(); } }
void CDKProgress::onError(gcException& e) { if (e.getErrId() == ERR_CDKEY && e.getSecErrId() == 117) //not required { if (m_bLaunch) g_pMainApp->handleInternalLink(getItemId(), ACTION_LAUNCH, FormatArgs("cdkey")); GetParent()->Close(); } gcFrame* par = dynamic_cast<gcFrame*>(GetParent()); if (par) par->setProgressState(gcFrame::P_ERROR); gcErrorBox(GetParent(), "#CDK_ERRTITLE", "#CDK_ERROR", e); GetParent()->Close(); }
void CreateMCFThread::createMcf() { std::string timeStr = bpt::to_iso_string( bpt::ptime(bpt::second_clock::local_time())); MCFBranch branch = m_hMCFile->getHeader()->getBranch(); gcString file("NewMcf_b{0}_{1}.mcf", branch, timeStr); UserCore::MCFManager *mm = GetMCFManager(); m_szFilePath = gcString("{0}{1}{2}", mm->getMcfSavePath(), DIRS_STR, getItemId().getFolderPathExtension(file.c_str())); m_hMCFile->setFile(m_szFilePath.c_str()); m_hMCFile->getErrorEvent() += delegate(&onErrorEvent); m_hMCFile->getProgEvent() += delegate(&onMcfProgressEvent); m_hMCFile->saveMCF(); }
void UploadInfoPage::resetAllValues() { //m_dpFile->SetPath(wxT("")); m_butUpload->Enable( false ); UserCore::Item::ItemInfoI *item = GetUserCore()->getItemManager()->findItemInfo(getItemId()); gcString filePath; gcString cachePath = GetUserCore()->getMcfCachePath(); if (!item) filePath = gcString("{0}{1}temp{1}", cachePath, DIRS_STR); else filePath = gcString("{0}{2}{1}", cachePath, item->getId().getFolderPathExtension().c_str(), DIRS_STR); gcWString wfilePath(filePath); m_tbItemFile->SetValue(wfilePath.c_str()); }