diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-04-29 07:56:25 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-04-29 07:56:25 +0000 |
| commit | 7838b687360808e0a0407f4f15b42fd777f1e5e1 (patch) | |
| tree | 50c10193b3588c54727863383e2e259728aeea88 /src/QXmppMucManager.cpp | |
| parent | 32a5e7921021f89f694a7906afd21967ca6fb8b5 (diff) | |
| download | qxmpp-7838b687360808e0a0407f4f15b42fd777f1e5e1.tar.gz | |
handle nickname changes
Diffstat (limited to 'src/QXmppMucManager.cpp')
| -rw-r--r-- | src/QXmppMucManager.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/QXmppMucManager.cpp b/src/QXmppMucManager.cpp index d8e68fb3..d17e012f 100644 --- a/src/QXmppMucManager.cpp +++ b/src/QXmppMucManager.cpp @@ -48,7 +48,6 @@ public: QString password; QMap<QString, QXmppMucAdminIq::Item::Affiliation> affiliations; QString nickName; - QXmppPresence::Status status; QString subject; }; @@ -216,10 +215,10 @@ bool QXmppMucRoom::join() if (isJoined() || d->nickName.isEmpty()) return false; - QXmppPresence packet; + // reflect our current presence in the chat room + QXmppPresence packet = d->client->clientPresence(); packet.setTo(d->ownJid()); packet.setType(QXmppPresence::Available); - packet.setStatus(d->status); QXmppElement x; x.setTagName("x"); x.setAttribute("xmlns", ns_muc); @@ -310,10 +309,23 @@ bool QXmppMucRoom::sendMessage(const QString &text) } /// Sets your own nickname. +/// +/// You need to set your nickname before calling join(). +/// +/// \param nickName void QXmppMucRoom::setNickName(const QString &nickName) { + const bool wasJoined = isJoined(); d->nickName = nickName; + + // if we had already joined the room, request nickname change + if (wasJoined) { + QXmppPresence packet = d->client->clientPresence(); + packet.setTo(d->ownJid()); + packet.setType(QXmppPresence::Available); + d->client->sendPacket(packet); + } } /// Returns the presence for the given participant. @@ -354,24 +366,6 @@ void QXmppMucRoom::setPassword(const QString &password) d->password = password; } -QXmppPresence::Status QXmppMucRoom::status() const -{ - return d->status; -} - -void QXmppMucRoom::setStatus(const QXmppPresence::Status &status) -{ - d->status = status; - - if (isJoined()) { - QXmppPresence packet; - packet.setTo(d->ownJid()); - packet.setType(QXmppPresence::Available); - packet.setStatus(status); - d->client->sendPacket(packet); - } -} - /// Returns the room's subject. QString QXmppMucRoom::subject() const @@ -520,8 +514,11 @@ void QXmppMucRoom::_q_presenceReceived(const QXmppPresence &presence) const QString jid = presence.from(); // if our own presence changes, reflect it in the chat room - if (jid == d->client->configuration().jid()) - setStatus(presence.status()); + if (isJoined() && jid == d->client->configuration().jid()) { + QXmppPresence packet = d->client->clientPresence(); + packet.setTo(d->ownJid()); + d->client->sendPacket(packet); + } if (jidToBareJid(jid) != d->jid) return; |
