From db76af0b9b46bd89b685375e4c32b471d7f6713a Mon Sep 17 00:00:00 2001 From: Piotr Piastucki Date: Sun, 17 May 2015 11:02:00 +0000 Subject: - Forgot to save hotAuthToken which prevented login to Hotmail inbox after restart and relogin. You need to delete authTokenExpireTime in DB in order to get new token or wait 24h - Cached netId in MyOptions for faster access git-svn-id: http://svn.miranda-ng.org/main/trunk@13662 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_auth.cpp | 21 +++++++++++++-------- protocols/MSN/src/msn_commands.cpp | 4 ++-- protocols/MSN/src/msn_contact.cpp | 2 +- protocols/MSN/src/msn_global.h | 1 + protocols/MSN/src/msn_lists.cpp | 2 +- protocols/MSN/src/msn_misc.cpp | 6 +++--- protocols/MSN/src/msn_opts.cpp | 12 +++++++----- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 43ad0ee348..37167b7279 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -203,6 +203,7 @@ int CMsnProto::MSN_GetPassportAuth(void) ezxml_t node = ezxml_get(tokr, "wst:RequestedSecurityToken", 0, "EncryptedData", -1); free(hotAuthToken); hotAuthToken = ezxml_toxml(node, 0); + setString("hotAuthToken", hotAuthToken); node = ezxml_get(tokr, "wst:RequestedProofToken", 0, "wst:BinarySecret", -1); replaceStr(hotSecretToken, ezxml_txt(node)); @@ -681,6 +682,11 @@ void CMsnProto::LoadAuthTokensDB(void) replaceStr(hotSecretToken, dbv.pszVal); db_free(&dbv); } + if (getString("hotAuthToken", &dbv) == 0) { + free(hotAuthToken); + hotAuthToken = strdup(dbv.pszVal); + db_free(&dbv); + } } void CMsnProto::SaveAuthTokensDB(void) @@ -826,11 +832,8 @@ int CMsnProto::MSN_AuthOAuth(void) /* SkyLogin succeeded, request required tokens */ if (RefreshOAuth(pRefreshToken, "service::ssl.live.com::MBI_SSL", szToken)) { replaceStr(authSSLToken, szToken); - if (RefreshOAuth(pRefreshToken, "service::contacts.msn.com::MBI_SSL", szToken)) { - replaceStr(authContactToken, szToken); - replaceStr(authUser, MyOptions.szEmail); - authMethod=retVal=1; - } + replaceStr(authUser, MyOptions.szEmail); + authMethod=retVal=1; } } @@ -863,7 +866,6 @@ int CMsnProto::MSN_AuthOAuth(void) UrlDecode(pMappingContainer); replaceStr(authUIC, pMappingContainer); replaceStr(authUser, MyOptions.szEmail); - MSN_GetPassportAuth(); authMethod = retVal = 2; } else retVal = 0; } else retVal = 0; @@ -885,7 +887,10 @@ int CMsnProto::MSN_AuthOAuth(void) if (nlhrReply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } else hHttpsConnection = NULL; - if (retVal<=0) authTokenExpiretime=0; else SaveAuthTokensDB(); + if (retVal<=0) authTokenExpiretime=0; else { + MSN_GetPassportAuth(); + SaveAuthTokensDB(); + } return retVal; } @@ -900,7 +905,7 @@ const char *CMsnProto::GetMyUsername(int netId) if (netId == NETID_SKYPE) { - if (GetMyNetID()==NETID_MSN) + if (MyOptions.netId==NETID_MSN) { if (db_get_static(NULL, m_szModuleName, "SkypePartner", szPartner, sizeof(szPartner)) == 0) return szPartner; diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index c325a7617c..cc6591fa13 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -1205,7 +1205,7 @@ LBL_InvalidCommand: { msnLoggedIn = true; isConnectSuccess = true; - emailEnabled = GetMyNetID()==NETID_MSN; // Let's assume it? + emailEnabled = MyOptions.netId==NETID_MSN; // Let's assume it? MSN_SetServerStatus(m_iStatus); MSN_EnableMenuItems(true); // Fork refreshing and populating contact list to the background @@ -1379,7 +1379,7 @@ LBL_InvalidCommand: char* msgBody = (char*)buf.surelyRead(atol(data.strMsgBytes)); if (strcmp(data.typeId, "CON")) break; - if (GetMyNetID()!=NETID_SKYPE) { + if (MyOptions.netId!=NETID_SKYPE) { /* MSN account login */ switch (MSN_AuthOAuth()) diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index 9d2371ce3a..6743aa8e74 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -252,7 +252,7 @@ bool CMsnProto::MSN_RefreshContactList(void) Lists_Wipe(); Lists_Populate(); - if (GetMyNetID() != NETID_SKYPE) + if (MyOptions.netId != NETID_SKYPE) { // Get your own profile info if (!MSN_SharingFindMembership()) return false; diff --git a/protocols/MSN/src/msn_global.h b/protocols/MSN/src/msn_global.h index f2b4074390..88e600038e 100644 --- a/protocols/MSN/src/msn_global.h +++ b/protocols/MSN/src/msn_global.h @@ -790,6 +790,7 @@ typedef struct _tag_MYOPTIONS bool ManageServer; char szEmail[MSN_MAX_EMAIL_LEN]; + int netId; char szMachineGuid[MSN_GUID_LEN]; char szMachineGuidP2P[MSN_GUID_LEN]; } diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 0e629a0006..ad94802bb7 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -327,7 +327,7 @@ void CMsnProto::MSN_CreateContList(void) if (msnP24Ver > 1) msnNsThread->sendPacketPayload("PUT", "MSGR\\SUBSCRIPTIONS", "%sABCH", - GetMyNetID()==NETID_MSN?"Hotmail":""); + MyOptions.netId==NETID_MSN?"Hotmail":""); mir_free(used); } diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 1d57af93b3..80607de098 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -506,7 +506,7 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha "From: %d:%s;epid=%s\r\n\r\n" "Reliability: 1.0\r\n\r\n%s", netId, email, - netId == NETID_SKYPE?netId:proto->GetMyNetID(), proto->GetMyUsername(netId), proto->MyOptions.szMachineGuid, + netId == NETID_SKYPE?netId:proto->MyOptions.netId, proto->GetMyUsername(netId), proto->MyOptions.szMachineGuid, parMsg); /* @@ -831,8 +831,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", - GetMyNetID(), MyOptions.szEmail, - GetMyNetID(), MyOptions.szEmail, + MyOptions.netId, MyOptions.szEmail, + MyOptions.netId, MyOptions.szEmail, MyOptions.szMachineGuid, sz, szMsg); diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 7f814dad6c..6b992dcb2f 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -662,18 +662,20 @@ INT_PTR CMsnProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) void CMsnProto::LoadOptions(void) { - int bNoWlid; memset(&MyOptions, 0, sizeof(MyOptions)); //Popup Options MyOptions.ManageServer = getByte("ManageServer", TRUE) != 0; MyOptions.ShowErrorsAsPopups = getByte("ShowErrorsAsPopups", TRUE) != 0; MyOptions.SlowSend = getByte("SlowSend", FALSE) != 0; - if ((bNoWlid=db_get_static(NULL, m_szModuleName, "wlid", MyOptions.szEmail, sizeof(MyOptions.szEmail))) && - db_get_static(NULL, m_szModuleName, "e-mail", MyOptions.szEmail, sizeof(MyOptions.szEmail))) - MyOptions.szEmail[0] = 0; - else if (bNoWlid) setString("wlid", MyOptions.szEmail); + if (db_get_static(NULL, m_szModuleName, "wlid", MyOptions.szEmail, sizeof(MyOptions.szEmail))) + { + if (db_get_static(NULL, m_szModuleName, "e-mail", MyOptions.szEmail, sizeof(MyOptions.szEmail))) + MyOptions.szEmail[0] = 0; + else setString("wlid", MyOptions.szEmail); + } _strlwr(MyOptions.szEmail); + MyOptions.netId = getDword("netId", GetMyNetID()); if (db_get_static(NULL, m_szModuleName, "MachineGuid", MyOptions.szMachineGuid, sizeof(MyOptions.szMachineGuid))) { char* uuid = getNewUuid(); -- cgit v1.2.3