int enna_util_init() { EVT("enna util init"); /* Prevent multiple loads */ if (_util_init_count > 0) return ++_util_init_count; sd = calloc(1, sizeof(Smart_Data)); sd->cache = eina_stringshare_printf("%s/%s", efreet_cache_home_get(), "/enna"); sd->config = eina_stringshare_printf("%s/%s", efreet_config_home_get(), "/enna"); sd->data = eina_stringshare_printf("%s/%s", efreet_data_home_get(), "/enna"); if (!ecore_file_is_dir(sd->cache)) ecore_file_mkdir(sd->cache); if (!ecore_file_is_dir(sd->config)) ecore_file_mkdir(sd->config); if (!ecore_file_is_dir(sd->data)) ecore_file_mkdir(sd->data); DBG("Set data directory to %s", sd->data); DBG("Set config directory to : %s", sd->config); DBG("Set cache directory to : %s", sd->cache); _util_init_count = 1; EVT("enna util init done"); return 1; }
Shotgun_Auth * shotgun_new(const char *svr_name, const char *username, const char *domain) { Shotgun_Auth *auth; auth = calloc(1, sizeof(Shotgun_Auth)); if (username) auth->user = eina_stringshare_add(username); if (domain) auth->from = eina_stringshare_add(domain); auth->resource = eina_stringshare_add("SHOTGUN!"); if (username && domain) { /* chat client may store username as the full jid */ if (strrchr(username, '@')) { auth->jid = eina_stringshare_printf("%s/%s", auth->user, auth->resource); auth->base_jid = eina_stringshare_add(username); } else { auth->jid = eina_stringshare_printf("%s@%s/%s", auth->user, auth->from, auth->resource); auth->base_jid = eina_stringshare_printf("%s@%s", auth->user, auth->from); } } if (svr_name) auth->svr_name = eina_stringshare_add(svr_name); auth->pending_ping = 0; auth->ping_max_attempts = 5; shotgun_ping_delay_set(auth, 60); shotgun_ping_timeout_set(auth, 30); return auth; }
static const char * _root_meta_get(void *data, Enna_File *file, const char *key) { Root_Directories *root = data; struct statfs st; if (!root) return NULL; if (!strcmp(key, ENNA_META_KEY_SIZE)) { if (statfs(root->uri+7, &st) != 0) { return NULL; } return eina_stringshare_printf("%s", make_human_readable_str( st.f_blocks, st.f_bsize, 0)); } else if (!strcmp(key, ENNA_META_KEY_USESPACE)) { if (statfs(root->uri+7, &st) != 0) { return NULL; } return eina_stringshare_printf("%s",make_human_readable_str( (st.f_blocks - st.f_bfree), st.f_bsize, 0)); } else if (!strcmp(key, ENNA_META_KEY_FREESPACE)) { if (statfs(root->uri+7, &st) != 0) { return NULL; } return eina_stringshare_printf("%s", make_human_readable_str(st.f_bavail, st.f_bsize, 0)); } else if (!strcmp(key, ENNA_META_KEY_PERCENT_USED)) { unsigned long blocks_used; unsigned blocks_percent_used; if (statfs(root->uri+7, &st) != 0) { return NULL; } blocks_used = st.f_blocks - st.f_bfree; blocks_percent_used = (blocks_used * 100ULL + (blocks_used + st.f_bavail)/2) / (blocks_used + st.f_bavail); return eina_stringshare_printf("%d", blocks_percent_used); } return NULL; }
static void _dialog_create_folder_ok_clicked_cb(void *data, Evas_Object *btn, void *ev) { Enna_Localfiles_Priv *priv = data; Enna_File *file; Evas_Object *entry; const char *new_name; const char *new_path; char uri[4096]; file = evas_object_data_get(priv->dialog, "file"); entry = evas_object_data_get(priv->dialog, "entry"); new_name = elm_object_text_get(entry); new_path = eina_stringshare_printf("%s/%s", ecore_file_dir_get(file->mrl), new_name); if (ecore_file_mkdir(new_name)) { Enna_File *f; snprintf(uri, sizeof(uri), "file://%s", new_path); printf(" uri : %s\n", uri); f = enna_file_directory_add(new_name, uri, new_path, new_name, "icon/directory"); enna_browser_file_add(priv->browser, f); } evas_object_del(priv->dialog); }
static void _wkb_name_acquired_cb(void *data, const Eldbus_Message *msg) { const char *name, *path; _check_message_errors(msg); if (!eldbus_message_arguments_get(msg, "s", &name)) { ERR("Error reading message arguments"); return; } DBG("NameAcquired: '%s'", name); if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0) { wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn); INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail"); } else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0) { path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get()); wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path); eina_stringshare_del(path); INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail"); } else { WRN("Unexpected name %s", name); } }
static void _db_build_implement(Eolian_Class *cl, Eolian_Function *foo_id) { if (foo_id->type == EOLIAN_PROP_SET) { if (foo_id->set_impl) return; } else if (foo_id->type == EOLIAN_PROP_GET) { if (foo_id->get_impl) return; } else if (foo_id->get_impl && foo_id->set_impl) return; Eolian_Implement *impl = calloc(1, sizeof(Eolian_Implement)); if (foo_id->type == EOLIAN_PROP_SET) impl->base = foo_id->set_base; else impl->base = foo_id->base; eina_stringshare_ref(impl->base.file); impl->klass = cl; impl->foo_id = foo_id; impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name, foo_id->name); if (foo_id->type == EOLIAN_PROPERTY) { if (foo_id->get_impl) { impl->is_prop_set = EINA_TRUE; foo_id->set_impl = impl; } else if (foo_id->set_impl) { impl->is_prop_get = EINA_TRUE; foo_id->get_impl = impl; } else foo_id->get_impl = foo_id->set_impl = impl; } else if (foo_id->type == EOLIAN_PROP_SET) { impl->is_prop_set = EINA_TRUE; foo_id->set_impl = impl; } else if (foo_id->type == EOLIAN_PROP_GET) { impl->is_prop_get = EINA_TRUE; foo_id->get_impl = impl; } else foo_id->get_impl = foo_id->set_impl = impl; cl->implements = eina_list_append(cl->implements, impl); }
static void _file_main_cb(void *data, Eio_File *handler, const Eina_File_Direct_Info *info) { Enna_Localfiles_Priv *priv = data; Enna_File *f; const char *buf; Enna_File_Action *action; buf = eina_stringshare_printf("file://%s", info->path); if (info->type == EINA_FILE_DIR) { f = enna_file_directory_add(info->path + info->name_start, buf, info->path, info->path + info->name_start, "icon/directory"); } else { if (priv->caps == ENNA_CAPS_ALL) f = enna_file_file_add(info->path + info->name_start, buf, info->path, info->path + info->name_start, "icon/file"); else if (priv->caps == ENNA_CAPS_MUSIC) f = enna_file_track_add(info->path + info->name_start, buf, info->path, info->path + info->name_start, "icon/music"); else if (priv->caps == ENNA_CAPS_VIDEO) f = enna_file_film_add(info->path + info->name_start, buf, info->path, info->path + info->name_start, "icon/video"); else f = enna_file_file_add(info->path + info->name_start, buf, info->path, info->path + info->name_start, "icon/music"); } action = enna_file_action_new(f, "copy", "Copy", "edit-copy", NULL, NULL); enna_file_action_add(f, action); action = enna_file_action_new(f, "move", "Move", "folder-move", NULL, NULL); enna_file_action_add(f, action); action = enna_file_action_new(f, "rename", "Rename", "gtk-edit", _action_rename_cb, priv); enna_file_action_add(f, action); action = enna_file_action_new(f, "delete", "Delete", "edit-delete", _action_delete_cb, priv); enna_file_action_add(f, action); action = enna_file_action_new(f, "details", "Details", "view-list-details", NULL, NULL); enna_file_action_add(f, action); action = enna_file_action_new(f, "create_folder", "Create new folder", "folder-new", _action_create_folder_cb, priv); enna_file_action_add(f, action); eina_stringshare_del(buf); enna_browser_file_add(priv->browser, f); }
static void _evas_gl_common_shader_binary_hash(Evas_GL_Shared *shared) { if (shared->shaders_checksum) return; /* This hash makes it sure that if the shaders code changes, then we * will not reuse the old binaries. */ shared->shaders_checksum = eina_stringshare_printf ("%#x:%#x", eina_hash_superfast(fragment_glsl, strlen(fragment_glsl)), eina_hash_superfast(vertex_glsl, strlen(vertex_glsl))); }
Eina_Bool shotgun_connect(Shotgun_Auth *auth) { if ((!auth->user) || (!auth->from) || (!auth->svr_name)) return EINA_FALSE; if (auth->changed) { auth->jid = eina_stringshare_printf("%s@%s/%s", auth->user, auth->from, auth->resource); auth->base_jid = eina_stringshare_printf("%s@%s", auth->user, auth->from); auth->changed = EINA_FALSE; } else if (!auth->jid) auth->jid = eina_stringshare_printf("%s@%s/%s", auth->user, auth->from, auth->resource); else if (!auth->base_jid) auth->base_jid = eina_stringshare_printf("%s@%s", auth->user, auth->from); auth->ev_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)shotgun_login_con, auth); auth->ev_del = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb)disc, auth); auth->ev_data = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)data, auth); auth->ev_error = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, (Ecore_Event_Handler_Cb)error, auth); auth->ev_upgrade = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_UPGRADE, (Ecore_Event_Handler_Cb)shotgun_login_con, auth); auth->ev_write = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_WRITE, (Ecore_Event_Handler_Cb)ev_write, auth); auth->svr = ecore_con_server_connect(ECORE_CON_REMOTE_NODELAY, auth->svr_name, 5222, auth); if (auth->svr) auth->keepalive = ecore_timer_add(300, (Ecore_Task_Cb)keepalive, auth); return !!auth->svr; }
static void _rename_done_cb(void *data, Eio_File *handler) { Enna_Localfiles_Priv *priv = data; const char *new_path = priv->new_path; const char *new_uri; const char *new_mrl; new_uri = eina_stringshare_printf("%s/%s", ecore_file_dir_get(priv->file_dialog->uri), ecore_file_file_get(new_path)); new_mrl = eina_stringshare_printf("%s/%s", ecore_file_dir_get(priv->file_dialog->mrl), ecore_file_file_get(new_path)); priv->file_dialog->name = eina_stringshare_add(ecore_file_dir_get(new_path)); priv->file_dialog->uri = new_uri; priv->file_dialog->label = eina_stringshare_add(ecore_file_file_get(new_path)); priv->file_dialog->mrl = new_mrl; enna_browser_file_update(priv->browser, priv->file_dialog); eina_stringshare_del(new_path); priv->new_path = NULL; }
/** * @brief Implementation atk_object_get_name * Returns accessible name if assigned, title or subtitle otherwise * * @param obj EailNaviframePage instance * @returns obj accessible name if assigned, title or subtitle otherwise */ static const char * eail_naviframe_page_name_get(AtkObject *obj) { g_return_val_if_fail(EAIL_IS_NAVIFRAME_PAGE(obj), NULL); EailNaviframePage *page = EAIL_NAVIFRAME_PAGE(obj); if (page->name != NULL) return page->name; const char *title = elm_object_item_part_text_get(page->page, "default"); const char *subtitle = elm_object_item_part_text_get(page->page, "subtitle"); if (subtitle != NULL) page->name = eina_stringshare_printf("%s\n%s", title, subtitle); else page->name = eina_stringshare_add(title); return page->name; }
static void _set_text(Evas_Object *obj, const char *part, const char *text, const char *prefix, const char *alt) { const char *tmp; if (!text || !text[0] || text[0] == ' ') elm_layout_text_set(obj, "enna.text.genre", alt); else { tmp = eina_stringshare_printf("%s%s", prefix, text); elm_layout_text_set(obj, part, tmp); eina_stringshare_del(text); eina_stringshare_del(tmp); } }
static void _dialog_rename_ok_clicked_cb(void *data, Evas_Object *btn, void *ev) { Enna_Localfiles_Priv *priv = data; Enna_File *file; Evas_Object *entry; const char *new_name; const char *new_path; file = evas_object_data_get(priv->dialog, "file"); entry = evas_object_data_get(priv->dialog, "entry"); new_name = elm_object_text_get(entry); new_path = eina_stringshare_printf("%s/%s", ecore_file_dir_get(file->mrl), new_name); priv->new_path = new_path; if (priv->file_dialog) enna_file_free(priv->file_dialog); priv->file_dialog = enna_file_ref(file); if (file->type == ENNA_FILE_DIRECTORY) { eio_dir_move(file->mrl, new_path, _dir_filter_cb, _dir_progress_cb, _rename_done_cb, _error_cb, priv); } else if (file->type == ENNA_FILE_FILE) { eio_file_move(file->mrl, new_path, _dir_progress_cb, _rename_done_cb, _error_cb, priv); } evas_object_del(priv->dialog); }
int main(int argc, char **argv) { const char *str, *str2; const char *prologe = "The Cylons were created by man. They rebelled. They " "evolved."; const char *prologe2 = "%d Cylon models. %d are known. %d live in secret. " "%d will be revealed."; const char *prologe3 = "There are many copies. And they have a plan."; eina_init(); str = eina_stringshare_add_length(prologe, 31); printf("%s\n", str); printf("length: %d\n", eina_stringshare_strlen(str)); eina_stringshare_del(str); str = eina_stringshare_printf(prologe2, 12, 7, 4, 1); printf("%s\n", str); eina_stringshare_del(str); str = eina_stringshare_nprintf(45, "%s", prologe3); printf("%s\n", str); str2 = eina_stringshare_add(prologe3); printf("%s\n", str2); eina_stringshare_ref(str2); eina_stringshare_del(str2); printf("%s\n", str2); eina_stringshare_replace(&str, prologe); printf("%s\n", str); eina_stringshare_del(str); eina_stringshare_del(str2); eina_shutdown(); return 0; }
static void _wkb_name_acquired_cb(void *data, const Eldbus_Message *msg) { const char *name, *path; _check_message_errors(msg); if (!eldbus_message_arguments_get(msg, "s", &name)) { ERR("Error reading message arguments"); return; } DBG("NameAcquired: '%s'", name); if (strncmp(name, IBUS_INTERFACE_PANEL, strlen(IBUS_INTERFACE_PANEL)) == 0) { wkb_ibus->panel = wkb_ibus_panel_register(wkb_ibus->conn); INF("Registering Panel Interface: %s", wkb_ibus->panel ? "Success" : "Fail"); } else if (strncmp(name, IBUS_INTERFACE_CONFIG, strlen(IBUS_INTERFACE_CONFIG)) == 0) { path = eina_stringshare_printf("%s/wkb-ibus-cfg.eet", efreet_config_home_get()); wkb_ibus->config = wkb_ibus_config_register(wkb_ibus->conn, path); eina_stringshare_del(path); INF("Registering Config Interface: %s", wkb_ibus->config ? "Success" : "Fail"); if (wkb_ibus->config) { Eldbus_Object *obj = eldbus_object_get(wkb_ibus->conn, IBUS_SERVICE_CONFIG, IBUS_PATH_CONFIG); Eldbus_Proxy *config = eldbus_proxy_get(obj, IBUS_INTERFACE_CONFIG); eldbus_proxy_signal_handler_add(config, "ValueChanged", _wkb_config_value_changed_cb, wkb_ibus); } } else { INF("Unexpected name %s, ignoring", name); } }
static char * sback_units_format(double d) { return (char*)eina_stringshare_printf(_("%'d lines"), sback_double_to_expo_int(d)); }
static char * sback_indicator_units_format(double d) { return (char*)eina_stringshare_printf("%'d", sback_double_to_expo_int(d)); }
static Eina_Bool _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl) { const char *impl_name = impl->full_name; Eolian_Function *foo_id; Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; if (impl->is_prop_get) ftype = EOLIAN_PROP_GET; else if (impl->is_prop_set) ftype = EOLIAN_PROP_SET; if (impl->is_virtual) { foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl, impl_name, ftype); if (!foo_id) return _func_error(cl, impl); if (impl->is_prop_set) foo_id->set_virtual_pure = EINA_TRUE; else foo_id->get_virtual_pure = EINA_TRUE; impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name, impl_name); eina_stringshare_del(impl_name); impl_name = impl->full_name; _write_impl(foo_id, impl); } else if (impl->is_auto) { if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); if (!foo_id) goto pasttags; if (impl->is_prop_set) foo_id->set_auto = EINA_TRUE; else foo_id->get_auto = EINA_TRUE; _write_impl(foo_id, impl); } else if (impl->is_empty) { if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); if (!foo_id) goto pasttags; if (impl->is_prop_set) foo_id->set_empty = EINA_TRUE; else foo_id->get_empty = EINA_TRUE; _write_impl(foo_id, impl); } else if (!_get_impl_func(cl, impl, ftype, &foo_id)) return _func_error(cl, impl); pasttags: if (impl_name[0] == '.') { impl->full_name = eina_stringshare_printf("%s%s", cl->full_name, impl_name); eina_stringshare_del(impl_name); } return EINA_TRUE; }
static void _action_delete_cb(void *data, Enna_File *file) { Evas_Object *win; Evas_Object *bg; Evas_Object *fr; Evas_Object *lb; Evas_Object *bx; Evas_Object *btn_bx; Evas_Object *btn_ok; Evas_Object *btn_cancel; Enna_Localfiles_Priv *priv = data; const char *label; ENNA_OBJECT_DEL(priv->dialog); win = elm_win_add(enna->win, NULL, ELM_WIN_DIALOG_BASIC); elm_win_title_set(win, _("Delete files")); elm_win_autodel_set(win, EINA_TRUE); evas_object_data_set(win, "file", file); bg = elm_bg_add(win); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, bg); evas_object_show(bg); evas_object_size_hint_min_set(bg, 400, 64); fr = elm_frame_add(win); elm_object_style_set(fr, "pad_medium"); evas_object_show(fr); elm_win_resize_object_add(win, fr); bx = elm_box_add(win); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(bx, -1, -1); evas_object_show(bx); elm_frame_content_set(fr, bx); elm_box_padding_set(bx, 4, 4); lb = elm_label_add(win); elm_label_line_wrap_set(lb, ELM_WRAP_MIXED); elm_label_wrap_width_set(lb, 400); label = eina_stringshare_printf(_("Are you sure to delete <b>%s</b> ?"), file->label); elm_object_text_set(lb, label); eina_stringshare_del(label); evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(lb, 0.5, -1); evas_object_show(lb); elm_box_pack_end(bx, lb); btn_bx = elm_box_add(win); elm_box_horizontal_set(btn_bx, EINA_TRUE); evas_object_size_hint_weight_set(btn_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn_bx, EVAS_HINT_FILL, 0.5); evas_object_show(btn_bx); elm_box_padding_set(btn_bx, 8, 2); btn_ok = elm_button_add(win); elm_object_text_set(btn_ok, _("Delete")); evas_object_show(btn_ok); evas_object_size_hint_weight_set(btn_ok, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn_ok, EVAS_HINT_FILL, 0.5); elm_box_pack_end(btn_bx, btn_ok); evas_object_smart_callback_add(btn_ok, "clicked", _dialog_delete_ok_clicked_cb, priv); btn_cancel = elm_button_add(win); elm_object_text_set(btn_cancel, _("Cancel")); evas_object_show(btn_cancel); evas_object_size_hint_weight_set(btn_cancel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn_cancel, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_box_pack_end(btn_bx, btn_cancel); evas_object_smart_callback_add(btn_cancel, "clicked", _dialog_cancel_clicked_cb, priv); elm_box_pack_end(bx, btn_bx); evas_object_resize(win, 400, 128); evas_object_show(win); priv->dialog = win; }