Exemplo n.º 1
0
void TIconView::slotItemSelected( QIconViewItem* item )
{
    // kdWarning() << "LU LU LU I got some apple" << endl;
    TIconViewItem *_item = static_cast<TIconViewItem*>( item );
    KSimpleConfig cfg(_item->moduleinfo()->fileName(),true);
    cfg.setDesktopGroup();

    if(cfg.readBoolEntry("X-Tasma-Fork"))
    {
        KProcess proc;
        QStringList args = QStringList::split(QRegExp("\\s{1}"),cfg.readEntry("Exec"));

        QStringList::ConstIterator it = args.constBegin();

        while( it != args.constEnd() )
        {
            if (!(*it).startsWith("%"))
                proc << *it;
            ++it;
        }

        proc.start(KProcess::DontCare);
        return;
    }

    _module = KCModuleLoader::loadModule( *( _item->moduleinfo() ), KCModuleLoader::Dialog );

    if ( _module ) {
        emit signalModuleSelected( _module, _item->moduleinfo()->icon(), _item->text(),
                                   _item->moduleinfo()->fileName(), _item->moduleinfo()->needsRootPrivileges());
    }
}
Exemplo n.º 2
0
// if it's e.g. just 'www', try if it's a hostname in the local search domain
bool LocalDomainURIFilter::isLocalDomainHost( QString& cmd ) const
{
    // find() returns -1 when no match -> left()/truncate() are noops then
    QString host( cmd.left( cmd.find( '/' ) ) );
    host.truncate( host.find( ':' ) ); // Remove port number

    if( !(host == last_host && last_time > time( NULL ) - 5 ) ) {

        QString helper = KStandardDirs::findExe(QString::fromLatin1( "klocaldomainurifilterhelper" ));
        if( helper.isEmpty())
            return last_result = false;

        m_fullname = QString::null;

        KProcess proc;
        proc << helper << host;
        connect( &proc, SIGNAL(receivedStdout(KProcess *, char *, int)),
                 SLOT(receiveOutput(KProcess *, char *, int)) );
        if( !proc.start( KProcess::NotifyOnExit, KProcess::Stdout ))
            return last_result = false;

        last_host = host;
        last_time = time( (time_t *)0 );

        last_result = proc.wait( 1 ) && proc.normalExit() && !proc.exitStatus();

        if( !m_fullname.isEmpty() )
            cmd.replace( 0, host.length(), m_fullname );
    }
Exemplo n.º 3
0
bool KNewStuffGeneric::install( const QString &fileName )
{
  kdDebug() << "KNewStuffGeneric::install(): " << fileName << endl;
  QStringList list, list2;

  mConfig->setGroup("KNewStuff");

  QString uncompress = mConfig->readEntry( "Uncompress" );
  if ( !uncompress.isEmpty() ) {
    kdDebug() << "Uncompression method: " << uncompress << endl;
    KTar tar(fileName, uncompress);
    tar.open(IO_ReadOnly);
    const KArchiveDirectory *dir = tar.directory();
    dir->copyTo(destinationPath(0));
    tar.close();
    QFile::remove(fileName);
  }

  QString cmd = mConfig->readEntry( "InstallationCommand" );
  if ( !cmd.isEmpty() ) {
    kdDebug() << "InstallationCommand: " << cmd << endl;
    list = QStringList::split( " ", cmd );
    for ( QStringList::iterator it = list.begin(); it != list.end(); ++it ) {
        list2 << (*it).replace("%f", fileName);
    }
    KProcess proc;
    proc << list2;
    proc.start( KProcess::Block );
  }

  return true;
}
Exemplo n.º 4
0
QString OcrGocrDialog::version()
{
    kDebug() << "of" << m_ocrCmd;

    QString vers;

    KProcess proc;
    proc.setOutputChannelMode(KProcess::MergedChannels);
    proc << m_ocrCmd << "-h";

    int status = proc.execute(5000);
    if (status==0)
    {
        QByteArray output = proc.readAllStandardOutput();
        QRegExp rx("-- gocr ([\\d\\.\\s]+)");
        if (rx.indexIn(output)>-1) vers = rx.cap(1);
        else vers = i18n("Unknown");
    }
    else
    {
        kDebug() << "failed with status" << status;
        vers = i18n("Error");
    }

    return (vers);
}
Exemplo n.º 5
0
static
void executeXmodmap(const QString& configFileName)
{
    if( xmodmapNotFound )
        return;

    if( QFile(configFileName).exists() ) {
        if( xmodmapExe.isEmpty() ) {
            xmodmapExe = QStandardPaths::findExecutable(XMODMAP_EXEC);
            if( xmodmapExe.isEmpty() ) {
                xmodmapNotFound = true;
                qCritical() << "Can't find" << XMODMAP_EXEC << "- xmodmap files won't be run";
                return;
            }
        }

        KProcess xmodmapProcess;
        xmodmapProcess << xmodmapExe;
        xmodmapProcess << configFileName;
        qCDebug(KCM_KEYBOARD) << "Executing" << xmodmapProcess.program().join(QStringLiteral(" "));
        if( xmodmapProcess.execute() != 0 ) {
            qCritical() << "Failed to execute " << xmodmapProcess.program();
        }
    }
}
Exemplo n.º 6
0
bool K3b::mount( K3bDevice::Device* dev )
{
  if( !dev )
    return false;

  QString mntDev = dev->blockDeviceName();

#if KDE_IS_VERSION(3,4,0)
  // first try to mount it the standard way
  if( KIO::NetAccess::synchronousRun( KIO::mount( true, 0, mntDev, false ), 0 ) )
    return true;
#endif

#ifdef HAVE_HAL
  if( !K3bDevice::HalConnection::instance()->mount( dev ) )
    return true;
#endif

  // now try pmount
  QString pmountBin = K3b::findExe( "pmount" );
  if( !pmountBin.isEmpty() ) {
    KProcess p;
    p << pmountBin;
    p << mntDev;
    p.start( KProcess::Block );
    return !p.exitStatus();
  }
  return false;
}
Exemplo n.º 7
0
void DockBarExtension::loadContainerConfig()
{
    KConfig *conf = config();
    conf->setGroup("General");
    QStringList applets = conf->readListEntry("Applets");

    QStringList fail_list;
    for(QStringList::Iterator it = applets.begin(); it != applets.end(); ++it)
    {
        if(!conf->hasGroup(*it))
            continue;
        conf->setGroup(*it);
        QString cmd = conf->readPathEntry("Command");
        QString resName = conf->readPathEntry("resName");
        QString resClass = conf->readEntry("resClass");
        if(cmd.isEmpty() || resName.isEmpty() || resClass.isEmpty())
            continue;

        DockContainer *c = new DockContainer(cmd, this, resName, resClass);
        addContainer(c);

        KProcess proc;
        proc << KShell::splitArgs(cmd);
        if(!proc.start(KProcess::DontCare))
        {
            fail_list.append(cmd);
            removeContainer(c);
        }
    }
    if(!fail_list.isEmpty())
        KMessageBox::queuedMessageBox(0, KMessageBox::Information,
                                      i18n("The following dockbar applets could not be started: %1").arg(fail_list.join(", ")),
                                      i18n("kicker: information"), 0);
    saveContainerConfig();
}
Exemplo n.º 8
0
void KSSLInfoDlg::launchConfig()
{
    KProcess p;
    p << "kcmshell"
      << "crypto";
    p.start(KProcess::DontCare);
}
Exemplo n.º 9
0
bool MediaNotifier::execAutorun(const KFileItem &medium, const QString &path, const QString &autorunFile)
{
    // The desktop environment MUST prompt the user for confirmation
    // before automatically starting an application.
    QString mediumType = medium.mimeTypePtr()->name();
    QString text = i18n(
                       "An autorun file has been found on your '%1'."
                       " Do you want to execute it?\n"
                       "Note that executing a file on a medium may compromise"
                       " your system's security")
                   .arg(mediumType);
    QString caption = i18n("Autorun - %1").arg(medium.url().prettyURL());
    KGuiItem yes = KStdGuiItem::yes();
    KGuiItem no = KStdGuiItem::no();
    int options = KMessageBox::Notify | KMessageBox::Dangerous;

    int answer = KMessageBox::warningYesNo(0L, text, caption, yes, no, QString::null, options);

    if(answer == KMessageBox::Yes)
    {
        // When an Autostart file has been detected and the user has
        // confirmed its execution the autostart file MUST be executed
        // with the current working directory ( CWD ) set to the root
        // directory of the medium.
        KProcess proc;
        proc << "sh" << autorunFile;
        proc.setWorkingDirectory(path);
        proc.start();
        proc.detach();
    }

    return true;
}
Exemplo n.º 10
0
void BupSlave::listDir(const KUrl& pUrl) {
	KProcess lP;
	lP <<"logger" <<"listdir: " <<pUrl.url();
	lP.execute();

	if(!checkRunnningFuse(pUrl) || !pUrl.path(KUrl::AddTrailingSlash).startsWith(mFuseRunner->mRepoPath)) {
		error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl()));
		return;
	}

	QString lPathInRepo = pUrl.path();
	lPathInRepo.remove(0, mFuseRunner->mRepoPath.length());
	fileListDir(KUrl::fromPath(mFuseRunner->mMountPath + lPathInRepo));


