Fix widget-mgr tool 53/232953/3
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 11 May 2020 01:18:21 +0000 (10:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 11 May 2020 02:19:23 +0000 (11:19 +0900)
- Changes the file permission.
- Adds environment variables for using Wayland.

Change-Id: I9be0ae07bbaa816e25d802c894600f41b025348f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/libwidget_viewer.spec
tool/CMakeLists.txt
tool/widget-mgr.c

index 893d9e4..8ad12bb 100644 (file)
@@ -41,6 +41,7 @@ BuildRequires: pkgconfig(capi-system-device)
 BuildRequires: pkgconfig(gmock)
 BuildRequires: pkgconfig(screen_connector_launcher_service)
 BuildRequires: pkgconfig(screen_connector_shared_widget_launch)
+BuildRequires: pkgconfig(libsmack)
 %if 0%{?gcov:1}
 BuildRequires:  lcov
 BuildRequires:  zip
index ee32abe..aeb4274 100644 (file)
@@ -14,7 +14,8 @@ SET(WIDGET_MGR_PKG_CHECK_MODULES
        screen_connector_watcher_evas
        wayland-tbm-client
        ecore-wl2
-       tizen-remote-surface-client)
+       tizen-remote-surface-client
+       libsmack)
 
 PKG_CHECK_MODULES(WIDGET_MGR_PKGS REQUIRED ${WIDGET_MGR_PKG_CHECK_MODULES})
 
index c78e772..0a71d6c 100644 (file)
@@ -21,6 +21,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/smack.h>
 #include <glib.h>
 #include <aul.h>
 #include <aul_widget.h>
@@ -262,12 +263,35 @@ static gint __compare_surf(gconstpointer a, gconstpointer b)
        return -1;
 }
 
+static int __create_directory(const char *path)
+{
+       int ret;
+
+       ret = mkdir(path, 0755);
+       if (ret != 0) {
+               fprintf(stderr, "mkdir(%s) is failed. errno(%d)\n",
+                               path, errno);
+               return -1;
+       }
+
+       ret = chmod(path, 0777);
+       if (ret != 0)
+               fprintf(stderr, "chmod(%s) is failed. errno(%d)\n", path, ret);
+
+       ret = smack_setlabel(path, "*", SMACK_LABEL_ACCESS);
+       if (ret != 0) {
+               fprintf(stderr, "smack_setlabel() is failed. error(%d)\n", ret);
+               return -1;
+       }
+
+       return 0;
+}
+
 static void __screen_connector_toolkit_evas_added_cb(const char *appid,
                const char *instance_id, int pid,
                Evas_Object *image, void *data)
 {
        const char *path = (const char *)data;
-       char cwd[PATH_MAX];
        char buf[PATH_MAX];
        unsigned int surf;
        struct widget_info *info = NULL;
@@ -276,15 +300,6 @@ static void __screen_connector_toolkit_evas_added_cb(const char *appid,
        if (image == NULL)
                return;
 
-       if (path == NULL) {
-               path = getcwd(cwd, sizeof(cwd));
-               if (path == NULL)
-                       return;
-       }
-
-       if (access(path, F_OK) != 0)
-               mkdir(path, 0755);
-
        screen_connector_toolkit_evas_get_rid(image, (int *)&surf);
        found = g_list_find_custom(widget_info_list, GUINT_TO_POINTER(surf),
                        __compare_surf);
@@ -430,14 +445,21 @@ static gboolean __dump_widgets(gpointer data)
        bundle *event_data;
        int ret;
 
+       if (path == NULL)
+               path = "/tmp/widget_dump";
+
+       if (access(path, F_OK) != 0) {
+               if (__create_directory(path) < 0)
+                       return G_SOURCE_REMOVE;
+       }
+
        event_data = bundle_create();
        if (!event_data) {
                fprintf(stderr, "Failed to create bundle\n");
                return G_SOURCE_REMOVE;
        }
 
-       if (path)
-               bundle_add(event_data, "path", path);
+       bundle_add(event_data, "path", path);
 
        ret = aul_widget_send_event(AUL_WIDGET_EVENT_SAVE_IMAGE, event_data);
        if (ret != AUL_R_OK)
@@ -445,7 +467,8 @@ static gboolean __dump_widgets(gpointer data)
 
        bundle_free(event_data);
 
-       g_list_foreach(widget_info_list, __foreach_widget_info_list, data);
+       g_list_foreach(widget_info_list, __foreach_widget_info_list,
+                       (gpointer)path);
 
        return G_SOURCE_REMOVE;
 }
@@ -563,6 +586,9 @@ int main(int argc, char **argv)
                return -1;
        }
 
+       setenv("XDG_RUNTIME_DIR", "/run", 1);
+       setenv("WAYLAND_DISPLAY", "wayland-0", 1);
+
        r = __parse_args(argc, argv);
        if (r < 0)
                return -1;