bool UIUpdateServiceTask::initService() { if (!UIBaseServiceTask::initService()) { onComplete(); return false; } gcString oldBranchMcf = getBranchMcf(getItemInfo()->getId(), getItemInfo()->getInstalledBranch(), getMcfBuild()); m_pIPCIM = getServiceMain()->newUninstallBranch(); if (!m_pIPCIM) { gcException eFailCrtBrnch(ERR_NULLHANDLE, "Failed to create uninstall update mcf service!\n"); onErrorEvent(eFailCrtBrnch); return false; } m_pIPCIM->onCompleteEvent += delegate(this, &UIUpdateServiceTask::onComplete); m_pIPCIM->onProgressEvent += delegate(&onMcfProgressEvent); m_pIPCIM->onErrorEvent += delegate((UIBaseServiceTask*)this, &UIBaseServiceTask::onServiceError); m_pIPCIM->start(oldBranchMcf.c_str(), m_szPath.c_str(), getItemInfo()->getPath(), ""); return true; }
void User::runInstallScript(const char* file, const char* installPath, const char* function) { if (getServiceMain()) getServiceMain()->runInstallScript(file, installPath, function); }
void User::updateBinaryRegKey(const char* key, const char* value, size_t size) { if (getServiceMain()) getServiceMain()->updateBinaryRegKey(key, value, size); }
void User::updateRegKey(const char* key, const char* value) { if (getServiceMain()) getServiceMain()->updateRegKey(key, value); }
void User::removeUninstallInfo(DesuraId id) { if (getServiceMain()) getServiceMain()->removeUninstallRegKey(id.toInt64()); }
void User::updateUninstallInfo(DesuraId id, uint64 installSize) { if (getServiceMain()) getServiceMain()->setUninstallRegKey(id.toInt64(), installSize); }
void User::updateUninstallInfo() { if (getServiceMain()) getServiceMain()->updateAllUninstallRegKey(); }
void User::logIn(const char* user, const char* pass) { gcString appDataPath = UTIL::OS::getAppDataPath(); m_pThreadPool->unBlockTasks(); if (!m_pWebCore) throw gcException(ERR_NULLWEBCORE); tinyxml2::XMLDocument doc; m_pWebCore->logIn(user, pass, doc); tinyxml2::XMLElement *uNode = doc.FirstChildElement("memberlogin"); uint32 version = 0; XML::GetAtt("version", version, uNode); if (version == 0) version = 1; m_bDelayLoading = (version >= 3); if (!uNode) { logOut(); throw gcException(ERR_BADXML); } tinyxml2::XMLElement *memNode = uNode->FirstChildElement("member"); if (memNode) { const char* idStr = memNode->Attribute("siteareaid"); if (idStr) { m_iUserId = atoi(idStr); if ((int)m_iUserId <= 0) { logOut(); throw gcException(ERR_BAD_PORU); } } else { logOut(); throw gcException(ERR_BAD_PORU); } } XML::GetChild("admin", m_bAdmin, memNode); XML::GetChild("name", m_szUserName, memNode); XML::GetChild("nameid", m_szUserNameId, memNode); XML::GetChild("url", m_szProfileUrl, memNode); XML::GetChild("urledit", m_szProfileEditUrl, memNode); initPipe(); #ifdef WIN32 if (getServiceMain()) getServiceMain()->fixFolderPermissions(appDataPath.c_str()); try { testMcfCache(); } catch (...) { if (getServiceMain()) getServiceMain()->fixFolderPermissions(m_szMcfCachePath.c_str()); try { testMcfCache(); } catch (gcException &e) { Warning(gcString("Failed to set mcf cache path to be writeable: {0}", e)); } } #endif gcString szAvatar; XML::GetChild("avatar", szAvatar, memNode); m_pThreadPool->queueTask(new UserCore::Task::DownloadAvatarTask(this, szAvatar.c_str(), m_iUserId) ); tinyxml2::XMLElement *msgNode = memNode->FirstChildElement("messages"); if (msgNode) { XML::GetChild("updates", m_iUpdates, msgNode); XML::GetChild("privatemessages", m_iPms, msgNode); XML::GetChild("cart", m_iCartItems, msgNode); XML::GetChild("threadwatch", m_iThreads, msgNode); } m_pToolManager->loadItems(); m_pItemManager->loadItems(); try { if (m_bDelayLoading) { //do nothing as the update thread will grab it } else if (version == 2) { m_pItemManager->parseLoginXml2(memNode->FirstChildElement("games"), memNode->FirstChildElement("platforms")); } else { m_pItemManager->parseLoginXml(memNode->FirstChildElement("games"), memNode->FirstChildElement("developer")); } } catch (gcException &) { logOut(); throw; } tinyxml2::XMLElement *newsNode = memNode->FirstChildElement("news"); if (newsNode) parseNews(newsNode); tinyxml2::XMLElement *giftsNode = memNode->FirstChildElement("gifts"); if (giftsNode) parseGifts(giftsNode); m_pUThread = m_pThreadManager->newUpdateThread(&onForcePollEvent, m_bDelayLoading); m_pUThread->start(); #ifdef WIN32 m_pGameExplorerManager->loadItems(); #endif if (getServiceMain()) getServiceMain()->updateShortCuts(); if (!m_bDelayLoading) m_pItemManager->enableSave(); #ifdef WIN32 #ifdef DEBUG gcString val("\"{0}\"", UTIL::OS::getCurrentDir(L"desura-d.exe")); #else gcString val("\"{0}\"", UTIL::OS::getCurrentDir(L"desura.exe")); #endif val += " \"%1\" -urllink"; updateRegKey("HKEY_CLASSES_ROOT\\Desura\\shell\\open\\command\\", val.c_str()); #endif }
bool UIComplexModServiceTask::initService() { m_OldBranch = getItemInfo()->getInstalledBranch(); m_OldBuild = getItemInfo()->getInstalledBuild(); UserCore::Item::ItemInfo* parentInfo = getParentItemInfo(); if (getItemInfo()->getInstalledModId().isOk()) parentInfo = getItemInfo(); if (!parentInfo) { onComplete(); return false; } m_idLastInstalledMod = parentInfo->getInstalledModId(); getUserCore()->getItemManager()->setInstalledMod(parentInfo->getId(), DesuraId()); if (!m_idLastInstalledMod.isOk()) { onComplete(); return false; } UserCore::Item::ItemInfo* modInfo = dynamic_cast<UserCore::Item::ItemInfo*>(getUserCore()->getItemManager()->findItemInfo(m_idLastInstalledMod)); if (!modInfo) { gcException eModNoExist(ERR_NULLHANDLE, "Installed mod doesnt exist in database!\n"); onErrorEvent(eModNoExist); return false; } m_pIPCCL = getServiceMain()->newComplexLaunch(); if (!m_pIPCCL) { gcException eFailedUninstall (ERR_NULLHANDLE, "Failed to create uninstall complex branch mcf service!\n"); onErrorEvent(eFailedUninstall); return false; } UserCore::MCFManager *mm = UserCore::GetMCFManager(); gcString installPath = modInfo->getPath(); gcString parPath = mm->getMcfBackup(parentInfo->getId(), m_idLastInstalledMod); gcString modMcfPath; if (m_idLastInstalledMod == getItemInfo()->getId()) modMcfPath = getBranchMcf(modInfo->getId(), m_OldBranch, m_OldBuild); else modMcfPath = getBranchMcf(modInfo->getId(), modInfo->getInstalledBranch(), modInfo->getInstalledBuild()); if (m_uiCompleteAction == CA_UNINSTALL) modInfo->resetInstalledMcf(); m_pIPCCL->onCompleteEvent += delegate(this, &UIComplexModServiceTask::onComplete); m_pIPCCL->onProgressEvent += delegate(this, &UIComplexModServiceTask::onProgress); m_pIPCCL->onErrorEvent += delegate((UIBaseServiceTask*)this, &UIBaseServiceTask::onServiceError); m_pIPCCL->startRemove(modMcfPath.c_str(), parPath.c_str(), installPath.c_str(), getItemInfo()->getInstallScriptPath()); return true; }