//	const QByteArray _path(QFile::encodeName("/tmp/lala"));
//	KProcess p;
//	p <<"logger" <<"filelistdir listing: " <<_path;
//	p.execute();

//	DIR* dp = opendir(_path.data());
//	struct dirent *ep;
//	while ( ( ep = readdir( dp ) ) != 0 ) {
//		KProcess lP;
//		lP <<"logger" <<"filelistdir listed: " <<ep->d_name;
//		lP.execute();
//	}

//	closedir( dp );

}
Exemplo n.º 11
0
bool BupSlave::checkRunnningFuse(const KUrl &pUrl) {

	if(mFuseRunner) {
		KProcess lP;
		lP <<"logger" <<"checking: " <<pUrl.path(KUrl::RemoveTrailingSlash) <<mFuseRunner->mRepoPath <<(mFuseRunner->mRunning ? "true": "false");
		lP.execute();

		if(mFuseRunner->mRunning)// && pUrl.path(KUrl::AddTrailingSlash).startsWith(mFuseRunner->mRepoPath))
			return true;
		else
			delete mFuseRunner;
	}

	QString lPath = pUrl.path(KUrl::RemoveTrailingSlash);
	QStringList lPathElements = lPath.split('/');
	QString lRepoPath;
	bool lFound = false;
//	error(KIO::ERR_SLAVE_DEFINED, QString("%1 elements.").arg(lPathElements.count()));
	foreach(QString lPathElement, lPathElements) {
		lRepoPath += lPathElement + "/";
		qDebug() <<"trying repo path: " << lRepoPath;
		if(QFile::exists(lRepoPath + "objects/pack/bup.bloom")) {
			lFound = true;
			break;
		}
	}
Exemplo n.º 12
0
/** No descriptions */
bool KCountryPage::save(KLanguageButton *comboCountry, KLanguageButton *comboLang) {
	kdDebug() << "KCountryPage::save()" << endl;
	KConfigBase *config = KGlobal::config();

	config->setGroup(QString::fromLatin1("Locale"));
	config->writeEntry(QString::fromLatin1("Country"), comboCountry->current(), true, true);
	config->writeEntry(QString::fromLatin1("Language"), comboLang->current(), true, true);
	config->sync();

	// only make the system reload the language, if the selected one deferes from the old saved one.
	if (b_savedLanguageChanged) {
		// Tell kdesktop about the new language
		QCString replyType; QByteArray replyData;
		QByteArray data, da;
		QDataStream stream( data, IO_WriteOnly );
		stream << comboLang->current();
		if ( !kapp->dcopClient()->isAttached() )
			kapp->dcopClient()->attach();
		// ksycoca needs to be rebuilt
		KProcess proc;
		proc << QString::fromLatin1("kbuildsycoca");
		proc.start(KProcess::DontCare);
		kdDebug() << "KLocaleConfig::save : sending signal to kdesktop" << endl;
		// inform kicker and kdeskop about the new language
		kapp->dcopClient()->send( "kicker", "Panel", "restart()", QString::null);
		// call, not send, so that we know it's done before coming back
		// (we both access kdeglobals...)
		kapp->dcopClient()->call( "kdesktop", "KDesktopIface", "languageChanged(QString)", data, replyType, replyData );
	}
	// KPersonalizer::next() probably waits for a return-value
	return true;
}
Exemplo n.º 13
0
bool EncoderLame::init(){
	// Determine if lame is installed on the system or not.
	if ( KStandardDirs::findExe( "lame" ).isEmpty() )
		return false;

	// Ask lame for the list of genres it knows; otherwise it barfs when doing
	// e.g. lame --tg 'Vocal Jazz'
	KProcess proc;
	proc.setOutputChannelMode(KProcess::MergedChannels);
	proc << "lame" << "--genre-list";
	proc.execute();

	if(proc.exitStatus() != QProcess::NormalExit)
		return false;

	QByteArray array = proc.readAll();
	QString str = QString::fromLocal8Bit( array );
	d->genreList = str.split( '\n', QString::SkipEmptyParts );
	// Remove the numbers in front of every genre
	for( QStringList::Iterator it = d->genreList.begin(); it != d->genreList.end(); ++it ) {
		QString& genre = *it;
		int i = 0;
		while ( i < genre.length() && ( genre[i].isSpace() || genre[i].isDigit() ) )
			++i;
		genre = genre.mid( i );

	}
	//kDebug(7117) << "Available genres:" << d->genreList;

	return true;
}
Exemplo n.º 14
0
void KTTSDlibSetupImpl::slotLaunchControlcenter()
{
    kdDebug(100200) << "KTTSDlibSetupImpl::slotLaunchControlCenter()" << endl;

    // check if controllcenter module for KTTSD exists
    FILE *fp;
    char cmdresult[20];

    // if ( (fp = popen("kcmshell --list | grep kcmkttsmgr", "r")) != NULL){
    if ( (fp = popen("kcmshell --list | grep kcmkttsd", "r")) != NULL) {
        fgets(cmdresult, 18, fp);
        pclose(fp);
    }
    if ( !QCString(cmdresult).contains("kcmkttsd") ) {
        QString error = i18n("Control Center Module for KTTSD not found.");
        KMessageBox::sorry(this, error, i18n("Problem"));
        return;
    }

    // invoke the Control Center Module
    KProcess *kcmproc = new KProcess();
    connect(kcmproc, SIGNAL(processExited(KProcess*)),
            this, SLOT(slotKCMProcessExited(KProcess*)) );
    (*kcmproc) << "kcmshell";
    (*kcmproc) << "kcmkttsd";
    kcmproc->start(KProcess::NotifyOnExit);

    kcm_Button->setEnabled(false);
}
Exemplo n.º 15
0
void ZipArch::open()
{
    setHeaders();

    m_buffer = "";
    m_header_removed = false;
    m_finished = false;

    KProcess *kp = m_currentProcess = new KProcess;

    *kp << m_unarchiver_program << "-v" << m_filename;

    connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
             SLOT( slotReceivedTOC(KProcess*, char*, int) ) );
    connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
             SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
    connect( kp, SIGNAL( processExited(KProcess*) ),
             SLOT( slotOpenExited(KProcess*) ) );

    if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
    {
        KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
        emit sigOpen( this, false, QString::null, 0 );
    }
}
void AdminDatabase::modifyButtonClicked() // RESTORE
{
	std::cout << "Restoring backup..." << std::endl;
	if ( m_havePsql )
	{
		KProcess *proc = new KProcess(this);
		
		*proc << "psql";
		*proc << "-h" << klapp->config("Connection")->readEntry("Server", "localhost");
		*proc << "-U" << klapp->config("Connection")->readEntry("Login");
		*proc << klapp->config("Connection")->readEntry("Database");
		*proc << "-f" << m_dumpDir->absPath()+"/"+"backup-"+QDate::currentDate().toString(Qt::ISODate)+".sql"; // TODO: Cambiar esto
		
// 		connect(proc, SIGNAL(receivedStdout (KProcess *, char *, int )), this, SLOT(makeDump(KProcess *, char *, int ) ));
// 		connect(proc, SIGNAL(processExited(KProcess *)), this, SLOT(saveBackup(KProcess *)));
		
		LOGGER->log(i18n("Making backup"), KLLogger::Inf);
		
		proc->start(/*KProcess::NotifyOnExit , KProcess::Stdout*/);
	}
	else
	{
		QString error = "";
		if ( ! m_havePsql )
			error += "You doesn't have the command psql\n";
// 		if ( !m_havePsql)
// 			error += "You doesn't have the command psql\n";
		
		KMessageBox::detailedSorry (0, i18n("I can't restore the database!"), error);
	}
}
Exemplo n.º 17
0
bool HelpWidget::clicked(const QString &_url)
{
    if(_url.isNull())
        return true;

    if(_url.find('@') > -1)
    {
        kapp->invokeMailer(_url);
        return true;
    }

    KProcess process;
    KURL url(KURL("help:/"), _url);

    if(url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info")
    {
        process << "khelpcenter" << url.url();
        process.start(KProcess::DontCare);
    }
    else
    {
        new KRun(url);
    }
    return true;
}
Exemplo n.º 18
0
void SMSClient::send(const Kopete::Message& msg)
{
	kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
	if (!m_account) return;

	m_msg = msg;
	
	KConfigGroup* c = m_account->configGroup();
	QString provider = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProviderName"), QString::null);

	if (provider.isNull())
	{
		KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("No provider configured"), i18n("Could Not Send Message"));
		return;
	}

	QString programName = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProgramName"). QString::null);
	if (programName.isNull())
		programName = "/usr/bin/sms_client";

	KProcess* p = new KProcess;

	QString message = msg.plainBody();
	QString nr = msg.to().first()->contactId();

	*p << programName;
	*p << provider + ":" + nr;
	*p << message;

	QObject::connect(p, SIGNAL(processExited(KProcess *)), this, SLOT(slotSendFinished(KProcess*)));
	QObject::connect(p, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
	QObject::connect(p, SIGNAL(receivedStderr(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));

	p->start(KProcess::Block, KProcess::AllOutput);
}
Exemplo n.º 19
0
void TOC::buildCache()
{
    KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );

    KProcess *meinproc = new KProcess;
    connect( meinproc, SIGNAL( finished( int, QProcess::ExitStatus) ),
             this, SLOT( meinprocExited( int, QProcess::ExitStatus) ) );

    *meinproc << KStandardDirs::locate("exe", "meinproc4");
    *meinproc << "--stylesheet" << KStandardDirs::locate( "data", "khelpcenter/table-of-contents.xslt" );
    *meinproc << "--output" << m_cacheFile;
    *meinproc << m_sourceFile;

    meinproc->setOutputChannelMode(KProcess::OnlyStderrChannel);
    meinproc->start();
    if (!meinproc->waitForStarted()) {
        kError() << "could not start process" << meinproc->program();
        if (mainWindow && !m_alreadyWarned) {
            ; // add warning message box with don't display again option 
              // http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classKDialog.html
            m_alreadyWarned = true;
        }
        delete meinproc;
    }
}
Exemplo n.º 20
0
void KProcessController::slotDoHousekeeping(int )
{
  KProcess *proc;
  int bytes_read;
  pid_t pid;
  int status;

  bytes_read  = ::read(fd[0], &pid, sizeof(pid_t));
  bytes_read += ::read(fd[0], &status, sizeof(int));

  if (bytes_read != sizeof(int)+sizeof(pid_t))
	fprintf(stderr,"Error: Could not read info from signal handler!\n");
 
  proc = processList->first();

  while (0L != proc) {
	if (proc->pid == pid) {
	  // process has exited, so do emit the respective events
	  if (proc->run_mode == KProcess::Block) {
	    // If the reads are done blocking then set the status in proc
	    // but do nothing else because KProcess will perform the other
	    // actions of processHasExited.
	    proc->status = status;
	  } else {
	    proc->processHasExited(status);
	  }
	}
	proc = processList->next();
  }
}
Exemplo n.º 21
0
void IndexBuilder::processCmdQueue()
{
  kDebug(1402) << "IndexBuilder::processCmdQueue()";

  QStringList::Iterator it = mCmdQueue.begin();

  if ( it == mCmdQueue.end() ) {
    quit();
    return;
  }

  QString cmd = *it;

  kDebug(1402) << "PROCESS: " << cmd;

  KProcess *proc = new KProcess;

  *proc << KShell::splitArgs(cmd);

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

  mCmdQueue.erase( it );

  proc->start();

  if ( !proc->waitForStarted() )  {
    sendErrorSignal( i18n("Unable to start command '%1'.", cmd ) );
    processCmdQueue();
    delete proc;
  }
}
Exemplo n.º 22
0
void IndexBuilder::processCmdQueue()
{
    kdDebug(1402) << "IndexBuilder::processCmdQueue()" << endl;

    QStringList::Iterator it = mCmdQueue.begin();

    if(it == mCmdQueue.end())
    {
        quit();
        return;
    }

    QString cmd = *it;

    kdDebug(1402) << "PROCESS: " << cmd << endl;

    KProcess *proc = new KProcess;
    proc->setRunPrivileged(true);

    QStringList args = QStringList::split(" ", cmd);
    *proc << args;


    connect(proc, SIGNAL(processExited(KProcess *)), SLOT(slotProcessExited(KProcess *)));
    connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)), SLOT(slotReceivedStdout(KProcess *, char *, int)));
    connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)), SLOT(slotReceivedStderr(KProcess *, char *, int)));

    mCmdQueue.remove(it);

    if(!proc->start(KProcess::NotifyOnExit, KProcess::AllOutput))
    {
        sendErrorSignal(i18n("Unable to start command '%1'.").arg(cmd));
        processCmdQueue();
    }
}
Exemplo n.º 23
0
void NotifyByExecute::notify( int id, KNotifyConfig * config )
{
	QString command=config->readEntry( "Execute" );
	
	kDebug() << command;
	
	if (!command.isEmpty()) {
// 	kDebug() << "executing command '" << command << "'";
		QHash<QChar,QString> subst;
		subst.insert( 'e', config->eventid );
		subst.insert( 'a', config->appname );
		subst.insert( 's', config->text );
		subst.insert( 'w', QString::number( (quintptr)config->winId ));
		subst.insert( 'i', QString::number( id ));
		QString execLine = KMacroExpander::expandMacrosShellQuote( command, subst );
		if ( execLine.isEmpty() )
			execLine = command; // fallback
                KProcess proc;
		proc.setShellCommand(execLine.trimmed());
		if(!proc.startDetached())
			kDebug()<<"KNotify: Could not start process!";
	}
	
	finish( id );
}
Exemplo n.º 24
0
bool KNotify::notifyBySound(const QString &sound, const QString &appname, int eventId)
{
    if(sound.isEmpty())
    {
        soundFinished(eventId, NoSoundFile);
        return false;
    }

    bool external = d->useExternal && !d->externalPlayer.isEmpty();
    // get file name
    QString soundFile(sound);
    if(QFileInfo(sound).isRelative())
    {
        QString search = QString("%1/sounds/%2").arg(appname).arg(sound);
        soundFile = KGlobal::instance()->dirs()->findResource("data", search);
        if(soundFile.isEmpty())
            soundFile = locate("sound", sound);
    }
    if(soundFile.isEmpty())
    {
        soundFinished(eventId, NoSoundFile);
        return false;
    }

    // kdDebug() << "KNotify::notifyBySound - trying to play file " << soundFile << endl;

    if(!external)
    {
#ifdef WITH_PULSEAUDIO
        d->pulsePlayer.play(soundFile.utf8());
        return true;
#else
        soundFinished(eventId, NoSoundSupport);
        return false;
#endif
    }
    else if(!d->externalPlayer.isEmpty())
    {
        // use an external player to play the sound
        KProcess *proc = d->externalPlayerProc;
        if(!proc)
        {
            proc = d->externalPlayerProc = new KProcess;
            connect(proc, SIGNAL(processExited(KProcess *)), SLOT(slotPlayerProcessExited(KProcess *)));
        }
        if(proc->isRunning())
        {
            soundFinished(eventId, PlayerBusy);
            return false; // Skip
        }
        proc->clearArguments();
        (*proc) << d->externalPlayer << QFile::encodeName(soundFile);
        d->externalPlayerEventId = eventId;
        proc->start(KProcess::NotifyOnExit);
        return true;
    }

    soundFinished(eventId, Unknown);
    return false;
}
Exemplo n.º 25
0
QString unquoteWord(const QString &word)
{
    if (word.isEmpty()) {
        return QString();
    }

    KProcess echo;
    echo.setShellCommand(QString(QLatin1String("echo -n %1")).arg(word));
    echo.setOutputChannelMode(KProcess::OnlyStdoutChannel);
    if (echo.execute() == 0) {
        return QString::fromLocal8Bit(echo.readAllStandardOutput().constData());
    }

    QChar ch;
    QString quotedWord = word, unquotedWord;
    QTextStream stream(&quotedWord, QIODevice::ReadOnly | QIODevice::Text);
    while (!stream.atEnd()) {
        stream >> ch;
        if (ch == QLatin1Char('\'')) {
            Q_FOREVER {
                if (stream.atEnd()) {
                    return QString();
                }
                stream >> ch;
                if (ch == QLatin1Char('\'')) {
                    return unquotedWord;
                } else {
                    unquotedWord.append(ch);
                }
            }
        } else if (ch == QLatin1Char('"')) {
Exemplo n.º 26
0
/* check if starting realtime would be possible */
bool KArtsModule::realtimeIsPossible()
{
	static bool checked = false;
	if (!checked)
	{
	KProcess* checkProcess = new KProcess();
	*checkProcess << "artswrapper";
	*checkProcess << "check";

	connect(checkProcess, SIGNAL(processExited(KProcess*)),
	        this, SLOT(slotArtsdExited(KProcess*)));
	if (!checkProcess->start(KProcess::Block))
	{
		delete checkProcess;
		realtimePossible =  false;
	}
	else if (latestProcessStatus == 0)
	{
		realtimePossible =  true;
	}
	else
	{
		realtimePossible =  false;
	}

	checked = true;

	}
Exemplo n.º 27
0
SambaShare* SambaFile::getTestParmValues(bool reload)
{
  if (_testParmValues && !reload)
    return _testParmValues;


  KProcess testParam;
  testParam << "testparm";
  testParam << "-s"; 
  
  if (getSambaVersion() == 3)
     testParam << "-v";


  testParam << "/dev/null";
  _parmOutput = QString("");
  
  connect( &testParam, SIGNAL(receivedStdout(KProcess*,char*,int)),
          this, SLOT(testParmStdOutReceived(KProcess*,char*,int)));

  if (testParam.start(KProcess::Block,KProcess::Stdout))
  {
    parseParmStdOutput();
  } else
    _testParmValues = new SambaShare(_sambaConfig);

  return _testParmValues;
}
Exemplo n.º 28
0
/*
 * Free up authentication data.
 */
void FreeAuthenticationData(int count, IceAuthDataEntry *authDataEntries)
{
    /* Each transport has entries for ICE and XSMP */
    if (only_local)
        return;

    for (int i = 0; i < count * 2; i++) {
        free (authDataEntries[i].network_id);
        free (authDataEntries[i].auth_data);
    }

    free (authDataEntries);

    QString iceAuth = KGlobal::dirs()->findExe("iceauth");
    if (iceAuth.isEmpty())
    {
        qWarning("KSMServer: could not find iceauth");
        return;
    }

    if (remTempFile)
    {
        KProcess p;
        p << iceAuth << "source" << remTempFile->fileName();
        p.execute();
    }

    delete remTempFile;
    remTempFile = 0;
}
Exemplo n.º 29
0
void ZooArch::remove( QStringList *list )
{
  if (!list)
    return;

  KProcess *kp = m_currentProcess = new KProcess;
  kp->clearArguments();

  *kp << m_archiver_program << "D" << m_filename;

  QStringList::Iterator it;
  for ( it = list->begin(); it != list->end(); ++it )
  {
    QString str = *it;
    *kp << str;
  }

  connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
  connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
  connect( kp, SIGNAL( processExited(KProcess*) ),
           SLOT( slotDeleteExited(KProcess*) ) );

  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
  {
    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
    emit sigDelete( false );
  }
}
void InformationcenterApplet::slotrun()
{
    KProcess proc;

    proc << locate("exe", "ksysguard");
    proc.start(KProcess::DontCare);
}