summaryrefslogtreecommitdiff
path: root/protocols/Teams/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Teams/src')
-rw-r--r--protocols/Teams/src/teams_chatrooms.cpp4
-rw-r--r--protocols/Teams/src/teams_contacts.cpp8
-rw-r--r--protocols/Teams/src/teams_endpoint.cpp24
-rw-r--r--protocols/Teams/src/teams_login.cpp11
-rw-r--r--protocols/Teams/src/teams_options.cpp6
-rw-r--r--protocols/Teams/src/teams_proto.cpp3
-rw-r--r--protocols/Teams/src/teams_proto.h12
7 files changed, 17 insertions, 51 deletions
diff --git a/protocols/Teams/src/teams_chatrooms.cpp b/protocols/Teams/src/teams_chatrooms.cpp
index dcb2451911..42c5f269ce 100644
--- a/protocols/Teams/src/teams_chatrooms.cpp
+++ b/protocols/Teams/src/teams_chatrooms.cpp
@@ -200,7 +200,7 @@ int CTeamsProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
INT_PTR CTeamsProto::OnJoinChatRoom(WPARAM hContact, LPARAM)
{
if (hContact) {
- ptrW idT(getWStringA(hContact, SKYPE_SETTINGS_ID));
+ ptrW idT(getWStringA(hContact, DBKEY_ID));
ptrW nameT(getWStringA(hContact, "Nick"));
StartChatRoom(idT, nameT != NULL ? nameT : idT);
}
@@ -213,7 +213,7 @@ INT_PTR CTeamsProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
return 1;
if (hContact && IDYES == MessageBox(nullptr, TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)) {
- ptrW idT(getWStringA(hContact, SKYPE_SETTINGS_ID));
+ ptrW idT(getWStringA(hContact, DBKEY_ID));
auto *si = Chat_Find(idT, m_szModuleName);
Chat_Control(si, SESSION_OFFLINE);
Chat_Terminate(si);
diff --git a/protocols/Teams/src/teams_contacts.cpp b/protocols/Teams/src/teams_contacts.cpp
index fa4577ecfc..b8f94be72d 100644
--- a/protocols/Teams/src/teams_contacts.cpp
+++ b/protocols/Teams/src/teams_contacts.cpp
@@ -34,7 +34,7 @@ void CTeamsProto::SetContactStatus(MCONTACT hContact, uint16_t status)
void CTeamsProto::SetChatStatus(MCONTACT hContact, int iStatus)
{
- ptrW tszChatID(getWStringA(hContact, SKYPE_SETTINGS_ID));
+ ptrW tszChatID(getWStringA(hContact, DBKEY_ID));
if (tszChatID != NULL)
Chat_Control(Chat_Find(tszChatID, m_szModuleName), (iStatus == ID_STATUS_OFFLINE) ? SESSION_OFFLINE : SESSION_ONLINE);
}
@@ -60,7 +60,7 @@ MCONTACT CTeamsProto::GetContactFromAuthEvent(MEVENT hEvent)
MCONTACT CTeamsProto::FindContact(const char *skypeId)
{
for (auto &hContact : AccContacts())
- if (!mir_strcmpi(skypeId, ptrA(getUStringA(hContact, SKYPE_SETTINGS_ID))))
+ if (!mir_strcmpi(skypeId, ptrA(getUStringA(hContact, DBKEY_ID))))
return hContact;
return 0;
@@ -69,7 +69,7 @@ MCONTACT CTeamsProto::FindContact(const char *skypeId)
MCONTACT CTeamsProto::FindContact(const wchar_t *skypeId)
{
for (auto &hContact : AccContacts())
- if (!mir_wstrcmpi(skypeId, getMStringW(hContact, SKYPE_SETTINGS_ID)))
+ if (!mir_wstrcmpi(skypeId, getMStringW(hContact, DBKEY_ID)))
return hContact;
return 0;
@@ -84,7 +84,7 @@ MCONTACT CTeamsProto::AddContact(const char *skypeId, const char *nick, bool isT
hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
- setString(hContact, SKYPE_SETTINGS_ID, skypeId);
+ setString(hContact, DBKEY_ID, skypeId);
setUString(hContact, "Nick", (nick) ? nick : GetSkypeNick(skypeId));
if (m_wstrCListGroup) {
diff --git a/protocols/Teams/src/teams_endpoint.cpp b/protocols/Teams/src/teams_endpoint.cpp
index d0431cd3b2..047e41c5dd 100644
--- a/protocols/Teams/src/teams_endpoint.cpp
+++ b/protocols/Teams/src/teams_endpoint.cpp
@@ -17,30 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-void CTeamsProto::CheckConvert()
-{
- m_szSkypename = getMStringA(SKYPE_SETTINGS_ID);
- if (m_szSkypename.IsEmpty()) {
- m_szSkypename = getMStringA(SKYPE_SETTINGS_LOGIN);
- if (!m_szSkypename.IsEmpty()) { // old settings format, need to update all settings
- m_szSkypename.Insert(0, "8:");
- setString(SKYPE_SETTINGS_ID, m_szSkypename);
-
- for (auto &hContact : AccContacts()) {
- CMStringA id(ptrA(getUStringA(hContact, "Skypename")));
- if (!id.IsEmpty())
- setString(hContact, SKYPE_SETTINGS_ID, (isChatRoom(hContact)) ? "19:" + id : "8:" + id);
-
- ptrW wszNick(getWStringA(hContact, "Nick"));
- if (wszNick == nullptr)
- setUString(hContact, "Nick", id);
-
- delSetting(hContact, "Skypename");
- }
- }
- }
-}
-
void CTeamsProto::ProcessTimer()
{
if (!IsOnline())
diff --git a/protocols/Teams/src/teams_login.cpp b/protocols/Teams/src/teams_login.cpp
index 72324355ac..515d84fa98 100644
--- a/protocols/Teams/src/teams_login.cpp
+++ b/protocols/Teams/src/teams_login.cpp
@@ -220,25 +220,22 @@ void CTeamsProto::OauthRefreshServices()
void CTeamsProto::Login()
{
- CMStringA szLogin(getMStringA("Login")), szPassword(getMStringA("Password"));
- if (szLogin.IsEmpty() || szPassword.IsEmpty()) {
- LoginError();
- return;
- }
-
- // login
+ // set plugin status to connect
int oldStatus = m_iStatus;
m_iStatus = ID_STATUS_CONNECTING;
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ // launch http queue
StartQueue();
+ // if refresh token doesn't exist, perform a device code authentication
m_szAccessToken = getMStringA("RefreshToken");
if (m_szAccessToken.IsEmpty()) {
auto *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_LOGIN, "/common/oauth2/devicecode", &CTeamsProto::OnReceiveDeviceToken);
pReq << CHAR_PARAM("client_id", TEAMS_CLIENT_ID) << CHAR_PARAM("resource", TEAMS_OAUTH_RESOURCE);
PushRequest(pReq);
}
+ // or use a refresh token otherwise
else {
RefreshToken(TEAMS_OAUTH_SCOPE SCOPE_SUFFIX, &CTeamsProto::OnRefreshAccessToken);
OauthRefreshServices();
diff --git a/protocols/Teams/src/teams_options.cpp b/protocols/Teams/src/teams_options.cpp
index e5334a0985..6191f15a41 100644
--- a/protocols/Teams/src/teams_options.cpp
+++ b/protocols/Teams/src/teams_options.cpp
@@ -45,7 +45,7 @@ public:
bool OnInitDialog() override
{
- m_login.SetTextA(ptrA(m_proto->getStringA(SKYPE_SETTINGS_ID)));
+ m_login.SetTextA(ptrA(m_proto->getStringA(DBKEY_ID)));
m_password.SetTextA(pass_ptrA(m_proto->getStringA("Password")));
m_place.Enable(!m_proto->m_bUseHostnameAsPlace);
m_login.SendMsg(EM_LIMITTEXT, 128, 0);
@@ -57,12 +57,12 @@ public:
bool OnApply() override
{
ptrA szNewSkypename(m_login.GetTextA()),
- szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID));
+ szOldSkypename(m_proto->getStringA(DBKEY_ID));
pass_ptrA szNewPassword(m_password.GetTextA()),
szOldPassword(m_proto->getStringA("Password"));
if (mir_strcmpi(szNewSkypename, szOldSkypename) || mir_strcmp(szNewPassword, szOldPassword))
m_proto->delSetting("TokenExpiresIn");
- m_proto->setString(SKYPE_SETTINGS_ID, szNewSkypename);
+ m_proto->setString(DBKEY_ID, szNewSkypename);
m_proto->setString("Password", szNewPassword);
ptrW group(m_group.GetText());
if (mir_wstrlen(group) > 0 && !Clist_GroupExists(group))
diff --git a/protocols/Teams/src/teams_proto.cpp b/protocols/Teams/src/teams_proto.cpp
index c2dabdfc1c..9dfa1baab0 100644
--- a/protocols/Teams/src/teams_proto.cpp
+++ b/protocols/Teams/src/teams_proto.cpp
@@ -9,7 +9,7 @@ CTeamsProto::CTeamsProto(const char *protoName, const wchar_t *userName) :
m_bAutoHistorySync(this, "AutoSync", true),
m_bUseHostnameAsPlace(this, "UseHostName", true),
m_bUseBBCodes(this, "UseBBCodes", true),
- m_wstrCListGroup(this, SKYPE_SETTINGS_GROUP, L"Skype"),
+ m_wstrCListGroup(this, DBKEY_GROUP, L"Skype"),
m_wstrPlace(this, "Place", L""),
m_iMood(this, "Mood", 0),
m_wstrMoodEmoji(this, "MoodEmoji", L""),
@@ -43,7 +43,6 @@ CTeamsProto::CTeamsProto(const char *protoName, const wchar_t *userName) :
g_plugin.addSound("skype_inc_call", L"SkypeWeb", LPGENW("Incoming call"));
g_plugin.addSound("skype_call_canceled", L"SkypeWeb", LPGENW("Incoming call canceled"));
- CheckConvert();
InitGroupChatModule();
}
diff --git a/protocols/Teams/src/teams_proto.h b/protocols/Teams/src/teams_proto.h
index 9066d56079..850aae8808 100644
--- a/protocols/Teams/src/teams_proto.h
+++ b/protocols/Teams/src/teams_proto.h
@@ -1,10 +1,7 @@
#define TEAMS_CLIENT_ID "8ec6bc83-69c8-4392-8f08-b3c986009232"
-#define SKYPE_SETTINGS_ID "SkypeId"
-#define SKYPE_SETTINGS_LOGIN "Skypename"
-#define SKYPE_SETTINGS_USERTYPE "UserType"
-#define SKYPE_SETTINGS_PASSWORD "Password"
-#define SKYPE_SETTINGS_GROUP "DefaultGroup"
+#define DBKEY_ID "id"
+#define DBKEY_GROUP "DefaultGroup"
struct COwnMessage
{
@@ -172,7 +169,7 @@ public:
MCONTACT m_hMyContact;
__forceinline CMStringA getId(MCONTACT hContact) {
- return getMStringA(hContact, SKYPE_SETTINGS_ID);
+ return getMStringA(hContact, DBKEY_ID);
}
void OnSearch(MHttpResponse *response, AsyncHttpRequest *pRequest);
@@ -211,9 +208,6 @@ public:
void OnGetChatInfo(MHttpResponse *response, AsyncHttpRequest *pRequest);
void OnGetChatMembers(MHttpResponse *response, AsyncHttpRequest *pRequest);
- void CheckConvert(void);
- bool CheckOauth(const char *szResponse);
-
void LoadProfile(MHttpResponse *response, AsyncHttpRequest *pRequest);
static INT_PTR __cdecl GlobalParseSkypeUriService(WPARAM, LPARAM lParam);