summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-16 14:57:07 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-16 14:57:07 +0300
commitecee3cf571be168342936201457d00d094239a80 (patch)
tree06b3d401c7a1a76622c05b1b08d5fb33ae0aa324 /protocols/JabberG/src
parent93e78f0795929ac87f4b85ffc9af077b257dbcda (diff)
Jabber:
- useless parameter in CJabberProto::OnAddContactForever removed; - when we receive subscription = remove we just change it to SUB_NONE instead of removing contact from LIST_ROSTER; - code cleaning
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_events.cpp11
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp35
-rw-r--r--protocols/JabberG/src/jabber_list.cpp29
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp6
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h2
5 files changed, 37 insertions, 46 deletions
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index a05355f973..ec31312ec5 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -125,11 +125,8 @@ void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, MCONTACT
}
}
-void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, MCONTACT hContact)
+void __cdecl CJabberProto::OnAddContactForever(MCONTACT hContact)
{
- if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
- return;
-
ptrW jid(getWStringA(hContact, "jid"));
if (jid == nullptr)
return;
@@ -169,8 +166,10 @@ 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"))
- OnAddContactForever(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_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index 63416972c8..92f4492ee4 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -227,8 +227,6 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
}
}
- const wchar_t *jid, *str;
-
debugLogA("<iq/> Got roster push, query has %d children", XmlGetChildCount(queryNode));
for (int i = 0;; i++) {
HXML itemNode = XmlGetChild(queryNode, i);
@@ -237,9 +235,9 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
if (mir_wstrcmp(XmlGetName(itemNode), L"item") != 0)
continue;
- if ((jid = XmlGetAttrValue(itemNode, L"jid")) == nullptr)
- continue;
- if ((str = XmlGetAttrValue(itemNode, L"subscription")) == nullptr)
+
+ const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid"), *str = XmlGetAttrValue(itemNode, L"subscription");
+ if (jid == nullptr || str == nullptr)
continue;
// we will not add new account when subscription=remove
@@ -283,27 +281,28 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
}
if (JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid)) {
- if (!mir_wstrcmp(str, L"both")) item->subscription = SUB_BOTH;
- else if (!mir_wstrcmp(str, L"to")) item->subscription = SUB_TO;
- else if (!mir_wstrcmp(str, L"from")) item->subscription = SUB_FROM;
- else item->subscription = SUB_NONE;
- debugLogW(L"Roster push for jid=%s, set subscription to %s", jid, str);
+ if (!mir_wstrcmp(str, L"both"))
+ item->subscription = SUB_BOTH;
+ else if (!mir_wstrcmp(str, L"to"))
+ item->subscription = SUB_TO;
+ else if (!mir_wstrcmp(str, L"from"))
+ item->subscription = SUB_FROM;
+ else
+ item->subscription = SUB_NONE;
- MCONTACT hContact = HContactFromJID(jid);
+ debugLogW(L"Roster push for jid=%s (hContact=%d), set subscription to %s", jid, item->hContact, str);
// subscription = remove is to remove from roster list
// but we will just set the contact to offline and not actually
// remove, so that history will be retained.
if (!mir_wstrcmp(str, L"remove")) {
- if (hContact) {
- SetContactOfflineStatus(hContact);
- ListRemove(LIST_ROSTER, jid);
- }
+ SetContactOfflineStatus(item->hContact);
+ UpdateSubscriptionInfo(item->hContact, item);
}
- else if (isChatRoom(hContact))
- db_unset(hContact, "CList", "Hidden");
+ else if (isChatRoom(item->hContact))
+ db_unset(item->hContact, "CList", "Hidden");
else
- UpdateSubscriptionInfo(hContact, item);
+ UpdateSubscriptionInfo(item->hContact, item);
}
}
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index 8a4b817965..94ba7846e8 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "jabber_list.h"
-void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item);
-
/////////////////////////////////////////////////////////////////////////////////////////
// List item constructor & destructor
@@ -87,20 +85,21 @@ void JABBER_RESOURCE_STATUS::Release()
delete this;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CJabberProto::ListInit(void)
{
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if (!isChatRoom(hContact)) continue;
- ptrW jid(getWStringA(hContact, "ChatRoomID"));
- if (jid != nullptr)
- ListAdd(LIST_CHATROOM, jid, hContact);
- }
-
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if (isChatRoom(hContact)) continue;
- ptrW jid(getWStringA(hContact, "jid"));
- if (jid != nullptr)
- ListAdd(LIST_ROSTER, jid, hContact);
+ if (isChatRoom(hContact)) {
+ ptrW jid(getWStringA(hContact, "ChatRoomID"));
+ if (jid != nullptr)
+ ListAdd(LIST_CHATROOM, jid, hContact);
+ }
+ else {
+ ptrW jid(getWStringA(hContact, "jid"));
+ if (jid != nullptr)
+ ListAdd(LIST_ROSTER, jid, hContact);
+ }
}
}
@@ -130,8 +129,8 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC
wchar_t *s = mir_wstrdup(jid);
wchar_t *q = nullptr;
+
// strip resource name if any
- //fyr
if (!((list == LIST_ROSTER) && ListGetItemPtr(LIST_CHATROOM, jid))) { // but only if it is not chat room contact
if (list != LIST_VCARD_TEMP) {
wchar_t *p;
@@ -143,7 +142,7 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC
else bUseResource = true;
if (!bUseResource && list == LIST_ROSTER) {
- //if it is a chat room keep resource and made it resource sensitive
+ // if it is a chat room keep resource and made it resource sensitive
if (ChatRoomHContactFromJID(s)) {
if (q != nullptr)
*q = '/';
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index bd9b540917..eedaec74af 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -1167,8 +1167,6 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param)
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
if (item != nullptr) {
if (item->arResources.getCount() > 0) {
- debugLogA("arResources.getCount() > 0");
-
CMStringW str;
for (auto &r : item->arResources)
if (r->m_tszStatusMessage)
@@ -1192,8 +1190,6 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param)
HANDLE __cdecl CJabberProto::GetAwayMsg(MCONTACT hContact)
{
- debugLogA("GetAwayMsg called, hContact=%08X", hContact);
-
ForkThread(&CJabberProto::GetAwayMsgThread, (void*)hContact);
return (HANDLE)1;
}
@@ -1203,8 +1199,6 @@ HANDLE __cdecl CJabberProto::GetAwayMsg(MCONTACT hContact)
int __cdecl CJabberProto::SetAwayMsg(int status, const wchar_t *msg)
{
- debugLogW(L"SetAwayMsg called, wParam=%d lParam=%s", status, msg);
-
wchar_t **szMsg;
mir_cslockfull lck(m_csModeMsgMutex);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index d6144695d7..1601bfed14 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -116,7 +116,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
INT_PTR __cdecl GetMyAwayMsg(WPARAM wParam, LPARAM lParam);
//====| Events |======================================================================
- void __cdecl OnAddContactForever(DBCONTACTWRITESETTING* cws, MCONTACT hContact);
+ void __cdecl OnAddContactForever(MCONTACT hContact);
int __cdecl OnContactDeleted(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
int __cdecl OnIdleChanged(WPARAM, LPARAM);