示例#1
0
void ServerThread::run() {
	server::BuiltinServer server;
#ifdef NDEBUG
	logger::setLogLevel(logger::LOG_WARNING);
#else
	logger::setLogLevel(logger::LOG_DEBUG);
#endif

	connect(&server, SIGNAL(serverStopped()), this, SLOT(quit()));

	logger::info() << "Starting server";
	if(!server.start(_port)) {
		_port = 0;
		_error = server.errorString();
		_starter.wakeOne();
		return;
	}

	_port = server.port();
	_starter.wakeOne();

	exec();

	logger::info() << "server thread exiting.";
	if(_deleteonexit)
		deleteLater();
}
示例#2
0
void ServerThread::run() {
	server::BuiltinServer server;
#ifdef NDEBUG
	logger::setLogLevel(logger::LOG_WARNING);
#else
	logger::setLogLevel(logger::LOG_DEBUG);
#endif

	connect(&server, SIGNAL(serverStopped()), this, SLOT(quit()));

	logger::info() << "Starting server";
	if(!server.start(_port)) {
		_port = 0;
		_error = server.errorString();
		_starter.wakeOne();
		return;
	}

	_port = server.port();
	_starter.wakeOne();

	exec();

#ifdef HAVE_UPNP
	if(_portForwarded) {
		qDebug() << "Removing port" << _port << "forwarding";
		UPnPClient::instance()->deactivateForward(_port);
	}
#endif

	logger::info() << "server thread exiting.";
	if(_deleteonexit)
		deleteLater();
}
示例#3
0
void TcpServer::run() {

  m_listening = true;

  while (m_listening && m_open) {

    //printf("TcpServer: spinning\n");
    check_for_clients(); // new connections
    check_for_messages(); // messages from clients
  }

  serverStopped();
  m_listening = false;
}
示例#4
0
/**
 * Disconnect all clients and stop listening.
 */
void MultiServer::stop() {
	if(_state == RUNNING) {
		logger::info() << "Stopping server and kicking out" << _sessions->totalUsers() << "users...";
		_state = STOPPING;
		_server->close();

		_sessions->stopAll();
	}

	if(_state == STOPPING) {
		if(_sessions->totalUsers() == 0) {
			_state = STOPPED;
			logger::info() << "Server stopped.";
			emit serverStopped();
		}
	}
}
示例#5
0
/**
 * Disconnect all clients and stop listening.
 */
void BuiltinServer::stop() {
	if(_state == RUNNING) {
		logger::debug() << "Stopping built-in server...";
		_state = STOPPING;

		_server->close();
		_sessions->stopAll();
	}

	if(_state == STOPPING) {
		if(_sessions->totalUsers() == 0) {
			_state = STOPPED;
			logger::debug() << "Built-in server stopped.";
			emit serverStopped();
		}
	}
}
示例#6
0
/**
 * Disconnect all clients and stop listening.
 */
