diff options
Diffstat (limited to 'plugins/Modernb/modern_skinned_profile.cpp')
-rw-r--r-- | plugins/Modernb/modern_skinned_profile.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/plugins/Modernb/modern_skinned_profile.cpp b/plugins/Modernb/modern_skinned_profile.cpp new file mode 100644 index 0000000000..d31fe7d18f --- /dev/null +++ b/plugins/Modernb/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 |