#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>
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;
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);
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)
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;
}
return -1;
}
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ setenv("WAYLAND_DISPLAY", "wayland-0", 1);
+
r = __parse_args(argc, argv);
if (r < 0)
return -1;