Remove GUID and refactoring update mode
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_database.cpp
index 874bad8..329b618 100644 (file)
@@ -28,7 +28,7 @@
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/widget_install_context.h>
-#include <web-provider-info.h>
+#include <web_provider_livebox_info.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/vconf_config.h>
 #include <dpl/foreach.h>
@@ -36,6 +36,7 @@
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <wrt-commons/security-origin-dao/security_origin_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_types.h>
 #include <string>
 #include <sstream>
 #include <ace_api_install.h>
@@ -73,7 +74,7 @@ void TaskDatabase::StepWrtDBInsert()
         /* Set install Time */
         time(&m_context.widgetConfig.installedTime);
 
-        if (m_context.existingWidgetInfo.isExist) { //update
+        if (m_context.isUpdateMode) { //update
             LogInfo("Registering widget... (update)");
             Try
             {
@@ -84,7 +85,7 @@ void TaskDatabase::StepWrtDBInsert()
             {
                 LogError(
                     "Given tizenId not found for update installation (Same GUID?)");
-                ThrowMsg(Exceptions::InvalidPackage,
+                ThrowMsg(Exceptions::DatabaseFailure,
                          "Given tizenId not found for update installation");
             }
             WidgetDAO::registerOrUpdateWidget(
@@ -152,6 +153,8 @@ void TaskDatabase::StepSecurityOriginDBInsert()
     LogDebug("Create Security origin database");
     // automatically create security origin database
     using namespace SecurityOriginDB;
+    using namespace WrtDB;
+
     SecurityOriginDAO dao(m_context.locations->getPkgId());
 
     // Checking privilege list for setting security origin exception data
@@ -159,7 +162,13 @@ void TaskDatabase::StepSecurityOriginDBInsert()
         std::map<std::string, Feature>::const_iterator result =
             g_W3CPrivilegeTextMap.find(DPL::ToUTF8String(it->name));
         if (result != g_W3CPrivilegeTextMap.end()) {
-            dao.setPrivilegeSecurityOriginData(result->second);
+            if (result->second == FEATURE_USER_MEDIA) {
+                dao.setPrivilegeSecurityOriginData(result->second, false);
+            } else if (result->second == FEATURE_FULLSCREEN_MODE) {
+                continue;
+            } else {
+                dao.setPrivilegeSecurityOriginData(result->second);
+            }
         }
     }
 
@@ -172,7 +181,7 @@ void TaskDatabase::StepRegisterExternalFiles()
 {
     WrtDB::ExternalLocationList externalLocationsUpdate =
         m_context.locations->listExternalLocations();
-    if (m_context.existingWidgetInfo.isExist) { //update
+    if (m_context.isUpdateMode) { //update
         Try
         {
             WidgetDAO dao(m_context.widgetConfig.tzAppid);
@@ -301,16 +310,23 @@ void TaskDatabase::StepLiveboxDBInsert()
         std::string boxId = DPL::ToUTF8String((**it).m_liveboxId);
         std::string boxType;
         if ((**it).m_type == L"") {
-            boxType = web_provider_info_get_default_type();
+            boxType = web_provider_livebox_get_default_type();
         } else {
             boxType = DPL::ToUTF8String((**it).m_type);
         }
         LogInfo("livebox id: " << boxId);
         LogInfo("livebox type: " << boxType);
 
+        int autoLaunch;
+        if ((**it).m_autoLaunch == L"true") {
+            autoLaunch = 1;
+        } else {
+            autoLaunch = 0;
+        }
+
         int ret =
-            web_provider_info_insert_box_type(
-                boxId.c_str(), tizenId.c_str(), boxType.c_str());
+            web_provider_livebox_insert_box_info(
+                boxId.c_str(), tizenId.c_str(), boxType.c_str(), autoLaunch);
 
         if (ret < 0) {
             LogDebug("failed to set type of livebox: " << boxId);