diff options
Diffstat (limited to 'protocols/JabberG/jabber_groupchat.cpp')
-rw-r--r-- | protocols/JabberG/jabber_groupchat.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
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;
|