/* Jabber Protocol Plugin for Miranda NG Copyright (c) 2002-04 Santithorn Bunchua Copyright (c) 2005-12 George Hazan Copyright (c) 2007-09 Maxim Mluhov Copyright (c) 2007-09 Victor Pavlychko Copyright (c) 2012-14 Miranda NG project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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. */ #ifndef __jabber_db_utils_h__ #define __jabber_db_utils_h__ template struct CMIntTraits { static __forceinline bool IsSigned() { return false; } }; template<> struct CMIntTraits { static __forceinline bool IsSigned() { return true; } }; template<> struct CMIntTraits { static __forceinline bool IsSigned() { return true; } }; template<> struct CMIntTraits { static __forceinline bool IsSigned() { return true; } }; template struct CMDBTraits { }; template<> struct CMDBTraits<1> { typedef BYTE DBType; enum { DBTypeId = DBVT_BYTE }; static __forceinline DBType Get(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { return pPro->getByte(szSetting, value); } static __forceinline void Set(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { pPro->setByte(szSetting, value); } }; template<> struct CMDBTraits<2> { typedef WORD DBType; enum { DBTypeId = DBVT_WORD }; static __forceinline DBType Get(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { pPro->getWord(szSetting, value); } static __forceinline void Set(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { pPro->setWord(szSetting, value); } }; template<> struct CMDBTraits<4> { typedef DWORD DBType; enum { DBTypeId = DBVT_DWORD }; static __forceinline DBType Get(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { return pPro->getDword(szSetting, value); } static __forceinline void Set(PROTO_INTERFACE *pPro, char *szSetting, DBType value) { pPro->setDword(szSetting, value); } }; class CMOptionBase { public: char* GetDBModuleName() const { return m_proto->m_szModuleName; } char* GetDBSettingName() const { return m_szSetting; } protected: CMOptionBase(PROTO_INTERFACE *proto, char *szSetting): m_proto(proto), m_szSetting(szSetting) {} PROTO_INTERFACE *m_proto; char *m_szSetting; private: CMOptionBase(const CMOptionBase &) {} void operator= (const CMOptionBase &) {} }; template class CMOption: public CMOptionBase { public: typedef T Type; __forceinline CMOption(PROTO_INTERFACE *proto, char *szSetting, Type defValue): CMOptionBase(proto, szSetting), m_default(defValue) {} __forceinline operator Type() { return (Type)CMDBTraits::Get(m_proto, m_szSetting, m_default); } __forceinline Type operator= (Type value) { CMDBTraits::Set(m_proto, m_szSetting, (CMDBTraits::DBType)value); return value; } private: Type m_default; CMOption(const CMOption &): CMOptionBase(NULL, NULL, DBVT_DELETED) {} void operator= (const CMOption &) {} }; struct CJabberOptions { CMOption AllowVersionRequests; CMOption AcceptHttpAuth; CMOption AddRoster2Bookmarks; CMOption AutoAcceptAuthorization; CMOption AutoAcceptMUC; CMOption AutoAdd; CMOption AutoJoinBookmarks; CMOption AutoJoinConferences; CMOption AutoJoinHidden; CMOption AvatarType; CMOption BsDirect; CMOption BsDirectManual; CMOption BsOnlyIBB; CMOption BsProxyManual; CMOption Disable3920auth; CMOption DisableFrame; CMOption EnableAvatars; CMOption EnableRemoteControl; CMOption EnableUserActivity; CMOption EnableUserMood; CMOption EnableUserTune; CMOption EnableZlib; CMOption ExtendedSearch; CMOption FixIncorrectTimestamps; CMOption GcLogAffiliations; CMOption GcLogBans; CMOption GcLogConfig; CMOption GcLogRoles; CMOption GcLogStatuses; CMOption GcLogChatHistory; CMOption HostNameAsResource; CMOption IgnoreMUCInvites; CMOption KeepAlive; CMOption LogChatstates; CMOption LogPresence; CMOption LogPresenceErrors; CMOption ManualConnect; CMOption MsgAck; CMOption RosterSync; CMOption SavePassword; CMOption UseDomainLogin; CMOption ShowForeignResourceInMirVer; CMOption ShowOSVersion; CMOption ShowTransport; CMOption UseSSL; CMOption UseTLS; CMOption AcceptNotes; CMOption AutosaveNotes; CMOption EnableMsgArchive; CMOption RcMarkMessagesAsRead; CMOption ConnectionKeepAliveInterval; CMOption ConnectionKeepAliveTimeout; CMOption ProcessXMPPLinks; CMOption IgnoreRosterGroups; CJabberOptions(PROTO_INTERFACE *proto): BsDirect(proto, "BsDirect", TRUE), AllowVersionRequests(proto, "AllowVersionRequests", TRUE), AcceptHttpAuth(proto, "AcceptHttpAuth", TRUE), AddRoster2Bookmarks(proto, "AddRoster2Bookmarks", TRUE), AutoAcceptAuthorization(proto, "AutoAcceptAuthorization", FALSE), AutoAcceptMUC(proto, "AutoAcceptMUC", FALSE), AutoAdd(proto, "AutoAdd", TRUE), AutoJoinBookmarks(proto, "AutoJoinBookmarks", TRUE), AutoJoinConferences(proto, "AutoJoinConferences", 0), AutoJoinHidden(proto, "AutoJoinHidden", TRUE), AvatarType(proto, "AvatarType", PA_FORMAT_UNKNOWN), BsDirectManual(proto, "BsDirectManual", FALSE), BsOnlyIBB(proto, "BsOnlyIBB", FALSE), BsProxyManual(proto, "BsProxyManual", FALSE), Disable3920auth(proto, "Disable3920auth", FALSE), DisableFrame(proto, "DisableFrame", TRUE), EnableAvatars(proto, "EnableAvatars", TRUE), EnableRemoteControl(proto, "EnableRemoteControl", FALSE), EnableMsgArchive(proto, "EnableMsgArchive", FALSE), EnableUserActivity(proto, "EnableUserActivity", TRUE), EnableUserMood(proto, "EnableUserMood", TRUE), EnableUserTune(proto, "EnableUserTune", FALSE), EnableZlib(proto, "EnableZlib", TRUE), ExtendedSearch(proto, "ExtendedSearch", TRUE), FixIncorrectTimestamps(proto, "FixIncorrectTimestamps", TRUE), GcLogAffiliations(proto, "GcLogAffiliations", FALSE), GcLogBans(proto, "GcLogBans", TRUE), 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), LogChatstates(proto, "LogChatstates", FALSE), LogPresence(proto, "LogPresence", TRUE), LogPresenceErrors(proto, "LogPresenceErrors", FALSE), ManualConnect(proto, "ManualConnect", FALSE), MsgAck(proto, "MsgAck", FALSE), RosterSync(proto, "RosterSync", FALSE), SavePassword(proto, "SavePassword", TRUE), ShowForeignResourceInMirVer(proto, "ShowForeignResourceInMirVer", FALSE), ShowOSVersion(proto, "ShowOSVersion", TRUE), ShowTransport(proto, "ShowTransport", TRUE), UseSSL(proto, "UseSSL", FALSE), UseTLS(proto, "UseTLS", TRUE), UseDomainLogin(proto, "UseDomainLogin", FALSE), AcceptNotes(proto, "AcceptNotes", TRUE), AutosaveNotes(proto, "AutosaveNotes", FALSE), RcMarkMessagesAsRead(proto, "RcMarkMessagesAsRead", 1), ConnectionKeepAliveInterval(proto, "ConnectionKeepAliveInterval", 60000), ConnectionKeepAliveTimeout(proto, "ConnectionKeepAliveTimeout", 50000), ProcessXMPPLinks(proto, "ProcessXMPPLinks", FALSE), IgnoreRosterGroups(proto, "IgnoreRosterGroups", FALSE) {} }; #endif // __jabber_db_utils_h__