Exemplo n.º 1
0
void BranchInfo::loadDb(sqlite3x::sqlite3_connection* db)
{
	if (!db)
		return;

	sqlite3x::sqlite3_command cmd(*db, "SELECT * FROM branchinfo WHERE branchid=? AND internalid=?;");
	cmd.bind(1, (int)m_uiBranchId);
	cmd.bind(2, (long long int)m_ItemId.toInt64());

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

	m_szName		= gcString(reader.getstring(2));		//name
	m_uiFlags		= reader.getint(3);						//flags
	m_szEulaUrl		= reader.getstring(4);
	m_szEulaDate	= reader.getstring(5);
	m_szPreOrderDate = reader.getstring(6);
	decodeCDKey(reader.getstring(7));
	m_szInstallScript = UTIL::OS::getAbsPath(reader.getstring(8));
	m_uiInstallScriptCRC = reader.getint(9);
	m_uiGlobalId = MCFBranch::BranchFromInt(reader.getint(10), true);

	m_uiFlags &= ~BF_ONACCOUNT;

	{
		sqlite3x::sqlite3_command cmd(*db, "SELECT * FROM tools WHERE branchid=?;");
		cmd.bind(1, (int)m_uiBranchId);
		sqlite3x::sqlite3_reader reader = cmd.executereader();
	
		while (reader.read())
			m_vToolList.push_back(DesuraId(reader.getint64(1)));
	}
}
Exemplo n.º 2
0
void CIPManager::getCIPList(std::vector<UserCore::Misc::CIPItem> &list)
{
	try 
	{
		sqlite3x::sqlite3_connection db(m_szDBName.c_str());
		sqlite3x::sqlite3_command cmd(db, "SELECT c.internalid, c.path, i.name FROM cip as c INNER JOIN cipiteminfo as i USING(internalid);");
		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read()) 
		{
			UserCore::Misc::CIPItem cip;

			cip.id = DesuraId(reader.getint64(0));
			cip.path = reader.getstring(1);
			cip.name = reader.getstring(2);

			if (cip.path.size() == 0)
				continue;

			list.push_back(cip);
		}
	}
	catch(std::exception &ex) 
	{
		Warning("Failed to update cip (loadItems) {0}\n", ex.what());
	}
}
Exemplo n.º 3
0
DesuraId GameDiskForm::getItemId()
{
	if (!m_pItem)
		return DesuraId();

	return m_pItem->getId();
}
Exemplo n.º 4
0
	TEST(BranchInfo, CDKeyPerUser)
	{
		auto bi = gcRefPtr<StubBranchItemInfo2>::create();
		auto info = gcRefPtr<BranchInstallInfo>::create(1, bi, UTIL::FS::g_pDefaultUTILFS);
		auto a = gcRefPtr<BranchInfo>::create(MCFBranch::BranchFromInt(1), DesuraId("2", "games"), info, 0, 123);
		auto b = gcRefPtr<BranchInfo>::create(MCFBranch::BranchFromInt(1), DesuraId("2", "games"), info, 0, 123);
		auto c = gcRefPtr<BranchInfo>::create(MCFBranch::BranchFromInt(1), DesuraId("2", "games"), info, 0, 456);

		a->setCDKey("A Test CD Key");

		{
			std::vector<gcString> vCDKeys;
			a->getCDKey(vCDKeys);

			ASSERT_EQ(1, vCDKeys.size());
			ASSERT_STREQ("A Test CD Key", vCDKeys[0].c_str());
		}


		sqlite3x::sqlite3_connection db(":memory:");
		createItemInfoDbTables(db);


		a->saveDbFull(&db);
		b->loadDb(&db);
		c->loadDb(&db);

		{
			std::vector<gcString> vCDKeys;
			b->getCDKey(vCDKeys);

			ASSERT_EQ(1, vCDKeys.size());
			ASSERT_STREQ("A Test CD Key", vCDKeys[0].c_str());
		}

		{
			std::vector<gcString> vCDKeys;
			c->getCDKey(vCDKeys);

			ASSERT_EQ(0, vCDKeys.size());
		}
	}
