Exemplo n.º 1
0
gcString MCFManager::getMcfPath(DesuraId id, MCFBranch branch, MCFBuild build, bool isUnAuthed)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());
	std::string res;

	try
	{
		int flags = isUnAuthed?FLAG_UNAUTHED:FLAG_NONE;

		sqlite3x::sqlite3_connection db(szItemDb.c_str());

		if (flags == FLAG_NONE)
		{
			sqlite3x::sqlite3_command cmd(db, "SELECT path FROM mcfitem WHERE internalid=? AND mcfbuild=? AND branch=?;");
			cmd.bind(1, (long long int)id.toInt64());
			cmd.bind(2, (int)build);
			cmd.bind(3, (int)branch);
			res = cmd.executestring();
		}
		else
		{
			sqlite3x::sqlite3_command cmd(db, "SELECT path FROM mcfitem WHERE internalid=? AND mcfbuild=? AND branch=? AND flags & ?;");
			cmd.bind(1, (long long int)id.toInt64());
			cmd.bind(2, (int)build);
			cmd.bind(3, (int)branch);
			cmd.bind(4, (int)flags);
			res = UTIL::OS::getAbsPath(cmd.executestring());
		}
	}
	catch (std::exception &)
	{
	}

	return res;
}
Exemplo n.º 2
0
gcString MCFManager::getMcfBackup(DesuraId gid, DesuraId mid)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());
	std::string res;

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "SELECT path FROM mcfbackup WHERE gid=? AND mid=?;");
		cmd.bind(1, (long long int)gid.toInt64());
		cmd.bind(2, (long long int)mid.toInt64());
		res = UTIL::OS::getRelativePath(cmd.executestring());

		if (!UTIL::FS::isValidFile(UTIL::FS::PathWithFile(res)))
		{
			properDelMcfBackup(gid, mid);
			res = "";
		}
	}
	catch (std::exception &)
	{
	}

	return res;
}
Exemplo n.º 3
0
void MCFManager::delAllMcfPath(DesuraId id)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());
	sqlite3x::sqlite3_connection db(szItemDb.c_str());

	try
	{
		sqlite3x::sqlite3_command cmd(db, "SELECT path FROM mcfitem WHERE internalid=?;");
		cmd.bind(1, (long long int)id.toInt64());
		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read())
		{
			std::string path = reader.getstring(0);
			UTIL::FS::delFile(UTIL::FS::PathWithFile(path));
		}
	}
	catch (std::exception &)
	{
	}

	try
	{
		sqlite3x::sqlite3_command cmd(db, "DELETE FROM mcfitem WHERE internalid=?;");
		cmd.bind(1, (long long int)id.toInt64());
		cmd.executenonquery();
	}
	catch (std::exception &e)
	{
		Warning("Failed to delete mcf items: {0}\n", e.what());
	}
}
Exemplo n.º 4
0
ToolStartRes ToolTransInfo::startNextInstall(std::shared_ptr<IPCToolMain> pToolMain, DesuraId &toolId)
{
	gcTrace("ToolId {0}", toolId);

	if (m_uiCompleteCount == m_pTransaction->size())
		return ToolStartRes::NoToolsLeft;

	toolId = m_pTransaction->get(m_uiCompleteCount);
	ToolInfo* info = m_pToolManager->findItem(toolId.toInt64());

	if (!info)
	{
		Warning("Failed to find tool for tool install with id {0}", toolId.toInt64());
		m_uiCompleteCount++;
		return startNextInstall(pToolMain, toolId);
	}
		
	if (info->isInstalled())
	{
		onINComplete();
		return startNextInstall(pToolMain, toolId);
	}

	DesuraId id = info->getId();
	m_pTransaction->onStartInstallEvent(id);

	gcException e = pToolMain->installTool(info);

#ifdef NIX
	if (e.getErrId() == ERR_COMPLETED)
	{
		onINComplete();
		return startNextInstall(pToolMain, toolId);
	}
#endif

	if (e.getErrId() != WARN_OK && e.getErrId() != ERR_UNKNOWNERROR)
	{
		onINError(e);
		return ToolStartRes::Failed;
	}
	else
	{
		UserCore::Misc::ToolProgress prog;

		prog.done = m_uiCompleteCount;
		prog.total = m_pTransaction->size();
		prog.percent = prog.done*100/prog.total;

		m_pTransaction->onProgressEvent(prog);
	}
	
	return ToolStartRes::Success;
}
Exemplo n.º 5
0
gcString MCFManager::newMcfPath(DesuraId id, MCFBranch branch, MCFBuild build, bool isUnAuthed)
{
	gcString curPath = getMcfPath(id, branch, build, isUnAuthed);

	if (curPath != "")
		return curPath;

	curPath = generatePath(id, branch, build, isUnAuthed);
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());

	try
	{
		int flags = isUnAuthed?FLAG_UNAUTHED:FLAG_NONE;

		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "INSERT INTO mcfitem VALUES (?,?,?,?,?);");
		cmd.bind(1, (long long int)id.toInt64());
		cmd.bind(2, (int)build);
		cmd.bind(3, UTIL::OS::getRelativePath(curPath));
		cmd.bind(4, (int)branch);
		cmd.bind(5, (int)flags);

		cmd.executenonquery();
	}
	catch (std::exception &e)
	{
		curPath = "";
		Warning("Failed to insert mcf item: {0}\n", e.what());
	}

	return curPath;
}
Exemplo n.º 6
0
void InternalLink::installItem(DesuraId id, Args args)
{
	std::string branch = args.getArgValue("branch");
	std::string global = args.getArgValue("global");

	MCFBranch iBranch;

	if (branch == "shortcut" || global == "shortcut")
	{
		iBranch = MCFBranch::BranchFromInt(-1);
	}
	else if (global.size() > 0)
	{
		iBranch = MCFBranch::BranchFromInt(Safe::atoi(global.c_str()), true);
	}
	else
	{
		iBranch = MCFBranch::BranchFromInt(Safe::atoi(branch.c_str()));
	}

	g_pMainApp->showPlay();

	if (iBranch == 0 && !args.containsArg("skippreorder") && checkForPreorder(id))
		return;
	
	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_INSTALL, iBranch);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for install [{0}].\n", id.toInt64()));	
}
Exemplo n.º 7
0
void InternalLink::installCheck(DesuraId id)
{
	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_INSTALL_CHECK);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for install check [{0}].\n", id.toInt64()));
}
Exemplo n.º 8
0
void MCFManager::getMCFFiles(std::vector<mcfInfo*> &validFiles, DesuraId id)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());

		sqlite3x::sqlite3_command cmd(db, "SELECT path, mcfbuild FROM mcfitem WHERE internalid=?;");
		cmd.bind(1, (long long int)id.toInt64());

		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read())
		{
			std::string p = UTIL::OS::getAbsPath(reader.getstring(0));
			uint32 v = reader.getint(1);

			validFiles.push_back(new mcfInfo(p.c_str(), v, MCFBranch()));
		}
	}
	catch (std::exception &)
	{
	}
}
Exemplo n.º 9
0
void GameExplorerManager::removeItem(DesuraId item)
{
	Misc::GameExplorerInfo* gei = BaseManager::findItem(item.toInt64());

	if (gei)
		gei->removeDll();
}
Exemplo n.º 10
0
void ToolManager::cancelDownload(Misc::ToolTransInfo* info, bool force)
{
	if (!info)
		return;

	m_DownloadLock.lock();

	std::vector<DesuraId> idList;
	info->getIds(idList);

	for (size_t x=0; x<idList.size(); x++)
	{
		DesuraId id = idList[x];
		ToolInfo* info = findItem(id.toInt64());

		//This should not happen as there is a check before a download starts to make sure all tool ids are valid
		if (!info)
			continue;	

		std::map<uint64, UserCore::Task::DownloadToolTask*>::iterator it = m_mDownloads.find(id.toInt64());

		if (it != m_mDownloads.end())
			it->second->decreaseRefCount(force);
	}

	m_DownloadLock.unlock();	
}
Exemplo n.º 11
0
void MCFManager::properDelMcfBackup(DesuraId gid, DesuraId mid)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());
	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "DELETE FROM mcfbackup WHERE gid=? AND mid=?;");
		cmd.bind(1, (long long int)gid.toInt64());
		cmd.bind(2, (long long int)mid.toInt64());
		cmd.executenonquery();
	}
	catch (std::exception &e)
	{
		Warning("Failed to delete mcf backup: {0}\n", e.what());
	}
}
Exemplo n.º 12
0
void User::removeUninstallInfo(DesuraId id)
{
#ifdef WIN32
	if (getServiceMain())
		getServiceMain()->removeUninstallRegKey(id.toInt64());
#endif
}
Exemplo n.º 13
0
void MCFManager::getAllMcfPaths(DesuraId id, std::vector<McfPathData> &vList)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());
	std::string res;

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());

		sqlite3x::sqlite3_command cmd(db, "SELECT path, mcfbuild, branch FROM mcfitem WHERE internalid=?");
		cmd.bind(1, (long long int)id.toInt64());

		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read())
		{
			McfPathData mpd;

			mpd.path = UTIL::OS::getAbsPath(reader.getstring(0));
			mpd.build = MCFBuild::BuildFromInt(reader.getint(1));
			mpd.branch = MCFBranch::BranchFromInt(reader.getint(2));

			vList.push_back(mpd);
		}
	}
	catch (std::exception &)
	{
	}
}
Exemplo n.º 14
0
void InternalLink::cleanComplexMod(DesuraId id)
{
	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_CLEANCOMPLEX, true);

	if (!form)
		Warning("Cant find item (or item not ready) for clean complex mod [{0}].\n", id.toInt64());
}
Exemplo n.º 15
0
void User::updateUninstallInfo(DesuraId id, uint64 installSize)
{
#ifdef WIN32
	if (getServiceMain())
		getServiceMain()->setUninstallRegKey(id.toInt64(), installSize);
#endif
}
Exemplo n.º 16
0
gcString MCFManager::newMcfBackup(DesuraId gid, DesuraId mid)
{
	gcString curPath = getMcfBackup(gid, mid);

	if (curPath != "")
		return curPath;

	gcString parPath;
	gcString parFile;

	size_t x=0;


	do
	{


		if (x==0)
			parFile = gcString("backup_{0}.mcf", mid.toInt64());
		else
			parFile = gcString("backup_{0}_{1}.mcf", mid.toInt64(), x);

		parPath = gcString("{0}{1}{2}", m_szMCFSavePath, DIRS_STR, gid.getFolderPathExtension(parFile.c_str()));
		x++;
	}
	while ( UTIL::FS::isValidFile(UTIL::FS::PathWithFile(parPath)) );

	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "INSERT INTO mcfbackup VALUES (?,?,?);");
		cmd.bind(1, (long long int)gid.toInt64());
		cmd.bind(2, (long long int)mid.toInt64());
		cmd.bind(3, UTIL::OS::getRelativePath(parPath));

		cmd.executenonquery();
	}
	catch (std::exception &e)
	{
		Warning("Failed to update mcf backup: {0}\n", e.what());
	}

	return parPath;
}
Exemplo n.º 17
0
void InternalLink::uninstallMCF(DesuraId id)
{	
	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_UNINSTALL);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for uninstall [{0}].\n", id.toInt64()));

	form->Raise();
}
Exemplo n.º 18
0
void InternalLink::updateItem(DesuraId id, Args args)
{
	bool show = args.containsArg("show") && args.getArgValue("show") == "true";

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_UPDATE, show);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for update [{0}].\n", id.toInt64()));
}
Exemplo n.º 19
0
std::string ToolManager::getToolName(DesuraId toolId)
{
	ToolInfo* info = findItem(toolId.toInt64());

	if (!info)
		return "";

	return info->getName();
}
Exemplo n.º 20
0
void User::updateUninstallInfo(DesuraId id, uint64 installSize)
{
#ifdef WIN32
	if (getItemManager())
		getItemManager()->saveItem(getItemManager()->findItemInfo(id));

	if (getServiceMain())
		getServiceMain()->setUninstallRegKey(id.toInt64(), installSize);
#endif
}
Exemplo n.º 21
0
void InternalLink::verifyItem(DesuraId id, Args args)
{
	bool showForm = args.getArgValue("show") != "false";

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_VERIFY, showForm);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for verify [{0}].\n", id.toInt64()));
	else if (showForm == false)
		form->Show(false);
}
Exemplo n.º 22
0
GameExplorerInfo::GameExplorerInfo(DesuraId id, gcRefPtr<UserCore::UserI> &user)
{
	m_Id = id;

	m_uiHash = id.toInt64();
	m_pUser = user;
	m_uiFlags = 0;

	m_pItemInfo = nullptr;

	regEvent();
}
Exemplo n.º 23
0
void CIPManager::deleteItem(DesuraId id)
{
	try
	{
		sqlite3x::sqlite3_connection db(m_szDBName.c_str());
		sqlite3x::sqlite3_command cmd(db, "DELETE FROM cip WHERE internalid=?;");
		cmd.bind(1, (long long int)id.toInt64());
		cmd.executenonquery();
	}
	catch (...)
	{
	}
}
Exemplo n.º 24
0
void InternalLink::handleInternalLink(DesuraId id, uint8 action, const std::vector<std::string> &argsList)
{
	if (g_pMainApp->isOffline() && action != ACTION_LAUNCH)
		return;

	Args args(argsList);

	bool handled = true;

	switch (action)
	{
	case ACTION_UPLOAD		: uploadMCF( id );						break;
	case ACTION_CREATE		: createMCF( id );						break;
	case ACTION_RESUPLOAD	: resumeUploadMCF( id, args );			break;
#ifdef WIN32
	case ACTION_INSTALLEDW	: installedWizard();					break;
#endif
	case ACTION_SHOWSETTINGS: showSettings(args);					break;
	case ACTION_APPUPDATELOG: showUpdateLogApp( id.getItem() );		break;
	case ACTION_PAUSE		: setPauseItem( id , true );			break;
	case ACTION_UNPAUSE		: setPauseItem( id , false );			break;
	case ACTION_UNINSTALL	: uninstallMCF( id );					break;
	case ACTION_PROMPT		: showPrompt(id, args);					break;
	case ACTION_UPDATELOG	: showUpdateLog(id);					break;
	case ACTION_DISPCDKEY	: showCDKey(id, args);					break;

	default: 
		handled = false;
		break;
	}

	if (handled || checkForm(id))
		return;

	switch (action)
	{
	case ACTION_INSTALL		: installItem(id, args);				break;
	case ACTION_LAUNCH		: launchItem(id, args);					break;
	case ACTION_VERIFY		: verifyItem(id, args);					break;
	case ACTION_UPDATE		: updateItem(id, args);					break;
	case ACTION_TEST		: installTestMCF(id, args);				break;
	case ACTION_INSCHECK	: installCheck(id);						break;
	case ACTION_SHOWUPDATE	: showUpdateForm(id, args);				break;
	case ACTION_SWITCHBRANCH: switchBranch(id, args);				break;
	case ACTION_CLEANCOMPLEXMOD: cleanComplexMod(id);				break;

	default: 
		Warning(gcString("Unknown internal link {0} for item {1}\n.", (uint32)action, id.toInt64()));	
		break;
	}
}
Exemplo n.º 25
0
bool ToolTransInfo::startNextInstall(IPCToolMain* pToolMain, DesuraId &toolId)
{
	if (m_uiCompleteCount == m_pTransaction->toolsList.size())
		return false;

	toolId = m_pTransaction->toolsList[m_uiCompleteCount];
	ToolInfo* info = m_pToolManager->findItem(toolId.toInt64());

	if (!info)
		return true;

	if (info->isInstalled())
	{
		m_uiCompleteCount++;
		return startNextInstall(pToolMain, toolId);
	}

	DesuraId id = info->getId();
	m_pTransaction->onStartInstallEvent(id);

	gcException e = pToolMain->installTool(info);

#ifdef NIX
	if (e.getErrId() == ERR_COMPLETED)
	{
		onINComplete();
		return startNextInstall(pToolMain, toolId);
	}
#endif

	if (e.getErrId() != WARN_OK && e.getErrId() != ERR_UNKNOWNERROR)
	{
		onINError(e);
		return false;
	}
	else
	{
		UserCore::Misc::ToolProgress prog;

		prog.done = m_uiCompleteCount;
		prog.total = m_pTransaction->toolsList.size();
		prog.percent = prog.done*100/prog.total;

		m_pTransaction->onProgressEvent(prog);
	}
	
	return true;
}
Exemplo n.º 26
0
void InternalLink::switchBranch(DesuraId id, Args args)
{
	std::string branch = args.getArgValue("branch");

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

	MCFBranch iBranch = MCFBranch::BranchFromInt(Safe::atoi(branch.c_str()));

	if (iBranch == 0)
		return;

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_SWITCH_BRANCH, iBranch);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for uninstall [{0}].\n", id.toInt64()));
}
Exemplo n.º 27
0
void MCFManager::validateMcf(const char* mcf)
{
	if (!UTIL::FS::isValidFile(UTIL::FS::PathWithFile(mcf)))
		return;

	McfHandle mcfHandle;
	mcfHandle->setFile(mcf);

	try
	{
		mcfHandle->parseMCF();
	}
	catch (gcException &)
	{
		return;
	}

	MCFCore::MCFHeaderI *mcfHead = mcfHandle->getHeader();

	DesuraId id = mcfHead->getDesuraId();
	MCFBuild build = mcfHead->getBuild();
	MCFBranch branch = mcfHead->getBranch();

	bool isPatch = strstr(mcf, "patch")?true:false;
	bool isUnAuthed = strstr(mcf, "unauth")?true:false;
	int flags = (isPatch?FLAG_PATCH:FLAG_NONE) + (isUnAuthed?FLAG_UNAUTHED:FLAG_NONE);

	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "INSERT INTO mcfitem VALUES (?,?,?,?,?);");
		cmd.bind(1, (long long int)id.toInt64());
		cmd.bind(2, (int)build);
		cmd.bind(3, UTIL::OS::getRelativePath(mcf));
		cmd.bind(4, (int)branch);
		cmd.bind(5, (int)flags);

		cmd.executenonquery();
	}
	catch (std::exception &)
	{
	}
}
Exemplo n.º 28
0
void InternalLink::showGameDisk(DesuraId id, const char* exe, bool cdkey)
{
	FINDFORM(id, GameDiskForm);

	UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id );

	if (!item)
	{
		Warning(gcString("Cant find item for show game disk [{0}].\n", id.toInt64()));
		return;
	}

	GameDiskForm* form = new GameDiskForm(m_pParent, exe, cdkey);
	m_vSubForms.push_back(form);

	form->setInfo(id);
	form->Show(true);
}
Exemplo n.º 29
0
bool InternalLink::checkForm(DesuraId id)
{
	std::map<uint64,gcFrame*>::iterator it = m_mFormMap.find(id.toInt64());

	if (it != m_mFormMap.end() && it->second)
	{
		UI::Forms::ItemForm* itemForm = dynamic_cast<UI::Forms::ItemForm*>(it->second);

		if (itemForm && !itemForm->isInit())
			return false;

		it->second->Show();
		it->second->Raise();
		return true;
	}

	return false;
}
Exemplo n.º 30
0
void MCFManager::delMcfPath(DesuraId id, MCFBranch branch, MCFBuild build)
{
	gcString szItemDb = getMcfDb(m_szAppDataPath.c_str());

	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		sqlite3x::sqlite3_command cmd(db, "DELETE FROM mcfitem WHERE internalid=? AND mcfbuild=? AND branch=?;");
		cmd.bind(1, (long long int)id.toInt64());
		cmd.bind(2, (int)build);
		cmd.bind(3, (int)branch);
		cmd.executenonquery();
	}
	catch (std::exception &e)
	{
		Warning("Failed to delete mcf item: {0}\n", e.what());
	}
}