コード例 #1
0
ファイル: k3bglobals.cpp プロジェクト: franhaufer/k3b
bool K3b::unmount( K3b::Device::Device* dev )
{
    if( !dev )
        return false;

    Solid::StorageAccess *sa = dev->solidStorage();
    if ( sa && sa->teardown() ){
        return true;
    }

    QString mntDev = dev->blockDeviceName();

    // first try to unmount it the standard way
    if( KIO::NetAccess::synchronousRun( KIO::unmount( mntDev ), 0 ) )
        return true;

    QString mntPath;
    if ( KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByDevice( dev->blockDeviceName() ) ) {
        mntPath = mp->mountPoint();
    }
    if ( mntPath.isEmpty() ) {
        mntPath = dev->blockDeviceName();
    }

    QString umountBin = K3b::findExe( "umount" );
    if( !umountBin.isEmpty() ) {
        KProcess p;
        p << umountBin;
        p << "-l"; // lazy unmount
        p << mntPath;
        p.start();
        if (p.waitForFinished(-1))
          return true;
    }

    // now try pmount
    QString pumountBin = K3b::findExe( "pumount" );
    if( !pumountBin.isEmpty() ) {
        KProcess p;
        p << pumountBin;
        p << "-l"; // lazy unmount
        p << mntPath;
        p.start();
        return p.waitForFinished(-1);
    }
    else {
        return false;
    }
}
コード例 #2
0
void SqlBackendTest::allTests()
{
	QString dbname = "test";

	Classes::setup();

	// Drop the database if already exists
	KProcess *proc = new KProcess;
	*proc << "dropdb";
	*proc << dbname;
	proc->start();
	proc->wait();
	delete proc;

	// Create the database
	proc = new KProcess;
	*proc << "createdb";
	*proc << dbname;
	CHECK( proc->start(), true );
	proc->wait();
	if ( ! proc->normalExit() || proc->exitStatus() != 0 ) {
		CHECK( true, false );
		delete proc;
		return;
	}
	delete proc;

	QSqlDatabase *db = QSqlDatabase::addDatabase( "QPSQL7" );
	db->setDatabaseName( dbname );
	db->setUserName( "albert" );
	db->setPassword( "" );
	db->setHostName( "localhost" );
	if ( ! db->open() ) {
		kdDebug() << "Failed to open database: " << db->lastError().text() << endl;
		return;
	}
	DbBackendIface *backend = new SqlDbBackend( db );

	m_manager = new Manager( backend );
	m_manager->createSchema();

	transactions();
	collections();
	cache();
	freeing();
	testRelations();

	delete m_manager;
}
コード例 #3
0
bool KFileShare::setShared(const QString &path, bool shared)
{
    if(!KFileShare::sharingEnabled() || KFileShare::shareMode() == Advanced)
        return false;

    kdDebug(7000) << "KFileShare::setShared " << path << "," << shared << endl;
    QString exe = KFileShare::findExe("fileshareset");
    if(exe.isEmpty())
        return false;

    KProcess proc;
    proc << exe;
    if(shared)
        proc << "--add";
    else
        proc << "--remove";
    proc << path;
    proc.start(KProcess::Block); // should be ok, the perl script terminates fast
    bool ok = proc.normalExit() && (proc.exitStatus() == 0);
    kdDebug(7000) << "KFileSharePropsPlugin::setShared normalExit=" << proc.normalExit() << endl;
    kdDebug(7000) << "KFileSharePropsPlugin::setShared exitStatus=" << proc.exitStatus() << endl;
    if(proc.normalExit())
    {
        switch(proc.exitStatus())
        {
            case 1:
                // User is not authorized
                break;
            case 3:
                // Called script with --add, but path was already shared before.
                // Result is nevertheless what the client wanted, so
                // this is alright.
                ok = true;
                break;
            case 4:
                // Invalid mount point
                break;
            case 5:
                // Called script with --remove, but path was not shared before.
                // Result is nevertheless what the client wanted, so
                // this is alright.
                ok = true;
                break;
            case 6:
                // There is no export method
                break;
            case 7:
                // file sharing is disabled
                break;
            case 8:
                // advanced sharing is enabled
                break;
            case 255:
                // Abitrary error
                break;
        }
    }

    return ok;
}
コード例 #4
0
ファイル: smsclient.cpp プロジェクト: serghei/kde3-kdenetwork
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);
}
コード例 #5
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);
	}
}
コード例 #6
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;
}
コード例 #7
0
void KSSLInfoDlg::launchConfig()
{
    KProcess p;
    p << "kcmshell"
      << "crypto";
    p.start(KProcess::DontCare);
}
コード例 #8
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;
}
コード例 #9
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);
}
コード例 #10
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());
    }
}
コード例 #11
0
void InformationcenterApplet::slotrun()
{
    KProcess proc;

    proc << locate("exe", "ksysguard");
    proc.start(KProcess::DontCare);
}
コード例 #12
0
ファイル: k3bexporter.cpp プロジェクト: delight/Pana
void K3bExporter::exportViaCmdLine( const KURL::List &urls, int openmode )
{
    QCString cmdOption;

    switch( openmode ) {
    case AudioCD:
        cmdOption = "--audiocd";
        break;

    case DataCD:
        cmdOption = "--datacd";
        break;

    case Abort:
        return;
    }

    KProcess *process = new KProcess;

    *process << "k3b";
    *process << cmdOption;

    KURL::List::ConstIterator it;
    KURL::List::ConstIterator end( urls.end() );
    for( it = urls.begin(); it != end; ++it )
        *process << ( *it ).path();

    if( !process->start( KProcess::DontCare ) )
        KMessageBox::error( 0, i18n("Unable to start K3b.") );
}
コード例 #13
0
ファイル: engine.cpp プロジェクト: drewbug/kandas
int Kandas::Daemon::Engine::addDevice(const QString &deviceName, const QList<QString> &readKey, const QString &writeKey)
{
    //only register new device if no device with this name exists
    if (m_devices.device(deviceName))
        return Kandas::DeviceExistsAlready;
    //validate input
    if (deviceName.contains('/') || deviceName.contains(' ')) //spaces in the device name are possible, but interfere with the parsing of /proc/ndas/devs
        return Kandas::InvalidDeviceName;
    if (readKey.count() != 4)
        return Kandas::InvalidDeviceKey;
    foreach (const QString &keyBlock, readKey)
        if (!validateKeyBlock(keyBlock))
            return Kandas::InvalidDeviceKey;
    if (!validateKeyBlock(writeKey, true))
        return Kandas::InvalidDeviceKey;
    //build key string
    QString keyString = QStringList(readKey).join(QChar('-'));
    if (!writeKey.isEmpty())
        keyString += '-' + writeKey;
    //call ndasadmin
    QStringList args; args << "register" << keyString << "-n" << deviceName << "-b";
    KProcess process;
    process.setProgram("ndasadmin", args);
    process.setOutputChannelMode(KProcess::OnlyStderrChannel);
    process.start();
    process.waitForFinished();
    const QString errorOutput = QString::fromUtf8(process.readAllStandardError()).simplified();
    if (errorOutput.isEmpty())
        return Kandas::DeviceAdded;
    else if (errorOutput.contains(QLatin1String("register: invalid NDAS ID.")))
        return Kandas::InvalidDeviceKey;
    else
        return Kandas::DeviceAdditionFailed;
    //
}
コード例 #14
0
ファイル: zoo.cpp プロジェクト: serghei/kde3-kdeutils
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 );
  }
}
コード例 #15
0
ファイル: apm.cpp プロジェクト: serghei/kde3-kdeutils
void ApmConfig::setupHelper()
{
	QString kdesu = KStandardDirs::findExe("kdesu");
	if (!kdesu.isEmpty()) {
		int rc = KMessageBox::warningContinueCancel(0,
				i18n("You will need to supply a root password "
					"to allow the privileges of the %1 application to change.").arg(apm_name),
				"KLaptopDaemon", KStdGuiItem::cont(),
				"");
		if (rc == KMessageBox::Continue) {
			KProcess proc;
			proc << kdesu;
			proc << "-u";
			proc << "root";
			proc <<  QString("chown root ")+apm_name+"; chmod +s "+apm_name;
			proc.start(KProcess::Block);	// run it sync so has_apm below sees the results
		}
	} else {
		KMessageBox::sorry(0, i18n("%1 cannot be enabled because kdesu cannot be found.  Please make sure that it is installed correctly.").arg(QString(apm_name)),
				i18n("KLaptopDaemon"));
	}
	laptop_portable::apm_set_mask(enablestandby, enablesuspend);
    	bool can_enable = laptop_portable::has_apm(1);	// is helper ready
    	enableStandby->setEnabled(can_enable);
    	enableSuspend->setEnabled(can_enable);
	wake_laptop_daemon();
}
コード例 #16
0
ファイル: sambafile.cpp プロジェクト: serghei/kde3-kdenetwork
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;
}
コード例 #17
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;
}
コード例 #18
0
ファイル: khc_indexbuilder.cpp プロジェクト: KDE/kde-runtime
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;
  }
}
コード例 #19
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 );
    }