Exemplo n.º 5
0
void CIPManager::getItemList(std::vector<UserCore::Misc::CIPItem> &list)
{
	try 
	{
		sqlite3x::sqlite3_connection db(m_szDBName.c_str());
		sqlite3x::sqlite3_command cmd(db, "select * from cipiteminfo;");
		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read()) 
		{
			UserCore::Misc::CIPItem cip;

			cip.id = DesuraId(reader.getint64(0));
			cip.name =  reader.getstring(1);

			list.push_back(cip);
		}
	}
	catch(std::exception &ex) 
	{
		Warning("Failed to update cip (loadItems) {0}\n", ex.what());
	}

	std::vector<UserCore::Item::ItemInfoI*> items;
	m_pUser->getItemManager()->getGameList(items);

	for (size_t x=0; x<items.size(); x++)
	{
		bool found = false;

		for (size_t y=0; y<list.size(); y++)
		{
			if (list[y].id == items[x]->getId())
			{
				found = true;
				break;
			}
		}

		if (!found)
		{
			UserCore::Misc::CIPItem cip;

			cip.id = items[x]->getId();
			cip.name = items[x]->getName();

			list.push_back(cip);
		}
	}
}
Exemplo n.º 6
0
	virtual void loadFromDb(sqlite3x::sqlite3_connection* db)
	{
		ToolInfo::loadFromDb(db);

		std::vector<std::string> out;
		UTIL::STRING::tokenize(m_szUrl, out, "|");

		m_ItemId = DesuraId(UTIL::MISC::atoll(out[0].c_str()));

		if (out.size() > 1)
			m_uiBranchId = MCFBranch::BranchFromInt(atoi(out[1].c_str()));

		m_szUrl = "";
	}
Exemplo n.º 7
0
void ToolManager::loadItems()
{
	sqlite3x::sqlite3_connection db(getToolInfoDb(m_pUser->getAppDataPath()).c_str());

	std::vector<DesuraId> toolIdList;

	try
	{
		sqlite3x::sqlite3_command cmd(db, "SELECT internalid FROM toolinfo;");
		sqlite3x::sqlite3_reader reader = cmd.executereader();

		while (reader.read())
		{
			toolIdList.push_back(DesuraId(reader.getint64(0)));
		}
	}
	catch (std::exception &)
	{
	}

	for (size_t x=0; x<toolIdList.size(); x++)
	{
		ToolInfo* tool = findItem(toolIdList[x].toInt64());

		bool bAdd = false;

		int32 negId = toolIdList[x].getItem();

		if (!tool)
		{
			if (negId >= 0)
				tool = new ToolInfo(toolIdList[x]);
#ifdef WIN32
			else
				tool = NewJSToolInfo(toolIdList[x]);
#endif

			bAdd = true;
		}
		else if (negId < m_iLastCustomToolId)
		{
			m_iLastCustomToolId = negId;
		}

		tool->loadFromDb(&db);

		if (bAdd)
			addItem(tool);
	}
}
Exemplo n.º 8
0
void TaskBarIcon::onBallonClick(wxTaskBarIconEvent &event)
{
	if (m_iLastBallon == BALLON_GIFTS)
	{
		g_pMainApp->showNews();
	}
	else if (m_iLastBallon == BALLON_APPUPDATE)
	{
		g_pMainApp->handleInternalLink(DesuraId(m_AppUpdateVer.build, 0), ACTION_APPUPDATELOG);
	}
	else if (m_iLastBallon == BALLON_GAMEUPDATE)
	{
		g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Updates).c_str(), COMMUNITY);
	}

	m_iLastBallon = BALLON_NONE;
}
Exemplo n.º 9
0
void TBIUpdateMenu::onMenuSelect(wxCommandEvent& event)
{
	switch (event.GetId())
	{
	case mcMENU_MESSAGE:
		g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Inbox).c_str(), COMMUNITY);
		break;

	case mcMENU_UPDATE:
		g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Updates).c_str(), COMMUNITY);
		break;

	case mcMENU_CART:
		g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Cart).c_str(), COMMUNITY);
		break;

	case mcMENU_GAMEUPDATE:
	case mcMENU_MODUPDATE:
		g_pMainApp->handleInternalLink(DesuraId(), ACTION_PLAY);
		break;
	}
}
Exemplo n.º 10
0
	TEST_F(MCFManagerFixture, getListOfBadMcfPaths)
	{
		sqlite3x::sqlite3_connection db(":memory:");
		db.executenonquery(CREATE_MCFITEM);

		auto insertItem = [&db](DesuraId id, gcString strPath, bool bUnAuthed) -> void
		{
			try
			{
				sqlite3x::sqlite3_command cmd(db, "INSERT INTO mcfitem VALUES (?,?,?,?,?);");
				cmd.bind(1, (long long int)id.toInt64());
				cmd.bind(2, 0);
				cmd.bind(3, UTIL::FS::PathWithFile(strPath).getFullPath());
				cmd.bind(4, 0);
				cmd.bind(5, bUnAuthed ? FLAG_UNAUTHED : 0);

				cmd.executenonquery();
			}
			catch (std::exception &)
			{
			}
		};

		insertItem(DesuraId("51", "games"), "appdata\\test1.mcf", true);
		insertItem(DesuraId("62", "games"), "appdata\\test2.mcf", false);
		insertItem(DesuraId("73", "games"), "appdata\\test3.mcf", false);
		insertItem(DesuraId("84", "games"), "mcfroot\\test4.mcf", false);

		std::vector<UserCore::MigrateInfo> delList;
		std::vector<UserCore::MigrateInfo> updateList;

		getListOfBadMcfPaths(db, delList, updateList);

		ASSERT_EQ(1, delList.size());
		ASSERT_EQ(DesuraId("51", "games"), delList[0].id);

		ASSERT_EQ(2, updateList.size());
		ASSERT_EQ(DesuraId("62", "games"), updateList[0].id);
		ASSERT_EQ(DesuraId("73", "games"), updateList[1].id);
	}
