aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_fm_main.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2007-10-22 07:38:25 +0000
committerCarsten Haitzler <raster@rasterman.com>2007-10-22 07:38:25 +0000
commit91b0dbc6fc186ff41958211ca20eafa20ee9ad8f (patch)
tree5d4b14b2f1803c6a6be786b9eefd4c3ee758a87e /src/bin/e_fm_main.c
parent * properly add freqset to the package (diff)
downloadenlightenment-91b0dbc6fc186ff41958211ca20eafa20ee9ad8f.tar.gz
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
Diffstat (limited to 'src/bin/e_fm_main.c')
-rw-r--r--src/bin/e_fm_main.c190
1 files changed, 147 insertions, 43 deletions
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);
@@ -429,6 +431,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)
{
E_Storage *s = data;
@@ -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
- {
- snprintf(buf, sizeof(buf), "unknown-%i\n", mount_id++);
- mount_point = buf;
- }
- if (v->mount_point != mount_point)
+
+ 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"))
+ )
{
- if (v->mount_point) free(v->mount_point);
- v->mount_point = strdup(mount_point);
+ opt = ecore_list_new();
+ snprintf(buf, sizeof(buf), "uid=%i", (int)getuid());
+ ecore_list_append(opt, buf);
}
- 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);