Exemplo n.º 1
0
bool CCheckForUpdatesDlg::Download(CString filename)
{
	CString destFilename = GetDownloadsDirectory() + filename;
	if (PathFileExists(destFilename))
	{
		if (VerifySignature(destFilename))
			return true;
		else
			DeleteFile(destFilename);
	}

	CBSCallbackImpl bsc(this->GetSafeHwnd(), m_eventStop);

	CString url = m_sFilesURL + filename;

	m_progress.SetRange32(0, 1);
	m_progress.SetPos(0);
	m_progress.ShowWindow(SW_SHOW);

	CString tempfile = CTempFiles::Instance().GetTempFilePath(true).GetWinPathString();
	HRESULT res = URLDownloadToFile(NULL, url, tempfile, 0, &bsc);
	if (res == S_OK)
	{
		if (VerifySignature(tempfile))
		{
			if (PathFileExists(destFilename))
				DeleteFile(destFilename);
			MoveFile(tempfile, destFilename);
			return true;
		}
	}
	return false;
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// static member function - the controlling function for the worker thread
// pParam: DOWNLOADPARAM *
//		   {
//			   HWND hWnd - IN				the window handle to display status
//			   HANDLE hEventStop - IN		the event object to signal to stop
//			   CString strURL - IN			the URL of the file to be downloaded
//			   CString strFileName - OUT	the filename of the downloaded file
//		   }
// return value: not used
UINT AsyncDownloader::Download(LPVOID pParam)
{
	DOWNLOADPARAM *const pDownloadParam = static_cast<DOWNLOADPARAM *>(pParam);
	ASSERT_POINTER(pDownloadParam, DOWNLOADPARAM);

	ASSERT(::IsWindow(pDownloadParam->hWnd));

	/*
		URLDownloadToCacheFile is a blocking function. Even though the data is
		downloaded asynchronously the function does not return until all the
		data is downloaded. If complete asynchronous downloading is desired,
		one of the other UOS functions, such as URLOpenStream, or perhaps
		general URL monikers would be more appropriate.
	*/

	::DeleteUrlCacheEntry(pDownloadParam->strURL);

	CBSCallbackImpl bsc(pDownloadParam->hWnd, pDownloadParam->hEventStop);

	const HRESULT hr = ::URLDownloadToCacheFile(NULL,
												pDownloadParam->strURL,
												pDownloadParam->strFileName.
													GetBuffer(MAX_PATH),
												URLOSTRM_GETNEWESTVERSION,
												0,
												&bsc);

	/*
		The resource from the cache is used for the second and subsequent
		calls to URLDownloadToCacheFile during the session of the program
		unless the following setting is selected, in which case, every call
		to URLDownloadToCacheFile downloads the resource from the Internet.

		Control Panel/Internet/General/Temporary Internet files/Settings/
		Check for newer versions of stored pages -> Every visit to the page
	*/

	// empty the filename string if failed or canceled
	pDownloadParam->strFileName.ReleaseBuffer(SUCCEEDED(hr) ? -1 : 0);

	TRACE(_T("URLDownloadToCacheFile ends: 0x%08lX\nCache file name: %s\n"),
		  hr, pDownloadParam->strFileName);

	// let the dialog box know it is done
	VERIFY(::PostMessage(pDownloadParam->hWnd, WM_USER_ENDDOWNLOAD, 0, 0));

	return 0;
}
Exemplo n.º 3
0
void PPInstance::HandleRequestGetUrl( void* data )
{
	HRESULT hr( S_OK );
    P3D_request *request = static_cast<P3D_request*>( data );
    if ( !request )
    {
        return;
    }
    int unique_id = request->_request._get_url._unique_id;
    const std::string &url = request->_request._get_url._url;
    CP3DActiveXCtrl* parent = static_cast<CP3DActiveXCtrl*> ( request->_instance->_user_data );

    if ( !parent )
    {
        return;
    }

    nout << "Handling P3D_RT_get_url request from " << url << "\n";
	{
		PPDownloadRequest p3dObjectDownloadRequest( parent->m_instance, request ); 
		PPDownloadCallback bsc( p3dObjectDownloadRequest );
		hr = ::URLOpenStream( parent->GetControllingUnknown(), url.c_str(), 0, &bsc );
	}
    P3D_result_code result_code = P3D_RC_done;
    if ( FAILED( hr ) )
    {
        nout << "Error handling P3D_RT_get_url request" << " :" << hr << "\n"; 
        result_code = P3D_RC_generic_error;
    }

    P3D_instance_feed_url_stream_ptr( 
        request->_instance, 
        request->_request._get_url._unique_id, 
        result_code, 
        0, 
        0, 
        (const void*)NULL, 
        0 
        );
    P3D_request_finish_ptr( request, true );
}
Exemplo n.º 4
0
// do the actual cleanup
void CompileRequest::Process(IManager* manager)
{
    wxString cmd;
    wxString errMsg;
    wxStringMap_t om;

    BuildSettingsConfig* bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get());
    BuildManager* bm(manager ? manager->GetBuildManager() : BuildManagerST::Get());
    clCxxWorkspace* w(manager ? manager->GetWorkspace() : clCxxWorkspaceST::Get());
    EnvironmentConfig* env(manager ? manager->GetEnv() : EnvironmentConfig::Instance());

    ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg);
    if(!proj) {
        AppendLine(_("Cant find project: ") + m_info.GetProject());
        return;
    }

    wxString pname(proj->GetName());
    // BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc"));
    BuilderPtr builder = bm->GetSelectedBuilder();
    if(m_fileName.IsEmpty() == false) {
        // we got a complie request of a single file
        cmd = m_preprocessOnly ?
                  builder->GetPreprocessFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName, errMsg) :
                  builder->GetSingleFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName);
    } else if(m_info.GetProjectOnly()) {

        switch(m_info.GetKind()) {
        case QueueCommand::kRebuild:
            cmd = builder->GetPORebuildCommand(m_info.GetProject(), m_info.GetConfiguration());
            break;
        default:
        case QueueCommand::kBuild:
            cmd = builder->GetPOBuildCommand(m_info.GetProject(), m_info.GetConfiguration());
            break;
        }

    } else {
        cmd = builder->GetBuildCommand(m_info.GetProject(), m_info.GetConfiguration());
    }

    // Notify plugins that a compile process is going to start
    clBuildEvent event(wxEVT_BUILD_STARTING);
    event.SetProjectName(pname);
    event.SetConfigurationName(m_info.GetConfiguration());

    if(EventNotifier::Get()->ProcessEvent(event)) {

        // the build is being handled by some plugin, no need to build it
        // using the standard way
        return;
    }

    // Send the EVENT_STARTED : even if this event is sent, next event will
    // be post, so no way to be sure the the build process has not started
    SendStartMsg();

    // if we require to run the makefile generation command only, replace the 'cmd' with the
    // generation command line
    BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
    if(m_premakeOnly && bldConf) {
        BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
        if(bldConf) {
            cmd = bldConf->GetMakeGenerationCommand();
        }
    }

    if(bldConf) {
        wxString cmpType = bldConf->GetCompilerType();
        CompilerPtr cmp = bsc->GetCompiler(cmpType);
        if(cmp) {
            // Add the 'bin' folder of the compiler to the PATH environment variable
            wxString scxx = cmp->GetTool("CXX");
            scxx.Trim().Trim(false);
            scxx.StartsWith("\"", &scxx);
            scxx.EndsWith("\"", &scxx);
            // Strip the double quotes
            wxFileName cxx(scxx);
            wxString pathvar;
            pathvar << cxx.GetPath() << clPATH_SEPARATOR;
            
            // If we have an additional path, add it as well
            if(!cmp->GetPathVariable().IsEmpty()) {
                pathvar << cmp->GetPathVariable() << clPATH_SEPARATOR;
            }
            pathvar << "$PATH";
            om["PATH"] = pathvar;
        }
    }

    if(cmd.IsEmpty()) {
        // if we got an error string, use it
        if(errMsg.IsEmpty() == false) {
            AppendLine(errMsg);
        } else {
            AppendLine(_("Command line is empty. Build aborted."));
        }
        return;
    }

    WrapInShell(cmd);
    DirSaver ds;

    DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false);

    // expand the variables of the command
    cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), m_fileName);

    // print the build command
    AppendLine(cmd + wxT("\n"));
    if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) {
        // set working directory
        DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false);
    }

    // print the prefix message of the build start. This is important since the parser relies
    // on this message
    if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) {
        wxString configName(m_info.GetConfiguration());

        // also, send another message to the main frame, indicating which project is being built
        // and what configuration
        wxString text;
        text << wxGetTranslation(BUILD_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]");
        if(m_fileName.IsEmpty()) {
            text << wxT("----------\n");
        } else if(m_preprocessOnly) {
            text << wxT(" (Preprocess Single File)----------\n");
        } else {
            text << wxT(" (Single File Build)----------\n");
        }
        AppendLine(text);
    }

    EnvSetter envir(env, &om, proj->GetName());
    m_proc = CreateAsyncProcess(this, cmd);
    if(!m_proc) {
        wxString message;
        message << _("Failed to start build process, command: ") << cmd << _(", process terminated with exit code: 0");
        AppendLine(message);
        return;
    }
}
Exemplo n.º 5
0
//do the actual cleanup
void CleanRequest::Process(IManager *manager)
{
    wxString cmd;
    wxString errMsg;
    wxStringMap_t om;

    BuildSettingsConfig *bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get());
    BuildManager *       bm(manager ? manager->GetBuildManager() : BuildManagerST::Get());
    Workspace *          w(manager ? manager->GetWorkspace() : WorkspaceST::Get());


    ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg);
    if (!proj) {
        AppendLine(_("Cant find project: ") + m_info.GetProject());
        return;
    }
    wxString             pname (proj->GetName());

    //BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc"));
    BuilderPtr builder = bm->GetSelectedBuilder();
    if (m_info.GetProjectOnly()) {
        cmd = builder->GetPOCleanCommand(m_info.GetProject(), m_info.GetConfiguration());
    } else {
        cmd = builder->GetCleanCommand(m_info.GetProject(), m_info.GetConfiguration());
    }

    if ( cmd.IsEmpty() ) {
        AppendLine(_("Sorry, there is no 'Clean' command available\n"));
        return;
    }

    BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
    if(bldConf) {
        wxString cmpType = bldConf->GetCompilerType();
        CompilerPtr cmp = bsc->GetCompiler(cmpType);
        if(cmp) {
            wxString value( cmp->GetPathVariable() );
            if(value.Trim().Trim(false).IsEmpty() == false) {
                wxLogMessage(wxString::Format(wxT("Setting PATH to '%s'"), value.c_str()));
                om[wxT("PATH")] = value.Trim().Trim(false);
            }
        }
    } else {
        AppendLine(_("Sorry, couldn't find the Build configuration\n"));
        return;
    }

    // Notify plugins that a compile process is going to start
    clBuildEvent event(wxEVT_BUILD_STARTING);
    event.SetProjectName( pname );
    event.SetConfigurationName( m_info.GetConfiguration() );
    
    if (EventNotifier::Get()->ProcessEvent(event)) {
        // the build is being handled by some plugin, no need to build it
        // using the standard way
        return;
    }
    
    SendStartMsg();
    // Expand the variables of the command
    cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), wxEmptyString);
    WrapInShell(cmd);
    DirSaver ds;
    DoSetWorkingDirectory(proj, false, false);

    if (m_info.GetProjectOnly() ) {
        //need to change directory to project dir
        wxSetWorkingDirectory(proj->GetFileName().GetPath());
    }
    //print the build command
    AppendLine(cmd + wxT("\n"));

    // print the prefix message of the build start. This is important since the parser relies
    // on this message
    if(m_info.GetProjectOnly()) {
        wxString configName(m_info.GetConfiguration());

        //also, send another message to the main frame, indicating which project is being built
        //and what configuration
        wxString text;
        text << wxGetTranslation(CLEAN_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]");
        text << wxT("----------\n");
        AppendLine(text);
    }

    //apply environment settings
    EnvSetter env(NULL, &om, proj->GetName());
    m_proc = CreateAsyncProcess(this, cmd);
    if ( !m_proc ) {

        //remove environment settings applied
        wxString message;
        message << _("Failed to start clean process, command: ") << cmd << _(", process terminated with exit code: 0");
        AppendLine(message);
        return;
    }
}
Exemplo n.º 6
0
int		main(int ac, char **av)
{
  if (ac < 2)
    return (my_puterror(USAGE));
  return (bsc(av), ac);
}
Exemplo n.º 7
0
int main(int argc, char** argv)
{
    if (argc < 2)
    {
        fprintf(stderr, "%s <size of cache, log2> <taskgraph>\n", argv[0]);
        return 1;
    }
    
    #if 0
    if (argc == 3)
    {
        SimpleCacheBackend* bsc = new SimpleCacheBackend(atoi(argv[1]), 2, 1);
        contech::SimpleBackendWrapper* sbw = new contech::SimpleBackendWrapper(argv[2], bsc);
        
        sbw->runBackend();
        sbw->completeRun(stdout);
        delete sbw;
        delete bsc;
    }
    else
    {
        for (int c = 10; c <= 28; c++)
        {
            SimpleCacheBackend* bsc = new SimpleCacheBackend(c, 2, 0);
            contech::SimpleBackendWrapper* sbw = new contech::SimpleBackendWrapper(argv[1], bsc);
        
            sbw->runBackend();
            sbw->completeRun(stdout);
            delete sbw;
            delete bsc;
        }
    }
    
    #endif
    if (argc == 3)
    {
        TraceWrapper* tw = new TraceWrapper(argv[2]);
        SimpleCacheBackend* bsc = new SimpleCacheBackend(atoi(argv[1]), 2, 1);
        MemReqContainer mrc;
        
        while (tw->getNextMemoryRequest(mrc))
        {
            bsc->updateBackend(mrc);
        }
        
        bsc->completeBackend(stdout, tw->tg->getTaskGraphInfo());
        delete bsc;
        delete tw;
    }
    else
    {
        for (int c  = 10; c <= 28; c++)
        {
            TraceWrapper tw(argv[1]);
            SimpleCacheBackend bsc(c, 2, 0);
            
            MemReqContainer mrc;
            while (tw.getNextMemoryRequest(mrc))
            {
                bsc.updateBackend(mrc);
            }
            
            bsc.completeBackend(stdout, tw.tg->getTaskGraphInfo());
            fflush(stdout);
        }
    
        #if 0
        TraceWrapper* tw;
        
        MemReqContainer mrc;
        int c_start = 10, c_end = 29, c_pt;
        
        while (c_start < c_end)
        {
            vector<SimpleCacheBackend*> scbv;
            tw = new TraceWrapper(argv[1]);
            
            c_pt = c_start + 2;
            if (c_pt > c_end) c_pt = c_end;
            
            for (int c = c_start; c < c_pt; c++)
            {
                //printf("", c);
                //fflush(stdout);
                SimpleCacheBackend* bsc = new SimpleCacheBackend(c, 2, 0);
                scbv.push_back(bsc);
            }
            
            while (tw->getNextMemoryRequest(mrc))
            {
                for (auto bsc : scbv)
                {
                    bsc->updateBackend(mrc);
                }
            }
            
            for (auto bsc : scbv)
            {
                bsc->completeBackend(stdout, tw->tg->getTaskGraphInfo());
                delete bsc;
            }
            fflush(stdout);
            
            c_start += 2;
            delete tw;
        }
        #endif
    }
    
    return 0;
}