Beispiel #1
0
int main(int argc, char *argv[])
{
   QCoreApplication a(argc, argv);

   // init the logging mechanism
   QsLogging::Logger& logger = QsLogging::Logger::instance();
   logger.setLoggingLevel(QsLogging::TraceLevel);
   const QString sLogPath(QDir(a.applicationDirPath()).filePath("log.txt"));
   QsLogging::DestinationPtr fileDestination(
      QsLogging::DestinationFactory::MakeFileDestination(sLogPath) );
   QsLogging::DestinationPtr debugDestination(
      QsLogging::DestinationFactory::MakeDebugOutputDestination() );
   logger.addDestination(debugDestination.get());
   logger.addDestination(fileDestination.get());
   //logger.setLoggingLevel(QsLogging::InfoLevel);

   QLOG_INFO() << "Program started";
   QLOG_INFO() << "Built with Qt" << QT_VERSION_STR << "running on" << qVersion();

   QLOG_TRACE() << "Here's a" << QString("trace") << "message";
   QLOG_DEBUG() << "Here's a" << static_cast<int>(QsLogging::DebugLevel) << "message";
   QLOG_WARN()  << "Uh-oh!";
   qDebug() << "This message won't be picked up by the logger";
   QLOG_ERROR() << "An error has occurred";
   qWarning() << "Neither will this one";
   QLOG_FATAL() << "Fatal error!";

   const int ret = 0;
   std::cout << std::endl << "Press any key...";
   std::cin.get();
   QLOG_INFO() << "Program exited with return code" << ret;
   return ret;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    qRegisterMetaType<CurrentStatusUpdate>("CurrentStatusUpdate");
    qRegisterMetaType<Items>("Items");
    qRegisterMetaType<std::vector<std::string>>("std::vector<std::string>");
    qRegisterMetaType<QsLogging::Level>("QsLogging::Level");

    QLocale::setDefault(QLocale::C);

//#if defined(CRASHRPT) && !defined(DEBUG)
//    CR_INSTALL_INFOW info;
//    memset(&info, 0, sizeof(CR_INSTALL_INFOW));
//    info.cb = sizeof(CR_INSTALL_INFOW);
//    info.pszAppName = L"Acquisition";
//    info.pszAppVersion = L"0.0";
//    info.pszUrl = L"https://xyz.is/acquisition/utils/crashrpt.php";
//    CrAutoInstallHelper cr_install_helper(&info);
//#endif

    InitModlist();

    QApplication a(argc, argv);
    Filesystem::Init();

    QCommandLineParser parser;
    QCommandLineOption option_data_dir("data-dir", "Where to save Acquisition data.", "data-dir");
    parser.addOption(option_data_dir);
    parser.process(a);

    if (parser.isSet(option_data_dir))
        Filesystem::SetUserDir(parser.value(option_data_dir).toStdString());

    QsLogging::Logger& logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::InfoLevel);
    const QString sLogPath(QDir(Filesystem::UserDir().c_str()).filePath("log.txt"));

    QsLogging::DestinationPtr fileDestination(
        QsLogging::DestinationFactory::MakeFileDestination(sLogPath, true, 10 * 1024 * 1024, 0) );
    QsLogging::DestinationPtr debugDestination(
        QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    logger.addDestination(debugDestination);
    logger.addDestination(fileDestination);

    qApp->setStyle(QStyleFactory::create("Fusion"));

    QLOG_INFO() << "--------------------------------------------------------------------------------";
    QLOG_INFO() << "Built with Qt" << QT_VERSION_STR << "running on" << qVersion();

    LoginDialog login(std::make_unique<Application>());
    login.show();

    return a.exec();
}
Beispiel #3
0
void Robot::logInit()
{
   QCoreApplication *pApp = QCoreApplication::instance();
   QsLogging::Logger& logger = QsLogging::Logger::instance();
   logger.setLoggingLevel(QsLogging::TraceLevel);
   //Log to file
   const QString logPath(QDir(pApp->applicationDirPath()).filePath("Log.txt"));
   QsLogging::DestinationPtr fileDestination(
      QsLogging::DestinationFactory::MakeFileDestination(logPath) );
   logger.addDestination(fileDestination);
   //Log to standard output
   QsLogging::DestinationPtr debugDestination = QsLogging::DestinationFactory::MakeDebugOutputDestination();
   logger.addDestination(debugDestination);
}
Beispiel #4
0
int main(int argc, char *argv[])
{
	qInstallMessageHandler(messageHandler);

    QCoreApplication app(argc, argv);
	QsLogging::Logger& logger = QsLogging::Logger::instance();
	logger.setLoggingLevel(QsLogging::TraceLevel);
	logger.setTimestampFormat("yyyy-MM-dd hh:mm:ss");

	// Find a free log file name.
	QString logFile(QDir(app.applicationDirPath()).filePath("phototweet"));
	int logNumber = 0;
	while (1)
	{
		QString name = logFile + QString::number(logNumber) + ".log";
		if (!QFile::exists(name))
		{
			logFile = name;
			break;
		}

		logNumber++;
	}

	QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(logFile));
	logger.addDestination(fileDestination.get());

	QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination(true));
	logger.addDestination(debugDestination.get());

	if (!QFile::exists("phototweet.cfg"))
	{
		QLOG_FATAL() << "Couldn't find config file 'phototweet.cfg'!";
		return 1;
	}

	Config config("phototweet.cfg");
	QString loggingLevel = config.GetValue("logging_level");
	logger.setLoggingLevel(loggingLevel);
	QLOG_INFO() << "Phototweet is starting..";

    PhotoTweet pt(&config);
    QObject::connect(&pt, SIGNAL(quit()), &app, SLOT(quit()));
    QMetaObject::invokeMethod(&pt, "main", Qt::QueuedConnection);
    return app.exec();
}
Beispiel #5
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Initialize the QS logger
    QsLogging::Logger& logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);

    // Set up the logging file
    const QString logFilePath(QDir(a.applicationDirPath()).filePath("clientLog.txt"));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(logFilePath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(fileDestination.get());
    logger.addDestination(debugDestination.get());

    QLOG_TRACE() << "Tracer Initialized";

    QLOG_INFO() << "Program started";
    QLOG_INFO() << "Built with QT " << QT_VERSION_STR << "running on " << qVersion();

   // MainWindow w;
    ClientInterface w;

    QLOG_TRACE() << "Object of MainWindow called w created";

    w.show();

    QLOG_TRACE() << "Showing the client UI through MainWindow called w";
    
    if (a.exec() == 0)
    {
        QLOG_TRACE() << "Program exit successful";
        return 0;
    }
    else {
        QLOG_FATAL() << "Program exit successful";
        return -1;
    }
}
Beispiel #6
0
int main(int argc, char ** argv)
{
    #ifdef DEBUG
    if (argc != 2)
        return 0;
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("deploy") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("deploy") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());
    //QTest::qSleep(15000);
    QLOG_INFO() << " STARTING DEPLOY";
