summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/JabberG/jabber_chat.cpp5
-rw-r--r--protocols/JabberG/jabber_groupchat.cpp36
-rw-r--r--protocols/JabberG/jabber_list.cpp49
-rw-r--r--protocols/JabberG/jabber_list.h11
-rw-r--r--protocols/JabberG/jabber_menu.cpp72
-rw-r--r--protocols/JabberG/jabber_misc.cpp11
-rw-r--r--protocols/JabberG/jabber_proto.cpp10
-rw-r--r--protocols/JabberG/jabber_thread.cpp61
-rw-r--r--protocols/JabberG/jabber_userinfo.cpp4
-rw-r--r--protocols/JabberG/jabber_util.cpp9
10 files changed, 158 insertions, 110 deletions
diff --git a/protocols/JabberG/jabber_chat.cpp b/protocols/JabberG/jabber_chat.cpp
index 60dc011faa..8f9fce33ad 100644
--- a/protocols/JabberG/jabber_chat.cpp
+++ b/protocols/JabberG/jabber_chat.cpp
@@ -372,11 +372,6 @@ void CJabberProto::GcQuit( JABBER_LIST_ITEM* item, int code, HXML reason )
if ( reason != NULL && xmlGetText( reason ) != NULL )
szReason = xmlGetText( reason );
- if (m_options.GcLogChatHistory) {
- HANDLE hContact = ChatRoomHContactFromJID(item->jid);
- JSetDword(hContact, "muc_lastevent", time(NULL));
- }
-
GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
gcd.ptszID = item->jid;
GCEVENT gce = {0};
diff --git a/protocols/JabberG/jabber_groupchat.cpp b/protocols/JabberG/jabber_groupchat.cpp
index 9bacd42ca2..3f535352d8 100644
--- a/protocols/JabberG/jabber_groupchat.cpp
+++ b/protocols/JabberG/jabber_groupchat.cpp
@@ -303,10 +303,10 @@ void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, co
info.saveRecent(0);
}
- TCHAR jid[512];
- mir_sntprintf( jid, SIZEOF(jid), _T("%s@%s/%s"), room, server, nick );
+ TCHAR text[512];
+ mir_sntprintf( text, SIZEOF(text), _T("%s@%s/%s"), room, server, nick );
- JABBER_LIST_ITEM* item = ListAdd( LIST_CHATROOM, jid );
+ JABBER_LIST_ITEM* item = ListAdd( LIST_CHATROOM, text );
item->bAutoJoin = autojoin;
replaceStr( item->nick, nick );
replaceStr( item->password, info.password );
@@ -317,16 +317,21 @@ void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, co
x << XCHILD( _T("password"), info.password );
if (m_options.GcLogChatHistory) {
- HANDLE hContact = ChatRoomHContactFromJID(jid);
- time_t lasteventtime = JGetDword(hContact, "muc_lastevent", 0);
- if (hContact && lasteventtime) {
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, SIZEOF(setting), "muc_%s@%s_lastevent", _T2A(room), _T2A(server));
+ time_t lasteventtime = this->JGetDword( NULL, setting, 0 );
+ if ( lasteventtime > 0 ) {
+ _tzset();
+ lasteventtime += _timezone + 1;
+ struct tm* time = localtime(&lasteventtime);
TCHAR lasteventdate[40];
- tmi.printTimeStamp(UTC_TIME_HANDLE, lasteventtime, _T("I"), lasteventdate, SIZEOF(lasteventdate), 0);
+ mir_sntprintf(lasteventdate, SIZEOF(lasteventdate), _T("%04d-%02d-%02dT%02d:%02d:%02dZ"),
+ time->tm_year+1900, time->tm_mon+1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
x << XCHILD( _T("history")) << XATTR( _T("since"), lasteventdate);
}
}
- SendPresenceTo( status, jid, x );
+ SendPresenceTo( status, text, x );
}
////////////////////////////////////////////////////////////////////////////////
@@ -1236,8 +1241,17 @@ void CJabberProto::GroupchatProcessMessage( HXML node )
for ( int i = 1; ( xNode = xmlGetNthChild( node, _T("x"), i )) != NULL; i++ )
if (( p = xmlGetAttrValue( xNode, _T("xmlns"))) != NULL )
if ( !_tcscmp( p, _T("jabber:x:delay")) && msgTime==0 )
- if (( p = xmlGetAttrValue( xNode, _T("stamp"))) != NULL )
+ if (( p = xmlGetAttrValue( xNode, _T("stamp"))) != NULL ) {
msgTime = JabberIsoToUnixTime( p );
+ if (m_options.GcLogChatHistory && msgTime > 0 ) {
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, sizeof(setting), "muc_%s_lastevent", _T2A(gcd.ptszID));
+ this->JSetDword(NULL, setting, msgTime);
+ } }
+
+ time_t now = time( NULL );
+ if ( msgTime == 0 || msgTime > now )
+ msgTime = now;
if ( resource != NULL ) {
JABBER_RESOURCE_STATUS* r = GcFindResource(item, resource);
@@ -1246,10 +1260,6 @@ void CJabberProto::GroupchatProcessMessage( HXML node )
else
nick = NULL;
- time_t now = time( NULL );
- if ( msgTime == 0 || msgTime > now )
- msgTime = now;
-
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
gce.pDest = &gcd;
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;
}
diff --git a/protocols/JabberG/jabber_list.h b/protocols/JabberG/jabber_list.h
index c2ee0409e8..503a479ece 100644
--- a/protocols/JabberG/jabber_list.h
+++ b/protocols/JabberG/jabber_list.h
@@ -60,8 +60,9 @@ typedef enum {
ROLE_MODERATOR
} JABBER_GC_ROLE;
-typedef enum { // initial default to RSMODE_SERVER
+typedef enum { // initial default to RSMODE_LASTSEEN
RSMODE_SERVER, // always let server decide ( always send correspondence without resouce name )
+ RSMODE_LASTSEEN, // use the last seen resource ( or let server decide if haven't seen anything yet )
RSMODE_MANUAL // specify resource manually ( see the defaultResource field - must not be NULL )
} JABBER_RESOURCE_MODE;
@@ -113,7 +114,7 @@ struct JABBER_RESOURCE_STATUS
JabberCapsBits jcbManualDiscoveredCaps;
// XEP-0085 gone event support
- BOOL uMessageSessionActive;
+ BOOL bMessageSessionActive;
JABBER_XEP0232_SOFTWARE_INFO* pSoftwareInfo;
};
@@ -128,8 +129,8 @@ struct JABBER_LIST_ITEM
int resourceCount;
JABBER_RESOURCE_STATUS *resource;
JABBER_RESOURCE_STATUS itemResource; // resource for jids without /resource node
- JABBER_RESOURCE_STATUS *lastSeenResource; // index to resource[x] which was last seen active
- JABBER_RESOURCE_STATUS *manualResource; // manually set index to resource[x]
+ 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_MODE resourceMode;
JABBER_SUBSCRIPTION subscription;
@@ -156,7 +157,7 @@ struct JABBER_LIST_ITEM
HWND hwndGcListAdmin;
HWND hwndGcListOwner;
int iChatState;
- // BOOL bAutoJoin; // chat session was started via auto-join
+ // BOOL bAutoJoin; // chat sessio was started via auto-join
// LIST_FILE
// jid = string representation of port number
diff --git a/protocols/JabberG/jabber_menu.cpp b/protocols/JabberG/jabber_menu.cpp
index 1bc4007148..963d5d4219 100644
--- a/protocols/JabberG/jabber_menu.cpp
+++ b/protocols/JabberG/jabber_menu.cpp
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m_toolbar.h"
+#define MENUITEM_LASTSEEN 1
#define MENUITEM_SERVER 2
#define MENUITEM_RESOURCES 10
@@ -54,6 +55,7 @@ static HGENMENU g_hMenuRefresh;
static HGENMENU g_hMenuCommands;
static HGENMENU g_hMenuSendNote;
static HGENMENU g_hMenuResourcesRoot;
+static HGENMENU g_hMenuResourcesActive;
static HGENMENU g_hMenuResourcesServer;
static struct
@@ -336,12 +338,20 @@ void g_MenuInit( void )
mi.icolibItem = g_GetIconHandle( IDI_JABBER );
g_hMenuResourcesRoot = Menu_AddContactMenuItem(&mi);
+ mi.pszService = "Jabber/UseResource_last";
+ mi.pszName = LPGEN("Last Active");
+ mi.position = -1999901000;
+ mi.hParentMenu = g_hMenuResourcesRoot;
+ mi.icolibItem = g_GetIconHandle( IDI_JABBER );
+ mi.flags |= CMIF_ROOTHANDLE;
+ g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi);
+ List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN ));
+
mi.pszService = "Jabber/UseResource_server";
mi.pszName = LPGEN("Server's Choice");
mi.position = -1999901000;
- mi.hParentMenu = g_hMenuResourcesRoot;
+ mi.pszPopupName = (char *)g_hMenuResourcesRoot;
mi.icolibItem = g_GetIconHandle( IDI_NODE_SERVER );
- mi.flags |= CMIF_ROOTHANDLE;
g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi);
List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER ));
}
@@ -441,6 +451,7 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM )
mi.flags = CMIM_ICON|CMIM_FLAGS;
mi.icolibItem = GetIconHandle( IDI_JABBER );
CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesRoot, ( LPARAM )&mi );
+ CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
int nMenuResourceItemsNew = m_nMenuResourceItems;
if ( m_nMenuResourceItems < item->resourceCount ) {
@@ -474,7 +485,7 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM )
CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
- if ((item->resourceMode == RSMODE_MANUAL) && (item->manualResource == &item->resource[i]))
+ if ((item->resourceMode == RSMODE_MANUAL) && (item->manualResource == i))
clmi.flags |= CMIF_CHECKED;
if (ServiceExists( "Fingerprint/GetClientIcon" )) {
clmi.flags |= CMIM_ICON;
@@ -498,6 +509,10 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM )
mi.cbSize = sizeof(CLISTMENUITEM);
mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
+ ((item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
+
+ mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
((item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);
CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesServer, ( LPARAM )&mi );
@@ -1107,8 +1122,8 @@ int CJabberProto::OnProcessSrmmEvent( WPARAM, LPARAM lParam )
JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( jid );
- if ( r && r->uMessageSessionActive ) {
- r->uMessageSessionActive = 0;
+ if ( r && r->bMessageSessionActive ) {
+ r->bMessageSessionActive = FALSE;
JabberCapsBits jcb = GetResourceCapabilites( jid, TRUE );
if ( jcb & JABBER_CAPS_CHATSTATES ) {
@@ -1145,35 +1160,35 @@ int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam )
TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("Last active"),
- LI->lastSeenResource ? LI->lastSeenResource->resourceName :
- TranslateT("No activity yet, use server's choice"));
+ ((LI->lastSeenResource>=0) && (LI->lastSeenResource < LI->resourceCount)) ?
+ LI->resource[LI->lastSeenResource].resourceName : TranslateT("No activity yet, use server's choice"));
+ AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf);
- AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Standard"));
+ AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
- int manInd = -1;
- for (int i = 0; i < LI->resourceCount; ++i) {
+ for (int i = 0; i < LI->resourceCount; ++i)
AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->resource[i].resourceName);
- if (&LI->resource[i] == LI->manualResource)
- manInd = i;
- }
- if (LI->resourceMode == RSMODE_MANUAL)
- CheckMenuItem(hMenu, MENUITEM_RESOURCES + manInd, MF_BYCOMMAND|MF_CHECKED);
- else
+ 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);
int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL);
- if (res == MENUITEM_SERVER) {
- LI->manualResource = NULL;
+ if ( res == MENUITEM_LASTSEEN ) {
+ LI->manualResource = -1;
+ LI->resourceMode = RSMODE_LASTSEEN;
+ }
+ else if (res == MENUITEM_SERVER) {
+ LI->manualResource = -1;
LI->resourceMode = RSMODE_SERVER;
-
- for ( int i=0; i<LI->resourceCount; i++ )
- LI->resource[i].uMessageSessionActive = 0;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = &LI->resource[res - MENUITEM_RESOURCES];
+ LI->manualResource = res - MENUITEM_RESOURCES;
LI->resourceMode = RSMODE_MANUAL;
}
@@ -1200,15 +1215,16 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM
if ( !LI )
return 0;
- if (res == MENUITEM_SERVER) {
- LI->manualResource = NULL;
+ if ( res == MENUITEM_LASTSEEN ) {
+ LI->manualResource = -1;
+ LI->resourceMode = RSMODE_LASTSEEN;
+ }
+ else if (res == MENUITEM_SERVER) {
+ LI->manualResource = -1;
LI->resourceMode = RSMODE_SERVER;
-
- for ( int i=0; i<LI->resourceCount; i++ )
- LI->resource[i].uMessageSessionActive = 0;
}
else if (res >= MENUITEM_RESOURCES) {
- LI->manualResource = &LI->resource[res - MENUITEM_RESOURCES];
+ LI->manualResource = res - MENUITEM_RESOURCES;
LI->resourceMode = RSMODE_MANUAL;
}
diff --git a/protocols/JabberG/jabber_misc.cpp b/protocols/JabberG/jabber_misc.cpp
index 1faeaaadda..c50c48ecdd 100644
--- a/protocols/JabberG/jabber_misc.cpp
+++ b/protocols/JabberG/jabber_misc.cpp
@@ -467,10 +467,15 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item)
Log("JabberUpdateMirVer: for jid " TCHAR_STR_PARAM, item->jid);
- JABBER_RESOURCE_STATUS *resource = item->resourceMode == RSMODE_MANUAL ? item->manualResource : item->lastSeenResource;
- if (resource == NULL) resource = &item->resource[0];
+ int resource = -1;
+ if (item->resourceMode == RSMODE_LASTSEEN)
+ resource = item->lastSeenResource;
+ else if (item->resourceMode == RSMODE_MANUAL)
+ resource = item->manualResource;
+ if ((resource < 0) || (resource >= item->resourceCount))
+ return;
- UpdateMirVer( hContact, resource );
+ UpdateMirVer( hContact, &item->resource[resource] );
}
void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize)
diff --git a/protocols/JabberG/jabber_proto.cpp b/protocols/JabberG/jabber_proto.cpp
index 58d8d515c5..8e6bc32294 100644
--- a/protocols/JabberG/jabber_proto.cpp
+++ b/protocols/JabberG/jabber_proto.cpp
@@ -1090,10 +1090,10 @@ HANDLE __cdecl CJabberProto::SendFile( HANDLE hContact, const TCHAR* szDescripti
return 0;
}
- JabberCapsBits jcb = GetTotalJidCapabilites( item->jid );
- if (( jcb & JABBER_RESOURCE_CAPS_IN_PROGRESS ) == JABBER_RESOURCE_CAPS_IN_PROGRESS ) {
+ JabberCapsBits jcb = GetResourceCapabilites( item->jid, TRUE );
+ if ( jcb == JABBER_RESOURCE_CAPS_IN_PROGRESS ) {
Sleep(600);
- jcb = GetTotalJidCapabilites( item->jid );
+ jcb = GetResourceCapabilites( item->jid, TRUE );
}
// fix for very smart clients, like gajim
@@ -1238,6 +1238,10 @@ int __cdecl CJabberProto::SendMsg( HANDLE hContact, int flags, const char* pszSr
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
GetClientJID( dbv.ptszVal, szClientJid, SIZEOF( szClientJid ));
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( szClientJid );
+ if ( r )
+ r->bMessageSessionActive = TRUE;
+
JabberCapsBits jcb = GetResourceCapabilites( szClientJid, TRUE );
if ( jcb & JABBER_RESOURCE_CAPS_ERROR )
diff --git a/protocols/JabberG/jabber_thread.cpp b/protocols/JabberG/jabber_thread.cpp
index 191516a9d7..740c9c4c91 100644
--- a/protocols/JabberG/jabber_thread.cpp
+++ b/protocols/JabberG/jabber_thread.cpp
@@ -1114,7 +1114,7 @@ HANDLE CJabberProto::CreateTemporaryContact( const TCHAR *szJid, JABBER_LIST_ITE
void CJabberProto::OnProcessMessage( HXML node, ThreadData* info )
{
HXML subjectNode, xNode, inviteNode, idNode, n;
- LPCTSTR from, type, idStr;
+ LPCTSTR from, type, idStr, fromResource;
HANDLE hContact;
if ( !xmlGetName( node ) || _tcscmp( xmlGetName( node ), _T("message")))
@@ -1211,11 +1211,8 @@ void CJabberProto::OnProcessMessage( HXML node, ThreadData* info )
JCallService( MS_PROTO_CONTACTISTYPING, ( WPARAM )hContact, PROTOTYPE_CONTACTTYPING_OFF );
// chatstates inactive event
- if ( hContact && xmlGetChildByTag( node, "inactive", "xmlns", _T( JABBER_FEAT_CHATSTATES ))) {
+ if ( hContact && xmlGetChildByTag( node, "inactive", "xmlns", _T( JABBER_FEAT_CHATSTATES )))
JCallService( MS_PROTO_CONTACTISTYPING, ( WPARAM )hContact, PROTOTYPE_CONTACTTYPING_OFF );
- if ( resourceStatus )
- resourceStatus->uMessageSessionActive = 0;
- }
// message receipts delivery notification
if ( n = xmlGetChildByTag( node, "received", "xmlns", _T( JABBER_FEAT_MESSAGE_RECEIPTS ))) {
@@ -1255,20 +1252,17 @@ void CJabberProto::OnProcessMessage( HXML node, ThreadData* info )
}
// chatstates gone event
- if ( hContact && xmlGetChildByTag( node, "gone", "xmlns", _T( JABBER_FEAT_CHATSTATES ))) {
- if ( resourceStatus ) resourceStatus->uMessageSessionActive = 0;
- if ( m_options.LogChatstates ) {
- DBEVENTINFO dbei;
- BYTE bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = &bEventType;
- dbei.cbBlob = 1;
- dbei.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
- dbei.flags = DBEF_READ;
- dbei.timestamp = time(NULL);
- dbei.szModule = m_szModuleName;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
- }
+ if ( hContact && xmlGetChildByTag( node, "gone", "xmlns", _T( JABBER_FEAT_CHATSTATES )) && m_options.LogChatstates ) {
+ DBEVENTINFO dbei;
+ BYTE bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
+ dbei.cbSize = sizeof(dbei);
+ dbei.pBlob = &bEventType;
+ dbei.cbBlob = 1;
+ dbei.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
+ dbei.flags = DBEF_READ;
+ dbei.timestamp = time(NULL);
+ dbei.szModule = m_szModuleName;
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
}
if (( n = xmlGetChildByTag( node, "confirm", "xmlns", _T( JABBER_FEAT_HTTP_AUTH ))) && m_options.AcceptHttpAuth ) {
@@ -1474,26 +1468,25 @@ void CJabberProto::OnProcessMessage( HXML node, ThreadData* info )
if (( szMessage = JabberUnixToDosT( szMessage )) == NULL )
szMessage = mir_tstrdup( _T(""));
- char* buf = mir_utf8encodeW(szMessage);
+ char* buf = mir_utf8encodeW( szMessage );
if ( item != NULL ) {
+ if ( resourceStatus ) resourceStatus->bMessageSessionActive = TRUE;
if ( hContact != NULL )
JCallService( MS_PROTO_CONTACTISTYPING, ( WPARAM ) hContact, PROTOTYPE_CONTACTTYPING_OFF );
- if (item->resourceMode != RSMODE_MANUAL && resourceStatus != item->lastSeenResource) {
- item->lastSeenResource = resourceStatus;
- UpdateMirVer(item);
- }
- else item->lastSeenResource = resourceStatus;
-
- if ( resourceStatus && resourceStatus->uMessageSessionActive == 0 ) {
- for ( int i=0; i<item->resourceCount; i++ )
- if ( &item->resource[i] != resourceStatus )
- item->resource[i].uMessageSessionActive = 0;
- }
- if ( resourceStatus )
- resourceStatus->uMessageSessionActive = time(NULL);
- }
+ // no we will monitor last resource in all modes
+ 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;
+ } } } } }
// Create a temporary contact
if ( hContact == NULL )
diff --git a/protocols/JabberG/jabber_userinfo.cpp b/protocols/JabberG/jabber_userinfo.cpp
index f79202ca73..b24c649e1d 100644
--- a/protocols/JabberG/jabber_userinfo.cpp
+++ b/protocols/JabberG/jabber_userinfo.cpp
@@ -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 )
- lstrcpyn( buf, item->lastSeenResource->resourceName, SIZEOF( buf ));
+ if (( item->lastSeenResource >= 0 ) && ( item->lastSeenResource < item->resourceCount ))
+ lstrcpyn( buf, item->resource[item->lastSeenResource].resourceName, SIZEOF( buf ));
else
lstrcpyn( buf, TranslateT( "<no information available>" ), SIZEOF( buf ));
diff --git a/protocols/JabberG/jabber_util.cpp b/protocols/JabberG/jabber_util.cpp
index 31c4ead6c7..463612c4e4 100644
--- a/protocols/JabberG/jabber_util.cpp
+++ b/protocols/JabberG/jabber_util.cpp
@@ -1046,6 +1046,15 @@ TCHAR* CJabberProto::GetClientJID( const TCHAR* jid, TCHAR* dest, size_t destLen
dest[ len ] = '\0';
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 ( p ) *p = 0;
+ return dest;
+ }
+
if ( p == NULL ) {
TCHAR* resource = ListGetBestResourceNamePtr( jid );
if ( resource != NULL )