Exemple #1
0
void loadbotservdb()
{
    char nick[NICKLEN+1];
    char ident[NICKLEN+1];
    char host[HOSTLEN+1];
    char chan[CHANLEN+1];
    MYSQL_RES *result;
    MYSQL_ROW row;

    if (!reconnect_to_db()) {
        fprintf(stderr,"Cannot connect to db\n");
        operlog("Cannot connect to db");
        return;
    }

    mysql_query(&mysql,"SELECT * FROM child_botserv_bots");
    if ((result = mysql_use_result(&mysql)) == NULL) {
        fprintf(stderr,"CRITICAL: Cannot load botserv bots table: mysql_use_result returned NULL\n");
        return;
    }
    while ((row = mysql_fetch_row(result))) {
        strncpy(nick,row[0],NICKLEN);
        strncpy(ident,row[1],NICKLEN);
        strncpy(host,row[2],HOSTLEN);
        if (find_bot(nick)) continue;
        addBot(nick,ident,host);
        if (vv) printf("Bot %s added (%s@%s)\n",nick,ident,host);
    }

    mysql_query(&mysql,"SELECT * FROM child_botserv_chans");
    if ((result = mysql_use_result(&mysql)) == NULL) {
        fprintf(stderr,"CRITICAL: Cannot load botserv chans table: mysql_use_result returned NULL\n");
        return;
    }
    while ((row = mysql_fetch_row(result))) {
        strncpy(chan,row[0],CHANLEN);
        strncpy(nick,row[1],NICKLEN);
        if (find_chanbot(chan)) continue;
        if (!find_bot(nick)) continue;
        if (!find_channel(chan)) continue;
        addChanbot(chan,nick);
        if (vv) printf("Chanbot %s added with bot %s\n",chan,nick);
    }

    mysql_close(&mysql);
}
Exemple #2
0
CLauncher::CLauncher(QWidget *pParent)
  : QWidget::QWidget(pParent)
{
    // Configuration of the window
    setWindowTitle(tr("BomberLua launcher"));

    // Horizontal layout
    {
        QHBoxLayout *layout = new QHBoxLayout;

        // List of bots
        m_pBotsList = new QListWidget;
        layout->addWidget(m_pBotsList);

        // Vertical layout
        {
            QVBoxLayout *column = new QVBoxLayout;

            // Button to add a bot
            QPushButton *add = new QPushButton(tr("Add a bot"));
            connect(add, SIGNAL(clicked()), this, SLOT(addBot()));
            column->addWidget(add);

            // Button to remove a bot
            QPushButton *remove = new QPushButton(tr("Remove this bot"));
            connect(remove, SIGNAL(clicked()), this, SLOT(removeBot()));
            column->addWidget(remove);

            // Allows to choose whether to run graphically or not
            m_pGraphic = new QCheckBox(tr("Graphics"));
            m_pGraphic->setCheckState(Qt::Checked);
            column->addWidget(m_pGraphic);

            // Button to start the game
            QPushButton *startButton = new QPushButton(tr("Start"));
            connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
            column->addWidget(startButton);

            layout->addLayout(column);
        }

        setLayout(layout);
    }
}
Exemple #3
0
CLauncher::CLauncher(QWidget *pParent)
  : QWidget::QWidget(pParent)
{
    // Paramétrage de la fenêtre
    setWindowTitle(tr("BomberLua launcher"));

    // Layout horizontal
    {
        QHBoxLayout *layout = new QHBoxLayout;

        // Liste des bots
        m_pBotsList = new QListWidget;
        layout->addWidget(m_pBotsList);

        // Layout vertical
        {
            QVBoxLayout *column = new QVBoxLayout;

            // Bouton pour ajouter un bot
            QPushButton *add = new QPushButton(tr("Ajouter un bot"));
            connect(add, SIGNAL(clicked()), this, SLOT(addBot()));
            column->addWidget(add);

            // Bouton pour enlever un bot
            QPushButton *remove = new QPushButton(tr("Retirer ce bot"));
            connect(remove, SIGNAL(clicked()), this, SLOT(removeBot()));
            column->addWidget(remove);

            // Permet de choisir si on est graphique ou pas
            m_pGraphic = new QCheckBox(tr("Graphique"));
            m_pGraphic->setCheckState(Qt::Checked);
            column->addWidget(m_pGraphic);

            // Bouton pour lancer le bazar
            QPushButton *startButton = new QPushButton(tr("Lancer"));
            connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
            column->addWidget(startButton);

            layout->addLayout(column);
        }

        setLayout(layout);
    }
}
UserSessionsWidget::UserSessionsWidget(QTabFramework& tabFramework, QSettings& settings, Entity::Manager& entityManager, DataService& dataService) :
  QWidget(&tabFramework), tabFramework(tabFramework), entityManager(entityManager),  dataService(dataService), sessionsModel(entityManager), /*ordersModel(entityManager), transactionModel(entityManager), */selectedSessionId(0)
{
  entityManager.registerListener<EConnection>(*this);

  setWindowTitle(tr("Bot Sessions"));

  QToolBar* toolBar = new QToolBar(this);
  toolBar->setStyleSheet("QToolBar { border: 0px }");
  toolBar->setIconSize(QSize(16, 16));
  toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

  addAction = toolBar->addAction(QIcon(":/Icons/user_gray_add.png"), tr("&Add"));
  addAction->setEnabled(false);
  connect(addAction, SIGNAL(triggered()), this, SLOT(addBot()));

  //optimizeAction = toolBar->addAction(QIcon(":/Icons/chart_curve.png"), tr("&Optimize"));
  //optimizeAction->setEnabled(false);
  //connect(optimizeAction, SIGNAL(triggered()), this, SLOT(optimize()));

  simulateAction = toolBar->addAction(QIcon(":/Icons/user_gray_go_gray.png"), tr("&Simulate"));
  simulateAction->setEnabled(false);
  connect(simulateAction, SIGNAL(triggered()), this, SLOT(simulate()));

  activateAction = toolBar->addAction(QIcon(":/Icons/user_gray_go.png"), tr("&Activate"));
  activateAction->setEnabled(false);
  connect(activateAction, SIGNAL(triggered()), this, SLOT(activate()));

  cancelAction = toolBar->addAction(QIcon(":/Icons/cancel2.png"), tr("&Cancel"));
  cancelAction->setEnabled(false);
  connect(cancelAction, SIGNAL(triggered()), this, SLOT(cancelBot()));

  sessionView = new QTreeView(this);
  sessionView->setUniformRowHeights(true);
  proxyModel = new QSortFilterProxyModel(this);
  proxyModel->setDynamicSortFilter(true);
  proxyModel->setSourceModel(&sessionsModel);
  sessionView->setModel(proxyModel);
  sessionView->setSortingEnabled(true);
  sessionView->setRootIsDecorated(false);
  sessionView->setAlternatingRowColors(true);
  connect(sessionView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(sessionSelectionChanged()));
  connect(&sessionsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(sessionDataChanged(const QModelIndex&, const QModelIndex&)));
  connect(&sessionsModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(sessionDataRemoved(const QModelIndex&, int, int)));
  connect(&sessionsModel, SIGNAL(modelReset()), this, SLOT(sessionDataReset()));
  connect(&sessionsModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(sessionDataAdded(const QModelIndex&, int, int)));

  QVBoxLayout* layout = new QVBoxLayout;
  layout->setMargin(0);
  layout->setSpacing(0);
  layout->addWidget(toolBar);
  layout->addWidget(sessionView);
  setLayout(layout);

  QHeaderView* headerView = sessionView->header();
  //headerView->resizeSection(0, 300);
  settings.beginGroup("BotSessions");
  headerView->restoreState(settings.value("HeaderState").toByteArray());
  selectedSessionId = settings.value("SelectedSessionId").toUInt();
  settings.endGroup();
  headerView->setStretchLastSection(false);
  headerView->setResizeMode(0, QHeaderView::Stretch);
}