Move illegal file access from style manager to adaptor 73/39673/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 20 May 2015 14:29:36 +0000 (15:29 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 20 May 2015 14:30:41 +0000 (15:30 +0100)
Change-Id: Iad712d3e9ee8a1fd8237298cefb10e5bae06020e

adaptors/common/style-monitor-impl.cpp
adaptors/common/style-monitor-impl.h
adaptors/devel-api/adaptor-framework/style-monitor.cpp
adaptors/devel-api/adaptor-framework/style-monitor.h

index 756df14..6764883 100644 (file)
@@ -20,6 +20,8 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
+#include <fstream>
+#include <sstream>
 
 // INTERNAL INCLUDES
 #include <adaptor-impl.h>
@@ -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;
index f2aa027..be32214 100644 (file)
@@ -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
 
   /**
index 632fe83..efc32bd 100644 (file)
@@ -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();
index 5ca8b6b..e4b3afa 100644 (file)
@@ -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
 
   /**