Beispiel #1
0
MonitorWindow::MonitorWindow():
   connected(false),
   usersSelectionCount(0),
   initialized(false )
{
   qServer = new afqt::QServer( this);
   qthreadClientUp = new afqt::QThreadClientUp( this, false, af::Environment::getMonitorUpdatePeriod(), af::Environment::getMonitorConnectRetries());
   qthreadClientSend = new afqt::QThreadClientSend( this);
   if( qServer->isInitialized() == false )
   {
      AFERROR("MonitorWindow::MonitorWindow: Server initialization failed.\n");
      return;
   }
   username = afqt::stoq( af::Environment::getUserName());
   hostname = afqt::stoq( af::Environment::getHostName());
   setWindowTitle("MonitorWindow::" + username + "@" + hostname + ":(connecting...)");


   QMenu * viewMenu = menuBar()->addMenu("View");


   QDockWidget * dock;

   dock = new QDockWidget( "Renders", this);
   rendersList = new ListRenders( dock);
   dock->setWidget( rendersList);
   addDockWidget( Qt::LeftDockWidgetArea, dock);
   viewMenu->addAction( dock->toggleViewAction());

   dock = new QDockWidget( "Users", this);
   usersList = new ListUsers( dock);
   dock->setWidget( usersList);
   addDockWidget( Qt::RightDockWidgetArea, dock);
   viewMenu->addAction( dock->toggleViewAction());

   dock = new QDockWidget( "Jobs", this);
   jobsList = new ListJobs( dock);
   dock->setWidget( jobsList);
   addDockWidget( Qt::RightDockWidgetArea, dock);
   viewMenu->addAction( dock->toggleViewAction());

   nodesList[ MTRenders ] = rendersList;
   nodesList[ MTUsers   ] = usersList;
   nodesList[ MTJobs    ] = jobsList;

   connect( usersList,         SIGNAL( itemSelectionChanged()), this, SLOT( usersSelectionChanged()));

   connect( qServer,           SIGNAL( newMsg( af::Msg*)), this, SLOT( caseMessage( af::Msg*)));
   connect( qthreadClientUp,   SIGNAL( newMsg( af::Msg*)), this, SLOT( caseMessage( af::Msg*)));
   connect( qthreadClientSend, SIGNAL( newMsg( af::Msg*)), this, SLOT( caseMessage( af::Msg*)));
   connect( qthreadClientUp,   SIGNAL( connectionLost() ), this, SLOT( connectionLost()));
   connect( qthreadClientSend, SIGNAL( connectionLost() ), this, SLOT( connectionLost()));
   monitor = new MonitorHost();
   initialized = true;
   monitor->stdOut();
   sendRegister();
}
Beispiel #2
0
void Dialog::caseMessage( af::Msg * msg)
{
//AFINFO("void Dialog::caseMessage( Msg msg)\n");
    if( msg == NULL)
    {
        AFERROR("Dialog::caseMessage: msg == NULL\n");
        return;
    }
#ifdef AFOUTPUT
    msg->stdOut();
#endif
    switch( msg->type())
    {
    case af::Msg::TClientExitRequest:
    case af::Msg::TVersionMismatch:
    case af::Msg::TMagicMismatch:
    {
        emit stop();
        break;
    }
    case af::Msg::TTalkId:
    {
        if( talk->getId())
        {
            if( msg->int32() != talk->getId()) connectionLost();
        }
        else
        {
            if( msg->int32())
            {
                talk->setId( msg->int32());
                qthreadClientUp->setUpMsg( new af::Msg( af::Msg::TTalkUpdateId, talk->getId(), true));
            }
            else connectionLost();
        }
        break;
    }
    case af::Msg::TTalksList:
    {
        upOnline( *msg);
        break;
    }
    case af::Msg::TTalkData:
    {
        af::MCTalkmessage amsg( msg);
        std::string user, text;
        amsg.getUser( user);
        amsg.getText( text);
        appendMessage( afqt::stoq( user), afqt::stoq( text));
        break;
    }
    default:
        AFERROR("Dialog::caseMessage Unknown message recieved.\n");
        msg->stdOut();
    }
    delete msg;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

	//QTranslator *qt_translator = new QTranslator;
	//if (qt_translator->load(":tr/qt_ru.qm")) a.installTranslator(qt_translator);

	QString cfg_file = a.applicationFilePath();
	#ifdef Q_OS_WIN32
		cfg_file.replace(".exe", ".xml");
	#else
		cfg_file += ".xml";
	#endif
	ProgramConfig conf(cfg_file);
	if (!conf.read()) return 0;
	Resources::config = &conf;

	try
	{
		Resources::db = new DBConnection();
	}
	catch(QString e)
	{
		QMessageBox::critical(0, a.applicationName(), e);
		return 0;
	}

	if (!Resources::db->login())
	{
		delete Resources::db;
		Resources::db = 0;
		return 0;
	}

	Resources::initStates();
	Resources::initShops();
	Resources::initLines();
	Resources::initSubstances();


	MainWindow w;
	QObject::connect(Resources::db, SIGNAL(connectionLost()), &w, SLOT(connectionLost()));
	QObject::connect(Resources::db, SIGNAL(connectionRepaired()), &w, SLOT(connectionRepaired()));
	w.setGeometry(400, 50, 1024, 700);
	w.showNormal();

	int ret = a.exec();
	if (Resources::db)
	{
		Resources::db->close();
		delete Resources::db;
		Resources::db = 0;
	}
	return ret;
}
void Communication::on_stateCounterChanged(int value)
{
    if(value > 2){
        emit connectionLost(true);
        ///when connection is lost, try opening port
        /// after informing the user.
        openPort();
    }

    if(value == 0){
        emit connectionLost(false);
    }
}
void UserRefreshThread::setRoom(const QString & _room)
{
    if (!m_canRefresh) return;

	if (_room == QString(""))
		return;
	QMutex * pMutex = new QMutex();
	pMutex->lock();
	pMutex->unlock(); delete pMutex;

	QString * initCommand = new QString(tr("ENTER-ROOM"));
	QString * leaveCommand = new QString(tr("LEAVE-ROOM"));

	QString * host = new QString(*m_pServer->getHost());
	unsigned int * port = new unsigned int; *port = 2015;

	char * response = new char[m_pServer->MAX_RESPONSE];
	memset(response, '\0', m_pServer->MAX_RESPONSE);
	
	char * response1 = new char[m_pServer->MAX_RESPONSE];
	memset(response1, '\0', m_pServer->MAX_RESPONSE);

	pMutex = new QMutex();
	pMutex->lock();

	m_roomName = _room;
	*leaveCommand += " " + *m_pUser + " " + *m_pPass;
	*initCommand += " " + *m_pUser + " " + *m_pPass + " " + m_roomName;

	if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
								(char*) leaveCommand->toStdString().c_str(), response))
	{ Q_EMIT connectionLost(); }

	if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
								(char*) initCommand->toStdString().c_str(), response))
	{ Q_EMIT connectionLost(); }


	pMutex->unlock(); delete pMutex;
	QString * toCheck = new QString(response);
	delete   initCommand; delete leaveCommand;
	delete[] response; delete[] response1;

	if (!(toCheck->contains(QString(tr("success:"))))) {
		Q_EMIT throwLoginFailed();
		return; //unable to login - exit.
	}
	*m_canRefresh = true;
	Q_EMIT updateRoom2();
}
Beispiel #6
0
Dialog::Dialog():
    connected(false),
    init(false )
{
    qServer = new afqt::QServer( this);
    qthreadClientUp = new afqt::QThreadClientUp( this, false, af::Environment::getTalkUpdatePeriod(), af::Environment::getTalkConnectRetries());
    qthreadClientSend = new afqt::QThreadClientSend( this);

    if( qServer->isInitialized() == false )
    {
        AFERROR("Dialog::Dialog: Server initialization failed.\n");
        return;
    }

    username = af::Environment::getUserName();
    hostname = af::Environment::getHostName();
    setWindowTitle((std::string("Talk::") + username + "@" + hostname + ":(connecting...)").c_str());

    editor = new Editor(this);
    textView  = new TextView(  this, afqt::stoq( username));
    usersList = new UsersList( this, afqt::stoq( username));

    QHBoxLayout *hlayout = new QHBoxLayout( this);
    QVBoxLayout *vlayout = new QVBoxLayout();
    hlayout->addLayout( vlayout);
    hlayout->addWidget( usersList);
    vlayout->addWidget( textView);
    vlayout->addWidget( editor);

    connect( qServer,         SIGNAL( newMsg( af::Msg*)), this, SLOT( caseMessage( af::Msg*)));
    connect( qthreadClientUp, SIGNAL( newMsg( af::Msg*)), this, SLOT( caseMessage( af::Msg*)));
    connect( qthreadClientUp, SIGNAL( connectionLost() ), this, SLOT( connectionLost()));

    connect( editor, SIGNAL( sendMessage()), this, SLOT( sendMessage()));

    connect( textView,  SIGNAL( activated()), this, SLOT( activated()));
    connect( usersList, SIGNAL( activated()), this, SLOT( activated()));
    connect( editor,    SIGNAL( activated()), this, SLOT( activated()));

    tray = new Tray( this, QString::fromUtf8( username.c_str()));
    connect( tray, SIGNAL( hideRaiseDialog()), this, SLOT( hideRaiseDialog()));

    talk = new TalkHost();
    init = true;
    talk->stdOut();

    sendRegister();
}
void StreamClient::handleInterrupt()
{
    if (m_socket.is_open() == false) return;
    stop();
    m_exit_result = CONNECTION_LOST;
    emit connectionLost();
}
Beispiel #8
0
Tip* TipCollection::canvasObjectToTip(CanvasObjectManager::Object obj)
{
   switch(obj) {
      case CanvasObjectManager::Object::DialInfo:
         return dialPad();
      case CanvasObjectManager::Object::EndCall :
         return endCall();
      case CanvasObjectManager::Object::Ringing :
         return ringing();
      case CanvasObjectManager::Object::Network :
         return connectionLost();
      case CanvasObjectManager::Object::DropInfo:
         return removeConference();
      case CanvasObjectManager::Object::ConfInfo:
         return conference();
      case CanvasObjectManager::Object::AccountDown:
         return networkLost();
      case CanvasObjectManager::Object::Searching:
         return searching();
      case CanvasObjectManager::Object::NoObject:
      case CanvasObjectManager::Object::AutoComplete:
         return nullptr;
   }
   return nullptr;
}
Beispiel #9
0
SimondConnector::SimondConnector(QObject *parent) :
    QObject(parent), state(Unconnected),
    socket(new QSslSocket(this)),
    timeoutTimer(new QTimer(this)),
    response(new QDataStream(socket)),
    mic(new SoundInput(SOUND_CHANNELS, SOUND_SAMPLERATE, this)),
    passThroughSound(false)
{
    connect(this, SIGNAL(connectionState(ConnectionState)), this, SLOT(setCurrentState(ConnectionState)));
    connect(socket, SIGNAL(readyRead()), this, SLOT(messageReceived()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()));
    connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(socketError()));
    connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(encrypted()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(connectionLost()));

    connect(mic, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
    connect(mic, SIGNAL(microphoneLevel(int,int,int)), this, SIGNAL(microphoneLevel(int,int,int)));
    connect(mic, SIGNAL(listening()), this, SLOT(startRecording()));
    connect(mic, SIGNAL(complete()), this, SLOT(commitRecording()));
    connect(mic, SIGNAL(readyRead()), this, SLOT(soundDataAvailable()));

    connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(timeoutReached()));
    timeoutTimer->setSingleShot(true);
    timeoutTimer->setInterval(SOCKET_TIMEOUT);
}
Beispiel #10
0
void Connector::disconnected(){
    emit connectionLost();
    /*QMessageBox::warning(0, tr("Disconnected"), tr("The connection was interrupted."),
                         QMessageBox::Ok,QMessageBox::NoButton);*/
    delete this->_socket;
    this->_socket = 0;
}
Beispiel #11
0
void MonitorWindow::caseMessage( af::Msg *msg)
{
//AFINFO("void MonitorWindow::caseMessage( Msg msg)\n");
   if( msg == NULL)
   {
      AFERROR("MonitorWindow::caseMessage: msg == NULL\n");
      return;
   }
#ifdef AFOUTPUT
   msg->stdOut();
#endif
   switch( msg->type())
   {
   case af::Msg::TClientExitRequest:
   case af::Msg::TVersionMismatch:
   case af::Msg::TMagicMismatch:
   {
      emit stop();
      break;
   }
   case af::Msg::TMonitorId:
   {
      if( monitor->getId() != 0 )
      {
         if( msg->int32() != monitor->getId()) connectionLost();
      }
      else
      {
         if( msg->int32() == 0)
         {
            connectionLost();
         }
         else
         {
            monitor->setId( msg->int32());
            connectionEstablished();
            af::Msg * msg = new af::Msg( af::Msg::TMonitorUpdateId, monitor->getId(), true);
            qthreadClientUp->setUpMsg( msg);
         }
      }
      break;
   }
   default:
      for( int t = 0; t < MTLast; t++) if( nodesList[t]->caseMessage( msg)) break;
   }
   delete msg;
}
void WDClient::conDisconnected()
{
	emit connectionLost();
	qDebug() << "Client:  Socket connection closed.";
	disconnect(mSocket, SIGNAL(disconnected()));
	disconnect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
	mSocket->deleteLater();
}
Beispiel #13
0
void Dialog::idReceived( int i_id, int i_uid)
{
	if( MonitorHost::id() > 0 )
	{
		if( i_id != MonitorHost::id())
		{
			connectionLost();
		}
	}
	else
	{
		if( i_id == 0)
		{
			connectionLost();
		}
		else
		{
			AFINFA("Dialog::idReceived: ID=%d UID=%d\n", i_id, i_uid)

			MonitorHost::connectionEstablished( i_id, i_uid);
			connectionEstablished();
			Watch::connectionEstablished();

			if( i_uid == -1 )
			{
				if( m_monitorType == Watch::WJobs )
				{
					ButtonMonitor::unset();
					closeList();
				}
				displayWarning("You are not exist.");
			}
			else
			{
				displayInfo("You have registered.");
				if( m_monitorType == Watch::WNONE )
				{
					ButtonMonitor::pushButton( Watch::WJobs);
				}
			}

			af::Msg * msg = new af::Msg( af::Msg::TMonitorUpdateId, i_id);
			m_qThreadClientUpdate.setUpMsg( msg);
		}
	}
}
Beispiel #14
0
/*!
    \internal
*/
void QInterProcessChannel::check()
{
    //qDebug("checking connection...");
    
    QTcpSocket *pSocket = new QTcpSocket(this);
    pSocket->connectToHost(m_addr, m_port);
    
    if ( pSocket->error() != -1 )
    {
        emit connectionLost();
        return;
    }
    
    pSocket->waitForConnected(WAIT_TIMEOUT);
    
    if ( pSocket->error() != -1 )
    {
        emit connectionLost();
        return;
    }
}
Beispiel #15
0
/**
 * @brief EngineClient::~LocalServer
 *  Destructor
 */
