Beispiel #1
0
int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
#ifdef DEBUG
    //BootLoaderUtil::WaitForDebugger();
#endif

#ifndef DEBUG
    MiniDumpGenerator miniDump;
    miniDump.showMessageBox(false);
#endif

    BootLoaderUtil::SetCurrentDir();

    if (!BootLoaderUtil::SetDllDir(".\\bin"))
        exit(-100);

    std::vector<std::string> out;
    UTIL::STRING::tokenize(gcString(lpCmdLine), out, " ");

    std::string userAgent;

    UTIL::STRING::base64_decode(out[2], [&userAgent](const unsigned char* buff, size_t size) -> bool
    {
        userAgent.append((const char*)buff, size);
        return true;
    });

    InitWebControl(out[1].c_str(), userAgent.c_str());

    {
        IPC::PipeServer pipeserver(out[0].c_str(), 1, true);

        pipeserver.onConnectEvent += delegate(&OnPipeConnect);
        pipeserver.onDisconnectEvent += delegate(&OnPipeDisconnect);

        pipeserver.start();

        g_WaitCond.wait(15);

        if (g_bClientConnected)
            g_WaitCond.wait();
    }

    ShutdownWebControl();
}
Beispiel #2
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 #3
0
bool CreateMcf(DesuraId id, std::string &strFolderPath)
{
	Msg("Creating Mcf....\n");

	UserCore::Thread::MCFThreadI* pThread = g_pUserHandle->getThreadManager()->newCreateMCFThread(id, strFolderPath.c_str());

	*pThread->getMcfProgressEvent() += delegate(&OnMCFCreateProgress);
	*pThread->getErrorEvent() += delegate(&OnMCFCreateError);
	*pThread->getCompleteStringEvent() += delegate(&OnMCFCreateComplete);

	pThread->start();
	safe_delete(pThread);

	g_WaitCon.wait();

	return g_strMcfOutPath.size() != 0;
}
Beispiel #4
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 #5
0
void OnUploadComplete(uint32& status)
{
	Msg("Upload complete\n");
	g_bUploadDone = true;
	g_WaitCon.notify();
}
Beispiel #6
0
void OnUploadError(gcException &e)
{
	Warning(gcString("Failed to upload of mcf: {0}", e));
	g_WaitCon.notify();
}
Beispiel #7
0
void OnStartUploadComplete(gcString &strHash)
{
	g_strUploadHash = strHash;
	g_WaitCon.notify();
}
Beispiel #8
0
void OnMCFCreateComplete(gcString &strPath)
{	
	Msg("Completed creating Mcf.\n");
	g_strMcfOutPath = strPath;
	g_WaitCon.notify();
}
Beispiel #9
0
void OnMCFCreateError(gcException &e)
{
	Warning(gcString("Failed to create mcf: {0}", e));
	g_WaitCon.notify();
}
Beispiel #10
0
void OnPipeConnect(uint32 &e)
{
    g_bClientConnected = true;
    g_WaitCond.notify();
}
Beispiel #11
0
void OnPipeDisconnect(uint32 &e)
{
    g_WaitCond.notify();
}