Esempio n. 1
0
void MldConfig::dumpConfig(FILE *stream)
{
  if(!mysqlHostname().isEmpty()) {
    fprintf(stream,"[mySQL]\n");
    fprintf(stream,
	    "  Hostname = %s\n",(const char *)mysqlHostname().toAscii());
    fprintf(stream,
	    "  Loginname = %s\n",(const char *)mysqlUsername().toAscii());
    fprintf(stream,
	    "  Database = %s\n",(const char *)mysqlDbname().toAscii());
    fprintf(stream,
	    "  Password = %s\n",(const char *)mysqlPassword().toAscii());
    fprintf(stream,"\n");
  }
  fprintf(stream,"[MCallMan]\n");
  fprintf(stream,"  DetailsRefreshInterval = %d\n",
	  conf_details_refresh_interval);
  fprintf(stream,"\n");
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    ApplicationHelper appHelper;

    QObject::connect(&app, SIGNAL(aboutToQuit()), &appHelper, SLOT(aboutToQuit()));
    signal(SIGINT, signalHandler);

    // Set application variables
    QCoreApplication::setApplicationName("pokerspiel-metaserver");
    QCoreApplication::setApplicationVersion("0.1.0");
    QCoreApplication::setOrganizationName("PokerSpielServices");
    QCoreApplication::setOrganizationDomain("pokerspielservices.me");

    // Get command line arguments
    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption serverPort(QStringList() << "P" << "port",
                                  "Port of the websocket server.",
                                  "ws_port",
                                  WEBSOCKET_PORT);
    parser.addOption(serverPort);
    QCommandLineOption mysqlHost(QStringList() << "h" << "host",
                                  "Hostname for mysql database.",
                                  "mysql_hostname",
                                  MYSQL_HOSTNAME);
    parser.addOption(mysqlHost);
    QCommandLineOption mysqlUsername(QStringList() << "u" << "username",
                                  "Username for mysql database.",
                                  "mysql_username",
                                  MYSQL_USERNAME);
    parser.addOption(mysqlUsername);
    QCommandLineOption mysqlPassword(QStringList() << "p" << "password",
                                  "Password of the mysql database.",
                                  "mysql_password",
                                  MYSQL_PASSWORD);
    parser.addOption(mysqlPassword);
    QCommandLineOption mysqlDatabase(QStringList() << "d" << "database",
                                  "Name of the mysql database.",
                                  "mysql_db",
                                  MYSQL_DB);
    parser.addOption(mysqlDatabase);

    QCommandLineOption jsonLog("json");
    jsonLog.setDescription("Output log in JSON format");
    parser.addOption(jsonLog);

    parser.process(app);

    if (parser.isSet(jsonLog)) {
        appHelper.jsonOutput = true;
        qInstallMessageHandler(jsonOutput);
    } else {
        appHelper.jsonOutput = false;
        qInstallMessageHandler(messageOutput);
    }

    // Connect to database
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName(parser.value(mysqlHost));
    db.setDatabaseName(parser.value(mysqlDatabase));
    db.setUserName(parser.value(mysqlUsername));
    db.setPassword(parser.value(mysqlPassword));
    db.setConnectOptions("MYSQL_OPT_RECONNECT=1");
    if (!db.open()) {
        qFatal("SQL Error: %s", db.lastError().text().toUtf8().constData());
    } else {
        qDebug() << "Connection to MYSQL-Server established (" << db.userName() << "@" << db.hostName() << ")";
    }

    // Start websocket server
    WebSocketServer server(parser.value(serverPort).toUInt());
    Q_UNUSED(server);

    return app.exec();
}