void BranchInstallInfo::extractInstallChecks(const XML::gcXMLElement &icsNode, gcRefPtr<WildcardManager> &pWildCard, std::vector<InsCheck> &vInsChecks)
{
	icsNode.for_each_child("installlocation", [&vInsChecks, pWildCard, this](const XML::gcXMLElement &icNode)
	{
		const gcString iCheck = icNode.GetChild("check");
		const gcString iPath = icNode.GetChild("path");

		if (iCheck.empty() || iPath.empty())
			return;

		try
		{
			gcString strCheckRes = pWildCard->constructPath(iCheck.c_str());

			if (isInstalled())
			{
				if (!updateInstallCheck(strCheckRes, iPath))
					return;

				vInsChecks.push_back(InsCheck(strCheckRes.c_str(), m_szPath.c_str()));
			}
			else
			{
				vInsChecks.push_back(InsCheck(strCheckRes.c_str(), iPath.c_str()));
			}
		}
		catch (...)
		{
		}
	});
}
	gcString GetWildcardPath(gcString wildcard)
	{
#ifdef WIN32
		if (Safe::stricmp("PROGRAM_FILES", wildcard.c_str()) == 0)
		{
			wchar_t path[MAX_PATH]  = {0};
			SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, path);
			return path;
		}
		else if (Safe::stricmp("DOCUMENTS", wildcard.c_str()) == 0)
		{
			return GetSpecialPath(1);
		}
		else if (Safe::stricmp("JAVA_PATH", wildcard.c_str()) == 0)
		{
			std::string cur = UTIL::WIN::getRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\CurrentVersion");

			if (cur.size() > 0)
				return UTIL::WIN::getRegValue(gcString("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\{0}\\JavaHome", cur));
		}
		else if (Safe::stricmp("APP_DATA", wildcard.c_str())==0)
		{
			wchar_t path[MAX_PATH]  = {0};
			SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
			return path;
		}
		else if (Safe::stricmp("USER_APP_DATA", wildcard.c_str())==0)
		{
			return GetSpecialPath(2);
		}
#endif
		return "";
	}