コード例 #20
0
ファイル: toc.cpp プロジェクト: KDE/kde-runtime
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;
    }
}
コード例 #21
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();
}
コード例 #22
0
ファイル: helpwidget.cpp プロジェクト: serghei/kde3-kdebase
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;
}
コード例 #23
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;
}
コード例 #24
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;

	}
コード例 #25
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 );
    }
}
コード例 #26
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;
}
コード例 #27
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();
    }
}
コード例 #28
0
ファイル: sevenzip.cpp プロジェクト: serghei/kde3-kdeutils
void SevenZipArch::addFile( const QStringList & urls )
{
  KProcess *kp = m_currentProcess = new KProcess;

  kp->clearArguments();
  *kp << m_archiver_program << "a" ;

  KURL url( urls.first() );
  QDir::setCurrent( url.directory() );

  *kp << m_filename;

  QStringList::ConstIterator iter;
  for ( iter = urls.begin(); iter != urls.end(); ++iter )
  {
    KURL url( *iter );
    *kp << url.fileName();
  }

  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( slotAddExited(KProcess*) ) );

  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
  {
    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
    emit sigAdd( false );
  }
}
コード例 #29
0
void MultipleBackendsTest::xml2sql()
{
	QString dbname = "testmultiple";
	// Drop the database if already exists
	KProcess *proc = new KProcess;
	*proc << "dropdb";
	*proc << dbname;
	proc->start();
	proc->wait();
	delete proc;

	// Create the database
	proc = new KProcess;
	*proc << "createdb";
	*proc << dbname;
	CHECK( proc->start(), true );
	proc->wait();
	if ( ! proc->normalExit() || proc->exitStatus() != 0 ) {
		CHECK( true, false );
		delete proc;
		return;
	}
	delete proc;

	DbBackendIface *backend1 = new XmlDbBackend( "database.xml" );
	Manager *manager1 = new Manager( backend1 );
	manager1->createSchema();

	QSqlDatabase *db = QSqlDatabase::addDatabase( "QPSQL7" );
	db->setDatabaseName( dbname );
	db->setUserName( "ak213" );
	db->setPassword( "ak" );
	db->setHostName( "localhost" );
	if ( ! db->open() ) {
		kdDebug() << "Failed to open database: " << db->lastError().text() << endl;
		return;
	}
	DbBackendIface *backend2 = new SqlDbBackend( db );
	Manager *manager2 = new Manager( backend2 );
	manager2->createSchema();
	manager1->copyTo( manager2 );
	manager2->commit();
	delete manager2;
	delete manager1;
	QSqlDatabase::removeDatabase( db );
}
コード例 #30
0
void SynergyClient::stop()
{
    KProcess *p = ProcessUtils::getNew(this, "killall", "-9", "synergyc");
    p->start();
    if (!p->waitForFinished())
        return;
    m_clientPid = 0;
}