From 3e6fb10c557538bbb89666b1423bf7c85f1e4aff Mon Sep 17 00:00:00 2001 From: leecher1337 Date: Thu, 29 Mar 2018 01:04:55 +0200 Subject: Seems like MSN now only uses Skype contacts internally, therefore crude hack to migrate MSN-user messages to Skype. --- protocols/MSN/src/msn_contact.cpp | 4 ++- protocols/MSN/src/msn_misc.cpp | 6 ++--- protocols/MSN/src/msn_skypeab.cpp | 51 ++++++++++++++++++++++++--------------- 3 files changed, 37 insertions(+), 24 deletions(-) (limited to 'protocols/MSN/src') diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index a00547b270..aba8a2b99f 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -222,6 +222,7 @@ bool CMsnProto::MSN_RefreshContactList(void) Lists_Wipe(); Lists_Populate(); + /* if (MyOptions.netId != NETID_SKYPE) { // Get your own profile info (does not work anymore, byrdr died) @@ -250,7 +251,8 @@ bool CMsnProto::MSN_RefreshContactList(void) // Read my own profile from SOAP AB (does not work anymore, byrdr died) //MSN_StoreGetProfile(); } - else + else + */ { // Refresh Skype contact list MSN_SKYABRefreshClist(); diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 35280a1610..3e2180ac1f 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -461,7 +461,7 @@ int ThreadData::sendMessage(int, const char *email, int netId, const char *parMs "From: %d:%s;epid=%s\r\n\r\n" "Reliability: 1.0\r\n\r\n%s", netId, email, - netId == NETID_SKYPE?netId:proto->MyOptions.netId, proto->GetMyUsername(netId), proto->MyOptions.szMachineGuid, + NETID_SKYPE, proto->GetMyUsername(NETID_SKYPE), proto->MyOptions.szMachineGuid, parMsg); return seq; @@ -657,8 +657,8 @@ void CMsnProto::MSN_SetServerStatus(int newStatus) "Uri: /user\r\n" "Content-Type: application/user+xml\r\n" "Content-Length: %d\r\n\r\n%s", - MyOptions.netId, MyOptions.szEmail, - MyOptions.netId, MyOptions.szEmail, + NETID_SKYPE, GetMyUsername(NETID_SKYPE), + NETID_SKYPE, GetMyUsername(NETID_SKYPE), MyOptions.szMachineGuid, sz, szMsg); diff --git a/protocols/MSN/src/msn_skypeab.cpp b/protocols/MSN/src/msn_skypeab.cpp index 571dcf63b3..6350421a80 100644 --- a/protocols/MSN/src/msn_skypeab.cpp +++ b/protocols/MSN/src/msn_skypeab.cpp @@ -63,7 +63,8 @@ bool CMsnProto::MSN_SKYABRefreshClist(void) // initialize the netlib request if (!APISkypeComRequest(&nlhr, headers)) return false; nlhr.requestType = REQUEST_GET; - nlhr.szUrl = "https://api.skype.com/users/self/contacts"; + nlhr.szUrl = "https://contacts.skype.com/contacts/v1/users/SELF/contacts"; + // Query addressbook mHttpsTS = clock(); @@ -76,30 +77,37 @@ bool CMsnProto::MSN_SKYABRefreshClist(void) if (root == nullptr) return false; - JSONNode *items = json_as_array(root), *item; + JSONNode *items = json_get(root, "contacts"), *item, *node; for (size_t i = 0; i < json_size(items); i++) { - int lstId = LIST_FL; - ptrW nick; - + int lstId = LIST_FL, type = NETID_SKYPE; item = json_at(items, i); if (item == nullptr) break; - ptrA skypename(mir_u2a(ptrW(json_as_string(json_get(item, "skypename"))))); - ptrA pszNick(mir_u2a(ptrW(get_json_str(item, "fullname")))); - char szWLId[128]; - mir_snprintf(szWLId, sizeof(szWLId), "%d:%s", NETID_SKYPE, skypename); - MCONTACT hContact = MSN_HContactFromEmail(szWLId, pszNick, true, false); + ptrW value; + ptrA skypename(mir_u2a(ptrW(json_as_string(json_get(item, "id"))))); + ptrA wlid(mir_u2a(ptrW(json_as_string(json_get(item, "person_id"))))); + MCONTACT hContact = MSN_HContactFromEmail(wlid, skypename, false, false); + if (hContact) { if (!json_as_bool(json_get(item, "authorized"))) lstId = LIST_PL; if (!json_as_bool(json_get(item, "blocked"))) lstId = LIST_BL; - Lists_Add(lstId, NETID_SKYPE, skypename, NULL, pszNick, nullptr); - post.AppendFormat("contacts[]=%s&", skypename); + if ((node = json_get(item, "name")) && !node->empty()) { + if (value = get_json_str(node, "first")) setWString(hContact, "FirstName", value); + } + //if (value = get_json_str(item, "lastname")) setWString(hContact, "LastName", value); + if ((node = json_get(item, "locations")) && !node->empty()) { + if (value = get_json_str(node, "country")) setString(hContact, "Country", (char*)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)(char*)_T2A(value), 0)); + if (value = get_json_str(node, "city")) setWString(hContact, "City", value); + } + if (value = get_json_str(item, "mood")) db_set_ws(hContact, "CList", "StatusMsg", value); + if ((value = get_json_str(item, "type")) && mir_wstrcmp(value, L"skype")) type = NETID_MSN; + if (value = get_json_str(item, "display_name")) setWString(hContact, "Nick", value); + Lists_Add(lstId, type, skypename, NULL, value?ptrA(mir_u2a(value)):skypename, NULL); } } bRet = true; - json_delete(items); - MSN_SKYABGetProfiles((const char*)post); + //MSN_SKYABGetProfiles((const char*)post); } Netlib_FreeHttpRequest(nlhrReply); } @@ -274,7 +282,7 @@ bool CMsnProto::MSN_SKYABDeleteContact(const char *wlid) // initialize the netlib request if (!APISkypeComRequest(&nlhr, headers)) return false; nlhr.requestType = REQUEST_DELETE; - mir_snprintf(szURL, sizeof(szURL), "https://api.skype.com/users/self/contacts/%s", wlid); + mir_snprintf(szURL, sizeof(szURL), "https://contacts.skype.com/contacts/v2/users/SELF/contacts/%s", wlid); nlhr.szUrl = szURL; nlhr.headers[3].szName = "Content-type"; nlhr.headers[3].szValue = "application/x-www-form-urlencoded"; @@ -303,7 +311,7 @@ bool CMsnProto::MSN_SKYABAuthRsp(const char *wlid, const char *pszAction) // initialize the netlib request if (!APISkypeComRequest(&nlhr, headers)) return false; nlhr.requestType = REQUEST_PUT; - mir_snprintf(szURL, sizeof(szURL), "https://api.skype.com/users/self/contacts/auth-request/%s/%s", wlid, pszAction); + mir_snprintf(szURL, sizeof(szURL), "https://contacts.skype.com/contacts/v2/users/SELF/invites/%s/%s", wlid, pszAction); nlhr.szUrl = szURL; mHttpsTS = clock(); @@ -329,13 +337,16 @@ bool CMsnProto::MSN_SKYABAuthRq(const char *wlid, const char *pszGreeting) // initialize the netlib request if (!APISkypeComRequest(&nlhr, headers)) return false; nlhr.requestType = REQUEST_PUT; - mir_snprintf(szURL, sizeof(szURL), "https://api.skype.com/users/self/contacts/auth-request/%s", wlid); - nlhr.szUrl = szURL; + nlhr.szUrl = "https://contacts.skype.com/contacts/v2/users/SELF/contacts"; nlhr.headers[3].szName = "Content-type"; nlhr.headers[3].szValue = "application/x-www-form-urlencoded"; nlhr.headersCount++; - post.Format("greeting=%s", pszGreeting); - nlhr.dataLength = (int)mir_strlen(post); + JSONNode node; + node + << JSONNode("mri", wlid) + << JSONNode("greeting", pszGreeting); + post = node.write().c_str(); + nlhr.dataLength = post.GetLength(); nlhr.pData = (char*)(const char*)post; mHttpsTS = clock(); -- cgit v1.2.3