summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/requests
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-04-07 21:50:05 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-04-07 21:50:05 +0000
commit90a05404a6ded56141c0230f663686439f8fa146 (patch)
tree6531783fbbedc04db025526243342823ed9ccd65 /protocols/SkypeWeb/src/requests
parentde593c8e4ae504a8d159cc272740846ef9c20ca6 (diff)
SkypeWeb:
- added ability to getting contacts statuses - partly reworked login flow git-svn-id: http://svn.miranda-ng.org/main/trunk@12665 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/requests')
-rw-r--r--protocols/SkypeWeb/src/requests/avatars.h8
-rw-r--r--protocols/SkypeWeb/src/requests/capabilities.h25
-rw-r--r--protocols/SkypeWeb/src/requests/contacts.h33
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h29
-rw-r--r--protocols/SkypeWeb/src/requests/status.h6
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h4
6 files changed, 80 insertions, 25 deletions
diff --git a/protocols/SkypeWeb/src/requests/avatars.h b/protocols/SkypeWeb/src/requests/avatars.h
index 6b71a0732d..f089ae5c1b 100644
--- a/protocols/SkypeWeb/src/requests/avatars.h
+++ b/protocols/SkypeWeb/src/requests/avatars.h
@@ -16,13 +16,15 @@ public:
SetAvatarRequest(const char *token, const char *skypename, const char *data, size_t dataSize) :
HttpRequest(REQUEST_PUT, FORMAT, "api.skype.com/users/%s/profile/avatar", skypename)
{
- pData = (char*)mir_alloc(dataSize);
- memcpy(pData, data, dataSize);
- dataLength = dataSize;
Headers
<< CHAR_VALUE("X-Skypetoken", token)
<< CHAR_VALUE("Content-Type", "image/jpeg");
+
+ pData = (char*)mir_alloc(dataSize);
+ memcpy(pData, data, dataSize);
+ dataLength = dataSize;
}
+
~SetAvatarRequest()
{
mir_free(pData);
diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h
new file mode 100644
index 0000000000..3c2894ac91
--- /dev/null
+++ b/protocols/SkypeWeb/src/requests/capabilities.h
@@ -0,0 +1,25 @@
+#ifndef _SKYPE_REQUEST_CAPS_H_
+#define _SKYPE_REQUEST_CAPS_H_
+
+class SendCapabilitiesRequest : public HttpRequest
+{
+public:
+ SendCapabilitiesRequest(const char *regToken, const char *endpointID, const char *server = "client-s.gateway.messenger.live.com") :
+ HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/endpoints/%s/presenceDocs/messagingService", server, ptrA(mir_urlEncode(endpointID)))
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
+ CMStringA data;
+
+ int bitness = 32;
+#ifdef _WIN64
+ bitness = 64;
+#endif
+ data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x%d\"}}", MIRANDA_VERSION_STRING, bitness);
+ Body <<
+ VALUE(data);
+ }
+};
+#endif //_SKYPE_REQUEST_CAPS_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h
index 8a23526bf9..585df9a92d 100644
--- a/protocols/SkypeWeb/src/requests/contacts.h
+++ b/protocols/SkypeWeb/src/requests/contacts.h
@@ -30,6 +30,39 @@ public:
}
};
+class GetContactStatusRequest : public HttpRequest
+{
+public:
+ GetContactStatusRequest(const char *regToken, const char *skypename, const char *server = "client-s.gateway.messenger.live.com") :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/contacts/8:%s/presenceDocs/messagingService", server, skypename)
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
+ }
+};
+
+class CreateContactsRequest : public HttpRequest
+{
+public:
+ CreateContactsRequest(const char *regToken, const LIST<char> &skypenames, const char *server = "client-s.gateway.messenger.live.com") :
+ HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/contacts", server)
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
+
+ CMStringA data = "{\"contacts\":[";
+ for (int i = 0; i < skypenames.getCount(); i++)
+ data.AppendFormat("{\"id\":\"8:%s\"},", skypenames[i]);
+ data.Truncate(data.GetLength() - 1);
+ data.Append("]}");
+
+ Body << VALUE(data);
+ }
+};
+
class GetContactsAuthRequest : public HttpRequest
{
public:
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
index 8af43de6c3..51c7e6f634 100644
--- a/protocols/SkypeWeb/src/requests/endpoint.h
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -1,25 +1,20 @@
-#ifndef _SKYPE_REQUEST_ENDPOINT_H_
-#define _SKYPE_REQUEST_ENDPOINT_H_
+#ifndef _SKYPE_REQUEST_REGINFO_H_
+#define _SKYPE_REQUEST_REGINFO_H_
-class GetEndpointRequest : public HttpRequest
+class CreateEndpointRequest : public HttpRequest
{
public:
- GetEndpointRequest(const char *regToken, const char *endpointID, const char *server = "client-s.gateway.messenger.live.com") :
- HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/endpoints/%s/presenceDocs/messagingService", server, ptrA(mir_urlEncode(endpointID)))
+ CreateEndpointRequest(const char *token, const char *server = "client-s.gateway.messenger.live.com") :
+ HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/endpoints", server)
{
+
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
- << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
- << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- CMStringA data;
-
- int bitness = 32;
-#ifdef _WIN64
- bitness = 64;
-#endif
- data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x%d\"}}", MIRANDA_VERSION_STRING, bitness);
- Body <<
- VALUE(data);
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
+ << FORMAT_VALUE("Authentication", "skypetoken=%s", token);
+
+ Body << VALUE("{}");
}
};
-#endif //_SKYPE_REQUEST_ENDPOINT_H_ \ No newline at end of file
+
+#endif //_SKYPE_REQUEST_STATUS_H_
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
index f7669e2197..6d61af48d5 100644
--- a/protocols/SkypeWeb/src/requests/status.h
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -7,14 +7,14 @@ public:
SetStatusRequest(const char *regToken, const char *status, const char *server = "client-s.gateway.messenger.live.com") :
HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/presenceDocs/messagingService", server)
{
- CMStringA statuss;
- statuss.AppendFormat("{\"status\":\"%s\"}", status);
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- Body << VALUE(statuss);
+ CMStringA data;
+ data.AppendFormat("{\"status\":\"%s\"}", status);
+ Body << VALUE(data);
}
};
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index 236b26f7cc..bff30fdb2e 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -1,10 +1,10 @@
#ifndef _SKYPE_REQUEST_SUBSCIPTIONS_H_
#define _SKYPE_REQUEST_SUBSCIPTIONS_H_
-class SubscriptionsRequest : public HttpRequest
+class CreateSubscriptionsRequest : public HttpRequest
{
public:
- SubscriptionsRequest(const char *regToken, const char *server = "client-s.gateway.messenger.live.com") :
+ CreateSubscriptionsRequest(const char *regToken, const char *server = "client-s.gateway.messenger.live.com") :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/endpoints/SELF/subscriptions", server)
{
Headers