From f673f034c2fef25e932a12fbd5e2772f90c75e6d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Jun 2012 12:44:02 +0000 Subject: Clist_mw & Clist_modern renamed git-svn-id: http://svn.miranda-ng.org/main/trunk@455 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/modern_skinned_profile.cpp | 115 ++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 plugins/Clist_modern/modern_skinned_profile.cpp (limited to 'plugins/Clist_modern/modern_skinned_profile.cpp') diff --git a/plugins/Clist_modern/modern_skinned_profile.cpp b/plugins/Clist_modern/modern_skinned_profile.cpp new file mode 100644 index 0000000000..d31fe7d18f --- /dev/null +++ b/plugins/Clist_modern/modern_skinned_profile.cpp @@ -0,0 +1,115 @@ + + +#include "hdr/modern_commonheaders.h" + +#ifdef _DEBUG // REMOVE ME, as soon as ghazan will implement msvcprt.lib msvcrt.lib analogs to vc6tovc7.lib +#include "hdr/modern_skinned_profile.h" + + +//need to be linked in: atls.lib msvcprt.lib msvcrt.lib + +CSkinnedProfile CSkinnedProfile::_me; + + +CSkinnedProfile::CSkinnedProfile() +{ + Init(); +} + +CSkinnedProfile::~CSkinnedProfile() +{ + +} + +HRESULT CSkinnedProfile::Init() +{ + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + SkinnedProfile.clear(); + return S_OK; +} + +HRESULT CSkinnedProfile::Clear() +{ + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + SkinnedProfile.clear(); + return S_OK; +} + + +ValueVariant* CSkinnedProfile::_GetValue( const char * szSection, const char * szKey ) +{ + KeyList_t::iterator k_it = SkinnedProfile.find( szSection ); + if ( k_it == SkinnedProfile.end() ) + return NULL; // Not skinned + + ValueList_t::iterator v_it = k_it->second.find( szKey ); + if ( v_it == k_it->second.end() ) + return NULL; // Not skinned + + return &( v_it->second ); +}; + +BYTE CSkinnedProfile::SpiGetSkinByte( HANDLE hContact, const char * szSection, const char * szKey, const BYTE defValue ) +{ + if ( hContact ) + return ModernGetSettingByte( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all + + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + + ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey ); + + if ( value == NULL ) // not skinned => return DB + return ModernGetSettingWord( hContact, szSection, szKey, defValue ); + + else if ( !value->IsEmpty() ) + return value->GetByte(); + + return defValue; // skinned but empty => return default value +} + +WORD CSkinnedProfile::SpiGetSkinWord( HANDLE hContact, const char * szSection, const char * szKey, const WORD defValue ) +{ + if ( hContact ) + return ModernGetSettingWord( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all + + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + + ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey ); + + if ( value == NULL ) // not skinned => return DB + return ModernGetSettingWord( hContact, szSection, szKey, defValue ); + + else if ( !value->IsEmpty() ) + return value->GetWord(); + + return defValue; // skinned but empty => return default value +} + +DWORD CSkinnedProfile::SpiGetSkinDword( HANDLE hContact, const char * szSection, const char * szKey, const DWORD defValue ) +{ + if ( hContact ) + return ModernGetSettingDword( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all + + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + + ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey ); + + if ( value == NULL ) // not skinned => return DB + return ModernGetSettingDword( hContact, szSection, szKey, defValue ); + + else if ( !value->IsEmpty() ) + return value->GetDword(); + + return defValue; // skinned but empty => return default value +} + +BOOL CSkinnedProfile::SpiCheckSkinned( HANDLE hContact, const char * szSection, const char * szKey ) +{ + if ( hContact ) + return FALSE; + + CAutoCriticalSection Lock( SkinProfile()->_Lock, true ); + + return ( SkinProfile()->_GetValue( szSection, szKey ) == NULL ); +} +#endif // _DEBUG // REMOVE ME, as soon as ghazan will implement msvcprt.lib msvcrt.lib analogs to vc6tovc7.lib \ No newline at end of file -- cgit v1.2.3