Modify installed path for preload widget.
authorSoyoung Kim <sy037.kim@samsung.com>
Tue, 20 Nov 2012 06:18:20 +0000 (15:18 +0900)
committerGerrit Code Review <gerrit2@kim11>
Tue, 27 Nov 2012 06:50:58 +0000 (15:50 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Add db column for widget installed path at WidgetExtendedInfo
[SCMRequest] This commit should release with wrt-installer.

Change-Id: If213499637fef81ec9839f4ef24df370c8679e62

modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/orm/wrt_db

index 56076b1..d46f378 100644 (file)
@@ -392,7 +392,7 @@ void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
     row.Set_install_time(regInfo.installedTime);
     row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
     row.Set_background_page(regInfo.configInfo.backgroundPage);
-
+    row.Set_installed_path(regInfo.widgetInstalledPath);
 
     DO_INSERT(row, WidgetExtendedInfo)
 }
index 4671cb0..0d52aae 100644 (file)
@@ -215,14 +215,9 @@ DPL::OptionalInt WidgetDAOReadOnly::checkPropertyReadFlag(
 
 DPL::String WidgetDAOReadOnly::getPath() const
 {
-    DPL::String path = DPL::FromUTF8String(
-            GlobalConfig::GetUserInstalledWidgetPath());
+    DPL::String path = *getWidgetInstalledPath();
     DPL::String srcPath = DPL::FromUTF8String(GlobalConfig::GetWidgetSrcPath());
 
-    DPL::OStringStream strAppId;
-    strAppId << m_widgetHandle;
-    DPL::OptionalString pkgname = getPkgname();
-    path += L"/" + *pkgname;
     path += srcPath + L"/";
 
     return path;
@@ -1142,6 +1137,25 @@ SettingsType WidgetDAOReadOnly::getFileSystemUsage(void) const
     return static_cast<SettingsType>(*result);
 }
 
+DPL::OptionalString WidgetDAOReadOnly::getWidgetInstalledPath() const
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
+
+        WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
+        if (rows.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << m_widgetHandle);
+        }
+
+        return rows.front().Get_installed_path();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget installed path")
+}
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
 #undef CHECK_WIDGET_EXISTENCE
index 9f18da2..2721214 100644 (file)
@@ -61,6 +61,22 @@ inline const char* GetUserInstalledWidgetPath()
 }
 
 /**
+ * WRT widgets that are preloaded
+ */
+inline const char* GetUserPreloadedWidgetPath()
+{
+    return "/usr/apps";
+}
+
+/**
+ * WRT widgets that are downloaded and installed by user
+ */
+inline const char* GetWidgetUserDataPath()
+{
+    return "/opt/usr/apps";
+}
+
+/**
  * WRT widgets that are downloaded and installed by user
  */
 inline const char* GetWidgetSrcPath()
index bd1ee00..7669701 100644 (file)
@@ -35,7 +35,7 @@ namespace WidgetConfig {
 inline std::string GetWidgetBasePath(DPL::String pkgName)
 {
     return PathBuilder()
-               .Append(GlobalConfig::GetUserInstalledWidgetPath())
+               .Append(GlobalConfig::GetWidgetUserDataPath())
                .Append(DPL::ToUTF8String(pkgName))
                .GetFullPath();
 }
index 2d776ca..3d33b89 100644 (file)
@@ -180,6 +180,7 @@ struct WidgetRegisterInfo
     PackagingType packagingType;
     EncryptedFileList encryptedFiles;
     ExternalLocationList externalLocations;
+    DPL::OptionalString widgetInstalledPath;
 };
 
 typedef std::list<std::string> CertificateChainList;
@@ -765,6 +766,13 @@ class WidgetDAOReadOnly
     SettingsType getWebNotificationUsage() const;
     SettingsType getWebDatabaseUsage() const;
     SettingsType getFileSystemUsage() const;
+
+    /**
+     * This method returns widget's installed path
+     *
+     * @return path of widget installed
+     */
+    DPL::OptionalString getWidgetInstalledPath() const;
 };
 
 } // namespace WrtDB
index 751addc..56c93a0 100644 (file)
@@ -91,6 +91,7 @@ CREATE_TABLE(WidgetExtendedInfo)
     COLUMN_NOT_NULL(test_widget, INT, CHECK(test_widget between 0 and 1) DEFAULT 0)
     COLUMN(splash_img_src,      VARCHAR(256),   DEFAULT '')
     COLUMN(background_page,      VARCHAR(256),   DEFAULT '')
+    COLUMN(installed_path,      VARCHAR(512),   DEFAULT '')
     TABLE_CONSTRAINTS(
         FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     )