summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Teams/res/Resource.rc2
-rw-r--r--protocols/Teams/src/resource.h5
-rw-r--r--protocols/Teams/src/teams_login.cpp8
-rw-r--r--protocols/Teams/src/teams_options.cpp19
-rw-r--r--protocols/Teams/src/teams_proto.h1
5 files changed, 28 insertions, 7 deletions
diff --git a/protocols/Teams/res/Resource.rc b/protocols/Teams/res/Resource.rc
index b143a522b6..25c910f1d2 100644
--- a/protocols/Teams/res/Resource.rc
+++ b/protocols/Teams/res/Resource.rc
@@ -79,6 +79,7 @@ BEGIN
EDITTEXT IDC_LOGIN,60,0,124,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Default group:",IDC_STATIC,0,16,58,12
EDITTEXT IDC_GROUP,60,14,124,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Logout",IDC_LOGOUT,130,33,50,14
END
IDD_OPTIONS_MAIN DIALOGEX 0, 0, 310, 149
@@ -91,6 +92,7 @@ BEGIN
EDITTEXT IDC_LOGIN,178,17,117,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Default group:",IDC_STATIC,13,34,152,12
EDITTEXT IDC_GROUP,178,32,117,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Logout",IDC_LOGOUT,253,56,50,14
END
diff --git a/protocols/Teams/src/resource.h b/protocols/Teams/src/resource.h
index 968131a274..ea9044c6da 100644
--- a/protocols/Teams/src/resource.h
+++ b/protocols/Teams/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by W:\miranda-ng\protocols\Teams\res\resource.rc
+// Used by W:\miranda-ng\protocols\Teams\res\Resource.rc
//
#define IDI_TEAMS 100
#define IDC_LOGIN 101
@@ -30,6 +30,7 @@
#define IDC_CHANGEPASS 1038
#define IDC_MOOD_EMOJI 1039
#define IDC_MOOD_TEXT 1041
+#define IDC_LOGOUT 1042
// Next default values for new objects
//
@@ -37,7 +38,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 126
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1042
+#define _APS_NEXT_CONTROL_VALUE 1044
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Teams/src/teams_login.cpp b/protocols/Teams/src/teams_login.cpp
index b3c800d13a..4dd815a0d1 100644
--- a/protocols/Teams/src/teams_login.cpp
+++ b/protocols/Teams/src/teams_login.cpp
@@ -61,7 +61,7 @@ void CTeamsProto::OnReceiveDevicePoll(MHttpResponse *response, AsyncHttpRequest
m_szDeviceCode.Empty();
auto &root = reply.data();
- setWString("RefreshToken", root["refresh_token"].as_mstring());
+ setWString(DBKEY_RTOKEN, root["refresh_token"].as_mstring());
OauthRefreshServices();
}
@@ -169,7 +169,7 @@ void CTeamsProto::OnRefreshAccessToken(MHttpResponse *response, AsyncHttpRequest
auto &root = reply.data();
m_szAccessToken = root["access_token"].as_mstring();
- setWString("RefreshToken", root["refresh_token"].as_mstring());
+ setWString(DBKEY_RTOKEN, root["refresh_token"].as_mstring());
}
void CTeamsProto::OnRefreshSkypeToken(MHttpResponse *response, AsyncHttpRequest *)
@@ -204,7 +204,7 @@ void CTeamsProto::RefreshToken(const char *pszScope, AsyncHttpRequest::MTHttpReq
{
auto *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_LOGIN, "/" TEAMS_PERSONAL_TENANT_ID "/oauth2/v2.0/token", pFunc);
pReq << CHAR_PARAM("scope", pszScope) << CHAR_PARAM("client_id", TEAMS_CLIENT_ID)
- << CHAR_PARAM("grant_type", "refresh_token") << CHAR_PARAM("refresh_token", getMStringA("RefreshToken"));
+ << CHAR_PARAM("grant_type", "refresh_token") << CHAR_PARAM("refresh_token", getMStringA(DBKEY_RTOKEN));
PushRequest(pReq);
}
@@ -228,7 +228,7 @@ void CTeamsProto::Login()
StartQueue();
// if refresh token doesn't exist, perform a device code authentication
- m_szAccessToken = getMStringA("RefreshToken");
+ m_szAccessToken = getMStringA(DBKEY_RTOKEN);
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);
diff --git a/protocols/Teams/src/teams_options.cpp b/protocols/Teams/src/teams_options.cpp
index 693af22fb1..4405939c47 100644
--- a/protocols/Teams/src/teams_options.cpp
+++ b/protocols/Teams/src/teams_options.cpp
@@ -21,6 +21,7 @@ class COptionsMainDlg : public CTeamsDlgBase
{
CCtrlEdit m_login, m_group;
CCtrlCheck m_autosync, m_usehostname, m_usebb;
+ CCtrlButton btnLogout;
public:
COptionsMainDlg(CTeamsProto *proto, int idDialog) :
@@ -29,16 +30,22 @@ public:
m_group(this, IDC_GROUP),
m_autosync(this, IDC_AUTOSYNC),
m_usehostname(this, IDC_USEHOST),
- m_usebb(this, IDC_BBCODES)
+ m_usebb(this, IDC_BBCODES),
+ btnLogout(this, IDC_LOGOUT)
{
CreateLink(m_group, proto->m_wstrCListGroup);
CreateLink(m_autosync, proto->m_bAutoHistorySync);
CreateLink(m_usehostname, proto->m_bUseHostnameAsPlace);
CreateLink(m_usebb, proto->m_bUseBBCodes);
+
+ btnLogout.OnClick = Callback(this, &COptionsMainDlg::onClick_Logout);
}
bool OnInitDialog() override
{
+ if (m_proto->getMStringA(DBKEY_RTOKEN).IsEmpty())
+ btnLogout.Disable();
+
m_login.SetTextA(ptrA(m_proto->getStringA(DBKEY_ID)));
m_group.SendMsg(EM_LIMITTEXT, 64, 0);
return true;
@@ -51,6 +58,16 @@ public:
Clist_GroupCreate(0, group);
return true;
}
+
+ void onClick_Logout(CCtrlButton *)
+ {
+ m_proto->delSetting(DBKEY_RTOKEN);
+
+ if (m_proto->IsOnline())
+ m_proto->SetStatus(ID_STATUS_OFFLINE);
+
+ btnLogout.Disable();
+ }
};
/////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Teams/src/teams_proto.h b/protocols/Teams/src/teams_proto.h
index c14892a0c1..939f6db0a0 100644
--- a/protocols/Teams/src/teams_proto.h
+++ b/protocols/Teams/src/teams_proto.h
@@ -8,6 +8,7 @@
#define DBKEY_ID "id"
#define DBKEY_GROUP "DefaultGroup"
+#define DBKEY_RTOKEN "RefreshToken"
struct COwnMessage
{