p->attachSignal(this, SIGNAL(networkCreated(NetworkId)));
p->attachSignal(this, SIGNAL(networkRemoved(NetworkId)));
p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &)), this, SLOT(createNetwork(const NetworkInfo &)));
- p->attachSlot(SIGNAL(updateNetwork(const NetworkInfo &)), this, SLOT(updateNetwork(const NetworkInfo &)));
p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, SLOT(removeNetwork(NetworkId)));
loadSettings();
void CoreSession::networkStateRequested() {
}
-void CoreSession::addClient(QObject *dev) { // this is QObject* so we can use it in signal connections
- QIODevice *device = qobject_cast<QIODevice *>(dev);
+void CoreSession::addClient(QIODevice *device) {
if(!device) {
quError() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!";
} else {
+ // if the socket is an orphan, the signalProxy adopts it.
+ // -> we don't need to care about it anymore
+ device->setParent(0);
signalProxy()->addPeer(device);
QVariantMap reply;
reply["MsgType"] = "SessionInit";
}
}
+void CoreSession::addClient(SignalProxy *proxy) {
+ signalProxy()->addPeer(proxy);
+ emit sessionState(sessionState());
+}
+
void CoreSession::removeClient(QIODevice *iodev) {
- // no checks for validity check - privateslot...
QTcpSocket *socket = qobject_cast<QTcpSocket *>(iodev);
if(socket)
quInfo() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt()));
- else
- quInfo() << "Local client disconnedted.";
- disconnect(socket, 0, this, 0);
- socket->deleteLater();
}
SignalProxy *CoreSession::signalProxy() const {
emit networkCreated(id);
} else {
quWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
- updateNetwork(info);
- }
-}
-
-// FIXME: move to CoreNetwork
-void CoreSession::updateNetwork(const NetworkInfo &info) {
- if(!_networks.contains(info.networkId)) {
- quWarning() << "Update request for unknown network received!";
- return;
+ _networks[info.networkId]->requestSetNetworkInfo(info);
}
- _networks[info.networkId]->setNetworkInfo(info);
- Core::updateNetwork(user(), info);
}
void CoreSession::removeNetwork(NetworkId id) {