summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-03-31 12:46:57 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-03-31 12:46:57 +0300
commited709ad17833b630a02636295fd0939a193aa2cc (patch)
tree266438590ab6ddd6c6342cd21171e3c4a6238b95
parent4747d2ed93f4f916c72d29a8dcd35425fcfea880 (diff)
Teams: we don't need to enter login & password, since the authorization is handled by a browser
-rw-r--r--protocols/Teams/res/Resource.rc23
-rw-r--r--protocols/Teams/src/resource.h4
-rw-r--r--protocols/Teams/src/teams_endpoint.cpp11
-rw-r--r--protocols/Teams/src/teams_http.cpp6
-rw-r--r--protocols/Teams/src/teams_login.cpp5
-rw-r--r--protocols/Teams/src/teams_options.cpp27
6 files changed, 25 insertions, 51 deletions
diff --git a/protocols/Teams/res/Resource.rc b/protocols/Teams/res/Resource.rc
index 5aba8192d5..152ffe592c 100644
--- a/protocols/Teams/res/Resource.rc
+++ b/protocols/Teams/res/Resource.rc
@@ -76,11 +76,9 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Login:",IDC_STATIC,0,2,58,12
- EDITTEXT IDC_LOGIN,60,0,124,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,0,18,58,12
- EDITTEXT IDC_PASSWORD,60,16,124,12,ES_PASSWORD | ES_AUTOHSCROLL
- LTEXT "Default group:",IDC_STATIC,0,34,58,12
- EDITTEXT IDC_GROUP,60,32,124,12,ES_AUTOHSCROLL
+ 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
END
IDD_OPTIONS_MAIN DIALOGEX 0, 0, 310, 149
@@ -88,13 +86,11 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Account",IDC_STATIC,7,7,296,63
+ GROUPBOX "Account",IDC_STATIC,7,7,296,45
LTEXT "Login:",IDC_STATIC,13,19,152,11
- EDITTEXT IDC_LOGIN,178,17,117,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,13,35,152,8
- EDITTEXT IDC_PASSWORD,178,33,117,12,ES_PASSWORD | ES_AUTOHSCROLL
- LTEXT "Default group:",IDC_STATIC,13,51,152,12
- EDITTEXT IDC_GROUP,178,49,117,12,ES_AUTOHSCROLL
+ 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
END
@@ -127,6 +123,11 @@ BEGIN
0
END
+IDD_ACCOUNT_MANAGER AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English (Neutral) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Teams/src/resource.h b/protocols/Teams/src/resource.h
index 5ea05c18d7..968131a274 100644
--- a/protocols/Teams/src/resource.h
+++ b/protocols/Teams/src/resource.h
@@ -1,10 +1,9 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by W:\miranda-ng\protocols\SkypeWeb\res\resource.rc
+// Used by W:\miranda-ng\protocols\Teams\res\resource.rc
//
#define IDI_TEAMS 100
#define IDC_LOGIN 101
-#define IDC_PASSWORD 102
#define IDD_ACCOUNT_MANAGER 103
#define IDD_OPTIONS_MAIN 104
#define IDD_MOOD 105
@@ -25,7 +24,6 @@
#define IDC_CLIST 1030
#define IDC_TITLE 1031
#define IDC_CONTACT 1032
-#define IDC_PLACE 1034
#define IDC_USEHOST 1035
#define IDC_BBCODES 1036
#define IDC_MOOD_COMBO 1037
diff --git a/protocols/Teams/src/teams_endpoint.cpp b/protocols/Teams/src/teams_endpoint.cpp
index 047e41c5dd..39b6958abb 100644
--- a/protocols/Teams/src/teams_endpoint.cpp
+++ b/protocols/Teams/src/teams_endpoint.cpp
@@ -29,6 +29,7 @@ void CTeamsProto::ProcessTimer()
void CTeamsProto::SendCreateEndpoint()
{
auto *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints", &CTeamsProto::OnEndpointCreated);
+ pReq->flags |= NLHRF_REDIRECT;
pReq->m_szParam = "{\"endpointFeatures\":\"Agent,Presence2015,MessageProperties,CustomUserProperties,Casts,ModernBots,AutoIdleForWebApi,secureThreads,notificationStream,InviteFree,SupportsReadReceipts,ued\"}";
pReq->AddHeader("Origin", "https://web.skype.com");
pReq->AddHeader("Referer", "https://web.skype.com/");
@@ -54,16 +55,6 @@ void CTeamsProto::OnEndpointCreated(MHttpResponse *response, AsyncHttpRequest*)
case 201: // okay, endpoint created
break;
- case 301:
- case 302: // redirect to the closest data center
- if (auto *hdr = response->FindHeader("Location")) {
- CMStringA szUrl(hdr+8);
- int iEnd = szUrl.Find('/');
- // g_plugin.szDefaultServer = (iEnd != -1) ? szUrl.Left(iEnd) : szUrl;
- }
- SendCreateEndpoint();
- return;
-
case 401: // unauthorized
default:
delSetting("TokenExpiresIn");
diff --git a/protocols/Teams/src/teams_http.cpp b/protocols/Teams/src/teams_http.cpp
index e32ae4c3cb..18e3067119 100644
--- a/protocols/Teams/src/teams_http.cpp
+++ b/protocols/Teams/src/teams_http.cpp
@@ -129,6 +129,12 @@ MHttpResponse* CTeamsProto::DoSend(AsyncHttpRequest *pReq)
pReq->AddHeader("Accept", "application/json");
break;
+ case HOST_LOGIN:
+ #ifndef _DEBUG
+ pReq->flags |= NLHRF_NODUMP;
+ #endif
+ break;
+
case HOST_DEFAULT:
if (m_szToken)
pReq->AddRegister(this);
diff --git a/protocols/Teams/src/teams_login.cpp b/protocols/Teams/src/teams_login.cpp
index 515d84fa98..9e4f2a966a 100644
--- a/protocols/Teams/src/teams_login.cpp
+++ b/protocols/Teams/src/teams_login.cpp
@@ -154,8 +154,9 @@ void CTeamsProto::OnReceiveSkypeToken(MHttpResponse *response, AsyncHttpRequest
return;
}
- auto &root = reply.data();
- m_szSkypeToken = root["skypeToken"]["skypetoken"].as_mstring();
+ auto &token = reply.data()["skypeToken"];
+ m_szSkypeToken = token["skypetoken"].as_mstring();
+ setWString(DBKEY_ID, token["skypeid"].as_mstring());
LoggedIn();
}
diff --git a/protocols/Teams/src/teams_options.cpp b/protocols/Teams/src/teams_options.cpp
index 6191f15a41..040583ad85 100644
--- a/protocols/Teams/src/teams_options.cpp
+++ b/protocols/Teams/src/teams_options.cpp
@@ -19,61 +19,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class COptionsMainDlg : public CTeamsDlgBase
{
- CCtrlEdit m_login, m_password, m_group, m_place;
+ CCtrlEdit m_login, m_group;
CCtrlCheck m_autosync, m_usehostname, m_usebb;
- CCtrlHyperlink m_link;
public:
COptionsMainDlg(CTeamsProto *proto, int idDialog) :
CTeamsDlgBase(proto, idDialog),
m_login(this, IDC_LOGIN),
- m_password(this, IDC_PASSWORD),
m_group(this, IDC_GROUP),
- m_place(this, IDC_PLACE),
m_autosync(this, IDC_AUTOSYNC),
m_usehostname(this, IDC_USEHOST),
- m_usebb(this, IDC_BBCODES),
- m_link(this, IDC_CHANGEPASS, "https://login.skype.com/recovery/password-change") // TODO : ...?username=%username%
+ m_usebb(this, IDC_BBCODES)
{
CreateLink(m_group, proto->m_wstrCListGroup);
CreateLink(m_autosync, proto->m_bAutoHistorySync);
- CreateLink(m_place, proto->m_wstrPlace);
CreateLink(m_usehostname, proto->m_bUseHostnameAsPlace);
CreateLink(m_usebb, proto->m_bUseBBCodes);
- m_usehostname.OnChange = Callback(this, &COptionsMainDlg::OnUsehostnameCheck);
}
bool OnInitDialog() override
{
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);
- m_password.SendMsg(EM_LIMITTEXT, 128, 0);
m_group.SendMsg(EM_LIMITTEXT, 64, 0);
return true;
}
bool OnApply() override
{
- ptrA szNewSkypename(m_login.GetTextA()),
- 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(DBKEY_ID, szNewSkypename);
- m_proto->setString("Password", szNewPassword);
ptrW group(m_group.GetText());
if (mir_wstrlen(group) > 0 && !Clist_GroupExists(group))
Clist_GroupCreate(0, group);
return true;
}
-
- void OnUsehostnameCheck(CCtrlCheck *)
- {
- m_place.Enable(!m_usehostname.GetState());
- }
};
/////////////////////////////////////////////////////////////////////////////////