21
21
#include <KStandardDirs>
24
ScriptLauncher::ScriptLauncher(QObject* parent) : QObject(parent)
24
ScriptLauncher::ScriptLauncher(Server* server)
28
30
ScriptLauncher::~ScriptLauncher()
32
QString ScriptLauncher::scriptPath(const QString& script)
34
return KStandardDirs::locate("data", "konversation/scripts/" + script);
37
void ScriptLauncher::launchScript(int connectionId, const QString& target, const QString ¶meter)
34
void ScriptLauncher::launchScript(const QString& target, const QString ¶meter)
39
36
// send the script all the information it will need
40
37
QStringList parameterList = parameter.split(' ');
41
38
// find script path (could be installed for all users in $KDEDIR/share/apps/ or
42
39
// for one user alone in $HOME/.kde/share/apps/
43
40
QString script(parameterList.takeFirst());
44
QString path = scriptPath(script);
41
QString scriptPath(KStandardDirs::locate("data", "konversation/scripts/" + script));
45
42
parameterList.prepend(target);
46
parameterList.prepend(QString::number(connectionId));
47
QFileInfo fileInfo(path);
49
if (!QProcess::startDetached(path, parameterList, fileInfo.path()))
43
parameterList.prepend(QString::number(m_server->connectionId()));
44
QFileInfo fileInfo(scriptPath);
45
if (!QProcess::startDetached(scriptPath, parameterList, fileInfo.path()))
51
if (!fileInfo.exists())
47
if(!fileInfo.exists())
52
48
emit scriptNotFound(script);
54
50
emit scriptExecutionError(script);