Beispiel #3
0
void DesuraJSSettings::setValue(gcString name, gcString val)
{
	CVar* cvar = GetCVarManager()->findCVar(name.c_str());

	if (cvar && val != gcString(cvar->getString()))
		cvar->setValue(val.c_str());
}
Beispiel #4
0
gcString DesuraJSBinding::getThemeColor(gcString name, gcString id)
{
	Color col = GetGCThemeManager()->getColor(name.c_str(), id.c_str());

	char colStr[255];
	Safe::snprintf(colStr, 255, (char*)"#%02X%02X%02X", col.red, col.green, col.blue);

	return gcString(colStr);
}
Beispiel #5
0
void gcWebControl::loadUrl(const gcString& url)
{
	if (m_szHomeUrl == L"about:blank")
		m_szHomeUrl = url;

	m_pChromeBrowser->loadUrl(url.c_str());
}
Beispiel #6
0
void CDKProgress::onComplete(gcString& cdKey)
{
	CDKeyForm* keyForm = dynamic_cast<CDKeyForm*>(GetParent());

	if (keyForm)
		keyForm->finish(cdKey.c_str());
}
Beispiel #7
0
bool VSCheckMcf::checkMcf(gcString path)
{
	if (isStopped())
		return false;

	if (!UTIL::FS::isValidFile(UTIL::FS::PathWithFile(path)))
		return false;

	//read file to make sure it is what it says it is
	m_hTempMcf->setFile(path.c_str());

	try
	{
		m_hTempMcf->parseMCF();
	}
	catch (gcException &except)
	{
		Warning("Verify - MCF Error: {0}\n", except);
		return false;
	}

	if (isStopped())
		return false;

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

	bool res = (mcfHead && mcfHead->getBuild() == getMcfBuild());

	m_hTempMcf = McfHandle();
	return res;
}
Beispiel #8
0
gcString DesuraJSSettings::getValue(gcString name)
{
	CVar* cvar = GetCVarManager()->findCVar(name.c_str());
	if (!cvar)
		return "";

	return cvar->getExitString();
}
Beispiel #9
0
gcString DesuraJSBinding::getCVarValue(gcString name)
{
	auto cvar = GetCVarManager()->findCVar(name.c_str());

	if (!cvar)
		return "";

	return cvar->getString();
}
Beispiel #10
0
void DownloadTask::onComplete(gcString &savePath)
{
	bool hasError = m_bInError || isStopped();

	if (m_bToolDownloadComplete)
	{
		getUserCore()->getToolManager()->removeTransaction(m_ToolTTID, hasError);
		m_ToolTTID = UINT_MAX;
	}

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

	onCompleteStrEvent(savePath);

	if (getItemInfo()->getCurrentBranch()->isPreOrder())
	{
		getItemInfo()->addSFlag(UserCore::Item::ItemInfoI::STATUS_PRELOADED);
		getItemInfo()->delSFlag(UserCore::Item::ItemInfoI::STATUS_DOWNLOADING);
		getItemHandle()->getInternal()->completeStage(true);
	}
	else if (m_ToolTTID != UINT_MAX)
	{
		UserCore::Misc::ToolTransaction* tt = new UserCore::Misc::ToolTransaction();
		getUserCore()->getToolManager()->updateTransaction(m_ToolTTID, tt);

		getItemHandle()->getInternal()->goToStageDownloadTools(m_ToolTTID, savePath.c_str(), getMcfBranch(), getMcfBuild());
	}
	else
	{
		//mirrored in download tool item task. Make sure to update it as well
		if (HasAllFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX))
		{
			getItemHandle()->getInternal()->goToStageInstallComplex(getMcfBranch(), getMcfBuild());
		}
		else
		{
			getItemHandle()->getInternal()->goToStageInstall(savePath.c_str(), getMcfBranch());
		}
	}
}
Beispiel #11
0
gcRefPtr<UserCore::Item::ItemInfoI> DesuraJSBinding::getItemInfoFromId(gcString szId)
{
	auto im = getItemManager();

	if (!im)
		return nullptr;

	DesuraId id(Safe::atoll(szId.c_str()));
	return im->findItemInfo(id);
}
Beispiel #12
0
void MCFManager::getListOfBadMcfPaths(const gcString &szItemDb, std::vector<MigrateInfo> &delList, std::vector<MigrateInfo> &updateList)
{
	try
	{
		sqlite3x::sqlite3_connection db(szItemDb.c_str());
		getListOfBadMcfPaths(db, delList, updateList);
	}
	catch (std::exception &)
	{
	}
}
Beispiel #13
0
void DesuraJSBinding::setCacheValue(gcString name, gcString value)
{
	gcString fullname("WEBCACHE_{0}", name);
	auto cvar = GetCVarManager()->findCVar(fullname.c_str());

	if (!cvar)
	{
		cvar = gcRefPtr<CVar>::create(fullname.c_str(), "", CFLAG_USER);
		g_pCvarList.push_back(cvar);
	}

	cvar->setValue(value.c_str());
}
Beispiel #14
0
gcString DesuraJSBinding::getThemeImage(gcString id)
{
	gcString img = GetGCThemeManager()->getImage(id.c_str());
	gcString path = GetGCThemeManager()->getThemeFolder();

	size_t pos = img.find(path);
	if (pos != std::string::npos)
	{
		img = gcString(".") + img.substr(pos + path.size(), -1);
	}

	return img;
}
Beispiel #15
0
void DesuraJSLinks::loadUrl(int32 tabId, gcString url)
{
	if (tabId == -1)
		return;
	
	if (tabId >= END_PAGE || tabId != ITEMS)
		return;
	
	if (url.size() == 0)
		return;

	g_pMainApp->loadUrl(url.c_str(), (PAGE)tabId);
}
Beispiel #16
0
void ToolManager::addJSTool(UserCore::Item::ItemInfo* item, uint32 branchId, gcString name, gcString exe, gcString args, gcString res)
{
	if (!item)
		return;

	UserCore::Item::BranchInfoI* branch = item->getBranchById(branchId);

	if (!branch)
		return;

	UserCore::Item::BranchInfo* realBranch = dynamic_cast<UserCore::Item::BranchInfo*>(branch);

	if (!realBranch)
		return;

	bool found = false;


	JSToolInfo* jsinfo = nullptr;

	BaseManager<ToolInfo>::for_each([&](ToolInfo* info)
	{
		auto temp = dynamic_cast<JSToolInfo*>(info);

		if (!temp)
			return;

		if (item->getId() == temp->getItemId() && name == info->getName() && temp->getBranchId() == branchId)
		{
			jsinfo = temp;
			found = true;
		}
	});

	if (found)
	{
		if (!jsinfo->isRealyInstalled())
			jsinfo->setExePath(exe.c_str());

		return;
	}


	DesuraId toolId(m_iLastCustomToolId, DesuraId::TYPE_TOOL);
	m_iLastCustomToolId--;

	JSToolInfo* tool = new JSToolInfo(item->getId(), realBranch->getBranchId(), toolId, name, exe, args, res);
	realBranch->addJSTool(toolId);
	addItem(tool);
}
void ToolManager::addJSTool(gcRefPtr<UserCore::Item::ItemInfo> item, uint32 branchId, gcString name, gcString exe, gcString args, gcString res)
{
	if (!item)
		return;

	auto branch = item->getBranchById(branchId);

	if (!branch)
		return;

	auto realBranch = gcRefPtr<UserCore::Item::BranchInfo>::dyn_cast(branch);

	if (!realBranch)
		return;

	bool found = false;


	gcRefPtr<JSToolInfo> jsinfo;

	BaseManager<ToolInfo>::for_each([&](gcRefPtr<ToolInfo> info)
	{
		auto temp = gcRefPtr<JSToolInfo>::dyn_cast(info);

		if (!temp)
			return;

		if (item->getId() == temp->getItemId() && name == info->getName() && temp->getBranchId() == branchId)
		{
			jsinfo = temp;
			found = true;
		}
	});

	if (found)
	{
		if (!jsinfo->isRealyInstalled())
			jsinfo->setExePath(exe.c_str());

		return;
	}


	DesuraId toolId(m_iLastCustomToolId, DesuraId::TYPE_TOOL);
	m_iLastCustomToolId--;

	auto tool = gcRefPtr<JSToolInfo>::create(item->getId(), realBranch->getBranchId(), toolId, name, exe, args, res);
	realBranch->addJSTool(toolId);
	addItem(tool);
}
void CreateProgPage::onComplete(gcString& path)
{
	gcFrame* par = dynamic_cast<gcFrame*>(GetParent());
	gcException eFailCrtMCF(ERR_BADPATH, "Failed to create MCF");
	if (par)
		par->setProgressState(gcFrame::P_NONE);

	if (UTIL::FS::isValidFile(UTIL::FS::PathWithFile(path)))
	{
		CreateMCFForm* temp = dynamic_cast<CreateMCFForm*>(GetParent());

		if (temp)
			temp->showOverView(path.c_str());
	}
	else
	{
		onError(eFailCrtMCF);
	}
}
Beispiel #19
0
bool FileSystemJSBinding::WriteFile(int32 handle, gcString string)
{
	if (handle < 0 || handle > (int32)m_vFileHandles.size())
		return false;

	auto fh = m_vFileHandles[handle];

	try
	{
		fh->write(string.c_str(), string.size());
		return true;
	}
	catch (gcException &e)
	{
		Warning("Failed to write to file in scriptcore: {0}\n", e);
	}

	return false;
}
Beispiel #20
0
bool DesuraJSSettings::isValidLinkBinary(gcString path)
{
	if (!UTIL::FS::isValidFile(path))
		return false;

#ifdef WIN32
	return (path.find_last_of(".exe") == path.size()-1);
#else
	char magicBytes[5] = {0};

	try
	{
		UTIL::FS::FileHandle fh(path.c_str(), UTIL::FS::FILE_READ);
		fh.read(magicBytes, 5);
	}
	catch (...)
	{
		return false;
	}

	return UTIL::LIN::getFileType(magicBytes, 5) != UTIL::LIN::BT_UNKNOWN;
#endif
}
Beispiel #21
0
const char* GetUICoreVersion()
{
	return g_szUICoreVersion.c_str();
}
Beispiel #22
0
bool CompressFile(gcString &filePath)
{
	uint64 fileSize = UTIL::FS::getFileSize(UTIL::FS::Path(filePath, "", true));

	if (fileSize == 0)
		return false;

	gcString destPath(filePath);
	destPath += ".bz2";

	try
	{
		UTIL::FS::FileHandle fhRead(filePath.c_str(), UTIL::FS::FILE_READ);
		UTIL::FS::FileHandle fhWrite(destPath.c_str(), UTIL::FS::FILE_WRITE);

		if (fhRead.isValidFile() == false)
			return false;

		if (fhWrite.isValidFile() == false)
			return false;

		UTIL::MISC::BZ2Worker worker(UTIL::MISC::BZ2_COMPRESS);

		char buff[10*1024];

		const size_t buffsize = 10*1024;
		uint32 leftToDo = (uint32)fileSize;

		bool end = false;

		do
		{
			size_t curSize = buffsize;

			if (buffsize > leftToDo)
			{
				end = true;
				curSize = leftToDo;
			}

			fhRead.read(buff, curSize);
			leftToDo -= curSize;
			worker.write(buff, curSize, end);

			worker.doWork();
			size_t b = 0;

			do
			{
				b = buffsize;
				worker.read(buff, b);
				fhWrite.write(buff, b);
			}
			while (b > 0);
		}
		while (!end);
	}
	catch (gcException)
	{
		return false;
	}

	UTIL::FS::delFile(UTIL::FS::Path(filePath, "", true));
	filePath = destPath;

	return true;
}
Beispiel #23
0
void DesuraControl::onNewAvatar(gcString& image)
{
	m_pAvatar->setDefaultImage(image.c_str());
	gc_lastavatar.setValue(image.c_str());
}
Beispiel #24
0
McfViewerForm::McfViewerForm(wxWindow* parent, gcString mcf) : gcFrame(parent, wxID_ANY, PRODUCT_NAME_CATW(L": Mcf Viewer"), wxDefaultPosition, wxSize(370,500), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
{
	Bind(wxEVT_COMMAND_BUTTON_CLICKED, &McfViewerForm::onButtonClicked, this); 
	Bind(wxEVT_CLOSE_WINDOW, &McfViewerForm::onClose, this);

	this->SetSizeHints( wxSize( 370,400 ), wxDefaultSize );
	
	wxStaticText* m_staticText26 = new wxStaticText( this, wxID_ANY, wxT("Item Id"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText27 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labId = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText14 = new wxStaticText( this, wxID_ANY, wxT("File Version"), wxDefaultPosition, wxSize( 80,-1 ), 0 );
	wxStaticText* m_staticText15 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labVersion = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText23 = new wxStaticText( this, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText24 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labType = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText16 = new wxStaticText( this, wxID_ANY, wxT("Build"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText17 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labMCFVers = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText18 = new wxStaticText( this, wxID_ANY, wxT("Flags"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText19 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labPatch = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText20 = new wxStaticText( this, wxID_ANY, wxT("Branch"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText21 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labBranch = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );

	m_tcFileTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxTR_DEFAULT_STYLE );

	m_butOpen = new gcButton(this, wxID_ANY, L"Open", wxDefaultPosition, wxSize(75,22));

	wxFlexGridSizer* fgSizer11;
	fgSizer11 = new wxFlexGridSizer( 20, 3, 0, 0 );
	fgSizer11->SetFlexibleDirection( wxBOTH );
	fgSizer11->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	fgSizer11->Add( m_staticText26, 0, 0, 5 );
	fgSizer11->Add( m_staticText27, 0, 0, 5 );
	fgSizer11->Add( m_labId, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText14, 0, 0, 5 );
	fgSizer11->Add( m_staticText15, 0, 0, 5 );
	fgSizer11->Add( m_labVersion, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText23, 0, 0, 5 );
	fgSizer11->Add( m_staticText24, 0, 0, 5 );
	fgSizer11->Add( m_labType, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText16, 0, 0, 5 );
	fgSizer11->Add( m_staticText17, 0, 0, 5 );
	fgSizer11->Add( m_labMCFVers, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText18, 0, 0, 5 );
	fgSizer11->Add( m_staticText19, 0, 0, 5 );
	fgSizer11->Add( m_labPatch, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText20, 0, 0, 5 );
	fgSizer11->Add( m_staticText21, 0, 0, 5 );
	fgSizer11->Add( m_labBranch, 0, wxLEFT, 5 );


	wxFlexGridSizer* fgSizer12;
	fgSizer12 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer12->AddGrowableCol( 0 );
	fgSizer12->AddGrowableRow( 0 );
	fgSizer12->SetFlexibleDirection( wxBOTH );
	fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );

	fgSizer12->Add( fgSizer11, 1, wxEXPAND, 7 );
	fgSizer12->Add( m_butOpen, 1, 0, 5 );

	wxFlexGridSizer* fgSizer10;
	fgSizer10 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer10->AddGrowableCol( 0 );
	fgSizer10->AddGrowableRow( 1 );
	fgSizer10->SetFlexibleDirection( wxBOTH );
	fgSizer10->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );

	fgSizer10->Add( fgSizer12, 1, wxEXPAND|wxALL, 7 );
	fgSizer10->Add( m_tcFileTree, 1, wxALL|wxEXPAND, 5 );
	
	this->SetSizer( fgSizer10 );
	this->Layout();

	Centre(wxBOTH);

	if (mcf.size() > 0)
		loadMcf(mcf.c_str());
}
Beispiel #25
0
bool StartUpload(DesuraId id)
{
	Msg("Starting Mcf Upload....\n");

	//start upload
	UserCore::Thread::MCFThreadI* pPrepThread = g_pUserHandle->getThreadManager()->newUploadPrepThread(id, g_strMcfOutPath.c_str());

	*pPrepThread->getErrorEvent() += delegate(&OnStartUploadError);
	*pPrepThread->getCompleteStringEvent() += delegate(&OnStartUploadComplete);

	pPrepThread->start();

	g_WaitCon.wait();

	return g_strUploadHash.size() != 0;
}
Beispiel #26
0
bool UploadMcf()
{
	Msg("Uploading Mcf....\n");

	//upload
	UserCore::Misc::UploadInfoThreadI* info = g_pUserHandle->getUploadManager()->findItem(g_strUploadHash.c_str());
	assert(info);

	*info->getUploadProgressEvent() += delegate(&OnUploadProgress);
	*info->getErrorEvent() += delegate(&OnUploadError);
	*info->getCompleteEvent() += delegate(&OnUploadComplete);

	if (info->isPaused())
		info->unpause();

	info->start();
	g_WaitCon.wait();

	return g_bUploadDone;
}
Beispiel #27
0
void UploadInfoPage::onResumeCompleteCB(gcString& file)
{
	onResumeComplete(file.c_str());
}
Beispiel #28
0
	bool isValid = UTIL::FS::isValidFile(path);

	if (!isValid)
		Warning(gcString("Theme {0} is not a valid theme file.\n", val));

	return isValid;
}

CVar gc_language("gc_language", "english", CFLAG_SAVEONEXIT, (CVarCallBackFn)&LangChanged);
CVar gc_theme("gc_theme", "default", CFLAG_SAVEONEXIT, (CVarCallBackFn)&ThemeChanged);


CONCOMMAND(cc_reloadlanguage, "reload_language")
{
	gcString lan("{0}{1}.xml", LANGFOLDER(), gc_language.getString());
	GetLanguageManager().loadFromFile(lan.c_str());
}


UserCore::UserThreadManagerI* GetThreadManager()
{
	if (GetUserCore())
		return GetUserCore()->getThreadManager();

	return nullptr;	
}

UserCore::UploadManagerI* GetUploadMng()
{
	if (GetUserCore())
		return GetUserCore()->getUploadManager();
Beispiel #29
0
void gcWebControl::executeJScript(const gcString& code)
{
	m_pChromeBrowser->executeJScript(code.c_str());
}
Beispiel #30
0
void gcWebControl::loadString(const gcString& string)
{
	m_pChromeBrowser->loadString(string.c_str());
}