This makes things a bit cleaner and spares us another custom signal between
client and core.
p->attachSignal(this, SIGNAL(requestNetworkStates()));
p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &)), SIGNAL(createIdentity(const Identity &)));
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)));
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);
}
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) {
}
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.
//! 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.
//! 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 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);
//! Sent to the core when an identity shall be removed. Should not be used elsewhere.
void requestRemoveIdentity(IdentityId);
void Identity::init() {
setObjectName(QString::number(id().toInt()));
void Identity::init() {
setObjectName(QString::number(id().toInt()));
+ setAllowClientUpdates(true);
}
void Identity::setToDefaults() {
}
void Identity::setToDefaults() {
bool Identity::operator==(const Identity &other) {
for(int idx = metaObject()->propertyOffset(); idx < metaObject()->propertyCount(); idx++) {
QMetaProperty metaProp = metaObject()->property(idx);
bool Identity::operator==(const Identity &other) {
for(int idx = metaObject()->propertyOffset(); idx < metaObject()->propertyCount(); idx++) {
QMetaProperty metaProp = metaObject()->property(idx);
SignalProxy *p = signalProxy();
connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
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->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->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)));
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]);
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)));
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 alias manager
p->synchronize(&aliasManager());
// init BacklogManager
p->synchronize(_backlogManager);
// init IrcListHelper
p->synchronize(ircListHelper());
// init BacklogManager
p->synchronize(_backlogManager);
// init IrcListHelper
p->synchronize(ircListHelper());
// init CoreInfo
p->synchronize(&_coreInfo);
// init CoreInfo
p->synchronize(&_coreInfo);
// Restore session state
if(restoreState) restoreSessionState();
// Restore session state
if(restoreState) restoreSessionState();
+ connect(i, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &)));
_identities[i->id()] = i;
signalProxy()->synchronize(i);
}
_identities[i->id()] = i;
signalProxy()->synchronize(i);
}
void CoreSession::disconnectFromNetwork(NetworkId id) {
if(!_connections.contains(id))
return;
void CoreSession::disconnectFromNetwork(NetworkId id) {
if(!_connections.contains(id))
return;
//_connections[id]->disconnectFromIrc();
_connections[id]->userInputHandler()->handleQuit(BufferInfo(), QString());
}
//_connections[id]->disconnectFromIrc();
_connections[id]->userInputHandler()->handleQuit(BufferInfo(), QString());
}
signalProxy()->synchronize(newId);
CoreUserSettings s(user());
s.storeIdentity(*newId);
signalProxy()->synchronize(newId);
CoreUserSettings s(user());
s.storeIdentity(*newId);
+ connect(newId, SIGNAL(updated(const QVariantMap &)), this, SLOT(identityUpdated(const QVariantMap &)));
emit identityCreated(*newId);
}
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::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_) {
/*** Network Handling ***/
void CoreSession::createNetwork(const NetworkInfo &info_) {
quWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
return;
}
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::StatusBuffer) {
quWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
return;
}
if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
CoreNetwork *net = network(bufferInfo.networkId());
if(!net) {
if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
CoreNetwork *net = network(bufferInfo.networkId());
if(!net) {
AliasManager &aliasManager() { return _aliasManager; }
inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; }
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 attachNetworkConnection(NetworkConnection *conn);
//! Return necessary data for restoring the session after restarting the core
*/
void createIdentity(const Identity &identity);
*/
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.
*/
//! Remove identity and propagate that fact to the clients.
/** \param identity The identity to be removed.
*/
void destroyNetwork(NetworkId);
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)
//! 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)
- // FIXME this only checks for one changed item rather than all!
connect(cid, SIGNAL(updatedRemotely()), this, SLOT(clientEvent()));
connect(cid, SIGNAL(updatedRemotely()), this, SLOT(clientEvent()));
- Client::updateIdentity(*id);
+ Client::updateIdentity(id->id(), id->toVariantMap());
}
foreach(IdentityId id, toRemove) {
Client::removeIdentity(id);
}
foreach(IdentityId id, toRemove) {
Client::removeIdentity(id);