void StartUi::slotStartServer() { /* todo GameFrame if(!settings->getShowIpStats()) ip_stats->hide(); */ menuTabFrame->setSettings(); if(settings->isServer()) { qsrand(QDateTime::currentDateTime().toTime_t()); adminPassword.setNum(qrand ()); if(server) { server->kill(); delete server; } server = new QProcess(this); connect(server, SIGNAL(started()), this, SLOT(slotServerLaunched())); connect(server, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotServerLaunchedError(QProcess::ProcessError))); //read debug ouputs connect(server,SIGNAL(readyReadStandardOutput()),this,SLOT(slotReadServerDebug())); server->setReadChannelMode(QProcess::MergedChannels); QString serverCmdLine("./Serverd"); serverCmdLine += " --port "; serverCmdLine += QString::number(settings->getServerPort()); serverCmdLine += " --admin-password " + adminPassword; if(settings->isDebugMode()) serverCmdLine += " --debug-mode"; serverCmdLine += " --started-from-gui"; server->start(serverCmdLine); } else { adminPassword = menuTabFrame->getAdminPassword(); } gamePlay = new GamePlay(settings, menuTabFrame->getGraphicPreview(), menuTabFrame->getPlayerName()); NetClient *netclient = gamePlay->getNetClient(); connect( gamePlay, SIGNAL(quitGame()), this, SLOT(closeGame()), Qt::QueuedConnection ); connect( gamePlay, SIGNAL(sigLoadInterGame()), this, SLOT(slotLoadInterGame()) ); /* Connect some signals to the ourselves */ connect( netclient, SIGNAL(sigConnectionError()), this, SLOT(slotConnectionError()), Qt::QueuedConnection); connect( netclient, SIGNAL(sigGameStarted()), this, SLOT(slotGameStarted())); connect( netclient, SIGNAL(sigNetClientEnd()), this, SLOT(closeGame())); /* Connect some signals to the IP stats widget */ connect( netclient, SIGNAL(sigStatPing(int)), &ipStats, SLOT(slotStatPing(int))); connect( netclient, SIGNAL(sigStatPacketLoss(double)), &ipStats, SLOT(slotStatPacketLoss(double))); /* Connect some signals to the frame menu */ connect( netclient, SIGNAL(sigConnected()), menuTabFrame, SLOT(slotConnectedToServer())); connect( netclient, SIGNAL(sigIsServerAdmin()), menuTabFrame, SLOT(slotIsServerAdmin())); connect( netclient, SIGNAL(sigUpdatePlayerData(qint8,QString)), menuTabFrame, SLOT(slotUpdatePlayerData(qint8,QString))); connect( netclient, SIGNAL(sigMaxPlayersChanged(int)), menuTabFrame, SLOT(slotMaxPlayersValueChanged(int))); connect( netclient, SIGNAL(sigMaxWinsChanged(int)), menuTabFrame, SLOT(slotMaxWinsValueChanged(int))); connect( netclient, SIGNAL(sigMapRandom(bool)), menuTabFrame, SLOT(slotMapRandom(bool))); connect( netclient, SIGNAL(mapPreviewReceived(MapClient*)), menuTabFrame,SLOT(slotMapPreviewReceived(MapClient*))); connect( netclient, SIGNAL(sigPlayerLeft(qint8)), menuTabFrame, SLOT(slotPlayerLeft(qint8))); /* Connect some signals to the player list */ connect( netclient, SIGNAL(sigUpdatePlayerData(qint8, QString)), &playerListWidget, SLOT(slotAddPlayer(qint8, QString))); connect( gamePlay, SIGNAL(sigNewPlayerGraphic(qint8,const QPixmap &)), &playerListWidget, SLOT(slotNewPlayerGraphic(qint8,const QPixmap &))); connect( netclient, SIGNAL(sigPlayerLeft(qint8)), &playerListWidget, SLOT(slotRemovePlayer(qint8))); connect( netclient, SIGNAL(sigScoreUpdate(qint8, qint16)), &playerListWidget, SLOT(slotUpdatePlayerScore(qint8, qint16))); // must be queued otherwise NetClient instance is deleted before finishing its processing connect( netclient, SIGNAL(sigServerStopped()), this, SLOT(slotServerStopped()), Qt::QueuedConnection); // if the server is remote, try to connect immediately (otherwise server's output must be checked) if(!settings->isServer()) gamePlay->cliConnect(adminPassword); }
/** * @brief Constructor * * Sets the activitionstate to true * * @author Peter Grasch */ SimonControl::SimonControl(QWidget *parent) : QObject (parent) { setStatus(SimonControl::Disconnected); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connected()), this, SLOT(connectedToServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(disconnected()), this, SLOT(disconnectedFromServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connectionError(QString)), this, SLOT(slotConnectionError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemError(QString)), this, SLOT(slotSimondSystemError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationError(QString)), this, SLOT(slotSynchronisationError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionError(QString,QString)), this, SLOT(slotRecognitionError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationError(QString,QString)), this, SLOT(slotCompilationError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemWarning(QString)), this, SLOT(slotSimondSystemWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationWarning(QString)), this, SLOT(slotSynchronisationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionWarning(QString)), this, SLOT(slotRecognitionWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationWarning(QString)), this, SLOT(slotCompilationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(loggedIn()), this, SLOT(loggedIn())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognised(RecognitionResultList)), this, SLOT(wordRecognised(RecognitionResultList))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionStatusChanged(RecognitionControl::RecognitionStatus)), this, SLOT(recognitionStatusChanged(RecognitionControl::RecognitionStatus))); QObject::connect(ScenarioManager::getInstance(), SIGNAL(deactivatedScenarioListChanged()), this, SIGNAL(deactivatedScenarioListChanged())); QObject::connect(this, SIGNAL(deactivatedScenarioListChanged()), RecognitionControl::getInstance(), SLOT(sendDeactivatedScenarioList())); QObject::connect(ContextManager::instance(), SIGNAL(sampleGroupChanged(QStringList)), RecognitionControl::getInstance(), SLOT(sendDeactivatedSampleGroups(QStringList))); ContextManager::instance()->getSampleGroupCondition()->loadSampleGroupContext(); ActionManager::getInstance(); // initializing action manager SimonTTS::getInstance(); // initializing TTS system for dbus interface if (!ScenarioManager::getInstance()->init()) { KMessageBox::error(0, i18n("Could not initialize scenarios and shadow dictionary.")); if (!ScenarioManager::getInstance()->getCurrentScenario()) { kDebug() << "Aborting due to fatal error while loading scenarios"; exit(-1); // this is fatal } } connect(SoundServer::getInstance(), SIGNAL(error(QString)), this, SLOT(slotSoundError(QString))); }