summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-04-12 14:53:23 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-04-12 14:53:23 +0000
commit1bc1672368e1ba87a68fca21b846c70156e71f05 (patch)
treef4265b4e50fedd1f149be0c136e2b28088522850 /protocols/JabberG
parentbdb3f0597f6ac1eac050a68053d2c4acebdf644d (diff)
jabber: shit wiping began
git-svn-id: http://svn.miranda-ng.org/main/trunk@16633 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_api.cpp7
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp6
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp2
-rw-r--r--protocols/JabberG/src/jabber_message_manager.cpp2
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp15
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp39
-rw-r--r--protocols/JabberG/src/jabber_proto.h3
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp5
-rw-r--r--protocols/JabberG/src/jabber_util.cpp11
-rw-r--r--protocols/JabberG/src/stdafx.h1
10 files changed, 31 insertions, 60 deletions
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp
index 5bdf0a7d78..4c4b93c27c 100644
--- a/protocols/JabberG/src/jabber_api.cpp
+++ b/protocols/JabberG/src/jabber_api.cpp
@@ -50,15 +50,8 @@ DWORD CJabberProto::GetJabberVersion() const
return PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
}
-int CJabberProto::CompareJIDs(LPCTSTR jid1, LPCTSTR jid2)
-{
- if (!jid1 || !jid2) return 0;
- return JabberCompareJids(jid1, jid2);
-}
-
MCONTACT CJabberProto::ContactFromJID(LPCTSTR jid)
{
- if (jid == NULL) return NULL;
return HContactFromJID(jid);
}
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index ad1ca7c27e..6149d6d1e9 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -166,7 +166,7 @@ void CJabberIqManager::ExpireInfo(CJabberIqInfo *pInfo)
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
pInfo->m_szFrom = pInfo->m_szReceiver;
if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (pInfo->m_szFrom))
- pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom , 3);
+ pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
ppro->debugLog(_T("Expiring iq id %d, sent to %s"), pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : _T("server"));
@@ -274,7 +274,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
pInfo->m_szFrom = (TCHAR*)XmlGetAttrValue(pNode, _T("from"));
if (pInfo->m_szFrom && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT))
- pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom, 3);
+ pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_ID_STR)
pInfo->m_szId = (TCHAR*)XmlGetAttrValue(pNode, _T("id"));
@@ -331,7 +331,7 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode)
iqInfo.m_szFrom = (TCHAR*)XmlGetAttrValue(pNode, _T("from"));
if ((pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
- iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom, 3);
+ iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom);
ppro->debugLog(_T("Handling iq id %s, type %s, from %s"), iqInfo.m_szId, szType, iqInfo.m_szFrom);
if ((ppro->*(pInfo.m_pHandler))(pNode, &iqInfo))
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index 2a7a706a50..b64cbfb12a 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -260,7 +260,7 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
HXML groupNode = XmlGetChild(itemNode, "group");
replaceStrT(item->group, XmlGetText(groupNode));
- if ((hContact = HContactFromJID(jid, 0)) == NULL) {
+ if ((hContact = HContactFromJID(jid, false)) == NULL) {
// Received roster has a new JID.
// Add the jid (with empty resource) to Miranda contact list.
hContact = DBCreateContact(jid, nick, FALSE, FALSE);
diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp
index 4f72daab5c..a23eb6f2f6 100644
--- a/protocols/JabberG/src/jabber_message_manager.cpp
+++ b/protocols/JabberG/src/jabber_message_manager.cpp
@@ -97,7 +97,7 @@ bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea
messageInfo.m_szTo = XmlGetAttrValue(node, _T("to"));
if (pInfo.m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
- messageInfo.m_hContact = ppro->HContactFromJID(messageInfo.m_szFrom, 3);
+ messageInfo.m_hContact = ppro->HContactFromJID(messageInfo.m_szFrom);
if (messageInfo.m_szFrom)
ppro->debugLog(_T("Handling message from %s"), messageInfo.m_szFrom);
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 899a728b8b..44e491f1fd 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -51,21 +51,6 @@ void JabberChatDllError()
}
///////////////////////////////////////////////////////////////////////////////
-// JabberCompareJids
-
-int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
-{
- if (!mir_tstrcmpi(jid1, jid2))
- return 0;
-
- // match only node@domain part
- TCHAR szTempJid1[JABBER_MAX_JID_LEN], szTempJid2[JABBER_MAX_JID_LEN];
- return mir_tstrcmpi(
- JabberStripJid(jid1, szTempJid1, _countof(szTempJid1)),
- JabberStripJid(jid2, szTempJid2, _countof(szTempJid2)));
-}
-
-///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 5d939b9c34..f8c6d98885 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -31,7 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma warning(disable:4355)
static int compareTransports(const TCHAR *p1, const TCHAR *p2)
-{ return mir_tstrcmpi(p1, p2);
+{
+ return mir_tstrcmpi(p1, p2);
}
static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM *p2)
@@ -177,7 +178,7 @@ CJabberProto::~CJabberProto()
mir_free(m_transportProtoTableStartIndex);
- for (int i=0; i < m_lstTransports.getCount(); i++)
+ for (int i = 0; i < m_lstTransports.getCount(); i++)
mir_free(m_lstTransports[i]);
for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
@@ -191,7 +192,7 @@ CJabberProto::~CJabberProto()
////////////////////////////////////////////////////////////////////////////////////////
// OnModulesLoadedEx - performs hook registration
-static COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+static COLORREF crCols[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
{
@@ -244,14 +245,15 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
if (!getByte(hContact, "IsTransport", 0))
continue;
- ptrT jid( getTStringA(hContact, "jid"));
- if (jid == NULL) continue;
+ ptrT jid(getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ continue;
TCHAR *domain = NEWTSTR_ALLOCA(jid);
TCHAR *resourcepos = _tcschr(domain, '/');
if (resourcepos != NULL)
*resourcepos = '\0';
- m_lstTransports.insert( mir_tstrdup(domain));
+ m_lstTransports.insert(mir_tstrdup(domain));
}
return 0;
@@ -346,20 +348,17 @@ MCONTACT __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, MEV
DBEVENTINFO dbei = { sizeof(dbei) };
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return NULL;
- if ((dbei.pBlob=(PBYTE)alloca(dbei.cbBlob)) == NULL)
+ if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == NULL)
return NULL;
if (db_event_get(hDbEvent, &dbei))
return NULL;
if (mir_strcmp(dbei.szModule, m_szModuleName))
return NULL;
-/*
// EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Jabber)
// EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Jabber)
// Jabber will only handle the case of EVENTTYPE_AUTHREQUEST
// EVENTTYPE_AUTHREQUEST is when adding from the authorization request dialog
-*/
-
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return NULL;
@@ -415,7 +414,9 @@ int CJabberProto::Authorize(MEVENT hDbEvent)
// Trigger actual add by removing the "NotOnList" added by AddToListByJID()
// See AddToListByJID() and JabberDbSettingChanged().
db_unset(hContact, "CList", "NotOnList");
- } } }
+ }
+ }
+ }
mir_free(newJid);
return 0;
@@ -435,7 +436,7 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const TCHAR*)
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return 1;
- mir_ptr<BYTE> pBlob((PBYTE) mir_alloc(dbei.cbBlob));
+ mir_ptr<BYTE> pBlob((PBYTE)mir_alloc(dbei.cbBlob));
if ((dbei.pBlob = pBlob) == NULL)
return 1;
@@ -456,7 +457,7 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const TCHAR*)
debugLogA("Send 'authorization denied' to %s", jid);
ptrT newJid(dbei.flags & DBEF_UTF ? mir_utf8decodeT(jid) : mir_a2t(jid));
- m_ThreadInfo->send( XmlNode(_T("presence")) << XATTR(_T("to"), newJid) << XATTR(_T("type"), _T("unsubscribed")));
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), newJid) << XATTR(_T("type"), _T("unsubscribed")));
return 0;
}
@@ -535,9 +536,9 @@ int __cdecl CJabberProto::FileDeny(MCONTACT, HANDLE hTransfer, const TCHAR *)
case FT_IBB:
m_ThreadInfo->send(
XmlNodeIq(_T("error"), ft->szId, ft->jid)
- << XCHILD(_T("error"), _T("File transfer refused")) << XATTRI(_T("code"), 403) << XATTR(_T("type"), _T("cancel"))
- << XCHILDNS(_T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"))
- << XCHILD(_T("text"), _T("File transfer refused")) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ << XCHILD(_T("error"), _T("File transfer refused")) << XATTRI(_T("code"), 403) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"))
+ << XCHILD(_T("text"), _T("File transfer refused")) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
break;
}
delete ft;
@@ -633,7 +634,7 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
if (item != NULL) {
if (item->arResources.getCount()) {
- for (int i=0; i < item->arResources.getCount(); i++) {
+ for (int i = 0; i < item->arResources.getCount(); i++) {
pResourceStatus r(item->arResources[i]);
TCHAR tmp[JABBER_MAX_JID_LEN];
mir_sntprintf(tmp, _T("%s/%s"), szBareJid, r->m_tszResourceName);
@@ -942,9 +943,7 @@ void __cdecl CJabberProto::SendMessageAckThread(void* param)
TFakeAckParams *par = (TFakeAckParams*)param;
Sleep(100);
debugLogA("Broadcast ACK");
- ProtoBroadcastAck(par->hContact, ACKTYPE_MESSAGE,
- par->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
- (HANDLE)par->msgid, (LPARAM)par->msg);
+ ProtoBroadcastAck(par->hContact, ACKTYPE_MESSAGE, par->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, (HANDLE)par->msgid, (LPARAM)par->msg);
debugLogA("Returning from thread");
delete par;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 2687498404..e24802ccb0 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -740,7 +740,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_util.c -----------------------------------------------------------------
pResourceStatus ResourceInfoFromJID(const TCHAR *jid);
- MCONTACT HContactFromJID(const TCHAR *jid, BOOL bStripResource = 3);
+ MCONTACT HContactFromJID(const TCHAR *jid, bool bStripResource = true);
MCONTACT ChatRoomHContactFromJID(const TCHAR *jid);
void SendVisibleInvisiblePresence(BOOL invisible);
void SendPresenceTo(int status, const TCHAR* to, HXML extra, const TCHAR *msg = NULL);
@@ -839,7 +839,6 @@ public:
int STDMETHODCALLTYPE GetVersion() const; // Returns version of IJabberInterface.
DWORD STDMETHODCALLTYPE GetJabberVersion() const; // Returns Jabber plugin version.
- int STDMETHODCALLTYPE CompareJIDs(LPCTSTR jid1, LPCTSTR jid2); // Strips resource names from given JIDs and returns result of comparison for these JIDs.
MCONTACT STDMETHODCALLTYPE ContactFromJID(LPCTSTR jid); // Returns contact handle for given JID.
LPTSTR STDMETHODCALLTYPE ContactToJID(MCONTACT hContact); // Returns JID of hContact. You must free the result using mir_free().
LPTSTR STDMETHODCALLTYPE GetBestResourceName(LPCTSTR jid); // Returns best resource name for given JID. You must free the result using mir_free().
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 788814b811..317687a073 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -402,7 +402,6 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara
}
// File Association Manager plugin support
-
INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
{
TCHAR *arg = (TCHAR *)lParam;
@@ -441,7 +440,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
return 1;
TCHAR *szMsgBody = NULL;
- MCONTACT hContact = HContactFromJID(szJid, TRUE);
+ MCONTACT hContact = HContactFromJID(szJid, false);
if (hContact == NULL)
hContact = DBCreateContact(szJid, szJid, TRUE, TRUE);
if (hContact == NULL)
@@ -508,7 +507,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
// send file
if (!mir_tstrcmpi(szCommand, _T("sendfile"))) {
- MCONTACT hContact = HContactFromJID(szJid, TRUE);
+ MCONTACT hContact = HContactFromJID(szJid, false);
if (hContact == NULL)
hContact = DBCreateContact(szJid, szJid, TRUE, TRUE);
if (hContact == NULL)
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 3b7ab9152f..8d1d1e7c72 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -55,7 +55,7 @@ MCONTACT CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
///////////////////////////////////////////////////////////////////////////////
// JabberHContactFromJID - looks for the MCONTACT with required JID
-MCONTACT CJabberProto::HContactFromJID(const TCHAR *jid, BOOL bStripResource)
+MCONTACT CJabberProto::HContactFromJID(const TCHAR *jid, bool bStripResource)
{
if (jid == NULL)
return NULL;
@@ -71,17 +71,14 @@ MCONTACT CJabberProto::HContactFromJID(const TCHAR *jid, BOOL bStripResource)
if (item != NULL)
result = mir_tstrcmpi(jid, dbJid);
else {
- if (bStripResource == 3) {
+ if (bStripResource) {
if (bIsChat)
result = mir_tstrcmpi(jid, dbJid); // for chat room we have to have full contact matched
- else if (TRUE)
- result = _tcsnicmp(jid, dbJid, mir_tstrlen(dbJid));
else
- result = JabberCompareJids(jid, dbJid);
+ result = _tcsnicmp(jid, dbJid, mir_tstrlen(dbJid));
}
// most probably it should just look full matching contact
- else
- result = mir_tstrcmpi(jid, dbJid);
+ else result = mir_tstrcmpi(jid, dbJid);
}
if (result == 0)
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index 0e54bb6000..87c791afb1 100644
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -676,7 +676,6 @@ int g_OnToolbarInit(WPARAM, LPARAM);
//---- jabber_misc.c ------------------------------------------------
void JabberChatDllError(void);
-int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2);
TCHAR* UnEscapeChatTags(TCHAR* str_in);
//---- jabber_adhoc.cpp ---------------------------------------------