예제 #1
0
void ScriptResolver::readStdout()
{
    qDebug() << Q_FUNC_INFO << m_proc.bytesAvailable();
    if( m_msgsize == 0 )
    {
        if( m_proc.bytesAvailable() < 4 ) return;
        quint32 len_nbo;
        m_proc.read( (char*) &len_nbo, 4 );
        m_msgsize = qFromBigEndian( len_nbo );
        qDebug() << Q_FUNC_INFO << "msgsize" << m_msgsize;
    }

    if( m_msgsize > 0 )
    {
        m_msg.append( m_proc.read( m_msgsize - m_msg.length() ) );
    }

    if( m_msgsize == (quint32) m_msg.length() )
    {
        handleMsg( m_msg );
        m_msgsize = 0;
        m_msg.clear();
        if( m_proc.bytesAvailable() ) QTimer::singleShot( 0, this, SLOT(readStdout()) );
    }
}
예제 #2
0
ScriptResolver::ScriptResolver( const QString& exe )
    : Tomahawk::ExternalResolver( exe )
    , m_num_restarts( 0 )
    , m_msgsize( 0 )
    , m_ready( false )
    , m_stopped( true )
    , m_configSent( false )
    , m_error( Tomahawk::ExternalResolver::NoError )
{
    tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
    connect( &m_proc, SIGNAL( readyReadStandardError() ), SLOT( readStderr() ) );
    connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
    connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );

    QString runPath = filePath();
#ifdef WIN32
    // have to enclose in quotes if path contains spaces on windows...
    runPath = QString( "\"%1\"" ).arg( filePath() );
