From: Kimmo Hoikka Date: Wed, 20 May 2015 14:29:36 +0000 (+0100) Subject: Move illegal file access from style manager to adaptor X-Git-Tag: accepted/tizen/common/20150529.134105~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a07898c16d73ea15973f99ba474bf96dd45c4d4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Move illegal file access from style manager to adaptor Change-Id: Iad712d3e9ee8a1fd8237298cefb10e5bae06020e --- diff --git a/adaptors/common/style-monitor-impl.cpp b/adaptors/common/style-monitor-impl.cpp index 756df14..6764883 100644 --- a/adaptors/common/style-monitor-impl.cpp +++ b/adaptors/common/style-monitor-impl.cpp @@ -20,6 +20,8 @@ // EXTERNAL INCLUDES #include +#include +#include // INTERNAL INCLUDES #include @@ -134,6 +136,23 @@ void StyleMonitor::SetTheme(const std::string& path) EmitStyleChangeSignal(styleChange); } +bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output ) +{ + bool retval( false ); + std::ifstream in( filename.c_str(), std::ios::in ); + if( in ) + { + std::stringstream buffer; + buffer << in.rdbuf(); + + output = buffer.str(); + + in.close(); + retval = true; + } + return retval; +} + Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal() { return mStyleChangeSignal; diff --git a/adaptors/common/style-monitor-impl.h b/adaptors/common/style-monitor-impl.h index f2aa027..be32214 100644 --- a/adaptors/common/style-monitor-impl.h +++ b/adaptors/common/style-monitor-impl.h @@ -92,6 +92,11 @@ public: */ void SetTheme(const std::string& themeFilePath); + /** + * @copydoc Dali::StyleMonitor::LoadThemeFile() + */ + bool LoadThemeFile( const std::string& filename, std::string& output ); + // Signals /** diff --git a/adaptors/devel-api/adaptor-framework/style-monitor.cpp b/adaptors/devel-api/adaptor-framework/style-monitor.cpp index 632fe83..efc32bd 100644 --- a/adaptors/devel-api/adaptor-framework/style-monitor.cpp +++ b/adaptors/devel-api/adaptor-framework/style-monitor.cpp @@ -67,6 +67,11 @@ void StyleMonitor::SetTheme(const std::string& themFilePath) return GetImplementation(*this).SetTheme(themFilePath); } +bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output ) +{ + return GetImplementation(*this).LoadThemeFile( filename, output ); +} + StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal() { return GetImplementation(*this).StyleChangeSignal(); diff --git a/adaptors/devel-api/adaptor-framework/style-monitor.h b/adaptors/devel-api/adaptor-framework/style-monitor.h index 5ca8b6b..e4b3afa 100644 --- a/adaptors/devel-api/adaptor-framework/style-monitor.h +++ b/adaptors/devel-api/adaptor-framework/style-monitor.h @@ -134,6 +134,14 @@ public: // Style Information */ void SetTheme(const std::string& themeFilePath); + /** + * @brief Utility to load a theme file + * @param filename of the theme + * @param output to write the contents to + * @return true if the load is successful + */ + bool LoadThemeFile( const std::string& filename, std::string& output ); + public: // Signals /**