summaryrefslogtreecommitdiff
path: root/protocols/JabberG/jabber_list.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-03 15:16:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-03 15:16:37 +0000
commit78f8991554dd09d2e7f7efcdd9dcacf18f75f428 (patch)
treeef50761216cd51b0da6cb17b3ca1199de10fb6cf /protocols/JabberG/jabber_list.cpp
parentcfe2d8b10186a7ed42ba0dffd75528a38bee1435 (diff)
old svn info removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@735 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/jabber_list.cpp')
-rw-r--r--protocols/JabberG/jabber_list.cpp55
1 files changed, 18 insertions, 37 deletions
diff --git a/protocols/JabberG/jabber_list.cpp b/protocols/JabberG/jabber_list.cpp
index 155f9e2b60..0bf29fe45d 100644
--- a/protocols/JabberG/jabber_list.cpp
+++ b/protocols/JabberG/jabber_list.cpp
@@ -2,7 +2,7 @@
Jabber Protocol Plugin for Miranda IM
Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-11 George Hazan
+Copyright ( C ) 2005-12 George Hazan
Copyright ( C ) 2007 Maxim Mluhov
This program is free software; you can redistribute it and/or
@@ -19,10 +19,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-Revision : $Revision: 13452 $
-Last change on : $Date: 2011-03-17 21:12:56 +0200 (Чт, 17 мар 2011) $
-Last change by : $Author: george.hazan $
-
*/
#include "jabber.h"
@@ -153,15 +149,10 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd( JABBER_LIST list, const TCHAR* jid )
bUseResource=TRUE;
}
}
- item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
- ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
+ item = ( JABBER_LIST_ITEM* )mir_calloc( 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 );
@@ -309,19 +300,15 @@ void CJabberProto::ListRemoveResource( JABBER_LIST list, const TCHAR* jid )
}
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--;
+ if ( LI->lastSeenResource == r )
+ LI->lastSeenResource = NULL;
+
// 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 (LI->resourceMode == RSMODE_MANUAL) {
+ if ( LI->manualResource == r ) {
+ LI->resourceMode = RSMODE_SERVER;
+ LI->manualResource = NULL;
+ }
}
// Update MirVer due to possible resource changes
@@ -356,26 +343,20 @@ TCHAR* CJabberProto::ListGetBestResourceNamePtr( const TCHAR* jid )
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_MANUAL && LI->manualResource )
+ res = LI->manualResource->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;
- nBestPos = j;
+ for ( int j = 0; j < LI->resourceCount; j++ ) {
+ if ( LI->resource[ j ].uMessageSessionActive + 120 > time( NULL )) {
+ res = LI->resource[ j ].resourceName;
+ break;
}
+ 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;
}