Default identity is now created by the client, if no identity exists.
[quassel.git] / src / core / coresession.cpp
index 841ae7c..1e7d2a1 100644 (file)
@@ -51,7 +51,6 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _coreInfo(this),
     scriptEngine(new QScriptEngine(this))
 {
-
   SignalProxy *p = signalProxy();
   connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
 
@@ -75,29 +74,18 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   loadSettings();
   initScriptEngine();
 
-  // init BufferSyncer
-  QHash<BufferId, MsgId> lastSeenHash = Core::bufferLastSeenMsgIds(user());
-  foreach(BufferId id, lastSeenHash.keys())
-    _bufferSyncer->requestSetLastSeenMsg(id, lastSeenHash[id]);
+  connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), _bufferSyncer, SLOT(storeDirtyIds()));
+  connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), _bufferViewManager, SLOT(saveBufferViews()));
 
-  connect(_bufferSyncer, SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(storeBufferLastSeenMsg(BufferId, MsgId)));
   p->synchronize(_bufferSyncer);
-
-
-  // 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();
+  if(restoreState)
+    restoreSessionState();
 
   emit initialized();
 }
@@ -145,12 +133,6 @@ void CoreSession::loadSettings() {
   foreach(CoreIdentity identity, Core::identities(user())) {
     createIdentity(identity);
   }
-  if(!_identities.count()) {
-    Identity identity;
-    identity.setToDefaults();
-    identity.setIdentityName(tr("Default Identity"));
-    createIdentity(identity, QVariantMap());
-  }
 
   foreach(NetworkInfo info, Core::networks(user())) {
     createNetwork(info);
@@ -158,6 +140,8 @@ void CoreSession::loadSettings() {
 }
 
 void CoreSession::saveSessionState() const {
+  _bufferSyncer->storeDirtyIds();
+  _bufferViewManager->saveBufferViews();
 }
 
 void CoreSession::restoreSessionState() {
@@ -263,10 +247,6 @@ QVariant CoreSession::sessionState() {
   return v;
 }
 
-void CoreSession::storeBufferLastSeenMsg(BufferId buffer, const MsgId &msgId) {
-  Core::setBufferLastSeenMsg(user(), buffer, msgId);
-}
-
 void CoreSession::initScriptEngine() {
   signalProxy()->attachSlot(SIGNAL(scriptRequest(QString)), this, SLOT(scriptRequest(QString)));
   signalProxy()->attachSignal(this, SIGNAL(scriptResult(QString)));
@@ -384,8 +364,10 @@ void CoreSession::destroyNetwork(NetworkId id) {
 }
 
 void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) {
-  BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName);
-  _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
+  BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName, false);
+  if(bufferInfo.isValid()) {
+    _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
+  }
 }
 
 void CoreSession::clientsConnected() {