Exemplo n.º 1
0
WVDialer::WVDialer( QWidget *parent, const char *name ) :
  WVDialerDlg( parent, name ),
  exitFlag( false ),
  upTimer( -1 ),
  delayTimer( -1 ),
  upTime( 0 ),
  pppUp( false ),
  trayIcon(NULL),
  tray(NULL)
{  
  checkOldConfiguration();

  if (QFile::exists("/usr/share/icons/hicolor/32x32/qtwvdialer.png"))
  {
    trayIcon = new QIcon("/usr/share/icons/hicolor/32x32/qtwvdialer.png");
    this->setWindowIcon(*trayIcon);
    initializeTray();
  }
  
  QString fname = QDir::homeDirPath();
  fname += "/.qtwvdialer/settings";  
  cfg = new SimpleCfg( fname );
    
  configDlg = new WVConfigDlg( this );
  configDlg->hide();
  configDlg->load();
  
  loadConfig();
  
  wvdial = new Q3Process( this );
  startProcess = new Q3Process( this );
  
  stats = new PPPStats();
  
  errPix = QPixmap( (const char **)error_xpm );
  
  connect( connectBut, SIGNAL( clicked() ), this, SLOT( connectSLOT() ));
  connect( quitBut, SIGNAL( clicked() ), this, SLOT( quitSLOT() ));
  connect( helpBut, SIGNAL( clicked() ), this, SLOT( helpSLOT() ));
  connect( configBut, SIGNAL( clicked() ), this, SLOT( configSLOT() ));
  connect( wvdial, SIGNAL( readyReadStdout() ),
           this, SLOT( readStdoutSLOT()));
  connect( wvdial, SIGNAL( readyReadStderr() ),
           this, SLOT( readStderrSLOT()));
  connect( wvdial, SIGNAL( processExited() ),
           this, SLOT( exitedSLOT() ));
  connect( startProcess, SIGNAL( processExited() ),
           this, SLOT( exitedSLOT() ));
  connect( stats, SIGNAL( status( unsigned, unsigned, unsigned, unsigned )),
           this, SLOT( statsSLOT( unsigned, unsigned, unsigned, unsigned )));
  connect( stats, SIGNAL( remoteAddr( const QString & )),
           ipLabel, SLOT( setText( const QString & )));
  connect( stats, SIGNAL( pppStatus( bool ) ),
           this, SLOT( pppStatusSLOT( bool ) ));
  
  setIconText( tr( "PPP DOWN" ) );
}
Exemplo n.º 2
0
void ComputerPlayer::play(bool black, const QString& stateFileName, int nbMovesLeft)
{
  if (!isActive_)
    return; // So that human user can play

  while (true)
    {
      const QFileInfo fi(programFileName());
      
      if (fi.exists())
	if (fi.isExecutable())
	  {
#if QT_VERSION < 0x040000
	    process_ = new QProcess(programFileName());
	    process_->addArgument(stateFileName);
	    process_->addArgument(QString::number(black?allowedTime():-allowedTime()));
	    process_->addArgument(QString::number(nbMovesLeft));
	    connect(process_, SIGNAL(processExited()), this, SLOT(readFromStdout()));
	    if (process_->start())
#else
	    process_ = new QProcess();
	    connect(process_, SIGNAL(finished(int)), this, SLOT(readFromStdout()));
		process_->start(programFileName(), QStringList() << stateFileName << QString::number(black?allowedTime():-allowedTime()) << QString::number(nbMovesLeft));
	    if (process_->waitForStarted())
#endif
	      {
		Clock.start();
		break;
	      }
	    else
	      QMessageBox::warning(NULL ,"Unable to start process",
				   "Unable to start process.\nSelect another program or update permissions");
	  }
	else
Exemplo n.º 3
0
void KstJS::showConsole() {
#ifdef KST_HAVE_READLINE
  _showAction->setText(i18n("Hide &JavaScript Console"));
  if (!_konsolePart) {
    strcpy(shellStr, "SHELL=kstcmd");
    putenv(shellStr);
    KLibFactory *f = KLibLoader::self()->factory("libkonsolepart");
    if (!f) {
      KMessageBox::sorry(app(), i18n("Could not load konsole part.  Please install kdebase."));
      return;
    }
    _splitter = new QSplitter(Qt::Vertical, app());
    KParts::Part *p = dynamic_cast<KParts::Part*>(f->create(_splitter, "kstcmd"));
    if (!p) {
      KMessageBox::sorry(app(), i18n("Konsole part appears to be incompatible.  Please install kdebase correctly."));
      delete _splitter;
      return;
    }

    _oldCentralWidget = app()->centralWidget();
    _oldCentralWidget->reparent(_splitter, QPoint(0, 0));
    _splitter->moveToLast(p->widget());
    app()->setCentralWidget(_splitter);

    connect(p, SIGNAL(processExited()), this, SLOT(shellExited()));
    _konsolePart = p;
  }
  _splitter->show();
  _konsolePart->widget()->show();
#endif
}
Exemplo n.º 4
0
void Konsole::cancel()
{
  if (!mProcess) 
    return;
  mProcess->cancel();
  processExited(mProcess);
}
void KaduExtInfo::openMailComposer(const QString &link)
{
    kdebugf();
    QProcess *browser;
    QStringList args;
    QString mail = link;

    QString mailComposer = mailProgram;
    if (mailProgram.isEmpty())
    {
        /*QMessageBox::warning(0, qApp->translate("@default", QT_TR_NOOP("WWW error")),
            qApp->translate("@default", QT_TR_NOOP("Web browser was not specified. Visit the configuration section")));*/
        kdebugmf(KDEBUG_INFO, "Mail composer NOT specified.\n");
        return;
    }
    if (!mailComposer.contains("%1"))
        mailComposer.append(" \"%1\"");

    mail.replace("mailto:","");
    mailComposer.replace("%1", unicode2latinUrl(mail));

    args=toStringList("sh", "-c", mailComposer);

    CONST_FOREACH(i, args)
        kdebugmf(KDEBUG_INFO, "%s\n", (*i).local8Bit().data());
    browser = new QProcess(qApp);
    browser->setArguments(args);
    QObject::connect(browser, SIGNAL(processExited()), browser, SLOT(deleteLater()));

    if (!browser->start())
        QMessageBox::critical(0, tr("Mail error"), tr("Could not spawn Mail composer process. Check if the Mail program is functional"));

    kdebugf2();
}
int Q3Process::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: readyReadStdout(); break;
        case 1: readyReadStderr(); break;
        case 2: processExited(); break;
        case 3: wroteToStdin(); break;
        case 4: launchFinished(); break;
        case 5: tryTerminate(); break;
        case 6: kill(); break;
        case 7: writeToStdin((*reinterpret_cast< const QByteArray(*)>(_a[1]))); break;
        case 8: writeToStdin((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 9: closeStdin(); break;
        case 10: socketRead((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: socketWrite((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: timeout(); break;
        case 13: closeStdinLaunch(); break;
        }
        _id -= 14;
    }
    return _id;
}
Exemplo n.º 7
0
ChatSession::ChatSession(const QString& session_name, QMtp * mtp, QWidget *parent, const char *name, QDomDocument * dom)
        : Master(parent, name) {

    context()->setVar("Client",CLIENT);

    host = DomUtil::readEntry(*dom,"/sessions/" + session_name + "/host","");
    port = DomUtil::readEntry(*dom,"/sessions/" + session_name + "/port","");
    this->mtp = mtp;
    this->m_dom = dom;
    this->session_name = session_name;

    createTelnetManager();

    displayStderr("Connecting to " + host + ":" + port);

    connect(mng, SIGNAL(processExited()),
            this, SLOT(closeSession()));

    m_filter = new MtpFilter(dom,context());
    m_chatpage = new MainChatPage(parent,name,this);

#ifdef GUILE
    m_scm = Scm::getInstance();
#endif

    connect(m_chatpage, SIGNAL(destroyed()),
            this, SLOT(deleteLater()));
}
Exemplo n.º 8
0
/*!  \reimp
*/
void QProcess::connectNotify( const char * signal )
{
#if defined(QT_QPROCESS_DEBUG)
    qDebug( "QProcess::connectNotify(): signal %s has been connected", signal );
#endif
    if ( !ioRedirection )
	if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 ||
		qstrcmp( signal, SIGNAL(readyReadStderr()) )==0
	   ) {
#if defined(QT_QPROCESS_DEBUG)
	    qDebug( "QProcess::connectNotify(): set ioRedirection to TRUE" );
#endif
	    setIoRedirection( TRUE );
	    return;
	}
    if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) {
#if defined(QT_QPROCESS_DEBUG)
	qDebug( "QProcess::connectNotify(): set notifyOnExit to TRUE" );
#endif
	setNotifyOnExit( TRUE );
	return;
    }
    if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) {
#if defined(QT_QPROCESS_DEBUG)
	qDebug( "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" );
#endif
	setWroteStdinConnected( TRUE );
	return;
    }
}
// ------------------------------------------------------------------------
bool OctaveWindow::startOctave()
{
  if(octProcess.isRunning())
    return true;

  QStringList CommandLine;
  CommandLine << "octave" << "--no-history" << "-i" << "-f" << "-p"
	      << QDir::convertSeparators(QucsSettings.OctaveDir);
  octProcess.setArguments(CommandLine);

  disconnect(&octProcess, 0, 0, 0);
  connect(&octProcess, SIGNAL(readyReadStderr()), SLOT(slotDisplayErr()));
  connect(&octProcess, SIGNAL(readyReadStdout()), SLOT(slotDisplayMsg()));
  connect(&octProcess, SIGNAL(processExited()), SLOT(slotOctaveEnded()));

  output->clear();

  if(!octProcess.start()) {
    output->setText(tr("ERROR: Cannot start Octave!"));
    return false;
  }

  adjustDirectory();
  return true;
}
Exemplo n.º 10
0
void TESession::done(int exitStatus)
{
  if (!autoClose)
  {
    userTitle = i18n("<Finished>");
    emit updateTitle(this);
    return;
  }
  if (!wantedClose && (exitStatus || sh->signalled()))
  {
    if (sh->normalExit())
      KNotifyClient::event(winId, "Finished", i18n("Session '%1' exited with status %2.").arg(title).arg(exitStatus));
    else if (sh->signalled())
    {
      if (sh->coreDumped())
        KNotifyClient::event(winId, "Finished", i18n("Session '%1' exited with signal %2 and dumped core.").arg(title).arg(sh->exitSignal()));
      else
        KNotifyClient::event(winId, "Finished", i18n("Session '%1' exited with signal %2.").arg(title).arg(sh->exitSignal()));
    }
    else
      KNotifyClient::event(winId, "Finished", i18n("Session '%1' exited unexpectedly.").arg(title));
  }
  emit processExited(sh);
  emit done(this);
}
Exemplo n.º 11
0
void ExternalLanguage::processExited( K3Process * )
{
	if ( !m_languageProcess )
		return;
	bool allOk = processExited( (m_languageProcess->normalExit()) && (m_errorCount == 0) );
	finish(allOk);
	deleteLanguageProcess();
}
void ApplicationLauncher::consoleProcessError(const QString &error)
{
    emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
    if (d->m_processRunning && d->m_consoleProcess.applicationPID() == 0) {
        d->m_processRunning = false;
        emit processExited(-1);
    }
}
Exemplo n.º 13
0
void ProcessStatusChecker::timeout()
{
//#pragma message("Write this function for unix (leckels)")
#if defined(ESRI_WINDOWS)
   HANDLE proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, mPid);
   if (proc == NULL)
   {
      emit processExited();
   }

   DWORD exitCode = STILL_ACTIVE;
   if (GetExitCodeProcess(proc, &exitCode) == 0 || exitCode != STILL_ACTIVE)
   {
      emit processExited();
   }
   
   CloseHandle(proc);
#endif
}
Exemplo n.º 14
0
void ChatSession::executeShellCommand(const QString& com) {
    //    if (!proc->isRunning()) {
    proc = new QProcess(this);
    QStringList list = QStringList::split(" ",com);
    proc->setArguments(list);
    proc->start();
    connect(proc, SIGNAL(processExited()),
            this, SLOT(deleteProcess()));
    //    }
}
void ConsoleModel::handleProcessFinish(int exitCode, QProcess::ExitStatus status)
{
    if (status == QProcess::CrashExit) { // if it crashed, then use some error exit code
        exitCode = -99999;
        appendLine(tr("** crashed"));

    } else if (exitCode != 0) {
        appendLine(tr("** error: %1").arg(exitCode));
    }
    emit processExited(exitCode);
}
Exemplo n.º 16
0
void ProcessWidget::slotProcessExited(KProcess *)
{
    procLineMaker->flush();
    if( !stdoutbuf.isEmpty() ) 
        insertStdoutLine("");
    if( !stderrbuf.isEmpty() ) 
        insertStderrLine("");
    childFinished(childproc->normalExit(), childproc->exitStatus());
    maybeScrollToBottom();
    emit processExited(childproc);
}
Exemplo n.º 17
0
void COutputWindow::execute(const QString &command)
{
  compiler = new QProcess(this);
  compiler->addArgument(command);


  connect(compiler, SIGNAL(readyReadStderr()), this, SLOT(updateError()));
  connect(compiler, SIGNAL(readyReadStdout()), this, SLOT(updateText()));
  connect(compiler, SIGNAL(processExited()), this, SLOT(updateExit()));
  compiler->start();
  
}
Exemplo n.º 18
0
void K3Process::processHasExited(int state)
{
    // only successfully run NotifyOnExit processes ever get here

    status = state;
    runs = false; // do this before commClose, so it knows we're dead

    commClose(); // cleanup communication sockets

    if (run_mode != DontCare)
      emit processExited(this);
}
Exemplo n.º 19
0
// ------------------------------------------------------------------------
bool SimMessage::startProcess()
{
  Abort->setText(tr("Abort simulation"));
  Display->setDisabled(true);

  ProgText->insert(tr("Starting new simulation on ")+
                   QDate::currentDate().toString("ddd dd. MMM yyyy"));
  ProgText->insert(tr(" at ")+
                   QTime::currentTime().toString("hh:mm:ss")+"\n\n");

  SimProcess.blockSignals(false);
  if(SimProcess.isRunning()) {
    ErrText->insert(tr("ERROR: Simulator is still running!"));
    FinishSimulation(-1);
    return false;
  }

  Collect.clear();  // clear list for NodeSets, SPICE components etc.
  ProgText->insert(tr("creating netlist... "));
  NetlistFile.setName(QucsHomeDir.filePath("netlist.txt"));
   if(!NetlistFile.open(IO_WriteOnly)) {
    ErrText->insert(tr("ERROR: Cannot write netlist file!"));
    FinishSimulation(-1);
    return false;
  }

  Stream.setDevice(&NetlistFile);

  if(!DocWidget->inherits("QTextEdit")) {
    SimPorts =
       ((Schematic*)DocWidget)->prepareNetlist(Stream, Collect, ErrText);
    if(SimPorts < -5) {
      NetlistFile.close();
      FinishSimulation(-1);
      return false;
    }
  }
  Collect.append("*");   // mark the end


  disconnect(&SimProcess, 0, 0, 0);
  connect(&SimProcess, SIGNAL(readyReadStderr()), SLOT(slotDisplayErr()));
  connect(&SimProcess, SIGNAL(readyReadStdout()),
                       SLOT(slotReadSpiceNetlist()));
  connect(&SimProcess, SIGNAL(processExited()),
                       SLOT(slotFinishSpiceNetlist()));

  nextSPICE();
  return true;
  // Since now, the Doc pointer may be obsolete, as the user could have
  // closed the schematic !!!
}
Exemplo n.º 20
0
void MidiPlayerThread::processFinished()
{
    qDebug() << "MidiPlayerThread::processFinished";

    m_isFinished = true;
    // Send this signal before the endoffile one, otherwise
    // the playlist will start to play next file before all
    // objects are notified that the process has exited.
    emit processExited();
    if ( m_received_end_of_file ) {
        emit receivedEndOfFile();
    }
}
Exemplo n.º 21
0
bool QProcess::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: readyReadStdout(); break;
    case 1: readyReadStderr(); break;
    case 2: processExited(); break;
    case 3: wroteToStdin(); break;
    case 4: launchFinished(); break;
    default:
	return QObject::qt_emit(_id,_o);
    }
    return TRUE;
}
QString KSimpleProcess::execInternal( const QString &args, bool addStdError)
{
	m_proc->setArguments( splitArgList( args ));
	connect(m_proc, SIGNAL(processExited()), this, SLOT(slotProcessExited()));
	connect(m_proc, SIGNAL(readyReadStdout()), this, SLOT(slotReceivedStdout()));
	if( addStdError )
		connect(m_proc, SIGNAL(readyReadStderr()), this, SLOT(slotReceivedStderr()));

	if ( !m_proc->start()  )
		return i18n("Could not run command '%1'.").arg( args.latin1() );
	enter_loop();
	return m_currBuffer;
}
Exemplo n.º 23
0
void qt4encodeWnd::demarrerA( )
{
	cbKeep->setChecked( true );
	cbKeep->show();
	pbClose->show();
	setWindowTitle( "Authoring " );
	setModal( true );
	teAuthor->clear();
	connect( procEncode, SIGNAL(readyReadStderr()),
						this, SLOT(readAuthor()));
	connect( procEncode, SIGNAL(processExited()),
						this, SLOT(endAuthor()));
	exec();
}
void ApplicationLauncher::guiProcessError()
{
    QString error;
    switch (d->m_guiProcess.error()) {
    case QProcess::FailedToStart:
        error = tr("Failed to start program. Path or permissions wrong?");
        break;
    case QProcess::Crashed:
        error = tr("The program has unexpectedly finished.");
        break;
    default:
        error = tr("Some error has occurred while running the program.");
    }
    emit appendMessage(error + QLatin1Char('\n'), Utils::ErrorMessageFormat);
    if (d->m_processRunning && !isRunning()) {
        d->m_processRunning = false;
        emit processExited(-1);
    }
}
Exemplo n.º 25
0
void qt4encodeWnd::demarrer(QString fn, int tf )
{
	cbKeep->setChecked( false);
	cbKeep->hide();
	pbClose->hide();
	setWindowTitle( "Encoding to vob" );
	setModal( true );
	//FIXME teAuthor->setMaxLogLines(1000);
	teAuthor->clear();
	teAuthor->append( fn );
	pbEncode->setMaximum( tf );
	connect( procEncode, SIGNAL(readyReadStdout()),
						this, SLOT(readEncode()));
	connect( procEncode, SIGNAL(readyReadStderr()),
						this, SLOT(readEncMpeg()));
	connect( procEncode, SIGNAL(processExited()),
						this, SLOT(accept()));
	exec();
}
Exemplo n.º 26
0
void GenGraphForm::runTask()
{
    QStringList argv = tasks.front();
    tasks.pop_front();
    exportButton->setText("&Kill");
    QString cmd = argv.join(QString(" "));
    std::cout << "STARTING TASK " << (const char*)cmd << std::endl;
#ifdef SOFA_QT4
    QProcess* p = new QProcess(this);
    QString program = argv.front();
    argv.pop_front();
    p->setReadChannelMode(QProcess::ForwardedChannels);
    connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(taskFinished()));
    p->start(program, argv);
