revert lok's patch - gettign segv's and mount success/failure is not working.

SVN revision: 31951
This commit is contained in:
Carsten Haitzler 2007-10-03 17:19:17 +00:00
parent 055b45c306
commit 6b23fae2f8
3 changed files with 69 additions and 259 deletions

View File

@ -189,7 +189,6 @@ struct _E_Fm2_Mount
{
const char *udi;
const char *mount_point;
int instances;
Ecore_Timer *timeout;
void (*mount_ok) (void *data);
@ -214,7 +213,6 @@ 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);
@ -470,10 +468,9 @@ 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 || !path) return; // safety
if (!sd) return; // safety
if (!evas_object_type_get(obj)) return; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety
@ -513,6 +510,12 @@ 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);
@ -528,30 +531,8 @@ 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->mount) && (sd->dev) && (!strncmp(sd->dev, "removable:", 10)))
if ((sd->dev) && (!strncmp(sd->dev, "removable:", 10)))
{
E_Volume *v;
@ -1390,21 +1371,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->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);
}
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);
}
}
@ -1424,7 +1405,7 @@ _e_fm2_mount_ok(const char *udi)
for (l = _e_fm2_mounts; l; l = l->next)
{
m = l->data;
if ((!strcmp(m->udi, udi)) && (m->mount_ok))
if ((!m->delete_me) && (!strcmp(m->udi, udi)) && (m->mount_ok))
{
m->mounted = 1;
m->mount_ok(m->data);
@ -1435,7 +1416,7 @@ _e_fm2_mount_ok(const char *udi)
}
}
}
//_e_fm2_mount_flush();
_e_fm2_mount_flush();
_e_fm2_mount_stack--;
}
@ -1531,19 +1512,18 @@ _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))
{
m = m2;
m->instances++;
exists = 1;
mounted = m2->mounted;
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;
@ -1551,14 +1531,13 @@ _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 = v->mounted;
m->instances++;
if (!v->mounted)
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);
}
_e_fm2_mounts = evas_list_prepend(_e_fm2_mounts, m);
return m;
}
@ -1570,13 +1549,12 @@ _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)) break;
if (!strcmp(m->udi, m2->udi)) exists++;
}
if (l && !m->instances)
if (exists == 1)
{
printf("_e_fm2_unmount UM\n");
_e_fm2_client_unmount(m->udi);
@ -1966,20 +1944,15 @@ _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(mp);
l2 = strlen(mountpoint);
l = l1 + 1 + l2 + 1;
d = alloca(l);
strcpy(d, udi);
strcpy(d + l1 + 1, mp);
printf("SEND %s %s\n", udi, mp);
strcpy(d + l1 + 1, mountpoint);
printf("SEND %s %s\n", udi, mountpoint);
cl = _e_fm2_client_get();
if (!cl)
{
@ -2552,21 +2525,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)
snprintf(buf, sizeof(buf), "/media/%s", strdup(v->uuid));
v->mount_point = strdup(v->uuid);
else if (v->label)
snprintf(buf, sizeof(buf), "/media/%s", strdup(v->label));
v->mount_point = strdup(v->label);
else if ((v->storage) && (v->storage->serial))
snprintf(buf, sizeof(buf), "/media/%s", strdup(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);
}
v->mount_point = strdup(buf);
}
if (s)
{
@ -2614,11 +2587,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
{
v->mounted = 1;
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("MOUNT %s %s\n", v->udi, v->mount_point);
v->mount_point = strdup(mountpoint);
printf("MOUNT %s %s\n", udi, mountpoint);
}
_e_fm2_mount_ok(udi);
}
@ -2635,12 +2605,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
if (v)
{
v->mounted = 0;
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);
printf("UNMOUNT %s %s\n", udi, mountpoint);
}
_e_fm2_unmount_ok(udi);
}
@ -2728,9 +2693,9 @@ _e_fm2_dev_path_map(const char *dev, const char *path)
E_Volume *v;
v = e_volume_find(dev + strlen("removable:"));
if (v && v->mount_point)
if (v)
{
snprintf(buf, sizeof(buf), "%s%s", v->mount_point, path);
snprintf(buf, sizeof(buf), "/media/%s", v->mount_point);
}
}
else if (CMP("dvd") || CMP("dvd-*")) {
@ -2774,27 +2739,6 @@ _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)
@ -5459,7 +5403,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

View File

@ -142,10 +142,8 @@ 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);
@ -430,54 +428,6 @@ _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)
{
@ -537,7 +487,7 @@ _e_dbus_cb_store_prop(void *data, void *reply_data, DBusError *error)
return;
error:
printf("ERR on %s \n name : %s\n msg : %s\n", s->udi, error->name, error->message);
printf("ERR %s\n", s->udi);
e_storage_del(s->udi);
}
@ -680,52 +630,6 @@ _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 *
@ -742,10 +646,6 @@ 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;
}
@ -793,7 +693,6 @@ _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);
@ -843,7 +742,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, NULL, v);
v->fstype, opt, _e_dbus_cb_vol_mounted, v);
// ecore_list_destroy(opt);
}
@ -1001,11 +900,7 @@ _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;
continue;
}
if (!strcmp(dp->d_name, ".order")) dot_order = 1;
files = evas_list_append(files, strdup(dp->d_name));
}
closedir(dir);

View File

@ -964,14 +964,16 @@ _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 = NULL, *apps = NULL, *mlist = NULL;
Evas_Hash *mimes = NULL;
Evas_List *l;
Evas_List *apps;
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)
{
@ -983,53 +985,30 @@ _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 (!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);
}
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 if ((ici->link) && (ici->removable))
{
snprintf(buf, sizeof(buf), "removable:%s", ici->link);
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);
}
if (fwin->win)
fwin2 = _e_fwin_new(fwin->win->container, buf, "/");
else if (fwin->zone)
fwin2 = _e_fwin_new(fwin->zone->container, buf, "/");
}
else if (ici->real_link)
{
if (S_ISDIR(ici->statinfo.st_mode))
{
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);
}
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
need_dia = 1;
@ -1040,18 +1019,10 @@ _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 (!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);
}
if (fwin->win)
fwin2 = _e_fwin_new(fwin->win->container, NULL, buf);
else
fwin2 = _e_fwin_new(fwin->zone->container, NULL, buf);
}
else
need_dia = 1;