void CustomServerNetworkHandler::onDisconnect(ServerNetworkHandler *real, const RakNet::RakNetGUID &guid, const std::string &message)
{
	for (SMPlayer *player : ServerManager::getOnlinePlayers())
	{
		if (player->getHandle()->guid == guid)
		{
			real->level->getLevelStorage()->save(*player->getHandle());

			PlayerQuitEvent quitEvent(player, "§e%multiplayer.player.left", { player->getName() });
			ServerManager::getPluginManager()->callEvent(quitEvent);

			TextPacket pk;
			pk.type = TextPacket::TYPE_TRANSLATION;
			pk.message = quitEvent.getQuitMessage();
			pk.params = quitEvent.getQuitParams();
			real->sender->send(pk);

			ServerManager::getServer()->removePlayer(player);

			ServerPlayer *serverPlayer = (ServerPlayer *)player->getHandle();
			serverPlayer->disconnect();
			serverPlayer->remove();

			real->raknet->announceServer(ServerManager::getServerName());
			break;
		}
	}
}
Beispiel #2
0
void wxStEditApp::OnSTEShellEvent(wxSTEditorEvent& event)
{
    // handle the event and for this example we just write it back
    wxSTEditorShell* shell = wxDynamicCast(event.GetEventObject(), wxSTEditorShell);
    wxString val = event.GetString();
    shell->AppendText(_("\nText Entered : '") + val + wxT("'\n"));

    // very simple mechanism to parse the line to do things, you may prefer
    //   using wxPython or wxLua and running the string as is.
    wxString token(val.BeforeFirst(wxT(' ')).Lower());

    if (val.Lower().Strip(wxString::both) == wxT("quit"))
    {
        wxCommandEvent quitEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
        event.SetEventObject(shell);
        shell->GetEventHandler()->ProcessEvent(quitEvent);
    }
    else if (token == wxT("setmaxhistorylines"))
    {
        wxString num = val.AfterFirst(wxT(' '));
        long n = 0;
        if (num.ToLong(&n))
        {
            shell->SetMaxHistoryLines(n);
            shell->AppendText(wxString::Format(_("The maximum number of history lines is set to %d.\n"), n));
        }
        else
            shell->AppendText(_("ERR: Expected number, eg. SetMaxHistoryLines 10\n"));
    }
    else if (token == wxT("setmaxlines"))
    {
        wxString num1 = val.AfterFirst(wxT(' ')).Strip(wxString::both);
        wxString num2 = num1.AfterFirst(wxT(' ')).Strip(wxString::both);
        num1 = num1.BeforeFirst(wxT(' ')).Strip(wxString::both);

        long n1 = 0, n2 = 2000;
        if (num1.ToLong(&n1) && (num2.IsEmpty() || num2.ToLong(&n2)))
        {

            shell->SetMaxLines(n1, n2);
            shell->AppendText(wxString::Format(_("The maximum number of displayed lines is set to\n  %d with an overflow of %d lines before deleting up to max lines.\n"), n1, n2));
        }
        else
            shell->AppendText(_("ERR: Expected number, eg. SetMaxLines 10 [2000]\n"));
    }

    shell->CheckPrompt(true);
}
Beispiel #3
0
bool QHaikuApplication::QuitRequested()
{
    QEvent quitEvent(QEvent::Quit);
    QCoreApplication::sendEvent(QCoreApplication::instance(), &quitEvent);
    return true;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    pDetectorProgress = NULL;
    mLogAllXmlRpcOutput = false;
    mDbUpdated = false;
    // mSyncRequests tracks how many sync requests have been made
    // in order to know when to re-enable the widgets
    mSyncRequests = 0;
    // mSyncPosition is used to iterate through the backend list,
    // so we only sync one repository at a time, rather than flinging
    // requests at all of them at once.
    mSyncPosition = 0;
    mUploading = false;
    QSettings settings("Entomologist");

    pManager = new QNetworkAccessManager();
    connect(pManager, SIGNAL(sslErrors(QNetworkReply *, const QList<QSslError> &)),
            this, SLOT(handleSslErrors(QNetworkReply *, const QList<QSslError> &)));

    ui->setupUi(this);

    QToolBar *toolBar = new QToolBar("Main Toolbar");
    toolBar->setObjectName("Main ToolBar");
    toolBar->setIconSize(QSize(32,32));
    refreshButton = toolBar->addAction(style()->standardIcon(QStyle::SP_BrowserReload), "");
    refreshButton->setToolTip("Resync all trackers");
    uploadButton = toolBar->addAction(style()->standardIcon(QStyle::SP_ArrowUp), "");
    uploadButton->setToolTip("Upload changes");
    changelogButton = toolBar->addAction(style()->standardIcon(QStyle::SP_FileDialogInfoView), "");
    changelogButton->setToolTip("Show changelog");
    toolBar->setMovable(false);
    addToolBar(Qt::TopToolBarArea, toolBar);


    setupTrayIcon();
    // Setup the "Show" menu and "Work Offline"
    ui->actionMy_Bugs->setChecked(settings.value("show-my-bugs", true).toBool());
    ui->actionMy_Reports->setChecked(settings.value("show-my-reports", true).toBool());
    ui->actionMy_CCs->setChecked(settings.value("show-my-ccs", true).toBool());
    ui->actionMonitored_Components->setChecked(settings.value("show-my-monitored", true).toBool());
    ui->action_Work_Offline->setChecked(settings.value("work-offline", false).toBool());

    // Set the default network status
    pStatusIcon = new QLabel();
    pStatusIcon->setPixmap(QPixmap(":/online"));
    pStatusMessage = new QLabel("");
    ui->statusBar->addPermanentWidget(pStatusMessage);
    ui->statusBar->addPermanentWidget(pStatusIcon);

    // We use a spinner animation to show that we're doing things
    pSpinnerMovie = new QMovie(this);
    pSpinnerMovie->setFileName(":/spinner");
    pSpinnerMovie->setScaledSize(QSize(48,48));
    ui->spinnerLabel->setMovie(pSpinnerMovie);
    ui->spinnerLabel->hide();
    ui->syncingLabel->hide();

    // Set up the resync timer
    pUpdateTimer = new QTimer(this);
    connect(pUpdateTimer, SIGNAL(timeout()),
            this, SLOT(resync()));
    setTimer();

    // Keyboard shortcuts for search bar focus / upload changes.
    QShortcut* searchFocus;
    QShortcut* uploadChange;
    QShortcut *logXmlRpc;

    searchFocus = new QShortcut(QKeySequence(Qt::META + Qt::Key_Space),this);
    searchFocus->setContext(Qt::ApplicationShortcut);
    connect(searchFocus,SIGNAL(activated()),this,SLOT(searchFocusTriggered()));

    uploadChange = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S),this);
    uploadChange->setContext(Qt::ApplicationShortcut);
    connect(uploadChange,SIGNAL(activated()),this,SLOT(upload()));

    logXmlRpc = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this);
    logXmlRpc->setContext(Qt::ApplicationShortcut);
    connect(logXmlRpc, SIGNAL(activated()), this, SLOT(toggleXmlRpcLogging()));

    // Menu actions
    connect(ui->action_Add_Tracker, SIGNAL(triggered()),
            this, SLOT(addTrackerTriggered()));
    connect(ui->action_Refresh_Tracker,SIGNAL(triggered()),
            this, SLOT(resync()));
    connect(ui->actionShow_ToDo_List, SIGNAL(triggered()),
            this, SLOT(showTodoList()));
    connect(ui->action_About, SIGNAL(triggered()),
            this, SLOT(aboutTriggered()));
    connect(ui->action_Web_Site, SIGNAL(triggered()),
            this, SLOT(websiteTriggered()));
    connect(ui->action_Preferences, SIGNAL(triggered()),
            this, SLOT(prefsTriggered()));
    connect(ui->action_Quit, SIGNAL(triggered()),
            this, SLOT(quitEvent()));
    connect(ui->actionMy_Bugs, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMy_CCs, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMy_Reports, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionMonitored_Components, SIGNAL(triggered()),
            this, SLOT(showActionTriggered()));
    connect(ui->actionEdit_Monitored_Components, SIGNAL(triggered()),
            this, SLOT(showEditMonitoredComponents()));
    connect(ui->action_Work_Offline, SIGNAL(triggered()),
            this, SLOT(workOfflineTriggered()));

    // Set up the search button
    connect(changelogButton, SIGNAL(triggered()),
            this, SLOT(changelogTriggered()));

    connect(ui->trackerTab, SIGNAL(showMenu(int)),
            this, SLOT(showMenu(int)));
    ui->trackerTab->removeTab(0);
    ui->trackerTab->removeTab(0);

    // And finally set up the various other widgets
    connect(refreshButton, SIGNAL(triggered()),
            this, SLOT(resync()));
    connect(uploadButton, SIGNAL(triggered()),
            this, SLOT(upload()));
    restoreGeometry(settings.value("window-geometry").toByteArray());
    // Set the network status bar and check for updates if possible
    if (isOnline())
        if (settings.value("update-check", true).toBool() == true)
            checkForUpdates();

    setupDB();
    toggleButtons();

    // Now we need the todo list widget
    pToDoDock = new QDockWidget(tr("ToDo List"), this);
    pToDoDock->setObjectName("ToDoDock");
    pToDoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    pToDoListWidget = new ToDoListWidget(pToDoDock);
    pToDoDock->setWidget(pToDoListWidget);
    addDockWidget(Qt::LeftDockWidgetArea, pToDoDock);
    pToDoDock->hide();
    restoreState(settings.value("entomologist-state").toByteArray());
    connect(pToDoDock, SIGNAL(visibilityChanged(bool)),
            this, SLOT(dockVisibilityChanged(bool)));
    if (pToDoDock->isVisible())
        ui->actionShow_ToDo_List->setText("Hide ToDo List");
    else
        ui->actionShow_ToDo_List->setText("Show ToDo List");

    pSearchTab = new SearchTab(this);
    connect(pSearchTab, SIGNAL(openSearchedBug(QString,QString)),
            this, SLOT(openSearchedBug(QString,QString)));

    loadTrackers();
    ui->trackerTab->addTab(pSearchTab, QIcon(":/search"), "Search");

    if ((settings.value("startup-sync", false).toBool() == true)
       || (mDbUpdated))
        syncNextTracker();
}
Beispiel #5
0
ConfigFileTestApp::~ConfigFileTestApp()
{
    boost::shared_ptr<QuitEvent> quitEvent(new QuitEvent());
    applEventProcessor->queue_event(quitEvent);
    applThread.join();
}