diff options
Diffstat (limited to 'Swiften/Client')
-rw-r--r-- | Swiften/Client/NickManagerImpl.cpp | 9 | ||||
-rw-r--r-- | Swiften/Client/NickManagerImpl.h | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Swiften/Client/NickManagerImpl.cpp b/Swiften/Client/NickManagerImpl.cpp index 09f8de5..fd37222 100644 --- a/Swiften/Client/NickManagerImpl.cpp +++ b/Swiften/Client/NickManagerImpl.cpp @@ -14,6 +14,8 @@ namespace Swift { NickManagerImpl::NickManagerImpl(const JID& ownJID, VCardManager* vcardManager) : ownJID(ownJID), vcardManager(vcardManager) { vcardManager->onVCardChanged.connect(boost::bind(&NickManagerImpl::handleVCardReceived, this, _1, _2)); + + updateOwnNickFromVCard(vcardManager->getVCard(ownJID.toBare())); } NickManagerImpl::~NickManagerImpl() { @@ -21,7 +23,7 @@ NickManagerImpl::~NickManagerImpl() { } String NickManagerImpl::getOwnNick() const { - return ownJID; + return ownNick; } void NickManagerImpl::setOwnNick(const String&) { @@ -31,9 +33,12 @@ void NickManagerImpl::handleVCardReceived(const JID& jid, VCard::ref vcard) { if (!jid.equals(ownJID, JID::WithoutResource)) { return; } + updateOwnNickFromVCard(vcard); +} +void NickManagerImpl::updateOwnNickFromVCard(VCard::ref vcard) { String nick; - if (!vcard->getNickname().isEmpty()) { + if (vcard && !vcard->getNickname().isEmpty()) { nick = vcard->getNickname(); } if (ownNick != nick) { diff --git a/Swiften/Client/NickManagerImpl.h b/Swiften/Client/NickManagerImpl.h index 87c9711..8796dbe 100644 --- a/Swiften/Client/NickManagerImpl.h +++ b/Swiften/Client/NickManagerImpl.h @@ -24,6 +24,7 @@ namespace Swift { private: void handleVCardReceived(const JID& jid, VCard::ref vCard); + void updateOwnNickFromVCard(VCard::ref vcard); private: JID ownJID; |