#endif
    if (UmlCom::connect(QString(argv[1]).toUInt())) {
        try {
            UmlCom::trace("<b>Deploy classes</b> release 1.1 (C++ version)<br>");
            UmlCom::targetItem()->deploy();
            UmlCom::trace("Done");
        }
        catch (...)
        {
            QLOG_INFO() << "Exception caught";
        }

        // must be called to cleanly inform that all is done
        UmlCom::bye();
    }

    UmlCom::close();
    return 0;
}
Beispiel #7
0
int main(int argc, char ** argv)
{

    ExitOnError = FALSE;

    QApplication a(argc, argv);

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

//#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("douml") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("douml") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());
    QLOG_INFO() << "Starting the log";
//#endif


    An<EdgeMenuFactory> factory;
    factory->AddFactory(TypeIdentifier<ClassDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ClassDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<OperationDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<OperationDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ArtifactDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ArtifactDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ConstructorInitializerDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctorQt4(TypeIdentifier<ConstructorInitializerDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialogQt4>);


    UmlDesktop::init();
    QSettings settings("settings.ini", QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    bool overridePresent = QFileInfo("override_transition.txt").exists();
    if(settings.value("Main/compatibility_save") .toInt() == 1 && !overridePresent)
    {
    QMessageBox::warning(0, QObject::tr("Warning"),
                         QObject::tr("Douml is working in transitional mode.\n All UI improvements are yours to use,  "
                                     "but saving is done in the format of Bouml 4.22 "
                                     "which loses all new c++11 and hierarchy specifiers\n\n"
                                     "To suppress this warning place empty file override_transition.txt into the application folder\n"
                                     "To disable the mode - change compatibility_save parameter to 0 in settings.ini\n"));
    }

    // note : bool conv_env = !QDir::home().exists(".doumlrc") doesn't work
    // if the path contains non latin1 characters, for instance cyrillic !
    QString s = QDir::home().absFilePath(".doumlrc");
    FILE * fp = fopen((const char *) s, "r");
    bool conv_env = (fp == 0);


    if (conv_env)
        EnvDialog::edit(TRUE);
    else
        fclose(fp);

    read_doumlrc();	// for virtual desktop
    init_pixmaps();
    init_font();
    Shortcut::init(conv_env);

    bool exec = FALSE;
    bool no_gui = FALSE;

    if (argc > 3) {
        if (!strcmp(argv[2], "-execnogui"))
            exec = no_gui = TRUE;
        else
            exec = !strcmp(argv[2], "-exec");
    }

    UmlWindow * uw = new UmlWindow(exec);

    if (no_gui)
        UmlDesktop::set_nogui();
    else
    {
        uw->showMaximized();
    }

    if (argc > 1) {
        try {
            if ((argc == 3) &&
                !strcmp(argv[2], "-root") &&
                (msg_critical(TR("DO NOT CONFIRM"),
                              TR("Root mode protection\n\n"
                                 "This mode allows me to develop BOUML\n\n"
                                 "do NOT confirm to avoid a disaster !!!\n\n"
                                 "confirm ?"),
                              QMessageBox::Yes, QMessageBox::No)
                 == QMessageBox::Yes)) {
                set_user_id(0);
                set_editor(getenv("BOUML_EDITOR")); // no environment file
                argc = 1;
            }

            uw->load_it(argv[1]);
        }
        catch (...) {
            // cannot read a file
            return -1;

        }
    }

    QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

    try {
        if (argc > 2) {
            if (exec) {
                bool with_exit = FALSE;

                if (!strcmp(argv[argc - 1], "-exit")) {
                    with_exit = TRUE;
                    argc -= 1;
                }

                WrapperStr cmd = argv[3];
                WrapperStr space = " ";
                int index;

                for (index = 4; index != argc; index += 1)
                    cmd += space + WrapperStr(argv[index]);

                ToolCom::run((const char *) cmd, BrowserView::get_project(), with_exit);
            }
            else
                msg_warning(TR("Error"), TR("Bouml was called with wrong parameters, ignore them"));
        }


        ExitOnError = TRUE;
        a.exec();
    }
    catch (...) {
        ;
    }


    return exit_value();
}
Beispiel #8
0
int main(int argc, char ** argv)
{
#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("cpp_utils") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("cpp_generator") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());

    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    QString locale = settings.value("Main/encoding").toString();
    QTextCodec* codec = QTextCodec::codecForName(locale.toLatin1().constData());
    QTextCodec::setCodecForLocale(codec);

    QLOG_INFO() << " STARTING CPP_GENERATOR";

#endif
    //QTest::qSleep(7000);
    int port_index;
#ifndef _RUN_PLUGOUT_EXTERNAL_
    if (argc == 2) {
        port_index = 1;
        QLOG_INFO() << "Got two arguments from Douml as argv";
        QLOG_INFO() << "Using first port index mode";
    }
    else if (argc == 3) {
        QLOG_INFO() << "Got three arguments from Douml as argv";
        if (argv[1][1] == 'v') {
            QLOG_INFO() << "Using verbose mode";
            set_verbose();
        }
        else {
            QLOG_INFO() << "Using preserve mode";
            set_preserve();
        }
        QLOG_INFO() << "Using second port index mode";
        port_index = 2;
    }
    else if (argc == 4) {
        QLOG_INFO() << "Got four arguments from Douml as argv";
        QLOG_INFO() << "Using preserve mode";
        QLOG_INFO() << "Using verbose mode";
        QLOG_INFO() << "Using third port index mode";
        set_verbose();
        set_preserve();
        port_index = 3;
    }
    else {
        QLOG_INFO() << "Got too little or too much arguments from Douml, exiting";
        return 0;
    }
    if (UmlCom::connect(QString(argv[port_index]).toUInt())) {
#else
    port_index = 1;
    if (UmlCom::connect(5000)) {
#endif
        try {

            UmlCom::trace("<b>C++ generator</b> release 2.18<br>");
            UmlCom::traceAutoRaise(FALSE);
            UmlCom::targetItem()->generate();

            QString s;

            s = "<hr><font face=helvetica>Generation done : %1 warnings, %2 errors</font><br>";
            s=s.arg(QString::number(n_warnings())).arg(QString::number(n_errors()));

            UmlCom::trace(s.toLatin1().constData());

            UmlCom::showTrace();
            UmlCom::message("");

            UmlCom::bye(n_errors());
        }
        catch (...) {
            QLOG_INFO() << "unhandled exception caught";
        }
    }

    UmlCom::close();
    return 0;
}
Beispiel #9
0
int main(int argc, char *argv[])
{

    Botan::LibraryInitializer botanInit;

    // Setup the QApplication so we can begin
    Application a(argc, argv);
    global.application = &a;

    // Setup the QLOG functions for debugging & messages
    QsLogging::Logger& logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    const QString sLogPath(a.applicationDirPath());

    QsLogging::DestinationPtr fileDestination(
                QsLogging::DestinationFactory::MakeFileDestination(sLogPath) );
    QsLogging::DestinationPtr debugDestination(
                QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());


    // Begin setting up the environment
    global.argc = argc;
    global.argv = argv;

    // Show Qt version.  This is useful for debugging
    QLOG_INFO() << "Built with Qt" << QT_VERSION_STR << "running on" << qVersion();


    StartupConfig startupConfig;
    startupConfig.programDirPath = global.getProgramDirPath() + QDir().separator();
    startupConfig.name = "NixNote";
    startupConfig.accountId = 1;
    global.setup(startupConfig);

    // Create a shared memory region.  We use this to communicate
    // with any other instance that may be running.  If another instance
    // is found we need to either show that one or kill this one.
    bool memInitNeeded = true;
    if( !global.sharedMemory->create( 512, QSharedMemory::ReadWrite) ) {
        // Attach to it and detach.  This is done in case it crashed.
        global.sharedMemory->attach();
        global.sharedMemory->detach();
        if( !global.sharedMemory->create( 512, QSharedMemory::ReadWrite) ) {
            global.settings->beginGroup("Debugging");
            QString startup = global.settings->value("onMultipleInstances", "SHOW_OTHER").toString();
            global.settings->endGroup();
            global.sharedMemory->attach();
            global.sharedMemory->lock();
            void *dataptr = global.sharedMemory->data();
            if (startup == "SHOW_OTHER") {
                memcpy(dataptr, "SHOW_WINDOW", 11);  // Tell the other guy to show himself
                QLOG_INFO() << "Another NixNote was found.  Stopping this instance";
                exit(0);  // Exit this one
            }
            if (startup == "STOP_OTHER") {
                memcpy(dataptr, "IMMEDIATE_SHUTDOWN", 18);  // Tell the other guy to shut down
                memInitNeeded = false;
            }
            global.sharedMemory->unlock();
        }
    }
    if (memInitNeeded) {
        global.sharedMemory->lock();
        memset(global.sharedMemory->data(), 0, global.sharedMemory->size());
        global.sharedMemory->unlock();
    }



    // Save the clipboard
    global.clipboard = QApplication::clipboard();

    NixNote w;
    w.show();

    return a.exec();

}
Beispiel #10
0
int main(int argc, char *argv[])
{
    qRegisterMetaType<CurrentStatusUpdate>("CurrentStatusUpdate");
    qRegisterMetaType<Items>("Items");
    qRegisterMetaType<std::vector<std::string>>("std::vector<std::string>");
    qRegisterMetaType<std::vector<ItemLocation>>("std::vector<ItemLocation>");
    qRegisterMetaType<QsLogging::Level>("QsLogging::Level");
    qRegisterMetaType<TabSelection::Type>("TabSelection::Type");

    QLocale::setDefault(QLocale::C);
    std::setlocale(LC_ALL, "C");

#if defined(CRASHRPT) && !defined(_DEBUG)
    CR_INSTALL_INFOW info;
    memset(&info, 0, sizeof(info));
    info.cb = sizeof(info);
    info.pszAppName = L"Acquisition";
    WCHAR wversion[64];
    MultiByteToWideChar(CP_UTF8, 0, VERSION_NAME, -1, wversion, sizeof(wversion) / sizeof(wversion[0]));
    info.pszAppVersion = wversion;
    // URL for sending reports over HTTP.
    info.pszUrl = L"https://xyz.is/crashfix/index.php/crashReport/uploadExternal";
    // Define delivery transport priorities.
    info.uPriorities[CR_HTTP] = 1;                     // Use HTTP.
    info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY;  // Not use SMTP.
    info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; // Not use Simple MAPI.
    // Define flags.
    info.dwFlags = 0;
    info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Install all available exception handlers.
    info.dwFlags |= CR_INST_HTTP_BINARY_ENCODING;  // Use binary encoding for HTTP uploads (recommended).
    CrAutoInstallHelper cr_install_helper(&info);
#endif

    InitModlist();

    QApplication a(argc, argv);
    Filesystem::Init();

    QFontDatabase::addApplicationFont(":/fonts/Fontin-SmallCaps.ttf");

    QCommandLineParser parser;
    QCommandLineOption option_test("test"), option_data_dir("data-dir", "Where to save Acquisition data.", "data-dir");
    parser.addOption(option_test);
    parser.addOption(option_data_dir);
    parser.process(a);

    if (parser.isSet(option_test))
        return test_main();

    if (parser.isSet(option_data_dir))
        Filesystem::SetUserDir(parser.value(option_data_dir).toStdString());

    QsLogging::Logger& logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::InfoLevel);
    const QString sLogPath(QDir(Filesystem::UserDir().c_str()).filePath("log.txt"));

    QsLogging::DestinationPtr fileDestination(
        QsLogging::DestinationFactory::MakeFileDestination(sLogPath, true, 10 * 1024 * 1024, 0) );
    QsLogging::DestinationPtr debugDestination(
        QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    logger.addDestination(debugDestination);
    logger.addDestination(fileDestination);

    QLOG_DEBUG() << "-------------------------------------------------------------------------------";
    QLOG_DEBUG() << "Built with Qt" << QT_VERSION_STR << "running on" << qVersion();

    LoginDialog login(std::make_unique<Application>());
    login.show();

    return a.exec();
}
Beispiel #11
0
int main( int argc, char * argv[] )
{
    QString fileName = CHostTray::iniFileName();
    QSettings s( fileName, QSettings::IniFormat );
    bool logging = s.value( "logging", true ).toBool();
    s.setValue( "logging", logging );
    bool console = s.value( "console", false ).toBool();
    s.setValue( "console", console );
    s.sync();

    QsLogging::Logger& logger = QsLogging::Logger::instance();
    if ( logging )
        logger.setLoggingLevel(QsLogging::TraceLevel);
    else
        logger.setLoggingLevel(QsLogging::InfoLevel);
    
    const QString sLogPath = QString( "host-%1.log" ).arg( QDateTime(QDateTime::currentDateTime() ).toString( "yyyy.MM.dd-hh.mm.ss" ) );
    QsLogging::DestinationPtr fileDestination(
       QsLogging::DestinationFactory::MakeFileDestination(sLogPath) );
    
    QsLogging::DestinationPtr debugDestination(
       QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    
    logger.addDestination( debugDestination.get() );
    logger.addDestination( fileDestination.get() );

    QLOG_INFO() << "Host started";

    if ( !console )
    {
        QApplication a( argc, argv );

        QLOG_INFO() << "GUI mode";

        CHostTray * ht = new CHostTray();
        ht->show();

        int ret = a.exec();
        
        QLOG_INFO() << "Host exited with code " << ret;
        return ret;
    }
    else
    {
        QCoreApplication a( argc, argv );
        QLOG_INFO() << "Console mode";

        QString listen  = s.value( "listen",  "tcp -p 26001 -t 5000" ).toString();
        QString connect = s.value( "connect", "default -p 12345 -t 5000" ).toString();
        QString passwd  = s.value( "passwd", "qwertyqwerty" ).toString();
        bool    emulation = s.value( "emulation", true ).toBool();
        CHostIceThread * host = new CHostIceThread( listen.toStdString(), 
                                                    connect.toStdString(), 
                                                    passwd.toStdString() );
        if ( !host->listen() )
        {
            QLOG_INFO() << "host->losten() failed";
            return 1;
        }
        if ( !host->connect( emulation ) )
            QLOG_INFO() << "host->connect() failed";
            return 2;
        int res = a.exec();
        QLOG_INFO() << "Host exited with code " << res;
        return res;
    }
}
Beispiel #12
0
int main( int argc, char * argv[] )
{
    QString fileName = CTray::iniFileName();
    QSettings s( fileName, QSettings::IniFormat );
    bool logging = s.value( "logging", true ).toBool();
    s.setValue( "logging", logging );
    bool console = s.value( "console", false ).toBool();
    s.setValue( "console", console );
    s.sync();

    QsLogging::Logger& logger = QsLogging::Logger::instance();
    if ( logging )
        logger.setLoggingLevel(QsLogging::TraceLevel);
    else
        logger.setLoggingLevel(QsLogging::InfoLevel);
    
    const QString sLogPath = QString( "proxy-%1.log" ).arg( QDateTime(QDateTime::currentDateTime() ).toString( "yyyy.MM.dd-hh.mm.ss" ) );
    QsLogging::DestinationPtr fileDestination(
       QsLogging::DestinationFactory::MakeFileDestination(sLogPath) );
    
    QsLogging::DestinationPtr debugDestination(
       QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    
    logger.addDestination( debugDestination.get() );
    logger.addDestination( fileDestination.get() );

    QLOG_INFO() << "Proxy started";

    if ( !console )
    {
        QApplication a( argc, argv );

        QLOG_INFO() << "GUI mode";

        CTray * ht = new CTray();
        ht->show();

        int ret = a.exec();

        return ret;
    }
    else
    {
        QCoreApplication a( argc, argv );

        QLOG_INFO() << "Console mode";

        QString listenHost  = s.value( "listenHost",  "" ).toString();
        QString connectHost = s.value( "connectHost", "localhost" ).toString();
        int listenPort  = s.value( "listenPort",  "1234" ).toInt();
        int connectPort = s.value( "connectPort", "26001" ).toInt();

        CProxy * proxy = new CProxy( 0, listenHost, listenPort, connectHost, connectPort );
        if ( !proxy->isListening() )
        {
            QLOG_INFO() << "Listen failed";
            return 1;
        }
        int res = a.exec();
        return res;
    }
}
Beispiel #13
0
int main(int argc, char ** argv){
    QApplication app(argc, argv);
    app.setApplicationName(QObject::tr("ImproGui"));

    QsLogging::Logger& logger  = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    const QString sLogPath(QDir(app.applicationDirPath()).filePath("log.txt"));
    QsLogging::DestinationPtr fileDestination( QsLogging::DestinationFactory::MakeFileDestination(sLogPath) );
    QsLogging::DestinationPtr debugDestination( QsLogging::DestinationFactory::MakeDebugOutputDestination() );
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());


    QLOG_TRACE() << "Logging initiated";

    // manually set some file paths for scaffolding
    // load it in the workspace using the workspace API
    // with the appropriate settings for all the Track properties
    Workspace * activeWorkspace = new Workspace(0);

    Track * t;

    // scaffholding
    // load file list from ".txt"
    // this is temporary
    QFile file("./filestoload.txt");
    if(!file.open(QIODevice::ReadOnly)) {
        QLOG_ERROR() << file.errorString();
        return 1;
    }

    QLOG_TRACE() << "Loading file " << file.fileName() ;
    QTextStream in(&file);
    int index=0;
    while(!in.atEnd()) {
        QString line = in.readLine();
        QLOG_TRACE() << "Reading line: " << line ;
        QStringList fields = line.split(",");
        if(fields.size() < 8 ){
            QLOG_TRACE() << "Line unreadable";
        }else{
            t = new Track(
                        fields[0], // file name
                        ("true" == fields[1].toLower()), // loop
                        fields[2].toInt(), // start
                        fields[3].toInt(), // stop
                        fields[4].toInt(), // fade in
                        fields[5].toInt(), // fade out
                        ("true" == fields[6].toLower()), // showFilename
                        activeWorkspace
                        );

            index = activeWorkspace->addTrack(t);
            if( ("b" == fields[7].toLower()) ){
                activeWorkspace->stockToButtons(index);
            }else{
                activeWorkspace->stockToList(index);
            }
        };
    }


    // give the workspace to the media player (or use the controller as a broker between them?)
    // the media player should register to the signals triggered when a track is added or remove from the playlist
    // ...

    // create a "Players" object to deal with controlling the players
    MediaPlayerFactory * mediaPlayerFactory = new GstMediaPlayerFactory();
    Players * players = new Players(mediaPlayerFactory);
    UiController controller(players,activeWorkspace);

    BasicUi ui(&controller);
    ui.setWorkspace(activeWorkspace);

    ui.show();
    app.exec();

    delete activeWorkspace;
    //delete player;
    QLOG_TRACE() << "Workspace deleted";

    return 0;
}
Beispiel #14
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	//Init the logger
	QsLogging::Logger& logger = QsLogging::Logger::instance();
	logger.setLoggingLevel(QsLogging::TraceLevel);
#ifdef Q_OS_WIN
	QString appDataDir = QString(getenv("%USERPROFILE%")).replace("\\","/");
#else
	QString appDataDir = getenv("HOME");
#endif
	QDir appDir(appDataDir);
	if (appDir.exists())
	{
		if (!appDir.cd("EMStudio"))
		{
			appDir.mkdir("EMStudio");
			appDir.cd("EMStudio");
		}
		if (!appDir.cd("applogs"))
		{
			appDir.mkdir("applogs");
		}
	}
	const QString sLogPath(QDir(appDataDir + "/EMStudio/applogs").filePath("log.txt"));

	QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath, true, 0, 100));
	QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
	logger.addDestination(debugDestination);
	logger.addDestination(fileDestination);

	QString port = "";
	bool autoconnect = true;
	QString plugin = "";
	QList<QPair<QString,QString> > args = getArgs(argc,argv);
	for (int i=0;i<args.size();i++)
	{
		if (args[i].first == "--dev" || args[i].first == "-d")
		{
			port = args[i].second;
		}
		else if (args[i].first == "--help" || args[i].first == "-h")
		{
			printHelp();
			return 0;
		}
		else if (args[i].first == "--autoconnect" || args[i].first == "-a")
		{
			if (args[i].second.toLower() == "false")
			{
				autoconnect = false;
			}
		}
		else if (args[i].first == "--plugin" || args[i].first == "-p")
		{
			plugin = args[i].second;
		}
		else
		{
			qDebug() << "Unknown command" << args[i].first;
			printHelp();
			return 0;
		}
	}

	MainWindow *w = new MainWindow();
	if (port != "")
	{
		w->setDevice(port);
	}
	if (plugin == "")
	{
		//If no plugin is specified, load some reasonable defaults.
		if (QFile::exists("plugins/libfreeemsplugin.so"))
		{
			plugin = "plugins/libfreeemsplugin.so";
		}
		else if (QFile::exists("/usr/share/yats/plugins/libfreeemsplugin.so"))
		{
			plugin = "/usr/share/yats/plugins/libfreeemsplugin.so";
		}
		else if (QFile::exists("plugins/freeemsplugin.lib"))
		{
			plugin = "plugins/freeemsplugin.lib";
		}
		else if (QFile::exists("plugins/libfreeemsplugin.a"))
		{
			plugin = "plugins/libfreeemsplugin.a";
		}
		else if (QFile::exists("plugins/freeemsplugin.dll"))
		{
			plugin = "plugins/freeemsplugin.dll";
		}
		else if (QFile::exists("../../../plugins/libfreeemsplugin.dylib"))
		{
			plugin = "../../../plugins/libfreeemsplugin.dylib";
		}
		else if (QFile::exists("/usr/share/yats/plugins/libfreeemsplugin.dylib"))
		{
			plugin = "/usr/share/yats/plugins/libfreeemsplugin.dylib";
		}
	}
	w->setPlugin(plugin);
	if (autoconnect)
	{
		w->connectToEms();
	}
	w->show();
	return a.exec();
}