EngineClient::~EngineClient()
{
    if(ipClient)
    {
        disconnect(this, SIGNAL(sendMessage(QString)), ipClient, SLOT(sendMessage(QString)));
        disconnect(ipClient, SIGNAL(messageIn(QString)), this, SLOT(slotOnData(QString)));
        disconnect(this, SIGNAL(closed()), ipClient, SLOT(doClose()));
        disconnect(this, SIGNAL(open()), ipClient, SLOT(doOpen()));
        disconnect(ipClient, SIGNAL(closeThread()), this, SLOT(connectionLost()));
        delete ipClient;
    }
    ipClient=NULL;
}
Beispiel #16
0
void UserRefreshThread::updateRoom(QString newRoom)
{
	qDebug("In updateRoom!");
	QString * initCommand = new QString(tr("ENTER-ROOM"));
	QString * leaveCommand = new QString(tr("LEAVE-ROOM"));
	*leaveCommand += " " + *m_pUser + " " + *m_pPass + " " + m_roomName;
	*initCommand += " " + *m_pUser + " " + *m_pPass + " " + newRoom;
	QString * host = new QString(*m_pServer->getHost());
	unsigned int * port = new unsigned int; *port = 2015;
	char * response = new char[m_pServer->MAX_RESPONSE];
	QMutex * pMutex = new QMutex();
	pMutex->lock();
	m_list.clear();

	if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
								(char*) leaveCommand->toStdString().c_str(), response))
	{ Q_EMIT connectionLost(); }

	delete leaveCommand;

	if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
								(char*) initCommand->toStdString().c_str(), response))
	{ Q_EMIT connectionLost(); }

	pMutex->unlock(); delete pMutex;
	QString * toCheck = new QString(response);
	delete   initCommand;
	delete[] response;

	if (!(toCheck->contains(QString(tr("success:"))))) {
		Q_EMIT throwLoginFailed();
		return; //unable to login - exit.
	}

	m_roomName = newRoom;
}
Beispiel #17
0
EngineClient::EngineClient() : QThread(NULL)
{
    if(!ipClient)
    {
        ipClient = new IpsEngineClient();
        connect(this, SIGNAL(sendMessage(QString)), ipClient, SLOT(sendMessage(QString)));
        connect(ipClient, SIGNAL(messageIn(QString)), this, SLOT(slotOnData(QString)));
        connect(this, SIGNAL(closed()), ipClient, SLOT(doClose()));
        connect(this, SIGNAL(open()), ipClient, SLOT(doOpen()));
        connect(ipClient, SIGNAL(closeThread()), this, SLOT(connectionLost()));
    }
    readyToSendLvlx = false;
    _connected = false;
    _busy = false;
    working=false;
    doSendData = false;
}
Beispiel #18
0
uint8_t MWiFi::decodeAsync()
{
         uint8_t ev=rxmbuff[0];
         switch (ev)
         {
           case 8: CONNSTATUS=rxmbuff[1];CONNEVDATA=rxmbuff[2];
                   if (CONNSTATUS==5) connectionLost();break;
           case 9: NNETS=rxmbuff[1];break;
           case 16: memcpy(&IP[0],&rxmbuff[2],4);break;
           case 26: PINGOK=rxmbuff[1];memcpy(&PINGTIME,&rxmbuff[2],2);break;
           case 27: STARTUPBITS=rxmbuff[1];memcpy(&MCWVERSION[0],&rxmbuff[2],2);
                    memcpy(&RADIOVERSION[0],&rxmbuff[4],2);break;
           case 255: memcpy(&ERRORTYPE,&rxmbuff[2],2);errorRoutine();break;
         }
         #if WIFIDEBUG
         printAsync(ev);
         #endif
         return ev;
}
Beispiel #19
0
void CameraTcpServer::incomingConnection(int socketDescriptor)
{
	QList<QTcpSocket*> clients = this->findChildren<QTcpSocket*>();
	if(clients.size() >= 1)
	{
		UWARN("A client is already connected. Only one connection allowed at the same time.");
		QTcpSocket socket;
		socket.setSocketDescriptor(socketDescriptor);
		socket.close(); // close without sending an acknowledge
	}
	else
	{
		QTcpSocket * socket = new QTcpSocket(this);
		connect(socket, SIGNAL(readyRead()), this, SLOT(readReceivedData()));
		connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
		connect(socket, SIGNAL(disconnected()), this, SLOT(connectionLost()));
		socket->setSocketDescriptor(socketDescriptor);
		socket->write(QByteArray("1")); // send acknowledge
	}
}
void ClientConnectionManager::socketDisconnected()
{
    // get a pointer to the calling socket
    QTcpSocket * socket = qobject_cast<QTcpSocket*>(sender());

    QString socket_id = QString::number(int(socket->socketDescriptor()));

    emit connectionLost(socket_id);
    disconnect(socket,0,0,0);

    // get the socket id

    // clean the socket up
    int removed = mSockets.removeAll(socket);

    if(removed > 1 )
        qDebug() << "More than one removed?";


}
Beispiel #21
0
void MainWindow::Au2connect()
{
    if(isConnected)
    {
        QMessageBox messageBox;
        messageBox.information(0,"Status","Forbindelsen er allerede oprettet!");
        messageBox.setFixedSize(500,200);
    }
    else
    {
        socket = new QTcpSocket(this);

        connect(socket,SIGNAL(connected()),this,SLOT(connected()),Qt::DirectConnection);
        connect(socket,SIGNAL(disconnected()),this,SLOT(connectionLost()),Qt::DirectConnection);

        socket->connectToHost(IP,1234);

        if(!socket->waitForConnected(1000))
        {
            QMessageBox messageBox;
            messageBox.critical(0,"Fejl","Forbindelsen blev ikke oprettet!");
            messageBox.setFixedSize(500,200);
        }
        else
        {
            controller();
            int error = pthread_create(&dataThread, NULL, this->getDataHelper ,this);
               if(error !=0)
              {
                qDebug()<<"Error on pthread_create"<<endl;
                return;
              }

            openPlayer();
         }
     }
}
Beispiel #22
0
int main(int argc, char *argv[])
{
	QCoreApplication app(argc, argv);

	initLogger(QsLogging::InfoLevel);

	bool expectVerbosity = false;
	bool expectDBusAddress = false;
	QString portName;
	QString dbusAddress = "system";
	QStringList args = app.arguments();
	args.pop_front();
	foreach (QString arg, args) {
		if (expectVerbosity) {
			QsLogging::Logger &logger = QsLogging::Logger::instance();
			QsLogging::Level logLevel = static_cast<QsLogging::Level>(qBound(
				static_cast<int>(QsLogging::TraceLevel),
				arg.toInt(),
				static_cast<int>(QsLogging::OffLevel)));
			logger.setLoggingLevel(logLevel);
			expectVerbosity = false;
		} else if (expectDBusAddress) {
			dbusAddress = arg;
			expectDBusAddress = false;
		} else if (arg == "-h" || arg == "--help") {
			QLOG_INFO() << app.arguments().first();
			QLOG_INFO() << "\t-h, --help";
			QLOG_INFO() << "\t Show this message.";
			QLOG_INFO() << "\t-V, --version";
			QLOG_INFO() << "\t Show the application version.";
			QLOG_INFO() << "\t-d level, --debug level";
			QLOG_INFO() << "\t Set log level";
			QLOG_INFO() << "\t-b, --dbus";
			QLOG_INFO() << "\t dbus address or 'session' or 'system'";
			QLOG_INFO() << "\t <Port Name>";
			QLOG_INFO() << "\t Name of communication port (eg. /dev/ttyUSB0)";
			exit(1);
		} else if (arg == "-V" || arg == "--version") {
			QLOG_INFO() << VERSION;
			exit(0);
		} else if (arg == "-d" || arg == "--debug") {
			expectVerbosity = true;
		} else if (arg == "-t" || arg == "--timestamp") {
			QsLogging::Logger &logger = QsLogging::Logger::instance();
			logger.setIncludeTimestamp(true);
		} else if (arg == "-b" || arg == "--dbus") {
			expectDBusAddress = true;
		} else if (!arg.startsWith('-')) {
			portName = arg;
		}
	}

	if (portName.isEmpty()) {
		QLOG_ERROR() << "No communication port specified on command line";
		exit(2);
	} else {
		QLOG_INFO() << "Connecting to" << portName;
	}

	initDBus(dbusAddress);

	DBusRedflow a(portName);

	app.connect(&a, SIGNAL(connectionLost()), &app, SLOT(quit()));

	return app.exec();
}
int ClientInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: sendMessage(); break;
        case 1: chat((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[4]))); break;
        case 2: changeServerInformations((*reinterpret_cast< ServerInformations(*)>(_a[1]))); break;
        case 3: changeClientID((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 4: changeClientNickname((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: showError((*reinterpret_cast< ENUM_TYPE(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: changeGameMaster((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 7: clientVoted((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< CLID(*)>(_a[2]))); break;
        case 8: connectionEtablished(); break;
        case 9: connectionLost(); break;
        case 10: diceRolled((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2])),(*reinterpret_cast< quint16(*)>(_a[3]))); break;
        case 11: sanctionned((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 12: rollDice(); break;
        case 13: rollSpecialDice(); break;
        case 14: serverName((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 15: motdChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 16: gameLaunched(); break;
        case 17: setTitle(); break;
        case 18: playSound((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 19: updatePlayerList(); break;
        case 20: clientJoined((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 21: clientLeft((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 22: updateGMLabel(); break;
        case 23: updateGMPanel(); break;
        case 24: { bool _r = addLanguage();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 25: { bool _r = addLanguage((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 26: languageListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 27: { bool _r = removeLanguage((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 28: removeLanguageMenu(); break;
        case 29: importLanguageList(); break;
        case 30: sendLanguageList(); break;
        case 31: { CLID _r = CLIDFromString((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< CLID*>(_a[0]) = _r; }  break;
        case 32: switchConnectionState(); break;
        case 33: openSettings(); break;
        case 34: openSoundsGUI(); break;
        case 35: aboutUs(); break;
        case 36: aboutServer(); break;
        case 37: openMapEditor(); break;
        case 38: clearMapEditor(); break;
        case 39: mapFlare(); break;
        case 40: resetData(); break;
        case 41: setCSS((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 42: setCSS(); break;
        case 43: setInterface((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 44: setInterface(); break;
        case 45: playerListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 46: actionKick(); break;
        case 47: actionBan(); break;
        case 48: actionVoteGM(); break;
        case 49: actionChangeGM(); break;
        case 50: refresh(); break;
        case 51: textChanged(); break;
        case 52: narrationChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 53: syncSoundLibs((*reinterpret_cast< QList<SoundLibInformations>(*)>(_a[1]))); break;
        case 54: syncLanguagesList((*reinterpret_cast< QList<QPair<QString,QString> >(*)>(_a[1]))); break;
        case 55: syncDictionariesList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 56: requestScriptDownload((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 57: sendScriptToServer((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 58: deleteScript((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 59: renameScript((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 60: makeEntity((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 61: deleteEntity((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 62: injectCode((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: scriptToGMMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 64: scriptToOwnerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 65: scriptActionMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 66: scriptToPlayerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 67: scriptMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 68: scriptError((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 69: sendMapToServer((*reinterpret_cast< const MapInformations*const(*)>(_a[1])),(*reinterpret_cast< const QMap<QString,RSID>(*)>(_a[2]))); break;
        case 70: addDictionnary(); break;
        case 71: saveGame(); break;
        case 72: loadGame(); break;
        case 73: VOIPRemoveClient(); break;
        case 74: VOIPAddClient(); break;
        case 75: VOIPClientVolume(); break;
        case 76: dataPerSecond((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 77;
    }
    return _id;
}
Beispiel #24
0
void Slave::startup()
{
    registerBuiltinBurners();
    loadEmbeddedPython();

    LOG_5( "Slave::startup()" );
    mHost = Host::currentHost();

    mSpooler = new Spooler( this );

    if( !mHost.isRecord() ) {
        if( mAutoRegister ) {
            LOG_3( "Slave::startup: no host record, auto-registering" );
            mHost = Host::autoRegister();
        } else {
            LOG_3( "Slave::startup: no host record, uh oh!" );
            exit(-1);
        }
    } else
        mHost.updateHardwareInfo();

    mHostStatus = mHost.hostStatus();

    if( !mHostStatus.isRecord() ) {
        if( mAutoRegister ) {
            LOG_3( "Slave::startup: No host status record(are all your triggers installed?), creating one" );
            mHostStatus.setHost( mHost );
            mHostStatus.setOnline( 1 );
        } else {
            LOG_3( "Slave::startup: no host status record, uh oh!" );
            exit(-1);
        }
    }
    mHostStatus.setAvailableMemory( mHost.memory() );
    mHostStatus.commit();

    connect( Database::current()->connection(), SIGNAL( connectionLost() ), SLOT( slotConnectionLost() ) );
    connect( Database::current()->connection(), SIGNAL( connected() ), SLOT( slotConnected() ) );

    // The rest of the initialization is only for normal mode where we moniter and manipulate
    // the hosts status.  In burn only mode we simply execute a job and exit
    if( mBurnOnlyJobAssignmentKey ) {
        burn( JobAssignment(mBurnOnlyJobAssignmentKey) );
        return;
    }

    mService = Service::ensureServiceExists("Assburner");

    // Start remote log server and set port in our Assburner HostService record
    RemoteLogServer * rls = new RemoteLogServer();
    HostService hs = HostService::recordByHostAndService( mHost, mService );
    if( hs.isRecord() && rls->tcpServer()->isListening() ) {
        hs.setRemoteLogPort( rls->tcpServer()->serverPort() );
        hs.commit();
    }

    // Set host version string.
    mHost.setAbVersion( "v" + QString(VERSION));
    mHost.commit();

    // Reset any frame assignments and set our host status
    // to ready.  Do we need this anymore?  The reaper
    // should now detect and re-assign frames if we are
    // offline, and this prevents a client-update from
    // happening when assburner starts.
    //
    // Nope, this doesn't f**k with the status, so it is
    // safe.  It just clears fkeyJob to slaveFrames.  And
    // returns any frames that have fkeyHost=this
    mHostStatus.returnSlaveFrames();

    loadForbiddenProcesses();

    mTimer = new QTimer( this );
    connect( mTimer, SIGNAL( timeout() ), SLOT( loop() ) );

    // Default 5000ms, min 200ms, max 600,000ms - 10 minutes
    mLoopTime = qMax( 200, qMin( 1000 * 60 * 10, Config::getInt( "assburnerLoopTime", 5000 ) ) );

    // Default mLoopTime / 2,  min 100ms, max mLoopTime
    mQuickLoopTime = qMax( 100, qMin( mLoopTime, Config::getInt( "assburnerQuickLoopTime", mLoopTime / 2 ) ) );

    // Default 60 seconds, min 10 seconds.
    mPulsePeriod = qMax( 10, Config::getInt( "arsenalPulsePeriod", 600 ) );

    // Default 60 seconds, min 10 seconds.
    mMemCheckPeriod = qMax( 10, Config::getInt( "abMemCheckPeriod", 60 ) );

    IniConfig & c = config();

    c.pushSection( "BackgroundMode" );
    mBackgroundModeEnabled = c.readBool( "Enabled", true );
    c.popSection();

    // Pulse right away.
    pulse();

    // We need to set our host status to offline when assburner quits
    connect( qApp, SIGNAL( aboutToQuit() ), SLOT( offlineFromAboutToQuit() ) );

    if( mUseGui ) {
        mIdle = new Idle();
        connect( mIdle, SIGNAL( secondsIdle( int ) ), SLOT( slotSecondsIdle( int ) ) );
        mIdle->start();
    }

    if( mHostStatus.slaveStatus() == "client-update-offline" )
        offline();
    else if( mHostStatus.slaveStatus() == "client-update" )
        clientUpdate();
    else {
        // Store the current status
        QString currentStatus = mHostStatus.slaveStatus();

        // We run the host through the online method first
        online();

        // Check if the old host status wasn't empty
        if( !currentStatus.isEmpty() ) {
            // Resume the state the host was in.
            LOG_3("Slave::startup() Resuming previous status of " + currentStatus);
            handleStatusChange(currentStatus, "");
        }
    }

    // Create a timer for logged in user checks
    mUserTimer = new QTimer( this );
    connect( mUserTimer, SIGNAL( timeout() ), SLOT( updateLoggedUsers() ) );

    // Set it to trigger every 5 mins
    mUserTimer->start(300000);

    LOG_5( "Slave::startup() done" );
}
/*! The client needs to be removed from the server. Delete the socket and this object.
*/
void QwsClientSocket::disconnectClient()
{
    qDebug() << this << "Called disconnectClient()";
    pSocket->disconnectFromHost();
    emit connectionLost();
}
Beispiel #26
0
void Drone::runUpdateLoop()
{
	int runTime = 0;
	int updateInterval = 1000/40;

	boost::timer::cpu_timer timer;

	while(!_stop_flag)
	{
		timer.start();

		// TODO: Think this through really well, find memory leaks!

		// Check connection status and handle unexpected loss of connection
		if(!_connected.load()) {
			notifyConnectionLost();
			connectionLost();
			return;
		}

		// Call any miscellaneous functionality needed by implementation
		beforeUpdate();

		// Process command queue
		_commandmutex.lock();
		if(_commandqueue.empty())
		{
			_connected.store(processNoCommand());
			if(!_connected.load())
			{
				continue;
			}
		}
		else
		{
			for(drone::command command : _commandqueue)
			{
				_connected.store(processCommand(command));
				if(!_connected.load())
				{
					_commandqueue.clear();
					continue;
				}
			}
		}
		_commandqueue.clear();
		_commandmutex.unlock();

		// Retrieve and process navdata
		std::shared_ptr<drone::navdata> navdata;
		bool newNavdata = decodeNavdata(navdata);

		if(newNavdata)
		{
			notifyNavdataListeners(navdata);
		}

		// Call any miscellaneous functionality needed by implementation
		updateCycle();

		// Run at continuous update rate
		runTime = timer.elapsed().wall / 1000000;
		timer.stop();

		if(updateInterval - runTime > 0)
		{
			boost::this_thread::sleep_for(boost::chrono::milliseconds(updateInterval - runTime));
		}
	}
}
Beispiel #27
0
void UserRefreshThread::refreshLoop()
{
	const QRegExp rx("[\r\n]");
	QString refreshCommand = QString(tr("GET-ROOM-USERS "));
	refreshCommand += *m_pUser + QString(" ");
	refreshCommand += *m_pPass;
	bool refresh;

	while (!m_pThread->isInterruptionRequested()) {
		refresh = false;
		QStringList * parsed = new QStringList();
		char * response = new char[m_pServer->MAX_RESPONSE];
		QString * command = new QString();

		QString * host = new QString(*m_pServer->getHost());
		unsigned int * port = new unsigned int; *port = 2015;

		QMutex * pMutex = new QMutex();
		pMutex->lock();

		if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
								   (char*) command->toStdString().c_str(), response))
		{ Q_EMIT connectionLost(); }
		qDebug() << "Server response: " << response;
		QString * reply = new QString(tr(response));
		*parsed  = reply->split(rx, QString::SkipEmptyParts);
		delete[] response; delete reply; delete command;

		m_list.clear();
		m_list << *m_pUser << tr("\n");
		for (quint16 x = 1; x < parsed->size(); ++x) {
			const QString * toAdd = &parsed->at(x);

			if (!m_list.contains(*toAdd)) {
				refresh = true;
				m_list << *toAdd;
			}
		} delete parsed;
		pMutex->unlock(); delete pMutex;

		parsed   = new QStringList();
		response = new char[m_pServer->MAX_RESPONSE];
		command  = new QString();

		*command += QString(tr("GET-NEW-MSGS ")) + *m_pUser + " "
				+ *m_pPass + " " + QString("").setNum(0);

		pMutex = new QMutex();

		pMutex->lock();

		if (!m_pServer->sendCommand((char*) host->toStdString().c_str(), *port,
									(char*) command->toStdString().c_str(), response))
		{ Q_EMIT connectionLost(); }

		pMutex->unlock(); delete pMutex;
		reply = new QString(tr(response));
		*parsed  = reply->split(rx, QString::SkipEmptyParts);
		delete[] response; delete reply; delete command;

		for (quint16 x = 1; x < parsed->size(); ++x) {
			const QString * toAdd = &parsed->at(x);
			m_messageList<<*toAdd;
		}

		delete parsed;
		if (refresh)
			Q_EMIT refreshed();
#if QT_VERSION >= 0x050000
		m_pThread->msleep(1000);//wait a second!
#endif
	}
}
Beispiel #28
0
 /*!
  * \brief VideoService::checkLost checks the state of the connection (every 2000ms).
  * If the connection is lost the connectionLost() signal is emited.
  */
 void VideoService::checkLost()
 {
     if(lostConnection)
         emit connectionLost();
     lostConnection = true;
 }
Beispiel #29
0
Window::Window()
{
    QCommandLineParser parser;
    QCommandLineOption pathToAgentOption("p", "Path to sync agent", "agentPath");
    parser.addOption(pathToAgentOption);
    QCommandLineOption skipAgentStartOption("s", "Do not try to start agent on start up", "skipAgentStart");
    parser.addOption(skipAgentStartOption);
    QCommandLineOption dumbTestOption("test", "Super simple start/stop test.");
    parser.addOption(dumbTestOption);
    parser.process(*qApp);
    bool startAgent = true;
    if(parser.isSet(skipAgentStartOption) && parser.value(skipAgentStartOption) == "true"){
        startAgent = false;
    }
    cmdHelper = new CmdHelper(this, (parser.isSet(pathToAgentOption))?parser.value(pathToAgentOption):"");
    if(parser.isSet(dumbTestOption)){
        QTimer *t = new QTimer(this);
        connect(t, SIGNAL(timeout()), qApp, SLOT(quit()));
        t->setInterval(5000);
        t->setSingleShot(true);
        t->start();
        qDebug()<<"Dumb test, will exit in 5 seconds...";
    }
    else{
        if(startAgent){
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
            cmdHelper->launchAgentProcess();
#elif defined(Q_OS_MAC)
            qDebug()<<"Starting agent via launchctl command.";
            cmdHelper->launchAgentMac();
#endif

        }

        if(CHECK_FOR_UPDATE){
            updateDialog = new UpdateDialog(this);
            updatePinger = new PydioUpdatePinger(this);
            connect(updatePinger, SIGNAL(updateFound(QString,QString,QString,QString)),
                    updateDialog, SLOT(proposeDownload(QString,QString,QString,QString)));
            updatePinger->lookForUpdate();
        }

        QString dataDir = CmdHelper::getAppDataDir() +'/'+ PORT_CONFIG_FILE_NAME;
        portConfigurer = new PortConfigurer(dataDir);
        pollTimer = new QTimer(this);
        pollTimer->setInterval(POLL_INTERVAL);
        pollTimer->setSingleShot(true);

        httpManager = new HTTPManager(this);
        this->createTrayIcon();
        tray->show();

        aboutDialog = new AboutDialog(this);

        connect(pollTimer, SIGNAL(timeout()), httpManager, SLOT(poll()));
        connect(httpManager, SIGNAL(requestFinished()), pollTimer, SLOT(start()));
        connect(httpManager, SIGNAL(newJob(Job*)), tray, SLOT(onNewJob(Job*)));
        connect(httpManager, SIGNAL(jobUpdated(QString)), tray, SLOT(onJobUpdate(QString)));
        connect(httpManager, SIGNAL(jobDeleted(QString)), tray, SLOT(onJobDeleted(QString)));
        connect(httpManager, SIGNAL(connectionProblem()), tray, SLOT(connectionLost()));
        connect(httpManager, SIGNAL(agentReached()), this, SLOT(agentReached()));
        connect(httpManager, SIGNAL(noActiveJobsAtLaunch()), this, SLOT(show()));
        connect(httpManager, SIGNAL(jobsCleared()), tray, SLOT(jobsCleared()));
        connect(httpManager, SIGNAL(webUI404()), this, SLOT(notFoundFromPython()));
        connect(httpManager, SIGNAL(noInternetConnection()), tray, SLOT(noInternetConnection()));
        connect(httpManager, SIGNAL(internetConnectionOk()), tray, SLOT(internetConnectionOk()));
        connect(httpManager, SIGNAL(connectionProblem()), this, SLOT(connectionLost()));
        connect(httpManager, SIGNAL(jobNotifyMessage(QString,QString,QString)), tray, SLOT(notificationReceived(QString,QString,QString)));

        connect(tray, SIGNAL(about()), this, SLOT(about()));
        connect(tray, SIGNAL(pauseSync()), httpManager, SLOT(pauseSync()));
        connect(tray, SIGNAL(resumeSync()), httpManager, SLOT(resumeSync()));
        connect(tray, SIGNAL(quit()), this, SLOT(cleanQuit()));
        connect(tray, SIGNAL(launchAgentSignal()), cmdHelper, SLOT(launchAgentProcess()));
//        connect(cmdHelper, SIGNAL(winAgentLaunched()), this, SLOT(show()));

        settingsWebView = new QWebView();

        jsDialog = new JSEventHandler(this);

        portConfigurer->updatePorts();
        httpManager->setUrl(AGENT_SERVER_URL + portConfigurer->port(), portConfigurer->username(), portConfigurer->password());
        httpManager->poll();

        //this->setWindowFlags(Qt::Tool);
        setWindowTitle(PYDIO_DATA_DIR);
        setWindowIcon(QIcon(":/images/PydioSync-Systray-Mac.png"));
    }
}
Beispiel #30
0
void MsgStream::disconnected(void) {
	emit connectionLost(&peerId);
}