Пример #1
0
// path in module specific load
oql_rc_t oqlDatabase::LoadSdlModule()
{
	// for shore, scan a module
#ifndef NO_SDL
	Ref<sdlModule> m;
	// the name can be 1: an sdl module
	// 2: a registered, sdl object
	// 3: a directory.
	// get a ref.
	m = lookup_module(_name);
	if (m==0)
	{
		errstream() << "couldn't find module" << _name;
	   return OQL_OK;
	}
	Ref<sdlDeclaration> bpt;
	for (bpt = m->decl_list; bpt != 0; bpt = bpt->next)
	// insert types in db.
	{
		Type *nt;
		if(bpt->kind==TypeName)
		{
			nt = AddShoreType(bpt->type);
			if (nt!=0)
			{
				if (nt->isObject()) {
					// Add to the list of extents
					extents.add(bpt->name, new SetType(nt));  
				}
			}
			else
				errstream()<< "create_Type faied for " 
					<< bpt->name.string() << "in module " << _name;
		}
	}

#endif
   // Assume that the _cat is open. Assume that the 
   // mutex has been taken
#ifdef NO_SDL
   AutoMutex myMutex(*(_cat->mutex));
   W_COERCE(myMutex.acquire());

   uint4 numExtents = _cat->dbCache.extentCnt;
   uint4 i;
   
   if (numExtents) assert(t_array = new Type*[numExtents]);

   // Now go thru each extent...
   for (i = 0; i < numExtents; i++)
      Do(_cat->extentCache[i], t_array[i]);

   // That's it...
   if (t_array) delete [] t_array;
#endif

   return OQL_OK;
}
Пример #2
0
int ProcessUtility(Ql_tree_node* root, oqlContext& context)
{
   oql_rc_t status = OQL_OK;
   const char* name = 0;

   switch(root->_type)
   {
    case create_db_n:
    case drop_db_n:
    case open_db_n:
    case drop_extent_n:
      // assert(root->_kids[0]->_type == id_n);
      name = root->_kids[0]->_id;
      break;
    case create_index_n:
    case create_clustered_index_n:
    case drop_index_n:
      errstream() << "Index operations not yet implemented..." << endl;
      return paraQ_ERROR;
    case close_db_n:
      break;
    default:
      cerr << "Unknown case in switch in function ProcessUtility" << endl;
      para_check(0);
   }
#ifndef STAND_ALONE
   switch(root->_type)
   {
   case create_db_n:
      status = context.create_db(name); 
      break;
   case drop_db_n:
      status = context.drop_db(name); 
      break;
   case open_db_n:
      status = context.open_db(name); 
      break;
   case close_db_n:
      status = context.close_db(); 
      break;
   case drop_extent_n:
      status = context.drop_extent(name); 
      break;
   }
#endif STAND_ALONE
   if (status != OQL_OK)
   {
      errstream() << "Error occurred in processing this utility."
	          << "Dont know [and couldnt care less]"
                  << " where the error is...\n";
      return paraQ_ERROR;
   }
   return paraNOERROR;
}
Пример #3
0
bool LxcZone::runInZone(const std::vector<std::string>& argv)
{
    std::vector<const char *> args;
    args.reserve(argv.size() + 1);

    for (const auto& arg : argv) {
        args.push_back(arg.c_str());
    }
    args.push_back(nullptr);

    lxc_attach_options_t options = LXC_ATTACH_OPTIONS_DEFAULT;
    options.attach_flags = LXC_ATTACH_REMOUNT_PROC_SYS |
                           LXC_ATTACH_DROP_CAPABILITIES |
                           LXC_ATTACH_SET_PERSONALITY |
                           LXC_ATTACH_LSM_EXEC |
                           LXC_ATTACH_LSM_NOW |
                           LXC_ATTACH_MOVE_TO_CGROUP;

    // use Channel to catch stderr from binary
    utils::Channel channel;
    RunBinaryPayload payload{&channel, args.data()};

    pid_t pid;
    int ret = mLxcContainer->attach(mLxcContainer,
                                    runBinaryInZone,
                                    &payload,
                                    &options,
                                    &pid);
    if (ret != 0) {
        return false;
    }

    channel.setLeft();
    std::string msg;

    do {
        namespace io = boost::iostreams;
        io::stream<io::file_descriptor_source> errstream(io::file_descriptor_source(channel.getFD(), io::never_close_handle));
        std::string line;
        while (std::getline(errstream, line).good()) msg += line + ";";
    } while (false);

    int status;
    if (!utils::waitPid(pid, status)) {
        LOGE("waitPid: " + utils::getSystemErrorMessage());
        return false;
    }
    channel.shutdown();
    if (status) {
        LOGE("[child err=" + std::to_string(status) + "] " + msg);
    } else if (!msg.empty()) {
        LOGI("[child]: " + msg);
    }
    return status == 0;
}
Пример #4
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString serialPortName;
    QString serialPortFriendlyName;
    QString sisFile;
    QString exeFile;
    QStringList cmdLine;
    QStringList args = QCoreApplication::arguments();
    QTextStream outstream(stdout);
    QTextStream errstream(stderr);
    QString uploadLocalFile;
    QString uploadRemoteFile;
    QString downloadRemoteFile;
    QString downloadLocalFile;
    QString dstName = "c:\\data\\testtemp.sis";
    int loglevel=1;
    int timeout=0;
    bool crashlog = true;
    enum {AgentUnknown, AgentCoda, AgentTRK} debugAgent = AgentUnknown;
    QString crashlogpath;
    QListIterator<QString> it(args);
    it.next(); //skip name of program
    while (it.hasNext()) {
        QString arg = it.next();

        if (arg.startsWith("-")) {
            if (arg == "--portname" || arg == "-p") {
                CHECK_PARAMETER_EXISTS
                serialPortName = it.next();
            }
            else if (arg == "--portfriendlyname" || arg == "-f") {
                CHECK_PARAMETER_EXISTS
                serialPortFriendlyName = it.next();
            }
            else if (arg == "--sis" || arg == "-s") {
                CHECK_PARAMETER_EXISTS
                sisFile = it.next();
                if (!QFileInfo(sisFile).exists()) {
                    errstream << "Sis file (" << sisFile << ") doesn't exist" << endl;
                    return 1;
                }
            }
            else if (arg == "--upload" || arg == "-u") {
                CHECK_PARAMETER_EXISTS
                uploadLocalFile = it.next();
                if (!QFileInfo(uploadLocalFile).exists()) {
                    errstream << "Executable file (" << uploadLocalFile << ") doesn't exist" << endl;
                    return 1;
                }
                CHECK_PARAMETER_EXISTS
                uploadRemoteFile = it.next();
            }
            else if (arg == "--download" || arg == "-d") {
                CHECK_PARAMETER_EXISTS
                downloadRemoteFile = it.next();
                CHECK_PARAMETER_EXISTS
                downloadLocalFile = it.next();
                QFileInfo downloadInfo(downloadLocalFile);
                if (downloadInfo.exists() && !downloadInfo.isFile()) {
                    errstream << downloadLocalFile << " is not a file." << endl;
                    return 1;
                }
            }
            else if (arg == "--timeout" || arg == "-t") {
                CHECK_PARAMETER_EXISTS
                bool ok;
                timeout = it.next().toInt(&ok);
                if (!ok) {
                    errstream << "Timeout must be specified in milliseconds" << endl;
                    return 1;
                }
            }
            else if (arg == "--coda")
                debugAgent = AgentCoda;
            else if (arg == "--trk")
                debugAgent = AgentTRK;
            else if (arg == "--tempfile" || arg == "-T") {
                CHECK_PARAMETER_EXISTS
                dstName = it.next();
            }
            else if (arg == "--verbose" || arg == "-v")
                loglevel=2;
            else if (arg == "--quiet" || arg == "-q")
                loglevel=0;
            else if (arg == "--nocrashlog")
                crashlog = false;
            else if (arg == "--crashlogpath") {
                CHECK_PARAMETER_EXISTS
                crashlogpath = it.next();
            }
            else
                errstream << "unknown command line option " << arg << endl;
        } else {
            exeFile = arg;
            while(it.hasNext()) {
                cmdLine.append(it.next());
            }
        }
    }

    if (exeFile.isEmpty() && sisFile.isEmpty() &&
        (uploadLocalFile.isEmpty() || uploadRemoteFile.isEmpty()) &&
        (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) {
        printUsage(outstream, args[0]);
        return 1;
    }

    if (!uploadLocalFile.isEmpty() && (!downloadLocalFile.isEmpty() || !downloadRemoteFile.isEmpty())) {
        errstream << "Upload option can't be used together with download" << endl;
        printUsage(outstream, args[0]);
        return 1;
    }

    if (serialPortName.isEmpty()) {
        if (loglevel > 0)
            outstream << "Detecting serial ports" << endl;
        foreach (const SerialPortId &id, enumerateSerialPorts(loglevel)) {
            if (loglevel > 0)
                outstream << "Port Name: " << id.portName << ", "
                     << "Friendly Name:" << id.friendlyName << endl;
            if (!id.friendlyName.isEmpty()
                    && serialPortFriendlyName.isEmpty()
                    && (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
                        || id.friendlyName.contains("s60", Qt::CaseInsensitive)
                        || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) {
                serialPortName = id.portName;
                break;
            } else if (!id.friendlyName.isEmpty()
                    && !serialPortFriendlyName.isEmpty()
                    && id.friendlyName.contains(serialPortFriendlyName)) {
                serialPortName = id.portName;
                break;
            }
        }
        if (serialPortName.isEmpty()) {
            errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl;
            return 1;
        }
    }

    CodaSignalHandler codaHandler;
    QScopedPointer<trk::Launcher> launcher;
    TrkSignalHandler trkHandler;
    QFileInfo info(exeFile);
    QFileInfo uploadInfo(uploadLocalFile);

    if (debugAgent == AgentUnknown) {
        outstream << "detecting debug agent..." << endl;
        CodaSignalHandler codaDetector;
        //auto detect agent
        codaDetector.setSerialPortName(serialPortName);
        codaDetector.setLogLevel(loglevel);
        codaDetector.setActionType(ActionPingOnly);
        codaDetector.setTimeout(1000);
        if (!codaDetector.run()) {
            debugAgent = AgentCoda;
            outstream << " - Coda is found" << endl;
        } else {
            debugAgent = AgentTRK;
            outstream << " - Coda is not found, defaulting to TRK" << endl;
        }
    }

    if (debugAgent == AgentCoda) {
        codaHandler.setSerialPortName(serialPortName);
        codaHandler.setLogLevel(loglevel);

        if (!sisFile.isEmpty()) {
            codaHandler.setActionType(ActionCopyInstall);
            codaHandler.setCopyFileName(sisFile, dstName);
        }
        else if (!uploadLocalFile.isEmpty() && uploadInfo.exists()) {
            codaHandler.setActionType(ActionCopy);
            codaHandler.setCopyFileName(uploadLocalFile, uploadRemoteFile);
        }
        if (!exeFile.isEmpty()) {
            codaHandler.setActionType(ActionRun);
            codaHandler.setAppFileName(QString("c:\\sys\\bin\\") + info.fileName());
            codaHandler.setCommandLineArgs(cmdLine.join(QLatin1String(", ")));
        }
        if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) {
            codaHandler.setActionType(ActionDownload);
            codaHandler.setDownloadFileName(downloadRemoteFile, downloadLocalFile);
        }

        if (loglevel > 0)
            outstream << "Connecting to target via " << serialPortName << endl;

        if (timeout > 0)
            codaHandler.setTimeout(timeout);

        QObject::connect(OsSignalConverter::instance(), SIGNAL(terminate()), &codaHandler, SLOT(terminate()), Qt::QueuedConnection);
        return codaHandler.run();

    } else {
        launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly,
            SymbianUtils::SymbianDeviceManager::instance()->acquireDevice(serialPortName)));
        QStringList srcNames, dstNames;
        if (!sisFile.isEmpty()) {
            launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
            srcNames.append(sisFile);
            dstNames.append(dstName);
            launcher->setInstallFileNames(QStringList(dstName));
        }
        if (!uploadLocalFile.isEmpty() && uploadInfo.exists()) {
            launcher->addStartupActions(trk::Launcher::ActionCopy);
            srcNames.append(uploadLocalFile);
            dstNames.append(uploadRemoteFile);
        }
        launcher->setCopyFileNames(srcNames, dstNames);
        if (!exeFile.isEmpty()) {
            launcher->addStartupActions(trk::Launcher::ActionRun);
            launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName());
            launcher->setCommandLineArgs(cmdLine.join(QLatin1String(" ")));
        }
        if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) {
            launcher->addStartupActions(trk::Launcher::ActionDownload);
            launcher->setDownloadFileName(downloadRemoteFile, downloadLocalFile);
        }
        if (loglevel > 0)
            outstream << "Connecting to target via " << serialPortName << endl;
        launcher->setTrkServerName(serialPortName);

        if (loglevel > 1)
            launcher->setVerbose(1);

        trkHandler.setLogLevel(loglevel);
        trkHandler.setCrashLogging(crashlog);
        trkHandler.setCrashLogPath(crashlogpath);

        QObject::connect(launcher.data(), SIGNAL(copyingStarted(const QString &)), &trkHandler, SLOT(copyingStarted(const QString &)));
        QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &trkHandler, SLOT(canNotConnect(const QString &)));
        QObject::connect(launcher.data(), SIGNAL(canNotCreateFile(const QString &, const QString &)), &trkHandler, SLOT(canNotCreateFile(const QString &, const QString &)));
        QObject::connect(launcher.data(), SIGNAL(canNotWriteFile(const QString &, const QString &)), &trkHandler, SLOT(canNotWriteFile(const QString &, const QString &)));
        QObject::connect(launcher.data(), SIGNAL(canNotCloseFile(const QString &, const QString &)), &trkHandler, SLOT(canNotCloseFile(const QString &, const QString &)));
        QObject::connect(launcher.data(), SIGNAL(installingStarted(const QString &)), &trkHandler, SLOT(installingStarted(const QString &)));
        QObject::connect(launcher.data(), SIGNAL(canNotInstall(const QString &, const QString &)), &trkHandler, SLOT(canNotInstall(const QString &, const QString &)));
        QObject::connect(launcher.data(), SIGNAL(installingFinished()), &trkHandler, SLOT(installingFinished()));
        QObject::connect(launcher.data(), SIGNAL(startingApplication()), &trkHandler, SLOT(startingApplication()));
        QObject::connect(launcher.data(), SIGNAL(applicationRunning(uint)), &trkHandler, SLOT(applicationRunning(uint)));
        QObject::connect(launcher.data(), SIGNAL(canNotRun(const QString &)), &trkHandler, SLOT(canNotRun(const QString &)));
        QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &trkHandler, SLOT(applicationOutputReceived(const QString &)));
        QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &trkHandler, SLOT(copyProgress(int)));
        QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &trkHandler, SLOT(stateChanged(int)));
        QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &trkHandler, SLOT(stopped(uint,uint,uint,QString)));
        QObject::connect(launcher.data(), SIGNAL(libraryLoaded(trk::Library)), &trkHandler, SLOT(libraryLoaded(trk::Library)));
        QObject::connect(launcher.data(), SIGNAL(libraryUnloaded(trk::Library)), &trkHandler, SLOT(libraryUnloaded(trk::Library)));
        QObject::connect(launcher.data(), SIGNAL(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &)), &trkHandler, SLOT(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &)));
        QObject::connect(&trkHandler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint)));
        QObject::connect(&trkHandler, SIGNAL(terminate()), launcher.data(), SLOT(terminate()));
        QObject::connect(&trkHandler, SIGNAL(getRegistersAndCallStack(uint,uint)), launcher.data(), SLOT(getRegistersAndCallStack(uint,uint)));
        QObject::connect(launcher.data(), SIGNAL(finished()), &trkHandler, SLOT(finished()));

        QObject::connect(OsSignalConverter::instance(), SIGNAL(terminate()), launcher.data(), SLOT(terminate()), Qt::QueuedConnection);

        QTimer timer;
        timer.setSingleShot(true);
        QObject::connect(&timer, SIGNAL(timeout()), &trkHandler, SLOT(timeout()));
        if (timeout > 0) {
            timer.start(timeout);
        }

        QString errorMessage;
        if (!launcher->startServer(&errorMessage)) {
            errstream << errorMessage << endl;
            return 1;
        }
    }

    return a.exec();
}
Пример #5
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString serialPortName;
    QString serialPortFriendlyName;
    QString sisFile;
    QString exeFile;
    QStringList cmdLine;
    QStringList args = QCoreApplication::arguments();
    QTextStream outstream(stdout);
    QTextStream errstream(stderr);
    QString downloadRemoteFile;
    QString downloadLocalFile;
    int loglevel=1;
    int timeout=0;
    QListIterator<QString> it(args);
    it.next(); //skip name of program
    while (it.hasNext()) {
        QString arg = it.next();

        if (arg.startsWith("-")) {
            if (arg == "--portname" || arg == "-p") {
                CHECK_PARAMETER_EXISTS
                serialPortName = it.next();
            }
            else if (arg == "--portfriendlyname" || arg == "-f") {
                CHECK_PARAMETER_EXISTS
                serialPortFriendlyName = it.next();
            }
            else if (arg == "--sis" || arg == "-s") {
                CHECK_PARAMETER_EXISTS
                sisFile = it.next();
            }
            else if (arg == "--download" || arg == "-d") {
                CHECK_PARAMETER_EXISTS
                downloadRemoteFile = it.next();
                CHECK_PARAMETER_EXISTS
                downloadLocalFile = it.next();
            }
            else if (arg == "--timeout" || arg == "-t") {
                CHECK_PARAMETER_EXISTS
                bool ok;
                timeout = it.next().toInt(&ok);
                if (!ok) {
                    errstream << "Timeout must be specified in milliseconds" << endl;
                    return 1;
                }
            }
            else if (arg == "--verbose" || arg == "-v")
                loglevel=2;
            else if (arg == "--quiet" || arg == "-q")
                loglevel=0;
            else
                errstream << "unknown command line option " << arg << endl;
        } else {
            exeFile = arg;
            while(it.hasNext()) {
                cmdLine.append(it.next());
            }
        }
    }

    if (exeFile.isEmpty() && sisFile.isEmpty() && 
        (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) {
        printUsage(outstream, args[0]);
        return 1;
    }

    if (serialPortName.isEmpty()) {
        if (loglevel > 0)
            outstream << "Detecting serial ports" << endl;
        foreach (const SerialPortId &id, enumerateSerialPorts()) {
            if (loglevel > 0)
                outstream << "Port Name: " << id.portName << ", "
                     << "Friendly Name:" << id.friendlyName << endl;
            if (!id.friendlyName.isEmpty()
                    && serialPortFriendlyName.isEmpty()
                    && (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
                        || id.friendlyName.contains("s60", Qt::CaseInsensitive)
                        || id.friendlyName.contains("nokia", Qt::CaseInsensitive))) {
                serialPortName = id.portName;
                break;
            } else if (!id.friendlyName.isEmpty()
                    && !serialPortFriendlyName.isEmpty()
                    && id.friendlyName.contains(serialPortFriendlyName)) {
                serialPortName = id.portName;
                break;
            }
        }
        if (serialPortName.isEmpty()) {
            errstream << "No phone found, ensure USB cable is connected or specify manually with -p" << endl;
            return 1;
        }
    }

    QScopedPointer<trk::Launcher> launcher;
    launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly));
    QFileInfo info(exeFile);
    if (!sisFile.isEmpty()) {
        launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
        launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis");
        launcher->setInstallFileName("c:\\data\\testtemp.sis");
    }
    else if (info.exists()) {
        launcher->addStartupActions(trk::Launcher::ActionCopy);
        launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName());
    }
    if (!exeFile.isEmpty()) {
        launcher->addStartupActions(trk::Launcher::ActionRun);
        launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName());
        launcher->setCommandLineArgs(cmdLine);
    }
    if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) {
        launcher->addStartupActions(trk::Launcher::ActionDownload);
        launcher->setDownloadFileName(downloadRemoteFile, downloadLocalFile);
    }
    if (loglevel > 0)
        outstream << "Connecting to target via " << serialPortName << endl;
    launcher->setTrkServerName(serialPortName);

    if (loglevel > 1)
        launcher->setVerbose(1);

    TrkSignalHandler handler;
    handler.setLogLevel(loglevel);

    QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted()));
    QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &handler, SLOT(canNotConnect(const QString &)));
    QObject::connect(launcher.data(), SIGNAL(canNotCreateFile(const QString &, const QString &)), &handler, SLOT(canNotCreateFile(const QString &, const QString &)));
    QObject::connect(launcher.data(), SIGNAL(canNotWriteFile(const QString &, const QString &)), &handler, SLOT(canNotWriteFile(const QString &, const QString &)));
    QObject::connect(launcher.data(), SIGNAL(canNotCloseFile(const QString &, const QString &)), &handler, SLOT(canNotCloseFile(const QString &, const QString &)));
    QObject::connect(launcher.data(), SIGNAL(installingStarted()), &handler, SLOT(installingStarted()));
    QObject::connect(launcher.data(), SIGNAL(canNotInstall(const QString &, const QString &)), &handler, SLOT(canNotInstall(const QString &, const QString &)));
    QObject::connect(launcher.data(), SIGNAL(installingFinished()), &handler, SLOT(installingFinished()));
    QObject::connect(launcher.data(), SIGNAL(startingApplication()), &handler, SLOT(startingApplication()));
    QObject::connect(launcher.data(), SIGNAL(applicationRunning(uint)), &handler, SLOT(applicationRunning(uint)));
    QObject::connect(launcher.data(), SIGNAL(canNotRun(const QString &)), &handler, SLOT(canNotRun(const QString &)));
    QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &handler, SLOT(applicationOutputReceived(const QString &)));
    QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int)));
    QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int)));
    QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString)));
    QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint)));
    QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate()));
    QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished()));

    QTimer timer;
    timer.setSingleShot(true);
    QObject::connect(&timer, SIGNAL(timeout()), &handler, SLOT(timeout()));
    if (timeout > 0) {
        timer.start(timeout);
    }

    QString errorMessage;
    if (!launcher->startServer(&errorMessage)) {
        errstream << errorMessage << endl;
        return 1;
    }

    return a.exec();
}