diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index dface7497..d0a040a4f 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -189,6 +189,7 @@ struct _E_Fm2_Mount { const char *udi; const char *mount_point; + int instances; Ecore_Timer *timeout; void (*mount_ok) (void *data); @@ -213,6 +214,7 @@ 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 char *_e_fm2_vol_mountpoint_resolve(E_Volume *v); 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); static void _e_fm2_queue_process(Evas_Object *obj); @@ -468,9 +470,10 @@ EAPI void e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) { E_Fm2_Smart_Data *sd; + Evas_List *l; 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 @@ -510,12 +513,6 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) 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); @@ -531,8 +528,30 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path) _e_fm2_regions_free(obj); _e_fm2_icons_free(obj); edje_object_part_text_set(sd->overlay, "e.text.busy_label", ""); + + if (!sd->mount && !sd->dev) + { + for (l = _e_fm2_mounts; l; l = l->next) + { + E_Fm2_Mount *m; + m = l->data; + if (!strncmp(m->mount_point, sd->realpath, strlen(m->mount_point))) + { + sd->mount = m; + m->instances++; + break; + } + } + } + if (!l && sd->mount && strncmp(sd->mount->mount_point, sd->realpath, + strlen(sd->mount->mount_point))) + { + printf("UM2\n"); + _e_fm2_unmount(sd->mount); + sd->mount = NULL; + } - if ((sd->dev) && (!strncmp(sd->dev, "removable:", 10))) + if ((!sd->mount) && (sd->dev) && (!strncmp(sd->dev, "removable:", 10))) { E_Volume *v; @@ -1371,21 +1390,21 @@ _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); + if (m->instances == 0) + { + _e_fm2_mounts = evas_list_remove(_e_fm2_mounts, m); + evas_stringshare_del(m->udi); + evas_stringshare_del(m->mount_point); + if (m->timeout) + { + ecore_timer_del(m->timeout); + m->timeout = NULL; + } + free(m); + } } } @@ -1405,7 +1424,7 @@ _e_fm2_mount_ok(const char *udi) for (l = _e_fm2_mounts; l; l = l->next) { m = l->data; - if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->mount_ok)) + if ((!strcmp(m->udi, udi)) && (m->mount_ok)) { m->mounted = 1; m->mount_ok(m->data); @@ -1416,7 +1435,7 @@ _e_fm2_mount_ok(const char *udi) } } } - _e_fm2_mount_flush(); + //_e_fm2_mount_flush(); _e_fm2_mount_stack--; } @@ -1512,18 +1531,19 @@ _e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (voi 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; + m = m2; + m->instances++; break; } } + + m = calloc(1, sizeof(E_Fm2_Mount)); + if (!m) return NULL; m->udi = evas_stringshare_add(v->udi); m->mount_point = evas_stringshare_add(v->mount_point); m->mount_ok = mount_ok; @@ -1531,13 +1551,14 @@ _e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (voi m->unmount_ok = unmount_ok; m->unmount_fail = unmount_fail; m->data = data; - m->mounted = mounted; - if (!exists) + m->mounted = v->mounted; + m->instances++; + if (!v->mounted) { 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); } - _e_fm2_mounts = evas_list_prepend(_e_fm2_mounts, m); return m; } @@ -1549,12 +1570,13 @@ _e_fm2_unmount(E_Fm2_Mount *m) int exists = 0; _e_fm2_mount_stack++; + m->instances--; for (l = _e_fm2_mounts; l; l = l->next) { m2 = l->data; - if (!strcmp(m->udi, m2->udi)) exists++; + if (!strcmp(m->udi, m2->udi)) break; } - if (exists == 1) + if (l && !m->instances) { printf("_e_fm2_unmount UM\n"); _e_fm2_client_unmount(m->udi); @@ -1944,15 +1966,20 @@ _e_fm2_client_mount(const char *udi, const char *mountpoint) { E_Fm2_Client *cl; char *d; + const char *mp; int l, l1, l2; + if (!strncmp(mountpoint, "/media/", 7)) + mp = mountpoint + 7; + else + mp = mountpoint; l1 = strlen(udi); - l2 = strlen(mountpoint); + l2 = strlen(mp); l = l1 + 1 + l2 + 1; d = alloca(l); strcpy(d, udi); - strcpy(d + l1 + 1, mountpoint); - printf("SEND %s %s\n", udi, mountpoint); + strcpy(d + l1 + 1, mp); + printf("SEND %s %s\n", udi, mp); cl = _e_fm2_client_get(); if (!cl) { @@ -2525,21 +2552,21 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) s = e_storage_find(v->parent); if (!v->mount_point) { + char buf[512]; if (v->uuid) - v->mount_point = strdup(v->uuid); + snprintf(buf, sizeof(buf), "/media/%s", strdup(v->uuid)); else if (v->label) - v->mount_point = strdup(v->label); + snprintf(buf, sizeof(buf), "/media/%s", strdup(v->label)); else if ((v->storage) && (v->storage->serial)) - v->mount_point = strdup(v->storage->serial); + snprintf(buf, sizeof(buf), "/media/%s", 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); } + v->mount_point = strdup(buf); } if (s) { @@ -2587,8 +2614,11 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) { v->mounted = 1; if (v->mount_point) free(v->mount_point); - v->mount_point = strdup(mountpoint); - printf("MOUNT %s %s\n", udi, mountpoint); + if (mountpoint[0] == 0) + v->mount_point = _e_fm2_vol_mountpoint_resolve(v); + else + v->mount_point = strdup(mountpoint); + printf("MOUNT %s %s\n", v->udi, v->mount_point); } _e_fm2_mount_ok(udi); } @@ -2605,7 +2635,12 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e) if (v) { v->mounted = 0; - printf("UNMOUNT %s %s\n", udi, mountpoint); + if (v->mount_point) free(v->mount_point); + if (mountpoint[0] == 0) + v->mount_point = _e_fm2_vol_mountpoint_resolve(v); + else + v->mount_point = strdup(mountpoint); + printf("UNMOUNT %s %s\n", v->udi, v->mount_point); } _e_fm2_unmount_ok(udi); } @@ -2693,9 +2728,9 @@ _e_fm2_dev_path_map(const char *dev, const char *path) E_Volume *v; v = e_volume_find(dev + strlen("removable:")); - if (v) + if (v && v->mount_point) { - snprintf(buf, sizeof(buf), "/media/%s", v->mount_point); + snprintf(buf, sizeof(buf), "%s%s", v->mount_point, path); } } else if (CMP("dvd") || CMP("dvd-*")) { @@ -2739,6 +2774,27 @@ _e_fm2_dev_path_map(const char *dev, const char *path) } return evas_stringshare_add(buf); } + +static char * +_e_fm2_vol_mountpoint_resolve(E_Volume *v) +{ + if (!v) return; + char buf[512]; + if (v->uuid) + snprintf(buf, sizeof(buf), "/media/%s", strdup(v->uuid)); + else if (v->label) + snprintf(buf, sizeof(buf), "/media/%s", strdup(v->label)); + else if ((v->storage) && (v->storage->serial)) + snprintf(buf, sizeof(buf), "/media/%s", strdup(v->storage->serial)); + else + { + static int mount_count = 0; + + snprintf(buf, sizeof(buf), "/media/unknown-%i", mount_count); + mount_count++; + } + return strdup(buf); +} static void _e_fm2_file_add(Evas_Object *obj, const char *file, int unique, const char *file_rel, int after, E_Fm2_Finfo *finf) @@ -5403,7 +5459,7 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf snprintf(buf, sizeof(buf), "%s/%s", ic->sd->path, ic->info.file); e_fm2_path_set(ic->sd->obj, dev, buf); E_FREE(dev); - } + } else evas_object_smart_callback_call(ic->sd->obj, "selected", NULL); /* if its in file selector mode then signal that a selection has diff --git a/src/bin/e_fm_main.c b/src/bin/e_fm_main.c index c92fd8aa9..bb55f9d79 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) { @@ -487,7 +537,7 @@ _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error) return; error: - printf("ERR %s\n", s->udi); + printf("ERR on %s \n name : %s\n msg : %s\n", s->udi, error->name, error->message); e_storage_del(s->udi); } @@ -630,6 +680,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 * @@ -646,6 +742,10 @@ e_volume_add(const char *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); + 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; } @@ -693,6 +793,7 @@ _e_dbus_cb_vol_mounted(void *user_data, void *method_return, DBusError *error) v->mounted = 1; printf("MOUNT: %s from %s\n", v->udi, v->mount_point); + printf("DBus Error name: %s \nmsg : %s\n", error->name, error->message); size = strlen(v->udi) + 1 + strlen(v->mount_point) + 1; buf = alloca(size); strcpy(buf, v->udi); @@ -742,7 +843,7 @@ e_volume_mount(E_Volume *v) // 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); + v->fstype, opt, NULL, v); // ecore_list_destroy(opt); } @@ -900,7 +1001,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/modules/fileman/e_fwin.c b/src/modules/fileman/e_fwin.c index 40e522016..110564342 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;