diff options
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 18 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.h | 18 |
2 files changed, 5 insertions, 31 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index c271a83be2..56c86c6806 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -586,8 +586,10 @@ void WAConnection::parsePresense(ProtocolTreeNode *node) throw(WAException) if (m_pEventHandler != NULL) {
const string &type = node->getAttributeValue("type");
- if (type == "unavailable")
- m_pEventHandler->onAvailable(from, false);
+ if (type == "unavailable") {
+ const string &lastSeen = node->getAttributeValue("last");
+ m_pEventHandler->onAvailable(from, false, (lastSeen == "deny") ? -2 : atoi(lastSeen.c_str()));
+ }
else if (type == "available" || type == "")
m_pEventHandler->onAvailable(from, true);
}
@@ -962,18 +964,6 @@ void WAConnection::sendPresenceSubscriptionRequest(const std::string &to) throw( out.write(ProtocolTreeNode("presence") << XATTR("type", "subscribe") << XATTR("to", to));
}
-void WAConnection::sendQueryLastOnline(const std::string &jid) throw (WAException)
-{
- if (jid == "Server@s.whatsapp.net") // to avoid error 405
- return;
-
- std::string id = makeId("iq_");
- this->pending_server_requests[id] = new IqResultQueryLastOnlineHandler(this);
-
- out.write(ProtocolTreeNode("iq", new ProtocolTreeNode("query"))
- << XATTR("id", id) << XATTR("type", "get") << XATTR("to", jid) << XATTR("xmlns", "jabber:iq:last"));
-}
-
void WAConnection::sendSetPicture(const char *jid, std::vector<unsigned char>* data, std::vector<unsigned char>* preview) throw (WAException)
{
std::string id = this->makeId("set_photo_");
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h index a1a366c13e..5b6970df60 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h @@ -36,9 +36,8 @@ public: virtual void onMessageError(const FMessage &message, int paramInt) = 0;
virtual void onPing(const std::string ¶mString) throw (WAException) = 0;
virtual void onPingResponseReceived() = 0;
- virtual void onAvailable(const std::string ¶mString, bool paramBoolean) = 0;
+ virtual void onAvailable(const std::string ¶mString, bool paramBoolean, int lastSeenTime = -1) = 0;
virtual void onClientConfigReceived(const std::string ¶mString) = 0;
- virtual void onLastSeen(const std::string ¶mString1, int paramInt, const string ¶mString2) = 0;
virtual void onIsTyping(const std::string ¶mString, bool paramBoolean) = 0;
virtual void onAccountChange(int paramInt, time_t paramLong) = 0;
virtual void onPrivacyBlockListAdd(const std::string ¶mString) = 0;
@@ -219,20 +218,6 @@ class WAConnection }
};
- class IqResultQueryLastOnlineHandler: public IqResultHandler {
- public:
- IqResultQueryLastOnlineHandler(WAConnection* con):IqResultHandler(con) {}
- virtual void parse(ProtocolTreeNode* node, const std::string &from) throw (WAException) {
- ProtocolTreeNode* firstChild = node->getChild(0);
- ProtocolTreeNode::require(firstChild, "query");
- const string &seconds = firstChild->getAttributeValue("seconds");
- const string &status = firstChild->getDataAsString();
- if (!seconds.empty() && !from.empty())
- if (this->con->m_pEventHandler != NULL)
- this->con->m_pEventHandler->onLastSeen(from, atoi(seconds.c_str()), status);
- }
- };
-
class IqResultGetPhotoHandler: public IqResultHandler {
private:
std::string jid;
@@ -399,7 +384,6 @@ public: void sendAck(ProtocolTreeNode * node, const char *classType);
void sendPing() throw(WAException);
- void sendQueryLastOnline(const std::string &jid) throw (WAException);
void sendPong(const std::string &id) throw(WAException);
void sendComposing(const std::string &to) throw(WAException);
void sendActive() throw(WAException);
|