void CfgEmailClient::selectEmailClient() { KURL::List urlList; KOpenWithDlg dlg(urlList, i18n("Select preferred email client:"), QString::null, this); // hide "Do not &close when command exits" here, we don't need it for a mail client dlg.hideNoCloseOnExit(); if(dlg.exec() != QDialog::Accepted) return; QString client = dlg.text(); // get the preferred Terminal Application KConfigGroup confGroup(KGlobal::config(), QString::fromLatin1("General")); QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", QString::fromLatin1("konsole")); preferredTerminal += QString::fromLatin1(" -e "); int len = preferredTerminal.length(); bool b = client.left(len) == preferredTerminal; if(b) client = client.mid(len); if(!client.isEmpty()) { chkRunTerminal->setChecked(b); txtEMailClient->setText(client); } }
void ShellRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { Q_UNUSED(match); // filter match's id to remove runner's name // as this is the command we want to run if (m_enabled) { #ifdef Q_OS_UNIX //qDebug() << m_asOtherUser << m_username << m_password; if (m_asOtherUser && !m_username.isEmpty()) { //TODO: provide some user feedback on failure QString exec; QString args; if (m_inTerminal) { // we have to reimplement this from KToolInvocation because we need to use KDESu KConfigGroup confGroup( KGlobal::config(), "General" ); exec = confGroup.readPathEntry("TerminalApplication", "konsole"); if (!exec.isEmpty()) { if (exec == "konsole") { args += " --noclose"; } else if (exec == "xterm") { args += " -hold"; } args += " -e " + context.query(); } } else { const QStringList commandLine = KShell::splitArgs(context.query(), KShell::TildeExpand); if (!commandLine.isEmpty()) { exec = commandLine.at(0); } args = context.query().right(context.query().size() - commandLine.at(0).length()); } if (!exec.isEmpty()) { exec = KStandardDirs::findExe(exec); exec.append(args); if (!exec.isEmpty()) { KDESu::SuProcess client(m_username.toLocal8Bit(), exec.toLocal8Bit()); const QByteArray password = m_password.toLocal8Bit(); //TODO handle errors like wrong password via KNotifications in 4.7 client.exec(password.constData()); } } } else #endif if (m_inTerminal) { KToolInvocation::invokeTerminal(context.query()); } else { KRun::runCommand(context.query(), NULL); } } // reset for the next run! m_inTerminal = false; m_asOtherUser = false; m_username.clear(); m_password.clear(); }