diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-28 23:20:50 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-28 23:20:50 +0000 |
commit | ebbf4ad769d99f07c6d5184d9fe4323e7eaf0246 (patch) | |
tree | 23edc80f39815511a97dc5c111564422b3a570da /protocols/WhatsApp/src/WhatsAPI++ | |
parent | 998a7c4af898008db19fa3870c1df97d28b33eec (diff) |
avatars are back
git-svn-id: http://svn.miranda-ng.org/main/trunk@11943 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 26 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.h | 34 |
2 files changed, 10 insertions, 50 deletions
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<std::string>& jids) throw (WAException)
-{
- std::string id = makeId("get_picture_ids_");
- this->pending_server_requests[id] = new IqResultGetPictureIdsHandler(this);
-
- std::vector<ProtocolTreeNode*>* children = new std::vector<ProtocolTreeNode*>();
- 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<string,string>& 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<string,string>* ids)=0;
- virtual void onSendGetPicture(const std::string& jid, const std::vector<unsigned char>& data, const std::string& oldId, const std::string& newId)=0;
+ virtual void onSendGetPicture(const std::string& jid, const std::vector<unsigned char>& 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<unsigned char> 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<ProtocolTreeNode*> children(groupNode->getAllChildren("user"));
- std::map<std::string, std::string> 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<std::string>& 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<std::string>& jids) throw (WAException);
+ void sendGetPicture(const std::string& jid, const std::string& type) throw (WAException);
void sendSetPicture(const std::string& jid, std::vector<unsigned char>* data) throw (WAException);
void sendNotificationReceived(const std::string& from, const std::string& id) throw(WAException);
void sendDeleteAccount() throw(WAException);
|