-UserId CoreSession::userId() const {
- return user;
-}
-
-void CoreSession::storeSessionData(const QString &key, const QVariant &data) {
- QSettings s;
- s.beginGroup(QString("SessionData/%1").arg(user));
- mutex.lock();
- sessionData[key] = data;
- s.setValue(key, data);
- mutex.unlock();
- s.endGroup();
- emit sessionDataChanged(key, data);
- emit sessionDataChanged(key);
-}
-
-QVariant CoreSession::retrieveSessionData(const QString &key, const QVariant &def) {
- QVariant data;
- mutex.lock();
- if(!sessionData.contains(key)) data = def;
- else data = sessionData[key];
- mutex.unlock();
- return data;
-}
-
-void CoreSession::connectToNetwork(QString network) {
- QStringList networks; networks << network; // FIXME obsolete crap
- foreach(QString net, networks) {
- if(servers.contains(net)) {
-
- } else {
- Server *server = new Server(userId(), net);
- connect(this, SIGNAL(serverStateRequested()), server, SLOT(sendState()));
- connect(this, SIGNAL(connectToIrc(QString)), server, SLOT(connectToIrc(QString)));
- connect(this, SIGNAL(disconnectFromIrc(QString)), server, SLOT(disconnectFromIrc(QString)));
- connect(this, SIGNAL(msgFromGui(QString, QString, QString)), server, SLOT(userInput(QString, QString, QString)));
-
- connect(server, SIGNAL(connected(QString)), this, SLOT(serverConnected(QString)));
- connect(server, SIGNAL(disconnected(QString)), this, SLOT(serverDisconnected(QString)));
- connect(server, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)), this, SLOT(recvMessageFromServer(Message::Type, QString, QString, QString, quint8)));
- connect(server, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString)));
-
- SignalProxy *p = signalProxy();
- p->attachSignal(server, SIGNAL(serverState(QString, QVariantMap)), SIGNAL(networkState(QString, QVariantMap)));
- p->attachSignal(server, SIGNAL(modeSet(QString, QString, QString)));
- p->attachSignal(server, SIGNAL(nickAdded(QString, QString, QVariantMap)));
- p->attachSignal(server, SIGNAL(nickRenamed(QString, QString, QString)));
- p->attachSignal(server, SIGNAL(nickRemoved(QString, QString)));
- p->attachSignal(server, SIGNAL(nickUpdated(QString, QString, QVariantMap)));
- p->attachSignal(server, SIGNAL(ownNickSet(QString, QString)));
- p->attachSignal(server, SIGNAL(queryRequested(QString, QString)));
- // TODO add error handling
- p->attachSignal(server, SIGNAL(connected(QString)), SIGNAL(networkConnected(QString)));
- p->attachSignal(server, SIGNAL(disconnected(QString)), SIGNAL(networkDisconnected(QString)));
-
- server->start();
- servers[net] = server;
+void CoreSession::loadSettings() {
+ CoreUserSettings s(user());
+
+ // migrate to db
+ QList<IdentityId> ids = s.identityIds();
+ QList<NetworkInfo> networkInfos = Core::networks(user());
+ foreach(IdentityId id, ids) {
+ CoreIdentity identity(s.identity(id));
+ IdentityId newId = Core::createIdentity(user(), identity);
+ QList<NetworkInfo>::iterator networkIter = networkInfos.begin();
+ while(networkIter != networkInfos.end()) {
+ if(networkIter->identity == id) {
+ networkIter->identity = newId;
+ Core::updateNetwork(user(), *networkIter);
+ networkIter = networkInfos.erase(networkIter);
+ } else {
+ networkIter++;
+ }