unsigned int surf;
};
+struct dump_info {
+ guint tag;
+ char *path;
+ int count;
+};
+
static gchar *help;
static gpointer cmd_opt[CMD_MAX];
static GOptionEntry cmd_entries[] = {
fprintf(stderr, "chmod(%s) is failed. errno(%d)\n", path, ret);
ret = smack_setlabel(path, "*", SMACK_LABEL_ACCESS);
- if (ret != 0) {
+ if (ret != 0)
fprintf(stderr, "smack_setlabel() is failed. error(%d)\n", ret);
- return -1;
- }
return 0;
}
widget_info_list = g_list_remove(widget_info_list, info);
__destroy_widget_info(info);
-
- if (widget_info_list == NULL)
- elm_exit();
}
static void __screen_connector_toolkit_evas_removed_cb(const char *appid,
}
}
+static void __destroy_dump_info(struct dump_info *info)
+{
+ if (!info)
+ return;
+
+ if (info->tag)
+ g_source_remove(info->tag);
+
+ free(info->path);
+ free(info);
+}
+
+static struct dump_info *__create_dump_info(const char *path, int count)
+{
+ struct dump_info *info;
+
+ info = calloc(1, sizeof(struct dump_info));
+ if (!info) {
+ fprintf(stderr, "Out of memory\n");
+ return NULL;
+ }
+
+ info->path = strdup(path);
+ if (!info->path) {
+ fprintf(stderr, "Failed to duplicate path(%s)\n", path);
+ free(info);
+ return NULL;
+ }
+
+ info->count = count;
+
+ return info;
+}
+
+static int __get_image_count(const char *path)
+{
+ DIR *dp;
+ struct dirent *dentry = NULL;
+ char *ext;
+ int count = 0;
+
+ if (!path)
+ return -1;
+
+ dp = opendir(path);
+ if (dp == NULL) {
+ fprintf(stderr, "Failed to open dir(%s), errno(%d)",
+ path, errno);
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (dentry->d_name[0] == '.')
+ continue;
+
+ ext = strrchr(dentry->d_name, '.');
+ if (ext && strcmp(ext, ".jpg") == 0)
+ count++;
+ }
+
+ return count;
+}
+
+static gboolean __check_dump(gpointer data)
+{
+ struct dump_info *info = data;
+ int count;
+
+ /* The image files should be generated more than twice the widgets(homescreen + widget-mgr). */
+ count = __get_image_count(info->path);
+ if (count >= (info->count * 2)) {
+ printf("Images(%d) are created.\n", count);
+ info->tag = 0;
+ __destroy_dump_info(info);
+ elm_exit();
+ return G_SOURCE_REMOVE;
+ }
+
+ return G_SOURCE_CONTINUE;
+}
+
+static gboolean __terminate_cb(gpointer data)
+{
+ struct dump_info *info = data;
+
+ __destroy_dump_info(info);
+ elm_exit();
+
+ return G_SOURCE_REMOVE;
+}
+
static gboolean __dump_widgets(gpointer data)
{
const char *path = data;
bundle *event_data;
int ret;
+ int widget_cnt;
+ struct dump_info *info;
if (path == NULL)
path = "/tmp/widget_dump";
if (access(path, F_OK) != 0) {
- if (__create_directory(path) < 0)
+ if (__create_directory(path) < 0) {
+ elm_exit();
return G_SOURCE_REMOVE;
+ }
}
event_data = bundle_create();
if (!event_data) {
fprintf(stderr, "Failed to create bundle\n");
+ elm_exit();
return G_SOURCE_REMOVE;
}
bundle_free(event_data);
+ widget_cnt = g_list_length(widget_info_list);
g_list_foreach(widget_info_list, __foreach_widget_info_list,
(gpointer)path);
+ info = __create_dump_info(path, widget_cnt);
+ if (!info) {
+ elm_exit();
+ return G_SOURCE_REMOVE;
+ }
+
+ info->tag = g_timeout_add(500, __check_dump, info);
+ g_timeout_add(1000 * 10, __terminate_cb, info);
+
return G_SOURCE_REMOVE;
}