#else
    QProcess* p = new QProcess(argv, this);
    p->setCommunication(0);
    connect(p,SIGNAL(processExited()),this,SLOT(taskFinished()));
    p->start();
#endif
    currentTask = p;
}
Exemplo n.º 27
0
void GenGraphForm::doDisplay()
{
    if (exportedFile==QString("")) return;

    std::cout << "OPEN " << (const char*)exportedFile << std::endl;

#ifdef WIN32
    ShellExecuteA(NULL, "open", exportedFile, NULL, NULL, SW_SHOWNORMAL);
#else
    QStringList argv;
    argv << "display" << exportedFile;
#ifdef SOFA_QT4
    QString program = argv.front();
    argv.pop_front();
    //QProcess::startDetached(program, argv); //QString("start \"\"\"")+exportedFile+QString("\"\"\""));
    QProcess::startDetached(program, argv); //QString("start \"\"\"")+exportedFile+QString("\"\"\""));
#else
    QProcess* p = new QProcess(argv, this);
    p->setCommunication(0);
    connect(p,SIGNAL(processExited()),p,SLOT(deleteLater()));
    p->start();
#endif
#endif
}
Exemplo n.º 28
0
/*
  Use a timer for polling misc. stuff.
*/
void Q3Process::timeout()
{
    // Disable the timer temporary since one of the slots that are connected to
    // the readyRead...(), etc. signals might trigger recursion if
    // processEvents() is called.
    d->lookup->stop();

    // try to write pending data to stdin
    if ( !d->stdinBuf.isEmpty() )
	socketWrite( 0 );

    if ( ioRedirection ) {
	socketRead( 1 ); // try stdout
	socketRead( 2 ); // try stderr
    }

    if ( isRunning() ) {
	// enable timer again, if needed
	if ( !d->stdinBuf.isEmpty() || ioRedirection || notifyOnExit )
	    d->lookup->start( 100 );
    } else if ( notifyOnExit ) {
	emit processExited();
    }
}
Exemplo n.º 29
0
/*!  \reimp
*/
void QProcess::disconnectNotify( const char * )
{
    if ( ioRedirection &&
	    receivers( SIGNAL(readyReadStdout()) ) ==0 &&
	    receivers( SIGNAL(readyReadStderr()) ) ==0
	    ) {
#if defined(QT_QPROCESS_DEBUG)
	qDebug( "QProcess::disconnectNotify(): set ioRedirection to FALSE" );
#endif
	setIoRedirection( FALSE );
    }
    if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) {
#if defined(QT_QPROCESS_DEBUG)
	qDebug( "QProcess::disconnectNotify(): set notifyOnExit to FALSE" );
#endif
	setNotifyOnExit( FALSE );
    }
    if ( wroteToStdinConnected && receivers( SIGNAL(wroteToStdin()) ) == 0 ) {
#if defined(QT_QPROCESS_DEBUG)
	qDebug( "QProcess::disconnectNotify(): set wroteToStdinConnected to FALSE" );
#endif
	setWroteStdinConnected( FALSE );
    }
}
void ApplicationLauncher::processDone(int exitCode, QProcess::ExitStatus)
{
    emit processExited(exitCode);
}