From 33f0bae5cb9e1faef981f1192fc98a2c8b413c8e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 13 Oct 2010 02:53:25 +0000 Subject: [PATCH] e_fm2_dbus prefix is now e_fm2_device for upcoming seamless integration with eeze SVN revision: 53328 --- src/bin/Makefile.am | 8 +- src/bin/e_config.c | 6 +- src/bin/e_config.h | 6 +- src/bin/e_fm.c | 76 ++-- src/bin/e_fm/Makefile.am | 2 +- src/bin/e_fm/e_fm_main.c | 10 +- src/bin/e_fm/e_fm_main_dbus.c | 10 +- src/bin/e_fm_dbus.c | 664 ----------------------------- src/bin/e_fm_dbus.h | 32 -- src/bin/e_fm_shared_dbus.c | 42 -- src/bin/e_fm_shared_dbus.h | 9 - src/modules/fileman/e_mod_config.c | 4 +- src/modules/fileman/e_mod_main.c | 2 +- 13 files changed, 63 insertions(+), 808 deletions(-) delete mode 100644 src/bin/e_fm_dbus.c delete mode 100644 src/bin/e_fm_dbus.h delete mode 100644 src/bin/e_fm_shared_dbus.c delete mode 100644 src/bin/e_fm_shared_dbus.h diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 4d80c82ec..16cedf14f 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -66,14 +66,14 @@ e_exehist.h \ e_filereg.h \ e_flowlayout.h \ e_fm_custom.h \ -e_fm_dbus.h \ +e_fm_device.h \ e_fm.h \ e_fm_mime.h \ e_fm_op.h \ e_fm_op_registry.h \ e_fm_prop.h \ e_fm_shared_codec.h \ -e_fm_shared_dbus.h \ +e_fm_shared_device.h \ e_fm_shared_types.h \ e_focus.h \ e_font.h \ @@ -213,12 +213,12 @@ e_filereg.c \ e_flowlayout.c \ e_fm.c \ e_fm_custom.c \ -e_fm_dbus.c \ +e_fm_device.c \ e_fm_mime.c \ e_fm_op_registry.c \ e_fm_prop.c \ e_fm_shared_codec.c \ -e_fm_shared_dbus.c \ +e_fm_shared_device.c \ e_focus.c \ e_font.c \ e_gadcon.c \ diff --git a/src/bin/e_config.c b/src/bin/e_config.c index c88e71ee0..cf8803448 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -839,9 +839,9 @@ e_config_init(void) E_CONFIG_VAL(D, T, thumbscroll_momentum_threshhold, DOUBLE); E_CONFIG_VAL(D, T, thumbscroll_friction, DOUBLE); - E_CONFIG_VAL(D, T, dbus_desktop, INT); - E_CONFIG_VAL(D, T, dbus_auto_mount, INT); - E_CONFIG_VAL(D, T, dbus_auto_open, INT); + E_CONFIG_VAL(D, T, device_desktop, INT); + E_CONFIG_VAL(D, T, device_auto_mount, INT); + E_CONFIG_VAL(D, T, device_auto_open, INT); E_CONFIG_VAL(D, T, border_keyboard.timeout, DOUBLE); E_CONFIG_VAL(D, T, border_keyboard.move.dx, UCHAR); diff --git a/src/bin/e_config.h b/src/bin/e_config.h index 5c7172b7c..7079dccd8 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -286,9 +286,9 @@ struct _E_Config double thumbscroll_momentum_threshhold; // GUI double thumbscroll_friction; // GUI - int dbus_desktop; - int dbus_auto_mount; - int dbus_auto_open; + int device_desktop; + int device_auto_mount; + int device_auto_open; struct { double timeout; diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index befcc05a9..dcf9b7b63 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -1,5 +1,5 @@ #include "e.h" -#include "e_fm_dbus.h" +#include "e_fm_device.h" #include "e_fm_op.h" #define OVERCLIP 128 @@ -357,7 +357,7 @@ static void _e_fm_error_abort_cb(void *data, E_Dialog *dialog); static void _e_fm_error_ignore_this_cb(void *data, E_Dialog *dialog); static void _e_fm_error_ignore_all_cb(void *data, E_Dialog *dialog); -static void _e_fm_dbus_error_dialog(const char *title, const char *msg, const char *pstr); +static void _e_fm_device_error_dialog(const char *title, const char *msg, const char *pstr); static void _e_fm2_file_delete(Evas_Object *obj); static void _e_fm2_file_delete_menu(void *data, E_Menu *m, E_Menu_Item *mi); @@ -833,7 +833,7 @@ _e_fm2_cb_mount_fail(void *data) if (!sd) return; // safety if (sd->mount) { - // At this moment E_Fm2_Mount object already deleted in e_fm_dbus.c + // At this moment E_Fm2_Mount object already deleted in e_fm_device.c sd->mount = NULL; if (sd->config->view.open_dirs_in_place) e_fm2_path_set(data, "favorites", "/"); @@ -973,7 +973,7 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) && strncmp(sd->mount->mount_point, sd->realpath, strlen(sd->mount->mount_point))) { - e_fm2_dbus_unmount(sd->mount); + e_fm2_device_unmount(sd->mount); sd->mount = NULL; } @@ -982,18 +982,18 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) { E_Volume *v = NULL; - v = e_fm2_dbus_volume_find(sd->dev + strlen("removable:")); + v = e_fm2_device_volume_find(sd->dev + strlen("removable:")); if (v) - sd->mount = e_fm2_dbus_mount(v, + sd->mount = e_fm2_device_mount(v, _e_fm2_cb_mount_ok, _e_fm2_cb_mount_fail, _e_fm2_cb_unmount_ok, NULL, obj); } else if (sd->config->view.open_dirs_in_place == 0) { E_Fm2_Mount *m; - m = e_fm2_dbus_mount_find(sd->realpath); + m = e_fm2_device_mount_find(sd->realpath); if (m) - sd->mount = e_fm2_dbus_mount(m->volume, + sd->mount = e_fm2_device_mount(m->volume, _e_fm2_cb_mount_ok, _e_fm2_cb_mount_fail, _e_fm2_cb_unmount_ok, NULL, obj); } @@ -2914,7 +2914,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Storage *s; s = _e_fm_shared_codec_storage_decode(e->data, e->size); - if (s) e_fm2_dbus_storage_add(s); + if (s) e_fm2_device_storage_add(s); } break; @@ -2925,8 +2925,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Storage *s; udi = e->data; - s = e_fm2_dbus_storage_find(udi); - if (s) e_fm2_dbus_storage_del(s); + s = e_fm2_device_storage_find(udi); + if (s) e_fm2_device_storage_del(s); } break; @@ -2938,8 +2938,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) v = _e_fm_shared_codec_volume_decode(e->data, e->size); if (v) { - e_fm2_dbus_volume_add(v); - if (e_config->dbus_auto_mount && !v->mounted && !v->first_time) + e_fm2_device_volume_add(v); + if (e_config->device_auto_mount && !v->mounted && !v->first_time) _e_fm2_client_mount(v->udi, v->mount_point); v->first_time = 0; } @@ -2953,8 +2953,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Volume *v; udi = e->data; - v = e_fm2_dbus_volume_find(udi); - if (v) e_fm2_dbus_volume_del(v); + v = e_fm2_device_volume_find(udi); + if (v) e_fm2_device_volume_del(v); } break; @@ -2966,12 +2966,12 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) udi = e->data; mountpoint = udi + strlen(udi) + 1; - v = e_fm2_dbus_volume_find(udi); + v = e_fm2_device_volume_find(udi); if (v) { - e_fm2_dbus_mount_add(v, mountpoint); + e_fm2_device_mount_add(v, mountpoint); _e_fm2_volume_icon_update(v); - if (e_config->dbus_auto_open && !eina_list_count(v->mounts)) + if (e_config->device_auto_open && !eina_list_count(v->mounts)) { E_Action *a; Eina_List *m; @@ -2992,10 +2992,10 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) char *udi; udi = e->data; - v = e_fm2_dbus_volume_find(udi); + v = e_fm2_device_volume_find(udi); if (v) { - e_fm2_dbus_mount_del(v); + e_fm2_device_mount_del(v); _e_fm2_volume_icon_update(v); } } @@ -3011,11 +3011,11 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) char *udi; udi = e->data; - v = e_fm2_dbus_volume_find(udi); + v = e_fm2_device_volume_find(udi); if (v) { - _e_fm_dbus_error_dialog(_("Mount Error"), _("Can't mount device"), e->data); - e_fm2_dbus_mount_fail(v); + _e_fm_device_error_dialog(_("Mount Error"), _("Can't mount device"), e->data); + e_fm2_device_mount_fail(v); } } break; @@ -3027,11 +3027,11 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) char *udi; udi = e->data; - v = e_fm2_dbus_volume_find(udi); + v = e_fm2_device_volume_find(udi); if (v) { - _e_fm_dbus_error_dialog(_("Unmount Error"), _("Can't unmount device"), e->data); - e_fm2_dbus_unmount_fail(v); + _e_fm_device_error_dialog(_("Unmount Error"), _("Can't unmount device"), e->data); + e_fm2_device_unmount_fail(v); } } break; @@ -3043,9 +3043,9 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) char *udi; udi = e->data; - v = e_fm2_dbus_volume_find(udi); + v = e_fm2_device_volume_find(udi); if (v) - _e_fm_dbus_error_dialog(_("Eject Error"), _("Can't eject device"), e->data); + _e_fm_device_error_dialog(_("Eject Error"), _("Can't eject device"), e->data); } break; @@ -3221,11 +3221,11 @@ _e_fm2_dev_path_map(const char *dev, const char *path) { E_Volume *v; - v = e_fm2_dbus_volume_find(dev + strlen("removable:")); + v = e_fm2_device_volume_find(dev + strlen("removable:")); if (v) { if (!v->mount_point) - v->mount_point = e_fm2_dbus_volume_mountpoint_get(v);; + v->mount_point = e_fm2_device_volume_mountpoint_get(v);; if (PRT("%s/%s", v->mount_point, path) >= sizeof(buf)) return NULL; } @@ -4915,8 +4915,8 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic) else if (!strcmp(type, "Removable")) { ic->info.removable = EINA_TRUE; - if ((!e_fm2_dbus_storage_find(ic->info.link)) && - (!e_fm2_dbus_volume_find(ic->info.link))) + if ((!e_fm2_device_storage_find(ic->info.link)) && + (!e_fm2_device_volume_find(ic->info.link))) { _e_fm2_live_file_del(ic->sd->obj, ic->info.file); efreet_desktop_free(desktop); @@ -7536,7 +7536,7 @@ _e_fm2_smart_del(Evas_Object *obj) sd->dev = sd->path = sd->realpath = NULL; if (sd->mount) { - e_fm2_dbus_unmount(sd->mount); + e_fm2_device_unmount(sd->mount); sd->mount = NULL; } if (sd->config) _e_fm2_config_free(sd->config); @@ -8052,7 +8052,7 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp) { E_Volume *v; - v = e_fm2_dbus_volume_find(ic->info.link); + v = e_fm2_device_volume_find(ic->info.link); if (v) { mi = e_menu_item_new(mn); @@ -9170,7 +9170,7 @@ _e_fm_error_ignore_all_cb(void *data __UNUSED__, E_Dialog *dialog) } static void -_e_fm_dbus_error_dialog(const char *title, const char *msg, const char *pstr) +_e_fm_device_error_dialog(const char *title, const char *msg, const char *pstr) { E_Manager *man; E_Container *con; @@ -9183,7 +9183,7 @@ _e_fm_dbus_error_dialog(const char *title, const char *msg, const char *pstr) con = e_container_current_get(man); if (!con) return; - dialog = e_dialog_new(con, "E", "_fm_dbus_error_dialog"); + dialog = e_dialog_new(con, "E", "_fm_device_error_dialog"); e_dialog_title_set(dialog, title); e_dialog_icon_set(dialog, "drive-harddisk", 64); e_dialog_button_add(dialog, _("OK"), NULL, NULL, NULL); @@ -9742,7 +9742,7 @@ _e_fm2_volume_mount(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__ v = data; if (!v) return; - mp = e_fm2_dbus_volume_mountpoint_get(v); + mp = e_fm2_device_volume_mountpoint_get(v); _e_fm2_client_mount(v->udi, mp); eina_stringshare_del(mp); } @@ -9827,7 +9827,7 @@ _e_fm2_icon_removable_update(E_Fm2_Icon *ic) E_Volume *v; if (!ic) return; - v = e_fm2_dbus_volume_find(ic->info.link); + v = e_fm2_device_volume_find(ic->info.link); _update_volume_icon(v, ic); } diff --git a/src/bin/e_fm/Makefile.am b/src/bin/e_fm/Makefile.am index 50199d648..a52d23043 100644 --- a/src/bin/e_fm/Makefile.am +++ b/src/bin/e_fm/Makefile.am @@ -25,7 +25,7 @@ e_fm_main.c \ e_fm_main_dbus.c \ e_fm_ipc.c \ ../e_fm_shared_codec.c \ -../e_fm_shared_dbus.c \ +../e_fm_shared_device.c \ ../e_user.c \ ../e_sha1.c diff --git a/src/bin/e_fm/e_fm_main.c b/src/bin/e_fm/e_fm_main.c index 9a0657ea7..304f0833a 100644 --- a/src/bin/e_fm/e_fm_main.c +++ b/src/bin/e_fm/e_fm_main.c @@ -1,4 +1,6 @@ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_ALLOCA_H # include @@ -55,15 +57,13 @@ void *alloca (size_t); /* if using ehal, functions will point to _e_fm_main_dbus_X * if using eeze, functions will point to _e_fm_main_eeze_X */ +#include "e_fm_shared_device.h" #ifndef HAVE_EEZE_MOUNT #include "e_fm_main_dbus.h" -#include "e_fm_shared_dbus.h" #define _E_FM(FUNC) _e_fm_main_dbus_##FUNC -#define _E_FM_SHARED(FUNC) _e_fm_shared_dbus_##FUNC #else #include "e_fm_main_eeze.h" #define _E_FM(FUNC) _e_fm_main_eeze_##FUNC -#define _E_FM_SHARED(FUNC) _e_fm_shared_eeze_##FUNC #endif /* FIXME: things to add to the slave enlightenment_fm process and ipc to e: @@ -201,11 +201,11 @@ e_storage_find(const char *udi) void _e_storage_free(E_Storage *s) { - _E_FM_SHARED(storage_free)(s); + _e_fm_shared_device_storage_free(s); } void _e_volume_free(E_Volume *v) { - _E_FM_SHARED(volume_free)(v); + _e_fm_shared_device_volume_free(v); } diff --git a/src/bin/e_fm/e_fm_main_dbus.c b/src/bin/e_fm/e_fm_main_dbus.c index f3dfd3b51..5903ae993 100644 --- a/src/bin/e_fm/e_fm_main_dbus.c +++ b/src/bin/e_fm/e_fm_main_dbus.c @@ -1,4 +1,6 @@ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_ALLOCA_H # include @@ -50,9 +52,9 @@ void *alloca (size_t); #include "e_fm_main_dbus.h" #include "e_fm_shared_codec.h" -#include "e_fm_shared_dbus.h" +#include "e_fm_shared_device.h" #include "e_fm_ipc.h" -#include "e_fm_dbus.h" +#include "e_fm_device.h" static E_DBus_Signal_Handler *_hal_poll = NULL; static E_DBus_Connection *_e_fm_main_dbus_conn = NULL; @@ -841,7 +843,7 @@ _e_fm_main_dbus_volume_del(const char *udi) 0, 0, 0, v->udi, eina_stringshare_strlen(v->udi) + 1); } _e_vols = eina_list_remove(_e_vols, v); - _e_fm_shared_dbus_volume_free(v); + _e_fm_shared_device_volume_free(v); } E_Volume * @@ -987,7 +989,7 @@ _e_fm_main_dbus_storage_del(const char *udi) 0, 0, 0, s->udi, strlen(s->udi) + 1); } _e_stores = eina_list_remove(_e_stores, s); - _e_fm_shared_dbus_storage_free(s); + _e_fm_shared_device_storage_free(s); } E_Storage * diff --git a/src/bin/e_fm_dbus.c b/src/bin/e_fm_dbus.c deleted file mode 100644 index 9e3c07440..000000000 --- a/src/bin/e_fm_dbus.c +++ /dev/null @@ -1,664 +0,0 @@ -#include "e_fm_dbus.h" -#include "e_fm_shared_codec.h" -#include "e_fm_shared_dbus.h" - -static void _e_fm2_volume_write(E_Volume *v) EINA_ARG_NONNULL(1); -static void _e_fm2_volume_erase(E_Volume *v) EINA_ARG_NONNULL(1); -static void _e_fm2_dbus_mount_free(E_Fm2_Mount *m); EINA_ARG_NONNULL(1); -static void _e_fm2_dbus_mount_ok(E_Fm2_Mount *m) EINA_ARG_NONNULL(1); -static void _e_fm2_dbus_mount_fail(E_Fm2_Mount *m) EINA_ARG_NONNULL(1); -static void _e_fm2_dbus_unmount_ok(E_Fm2_Mount *m) EINA_ARG_NONNULL(1); -static void _e_fm2_dbus_unmount_fail(E_Fm2_Mount *m) EINA_ARG_NONNULL(1); - -static Eina_List *_e_stores = NULL; -static Eina_List *_e_vols = NULL; - -EAPI void -e_fm2_dbus_storage_add(E_Storage *s) -{ - if (e_fm2_dbus_storage_find(s->udi)) return; - - s->validated = EINA_TRUE; - _e_stores = eina_list_append(_e_stores, s); -/* - printf("STO+\n" - " udi: %s\n" - " bus: %s\n" - " drive_type: %s\n" - " model: %s\n" - " vendor: %s\n" - " serial: %s\n" - " removable: %i\n" - " media_available: %i\n" - " media_size: %lli\n" - " requires_eject: %i\n" - " hotpluggable: %i\n" - " media_check_enabled: %i\n" - " icon.drive: %s\n" - " icon.volume: %s\n\n" - , - s->udi, - s->bus, - s->drive_type, - s->model, - s->vendor, - s->serial, - s->removable, - s->media_available, - s->media_size, - s->requires_eject, - s->hotpluggable, - s->media_check_enabled, - s->icon.drive, - s->icon.volume); - */ - if ((s->removable == 0) && - (s->media_available == 0) && - (s->media_size == 0) && - (s->requires_eject == 0) && - (s->hotpluggable == 0) && - (s->media_check_enabled == 0)) - { -// printf(" Ignore this storage\n"); - } - else - { - s->trackable = EINA_TRUE; - } -} - -EAPI void -e_fm2_dbus_storage_del(E_Storage *s) -{ -// printf("STO- %s\n", s->udi); - _e_stores = eina_list_remove(_e_stores, s); - _e_fm_shared_dbus_storage_free(s); -} - -EAPI E_Storage * -e_fm2_dbus_storage_find(const char *udi) -{ - Eina_List *l; - E_Storage *s; - - if (!udi) return NULL; - EINA_LIST_FOREACH(_e_stores, l, s) - { - if (!strcmp(udi, s->udi)) return s; - } - return NULL; -} - -#define TEBIBYTE_SIZE 1099511627776LL -#define GIBIBYTE_SIZE 1073741824 -#define MEBIBYTE_SIZE 1048576 -#define KIBIBYTE_SIZE 1024 - -EAPI void -e_fm2_dbus_volume_add(E_Volume *v) -{ - E_Storage *s; - - if (e_fm2_dbus_volume_find(v->udi)) return; - - v->validated = EINA_TRUE; - _e_vols = eina_list_append(_e_vols, v); -/* - printf("VOL+\n" - " udi: %s\n" - " uuid: %s\n" - " fstype: %s\n" - " size: %llu\n" - " label: %s\n" - " partition: %d\n" - " partition_number: %d\n" - " partition_label: %s\n" - " mounted: %d\n" - " mount_point: %s\n" - " parent: %s\n" - , - v->udi, - v->uuid, - v->fstype, - v->size, - v->label, - v->partition, - v->partition_number, - v->partition ? v->partition_label : "(not a partition)", - v->mounted, - v->mount_point, - v->parent); - */ - /* Check mount point */ - if ((!v->mount_point) || (v->mount_point[0] == 0)) - { - if (v->mount_point) eina_stringshare_del(v->mount_point); - v->mount_point = NULL; - v->mount_point = e_fm2_dbus_volume_mountpoint_get(v); - if ((!v->mount_point) || (v->mount_point[0] == 0)) - { - char buf[PATH_MAX]; - const char *id; - - if (v->mount_point) eina_stringshare_del(v->mount_point); - v->mount_point = NULL; - id = "disk"; - if ((v->uuid) && (v->uuid[0])) id = v->uuid; - if (ecore_file_is_dir("/media")) - snprintf(buf, sizeof(buf), "/media/%s", id); - else if (ecore_file_is_dir("/mnt")) - snprintf(buf, sizeof(buf), "/mnt/%s", id); - else if (ecore_file_is_dir("/tmp")) - snprintf(buf, sizeof(buf), "/tmp/%s", id); - else - buf[0] = 0; - v->mount_point = eina_stringshare_add(buf); - } - } - - /* Search parent storage */ - if ((s = e_fm2_dbus_storage_find(v->parent))) - { - v->storage = s; - s->volumes = eina_list_append(s->volumes, v); - } - - if (v->storage) - { - char label[1024] = {0}; - char size[256] = {0}; - const char *icon = NULL; - unsigned long long sz; - - /* Compute the size in a readable form */ - if (v->size) - { - if ((sz = (v->size / TEBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu TiB"), sz); - else if ((sz = (v->size / GIBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu GiB"), sz); - else if ((sz = (v->size / MEBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu MiB"), sz); - else if ((sz = (v->size / KIBIBYTE_SIZE)) > 0) - snprintf(size, sizeof(size) - 1, _("%llu KiB"), sz); - else - snprintf(size, sizeof(size) - 1, _("%llu B"), v->size); - } - - /* Choose the label */ - if ((v->label) && (v->label[0])) - {} - else if ((v->partition_label) && (v->partition_label[0])) - snprintf(label, sizeof(label) - 1, "%s", v->partition_label); - else if (((v->storage->vendor) && (v->storage->vendor[0])) && - ((v->storage->model) && (v->storage->model[0]))) - { - if (size[0] != '\0') - snprintf(label, sizeof(label) - 1, "%s %s - %s", v->storage->vendor, v->storage->model, size); - else - snprintf(label, sizeof(label) - 1, "%s %s", v->storage->vendor, v->storage->model); - } - else if ((v->storage->model) && (v->storage->model[0])) - { - if (size[0] != '\0') - snprintf(label, sizeof(label) - 1, "%s - %s", v->storage->model, size); - else - snprintf(label, sizeof(label) - 1, "%s", v->storage->model); - } - else if ((v->storage->vendor) && (v->storage->vendor[0])) - { - if (size[0] != '\0') - snprintf(label, sizeof(label) - 1, "%s - %s", v->storage->vendor, size); - else - snprintf(label, sizeof(label) - 1, "%s", v->storage->vendor); - } - else - snprintf(label, sizeof(label), _("Unknown Volume")); - - if (label[0]) - { - if (v->label) eina_stringshare_del(v->label); - v->label = eina_stringshare_add(label); - } - - /* Choose the icon */ - /* http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html */ - if (v->storage->icon.volume) - icon = v->storage->icon.volume; - else - { - if (!strcmp(v->storage->drive_type, "disk")) - { - if (v->storage->removable == 0) - icon = "drive-harddisk"; - else - icon = "drive-removable-media"; - } - else if (!strcmp(v->storage->drive_type, "cdrom")) - icon = "drive-optical"; - else if (!strcmp(v->storage->drive_type, "floppy")) - icon = "media-floppy"; - else if (!strcmp(v->storage->drive_type, "tape")) - icon = "media-tape"; - else if (!strcmp(v->storage->drive_type, "compact_flash") - || !strcmp(v->storage->drive_type, "memory_stick") - || !strcmp(v->storage->drive_type, "smart_media") - || !strcmp(v->storage->drive_type, "sd_mmc")) - icon = "media-flash"; - } - if (icon) - { - if (v->icon) eina_stringshare_del(v->icon); - v->icon = eina_stringshare_add(icon); - } - - if ((!v->mount_point) || - (strcmp(v->mount_point, "/") && - strcmp(v->mount_point, "/home") && - strcmp(v->mount_point, "/tmp"))) - _e_fm2_volume_write(v); - } -} - -EAPI void -e_fm2_dbus_volume_del(E_Volume *v) -{ - E_Fm2_Mount *m; - -// printf("VOL- %s\n", v->udi); - _e_vols = eina_list_remove(_e_vols, v); - _e_fm2_volume_erase(v); - if (v->storage) - { - v->storage->volumes = eina_list_remove(v->storage->volumes, v); - v->storage = NULL; - } - EINA_LIST_FREE(v->mounts, m) - { - _e_fm2_dbus_unmount_ok(m); - _e_fm2_dbus_mount_free(m); - } - _e_fm_shared_dbus_volume_free(v); -} - -static void -_e_fm2_volume_write(E_Volume *v) -{ - char buf[PATH_MAX], buf2[PATH_MAX]; - FILE *f; - const char *id; - - if (!v->storage) return; - id = ecore_file_file_get(v->storage->udi); -// printf("vol write %s\n", id); - e_user_dir_snprintf(buf, sizeof(buf), "fileman/favorites/|%s_%d.desktop", - id, v->partition_number); - - f = fopen(buf, "w"); - if (f) - { - fprintf(f, - "[Desktop Entry]\n" - "Encoding=UTF-8\n" - "Type=Link\n" - "X-Enlightenment-Type=Removable\n" - "X-Enlightenment-Removable-State=Full\n" - "Name=%s\n" - "Icon=%s\n" - "Comment=%s\n" - "URL=file:/%s\n" - , - v->label, - v->icon, - _("Removable Device"), - v->udi); - fclose(f); - - if (e_config->dbus_desktop) - { - e_user_homedir_snprintf(buf2, sizeof(buf2), - "%s/|%s_%d.desktop", - _("Desktop"), id, v->partition_number); - ecore_file_symlink(buf, buf2); - } - - /* FIXME: manipulate icon directly */ - _e_fm2_file_force_update(buf); - //_e_fm2_file_force_update(buf2); - } -} - -#undef TEBIBYTE_SIZE -#undef GIBIBYTE_SIZE -#undef MEBIBYTE_SIZE -#undef KIBIBYTE_SIZE - -static void -_e_fm2_volume_erase(E_Volume *v) -{ - char buf[PATH_MAX] = {0}; - const char *id; - - if (!v->storage) return; - id = ecore_file_file_get(v->storage->udi); - e_user_homedir_snprintf(buf, sizeof(buf), "%s/|%s_%d.desktop", - _("Desktop"), id, v->partition_number); - ecore_file_unlink(buf); - _e_fm2_file_force_update(buf); - - if (e_config->dbus_desktop) - { - e_user_dir_snprintf(buf, sizeof(buf), - "fileman/favorites/|%s_%d.desktop", - id, v->partition_number); - ecore_file_unlink(buf); - _e_fm2_file_force_update(buf); - } -} - -EAPI E_Volume * -e_fm2_dbus_volume_find(const char *udi) -{ - Eina_List *l; - E_Volume *v; - - if (!udi) return NULL; - - EINA_LIST_FOREACH(_e_vols, l, v) - { - if (!v->udi) continue; - if (!strcmp(udi, v->udi)) return v; - } - - return NULL; -} - -EAPI const char * -e_fm2_dbus_volume_mountpoint_get(E_Volume *v) -{ - char buf[PATH_MAX] = {0}; - - if (!v) return NULL; - if (v->mount_point) - { -// printf("GET MOUNTPOINT = %s\n", v->mount_point); - return eina_stringshare_add(v->mount_point); - } - - if (v->label && v->label[0] != '\0') - snprintf(buf, sizeof(buf) - 1, "/media/%s", v->label); - else if (v->uuid && v->uuid[0] != '\0') - snprintf(buf, sizeof(buf) - 1, "/media/%s", v->uuid); - else if ((v->storage) && (v->storage->serial) && v->storage->serial[0] != '\0') - snprintf(buf, sizeof(buf) - 1, "/media/%s", v->storage->serial); - else - { - static int mount_count = 1; - snprintf(buf, sizeof(buf) - 1, "/media/unknown-%i", mount_count++); - } -// printf("GET MOUNTPOINT = %s\n", buf); - return eina_stringshare_add(buf); -} - -EAPI void -e_fm2_dbus_mount_add(E_Volume *v, const char *mountpoint) -{ - Eina_List *l; - E_Fm2_Mount *m; - - v->mounted = EINA_TRUE; - if (mountpoint && (*mountpoint != 0)) - { - if (v->mount_point) - eina_stringshare_del(v->mount_point); - v->mount_point = eina_stringshare_add(mountpoint); - } - - EINA_LIST_FOREACH(v->mounts, l, m) - _e_fm2_dbus_mount_ok(m); - -// printf("MOUNT %s %s\n", v->udi, v->mount_point); -} - -EAPI void -e_fm2_dbus_mount_del(E_Volume *v) -{ - E_Fm2_Mount *m; - - v->mounted = EINA_FALSE; - if (v->mount_point) - { - eina_stringshare_del(v->mount_point); - v->mount_point = NULL; - } - - EINA_LIST_FREE(v->mounts, m) - { - _e_fm2_dbus_unmount_ok(m); - _e_fm2_dbus_mount_free(m); - } -} - -EAPI void -_e_fm2_dbus_mount_free(E_Fm2_Mount *m) -{ - if (!m) return; - - if (m->udi) eina_stringshare_del(m->udi); - if (m->mount_point) eina_stringshare_del(m->mount_point); - - free(m); -} - -EAPI E_Fm2_Mount * -e_fm2_dbus_mount_find(const char *path) -{ - Eina_List *l; - E_Volume *v; - - EINA_LIST_FOREACH(_e_vols, l, v) - { - if (v->mounted - && v->mount_point - && !strncmp(path, v->mount_point, strlen(v->mount_point)) - && v->mounts) - return eina_list_data_get(v->mounts); - } - return NULL; -} - -EAPI E_Fm2_Mount * -e_fm2_dbus_mount(E_Volume *v, - Ecore_Cb mount_ok, Ecore_Cb mount_fail, - Ecore_Cb unmount_ok, Ecore_Cb unmount_fail, - void *data) -{ - E_Fm2_Mount *m; - - if (!v) return NULL; - - m = calloc(1, sizeof(E_Fm2_Mount)); - if (!m) return NULL; - m->udi = eina_stringshare_add(v->udi); - m->mount_ok = mount_ok; - m->mount_fail = mount_fail; - m->unmount_ok = unmount_ok; - m->unmount_fail = unmount_fail; - m->data = data; - m->volume = v; - m->mounted = v->mounted; - - v->mounts = eina_list_prepend(v->mounts, m); - -// printf("BEGIN MOUNT %p '%s'\n", m, v->mount_point); - - if (!v->mounted) - { - v->auto_unmount = EINA_TRUE; - _e_fm2_client_mount(v->udi, v->mount_point); - } - else - { - v->auto_unmount = EINA_FALSE; - m->mount_point = eina_stringshare_add(v->mount_point); - } - - return m; -} - -EAPI void -e_fm2_dbus_mount_fail(E_Volume *v) -{ - E_Fm2_Mount *m; - - v->mounted = EINA_FALSE; - if (v->mount_point) - { - eina_stringshare_del(v->mount_point); - v->mount_point = NULL; - } - - EINA_LIST_FREE(v->mounts, m) - { - _e_fm2_dbus_mount_fail(m); - _e_fm2_dbus_mount_free(m); - } -} - -EAPI void -e_fm2_dbus_unmount(E_Fm2_Mount *m) -{ - E_Volume *v; - - if (!(v = m->volume)) return; - v->mounts = eina_list_remove(v->mounts, m); - _e_fm2_dbus_mount_free(m); - - if (v->auto_unmount && v->mounted && !eina_list_count(v->mounts)) - _e_fm2_client_unmount(v->udi); -} - -EAPI void -e_fm2_dbus_unmount_fail(E_Volume *v) -{ - Eina_List *l; - E_Fm2_Mount *m; - - v->mounted = EINA_TRUE; - - EINA_LIST_FOREACH(v->mounts, l, m) - _e_fm2_dbus_unmount_fail(m); -} - -static void -_e_fm2_dbus_mount_ok(E_Fm2_Mount *m) -{ - if (m->mounted) return; - m->mounted = EINA_TRUE; - if (m->volume) - m->mount_point = eina_stringshare_add(m->volume->mount_point); - if (m->mount_ok) - m->mount_ok(m->data); -// printf("MOUNT OK '%s'\n", m->mount_point); -} - -static void -_e_fm2_dbus_mount_fail(E_Fm2_Mount *m) -{ - m->mounted = EINA_FALSE; - if (m->mount_point) - { - eina_stringshare_del(m->mount_point); - m->mount_point = NULL; - } - if (m->mount_fail) - m->mount_fail(m->data); -} - -static void -_e_fm2_dbus_unmount_ok(E_Fm2_Mount *m) -{ - if (!m->mounted) return; - m->mounted = EINA_FALSE; - if (m->mount_point) - { - eina_stringshare_del(m->mount_point); - m->mount_point = NULL; - } - if (m->unmount_ok) - m->unmount_ok(m->data); -} - -static void -_e_fm2_dbus_unmount_fail(E_Fm2_Mount *m) -{ - if (m->mounted) return; - m->mounted = EINA_TRUE; - if (m->unmount_fail) - m->unmount_fail(m->data); -} - -EAPI void -e_fm2_dbus_show_desktop_icons(void) -{ - Eina_List *l; - E_Volume *v; - char buf[PATH_MAX] = {0}; - char buf2[PATH_MAX] = {0}; - const char *id; - - EINA_LIST_FOREACH(_e_vols, l, v) - { - if (!v) continue; - if (!v->storage) continue; - - id = ecore_file_file_get(v->storage->udi); - - e_user_dir_snprintf(buf, sizeof(buf), - "fileman/favorites/|%s_%d.desktop", - id, v->partition_number); - - e_user_homedir_snprintf(buf2, sizeof(buf2), - "%s/|%s_%d.desktop", - _("Desktop"), id, v->partition_number); - - if (ecore_file_exists(buf) && !ecore_file_exists(buf2)) - { - ecore_file_symlink(buf, buf2); - _e_fm2_file_force_update(buf2); - } - } -} - -EAPI void -e_fm2_dbus_hide_desktop_icons(void) -{ - Eina_List *l; - E_Volume *v; - char buf[PATH_MAX] = {0}; - const char *id; - - EINA_LIST_FOREACH(_e_vols, l, v) - { - if (!v) continue; - if (!v->storage) continue; - - id = ecore_file_file_get(v->storage->udi); - - e_user_homedir_snprintf(buf, sizeof(buf), - "%s/|%s_%d.desktop", - _("Desktop"), id, v->partition_number); - - if (ecore_file_exists(buf)) - { - ecore_file_unlink(buf); - _e_fm2_file_force_update(buf); - } - } -} - -EAPI Eina_List* -e_fm2_dbus_volume_list_get(void) -{ - return _e_vols; -} diff --git a/src/bin/e_fm_dbus.h b/src/bin/e_fm_dbus.h deleted file mode 100644 index 373f655a5..000000000 --- a/src/bin/e_fm_dbus.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef E_FM_DBUS_H -#define E_FM_DBUS_H - -#include "e.h" -#include "e_fm.h" - -EAPI void e_fm2_dbus_storage_add(E_Storage *s); -EAPI void e_fm2_dbus_storage_del(E_Storage *s); -EAPI E_Storage *e_fm2_dbus_storage_find(const char *udi); - -EAPI void e_fm2_dbus_volume_add(E_Volume *s); -EAPI void e_fm2_dbus_volume_del(E_Volume *s); -EAPI E_Volume *e_fm2_dbus_volume_find(const char *udi); -EAPI const char *e_fm2_dbus_volume_mountpoint_get(E_Volume *v); - -EAPI void e_fm2_dbus_mount_add(E_Volume *v, const char *mountpoint); -EAPI void e_fm2_dbus_mount_del(E_Volume *v); -EAPI E_Fm2_Mount *e_fm2_dbus_mount_find(const char *path); -EAPI E_Fm2_Mount *e_fm2_dbus_mount(E_Volume *v, - Ecore_Cb mount_ok, Ecore_Cb mount_fail, - Ecore_Cb unmount_ok, Ecore_Cb unmount_fail, - void *data); -EAPI void e_fm2_dbus_mount_fail(E_Volume *v); -EAPI void e_fm2_dbus_unmount(E_Fm2_Mount *m); -EAPI void e_fm2_dbus_unmount_fail(E_Volume *v); - -EAPI void e_fm2_dbus_show_desktop_icons(void); -EAPI void e_fm2_dbus_hide_desktop_icons(void); - -EAPI Eina_List *e_fm2_dbus_volume_list_get(void); - -#endif diff --git a/src/bin/e_fm_shared_dbus.c b/src/bin/e_fm_shared_dbus.c deleted file mode 100644 index ee0e2ffaf..000000000 --- a/src/bin/e_fm_shared_dbus.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "e_fm_shared_types.h" -#include "e_fm_shared_dbus.h" - -void -_e_fm_shared_dbus_storage_free(E_Storage *s) -{ - E_Volume *v; - EINA_LIST_FREE(s->volumes, v) - { - v->storage = NULL; - _e_fm_shared_dbus_volume_free(v); - } - if (s->udi) eina_stringshare_del(s->udi); - if (s->bus) eina_stringshare_del(s->bus); - if (s->drive_type) eina_stringshare_del(s->drive_type); - if (s->model) eina_stringshare_del(s->model); - if (s->vendor) eina_stringshare_del(s->vendor); - if (s->serial) eina_stringshare_del(s->serial); - if (s->icon.drive) eina_stringshare_del(s->icon.drive); - if (s->icon.volume) eina_stringshare_del(s->icon.volume); - free(s); -} - - -void -_e_fm_shared_dbus_volume_free(E_Volume *v) -{ - if (v->storage) - { - v->storage->volumes = eina_list_remove(v->storage->volumes, v); - v->storage = NULL; - } - if (v->udi) eina_stringshare_del(v->udi); - if (v->uuid) eina_stringshare_del(v->uuid); - if (v->label) eina_stringshare_del(v->label); - if (v->icon) eina_stringshare_del(v->icon); - if (v->fstype) eina_stringshare_del(v->fstype); - if (v->partition_label) eina_stringshare_del(v->partition_label); - if (v->mount_point) eina_stringshare_del(v->mount_point); - if (v->parent) eina_stringshare_del(v->parent); - free(v); -} diff --git a/src/bin/e_fm_shared_dbus.h b/src/bin/e_fm_shared_dbus.h deleted file mode 100644 index e056bee9f..000000000 --- a/src/bin/e_fm_shared_dbus.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef E_FM_SHARED_DBUS_H -#define E_FM_SHARED_DBUS_H - -#include "e_fm_shared_types.h" - -void _e_fm_shared_dbus_storage_free(E_Storage *s); -void _e_fm_shared_dbus_volume_free(E_Volume *v); - -#endif diff --git a/src/modules/fileman/e_mod_config.c b/src/modules/fileman/e_mod_config.c index b8df1ecbe..d0f897943 100644 --- a/src/modules/fileman/e_mod_config.c +++ b/src/modules/fileman/e_mod_config.c @@ -160,9 +160,9 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) e_config->dbus_desktop = cfdata->dbus.desktop; if(e_config->dbus_desktop) - e_fm2_dbus_show_desktop_icons(); + e_fm2_device_show_desktop_icons(); else - e_fm2_dbus_hide_desktop_icons(); + e_fm2_device_hide_desktop_icons(); e_config->dbus_auto_mount = cfdata->dbus.auto_mount; e_config->dbus_auto_open = cfdata->dbus.auto_open; diff --git a/src/modules/fileman/e_mod_main.c b/src/modules/fileman/e_mod_main.c index 2a075eac5..9af8b4dca 100644 --- a/src/modules/fileman/e_mod_main.c +++ b/src/modules/fileman/e_mod_main.c @@ -348,7 +348,7 @@ _e_mod_menu_generate(void *data __UNUSED__, E_Menu *m) /* Volumes */ Eina_Bool volumes_visible = 0; - EINA_LIST_FOREACH(e_fm2_dbus_volume_list_get(), l, vol) + EINA_LIST_FOREACH(e_fm2_device_volume_list_get(), l, vol) { if (vol->mount_point && !strcmp(vol->mount_point, "/")) continue;