Beispiel #1
0
void WebCoreClass::newUpload(DesuraId id, const char* hash, uint64 fileSize, char **key)
{
	gcString size("{0}", fileSize);

	TiXmlDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["action"] = "newupload";
	post["filehash"] = hash;
	post["filesize"] = size;

	TiXmlNode *uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc);
	TiXmlNode* iNode = uNode->FirstChild("mcf");
	
	if (!iNode)
		throw gcException(ERR_BADXML);	

	TiXmlElement* cEl = iNode->ToElement();
		
	if (cEl)
	{
		const char* text = cEl->Attribute("key");

		if (!text)
			throw gcException(ERR_BADXML);	

		Safe::strcpy(key, text, 255);
	}
}
Beispiel #2
0
void WebCoreClass::resumeUpload(DesuraId id, const char* key, WebCore::Misc::ResumeUploadInfo &info)
{
	TiXmlDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["action"] = "resumeupload";
	post["key"] = key;

	TiXmlNode *uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc);
	TiXmlNode* mNode = uNode->FirstChild("mcf");

	if (!mNode)
		throw gcException(ERR_BADXML);	

	gcString complete;
	XML::GetChild("complete", complete, mNode);

	if (complete == "1")
		throw gcException(ERR_COMPLETED);

	XML::GetChild("date", info.szDate, mNode);
	XML::GetChild("filehash", info.szHash, mNode);
	XML::GetChild("filesize", info.size, mNode);
	XML::GetChild("filesizeup", info.upsize, mNode);
}
Beispiel #3
0
void WebCoreClass::resumeUpload(DesuraId id, const char* key, WebCore::Misc::ResumeUploadInfo &info)
{
	XML::gcXMLDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["action"] = "resumeupload";
	post["key"] = key;

	auto uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc);
	auto iNode = uNode.FirstChildElement("mcf");

	if (!iNode.IsValid())
		throw gcException(ERR_BADXML);	

	gcString complete;
	iNode.GetChild("complete", complete);

	if (complete == "1")
		throw gcException(ERR_COMPLETED);

	iNode.GetChild("date", info.szDate);
	iNode.GetChild("filehash", info.szHash);
	iNode.GetChild("filesize", info.size);
	iNode.GetChild("filesizeup", info.upsize);
}
Beispiel #4
0
void WebCoreClass::newUpload(DesuraId id, const char* hash, uint64 fileSize, char **key)
{
	gcString size("{0}", fileSize);

	XML::gcXMLDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["action"] = "newupload";
	post["filehash"] = hash;
	post["filesize"] = size;

	auto uNode = postToServer(getMcfUploadUrl(), "itemupload", post, doc);
	auto iNode = uNode.FirstChildElement("mcf");
	
	if (!iNode.IsValid())
		throw gcException(ERR_BADXML);	

	if (key)
	{
		const std::string text = iNode.GetAtt("key");

		if (text.empty())
			throw gcException(ERR_BADXML);	

		Safe::strcpy(key, text.c_str(), text.size());
	}
}
Beispiel #5
0
void MCF::setHeader(DesuraId id, MCFBranch branch, MCFBuild build)
{
	assert(m_sHeader);
	m_sHeader->setBranch(branch);
	m_sHeader->setType(id.getType());
	m_sHeader->setBuild(build);
	m_sHeader->setId(id.getItem());
}
bool UpdateThreadOld::pollUpdates()
{
	if (!m_pWebCore || !m_pUser)
		return false;

	updateBuildVer();

	std::map<std::string, std::string> post;

#ifdef DESURA_NONGPL_BUILD
	post["appid"] = gcString("{0}", m_iAppId);
	post["build"] = gcString("{0}", m_iAppVersion);
#endif

	for (uint32 x=0; x< m_pUser->getItemManager()->getCount(); x++)
	{
		UserCore::Item::ItemInfoI* item = m_pUser->getItemManager()->getItemInfo(x);

		if (!item)
			continue;

		if (!(item->getStatus() & UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER) || (item->getStatus()&UserCore::Item::ItemInfoI::STATUS_ONACCOUNT))
			continue;

		DesuraId id = item->getId();

		if (id.getType() == DesuraId::TYPE_LINK)
			continue;

		gcString key("updates[{0}][{1}]", id.getTypeString().c_str(), id.getItem());
		post[key] = "1";
	}

	TiXmlDocument doc;

	try
	{
		m_pWebCore->getUpdatePoll(doc, post);
	}
	catch (gcException &e)
	{
		Warning(gcString("Update poll failed: {0}\n", e));
		return false;
	}

	parseXML(doc);

#ifdef WIN32
	checkFreeSpace();
#endif

	m_hHttpHandle->cleanPostInfo();
	m_hHttpHandle->cleanUp();
	m_hHttpHandle->clearCookies();

	return true;
}
Beispiel #7
0
void MCF::setHeader(DesuraId id, MCFBranch branch, MCFBuild build)
{
	if (!m_sHeader)
		m_sHeader = new MCFCore::MCFHeader();

	m_sHeader->setBranch(branch);
	m_sHeader->setType(id.getType());
	m_sHeader->setBuild(build);
	m_sHeader->setId(id.getItem());
}
Beispiel #8
0
void WebCoreClass::updateAccountItem(DesuraId id, bool add)
{
	TiXmlDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["action"] = add?"add":"delete";

	postToServer(getUpdateAccountUrl(), "iteminstall", post, doc);
}
Beispiel #9
0
void WebCoreClass::getDownloadProviders(DesuraId id, XML::gcXMLDocument &xmlDocument, MCFBranch mcfBranch, MCFBuild mcfBuild)
{
	PostMap postData;

	postData["siteareaid"] = id.getItem();
	postData["sitearea"] = id.getTypeString();
	postData["branch"] = (size_t) mcfBranch;

	if (mcfBuild != 0)
		postData["build"] = (size_t) mcfBuild;

	postToServer(getMCFDownloadUrl(), "itemdownloadurl", postData, xmlDocument);
}
Beispiel #10
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;
	}
}
Beispiel #11
0
void WebCoreClass::getItemInfo(DesuraId id, TiXmlDocument &doc, MCFBranch mcfBranch, MCFBuild mcfBuild)
{
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();

	if (mcfBuild != 0)
		post["build"] = mcfBuild;

	if (mcfBranch != 0)
	{
		if (mcfBranch.isGlobal())
			post["branchglobal"] = mcfBranch;
		else
			post["branch"] = mcfBranch;
	}

	postToServer(getItemInfoUrl(), "iteminfo", post, doc);
}
Beispiel #12
0
bool CDKInfo::checkForArma(DesuraId id, const char* key)
{
	if (id.getType() != DesuraId::TYPE_GAME)
		return false;

	size_t x=0; 

	while (g_CDKeySpecial[x].item)
	{
		if (g_CDKeySpecial[x].item == id.getItem())
		{
			unsigned char binkey[255] = {0};
			DecodeMsgAMAR2CDKey(binkey, key);

			GetUserCore()->updateBinaryRegKey(g_CDKeySpecial[x].reg, (char*)binkey, 15);
			break;
		}

		x++;
	};

	if (g_CDKeySpecial[x].item == 14558 || g_CDKeySpecial[x].item == 0) //take on heli needs the cd key to be entered as well
		return false;

	if (m_bLaunch)
	{
		wxCommandEvent e(wxEVT_NULL, m_butLaunch->GetId());
		onButtonClicked(e);
		GetParent()->Close();
	}
	else
	{
		m_tbCdKey->SetLabel(Managers::GetString(L"#CDK_REGKEY"));
		m_tbCdKey->SetToolTip(Managers::GetString(L"#CDK_REGKEY_TOOLTIP"));
		m_imgCopyPart->Disable();
		m_imgCopyAll->Disable();
	}

	return true;
}
Beispiel #13
0
gcString WebCoreClass::getCDKey(DesuraId id, MCFBranch branch)
{
	TiXmlDocument doc;
	PostMap post;

	post["siteareaid"] = id.getItem();
	post["sitearea"] = id.getTypeString();
	post["branch"] = (size_t)branch;
	
#ifdef WIN32
	post["token"] =  UTIL::WIN::getRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\MachineGuid", true);
#else
	post["token"] = "todo";
#endif

	TiXmlNode* root = postToServer(getCDKeyUrl(), "cdkey", post, doc);
	TiXmlElement* key = root->FirstChildElement("key");

	if (!key)
		throw gcException(ERR_BADXML);

	return key->GetText();
}
Beispiel #14
0
void MCF::getDownloadProviders(const char* url, MCFCore::Misc::UserCookies *pCookies, bool *unauthed, bool local)
{
	if (!pCookies)
		throw gcException(ERR_INVALID, "Cookies are null (getDownloadProviders)");

	HttpHandle wc(url);
	pCookies->set(wc);


	DesuraId id = m_sHeader->getDesuraId();
	gcString type = id.getTypeString();

	wc->addPostText("siteareaid", id.getItem());
	wc->addPostText("sitearea", type.c_str());
	wc->addPostText("branch", m_sHeader->getBranch());

	MCFBuild build = m_sHeader->getBuild();

	if (build != 0)
		wc->addPostText("build", build);

	if (local)
		wc->addPostText("local", "yes");


	wc->postWeb();

	if (wc->getDataSize() == 0)
		throw gcException(ERR_BADRESPONSE);
	
	TiXmlDocument doc;

	doc.SetCondenseWhiteSpace(false);
	XML::loadBuffer(doc, const_cast<char*>(wc->getData()), wc->getDataSize());

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

	if (!uNode)
		throw gcException(ERR_BADXML);

	TiXmlNode* sNode = uNode->FirstChild("status");

	if (!sNode)
		throw gcException(ERR_BADXML);

	uint32 status = 0;
	TiXmlElement* sEl = sNode->ToElement();
	if (sEl)
	{
		const char* statStr = sEl->Attribute("code");
		if (statStr)
			status = atoi(statStr);
		else
			throw gcException(ERR_BADXML);
	}
	else
	{
		throw gcException(ERR_BADXML);
	}

	if (status != 0)
		throw gcException(ERR_BADSTATUS, status, gcString("Status: {0}", sEl->GetText()));

	TiXmlNode* iNode = uNode->FirstChild("item");

	if (!iNode)
	{
		throw gcException(ERR_BADXML);
	}

	TiXmlNode* mNode = iNode->FirstChild("mcf");

	if (!mNode)
	{
		throw gcException(ERR_BADXML);
	}

	TiXmlElement *melNode = mNode->ToElement();

	if (melNode)
	{
		const char* build = melNode->Attribute("build");
		const char* branch = melNode->Attribute("branch");

		//Debug(gcString("MCF: R: {0}.{1} G: {2}.{3}\n", m_sHeader->getBranch(), m_sHeader->getBuild(), build, branch));

		if (build)
			m_sHeader->setBuild(MCFBuild::BuildFromInt(atoi(build)));

		if (branch)
			m_sHeader->setBranch(MCFBranch::BranchFromInt(atoi(branch)));
	}
	
	safe_delete(m_pFileAuth);
	
	char *szAuthCode = NULL;
	XML::GetChild("authhash", szAuthCode, mNode);
	if (!szAuthCode)
		throw gcException(ERR_BADXML);

	m_pFileAuth = new Misc::GetFile_s;
	memset(m_pFileAuth, 0, sizeof(Misc::GetFile_s));

	Safe::strncpy(m_pFileAuth->authhash, 33, szAuthCode, 33);

	char buff[10];
	Safe::snprintf(buff, 10, "%d", pCookies->getUserId());
	size_t size = Safe::strlen(buff, 10);
	
	memcpy(m_pFileAuth->authkey, buff, size);
	safe_delete(szAuthCode);

	TiXmlNode* urlNode = mNode->FirstChild("urls");

	if (!urlNode)
		throw gcException(ERR_BADXML);

	char * szAuthed = NULL;
	XML::GetChild("authed", szAuthed, mNode);

	if (unauthed && szAuthed)
	{
		*unauthed = (atoi(szAuthed) == 0);
	}

	safe_delete(szAuthed);


#ifdef DEBUG
#if 0
	m_vProviderList.clear();
	m_vProviderList.push_back(new MCFCore::Misc::DownloadProvider("localhost", "mcf://10.0.0.121:62001", "", ""));
	return;
#endif
#endif

	TiXmlElement* pChild = urlNode->FirstChildElement("url");
	while (pChild)
	{
		MCFCore::Misc::DownloadProvider* temp = new MCFCore::Misc::DownloadProvider(pChild);
		m_vProviderList.push_back(temp);
		pChild = pChild->NextSiblingElement();
	}

	if (m_vProviderList.size() == 0)
		throw gcException(ERR_ZEROSIZE);
}
Beispiel #15
0
void ItemForm::showParentNoRunPrompt(DesuraId id)
{
	LinkArgs existing;

	if (!m_vArgs.empty())
		existing = m_vArgs.back();

	g_pMainApp->handleInternalLink(m_ItemId, ACTION_PROMPT, FormatArgs(existing, "prompt=needtorunfirst", gcString("parentid={0}", id.getItem())));
}