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 InternalLink::onUploadTrigger(ut& info) { FINDFORM(info.id, UploadMCFForm); UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( info.id ); if (!item && !GetUserCore()->isAdmin()) { //cant upload show prompt gcMessageBox(g_pMainApp->getMainWindow(), Managers::GetString(L"#MF_NONDEV_ERROR"), Managers::GetString(L"#MF_PERMISSION_ERRTITLE")); return; } if (item && !HasAllFlags(item->getStatus(), UserCore::Item::ItemInfoI::STATUS_DEVELOPER) && !GetUserCore()->isAdmin()) { //cant upload show prompt gcMessageBox(g_pMainApp->getMainWindow(), Managers::GetString(L"#MF_UPERMISSION_ERROR"), Managers::GetString(L"#MF_PERMISSION_ERRTITLE")); return; } //create new create from UploadMCFForm* form = new UploadMCFForm(m_pParent); form->setInfo_path(info.id, info.path.c_str()); if (info.caller) { wxPoint pos = info.caller->GetScreenPosition(); form->SetPosition(pos); } form->Show(true); form->Raise(); form->run(); m_vSubForms.push_back(form); }
void TaskBarIcon::onItemChanged(UserCore::Item::ItemInfoI::ItemInfo_s& info) { if (!GetUserCore()) return; if (info.changeFlags & UserCore::Item::ItemInfoI::CHANGED_STATUS) { UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo(info.id); if (!item) return; if (item->getStatus() & UserCore::Item::ItemInfoI::STATUS_UPDATEAVAL) { if (!findUpdateItem(item)) m_vNextUpdateList.push_back(item); } else { removeUpdateItem(item); } } updateIcon(); }
void InternalLink::showUpdateForm(DesuraId id, Args args) { UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id ); if (!item) return; if (!HasAllFlags(item->getStatus(), UserCore::Item::ItemInfoI::STATUS_UPDATEAVAL)) return; std::string reminder = args.getArgValue("reminder"); //create new gather info form from UpdateInfoForm* form = new UpdateInfoForm(m_pParent); regForm(id, form); form->setInfo(id, reminder == "true"); form->Show(true); }
void TaskBarIcon::tagItems() { if (!GetUserCore()) return; std::vector<UserCore::Item::ItemInfoI*> gList; GetUserCore()->getItemManager()->getGameList(gList, true); for (size_t x=0; x<gList.size(); x++) { UserCore::Item::ItemInfoI* game = gList[x]; if (game->getStatus() & UserCore::Item::ItemInfoI::STATUS_DELETED || (!(game->getStatus() & (UserCore::Item::ItemInfoI::STATUS_ONACCOUNT|UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER)) && (game->getStatus() & UserCore::Item::ItemInfoI::STATUS_DEVELOPER))) { *game->getInfoChangeEvent() -= guiDelegate(this, &TaskBarIcon::onItemChanged); continue; } if (!(game->getStatus() & (UserCore::Item::ItemInfoI::STATUS_ONACCOUNT|UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER))) continue; *game->getInfoChangeEvent() += guiDelegate(this, &TaskBarIcon::onItemChanged); #ifdef WIN32 std::vector<UserCore::Item::ItemInfoI*> mList; GetUserCore()->getItemManager()->getModList(game->getId(), mList, true); for (size_t y=0; y<mList.size(); y++) { UserCore::Item::ItemInfoI* mod = mList[y]; if (mod->getStatus() & UserCore::Item::ItemInfoI::STATUS_DELETED || (!(mod->getStatus() & (UserCore::Item::ItemInfoI::STATUS_ONACCOUNT|UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER)) && (mod->getStatus() & UserCore::Item::ItemInfoI::STATUS_DEVELOPER))) { *mod->getInfoChangeEvent() -= guiDelegate(this, &TaskBarIcon::onItemChanged); continue; } if (!(mod->getStatus() & (UserCore::Item::ItemInfoI::STATUS_ONACCOUNT|UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER))) continue; *mod->getInfoChangeEvent() += guiDelegate(this, &TaskBarIcon::onItemChanged); } #endif } }
int InstallBranch::setInfo(DesuraId id, bool selectBranch) { m_bSelectBranch = selectBranch; UserCore::Item::ItemInfoI* pItemInfo = GetUserCore()->getItemManager()->findItemInfo(id); if (!pItemInfo) return 1; m_bIsMod = id.getType() == DesuraId::TYPE_MOD; m_bIsExpansion = m_bIsMod == false && pItemInfo->getParentId().getType() == DesuraId::TYPE_GAME; m_Item = id; gcWString parName; gcWString itemName = pItemInfo->getName(); DesuraId par = pItemInfo->getParentId(); UserCore::Item::ItemInfoI *parInfo = NULL; if (par.isOk()) { parInfo = GetUserCore()->getItemManager()->findItemInfo(par); if (parInfo) parName = gcWString(parInfo->getName()); } fixName(parName); fixName(itemName); if (selectBranch == false && m_bIsMod) { m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_NOTFOUND"), itemName, parName)); m_labInfo->Wrap( 350 ); } else if (selectBranch == false && m_bIsExpansion) { m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_NOTFOUND_GAME"), itemName, parName)); m_labInfo->Wrap( 350 ); } else { m_labInfo->SetLabel(gcWString(Managers::GetString(L"#IF_BRANCHINFO"), itemName)); m_labInfo->Wrap( 350 ); } uint32 count = 0; int32 full = -1; uint32 fullReadyCount = 0; m_bBuy = true; UserCore::Item::ItemInfoI *i = pItemInfo; bool isCheckingParent = (m_bIsMod || m_bIsExpansion) && !selectBranch; if (isCheckingParent) { if (!parInfo) { gcMessageBox(GetParent(), Managers::GetString(L"#IF_IIPARENT"), Managers::GetString(L"#IF_IIERRTITLE")); return 1; } i = parInfo; } std::vector<UserCore::Item::BranchInfoI*> bList; for (uint32 x=0; x<i->getBranchCount(); x++) { UserCore::Item::BranchInfoI* bi = i->getBranch(x); if (!bi) continue; uint32 flags = bi->getFlags(); bool noRelease = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES); bool isPreorder = bi->isPreOrder(); bool isDemo = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_DEMO); bool onAccount = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT); bool locked = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_MEMBERLOCK|UserCore::Item::BranchInfoI::BF_REGIONLOCK); bool test = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_TEST); bool free = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_FREE); if (noRelease && !isPreorder) continue; if (!onAccount && locked) continue; if (!selectBranch && (isDemo || test)) continue; if ((free || onAccount) && isPreorder && !selectBranch) continue; bool globalFound = false; for (size_t x=0; x<bList.size(); x++) { if (bList[x]->getGlobalId() == bi->getGlobalId()) { globalFound = true; break; } } if (globalFound) continue; if (isDemo || test) { } else if (full == -1 || ((!m_bBuy || onAccount) && !free)) { if (full == -1 || m_bBuy) { //if this is the first full game or this is the first full game that you dont have to buy m_bBuy = (!onAccount && !free); full = count; } if (onAccount || free) fullReadyCount++; } bList.push_back(bi); count++; } for (size_t x=0; x<bList.size(); x++) { UserCore::Item::BranchInfoI* bi = bList[x]; gcString name = bi->getName(); gcWString title; uint32 flags = bi->getFlags(); bool noRelease = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES); bool isPreorder = bi->isPreOrder(); bool onAccount = HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT); bool free = HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_FREE); if (!free) title = gcString("{0} - {1}", name, Managers::GetString("#IF_BROUGHT")); else title = gcString("{0} - {1}", name, Managers::GetString("#IF_FREE")); if (!free && !onAccount) { gcWString cost(bi->getCost()); if (cost == "") cost = gcString(Managers::GetString("#TBA")); title = gcString("{0} - {1}", name, cost.c_str()); } else if (isPreorder) { if (noRelease) title = gcString("{0} - {1}", name, Managers::GetString("#IF_PREORDERED_NORELEASE")); else title = gcString("{0} - {1}", name, Managers::GetString("#IF_PREORDERED")); } m_cbBranchList->Append(title, new BranchData(bi->getBranchId(), bi->getGlobalId())); } count = bList.size(); if (full == -1) full = 0; #ifdef WIN32 if (HasAnyFlags(i->getStatus(), UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER)) m_cbBranchList->Append(Managers::GetString("#IF_ONCOMPUTER"), new BranchData(MCFBranch::BranchFromInt(-1), MCFBranch::BranchFromInt(-1))); else m_cbBranchList->Append(Managers::GetString("#IF_FINDONCOMPUTER"), new BranchData(MCFBranch::BranchFromInt(-2), MCFBranch::BranchFromInt(-2))); #endif m_cbBranchList->SetSelection(full); if (pItemInfo->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(pItemInfo->getIcon()))) setIcon(pItemInfo->getIcon()); SetTitle(gcWString(Managers::GetString(L"#IF_BRANCHTITLE"), itemName)); uint32 ret = 0; if (count == 0) { if (!isCheckingParent) gcMessageBox(GetParent(), Managers::GetString(L"#IF_IINOBRANCHES"), Managers::GetString(L"#IF_IIERRTITLE")); else if (selectBranch) ret = 1; } else if ((count == 1 || fullReadyCount == 1) && !m_bBuy) { ret = 1; } else { wxCommandEvent e; onChoice(e); } return ret; }
uint32 GatherInfoTask::validate() { UserCore::Item::ItemInfoI* pItemInfo = getItemHandle()->getItemInfo(); uint32 isValid = 0; if (!pItemInfo) return UserCore::Item::Helper::V_BADINFO; DesuraId par = pItemInfo->getParentId(); UserCore::Item::ItemInfoI *parInfo = nullptr; if (par.isOk()) { parInfo = getUserCore()->getItemManager()->findItemInfo(par); if (!parInfo || !(parInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_INSTALLED)) isValid |= UserCore::Item::Helper::V_PARENT; } const char* path = pItemInfo->getPath(getMcfBranch()); if (!path) { isValid |= UserCore::Item::Helper::V_BADPATH; } else { const char *comAppPath = getUserCore()->getAppDataPath(); uint64 inFreeSpace = UTIL::OS::getFreeSpace(path); uint64 dlFreeSpace = UTIL::OS::getFreeSpace(comAppPath); //if they are on the same drive: if (strncmp(comAppPath, path, 3) == 0) { if ((inFreeSpace+dlFreeSpace) < (pItemInfo->getDownloadSize()+pItemInfo->getInstallSize())) { isValid |= (UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_DL|UserCore::Item::Helper::V_FREESPACE_INS); } } else { if (dlFreeSpace < pItemInfo->getDownloadSize()) isValid |= UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_DL; if (inFreeSpace < pItemInfo->getInstallSize()) isValid |= UserCore::Item::Helper::V_FREESPACE|UserCore::Item::Helper::V_FREESPACE_INS; } if (pItemInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX) { const char* primPath = pItemInfo->getInsPrimary(); if (primPath && strcmp(primPath, "") != 0 && UTIL::FS::isValidFolder(primPath) && !UTIL::FS::isFolderEmpty(primPath)) isValid |= UserCore::Item::Helper::V_NONEMPTY; } else if (pItemInfo->getStatus() & UserCore::Item::ItemInfoI::STATUS_DLC) { if (!parInfo || gcString(path) != gcString(parInfo->getPath())) { if (!UTIL::FS::isFolderEmpty(path)) isValid |= UserCore::Item::Helper::V_NONEMPTY; } } else if (!UTIL::FS::isFolderEmpty(path)) { isValid |= UserCore::Item::Helper::V_NONEMPTY; } } #ifdef NIX UserCore::Item::BranchInfoI* bi = pItemInfo->getBranchById(getMcfBranch()); std::vector<DesuraId> toolList; bi->getToolList(toolList); uint32 res = getUserCore()->getToolManager()->hasNonInstallableTool(toolList); switch (res) { case 0: isValid |= UserCore::Item::Helper::V_JAVA_SUN; break; case 1: isValid |= UserCore::Item::Helper::V_JAVA; break; case 2: isValid |= UserCore::Item::Helper::V_MONO; break; case 3: isValid |= UserCore::Item::Helper::V_AIR; break; }; #endif return isValid; }