diff options
-rw-r--r-- | protocols/ICQ-WIM/res/resources.rc | 21 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/options.cpp | 63 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 5 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 6 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/resource.h | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/version.h | 2 |
7 files changed, 92 insertions, 9 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc index 3e8df0aa70..03271bb855 100644 --- a/protocols/ICQ-WIM/res/resources.rc +++ b/protocols/ICQ-WIM/res/resources.rc @@ -126,6 +126,18 @@ BEGIN EDITTEXT IDC_LASTSEEN,74,32,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP END +IDD_LOGINPW DIALOGEX 0, 0, 157, 70 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Enter ICQ Password" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Enter a password:",IDC_STATIC,7,7,142,8 + EDITTEXT IDC_PASSWORD,7,16,142,14,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Remember this session password",IDC_SAVEPASS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,38,142,10 + DEFPUSHBUTTON "OK",IDOK,47,53,50,14 + PUSHBUTTON "Cancel",IDCANCEL,102,53,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -164,6 +176,10 @@ BEGIN IDD_INFO_ICQ, DIALOG BEGIN END + + IDD_LOGINPW, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED @@ -203,6 +219,11 @@ BEGIN 0 END +IDD_LOGINPW AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp index 18bb8531cc..55428358d7 100644 --- a/protocols/ICQ-WIM/src/options.cpp +++ b/protocols/ICQ-WIM/src/options.cpp @@ -20,6 +20,55 @@ #include "stdafx.h" +class CIcqEnterLoginDlg : public CProtoDlgBase<CIcqProto> +{ + CCtrlEdit edtPass; + CCtrlCheck chkSave; + +public: + CIcqEnterLoginDlg(CIcqProto *ppro) : + CProtoDlgBase<CIcqProto>(ppro, IDD_LOGINPW), + edtPass(this, IDC_PASSWORD), + chkSave(this, IDC_SAVEPASS) + { + } + + bool OnInitDialog() override + { + chkSave.SetState(m_proto->m_bRememberPwd); + Window_SetIcon_IcoLib(m_hwnd, m_proto->m_hProtoIcon); + return true; + } + + bool OnApply() override + { + m_proto->setByte("RememberPass", m_proto->m_bRememberPwd = chkSave.GetState()); + m_proto->m_szPassword = ptrA(edtPass.GetTextU()); + EndModal(true); + return true; + } +}; + +bool CIcqProto::RetrievePassword() +{ + // if we registered via phone (i.e., server holds the password), we don't need to enter it + if (getByte(DB_KEY_PHONEREG)) + return true; + + if (!m_szPassword.IsEmpty() && m_bRememberPwd) + return true; + + m_szPassword = getMStringA("Password"); + if (!m_szPassword.IsEmpty()) { + m_bRememberPwd = true; + return true; + } + + return CIcqEnterLoginDlg(this).DoModal() == IDOK; +} + +///////////////////////////////////////////////////////////////////////////////////////// + struct CIcqRegistrationDlg : public CProtoDlgBase<CIcqProto> { CMStringA szTrans, szMsisdn; @@ -160,7 +209,7 @@ class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto> CCtrlEdit edtUin, edtPassword; CCtrlCheck chkHideChats, chkTrayIcon, chkLaunchMailbox, chkShowErrorPopups; CCtrlButton btnCreate; - CMStringW wszOldPass; + CMStringA wszOldPass; public: CIcqOptionsDlg(CIcqProto *ppro, int iDlgID, bool bFullDlg) : @@ -176,7 +225,6 @@ public: btnCreate.OnClick = Callback(this, &CIcqOptionsDlg::onClick_Register); CreateLink(edtUin, ppro->m_szOwnId); - CreateLink(edtPassword, ppro->m_szPassword); if (bFullDlg) { CreateLink(chkHideChats, ppro->m_bHideGroupchats); CreateLink(chkTrayIcon, ppro->m_bUseTrayIcon); @@ -186,6 +234,7 @@ public: chkTrayIcon.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Tray); } + edtPassword.SetText(Utf2T(ppro->m_szPassword)); wszOldPass = ppro->m_szPassword; } @@ -197,11 +246,19 @@ public: bool OnApply() override { - if (wszOldPass != ptrW(edtPassword.GetText())) { + ptrW wszPass(edtPassword.GetText()); + if (wszOldPass != wszPass) { m_proto->delSetting(DB_KEY_ATOKEN); m_proto->delSetting(DB_KEY_SESSIONKEY); m_proto->delSetting(DB_KEY_PHONEREG); } + + if (mir_wstrlen(wszPass)) { + m_proto->m_szPassword = T2Utf(wszPass).get(); + m_proto->m_bRememberPwd = true; + } + else m_proto->m_bRememberPwd = m_proto->getByte("RememberPass"); + return true; } diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 87dd35189a..15c4c6d4f1 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -38,7 +38,7 @@ static int CompareCache(const IcqCacheItem *p1, const IcqCacheItem *p2) return mir_wstrcmp(p1->m_aimid, p2->m_aimid); } -CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : +CIcqProto::CIcqProto(const char *aProtoName, const wchar_t *aUserName) : PROTO<CIcqProto>(aProtoName, aUserName), m_arHttpQueue(10), m_arOwnIds(1, PtrKeySortT), @@ -50,7 +50,6 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : m_iStatus2(this, "Status2", ID_STATUS_NA), m_iTimeDiff1(this, "TimeDiff1", 0), m_iTimeDiff2(this, "TimeDiff2", 0), - m_szPassword(this, "Password"), m_bHideGroupchats(this, "HideChats", true), m_bUseTrayIcon(this, "UseTrayIcon", false), m_bErrorPopups(this, "ShowErrorPopups", true), @@ -450,7 +449,7 @@ int CIcqProto::SetStatus(int iNewStatus) return 0; } - if (!getByte(DB_KEY_PHONEREG) && mir_wstrlen(m_szPassword) == 0) { + if (!RetrievePassword()) { debugLogA("Thread ended, password is not configured"); ConnectionFailed(LOGINERR_BADUSERID); return 0; diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index fcdded5f6c..15091e3fd3 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -157,6 +157,8 @@ class CIcqProto : public PROTO<CIcqProto> friend struct CIcqRegistrationDlg; friend class CGroupchatInviteDlg; friend class CEditIgnoreListDlg; + friend class CIcqEnterLoginDlg; + friend class CIcqOptionsDlg; friend AsyncHttpRequest* operator <<(AsyncHttpRequest*, const AIMSID&); @@ -170,6 +172,7 @@ class CIcqProto : public PROTO<CIcqProto> void GetPermitDeny(); wchar_t* GetUIN(MCONTACT hContact); void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); + bool RetrievePassword(); void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId = -1); void RetrieveUserInfo(MCONTACT = INVALID_CONTACT_ID); void SetServerStatus(int iNewStatus); @@ -228,6 +231,7 @@ class CIcqProto : public PROTO<CIcqProto> void ProcessTyping(const JSONNode&); IcqConn m_ConnPool[CONN_LAST]; + CMStringA m_szPassword; CMStringA m_szSessionKey; CMStringA m_szAToken; CMStringA m_szRToken; @@ -246,6 +250,7 @@ class CIcqProto : public PROTO<CIcqProto> CMStringA m_szMailBox; bool m_bIgnoreListEmpty = true; + bool m_bRememberPwd = false; // store password in a database //////////////////////////////////////////////////////////////////////////////////////// // group chats @@ -349,7 +354,6 @@ public: ~CIcqProto(); CMOption<wchar_t*> m_szOwnId; // our own aim id - CMOption<wchar_t*> m_szPassword; // password, if present CMOption<BYTE> m_bHideGroupchats; // don't pop up group chat windows on startup CMOption<BYTE> m_bUseTrayIcon; // use tray icon notifications CMOption<BYTE> m_bErrorPopups; // display popups with errors diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h index 72d0870920..9bdf21e844 100644 --- a/protocols/ICQ-WIM/src/resource.h +++ b/protocols/ICQ-WIM/src/resource.h @@ -11,6 +11,7 @@ #define IDI_INBOX 107 #define IDI_MAIL_NOTIFY 108 #define IDD_OPTIONS_ADV 109 +#define IDD_LOGINPW 110 #define IDC_PASSWORD 1001 #define IDC_UIN 1002 #define IDC_UIN2 1003 @@ -25,6 +26,7 @@ #define IDC_NICK 1012 #define IDC_MEMBERSINCE 1013 #define IDC_LASTSEEN 1014 +#define IDC_SAVEPASS 1015 #define IDC_LIST 1016 #define IDC_DIFF1 1017 #define IDC_SPIN1 1018 diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 1672985dc0..d1600d79d2 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -91,7 +91,7 @@ void CIcqProto::CheckPassword() if (m_szAToken.IsEmpty() || m_szSessionKey.IsEmpty()) { auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, "https://api.login.icq.net/auth/clientLogin", &CIcqProto::OnCheckPassword); pReq << CHAR_PARAM("clientName", "Miranda NG") << CHAR_PARAM("clientVersion", mirVer) << CHAR_PARAM("devId", ICQ_APP_ID) - << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << WCHAR_PARAM("s", m_szOwnId) << WCHAR_PARAM("pwd", m_szPassword); + << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << WCHAR_PARAM("s", m_szOwnId) << CHAR_PARAM("pwd", m_szPassword); pReq->flags |= NLHRF_NODUMPSEND; Push(pReq); } diff --git a/protocols/ICQ-WIM/src/version.h b/protocols/ICQ-WIM/src/version.h index bb1e4cc050..a5f369d606 100644 --- a/protocols/ICQ-WIM/src/version.h +++ b/protocols/ICQ-WIM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 95 #define __RELEASE_NUM 11 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include <stdver.h> |