void BuiltinServer::stop() {
	if(m_state == RUNNING) {
		qDebug("Stopping built-in server...");
		m_state = STOPPING;

		m_server->close();
		m_sessions->stopAll();
	}

	if(m_state == STOPPING) {
		if(m_sessions->totalUsers() == 0) {
			m_state = STOPPED;
			qDebug("Built-in server stopped.");
			emit serverStopped();
		}
	}
}
KCupsConnection::KCupsConnection(QObject *parent) :
    QThread(parent),
    m_inited(false),
    // Creating the dialog before start() will make it run on the gui thread
    m_passwordDialog(new KCupsPasswordDialog),
    m_subscriptionId(-1)
{
    // setup the DBus subscriptions

    // Server related signals
    // ServerStarted
    notifierConnect(QLatin1String("ServerStarted"),
                    this,
                    SIGNAL(serverStarted(QString)));

    // ServerStopped
    notifierConnect(QLatin1String("ServerStopped"),
                    this,
                    SIGNAL(serverStopped(QString)));

    // ServerRestarted
    notifierConnect(QLatin1String("ServerRestarted"),
                    this,
                    SIGNAL(serverRestarted(QString)));

    // ServerAudit
    notifierConnect(QLatin1String("ServerAudit"),
                    this,
                    SIGNAL(serverAudit(QString)));

    // Printer related signals
    // PrinterAdded
    notifierConnect(QLatin1String("PrinterAdded"),
                    this,
                    SIGNAL(printerAdded(QString,QString,QString,uint,QString,bool)));

    // PrinterModified
    notifierConnect(QLatin1String("PrinterModified"),
                    this,
                    SIGNAL(printerModified(QString,QString,QString,uint,QString,bool)));

    // PrinterDeleted
    notifierConnect(QLatin1String("PrinterDeleted"),
                    this,
                    SIGNAL(printerDeleted(QString,QString,QString,uint,QString,bool)));

    // PrinterStateChanged
    notifierConnect(QLatin1String("PrinterStateChanged"),
                    this,
                    SIGNAL(printerStateChanged(QString,QString,QString,uint,QString,bool)));

    // PrinterStopped
    notifierConnect(QLatin1String("PrinterStopped"),
                    this,
                    SIGNAL(printerStopped(QString,QString,QString,uint,QString,bool)));

    // PrinterShutdown
    notifierConnect(QLatin1String("PrinterShutdown"),
                    this,
                    SIGNAL(printerShutdown(QString,QString,QString,uint,QString,bool)));

    // PrinterRestarted
    notifierConnect(QLatin1String("PrinterRestarted"),
                    this,
                    SIGNAL(printerRestarted(QString,QString,QString,uint,QString,bool)));

    // PrinterMediaChanged
    notifierConnect(QLatin1String("PrinterMediaChanged"),
                    this,
                    SIGNAL(printerMediaChanged(QString,QString,QString,uint,QString,bool)));

    // PrinterFinishingsChanged
    notifierConnect(QLatin1String("PrinterFinishingsChanged"),
                    this,
                    SIGNAL(PrinterFinishingsChanged(QString,QString,QString,uint,QString,bool)));

    // Job related signals
    // JobState
    notifierConnect(QLatin1String("JobState"),
                    this,
                    SIGNAL(jobState(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // JobCreated
    notifierConnect(QLatin1String("JobCreated"),
                    this,
                    SIGNAL(jobCreated(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // JobStopped
    notifierConnect(QLatin1String("JobStopped"),
                    this,
                    SIGNAL(jobStopped(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // JobConfigChanged
    notifierConnect(QLatin1String("JobConfigChanged"),
                    this,
                    SIGNAL(jobConfigChanged(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // JobProgress
    notifierConnect(QLatin1String("JobProgress"),
                    this,
                    SIGNAL(jobProgress(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // JobCompleted
    notifierConnect(QLatin1String("JobCompleted"),
                    this,
                    SIGNAL(jobCompleted(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This signal is needed since the cups registration thing
    // doesn't emit printerAdded when we add a printer class
    // This is emitted when a printer/queue is changed
    QDBusConnection::systemBus().connect(QLatin1String(""),
                                         QLatin1String("/com/redhat/PrinterSpooler"),
                                         QLatin1String("com.redhat.PrinterSpooler"),
                                         QLatin1String("PrinterAdded"),
                                         this,
                                         SIGNAL(rhPrinterAdded(QString)));

    // This signal is needed since the cups registration thing
    // sometimes simple stops working... don't ask me why
    // This is emitted when a printer/queue is changed
    QDBusConnection::systemBus().connect(QLatin1String(""),
                                         QLatin1String("/com/redhat/PrinterSpooler"),
                                         QLatin1String("com.redhat.PrinterSpooler"),
                                         QLatin1String("QueueChanged"),
                                         this,
                                         SIGNAL(rhQueueChanged(QString)));

    // This signal is needed since the cups registration thing
    // doesn't emit printerRemoved when we add a printer class
    // This is emitted when a printer/queue is changed
    QDBusConnection::systemBus().connect(QLatin1String(""),
                                         QLatin1String("/com/redhat/PrinterSpooler"),
                                         QLatin1String("com.redhat.PrinterSpooler"),
                                         QLatin1String("PrinterRemoved"),
                                         this,
                                         SIGNAL(rhPrinterRemoved(QString)));

    QDBusConnection::systemBus().connect(QLatin1String(""),
                                         QLatin1String("/com/redhat/PrinterSpooler"),
                                         QLatin1String("com.redhat.PrinterSpooler"),
                                         QLatin1String("JobQueuedLocal"),
                                         this,
                                         SIGNAL(rhJobQueuedLocal(QString,uint,QString)));

    QDBusConnection::systemBus().connect(QLatin1String(""),
                                         QLatin1String("/com/redhat/PrinterSpooler"),
                                         QLatin1String("com.redhat.PrinterSpooler"),
                                         QLatin1String("JobStartedLocal"),
                                         this,
                                         SIGNAL(rhJobStartedLocal(QString,uint,QString)));

    // Starts this thread
    start();
}