Clean-up unused feature data
[platform/framework/web/wrt-plugins-common.git] / src / modules / tizen / WidgetDB / WidgetDB.cpp
index f4d9f11..08c3f42 100644 (file)
 
 #include "WidgetFeature.h"
 
-
 namespace WrtDeviceApis {
 namespace WidgetDB {
-
 WidgetDB::WidgetDB(int widgetId) : m_widgetId(widgetId) {}
 
-
 int WidgetDB::getWidgetId() const
 {
     return m_widgetId;
@@ -70,25 +67,24 @@ std::string WidgetDB::getLanguage() const
     }
 
     // get 'en' language or first from the list if 'en' does not exist
-    if (languageTags.size() > 1)
-    {
+    if (languageTags.size() > 1) {
         FOREACH(lang, languageTags)
         {
-            if ("en" == DPL::ToUTF8String(*lang))
+            if ("en" == DPL::ToUTF8String(*lang)) {
                 return "en";
+            }
         }
     }
 
-    if (!languageTags.empty())
-    {
-            // get first language tag
+    if (!languageTags.empty()) {
+        // get first language tag
         outLanguage = DPL::ToUTF8String(*(languageTags.begin()));
     }
     return outLanguage;
 }
 
 /*License,LicenseHref,Description,Name can be \
   returned with incorect language*/
*  returned with incorect language*/
 std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
 {
     LogDebug("entered");
@@ -102,55 +98,65 @@ std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
         std::ostringstream out;
 
         switch (attribute) {
-            case Api::ConfigAttribute::ID: {
+        case Api::ConfigAttribute::ID: {
             DPL::OptionalString val = dao.getGUID();
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::VERSION: {
             DPL::OptionalString val = dao.getVersion();
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::DESCRIPTION: {
             DPL::OptionalString val = widgetInfo.description;
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::LICENSE: {
             DPL::OptionalString val = widgetInfo.license;
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::LICENSE_HREF: {
             DPL::OptionalString val = widgetInfo.licenseHref;
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::AUTHOR_NAME: {
             DPL::OptionalString val = dao.getAuthorName();
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::AUTHOR_EMAIL: {
             DPL::OptionalString val = dao.getAuthorEmail();
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::AUTHOR_HREF: {
             DPL::OptionalString val = dao.getAuthorHref();
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::NAME: {
             DPL::OptionalString val = widgetInfo.name;
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::SHORT_NAME: {
             DPL::OptionalString val = widgetInfo.shortName;
             value = !val ? "" : DPL::ToUTF8String(*val);
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::ACCESS_NETWORK:
             value = dao.getAccessNetworkMode() ? "yes" : "no";
@@ -160,13 +166,15 @@ std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
             DPL::OptionalInt width = dao.getPreferredSize().width;
             !width ? out << "0" : out << *width;
             value = out.str();
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::HEIGHT: {
             DPL::OptionalInt height = dao.getPreferredSize().height;
             !height ? out << "0" : out << *height;
             value = out.str();
-            break; }
+            break;
+        }
 
         case Api::ConfigAttribute::INSTALL_PATH:
             value = DPL::ToUTF8String(dao.getPath());
@@ -195,14 +203,12 @@ std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
     return value;
 }
 
-
-
 std::string WidgetDB::getUserAgent() const
 {
-        LogDebug("Widget User_Agent data get");
+    LogDebug("Widget User_Agent data get");
 
-        std::string outUA("not implemented");
-        return outUA;
+    std::string outUA("not implemented");
+    return outUA;
 }
 
 Api::InstallationStatus WidgetDB::checkInstallationStatus(
@@ -210,8 +216,8 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
     const std::string& name,
     const std::string& version) const
 {
-        LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
-                 "), version(" << version << ")) installation status");
+    LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
+             "), version(" << version << ")) installation status");
 
     Api::InstallationStatus outStatus;
     Try
@@ -221,7 +227,7 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
 
         try {
             WrtDB::DbWidgetHandle widgetHandle =
-                    WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
+                WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
 
             WrtDB::WidgetDAOReadOnly dao(widgetHandle);
             DPL::OptionalString ver = dao.getVersion();
@@ -232,7 +238,7 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
             } else {
                 outStatus = Api::InstallationStatus::STATUS_LATEST;
             }
-        }catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
             outStatus = Api::InstallationStatus::STATUS_UNINSTALLED;
         }
     }
@@ -244,7 +250,6 @@ Api::InstallationStatus WidgetDB::checkInstallationStatus(
     return outStatus;
 }
 
-
 Api::Features WidgetDB::getWidgetFeatures() const
 {
     LogDebug("entered");
@@ -267,17 +272,8 @@ Api::Features WidgetDB::getWidgetFeatures() const
     FOREACH(it, features)
     {
         Api::IWidgetFeaturePtr feature(
-                new WidgetFeature(DPL::ToUTF8String((*it).name),
-                                  (*it).required,
-                                  true));  // requested (WidgetFeature param)
-        // iterating multimap
-        FOREACH(iterator, (*it).params)
-        {
-            // adding features with key(first) and value(second)
-            feature->addParam(DPL::ToUTF8String(iterator->first),
-                              DPL::ToUTF8String(iterator->second));
-        }
-
+            new WidgetFeature(DPL::ToUTF8String((*it).name),
+                              true));      // requested (WidgetFeature param)
         outFeatures.push_back(feature);
     }
 
@@ -321,9 +317,8 @@ Api::Features WidgetDB::getRegisteredFeatures() const
                 // feature is not on outRegisteredFeature so add it with
                 // 'required' property false
                 Api::IWidgetFeaturePtr newFeature(new WidgetFeature(
-                    dao.GetName(),
-                    false,
-                    false));
+                                                      dao.GetName(),
+                                                      false));
 
                 // TODO what about feature params? aren't they needed
                 outRegisteredFeatures.push_back(newFeature);
@@ -340,22 +335,20 @@ Api::Features WidgetDB::getRegisteredFeatures() const
     return outRegisteredFeatures;
 }
 
-
 std::string WidgetDB::getWidgetInstallationPath() const
 {
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
         std::string result(DPL::ToUTF8String(dao.getFullPath()));
-        result.erase(0,strlen("file://"));
+        result.erase(0, strlen("file://"));
         std::string::size_type pos = result.size();
         std::string separator("/");
         pos = result.rfind(separator, pos);
-        if((result.size()-pos) >0 && (result.size()-pos) < 2)
-        {
+        if ((result.size() - pos) > 0 && (result.size() - pos) < 2) {
             result.erase(pos, result.size());
         }
-       return result;
+        return result;
     }
     Catch(DPL::Exception)
     {
@@ -368,7 +361,9 @@ std::string WidgetDB::getWidgetPersistentStoragePath() const
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
-        return WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(dao.getPkgname_NOTNULL());
+        return
+            WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(
+                dao.getTizenPkgId());
     }
     Catch(DPL::Exception)
     {
@@ -381,13 +376,14 @@ std::string WidgetDB::getWidgetTemporaryStoragePath() const
     Try
     {
         WrtDB::WidgetDAOReadOnly dao(getWidgetId());
-        return WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(dao.getPkgname_NOTNULL());
+        return
+            WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(
+                dao.getTizenPkgId());
     }
     Catch(DPL::Exception)
     {
         ReThrow(Commons::PlatformException);
     }
 }
-
 } // WidgetDB
 } // WrtDeviceApis