diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-20 10:08:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-20 10:08:52 +0000 |
commit | f946ebcb1ac09b7220f8547074496aa2d1b83768 (patch) | |
tree | 30af27bf909684e191b08f6939e80eed51ce3efb | |
parent | 0b39e2b4ed0b578040a1eb584d045c6202885f7d (diff) |
- indexes replaces with pointers;
- members' name normalization
git-svn-id: http://svn.miranda-ng.org/main/trunk@5425 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/JabberG/src/jabber_adhoc.cpp | 42 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 10 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_disco.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 4 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_list.cpp | 252 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_list.h | 17 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 31 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 17 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 13 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 41 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_userinfo.cpp | 30 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 6 |
14 files changed, 206 insertions, 272 deletions
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index a4a1a98883..7dc7a8f5a4 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -543,51 +543,45 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact;
- DBVARIANT dbv;
+ HANDLE hContact = (HANDLE)wParam;
int res = -1;
- JABBER_LIST_ITEM * item=NULL;
- if (((hContact=(HANDLE)wParam)!=NULL || (lParam!=0)) && m_bJabberOnline) {
+ if ((hContact != NULL || lParam != 0) && m_bJabberOnline) {
+ DBVARIANT dbv;
if (wParam && !getTString(hContact, "jid", &dbv)) {
- TCHAR jid[ JABBER_MAX_JID_LEN ];
+ JABBER_LIST_ITEM *item = NULL;
int selected = 0;
+ TCHAR jid[ JABBER_MAX_JID_LEN ];
_tcsncpy(jid, dbv.ptszVal, SIZEOF(jid));
-
- ListLock();
{
+ mir_cslock lck(m_csLists);
item = ListGetItemPtr(LIST_ROSTER, jid);
- if (item)
- {
- if (item->resourceCount>1)
- {
- HMENU hMenu=CreatePopupMenu();
- for (int i=0; i<item->resourceCount; i++)
- AppendMenu(hMenu,MF_STRING,i+1, item->resource[i].resourceName);
+ if (item) {
+ if (item->resourceCount > 1) {
+ HMENU hMenu = CreatePopupMenu();
+ for (int i=0; i < item->resourceCount; i++)
+ AppendMenu(hMenu,MF_STRING,i+1, item->pResources[i].resourceName);
HWND hwndTemp=CreateWindowEx(WS_EX_TOOLWINDOW,_T("button"),_T("PopupMenuHost"),0,0,0,10,10,NULL,NULL,hInst,NULL);
SetForegroundWindow(hwndTemp);
POINT pt;
GetCursorPos(&pt);
RECT rc;
- selected=TrackPopupMenu(hMenu,TPM_RETURNCMD,pt.x,pt.y,0,hwndTemp,&rc);
+ selected = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndTemp, &rc);
DestroyMenu(hMenu);
DestroyWindow(hwndTemp);
}
- else selected=1;
+ else selected = 1;
- if (selected>0)
- {
+ if (selected > 0) {
selected--;
- if (item->resource)
- {
+ if (item->pResources) {
_tcsncat(jid,_T("/"),SIZEOF(jid));
- _tcsncat(jid,item->resource[selected].resourceName,SIZEOF(jid));
+ _tcsncat(jid,item->pResources[selected].resourceName,SIZEOF(jid));
}
- selected=1;
+ selected = 1;
}
}
}
- ListUnlock();
if ( !item || selected) {
CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, NULL);
@@ -596,7 +590,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam) db_free(&dbv);
}
- else if (lParam!=0)
+ else if (lParam != 0)
CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, lParam);
}
return res;
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index a8719a4c63..288fe494b8 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -217,7 +217,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid) if (item) {
for (int i = 0; i < item->resourceCount; i++) {
TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
- mir_sntprintf(szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->resource[i].resourceName);
+ 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))
jcbToReturn |= jcb;
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index ceca0cac8c..acc0ec2ab5 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -317,7 +317,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM* item, const TCHAR * break;
default:
for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& JS = item->resource[i];
+ JABBER_RESOURCE_STATUS& JS = item->pResources[i];
if ( !lstrcmp(resource, JS.resourceName)) {
if (action != GC_EVENT_JOIN) {
switch(action) {
@@ -552,7 +552,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& p = item->resource[i];
+ JABBER_RESOURCE_STATUS& p = item->pResources[i];
if ( !lstrcmp(p.resourceName, item->nick )) me = &p;
if ( !lstrcmp(p.resourceName, gcmi->pszUID)) him = &p;
}
@@ -1039,7 +1039,7 @@ static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* {
JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& p = item->resource[i];
+ JABBER_RESOURCE_STATUS& p = item->pResources[i];
if ( !lstrcmp(p.resourceName, item->nick )) me = &p;
if ( !lstrcmp(p.resourceName, gch->ptszUID)) him = &p;
}
@@ -1476,8 +1476,8 @@ static void sttSendPrivateMessage(CJabberProto* ppro, JABBER_LIST_ITEM* item, co HANDLE hContact = ppro->DBCreateContact(szFullJid, NULL, TRUE, FALSE);
if (hContact != NULL) {
for (int i=0; i < item->resourceCount; i++) {
- if (_tcsicmp(item->resource[i].resourceName, nick) == 0) {
- ppro->setWord(hContact, "Status", item->resource[i].status);
+ if (_tcsicmp(item->pResources[i].resourceName, nick) == 0) {
+ ppro->setWord(hContact, "Status", item->pResources[i].status);
break;
} }
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 8e19ff37a7..936127362b 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -1442,7 +1442,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == NULL) {
JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
- if (item->resource == NULL)
+ if (item->pResources == NULL)
ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0);
}
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index a3a76a5131..25f0d1bb93 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -205,7 +205,7 @@ JABBER_RESOURCE_STATUS* CJabberProto::GcFindResource(JABBER_LIST_ITEM *item, con JABBER_RESOURCE_STATUS *res = NULL;
EnterCriticalSection(&m_csLists);
- JABBER_RESOURCE_STATUS *r = item->resource;
+ JABBER_RESOURCE_STATUS *r = item->pResources;
for (int i=0; i<item->resourceCount; i++) {
if ( !_tcscmp(r[i].resourceName, resource)) {
res = &r[i];
@@ -882,7 +882,7 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM* item, const TCHAR *ol return;
for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& RS = item->resource[i];
+ JABBER_RESOURCE_STATUS& RS = item->pResources[i];
if ( !lstrcmp(RS.resourceName, oldNick)) {
replaceStrT(RS.resourceName, newNick);
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index 5f9c11c6ae..49b0460365 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -50,7 +50,7 @@ static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) if (item == NULL)
return;
- JABBER_RESOURCE_STATUS* r = item->resource;
+ JABBER_RESOURCE_STATUS* r = item->pResources;
for (int i=0; i < item->resourceCount; i++, r++)
JabberListFreeResourceInternal(r);
@@ -64,7 +64,7 @@ static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) mir_free(item->jid);
mir_free(item->nick);
- mir_free(item->resource);
+ mir_free(item->pResources);
mir_free(item->group);
mir_free(item->messageEventIdStr);
mir_free(item->name);
@@ -78,14 +78,11 @@ static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) void CJabberProto::ListWipe(void)
{
- int i;
-
- EnterCriticalSection(&m_csLists);
- for (i=0; i < m_lstRoster.getCount(); i++)
+ mir_cslock lck(m_csLists);
+ for (int i=0; i < m_lstRoster.getCount(); i++)
JabberListFreeItemInternal(m_lstRoster[i]);
m_lstRoster.destroy();
- LeaveCriticalSection(&m_csLists);
}
int CJabberProto::ListExist(JABBER_LIST list, const TCHAR *jid)
@@ -95,11 +92,8 @@ int CJabberProto::ListExist(JABBER_LIST list, const TCHAR *jid) tmp.jid = (TCHAR*)jid;
tmp.bUseResource = FALSE;
- EnterCriticalSection(&m_csLists);
-
- //fyr
- if (list == LIST_ROSTER)
- {
+ mir_cslock lck(m_csLists);
+ if (list == LIST_ROSTER) {
tmp.list = LIST_CHATROOM;
int id = m_lstRoster.getIndex(&tmp);
if (id != -1)
@@ -108,25 +102,17 @@ int CJabberProto::ListExist(JABBER_LIST list, const TCHAR *jid) }
int idx = m_lstRoster.getIndex(&tmp);
-
- if (idx == -1) {
- LeaveCriticalSection(&m_csLists);
- return 0;
- }
-
- LeaveCriticalSection(&m_csLists);
- return idx+1;
+ return (idx == -1) ? 0 : idx+1;
}
JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid)
{
- JABBER_LIST_ITEM* item;
BOOL bUseResource=FALSE;
- EnterCriticalSection(&m_csLists);
- if ((item = ListGetItemPtr(list, jid)) != NULL) {
- LeaveCriticalSection(&m_csLists);
+ mir_cslockfull lck(m_csLists);
+
+ JABBER_LIST_ITEM *item = ListGetItemPtr(list, jid);
+ if (item != NULL)
return item;
- }
TCHAR *s = mir_tstrdup(jid);
TCHAR *q = NULL;
@@ -139,17 +125,15 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid) if ((q = _tcschr(p, '/')) != NULL)
*q = '\0';
}
- } else {
- bUseResource=TRUE;
}
+ else bUseResource = TRUE;
- if ( !bUseResource && list== LIST_ROSTER)
- {
+ if ( !bUseResource && list == LIST_ROSTER) {
//if it is a chat room keep resource and made it resource sensitive
- if (ChatRoomHContactFromJID(s))
- {
- if (q != NULL) *q='/';
- bUseResource=TRUE;
+ if (ChatRoomHContactFromJID(s)) {
+ if (q != NULL)
+ *q='/';
+ bUseResource = TRUE;
}
}
@@ -157,14 +141,10 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid) item->list = list;
item->jid = s;
item->itemResource.status = ID_STATUS_OFFLINE;
- item->resource = NULL;
item->resourceMode = RSMODE_LASTSEEN;
- item->lastSeenResource = -1;
- item->manualResource = -1;
item->bUseResource = bUseResource;
-
m_lstRoster.insert(item);
- LeaveCriticalSection(&m_csLists);
+ lck.unlock();
MenuUpdateSrmmIcon(item);
return item;
@@ -172,13 +152,12 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid) void CJabberProto::ListRemove(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = ListExist(list, jid);
if (i != 0) {
JabberListFreeItemInternal(m_lstRoster[ --i ]);
m_lstRoster.remove(i);
}
- LeaveCriticalSection(&m_csLists);
}
void CJabberProto::ListRemoveList(JABBER_LIST list)
@@ -190,54 +169,42 @@ void CJabberProto::ListRemoveList(JABBER_LIST list) void CJabberProto::ListRemoveByIndex(int index)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
if (index >= 0 && index < m_lstRoster.getCount()) {
JabberListFreeItemInternal(m_lstRoster[index]);
m_lstRoster.remove(index);
}
- LeaveCriticalSection(&m_csLists);
}
JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid)
{
- JABBER_RESOURCE_STATUS *result = NULL;
-
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = ListExist(list, jid);
- if ( !i) {
- LeaveCriticalSection(&m_csLists);
- return 0;
- }
+ if (i == 0)
+ return NULL;
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
const TCHAR *p = _tcschr(jid, '@');
const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
- if (q)
- {
- const TCHAR *resource = q+1;
- if (*resource)
- for (int j=0; j < LI->resourceCount; j++)
- if ( !_tcscmp(LI->resource[j].resourceName, resource))
- {
- result = LI->resource + j;
- break;
- }
- }
-
- LeaveCriticalSection(&m_csLists);
+ if (q == NULL)
+ return NULL;
+
+ const TCHAR *resource = q+1;
+ if (*resource)
+ for (int j=0; j < LI->resourceCount; j++)
+ if ( !_tcscmp(LI->pResources[j].resourceName, resource))
+ return LI->pResources + j;
- return result;
+ return NULL;
}
int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslockfull lck(m_csLists);
int i = ListExist(list, jid);
- if ( !i) {
- LeaveCriticalSection(&m_csLists);
+ if (!i)
return 0;
- }
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
int bIsNewResource = false, j;
@@ -247,7 +214,7 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status if (q) {
const TCHAR *resource = q+1;
if (resource[0]) {
- JABBER_RESOURCE_STATUS* r = LI->resource;
+ JABBER_RESOURCE_STATUS* r = LI->pResources;
for (j=0; j < LI->resourceCount; j++, r++) {
if ( !_tcscmp(r->resourceName, resource)) {
// Already exist, update status and statusMessage
@@ -259,9 +226,9 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status if (j >= LI->resourceCount) {
// Not already exist, add new resource
- LI->resource = (JABBER_RESOURCE_STATUS *) mir_realloc(LI->resource, (LI->resourceCount+1)*sizeof(JABBER_RESOURCE_STATUS));
+ LI->pResources = (JABBER_RESOURCE_STATUS *) mir_realloc(LI->pResources, (LI->resourceCount+1)*sizeof(JABBER_RESOURCE_STATUS));
bIsNewResource = true;
- r = LI->resource + LI->resourceCount++;
+ r = LI->pResources + LI->resourceCount++;
memset(r, 0, sizeof(JABBER_RESOURCE_STATUS));
r->status = status;
r->affiliation = AFFILIATION_NONE;
@@ -279,7 +246,7 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status replaceStrT(LI->itemResource.statusMessage, statusMessage);
}
- LeaveCriticalSection(&m_csLists);
+ lck.unlock();
MenuUpdateSrmmIcon(LI);
return bIsNewResource;
@@ -287,111 +254,105 @@ int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslockfull lck(m_csLists);
int i = ListExist(list, jid);
- JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
- if ( !i || LI == NULL) {
- LeaveCriticalSection(&m_csLists);
+ JABBER_LIST_ITEM *LI = m_lstRoster[i-1];
+ if (i == 0 || LI == NULL)
return;
- }
const TCHAR *p = _tcschr(jid, '@');
const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
- if (q) {
- const TCHAR *resource = q+1;
- if (resource[0]) {
- JABBER_RESOURCE_STATUS* r = LI->resource;
- int j;
- for (j=0; j < LI->resourceCount; j++, r++) {
- if ( !_tcsicmp(r->resourceName, resource))
- break;
- }
- if (j < LI->resourceCount) {
- // Found last seen resource ID to be removed
- if (LI->lastSeenResource == j)
- LI->lastSeenResource = -1;
- else if (LI->lastSeenResource > j)
- LI->lastSeenResource--;
- // update manually selected resource ID
- if (LI->resourceMode == RSMODE_MANUAL)
- {
- if (LI->manualResource == j)
- {
- LI->resourceMode = RSMODE_LASTSEEN;
- LI->manualResource = -1;
- } else if (LI->manualResource > j)
- LI->manualResource--;
- }
+ if (q == NULL)
+ return;
- // Update MirVer due to possible resource changes
- UpdateMirVer(LI);
+ const TCHAR *resource = q+1;
+ if (resource[0] == 0)
+ return;
+
+ JABBER_RESOURCE_STATUS *r = LI->pResources;
+ for (int j=0; j < LI->resourceCount; j++, r++)
+ if ( !_tcsicmp(r->resourceName, resource))
+ break;
- JabberListFreeResourceInternal(r);
+ if (r >= LI->pResources + LI->resourceCount)
+ return;
- if (LI->resourceCount-- == 1) {
- mir_free(r);
- LI->resource = NULL;
- }
- else {
- memmove(r, r+1, (LI->resourceCount-j)*sizeof(JABBER_RESOURCE_STATUS));
- LI->resource = (JABBER_RESOURCE_STATUS*)mir_realloc(LI->resource, LI->resourceCount*sizeof(JABBER_RESOURCE_STATUS));
- } } } }
+ // Found last seen resource ID to be removed
+ if (LI->pLastSeenResource == r)
+ LI->pLastSeenResource = NULL;
- LeaveCriticalSection(&m_csLists);
+ // update manually selected resource ID
+ if (LI->resourceMode == RSMODE_MANUAL) {
+ if (LI->pManualResource == r) {
+ LI->resourceMode = RSMODE_LASTSEEN;
+ LI->pManualResource = NULL;
+ }
+ }
+
+ // Update MirVer due to possible resource changes
+ UpdateMirVer(LI);
+
+ JabberListFreeResourceInternal(r);
+
+ if (LI->resourceCount-- == 1) {
+ mir_free(r);
+ LI->pResources = NULL;
+ }
+ else {
+ memmove(r, r+1, (LI->resourceCount - (r-LI->pResources))*sizeof(JABBER_RESOURCE_STATUS));
+ LI->pResources = (JABBER_RESOURCE_STATUS*)mir_realloc(LI->pResources, LI->resourceCount*sizeof(JABBER_RESOURCE_STATUS));
+ }
+
+ lck.unlock();
MenuUpdateSrmmIcon(LI);
}
TCHAR* CJabberProto::ListGetBestResourceNamePtr(const TCHAR *jid)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = ListExist(LIST_ROSTER, jid);
- if ( !i) {
- LeaveCriticalSection(&m_csLists);
+ if (i == 0)
return NULL;
- }
TCHAR* res = NULL;
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
if (LI->resourceCount > 1) {
- if (LI->resourceMode == RSMODE_LASTSEEN && LI->lastSeenResource>=0 && LI->lastSeenResource < LI->resourceCount)
- res = LI->resource[ LI->lastSeenResource ].resourceName;
- else if (LI->resourceMode == RSMODE_MANUAL && LI->manualResource>=0 && LI->manualResource < LI->resourceCount)
- res = LI->resource[ LI->manualResource ].resourceName;
+ 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, j;
for (j = 0; j < LI->resourceCount; j++) {
- if (LI->resource[ j ].priority > nBestPri) {
- nBestPri = LI->resource[ j ].priority;
+ if (LI->pResources[ j ].priority > nBestPri) {
+ nBestPri = LI->pResources[ j ].priority;
nBestPos = j;
}
}
if (nBestPos != -1)
- res = LI->resource[ nBestPos ].resourceName;
+ res = LI->pResources[nBestPos].resourceName;
}
}
- if ( !res && LI->resource)
- res = LI->resource[0].resourceName;
+ if (!res && LI->pResources)
+ res = LI->pResources[0].resourceName;
- LeaveCriticalSection(&m_csLists);
return res;
}
TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = ListExist(LIST_ROSTER, jid);
- if ( !i) {
- LeaveCriticalSection(&m_csLists);
+ if (i == 0)
return NULL;
- }
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
TCHAR* res = ListGetBestResourceNamePtr(jid);
if (res == NULL) {
- JABBER_RESOURCE_STATUS* r = LI->resource;
+ JABBER_RESOURCE_STATUS* r = LI->pResources;
int status = ID_STATUS_OFFLINE;
res = NULL;
for (i=0; i < LI->resourceCount; i++) {
@@ -423,44 +384,33 @@ TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid) status = s;
} } }
- LeaveCriticalSection(&m_csLists);
return res;
}
int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = (fromOffset >= 0) ? fromOffset : 0;
for (; i<m_lstRoster.getCount(); i++)
- if (m_lstRoster[i]->list == list) {
- LeaveCriticalSection(&m_csLists);
+ if (m_lstRoster[i]->list == list)
return i;
- }
- LeaveCriticalSection(&m_csLists);
+
return -1;
}
JABBER_LIST_ITEM *CJabberProto::ListGetItemPtr(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
int i = ListExist(list, jid);
- if ( !i) {
- LeaveCriticalSection(&m_csLists);
- return NULL;
- }
- i--;
- LeaveCriticalSection(&m_csLists);
- return m_lstRoster[i];
+ return (i == 0) ? NULL : m_lstRoster[i-1];
}
JABBER_LIST_ITEM *CJabberProto::ListGetItemPtrFromIndex(int index)
{
- EnterCriticalSection(&m_csLists);
- if (index >= 0 && index < m_lstRoster.getCount()) {
- LeaveCriticalSection(&m_csLists);
+ mir_cslock lck(m_csLists);
+ if (index >= 0 && index < m_lstRoster.getCount())
return m_lstRoster[index];
- }
- LeaveCriticalSection(&m_csLists);
+
return NULL;
}
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index c2c7ad151e..7a4cf77a27 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -114,11 +114,11 @@ struct JABBER_LIST_ITEM // jid = jid of the contact
TCHAR* nick;
int resourceCount;
- JABBER_RESOURCE_STATUS *resource;
- JABBER_RESOURCE_STATUS itemResource; // resource for jids without /resource node
- int lastSeenResource; // index to resource[x] which was last seen active
- int manualResource; // manually set index to resource[x]
-// int defaultResource; // index to resource[x] which is the default, negative (-1) means no resource is chosen yet
+ 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;
@@ -132,19 +132,15 @@ struct JABBER_LIST_ITEM // LIST_ROOM
// jid = room JID
- // char* name; // room name
TCHAR* type; // room type
// LIST_CHATROOM
// jid = room JID
- // char* nick; // my nick in this chat room (SPECIAL: in TXT)
- // JABBER_RESOURCE_STATUS *resource; // participant nicks in this room
BOOL bChatActive;
HWND hwndGcListBan;
HWND hwndGcListAdmin;
HWND hwndGcListOwner;
int iChatState;
- // BOOL bAutoJoin; // chat sessio was started via auto-join
// LIST_FILE
// jid = string representation of port number
@@ -163,9 +159,6 @@ struct JABBER_LIST_ITEM //LIST_BOOKMARK
// jid = room JID
- // TCHAR* nick; // my nick in this chat room
- // TCHAR* name; // name of the bookmark
- // TCHAR* type; // type of bookmark ("url" or "conference")
TCHAR* password; // password for room
BOOL bAutoJoin;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 147e195920..e1c49fde40 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -455,19 +455,17 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi);
}
if (i < item->resourceCount) {
+ JABBER_RESOURCE_STATUS &r = item->pResources[i];
CLISTMENUITEM clmi = { sizeof(clmi) };
clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
- if ((item->resourceMode == RSMODE_MANUAL) && (item->manualResource == i))
+ if ((item->resourceMode == RSMODE_MANUAL) && (item->pManualResource == &r))
clmi.flags |= CMIF_CHECKED;
if (ServiceExists(MS_FP_GETCLIENTICONT)) {
clmi.flags |= CMIM_ICON;
- FormatMirVer(&item->resource[i], szTmp, SIZEOF(szTmp));
+ FormatMirVer(&r, szTmp, SIZEOF(szTmp));
clmi.hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)szTmp, 0);
}
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"),
- item->resource[i].resourceName,
- pcli->pfnGetStatusModeDescription(item->resource[i].status, 0),
- item->resource[i].priority);
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"), r.resourceName, pcli->pfnGetStatusModeDescription(r.status, 0), r.priority);
clmi.ptszName = szTmp;
Menu_ModifyItem(m_phMenuResourceItems[i], &clmi);
DestroyIcon(clmi.hIcon);
@@ -1099,35 +1097,34 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM wParam, LPARAM lParam) TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("Last active"),
- ((LI->lastSeenResource>=0) && (LI->lastSeenResource < LI->resourceCount)) ?
- LI->resource[LI->lastSeenResource].resourceName : TranslateT("No activity yet, use server's choice"));
+ LI->pLastSeenResource ? LI->pLastSeenResource->resourceName : TranslateT("No activity yet, use server's choice"));
AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf);
AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
for (int i = 0; i < LI->resourceCount; i++)
- AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->resource[i].resourceName);
+ AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->pResources[i].resourceName);
if (LI->resourceMode == RSMODE_LASTSEEN)
CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND|MF_CHECKED);
else if (LI->resourceMode == RSMODE_SERVER)
CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND|MF_CHECKED);
- else
- CheckMenuItem(hMenu, MENUITEM_RESOURCES+LI->manualResource, MF_BYCOMMAND|MF_CHECKED);
+ else if (LI->pManualResource)
+ CheckMenuItem(hMenu, MENUITEM_RESOURCES + (LI->pManualResource - LI->pResources), MF_BYCOMMAND|MF_CHECKED);
int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL);
if (res == MENUITEM_LASTSEEN) {
- LI->manualResource = -1;
+ LI->pManualResource = NULL;
LI->resourceMode = RSMODE_LASTSEEN;
}
else if (res == MENUITEM_SERVER) {
- LI->manualResource = -1;
+ LI->pManualResource = NULL;
LI->resourceMode = RSMODE_SERVER;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = res - MENUITEM_RESOURCES;
+ LI->pManualResource = &LI->pResources[res - MENUITEM_RESOURCES];
LI->resourceMode = RSMODE_MANUAL;
}
@@ -1155,15 +1152,15 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM return 0;
if (res == MENUITEM_LASTSEEN) {
- LI->manualResource = -1;
+ LI->pManualResource = NULL;
LI->resourceMode = RSMODE_LASTSEEN;
}
else if (res == MENUITEM_SERVER) {
- LI->manualResource = -1;
+ LI->pManualResource = NULL;
LI->resourceMode = RSMODE_SERVER;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = res - MENUITEM_RESOURCES;
+ LI->pManualResource = &LI->pResources[res - MENUITEM_RESOURCES];
LI->resourceMode = RSMODE_MANUAL;
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 8ad48dd6eb..6fb71eedf7 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -445,15 +445,14 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) Log("JabberUpdateMirVer: for jid %S", item->jid);
- int resource = -1;
+ JABBER_RESOURCE_STATUS *p = NULL;
if (item->resourceMode == RSMODE_LASTSEEN)
- resource = item->lastSeenResource;
+ p = item->pLastSeenResource;
else if (item->resourceMode == RSMODE_MANUAL)
- resource = item->manualResource;
- if ((resource < 0) || (resource >= item->resourceCount))
- return;
+ p = item->pManualResource;
- UpdateMirVer(hContact, &item->resource[resource]);
+ if (p)
+ UpdateMirVer(hContact, p);
}
void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 7daa60e3b3..c8af871226 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -753,7 +753,7 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) 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->resource[i];
+ JABBER_RESOURCE_STATUS &p = tmpItem->pResources[i];
if ( !lstrcmp(p.resourceName, pDelimiter))
him = &p;
}
@@ -767,23 +767,23 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) }
if (item) {
- if (item->resource) {
+ 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->resource[i].resourceName);
+ 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->resource[i].dwVersionRequestTime) {
+ 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->resource[i].pSoftwareInfo) {
+ 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);
@@ -1338,7 +1338,6 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact) {
DBVARIANT dbv;
JABBER_LIST_ITEM *item;
- JABBER_RESOURCE_STATUS *r;
int i, msgCount;
size_t len;
@@ -1347,15 +1346,15 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact) db_free(&dbv);
if (item->resourceCount > 0) {
Log("resourceCount > 0");
- r = item->resource;
+ JABBER_RESOURCE_STATUS *r = item->pResources;
len = msgCount = 0;
- for (i=0; i<item->resourceCount; i++)
+ for (i=0; i < item->resourceCount; i++)
if (r[i].statusMessage) {
msgCount++;
len += (_tcslen(r[i].resourceName) + _tcslen(r[i].statusMessage) + 8);
}
- TCHAR* str = (TCHAR*)alloca(sizeof(TCHAR)*(len+1));
+ TCHAR *str = (TCHAR*)alloca(sizeof(TCHAR)*(len+1));
str[0] = str[len] = '\0';
for (i=0; i < item->resourceCount; i++)
if (r[i].statusMessage) {
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index d68296ca32..a6780f4f63 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -400,7 +400,7 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara JABBER_RESOURCE_STATUS * info = NULL;
for (int i=0; i < item->resourceCount; i++) {
- JABBER_RESOURCE_STATUS& p = item->resource[i];
+ JABBER_RESOURCE_STATUS& p = item->pResources[i];
if ( !lstrcmp(p.resourceName, (TCHAR*)lParam)) {
info = &p;
break;
@@ -819,7 +819,7 @@ LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid) return NULL;
}
- if (item->resource == NULL) {
+ if (item->pResources == NULL) {
m_psProto->ListUnlock();
return NULL;
}
@@ -827,16 +827,15 @@ LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid) int i;
int iLen = 1; // 1 for extra zero terminator at the end of the string
// calculate total necessary string length
- for (i=0; i<item->resourceCount; i++) {
- iLen += lstrlen(item->resource[i].resourceName) + 1;
- }
+ for (i=0; i<item->resourceCount; i++)
+ iLen += lstrlen(item->pResources[i].resourceName) + 1;
// allocate memory and fill it
LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(TCHAR));
LPTSTR p = str;
for (i=0; i<item->resourceCount; i++) {
- lstrcpy(p, item->resource[i].resourceName);
- p += lstrlen(item->resource[i].resourceName) + 1;
+ lstrcpy(p, item->pResources[i].resourceName);
+ p += lstrlen(item->pResources[i].resourceName) + 1;
}
*p = 0; // extra zero terminator
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 8b167609bb..a37074a14c 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1098,8 +1098,8 @@ HANDLE CJabberProto::CreateTemporaryContact(const TCHAR *szJid, JABBER_LIST_ITEM hContact = DBCreateContact(szJid, p, TRUE, FALSE);
for (int i=0; i < chatItem->resourceCount; i++) {
- if ( !lstrcmp(chatItem->resource[i].resourceName, p)) {
- setWord(hContact, "Status", chatItem->resource[i].status);
+ if ( !lstrcmp(chatItem->pResources[i].resourceName, p)) {
+ setWord(hContact, "Status", chatItem->pResources[i].status);
break;
}
}
@@ -1462,14 +1462,17 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) if (/*item->resourceMode==RSMODE_LASTSEEN &&*/ (fromResource = _tcschr(from, '/'))!=NULL) {
fromResource++;
if (*fromResource != '\0') {
- for (int i=0; i<item->resourceCount; i++) {
- if ( !lstrcmp(item->resource[i].resourceName, fromResource)) {
- int nLastSeenResource = item->lastSeenResource;
- item->lastSeenResource = i;
- if ((item->resourceMode==RSMODE_LASTSEEN) && (i != nLastSeenResource))
- UpdateMirVer(item);
- break;
- } } } } }
+ for (int i=0; i < item->resourceCount; i++) {
+ JABBER_RESOURCE_STATUS *r = &item->pResources[i];
+ if ( lstrcmp(r->resourceName, fromResource))
+ continue;
+
+ JABBER_RESOURCE_STATUS *pLast = item->pLastSeenResource;
+ item->pLastSeenResource = r;
+ if (item->resourceMode == RSMODE_LASTSEEN && pLast == r)
+ UpdateMirVer(item);
+ break;
+ } } } }
// Create a temporary contact
if (hContact == NULL)
@@ -1556,24 +1559,24 @@ void CJabberProto::UpdateJidDbSettings(const TCHAR *jid) int nMaxPriority = -999; // -128...+127 valid range
for (i = 0; i < item->resourceCount; i++)
{
- if (item->resource[i].priority > nMaxPriority) {
- nMaxPriority = item->resource[i].priority;
- status = item->resource[i].status;
+ if (item->pResources[i].priority > nMaxPriority) {
+ nMaxPriority = item->pResources[i].priority;
+ status = item->pResources[i].status;
nSelectedResource = i;
}
- else if (item->resource[i].priority == nMaxPriority) {
- if ((status = JabberCombineStatus(status, item->resource[i].status)) == item->resource[i].status)
+ else if (item->pResources[i].priority == nMaxPriority) {
+ if ((status = JabberCombineStatus(status, item->pResources[i].status)) == item->pResources[i].status)
nSelectedResource = i;
}
}
item->itemResource.status = status;
if (nSelectedResource != -1) {
- Log("JabberUpdateJidDbSettings: updating jid %S to rc %S", item->jid, item->resource[nSelectedResource].resourceName);
- if (item->resource[nSelectedResource].statusMessage)
- db_set_ts(hContact, "CList", "StatusMsg", item->resource[nSelectedResource].statusMessage);
+ Log("JabberUpdateJidDbSettings: updating jid %S to rc %S", item->jid, item->pResources[nSelectedResource].resourceName);
+ if (item->pResources[nSelectedResource].statusMessage)
+ db_set_ts(hContact, "CList", "StatusMsg", item->pResources[nSelectedResource].statusMessage);
else
db_unset(hContact, "CList", "StatusMsg");
- UpdateMirVer(hContact, &item->resource[nSelectedResource]);
+ UpdateMirVer(hContact, &item->pResources[nSelectedResource]);
}
else delSetting(hContact, DBSETTING_DISPLAY_UID);
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index c3d0a9fde5..4fdff5c530 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -213,7 +213,7 @@ static void sttFillResourceInfo(CJabberProto* ppro, HWND hwndTree, HTREEITEM hti {
TCHAR buf[256];
HTREEITEM htiResource = htiRoot;
- JABBER_RESOURCE_STATUS *res = resource ? &item->resource[resource-1] : &item->itemResource;
+ JABBER_RESOURCE_STATUS *res = resource ? &item->pResources[resource-1] : &item->itemResource;
if (res->resourceName && *res->resourceName)
htiResource = sttFillInfoLine(hwndTree, htiRoot, LoadSkinnedProtoIcon(ppro->m_szModuleName, res->status),
@@ -354,18 +354,18 @@ static void sttFillUserInfo(CJabberProto* ppro, HWND hwndTree, JABBER_LIST_ITEM // subscription
switch (item->subscription) {
- case SUB_BOTH:
- sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
- break;
- case SUB_TO:
- sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
- break;
- case SUB_FROM:
- sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
- break;
- default:
- sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
- break;
+ case SUB_BOTH:
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ break;
+ case SUB_TO:
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ break;
+ case SUB_FROM:
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ break;
+ default:
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ break;
}
// logoff
@@ -388,8 +388,8 @@ static void sttFillUserInfo(CJabberProto* ppro, HWND hwndTree, JABBER_LIST_ITEM item->itemResource.statusMessage ? item->itemResource.statusMessage : TranslateT("<not specified>"), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
// activity
- if ((item->lastSeenResource >= 0) && (item->lastSeenResource < item->resourceCount))
- lstrcpyn(buf, item->resource[item->lastSeenResource].resourceName, SIZEOF(buf));
+ if (item->pLastSeenResource)
+ lstrcpyn(buf, item->pLastSeenResource->resourceName, SIZEOF(buf));
else
lstrcpyn(buf, TranslateT("<no information available>"), SIZEOF(buf));
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index bf438b42b7..d32ad2404e 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -172,7 +172,7 @@ JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID(const TCHAR *jid) return &item->itemResource;
if (*++p == '\0') return NULL;
- JABBER_RESOURCE_STATUS *r = item->resource;
+ JABBER_RESOURCE_STATUS *r = item->pResources;
if (r == NULL) return NULL;
int i;
@@ -1065,8 +1065,8 @@ TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR* dest, size_t destLen) TCHAR* p = _tcschr(dest, '/');
JABBER_LIST_ITEM* LI = ListGetItemPtr(LIST_ROSTER, jid);
- if (LI && LI->resourceCount == 1 && LI->resource[ 0 ].szCapsNode &&
- _tcsicmp(LI->resource[ 0 ].szCapsNode, _T("http://talk.google.com/xmpp/bot/caps")) == 0)
+ if (LI && LI->resourceCount == 1 && LI->pResources[ 0 ].szCapsNode &&
+ _tcsicmp(LI->pResources[ 0 ].szCapsNode, _T("http://talk.google.com/xmpp/bot/caps")) == 0)
{
if (p) *p = 0;
return dest;
|