Set nickname according to received vcard
This commit is contained in:
parent
b55ba07e93
commit
ca76287f4d
4 changed files with 6 additions and 3 deletions
|
@ -708,9 +708,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
void handleVCardUpdatedRequest(const std::string &user, const std::string &image) {
|
||||
void handleVCardUpdatedRequest(const std::string &user, const std::string &image, const std::string &nickname) {
|
||||
PurpleAccount *account = m_sessions[user];
|
||||
if (account) {
|
||||
purple_account_set_alias(account, nickname.c_str());
|
||||
purple_account_set_public_alias(account, nickname.c_str(), NULL, NULL);
|
||||
gssize size = image.size();
|
||||
// this will be freed by libpurple
|
||||
guchar *photo = (guchar *) g_malloc(size * sizeof(guchar));
|
||||
|
|
|
@ -201,7 +201,7 @@ class NetworkPlugin {
|
|||
/// You should update the VCard in legacy network too.
|
||||
/// \param user XMPP JID of user for which this event occurs.
|
||||
/// \param photo Raw photo data.
|
||||
virtual void handleVCardUpdatedRequest(const std::string &/*user*/, const std::string &/*photo*/) {}
|
||||
virtual void handleVCardUpdatedRequest(const std::string &/*user*/, const std::string &/*photo*/, const std::string &nickname) {}
|
||||
|
||||
|
||||
virtual void handleJoinRoomRequest(const std::string &/*user*/, const std::string &/*room*/, const std::string &/*nickname*/, const std::string &/*pasword*/) {}
|
||||
|
|
|
@ -449,7 +449,7 @@ void NetworkPlugin::handleVCardPayload(const std::string &data) {
|
|||
}
|
||||
|
||||
if (payload.has_photo()) {
|
||||
handleVCardUpdatedRequest(payload.username(), payload.photo());
|
||||
handleVCardUpdatedRequest(payload.username(), payload.photo(), payload.nickname());
|
||||
}
|
||||
else if (!payload.buddyname().empty()) {
|
||||
handleVCardRequest(payload.username(), payload.buddyname(), payload.id());
|
||||
|
|
|
@ -1218,6 +1218,7 @@ void NetworkPluginServer::handleVCardUpdated(User *user, boost::shared_ptr<Swift
|
|||
vcard.set_buddyname("");
|
||||
vcard.set_id(0);
|
||||
vcard.set_photo(&v->getPhoto()[0], v->getPhoto().size());
|
||||
vcard.set_nickname(v->getNickname());
|
||||
|
||||
std::string message;
|
||||
vcard.SerializeToString(&message);
|
||||
|
|
Loading…
Add table
Reference in a new issue