diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-20 14:23:07 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-20 14:23:07 +0000 |
commit | 5e4286f1becfb5ce52372f882a51ae8ea6f6ef6d (patch) | |
tree | 60e5dc3d3fa347ba34e1447e6b6e925c0e33c29b /protocols/JabberG/src/jabber_list.cpp | |
parent | d7382326906b9f3bdd66704dd1b41f9299c1daa6 (diff) |
- Jabber resource fix: in LAST_SEEN mode resource is skipped when no sessions were available;
- code cleanup;
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@5429 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_list.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_list.cpp | 57 |
1 files changed, 24 insertions, 33 deletions
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;
|