Exemplo n.º 11
0
		DesuraId getId() override
		{
			return DesuraId("2", "games");
		}
Exemplo n.º 12
0
void BranchInfo::loadXmlData(TiXmlNode *xmlNode)
{
	XML::GetChild("name", m_szName, xmlNode);
	XML::GetChild("price", m_szCost, xmlNode);
	XML::GetChild("eula", m_szEulaUrl, xmlNode);

	TiXmlNode* eNode = xmlNode->FirstChild("eula");

	if (eNode && XML::isValidElement(eNode))
	{
		TiXmlElement *eEl = dynamic_cast<TiXmlElement*>(eNode);

		const char* date = eEl->Attribute("date");

		if (date && m_szEulaDate != date)
		{
			m_uiFlags &= ~BF_ACCEPTED_EULA; 
			m_szEulaDate = date;
		}
	}

	gcString preload;
	XML::GetChild("preload", preload, xmlNode);

	if (m_szPreOrderDate.size() > 0 && (preload.size() == 0 || preload == "0"))
	{
		m_szPreOrderDate = "";
		m_uiFlags &= ~BF_PREORDER;

		onBranchInfoChangedEvent();
	}
	else if (preload != "0")
	{
		m_szPreOrderDate = preload;
		m_uiFlags |= BF_PREORDER;

		onBranchInfoChangedEvent();
	}


	bool nameon = false;
	bool free = false;
	bool onaccount = false;
	bool regionlock = false;
	bool memberlock = false;
	bool demo = false;
	bool test = false;
	bool cdkey = false;
	gcString cdkeyType;

	XML::GetChild("nameon", nameon, xmlNode);
	XML::GetChild("free", free, xmlNode);
	XML::GetChild("onaccount", onaccount, xmlNode);
	XML::GetChild("regionlock", regionlock, xmlNode);
	XML::GetChild("inviteonly", memberlock, xmlNode);
	XML::GetChild("demo", demo, xmlNode);
	XML::GetChild("test", test, xmlNode);
	XML::GetChild("cdkey", cdkey, xmlNode);
	XML::GetAtt("type", cdkeyType, xmlNode->FirstChildElement("cdkey"));

	int32 global = -1;
	XML::GetChild("global", global, xmlNode);

	if (global != -1)
		m_uiGlobalId = MCFBranch::BranchFromInt(global, true);

	if (nameon)
		m_uiFlags |= BF_DISPLAY_NAME;

	if (free)
		m_uiFlags |= BF_FREE;

	if (onaccount)
		m_uiFlags |= BF_ONACCOUNT;

	if (regionlock)
		m_uiFlags |= BF_REGIONLOCK;

	if (memberlock)
		m_uiFlags |= BF_MEMBERLOCK;

	if (demo)
		m_uiFlags |= BF_DEMO;

	if (test)
		m_uiFlags |= BF_TEST;

	if (cdkey)
		m_uiFlags |= BF_CDKEY;

	if (cdkeyType == "steam")
		m_uiFlags |= BF_STEAMGAME;

	//no mcf no release
	TiXmlNode* mcfNode = xmlNode->FirstChild("mcf");
	if (!mcfNode)
	{
		m_uiFlags |= BF_NORELEASES;
	}
	else
	{
		int32 build = -1;
		XML::GetChild("build", build, mcfNode);

		m_uiLatestBuild = MCFBuild::BuildFromInt(build);
	}

	TiXmlNode* toolsNode = xmlNode->FirstChild("tools");

	if (toolsNode)
	{
		m_vToolList.clear();

		TiXmlElement* toolNode = toolsNode->FirstChildElement("tool");

		while (toolNode)
		{
			const char* id = toolNode->GetText();

			if (id)
				m_vToolList.push_back(DesuraId(id, "tools"));

			toolNode = toolNode->NextSiblingElement("tool");
		}
	}

	TiXmlElement* scriptNode = xmlNode->FirstChildElement("installscript");

	if (scriptNode)
		processInstallScript(scriptNode);
}
Exemplo n.º 13
0
RegenLaunchScriptsTask::RegenLaunchScriptsTask(gcRefPtr<UserCore::UserI> user) 
	: UserTask(user, DesuraId())
{
}
Exemplo n.º 14
0
MigrateStandaloneTask::MigrateStandaloneTask(gcRefPtr<UserCore::UserI> user, const std::vector<UTIL::FS::Path> &fileList) 
	: UserTask(user, DesuraId())
{
	m_vFileList = fileList;
}
Exemplo n.º 15
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

