+void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
+ Q_ASSERT(proxy());
+ if(isInitialized()) {
+ qWarning() << "Network" << networkId() << "received init data for users and channels allthough there allready are known users or channels!";
+ return;
+ }
+
+ QVariantMap users = usersAndChannels.value("users").toMap();
+
+ QVariantMap::const_iterator userIter = users.constBegin();
+ QVariantMap::const_iterator userIterEnd = users.constEnd();
+ IrcUser *ircUser = 0;
+ QString hostmask;
+ while(userIter != userIterEnd) {
+ hostmask = userIter.key();
+ ircUser = new IrcUser(hostmask, this);
+ ircUser->fromVariantMap(userIter.value().toMap());
+ ircUser->setInitialized();
+ proxy()->synchronize(ircUser);
+
+ connect(ircUser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
+ connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
+
+ _ircUsers[nickFromMask(hostmask).toLower()] = ircUser;
+
+ emit ircUserAdded(hostmask);
+ emit ircUserAdded(ircUser);
+ emit ircUserInitDone(ircUser);
+
+ userIter++;
+ }
+
+
+ QVariantMap channels = usersAndChannels.value("channels").toMap();
+ QVariantMap::const_iterator channelIter = channels.constBegin();
+ QVariantMap::const_iterator channelIterEnd = channels.constEnd();
+ IrcChannel *ircChannel = 0;
+ QString channelName;
+
+ while(channelIter != channelIterEnd) {
+ channelName = channelIter.key();
+ ircChannel = new IrcChannel(channelName, this);
+ ircChannel->fromVariantMap(channelIter.value().toMap());
+ ircChannel->setInitialized();
+ proxy()->synchronize(ircChannel);
+
+ connect(ircChannel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
+ _ircChannels[channelName.toLower()] = ircChannel;
+
+ emit ircChannelAdded(channelName);
+ emit ircChannelAdded(ircChannel);
+ emit ircChannelInitDone(ircChannel);
+
+ channelIter++;
+ }
+