コード例 #1
0
ファイル: global.cpp プロジェクト: Spiek/etuprom-qt
void Global::initialize()
{
    // stop init process and exit if the class was allready initialized
    if(Global::init) {
        return;
    }

    // simplefy application instance
    QCoreApplication* app = QCoreApplication::instance();

    /// init settings
    QString strConfigFile = QFileInfo(app->applicationFilePath()).baseName() + ".ini";
    if(!QFile::exists(strConfigFile)) {
        qFatal("Cannot find Config file:\r\n%s", qPrintable(strConfigFile));
    }
    Global::settings = new QSettings(strConfigFile, QSettings::IniFormat);

    /// init database helper
    QSqlDatabase database = QSqlDatabase::addDatabase(Global::getConfigValue("database/driver").toString(), "sqm");
    database.setDatabaseName(Global::getConfigValue("database/name", "").toString());
    database.setHostName(Global::getConfigValue("database/hostname", "").toString());
    database.setPort(Global::getConfigValue("database/port", 0).toInt());
    database.setUserName(Global::getConfigValue("database/username", "").toString());
    database.setPassword(Global::getConfigValue("database/password", "").toString());
    database.setConnectOptions(Global::getConfigValue("database/connectoptions", "").toString());
    if(database.open()) {
        printf("Datenbank Verbindung erfolgreich!");
    } else {
        qFatal("Datenbank Verbindung NICHT erfolgreich!");
    }
    Global::databaseHelper = new DatabaseHelper("sqm");

    // class was successfull initialized!
    Global::init = true;
}
コード例 #2
0
ファイル: global.cpp プロジェクト: Spiek/etuprom-qt
void Global::initialize()
{
    // stop init process and exit if the class was allready initialized
    if(Global::init) {
        return;
    }

    // simplefy application instance
    QCoreApplication* app = QApplication::instance();


    // init settings
    QString strConfigFile = QFileInfo(app->applicationFilePath()).baseName() + ".ini";
    if(!QFile::exists(strConfigFile)) {
        qFatal("Cannot find Config file:\r\n%s", qPrintable(strConfigFile));
    }
    Global::settings = new QSettings(strConfigFile, QSettings::IniFormat);


    Global::strServerHostname = Global::settings->value("server/hostname", Global::strServerHostname).toString();
    Global::intServerPort = Global::settings->value("server/port", Global::intServerPort).toUInt();
    Global::strSessionName = Global::settings->value("session/name", Global::strSessionName).toString();


    // init socket
    Global::socketServer = new QTcpSocket(app);

    // init EleaphRpc handler
    Global::eleaphRpc = new EleaphRpc(app);
    Global::eleaphRpc->addDevice(Global::socketServer, IEleaph::NeverForgetDevice);

    // class was successfull initialized!
    Global::init = true;
}
コード例 #3
0
ファイル: UnixMurmur.cpp プロジェクト: ashurta/mumble
void LimitTest::testLimits(QCoreApplication &a) {
	QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance();
	if (QLatin1String(ed->metaObject()->className()) != QLatin1String("QEventDispatcherGlib"))
		qWarning("Not running with glib. While you may be able to open more descriptors, sockets above %d will not work", FD_SETSIZE);
	qWarning("Running descriptor test.");
	int count;
	QList<QFile *> ql;
	for (count=0;count < 524288; ++count) {
		QFile *qf = new QFile(a.applicationFilePath());
		if (qf->open(QIODevice::ReadOnly))
			ql.prepend(qf);
		else
			break;
		if ((count & 1023) == 0)
			qWarning("%d descriptors...", count);
	}
	foreach(QFile *qf, ql)
		delete qf;
	ql.clear();
	qCritical("Managed to open %d descriptors", count);

	qm = new QMutex();
	qw = new QWaitCondition();
	qstartw = new QWaitCondition();

	int fdcount = count / 8;
	if (sizeof(void *) < 8)
		if (fdcount > 1024)
			fdcount = 1024;

	QList<LimitTest *> qtl;
	for (count=0;count < fdcount; ++count) {
		LimitTest *t = new LimitTest();
		t->tid = count;
		qtl << t;
		qm->lock();
		t->start();
		qstartw->wait(qm);
		qm->unlock();
		if (! t->isRunning())
			break;
		if ((count & 511) == 0)
			qWarning("%d threads...", count);
	}
	qm->lock();
	qw->wakeAll();
	qm->unlock();

	foreach(LimitTest *qt, qtl) {
		if (! qt->wait(1000)) {
			qWarning("Thread %d failed to terminate...", qt->tid);
			qt->terminate();
		}
	}
	qFatal("Managed to spawn %d threads", count);
}
コード例 #4
0
ファイル: error.cpp プロジェクト: KDE/soprano
void Soprano::Error::ErrorCache::setError( const Error& error ) const
{
    if ( error ) {
        QCoreApplication* app = QCoreApplication::instance();
        qDebug() << ( app
                      ? QString( "%1(%2)" ).arg( app->applicationFilePath() ).arg( app->applicationPid() )
                      : QString() )
                 << "Soprano:" << error;
        QMutexLocker locker( &d->errorMapMutex );
        d->errorMap[QThread::currentThread()] = error;
    }
    else {
        clearError();
    }
}
コード例 #5
0
void AMCrashMonitorSupport::monitor(){
	if(!errorFile_)
		return;

	QCoreApplication *app = QApplication::instance();

	QStringList appArguments = app->arguments();
	if(!appArguments.contains("--enableCrashMonitor"))
		return;

	QStringList arguments;
	arguments << "-m";
	arguments << app->applicationFilePath();
	arguments << pathToCrashReportFiles_;
	arguments << QString("%1").arg(getpid());

	QProcess::startDetached(pathToCrashReporter_+"/AMCrashReporter", arguments, QDir::currentPath(), &globalCrashMonitorPID);
}
コード例 #6
0
ファイル: Global.cpp プロジェクト: Wushaowei001/labelling3
void Global::initialize()
{
    if(Global::Init) return;

    QCoreApplication* app = QApplication::instance();

    QString strConfigFile = QFileInfo(app->applicationFilePath()).baseName() + ".ini";
    if(!QFile::exists(strConfigFile))
    {
        qFatal("配置文件不存在:\r\n%s", qPrintable(strConfigFile));
    }

    Global::Awesome = new QtAwesome();
    Global::Awesome->initFontAwesome();

    Global::settings = new QSettings(strConfigFile, QSettings::IniFormat);
    settings->setIniCodec("UTF8");

    Global::Database = Global::settings->value("MYSQL/databasename", Global::Database).toString();
    Global::Hostname = Global::settings->value("MYSQL/hostname", Global::Hostname).toString();
    Global::Username = Global::settings->value("MYSQL/username", Global::Username).toString();
    Global::Passwd   = Global::settings->value("MYSQL/passwd", Global::Passwd).toString();

    Global::PathImage = Global::settings->value("IMAGE/pathImage",Global::PathImage).toString();
    Global::PathMask = Global::settings->value("IMAGE/pathMask", Global::PathMask).toString();
    Global::PathResult = Global::settings->value("IMAGE/pathResult", Global::PathResult).toString();

    QDir dirMask(Global::PathMask);
    QDir dirResult(Global::PathResult);
    if(!dirMask.exists()) dirMask.mkdir(Global::PathMask);
    if(!dirResult.exists()) dirResult.mkdir(Global::PathResult);

    Global::ExtMask = Global::settings->value("IMAGE/extMask", Global::ExtMask).toString();
    Global::ExtResult = Global::settings->value("IMAGE/extResult", Global::ExtResult).toString();

    Global::Init = true;
}
コード例 #7
0
ファイル: dataservice.cpp プロジェクト: vadimG2015i/Cplus
void DataService::start()
{

    try
    {
       //To do
          QCoreApplication *app = application();
           LOG4CXX_INFO( logger, "Service started" );
           LOG4CXX_INFO( logger, app->applicationFilePath().toStdString());
           DataTcpServer *server1 =new  DataTcpServer;//(app);
           server1->startServer(17002);

        // qDebug()<<"Service started";
         //qDebug()<<app->applicationFilePath();


    }
    catch(...)
    {
        qCritical()<< "Unknown error !";

    }

}
コード例 #8
0
ファイル: main.cpp プロジェクト: hsorby/opencor
int main(int pArgC, char *pArgV[])
{
    // Initialise Qt's message pattern

    OpenCOR::initQtMessagePattern();

    // Initialise the plugins path

    OpenCOR::initPluginsPath(pArgV[0]);

    // Create our application

    QCoreApplication *cliApp = new QCoreApplication(pArgC, pArgV);

    // Some general initialisations

    OpenCOR::initApplication();

    // Try to run OpenCOR as a CLI application

    int res;

    if (!OpenCOR::cliApplication(&res)) {
        // OpenCOR isn't meant to be run as a CLI application, so start its GUI
        // version instead

        static const QString DotExe = ".exe";

        if (cliApp->applicationFilePath().right(DotExe.size()) == DotExe) {
            // This is a safeguard from accidentally running a non-renamed (to
            // '.com') CLI version of OpenCOR

            error("the CLI version of "+qAppName()+" has the wrong extension ('.exe' instead of '.com').");

            res = -1;
        } else {
            QString guiAppFilePath = cliApp->applicationDirPath()+QDir::separator()+qAppName()+DotExe;

            if (!QFile::exists(guiAppFilePath)) {
                // We can't find the GUI version of OpenCOR, so...

                error("the GUI version of "+qAppName()+" cannot be found.");

                res = -1;
            } else {
                // We found the GUI version of OpenCOR, so run it with our
                // arguments, minus the first one since it corresponds to the
                // full path to our executable, which we are not interested in

                QStringList appArguments = cliApp->arguments();

                appArguments.removeFirst();

                QProcess().startDetached(guiAppFilePath, appArguments, QProcess().workingDirectory());

                res = 0;
            }
        }
    }

    // Release some memory

    delete cliApp;

    // We are done, so...

    return res;
}