diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-26 20:45:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-26 20:45:56 +0300 |
commit | c6e113731519bb85e0a79196ad32986e8b077e07 (patch) | |
tree | 551ea901904f0225099a80e5710d8295a7e9a7b2 /protocols/Icq10/src | |
parent | c5ac09f8f9da22213e1471370f54343e12a139ac (diff) |
icq10: options dialog
Diffstat (limited to 'protocols/Icq10/src')
-rw-r--r-- | protocols/Icq10/src/http.cpp | 6 | ||||
-rw-r--r-- | protocols/Icq10/src/options.cpp | 58 | ||||
-rw-r--r-- | protocols/Icq10/src/proto.cpp | 10 | ||||
-rw-r--r-- | protocols/Icq10/src/proto.h | 20 | ||||
-rw-r--r-- | protocols/Icq10/src/resource.h | 147 | ||||
-rw-r--r-- | protocols/Icq10/src/server.cpp | 5 |
6 files changed, 92 insertions, 154 deletions
diff --git a/protocols/Icq10/src/http.cpp b/protocols/Icq10/src/http.cpp index c7a183fa3c..eb2e07646d 100644 --- a/protocols/Icq10/src/http.cpp +++ b/protocols/Icq10/src/http.cpp @@ -27,9 +27,7 @@ void __cdecl CIcqProto::ServerThread(void*) memset(&m_ConnPool, 0, sizeof(m_ConnPool)); m_bTerminated = false; - int uin = getDword("UIN"); - ptrA szPassword(getStringA("Password")); - if (uin == 0 || szPassword == nullptr) { + if (m_dwUin == 0 || mir_strlen(m_szPassword) == 0) { debugLogA("Thread ended, UIN/password are not configured"); ConnectionFailed(LOGINERR_BADUSERID); return; @@ -45,7 +43,7 @@ void __cdecl CIcqProto::ServerThread(void*) 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") << INT_PARAM("s", uin) << CHAR_PARAM("pwd", szPassword); + << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << INT_PARAM("s", m_dwUin) << CHAR_PARAM("pwd", m_szPassword); pReq->flags |= NLHRF_NODUMPSEND; Push(pReq); } diff --git a/protocols/Icq10/src/options.cpp b/protocols/Icq10/src/options.cpp new file mode 100644 index 0000000000..4dc2175a13 --- /dev/null +++ b/protocols/Icq10/src/options.cpp @@ -0,0 +1,58 @@ +// ----------------------------------------------------------------------------- +// ICQ plugin for Miranda NG +// ----------------------------------------------------------------------------- +// Copyright © 2018 Miranda NG team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// ----------------------------------------------------------------------------- + +#include "stdafx.h" + +class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto> +{ + CCtrlEdit edtUin, edtPassword; + +public: + CIcqOptionsDlg(CIcqProto *ppro, int iDlgID, bool bFullDlg) : + CProtoDlgBase<CIcqProto>(ppro, iDlgID), + edtUin(this, IDC_UIN), + edtPassword(this, IDC_PASSWORD) + { + CreateLink(edtUin, ppro->m_dwUin); + CreateLink(edtPassword, ppro->m_szPassword); + } +}; + +INT_PTR CIcqProto::CreateAccMgrUI(WPARAM, LPARAM hwndParent) +{ + CIcqOptionsDlg *pDlg = new CIcqOptionsDlg(this, IDD_OPTIONS_ACCMGR, false); + pDlg->SetParent((HWND)hwndParent); + pDlg->Create(); + return (INT_PTR)pDlg->GetHwnd(); +} + +int CIcqProto::OnOptionsInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = {}; + odp.szTitle.w = m_tszUserName; + odp.flags = ODPF_UNICODE; + odp.szGroup.w = LPGENW("Network"); + + odp.position = 1; +// odp.szTab.w = LPGENW("Account"); + odp.pDialog = new CIcqOptionsDlg(this, IDD_OPTIONS_FULL, true); + g_plugin.addOptions(wParam, &odp); + return 0; +} diff --git a/protocols/Icq10/src/proto.cpp b/protocols/Icq10/src/proto.cpp index 89a9cd8006..e731f2d488 100644 --- a/protocols/Icq10/src/proto.cpp +++ b/protocols/Icq10/src/proto.cpp @@ -38,13 +38,21 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : m_arHttpQueue(10), m_arOwnIds(1), m_arCache(20, NumericKeySortT), - m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)) + m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)), + m_dwUin(this, "UIN", 0), + m_szPassword(this, "Password") { + // services + CreateProtoService(PS_CREATEACCMGRUI, &CIcqProto::CreateAccMgrUI); CreateProtoService(PS_GETAVATARINFO, &CIcqProto::GetAvatarInfo); CreateProtoService(PS_GETMYAVATAR, &CIcqProto::GetAvatar); CreateProtoService(PS_GETAVATARCAPS, &CIcqProto::GetAvatarCaps); CreateProtoService(PS_SETMYAVATAR, &CIcqProto::SetAvatar); + // events + HookProtoEvent(ME_OPT_INITIALISE, &CIcqProto::OnOptionsInit); + + // netlib handle CMStringW descr(FORMAT, TranslateT("%s server connection"), m_tszUserName); NETLIBUSER nlu = {}; diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h index 8bf9cbfb91..9b28adc787 100644 --- a/protocols/Icq10/src/proto.h +++ b/protocols/Icq10/src/proto.h @@ -93,7 +93,7 @@ class CIcqProto : public PROTO<CIcqProto> OBJLIST<IcqOwnMessage> m_arOwnIds; - ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// // http queue mir_cs m_csHttpQueue; @@ -103,7 +103,7 @@ class CIcqProto : public PROTO<CIcqProto> void ExecuteRequest(AsyncHttpRequest*); void Push(MHttpRequest*); - ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// // cache mir_cs m_csCache; @@ -114,7 +114,7 @@ class CIcqProto : public PROTO<CIcqProto> void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen); - ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// // threads HANDLE m_hWorkerThread; @@ -123,15 +123,22 @@ class CIcqProto : public PROTO<CIcqProto> HANDLE m_hPollThread; void __cdecl PollThread(void*); - ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// // services INT_PTR __cdecl GetAvatar(WPARAM, LPARAM); INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); INT_PTR __cdecl SetAvatar(WPARAM, LPARAM); + + INT_PTR __cdecl CreateAccMgrUI(WPARAM, LPARAM); - ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + // events + + int __cdecl OnOptionsInit(WPARAM, LPARAM); + + //////////////////////////////////////////////////////////////////////////////////////// // PROTO_INTERFACE MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override; @@ -178,6 +185,9 @@ class CIcqProto : public PROTO<CIcqProto> public: CIcqProto(const char*, const wchar_t*); ~CIcqProto(); + + CMOption<DWORD> m_dwUin; + CMOption<char*> m_szPassword; }; struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto> diff --git a/protocols/Icq10/src/resource.h b/protocols/Icq10/src/resource.h index ceeaac87fa..f44743d95f 100644 --- a/protocols/Icq10/src/resource.h +++ b/protocols/Icq10/src/resource.h @@ -2,153 +2,18 @@ // Microsoft Visual C++ generated include file. // Used by D:\miranda-ng\protocols\IcqOscarJ\res\resources.rc -#define IDD_ICQACCOUNT 101 -#define IDD_OPT_ICQ 102 -#define IDD_OPT_POPUPS 103 -#define IDC_POPUPS_ENABLED 410 -#define IDC_POPUPS_LOG_ENABLED 411 -#define IDC_POPUPS_SPAM_ENABLED 412 -#define IDC_POPUP_LOG0_TEXTCOLOR 420 -#define IDC_POPUP_LOG1_TEXTCOLOR 421 -#define IDC_POPUP_LOG2_TEXTCOLOR 422 -#define IDC_POPUP_LOG3_TEXTCOLOR 423 -#define IDC_POPUP_SPAM_TEXTCOLOR 425 -#define IDC_POPUP_LOG0_BACKCOLOR 430 -#define IDC_POPUP_LOG1_BACKCOLOR 431 -#define IDC_POPUP_LOG2_BACKCOLOR 432 -#define IDC_POPUP_LOG3_BACKCOLOR 433 -#define IDC_POPUP_SPAM_BACKCOLOR 435 -#define IDC_POPUP_LOG0_TIMEOUT 440 -#define IDC_POPUP_LOG1_TIMEOUT 441 -#define IDC_POPUP_LOG2_TIMEOUT 442 -#define IDC_POPUP_LOG3_TIMEOUT 443 -#define IDC_POPUP_SPAM_TIMEOUT 444 -#define IDC_USEWINCOLORS 450 -#define IDC_USESYSICONS 451 -#define IDC_PREVIEW 455 -#define IDC_SAVEPASS 1004 -#define IDC_RETRXSTATUS 1005 -#define IDC_XTITLE_STATIC 1006 -#define IDC_XMSG_STATIC 1007 -#define IDC_SSL 1008 -#define IDC_MD5LOGIN 1009 -#define IDC_XTITLE 1010 -#define IDC_LEGACY 1010 -#define IDC_KEEPALIVE 1011 -#define IDC_XMSG 1011 -#define IDC_UTFSTATIC 1013 -#define IDC_UTFCODEPAGE 1014 -#define IDC_PW 1015 -#define IDC_TEMPVISIBLE 1015 -#define IDC_REGISTER 1016 -#define IDC_EDITAUTH 1017 -#define IDC_LOGINPW 1018 -#define IDC_INSTRUCTION 1019 -#define IDC_PASSWORD 1020 -#define IDC_SUPTIME 1020 -#define IDC_DCENABLE 1020 -#define IDC_DCPASSIVE 1021 -#define IDC_OLDPASS 1021 -#define IDC_ICQNUM 1022 -#define IDC_USEPOPUPCOLORS 1023 -#define IDC_USEDEFCOLORS 1024 -#define IDC_CLIST 1035 -#define IDC_XSTATUSENABLE 1040 -#define IDC_XSTATUSAUTO 1041 -#define IDC_XSTATUSRESET 1042 -#define IDC_MOODSENABLE 1043 -#define IDC_KILLSPAMBOTS 1045 -#define IDC_EMAIL 1048 -#define IDC_NICK 1053 -#define IDC_GENDER 1060 -#define IDC_CITY 1061 -#define IDC_STATE 1062 -#define IDC_COUNTRY 1063 -#define IDC_COMPANY 1066 -#define IDC_DEPARTMENT 1067 -#define IDC_POSITION 1069 -#define IDC_IP 1094 -#define IDC_UINSTATIC 1122 -#define IDC_UIN 1123 -#define IDC_STATIC11 1154 -#define IDC_STATIC12 1155 -#define IDC_ICQSERVER 1171 -#define IDC_ICQPORT 1172 -#define IDC_VERSION 1179 -#define IDC_FIRSTNAME 1224 -#define IDC_LASTNAME 1225 -#define IDC_REALIP 1230 -#define IDC_RECONNECTREQD 1239 -#define IDC_OFFLINETOENABLE 1240 -#define IDC_PORT 1249 -#define IDC_MIRVER 1251 -#define IDC_ONLINESINCE 1252 -#define IDC_SYSTEMUPTIME 1253 -#define IDC_IDLETIME 1254 -#define IDC_STATUS 1255 -#define IDC_SLOWSEND 1301 -#define IDC_LOGLEVEL 1331 -#define IDC_LEVELDESCR 1332 -#define IDC_NOERRMULTI 1333 -#define IDC_STICQGROUP 1374 -#define IDC_AGERANGE 1410 -#define IDC_MARITALSTATUS 1411 -#define IDC_KEYWORDS 1412 -#define IDC_LANGUAGE 1414 -#define IDC_WORKFIELD 1421 -#define IDC_PASTCAT 1422 -#define IDC_PASTKEY 1423 -#define IDC_INTERESTSCAT 1424 -#define IDC_INTERESTSKEY 1425 -#define IDC_ORGANISATION 1426 -#define IDC_ORGKEYWORDS 1427 -#define IDC_OTHERGROUP 1429 -#define IDC_ONLINEONLY 1430 -#define IDC_HOMEPAGECAT 1431 -#define IDC_HOMEPAGEKEY 1432 -#define IDC_SUMMARYGROUP 1434 -#define IDC_WORKGROUP 1435 -#define IDC_LOCATIONGROUP 1436 -#define IDC_BACKGROUNDGROUP 1437 -#define IDC_NEWUINLINK 1438 -#define IDC_LOOKUPLINK 1439 -#define IDC_RESETSERVER 1472 -#define IDC_UPLOADNOW 1521 -#define IDC_GROUPS 1522 -#define IDC_ALLGROUPS 1526 -#define IDC_VISIBILITY 1527 -#define IDC_IGNORE 1528 -#define IDC_ENABLE 1529 -#define IDC_LOADFROMSERVER 1530 -#define IDC_ADDSERVER 1532 -#define IDC_SAVETOSERVER 1533 -#define IDC_ENABLEAVATARS 1536 -#define IDC_AUTOLOADAVATARS 1537 -#define IDC_STRICTAVATARCHECK 1539 -#define IDC_WEBAWARE 1546 -#define IDC_DCALLOW_ANY 1547 -#define IDC_DCALLOW_CLIST 1548 -#define IDC_DCALLOW_AUTH 1549 -#define IDC_PUBLISHPRIMARY 1550 -#define IDC_ADD_ANY 1551 -#define IDC_ADD_AUTH 1552 -#define IDC_STATUSMSG_CLIST 1553 -#define IDC_STATUSMSG_VISIBLE 1554 -#define IDC_STATIC_NOTONLINE 1555 -#define IDC_STATIC_DC2 1556 -#define IDC_STATIC_DC1 1557 -#define IDC_STATIC_CLIST 1558 -#define IDC_SAVE 1600 -#define IDC_LIST 1601 -#define IDC_UPLOADING 1602 +#define IDD_OPTIONS_FULL 101 +#define IDD_OPTIONS_ACCMGR 102 +#define IDC_PASSWORD 1001 +#define IDC_UIN 1002 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 113 +#define _APS_NEXT_RESOURCE_VALUE 103 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1026 +#define _APS_NEXT_CONTROL_VALUE 1003 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp index e8cf0b0d48..6ad4897cd8 100644 --- a/protocols/Icq10/src/server.cpp +++ b/protocols/Icq10/src/server.cpp @@ -136,18 +136,17 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) m_szAToken = ptrA(mir_urlDecode(m_szAToken)); setString("AToken", m_szAToken); - ptrA szPassword(getStringA("Password")); CMStringA m_szSessionSecret = data["sessionSecret"].as_mstring(); unsigned int len; BYTE hashOut[MIR_SHA256_HASH_SIZE]; - HMAC(EVP_sha256(), szPassword.get(), (int)mir_strlen(szPassword), (BYTE*)m_szSessionSecret.c_str(), m_szSessionSecret.GetLength(), hashOut, &len); + HMAC(EVP_sha256(), m_szPassword, (int)mir_strlen(m_szPassword), (BYTE*)m_szSessionSecret.c_str(), m_szSessionSecret.GetLength(), hashOut, &len); m_szSessionKey = ptrA(mir_base64_encode(hashOut, sizeof(hashOut))); setString("SessionKey", m_szSessionKey); CMStringA szUin = data["loginId"].as_mstring(); if (szUin) - setDword("UIN", atoi(szUin)); + m_dwUin = atoi(szUin); StartSession(); } |