示例#1
0
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));
	}
}
示例#2
0
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);
}
bool VSInstallMissing::doTask()
{
    const char* val = getUserCore()->getCVarValue("gc_corecount");
    gcException errFailMCFServ(ERR_NULLHANDLE, "Failed to create uninstall MCF service!\n");

    m_pIPCIM = getUserCore()->getServiceMain()->newInstallMcf();
    if (!m_pIPCIM)
    {
        onErrorEvent(errFailMCFServ);
        return false;
    }

    uint8 workers = 1;

    if (val)
        workers = atoi(val);

    if (workers == 0)
        workers = 1;

    m_pIPCIM->onCompleteEvent += delegate(this, &VSInstallMissing::onComplete);
    m_pIPCIM->onProgressEvent += delegate(&onProgressEvent);
    m_pIPCIM->onErrorEvent += delegate(&onErrorEvent);
    m_pIPCIM->start(m_hMcf->getFile(), getItemInfo()->getPath(), getItemInfo()->getInstallScriptPath(), workers);

    m_WaitCond.wait();

    m_bFinished = true;

    return isStopped() == false;
}
示例#4
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);
}
示例#5
0
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;
}
示例#6
0
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 GetItemListThread::doRun()
{
	m_szDbName = getCIBDb(getUserCore()->getAppDataPath());

	tinyxml2::XMLDocument doc;
	getWebCore()->getInstalledItemList(doc);

	int ver = XML::processStatus(doc, "itemwizard");

	tinyxml2::XMLElement *infoNode = doc.FirstChildElement("itemwizard");

	if (!infoNode)
		throw gcException(ERR_BADXML);

	if (isStopped())
		return;

	WildcardManager wMng = WildcardManager();

	if (ver == 1)
		parseItems1(infoNode, &wMng);
	else
		parseItems2(infoNode, &wMng);

	try
	{
		createCIPDbTables(getUserCore()->getAppDataPath());

		sqlite3x::sqlite3_connection db(m_szDbName.c_str());
		sqlite3x::sqlite3_command cmd(db, "REPLACE INTO cipiteminfo (internalid, name) VALUES (?,?);");

		for (size_t x=0; x<m_vGameList.size(); x++)
		{
			cmd.bind(1, (long long int)m_vGameList[x].getId().toInt64());
			cmd.bind(2, std::string(m_vGameList[x].getName()) ); 
			cmd.executenonquery();
		}
	}
	catch (std::exception &e)
	{
		Warning(gcString("Failed to update cip item list: {0}\n", e.what()));
	}

	uint32 prog=0;
	onCompleteEvent(prog);
}
示例#8
0
VSDownloadMissing::~VSDownloadMissing()
{
	m_hMcf->getNewProvider() -= delegate(this, &VSDownloadMissing::onNewProvider);

	UserCore::User* pUser = dynamic_cast<UserCore::User*>(getUserCore());

	if (pUser)
		pUser->getBDManager()->cancelDownloadBannerHooks(this);
}
示例#9
0
void VerifyServiceTask::refreshInfo()
{
	if (m_bRefreshedInfo)
		return;

	m_bRefreshedInfo = true;

	getUserCore()->getItemManager()->retrieveItemInfo(getItemId());
}
示例#10
0
void ItemHandle::doLaunch(Helper::ItemLaunchHelperI* helper)
{
	char magicBytes[5] = {0};
	UserCore::Item::Misc::ExeInfoI* ei = getItemInfo()->getActiveExe();
	
	const char* exe = ei->getExe();
	const char* args = getUserCore()->getCVarValue("gc_linux_launch_globalargs");
	gcString globalExe = getUserCore()->getCVarValue("gc_linux_launch_globalbin");
	
	if (globalExe.size() > 0)
	{
		if (!UTIL::FS::isValidFile(globalExe.c_str()))
		{
			Warning(gcString("Couldn't find global exe [{0}], ignoring.\n", globalExe));
			globalExe = "";
			exe = ei->getExe();
		}
		else
		{
			exe = globalExe.c_str();
		}
	}
	
	try
	{
		UTIL::FS::FileHandle fh(exe, UTIL::FS::FILE_READ);
		fh.read(magicBytes, 5);
	}
	catch (gcException& e)
	{
		throw gcException(ERR_LAUNCH, e.getSecErrId(), gcString("Failed to read [{0}]: {1}\n", exe, e));
	}

	UTIL::LIN::BinType type = UTIL::LIN::getFileType(magicBytes, 5);

	if (type == UTIL::LIN::BT_WIN && helper)
		helper->showWinLaunchDialog();
	
	//if we are not using globalExe set exe to Null so that we use the proper exe
	if (globalExe.size() == 0 || type == UTIL::LIN::BT_UNKNOWN)
		exe = NULL;

	doLaunch(type == UTIL::LIN::BT_UNKNOWN, exe, args);
}
示例#11
0
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;
}
示例#12
0
void VerifyServiceTask::checkHooks()
{
	refreshInfo();

	const char* hookPath = getItemInfo()->getInstallScriptPath();
	const char* insPath = getItemInfo()->getPath();

	if (hookPath && UTIL::FS::isValidFile(hookPath))
		getUserCore()->getServiceMain()->runInstallScript(hookPath, insPath, "PostInstall");
}
示例#13
0
void DownloadAvatarTask::doTask()
{
	try
	{
		if (strncmp(m_szUrl.c_str(),"http://", 7)==0)
		{
			HttpHandle wc(m_szUrl.c_str());
			wc->getWeb();
			
			if (wc->getDataSize() != 0)
			{
				if (UTIL::MISC::isValidImage((const unsigned char*)wc->getData()) == IMAGE_VOID)
					throw gcException(ERR_INVALIDDATA, gcString("The url [{0}] is not an image format", m_szUrl));
				
				UTIL::FS::Path urlPath(m_szUrl, "", true);
				UTIL::FS::Path path(getUserCore()->getAppDataPath(), "", false);

				path += "users";
				path += gcString("{0}", m_uiUserId);
				path += urlPath.getFile();

				UTIL::FS::recMakeFolder(path);
				UTIL::FS::FileHandle fh(path, UTIL::FS::FILE_WRITE);

				fh.write(wc->getData(), wc->getDataSize());
				fh.close();

				getUserCore()->setAvatarUrl(path.getFullPath().c_str());
			}
			else
			{
				throw gcException(ERR_BADRESPONSE);
			}
		}
	}
	catch (gcException &e)
	{
		onErrorEvent(e);
	}
}
示例#14
0
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());
}
示例#15
0
void DownloadToolTask::doRun()
{
	uint32 per = 0;
	getItemInfo()->setPercent(per);

	if (m_ToolTTID == UINT_MAX)
		validateTools();

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

	UserCore::Misc::ToolTransaction* tt = new UserCore::Misc::ToolTransaction();

	tt->onCompleteEvent += delegate(this, &DownloadToolTask::onDLComplete);
	tt->onErrorEvent += delegate(this, &DownloadToolTask::onDLError);
	tt->onProgressEvent += delegate(this, &DownloadToolTask::onDLProgress);
	tt->toolsList = toolList;
	
	if (m_ToolTTID != UINT_MAX)
	{
		bool res = getUserCore()->getToolManager()->updateTransaction(m_ToolTTID, tt);

		if (!res) //must be complete
		{
			onComplete();
			return;
		}
	}
	else
	{
		m_ToolTTID = getUserCore()->getToolManager()->downloadTools(tt);
	}

	if (m_ToolTTID != UINT_MAX)
		m_WaitCond.wait();

	onComplete();
}
示例#16
0
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());
	}
}
示例#17
0
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;
}
示例#18
0
void DownloadToolTask::validateTools()
{
	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

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

	if (!getUserCore()->getToolManager()->areAllToolsValid(toolList))
	{
		//missing tools. Gather info again
		TiXmlDocument doc;

		getWebCore()->getItemInfo(getItemId(), doc, MCFBranch(), MCFBuild());

		TiXmlNode *uNode = doc.FirstChild("iteminfo");

		if (!uNode)
			throw gcException(ERR_BADXML);

		TiXmlNode *toolNode = uNode->FirstChild("toolinfo");

		if (toolNode)
			getUserCore()->getToolManager()->parseXml(toolNode);

		TiXmlNode *gameNode = uNode->FirstChild("games");

		if (!gameNode)
			throw gcException(ERR_BADXML);

		getItemInfo()->getCurrentBranch()->getToolList(toolList);
	}

	if (!getUserCore()->getToolManager()->areAllToolsValid(toolList))
		throw gcException(ERR_INVALID, "Tool ids cannot be resolved into tools.");
}
示例#19
0
void DownloadToolTask::downloadTool()
{
	m_fhFile.open(m_Path, UTIL::FS::FILE_WRITE);

	HttpHandle hh(m_pTool->getUrl());

	m_pHttpHandle = hh.operator->();

	hh->getProgressEvent() += delegate(this, &DownloadToolTask::onProgress);
	hh->getWriteEvent() += delegate(this, &DownloadToolTask::onWrite);
	
	hh->setUserAgent(getUserCore()->getWebCore()->getUserAgent());
	hh->getWeb();

	m_pHttpHandle = nullptr;
	m_fhFile.close();
}
void DownloadToolTask::validateTools()
{
	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

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

	auto pToolManager = getUserCore()->getToolManager();

	if (pToolManager->areAllToolsValid(toolList))
		return;

	pToolManager->reloadTools(getItemId());
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	if (!pToolManager->areAllToolsValid(toolList))
		throw gcException(ERR_INVALID, "Tool ids cannot be resolved into tools.");
}
示例#21
0
void GatherInfoThread::doRun()
{
	auto wildc = gcRefPtr<WildcardManager>::create();
	wildc->onNeedSpecialEvent += delegate(&onNeedWCEvent);

	uint32 prog = 0;
	onProgUpdateEvent(prog);
	getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc, MCFBranch::BranchFromInt(getMcfBranch()), MCFBuild::BuildFromInt(getMcfBuild()));

	if (isStopped())
		return;

	auto item = getItemInfo();

	if (!item)
		throw gcException(ERR_INVALIDDATA, "The item handle was null (gather info failed)");

	uint32 itemId = item->getId().getItem();
	onCompleteEvent(itemId);
}
示例#22
0
bool VSCheckMcf::doTask(bool &goodMcf)
{
	auto mm = getUserCore()->getInternal()->getMCFManager();
	gcString filePath = mm->getMcfPath(getItemId(), getMcfBranch(), getMcfBuild());



	if (!checkMcf(filePath))
	{
		UTIL::FS::delFile(filePath);
		filePath = downloadMCFHeader();
	}

	if (!checkMcf(filePath))
		return false;

	goodMcf = false;


	m_hMcf->setFile(filePath.c_str());

	if (isStopped())
		return false;

	try
	{
		m_hMcf->parseMCF();

		bool passedVerify = m_hMcf->verifyMCF();

		if (m_hMcf->isComplete())
			goodMcf = passedVerify;

		m_hMcf->saveMCFHeader();
	}
	catch (gcException &)
	{
	}

	return true;
}
示例#23
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
	}
}
示例#24
0
void VSDownloadMissing::onNewProvider(MCFCore::Misc::DP_s& dp)
{
	if (isStopped())
		return;

	if (!dp.provider)
		return;

	if (dp.action == MCFCore::Misc::DownloadProvider::ADD)
	{
		UserCore::User* pUser = dynamic_cast<UserCore::User*>(getUserCore());

		if (pUser)
			pUser->getBDManager()->downloadBanner(this, dp.provider);
	}
	else if (dp.action == MCFCore::Misc::DownloadProvider::REMOVE)
	{
		UserCore::Misc::GuiDownloadProvider gdp(MCFCore::Misc::DownloadProvider::REMOVE, dp.provider);
		onNewProviderEvent(gdp);
	}
}
示例#25
0
void DownloadBannerTask::doTask()
{
	BannerCompleteInfo dpinfo(this, m_DownloadProvider);

	try
	{
		UTIL::FS::Path path(getUserCore()->getAppDataPath(), "", false);

		path += "temp";
		UTIL::FS::recMakeFolder(path);

		getWebCore()->downloadBanner(&m_DownloadProvider, path.getFullPath().c_str());
		dpinfo.complete = true;
	}
	catch (gcException &e)
	{
		Warning("Failed to download banner: {0}\n", e);
		dpinfo.complete = false;
	}

	onDLCompleteEvent(dpinfo);
}
示例#26
0
void ChangeAccountTask::doTask()
{
	auto pItem = getItemInfo();

	if (!pItem || !getWebCore())
		return;

	try
	{
		if (m_Action == ACCOUNT_ADD)
		{
			getWebCore()->updateAccountItem(pItem->getId(), true);
			pItem->addSFlag(ItemInfoI::STATUS_ONACCOUNT);
		}
		else
		{
			getWebCore()->updateAccountItem(pItem->getId(), false);
			pItem->delSFlag(ItemInfoI::STATUS_ONACCOUNT);

			if (!(pItem->getStatus() & (ItemInfoI::STATUS_INSTALLED|
										ItemInfoI::STATUS_ONCOMPUTER|
										ItemInfoI::STATUS_DOWNLOADING|
										ItemInfoI::STATUS_INSTALLING|
										ItemInfoI::STATUS_UPLOADING|
										ItemInfoI::STATUS_VERIFING)))
			{
				getUserCore()->getItemManager()->removeItem(pItem->getId());
			}
		}
	}
	catch (gcException &except)
	{
		if (except.getSecErrId() != 107)
			Warning("Error in Change Account task: {0}.\n", except);
	}
}
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;
}
示例#28
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;
}
示例#29
0
void CreateMCFThread::doRun()
{
	UserCore::Item::ItemInfo *item = getItemInfo();

	if (!item && !getUserCore()->isAdmin())
		throw gcException(ERR_BADITEM);

	if (!item)
	{
		waitForItemInfo();
		item = getItemInfo();
	}

	if (isStopped())
		return;

	if (!item)
		throw gcException(ERR_BADITEM);

	const char* val = getUserCore()->getCVarValue("gc_corecount");

	if (val && atoi(val) != 0)
		m_hMCFile->setWorkerCount(atoi(val));


	m_hMCFile->parseFolder(m_szPath.c_str(), true);

	if (m_hMCFile->getFileCount() == 0)
		throw gcException(ERR_ZEROFILECOUNT, gcString("There are no files in the folder {0}. \nPlease check to see if you have the correct folder and try again.", m_szPath));


	if (item->getBranchCount() == 0)
	{
		m_hMCFile->setHeader(getItemId(), MCFBranch(), MCFBuild());
		m_hMCFile->getHeader()->setParent(0);
	}
	else
	{
		std::vector<UserCore::Item::BranchInfo*> vBranchList;

		try
		{
			retrieveBranchList(vBranchList);

			if (vBranchList.size() != 0)
				compareBranches(vBranchList);
		}
		catch (...)
		{
		}

		safe_delete(vBranchList);
	}


	if (isStopped())
		return;

	createMcf();

	if (isStopped())
		return;

	m_bComplete = true;
	onCompleteStrEvent(m_szFilePath);	
}
		bool VSCheckMcfDownload::doTask(gcString &path)
		{
			auto mm = getUserCore()->getInternal()->getMCFManager();
			path = mm->getMcfPath(getItemId(), getMcfBranch(), getMcfBuild());
			return checkMcf(path);
		}