[Release] wrt-installer_0.1.23
[framework/web/wrt-installer.git] / src / misc / widget_location.h
index 84106e4..70c186a 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <wrt_common_types.h>
 
 /**
  * @brief The WidgetLocation class
@@ -36,6 +37,7 @@
  *
  * /opt/apps/[package_name]
  *           \_____________ /data
+ *           \_____________ /share
  *           \_____________ /bin
  *           \_____________ /bin/[id_of_installed_package]
  *           \_____________ /res/wgt/
  *                               \___ [widgets_archive_content]
  *
  * 1) Normal Widget
- *  Developer provides content of res/wgt directory (package contains that directory as root).
+ *  Developer provides content of res/wgt directory (package contains that
+ * directory as root).
  *
  * 2) For OSP Service Hybrid App is actually a bit different:
  *  Root is OSP Service directory, WebApp content is located in [root]/res/wgt
  *
  * Temporary directory is directory when widget is placed at the begining
- * of installation process. After parsing process of config.xml, destination directory is created.
+ * of installation process. After parsing process of config.xml, destination
+ * directory is created.
  */
 class WidgetLocation
 {
     class DirectoryDeletor
     {
-    public:
+      public:
         DirectoryDeletor();
+        DirectoryDeletor(std::string tempPath);
         ~DirectoryDeletor();
         std::string getTempPath() const;
-    private:
+
+      private:
         std::string m_dirpath;
     };
 
-public:
+  public:
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
     DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
     /**
@@ -73,44 +79,55 @@ public:
      */
     WidgetLocation();
     /**
-     * @brief WidgetLocation Builds paths for widget location during uninstallation
+     * @brief WidgetLocation Builds paths for widget location during
+     * uninstallation
      *
      * Uninstallation process needs only installed package directory.
      *
      * @param widgetname name of widget
      */
-    WidgetLocation(const std::string & widgetname);
+    explicit WidgetLocation(const std::string & widgetname);
     /**
-     * @brief WidgetLocation Builds paths for widget location during installation
+     * @brief WidgetLocation Builds paths for widget location during
+     * installation
      *
      * @param widgetname name of widget
-     * @param browserRequest is browser Request
      * @param sourcePath given source path
      * @param t declaraced type of widget if type is needed
      *
      * In destruction removes temporary directory
      */
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
-        bool browserRequest = false, WrtDB::PkgType t = WrtDB::PKG_TYPE_TIZEN_WEBAPP);
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+                   InstallLocationType ltype =
+                       INSTALL_LOCATION_TYPE_NOMAL);
+
+    WidgetLocation(const std::string & widgetname, std::string sourcePath,
+                   std::string dirPath,
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
+                   InstallLocationType ltype =
+                       INSTALL_LOCATION_TYPE_NOMAL);
+
     ~WidgetLocation();
 
     // Installed paths
-    std::string getInstallationDir() const;              // /opt/apps
-    std::string getPackageInstallationDir() const;       // /opt/apps/[package]
-    std::string getSourceDir() const;                    // /opt/apps/[package]/res/wgt
-    std::string getBinaryDir() const;                    // /opt/apps/[package]/bin
-    std::string getExecFile() const;                    // /opt/apps/[package]/bin/[package]
-    std::string getBackupDir() const;                    // /opt/apps/[package]/backup
-    std::string getBackupSourceDir() const;              // /opt/apps/[package]/backup/res/wgt
-    std::string getBackupBinaryDir() const;              // /opt/apps/[package]/backup/bin
-    std::string getBackupExecFile() const;              // /opt/apps/[package]/backup/bin/[package]
-
-    bool browserRequest() const;
+    std::string getInstallationDir() const; // /opt/apps or /usr/apps
+    std::string getPackageInstallationDir() const; // /opt/apps/[package]
+    std::string getSourceDir() const;  // /opt/apps/[package]/res/wgt
+    std::string getBinaryDir() const;  // /opt/apps/[package]/bin
+    std::string getExecFile() const;   // /opt/apps/[package]/bin/[package]
+    std::string getBackupDir() const;  // /opt/apps/[package]/backup
+    std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt
+    std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin
+    std::string getBackupExecFile() const;  // /opt/apps/[pkg]/backup/bin/[pkg]
+    std::string getUserDataRootDir() const; // /opt/usr/apps/[package]
+    std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data
 
     // Temporary paths
     /**
      * @brief getTemporaryRootDir
-     * @return value of root for developer's provide package (root of unpacked .wgt file)
+     * @return value of root for developer's provide package (root of unpacked
+     * .wgt file)
      */
     std::string getTemporaryPackageDir() const;
     /**
@@ -118,14 +135,17 @@ public:
      *
      * Value of this will differs according to type of installed widget.
      *
-     * @return value of root for content in temporary directory to be copied into 'res/wgt'
+     * @return value of root for content in temporary directory to be copied
+     * into 'res/wgt'
      */
     std::string getTemporaryRootDir() const;
     /**
-     * @brief getConfigurationDir Returns rott directory for configuration requirements
+     * @brief getConfigurationDir Returns rott directory for configuration
+     * requirements
      *
      * 1) For packed widgets it is just root of unpacked sources
-     * 2) For browser installation it is directory name of widget passed to installer
+     * 2) For browser installation it is directory name of widget passed to
+     * installer
      *
      * @return configuration directory
      */
@@ -133,16 +153,12 @@ public:
 
     //icons
     /**
-     * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+     * @brief setIconTargetFilenameForLocale set installed ion path according to
+     * locale
      * @param icon path of application icon
      */
     void setIconTargetFilenameForLocale(const std::string &icon);
-    /**
-     * @brief getIconTargetFilename gets icon path suffix for locale
-     * @param languageTag language tag
-     * @return value of suffix of path
-     */
-    DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+
     /**
      * @brief getIconTargetFilename gets icon full path
      * @param languageTag language tag
@@ -156,10 +172,10 @@ public:
      */
     std::string getWidgetSource() const;
     /**
-     * @brief pkgname Returns pkgname
-     * @return pkgname
+     * @brief pkgid Returns pkgid
+     * @return pkgid
      */
-    DPL::String getPkgname() const;
+    DPL::String getPkgId() const;
 
     //external files
     /**
@@ -176,14 +192,21 @@ public:
      */
     WrtDB::ExternalLocationList listExternalLocations() const;
 
-private:
-    std::string m_widgetSource;                   // Source widget zip file/widget url
-    bool m_browser;                               // is browser request installation
-    std::string m_pkgname;                        //name of package
+    /*
+     * @brief set appid
+     */
+    void registerAppid(const std::string & appid);
+
+  private:
+    std::string m_pkgid;                        //id of package
+    std::string m_widgetSource;                   // Source widget zip
+                                                  // file/widget url
+    std::string m_appid;                        //id of app
     std::string m_iconPath;                       //installed icon path
-    WrtDB::PkgType m_type;
+    WrtDB::PackagingType m_type;
     std::shared_ptr<DirectoryDeletor> m_temp;      //directory
     WrtDB::ExternalLocationList m_externals;
+    std::string m_installedPath;
 };
 
 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H