23 #include "apprunner.h"
25 #include "gui/standardserverconsole.h"
26 #include "serverapi/message.h"
38 QStringList::iterator it;
39 for (it = args.begin(); it != args.end(); ++it)
41 if (it->contains(
" "))
43 Strings::trim(*it,
"\"");
49 QString AppRunner::findBundleBinary(
const QFileInfo &file)
54 QFile pLists(file.canonicalFilePath() +
"/Contents/Info.plist");
55 if(!pLists.open(QIODevice::ReadOnly | QIODevice::Text))
57 gLog << tr(
"Could not read bundle plist. (%1)").arg(file.canonicalFilePath() +
"/Contents/Info.plist");
62 bool keyFound =
false;
63 while(pLists.readLine(line, 128) != -1)
67 if(QString(line).trimmed() ==
"<key>CFBundleExecutable</key>")
72 QString binaryLine(line);
73 binaryLine = binaryLine.trimmed();
74 if(binaryLine.startsWith(
"<string>") && binaryLine.endsWith(
"</string>"))
75 return QString(
"/Contents/MacOS/") + binaryLine.mid(8, binaryLine.indexOf(
"</string>")-8);
86 gLog << tr(
"Starting (working dir %1): %2").arg(cmdInfo.
applicationDir.absolutePath()).arg(cmdInfo.
executable.absoluteFilePath());
87 QStringList args = cmdInfo.
args;
95 result = QProcess::startDetached(cmdInfo.
executable.absoluteFilePath() + AppRunner::findBundleBinary(cmdInfo.
executable), args, cmdInfo.
applicationDir.absolutePath());
100 result = QProcess::startDetached(cmdInfo.
executable.absoluteFilePath(), args, cmdInfo.
applicationDir.absolutePath());
107 QString error = tr(
"File: %1\ncannot be run").arg(cmdInfo.
executable.absoluteFilePath());
119 gLog << tr(
"Starting (working dir %1): %2").arg(cli.
applicationDir.absolutePath())
121 QStringList args = cli.
args;
Structure holding parameters for application launch.
Message object used to pass messages throughout the Doomseeker's system.
QStringList args
launch parameters
static void runExecutableWrappedInStandardServerConsole(const QIcon &icon, const CommandLineInfo &cli)
Executes predefined command line.
static void cleanArguments(QStringList &args)
On Windows this removes any wrapping " chars.
QDir applicationDir
working directory
QFileInfo executable
path to the executable
static Message customError(const QString &content)
Convenience method. Sets type to Type::CUSTOM_ERROR.
bool isValid() const
It's valid when at least executable is set.