Ejemplo n.º 1
0
si_t save_as_button_callback(void* btn, void* msg)
{
    union message* m = (union message*)msg;
	struct button* b = NULL;
	switch(m->base.type)
	{
	case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
		if(NULL == save_window)
		{
			save_window = window_init("save window");
            /* 申请失败 */
            if(NULL == main_window)
            {
				EGUI_PRINT_ERROR("failed to init save window");
				application_exit();
                return -1;
            }
			window_set_bounds(save_window, main_window->area.x + 30, main_window->area.y + 30, 300, 60);
			window_set_color(save_window, NULL, &barely_blue);

			save_text_line = text_line_init(FILE_MAX, 0);
			if(NULL == save_text_line)
			{
				EGUI_PRINT_ERROR("failed to init save_text_line on save window");
				application_exit();
				return -1;
			}
			text_line_set_bounds(save_text_line, 5, 5, 230, 50);
			text_line_set_placeholder(save_text_line, "input file name");
			text_line_set_color(save_text_line, &dark_blue, NULL, &light_green);

			b = button_init("ok");
			if(NULL == b)
			{
				EGUI_PRINT_ERROR("failed to init ok button on save window");
				application_exit();
				return -1;
			}
			button_set_bounds(b, 240, 10, 50, 40);
			button_set_color(b, &dark_blue, &light_green);
			button_set_font(b, FONT_MATRIX_12);
			b->callback = save_window_ok_button_callback;

			object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(b));
			object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_text_line));
			application_add_window(NULL, save_window);
			break;
		}
		else
		{
			EGUI_PRINT_ERROR("save window already open!");
		}
	default:
		button_default_callback(btn, msg);
	}
	return 0;
}
Ejemplo n.º 2
0
int main()
{
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
	si_t app_type = APPLICATION_TYPE_NORMAL;
    struct window * w;
    struct scroll_bar* s;
    struct label* l;
    char show[25];

    /* 初始化用户应用程序 */
    application_init(video_access_mode, app_type, "scroll_bar");

    /* 申请窗口 */
    w = window_init("window with scroll_bar");
    /* 申请失败 */
    if(w == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w, 300, 100, 448, 200);

    s = scroll_bar_init(1, 400, 20);
    /* 申请失败 */
    if(s == NULL)
    {
        application_exit();
        return -1;
    }
	scroll_bar_set_bounds(s, 428, 0, 20, 200);
 
    l = label_init(show);
    /* 申请失败 */
    if(l == NULL)
    {
        application_exit();
        return -1;
    }
	label_set_bounds(l, 10, 40, 400, 20);
    sprintf(show, "not started");

    scroll_bar_register_move_handler(s, WIDGET_POINTER(l), SCROLL_BAR_EVENT_ALL, label_handler);
   
    object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(s));
    object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(l));

    /* 添加顶层窗口 */
    application_add_window(NULL, w);
    /* 设置主窗口 */
    application_set_main_window(w);

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 3
0
si_t pop_window()
{
    switch(save_or_rename_flag)
    {
        case 0:
            save_window = window_init("save_directory_window");
            break;
        case 1:
            save_window = window_init("save_file_window");
            break;
        case 2:
            save_window = window_init("rename_window");
            break;
        default:
            break;
     }
    if(NULL == save_window)
    {
        //EGUI_PRINT_ERROR("failed to init save window");
		application_exit();
        return -1;
    }
    window_set_bounds(save_window,200, 200, 300, 60);
    window_set_color(save_window, NULL, &ground_purple);
    save_text_line = text_line_init(100, 0);
    if(NULL == save_text_line)
    {
        //EGUI_PRINT_ERROR("failed to init save_text_line on save window");
        application_exit();
        return -1;
    }
    text_line_set_bounds(save_text_line, 5, 5, 230, 50);
    text_line_set_placeholder(save_text_line, "input file name");
    text_line_set_color(save_text_line, &heavy_blue, NULL, &heavy_blue );
    save_button = button_init("OK");
    if(NULL == save_button)
	{
	    //EGUI_PRINT_ERROR("failed to init ok button on save window");
        application_exit();
        return -1;
	}
    button_set_bounds(save_button, 240, 10, 50, 40);
    button_set_color(save_button, &ground_purple, &heavy_blue );
    button_set_font(save_button, FONT_MATRIX_12);
	save_button->callback = rename_window_ok_button_callback;
    object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_button));
    object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_text_line));
    application_add_window(Desktop_w, save_window);
    return 0;

}
Ejemplo n.º 4
0
/*
    测试 eicon
*/
int main()
{
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
    ewindow * w;
    eicon * ic;

    /* 初始化用户应用程序 */
    application_init(video_access_mode, "eicon");

    /* 申请窗口 */
    w = window_init(1);
    /* 申请失败 */
    if(w == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w,300,100,500,200);
    w->title = "window with eicon";
    w->minimize_enable = 1;
    w->maximize_enable = 1;
    w->callback = window_default_callback;

    /* 申请按钮 */
    ic = icon_init(2);
    /* 申请失败 */
    if(ic == NULL)
    {
        application_exit();
        return -1;
    }
    icon_set_bounds(ic ,50,50,100,120);
	icon_set_text(ic,"ehello");
	icon_set_img_path(ic,"/home/orange/Egui2.0/img/2.bmp");
	icon_set_is_text_visiable(ic ,1);
    ic->callback = icon_default_callback;

    /* 将按钮添加到窗口 */
    object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(ic));

	/* 添加顶层窗口 */
    application_add_window(NULL, w);
    /* 设置主窗口 */
    application_set_main_window(w);

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 5
0
/*
    测试 struct window
*/
int main()
{
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
	si_t app_type = APPLICATION_TYPE_NORMAL;
    struct window * w = NULL;

    /* 初始化用户应用程序 */
    application_init(video_access_mode, app_type, "single_window");

    w = window_init("single_window");
    /* 申请失败 */
    if(w == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w, 300, 100, 450, 200);

    /* 添加顶层窗口 */
    application_add_window(NULL, w);
    /* 设置主窗口 */
    application_set_main_window(w);

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 6
0
static si_t
handle_window_cancel
(union message * msg)
{
    struct widget* w;
    w = application_widgets_for_each_increament(do_find_window, msg);
    if(w->callback != NULL)
        w->callback(w, msg);

    /* 如果要关闭主窗口 */
    if(global_application.main_window == WINDOW_POINTER(w))
    {
        application_del_window(WINDOW_POINTER(w));
    }
    else
    {
        cancel_window(WINDOW_POINTER(w)->descriptor);
        application_del_window(WINDOW_POINTER(w));

        /* 没有顶层窗口了 */
        /* 退出程序 */
        /* 这是为了处理没有设置主窗口的情况 */
        if(vector_size(&(global_application.window_vector)) == 0)
        {
            application_exit();
        }
        /* 还有顶层窗口 */
        else
        {
            application_widgets_for_each_increament(do_dispatch_repaint_event_to_all, NULL);
        }
    }

    return 0;
}
Ejemplo n.º 7
0
//  replies on bucket versioning information
static void application_on_bucket_versioning_cb (gpointer ctx, gboolean success,
    const gchar *buf, size_t buf_len)
{
    Application *app = (Application *)ctx;
    gchar *tmp;

    if (!success) {
        LOG_err (APP_LOG, "Failed to get bucket versioning!");
        application_exit (app);
        return;
    }

    if (buf_len > 1) {
        tmp = (gchar *)buf;
        tmp[buf_len - 1] = '\0';

        if (strstr (buf, "<Status>Enabled</Status>")) {
            LOG_debug (APP_LOG, "Bucket has versioning enabled !");
            conf_set_boolean (app->conf, "s3.versioning", TRUE);
        } else {
            LOG_debug (APP_LOG, "Bucket has versioning disabled !");
            conf_set_boolean (app->conf, "s3.versioning", FALSE);
        }
    } else {
        conf_set_boolean (app->conf, "s3.versioning", FALSE);
    }

    application_finish_initialization_and_run (app);
}
Ejemplo n.º 8
0
Archivo: main.c Proyecto: skoobe/riofs
/*{{{ application_set_url*/
gboolean application_set_url (Application *app, const gchar *url)
{
    if (app->uri)
        evhttp_uri_free (app->uri);

    // check if URL contains HTTP or HTTPS
    if (strlen (url) < 4 || !strcasestr (url, "http") || strcasestr (url, "http") != url) {
        // XXX: check config and decide HTTP or HTTPS ?
        gchar *tmp;

        tmp = g_strdup_printf ("http://%s", url);
        app->uri = evhttp_uri_parse (tmp);
        g_free (tmp);
    } else
        app->uri = evhttp_uri_parse (url);


    if (!app->uri) {
        LOG_err (APP_LOG, " URL (%s) is not valid!", url);

        application_exit (app);
        return FALSE;
    }

    conf_set_string (app->conf, "s3.host", evhttp_uri_get_host (app->uri));
    conf_set_int (app->conf, "s3.port", uri_get_port (app->uri));
    conf_set_boolean (app->conf, "s3.ssl", uri_is_https (app->uri));

    return TRUE;
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: skoobe/riofs
// same as SIGINT
static void sigterm_cb (G_GNUC_UNUSED evutil_socket_t sig, G_GNUC_UNUSED short events, void *user_data)
{
    Application *app = (Application *) user_data;

    LOG_err (APP_LOG, "Got SIGTERM");

    // terminate after running all active events
    application_exit (app);
}
Ejemplo n.º 10
0
static void
browse_cb (GUPnPServiceProxy       *cds_proxy,
           GUPnPServiceProxyAction *action,
           gpointer                 user_data)
{
        GError *error;
        char *result;
        char *container_id;

        error = NULL;
        if (!gupnp_service_proxy_end_action (cds_proxy,
                                             action,
                                             &error,
                                             "Result",
                                                G_TYPE_STRING,
                                                &result,
                                             NULL)) {
                g_critical ("Failed to browse root container: %s",
                            error->message);

                g_error_free (error);

                application_exit ();

                return;
        }

        g_assert (result != NULL);

        container_id = parse_result (result);
        if (container_id == NULL) {
                g_critical ("Failed to find a suitable container for upload.");
                g_free (result);

                application_exit ();

                return;
        } else {
                container_found (container_id);
                g_free (container_id);
        }

        g_free (result);
}
Ejemplo n.º 11
0
G_MODULE_EXPORT
gboolean
on_delete_event (GtkWidget *widget,
                 GdkEvent  *event,
                 gpointer   user_data)
{
        application_exit ();

        return TRUE;
}
Ejemplo n.º 12
0
/**
 * 清理窗口管理器
 * 就不写注释了 函数名写的已经很明白。。
 **/
si_t window_manager_exit()
{
	application_exit();
	cursor_exit();
	graph_exit();
	comm_exit();
	event_exit();
	config_exit();
	terminal_exit();

	return 0;
}
Ejemplo n.º 13
0
//  replies on bucket ACL
static void application_on_bucket_acl_cb (gpointer ctx, gboolean success,
    G_GNUC_UNUSED const gchar *buf, G_GNUC_UNUSED size_t buf_len)
{
    Application *app = (Application *)ctx;

    if (!success) {
        LOG_err (APP_LOG, "Failed to get bucket ACL! Most likely you provided wrong AWS keys or bucket name !");
        application_exit (app);
        return;
    }

    // XXX: check ACL permissions

    bucket_client_get (app->service_con, "/?versioning", application_on_bucket_versioning_cb, app);
}
Ejemplo n.º 14
0
static void
goto_next_file (void)
{
        files = g_list_next (files);

        if (files != NULL) {
                create_item ((char *) files->data,
                             title,
                             cds_proxy,
                             dest_container);
        } else {
                /* Exit if there are no more files to upload */
                application_exit ();
        }
}
Ejemplo n.º 15
0
Archivo: main.c Proyecto: skoobe/riofs
//  replies on bucket ACL
static void application_on_bucket_acl_cb (gpointer ctx, gboolean success,
    G_GNUC_UNUSED const gchar *buf, G_GNUC_UNUSED size_t buf_len)
{
    Application *app = (Application *)ctx;

    if (!success) {
        LOG_err (APP_LOG, "Failed to get bucket ACL! Most likely you provided wrong AWS keys or bucket name !");
        application_exit (app);
        return;
    }

    // XXX: check ACL permissions

    application_finish_initialization_and_run (app);
}
Ejemplo n.º 16
0
/*
   如果 window 有左子节点
   那么这个左子节点并不是 window 子对象
   所以在析构以 window 为根的树之前一定要要将 window->lchild 成员清空

   如果 window 在对象树中
   那么完成删除工作后一定要更新 root->parent 的 lchild 成员和 rchild 成员
   这是为了保证遍历的正确
   */
si_t application_del_window(struct window * window)
{
	si_t is_top_window = 0;

	/* 删除主窗口 */
	/* 退出程序 */
	if(window == global_application.main_window)
	{
		application_exit();
		return 0;
	}

	if(window->parent->parent == OBJECT_POINTER(window))
	{
		is_top_window = 1;
	}

	cancel_window(window->descriptor);

	object_delete(OBJECT_POINTER(window), __widget_destructor);
	if(is_top_window)
	{
		si_t i = 0, n = 0;
		/* 有多少个窗口 */
		n = vector_size(&(global_application.window_vector));

		/* 找到这个窗口在向量中的索引 */
		for(i = 0; i < n; ++ i)
		{
			struct object* tree = vector_at(&(global_application.window_vector), i);
			if(tree->parent == OBJECT_POINTER(window))
			{
				/* 从窗口向量中删除这个节点 */
				vector_erase(&(global_application.window_vector), i);
				break;
			}
		}
	}

	return 0;
}
Ejemplo n.º 17
0
struct shortcut* new_shortcut(struct shortcut* sh_ptr, char* new_file){
	/* 申请快捷方式 */
	struct shortcut* sh = shortcut_init(2);
	/* 申请失败 */
	if(sh == NULL)
		application_exit();

	vector_push_back(&sh_desktop_vector, sh, sizeof(struct shortcut));
	
	struct shortcut* sh_add_ptr = vector_at(&sh_desktop_vector, app_number);
	sh_add_ptr->is_real= sh_ptr->is_real;
	shortcut_set_is_text_visiable(sh_add_ptr,1);
	char new_name[100]={0};
	strcpy(new_name,sh_ptr->text);
	strcat(new_name,"(2)");
	shortcut_set_text(sh_add_ptr,new_name);

	shortcut_set_img_path(sh_add_ptr,sh_ptr->img_path);
	shortcut_set_img_normal_path(sh_add_ptr,sh_ptr->img_normal_path);
	shortcut_set_img_select_path(sh_add_ptr,sh_ptr->img_select_path);
	strcpy(sh_add_ptr->app_name, sh_ptr->app_name);
	strcpy(sh_add_ptr->app_path, sh_ptr->app_path);
	strcpy(sh_add_ptr->link_file_path,new_file);
	sh_add_ptr->callback=shortcut_callback;
	int num=1;
	struct point p;
	while(1){
		p.x=num/area_num_y;
		p.y=num%area_num_y;
		num++;
		if(reset_shortcut_bound(sh_add_ptr,p)==1)
			break;
	}

	
	app_number++;

	object_attach_child(OBJECT_POINTER(Desktop_im), OBJECT_POINTER(sh_add_ptr));
	return sh_add_ptr;
}
Ejemplo n.º 18
0
void create_new_folder(){ 
	/* 申请快捷方式 */
	struct shortcut* sh = shortcut_init(2);
	/* 申请失败 */
	if(sh == NULL)
		application_exit();
	sh->is_real=1;

	vector_push_back(&sh_desktop_vector, sh, sizeof(struct shortcut));
	
	sh_new_ptr = vector_at(&sh_desktop_vector, app_number);
	sh_new_ptr->is_real=1;
	shortcut_set_is_text_visiable(sh_new_ptr,1);
	shortcut_set_text(sh_new_ptr,"new");
	shortcut_set_img_path(sh_new_ptr,"/home/wangfei/egui/resource/icons/file_icon/dir1_1.bmp");
	shortcut_set_img_normal_path(sh_new_ptr,"/home/wangfei/egui/resource/icons/file_icon/dir1_1.bmp");
	shortcut_set_img_select_path(sh_new_ptr,"/home/wangfei/egui/resource/icons/file_icon/dir1_2.bmp");
	strcpy(sh_new_ptr->app_name, "file_browser");
	strcpy(sh_new_ptr->app_path, "/home/wangfei/egui/_bulid/debug/samples/file_browser/");
	strcpy(sh_new_ptr->link_file_path,"/home/wangfei/me");
	sh_new_ptr->is_real=0;
	sh_new_ptr->callback=shortcut_callback;
	int num=1;
	while(1){
		struct point p;
		p.x=num/area_num_y;
		p.y=num%area_num_y;
		num++;
		if(reset_shortcut_bound(sh_new_ptr,p)==1)
			break;
	}
	
	app_number++;

	object_attach_child(OBJECT_POINTER(Desktop_im), OBJECT_POINTER(sh_new_ptr));


}
Ejemplo n.º 19
0
int main(int argc, char* argv[])
{
    struct scroll_bar* s;
    struct button* b1 = NULL, *b2 = NULL;
    char msg[LABEL_MAX];
	char file_msg[LABEL_MAX];
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
	si_t app_type = APPLICATION_TYPE_NORMAL;
	char* file_name = NULL;
	si_t fonty = 0;

    /**
     * open with file
     **/
    if(argc == 2)
	{
		struct stat st;
		if(stat(argv[1], &st) == -1)
		{
			EGUI_PRINT_ERROR("file %s does not exists", argv[1]);
			return -1;
		}

		if(!S_ISREG(st.st_mode) || access(argv[1], R_OK | W_OK) != 0)
		{
			EGUI_PRINT_ERROR("file %s cannot access!", argv[1]);
			return -1;
		}

		/**
		 * file too large
		 **/
		if(st.st_size > FILE_MAX)
		{
			EGUI_PRINT_ERROR("file %s does not exists\n", argv[1]);
			return -1;
		}
		file_name = argv[1];
    }
    else if(argc != 1)
    {
		EGUI_PRINT_ERROR("wrong parameter!\nusage: \nediterbasic\nor:\nediterbasic [filename]");
		return -1;
    }


    /* 初始化用户应用程序 */
    application_init(video_access_mode, app_type, "editerbasic");

    /**
     * window
     **/
    main_window = window_init("editer_basic");
    /* 申请失败 */
    if(main_window == NULL)
    {
        application_exit();
        return -1;
    }
    window_set_bounds(main_window, 300, 100, 550, 300);
	window_set_color(main_window, NULL, &light_green);

    /**
     * label that show process
     **/
	if(file_name)
	{
		sprintf(file_msg, "%s", file_name);
	}
	else
	{
		sprintf(file_msg, "new file");
	}
	file_label = label_init(file_msg);
    if(file_label == NULL)
    {
        application_exit();
        return -1;
    }
	label_set_bounds(file_label, 10, 10, 365, 20);
	label_set_color(file_label, &barely_blue, &light_blue);
	label_set_font(file_label, FONT_MATRIX_12);
 
    /**
     * save button
     **/
    b1 = button_init("save");
    if(b1 == NULL)
    {
        application_exit();
        return -1;
    }
	button_set_bounds(b1, 380, 5, 60, 30);
	button_set_color(b1, &dark_blue, &barely_blue);
	button_set_font(b1, FONT_MATRIX_12);
	b1->callback = save_button_callback;

	b2 = button_init("save as");
	if(b2 == NULL)
	{
		application_exit();
		return -1;
	}
	button_set_bounds(b2, 445, 5, 100, 30);
	button_set_color(b2, &dark_blue, &barely_blue);
	button_set_font(b2, FONT_MATRIX_12);
	b2->callback = save_as_button_callback;

    /**
     * text_line that shows file context
     **/
	file_context_text_line = text_line_init(FILE_MAX, 0);
    if(file_context_text_line == NULL)
    {
        application_exit();
        return -1;
    }
	text_line_set_bounds(file_context_text_line, 5, 40, 520, 230);
	text_line_set_color(file_context_text_line, &dark_blue, NULL, NULL);
	text_line_set_multilines(file_context_text_line);
	fonty = get_font_height(file_context_text_line->gd);

	if(file_name)
	{
		if(load_file(file_name, text_line_get_buf(file_context_text_line)) < 0)
		{
			EGUI_PRINT_ERROR("failed to load file %s", file_name);
			application_exit();
			return -1;
		}
		s = scroll_bar_init(1, fonty * text_line_get_max_line_shown(file_context_text_line), fonty);
	}
	else
	{
		s = scroll_bar_init(1, file_context_text_line->area.height, fonty);
	}
    if(s == NULL)
    {
        application_exit();
        return -1;
    }
	scroll_bar_set_bounds(s, 525, 40, 20, 230);

	text_line_register_move_handler(file_context_text_line, WIDGET_POINTER(s), TEXT_LINE_EVENT_ALL, scrollbar_subscribe_text_line);
	scroll_bar_register_move_handler(s, WIDGET_POINTER(file_context_text_line), SCROLL_BAR_EVENT_ALL, text_line_subscribe_scrollbar);

	log_label = label_init(msg);
    if(log_label == NULL)
    {
        application_exit();
        return -1;
    }
	label_set_bounds(log_label, 5, 275, 450, 20);
	label_set_color(log_label, NULL, &light_green);
	sprintf(msg, "open file successfully!");
 
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(file_label));
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(file_context_text_line));
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(log_label));
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(b1));
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(b2));
    object_attach_child(OBJECT_POINTER(main_window), OBJECT_POINTER(s));

    /* 添加顶层窗口 */
    application_add_window(NULL, main_window);
    /* 设置主窗口 */
    application_set_main_window(main_window);

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 20
0
/*
   总是将孩子节点加在子节点链的最右边

   如果 parent 在对象树中
   那么完成添加工作后一定要更新 root->parent 的 lchild 成员和 rchild 成员
   这是为了保证遍历的正确
   */
