コード例 #1
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;
}
コード例 #2
0
void KasTaskItem::sendToTray()
{
    QString s;
    s.setNum( task_->window() );

    KProcess proc;
    proc << "ksystraycmd";
    proc << "--wid" << s << "--hidden";

    bool ok = proc.start( KProcess::DontCare );
    if ( !ok ) {
	kdWarning(1345) << "Unable to launch ksystraycmd" << endl;
	KPassivePopup::message( i18n("Could Not Send to Tray"),
				i18n("%1").arg(strerror(errno)),
				Icon("error"),
				kasbar() );
	return;
    }

    proc.detach();
}