summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_adhoc.cpp2
-rw-r--r--protocols/JabberG/src/jabber_caps.cpp6
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp113
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp10
-rw-r--r--protocols/JabberG/src/jabber_events.cpp5
-rw-r--r--protocols/JabberG/src/jabber_file.cpp2
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp8
-rw-r--r--protocols/JabberG/src/jabber_list.cpp57
-rw-r--r--protocols/JabberG/src/jabber_list.h7
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp40
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp8
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp259
-rw-r--r--protocols/JabberG/src/jabber_proto.h6
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp4
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp8
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp6
-rw-r--r--protocols/JabberG/src/jabber_util.cpp61
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp2
-rw-r--r--protocols/JabberG/src/version.h9
21 files changed, 289 insertions, 328 deletions
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp
index 7dc7a8f5a4..462936715b 100644
--- a/protocols/JabberG/src/jabber_adhoc.cpp
+++ b/protocols/JabberG/src/jabber_adhoc.cpp
@@ -551,7 +551,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam)
if (wParam && !getTString(hContact, "jid", &dbv)) {
JABBER_LIST_ITEM *item = NULL;
int selected = 0;
- TCHAR jid[ JABBER_MAX_JID_LEN ];
+ TCHAR jid[JABBER_MAX_JID_LEN];
_tcsncpy(jid, dbv.ptszVal, SIZEOF(jid));
{
mir_cslock lck(m_csLists);
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index 288fe494b8..acb5fabab8 100644
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -198,7 +198,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid)
if ( !jid)
return JABBER_RESOURCE_CAPS_NONE;
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szBareJid, SIZEOF(szBareJid));
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szBareJid);
@@ -216,7 +216,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid)
if (item) {
for (int i = 0; i < item->resourceCount; i++) {
- TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szFullJid[JABBER_MAX_JID_LEN];
mir_sntprintf(szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->pResources[i].resourceName);
JabberCapsBits jcb = GetResourceCapabilites(szFullJid, FALSE);
if ( !(jcb & JABBER_RESOURCE_CAPS_ERROR))
@@ -228,7 +228,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid)
JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appendBestResource)
{
- TCHAR fullJid[ JABBER_MAX_JID_LEN ];
+ TCHAR fullJid[JABBER_MAX_JID_LEN];
if (appendBestResource)
GetClientJID(jid, fullJid, SIZEOF(fullJid));
else
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 043dc37382..48d1bf7e87 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -121,7 +121,7 @@ int JabberGcGetStatus(JABBER_RESOURCE_STATUS *r)
return JabberGcGetStatus(r->affiliation, r->role);
}
-int CJabberProto::GcInit(JABBER_LIST_ITEM* item)
+int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
{
int i;
@@ -191,7 +191,7 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM* item)
return 0;
}
-void CJabberProto::GcLogCreate(JABBER_LIST_ITEM* item)
+void CJabberProto::GcLogCreate(JABBER_LIST_ITEM *item)
{
if (item->bChatActive)
return;
@@ -276,7 +276,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, JABBER_RESOURCE_
}
}
-void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM* item, const TCHAR *resource, const TCHAR *nick, const TCHAR *jid, int action, HXML reason, int nStatusCode)
+void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const TCHAR *resource, const TCHAR *nick, const TCHAR *jid, int action, HXML reason, int nStatusCode)
{
int statusToSet = 0;
const TCHAR *szReason = NULL;
@@ -354,7 +354,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM* item, const TCHAR *
mir_free(myNick);
}
-void CJabberProto::GcQuit(JABBER_LIST_ITEM* item, int code, HXML reason)
+void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason)
{
TCHAR *szMessage = NULL;
@@ -393,7 +393,7 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM* item, int code, HXML reason)
item->bChatActive = FALSE;
if (m_bJabberOnline) {
- TCHAR szPresenceTo[ JABBER_MAX_JID_LEN ];
+ TCHAR szPresenceTo[JABBER_MAX_JID_LEN];
mir_sntprintf(szPresenceTo, SIZEOF(szPresenceTo), _T("%s/%s"), item->jid, item->nick);
m_ThreadInfo->send(
@@ -546,7 +546,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
if (lstrcmpiA(gcmi->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, gcmi->pszID);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gcmi->pszID);
if (item == NULL)
return 0;
@@ -699,7 +699,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase
{
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
- if (lstrcmpA(proto, m_proto->m_szModuleName) || db_get_b(hContact, proto, "ChatRoom", 0))
+ if (lstrcmpA(proto, m_proto->m_szModuleName) || m_proto->isChatRoom(hContact))
if (HANDLE hItem = m_clc.FindContact(hContact))
m_clc.DeleteItem(hItem);
}
@@ -731,7 +731,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase
}
public:
- CGroupchatInviteDlg(CJabberProto* ppro, TCHAR *room) :
+ CGroupchatInviteDlg(CJabberProto *ppro, TCHAR *room) :
CSuper(ppro, IDD_GROUPCHAT_INVITE, NULL),
m_newJids(1),
m_btnInvite(this, IDC_INVITE),
@@ -814,7 +814,7 @@ public:
// invite users from roster
for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
- if ( db_get_b(hContact, m_proto->m_szModuleName, "ChatRoom", 0))
+ if ( m_proto->isChatRoom(hContact))
continue;
if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0)) {
@@ -860,7 +860,7 @@ void CJabberProto::AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var,
// Member info dialog
struct TUserInfoData
{
- CJabberProto* ppro;
+ CJabberProto *ppro;
JABBER_LIST_ITEM *item;
JABBER_RESOURCE_STATUS *me, *him;
};
@@ -960,7 +960,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
if (dat->him->affiliation == value)
break;
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(dat->him->szRealJid, szBareJid, SIZEOF(szBareJid));
switch (value) {
@@ -1035,7 +1035,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
return FALSE;
}
-static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch)
+static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch)
{
JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
for (int i=0; i < item->resourceCount; i++) {
@@ -1095,7 +1095,7 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK*
mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s/%s"), item->jid, him->resourceName);
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
- JABBER_LIST_ITEM* item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
+ JABBER_LIST_ITEM *item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
item->bUseResource = TRUE;
ppro->ListAddResource(LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority);
@@ -1138,72 +1138,65 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK*
if (him->role != ROLE_VISITOR)
ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("role"), _T("visitor"));
break;
+
case IDM_SET_PARTICIPANT:
if (him->role != ROLE_PARTICIPANT)
ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("role"), _T("participant"));
break;
+
case IDM_SET_MODERATOR:
if (him->role != ROLE_MODERATOR)
ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("role"), _T("moderator"));
break;
case IDM_SET_NONE:
- if (him->affiliation != AFFILIATION_NONE)
- {
- if (him->szRealJid)
- {
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ if (him->affiliation != AFFILIATION_NONE) {
+ if (him->szRealJid) {
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("none"));
}
- else
- ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("none"));
+ else ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("none"));
}
break;
+
case IDM_SET_MEMBER:
- if (him->affiliation != AFFILIATION_MEMBER)
- {
- if (him->szRealJid)
- {
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ if (him->affiliation != AFFILIATION_MEMBER) {
+ if (him->szRealJid) {
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("member"));
}
- else
- ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("member"));
+ else ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("member"));
}
break;
+
case IDM_SET_ADMIN:
- if (him->affiliation != AFFILIATION_ADMIN)
- {
- if (him->szRealJid)
- {
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ if (him->affiliation != AFFILIATION_ADMIN) {
+ if (him->szRealJid) {
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("admin"));
}
- else
- ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("admin"));
+ else ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("admin"));
}
break;
+
case IDM_SET_OWNER:
- if (him->affiliation != AFFILIATION_OWNER)
- {
- if (him->szRealJid)
- {
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
+ if (him->affiliation != AFFILIATION_OWNER) {
+ if (him->szRealJid) {
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("owner"));
}
- else
- ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("owner"));
+ else ppro->AdminSet(item->jid, xmlnsAdmin, _T("nick"), him->resourceName, _T("affiliation"), _T("owner"));
}
break;
case IDM_SET_BAN:
if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
if (him->szRealJid && *him->szRealJid) {
- TCHAR szVictimBareJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szVictimBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(him->szRealJid, szVictimBareJid, SIZEOF(szVictimBareJid));
mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: "), me->resourceName);
@@ -1222,20 +1215,19 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK*
case IDM_LINK0: case IDM_LINK1: case IDM_LINK2: case IDM_LINK3: case IDM_LINK4:
case IDM_LINK5: case IDM_LINK6: case IDM_LINK7: case IDM_LINK8: case IDM_LINK9:
- {
- if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL)
- {
+ if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
TCHAR *resourceName_copy = NEWTSTR_ALLOCA(him->resourceName); // copy resource name to prevent possible crash if user list rebuilds
TCHAR *szInviteTo = 0;
int idx = gch->dwData - IDM_LINK0;
LISTFOREACH(i, ppro, LIST_CHATROOM)
+ {
if (JABBER_LIST_ITEM *item = ppro->ListGetItemPtrFromIndex(i))
- if ( !idx--)
- {
+ if ( !idx--) {
szInviteTo = item->jid;
break;
}
+ }
if ( !szInviteTo) break;
@@ -1256,41 +1248,40 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK*
}
dwLastBanKickTime = GetTickCount();
break;
- }
case IDM_CPY_NICK:
JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), him->resourceName);
break;
+
case IDM_RJID_COPY:
case IDM_CPY_RJID:
JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), him->szRealJid);
break;
+
case IDM_CPY_INROOMJID:
mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s/%s"), item->jid, him->resourceName);
JabberCopyText((HWND)CallService(MS_CLUI_GETHWND, 0, 0), szBuffer);
break;
case IDM_RJID_VCARD:
- if (him->szRealJid && *him->szRealJid)
- {
+ if (him->szRealJid && *him->szRealJid) {
HANDLE hContact;
JABBER_SEARCH_RESULT jsr ={0};
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), him->szRealJid);
if (TCHAR *tmp = _tcschr(jsr.jid, _T('/'))) *tmp = 0;
- JABBER_LIST_ITEM* item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
+ JABBER_LIST_ITEM *item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
item->bUseResource = TRUE;
ppro->ListAddResource(LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority);
hContact = (HANDLE)CallProtoService(ppro->m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
- break;
}
+ break;
case IDM_RJID_ADD:
- if (him->szRealJid && *him->szRealJid)
- {
+ if (him->szRealJid && *him->szRealJid) {
JABBER_SEARCH_RESULT jsr={0};
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
@@ -1303,12 +1294,12 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK*
acs.szProto = ppro->m_szModuleName;
acs.psr = (PROTOSEARCHRESULT *)&jsr;
CallService(MS_ADDCONTACT_SHOW, (WPARAM)CallService(MS_CLUI_GETHWND, 0, 0), (LPARAM)&acs);
- break;
}
+ break;
}
}
-static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch)
+static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch)
{
TCHAR szCaption[1024], szBuffer[1024];
szBuffer[ 0 ] = _T('\0');
@@ -1371,7 +1362,7 @@ static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* g
if (item->nick)
mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick);
if (ppro->EnterString(szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_")) {
- JABBER_LIST_ITEM* item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
+ JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
if (item != NULL) {
TCHAR text[ 1024 ];
mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), gch->pDest->ptszID, szBuffer);
@@ -1398,7 +1389,7 @@ static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* g
}
case IDM_BOOKMARKS:
{
- JABBER_LIST_ITEM* item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID);
+ JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID);
if (item == NULL) {
item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
if (item != NULL) {
@@ -1469,9 +1460,9 @@ static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* g
/////////////////////////////////////////////////////////////////////////////////////////
// Sends a private message to a chat user
-static void sttSendPrivateMessage(CJabberProto* ppro, JABBER_LIST_ITEM* item, const TCHAR *nick)
+static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, const TCHAR *nick)
{
- TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szFullJid[JABBER_MAX_JID_LEN];
mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), item->jid, nick);
HANDLE hContact = ppro->DBCreateContact(szFullJid, NULL, TRUE, FALSE);
if (hContact != NULL) {
@@ -1499,7 +1490,7 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
if (lstrcmpiA(gch->pDest->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
if (item == NULL)
return 0;
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index 936127362b..1d12223d3f 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -382,7 +382,7 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode* pNode, HXML parent)
void CJabberProto::PerformBrowse(HWND hwndDlg)
{
- TCHAR szJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szJid[JABBER_MAX_JID_LEN];
TCHAR szNode[ 512 ];
if ( !GetDlgItemText(hwndDlg, IDC_COMBO_JID, szJid, SIZEOF(szJid)))
szJid[ 0 ] = 0;
@@ -1400,7 +1400,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
case SD_ACT_BOOKMARK:
{
- JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid());
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid());
if (item == NULL) {
item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid());
if (item == NULL) {
@@ -1419,7 +1419,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
HANDLE hContact = HContactFromJID(pNode->GetJid());
if ( !hContact) {
hContact = DBCreateContact(pNode->GetJid(), pNode->GetName(), TRUE, FALSE);
- JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
+ JABBER_LIST_ITEM *item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
}
HMENU hContactMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
@@ -1440,7 +1440,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
hContact = (HANDLE)CallProtoService(m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
}
if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == NULL) {
- JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
+ JABBER_LIST_ITEM *item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
if (item->pResources == NULL)
ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0);
@@ -1453,7 +1453,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
{
HANDLE hContact = DBCreateContact(pNode->GetJid(), pNode->GetName(), FALSE, FALSE);
db_unset(hContact, "CList", "NotOnList");
- JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
+ JABBER_LIST_ITEM *item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
break;
}
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index 46412d2798..2a66c60b84 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -43,8 +43,9 @@ int CJabberProto::OnContactDeleted(WPARAM wParam, LPARAM)
if ( !m_bJabberOnline) // should never happen
return 0;
+ HANDLE hContact = (HANDLE)wParam;
DBVARIANT dbv;
- if ( !getTString((HANDLE)wParam, getByte((HANDLE) wParam, "ChatRoom", 0)?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
+ if ( !getTString(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid", &dbv)) {
if (ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) {
if ( !_tcschr(dbv.ptszVal, _T('@'))) {
TCHAR szStrippedJid[JABBER_MAX_JID_LEN];
@@ -113,7 +114,7 @@ void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING* cws, HANDLE hCon
}
}
else {
- TCHAR* p = sttSettingToTchar(cws);
+ TCHAR *p = sttSettingToTchar(cws);
if (cws->value.pszVal != NULL && lstrcmp(p, item->group)) {
Log("Group set to %S", p);
if (p)
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 69c55e3703..e7ed1f618f 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -291,7 +291,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
if (ft->httpPath) mir_free(ft->httpPath);
ft->httpPath = NULL;
- TCHAR* p;
+ TCHAR *p;
if ((p = _tcschr(ft->std.ptszFiles[i], '\\')) != NULL)
p++;
else
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 301af8caf8..71dfb28880 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -239,7 +239,7 @@ INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM wParam, LPARAM)
if ( !jabberChatDllPresent)
JabberChatDllError();
else {
- TCHAR* p = _tcschr(jid.ptszVal, '@');
+ TCHAR *p = _tcschr(jid.ptszVal, '@');
if (p != NULL) {
*p++ = 0;
GroupchatJoinRoom(p, jid.ptszVal, nick.ptszVal, password);
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index cfbb8be86a..846208a241 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -640,7 +640,7 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
SetContactOfflineStatus(hContact);
ListRemove(LIST_ROSTER, jid);
} }
- else if (getByte(hContact, "ChatRoom", 0))
+ else if ( isChatRoom(hContact))
db_unset(hContact, "CList", "Hidden");
else
UpdateSubscriptionInfo(hContact, item);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 38a944eeb9..7dcb813a5c 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -465,7 +465,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
}
else db_unset(hContact, "CList", "MyHandle");
- if (getByte(hContact, "ChatRoom", 0)) {
+ if ( isChatRoom(hContact)) {
GCSESSION gcw = {0};
gcw.cbSize = sizeof(GCSESSION);
gcw.iType = GCW_CHATROOM;
@@ -474,7 +474,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
gcw.ptszID = jid;
gcw.ptszName = NEWTSTR_ALLOCA(jid);
- TCHAR* p = (TCHAR*)_tcschr(gcw.ptszName, '@');
+ TCHAR *p = (TCHAR*)_tcschr(gcw.ptszName, '@');
if (p)
*p = 0;
@@ -1400,7 +1400,7 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode)
}
if (n == NULL) {
- TCHAR szJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szJid[JABBER_MAX_JID_LEN];
lstrcpyn(szJid, from, SIZEOF(szJid));
TCHAR *res = _tcschr(szJid, _T('/'));
if (res != NULL)
@@ -1448,7 +1448,7 @@ void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode)
}
if (n == NULL) {
- TCHAR szJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szJid[JABBER_MAX_JID_LEN];
lstrcpyn(szJid, from, SIZEOF(szJid));
TCHAR *res = _tcschr(szJid, _T('/'));
if (res != NULL)
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index 3c12848bb3..9ad7c79bce 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -139,8 +139,8 @@ void CJabberProto::ListRemove(JABBER_LIST list, const TCHAR *jid)
mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
if (LI != NULL) {
- JabberListFreeItemInternal(LI);
m_lstRoster.remove(LI);
+ JabberListFreeItemInternal(LI);
}
}
@@ -333,37 +333,29 @@ void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid)
MenuUpdateSrmmIcon(LI);
}
-TCHAR* CJabberProto::ListGetBestResourceNamePtr(const TCHAR *jid)
+JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getBestResource() const
{
- mir_cslock lck(m_csLists);
- JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
- if (LI == NULL)
+ if (!resourceCount)
return NULL;
- TCHAR *res = NULL;
+ if (resourceCount == 1)
+ return pResources;
- if (LI->resourceCount > 1) {
- if (LI->resourceMode == RSMODE_LASTSEEN && LI->pLastSeenResource)
- res = LI->pLastSeenResource->resourceName;
- else if (LI->resourceMode == RSMODE_MANUAL && LI->pManualResource)
- res = LI->pManualResource->resourceName;
- else {
- int nBestPos = -1, nBestPri = -200;
- for (int j = 0; j < LI->resourceCount; j++) {
- if (LI->pResources[ j ].priority > nBestPri) {
- nBestPri = LI->pResources[ j ].priority;
- nBestPos = j;
- }
- }
- if (nBestPos != -1)
- res = LI->pResources[nBestPos].resourceName;
- }
- }
+ if (resourceMode == RSMODE_LASTSEEN)
+ return pLastSeenResource;
- if (!res && LI->pResources)
- res = LI->pResources[0].resourceName;
+ if (resourceMode == RSMODE_MANUAL)
+ return pManualResource;
- return res;
+ int nBestPos = -1, nBestPri = -200;
+ for (int j=0; j < resourceCount; j++) {
+ if (pResources[j].priority > nBestPri) {
+ nBestPri = pResources[j].priority;
+ nBestPos = j;
+ }
+ }
+
+ return (nBestPos != -1) ? &pResources[nBestPos] : NULL;
}
TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
@@ -373,13 +365,12 @@ TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
if (LI == NULL)
return NULL;
- TCHAR *res = ListGetBestResourceNamePtr(jid);
- if (res != NULL)
- return res;
+ JABBER_RESOURCE_STATUS *r = LI->getBestResource();
+ if (r != NULL)
+ return r->resourceName;
- JABBER_RESOURCE_STATUS *r = LI->pResources;
int status = ID_STATUS_OFFLINE;
- res = NULL;
+ TCHAR *res = NULL;
for (int i=0; i < LI->resourceCount; i++) {
bool foundBetter = false;
switch (r[i].status) {
@@ -404,8 +395,8 @@ TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
break;
}
if (foundBetter) {
- res = r[i].resourceName;
- status = r[i].status;
+ res = LI->pResources[i].resourceName;
+ status = LI->pResources[i].status;
} }
return res;
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h
index 7a4cf77a27..b73c09bf49 100644
--- a/protocols/JabberG/src/jabber_list.h
+++ b/protocols/JabberG/src/jabber_list.h
@@ -105,7 +105,7 @@ struct JABBER_RESOURCE_STATUS
JABBER_XEP0232_SOFTWARE_INFO* pSoftwareInfo;
};
-struct JABBER_LIST_ITEM
+struct JABBER_LIST_ITEM : public MZeroedObject
{
JABBER_LIST list;
TCHAR* jid;
@@ -113,13 +113,16 @@ struct JABBER_LIST_ITEM
// LIST_ROSTER
// jid = jid of the contact
TCHAR* nick;
+
+ JABBER_RESOURCE_STATUS* getBestResource() const;
+ JABBER_RESOURCE_MODE resourceMode;
int resourceCount;
JABBER_RESOURCE_STATUS
*pResources, // array of resources
*pLastSeenResource, // resource which was last seen active
*pManualResource, // manually set resource
itemResource; // resource for jids without /resource node
- JABBER_RESOURCE_MODE resourceMode;
+
JABBER_SUBSCRIPTION subscription;
TCHAR* group;
TCHAR* photoFileName;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 9390b7317e..e4bc58399b 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -355,8 +355,8 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
if ((hContact=(HANDLE)wParam) == NULL)
return 0;
- BYTE bIsChatRoom = (BYTE)getByte(hContact, "ChatRoom", 0);
- BYTE bIsTransport = (BYTE)getByte(hContact, "IsTransport", 0);
+ bool bIsChatRoom = isChatRoom(hContact);
+ bool bIsTransport = getBool(hContact, "IsTransport", false);
if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
if ( !getTString(hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
@@ -484,15 +484,17 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM wParam, LPARAM)
{
- BYTE bIsChatRoom = (BYTE)getByte((HANDLE) wParam, "ChatRoom", 0);
- if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
- DBVARIANT dbv;
- if ( !getTString((HANDLE) wParam, (bIsChatRoom == GCW_CHATROOM)?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
- delSetting((HANDLE) wParam, (bIsChatRoom == GCW_CHATROOM)?"ChatRoomID":"jid");
- setTString((HANDLE) wParam, (bIsChatRoom != GCW_CHATROOM)?"ChatRoomID":"jid", dbv.ptszVal);
- db_free(&dbv);
- setByte((HANDLE) wParam, "ChatRoom", (bIsChatRoom == GCW_CHATROOM)?0:GCW_CHATROOM);
- } }
+ HANDLE hContact = (HANDLE)wParam;
+ BYTE bIsChatRoom = isChatRoom(hContact);
+ const char *szSetting = (bIsChatRoom) ? "ChatRoomID" : "jid";
+
+ DBVARIANT dbv;
+ if ( !getTString(hContact, szSetting, &dbv)) {
+ delSetting(hContact, szSetting);
+ setTString(hContact, szSetting, dbv.ptszVal);
+ db_free(&dbv);
+ setByte(hContact, "ChatRoom", !bIsChatRoom);
+ }
return 0;
}
@@ -1053,22 +1055,22 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
bSupportTyping = dbv.bVal == 1;
db_free(&dbv);
}
- if (bSupportTyping && !getTString(event->hContact, "jid", &dbv)) {
- TCHAR jid[ JABBER_MAX_JID_LEN ];
- GetClientJID(dbv.ptszVal, jid, SIZEOF(jid));
- db_free(&dbv);
+ if (!bSupportTyping)
+ return 0;
+ TCHAR jid[JABBER_MAX_JID_LEN];
+ if ( GetClientJID(event->hContact, jid, SIZEOF(jid))) {
JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(jid);
-
if (r && r->bMessageSessionActive) {
r->bMessageSessionActive = FALSE;
- JabberCapsBits jcb = GetResourceCapabilites(jid, TRUE);
- if (jcb & JABBER_CAPS_CHATSTATES)
+ if (GetResourceCapabilites(jid, TRUE) & JABBER_CAPS_CHATSTATES)
m_ThreadInfo->send(
XmlNode(_T("message")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("chat")) << XATTRID( SerialNext())
<< XCHILDNS(_T("gone"), _T(JABBER_FEAT_CHATSTATES)));
- } } }
+ }
+ }
+ }
return 0;
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 6fb71eedf7..0d2c0e54a1 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -58,7 +58,7 @@ int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
return 0;
// match only node@domain part
- TCHAR szTempJid1[ JABBER_MAX_JID_LEN ], szTempJid2[ JABBER_MAX_JID_LEN ];
+ TCHAR szTempJid1[JABBER_MAX_JID_LEN], szTempJid2[JABBER_MAX_JID_LEN];
return lstrcmpi(
JabberStripJid(jid1, szTempJid1, SIZEOF(szTempJid1)),
JabberStripJid(jid2, szTempJid2, SIZEOF(szTempJid2)));
@@ -325,7 +325,7 @@ void CJabberProto::ResolveTransportNicks(const TCHAR *jid)
continue;
}
- TCHAR* p = _tcschr(dbv.ptszVal, '@');
+ TCHAR *p = _tcschr(dbv.ptszVal, '@');
if (p) {
*p = 0;
if ( !lstrcmp(jid, p+1) && !lstrcmp(dbv.ptszVal, nick.ptszVal)) {
@@ -388,7 +388,7 @@ void CJabberProto::SetServerStatus(int iNewStatus)
TCHAR* EscapeChatTags(TCHAR* pszText)
{
int nChars = 0;
- for (TCHAR* p = pszText; (p = _tcschr(p, '%')) != NULL; p++)
+ for (TCHAR *p = pszText; (p = _tcschr(p, '%')) != NULL; p++)
nChars++;
if (nChars == 0)
@@ -547,7 +547,7 @@ void CJabberProto::UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resourc
DBVARIANT dbv;
if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szFullJid[JABBER_MAX_JID_LEN];
if (resource->resourceName)
mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), dbv.ptszVal, resource->resourceName);
else
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index fa3434d260..e38e06cb8a 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -693,13 +693,8 @@ DWORD_PTR __cdecl CJabberProto::GetCaps(int type, HANDLE hContact)
case PFLAG_UNIQUEIDSETTING:
return (DWORD_PTR)"jid";
case PFLAG_MAXCONTACTSPERPACKET:
- {
- DBVARIANT dbv;
- if (getTString(hContact, "jid", &dbv))
- return 0;
- TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
- db_free(&dbv);
+ TCHAR szClientJid[JABBER_MAX_JID_LEN];
+ if ( GetClientJID(hContact, szClientJid, SIZEOF(szClientJid))) {
JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
return ((~jcb & JABBER_CAPS_ROSTER_EXCHANGE) ? 0 : 50);
}
@@ -712,96 +707,87 @@ DWORD_PTR __cdecl CJabberProto::GetCaps(int type, HANDLE hContact)
int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/)
{
- if ( !m_bJabberOnline)
+ if ( !m_bJabberOnline || isChatRoom(hContact))
return 1;
- int result = 1;
- DBVARIANT dbv;
- if (getByte(hContact, "ChatRoom", 0))
+ TCHAR jid[JABBER_MAX_JID_LEN];
+ if ( !GetClientJID(hContact, jid, SIZEOF(jid)))
return 1;
-
- if ( !getTString(hContact, "jid", &dbv)) {
- if (m_ThreadInfo) {
- TCHAR jid[ JABBER_MAX_JID_LEN ];
- GetClientJID(dbv.ptszVal, jid, SIZEOF(jid));
-
- m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
- << XCHILDNS(_T("time"), _T(JABBER_FEAT_ENTITY_TIME)));
-
- // XEP-0012, last logoff time
- XmlNodeIq iq2(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, dbv.ptszVal, JABBER_IQ_PARSE_FROM));
- iq2 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
- m_ThreadInfo->send(iq2);
-
- JABBER_LIST_ITEM *item = NULL;
-
- if ((item = ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)) == NULL)
- item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
-
- if ( !item) {
- TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- _tcsncpy(szBareJid, dbv.ptszVal, SIZEOF(szBareJid));
- TCHAR* pDelimiter = _tcschr(szBareJid, _T('/'));
- if (pDelimiter) {
- *pDelimiter = 0;
- pDelimiter++;
- if ( !*pDelimiter)
- pDelimiter = NULL;
+
+ if (m_ThreadInfo) {
+ m_ThreadInfo->send(
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
+ << XCHILDNS(_T("time"), _T(JABBER_FEAT_ENTITY_TIME)));
+
+ // XEP-0012, last logoff time
+ XmlNodeIq iq2(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
+ iq2 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
+ m_ThreadInfo->send(iq2);
+
+ JABBER_LIST_ITEM *item = NULL;
+
+ if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ item = ListGetItemPtr(LIST_ROSTER, jid);
+
+ if ( !item) {
+ TCHAR szBareJid[JABBER_MAX_JID_LEN];
+ _tcsncpy(szBareJid, jid, SIZEOF(szBareJid));
+ TCHAR* pDelimiter = _tcschr(szBareJid, _T('/'));
+ if (pDelimiter) {
+ *pDelimiter = 0;
+ pDelimiter++;
+ if ( !*pDelimiter)
+ pDelimiter = NULL;
+ }
+ JABBER_LIST_ITEM *tmpItem = NULL;
+ if (pDelimiter && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) {
+ JABBER_RESOURCE_STATUS *him = NULL;
+ for (int i=0; i < tmpItem->resourceCount; i++) {
+ JABBER_RESOURCE_STATUS &p = tmpItem->pResources[i];
+ if ( !lstrcmp(p.resourceName, pDelimiter))
+ him = &p;
}
- JABBER_LIST_ITEM *tmpItem = NULL;
- if (pDelimiter && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) {
- JABBER_RESOURCE_STATUS *him = NULL;
- for (int i=0; i < tmpItem->resourceCount; i++) {
- JABBER_RESOURCE_STATUS &p = tmpItem->pResources[i];
- if ( !lstrcmp(p.resourceName, pDelimiter))
- him = &p;
- }
- if (him) {
- item = ListAdd(LIST_VCARD_TEMP, dbv.ptszVal);
- ListAddResource(LIST_VCARD_TEMP, dbv.ptszVal, him->status, him->statusMessage, him->priority);
- }
+ if (him) {
+ item = ListAdd(LIST_VCARD_TEMP, jid);
+ ListAddResource(LIST_VCARD_TEMP, jid, him->status, him->statusMessage, him->priority);
}
- else
- item = ListAdd(LIST_VCARD_TEMP, dbv.ptszVal);
}
+ else
+ item = ListAdd(LIST_VCARD_TEMP, jid);
+ }
- if (item) {
- if (item->pResources) {
- for (int i = 0; i < item->resourceCount; i++) {
- TCHAR szp1[ JABBER_MAX_JID_LEN ];
- JabberStripJid(dbv.ptszVal, szp1, SIZEOF(szp1));
- mir_sntprintf(jid, 256, _T("%s/%s"), szp1, item->pResources[i].resourceName);
-
- XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
- iq3 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
- m_ThreadInfo->send(iq3);
-
- if ( !item->pResources[i].dwVersionRequestTime) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
- iq4 << XQUERY(_T(JABBER_FEAT_VERSION));
- m_ThreadInfo->send(iq4);
- }
+ if (item && item->pResources) {
+ for (int i = 0; i < item->resourceCount; i++) {
+ TCHAR szp1[JABBER_MAX_JID_LEN], tmp[JABBER_MAX_JID_LEN];
+ JabberStripJid(jid, szp1, SIZEOF(szp1));
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, item->pResources[i].resourceName);
- if ( !item->pResources[i].pSoftwareInfo) {
- XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
- iq5 << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
- m_ThreadInfo->send(iq5);
- }
- }
- }
- else if ( !item->itemResource.dwVersionRequestTime) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
+ iq3 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
+ m_ThreadInfo->send(iq3);
+
+ if ( !item->pResources[i].dwVersionRequestTime) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
iq4 << XQUERY(_T(JABBER_FEAT_VERSION));
m_ThreadInfo->send(iq4);
- } } }
+ }
- SendGetVcard(dbv.ptszVal);
- db_free(&dbv);
- result = 0;
+ if ( !item->pResources[i].pSoftwareInfo) {
+ XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
+ iq5 << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ m_ThreadInfo->send(iq5);
+ }
+ }
+ }
+ else if ( !item->itemResource.dwVersionRequestTime) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ iq4 << XQUERY(_T(JABBER_FEAT_VERSION));
+ m_ThreadInfo->send(iq4);
+ }
}
- return result;
+ SendGetVcard(jid);
+ return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -983,13 +969,12 @@ int __cdecl CJabberProto::RecvUrl(HANDLE /*hContact*/, PROTORECVEVENT*)
int __cdecl CJabberProto::SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList)
{
- DBVARIANT dbv;
- if ( !m_bJabberOnline || getTString(hContact, "jid", &dbv))
+ if (!m_bJabberOnline)
return 0;
- TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
- db_free(&dbv);
+ TCHAR szClientJid[JABBER_MAX_JID_LEN];
+ if ( !GetClientJID(hContact, szClientJid, SIZEOF(szClientJid)))
+ return 0;
JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
if (~jcb & JABBER_CAPS_ROSTER_EXCHANGE)
@@ -1000,9 +985,9 @@ int __cdecl CJabberProto::SendContacts(HANDLE hContact, int flags, int nContacts
HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_ROSTER_EXCHANGE));
for (int i = 0; i < nContacts; i++) {
+ DBVARIANT dbv;
if ( !getTString(hContactsList[i], "jid", &dbv)) {
- x << XCHILD(_T("item")) << XATTR(_T("action"), _T("add")) <<
- XATTR(_T("jid"), dbv.ptszVal);
+ x << XCHILD(_T("item")) << XATTR(_T("action"), _T("add")) << XATTR(_T("jid"), dbv.ptszVal);
db_free(&dbv);
}
}
@@ -1030,7 +1015,7 @@ HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescriptio
int i, j;
struct _stati64 statbuf;
- JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
if (item == NULL) {
db_free(&dbv);
return 0;
@@ -1136,8 +1121,8 @@ static char PGP_EPILOG[] = "\r\n-----END PGP MESSAGE-----\r\n";
int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
{
- ptrT ptszJid( db_get_tsa(hContact, m_szModuleName, "jid"));
- if ( !m_bJabberOnline || ptszJid == NULL) {
+ TCHAR szClientJid[JABBER_MAX_JID_LEN];
+ if ( !m_bJabberOnline || !GetClientJID(hContact, szClientJid, SIZEOF(szClientJid))) {
TFakeAckParams *param = new TFakeAckParams(hContact, Translate("Protocol is offline or no jid"));
ForkThread(&CJabberProto::SendMessageAckThread, param);
return 1;
@@ -1169,7 +1154,7 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc
return 0;
TCHAR *msgType;
- if (ListGetItemPtr(LIST_CHATROOM, ptszJid) && _tcschr(ptszJid, '/') == NULL)
+ if (ListGetItemPtr(LIST_CHATROOM, szClientJid) && _tcschr(szClientJid, '/') == NULL)
msgType = _T("groupchat");
else
msgType = _T("chat");
@@ -1183,9 +1168,6 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc
}
mir_free(msg);
- TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID(ptszJid, szClientJid, SIZEOF(szClientJid));
-
JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(szClientJid);
if (r)
r->bMessageSessionActive = TRUE;
@@ -1209,7 +1191,7 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc
!m_options.MsgAck || !getByte(hContact, "MsgAck", TRUE))
{
if ( !lstrcmp(msgType, _T("groupchat")))
- xmlAddAttr(m, _T("to"), (TCHAR*)ptszJid);
+ xmlAddAttr(m, _T("to"), szClientJid);
else {
id = SerialNext();
xmlAddAttr(m, _T("to"), szClientJid); xmlAddAttrID(m, id);
@@ -1477,50 +1459,49 @@ int __cdecl CJabberProto::UserIsTyping(HANDLE hContact, int type)
{
if ( !m_bJabberOnline) return 0;
- DBVARIANT dbv;
- if (getTString(hContact, "jid", &dbv))
+ TCHAR szClientJid[JABBER_MAX_JID_LEN];
+ if ( !GetClientJID(hContact, szClientJid, SIZEOF(szClientJid)))
return 0;
- JABBER_LIST_ITEM *item;
- if ((item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) != NULL) {
- TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
-
- JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
- if (jcb & JABBER_RESOURCE_CAPS_ERROR)
- jcb = JABBER_RESOURCE_CAPS_NONE;
-
- XmlNode m(_T("message")); xmlAddAttr(m, _T("to"), szClientJid);
-
- if (jcb & JABBER_CAPS_CHATSTATES) {
- m << XATTR(_T("type"), _T("chat")) << XATTRID(SerialNext());
- switch (type) {
- case PROTOTYPE_SELFTYPING_OFF:
- m << XCHILDNS(_T("paused"), _T(JABBER_FEAT_CHATSTATES));
- m_ThreadInfo->send(m);
- break;
- case PROTOTYPE_SELFTYPING_ON:
- m << XCHILDNS(_T("composing"), _T(JABBER_FEAT_CHATSTATES));
- m_ThreadInfo->send(m);
- break;
- }
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szClientJid);
+ if (item == NULL)
+ return 0;
+
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ if (jcb & JABBER_RESOURCE_CAPS_ERROR)
+ jcb = JABBER_RESOURCE_CAPS_NONE;
+
+ XmlNode m(_T("message")); xmlAddAttr(m, _T("to"), szClientJid);
+
+ if (jcb & JABBER_CAPS_CHATSTATES) {
+ m << XATTR(_T("type"), _T("chat")) << XATTRID(SerialNext());
+ switch (type) {
+ case PROTOTYPE_SELFTYPING_OFF:
+ m << XCHILDNS(_T("paused"), _T(JABBER_FEAT_CHATSTATES));
+ m_ThreadInfo->send(m);
+ break;
+ case PROTOTYPE_SELFTYPING_ON:
+ m << XCHILDNS(_T("composing"), _T(JABBER_FEAT_CHATSTATES));
+ m_ThreadInfo->send(m);
+ break;
}
- else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
- HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
- if (item->messageEventIdStr != NULL)
- x << XCHILD(_T("id"), item->messageEventIdStr);
-
- switch (type) {
- case PROTOTYPE_SELFTYPING_OFF:
- m_ThreadInfo->send(m);
- break;
- case PROTOTYPE_SELFTYPING_ON:
- x << XCHILD(_T("composing"));
- m_ThreadInfo->send(m);
- break;
- } } }
+ }
+ else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
+ if (item->messageEventIdStr != NULL)
+ x << XCHILD(_T("id"), item->messageEventIdStr);
+
+ switch (type) {
+ case PROTOTYPE_SELFTYPING_OFF:
+ m_ThreadInfo->send(m);
+ break;
+ case PROTOTYPE_SELFTYPING_ON:
+ x << XCHILD(_T("composing"));
+ m_ThreadInfo->send(m);
+ break;
+ }
+ }
- db_free(&dbv);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 319a2a4b32..93bbe613cd 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -655,7 +655,6 @@ struct CJabberProto : public PROTO<CJabberProto>
JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid);
int ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority = 0, const TCHAR *nick = NULL);
void ListRemoveResource(JABBER_LIST list, const TCHAR *jid);
- TCHAR* ListGetBestResourceNamePtr(const TCHAR *jid);
TCHAR* ListGetBestClientResourceNamePtr(const TCHAR *jid);
void SetMucConfig(HXML node, void *from);
@@ -877,9 +876,12 @@ struct CJabberProto : public PROTO<CJabberProto>
void SendPresenceTo(int status, TCHAR* to, HXML extra, const TCHAR *msg = NULL);
void SendPresence(int m_iStatus, bool bSendToAll);
void StringAppend(char* *str, int *sizeAlloced, const char* fmt, ...);
- TCHAR* GetClientJID(const TCHAR *jid, TCHAR*, size_t);
void RebuildInfoFrame(void);
+ // returns buf or NULL on error
+ TCHAR* GetClientJID(HANDLE hContact, TCHAR *dest, size_t destLen);
+ TCHAR* GetClientJID(const TCHAR *jid, TCHAR *dest, size_t destLen);
+
void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, TCHAR *string, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
BOOL EnterString(TCHAR *result, size_t resultLen, TCHAR *caption=NULL, int type=0, char *windowName=NULL, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0);
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index eb01bc219a..917e5e0d80 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -589,7 +589,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
<< XCHILD(_T("body"), szEventText);
HXML addressesNode = msg << XCHILDNS(_T("addresses"), _T(JABBER_FEAT_EXT_ADDRESSING));
- TCHAR szOFrom[ JABBER_MAX_JID_LEN ];
+ TCHAR szOFrom[JABBER_MAX_JID_LEN];
EnterCriticalSection(&m_csLastResourceMap);
TCHAR *szOResource = FindLastResourceByDbEvent(hDbEvent);
if (szOResource)
@@ -791,7 +791,7 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo* pInfo, CJabbe
for (i = 0; i < xmlGetChildCount(fieldNode); i++) {
HXML valueNode = xmlGetChild(fieldNode, i);
if (valueNode && xmlGetName(valueNode) && xmlGetText(valueNode) && !_tcscmp(xmlGetName(valueNode), _T("value"))) {
- JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, xmlGetText(valueNode));
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, xmlGetText(valueNode));
if (item)
GcQuit(item, 0, NULL);
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index b220aaafe5..d1d5f9f6f8 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -156,7 +156,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
if (item != NULL) {
BOOL isXVcard = getByte(AI->hContact, "AvatarXVcard", 0);
- TCHAR szJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szJid[JABBER_MAX_JID_LEN];
if (item->resourceCount != NULL && !isXVcard) {
TCHAR *bestResName = ListGetBestClientResourceNamePtr(dbv.ptszVal);
mir_sntprintf(szJid, SIZEOF(szJid), bestResName?_T("%s/%s"):_T("%s"), dbv.ptszVal, bestResName);
@@ -384,7 +384,7 @@ static void appendString(bool bIsTipper, const TCHAR *tszTitle, const TCHAR *tsz
if (bIsTipper)
mir_sntprintf(buf, bufSize, _T("%s%s%s%s"), _T("<b>"), TranslateTS(tszTitle), _T("</b>\t"), tszValue);
else {
- TCHAR* p = TranslateTS(tszTitle);
+ TCHAR *p = TranslateTS(tszTitle);
mir_sntprintf(buf, bufSize, _T("%s%s\t%s"), p, _tcslen(p)<=7 ? _T("\t") : _T(""), tszValue);
}
}
@@ -591,7 +591,7 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM wParam, LPARAM)
HANDLE hContact = (HANDLE)wParam;
DBVARIANT dbv;
if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR tszJid[ JABBER_MAX_JID_LEN ];
+ TCHAR tszJid[JABBER_MAX_JID_LEN];
TCHAR *szResource = ListGetBestClientResourceNamePtr(dbv.ptszVal);
if (szResource)
mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), dbv.ptszVal, szResource);
@@ -788,7 +788,7 @@ HANDLE CJabberSysInterface::ContactFromJID(LPCTSTR jid)
LPTSTR CJabberSysInterface::ContactToJID(HANDLE hContact)
{
- return db_get_tsa(hContact, m_psProto->m_szModuleName, m_psProto->getByte(hContact, "ChatRoom", 0) ? "ChatRoomID" : "jid");
+ return db_get_tsa(hContact, m_psProto->m_szModuleName, m_psProto->isChatRoom(hContact) ? "ChatRoomID" : "jid");
}
LPTSTR CJabberSysInterface::GetBestResourceName(LPCTSTR jid)
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 7a89eae152..5ab49961be 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1176,7 +1176,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info)
const TCHAR *szJid = xmlGetAttrValue(addressNode, _T("jid"));
if (szJid) {
size_t cbLen = _tcslen(szMessage) + 1000;
- TCHAR* p = (TCHAR*)alloca(sizeof(TCHAR) * cbLen);
+ TCHAR *p = (TCHAR*)alloca(sizeof(TCHAR) * cbLen);
mir_sntprintf(p, cbLen, TranslateT("Message redirected from: %s\r\n%s"), from, szMessage);
szMessage = p;
from = szJid;
@@ -1615,9 +1615,9 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info)
}
BOOL bSelfPresence = FALSE;
- TCHAR szBareFrom[ JABBER_MAX_JID_LEN ];
+ TCHAR szBareFrom[JABBER_MAX_JID_LEN];
JabberStripJid(from, szBareFrom, SIZEOF(szBareFrom));
- TCHAR szBareOurJid[ JABBER_MAX_JID_LEN ];
+ TCHAR szBareOurJid[JABBER_MAX_JID_LEN];
JabberStripJid(info->fullJID, szBareOurJid, SIZEOF(szBareOurJid));
if ( !_tcsicmp(szBareFrom, szBareOurJid))
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index dac07bd2d8..3a89c0815e 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -84,7 +84,7 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
int result;
result = lstrcmpi(jid, dbv.ptszVal);
db_free(&dbv);
- if ( !result && getByte(hContact, "ChatRoom", 0) != 0)
+ if ( !result && isChatRoom(hContact))
return hContact;
} }
@@ -102,21 +102,16 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource)
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid);
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- int result;
- //safer way to check UID (coz some contact have both setting from convert to chat)
- if (db_get_b(hContact, m_szModuleName, "ChatRoom",0))
- result = getTString(hContact, "ChatRoomID", &dbv);
- else
- result = getTString(hContact, "jid", &dbv);
+ bool bIsChat = isChatRoom(hContact);
- if ( !result) {
+ DBVARIANT dbv;
+ if ( !getTString(hContact, bIsChat ? "ChatRoomID" : "jid", &dbv)) {
int result;
if (item != NULL)
result = lstrcmpi(jid, dbv.ptszVal);
else {
if (bStripResource == 3) {
- if (getByte(hContact, "ChatRoom", 0))
+ if (bIsChat)
result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
else if (TRUE)
result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
@@ -461,7 +456,7 @@ WCHAR* __stdcall JabberUnixToDosW(const WCHAR* str)
TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str)
{
- TCHAR* p, *q, *res;
+ TCHAR *p, *q, *res;
if (str == NULL) return NULL;
res = (TCHAR*) mir_alloc(3*_tcslen(str) + 1);
@@ -480,7 +475,7 @@ TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str)
void __stdcall JabberHttpUrlDecode(TCHAR* str)
{
- TCHAR* p, *q;
+ TCHAR *p, *q;
unsigned int code;
if (str == NULL) return;
@@ -1050,32 +1045,33 @@ int __stdcall JabberGetPacketID(HXML n)
///////////////////////////////////////////////////////////////////////////////
// JabberGetClientJID - adds a resource postfix to a JID
-TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR* dest, size_t destLen)
+TCHAR* CJabberProto::GetClientJID(HANDLE hContact, TCHAR *dest, size_t destLen)
{
- if (jid == NULL)
+ if (hContact == NULL)
return NULL;
- size_t len = _tcslen(jid);
- if (len >= destLen)
- len = destLen-1;
+ ptrT jid( db_get_tsa(hContact, m_szModuleName, "jid"));
+ return GetClientJID(jid, dest, destLen);
+}
- _tcsncpy(dest, jid, len);
- dest[ len ] = '\0';
+TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR *dest, size_t destLen)
+{
+ if (jid == NULL)
+ return NULL;
- TCHAR* p = _tcschr(dest, '/');
+ _tcsncpy_s(dest, destLen, jid, _TRUNCATE);
+ TCHAR *p = _tcschr(dest, '/');
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
- if (LI && LI->resourceCount == 1 && LI->pResources[ 0 ].szCapsNode &&
- _tcsicmp(LI->pResources[ 0 ].szCapsNode, _T("http://talk.google.com/xmpp/bot/caps")) == 0)
- {
+ if (LI && LI->resourceCount == 1 && !lstrcmp(LI->pResources->szCapsNode, _T("http://talk.google.com/xmpp/bot/caps"))) {
if (p) *p = 0;
return dest;
}
if (p == NULL) {
- TCHAR* resource = ListGetBestResourceNamePtr(jid);
- if (resource != NULL)
- mir_sntprintf(dest+len, destLen-len-1, _T("/%s"), resource);
+ JABBER_RESOURCE_STATUS *r = LI->getBestResource();
+ if (r != NULL)
+ mir_sntprintf(dest, destLen, _T("%s/%s"), jid, r->resourceName);
}
return dest;
@@ -1084,19 +1080,14 @@ TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR* dest, size_t destLen)
///////////////////////////////////////////////////////////////////////////////
// JabberStripJid - strips a resource postfix from a JID
-TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR* dest, size_t destLen)
+TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR *dest, size_t destLen)
{
if (jid == NULL)
*dest = 0;
else {
- size_t len = _tcslen(jid);
- if (len >= destLen)
- len = destLen-1;
-
- memcpy(dest, jid, len * sizeof(TCHAR));
- dest[ len ] = 0;
+ _tcsncpy_s(dest, destLen, jid, _TRUNCATE);
- TCHAR* p = _tcschr(dest, '/');
+ TCHAR *p = _tcschr(dest, '/');
if (p != NULL)
*p = 0;
}
@@ -1305,7 +1296,7 @@ const TCHAR *JabberStrIStr(const TCHAR *str, const TCHAR *substr)
CharUpperBuff(str_up, lstrlen(str_up));
CharUpperBuff(substr_up, lstrlen(substr_up));
- TCHAR* p = _tcsstr(str_up, substr_up);
+ TCHAR *p = _tcsstr(str_up, substr_up);
return p ? (str + (p - str_up)) : NULL;
}
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index 1d39fe75c4..50e4de28c9 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -1112,7 +1112,7 @@ void CPepActivity::SetActivity(HANDLE hContact, LPCTSTR szFirst, LPCTSTR szSecon
else SetExtraIcon(hContact, activity < 0 ? NULL : returnActivity(activity));
if (activity >= 0) {
- TCHAR* p = mir_a2t(ActivityGetId(activity));
+ TCHAR *p = mir_a2t(ActivityGetId(activity));
m_proto->WriteAdvStatus(hContact, ADVSTATUS_ACTIVITY, p, g_ActivityIcons.GetIcolibName(returnActivity(activity)), activityTitle, szText);
mir_free(p);
}
diff --git a/protocols/JabberG/src/version.h b/protocols/JabberG/src/version.h
index b03a88f50e..433d0013ae 100644
--- a/protocols/JabberG/src/version.h
+++ b/protocols/JabberG/src/version.h
@@ -1,12 +1,11 @@
-#define __FILEVERSION_STRING 0,11,0,2
-#define __VERSION_STRING "0.11.0.2"
-#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0,11,0,2)
+#define __FILEVERSION_STRING 0,11,0,3
+#define __VERSION_STRING "0.11.0.3"
+#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0,11,0,3)
#define __PLUGIN_NAME "Jabber Protocol"
#define __DESCRIPTION "Jabber protocol support for Miranda NG."
#define __AUTHOR "George Hazan, Maxim Mluhov, Victor Pavlychko, Artem Shpynov, Michael Stepura"
#define __AUTHOREMAIL "ghazan@miranda.im"
-#define __COPYRIGHT "(c) 2005-2012 George Hazan, Maxim Mluhov, Victor Pavlychko, Artem Shpynov, Michael Stepura"
+#define __COPYRIGHT "(c) 2005-2013 George Hazan, Maxim Mluhov, Victor Pavlychko, Artem Shpynov, Michael Stepura"
#define __AUTHORWEB "http://miranda-ng.org/p/Jabber/"
-