Пример #1
0
	void start()
	{
		QCoreApplication *app = application();
		
		QServer* tcpServer = createServer();
		if (tcpServer)
		{
			tcpServer->listen();

			if (!tcpServer->isListening()) {
				logMessage(QString("Failed to bind to port %1").arg(tcpServer->serverPort()), QtServiceBase::Error);
				app->quit();
			}
		}
	}	
Пример #2
0
void HttpService::start()
{
    QCoreApplication *app = application();

    quint16 port = (app->argc() > 1) ?
        QString::fromLocal8Bit(app->argv()[1]).toUShort() : m_listenPort;
    daemon = new HttpBridger(port, app);

    if (!daemon->isListening()) {
        XERROR("Failed to bind to port %d", daemon->serverPort());
        app->quit();
    }

    if (Configer::getFirsttime())
    {
        //默认设置为自动开启
        setStartupType(QtServiceController::AutoStartup);
        Configer::setFirstTime(false);
    }
}
Пример #3
0
void CRadsService::start()
{
	DEBUG_BREAK;

	QCoreApplication *app = application();

	if ( mDaemon )
	{
		delete mDaemon;
		LOG_WARN( "Deleted existing rads-client daemon before starting." );
	}

	mDaemon = new CRadsDaemon( mPaths, app );

	if (!mDaemon->IsListening() )
	{
		const QString msg = "Failed to setup rads-client daemon. Quiting...";
		logMessage( msg, QtServiceBase::Error );
		LOG_FATAL( msg );
		app->quit();
	}
}
Пример #4
0
void VlcStreamerService::start()
{
	QSocketNotifier		*snSignal;
	struct sigaction	act;

	QCoreApplication *app = application();

	snSignal = new QSocketNotifier(_sigFd[1], QSocketNotifier::Read);
	QObject::connect(snSignal, SIGNAL(activated(int)), app, SLOT(quit()));
	
	act.sa_handler = _Handler;
	sigemptyset(&act.sa_mask);
	act.sa_flags = SA_RESTART;
	sigaction(SIGINT, &act, 0);
	sigaction(SIGTERM, &act, 0);

	_app = new VlcStreamerApp();
	if(_app->Setup()) {
		QObject::connect(app, SIGNAL(aboutToQuit()), _app, SLOT(Stop()));
		return;
	}
	app->quit();
}
Пример #5
0
int main(int argc, char* argv[])
{
	QCoreApplication::setOrganizationName("rapcad");
	QCoreApplication::setOrganizationDomain("rapcad.org");
	QCoreApplication::setApplicationName("RapCAD");
	QCoreApplication::setApplicationVersion(STRINGIFY(RAPCAD_VERSION));

	QCoreApplication* a = new QCoreApplication(argc,argv);

	QCommandLineParser p;
	p.setApplicationDescription(QCoreApplication::translate("main","RapCAD the rapid prototyping IDE"));
	p.addHelpOption();
	p.addVersionOption();
	p.addPositionalArgument("filename", QCoreApplication::translate("main","File to open or process."));

	QCommandLineOption testOption(QStringList() << "t" << "test", QCoreApplication::translate("main","Run through tests in working directory."));
	p.addOption(testOption);

	QCommandLineOption compareOption(QStringList() << "c" << "compare", QCoreApplication::translate("main","Compare two files to see if they are identical."),"filename");
	p.addOption(compareOption);

	QCommandLineOption printOption(QStringList() << "p" << "print", QCoreApplication::translate("main","Print debugging output."));
	p.addOption(printOption);

	QCommandLineOption outputOption(QStringList() << "o" << "output",QCoreApplication::translate("main","Create output file <filename>."),"filename");
	p.addOption(outputOption);

#ifdef USE_READLINE
	QCommandLineOption interactOption(QStringList() << "i" << "interactive",QCoreApplication::translate("main","Start an interactive session"));
	p.addOption(interactOption);
#endif
	p.process(*a);

	QStringList inputFiles=p.positionalArguments();
	QString inputFile;
	if(!inputFiles.isEmpty())
		inputFile=inputFiles.at(0);

	QString outputFile;
	if(p.isSet(outputOption))
		outputFile=p.value(outputOption);
	else if(p.isSet(compareOption))
		outputFile=p.value(compareOption);

	QTextStream output(stdout);
	Strategy* s=NULL;
	if(p.isSet(compareOption)) {
		Comparer* c=new Comparer(output);
		c->setup(inputFile,outputFile);
		s=c;
	} else if(p.isSet(testOption)) {
		s=new Tester(output);
	} else if(p.isSet(outputOption)||p.isSet(printOption)) {
		Worker* w=new Worker(output);
		bool print = p.isSet(printOption);
		w->setup(inputFile,outputFile,print,false);
		s=w;
#ifdef USE_READLINE
    } else if(p.isSet(interactOption)) {
        showVersion(output);
		s=new Interactive(output);
#endif
	}

	if(s) {
		int retcode=s->evaluate();
		a->quit();
		return retcode;
	} else {
		delete a;
		a=new QApplication(argc,argv);
		return showUi(a,inputFiles);
	}
}