diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-03 18:15:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-03 18:15:52 +0000 |
commit | 4641ff7a3a0d6a124c22a5c044bffd04073720fc (patch) | |
tree | dd0abb5de957189fc8dd18cd83b3cf97eafe853b /protocols/JabberG/jabber_list.cpp | |
parent | ad4e888349c2d220828c93d2d50635ff23a6fc72 (diff) |
shit dropped out
git-svn-id: http://svn.miranda-ng.org/main/trunk@738 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/jabber_list.cpp')
-rw-r--r-- | protocols/JabberG/jabber_list.cpp | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/protocols/JabberG/jabber_list.cpp b/protocols/JabberG/jabber_list.cpp index 0bf29fe45d..3721b00c7e 100644 --- a/protocols/JabberG/jabber_list.cpp +++ b/protocols/JabberG/jabber_list.cpp @@ -149,10 +149,15 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd( JABBER_LIST list, const TCHAR* jid ) bUseResource=TRUE;
}
}
- item = ( JABBER_LIST_ITEM* )mir_calloc( sizeof( JABBER_LIST_ITEM ));
+ item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
+ ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
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 );
@@ -300,15 +305,19 @@ void CJabberProto::ListRemoveResource( JABBER_LIST list, const TCHAR* jid ) }
if ( j < LI->resourceCount ) {
// Found last seen resource ID to be removed
- if ( LI->lastSeenResource == r )
- LI->lastSeenResource = NULL;
-
+ 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 == r ) {
- LI->resourceMode = RSMODE_SERVER;
- LI->manualResource = NULL;
- }
+ if (LI->resourceMode == RSMODE_MANUAL)
+ {
+ if ( LI->manualResource == j )
+ {
+ LI->resourceMode = RSMODE_LASTSEEN;
+ LI->manualResource = -1;
+ } else if ( LI->manualResource > j )
+ LI->manualResource--;
}
// Update MirVer due to possible resource changes
@@ -343,20 +352,26 @@ TCHAR* CJabberProto::ListGetBestResourceNamePtr( const TCHAR* jid ) JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
if ( LI->resourceCount > 1 ) {
- if (LI->resourceMode == RSMODE_MANUAL && LI->manualResource )
- res = LI->manualResource->resourceName;
+ 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;
else {
- for ( int j = 0; j < LI->resourceCount; j++ ) {
- if ( LI->resource[ j ].uMessageSessionActive + 120 > time( NULL )) {
- res = LI->resource[ j ].resourceName;
- break;
+ int nBestPos = -1, nBestPri = -200, j;
+ for ( j = 0; j < LI->resourceCount; j++ ) {
+ if ( LI->resource[ j ].priority > nBestPri ) {
+ nBestPri = LI->resource[ j ].priority;
+ nBestPos = j;
}
- else
- LI->resource[ j ].uMessageSessionActive = 0;
}
+ if ( nBestPos != -1 )
+ res = LI->resource[ nBestPos ].resourceName;
}
}
+ if ( !res && LI->resource)
+ res = LI->resource[0].resourceName;
+
LeaveCriticalSection( &m_csLists );
return res;
}
|