summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-01-28 14:21:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-01-28 14:21:40 +0300
commite6a42bce6b8fb4ddb69de1e62bf317689db876d0 (patch)
tree7dd580376951ed823241a82d64ea023e4a88d1be /protocols/ICQ-WIM
parentea13e922ef9292788a95d6338bae9e84263bd622 (diff)
ICQ-WIM:
- fixes #1766 (ICQ10: rework "Use friendly names" option) - icq nicks moved to User Info dialog; - more data added to User Info; - code optimization
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r--protocols/ICQ-WIM/res/resources.rc25
-rw-r--r--protocols/ICQ-WIM/src/options.cpp9
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp4
-rw-r--r--protocols/ICQ-WIM/src/proto.h13
-rw-r--r--protocols/ICQ-WIM/src/resource.h5
-rw-r--r--protocols/ICQ-WIM/src/server.cpp70
-rw-r--r--protocols/ICQ-WIM/src/stdafx.h2
-rw-r--r--protocols/ICQ-WIM/src/userinfo.cpp7
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp20
9 files changed, 77 insertions, 78 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc
index 447abd8680..169f4d25b0 100644
--- a/protocols/ICQ-WIM/res/resources.rc
+++ b/protocols/ICQ-WIM/res/resources.rc
@@ -35,20 +35,18 @@ BEGIN
PUSHBUTTON "Create a new ICQ account",IDC_REGISTER,62,34,122,14
END
-IDD_OPTIONS_FULL DIALOGEX 0, 0, 310, 98
+IDD_OPTIONS_FULL DIALOGEX 0, 0, 310, 81
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "ICQ",IDC_STATIC,4,0,302,74
+ GROUPBOX "ICQ",IDC_STATIC,4,0,302,60
RTEXT "ICQ number:",IDC_STATIC,12,14,51,8
EDITTEXT IDC_UIN,68,12,106,12,ES_AUTOHSCROLL
RTEXT "Password:",IDC_STATIC,12,28,51,8
EDITTEXT IDC_PASSWORD,68,26,106,12,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Use friendly names instead of contact nicks",IDC_USEFRIENDLY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,43,285,10
- PUSHBUTTON "Create a new ICQ account",IDC_REGISTER,183,78,122,14
- CONTROL "Hide group chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,57,285,10
+ PUSHBUTTON "Create a new ICQ account",IDC_REGISTER,183,63,122,14
+ CONTROL "Hide group chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,45,285,10
END
IDD_GROUPCHAT_INVITE DIALOGEX 0, 0, 215, 263
@@ -81,12 +79,16 @@ 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
+ LTEXT "UIN:",IDC_STATIC,5,7,63,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
+ LTEXT "Online since:",IDC_STATIC,5,32,63,8
+ EDITTEXT IDC_ONLINESINCE,74,32,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+ LTEXT "Idle since:",IDC_STATIC,5,45,63,8
+ EDITTEXT IDC_IDLETIME,74,45,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+ LTEXT "Nick:",IDC_STATIC,5,19,63,8
+ EDITTEXT IDC_NICK,74,19,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+ LTEXT "Member since:",IDC_STATIC,5,58,63,8
+ EDITTEXT IDC_MEMBERSINCE,74,58,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END
@@ -104,7 +106,6 @@ BEGIN
IDD_OPTIONS_FULL, DIALOG
BEGIN
- BOTTOMMARGIN, 78
END
IDD_GROUPCHAT_INVITE, DIALOG
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp
index f1c0a2cd65..3a9d3be3f1 100644
--- a/protocols/ICQ-WIM/src/options.cpp
+++ b/protocols/ICQ-WIM/src/options.cpp
@@ -156,7 +156,7 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto>
{
CCtrlEdit edtUin, edtPassword;
- CCtrlCheck chkUseFriendly, chkHideChats;
+ CCtrlCheck chkHideChats;
CCtrlButton btnCreate;
CMStringW wszOldPass;
@@ -166,17 +166,14 @@ public:
edtUin(this, IDC_UIN),
btnCreate(this, IDC_REGISTER),
edtPassword(this, IDC_PASSWORD),
- chkHideChats(this, IDC_HIDECHATS),
- chkUseFriendly(this, IDC_USEFRIENDLY)
+ chkHideChats(this, IDC_HIDECHATS)
{
btnCreate.OnClick = Callback(this, &CIcqOptionsDlg::onClick_Register);
CreateLink(edtUin, ppro->m_dwUin);
CreateLink(edtPassword, ppro->m_szPassword);
- if (bFullDlg) {
+ if (bFullDlg)
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
- CreateLink(chkUseFriendly, ppro->m_bUseFriendly);
- }
wszOldPass = ppro->m_szPassword;
}
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 471c09d6d7..6628c10a80 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -42,9 +42,11 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) :
m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
m_dwUin(this, DB_KEY_UIN, 0),
m_szPassword(this, "Password"),
- m_bUseFriendly(this, "UseFriendly", 1),
m_bHideGroupchats(this, "HideChats", 1)
{
+ db_set_resident(m_szModuleName, "IdleTS");
+ db_set_resident(m_szModuleName, "OnlineTS");
+
// services
CreateProtoService(PS_CREATEACCMGRUI, &CIcqProto::CreateAccMgrUI);
CreateProtoService(PS_GETAVATARINFO, &CIcqProto::GetAvatarInfo);
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index 9754eacfa8..522dae7736 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -122,21 +122,23 @@ class CIcqProto : public PROTO<CIcqProto>
friend class CGroupchatInviteDlg;
bool m_bOnline = false, m_bTerminated = false;
- void CheckAvatarChange(MCONTACT hContact, const JSONNode&);
- void CheckLastId(MCONTACT hContact, const JSONNode&);
- void CheckNickChange(MCONTACT hContact, const JSONNode&);
MCONTACT CheckOwnMessage(const CMStringA &reqId, const CMStringA &msgId, bool bRemove);
void CheckPassword(void);
void ConnectionFailed(int iReason);
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);
void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId);
void RetrieveUserInfo(MCONTACT);
void SetServerStatus(int iNewStatus);
void ShutdownSession(void);
void StartSession(void);
+ void CheckAvatarChange(MCONTACT hContact, const JSONNode&);
+ void CheckLastId(MCONTACT hContact, const JSONNode&);
+ void Json2int(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting);
+ void Json2string(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting);
+ MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = -1);
+ void ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &msg);
+
void OnLoggedIn(void);
void OnLoggedOut(void);
@@ -293,7 +295,6 @@ public:
CMOption<DWORD> m_dwUin; // our own id
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);
diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h
index 866a0b9363..bbbfab49e9 100644
--- a/protocols/ICQ-WIM/src/resource.h
+++ b/protocols/ICQ-WIM/src/resource.h
@@ -9,8 +9,6 @@
#define IDD_REGISTER 105
#define IDC_PASSWORD 1001
#define IDC_UIN 1002
-#define IDC_USEFRIENDLY 1003
-#define IDC_USEFRIENDLY2 1004
#define IDC_HIDECHATS 1004
#define IDC_REGISTER 1005
#define IDC_PHONE 1006
@@ -19,6 +17,9 @@
#define IDC_CODE 1009
#define IDC_ONLINESINCE 1010
#define IDC_IDLETIME 1011
+#define IDC_NICK 1012
+#define IDC_IDLETIME2 1013
+#define IDC_MEMBERSINCE 1013
// Next default values for new objects
//
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 61205b005b..369b732e59 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -44,17 +44,6 @@ void CIcqProto::CheckLastId(MCONTACT hContact, const JSONNode &ev)
setId(hContact, DB_KEY_LASTMSGID, msgId);
}
-void CIcqProto::CheckNickChange(MCONTACT hContact, const JSONNode &ev)
-{
- // if we already set a nick, ignore change when friendly names aren't used
- if (!m_bUseFriendly && !getMStringW(hContact, "Nick").IsEmpty())
- return;
-
- CMStringW wszNick = ev["friendly"].as_mstring();
- if (m_bUseFriendly || !wszNick.IsEmpty())
- setWString(hContact, "Nick", wszNick);
-}
-
MCONTACT CIcqProto::CheckOwnMessage(const CMStringA &reqId, const CMStringA &msgId, bool bRemove)
{
for (auto &own: m_arOwnIds) {
@@ -158,20 +147,25 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact)
CMStringW str(buddy["state"].as_mstring());
setDword(hContact, "Status", StatusFromString(str));
- const JSONNode &profile = buddy["profile"];
- if (profile) {
- str = profile["firstName"].as_mstring();
- if (!str.IsEmpty())
- setWString(hContact, "FirstName", str);
+ Json2string(hContact, buddy, "friendly", "Nick");
+ Json2string(hContact, buddy, "emailId", "e-mail");
+ Json2string(hContact, buddy, "cellNumber", "Cellular");
+ Json2string(hContact, buddy, "phoneNumber", "Phone");
+ Json2string(hContact, buddy, "workNumber", "CompanyPhone");
+ Json2string(hContact, buddy, "emailId", "e-mail");
- str = profile["lastName"].as_mstring();
- if (!str.IsEmpty())
- setWString(hContact, "LastName", str);
+ Json2int(hContact, buddy, "official", "Official");
+ Json2int(hContact, buddy, "lastseen", "LastSeen");
+ Json2int(hContact, buddy, "onlineTime", "OnlineTS");
+ Json2int(hContact, buddy, "idleTime", "IdleTS");
+ Json2int(hContact, buddy, "memberSince", DB_KEY_MEMBERSINCE);
- str = profile["friendlyName"].as_mstring();
- if (!str.IsEmpty())
- if (!m_bUseFriendly || getMStringW("Nick").IsEmpty())
- setWString(hContact, "Nick", str);
+ const JSONNode &profile = buddy["profile"];
+ if (profile) {
+ Json2string(hContact, profile, "friendlyName", DB_KEY_ICQNICK);
+ Json2string(hContact, profile, "firstName", "FirstName");
+ Json2string(hContact, profile, "lastName", "LastName");
+ Json2string(hContact, profile, "aboutMe", DB_KEY_ABOUT);
time_t birthDate = profile["birthDate"].as_int();
if (birthDate != 0) {
@@ -183,12 +177,6 @@ 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")
@@ -198,26 +186,12 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact)
}
for (auto &it : profile["homeAddress"]) {
- str = it["city"].as_mstring();
- if (!str.IsEmpty())
- setWString(hContact, "City", str);
-
- str = it["state"].as_mstring();
- if (!str.IsEmpty())
- setWString(hContact, "State", str);
-
- str = it["country"].as_mstring();
- if (!str.IsEmpty())
- setWString(hContact, "Country", str);
+ Json2string(hContact, it, "city", "City");
+ Json2string(hContact, it, "state", "State");
+ Json2string(hContact, it, "country", "Country");
}
}
- CheckNickChange(hContact, buddy);
-
- int lastLogin = buddy["lastseen"].as_int();
- if (lastLogin)
- setDword(hContact, "LastSeen", lastLogin);
-
str = buddy["statusMsg"].as_mstring();
if (str.IsEmpty())
db_unset(hContact, "CList", "StatusMsg");
@@ -899,7 +873,7 @@ void CIcqProto::ProcessImState(const JSONNode &ev)
void CIcqProto::ProcessMyInfo(const JSONNode &ev)
{
- CheckNickChange(0, ev);
+ Json2string(0, ev, "friendly", "Nick");
CheckAvatarChange(0, ev);
}
@@ -911,7 +885,7 @@ void CIcqProto::ProcessPresence(const JSONNode &ev)
if (pCache) {
setDword(pCache->m_hContact, "Status", StatusFromString(ev["state"].as_mstring()));
- CheckNickChange(pCache->m_hContact, ev);
+ Json2string(pCache->m_hContact, ev, "friendly", "Nick");
CheckAvatarChange(pCache->m_hContact, ev);
}
}
diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h
index e2b7150f67..a0c05d46c5 100644
--- a/protocols/ICQ-WIM/src/stdafx.h
+++ b/protocols/ICQ-WIM/src/stdafx.h
@@ -84,12 +84,14 @@
#define DB_KEY_IDLE "IdleTS"
#define DB_KEY_ABOUT "About"
#define DB_KEY_ATOKEN "AToken"
+#define DB_KEY_ICQNICK "IcqNick"
#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"
#define DB_KEY_SESSIONKEY "SessionKey"
+#define DB_KEY_MEMBERSINCE "MemberSince"
#include "http.h"
#include "proto.h"
diff --git a/protocols/ICQ-WIM/src/userinfo.cpp b/protocols/ICQ-WIM/src/userinfo.cpp
index faa14ebcb4..615cf44466 100644
--- a/protocols/ICQ-WIM/src/userinfo.cpp
+++ b/protocols/ICQ-WIM/src/userinfo.cpp
@@ -33,10 +33,11 @@ static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam
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_UIN, ppro->GetUserId(hContact));
+ SetDlgItemTextW(hwndDlg, IDC_NICK, ppro->getMStringW(hContact, DB_KEY_ICQNICK));
SetDlgItemTextA(hwndDlg, IDC_IDLETIME, time2text(ppro->getDword(hContact, DB_KEY_IDLE)));
+ SetDlgItemTextA(hwndDlg, IDC_MEMBERSINCE, time2text(ppro->getDword(hContact, DB_KEY_MEMBERSINCE)));
SetDlgItemTextA(hwndDlg, IDC_ONLINESINCE, time2text(ppro->getDword(hContact, DB_KEY_LASTSEEN)));
}
break;
@@ -54,7 +55,7 @@ int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact)
return 0;
OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
+ odp.flags = ODPF_USERINFOTAB;
odp.dwInitParam = LPARAM(this);
odp.szTitle.a = "ICQ";
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index 5f7e806e96..f372d71de5 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -71,6 +71,26 @@ void CIcqProto::CalcHash(AsyncHttpRequest *pReq)
}
/////////////////////////////////////////////////////////////////////////////////////////
+
+void CIcqProto::Json2int(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting)
+{
+ const JSONNode &var = node[szJson];
+ if (var)
+ setDword(hContact, szSetting, var.as_int());
+ else
+ delSetting(hContact, szSetting);
+}
+
+void CIcqProto::Json2string(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting)
+{
+ const JSONNode &var = node[szJson];
+ if (var)
+ setWString(hContact, szSetting, var.as_mstring());
+ else
+ delSetting(hContact, szSetting);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Avatars
void CIcqProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t cbLen)