diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-28 12:03:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-28 12:03:47 +0300 |
commit | c505cadce283c5abf15f87e3c72655c70d738e21 (patch) | |
tree | 114c31c8a5715e48af60d180b34693648962a44a /protocols | |
parent | 76350d50ef7043a171292d6ec7574ed863af4067 (diff) |
ICQ10:
- fixes #1800 (ICQ10: add aboutMe content to user info);
- added ICQ User Info page
- code cleaning
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/ICQ-WIM/res/resources.rc | 24 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 70 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/resource.h | 9 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 6 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/stdafx.h | 4 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/userinfo.cpp | 67 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 17 |
8 files changed, 162 insertions, 37 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc index d2b7888d8d..447abd8680 100644 --- a/protocols/ICQ-WIM/res/resources.rc +++ b/protocols/ICQ-WIM/res/resources.rc @@ -76,6 +76,20 @@ BEGIN EDITTEXT IDC_CODE,7,70,302,14,ES_AUTOHSCROLL | WS_DISABLED END +IDD_INFO_ICQ DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "UIN:",IDC_STATIC,5,7,71,8 + EDITTEXT IDC_UIN,74,7,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Online since:",IDC_STATIC,5,19,71,8 + EDITTEXT IDC_ONLINESINCE,74,19,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP + LTEXT "Idle since:",IDC_STATIC,5,32,71,8 + EDITTEXT IDC_IDLETIME,74,32,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP +END + + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -104,6 +118,10 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 104 END + + IDD_INFO_ICQ, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED @@ -133,6 +151,12 @@ BEGIN 0 END +IDD_INFO_ICQ AFX_DIALOG_LAYOUT +BEGIN + 0 +END + + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 0b82b7a623..6e14f91a01 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -88,6 +88,8 @@ void CIcqProto::OnModulesLoaded() gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; Chat_Register(&gcr); + + HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit); } void CIcqProto::OnShutdown() diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 8188e75fe6..9754eacfa8 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -128,7 +128,6 @@ class CIcqProto : public PROTO<CIcqProto> MCONTACT CheckOwnMessage(const CMStringA &reqId, const CMStringA &msgId, bool bRemove); void CheckPassword(void); void ConnectionFailed(int iReason); - CMStringA GetUserId(MCONTACT); void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = -1); void ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &msg); @@ -249,43 +248,44 @@ class CIcqProto : public PROTO<CIcqProto> //////////////////////////////////////////////////////////////////////////////////////// // events - int __cdecl OnGroupChange(WPARAM, LPARAM); - int __cdecl OnDbEventRead(WPARAM, LPARAM); - int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnGroupChange(WPARAM, LPARAM); + int __cdecl OnDbEventRead(WPARAM, LPARAM); + int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnUserInfoInit(WPARAM, LPARAM); //////////////////////////////////////////////////////////////////////////////////////// // PROTO_INTERFACE - MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override; - - int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override; - - HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override; - int FileCancel(MCONTACT hContact, HANDLE hTransfer) override; - int FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szReason) override; - int FileResume( HANDLE hTransfer, int *action, const wchar_t **szFilename) override; - - INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override; - int GetInfo(MCONTACT hContact, int infoType) override; - - HANDLE SearchBasic(const wchar_t *id) override; - - HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; - int SendMsg(MCONTACT hContact, int flags, const char *msg) override; - - int SetApparentMode(MCONTACT hContact, int mode) override; - int SetStatus(int iNewStatus) override; - - HANDLE GetAwayMsg(MCONTACT hContact) override; - int RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT *evt) override; - int SetAwayMsg(int m_iStatus, const wchar_t *msg) override; - - int UserIsTyping(MCONTACT hContact, int type) override; - - void OnBuildProtoMenu(void) override; - void OnContactDeleted(MCONTACT) override; - void OnModulesLoaded() override; - void OnShutdown() override; + MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override; + + int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override; + + HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override; + int FileCancel(MCONTACT hContact, HANDLE hTransfer) override; + int FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szReason) override; + int FileResume( HANDLE hTransfer, int *action, const wchar_t **szFilename) override; + + INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override; + int GetInfo(MCONTACT hContact, int infoType) override; + + HANDLE SearchBasic(const wchar_t *id) override; + + HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; + int SendMsg(MCONTACT hContact, int flags, const char *msg) override; + + int SetApparentMode(MCONTACT hContact, int mode) override; + int SetStatus(int iNewStatus) override; + + HANDLE GetAwayMsg(MCONTACT hContact) override; + int RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT *evt) override; + int SetAwayMsg(int m_iStatus, const wchar_t *msg) override; + + int UserIsTyping(MCONTACT hContact, int type) override; + + void OnBuildProtoMenu(void) override; + void OnContactDeleted(MCONTACT) override; + void OnModulesLoaded() override; + void OnShutdown() override; public: CIcqProto(const char*, const wchar_t*); @@ -295,6 +295,8 @@ public: CMOption<wchar_t*> m_szPassword; // password, if present CMOption<BYTE> m_bUseFriendly; // use friendly names instead of old icq nicks CMOption<BYTE> m_bHideGroupchats; // don't pop up group chat windows on startup + + CMStringA GetUserId(MCONTACT); }; struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto> diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h index beeac3d899..866a0b9363 100644 --- a/protocols/ICQ-WIM/src/resource.h +++ b/protocols/ICQ-WIM/src/resource.h @@ -1,10 +1,11 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by w:\miranda-ng\protocols\Icq10\res\resources.rc +// Used by w:\miranda-ng\protocols\ICQ-WIM\res\resources.rc // #define IDD_OPTIONS_FULL 101 #define IDD_OPTIONS_ACCMGR 102 #define IDD_GROUPCHAT_INVITE 103 +#define IDD_INFO_ICQ 104 #define IDD_REGISTER 105 #define IDC_PASSWORD 1001 #define IDC_UIN 1002 @@ -16,14 +17,16 @@ #define IDC_CLIST 1007 #define IDC_SENDSMS 1008 #define IDC_CODE 1009 +#define IDC_ONLINESINCE 1010 +#define IDC_IDLETIME 1011 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_RESOURCE_VALUE 108 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1010 +#define _APS_NEXT_CONTROL_VALUE 1013 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index dbf2e93e7b..61205b005b 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -183,6 +183,12 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact) } } + str = profile["aboutMe"].as_mstring(); + if (!str.IsEmpty()) + setWString(hContact, DB_KEY_ABOUT, str); + else + delSetting(hContact, DB_KEY_ABOUT); + str = profile["gender"].as_mstring(); if (!str.IsEmpty()) { if (str == "male") diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h index ed564a18f0..e2b7150f67 100644 --- a/protocols/ICQ-WIM/src/stdafx.h +++ b/protocols/ICQ-WIM/src/stdafx.h @@ -81,8 +81,11 @@ #define MODULENAME "ICQ" #define DB_KEY_UIN "UIN" +#define DB_KEY_IDLE "IdleTS" +#define DB_KEY_ABOUT "About" #define DB_KEY_ATOKEN "AToken" #define DB_KEY_PHONEREG "PhoneReg" +#define DB_KEY_LASTSEEN "LastSeen" #define DB_KEY_RCLIENTID "RClientID" #define DB_KEY_LASTMSGID "LastMsgId" #define DB_KEY_REMOTEREAD "RemoteReadId" @@ -94,6 +97,7 @@ bool IsChat(const CMStringW &aimid); int StatusFromString(const CMStringW&); +char* time2text(time_t time); extern HWND g_hwndHeartbeat; extern bool g_bMessageState; diff --git a/protocols/ICQ-WIM/src/userinfo.cpp b/protocols/ICQ-WIM/src/userinfo.cpp new file mode 100644 index 0000000000..faa14ebcb4 --- /dev/null +++ b/protocols/ICQ-WIM/src/userinfo.cpp @@ -0,0 +1,67 @@ +// ----------------------------------------------------------------------------- +// ICQ plugin for Miranda NG +// ----------------------------------------------------------------------------- +// Copyright © 2018-19 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" + +static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_PARAMCHANGED) { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + CIcqProto *ppro = (CIcqProto*)((PSHNOTIFY*)lParam)->lParam; + + CMStringA szId(ppro->GetUserId(hContact)); + SetDlgItemTextA(hwndDlg, IDC_UIN, szId); + + SetDlgItemTextA(hwndDlg, IDC_IDLETIME, time2text(ppro->getDword(hContact, DB_KEY_IDLE))); + SetDlgItemTextA(hwndDlg, IDC_ONLINESINCE, time2text(ppro->getDword(hContact, DB_KEY_LASTSEEN))); + } + break; + } + + return 0; +} + +int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact) +{ + if (!hContact || mir_strcmp(GetContactProto(hContact), m_szModuleName)) + return 0; + + if (isChatRoom(hContact)) + return 0; + + OPTIONSDIALOGPAGE odp = {}; + odp.flags = ODPF_USERINFOTAB | ODPF_DONTTRANSLATE; + odp.dwInitParam = LPARAM(this); + odp.szTitle.a = "ICQ"; + + odp.pfnDlgProc = IcqDlgProc; + odp.position = -1900000000; + odp.szTab.a = LPGEN("Details"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_ICQ); + g_plugin.addUserInfo(wParam, &odp); + return 0; +} diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index 7f41347918..5f7e806e96 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -240,3 +240,20 @@ void CIcqProto::setId(MCONTACT hContact, const char *szSetting, __int64 iValue) if (oldVal != iValue) db_set_blob(hContact, m_szModuleName, szSetting, &iValue, sizeof(iValue)); } + +///////////////////////////////////////////////////////////////////////////////////////// + +char* time2text(time_t time) +{ + if (time == 0) + return ""; + + tm *local = localtime(&time); + if (local) { + char *str = asctime(local); + str[24] = '\0'; // remove new line + return str; + } + + return "<invalid>"; +} |