summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/requests
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-03-22 21:07:19 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-03-22 21:07:19 +0000
commitd2a83c7d22df33abd1678756fd4caba432700860 (patch)
treee1e2dc51a300c3af8fb9877f97a34db094ea2653 /protocols/SkypeWeb/src/requests
parenta9edb12c2cc13a74f16c0a61deaeaa8780f13f4e (diff)
SkypeWeb:
- refactored HttpRequest 2 - status changing support (patch from MikalaiR) git-svn-id: http://svn.miranda-ng.org/main/trunk@12478 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/requests')
-rw-r--r--protocols/SkypeWeb/src/requests/contacts.h30
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h25
-rw-r--r--protocols/SkypeWeb/src/requests/login.h17
-rw-r--r--protocols/SkypeWeb/src/requests/logout.h7
-rw-r--r--protocols/SkypeWeb/src/requests/profile.h6
-rw-r--r--protocols/SkypeWeb/src/requests/reg_info.h23
-rw-r--r--protocols/SkypeWeb/src/requests/status.h26
7 files changed, 96 insertions, 38 deletions
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h
index aff095df65..96c0b1c203 100644
--- a/protocols/SkypeWeb/src/requests/contacts.h
+++ b/protocols/SkypeWeb/src/requests/contacts.h
@@ -1,14 +1,12 @@
#ifndef _SKYPE_REQUEST_CONTACTS_H_
#define _SKYPE_REQUEST_CONTACTS_H_
-class GetContactListRequest : public HttpRequest
+class GetContactListRequest : public HttpsGetRequest
{
public:
GetContactListRequest(const char *token, const char *skypename = "self") :
- HttpRequest(REQUEST_GET, "api.skype.com/users/%s/contacts?hideDetails=true", skypename)
+ HttpsGetRequest("api.skype.com/users/%s/contacts", skypename)
{
- flags |= NLHRF_SSL;
-
Url << CHAR_VALUE("hideDetails", "true");
Headers
@@ -18,14 +16,12 @@ public:
}
};
-class GetContactsInfoRequest : public HttpRequest
+class GetContactsInfoRequest : public HttpsPostRequest
{
public:
GetContactsInfoRequest(const char *token, const LIST<char> &skypenames, const char *skypename = "self") :
- HttpRequest(REQUEST_POST, "api.skype.com/users/%s/contacts/profiles", skypename)
+ HttpsPostRequest("api.skype.com/users/%s/contacts/profiles", skypename)
{
- flags |= NLHRF_SSL;
-
Headers
<< CHAR_VALUE("X-Skypetoken", "Accept")
<< CHAR_VALUE("X-Skypetoken", token)
@@ -38,42 +34,36 @@ public:
}
};
-class GetContactsAuthRequest : public HttpRequest
+class GetContactsAuthRequest : public HttpsGetRequest
{
public:
GetContactsAuthRequest(const char *token, const char *skypename = "self") :
- HttpRequest(REQUEST_GET, "api.skype.com/users/%s/contacts/auth-request", skypename)
+ HttpsGetRequest("api.skype.com/users/%s/contacts/auth-request", skypename)
{
- flags |= NLHRF_SSL;
-
Headers
<< CHAR_VALUE("X-Skypetoken", token)
<< CHAR_VALUE("Accept", "application/json");
}
};
-class AuthAcceptRequest : public HttpRequest
+class AuthAcceptRequest : public HttpsGetRequest
{
public:
AuthAcceptRequest(const char *token, const char *who, const char *skypename = "self") :
- HttpRequest(REQUEST_GET, "api.skype.com/users/%s/contacts/auth-request/%s/accept", skypename, who)
+ HttpsGetRequest("api.skype.com/users/%s/contacts/auth-request/%s/accept", skypename, who)
{
- flags |= NLHRF_SSL;
-
Headers
<< CHAR_VALUE("X-Skypetoken", token)
<< CHAR_VALUE("Accept", "application/json");
}
};
-class AuthDeclineRequest : public HttpRequest
+class AuthDeclineRequest : public HttpsGetRequest
{
public:
AuthDeclineRequest(const char *token, const char *who, const char *skypename = "self") :
- HttpRequest(REQUEST_GET, "api.skype.com/users/%s/contacts/auth-request/%s/decline", skypename)
+ HttpsGetRequest("api.skype.com/users/%s/contacts/auth-request/%s/decline", skypename)
{
- flags |= NLHRF_SSL;
-
Headers
<< CHAR_VALUE("X-Skypetoken", token)
<< CHAR_VALUE("Accept", "application/json");
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
new file mode 100644
index 0000000000..a6878f3f1f
--- /dev/null
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -0,0 +1,25 @@
+#ifndef _SKYPE_REQUEST_ENDPOINT_H_
+#define _SKYPE_REQUEST_ENDPOINT_H_
+
+class GetEndpointRequest : public HttpsRequest
+{
+public:
+ GetEndpointRequest(const char *regToken, const char *endpointURL) :
+ HttpsRequest(REQUEST_PUT, endpointURL)
+ {
+ flags |= NLHRF_SSL;
+
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << CHAR_VALUE("Expires", "0")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
+ << CHAR_VALUE("Referer", "https://web.skype.com/main")
+ << CHAR_VALUE("Origin", "https://web.skype.com")
+ << CHAR_VALUE("Connection", "keep-alive");
+
+ Body <<
+ VALUE("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"skype\"},\"publicInfo\":{\"capabilities\":\"video | audio\",\"type\":1,\"skypeNameVersion\":\"908 / 1.0.30 / swx - skype.com\",\"nodeInfo\":\"xx\",\"version\":\"908 / 1.0.30\"}}");
+ }
+};
+#endif //_SKYPE_REQUEST_ENDPOINT_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h
index 12f0e9e5cc..8c45c7237c 100644
--- a/protocols/SkypeWeb/src/requests/login.h
+++ b/protocols/SkypeWeb/src/requests/login.h
@@ -1,30 +1,29 @@
#ifndef _SKYPE_REQUEST_LOGIN_H_
#define _SKYPE_REQUEST_LOGIN_H_
-class LoginRequest : public HttpRequest
+class LoginRequest : public HttpsPostRequest
{
public:
LoginRequest() :
- HttpRequest(REQUEST_POST, "login.skype.com/login")
+ HttpsPostRequest("login.skype.com/login")
{
- flags |= NLHRF_SSL;
-
Url
<< INT_VALUE("client_id", 578134)
<< CHAR_VALUE("redirect_uri", "https%3A%2F%2Fweb.skype.com");
Headers
- << CHAR_VALUE("Host", "login.skype.com")
- << CHAR_VALUE("Referer", "https://web.skype.com/");
+ << CHAR_VALUE("Host", "login.skype.com");
}
LoginRequest(const char *skypename, const char *password, const char *pie, const char *etm) :
- HttpRequest(REQUEST_POST, "login.skype.com/login")
+ HttpsPostRequest("login.skype.com/login")
{
- this->LoginRequest::LoginRequest();
+ Url
+ << INT_VALUE("client_id", 578134)
+ << CHAR_VALUE("redirect_uri", "https%3A%2F%2Fweb.skype.com");
Headers
- << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded")
+ << CHAR_VALUE("Host", "login.skype.com")
<< CHAR_VALUE("Referer", "https://login.skype.com/login?method=skype&client_id=578134&redirect_uri=https%3A%2F%2Fweb.skype.com");
LPTIME_ZONE_INFORMATION tzi = tmi.getTziByContact(NULL);
diff --git a/protocols/SkypeWeb/src/requests/logout.h b/protocols/SkypeWeb/src/requests/logout.h
index 60f30e639c..b1585c9e91 100644
--- a/protocols/SkypeWeb/src/requests/logout.h
+++ b/protocols/SkypeWeb/src/requests/logout.h
@@ -1,13 +1,10 @@
#ifndef _SKYPE_REQUEST_LOGOUT_H_
#define _SKYPE_REQUEST_LOGOUT_H_
-class LogoutRequest : public HttpRequest
+class LogoutRequest : public HttpsPostRequest
{
public:
- LogoutRequest() : HttpRequest(REQUEST_POST, "login.skype.com/logout")
- {
- flags |= NLHRF_SSL;
- }
+ LogoutRequest() : HttpsPostRequest("login.skype.com/logout") { }
};
#endif //_SKYPE_REQUEST_LOGOUT_H_
diff --git a/protocols/SkypeWeb/src/requests/profile.h b/protocols/SkypeWeb/src/requests/profile.h
index 2c0b4e8fb6..579ac446b4 100644
--- a/protocols/SkypeWeb/src/requests/profile.h
+++ b/protocols/SkypeWeb/src/requests/profile.h
@@ -1,14 +1,12 @@
#ifndef _SKYPE_REQUEST_PROFILE_H_
#define _SKYPE_REQUEST_PROFILE_H_
-class GetProfileRequest : public HttpRequest
+class GetProfileRequest : public HttpsGetRequest
{
public:
GetProfileRequest(const char *token, const char *skypename = "self") :
- HttpRequest(REQUEST_GET, "api.skype.com/users/%s/profile", skypename)
+ HttpsGetRequest("api.skype.com/users/%s/profile", skypename)
{
- flags |= NLHRF_SSL;
-
Headers
<< CHAR_VALUE("X-Skypetoken", token)
<< CHAR_VALUE("Accept", "application/json");
diff --git a/protocols/SkypeWeb/src/requests/reg_info.h b/protocols/SkypeWeb/src/requests/reg_info.h
new file mode 100644
index 0000000000..6ba0518524
--- /dev/null
+++ b/protocols/SkypeWeb/src/requests/reg_info.h
@@ -0,0 +1,23 @@
+#ifndef _SKYPE_REQUEST_REGINFO_H_
+#define _SKYPE_REQUEST_REGINFO_H_
+
+class GetRegInfoRequest : public HttpsPostRequest
+{
+public:
+ GetRegInfoRequest(const char *token) :
+ HttpsPostRequest("client-s.gateway.messenger.live.com/v1/users/ME/endpoints")
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << CHAR_VALUE("Expires", "0")
+ << FORMAT_VALUE("Authentication", "skypetoken=%s", token)
+ << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8")
+ << CHAR_VALUE("Referer", "https://web.skype.com/main")
+ << CHAR_VALUE("Origin", "https://web.skype.com")
+ << CHAR_VALUE("Connection", "keep-alive");
+
+ Body << VALUE("{}");
+ }
+};
+
+#endif //_SKYPE_REQUEST_STATUS_H_
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
new file mode 100644
index 0000000000..07703e84ae
--- /dev/null
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -0,0 +1,26 @@
+#ifndef _SKYPE_REQUEST_STATUS_H_
+#define _SKYPE_REQUEST_STATUS_H_
+
+class SetStatusRequest : public HttpsRequest
+{
+public:
+ SetStatusRequest(const char *regToken, bool status) :
+ HttpsRequest(REQUEST_PUT, "client-s.gateway.messenger.live.com/v1/users/ME/presenceDocs/messagingService")
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application / json, text / javascript")
+ << CHAR_VALUE("Expires", "0")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("Content-Type", "application/json; charset = UTF-8")
+ << CHAR_VALUE("Referer", "https://web.skype.com/main")
+ << CHAR_VALUE("Origin", "https://web.skype.com")
+ << CHAR_VALUE("Connection", "keep-alive");
+
+ const char *data = status
+ ? "{\"status\":\"Online\"}"
+ : "{\"status\":\"Hidden\"}";
+ Body << VALUE(data);
+ }
+};
+
+#endif //_SKYPE_REQUEST_STATUS_H_