Exemple #1
0
void GatherInfoTask::onComplete()
{
	if (getItemHandle()->getItemInfo()->isDownloadable())
		checkRequirements();
	else
		getItemHandle()->getInternal()->completeStage(true);
}
void VerifyServiceTask::finishVerify(UserCore::Misc::VerifyComplete::VSTATUS status, const char* installpath, bool endStage)
{
	if (m_bError)
		return;

	MCFCore::Misc::ProgressInfo prog;
	prog.percent = 100;
	onMcfProgressEvent(prog);

	UserCore::Item::ItemInfo* pItem = getItemInfo();

	if (pItem)
	{
		pItem->delSFlag(UserCore::Item::ItemInfoI::STATUS_VERIFING);

		if (status == UserCore::Misc::VerifyComplete::V_COMPLETE)
			pItem->addSFlag(UserCore::Item::ItemInfoI::STATUS_READY);
	
		if (status == UserCore::Misc::VerifyComplete::V_RESET)
		{
			uint32 flags = UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER|UserCore::Item::ItemInfoI::STATUS_DOWNLOADING|UserCore::Item::ItemInfoI::STATUS_INSTALLING|UserCore::Item::ItemInfoI::STATUS_UPDATING|UserCore::Item::ItemInfoI::STATUS_INSTALLED|UserCore::Item::ItemInfoI::STATUS_UPDATEAVAL;

			pItem->resetInstalledMcf();
			pItem->delSFlag(flags);
		}
	}

	UserCore::Misc::VerifyComplete vInstallPath(status, installpath);
	onVerifyCompleteEvent(vInstallPath);

	if (status == UserCore::Misc::VerifyComplete::V_INSTALL)
	{
		getItemInfo()->addToAccount();
		getItemHandle()->goToStageInstall(installpath, getMcfBranch());
	}
	else if (status == UserCore::Misc::VerifyComplete::V_DOWNLOAD)
	{
		getItemInfo()->addToAccount();

		if (installpath)
			getItemHandle()->goToStageDownload(installpath);
		else
			getItemHandle()->goToStageDownload(getItemInfo()->getCurrentBranch()->getBranchId(), m_McfBuild);	
	}
	else if (status == UserCore::Misc::VerifyComplete::V_SWITCHBRANCH)
	{
		getItemInfo()->addToAccount();
		getItemHandle()->switchBranch(m_McfBranch);	
	}
	else if (endStage)
	{
		getItemHandle()->completeStage(true);
	}
}
void UIComplexModServiceTask::onComplete()
{
	if (HasAllFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX))
	{
		UserCore::MCFManager *mm = UserCore::GetMCFManager();
		mm->delMcfBackup(getItemInfo()->getParentId(), m_idLastInstalledMod);
	}

	if (HasAllFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_LINK))
	{
		if (m_uiCompleteAction == CA_LAUNCH)
			getItemHandle()->goToStageLaunch();
	}
	else
	{
		switch (m_uiCompleteAction)
		{
		case CA_INSTALL:
			getItemHandle()->goToStageInstallComplex(getMcfBranch(), getMcfBuild());
			break;

		case CA_UNINSTALL_BRANCH:
			getItemHandle()->goToStageUninstallBranch(getMcfBranch(), getMcfBuild());
			break;

		case CA_UNINSTALL:
			getItemInfo()->delSFlag(	UserCore::Item::ItemInfoI::STATUS_INSTALLED|
										UserCore::Item::ItemInfoI::STATUS_READY|
										UserCore::Item::ItemInfoI::STATUS_DOWNLOADING|
										UserCore::Item::ItemInfoI::STATUS_VERIFING|
										UserCore::Item::ItemInfoI::STATUS_INSTALLING|
										UserCore::Item::ItemInfoI::STATUS_UPDATING|
										UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER|
										UserCore::Item::ItemInfoI::STATUS_PAUSED|
										UserCore::Item::ItemInfoI::STATUS_PAUSABLE);

			completeUninstall(m_bRemoveAll, m_bRemoveAcc);
			break;

		case CA_UIPATCH:
			getItemHandle()->goToStageUninstallPatch(getMcfBranch(), getMcfBuild());
			break;
		};
	}

	if (m_bEndStage)
		getItemHandle()->completeStage(true);

	UIBaseServiceTask::onComplete();
}
void VerifyServiceTask::onError(gcException& e)
{
	m_bError = true;

	Warning(gcString("Error in verify install: {0}\n", e));
	getItemHandle()->setPausable(false);

	if (!getItemHandle()->shouldPauseOnError())
		getItemHandle()->resetStage(true);
	else
		getItemHandle()->setPaused(true, true);

	onErrorEvent(e);
}
void ICheckFinishPage::init()
{
	auto item = getItemHandle()->getItemInfo();

	if (item)
	{
		gcWString msg;

		if (item->isInstalled())
		{
			m_butTryAgain->Show(false);
			m_butCIP->Show(false);

			msg = gcWString(Managers::GetString(L"#IF_CHECK_FOUND"), item->getName());
		}
		else
		{
			m_butLaunch->Show(false);
			msg = gcWString(Managers::GetString(L"#IF_CHECK_NOTFOUND"), item->getName());
		}

		m_labInfo->SetLabel(msg);
		m_labInfo->Wrap(350);
		Layout();
	}
	else
	{
		gcException e(ERR_NULLHANDLE, "Null item for install check.");
		gcErrorBox(this, "#IF_CHECK_ERRTITLE", "#IF_CHECK_ERROR", e);
		GetParent()->Close();
	}
}
Exemple #6
0
bool GatherInfoTask::handleInvalidBranch()
{
	MCFBranch branch = getMcfBranch();

	if (m_bCanceled || (m_pGIHH && !m_pGIHH->selectBranch(branch)))
	{
		completeStage();
		return false;
	}

	if (branch == UINT_MAX)
	{
		//means the item was set as a link and needs to be launched
		getItemHandle()->getInternal()->goToStageLaunch();
		return false;
	}
	else
	{
		if (branch.isGlobal())
			branch = getItemInfo()->getInternal()->getBestBranch(branch);

		UserCore::Item::BranchInfoI* branchInfo = getItemInfo()->getBranchById(branch);
		checkNullBranch(branchInfo);
	}

	m_uiMcfBranch = branch;
	return true;
}
Exemple #7
0
void InstallVIPage::onError(gcException& e)
{
	gcFrame* par = dynamic_cast<gcFrame*>(GetParent());
	if (par)
		par->setProgressState(gcFrame::P_ERROR);

	if (!getItemHandle()->shouldPauseOnError())
		gcErrorBox(GetParent(), "#IF_VERRTITLE", "#IF_VERROR", e);
}
void UIBranchServiceTask::onComplete()
{
	MCFCore::Misc::ProgressInfo prog;
	prog.percent = 100;

	onMcfProgressEvent(prog);

	getItemHandle()->goToStageDownload(getMcfBranch(), getMcfBuild(), m_bTestInstall);
	UIBaseServiceTask::onComplete();
}
bool VerifyServiceTask::checkTools()
{
	refreshInfo();

	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	if (toolList.size() == 0)
		return false;

	getUserCore()->getToolManager()->invalidateTools(toolList);

	if (!getUserCore()->getToolManager()->areAllToolsDownloaded(toolList))
		getItemHandle()->goToStageDownloadTools(false);
	else
		getItemHandle()->goToStageInstallTools(false);

	return true;
}
void UIUpdateServiceTask::onComplete()
{
	MCFCore::Misc::ProgressInfo prog;
	prog.percent = 100;

	onMcfProgressEvent(prog);

	getItemHandle()->goToStageDownload(m_szPath.c_str());
	UIBaseServiceTask::onComplete();
}
Exemple #11
0
void InstallVIPage::onButtonPressed(wxCommandEvent& event)
{
	if (event.GetId() == m_butCancel->GetId())
	{
		getItemHandle()->setPaused(true);
		GetParent()->Close();
	}
	else
	{
		InstallBannerPage::onButtonPressed(event);
	}
}
void VerifyServiceTask::setupCurTask()
{
	m_pCurTask->onErrorEvent += delegate(this, &VerifyServiceTask::onError);

	m_pCurTask->setItemHandle(getItemHandle());
	m_pCurTask->setMcfBuild(m_McfBuild);
	m_pCurTask->setMcfBranch(m_McfBranch);

	m_pCurTask->setUserCore(getUserCore());
	m_pCurTask->setWebCore(getWebCore());

	m_pCurTask->setMcfHandle(m_hMcf.handle());
}
Exemple #13
0
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 DownloadToolTask::onComplete()
{
	bool notComplete = isStopped() || m_bCancelled;

	getUserCore()->getToolManager()->removeTransaction(m_ToolTTID, notComplete);
	m_ToolTTID = UINT_MAX;

	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	if (!m_bCancelled && !getUserCore()->getToolManager()->areAllToolsDownloaded(toolList))
	{
		gcException e(ERR_INVALID, "Failed to download tools.");
		onErrorEvent(e);
		notComplete = true;
	}

	if (notComplete)
	{
		getItemHandle()->completeStage(true);
		return;
	}

	uint32 blank = 0;
	onCompleteEvent(blank);

	if (m_bInstallAfter)
	{
		getItemHandle()->goToStageInstallTools(m_bLaunch);
	}
	else
	{
		if (HasAllFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX))
			getItemHandle()->goToStageInstallComplex(getMcfBranch(), getMcfBuild());
		else
			getItemHandle()->goToStageInstall(m_szDownloadPath.c_str(), getMcfBranch());
	}
}
Exemple #15
0
MRESULT EXPENTRY wpMatch(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
   static CDDBQUERY_DATA *chosen; /* somebody find me a better way to do this */

	switch(msg)
	{
		case WM_INITDLG:
		{
			HWND focusHwnd = (HWND) mp1;
         FUZZYMATCHCREATEPARAMS *data = (FUZZYMATCHCREATEPARAMS *) mp2;
			int i = 0;

			WinSetFocus(HWND_DESKTOP, focusHwnd);

			while(data->matches[i].discid)
			{
            int inserted = insertItemText(hwnd,LB_MATCHES,LIT_END,data->matches[i].title);
				setItemHandle(hwnd, LB_MATCHES,inserted,&data->matches[i]);
				i++;
			}
			chosen = data->chosen;
         memset(chosen,0,sizeof(*chosen));
         return 0;
		}

		case WM_COMMAND:
		{
			switch(SHORT1FROMMP(mp1))
			{
            case DID_OK:
				{
					int selected = getSelectItem(hwnd, LB_MATCHES, LIT_FIRST);
               if(selected != LIT_NONE)
                  memcpy(chosen,getItemHandle(hwnd,LB_MATCHES,selected),sizeof(*chosen));
					WinPostMsg(hwnd,WM_CLOSE,0,0);
				}
            case DID_CANCEL:
					WinPostMsg(hwnd,WM_CLOSE,0,0);
			}
			return 0;
		}
	}
	return WinDefDlgProc(hwnd,msg,mp1,mp2);
}
Exemple #16
0
void RegenLaunchScriptsTask::doTask()
{
	std::vector<gcRefPtr<UserCore::Item::ItemHandleI>> itemList;
	
	auto im = getUserCore()->getItemManager();
	
	for (size_t x=0; x<im->getCount(); x++)
	{
		itemList.push_back(im->getItemHandle(x));
	}
	
	for (size_t x=0; x<itemList.size(); x++)
	{
		if (!itemList[x] || !itemList[x]->getItemInfo()->isInstalled())
			continue;

#ifdef NIX
		itemList[x]->installLaunchScripts();
#endif
	}
}
Exemple #17
0
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;
}
Exemple #18
0
void GatherInfoTask::checkRequirements()
{
	if (!isValidBranch() && !handleInvalidBranch())
		return;

	MCFBranch branch = getMcfBranch();

	UserCore::Item::BranchInfoI* branchInfo = getItemHandle()->getItemInfo()->getBranchById(branch);
	
	if (!checkNullBranch(branchInfo))
		return;

	if (m_bCanceled)
	{
		completeStage();
		return;
	}

	if (branchInfo->isPreOrderAndNotPreload())
	{
		//show the preorder prompt
		getItemHandle()->getInternal()->goToStageLaunch();
		return;
	}

	uint32 res = validate();
	
#ifdef NIX
	UserCore::Item::Helper::TOOL tool = (UserCore::Item::Helper::TOOL)(res>>28);

	//check tool deps
	if ( (tool > 0) && (!m_pGIHH || !m_pGIHH->showToolPrompt(tool)) )
	{
		completeStage();
		return;				
	}
	
	res = (res<<4)>>4;
#endif
	
	if (res == 0)
	{
		getItemHandle()->getItemInfo()->addToAccount();
		getItemHandle()->getInternal()->goToStageDownload(branch, getMcfBuild(), HasAnyFlags(m_uiFlags, GI_FLAG_TEST));
	}
	else
	{
		if (res == UserCore::Item::Helper::V_NONEMPTY)
		{
			if (HasAnyFlags(m_uiFlags, GI_FLAG_UPDATE))
			{
				getItemHandle()->getInternal()->goToStageDownload(branch, getMcfBuild(), false);
			}
			else if (getItemHandle()->getItemInfo()->getStatus() & UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX)
			{
				if (!m_bCanceled && m_pGIHH && m_pGIHH->showComplexPrompt())
					getItemHandle()->getInternal()->goToStageDownload(branch, getMcfBuild(), HasAnyFlags(m_uiFlags, GI_FLAG_TEST));
				else
					resetStage();
			}
			else
			{
				UserCore::Item::Helper::ACTION promptRes = UserCore::Item::Helper::C_NONE;
				
				if (!m_bCanceled && m_pGIHH)
					promptRes = m_pGIHH->showInstallPrompt(getItemHandle()->getItemInfo()->getPath(getMcfBranch()));

				switch (promptRes)
				{
				case UserCore::Item::Helper::C_REMOVE:
						getItemInfo()->addOFlag(UserCore::Item::ItemInfoI::OPTION_REMOVEFILES);

				case UserCore::Item::Helper::C_INSTALL:
						getItemInfo()->addToAccount();
						getItemHandle()->getInternal()->goToStageDownload(branch, getMcfBuild(), HasAnyFlags(m_uiFlags, GI_FLAG_TEST));
						break;

				case UserCore::Item::Helper::C_VERIFY:
						getItemInfo()->addToAccount();
						getItemInfo()->addSFlag(UserCore::Item::ItemInfoI::STATUS_INSTALLED);
						getItemInfo()->setInstalledMcf(branch, getMcfBuild());
						getItemHandle()->getInternal()->goToStageVerify(branch, getMcfBuild(), true, true, true);
						break;

					default:
						resetStage();
						break;
				}
			}
		}
		else
		{
			if (m_bCanceled || !m_pGIHH || m_pGIHH->showError(res))
			{
				resetStage();
			}
			else
			{
				getItemHandle()->getItemInfo()->addToAccount();
				getItemHandle()->getInternal()->goToStageDownload(branch, getMcfBuild(), HasAnyFlags(m_uiFlags, GI_FLAG_TEST));
			}
		}
	}
}