~ubuntu-branches/ubuntu/lucid/konversation/lucid-updates

« back to all changes in this revision

Viewing changes to src/scriptlauncher.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-02-11 14:52:14 UTC
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20100211145214-xsbd3hmrnu5fmb8f
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <KStandardDirs>
22
22
 
23
23
 
24
 
ScriptLauncher::ScriptLauncher(QObject* parent) : QObject(parent)
 
24
ScriptLauncher::ScriptLauncher(Server* server)
 
25
: QObject(server)
25
26
{
 
27
    m_server = server;
26
28
}
27
29
 
28
30
ScriptLauncher::~ScriptLauncher()
29
31
{
30
32
}
31
33
 
32
 
QString ScriptLauncher::scriptPath(const QString& script)
33
 
{
34
 
    return KStandardDirs::locate("data", "konversation/scripts/" + script);
35
 
}
36
 
 
37
 
void ScriptLauncher::launchScript(int connectionId, const QString& target, const QString &parameter)
 
34
void ScriptLauncher::launchScript(const QString& target, const QString &parameter)
38
35
{
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);
48
 
 
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()))
50
46
    {
51
 
        if (!fileInfo.exists())
 
47
        if(!fileInfo.exists())
52
48
           emit scriptNotFound(script);
53
49
        else
54
50
           emit scriptExecutionError(script);