diff options
author | George Hazan <george.hazan@gmail.com> | 2012-05-30 13:54:56 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-05-30 13:54:56 +0000 |
commit | ee9d85e617be7be900d31be00d0dec766119c2e5 (patch) | |
tree | fcc7a837d39e057a79bae3b9509bef659f1643f2 /protocols/JabberG | |
parent | 9951afcf3b7dbb6ec2037dcb345c56db811329cd (diff) |
yet another option for chats' history reading
git-svn-id: http://svn.miranda-ng.org/main/trunk@233 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/jabber.h | 21 | ||||
-rw-r--r-- | protocols/JabberG/jabber_db_utils.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/jabber_groupchat.cpp | 30 | ||||
-rw-r--r-- | protocols/JabberG/jabber_opt.cpp | 1 |
4 files changed, 35 insertions, 19 deletions
diff --git a/protocols/JabberG/jabber.h b/protocols/JabberG/jabber.h index c5965f9f8f..d990982d90 100644 --- a/protocols/JabberG/jabber.h +++ b/protocols/JabberG/jabber.h @@ -332,7 +332,7 @@ struct ThreadData HANDLE hThread;
JABBER_SESSION_TYPE type;
-
+
// network support
JABBER_SOCKET s;
BOOL useSSL;
@@ -445,7 +445,7 @@ struct filetransfer HANDLE hFileEvent;
unsigned __int64 *fileSize;
TCHAR* szDescription;
-
+
CJabberProto* ppro;
};
@@ -499,8 +499,8 @@ class _A2T TCHAR* buf;
public:
- _A2T( const char* s ) : buf( mir_a2t( s )) {}
- _A2T( const char* s, int cp ) : buf( mir_a2t_cp( s, cp )) {}
+ __forceinline _A2T( const char* s ) : buf( mir_a2t( s )) {}
+ __forceinline _A2T( const char* s, int cp ) : buf( mir_a2t_cp( s, cp )) {}
~_A2T() { mir_free(buf); }
__forceinline operator TCHAR*() const
@@ -508,6 +508,19 @@ public: }
};
+class _T2A
+{
+ char* buf;
+
+public:
+ __forceinline _T2A( const TCHAR* s ) : buf( mir_t2a( s )) {}
+ __forceinline ~_T2A() { mir_free(buf); }
+
+ __forceinline operator char*() const
+ { return buf;
+ }
+};
+
//---- jabber_treelist.c ------------------------------------------------
typedef struct TTreeList_ItemInfo *HTREELISTITEM;
diff --git a/protocols/JabberG/jabber_db_utils.h b/protocols/JabberG/jabber_db_utils.h index b1cda11547..3670bfaeb5 100644 --- a/protocols/JabberG/jabber_db_utils.h +++ b/protocols/JabberG/jabber_db_utils.h @@ -198,6 +198,7 @@ struct CJabberOptions CMOption<BYTE> GcLogConfig;
CMOption<BYTE> GcLogRoles;
CMOption<BYTE> GcLogStatuses;
+ CMOption<BYTE> GcLogChatHistory;
CMOption<BYTE> HostNameAsResource;
CMOption<BYTE> IgnoreMUCInvites;
CMOption<BYTE> KeepAlive;
@@ -252,6 +253,7 @@ struct CJabberOptions GcLogConfig(proto, "GcLogConfig", FALSE),
GcLogRoles(proto, "GcLogRoles", FALSE),
GcLogStatuses(proto, "GcLogStatuses", FALSE),
+ GcLogChatHistory(proto, "GcLogChatHistory", TRUE),
HostNameAsResource(proto, "HostNameAsResource", FALSE),
IgnoreMUCInvites(proto, "IgnoreMUCInvites", FALSE),
KeepAlive(proto, "KeepAlive", TRUE),
diff --git a/protocols/JabberG/jabber_groupchat.cpp b/protocols/JabberG/jabber_groupchat.cpp index eb2ae55adb..8e11f030cf 100644 --- a/protocols/JabberG/jabber_groupchat.cpp +++ b/protocols/JabberG/jabber_groupchat.cpp @@ -320,19 +320,19 @@ void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, co if ( info.password && info.password[0] )
x << XCHILD( _T("password"), info.password );
- char setting[MAXMODULELABELLENGTH];
- DBVARIANT dbv;
- mir_snprintf(setting, sizeof(setting), "muc_%s@%s_lastevent", mir_u2a(room), mir_u2a(server));
- time_t lasteventtime = this->JGetDword( NULL, setting, 0 );
- if ( lasteventtime > 0 ) {
- _tzset();
- lasteventtime += _timezone + 1;
- struct tm* time = localtime(&lasteventtime);
- TCHAR lasteventdate[20];
- TCHAR* timeformat = mir_a2u("%04d-%02d-%02dT%02d:%02d:%02dZ");
- mir_sntprintf(lasteventdate, sizeof(lasteventdate), timeformat, 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);
- JFreeVariant( &dbv );
+ if (m_options.GcLogChatHistory) {
+ 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[20];
+ 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, text, x );
@@ -1250,9 +1250,9 @@ void CJabberProto::GroupchatProcessMessage( HXML node ) if ( !_tcscmp( p, _T("jabber:x:delay")) && msgTime==0 )
if (( p = xmlGetAttrValue( xNode, _T("stamp"))) != NULL ) {
msgTime = JabberIsoToUnixTime( p );
- if ( msgTime > 0 ) {
+ if (m_options.GcLogChatHistory && msgTime > 0 ) {
char setting[MAXMODULELABELLENGTH];
- mir_snprintf(setting, sizeof(setting), "muc_%s_lastevent", mir_u2a(gcd.ptszID));
+ mir_snprintf(setting, sizeof(setting), "muc_%s_lastevent", _T2A(gcd.ptszID));
this->JSetDword(NULL, setting, msgTime);
} }
diff --git a/protocols/JabberG/jabber_opt.cpp b/protocols/JabberG/jabber_opt.cpp index 884fe0f077..574cf4b50c 100644 --- a/protocols/JabberG/jabber_opt.cpp +++ b/protocols/JabberG/jabber_opt.cpp @@ -956,6 +956,7 @@ public: m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Affiliation changes"), m_proto->m_options.GcLogAffiliations);
m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Role changes"), m_proto->m_options.GcLogRoles);
m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Status changes"), m_proto->m_options.GcLogStatuses);
+ m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Filter history messages"), m_proto->m_options.GcLogChatHistory);
}
static CDlgBase *Create(void *param) { return new CDlgOptGc((CJabberProto *)param); }
|