void FileExplorerUpdater::ExecMain()
{
    m_exec_output.Empty();
    m_exec_proc=new wxProcess(this);
    m_exec_proc->Redirect();
    m_exec_mutex->Lock();
    m_exec_proc_id=wxExecute(m_exec_cmd,wxEXEC_ASYNC,m_exec_proc);
    if(m_exec_proc_id==0)
    {
        m_exec_cond->Signal();
        m_exec_mutex->Unlock();
        return;
    }
    m_exec_timer=new wxTimer(this,ID_EXEC_TIMER);
    m_exec_timer->Start(100,true);
}
Exemplo n.º 2
0
/* static */
wxProcess *wxProcess::Open(const wxString& cmd, int flags)
{
    wxASSERT_MSG( !(flags & wxEXEC_SYNC), wxT("wxEXEC_SYNC should not be used." ));
    wxProcess *process = new wxProcess(wxPROCESS_REDIRECT);
    long pid = wxExecute(cmd, flags, process);
    if( !pid )
    {
        // couldn't launch the process
        delete process;
        return NULL;
    }

    process->SetPid(pid);

    return process;
}
Exemplo n.º 3
0
void CPyProcess::Execute(const wxChar* cmd)
{
	if(redirect) {
		Redirect();
	}
	// make process group leader so Cancel kan terminate process including children
	m_pid = wxExecute(cmd, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER, this);
	if (!m_pid) {
	  wxLogMessage(_T("could not execute '%s'"),cmd);
	} else {
	  wxLogMessage(_T("starting '%s' (%d)"),cmd,m_pid);
	}
	if (redirect) {
		m_timer.Start(100);   //msec
	}
}
Exemplo n.º 4
0
void MyApp::OnFileMenu(wxCommandEvent &ev)
{
  switch (ev.GetId())
  {
    case wxMaximaFrame::menu_new_id:
    case ToolBar::tb_new:
    case wxMaxima::mac_newId:

      // Mac computers insist that all instances of a new application need to share
      // the same process. On all other OSes we create a separate process for each
      // window: This way if one instance of wxMaxima crashes all the other instances
      // are still alive.
#if defined __WXMAC__
      NewWindow();
#else
//      NewWindow();
      wxExecute(wxT("\"")+wxStandardPaths::Get().GetExecutablePath()+wxT("\""));
#endif
      break;
    case wxMaxima::mac_openId:
    {
      wxString file = wxFileSelector(_("Open"), wxEmptyString,
                                     wxEmptyString, wxEmptyString,
                                     _("wxMaxima document (*.wxm, *.wxmx)|*.wxm;*.wxmx"),
                                     wxFD_OPEN);
      if (file.Length() > 0)
        NewWindow(file);
    }
      break;
    case wxID_EXIT:
    {
      bool quit = true;
      std::list<wxMaxima *>::iterator it=m_topLevelWindows.begin();
      while(it != m_topLevelWindows.end())
      {
        if (!(*it)->Close())
        {
          quit = false;
          break;
        }
      }
      if (quit)
        wxExit();
    }
    break;
  }
}
Exemplo n.º 5
0
void NetstatPanel::OnStartTest(wxCommandEvent& event)
{
  if( !m_running )
    {
	  ((wxButton*)this->
	   FindWindow( wxID_NETSTAT_BUTTON_START ))->
	    SetLabel( wxT("Avbryt") );
	  this->m_TextOut->Clear();
	  this->SetCursor( *wxHOURGLASS_CURSOR );
	  
	  wxString cmd;

#ifdef WIN32
	  cmd = 
	    wxT("netstat -na ");
#endif

#ifdef MACOSX
	  cmd = 
	    wxT("netstat -nafinet");
#endif

	  m_running = true;

	  m_proc->Redirect();

	  if( wxExecute( cmd, wxEXEC_ASYNC, m_proc ) <= 0 )
	    {
	      this->m_TextOut->AppendText( wxT("Kommandot misslyckades\n") );
	      m_die = true;
	    }
	  
	  m_procIn = m_proc->GetInputStream(); 

	  if( !m_proc->IsInputOpened() ) {
	    wxMessageBox( wxT("Kunde inte starta netstat.") );
	    return;
	  }

	  m_timer->Start(1000);

    } // if running
  else
    {
      m_die = true;
    }
}
Exemplo n.º 6
0
void wxFormBuilder::DoLaunchWxFB(const wxString& file)
{
	wxString fbpath = GetWxFBPath();
	if (fbpath.IsEmpty()) {
		wxMessageBox(_("Failed to launch wxFormBuilder, no path specified\nPlease set wxFormBuilder path from Plugins -> wxFormBuilder -> Settings..."),
		             wxT("EmbeddedLite"), wxOK|wxCENTER|wxICON_WARNING);
		return;
	}
	ConfFormBuilder confData;
	m_mgr->GetConfigTool()->ReadObject(wxT("wxFormBuilder"), &confData);
	wxString cmd = confData.GetCommand();
	cmd.Replace(wxT("$(wxfb)"), fbpath);
	cmd.Replace(wxT("$(wxfb_project)"), wxString::Format(wxT("\"%s\""), file.c_str()));

	// Launch !
	wxExecute(cmd);
}
Exemplo n.º 7
0
void ExternalToolsPlugin::DoLaunchTool(const ToolInfo& ti)
{
	wxString command, working_dir;

	command << wxT("\"") << ti.GetPath() << wxT("\" ") << ti.GetArguments();
	working_dir = ti.GetWd();

	if (m_mgr->IsWorkspaceOpen()) {
		command     = m_mgr->GetMacrosManager()->Expand(command, m_mgr, m_mgr->GetSolution()->GetActiveProjectName());
		working_dir = m_mgr->GetMacrosManager()->Expand(working_dir, m_mgr, m_mgr->GetSolution()->GetActiveProjectName());
	}

	// check to see if we require to save all files before continuing
	if (ti.GetSaveAllFiles() && !m_mgr->SaveAll())
		return;

	if (ti.GetCaptureOutput() == false) {
		// change the directory to the requested working directory
		DirSaver ds;
		wxSetWorkingDirectory(working_dir);

		// apply environment
		EnvSetter envGuard(m_mgr->GetEnv());
		wxExecute(command);

	} else {
		// create a piped process
		if (m_pipedProcess && m_pipedProcess->IsBusy()) {
			// a process is already running
			return;
		}

		m_pipedProcess = new AsyncExeCmd(m_mgr->GetOutputWindow());

		DirSaver ds;
		EnvSetter envGuard(m_mgr->GetEnv());
		wxSetWorkingDirectory(working_dir);

		// hide console if any,
		// redirect output
		m_pipedProcess->Execute(command, true, true);
		if (m_pipedProcess->GetProcess()) {
			m_pipedProcess->GetProcess()->Connect(wxEVT_END_PROCESS, wxProcessEventHandler(ExternalToolsPlugin::OnProcessEnd), NULL, this);
		}
	}
}
Exemplo n.º 8
0
//Format and (optionally) execute command
bool ExecInput::FormatCommand(const GameType *gtype, const wxString &host, int port,
                              const wxString &password, const wxString &name, 
                              wxString *out, bool execute)
{
    wxString path, order, conn, pass, nm;
    wxString command;
 
    ReadExecOpts(gtype, &path, &order, &conn, &pass, &nm);
    
    if (path.IsEmpty() || order.IsEmpty() || conn.IsEmpty())
        return false;
        
    VarMap vmap, optmap;

    vmap["host"] = host;
    vmap["port"] = wxString::Format("%d", port);

    optmap["connect_opt"] = VarSubst(conn, vmap);
    

    if (!password.IsEmpty() && !pass.IsEmpty())
    {
        vmap["password"] = password;
        optmap["password_opt"] = VarSubst(pass, vmap);
    }
    
    if (!name.IsEmpty() && !nm.IsEmpty())
    {
        vmap["name"] = name;
        optmap["name_opt"] = VarSubst(nm, vmap);
    }

    wxFileName exec(path);
    exec.Normalize();
    
    wxSetWorkingDirectory(exec.GetPath());  
 
    command = exec.GetFullPath() + _T(" ") + VarSubst(order, optmap);
    if (out) 
        *out = command;
    
    if (execute)
        wxExecute(command);   
 
    return true;
}
Exemplo n.º 9
0
void DialogAbout::OnLeftDown( wxMouseEvent &event )
{
	if( event.m_x > 320 &&
		event.m_x < 400 &&
		event.m_y > 330 &&
		event.m_y < 354 )
	{
	  wxString strHelpURL = wxT("http://www.ghn.se");
	  
	  wxMimeTypesManager manager;
	  wxFileType * filetype = manager.GetFileTypeFromExtension( wxT("html") );
	  wxString command = filetype->GetOpenCommand( strHelpURL );
	  wxExecute(command);
	}

	event.Skip();
}
Exemplo n.º 10
0
void ProcUtils::ExecuteCommand(const wxString &command, wxArrayString &output, long flags)
{
#ifdef __WXMSW__
    wxExecute(command, output, flags);
#else
    FILE *fp;
    char line[512];
    memset(line, 0, sizeof(line));
    fp = popen(command.mb_str(wxConvUTF8), "r");
    while ( fgets( line, sizeof line, fp)) {
        output.Add(wxString(line, wxConvUTF8));
        memset(line, 0, sizeof(line));
    }

    pclose(fp);
#endif
}
Exemplo n.º 11
0
INT32 PluginOILFilter::HowCompatible(PathName& FileName)
{
	INT32 HowCompatible = 0;

	// Here we need to run the plugin synchronously with the following options
	// -c -f <filename>

	// Check stderr for errors
	// Get HowCompatible from stdout
	if (!m_CanImport.IsEmpty())
	{
		wxString sCommand(m_CanImport);
		sCommand.Replace(_T("%IN%"), (LPCTSTR)FileName.GetPath());

		TRACEUSER("Gerry", _T("Running '%s'"), sCommand.c_str());

		wxArrayString saOutput;
		wxArrayString saErrors;
		INT32 code = wxExecute(sCommand, saOutput, saErrors, wxEXEC_NODISABLE);
		TRACEUSER("Gerry", _T("wxExecute returned %d"), code);
		if (code == 0)
		{
			// Extract the value from saOutput
			if (saOutput.Count() > 0)
			{
				INT32 Val = wxAtoi(saOutput[0]);
				TRACEUSER("Gerry", _T("Command '%s' returned string '%s'"), sCommand.c_str(), saOutput[0].c_str());
				TRACEUSER("Gerry", _T("Value = %d"), Val);
				if (Val >= 0 && Val <= 10)
				{
					HowCompatible = Val;
				}
			}
			else
			{
				TRACEUSER("Gerry", _T("Command '%s' returned no output value"), sCommand.c_str());
			}
		}
		else
		{
			TRACEUSER("Gerry", _T("Command '%s' exited with code %d"), sCommand.c_str(), code);
		}
	}

	return(HowCompatible);
}
Exemplo n.º 12
0
long wxExecute(const wxString& command, int flags, wxProcess *process,
               const wxExecuteEnv *env)
{
    // FIXME: shouldn't depend on wxCmdLineParser
    wxArrayString args(wxCmdLineParser::ConvertStringToArgs(command));
    size_t n = args.size();
    wxChar **argv = new wxChar*[n + 1];

    argv[n] = NULL;
    while (n-- > 0)
        argv[n] = const_cast<wxChar*>((const char *)args[n].c_str());

    long result = wxExecute(argv, flags, process);

    delete [] argv;
    return result;
}
Exemplo n.º 13
0
void OpenWebBrowser(const wxString& url)
{
	if (sett().GetWebBrowserUseDefault()
	    // These shouldn't happen, but if they do we use the default browser anyway.
	    ||
	    sett().GetWebBrowserPath() == wxEmptyString || sett().GetWebBrowserPath() == _T("use default")) {
		if (!wxLaunchDefaultBrowser(url)) {
			wxLogWarning(_T("can't launch default browser"));
			customMessageBoxNoModal(SL_MAIN_ICON, _("Couldn't launch browser. URL is: ") + url, _("Couldn't launch browser."));
		}
	} else {
		if (!wxExecute(sett().GetWebBrowserPath() + _T(" ") + url, wxEXEC_ASYNC)) {
			wxLogWarning(_T("can't launch browser: %s"), sett().GetWebBrowserPath().c_str());
			customMessageBoxNoModal(SL_MAIN_ICON, _("Couldn't launch browser. URL is: ") + url + _("\nBroser path is: ") + sett().GetWebBrowserPath(), _("Couldn't launch browser."));
		}
	}
}
Exemplo n.º 14
0
void Utils::OpenFolder(wxFileName path)
{
	wxString cmd;
	
#if WINDOWS
	cmd = "explorer ";
#elif OSX
	cmd = "open ";
#elif LINUX
	cmd = "xdg-open ";
#endif

	cmd.Append("\"");
	cmd.Append(path.GetFullPath());
	cmd.Append("\"");
    wxExecute(cmd);
}
Exemplo n.º 15
0
void MAJ::OndownloadAndInstallBtClick(wxCommandEvent& event)
{
    //Warn the user his work can be lost
    if ( wxMessageBox(_("GDevelop will be closed at the end of the download so as to install the new version. Don't forget to save your work.\nDownload and install the new version \?"), _("Installation of the new version"), wxYES_NO | wxICON_QUESTION, this) == wxNO )
        return;

    wxString tempDir = wxFileName::GetHomeDir()+"/.GDevelop";

    //Open connection to file
    wxHTTP http;
    wxURL *url = new wxURL(_T("http://www.compilgames.net/dl/gd.exe"));
    wxInputStream * input = url->GetInputStream();

    if (input!=NULL) {
        unsigned int current_progress = 0;
        char buffer[1024];

        wxProgressDialog progress(_("Download"),_("Progress"),(int)input->GetSize(), NULL, wxPD_CAN_ABORT | wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
        wxFileOutputStream outputfile(tempDir+"/newgd.exe");
        while(!input->Eof() && current_progress!=input->GetSize()) { //Download part as long we haven't reached the end
            input->Read((void *)buffer,1024);
            outputfile.Write((const void *)buffer,input->LastRead());
            current_progress+=input->LastRead();
            if ( !progress.Update(current_progress) ) //Enable the user to stop downloading
            {
                if ( wxMessageBox(_("Stop the download \?\n\nYou can also get the new version by downloading it on our website."), _("Stop the download"), wxYES_NO | wxICON_QUESTION, this) == wxYES )
                {
                    wxRemoveFile(tempDir+"/newgd.exe");
                    return;
                }
                else
                    progress.Resume();
            }
        }

        delete input;
    }
    else
    {
        gd::LogWarning( _( "Unable to connect to the server so as to check for updates.\nCheck :\n-Your internet connection\n-Your firewall-If you can manually access  our site.\n\nYou can disable Check for updates in the preferences of GDevelop." ) );
        return;
    }

    wxExecute(tempDir+"/newgd.exe /SILENT /LANG="+gd::LocaleManager::Get()->locale->GetLocale(), wxEXEC_ASYNC);
    EndModal(2);
}
bool progress_dialog::execute_command_redirected_to_listbox( const wxString& command_string )
{
    process_data_type   pdata;
    piped_process       *process;

    process = new piped_process( this, &pdata );
    
    // FALSE argument tells to make it execute async instead of sync (meaning dont wait for 
    // the program to be done before continuing).
    // Store the pid (process id) that is returned from it so, can be killed with the stop 
    // button if user wants to abort.
    m_most_recent_pid = wxExecute( command_string, FALSE, process );

#ifdef __WXMSW__    
    // MSW can have long unsigned as process ids. We ifdef just to avoid a compiler
    // warning on GCC that we have mismatched unsigned and long unsigned.
    wxLogDebug( "Started execution. m_most_recent_pid=%lu", m_most_recent_pid );
#else
    wxLogDebug( "Started execution. m_most_recent_pid=%u", m_most_recent_pid );
#endif

    // Show a warning box if couldn't execute it. Also set our m_is_process_running 
    // accordingly, ready for our examination in kill_most_recent_process()
    if ( m_most_recent_pid == 0 ) {
        m_is_process_running = FALSE;
        wxLogError( "Error: cannot execute: " + command_string );
        return FALSE;
    } else {
        m_is_process_running = TRUE;
    }

    while ( pdata.is_running ) {
        wxLogDebug( "Entered pdata.is_running loop. About to call process->has_input" );
        process->has_input();
        // Sleeps for plkrPROGRESS_DIALOG_DETAILS_REFRESH_DELAY milliseconds, 
        // then yields
        wxUsleep( plkrPROGRESS_DIALOG_DETAILS_REFRESH_DELAY ); 
        // Yield to update the display
        wxYield();       
    }
        
    //! \todo SOURCE PUT THIS BACK INSTEAD OF RETURN TRUE. Why was it turned off?
    //return pdata.exit_code == 0;
    return TRUE;
}
void LauncherApp::netDownload()
{
  wxString browser;

#ifdef __WINDOWS__
  // We use the default browser.
  browser = "rundll32 url.dll,FileProtocolHandler ";
#endif

#ifdef __UNIX__
  // We try some browsers and use the first successful one.
  std::list<std::pair<wxString, wxString> > commands;
  std::pair<wxString, wxString> cmd;
  cmd.first = "konqueror "; cmd.second = "konqueror -v";
  commands.push_back(cmd);
  cmd.first = "mozilla -splash "; cmd.second = "mozilla -v";
  commands.push_back(cmd);
  cmd.first = "firefox -splash "; cmd.second = "firefox -v";
  commands.push_back(cmd);
  cmd.first = "firebird -splash "; cmd.second = "firebird -v";
  commands.push_back(cmd);
  cmd.first = "opera "; cmd.second = "opera -v";
  commands.push_back(cmd);
  cmd.first = "netscape "; cmd.second = "netscape -v";
  commands.push_back(cmd);
  std::list<std::pair<wxString, wxString> >::iterator it;
  for (it = commands.begin(); it != commands.end(); ++it)
  {
    if (wxExecute(it->second, wxEXEC_SYNC) == 0)
    {
      browser = it->first;
      break;
    }
  }
#endif

  if (run_external(browser + params["download"]))
  {
    completed = true;
  }
  else
  {
    error(_("Could not find a web browser."));
  }
}
Exemplo n.º 18
0
long wxLuaDebuggerBase::StartClient()
{
    if (m_debuggeeProcess == NULL)
    {
        m_debuggeeProcess = new wxLuaDebuggerProcess(this, ID_WXLUA_DEBUGGEE_PROCESS);
        wxString command = wxString::Format(wxT("%s -d%s:%u"),
                                            GetProgramName().c_str(),
                                            GetNetworkName().c_str(),
                                            m_port_number);

        m_debuggeeProcessID = wxExecute(command, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER, m_debuggeeProcess);

        if (m_debuggeeProcessID < 1)
            KillDebuggee();
    }

    return m_debuggeeProcessID;
}
Exemplo n.º 19
0
bool DescriptorFrame::into_zip(std::string cad,std::string zip)
{
	bool value;
	wxProcess *process = new wxProcess(this);

	
			
    wxString cmd = "zip -m ";
	cmd.append(zip.c_str());
	cmd.append(" ");
	cmd.append(cad.c_str());
	
	
	value = wxExecute(cmd, wxEXEC_SYNC, NULL);
	delete process;
	
	return value;
}
Exemplo n.º 20
0
void ExtensionsDialog::OnClickOpenFolder(wxCommandEvent& evt)
{
	wxString cmd, extensionsDir = g_gui.GetExtensionsDirectory();
#if defined __WINDOWS__
	cmd << "explorer";
#elif defined __APPLE__
	cmd << "open";
	extensionsDir.Replace(" ", "\\ "); //Escape spaces
#elif defined __linux
	cmd << "xdg-open";
#else
#error "NOT IMPLEMENTED"
#endif

	cmd << " " << extensionsDir;

	wxExecute(cmd);
}
Exemplo n.º 21
0
void MainFrame::OnForumClick( wxCommandEvent& event )
{
	wxString url = wxT("http://nwnx.org/index.php?id=forum");
	bool ok = false;

	wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));
	if (ft)
	{
		wxString cmd;
		ok = ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(url, wxEmptyString));
		delete ft;

		if (ok)
			ok = (wxExecute(cmd, wxEXEC_ASYNC) != 0);
		else
			wxLogMessage(wxT("Could not start webbrowser. Check your installation."));
	}
}
Exemplo n.º 22
0
void TestDialog::OnButtonSelect( wxCommandEvent& event )
{
//   	wxMessageBox(wxT("impl"));
    wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
                                     wxT("dialog"),
                                     wxT("command"));

    if ( !cmd )
        return;

    wxLogStatus( _T("'%s' is running please wait..."), cmd.c_str() );

    int code = wxExecute(cmd, wxEXEC_SYNC);

    wxLogStatus(_T("Process '%s' terminated with exit code %d."),
        cmd.c_str(), code);

    //m_cmdLast = cmd; 
}
Exemplo n.º 23
0
void DecisionLogicFrame::OnHelp(wxCommandEvent& WXUNUSED(event))
{
    //shell out the htm help
	wxMimeTypesManager manager;
	wxFileType * filetype = manager.GetFileTypeFromExtension(_T("htm"));
	wxString command;
	wxString path;
	if (m_working_directory.length() > 0)
		path += m_working_directory + PATHSEP;
	path += _T("DecisionLogicHelp.htm");
	bool ok = filetype->GetOpenCommand(&command, wxFileType::MessageParameters(path));
	if (ok)
	{
		wxProcess *process = new MyProcess(this, command);
		long pid = wxExecute(command, wxEXEC_ASYNC, process);
		if (!pid)
			delete process;
	}
}
Exemplo n.º 24
0
void MainFrame::OnPdf(wxCommandEvent& event) {
	wxFileName fileName;
	fileName.SetPath(wxGetCwd());
	fileName.SetFullName(wxT("default.pdf"));
	wxPrintData printData;
	printData.SetOrientation(wxPORTRAIT);
	printData.SetPaperId(wxPAPER_A4);
	printData.SetFilename(fileName.GetFullPath());
	{
		wxPdfDC dc(printData);
		int w, h;
		dc.GetSize(&w, &h);

		float scaleX = float(w) / 730;
		float scaleY = float(h) / 730;
		float actualScale = wxMin(scaleX, scaleY);
		dc.SetUserScale(actualScale, actualScale);
		dc.SetDeviceOrigin(0, 0);

		// set wxPdfDC mapping mode style so
		// we can scale fonts and graphics
		// coords with a single setting
		dc.SetMapModeStyle(wxPDF_MAPMODESTYLE_PDF);
		dc.SetMapMode(wxMM_POINTS);
		bool ok = dc.StartDoc(_("Printing ..."));
		if (ok) {
			dc.StartPage();
			m_Patients[m_PatientIndex].getTreatment(m_TreatmentIndex).Print(m_Patients[m_PatientIndex],
					m_TreatmentIndex + 1, wxRect(10, 20, 710, 710), &dc);
			dc.EndPage();
			dc.EndDoc();
		}
	}

	wxFileType* fileType = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("pdf"));
	if (fileType != NULL) {
		wxString cmd = fileType->GetOpenCommand(fileName.GetFullPath());
		if (!cmd.IsEmpty()) {
			wxExecute(cmd);
		}
		delete fileType;
	}
}
Exemplo n.º 25
0
bool wxLaunchDefaultApplication(const wxString& document, int flags)
{
    wxUnusedVar(flags);

    // Our best best is to use xdg-open from freedesktop.org cross-desktop
    // compatibility suite xdg-utils
    // (see http://portland.freedesktop.org/wiki/) -- this is installed on
    // most modern distributions and may be tweaked by them to handle
    // distribution specifics.
    wxString path, xdg_open;
    if ( wxGetEnv("PATH", &path) &&
         wxFindFileInPath(&xdg_open, path, "xdg-open") )
    {
        if ( wxExecute(xdg_open + " " + document) )
            return true;
    }

    return false;
}
Exemplo n.º 26
0
void
mux_dialog::on_abort(wxCommandEvent &) {
#if defined(SYS_WINDOWS)
    if (0 == pid) {
        wxFileName output_file_name(static_cast<mmg_dialog *>(GetParent())->tc_output->GetValue());
        wxExecute(wxString::Format(wxT("explorer \"%s\""), output_file_name.GetPath().c_str()));
        return;
    }

    wxKill(pid, wxSIGKILL);
    change_abort_button();
#else
    if (0 == pid)
        return;

    wxKill(pid, wxSIGTERM);
    b_abort->Enable(false);
#endif
}
Exemplo n.º 27
0
bool wxDebugReportUpload::DoProcess()
{
    if ( !wxDebugReportCompress::DoProcess() )
        return false;


    wxArrayString output, errors;
    int rc = wxExecute(wxString::Format
                       (
                            wxT("%s -F %s=@\"%s\" %s"),
                            m_curlCmd.c_str(),
                            m_inputField.c_str(),
                            GetCompressedFileName().c_str(),
                            m_uploadURL.c_str()
                       ),
                       output,
                       errors);
    if ( rc == -1 )
    {
        wxLogError(_("Failed to execute curl, please install it in PATH."));
    }
    else if ( rc != 0 )
    {
        const size_t count = errors.GetCount();
        if ( count )
        {
            for ( size_t n = 0; n < count; n++ )
            {
                wxLogWarning(wxT("%s"), errors[n].c_str());
            }
        }

        wxLogError(_("Failed to upload the debug report (error code %d)."), rc);
    }
    else // rc == 0
    {
        if ( OnServerReply(output) )
            return true;
    }

    return false;
}
Exemplo n.º 28
0
void Launcher::OnNSDStartButton(wxCommandEvent& WXUNUSED(event)) 
{
	if (nsd_started_){
		wxKill (nsd_pid_, wxSIGKILL);
		nsd_started_= false;
		NSDStartBtn->SetLabel("Start");
		NSDStartBtn -> SetBackgroundColour(wxColour(255, 0, 0));
		NSDStartBtn->Refresh();
	} else
	{
		wxString port_nr = port_number_->GetValue(); 
		
		wxString host_name = wxGetHostName();
		// get the computers name first 

		wxString cmd = "nsd -ORBIIOPAddr inet:";
		cmd.append(host_name);
		cmd.append(":");
		cmd.append(port_nr);

		wxProcess *process = new wxProcess (this);
	//	process->Redirect();
		nsd_pid_ = wxExecute(cmd, wxEXEC_ASYNC, process);
		if ( !nsd_pid_ )
		{
			wxLogError( _T("Execution of '%s' failed."), cmd.c_str() );

			delete process;
		}
		else
		{
			// change Button
			nsd_started_= true;
			NSDStartBtn->SetLabel("Stop");
			NSDStartBtn -> SetBackgroundColour(wxColour(0, 255, 0));
			NSDStartBtn->Refresh();


		}

	}
}
Exemplo n.º 29
0
long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler,
                   const wxExecuteEnv *env)
{
    wxString command;
    command.reserve(1024);

    wxString arg;
    for ( ;; )
    {
        arg = *argv++;

        bool quote;
        if ( arg.empty() )
        {
            // we need to quote empty arguments, otherwise they'd just
            // disappear
            quote = true;
        }
        else // non-empty
        {
            // escape any quotes present in the string to avoid interfering
            // with the command line parsing in the child process
            arg.Replace("\"", "\\\"", true /* replace all */);

            // and quote any arguments containing the spaces to prevent them from
            // being broken down
            quote = arg.find_first_of(" \t") != wxString::npos;
        }

        if ( quote )
            command += '\"' + arg + '\"';
        else
            command += arg;

        if ( !*argv )
            break;

        command += ' ';
    }

    return wxExecute(command, flags, handler, env);
}
Exemplo n.º 30
0
void ABoxDlg::executeStub(const char* filepath) {
  wxFileType *filetype=wxTheMimeTypesManager->GetFileTypeFromExtension(wxString(StrOp.getExtension(filepath),wxConvUTF8));
  if( filetype == NULL ) {
    char* tip = StrOp.fmt( wxGetApp().getCMsg("nodefaultapplicationfound"), filepath );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
    return;
  }
  wxString command=filetype->GetOpenCommand(wxString(filepath,wxConvUTF8));
  TraceOp.trc( "aboxdlg", TRCLEVEL_INFO, __LINE__, 9999, "execute [%s]", (const char*)command.mb_str(wxConvUTF8) );
  if( command.IsEmpty() ) {
    // No default application...
    char* tip = StrOp.fmt( wxGetApp().getCMsg("nodefaultapplicationfound"), filepath );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
  }
  else {
    wxExecute(command);
  }
}