p->attachSignal(this, SIGNAL(requestNetworkStates()));
p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &)), SIGNAL(createIdentity(const Identity &)));
- p->attachSignal(this, SIGNAL(requestUpdateIdentity(const Identity &)), SIGNAL(updateIdentity(const Identity &)));
p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId)));
p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &)));
p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId)));
emit instance()->requestCreateIdentity(id);
}
-void Client::updateIdentity(const Identity &id) {
- emit instance()->requestUpdateIdentity(id);
+void Client::updateIdentity(IdentityId id, const QVariantMap &ser) {
+ //emit instance()->requestUpdateIdentity(id);
+ Identity *idptr = instance()->_identities.value(id, 0);
+ if(!idptr) {
+ qWarning() << "Update for unknown identity requested:" << id;
+ return;
+ }
+ idptr->requestUpdate(ser);
}
void Client::removeIdentity(IdentityId id) {
//! Request update of an identity with the given data.
/** The request will be sent to the core, and will be propagated back to all the clients.
- * \param identity The identity to be updated.
+ * \param id The identity to be updated.
+ * \param serializedData The identity's content (cf. SyncableObject::toVariantMap())
*/
- static void updateIdentity(const Identity &identity);
+ static void updateIdentity(IdentityId id, const QVariantMap &serializedData);
//! Request removal of the identity with the given ID from the core (and all the clients, of course).
/** \param id The ID of the identity to be removed.
//! Sent to the core when an identity shall be created. Should not be used elsewhere.
void requestCreateIdentity(const Identity &);
- //! Sent to the core when an identity shall be updated. Should not be used elsewhere.
- void requestUpdateIdentity(const Identity &);
//! Sent to the core when an identity shall be removed. Should not be used elsewhere.
void requestRemoveIdentity(IdentityId);
SignalProxy *p = signalProxy();
connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
-
+
//p->attachSlot(SIGNAL(disconnectFromNetwork(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); // FIXME
p->attachSlot(SIGNAL(sendInput(BufferInfo, QString)), this, SLOT(msgFromClient(BufferInfo, QString)));
p->attachSignal(this, SIGNAL(displayMsg(Message)));
p->attachSignal(this, SIGNAL(identityCreated(const Identity &)));
p->attachSignal(this, SIGNAL(identityRemoved(IdentityId)));
p->attachSlot(SIGNAL(createIdentity(const Identity &)), this, SLOT(createIdentity(const Identity &)));
- p->attachSlot(SIGNAL(updateIdentity(const Identity &)), this, SLOT(updateIdentity(const Identity &)));
p->attachSlot(SIGNAL(removeIdentity(IdentityId)), this, SLOT(removeIdentity(IdentityId)));
p->attachSignal(this, SIGNAL(networkCreated(NetworkId)));
QHash<BufferId, MsgId> lastSeenHash = Core::bufferLastSeenMsgIds(user());
foreach(BufferId id, lastSeenHash.keys())
_bufferSyncer->requestSetLastSeenMsg(id, lastSeenHash[id]);
-
+
connect(_bufferSyncer, SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(storeBufferLastSeenMsg(BufferId, MsgId)));
connect(_bufferSyncer, SIGNAL(removeBufferRequested(BufferId)), this, SLOT(removeBufferRequested(BufferId)));
connect(this, SIGNAL(bufferRemoved(BufferId)), _bufferSyncer, SLOT(removeBuffer(BufferId)));
// init alias manager
p->synchronize(&aliasManager());
-
+
// init BacklogManager
p->synchronize(_backlogManager);
// init IrcListHelper
p->synchronize(ircListHelper());
-
+
// init CoreInfo
p->synchronize(&_coreInfo);
-
+
// Restore session state
if(restoreState) restoreSessionState();
delete i;
continue;
}
+ connect(i, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &)));
_identities[i->id()] = i;
signalProxy()->synchronize(i);
}
void CoreSession::disconnectFromNetwork(NetworkId id) {
if(!_connections.contains(id))
return;
-
+
//_connections[id]->disconnectFromIrc();
_connections[id]->userInputHandler()->handleQuit(BufferInfo(), QString());
}
signalProxy()->synchronize(newId);
CoreUserSettings s(user());
s.storeIdentity(*newId);
+ connect(newId, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &)));
emit identityCreated(*newId);
}
-void CoreSession::updateIdentity(const Identity &id) {
- if(!_identities.contains(id.id())) {
- quWarning() << "Update request for unknown identity received!";
- return;
- }
- _identities[id.id()]->update(id);
-
- CoreUserSettings s(user());
- s.storeIdentity(id);
-}
-
void CoreSession::removeIdentity(IdentityId id) {
Identity *i = _identities.take(id);
if(i) {
}
}
+void CoreSession::identityUpdated(const QVariantMap &data) {
+ IdentityId id = data.value("identityId", 0).value<IdentityId>();
+ if(!id.isValid() || !_identities.contains(id)) {
+ quWarning() << "Update request for unknown identity received!";
+ return;
+ }
+ CoreUserSettings s(user());
+ s.storeIdentity(*_identities.value(id));
+}
+
/*** Network Handling ***/
void CoreSession::createNetwork(const NetworkInfo &info_) {
quWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
return;
}
-
+
if(bufferInfo.type() == BufferInfo::StatusBuffer) {
quWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
return;
}
-
+
if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
CoreNetwork *net = network(bufferInfo.networkId());
if(!net) {
AliasManager &aliasManager() { return _aliasManager; }
inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; }
-
+
void attachNetworkConnection(NetworkConnection *conn);
//! Return necessary data for restoring the session after restarting the core
*/
void createIdentity(const Identity &identity);
- //! Update an identity and propagate the changes to the clients.
- /** \param identity The identity to be updated.
- */
- void updateIdentity(const Identity &identity);
-
//! Remove identity and propagate that fact to the clients.
/** \param identity The identity to be removed.
*/
void destroyNetwork(NetworkId);
+ void identityUpdated(const QVariantMap &);
+ //void networkUpdated(const QVariantMap &);
+
//! Called when storage updated a BufferInfo.
/** This emits bufferInfoUpdated() via SignalProxy, iff it's one of our buffers.
* \param user The buffer's owner (not necessarily us)