Popup removal 2
[framework/web/wrt-installer.git] / src / wrt-installer / plugin_utils.cpp
index 2b6bc3c..5368f3f 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   Header file for plugin util
  */
 
+#include <unistd.h>
 #include "plugin_utils.h"
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
@@ -33,17 +34,21 @@ const char* PLUGIN_INSTALL_LOCK_FILE = "/tmp/.wrt_plugin_install_lock";
 
 static int s_plugin_install_lock_fd = -1;
 
-bool lockPluginInstallation()
+bool lockPluginInstallation(bool isPreload)
 {
+    if (isPreload) {
+        fprintf(stderr, "Skip create lock file.. \n");
+        return true;
+    }
+
     int ret = 0;
 
     LogInfo("Try to lock for plugins installation.");
 
     s_plugin_install_lock_fd =
-        open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY|O_CREAT, 0666);
+        open(PLUGIN_INSTALL_LOCK_FILE, O_RDONLY | O_CREAT, 0666);
 
-    if (s_plugin_install_lock_fd == -1)
-    {
+    if (s_plugin_install_lock_fd == -1) {
         LogError("Lock file open failed!");
 
         return false;
@@ -51,8 +56,7 @@ bool lockPluginInstallation()
 
     ret = flock(s_plugin_install_lock_fd, LOCK_EX); //lock with waiting
 
-    if (ret == -1)
-    {
+    if (ret == -1) {
         LogError("Lock failed!");
 
         close(s_plugin_install_lock_fd);
@@ -64,18 +68,20 @@ bool lockPluginInstallation()
     return true;
 }
 
-bool unlockPluginInstallation()
+bool unlockPluginInstallation(bool isPreload)
 {
     LogInfo("Unlock for plugins installation.");
+    if (isPreload) {
+        fprintf(stderr, "Skip plugin unlock.. \n");
+        return true;
+    }
 
-    if (s_plugin_install_lock_fd != -1)
-    {
+    if (s_plugin_install_lock_fd != -1) {
         int ret = 0;
 
         ret = flock(s_plugin_install_lock_fd, LOCK_UN); //unlock
 
-        if (ret == -1)
-        {
+        if (ret == -1) {
             LogError("Unlock failed!");
         }
 
@@ -83,9 +89,7 @@ bool unlockPluginInstallation()
         s_plugin_install_lock_fd = -1;
 
         return true;
-    }
-    else
-    {
+    } else {
         LogError("Lock file was not created!");
     }
 
@@ -101,11 +105,11 @@ bool checkPluginInstallationRequired()
         checkFile(installRequest);
 
     switch (installationRequest) {
-        case FileState::FILE_EXISTS:
-            return true;
-        case FileState::FILE_NOT_EXISTS:
-            return false;
-        default:
+    case FileState::FILE_EXISTS:
+        return true;
+    case FileState::FILE_NOT_EXISTS:
+        return false;
+    default:
         LogWarning("Opening installation request file failed");
         return false;
     }