diff options
Diffstat (limited to 'protocols/Teams/src')
-rw-r--r-- | protocols/Teams/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/Teams/src/teams_contacts.cpp | 9 | ||||
-rw-r--r-- | protocols/Teams/src/teams_http.cpp | 23 | ||||
-rw-r--r-- | protocols/Teams/src/teams_proto.h | 77 | ||||
-rw-r--r-- | protocols/Teams/src/teams_server.cpp | 2 | ||||
-rw-r--r-- | protocols/Teams/src/teams_trouter.cpp | 2 |
6 files changed, 61 insertions, 53 deletions
diff --git a/protocols/Teams/src/stdafx.h b/protocols/Teams/src/stdafx.h index 542f889615..07aee25c19 100644 --- a/protocols/Teams/src/stdafx.h +++ b/protocols/Teams/src/stdafx.h @@ -72,6 +72,7 @@ enum SkypeHost HOST_GRAPH, HOST_LOGIN, HOST_TEAMS, + HOST_TEAMS_API, HOST_CHATS, HOST_PRESENCE, HOST_OTHER diff --git a/protocols/Teams/src/teams_contacts.cpp b/protocols/Teams/src/teams_contacts.cpp index 3cc2f857dc..24b986cbd5 100644 --- a/protocols/Teams/src/teams_contacts.cpp +++ b/protocols/Teams/src/teams_contacts.cpp @@ -135,7 +135,14 @@ void CTeamsProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*) } } -void CTeamsProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*) +///////////////////////////////////////////////////////////////////////////////////////// + +void CTeamsProto::RefreshContactsInfo() +{ + PushRequest(new AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/contacts", &CTeamsProto::OnGotContactsInfo)); +} + +void CTeamsProto::OnGotContactsInfo(MHttpResponse *response, AsyncHttpRequest*) { TeamsReply reply(response); if (reply.error()) diff --git a/protocols/Teams/src/teams_http.cpp b/protocols/Teams/src/teams_http.cpp index 015b294036..35c1a03c1f 100644 --- a/protocols/Teams/src/teams_http.cpp +++ b/protocols/Teams/src/teams_http.cpp @@ -26,6 +26,7 @@ AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpR case HOST_GRAPH: m_szUrl = "skypegraph.skype.com"; break; case HOST_LOGIN: m_szUrl = "login.microsoftonline.com"; break; case HOST_TEAMS: m_szUrl = TEAMS_BASE_HOST; break; + case HOST_TEAMS_API: m_szUrl = TEAMS_BASE_HOST "/api/mt/beta"; break; case HOST_CHATS: m_szUrl = TEAMS_BASE_HOST "/api/chatsvc/consumer/v1"; break; case HOST_PRESENCE: m_szUrl = "presence." TEAMS_BASE_HOST "/v1"; break; @@ -84,13 +85,6 @@ void CTeamsProto::PushRequest(AsyncHttpRequest *request) { if (m_isTerminated) return; - - if (request->m_host == HOST_TEAMS) { - if (!request->FindHeader("Authorization")) - request->AddHeader("Authorization", "Bearer " + m_szAccessToken); - request->AddHeader("Accept", "application/json"); - } - { mir_cslock lock(m_requestQueueLock); m_requests.insert(request); @@ -123,14 +117,23 @@ MHttpResponse* CTeamsProto::DoSend(AsyncHttpRequest *pReq) switch (pReq->m_host) { case HOST_CONTACTS: case HOST_DEFAULT: - if (m_szSkypeToken) - pReq->AddHeader("X-Skypetoken", m_szSkypeToken); - + pReq->AddAuthentication(this); pReq->AddHeader("Accept", "application/json"); pReq->AddHeader("X-Stratus-Caller", TEAMS_CLIENTINFO_NAME); pReq->AddHeader("X-Stratus-Request", "abcd1234"); pReq->AddHeader("Origin", "https://teams.live.com"); pReq->AddHeader("Referer", "https://teams.live.com/"); + pReq->AddHeader("ms-ic3-product", "tfl"); + pReq->AddHeader("ms-ic3-additional-product", "Sfl"); + break; + + case HOST_TEAMS: + case HOST_TEAMS_API: + if (!pReq->FindHeader("Authorization")) + pReq->AddHeader("Authorization", "Bearer " + m_szAccessToken); + pReq->AddHeader("Accept", "application/json"); + pReq->AddHeader("ms-ic3-product", "tfl"); + pReq->AddHeader("ms-ic3-additional-product", "Sfl"); break; case HOST_CHATS: diff --git a/protocols/Teams/src/teams_proto.h b/protocols/Teams/src/teams_proto.h index be53411952..c5e072ad22 100644 --- a/protocols/Teams/src/teams_proto.h +++ b/protocols/Teams/src/teams_proto.h @@ -187,7 +187,7 @@ public: void OnASMObjectUploaded(MHttpResponse *response, AsyncHttpRequest *pRequest); void LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest *pRequest); - void LoadContactList(MHttpResponse *response, AsyncHttpRequest *pRequest); + void OnGotContactsInfo(MHttpResponse *response, AsyncHttpRequest *pRequest); void OnBlockContact(MHttpResponse *response, AsyncHttpRequest *pRequest); void OnUnblockContact(MHttpResponse *response, AsyncHttpRequest *pRequest); @@ -215,11 +215,6 @@ private: LIST<void> m_PopupClasses; OBJLIST<COwnMessage> m_OutMessages; - // locks - mir_cs m_lckOutMessagesList; - mir_cs messageSyncLock; - mir_cs m_StatusLock; - // avatars void SetAvatarUrl(MCONTACT hContact, const CMStringW &tszUrl); bool ReceiveAvatar(MCONTACT hContact); @@ -231,23 +226,31 @@ private: INT_PTR __cdecl SvcGetMyAvatar(WPARAM, LPARAM); INT_PTR __cdecl SvcSetMyAvatar(WPARAM, LPARAM); - // menus - static HGENMENU ContactMenuItems[CMI_MAX]; - int OnPrebuildContactMenu(WPARAM hContact, LPARAM); - static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam); + // chats + void InitGroupChatModule(); - // options - int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam); + int __cdecl OnGroupChatEventHook(WPARAM, LPARAM lParam); + int __cdecl OnGroupChatMenuHook(WPARAM, LPARAM lParam); + INT_PTR __cdecl OnJoinChatRoom(WPARAM hContact, LPARAM); + INT_PTR __cdecl OnLeaveChatRoom(WPARAM hContact, LPARAM); - // profile - void UpdateProfileDisplayName(const JSONNode &root, MCONTACT hContact = NULL); - void UpdateProfileGender(const JSONNode &root, MCONTACT hContact = NULL); - void UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact = NULL); - void UpdateProfileCountry(const JSONNode &node, MCONTACT hContact = NULL); - void UpdateProfileEmails(const JSONNode &root, MCONTACT hContact = NULL); - void UpdateProfileAvatar(const JSONNode &root, MCONTACT hContact = NULL); + SESSION_INFO *StartChatRoom(const wchar_t *tid, const wchar_t *tname, const char *pszVersion = nullptr); + + bool OnChatEvent(const JSONNode &node); + wchar_t *GetChatContactNick(SESSION_INFO *si, const wchar_t *id, const wchar_t *name = nullptr, bool *isQualified = nullptr); + + bool AddChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *role, bool isChange = false); + void RemoveChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *initiator = L""); + void SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage); + + void KickChatUser(const char *chatId, const char *userId); + + void SetChatStatus(MCONTACT hContact, int iStatus); + + bool ParseMessage(const JSONNode &node, DB::EventInfo &dbei); // contacts + void RefreshContactsInfo(); void SetContactStatus(MCONTACT hContact, uint16_t status); MCONTACT FindContact(const char *skypeId); @@ -264,8 +267,14 @@ private: INT_PTR __cdecl SvcOfflineFile(WPARAM, LPARAM); + // menus + static HGENMENU ContactMenuItems[CMI_MAX]; + int OnPrebuildContactMenu(WPARAM hContact, LPARAM); + static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam); + // messages std::map<ULONGLONG, HANDLE> m_mpOutMessagesIds; + mir_cs m_lckOutMessagesList; int SendServerMsg(MCONTACT hContact, const char *szMessage, int64_t iMessageId = 0); @@ -274,28 +283,16 @@ private: void ProcessContactRecv(MCONTACT hContact, const char *szContent, DB::EventInfo &dbei); void ProcessFileRecv(MCONTACT hContact, const char *szContent, DB::EventInfo &dbei); - // chats - void InitGroupChatModule(); - - int __cdecl OnGroupChatEventHook(WPARAM, LPARAM lParam); - int __cdecl OnGroupChatMenuHook(WPARAM, LPARAM lParam); - INT_PTR __cdecl OnJoinChatRoom(WPARAM hContact, LPARAM); - INT_PTR __cdecl OnLeaveChatRoom(WPARAM hContact, LPARAM); - - SESSION_INFO* StartChatRoom(const wchar_t *tid, const wchar_t *tname, const char *pszVersion = nullptr); - - bool OnChatEvent(const JSONNode &node); - wchar_t* GetChatContactNick(SESSION_INFO *si, const wchar_t *id, const wchar_t *name = nullptr, bool *isQualified = nullptr); - - bool AddChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *role, bool isChange = false); - void RemoveChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *initiator = L""); - void SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage); - - void KickChatUser(const char *chatId, const char *userId); - - void SetChatStatus(MCONTACT hContact, int iStatus); + // options + int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam); - bool ParseMessage(const JSONNode &node, DB::EventInfo &dbei); + // profile + void UpdateProfileDisplayName(const JSONNode &root, MCONTACT hContact = NULL); + void UpdateProfileGender(const JSONNode &root, MCONTACT hContact = NULL); + void UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact = NULL); + void UpdateProfileCountry(const JSONNode &node, MCONTACT hContact = NULL); + void UpdateProfileEmails(const JSONNode &root, MCONTACT hContact = NULL); + void UpdateProfileAvatar(const JSONNode &root, MCONTACT hContact = NULL); // server requests void GetProfileInfo(MCONTACT hContact); diff --git a/protocols/Teams/src/teams_server.cpp b/protocols/Teams/src/teams_server.cpp index d7e029af08..b92f211000 100644 --- a/protocols/Teams/src/teams_server.cpp +++ b/protocols/Teams/src/teams_server.cpp @@ -29,7 +29,7 @@ void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest CreateContactSubscription(); ReceiveAvatar(0); - PushRequest(new AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/contacts", &CTeamsProto::LoadContactList)); + RefreshContactsInfo(); PushRequest(new SyncConversations()); JSONNode root = JSONNode::parse(response->body); diff --git a/protocols/Teams/src/teams_trouter.cpp b/protocols/Teams/src/teams_trouter.cpp index 5d8ac4a00d..7e9240dc7f 100644 --- a/protocols/Teams/src/teams_trouter.cpp +++ b/protocols/Teams/src/teams_trouter.cpp @@ -181,7 +181,7 @@ void CTeamsProto::TRouterRegister() { TRouterRegister("NextGenCalling", "DesktopNgc_2.3:SkypeNgc", m_szTrouterSurl + "NGCallManagerWin"); TRouterRegister("SkypeSpacesWeb", "SkypeSpacesWeb_2.3", m_szTrouterSurl + "SkypeSpacesWeb"); - TRouterRegister("TeamsCDLWebWorker", "TeamsCDLWebWorker_1.9", m_szTrouterSurl); + TRouterRegister("TeamsCDLWebWorker", "TeamsCDLWebWorker_2.3", m_szTrouterSurl); } void CTeamsProto::TRouterRegister(const char *pszAppId, const char *pszKey, const char *pszPath) |