From 91b0dbc6fc186ff41958211ca20eafa20ee9ad8f Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 22 Oct 2007 07:38:25 +0000 Subject: [PATCH] lok's patches for hal support. works a bit better now - removable devs are mounted as the user and it monitors other mount work by other apps etc. etc. some fixes to remove segv's and at least make mt cd/dvd drive recognised asa storage device, but it seesm as of now mounting of cd/dvd media doesn't work :( SVN revision: 32141 --- src/bin/Makefile.am | 2 + src/bin/e_fm.c | 628 ++++++----------------------------- src/bin/e_fm.h | 8 + src/bin/e_fm_main.c | 190 ++++++++--- src/bin/e_fm_shared.h | 28 +- src/modules/fileman/e_fwin.c | 71 ++-- 6 files changed, 329 insertions(+), 598 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 83b3b0a23..dda729f2a 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -131,6 +131,7 @@ e_confirm_dialog.h \ e_int_border_prop.h \ e_entry_dialog.h \ e_fm.h \ +e_fm_hal.h \ e_widget_scrollframe.h \ e_sha1.h \ e_widget_fsel.h \ @@ -262,6 +263,7 @@ e_confirm_dialog.c \ e_int_border_prop.c \ e_entry_dialog.c \ e_fm.c \ +e_fm_hal.c \ e_widget_scrollframe.c \ e_sha1.c \ e_widget_fsel.c \ diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 3c2e5400d..b3ecf469e 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -2,10 +2,7 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "e.h" - -#define E_FM_SHARED_DATATYPES -#include "e_fm_shared.h" -#undef E_FM_SHARED_DATATYPES +#include "e_fm_hal.h" #define OVERCLIP 128 @@ -27,7 +24,6 @@ typedef struct _E_Fm2_Region E_Fm2_Region; typedef struct _E_Fm2_Finfo E_Fm2_Finfo; typedef struct _E_Fm2_Action E_Fm2_Action; typedef struct _E_Fm2_Client E_Fm2_Client; -typedef struct _E_Fm2_Mount E_Fm2_Mount; typedef struct _E_Fm2_Uri E_Fm2_Uri; typedef struct _E_Fm2_Context_Menu_Data E_Fm2_Context_Menu_Data; @@ -186,22 +182,6 @@ struct _E_Fm2_Client int req; }; -struct _E_Fm2_Mount -{ - const char *udi; - const char *mount_point; - - Ecore_Timer *timeout; - void (*mount_ok) (void *data); - void (*mount_fail) (void *data); - void (*unmount_ok) (void *data); - void (*unmount_fail) (void *data); - void *data; - - unsigned char mounted : 1; - unsigned char delete_me : 1; -}; - struct _E_Fm2_Uri { const char *hostname; @@ -214,11 +194,6 @@ struct _E_Fm2_Context_Menu_Data E_Fm2_Mime_Handler *handler; }; -static E_Fm2_Mount *_e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (void *data), void (*unmount_ok) (void *data), void (*unmount_fail) (void *data), void *data); -static void _e_fm2_unmount(E_Fm2_Mount *m); -static E_Volume *e_volume_find(const char *udi); -static E_Storage *e_storage_find(const char *udi); - static const char *_e_fm2_dev_path_map(const char *dev, const char *path); static void _e_fm2_file_add(Evas_Object *obj, const char *file, int unique, const char *file_rel, int after, E_Fm2_Finfo *finf); static void _e_fm2_file_del(Evas_Object *obj, const char *file); @@ -356,8 +331,6 @@ static void _e_fm2_client_file_mkdir(int id, const char *path, const char *rel, static void _e_fm2_client_file_move(int id, const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h); static void _e_fm2_client_file_symlink(int id, const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h); static void _e_fm2_client_file_copy(int id, const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h); -static void _e_fm2_client_mount(const char *udi, const char *mountpoint); -static void _e_fm2_client_unmount(const char *udi); static void _e_fm2_sel_rect_update(void *data); static inline void _e_fm2_context_menu_append(Evas_Object *obj, const char *path, Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic); static int _e_fm2_context_list_sort(void *data1, void *data2); @@ -369,9 +342,6 @@ static Evas_List *_e_fm2_list_remove = NULL; static int _e_fm2_list_walking = 0; static Evas_List *_e_fm2_client_list = NULL; static int _e_fm2_id = 0; -static Evas_List *_e_stores = NULL; -static Evas_List *_e_vols = NULL; -static Evas_List *_e_fm2_mounts = NULL; static Evas_List *_e_fm2_menu_contexts = NULL; /* contains: @@ -470,7 +440,7 @@ _e_fm2_cb_mount_fail(void *data) if (sd->mount) { printf("UM1\n"); - _e_fm2_unmount(sd->mount); + e_fm2_hal_unmount(sd->mount); sd->mount = NULL; evas_object_smart_callback_call(data, "dir_deleted", NULL); } @@ -480,9 +450,11 @@ EAPI void e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) { E_Fm2_Smart_Data *sd; + Evas_List *l; + const char *realpath; sd = evas_object_smart_data_get(obj); - if (!sd) return; // safety + if (!sd || !path) return; // safety if (!evas_object_type_get(obj)) return; // safety if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety @@ -517,51 +489,86 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) sd->config->theme.fixed = 0; } + realpath = _e_fm2_dev_path_map(dev, path); + /* If the path doesn't exist, popup a dialog */ + if (dev && strncmp(dev, "removable:", 10) + && !ecore_file_exists(realpath)) + { + E_Manager *man; + E_Container *con; + E_Dialog *dialog; + char text[4096 + 256]; + + man = e_manager_current_get(); + if (!man) return; + con = e_container_current_get(man); + if (!con) return; + + dialog = e_dialog_new(con, "E", "_fm_file_unexisting_path_dialog"); + e_dialog_button_add(dialog, _("Close"), NULL, NULL, dialog); + e_dialog_button_focus_num(dialog, 0); + e_dialog_title_set(dialog, _("Unexisting path")); + + snprintf(text, sizeof(text), + _("%s doesn't exists"), + realpath); + + e_dialog_text_set(dialog, text); + e_win_centered_set(dialog->win, 1); + e_dialog_show(dialog); + return; + } + if (sd->realpath) _e_fm2_client_monitor_del(sd->id, sd->realpath); sd->listing = 0; if (sd->dev) evas_stringshare_del(sd->dev); if (sd->path) evas_stringshare_del(sd->path); - if (sd->mount) - { - printf("UM2\n"); - _e_fm2_unmount(sd->mount); - sd->mount = NULL; - } - if (sd->realpath) - { - evas_stringshare_del(sd->realpath); - } + if (sd->realpath) evas_stringshare_del(sd->realpath); sd->dev = sd->path = sd->realpath = NULL; sd->order_file = 0; if (dev) sd->dev = evas_stringshare_add(dev); if (path) sd->path = evas_stringshare_add(path); - sd->realpath = _e_fm2_dev_path_map(sd->dev, sd->path); + sd->realpath = realpath; _e_fm2_queue_free(obj); _e_fm2_regions_free(obj); _e_fm2_icons_free(obj); edje_object_part_text_set(sd->overlay, "e.text.busy_label", ""); - - if ((sd->dev) && (!strncmp(sd->dev, "removable:", 10))) + + /* If the path change from a mountpoint to something else, we fake-unmount */ + if (sd->mount && sd->mount->mount_point + && strncmp(sd->mount->mount_point, sd->realpath, + strlen(sd->mount->mount_point))) { - E_Volume *v; - - v = e_volume_find(sd->dev + strlen("removable:")); - if (v) - { - sd->mount = _e_fm2_mount(v, - _e_fm2_cb_mount_ok, - _e_fm2_cb_mount_fail, - NULL, - NULL, - obj); - printf("BEGIN MOUNT %p %s\n", sd->mount, v->mount_point); - } + printf("UM2\n"); + e_fm2_hal_unmount(sd->mount); + sd->mount = NULL; } - if ((!sd->mount) || (sd->mount->mounted)) + /* If the path is of type removable: we add a new mountpoint */ + if (sd->dev && !sd->mount && !strncmp(sd->dev, "removable:", 10)) + { + E_Volume *v = NULL; + + v = e_fm2_hal_volume_find(sd->dev + strlen("removable:")); + if (v) + sd->mount = e_fm2_hal_mount(v, + _e_fm2_cb_mount_ok, _e_fm2_cb_mount_fail, + NULL, NULL, obj); + } + else if (sd->config->view.open_dirs_in_place == 0) + { + E_Fm2_Mount *m; + m = e_fm2_hal_mount_find(sd->realpath); + if (m) + sd->mount = e_fm2_hal_mount(m->volume, + _e_fm2_cb_mount_ok, _e_fm2_cb_mount_fail, + NULL, NULL, obj); + } + + if (!sd->mount || sd->mount->mounted) { _e_fm2_client_monitor_add(sd->id, sd->realpath); sd->listing = 1; @@ -1375,207 +1382,6 @@ e_fm2_icon_file_info_get(E_Fm2_Icon *ic) return &(ic->info); } -static int _e_fm2_mount_stack = 0; - -static void -_e_fm2_mount_flush(void) -{ - E_Fm2_Mount *m; - Evas_List *l, *dels = NULL; - - if (_e_fm2_mount_stack > 1) return; - for (l = _e_fm2_mounts; l; l = l->next) - { - m = l->data; - if (m->delete_me) dels = evas_list_append(dels, m); - } - while (dels) - { - m = dels->data; - _e_fm2_mounts = evas_list_remove(_e_fm2_mounts, m); - dels = evas_list_remove_list(dels, dels); - evas_stringshare_del(m->udi); - evas_stringshare_del(m->mount_point); - if (m->timeout) ecore_timer_del(m->timeout); - free(m); - } -} - -static void -_e_fm2_mount_del(E_Fm2_Mount *m) -{ - m->delete_me = 1; -} - -static void -_e_fm2_mount_ok(const char *udi) -{ - Evas_List *l; - E_Fm2_Mount *m; - - _e_fm2_mount_stack++; - for (l = _e_fm2_mounts; l; l = l->next) - { - m = l->data; - if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->mount_ok)) - { - m->mounted = 1; - m->mount_ok(m->data); - if (m->timeout) - { - ecore_timer_del(m->timeout); - m->timeout = NULL; - } - } - } - _e_fm2_mount_flush(); - _e_fm2_mount_stack--; -} - -static void -_e_fm2_mount_fail(const char *udi) -{ - Evas_List *l; - E_Fm2_Mount *m; - - _e_fm2_mount_stack++; - for (l = _e_fm2_mounts; l; l = l->next) - { - m = l->data; - if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->mount_fail)) - { - m->mount_fail(m->data); - if (m->timeout) - { - ecore_timer_del(m->timeout); - m->timeout = NULL; - } - } - } - _e_fm2_mount_flush(); - _e_fm2_mount_stack--; -} - -static void -_e_fm2_unmount_ok(const char *udi) -{ - Evas_List *l; - E_Fm2_Mount *m; - - _e_fm2_mount_stack++; - for (l = _e_fm2_mounts; l; l = l->next) - { - m = l->data; - if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->unmount_ok)) - { - m->mounted = 0; - m->unmount_ok(m->data); - if (m->timeout) - { - ecore_timer_del(m->timeout); - m->timeout = NULL; - } - } - } - _e_fm2_mount_flush(); - _e_fm2_mount_stack--; -} - -static void -_e_fm2_unmount_fail(const char *udi) -{ - Evas_List *l; - E_Fm2_Mount *m; - - _e_fm2_mount_stack++; - for (l = _e_fm2_mounts; l; l = l->next) - { - m = l->data; - if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->unmount_fail)) - { - m->unmount_fail(m->data); - if (m->timeout) - { - ecore_timer_del(m->timeout); - m->timeout = NULL; - } - } - } - _e_fm2_mount_flush(); - _e_fm2_mount_stack--; -} - -static int -_e_fm2_cb_mount_timeout(void *data) -{ - E_Fm2_Mount *m; - - m = data; - m->timeout = NULL; - _e_fm2_mount_fail(m->udi); - return 0; -} - -static E_Fm2_Mount * -_e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (void *data), void (*unmount_ok) (void *data), void (*unmount_fail) (void *data), void *data) -{ - E_Fm2_Mount *m, *m2; - Evas_List *l; - int exists = 0; - int mounted = 0; - - m = calloc(1, sizeof(E_Fm2_Mount)); - if (!m) return NULL; - for (l = _e_fm2_mounts; l; l = l->next) - { - m2 = l->data; - if (!strcmp(v->udi, m2->udi)) - { - exists = 1; - mounted = m2->mounted; - break; - } - } - m->udi = evas_stringshare_add(v->udi); - m->mount_point = evas_stringshare_add(v->mount_point); - m->mount_ok = mount_ok; - m->mount_fail = mount_fail; - m->unmount_ok = unmount_ok; - m->unmount_fail = unmount_fail; - m->data = data; - m->mounted = mounted; - if (!exists) - { - m->timeout = ecore_timer_add(10.0, _e_fm2_cb_mount_timeout, m); - _e_fm2_client_mount(m->udi, m->mount_point); - } - _e_fm2_mounts = evas_list_prepend(_e_fm2_mounts, m); - return m; -} - -static void -_e_fm2_unmount(E_Fm2_Mount *m) -{ - E_Fm2_Mount *m2; - Evas_List *l; - int exists = 0; - - _e_fm2_mount_stack++; - for (l = _e_fm2_mounts; l; l = l->next) - { - m2 = l->data; - if (!strcmp(m->udi, m2->udi)) exists++; - } - if (exists == 1) - { - printf("_e_fm2_unmount UM\n"); - _e_fm2_client_unmount(m->udi); - } - _e_fm2_mount_del(m); - _e_fm2_mount_flush(); - _e_fm2_mount_stack--; -} - /* FIXME: track real exe with exe del events etc. */ static int _e_fm2_client_spawning = 0; @@ -1951,7 +1757,7 @@ _e_fm2_client_file_copy(int id, const char *path, const char *dest, const char * } } -static void +EAPI void _e_fm2_client_mount(const char *udi, const char *mountpoint) { E_Fm2_Client *cl; @@ -1981,7 +1787,7 @@ _e_fm2_client_mount(const char *udi, const char *mountpoint) } } -static void +EAPI void _e_fm2_client_unmount(const char *udi) { E_Fm2_Client *cl; @@ -2047,7 +1853,7 @@ _e_fm2_client_monitor_list_end(Evas_Object *obj) _e_fm2_live_process_begin(obj); } -static void +EAPI void _e_fm2_file_force_update(const char *path) { char *dir; @@ -2089,175 +1895,6 @@ _e_fm2_file_force_update(const char *path) free(dir); } -static E_Volume * -e_volume_find(const char *udi) -{ - Evas_List *l; - - for (l = _e_vols; l; l = l->next) - { - E_Volume *v; - - v = l->data; - if (!strcmp(udi, v->udi)) return v; - } - return NULL; -} - -static E_Storage * -e_storage_find(const char *udi) -{ - Evas_List *l; - - for (l = _e_stores; l; l = l->next) - { - E_Storage *s; - - s = l->data; - if (!strcmp(udi, s->udi)) return s; - } - return NULL; -} - -static void -_e_storage_write(E_Storage *s) -{ - char buf[PATH_MAX], buf2[PATH_MAX]; - FILE *f; - const char *id; - - id = ecore_file_file_get(s->udi); - printf("sto write %s\n", id); - snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/|%s.desktop", - e_user_homedir_get(), id); -// ecore_file_unlink(buf); - f = fopen(buf, "w"); - if (f) - { - char label[1024]; - - if ((s->vendor) && (s->model)) - snprintf(label, sizeof(label), "%s %s", s->vendor, s->model); - else if (s->model) - snprintf(label, sizeof(label), "%s", s->model); - else if (s->vendor) - snprintf(label, sizeof(label), "%s", s->vendor); - else - snprintf(label, sizeof(label), _("Unknown Data")); - fprintf(f, - "[Desktop Entry]\n" - "Encoding=UTF-8\n" - "Type=Link\n" - "X-Enlightenment-Type=Removable\n" - "X-Enlightenment-Removable-State=Empty\n" - "Name=%s\n" - "Icon=%s\n" - "Comment=%s\n" - "URL=file:/%s\n" - , - label, - "fileman/hd", /* FIXME different based on state and storage */ - _("Removable Device"), - s->udi); - fclose(f); - snprintf(buf2, sizeof(buf2), "%s/Desktop/|%s.desktop", - e_user_homedir_get(), id); -// ecore_file_unlink(buf2); - ecore_file_symlink(buf, buf2); - /* FIXME: manipulate icon directly */ - _e_fm2_file_force_update(buf); - _e_fm2_file_force_update(buf2); -// efreet_desktop_cache_flush(); - } -} - -static void -_e_storage_erase(E_Storage *s) -{ - char buf[PATH_MAX]; - const char *id; - - id = ecore_file_file_get(s->udi); - snprintf(buf, sizeof(buf), "%s/Desktop/|%s.desktop", - e_user_homedir_get(), id); - ecore_file_unlink(buf); - snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/|%s.desktop", - e_user_homedir_get(), id); - ecore_file_unlink(buf); -} - -static void -_e_volume_write(E_Volume *v) -{ - char buf[PATH_MAX], buf2[PATH_MAX]; - FILE *f; - const char *id; - - id = ecore_file_file_get(v->storage->udi); - printf("vol write %s\n", id); - snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/|%s.desktop", - e_user_homedir_get(), id); -// ecore_file_unlink(buf); - f = fopen(buf, "w"); - if (f) - { - char label[1024]; - - if (v->label) - snprintf(label, sizeof(label), "%s", v->label); - else if (v->partition_label) - snprintf(label, sizeof(label), "%s", v->partition_label); - else if ((v->storage->vendor) && (v->storage->model)) - snprintf(label, sizeof(label), "%s %s", v->storage->vendor, v->storage->model); - else if (v->storage->model) - snprintf(label, sizeof(label), "%s", v->storage->model); - else if (v->storage->vendor) - snprintf(label, sizeof(label), "%s", v->storage->vendor); - else - snprintf(label, sizeof(label), _("Unknown Data")); - 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" - , - label, - "fileman/hd", /* FIXME different based on state and storage */ - _("Removable Device"), - v->udi); - fclose(f); - snprintf(buf2, sizeof(buf2), "%s/Desktop/|%s.desktop", - e_user_homedir_get(), id); -// ecore_file_unlink(buf2); - ecore_file_symlink(buf, buf2); - /* FIXME: manipulate icon directly */ - _e_fm2_file_force_update(buf); - _e_fm2_file_force_update(buf2); -// efreet_desktop_cache_flush(); - } -} - -static void -_e_volume_erase(E_Volume *v) -{ - char buf[PATH_MAX]; - const char *id; - - id = ecore_file_file_get(v->storage->udi); - snprintf(buf, sizeof(buf), "%s/Desktop/|%s.desktop", - e_user_homedir_get(), id); - ecore_file_unlink(buf); - snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/|%s.desktop", - e_user_homedir_get(), id); - ecore_file_unlink(buf); - _e_storage_write(v->storage); -} - EAPI void e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) { @@ -2478,26 +2115,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Storage *s; s = eet_data_descriptor_decode(_e_storage_edd, e->data, e->size); - if (s) - { - s->validated = 1; - _e_stores = evas_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 = 1; - _e_storage_write(s); - } - } + if (s) e_fm2_hal_storage_add(s); } break; case 9:/*storage del*/ @@ -2507,17 +2125,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Storage *s; udi = e->data; - s = e_storage_find(udi); - if (s) - { - printf("STO- %s\n", s->udi); - if (s->trackable) - { - _e_storage_erase(s); - } - _e_stores = evas_list_remove(_e_stores, s); - _e_storage_free(s); - } + s = e_fm2_hal_storage_find(udi); + if (s) e_fm2_hal_storage_del(s); } break; @@ -2527,42 +2136,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Volume *v; v = eet_data_descriptor_decode(_e_volume_edd, e->data, e->size); - if (v) - { - E_Storage *s; - - v->validated = 1; - _e_vols = evas_list_append(_e_vols, v); - printf("VOL+\n udi: %s\n uuid: %s\n fstype: %s\n label: %s\n partition: %d\n partition_label: %s\n mounted: %d\n mount_point: %s\n parent: %s\n", v->udi, v->uuid, v->fstype, v->label, v->partition, v->partition ? v->partition_label : "(not a partition)", v->mounted, v->mount_point, v->parent); - s = e_storage_find(v->parent); - if (!v->mount_point) - { - if (v->uuid) - v->mount_point = strdup(v->uuid); - else if (v->label) - v->mount_point = strdup(v->label); - else if ((v->storage) && (v->storage->serial)) - v->mount_point = strdup(v->storage->serial); - else - { - char buf[256]; - static int mount_count = 0; - - snprintf(buf, sizeof(buf), "unknown-%i\n", mount_count); - mount_count++; - v->mount_point = strdup(buf); - } - } - if (s) - { - v->storage = s; - s->volumes = evas_list_append(s->volumes, v); - } - if ((v->storage) && (v->storage->trackable)) - { - _e_volume_write(v); - } - } + if (v) e_fm2_hal_volume_add(v); } break; case 11:/*volume del*/ @@ -2572,17 +2146,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) E_Volume *v; udi = e->data; - v = e_volume_find(udi); - if (v) - { - printf("VOL- %s\n", v->udi); - if ((v->storage) && (v->storage->trackable)) - { - _e_storage_write(v->storage); - } - _e_vols = evas_list_remove(_e_vols, v); - _e_volume_free(v); - } + v = e_fm2_hal_volume_find(udi); + if (v) e_fm2_hal_volume_del(v); } break; @@ -2594,32 +2159,24 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) udi = e->data; mountpoint = udi + strlen(udi) + 1; - v = e_volume_find(udi); - if (v) - { - v->mounted = 1; - if (v->mount_point) free(v->mount_point); - v->mount_point = strdup(mountpoint); - printf("MOUNT %s %s\n", udi, mountpoint); - } - _e_fm2_mount_ok(udi); + v = e_fm2_hal_volume_find(udi); + if (v) e_fm2_hal_mount_add(v, mountpoint); } break; case 13:/*unmount done*/ if ((e->data) && (e->size > 1)) { E_Volume *v; - char *udi, *mountpoint; + char *udi; udi = e->data; - mountpoint = udi + strlen(udi) + 1; - v = e_volume_find(udi); + v = e_fm2_hal_volume_find(udi); if (v) { v->mounted = 0; - printf("UNMOUNT %s %s\n", udi, mountpoint); + if (v->mount_point) free(v->mount_point); + v->mount_point = NULL; } - _e_fm2_unmount_ok(udi); } break; default: @@ -2709,10 +2266,15 @@ _e_fm2_dev_path_map(const char *dev, const char *path) else if (CMP("removable:*")) { E_Volume *v; - - v = e_volume_find(dev + strlen("removable:")); - if (v) - snprintf(buf, sizeof(buf), "/media/%s", v->mount_point); + char *mountpoint; + + v = e_fm2_hal_volume_find(dev + strlen("removable:")); + if (v) + { + if (!v->mount_point) + v->mount_point = e_fm2_hal_volume_mountpoint_get(v);; + snprintf(buf, sizeof(buf), "%s%s", v->mount_point, path); + } } else if (CMP("dvd") || CMP("dvd-*")) { @@ -4293,8 +3855,8 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic) { ic->info.removable = 1; printf("REMOVABLE %s\n", ic->info.link); - if ((!e_storage_find(ic->info.link)) && - (!e_volume_find(ic->info.link))) + if ((!e_fm2_hal_storage_find(ic->info.link)) && + (!e_fm2_hal_volume_find(ic->info.link))) { printf("REMOVE IT %s\n", ic->info.file); _e_fm2_live_file_del(ic->sd->obj, ic->info.file); @@ -4325,6 +3887,8 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic) ic->info.generic = NULL; ic->info.icon = NULL; ic->info.link = NULL; + //Hack + if (!strncmp(ic->info.file, "|storage_serial_", 16)) ecore_file_unlink(buf); return 0; } @@ -6351,7 +5915,7 @@ _e_fm2_smart_del(Evas_Object *obj) if (sd->mount) { printf("UM3\n"); - _e_fm2_unmount(sd->mount); + e_fm2_hal_unmount(sd->mount); sd->mount = NULL; } if (sd->realpath) diff --git a/src/bin/e_fm.h b/src/bin/e_fm.h index 27bdde923..a29709acc 100644 --- a/src/bin/e_fm.h +++ b/src/bin/e_fm.h @@ -36,6 +36,10 @@ typedef struct _E_Fm2_Config E_Fm2_Config; typedef struct _E_Fm2_Icon E_Fm2_Icon; typedef struct _E_Fm2_Icon_Info E_Fm2_Icon_Info; +#define E_FM_SHARED_DATATYPES +#include "e_fm_shared.h" +#undef E_FM_SHARED_DATATYPES + #else #ifndef E_FM_H #define E_FM_H @@ -153,6 +157,10 @@ EAPI E_Fm2_Icon_Info *e_fm2_icon_file_info_get(E_Fm2_Icon *ic); EAPI void e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e); EAPI void e_fm2_client_del(Ecore_Ipc_Event_Client_Del *e); + +EAPI void _e_fm2_client_mount(const char *udi, const char *mountpoint); +EAPI void _e_fm2_client_unmount(const char *udi); +EAPI void _e_fm2_file_force_update(const char *path); #endif #endif diff --git a/src/bin/e_fm_main.c b/src/bin/e_fm_main.c index 07a3060f0..bedb6d55e 100644 --- a/src/bin/e_fm_main.c +++ b/src/bin/e_fm_main.c @@ -142,8 +142,10 @@ static void _e_dbus_cb_vol_is(void *user_data, void *reply_data, DBusError *erro static void _e_dbus_cb_dev_add(void *data, DBusMessage *msg); static void _e_dbus_cb_dev_del(void *data, DBusMessage *msg); static void _e_dbus_cb_cap_add(void *data, DBusMessage *msg); +static void _e_dbus_cb_prop_modified(void *data, DBusMessage *msg); static void _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error); static void _e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error); +static void _e_dbus_cb_vol_prop_mount_modified(void *data, void *reply_data, DBusError *error); static void _e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error); static void _e_dbus_cb_vol_unmounted(void *user_data, void *method_return, DBusError *error); @@ -428,6 +430,54 @@ _e_dbus_cb_cap_add(void *data, DBusMessage *msg) } } +static void +_e_dbus_cb_prop_modified(void *data, DBusMessage *msg) +{ + E_Volume *v; + DBusMessageIter iter, sub, subsub; + struct { + const char *name; + int added; + int removed; + } prop; + int num_changes = 0, i; + + if (!(v = data)) return; + + if (dbus_message_get_error_name(msg)) + { + printf("DBUS ERROR: %s\n", dbus_message_get_error_name(msg)); + return; + } + if (!dbus_message_iter_init(msg, &iter)) return; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) return; + dbus_message_iter_get_basic(&iter, &num_changes); + if (num_changes == 0) return; + + dbus_message_iter_next(&iter); + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) return; + dbus_message_iter_recurse(&iter, &sub); + + for (i = 0; i < num_changes; i++, dbus_message_iter_next(&sub)) + { + dbus_message_iter_recurse(&sub, &subsub); + + if (dbus_message_iter_get_arg_type(&subsub) != DBUS_TYPE_STRING) break; + dbus_message_iter_get_basic(&subsub, &(prop.name)); + if (!strcmp(prop.name, "volume.mount_point")) + { + e_hal_device_get_all_properties(_e_dbus_conn, v->udi, + _e_dbus_cb_vol_prop_mount_modified, + v); + return; + } + + dbus_message_iter_next(&subsub); + dbus_message_iter_next(&subsub); + } +} + static void _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error) { @@ -436,12 +486,13 @@ _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error) int err = 0; if (!ret) goto error; + if (dbus_error_is_set(error)) { dbus_error_free(error); goto error; } - + s->bus = e_hal_property_string_get(ret, "storage.bus", &err); if (err) goto error; s->drive_type = e_hal_property_string_get(ret, "storage.drive_type", &err); @@ -451,9 +502,11 @@ _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error) s->vendor = e_hal_property_string_get(ret, "storage.vendor", &err); if (err) goto error; s->serial = e_hal_property_string_get(ret, "storage.serial", &err); - +// if (err) goto error; + if (err) printf("Error getting serial for %s\n", s->udi); + printf("S6\n"); + s->removable = e_hal_property_bool_get(ret, "storage.removable", &err); - if (err) goto error; if (s->removable) { @@ -578,20 +631,22 @@ _e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error) v->fstype = e_hal_property_string_get(ret, "volume.fstype", &err); // if (err) goto error; + + v->size = e_hal_property_uint64_get(ret, "volume.size", &err); v->mounted = e_hal_property_bool_get(ret, "volume.is_mounted", &err); if (err) goto error; v->partition = e_hal_property_bool_get(ret, "volume.is_partition", &err); if (err) goto error; - + v->mount_point = e_hal_property_string_get(ret, "volume.mount_point", &err); if (err) goto error; if (v->partition) { - v->partition_label = e_hal_property_string_get(ret, "volume.partition.label", &err); -// if (err) goto error; + v->partition_number = e_hal_property_int_get(ret, "volume.partition.number", NULL); + v->partition_label = e_hal_property_string_get(ret, "volume.partition.label", NULL); } v->parent = e_hal_property_string_get(ret, "info.parent", &err); @@ -605,7 +660,7 @@ _e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error) } } - printf("++VOL:\n udi: %s\n uuid: %s\n fstype: %s\n label: %s\n partition: %d\n partition_label: %s\n mounted: %d\n mount_point: %s\n", v->udi, v->uuid, v->fstype, v->label, v->partition, v->partition ? v->partition_label : "(not a partition)", v->mounted, v->mount_point); + 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", 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); if (s) printf(" for storage: %s\n", s->udi); else printf(" storage unknown\n"); v->validated = 1; @@ -630,6 +685,52 @@ _e_dbus_cb_vol_prop(void *data, void *reply_data, DBusError *error) return; } +static void +_e_dbus_cb_vol_prop_mount_modified(void *data, void *reply_data, DBusError *error) +{ + E_Volume *v = data; + E_Storage *s = NULL; + E_Hal_Device_Get_All_Properties_Return *ret = reply_data; + int err = 0; + char *str = NULL; + + if (!ret) return; + if (dbus_error_is_set(error)) + { + dbus_error_free(error); + return; + } + + v->mounted = e_hal_property_bool_get(ret, "volume.is_mounted", &err); + if (err) printf("HAL Error : can't get volume.is_mounted property"); + + if (v->mount_point) free(v->mount_point); + v->mount_point = e_hal_property_string_get(ret, "volume.mount_point", &err); + if (err) printf("HAL Error : can't get volume.is_mount_point property"); + + printf("**VOL udi: %s mount_point: %s mounted: %d\n", v->udi, v->mount_point, v->mounted); + { + char *buf; + int size; + + size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1; + buf = alloca(size); + strcpy(buf, v->udi); + strcpy(buf + strlen(buf) + 1, v->mount_point); + if (v->mounted) + ecore_ipc_server_send(_e_ipc_server, + 6/*E_IPC_DOMAIN_FM*/, + 12/*mount done*/, + 0, 0, 0, buf, size); + else + ecore_ipc_server_send(_e_ipc_server, + 6/*E_IPC_DOMAIN_FM*/, + 13/*unmount done*/, + 0, 0, 0, buf, size); + } + return; +} + static Evas_List *_e_vols = NULL; EAPI E_Volume * @@ -641,11 +742,16 @@ e_volume_add(const char *udi) if (e_volume_find(udi)) return NULL; v = calloc(1, sizeof(E_Volume)); if (!v) return NULL; -// printf("VOL+ %s\n", udi); + printf("VOL+ %s\n", udi); v->udi = strdup(udi); _e_vols = evas_list_append(_e_vols, v); e_hal_device_get_all_properties(_e_dbus_conn, v->udi, _e_dbus_cb_vol_prop, v); + v->prop_handler = e_dbus_signal_handler_add(_e_dbus_conn, "org.freedesktop.Hal", + udi, + "org.freedesktop.Hal.Device", + "PropertyModified", _e_dbus_cb_prop_modified, v); + return v; } @@ -656,6 +762,7 @@ e_volume_del(const char *udi) v = e_volume_find(udi); if (!v) return; + if (v->prop_handler) e_dbus_signal_handler_del(_e_dbus_conn, v->prop_handler); if (v->validated) { printf("--VOL %s\n", v->udi); @@ -691,6 +798,11 @@ _e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error) char *buf; int size; + if (dbus_error_is_set(error)) + { + dbus_error_free(error); + return; + } v->mounted = 1; printf("MOUNT: %s from %s\n", v->udi, v->mount_point); size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1; @@ -706,44 +818,27 @@ _e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error) EAPI void e_volume_mount(E_Volume *v) { - static int mount_id = 1; - char buf[4096], buf2[256], buf3[256]; + char buf[256]; char *mount_point; Ecore_List *opt = NULL; - - if (v->mount_point && v->mount_point[0]) - mount_point = v->mount_point; - else if (v->label && v->label[0]) - mount_point = v->label; - else if (v->uuid && v->uuid[0]) - mount_point = v->uuid; - else + + if (!v || !v->mount_point || strncmp(v->mount_point, "/media/", 7)) + return; + + mount_point = v->mount_point + 7; + printf("mount %s %s [fs type = %s]\n", v->udi, v->mount_point, v->fstype); + + if ((!strcmp(v->fstype, "vfat")) || (!strcmp(v->fstype, "ntfs")) +// || (!strcmp(v->fstype, "iso9660")) || (!strcmp(v->fstype, "udf")) + ) { - snprintf(buf, sizeof(buf), "unknown-%i\n", mount_id++); - mount_point = buf; + opt = ecore_list_new(); + snprintf(buf, sizeof(buf), "uid=%i", (int)getuid()); + ecore_list_append(opt, buf); } - if (v->mount_point != mount_point) - { - if (v->mount_point) free(v->mount_point); - v->mount_point = strdup(mount_point); - } - printf("mount %s %s\n", v->udi, v->mount_point); -// ******************************************* -// FIXME; need to mount AS the USER - not root!!! seems it mounts as root -// this doesn't work below. i add ANY mount options and dbus ignores the -// request -// ******************************************* -// opt = ecore_list_new(); -// snprintf(buf2, sizeof(buf2), "uid=%i", (int)getuid()); -// ecore_list_append(opt, buf2); -// snprintf(buf3, sizeof(buf3), "gid=%i", (int)getgid()); -// ecore_list_append(opt, buf3); -// ecore_list_append(opt, "uni_xlate"); -// ecore_list_append(opt, "user"); -// ecore_list_append(opt, "utf8"); - e_hal_device_volume_mount(_e_dbus_conn, v->udi, v->mount_point, - v->fstype, opt, _e_dbus_cb_vol_mounted, v); -// ecore_list_destroy(opt); + e_hal_device_volume_mount(_e_dbus_conn, v->udi, mount_point, + v->fstype, opt, NULL, v); + if (opt) ecore_list_destroy(opt); } static void @@ -753,6 +848,11 @@ _e_dbus_cb_vol_unmounted(void *user_data, void *method_return, DBusError *error) char *buf; int size; + if (dbus_error_is_set(error)) + { + dbus_error_free(error); + return; + } v->mounted = 0; printf("UNMOUNT: %s from %s\n", v->udi, v->mount_point); size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1; @@ -900,7 +1000,11 @@ _e_ipc_cb_server_data(void *data, int type, void *event) { if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) continue; - if (!strcmp(dp->d_name, ".order")) dot_order = 1; + if (!strcmp(dp->d_name, ".order")) + { + dot_order = 1; + continue; + } files = evas_list_append(files, strdup(dp->d_name)); } closedir(dir); diff --git a/src/bin/e_fm_shared.h b/src/bin/e_fm_shared.h index d25504795..1f8feb156 100644 --- a/src/bin/e_fm_shared.h +++ b/src/bin/e_fm_shared.h @@ -4,6 +4,7 @@ # define E_DEVICE_TYPE_VOLUME 2 typedef struct _E_Storage E_Storage; typedef struct _E_Volume E_Volume; +typedef struct _E_Fm2_Mount E_Fm2_Mount; struct _E_Storage { @@ -42,18 +43,39 @@ struct _E_Volume char *uuid; char *label; char *fstype; + unsigned long long size; - char partition; + char partition; + int partition_number; char *partition_label; - char mounted; + char mounted; char *mount_point; char *parent; E_Storage *storage; + void *prop_handler; + Evas_List *mounts; unsigned char validated; }; +struct _E_Fm2_Mount +{ + const char *udi; + const char *mount_point; + + Ecore_Timer *timeout; + void (*mount_ok) (void *data); + void (*mount_fail) (void *data); + void (*unmount_ok) (void *data); + void (*unmount_fail) (void *data); + void *data; + + E_Volume *volume; + + unsigned char mounted : 1; +}; + #endif #ifdef E_FM_SHARED_CODEC @@ -130,7 +152,9 @@ _e_volume_edd_new(void) DAT("uuid", uuid, EET_T_STRING); DAT("label", label, EET_T_STRING); DAT("fstype", fstype, EET_T_STRING); + DAT("size", size, EET_T_ULONG_LONG); DAT("partition", partition, EET_T_CHAR); + DAT("partition_number", partition_number, EET_T_INT); DAT("partition_label", partition_label, EET_T_STRING); DAT("mounted", mounted, EET_T_CHAR); DAT("mount_point", mount_point, EET_T_STRING); diff --git a/src/modules/fileman/e_fwin.c b/src/modules/fileman/e_fwin.c index 9e71eeb81..2439cc74c 100644 --- a/src/modules/fileman/e_fwin.c +++ b/src/modules/fileman/e_fwin.c @@ -964,16 +964,14 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files, int always) Evas_Coord mw, mh; Evas_Object *o, *ocon, *of, *oi, *mt; Evas *evas; - Evas_List *l; - Evas_List *apps; + Evas_List *l = NULL, *apps = NULL, *mlist = NULL; + Evas_Hash *mimes = NULL; E_Fwin_Apps_Dialog *fad; E_Fm2_Config fmc; E_Fm2_Icon_Info *ici; char buf[PATH_MAX]; const char *f; int need_dia = 0; - Evas_Hash *mimes = NULL; - Evas_List *mlist = NULL; if (fwin->fad) { @@ -985,30 +983,53 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files, int always) for (l = files; l; l = l->next) { ici = l->data; - printf("O: %s -- %i\n", ici->link, ici->removable); if ((ici->link) && (ici->mount)) { - if (fwin->win) - fwin2 = _e_fwin_new(fwin->win->container, ici->link, "/"); - else if (fwin->zone) - fwin2 = _e_fwin_new(fwin->zone->container, ici->link, "/"); + if (!fileman_config->view.open_dirs_in_place || fwin->zone) + { + if (fwin->win) + fwin2 = _e_fwin_new(fwin->win->container, ici->link, "/"); + else if (fwin->zone) + fwin2 = _e_fwin_new(fwin->zone->container, ici->link, "/"); + } + else + { + e_fm2_path_set(fwin->fm_obj, ici->link, "/"); + _e_fwin_window_title_set(fwin); + } } else if ((ici->link) && (ici->removable)) { snprintf(buf, sizeof(buf), "removable:%s", ici->link); - if (fwin->win) - fwin2 = _e_fwin_new(fwin->win->container, buf, "/"); - else if (fwin->zone) - fwin2 = _e_fwin_new(fwin->zone->container, buf, "/"); + if (!fileman_config->view.open_dirs_in_place || fwin->zone) + { + if (fwin->win) + fwin2 = _e_fwin_new(fwin->win->container, buf, "/"); + else if (fwin->zone) + fwin2 = _e_fwin_new(fwin->zone->container, buf, "/"); + } + else + { + e_fm2_path_set(fwin->fm_obj, buf, "/"); + _e_fwin_window_title_set(fwin); + } } else if (ici->real_link) { if (S_ISDIR(ici->statinfo.st_mode)) { - if (fwin->win) - fwin2 = _e_fwin_new(fwin->win->container, NULL, ici->real_link); - else if (fwin->zone) - fwin2 = _e_fwin_new(fwin->zone->container, NULL, ici->real_link); + if (!fileman_config->view.open_dirs_in_place || fwin->zone) + { + if (fwin->win) + fwin2 = _e_fwin_new(fwin->win->container, NULL, ici->real_link); + else if (fwin->zone) + fwin2 = _e_fwin_new(fwin->zone->container, NULL, ici->real_link); + } + else + { + e_fm2_path_set(fwin->fm_obj, NULL, ici->real_link); + _e_fwin_window_title_set(fwin); + } } else need_dia = 1; @@ -1019,10 +1040,18 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files, int always) e_fm2_real_path_get(fwin->fm_obj), ici->file); if (S_ISDIR(ici->statinfo.st_mode)) { - if (fwin->win) - fwin2 = _e_fwin_new(fwin->win->container, NULL, buf); - else - fwin2 = _e_fwin_new(fwin->zone->container, NULL, buf); + if (!fileman_config->view.open_dirs_in_place || fwin->zone) + { + if (fwin->win) + fwin2 = _e_fwin_new(fwin->win->container, NULL, buf); + else + fwin2 = _e_fwin_new(fwin->zone->container, NULL, buf); + } + else + { + e_fm2_path_set(fwin->fm_obj, NULL, buf); + _e_fwin_window_title_set(fwin); + } } else need_dia = 1;