KMessageJabber::KMessageJabber (const QString& peerJid, JabberClient* jabberClient, QObject *parent) : KMessageIO (parent), mClient(jabberClient), mPeerJid(peerJid) { kDebug() << peerJid; // initSocket (); connect(jabberClient, SIGNAL(messageReceived(XMPP::Message)), this, SLOT(slotMessageReceived(XMPP::Message))); connect(jabberClient, SIGNAL(resourceUnavailable(Jid,Resource)), this, SLOT(slotResourceUnavailable(Jid,Resource))); connect(jabberClient, SIGNAL(groupChatLeft(XMPP::Jid)), this, SLOT(slotGroupChatLeft(XMPP::Message))); connect(jabberClient, SIGNAL(groupChatPresence(XMPP::Jid,XMPP::Status)), this, SLOT(slotGroupChatPresence(XMPP::Jid,XMPP::Status))); }
void Client::ppPresence(const Jid &j, const Status &s) { if(s.isAvailable()) debug(QString("Client: %1 is available.\n").arg(j.full())); else debug(QString("Client: %1 is unavailable.\n").arg(j.full())); for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end(); it++) { GroupChat &i = *it; if(i.j.compare(j, false)) { bool us = (i.j.resource() == j.resource() || j.resource().isEmpty()) ? true: false; debug(QString("for groupchat i=[%1] pres=[%2], [us=%3].\n").arg(i.j.full()).arg(j.full()).arg(us)); switch(i.status) { case GroupChat::Connecting: if(us && s.hasError()) { Jid j = i.j; d->groupChatList.remove(it); groupChatError(j, s.errorCode(), s.errorString()); } else { // don't signal success unless it is a non-error presence if(!s.hasError()) { i.status = GroupChat::Connected; groupChatJoined(i.j); } groupChatPresence(j, s); } break; case GroupChat::Connected: groupChatPresence(j, s); break; case GroupChat::Closing: if(us && !s.isAvailable()) { Jid j = i.j; d->groupChatList.remove(it); groupChatLeft(j); } break; default: break; } return; } } if(s.hasError()) { presenceError(j, s.errorCode(), s.errorString()); return; } // is it me? if(j.compare(jid(), false)) { updateSelfPresence(j, s); } else { // update all relavent roster entries for(LiveRoster::Iterator it = d->roster.begin(); it != d->roster.end(); ++it) { LiveRosterItem &i = *it; if(!i.jid().compare(j, false)) continue; // roster item has its own resource? if(!i.jid().resource().isEmpty()) { if(i.jid().resource() != j.resource()) continue; } updatePresence(&i, j, s); } } }