si_t application_add_window(struct window * parent, struct window * window)
{
	struct object node, * tree;

	/* 添加顶层窗口 */
	if(parent == NULL)
	{
		/* node 的父节点是 window */
		node.parent = OBJECT_POINTER(window);
		node.lchild = object_tree_l_most_node(OBJECT_POINTER(window));
		node.rchild = object_tree_r_most_node(OBJECT_POINTER(window));
		node.name = NULL;
		node.id = 0;

		/* 将窗口添加到向量 */
		vector_push_back(&(global_application.window_vector), &node, sizeof(struct object));

		tree = vector_back(&(global_application.window_vector));

		/* window 的父节点是 node */
		window->parent = tree;
	}
	/* 添加非顶层窗口 */
	else
	{
		object_insert_child(OBJECT_POINTER(parent), OBJECT_POINTER(window));
	}
	/**
	 * if already running in app_exec
	 **/
	if(global_application.exec_flag)
	{
		union message msg;
		msg.base.type = MESSAGE_TYPE_WIDGET_REPAINT;
		msg.widget_repaint.area = window->area;

		if(global_application.focus != NULL)
		{
			struct window* w = WINDOW_POINTER(global_application.focus);
			struct object* tree, *node, *tree_real_parent;
			w->is_activated = 0;
			msg.widget_repaint.area = w->area;
			if(w->callback != NULL)
			{
				w->callback(w, &msg);
			}

			node = OBJECT_POINTER(w);
			tree = node->parent;
			tree_real_parent = tree->parent;
			tree->parent = node;
			node = object_tree_l_most_node(tree);
			while(node != NULL)
			{
				union message msg;
				msg.base.type = MESSAGE_TYPE_WIDGET_REPAINT;
				msg.widget_repaint.area = WIDGET_POINTER(node)->area;
				if(WIDGET_POINTER(node)->callback != NULL)
					WIDGET_POINTER(node)->callback(node, &msg);

				node = object_tree_iterator_increment(tree, node);
			}
			tree->parent = tree_real_parent;
		}

		window->descriptor = register_window((parent == NULL ? 0 : parent->descriptor), window->title, 
			window->area.x, window->area.y, window->area.width, window->area.height, 
			window->minimize_enable, window->maximize_enable, window->modal);
		if(window->descriptor == 0)
		{
			EGUI_PRINT_ERROR("failed to register window");
			application_exit();
			return -1;
		}

		/**
		 * find icon for the application
		 **/
		if((window->icon_path = (char*)malloc(256)) == NULL)
		{
			EGUI_PRINT_SYS_ERROR("failed to malloc for icon path. malloc");
			application_exit();
			return -1;
		}
		else
		{
			/**
			 * in C89 standard, snprintf() is NOT included in <stdio.h>
			 * so you have to use sprintf, which may be dangerous. be careful
			 **/
			sprintf(window->icon_path, "%s/icons/%s.bmp", global_application.icon_root_path, global_application.name);
			if(access(window->icon_path, R_OK) == -1)
			{
				sprintf(window->icon_path, "%s/icons/default.bmp", global_application.icon_root_path);
			}
		}

		msg.widget_repaint.area = window->area;
		global_application.focus = window;
		window->is_activated = 1;
		if(window->callback != NULL)
		{
			window->callback(window, &msg);
		}
	}

	return 0;
}
Ejemplo n.º 21
0
int main()
{
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
	si_t app_type = APPLICATION_TYPE_NORMAL;
    struct window * w;
    struct text_line * ta;
    char lyrics[]= "The boy with the thorn in his side\n"
		"Behind the hatred there lies\n"
		"A murderous desire for love\n"
		"\n"
		"How can they look into my eyes\n"
		"And still they don't believe me\n"
		"How can they hear me say those words\n"
		"And still they don't believe me\n"
		"And if they don't believe me now\n"
		"Will they ever believe me?\n"
		"And if they don't believe me now\n"
		"Will they ever believe me?\n"
		"\n"
		"The boy with the thorn in his side\n"
		"Behind the hatred there lies\n"
		"A plundering desire for love\n";

    char* buf;

    /* 初始化用户应用程序 */
    application_init(video_access_mode, app_type, "text_line");

    /* 申请窗口 */
    w = window_init("window with text_line");
    /* 申请失败 */
    if(w == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w, 300, 100, 548, 300);

    ta = text_line_init(2 * sizeof(lyrics), 0);
    /* 申请失败 */
    if(ta == NULL)
    {
        application_exit();

        return -1;
    }
	text_line_set_bounds(ta, 5, 5, 538, 290);
    text_line_set_multilines(ta);
    buf = text_line_get_buf(ta);
    strncpy(buf, lyrics, sizeof(lyrics));

    object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(ta));

    /* 添加顶层窗口 */
    application_add_window(NULL, w);
    /* 设置主窗口 */
    application_set_main_window(w);

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 22
0
Archivo: main.c Proyecto: skoobe/riofs
/*{{{ main */
int main (int argc, char *argv[])
{
    Application *app;
    gboolean verbose = FALSE;
    gboolean version = FALSE;
    GError *error = NULL;
    GOptionContext *context;
    gchar **s_params = NULL;
    gchar **s_config = NULL;
    gboolean foreground = FALSE;
    gchar conf_str[1023];
    struct stat st;
    gchar **cache_dir = NULL;
    gchar **s_fuse_opts = NULL;
    gchar **s_log_file = NULL;
    guint32 part_size = 0;
    gboolean disable_syslog = FALSE;
    gboolean disable_stats = FALSE;
    gboolean force_head_requests = FALSE;
    gint uid = -1;
    gint gid = -1;
    gint fmode = -1;
    gint dmode = -1;

    struct event_config *ev_config;

    srand (time (NULL));
    app = g_new0 (Application, 1);
    app->conf_path = g_build_filename (SYSCONFDIR, "riofs.conf.xml", NULL);
    g_snprintf (conf_str, sizeof (conf_str), "Path to configuration file. Default: %s", app->conf_path);

    GOptionEntry entries[] = {
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &s_params, NULL, NULL },
        { "config", 'c', 0, G_OPTION_ARG_FILENAME_ARRAY, &s_config, conf_str, NULL},

        { "uid", 0, 0, G_OPTION_ARG_INT, &uid, "Set UID of filesystem owner.", NULL },
        { "gid", 0, 0, G_OPTION_ARG_INT, &gid, "Set GID of filesystem owner.", NULL },
        { "fmode", 0, 0, G_OPTION_ARG_INT, &fmode, "Set mode for all files.", NULL },
        { "dmode", 0, 0, G_OPTION_ARG_INT, &dmode, "Set mode for all directories.", NULL },

        { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Flag. Do not daemonize process.", NULL },
        { "cache-dir", 0, 0, G_OPTION_ARG_STRING_ARRAY, &cache_dir, "Set cache directory.", NULL },
        { "fuse-options", 'o', 0, G_OPTION_ARG_STRING_ARRAY, &s_fuse_opts, "Fuse options.", "\"opt[,opt...]\"" },
        { "disable-syslog", 0, 0, G_OPTION_ARG_NONE, &disable_syslog, "Flag. Disable logging to syslog.", NULL },
        { "disable-stats", 0, 0, G_OPTION_ARG_NONE, &disable_stats, "Flag. Disable Statistics HTTP interface.", NULL },
        { "part-size", 0, 0, G_OPTION_ARG_INT, &part_size, "Set file part size (in bytes).", NULL },
        { "log-file", 'l', 0, G_OPTION_ARG_STRING_ARRAY, &s_log_file, "File to write output.", NULL },
        { "force-head-requests", 0, 0, G_OPTION_ARG_NONE, &force_head_requests, "Flag. Send HEAD request for each file.", NULL },
        { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Verbose output.", NULL },
        { "version", 'V', 0, G_OPTION_ARG_NONE, &version, "Show application version and exit.", NULL },
        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
    };

    // init libraries
    CRYPTO_set_mem_functions (g_malloc0, g_realloc, g_free);
    ENGINE_load_builtin_engines ();
    ENGINE_register_all_complete ();
    ERR_load_crypto_strings ();
    OpenSSL_add_all_algorithms ();
#ifdef SSL_ENABLED
    SSL_load_error_strings ();
    SSL_library_init ();
#endif
    g_random_set_seed (time (NULL));

    // init main app structure
    ev_config = event_config_new ();

#if defined(__APPLE__)
    // method select is the preferred method on OS X. kqueue and poll are not supported.
    event_config_avoid_method (ev_config, "kqueue");
    event_config_avoid_method (ev_config, "poll");
#endif

    app->evbase = event_base_new_with_config (ev_config);
    event_config_free (ev_config);

    if (!app->evbase) {
        LOG_err (APP_LOG, "Failed to create event base !");
        application_destroy (app);
        return -1;
    }

    app->dns_base = evdns_base_new (app->evbase, 1);
    if (!app->dns_base) {
        LOG_err (APP_LOG, "Failed to create DNS base !");
        application_destroy (app);
        return -1;
    }

    app->f_log = NULL;
    app->log_file_name = NULL;

/*{{{ cmd line args */

    // parse command line options
    context = g_option_context_new ("[bucketname] [mountpoint]");
    g_option_context_add_main_entries (context, entries, NULL);
    g_option_context_set_description (context, "Please set both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables!");
    if (!g_option_context_parse (context, &argc, &argv, &error)) {
        g_fprintf (stderr, "Failed to parse command line options: %s\n", error->message);
        application_destroy (app);
        g_option_context_free (context);
        return -1;
    }
    g_option_context_free (context);

        // check if --version is specified
    if (version) {
        g_fprintf (stdout, "RioFS File System v%s\n", VERSION);
        g_fprintf (stdout, "Copyright (C) 2012-2014 Paul Ionkin <*****@*****.**>\n");
        g_fprintf (stdout, "Copyright (C) 2012-2014 Skoobe GmbH. All rights reserved.\n");
        g_fprintf (stdout, "Libraries:\n");
        g_fprintf (stdout, " GLib: %d.%d.%d   libevent: %s  fuse: %d.%d",
                GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
                LIBEVENT_VERSION,
                FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION
        );
#if defined(__APPLE__) || defined(__FreeBSD__) || !defined(__GLIBC__)
        g_fprintf (stdout, "\n");
#else
        g_fprintf (stdout, "  glibc: %s\n", gnu_get_libc_version ());
#endif
        g_fprintf (stdout, "Features:\n");
        g_fprintf (stdout, " libevent backend method: %s\n", event_base_get_method(app->evbase));
#ifdef SSL_ENABLED
        g_fprintf (stdout, " SSL enabled\n");
#endif
        /*
        {
            int i;
            const char **methods = event_get_supported_methods ();

            g_fprintf (stdout, " Available libevent backend methods:\n");
            for (i = 0; methods[i] != NULL; ++i) {
                g_fprintf (stdout, "  %s\n", methods[i]);
            }
        }
        */

        return 0;
    }

    if (!s_params || g_strv_length (s_params) != 2) {
        LOG_err (APP_LOG, "Wrong number of provided arguments!\nTry `%s --help' for more information.", argv[0]);
        application_destroy (app);
        return -1;
    }

    if (verbose)
        log_level = LOG_debug;
    else
        log_level = LOG_msg;

/*}}}*/

/*{{{ parse config file */

    // user provided alternative config path
    if (s_config && g_strv_length (s_config) > 0) {
        g_free (app->conf_path);
        app->conf_path = g_strdup (s_config[0]);
        g_strfreev (s_config);
    }

    app->conf = conf_create ();
    if (access (app->conf_path, R_OK) == 0) {
        LOG_debug (APP_LOG, "Using config file: %s", app->conf_path);

        if (!conf_parse_file (app->conf, app->conf_path)) {
            LOG_err (APP_LOG, "Failed to parse configuration file: %s", app->conf_path);
            application_destroy (app);
            return -1;
        }

    } else {
        LOG_err (APP_LOG, "Configuration file is not found !");
        application_destroy (app);
        return -1;
    }

    if (!conf_check_keys (app->conf, conf_keys_str, conf_keys_len)) {
        LOG_err (APP_LOG, "Configuration file is missing keys, please re-check your configuration file: %s", app->conf_path);
        application_destroy (app);
        return -1;
    }

    if (disable_syslog) {
        conf_set_boolean (app->conf, "log.use_syslog", FALSE);
    }
    // update logging settings
    logger_set_syslog (conf_get_boolean (app->conf, "log.use_syslog"));
    logger_set_color (conf_get_boolean (app->conf, "log.use_color"));

    if (cache_dir && g_strv_length (cache_dir) > 0) {
        conf_set_string (app->conf, "filesystem.cache_dir", cache_dir[0]);
        g_strfreev (cache_dir);
    }

    if (!verbose)
        log_level = conf_get_int (app->conf, "log.level");

    if (uid >= 0)
        conf_set_int (app->conf, "filesystem.uid", uid);

    if (gid >= 0)
        conf_set_int (app->conf, "filesystem.gid", gid);

    if (fmode >= 0)
        conf_set_int (app->conf, "filesystem.file_mode", fmode);

    if (dmode >= 0)
        conf_set_int (app->conf, "filesystem.dir_mode", dmode);

/*}}}*/

    // try to get access parameters from the environment
    if (getenv ("AWS_ACCESS_KEY_ID")) {
        conf_set_string (app->conf, "s3.access_key_id", getenv ("AWS_ACCESS_KEY_ID"));
    // else check if it's set it the config file
    } else {
        if (!conf_node_exists (app->conf, "s3.access_key_id")) {
            LOG_err (APP_LOG, "Environment variables are not set!\nTry `%s --help' for more information.", argv[0]);
            application_destroy (app);
            return -1;
        }
    }
    if (getenv ("AWS_SECRET_ACCESS_KEY")) {
        conf_set_string (app->conf, "s3.secret_access_key", getenv ("AWS_SECRET_ACCESS_KEY"));
    } else {
        if (!conf_node_exists (app->conf, "s3.secret_access_key")) {
            LOG_err (APP_LOG, "Environment variables are not set!\nTry `%s --help' for more information.", argv[0]);
            application_destroy (app);
            return -1;
        }
    }

    // check if both strings are set
    if (!conf_get_string (app->conf, "s3.access_key_id") || !conf_get_string (app->conf, "s3.secret_access_key")) {
        LOG_err (APP_LOG, "Environment variables are not set!\nTry `%s --help' for more information.", argv[0]);
        application_destroy (app);
        return -1;
    }


    // foreground is set
    if (foreground)
        conf_set_boolean (app->conf, "app.foreground", foreground);

    if (part_size)
        conf_set_uint (app->conf, "s3.part_size", part_size);

    if (disable_stats)
        conf_set_boolean (app->conf, "statistics.enabled", FALSE);

    if (force_head_requests)
        conf_set_boolean (app->conf, "s3.force_head_requests_on_lookup", TRUE);
    else
        conf_set_boolean (app->conf, "s3.force_head_requests_on_lookup", FALSE);

    conf_set_string (app->conf, "s3.bucket_name", s_params[0]);
    if (!application_set_url (app, conf_get_string (app->conf, "s3.endpoint"))) {
        application_destroy (app);
        return -1;
    }

    if (s_fuse_opts && g_strv_length (s_fuse_opts) > 0) {
        app->fuse_opts = g_strdup (s_fuse_opts[0]);
        g_strfreev (s_fuse_opts);
    }

    if (s_log_file  && g_strv_length (s_log_file) > 0) {
        app->log_file_name = g_strdup (s_log_file[0]);
        app->f_log = fopen (s_log_file[0], "a+");
        if (!app->f_log) {
            LOG_err (APP_LOG, "Failed to open log file: %s Error: %s", s_log_file[0], strerror (errno));
            application_destroy (app);
            return -1;
        }

        LOG_debug (APP_LOG, "Using %s for storing application logs.", s_log_file[0]);
        logger_set_file (app->f_log);
        g_strfreev (s_log_file);
    }

    conf_set_string (app->conf, "app.mountpoint", s_params[1]);

    // check if directory exists
    if (stat (conf_get_string (app->conf, "app.mountpoint"), &st) == -1) {
        LOG_err (APP_LOG, "Mountpoint %s does not exist! Please check directory permissions!",
            conf_get_string (app->conf, "app.mountpoint"));
        application_destroy (app);
        return -1;
    }
    // check if it's a directory
    if (!S_ISDIR (st.st_mode)) {
        LOG_err (APP_LOG, "Mountpoint %s is not a directory!", conf_get_string (app->conf, "app.mountpoint"));
        application_destroy (app);
        return -1;
    }

    g_strfreev (s_params);

#ifdef SSL_ENABLED
    app->ssl_ctx = SSL_CTX_new (SSLv23_client_method ());
    if (!app->ssl_ctx) {
        LOG_err (APP_LOG, "Failed to initialize SSL engine !");
        application_exit (app);
        return -1;
    }
    SSL_CTX_set_options (app->ssl_ctx, SSL_OP_ALL);
#endif

#ifdef MAGIC_ENABLED
    app->magic_ctx = magic_open(MAGIC_MIME_TYPE);
    if (!app->magic_ctx) {
        LOG_err(APP_LOG, "Failed to initialize magic library\n");
        return -1;
    }
    if (magic_load(app->magic_ctx, NULL)) {
        LOG_err(APP_LOG, "Failed to load magic database: %s\n", magic_error(app->magic_ctx));
        magic_close(app->magic_ctx);
        return -1;
    }
#endif

    app->stat_srv = stat_srv_create (app);
    if (!app->stat_srv) {
        application_exit (app);
        return -1;
    }

    // perform the initial request to get  bucket ACL (handles redirect as well)
    app->service_con = http_connection_create (app);
    if (!app->service_con)  {
        application_destroy (app);
        return -1;
    }
    bucket_client_get (app->service_con, "/?acl", application_on_bucket_acl_cb, app);

    // start the loop
    event_base_dispatch (app->evbase);

    application_destroy (app);

    return 0;
}
Ejemplo n.º 23
0
si_t right_click_menu_init() {
	si_t i = 0;
	for(i=0;i<MENU_NUM;i++)
		menu_button[i]=NULL;
	
	//第一个邮件按钮(新建文件夹)
	menu_button[0] = button_init("NEW FOLDER");
	/* 申请失败 */
	if(menu_button[0] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[0]->callback = right_click_menu_NEW_FOLDER;    


	//第二个邮件按钮(新建文件)
	menu_button[1] = button_init("NEW FILE");
	/* 申请失败 */
	if(menu_button[1] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[1]->callback = right_click_menu_NEW_FILE;    

	

	//第三个邮件按钮(打开)
	menu_button[2] = button_init("open");
	/* 申请失败 */
	if(menu_button[2] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[2]->callback = right_click_menu_open;    


	//第四个邮件按钮(重命名)
	menu_button[3] = button_init("rename");
	/* 申请失败 */
	if(menu_button[3] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[3]->callback = right_click_menu_rename;    

	//第五个邮件按钮(删除)
	menu_button[4] = button_init("delete");
	/* 申请失败 */
	if(menu_button[4] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[4]->callback = right_click_menu_delete;


	//第六个邮件按钮(刷新)
	menu_button[5] = button_init("FLUSH");
	/* 申请失败 */
	if(menu_button[5] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[5]->callback = right_click_menu_FLUSH; 

	//第七个邮件按钮(复制)
	menu_button[6] = button_init("coyp");
	/* 申请失败 */
	if(menu_button[6] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[6]->callback = right_click_menu_copy;

	//第八个邮件按钮(粘贴)
	menu_button[7] = button_init("paste");
	/* 申请失败 */
	if(menu_button[7] == NULL)
	{
		application_exit();
		return -1;
	}
	menu_button[7]->callback = right_click_menu_paste; 
  
	/* 添加button */   
	for(i=0;i<MENU_NUM;i++){
		button_set_color(menu_button[i], &font_white, &ground_purple);
    	button_set_bounds(menu_button[i], 0, -30, 0, 0);
		object_attach_child(OBJECT_POINTER(Desktop_im), OBJECT_POINTER(menu_button[i]));
	}


	
	/* 右键菜单不显示 */	
	menu_show = 0;	
}
Ejemplo n.º 24
0
/*
    测试顶层窗口和子窗口

    程序一共申请了四个窗口 w1 w2 w3 w4
    其中 w1 和 w2 是顶层窗口
    w3 和 w4 是 w2 的同一层次子窗口

    w2 总在 w3 和 w4 的后面
    w3 和 w4 的前后关系则可以改变
*/
int main()
{
    si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER;
	si_t app_type = APPLICATION_TYPE_NORMAL;
    struct window * w1;
    struct window * w2;
    struct window * w3;
    struct window * w4;
    struct window * w5;
    struct radiobutton * r, *s;

    /* 初始化用户应用程序 */
    application_init(video_access_mode, app_type, "toplevel_child");

    w1 = window_init("uncle-1");
    /* 申请失败 */
    if(w1 == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w1, 300, 100, 448, 200);

    w2 = window_init("parent");
    /* 申请失败 */
    if(w2 == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w2, 350, 150, 448, 200);

    w3 = window_init("child-1");
    /* 申请失败 */
    if(w3 == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w3, 400, 200, 600, 600);

    w4 = window_init("child-2");
    /* 申请失败 */
    if(w4 == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w4, 450, 250, 448, 200);

    w5 = window_init("uncle-2");
    /* 申请失败 */
    if(w5 == NULL)
    {
        application_exit();
        return -1;
    }
	window_set_bounds(w5, 500, 300, 448, 200);

    {
        struct button *b = button_init("click me!");
        button_set_bounds(b, 50, 50, 150, 50);
        b->callback = button_callback;
        object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(b));
    }

    /*
     * Window structure illustraion:
     *           app
     *          / | \
     *  (main)w1 w5 w2
     *              / \
     *             w3  w4
     */

    /* 添加顶层窗口 */
    application_add_window(NULL, w1);
    /* 添加顶层窗口 */
    application_add_window(NULL, w2);
    /* 添加非顶层窗口 */
    application_add_window(w2, w3);
    /* 添加非顶层窗口 */
    application_add_window(w2, w4);
    /* 添加顶层窗口 */
    application_add_window(NULL, w5);
    /* 设置主窗口 */
    application_set_main_window(w1);

    r = radiobutton_init("test_group", 0);
    s = radiobutton_init("test_group", 1);
    radiobutton_set_bounds(r, 20, 20, 13, 13);
    radiobutton_set_bounds(s, 20, 40, 13, 13);
    object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(r));
    object_attach_child(OBJECT_POINTER(w4), OBJECT_POINTER(s));

    {
        struct panel *p = panel_init(0);
        struct button *pb = button_init("button in panel");
        struct checkbox *pcb = checkbox_init(0);
        panel_set_bounds(p, 5, 5, 500, 500);
        button_set_bounds(pb, 5, 5, 200, 50);
        checkbox_set_bounds(pcb, 210, 5, -1, -1);
        object_attach_child(OBJECT_POINTER(w3), OBJECT_POINTER(p));
        object_attach_child(OBJECT_POINTER(p), OBJECT_POINTER(pb));
        object_attach_child(OBJECT_POINTER(p), OBJECT_POINTER(pcb));
    }

    /* 运行 */
    application_exec();

    return 0;
}
Ejemplo n.º 25
0
Archivo: main.c Proyecto: skoobe/riofs
/*{{{ application_finish_initialization_and_run */
static gint application_finish_initialization_and_run (Application *app)
{
    struct sigaction sigact;

/*{{{ create Pools */
    // create ClientPool for reading operations
    app->read_client_pool = client_pool_create (app, conf_get_int (app->conf, "pool.readers"),
        http_connection_create,
        http_connection_destroy,
        http_connection_set_on_released_cb,
        http_connection_check_rediness,
        http_connection_get_stats_info_caption,
        http_connection_get_stats_info_data
        );
    if (!app->read_client_pool) {
        LOG_err (APP_LOG, "Failed to create ClientPool !");
        application_exit (app);
        return -1;
    }

    // create ClientPool for writing operations
    app->write_client_pool = client_pool_create (app, conf_get_int (app->conf, "pool.writers"),
        http_connection_create,
        http_connection_destroy,
        http_connection_set_on_released_cb,
        http_connection_check_rediness,
        http_connection_get_stats_info_caption,
        http_connection_get_stats_info_data
        );
    if (!app->write_client_pool) {
        LOG_err (APP_LOG, "Failed to create ClientPool !");
        application_exit (app);
        return -1;
    }

    // create ClientPool for various operations
    app->ops_client_pool = client_pool_create (app, conf_get_int (app->conf, "pool.operations"),
        http_connection_create,
        http_connection_destroy,
        http_connection_set_on_released_cb,
        http_connection_check_rediness,
        http_connection_get_stats_info_caption,
        http_connection_get_stats_info_data
        );
    if (!app->ops_client_pool) {
        LOG_err (APP_LOG, "Failed to create ClientPool !");
        application_exit (app);
        return -1;
    }
/*}}}*/

/*{{{ CacheMng */
    app->cmng = cache_mng_create (app);
    if (!app->cmng) {
        LOG_err (APP_LOG, "Failed to create CacheMng !");
        application_exit (app);
        return -1;
    }
/*}}}*/

/*{{{ DirTree*/
    app->dir_tree = dir_tree_create (app);
    if (!app->dir_tree) {
        LOG_err (APP_LOG, "Failed to create DirTree !");
        application_exit (app);
        return -1;
    }
/*}}}*/

/*{{{ FUSE*/
    app->rfuse = rfuse_new (app, conf_get_string (app->conf, "app.mountpoint"), app->fuse_opts);
    if (!app->rfuse) {
        LOG_err (APP_LOG, "Failed to create FUSE fs ! Mount point: %s", conf_get_string (app->conf, "app.mountpoint"));
        application_exit (app);
        return -1;
    }
/*}}}*/

  // set global App variable
    _app = app;

/*{{{ signal handlers*/
    // SIGINT
    app->sigint_ev = evsignal_new (app->evbase, SIGINT, sigint_cb, app);
    event_add (app->sigint_ev, NULL);
    // SIGSEGV
    sigact.sa_sigaction = sigsegv_cb;
    sigact.sa_flags = (int)SA_RESETHAND | SA_SIGINFO;
    sigemptyset (&sigact.sa_mask);
    if (sigaction (SIGSEGV, &sigact, (struct sigaction *) NULL) != 0) {
        LOG_err (APP_LOG, "error setting signal handler for %d (%s)\n", SIGSEGV, strsignal(SIGSEGV));
        application_exit (app);
        return 1;
    }
    // SIGTERM
    app->sigterm_ev = evsignal_new (app->evbase, SIGTERM, sigterm_cb, app);
    event_add (app->sigterm_ev, NULL);
    // SIGABRT
    sigact.sa_sigaction = sigsegv_cb;
    sigact.sa_flags = (int)SA_RESETHAND | SA_SIGINFO;
    sigemptyset (&sigact.sa_mask);
    if (sigaction (SIGABRT, &sigact, (struct sigaction *) NULL) != 0) {
        LOG_err (APP_LOG, "error setting signal handler for %d (%s)\n", SIGABRT, strsignal(SIGABRT));
        application_exit (app);
        return 1;
    }
    // SIGPIPE
    app->sigpipe_ev = evsignal_new (app->evbase, SIGPIPE, sigpipe_cb, app);
    event_add (app->sigpipe_ev, NULL);

    // SIGUSR1
    app->sigusr1_ev = evsignal_new (app->evbase, SIGUSR1, sigusr1_cb, app);
    event_add (app->sigusr1_ev, NULL);

    // SIGUSR2
    app->sigusr2_ev = evsignal_new (app->evbase, SIGUSR2, sigusr2_cb, app);
    event_add (app->sigusr2_ev, NULL);

/*}}}*/

    if (!conf_get_boolean (app->conf, "app.foreground"))
        fuse_daemonize (0);

    return 0;
}