tizen 2.4 release
[framework/web/wrt-commons.git] / modules / localization / src / w3c_file_localization.cpp
@@ -29,9 +29,8 @@
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/localization/localization_utils.h>
 
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
 #include <dpl/string.h>
-#include <dpl/optional.h>
 #include <dpl/foreach.h>
 
 #include <LanguageTagsProvider.h>
@@ -44,18 +43,18 @@ const DPL::String WIDGET_URI_BEGIN = L"widget://";
 const DPL::String APP_URI_BEGIN = L"app://";
 const DPL::String LOCALE_PREFIX = L"locales/";
 
-DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
+DPL::OptionalStdString GetFilePathInWidgetPackageInternal(
     const std::string& basePath,
     std::string filePath)
 {
-    LogDebug("Looking for file: " << filePath << "  in: " << basePath);
+    WrtLogD("Looking for file: %s in: %s", filePath.c_str(), basePath.c_str());
 
     const LanguageTags& ltags =
         LanguageTagsProviderSingleton::Instance().getLanguageTags();
 
     //Check if string isn't empty
     if (filePath.size() == 0) {
-        return DPL::Optional<std::string>::Null;
+        return DPL::OptionalStdString();
     }
     //Removing preceding '/'
     if (filePath[0] == '/') {
@@ -68,15 +67,15 @@ DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
     }
     //Check if string isn't empty
     if (filePath.size() == 0) {
-        return DPL::Optional<std::string>::Null;
+        return DPL::OptionalStdString();
     }
 
-    LogDebug("locales size = " << ltags.size());
+    WrtLogD("locales size = %i", ltags.size());
     for (LanguageTags::const_iterator it = ltags.begin();
          it != ltags.end();
          ++it)
     {
-        LogDebug("Trying locale: " << *it);
+        WrtLogD("Trying locale: %ls", it->c_str());
         std::string path = basePath;
         if (path[path.size() - 1] == '/') {
             path.erase(path.size() - 1);
@@ -88,27 +87,27 @@ DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
             path += "/locales/" + DPL::ToUTF8String(*it) + "/" + filePath;
         }
 
-        LogDebug("Trying locale: " << *it << " | " << path);
+        WrtLogD("Trying locale: %ls | %s", it->c_str(), path.c_str());
         struct stat buf;
         if (0 == stat(path.c_str(), &buf)) {
             if ((buf.st_mode & S_IFMT) == S_IFREG) {
                 path.erase(0, basePath.length());
-                return DPL::Optional<std::string>(path);
+                return DPL::OptionalStdString(path);
             }
         }
     }
 
-    return DPL::Optional<std::string>::Null;
+    return DPL::OptionalStdString();
 }
 
-DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
+DPL::OptionalString GetFilePathInWidgetPackageInternal(
     const DPL::String& basePath,
     const DPL::String& filePath)
 {
-    DPL::Optional<std::string> path =
+    DPL::OptionalStdString path =
         GetFilePathInWidgetPackageInternal(DPL::ToUTF8String(basePath),
                                            DPL::ToUTF8String(filePath));
-    DPL::Optional<DPL::String> dplPath;
+    DPL::OptionalString dplPath;
     if (!!path) {
         dplPath = DPL::FromUTF8String(*path);
     }
@@ -191,7 +190,7 @@ std::string getFilePathInWidgetPackageFromUrl(const std::string &tzAppId, const
         if (workingUrl.compare(0, DOUBLE_ROOT.length(), DOUBLE_ROOT) == 0)
         {
             workingUrl.erase(0, 1);
-            LogDebug("workingUrl: " << workingUrl);
+            WrtLogD("workingUrl: %s", workingUrl.c_str());
         }
 
         // remove src path
@@ -225,7 +224,7 @@ std::string getFilePathInWidgetPackageFromUrl(const std::string &tzAppId, const
         }
         else
         {
-            LogError("Tizen id does not match, ignoring");
+            WrtLogE("Tizen id does not match, ignoring");
             return "";
         }
     }
@@ -242,7 +241,7 @@ std::string getFilePathInWidgetPackageFromUrl(const std::string &tzAppId, const
 
     if (workingUrl.empty())
     {
-        LogError("URL Localization Error!");
+        WrtLogE("URL Localization Error!");
         return "";
     }
 
@@ -296,7 +295,7 @@ std::string getFilePathInWidgetPackageFromUrl(const std::string &tzAppId, const
     return workingUrl;
 }
 
-DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+DPL::OptionalString getFilePathInWidgetPackageFromUrl(
     const WrtDB::TizenAppId &tzAppId,
     const DPL::String &url)
 {
@@ -305,7 +304,7 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
                url);
 }
 
-DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+DPL::OptionalString getFilePathInWidgetPackageFromUrl(
     WrtDB::WidgetDAOReadOnlyPtr dao,
     const DPL::String &url)
 {
@@ -347,24 +346,24 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
         DPL::String id = dao->getTizenAppId();
         if(req.substr(0, id.size()) != id)
         {
-            LogError("Tizen id does not match, ignoring");
-            return DPL::Optional<DPL::String>::Null;
+            WrtLogE("Tizen id does not match, ignoring");
+            return DPL::OptionalString();
         }
         req.erase(0, id.length());
     } else {
-        LogDebug("Unknown path format, ignoring");
-        return DPL::Optional<DPL::String>::Null;
+        WrtLogD("Unknown path format, ignoring");
+        return DPL::OptionalString();
     }
 
     auto widgetPath = dao->getPath();
 
-    LogDebug("Required path: " << req);
-    DPL::Optional<DPL::String> found =
+    WrtLogD("Required path: %ls", req.c_str());
+    DPL::OptionalString found =
         GetFilePathInWidgetPackageInternal(widgetPath, req);
 
     if (!found) {
-        LogError("Path not found within current locale in current widget");
-        return DPL::Optional<DPL::String>::Null;
+        WrtLogE("Path not found within current locale in current widget");
+        return DPL::OptionalString();
     }
 
     found = widgetPath + *found + suffix;
@@ -372,7 +371,7 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
     return found;
 }
 
-DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+DPL::OptionalString getFilePathInWidgetPackage(
     const WrtDB::TizenAppId &tzAppId,
     const DPL::String& file)
 {
@@ -381,7 +380,7 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackage(
                file);
 }
 
-DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+DPL::OptionalString getFilePathInWidgetPackage(
     WrtDB::WidgetDAOReadOnlyPtr dao,
     const DPL::String& file)
 {
@@ -421,7 +420,7 @@ DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao)
         }
     }
 
-    return DPL::OptionalString::Null;
+    return DPL::OptionalString();
 }
 
 OptionalWidgetIcon getIcon(const WrtDB::TizenAppId & tzAppId)
@@ -461,7 +460,7 @@ OptionalWidgetIcon getIcon(WrtDB::WidgetDAOReadOnlyPtr dao)
         }
     }
 
-    return OptionalWidgetIcon::Null;
+    return OptionalWidgetIcon();
 }
 
 WidgetIconList getValidIconsList(const WrtDB::TizenAppId &tzAppId)
@@ -478,7 +477,7 @@ WidgetIconList getValidIconsList(WrtDB::WidgetDAOReadOnlyPtr dao)
 
     FOREACH(it, list)
     {
-        LogDebug(":" << it->iconSrc);
+        WrtLogD(":%ls", it->iconSrc.c_str());
         if (!!getFilePathInWidgetPackage(dao->getTizenAppId(),
                                          it->iconSrc))
         {
@@ -535,7 +534,7 @@ OptionalWidgetStartFileInfo getStartFileInfo(WrtDB::WidgetDAOReadOnlyPtr dao)
         }
     }
 
-    return OptionalWidgetStartFileInfo::Null;
+    return OptionalWidgetStartFileInfo();
 }
 
 WidgetLocalizedInfo getLocalizedInfo(const WrtDB::TizenAppId & tzAppId)