summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/SkypeWeb/src/http_request.h4
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h5
-rw-r--r--protocols/SkypeWeb/src/requests/login.h8
-rw-r--r--protocols/SkypeWeb/src/requests/reg_info.h6
-rw-r--r--protocols/SkypeWeb/src/requests/status.h4
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_events.cpp67
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp14
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
9 files changed, 83 insertions, 28 deletions
diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h
index 5d34d04e3f..db6c2caeec 100644
--- a/protocols/SkypeWeb/src/http_request.h
+++ b/protocols/SkypeWeb/src/http_request.h
@@ -245,7 +245,7 @@ public:
this->HttpRequest::HttpRequest(REQUEST_POST, urlFormat, args);
va_end(args);
- Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ //Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
}
};
@@ -291,7 +291,7 @@ public:
this->HttpsRequest::HttpsRequest(REQUEST_POST, urlFormat, args);
va_end(args);
- Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ //Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
}
};
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
index a6878f3f1f..3bd6827ac4 100644
--- a/protocols/SkypeWeb/src/requests/endpoint.h
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -8,11 +8,12 @@ public:
HttpsRequest(REQUEST_PUT, endpointURL)
{
flags |= NLHRF_SSL;
-
+ CMStringA auth = "registrationToken=";
+ auth += regToken;
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< CHAR_VALUE("Expires", "0")
- << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("RegistrationToken", auth)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< CHAR_VALUE("Referer", "https://web.skype.com/main")
<< CHAR_VALUE("Origin", "https://web.skype.com")
diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h
index 8c45c7237c..c7924a842c 100644
--- a/protocols/SkypeWeb/src/requests/login.h
+++ b/protocols/SkypeWeb/src/requests/login.h
@@ -7,24 +7,28 @@ public:
LoginRequest() :
HttpsPostRequest("login.skype.com/login")
{
+ //flags = NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT;
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("Host", "login.skype.com")
+ << CHAR_VALUE("Connection", "keep-alive");
}
LoginRequest(const char *skypename, const char *password, const char *pie, const char *etm) :
HttpsPostRequest("login.skype.com/login")
{
+ //flags = NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT;
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://login.skype.com/login?method=skype&client_id=578134&redirect_uri=https%3A%2F%2Fweb.skype.com");
+ << CHAR_VALUE("Referer", "https://login.skype.com/login?method=skype&client_id=578134&redirect_uri=https%3A%2F%2Fweb.skype.com")
+ << CHAR_VALUE("Connection", "keep-alive");
LPTIME_ZONE_INFORMATION tzi = tmi.getTziByContact(NULL);
char sign = tzi->Bias > 0 ? '-' : '+';
diff --git a/protocols/SkypeWeb/src/requests/reg_info.h b/protocols/SkypeWeb/src/requests/reg_info.h
index 6ba0518524..888ce987b0 100644
--- a/protocols/SkypeWeb/src/requests/reg_info.h
+++ b/protocols/SkypeWeb/src/requests/reg_info.h
@@ -7,10 +7,12 @@ public:
GetRegInfoRequest(const char *token) :
HttpsPostRequest("client-s.gateway.messenger.live.com/v1/users/ME/endpoints")
{
- Headers
+ CMStringA auth = "skypetoken=";
+ auth += token;
+ Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< CHAR_VALUE("Expires", "0")
- << FORMAT_VALUE("Authentication", "skypetoken=%s", token)
+ << CHAR_VALUE("Authentication", auth)
<< CHAR_VALUE("Content-Type", "application/json; charset = UTF-8")
<< CHAR_VALUE("Referer", "https://web.skype.com/main")
<< CHAR_VALUE("Origin", "https://web.skype.com")
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
index 07703e84ae..a8c40a492b 100644
--- a/protocols/SkypeWeb/src/requests/status.h
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -7,10 +7,12 @@ public:
SetStatusRequest(const char *regToken, bool status) :
HttpsRequest(REQUEST_PUT, "client-s.gateway.messenger.live.com/v1/users/ME/presenceDocs/messagingService")
{
+ CMStringA auth = "registrationToken=";
+ auth += regToken;
Headers
<< CHAR_VALUE("Accept", "application / json, text / javascript")
<< CHAR_VALUE("Expires", "0")
- << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("RegistrationToken", auth)
<< CHAR_VALUE("Content-Type", "application/json; charset = UTF-8")
<< CHAR_VALUE("Referer", "https://web.skype.com/main")
<< CHAR_VALUE("Origin", "https://web.skype.com")
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 08b0a6f063..c8a889d316 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -88,6 +88,7 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response)
if (response == NULL)
return;
+
JSONROOT root(response->pData);
if (root == NULL)
return;
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp
index 309110b285..ff2efa5fef 100644
--- a/protocols/SkypeWeb/src/skype_events.cpp
+++ b/protocols/SkypeWeb/src/skype_events.cpp
@@ -98,31 +98,68 @@ void CSkypeProto::OnLoginSecond(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnGetRegInfo(const NETLIBHTTPREQUEST *response)
{
+ if (response == NULL)
+ return;
+
std::regex regex;
std::smatch match;
std::string content = response->pData;
for (int i = 0; i < response->headersCount; i++)
{
- if (mir_strcmpi(response->headers[i].szName, "Set-RegistrationToken"))
+ if (mir_strcmpi(response->headers[i].szName, "Set-RegistrationToken") == 0)
+ {
+ regex = "^(.+?)=(.+?);";
+ content = response->headers[i].szValue;
+ if (std::regex_search(content, match, regex))
+ RegInfo[match[1]] = match[2];
+ }
+ else if (mir_strcmpi(response->headers[i].szName, "Location") == 0)
+ {
+ content = response->headers[i].szValue;
+ RegInfo["Location"] = content;
+ }
+ else
continue;
-
- regex = "^(.+?)=(.+?);";
- content = response->headers[i].szValue;
-
- if (std::regex_search(content, match, regex))
- RegInfo[match[1]] = match[2];
}
setString("RegistrationToken", RegInfo["registrationToken"].c_str());
+ setString("Endpoint", urlDecode(RegInfo["Location"].c_str()).c_str());
- for (int i = 0; i < response->headersCount; i++)
- {
- if (mir_strcmpi(response->headers[i].szName, "Location"))
- continue;
- content = response->headers[i].szValue;
- }
- setString("Endpoint", urlDecode(content.c_str()).c_str());
debugLogA(getStringA("RegistrationToken"));
debugLogA(getStringA("Endpoint"));
- PushRequest(new GetEndpointRequest(ptrA(getStringA("RegistrationToken")), ptrA(getStringA("Endpoint"))));
+ CMStringA endpointURL = getStringA("Endpoint");
+ endpointURL += "/presenceDocs/messagingService";
+ PushRequest(new GetEndpointRequest(ptrA(getStringA("RegistrationToken")), endpointURL));
PushRequest(new SetStatusRequest(ptrA(getStringA("RegistrationToken")), true));
+}
+
+void CSkypeProto::OnSetStatus(const NETLIBHTTPREQUEST *response)
+{
+ if (response == NULL)
+ return;
+
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
+ JSONNODE *status_json = json_get(root, "status");
+ debugLog(json_as_string(status_json));
+
+ const char* status = (const char *)json_as_string(status_json);
+ debugLogA(status);
+
+ int old_status = m_iStatus;
+ int iNewStatus;
+ if (mir_strcmp(status, "O")==0)
+ {
+ iNewStatus = ID_STATUS_ONLINE;
+ }
+ else if (mir_strcmp(status,"H")==0)
+ {
+ iNewStatus = ID_STATUS_INVISIBLE;
+ }
+ else
+ {
+ iNewStatus = ID_STATUS_ONLINE;
+ }
+ m_iStatus = iNewStatus;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 82a3ec1b00..4f3adf6462 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -133,6 +133,8 @@ int CSkypeProto::SetStatus(int iNewStatus)
int old_status = m_iStatus;
m_iDesiredStatus = iNewStatus;
+ CMStringA endpointURL = getStringA("Endpoint");
+ endpointURL += "/presenceDocs/messagingService";
if (iNewStatus == ID_STATUS_OFFLINE)
{
@@ -149,8 +151,8 @@ int CSkypeProto::SetStatus(int iNewStatus)
}
else if (iNewStatus == ID_STATUS_INVISIBLE)
{
- PushRequest(new GetEndpointRequest(ptrA(getStringA("RegistrationToken")), ptrA(getStringA("Endpoint"))));
- PushRequest(new SetStatusRequest(ptrA(getStringA("RegistrationToken")), false));
+ PushRequest(new GetEndpointRequest(ptrA(getStringA("RegistrationToken")), endpointURL));
+ PushRequest(new SetStatusRequest(ptrA(getStringA("RegistrationToken")), false), &CSkypeProto::OnSetStatus);
}
else
{
@@ -159,7 +161,12 @@ int CSkypeProto::SetStatus(int iNewStatus)
return 0;
}
- if (old_status == ID_STATUS_OFFLINE && m_iStatus == ID_STATUS_OFFLINE)
+ if (m_iStatus == ID_STATUS_INVISIBLE)
+ {
+ PushRequest(new GetEndpointRequest(ptrA(getStringA("RegistrationToken")), endpointURL));
+ PushRequest(new SetStatusRequest(ptrA(getStringA("RegistrationToken")), true), &CSkypeProto::OnSetStatus);
+ }
+ else if (old_status == ID_STATUS_OFFLINE && m_iStatus == ID_STATUS_OFFLINE)
{
// login
m_iStatus = ID_STATUS_CONNECTING;
@@ -178,6 +185,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
return 0;
}
+
HANDLE CSkypeProto::GetAwayMsg(MCONTACT) { return 0; }
int CSkypeProto::RecvAwayMsg(MCONTACT, int, PROTORECVEVENT*) { return 0; }
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 4310050bad..32bcd1f411 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -122,8 +122,8 @@ private:
// events
void OnLoginFirst(const NETLIBHTTPREQUEST *response);
void OnLoginSecond(const NETLIBHTTPREQUEST *response);
-
void OnGetRegInfo(const NETLIBHTTPREQUEST *response);
+ void OnSetStatus(const NETLIBHTTPREQUEST *response);
// profile
void UpdateProfileFirstName(JSONNODE *root, MCONTACT hContact = NULL);