summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-01-09 20:20:56 +0200
committerGeorge Hazan <ghazan@miranda.im>2019-01-09 20:20:56 +0200
commitac9a3bc8834ceab43c9948c70cd0454460bbbdcd (patch)
tree148298bcd8248168d423523b888a95760b434585
parentda99747eddef9c1c53c395406ec850d1b13f8e0a (diff)
ICQ10:
- fixes #1739 (Miranda doesn't react to renamed contact) - code cleaning
-rw-r--r--protocols/Icq10/res/resources.rc3
-rw-r--r--protocols/Icq10/src/options.cpp6
-rw-r--r--protocols/Icq10/src/proto.cpp58
-rw-r--r--protocols/Icq10/src/proto.h6
-rw-r--r--protocols/Icq10/src/resource.h1
-rw-r--r--protocols/Icq10/src/server.cpp39
6 files changed, 60 insertions, 53 deletions
diff --git a/protocols/Icq10/res/resources.rc b/protocols/Icq10/res/resources.rc
index 8b3c0683f2..a5dc252683 100644
--- a/protocols/Icq10/res/resources.rc
+++ b/protocols/Icq10/res/resources.rc
@@ -93,6 +93,7 @@ BEGIN
EDITTEXT IDC_UIN,54,0,131,12,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,0,16,53,12
EDITTEXT IDC_PASSWORD,54,16,131,12,ES_PASSWORD | ES_AUTOHSCROLL
+ PUSHBUTTON "Create a new ICQ account",IDC_REGISTER,183,61,122,14
END
IDD_OPTIONS_FULL DIALOGEX 0, 0, 310, 80
@@ -105,6 +106,8 @@ BEGIN
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,61,122,14
END
diff --git a/protocols/Icq10/src/options.cpp b/protocols/Icq10/src/options.cpp
index 57ef15c9b2..6eaa2e6114 100644
--- a/protocols/Icq10/src/options.cpp
+++ b/protocols/Icq10/src/options.cpp
@@ -156,6 +156,7 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto>
{
CCtrlEdit edtUin, edtPassword;
+ CCtrlCheck chkUseFriendly;
CCtrlButton btnCreate;
CMStringW wszOldPass;
@@ -164,12 +165,15 @@ public:
CProtoDlgBase<CIcqProto>(ppro, iDlgID),
edtUin(this, IDC_UIN),
btnCreate(this, IDC_REGISTER),
- edtPassword(this, IDC_PASSWORD)
+ edtPassword(this, IDC_PASSWORD),
+ chkUseFriendly(this, IDC_USEFRIENDLY)
{
btnCreate.OnClick = Callback(this, &CIcqOptionsDlg::onClick_Register);
CreateLink(edtUin, ppro->m_dwUin);
CreateLink(edtPassword, ppro->m_szPassword);
+ if (bFullDlg)
+ CreateLink(chkUseFriendly, ppro->m_bUseFriendly);
wszOldPass = ppro->m_szPassword;
}
diff --git a/protocols/Icq10/src/proto.cpp b/protocols/Icq10/src/proto.cpp
index 21573a9595..bbbdcf703f 100644
--- a/protocols/Icq10/src/proto.cpp
+++ b/protocols/Icq10/src/proto.cpp
@@ -41,7 +41,8 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) :
arMarkReadQueue(10, NumericKeySortT),
m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
m_dwUin(this, DB_KEY_UIN, 0),
- m_szPassword(this, "Password")
+ m_szPassword(this, "Password"),
+ m_bUseFriendly(this, "bUseFriendly", 1)
{
// services
CreateProtoService(PS_CREATEACCMGRUI, &CIcqProto::CreateAccMgrUI);
@@ -151,7 +152,7 @@ int CIcqProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
////////////////////////////////////////////////////////////////////////////////////////
// PS_AddToList - adds a contact to the contact list
-MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr)
+MCONTACT CIcqProto::AddToList(int, PROTOSEARCHRESULT *psr)
{
if (mir_wstrlen(psr->id.w) == 0)
return 0;
@@ -169,35 +170,6 @@ MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr)
return hContact;
}
-MCONTACT CIcqProto::AddToListByEvent(int flags, int iContact, MEVENT hDbEvent)
-{
- return 0; // Failure
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-// PS_AuthAllow - processes the successful authorization
-
-int CIcqProto::Authorize(MEVENT hDbEvent)
-{
- return 1; // Failure
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-// PS_AuthDeny - handles the unsuccessful authorization
-
-int CIcqProto::AuthDeny(MEVENT hDbEvent, const wchar_t* szReason)
-{
- return 1; // Failure
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-// PSR_AUTH
-
-int CIcqProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT* pre)
-{
- return 0;
-}
-
////////////////////////////////////////////////////////////////////////////////////////
// PSS_AUTHREQUEST
@@ -215,7 +187,7 @@ int CIcqProto::AuthRequest(MCONTACT hContact, const wchar_t* szMessage)
////////////////////////////////////////////////////////////////////////////////////////
// PS_FileAllow - starts a file transfer
-HANDLE CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szPath)
+HANDLE CIcqProto::FileAllow(MCONTACT, HANDLE, const wchar_t*)
{
return nullptr; // Failure
}
@@ -223,7 +195,7 @@ HANDLE CIcqProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t*
////////////////////////////////////////////////////////////////////////////////////////
// PS_FileCancel - cancels a file transfer
-int CIcqProto::FileCancel(MCONTACT hContact, HANDLE hTransfer)
+int CIcqProto::FileCancel(MCONTACT, HANDLE)
{
return 1; // Failure
}
@@ -231,7 +203,7 @@ int CIcqProto::FileCancel(MCONTACT hContact, HANDLE hTransfer)
////////////////////////////////////////////////////////////////////////////////////////
// PS_FileDeny - denies a file transfer
-int CIcqProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szReason)
+int CIcqProto::FileDeny(MCONTACT, HANDLE, const wchar_t*)
{
return 1; // Invalid contact
}
@@ -239,7 +211,7 @@ int CIcqProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szRe
////////////////////////////////////////////////////////////////////////////////////////
// PS_FileResume - processes file renaming etc
-int CIcqProto::FileResume(HANDLE hTransfer, int* action, const wchar_t** szFilename)
+int CIcqProto::FileResume(HANDLE, int*, const wchar_t**)
{
return 1; // Failure
}
@@ -247,7 +219,7 @@ int CIcqProto::FileResume(HANDLE hTransfer, int* action, const wchar_t** szFilen
////////////////////////////////////////////////////////////////////////////////////////
// GetCaps - return protocol capabilities bits
-INT_PTR CIcqProto::GetCaps(int type, MCONTACT hContact)
+INT_PTR CIcqProto::GetCaps(int type, MCONTACT)
{
INT_PTR nReturn = 0;
@@ -280,7 +252,7 @@ INT_PTR CIcqProto::GetCaps(int type, MCONTACT hContact)
////////////////////////////////////////////////////////////////////////////////////////
// GetInfo - retrieves a contact info
-int CIcqProto::GetInfo(MCONTACT hContact, int infoType)
+int CIcqProto::GetInfo(MCONTACT hContact, int)
{
RetrieveUserInfo(hContact);
return 0;
@@ -308,7 +280,7 @@ HANDLE CIcqProto::SearchBasic(const wchar_t *pszSearch)
////////////////////////////////////////////////////////////////////////////////////////
// SendFile - sends a file
-HANDLE CIcqProto::SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles)
+HANDLE CIcqProto::SendFile(MCONTACT, const wchar_t*, wchar_t**)
{
return nullptr; // Failure
}
@@ -339,7 +311,7 @@ int CIcqProto::SendMsg(MCONTACT hContact, int, const char *pszSrc)
////////////////////////////////////////////////////////////////////////////////////////
// SendUrl
-int CIcqProto::SendUrl(MCONTACT hContact, int, const char* url)
+int CIcqProto::SendUrl(MCONTACT, int, const char*)
{
return 1; // Failure
}
@@ -398,7 +370,7 @@ int CIcqProto::SetStatus(int iNewStatus)
////////////////////////////////////////////////////////////////////////////////////////
// PS_GetAwayMsg - returns a contact's away message
-HANDLE CIcqProto::GetAwayMsg(MCONTACT hContact)
+HANDLE CIcqProto::GetAwayMsg(MCONTACT)
{
return nullptr; // Failure
}
@@ -406,7 +378,7 @@ HANDLE CIcqProto::GetAwayMsg(MCONTACT hContact)
////////////////////////////////////////////////////////////////////////////////////////
// PSR_AWAYMSG - processes received status mode message
-int CIcqProto::RecvAwayMsg(MCONTACT hContact, int, PROTORECVEVENT* evt)
+int CIcqProto::RecvAwayMsg(MCONTACT, int, PROTORECVEVENT*)
{
return 0;
}
@@ -414,7 +386,7 @@ int CIcqProto::RecvAwayMsg(MCONTACT hContact, int, PROTORECVEVENT* evt)
////////////////////////////////////////////////////////////////////////////////////////
// PS_SetAwayMsg - sets the away status message
-int CIcqProto::SetAwayMsg(int status, const wchar_t* msg)
+int CIcqProto::SetAwayMsg(int, const wchar_t*)
{
return 0; // Success
}
@@ -436,7 +408,7 @@ int CIcqProto::UserIsTyping(MCONTACT hContact, int type)
////////////////////////////////////////////////////////////////////////////////////////
// PS_SetApparentMode - sets the visibility status
-int CIcqProto::SetApparentMode(MCONTACT hContact, int mode)
+int CIcqProto::SetApparentMode(MCONTACT, int)
{
return 1; // Failure
}
diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h
index 53a27f80a1..523a8ee7c0 100644
--- a/protocols/Icq10/src/proto.h
+++ b/protocols/Icq10/src/proto.h
@@ -112,6 +112,7 @@ class CIcqProto : public PROTO<CIcqProto>
void OnValidateSms(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void ProcessBuddyList(const JSONNode&);
+ void ProcessDiff(const JSONNode&);
void ProcessEvent(const JSONNode&);
void ProcessHistData(const JSONNode&);
void ProcessImState(const JSONNode&);
@@ -185,11 +186,7 @@ class CIcqProto : public PROTO<CIcqProto>
// PROTO_INTERFACE
MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override;
- MCONTACT AddToListByEvent( int flags, int iContact, MEVENT hDbEvent) override;
- int Authorize(MEVENT hDbEvent) override;
- int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override;
- int AuthRecv(MCONTACT hContact, PROTORECVEVENT*) override;
int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override;
@@ -225,6 +222,7 @@ public:
CMOption<DWORD> m_dwUin;
CMOption<wchar_t*> m_szPassword;
+ CMOption<BYTE> m_bUseFriendly;
};
struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto>
diff --git a/protocols/Icq10/src/resource.h b/protocols/Icq10/src/resource.h
index f32dc59f5f..cb5dfd3c17 100644
--- a/protocols/Icq10/src/resource.h
+++ b/protocols/Icq10/src/resource.h
@@ -7,6 +7,7 @@
#define IDD_REGISTER 105
#define IDC_PASSWORD 1001
#define IDC_UIN 1002
+#define IDC_USEFRIENDLY 1003
#define IDC_REGISTER 1005
#define IDC_PHONE 1006
#define IDC_SENDSMS 1008
diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp
index ad56d91617..52daefef3f 100644
--- a/protocols/Icq10/src/server.cpp
+++ b/protocols/Icq10/src/server.cpp
@@ -46,12 +46,12 @@ void CIcqProto::CheckLastId(MCONTACT hContact, const JSONNode &ev)
void CIcqProto::CheckNickChange(MCONTACT hContact, const JSONNode &ev)
{
- CMStringW wszNick(getMStringW(hContact, "Nick"));
- if (!wszNick.IsEmpty())
+ // if we already set a nick, ignore change when friendly names aren't used
+ if (!m_bUseFriendly && !getMStringW(hContact, "Nick").IsEmpty())
return;
- wszNick = ev["friendly"].as_mstring();
- if (!wszNick.IsEmpty())
+ CMStringW wszNick = ev["friendly"].as_mstring();
+ if (m_bUseFriendly || !wszNick.IsEmpty())
setWString(hContact, "Nick", wszNick);
}
@@ -135,7 +135,8 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy)
str = profile["friendlyName"].as_mstring();
if (!str.IsEmpty())
- setWString(hContact, "Nick", str);
+ if (!m_bUseFriendly || getMStringW("Nick").IsEmpty())
+ setWString(hContact, "Nick", str);
time_t birthDate = profile["birthDate"].as_int();
if (birthDate != 0) {
@@ -624,12 +625,40 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev)
db_set_b(it->m_hContact, "CList", "NotOnList", 1);
}
+void CIcqProto::ProcessDiff(const JSONNode &ev)
+{
+ for (auto &block : ev) {
+ CMStringW szType = block["type"].as_mstring();
+ if (szType != "updated")
+ continue;
+
+ for (auto &it : block["data"]) {
+ CMStringW szGroup = it["name"].as_mstring();
+ bool bCreated = false;
+
+ for (auto &buddy : it["buddies"]) {
+ MCONTACT hContact = ParseBuddyInfo(buddy);
+ if (db_get_sm(hContact, "CList", "Group").IsEmpty()) {
+ if (!bCreated) {
+ Clist_GroupCreate(0, szGroup);
+ bCreated = true;
+ }
+
+ db_set_ws(hContact, "CList", "Group", szGroup);
+ }
+ }
+ }
+ }
+}
+
void CIcqProto::ProcessEvent(const JSONNode &ev)
{
const JSONNode &pData = ev["eventData"];
CMStringW szType = ev["type"].as_mstring();
if (szType == L"buddylist")
ProcessBuddyList(pData);
+ else if (szType == L"diff")
+ ProcessDiff(pData);
else if (szType == L"histDlgState")
ProcessHistData(pData);
else if (szType == L"imState")