Tizen 2.1 base
[platform/framework/web/wrt-plugins-common.git] / src / modules / tizen / WidgetDB / WidgetDB.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 2727beb..0618c65
 #include <dpl/wrt-dao-ro/feature_model.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
+#include <dpl/localization/w3c_file_localization.h>
+
 #include "WidgetFeature.h"
 
-namespace { // anonymous
-    const int INVALID_WIDGET_HANDLE = -1;
-} // namespace
 
 namespace WrtDeviceApis {
 namespace WidgetDB {
@@ -97,9 +96,8 @@ std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
-        std::string language = getLanguage();
-        WrtDB::WidgetLocalizedInfo widgetInfo = dao.getLocalizedInfo(
-            DPL::FromUTF8String(language));
+        WrtDB::WidgetLocalizedInfo widgetInfo =
+            W3CFileLocalization::getLocalizedInfo(getWidgetId());
 
         std::ostringstream out;
 
@@ -221,23 +219,10 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
         const WrtDB::WidgetGUID w_guid =
             WrtDB::WidgetGUID(DPL::FromUTF8String(gid));
 
-        WrtDB::DbWidgetHandle widgetHandle = INVALID_WIDGET_HANDLE;
-
-        WrtDB::DbWidgetHandleList widgetList = WrtDB::WidgetDAOReadOnly
-            ::getHandleList();
+        try {
+            WrtDB::DbWidgetHandle widgetHandle =
+                    WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
 
-        FOREACH(iterator, widgetList) {
-            WrtDB::WidgetDAOReadOnly dao(*iterator);
-            WrtDB::WidgetGUID d_guid = dao.getGUID();
-            if (w_guid == d_guid) {
-                widgetHandle = *iterator;
-            }
-        }
-
-        // TODO check name
-        if (INVALID_WIDGET_HANDLE == widgetHandle) {
-            outStatus = Api::InstallationStatus::STATUS_UNINSTALLED;
-        } else {
             WrtDB::WidgetDAOReadOnly dao(widgetHandle);
             DPL::OptionalString ver = dao.getVersion();
             if (!ver || version > DPL::ToUTF8String(*ver)) {
@@ -247,6 +232,8 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
             } else {
                 outStatus = Api::InstallationStatus::STATUS_LATEST;
             }
+        }catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
+            outStatus = Api::InstallationStatus::STATUS_UNINSTALLED;
         }
     }
     Catch(DPL::Exception)
@@ -381,7 +368,7 @@ std::string WidgetDB::getWidgetPersistentStoragePath() const
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
-        return WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(*dao.getPkgname());
+        return WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(dao.getPkgName());
     }
     Catch(DPL::Exception)
     {
@@ -394,7 +381,7 @@ std::string WidgetDB::getWidgetTemporaryStoragePath() const
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
-        return WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(*dao.getPkgname());
+        return WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(dao.getPkgName());
     }
     Catch(DPL::Exception)
     {