#endif

    if ( !QFile::exists( filePath() ) )
        m_error = Tomahawk::ExternalResolver::FileNotFound;
    else
        m_proc.start( runPath );

    if ( !TomahawkUtils::nam() )
        return;

    // set the name to the binary, if we launch properly we'll get the name the resolver reports
    m_name = QFileInfo( filePath() ).baseName();

    sendConfig();
}
예제 #3
0
ScriptResolver::ScriptResolver( const QString& exe )
    : Tomahawk::ExternalResolverGui( exe )
    , m_num_restarts( 0 )
    , m_msgsize( 0 )
    , m_ready( false )
    , m_stopped( true )
    , m_configSent( false )
    , m_deleting( false )
    , m_error( Tomahawk::ExternalResolver::NoError )
{
    tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
    connect( &m_proc, SIGNAL( readyReadStandardError() ), SLOT( readStderr() ) );
    connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
    connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );

    startProcess();

    if ( !TomahawkUtils::nam() )
        return;

    // set the name to the binary, if we launch properly we'll get the name the resolver reports
    m_name = QFileInfo( filePath() ).baseName();

    // set the icon, if we launch properly we'll get the icon the resolver reports
    m_icon = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, QSize( 128, 128 ) );
}
예제 #4
0
파일: UserProgram.cpp 프로젝트: CBCJVM/cbc
UserProgram::UserProgram()
{
  QObject::connect(&m_userProgram, SIGNAL(started()), this, SLOT(programStarted()));
  QObject::connect(&m_userProgram, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(programFinished(int, QProcess::ExitStatus)));
  QObject::connect(&m_userProgram, SIGNAL(readyReadStandardError()), this, SLOT(readStderr()));
  QObject::connect(&m_userProgram, SIGNAL(readyReadStandardOutput()), this, SLOT(readStdout()));
  this->updateProgramName();
}
예제 #5
0
GoAstView::GoAstView(IApplication *app, QObject *parent):
    liteApp(app), QObject(parent)
{
    connect(&astProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readStdout()));
    connect(&astProcess,SIGNAL(readyReadStandardError()),this,SLOT(readStderr()));
    connect(&astProcess,SIGNAL(started()),this,SLOT(started()));
    connect(&astProcess,SIGNAL(finished(int)),this,SLOT(finished(int)));
    connect(&astProcess,SIGNAL(error(QProcess::ProcessError)),this,SLOT(error(QProcess::ProcessError)));
}
예제 #6
0
ScriptResolver::ScriptResolver(const QString& exe) :
    Tomahawk::Resolver()
    , m_cmd( exe )
    , m_num_restarts( 0 )
    , m_msgsize( 0 )
    , m_ready( false )
    , m_stopped( false )
{
    qDebug() << Q_FUNC_INFO << exe;
    connect( &m_proc, SIGNAL(readyReadStandardError()), SLOT(readStderr()) );
    connect( &m_proc, SIGNAL(readyReadStandardOutput()), SLOT(readStdout()) );
    connect( &m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(cmdExited(int,QProcess::ExitStatus)) );

    m_proc.start( m_cmd );
}
예제 #7
0
파일: updates.cpp 프로젝트: markwal/GpxUi
// ../Update.exe --download=https://markwal.github.io/GpxUi
// ../Update.exe --update=https://markwal.github.io/GpxUi
Updates::Updates(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Updates)
{
    ui->setupUi(this);

    QSettings settings;
    ui->cboxAutoUpdate->setChecked(settings.value("auto_update", true).toBool());

    pprocess = new QProcess(this);
    pprocess->setProcessChannelMode(QProcess::MergedChannels);
    connect(pprocess, SIGNAL(readyRead()), SLOT(readStdout()));
    connect(pprocess, SIGNAL(finished(int)), SLOT(finished(int)));

    checkForUpdates();
}
예제 #8
0
void OcaOctaveController::onListenerStateChanged( int listener_state )
{
  if( ( e_StateReady != m_state ) && ( 1 == listener_state ) ) {
    m_state = e_StateReady;
#ifndef Q_OS_WIN32
    readStdout();
#endif
    if( 0 != m_lastError ) {
      emit outputReceived( m_lastErrorString, m_lastError );
    }
    fprintf( stderr, "OcaOctaveController => READY\n" );
    emit readyStateChanged( true, 0 );
  }
  else {
    Q_ASSERT( false );
  }
}
bool KStreamRipper::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: browseButtonClicked(); break;
    case 1: addStreamButtonClicked(); break;
    case 2: deleteStreamButtonClicked(); break;
    case 3: tuneInButtonClicked(); break;
    case 4: ripButtonClicked(); break;
    case 5: stopRipButtonClicked(); break;
    case 6: addStreamFinished((AddNewStreamImpl*)static_QUType_ptr.get(_o+1)); break;
    case 7: readStdout(); break;
    case 8: setEmptyText(); break;
    case 9: quitButtonClicked(); break;
    case 10: aboutButtonClicked(); break;
    default:
	return KStreamRipperBase::qt_invoke( _id, _o );
    }
    return TRUE;
}
예제 #10
0
MyProcess::MyProcess(QObject * parent)
	: QProcess(parent) {

	//QProcess::MergedChannels
	//QProcess merges the output of the running process into the standard
	//output channel (stdout). The standard error channel (stderr) will not
	//receive any data. The standard output and standard error data of the
	//running process are interleaved.
	setProcessChannelMode(QProcess::MergedChannels);

	//QProcess::readyReadStandardOutput()
	//This signal is emitted when the process has made new data available through
	//its standard output channel (stdout). It is emitted regardless of the
	//current read channel.
	connect(this, SIGNAL(readyReadStandardOutput()), SLOT(readStdout()));

	connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(finished(int, QProcess::ExitStatus)));

	connect(this, SIGNAL(error(QProcess::ProcessError)), SLOT(error(QProcess::ProcessError)));
}
예제 #11
0
void KviKvsProcessAsyncOperation::processExited(int exitCode)
{
	if(m_bDeletePending)
		return;

	readStdout(); // just to make sure
	readStderr(); // just to make sure

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_OUTPUTBYBLOCKS)
	{
		// trigger Stdout and Stderr once
		if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDOUT)
		{
			if(trigger(EventStdout, m_szStdoutBuffer))
			{
				triggerSelfDelete();
				return;
			}
		}

		if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDERR)
		{
			if(trigger(EventStdout, m_szStderrBuffer))
			{
				triggerSelfDelete();
				return;
			}
		}
	}

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERTERMINATED)
	{
		QString szRetVal;
		szRetVal.setNum(exitCode);
		trigger(EventTerminated, szRetVal);
	}

	triggerSelfDelete();
}
예제 #12
0
MainWindow::MainWindow()
  : m_settings(QString::fromAscii("Doxygen.org"), QString::fromAscii("Doxywizard"))
{
  QMenu *file = menuBar()->addMenu(tr("File"));
  file->addAction(tr("Open..."), 
                  this, SLOT(openConfig()), Qt::CTRL+Qt::Key_O);
  m_recentMenu = file->addMenu(tr("Open recent"));
  file->addAction(tr("Save"), 
                  this, SLOT(saveConfig()), Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Save as..."), 
                  this, SLOT(saveConfigAs()), Qt::SHIFT+Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Quit"),  
                  this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);

  QMenu *settings = menuBar()->addMenu(tr("Settings"));
  settings->addAction(tr("Reset to factory defaults"),
                  this,SLOT(resetToDefaults()));
  settings->addAction(tr("Use current settings at startup"),
                  this,SLOT(makeDefaults()));
  settings->addAction(tr("Clear recent list"),
                  this,SLOT(clearRecent()));

  QMenu *help = menuBar()->addMenu(tr("Help"));
  help->addAction(tr("Online manual"), 
                  this, SLOT(manual()), Qt::Key_F1);
  help->addAction(tr("About"), 
                  this, SLOT(about()) );

  m_expert = new Expert;
  m_wizard = new Wizard(m_expert->modelData());

  // ----------- top part ------------------
  QWidget *topPart = new QWidget;
  QVBoxLayout *rowLayout = new QVBoxLayout(topPart);

  // select working directory
  QHBoxLayout *dirLayout = new QHBoxLayout;
  m_workingDir = new QLineEdit;
  m_selWorkingDir = new QPushButton(tr("Select..."));
  dirLayout->addWidget(m_workingDir);
  dirLayout->addWidget(m_selWorkingDir);

  //------------- bottom part --------------
  QWidget *runTab = new QWidget;
  QVBoxLayout *runTabLayout = new QVBoxLayout(runTab);

  // run doxygen
  QHBoxLayout *runLayout = new QHBoxLayout;
  m_run = new QPushButton(tr("Run doxygen"));
  m_run->setEnabled(false);
  m_runStatus = new QLabel(tr("Status: not running"));
  m_saveLog = new QPushButton(tr("Save log..."));
  m_saveLog->setEnabled(false);
  QPushButton *showSettings = new QPushButton(tr("Show configuration"));
  runLayout->addWidget(m_run);
  runLayout->addWidget(m_runStatus);
  runLayout->addStretch(1);
  runLayout->addWidget(showSettings);
  runLayout->addWidget(m_saveLog);

  // output produced by doxygen
  runTabLayout->addLayout(runLayout);
  runTabLayout->addWidget(new QLabel(tr("Output produced by doxygen")));
  QGridLayout *grid = new QGridLayout;
  m_outputLog = new QTextEdit;
  m_outputLog->setReadOnly(true);
  m_outputLog->setFontFamily(QString::fromAscii("courier"));
  m_outputLog->setMinimumWidth(600);
  grid->addWidget(m_outputLog,0,0);
  grid->setColumnStretch(0,1);
  grid->setRowStretch(0,1);
  QHBoxLayout *launchLayout = new QHBoxLayout;
  m_launchHtml = new QPushButton(tr("Show HTML output"));
  launchLayout->addWidget(m_launchHtml);

  launchLayout->addStretch(1);
  grid->addLayout(launchLayout,1,0);
  runTabLayout->addLayout(grid);

  QTabWidget *tabs = new QTabWidget;
  tabs->addTab(m_wizard,tr("Wizard"));
  tabs->addTab(m_expert,tr("Expert"));
  tabs->addTab(runTab,tr("Run"));

  rowLayout->addWidget(new QLabel(tr("Step 1: Specify the working directory from which doxygen will run")));
  rowLayout->addLayout(dirLayout);
  rowLayout->addWidget(new QLabel(tr("Step 2: Configure doxygen using the Wizard and/or Expert tab, then switch to the Run tab to generate the documentation")));
  rowLayout->addWidget(tabs);

  setCentralWidget(topPart);
  statusBar()->showMessage(tr("Welcome to Doxygen"),messageTimeout);

  m_runProcess = new QProcess;
  m_running = false;
  m_timer = new QTimer;

  // connect signals and slots
  connect(tabs,SIGNAL(currentChanged(int)),SLOT(selectTab(int)));
  connect(m_selWorkingDir,SIGNAL(clicked()),SLOT(selectWorkingDir()));
  connect(m_recentMenu,SIGNAL(triggered(QAction*)),SLOT(openRecent(QAction*)));
  connect(m_workingDir,SIGNAL(returnPressed()),SLOT(updateWorkingDir()));
  connect(m_runProcess,SIGNAL(readyReadStandardOutput()),SLOT(readStdout()));
  connect(m_runProcess,SIGNAL(finished(int, QProcess::ExitStatus)),SLOT(runComplete()));
  connect(m_timer,SIGNAL(timeout()),SLOT(readStdout()));
  connect(m_run,SIGNAL(clicked()),SLOT(runDoxygen()));
  connect(m_launchHtml,SIGNAL(clicked()),SLOT(showHtmlOutput()));
  connect(m_saveLog,SIGNAL(clicked()),SLOT(saveLog()));
  connect(showSettings,SIGNAL(clicked()),SLOT(showSettings()));
  connect(m_expert,SIGNAL(changed()),SLOT(configChanged()));

  loadSettings();
  updateLaunchButtonState();
  m_modified = false;
  updateTitle();
  m_wizard->refresh();
}
예제 #13
0
bool KviKvsProcessAsyncOperation::start()
{
	QStringList args;
	QString szcmd;

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_NOSHELL)
	{
		args = m_pData->szCommandline.split(" ", QString::SkipEmptyParts);
	}
	else
	{
		QString szShell = m_pData->szShell;
		if(szShell.isEmpty())
		{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
			// [01:26:00] <PragmaOff> btw, what is qt_winunicode ?
			// [01:26:12] <kode54> Qt export specific to win32
			// [01:26:27] <kode54> bool which indicates whether system is Unicode (NT) or not
			// [01:26:58] <kode54> not sure if that's documented, but it is a public export
			//
			// [02:50:21] <kode54> if ( QApplication::winVersion() & Qt::WV_NT_based )
			// [02:50:41] <kode54> I see another implementation using that, maybe it is the official way of detecting that :[
			szShell = !(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) ? "cmd.exe /c" : "command.com /c";
// Thnx kode54 :)
#else
			szShell = "sh -c";
#endif
		}
		args = szShell.split(" ", QString::SkipEmptyParts);
		args.append(m_pData->szCommandline);
	}

	m_pProcess = new QProcess(this);

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDOUT)
	{
		connect(m_pProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStdout()));
	}
	else
	{
		m_pProcess->closeReadChannel(QProcess::StandardOutput);
	}

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDERR)
	{
		connect(m_pProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStderr()));
	}
	else
	{
		m_pProcess->closeReadChannel(QProcess::StandardError);
	}

	connect(m_pProcess, SIGNAL(finished(int)), this, SLOT(processExited(int)));

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTARTED)
	{
		connect(m_pProcess, SIGNAL(started()), this, SLOT(processStarted()));
	}

	szcmd = args.takeFirst();
	m_pProcess->start(szcmd, args);

	if(m_pProcess->state() == QProcess::NotRunning)
	{
		return false;
	}

	if(m_pData->iMaxRunTime > 0)
	{
		m_pRunTimeTimer = new QTimer(this);
		connect(m_pRunTimeTimer, SIGNAL(timeout()), this, SLOT(maxRunTimeExpired()));
		m_pRunTimeTimer->start(m_pData->iMaxRunTime);
	}

	if(m_pData->iPingTimeout > 0)
	{
		m_pPingTimer = new QTimer(this);
		connect(m_pPingTimer, SIGNAL(timeout()), this, SLOT(ping()));
		m_pPingTimer->start(m_pData->iPingTimeout);
	}

	return true;
}