summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-10-29 12:17:04 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-10-29 12:17:04 +0300
commit9f627b4aebf1724aa223d4f6061a44be46544b50 (patch)
treef20657be8ce3a32890fb1ce095fad8675505f0de /protocols
parent5df3dd0b63c67b8139ff1c7e0d0c039db1a64b6d (diff)
fixes #3714 (Jabber: авторизованный, но не добавленный в ростер контакт сам собой добавляется в ростер)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_events.cpp32
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp13
-rw-r--r--protocols/JabberG/src/jabber_proto.h21
-rw-r--r--protocols/JabberG/src/jabber_util.cpp45
4 files changed, 54 insertions, 57 deletions
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index ed4976e769..2dfc7bbf84 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -143,34 +143,6 @@ void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, MCONTACT
}
}
-void __cdecl CJabberProto::OnAddContactForever(MCONTACT hContact)
-{
- ptrA jid(getUStringA(hContact, "jid"));
- if (jid == nullptr)
- return;
-
- debugLogA("Add %s permanently to list", jid.get());
- ptrA nick(db_get_utfa(hContact, "CList", "MyHandle"));
- if (nick == nullptr)
- nick = getUStringA(hContact, "Nick");
- if (nick == nullptr)
- nick = JabberNickFromJID(jid);
- if (nick == nullptr)
- return;
-
- AddContactToRoster(jid, nick, T2Utf(ptrW(Clist_GetGroup(hContact))));
-
- XmlNode xPresence("presence"); xPresence << XATTR("to", jid) << XATTR("type", "subscribe");
- ptrA myNick(getUStringA("Nick"));
- if (myNick != nullptr && !m_bIgnoreRoster)
- xPresence << XCHILD("nick", myNick) << XATTR("xmlns", JABBER_FEAT_NICK);
- m_ThreadInfo->send(xPresence);
-
- SendGetVcard(hContact);
-
- Contact::Hide(hContact, false);
-}
-
int __cdecl CJabberProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
{
if (hContact == 0 || !m_bJabberOnline)
@@ -184,10 +156,6 @@ int __cdecl CJabberProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
OnRenameGroup(cws, hContact);
else if (!strcmp(cws->szSetting, "MyHandle"))
OnRenameContact(cws, hContact);
- else if (!strcmp(cws->szSetting, "NotOnList")) {
- if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
- OnAddContactForever(hContact);
- }
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 993e0faf2f..f9b1ba6cdf 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -411,18 +411,17 @@ int CJabberProto::Authorize(MEVENT hDbEvent)
DB::AUTH_BLOB blob(dbei.pBlob);
debugLogA("Send 'authorization allowed' to %s", blob.get_email());
+ Contact::PutOnList(blob.get_contact());
m_ThreadInfo->send(XmlNode("presence") << XATTR("to", blob.get_email()) << XATTR("type", "subscribed"));
// Automatically add this user to my roster if option is enabled
if (m_bAutoAdd) {
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, blob.get_email());
- if (item == nullptr || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
- debugLogA("Try adding contact automatically jid = %s", blob.get_email());
- if (MCONTACT hContact = AddToListByJID(blob.get_email(), 0)) {
- // Trigger actual add by removing the "NotOnList" added by AddToListByJID()
- // See AddToListByJID() and JabberDbSettingChanged().
- Contact::PutOnList(hContact);
+ if (auto *item = ListGetItemPtr(LIST_ROSTER, blob.get_email())) {
+ if (item->subscription != SUB_BOTH && item->subscription != SUB_TO) {
+ debugLogA("Try adding contact automatically jid = %s", blob.get_email());
+ if (MCONTACT hContact = AddToListByJID(blob.get_email(), 0))
+ AddContactForever(hContact);
}
}
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 8791339476..1eed184afc 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -161,7 +161,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
INT_PTR __cdecl GetMyAwayMsg(WPARAM wParam, LPARAM lParam);
//====| Events |======================================================================
- void __cdecl OnAddContactForever(MCONTACT hContact);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
int __cdecl OnIdleChanged(WPARAM, LPARAM);
int __cdecl OnLangChanged(WPARAM, LPARAM);
@@ -342,8 +341,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
* Function declarations
*******************************************************************/
- void JabberUpdateDialogs(BOOL bEnable);
-
//---- jabber_adhoc.cpp --------------------------------------------------------------
int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam);
@@ -615,7 +612,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void FtSendFinal(bool success, filetransfer *ft);
int FtReceive(filetransfer *ft, char* buffer, int datalen);
void FtReceiveFinal(bool success, filetransfer *ft);
-
+
//---- jabber_iqid.cpp ---------------------------------------------------------------
void GroupchatJoinByHContact(MCONTACT hContact, bool autojoin=false);
@@ -770,13 +767,15 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
int RcGetUnreadEventsCount(void);
- //---- jabber_rostereditor.cpp -------------------------------------------------------
+ //---- jabber_roster.cpp -------------------------------------------------------------
CRosterEditorDlg *m_hwndRosterEditor;
INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam);
void _RosterHandleGetRequest(const TiXmlElement *node, CJabberIqInfo*);
+ void JabberUpdateDialogs(BOOL bEnable);
+
//---- jabber_search.cpp -------------------------------------------------------------
void OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
@@ -785,9 +784,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void SearchDeleteFromRecent(const char *szAddr, bool deleteLastFromDB);
void SearchAddToRecent(const char *szAddr, HWND hwndDialog = nullptr);
- //---- jabber_std.cpp ----------------------------------------------
- void JLoginFailed(int errorCode);
-
//---- jabber_svc.c ------------------------------------------------------------------
void CheckMenuItems();
@@ -822,7 +818,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void __cdecl ServerThread(JABBER_CONN_DATA *info);
bool ServerThreadStub(ThreadData &info);
-
+
void OnProcessFailure(const TiXmlElement *node, ThreadData *info);
void OnProcessFailed(const TiXmlElement *node, ThreadData *info);
void OnProcessEnabled(const TiXmlElement *node, ThreadData *info);
@@ -858,7 +854,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void OnPingReply(const TiXmlElement *node, CJabberIqInfo *pInfo);
bool ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info);
-
+ void JLoginFailed(int errorCode);
+
//---- jabber_userinfo.c -------------------------------------------------------------
void CheckOmemoUserInfo(WPARAM, USERINFOPAGE&);
@@ -867,7 +864,9 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
pResourceStatus ResourceInfoFromJID(const char *jid);
void OnGetBob(const TiXmlElement *node, CJabberIqInfo *pInfo);
-
+
+ void AddContactForever(MCONTACT hContact);
+
MCONTACT HContactFromJID(const char *jid, bool bStripResource = true);
MCONTACT ChatRoomHContactFromJID(const char *jid);
void SendVisibleInvisiblePresence(bool invisible);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index f8190485ae..c718d02293 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -31,7 +31,37 @@ int CJabberProto::SerialNext(void)
return ::InterlockedIncrement(&m_nSerial);
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CJabberProto::AddContactForever(MCONTACT hContact)
+{
+ ptrA jid(getUStringA(hContact, "jid"));
+ if (jid == nullptr)
+ return;
+
+ debugLogA("Add %s permanently to list", jid.get());
+ ptrA nick(db_get_utfa(hContact, "CList", "MyHandle"));
+ if (nick == nullptr)
+ nick = getUStringA(hContact, "Nick");
+ if (nick == nullptr)
+ nick = JabberNickFromJID(jid);
+ if (nick == nullptr)
+ return;
+
+ AddContactToRoster(jid, nick, T2Utf(ptrW(Clist_GetGroup(hContact))));
+
+ XmlNode xPresence("presence"); xPresence << XATTR("to", jid) << XATTR("type", "subscribe");
+ ptrA myNick(getUStringA("Nick"));
+ if (myNick != nullptr && !m_bIgnoreRoster)
+ xPresence << XCHILD("nick", myNick) << XATTR("xmlns", JABBER_FEAT_NICK);
+ m_ThreadInfo->send(xPresence);
+
+ SendGetVcard(hContact);
+
+ Contact::Hide(hContact, false);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// JabberChatRoomHContactFromJID - looks for the char room MCONTACT with required JID
MCONTACT CJabberProto::ChatRoomHContactFromJID(const char *jid)
@@ -43,7 +73,7 @@ MCONTACT CJabberProto::ChatRoomHContactFromJID(const char *jid)
return 0;
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// JabberHContactFromJID - looks for the MCONTACT with required JID
MCONTACT CJabberProto::HContactFromJID(const char *jid, bool bStripResource)
@@ -577,7 +607,7 @@ char* JabberId2string(int id)
return mir_strdup(text);
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// JabberGetClientJID - adds a resource postfix to a JID
char* CJabberProto::GetClientJID(MCONTACT hContact, char *dest, size_t destLen)
@@ -608,7 +638,7 @@ char* CJabberProto::GetClientJID(const char *jid, char *dest, size_t destLen)
return dest;
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// JabberStripJid - strips a resource postfix from a JID
char* JabberStripJid(const char *jid, char *dest, size_t destLen)
@@ -678,7 +708,7 @@ const char* TStringPairs::operator[](const char* key) const
return "";
}
-////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Manage combo boxes with recent item list
void CJabberProto::ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount)
@@ -739,8 +769,9 @@ time_t str2time(const char *buf)
return _mkgmtime(&T);
}
-////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// case-insensitive wcsstr
+
const wchar_t *JabberStrIStr(const wchar_t *str, const wchar_t *substr)
{
wchar_t *str_up = NEWWSTR_ALLOCA(str);
@@ -753,7 +784,7 @@ const wchar_t *JabberStrIStr(const wchar_t *str, const wchar_t *substr)
return p ? (str + (p - str_up)) : nullptr;
}
-////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
BOOL CJabberProto::EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName, int recentCount, int timeout)
{