#include "Common.h"
#include "ItemHandle.h"

#include "User.h"

DesuraId g_ElevatedGames [] = 
{
	DesuraId(196, DesuraId::TYPE_GAME),
	DesuraId(),
};




namespace UserCore
{
namespace Item
{


void ItemHandle::doLaunch(Helper::ItemLaunchHelperI* helper)
{
	preLaunchCheck();
Exemplo n.º 16
0
	void doTask()
	{
		RemoveUninstallRegKey(DesuraId(id));
	}
Exemplo n.º 17
0
	}

	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()));	
}

DesuraId g_GameDiskList[] = 
{
	DesuraId(49, DesuraId::TYPE_GAME),
	DesuraId(184, DesuraId::TYPE_GAME),
	DesuraId()
};

void InternalLink::launchItem(DesuraId id, Args args)
{
	bool cdKeyArg = args.containsArg("cdkey");
	bool noUpdateArg = args.containsArg("noupdate");
	bool exeNumArg = args.containsArg("exe");
	std::string exe = args.getArgValue("exe");

	if (exe == "")
		exeNumArg = false;

	g_pMainApp->showPlay();
Exemplo n.º 18
0
	void doTask()
	{
		SetUninstallRegKey(DesuraId(id), installSize);
	}
Exemplo n.º 19
0
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;
}
Exemplo n.º 20
0
UpdateThread::UpdateThread(Event<std::tuple<gcOptional<bool>, gcOptional<bool>, gcOptional<bool>>> *onForcePollEvent, bool loadLoginItems)
	: BaseUserThread<UserThreadI, ::Thread::BaseThread>( "Update poll Thread", DesuraId() )
{
	m_pBaseTask = new UpdateThreadOld(onForcePollEvent, loadLoginItems);
	m_pBaseTask->isStoppedEvent += delegate(this, &UpdateThread::isThreadStopped);
}