From ebbf4ad769d99f07c6d5184d9fe4323e7eaf0246 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Jan 2015 23:20:50 +0000 Subject: avatars are back git-svn-id: http://svn.miranda-ng.org/main/trunk@11943 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 26 ++++------------- protocols/WhatsApp/src/WhatsAPI++/WAConnection.h | 34 ++++------------------ 2 files changed, 10 insertions(+), 50 deletions(-) (limited to 'protocols/WhatsApp/src/WhatsAPI++') diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index 29aaec738b..27dd4aff3a 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -650,31 +650,15 @@ void WAConnection::sendGetOwningGroups() throw (WAException) this->mutex->unlock(); } -void WAConnection::sendGetPicture(const std::string& jid, const std::string& type, const std::string& oldId, const std::string& newId) throw (WAException) +void WAConnection::sendGetPicture(const std::string& jid, const std::string& type) throw (WAException) { - std::string id = makeId("get_picture_"); - this->pending_server_requests[id] = new IqResultGetPhotoHandler(this, jid, oldId, newId); + std::string id = makeId("iq_"); + this->pending_server_requests[id] = new IqResultGetPhotoHandler(this, jid); - ProtocolTreeNode *listNode = new ProtocolTreeNode("picture") - << XATTR("xmlns", "w:profile:picture") << XATTR("type", type); + ProtocolTreeNode *listNode = new ProtocolTreeNode("picture") << XATTR("type", type); this->out->write(ProtocolTreeNode("iq", listNode) - << XATTR("id", id) << XATTR("to", jid) << XATTR("type", "get")); -} - -void WAConnection::sendGetPictureIds(const std::vector& jids) throw (WAException) -{ - std::string id = makeId("get_picture_ids_"); - this->pending_server_requests[id] = new IqResultGetPictureIdsHandler(this); - - std::vector* children = new std::vector(); - for (size_t i = 0; i < jids.size(); i++) { - ProtocolTreeNode *child = new ProtocolTreeNode("user") << XATTR("jid", jids[i]); - children->push_back(child); - } - - ProtocolTreeNode *queryNode = new ProtocolTreeNode("list", NULL, children) << XATTR("xmlns", "w:profile:picture"); - this->out->write(ProtocolTreeNode("iq", queryNode) << XATTR("id", id) << XATTR("type", "get")); + << XATTR("id", id) << XATTR("to", jid) << XATTR("xmlns", "w:profile:picture") << XATTR("type", "get")); } void WAConnection::sendGetPrivacyList() throw (WAException) diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h index 560f957634..5a5dfc5b83 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h @@ -45,8 +45,7 @@ public: virtual void onDirty(const std::map& paramHashtable)=0; virtual void onDirtyResponse(int paramHashtable)=0; virtual void onRelayRequest(const std::string& paramString1, int paramInt, const std::string& paramString2)=0; - virtual void onSendGetPictureIds(std::map* ids)=0; - virtual void onSendGetPicture(const std::string& jid, const std::vector& data, const std::string& oldId, const std::string& newId)=0; + virtual void onSendGetPicture(const std::string& jid, const std::vector& data, const std::string& id)=0; virtual void onPictureChanged(const std::string& from, const std::string& author, bool set)=0; virtual void onDeleteAccount(bool result)=0; }; @@ -254,10 +253,8 @@ class WAConnection { std::string oldId; std::string newId; public: - IqResultGetPhotoHandler(WAConnection* con, const std::string& jid, const std::string& oldId, const std::string& newId):IqResultHandler(con) { + IqResultGetPhotoHandler(WAConnection* con, const std::string& jid):IqResultHandler(con) { this->jid = jid; - this->oldId = oldId; - this->newId = newId; } virtual void parse(ProtocolTreeNode* node, const std::string& from) throw (WAException) { const string &attributeValue = node->getAttributeValue("type"); @@ -269,7 +266,7 @@ class WAConnection { const string &id = current->getAttributeValue("id"); if (!id.empty() && current->data != NULL && current->data->size() > 0) { if (current->data != NULL) - this->con->event_handler->onSendGetPicture(this->jid, *current->data, this->oldId, this->newId); + this->con->event_handler->onSendGetPicture(this->jid, *current->data, id); break; } } @@ -278,7 +275,7 @@ class WAConnection { void error(ProtocolTreeNode* node) throw (WAException) { if (this->con->event_handler != NULL) { std::vector v; - this->con->event_handler->onSendGetPicture("error", v, "", ""); + this->con->event_handler->onSendGetPicture("error", v, ""); } } }; @@ -299,26 +296,6 @@ class WAConnection { } }; - class IqResultGetPictureIdsHandler: public IqResultHandler { - public: - IqResultGetPictureIdsHandler(WAConnection* con):IqResultHandler(con) {} - virtual void parse(ProtocolTreeNode* node, const std::string& from) throw (WAException) { - // logData("onGetPhotoIds %s", node->toString().c_str()); - ProtocolTreeNode* groupNode = node->getChild("list"); - std::vector children(groupNode->getAllChildren("user")); - std::map ids; - for (size_t i = 0; i < children.size(); i++) { - const string &jid = children[i]->getAttributeValue("jid"); - const string &id = children[i]->getAttributeValue("id"); - if (!jid.empty()) - ids[jid] = id; - } - - if (this->con->event_handler != NULL) - this->con->event_handler->onSendGetPictureIds(&ids); - } - }; - class IqResultSendDeleteAccount: public IqResultHandler { public: IqResultSendDeleteAccount(WAConnection* con):IqResultHandler(con) {} @@ -446,8 +423,7 @@ public: void sendRemoveParticipants(const std::string& gjid, const std::vector& participants) throw (WAException); void sendSetNewSubject(const std::string& gjid, const std::string& subject) throw (WAException); void sendStatusUpdate(std::string& status) throw (WAException); - void sendGetPicture(const std::string& jid, const std::string& type, const std::string& oldId, const std::string& newId) throw (WAException); - void sendGetPictureIds(const std::vector& jids) throw (WAException); + void sendGetPicture(const std::string& jid, const std::string& type) throw (WAException); void sendSetPicture(const std::string& jid, std::vector* data) throw (WAException); void sendNotificationReceived(const std::string& from, const std::string& id) throw(WAException); void sendDeleteAccount() throw(WAException); -- cgit v1.2.3