aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2013-01-02 13:16:19 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-02 13:16:19 +0000
commit5e4352e9b3c208c87c45157449480f29564ce0a2 (patch)
treeef92d081768dd655ad7e3c50a6f4212cd56daf07
parent5655cbf8af3b2f40451caf3a8eabc7096cbd4fdf (diff)
downloadenlightenment-5e4352e9b3c208c87c45157449480f29564ce0a2.tar.gz
enlightenment-5e4352e9b3c208c87c45157449480f29564ce0a2.tar.xz
enlightenment-5e4352e9b3c208c87c45157449480f29564ce0a2.zip
e: e_fm udisk ported to edbus
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 81985
-rw-r--r--configure.ac3
-rw-r--r--src/bin/e_fm.c2
-rw-r--r--src/bin/e_fm/e_fm_main.c2
-rw-r--r--src/bin/e_fm/e_fm_main_udisks.c1085
-rw-r--r--src/bin/e_fm_shared_device.c8
-rw-r--r--src/bin/e_fm_shared_types.h.in11
6 files changed, 648 insertions, 463 deletions
diff --git a/configure.ac b/configure.ac
index f43ccca1d..57c894e41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -457,7 +457,6 @@ ecore-file >= $efl_version \
ecore-ipc >= $efl_version \
eet >= $efl_version \
efreet >= $efl_version \
-edbus >= $efl_version \
edbus2 >= $efl_version \
eina >= $efl_version"
efm_requires="$efm_requires $eeze_mount $dbus_mount $hal_mount $udisks_mount"
@@ -469,8 +468,6 @@ PKG_CHECK_MODULES(E_FM_CMDLINE, [
ecore >= ${efl_version}
ecore-file >= ${efl_version}
edbus2 >= ${efl_version}
- edbus >= ${efl_version}
- dbus-1
])
PKG_CHECK_MODULES(E_FM_OP, [
diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c
index 765e3aa81..c75f3c3b1 100644
--- a/src/bin/e_fm.c
+++ b/src/bin/e_fm.c
@@ -2962,7 +2962,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
e_fm2_device_volume_add(v);
if (v->mounted)
e_fm2_device_mount(v, NULL, NULL, NULL, NULL, NULL);
- else if (e_config->device_auto_mount && !v->mounted && !v->first_time)
+ else if (e_config->device_auto_mount && !v->first_time)
_e_fm2_client_mount(v->udi, v->mount_point);
if (e_config->device_desktop)
e_fm2_device_show_desktop_icons();
diff --git a/src/bin/e_fm/e_fm_main.c b/src/bin/e_fm/e_fm_main.c
index b9df748b1..6e670b5ed 100644
--- a/src/bin/e_fm/e_fm_main.c
+++ b/src/bin/e_fm/e_fm_main.c
@@ -71,7 +71,7 @@ static Efm_Mode mode = EFM_MODE_USING_RASTER_MOUNT;
/* FIXME: things to add to the slave enlightenment_fm process and ipc to e:
*
* * reporting results of fop's (current status - what has been don, what failed etc.)
- * * dbus removable device monitoring (in e17 itself now via e_dbus - move to enlightenment_fm and ipc removable device add/del and anything else)
+ * * dbus removable device monitoring (in e17 itself now via edbus - move to enlightenment_fm and ipc removable device add/del and anything else)
* * mount/umount of removable devices (to go along with removable device support - put it in here and message back mount success/failure and where it is now mounted - remove from e17 itself)
*
*/
diff --git a/src/bin/e_fm/e_fm_main_udisks.c b/src/bin/e_fm/e_fm_main_udisks.c
index 7e7223bbe..324031218 100644
--- a/src/bin/e_fm/e_fm_main_udisks.c
+++ b/src/bin/e_fm/e_fm_main_udisks.c
@@ -45,8 +45,7 @@ void *alloca(size_t);
#include <Ecore_Ipc.h>
#include <Ecore_File.h>
#include <Eet.h>
-#include <E_DBus.h>
-#include <E_Ukit.h>
+#include <EDBus.h>
#include "e_fm_shared_device.h"
#include "e_fm_shared_codec.h"
@@ -56,321 +55,383 @@ void *alloca(size_t);
#include "e_fm_main_udisks.h"
#include "e_fm_main.h"
-static E_DBus_Signal_Handler *_udisks_poll = NULL;
-static E_DBus_Signal_Handler *_udisks_add = NULL;
-static E_DBus_Signal_Handler *_udisks_del = NULL;
-static E_DBus_Signal_Handler *_udisks_chg = NULL;
-static E_DBus_Connection *_e_fm_main_udisks_conn = NULL;
+#define UDISKS_BUS "org.freedesktop.UDisks"
+#define UDISKS_PATH "/org/freedesktop/UDisks"
+#define UDISKS_INTERFACE "org.freedesktop.UDisks"
+#define UDISKS_DEVICE_INTERFACE "org.freedesktop.UDisks.Device"
+
+static EDBus_Connection *_e_fm_main_udisks_conn = NULL;
+static EDBus_Proxy *_e_fm_main_udisks_proxy = NULL;
static Eina_List *_e_stores = NULL;
static Eina_List *_e_vols = NULL;
-static void _e_fm_main_udisks_cb_dev_all(void *user_data __UNUSED__,
- E_Ukit_String_List_Return *ret,
- DBusError *error);
-static void _e_fm_main_udisks_cb_dev_verify(const char *udi,
- E_Ukit_Property *ret,
- DBusError *error);
-static void _e_fm_main_udisks_cb_dev_add_verify(const char *udi,
- E_Ukit_Property *ret,
- DBusError *error);
-static void _e_fm_main_udisks_cb_dev_add(void *data,
- DBusMessage *msg);
-static void _e_fm_main_udisks_cb_dev_del(void *data,
- DBusMessage *msg);
-static void _e_fm_main_udisks_cb_dev_chg(void *data,
- DBusMessage *msg);
-static void _e_fm_main_udisks_cb_prop_modified(E_Volume *v,
- DBusMessage *msg);
-static void _e_fm_main_udisks_cb_store_prop(E_Storage *s,
- E_Ukit_Properties *ret,
- DBusError *error);
-static void _e_fm_main_udisks_cb_vol_prop(E_Volume *v,
- E_Ukit_Properties *ret,
- DBusError *error);
-static void _e_fm_main_udisks_cb_vol_mounted(E_Volume *v,
- DBusError *error);
-static void _e_fm_main_udisks_cb_vol_unmounted(E_Volume *v,
- DBusError *error);
-static void _e_fm_main_udisks_cb_vol_unmounted_before_eject(E_Volume *v,
- void *method_return __UNUSED__,
- DBusError *error);
+static void _e_fm_main_udisks_cb_dev_all(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending);
+static void _e_fm_main_udisks_cb_dev_verify(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending);
+static void _e_fm_main_udisks_cb_dev_add(void *data, const EDBus_Message *msg);
+static void _e_fm_main_udisks_cb_dev_del(void *data, const EDBus_Message *msg);
+static void _e_fm_main_udisks_cb_prop_modified(void *data, const EDBus_Message *msg);
+static void _e_fm_main_udisks_cb_store_prop(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending);
+static void _e_fm_main_udisks_cb_vol_prop(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending);
+static void _e_fm_main_udisks_cb_vol_mounted(E_Volume *v);
+static void _e_fm_main_udisks_cb_vol_unmounted(E_Volume *v);
+static void _e_fm_main_udisks_cb_vol_unmounted_before_eject(E_Volume *v);
static Eina_Bool _e_fm_main_udisks_cb_vol_ejecting_after_unmount(E_Volume *v);
-static void _e_fm_main_udisks_cb_vol_ejected(E_Volume *v,
- void *method_return __UNUSED__,
- DBusError *error);
+static void _e_fm_main_udisks_cb_vol_ejected(E_Volume *v);
static int _e_fm_main_udisks_format_error_msg(char **buf,
E_Volume *v,
- DBusError *error);
-static void _e_fm_main_udisks_test(void *data,
- DBusMessage *msg,
- DBusError *error);
-static void _e_fm_main_udisks_poll(void *data,
- DBusMessage *msg);
+ const char *name,
+ const char *message);
static Eina_Bool _e_fm_main_udisks_vol_mount_timeout(E_Volume *v);
static Eina_Bool _e_fm_main_udisks_vol_unmount_timeout(E_Volume *v);
static Eina_Bool _e_fm_main_udisks_vol_eject_timeout(E_Volume *v);
+static E_Storage *_storage_find_by_dbus_path(const char *path);
+static E_Volume *_volume_find_by_dbus_path(const char *path);
+static void _volume_del(E_Volume *v);
static void
-_e_fm_main_udisks_poll(void *data __UNUSED__,
- DBusMessage *msg)
+_e_fm_main_udisks_name_start(void *data __UNUSED__, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
- DBusError err;
- const char *name, *from, *to;
-
- dbus_error_init(&err);
- if (!dbus_message_get_args(msg, &err,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &from,
- DBUS_TYPE_STRING, &to,
- DBUS_TYPE_INVALID))
- dbus_error_free(&err);
-
- //INF("name: %s\nfrom: %s\nto: %s", name, from, to);
- if ((name) && !strcmp(name, E_UDISKS_BUS))
- _e_fm_main_udisks_test(NULL, NULL, NULL);
-}
+ unsigned flag = 0;
+ EDBus_Object *obj;
-static void
-_e_fm_main_udisks_test(void *data __UNUSED__,
- DBusMessage *msg __UNUSED__,
- DBusError *error)
-{
- if ((error) && (dbus_error_is_set(error)))
+ if (edbus_message_error_get(msg, NULL, NULL))
+ {
+ _e_fm_main_udisks_catch(EINA_FALSE);
+ return;
+ }
+ if (!edbus_message_arguments_get(msg, "u", &flag) || !flag)
{
- dbus_error_free(error);
_e_fm_main_udisks_catch(EINA_FALSE);
return;
}
- if (_udisks_poll)
- e_dbus_signal_handler_del(_e_fm_main_udisks_conn, _udisks_poll);
-
- e_udisks_get_all_devices(_e_fm_main_udisks_conn, (E_DBus_Callback_Func)_e_fm_main_udisks_cb_dev_all, NULL);
-
- if (!_udisks_add)
- _udisks_add = e_dbus_signal_handler_add(_e_fm_main_udisks_conn, E_UDISKS_BUS,
- E_UDISKS_PATH,
- E_UDISKS_BUS,
- "DeviceAdded", (E_DBus_Signal_Cb)_e_fm_main_udisks_cb_dev_add, NULL);
- if (!_udisks_del)
- _udisks_del = e_dbus_signal_handler_add(_e_fm_main_udisks_conn, E_UDISKS_BUS,
- E_UDISKS_PATH,
- E_UDISKS_BUS,
- "DeviceRemoved", (E_DBus_Signal_Cb)_e_fm_main_udisks_cb_dev_del, NULL);
- if (!_udisks_chg)
- _udisks_chg = e_dbus_signal_handler_add(_e_fm_main_udisks_conn, E_UDISKS_BUS,
- E_UDISKS_PATH,
- E_UDISKS_BUS,
- "DeviceChanged", (E_DBus_Signal_Cb)_e_fm_main_udisks_cb_dev_chg, NULL);
+ obj = edbus_object_get(_e_fm_main_udisks_conn, UDISKS_BUS, UDISKS_PATH);
+ _e_fm_main_udisks_proxy = edbus_proxy_get(obj, UDISKS_INTERFACE);
+
+ edbus_proxy_call(_e_fm_main_udisks_proxy, "EnumerateDevices",
+ _e_fm_main_udisks_cb_dev_all, NULL, -1, "");
+
+ edbus_proxy_signal_handler_add(_e_fm_main_udisks_proxy, "DeviceAdded",
+ _e_fm_main_udisks_cb_dev_add, NULL);
+ edbus_proxy_signal_handler_add(_e_fm_main_udisks_proxy, "DeviceRemoved",
+ _e_fm_main_udisks_cb_dev_del, NULL);
_e_fm_main_udisks_catch(EINA_TRUE); /* signal usage of udisks for mounting */
}
static void
-_e_fm_main_udisks_cb_dev_all(void *user_data __UNUSED__,
- E_Ukit_String_List_Return *ret,
- DBusError *error)
+_e_fm_main_udisks_cb_dev_all(void *data __UNUSED__, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
- Eina_List *l;
- const char *udi;
+ const char *name, *txt, *path;
+ EDBus_Message_Iter *array;
- if (!ret || !ret->strings) return;
+ if (edbus_message_error_get(msg, &name, &txt))
+ {
+ ERR("Error %s %s.", name, txt);
+ return;
+ }
- if (dbus_error_is_set(error))
+ if (!edbus_message_arguments_get(msg, "ao", &array))
{
- dbus_error_free(error);
+ ERR("Error getting arguments.");
return;
}
- EINA_LIST_FOREACH(ret->strings, l, udi)
+ while (edbus_message_iter_get_and_next(array, 'o', &path))
{
- INF("DB INIT DEV+: %s", udi);
- e_udisks_get_property(_e_fm_main_udisks_conn, udi, "IdUsage",
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_dev_verify, (void*)eina_stringshare_add(udi));
+ EDBus_Message *new_msg;
+ new_msg = edbus_message_method_call_new(UDISKS_BUS, path,
+ EDBUS_FDO_INTERFACE_PROPERTIES, "Get");
+ edbus_message_arguments_append(new_msg, "ss", UDISKS_DEVICE_INTERFACE, "IdUsage");
+ edbus_connection_send(_e_fm_main_udisks_conn, new_msg,
+ _e_fm_main_udisks_cb_dev_verify,
+ eina_stringshare_add(path), -1);
+ edbus_message_unref(new_msg);
+ INF("DB INIT DEV+: %s", path);
}
}
static void
-_e_fm_main_udisks_cb_dev_verify(const char *udi,
- E_Ukit_Property *ret,
- DBusError *error)
+_e_fm_main_udisks_cb_dev_verify(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
- if (!ret) return;
+ const char *name, *txt, *id_usage, *path = data;
+ EDBus_Message_Iter *variant;
- if (dbus_error_is_set(error))
+ if (edbus_message_error_get(msg, &name, &txt))
{
- dbus_error_free(error);
- return;
+ ERR("Error %s %s.", name, txt);
+ goto error;
}
- if ((!ret->val.s) || (!ret->val.s[0])) /* storage */
- _e_fm_main_udisks_storage_add(udi);
- else if (!strcmp(ret->val.s, "filesystem"))
+ if (!edbus_message_arguments_get(msg, "v", &variant))
{
- INF("DB VOL+: %s", udi);
- _e_fm_main_udisks_volume_add(udi, EINA_TRUE);
+ ERR("Error getting arguments.");
+ goto error;
}
+
+ if (!edbus_message_iter_arguments_get(variant, "s", &id_usage))
+ {
+ ERR("Type of variant not expected");
+ goto error;
+ }
+
+ if (!id_usage[0])
+ _e_fm_main_udisks_storage_add(path);
+ else if(!strcmp(id_usage, "filesystem"))
+ _e_fm_main_udisks_volume_add(path, EINA_TRUE);
else
- eina_stringshare_del(udi);
+ eina_stringshare_del(path);
+ return;
+error:
+ eina_stringshare_del(path);
}
static void
-_e_fm_main_udisks_cb_dev_add_verify(const char *udi,
- E_Ukit_Property *ret,
- DBusError *error)
+_e_fm_main_udisks_cb_dev_verify_added(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
- if (!ret) return;
+ const char *name, *txt, *id_usage, *path = data;
+ EDBus_Message_Iter *variant;
- if (dbus_error_is_set(error))
+ if (edbus_message_error_get(msg, &name, &txt))
{
- dbus_error_free(error);
- return;
+ ERR("Error %s %s.", name, txt);
+ goto error;
}
- if ((!ret->val.s) || (!ret->val.s[0])) /* storage */
- _e_fm_main_udisks_storage_add(udi);
- else if (!strcmp(ret->val.s, "filesystem"))
+ if (!edbus_message_arguments_get(msg, "v", &variant))
{
- INF("DB VOL+: %s", udi);
- _e_fm_main_udisks_volume_add(udi, EINA_FALSE);
+ ERR("Error getting arguments.");
+ goto error;
+ }
+
+ if (!edbus_message_iter_arguments_get(variant, "s", &id_usage))
+ {
+ ERR("Type of variant not expected");
+ goto error;
+ }
+
+ DBG("%s usage=%s", path, id_usage);
+ if (!id_usage[0])
+ {
+ E_Storage *s;
+ s = _storage_find_by_dbus_path(path);
+ if (!s)
+ _e_fm_main_udisks_storage_add(path);
+ else
+ edbus_proxy_property_get_all(s->proxy,
+ _e_fm_main_udisks_cb_store_prop, s);
+ }
+ else if(!strcmp(id_usage, "filesystem"))
+ {
+ E_Volume *v;
+ v = _volume_find_by_dbus_path(path);
+ if (!v)
+ _e_fm_main_udisks_volume_add(path, EINA_TRUE);
+ else
+ edbus_proxy_property_get_all(v->proxy,
+ _e_fm_main_udisks_cb_vol_prop, v);
}
else
- eina_stringshare_del(udi);
+ eina_stringshare_del(path);
+ return;
+error:
+ eina_stringshare_del(path);
}
static void
-_e_fm_main_udisks_cb_dev_add(void *data __UNUSED__,
- DBusMessage *msg)
+_e_fm_main_udisks_cb_dev_add(void *data __UNUSED__, const EDBus_Message *msg)
{
- DBusError err;
- char *udi = NULL;
+ EDBus_Message *new;
+ E_Volume *v;
+ char *path;
+
+ if (!edbus_message_arguments_get(msg, "o", &path))
+ return;
+ DBG("DB DEV+: %s", path);
+
+ v = _volume_find_by_dbus_path(path);
+ if (v)
+ {
+ edbus_proxy_property_get_all(v->proxy, _e_fm_main_udisks_cb_vol_prop, v);
+ return;
+ }
- dbus_error_init(&err);
- dbus_message_get_args(msg, &err, DBUS_TYPE_OBJECT_PATH, &udi, DBUS_TYPE_INVALID);
- if (!udi) return;
- e_udisks_get_property(_e_fm_main_udisks_conn, udi, "IdUsage",
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_dev_add_verify, (void*)eina_stringshare_add(udi));
+ new = edbus_message_method_call_new(UDISKS_BUS, path, EDBUS_FDO_INTERFACE_PROPERTIES, "Get");
+ edbus_message_arguments_append(new, "ss", UDISKS_DEVICE_INTERFACE, "IdUsage");
+ edbus_connection_send(_e_fm_main_udisks_conn, new,
+ _e_fm_main_udisks_cb_dev_verify_added,
+ eina_stringshare_add(path), -1);
}
static void
-_e_fm_main_udisks_cb_dev_del(void *data __UNUSED__,
- DBusMessage *msg)
+_e_fm_main_udisks_cb_dev_del(void *data __UNUSED__, const EDBus_Message *msg)
{
- DBusError err;
- char *udi;
+ char *path;
E_Volume *v;
- dbus_error_init(&err);
-
- dbus_message_get_args(msg,
- &err, DBUS_TYPE_OBJECT_PATH,
- &udi, DBUS_TYPE_INVALID);
- INF("DB DEV-: %s", udi);
- if ((v = _e_fm_main_udisks_volume_find(udi)))
+ if (!edbus_message_arguments_get(msg, "o", &path))
+ return;
+ DBG("DB DEV-: %s", path);
+ if ((v = _volume_find_by_dbus_path(path)))
{
if (v->optype == E_VOLUME_OP_TYPE_EJECT)
- _e_fm_main_udisks_cb_vol_ejected(v, msg, &err);
+ _e_fm_main_udisks_cb_vol_ejected(v);
}
- _e_fm_main_udisks_volume_del(udi);
- _e_fm_main_udisks_storage_del(udi);
+ _e_fm_main_udisks_volume_del(path);
+ _e_fm_main_udisks_storage_del(path);
}
static void
-_e_fm_main_udisks_cb_dev_chg(void *data __UNUSED__,
- DBusMessage *msg)
+_e_fm_main_udisks_cb_prop_modified(void *data,
+ const EDBus_Message *msg __UNUSED__)
{
- DBusError err;
- char *udi;
-
- dbus_error_init(&err);
+ E_Volume *v = data;
+ edbus_proxy_property_get_all(v->proxy, _e_fm_main_udisks_cb_vol_prop, v);
+}
- dbus_message_get_args(msg, &err,
- DBUS_TYPE_OBJECT_PATH, &udi,
- DBUS_TYPE_INVALID);
- INF("DB STORE CAP+: %s", udi);
- e_udisks_get_property(_e_fm_main_udisks_conn, udi, "IdUsage",
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_dev_add_verify, (void*)eina_stringshare_add(udi));
+static Eina_Bool
+_storage_del(void *data)
+{
+ const char *path = data;
+ _e_fm_main_udisks_storage_del(path);
+ return ECORE_CALLBACK_CANCEL;
}
static void
-_e_fm_main_udisks_cb_prop_modified(E_Volume *v,
- DBusMessage *msg)
+_e_fm_main_udisks_cb_store_prop(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
- if (!v) return;
+ E_Storage *s = data;
+ const char *name, *txt;
+ EDBus_Message_Iter *array, *dict;
- if (dbus_message_get_error_name(msg))
+ if (edbus_message_error_get(msg, &name, &txt))
{
- ERR("DBUS ERROR: %s", dbus_message_get_error_name(msg));
+ ERR("Error %s %s.", name, txt);
+ return;
+ }
+ if (!edbus_message_arguments_get(msg, "a{sv}", &array))
+ {
+ ERR("Error getting arguments.");
return;
}
- e_udisks_get_all_properties(_e_fm_main_udisks_conn, v->udi,
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_vol_prop, v);
-}
-static void
-_e_fm_main_udisks_cb_store_prop(E_Storage *s,
- E_Ukit_Properties *ret,
- DBusError *error)
-{
- const char *str;
- int err = 0;
+ while (edbus_message_iter_get_and_next(array, 'e', &dict))
+ {
+ char *key;
+ EDBus_Message_Iter *var;
+
+ if (!edbus_message_iter_arguments_get(dict, "sv", &key, &var))
+ continue;
+ if (!strcmp(key, "DeviceFile"))
+ {
+ const char *udi;
+ if (edbus_message_iter_arguments_get(var, "s", &udi))
+ eina_stringshare_replace(&s->udi, udi);
+ }
+ else if (!strcmp(key, "DriveConnectionInterface"))
+ {
+ const char *bus;
+ if (edbus_message_iter_arguments_get(var, "s", &bus))
+ {
+ if (s->bus)
+ eina_stringshare_del(bus);
+ s->bus = eina_stringshare_add(bus);
+ }
+ }
+ else if (!strcmp(key, "DriveMediaCompatibility"))
+ {
+ EDBus_Message_Iter *inner_array;
+ const char *media;
- if (!ret) goto error;
+ if (!edbus_message_iter_arguments_get(var, "as", &inner_array))
+ continue;
- if (dbus_error_is_set(error))
+ while(edbus_message_iter_get_and_next(inner_array, 's', &media))
+ {
+ eina_stringshare_replace(&s->drive_type, media);
+ break;
+ }
+ }
+ else if (!strcmp(key, "DriveModel"))
+ {
+ const char *model;
+ if (edbus_message_iter_arguments_get(var, "s", &model))
+ {
+ if (s->model)
+ eina_stringshare_del(s->model);
+ s->model = eina_stringshare_add(model);
+ }
+ }
+ else if (!strcmp(key, "DriveVendor"))
+ {
+ const char *vendor;
+ if (edbus_message_iter_arguments_get(var, "s", &vendor))
+ {
+ if (s->vendor)
+ eina_stringshare_del(s->vendor);
+ s->vendor = eina_stringshare_add(vendor);
+ }
+ }
+ else if (!strcmp(key, "DriveSerial"))
+ {
+ const char *serial;
+ if (edbus_message_iter_arguments_get(var, "s", &serial))
+ {
+ if (s->serial)
+ eina_stringshare_del(s->serial);
+ s->serial = eina_stringshare_add(serial);
+ }
+ }
+ else if (!strcmp(key, "DeviceIsSystemInternal"))
+ edbus_message_iter_arguments_get(var, "b", &s->system_internal);
+ else if (!strcmp(key, "DeviceIsMediaAvailable"))
+ edbus_message_iter_arguments_get(var, "b", &s->media_available);
+ else if (!strcmp(key, "DeviceSize"))
+ edbus_message_iter_arguments_get(var, "t", &s->media_size);
+ else if (!strcmp(key, "DriveIsMediaEjectable"))
+ edbus_message_iter_arguments_get(var, "b", &s->requires_eject);
+ else if (!strcmp(key, "DriveCanDetach"))
+ edbus_message_iter_arguments_get(var, "b", &s->hotpluggable);
+ else if (!strcmp(key, "DeviceIsMediaChangeDetectionInhibited"))
+ edbus_message_iter_arguments_get(var, "b", &s->media_check_enabled);
+ else if (!strcmp(key, "DevicePresentationIconName"))
+ {
+ const char *icon;
+ if (edbus_message_iter_arguments_get(var, "s", &icon))
+ {
+ if (s->icon.drive)
+ eina_stringshare_del(s->icon.drive);
+ s->icon.drive = NULL;
+ if (!icon[0])
+ s->icon.drive = eina_stringshare_add(icon);
+ s->icon.volume = s->icon.drive;
+ }
+ }
+ }
+ if (!s->udi)
{
- dbus_error_free(error);
- goto error;
+ ERR("removing storage with null udi %s", s->dbus_path);
+ ecore_idler_add(_storage_del, s->dbus_path);
+ return;
+ }
+ if (s->system_internal)
+ {
+ DBG("removing storage internal %s", s->udi);
+ ecore_idler_add(_storage_del, s->dbus_path);
+ return;
}
-
- s->bus = e_ukit_property_string_get(ret, "DriveConnectionInterface", &err);
- if (err) goto error;
- s->bus = eina_stringshare_add(s->bus);
- {
- const Eina_List *l;
-
- l = e_ukit_property_strlist_get(ret, "DriveMediaCompatibility", &err);
- if (err) goto error;
- if (l) s->drive_type = eina_stringshare_add(l->data);
- }
- s->model = e_ukit_property_string_get(ret, "DriveModel", &err);
- if (err) goto error;
- s->model = eina_stringshare_add(s->model);
- s->vendor = e_ukit_property_string_get(ret, "DriveVendor", &err);
- if (err) goto error;
- s->vendor = eina_stringshare_add(s->vendor);
- s->serial = e_ukit_property_string_get(ret, "DriveSerial", &err);
-// if (err) goto error;
- if (err) ERR("Error getting serial for %s", s->udi);
- s->serial = eina_stringshare_add(s->serial);
-
- //s->removable = e_ukit_property_bool_get(ret, "DeviceIsRemovable", &err);
- s->system_internal = e_ukit_property_bool_get(ret, "DeviceIsSystemInternal", &err);
- if (s->system_internal) goto error; /* only track non internal */
- str = e_ukit_property_string_get(ret, "IdUsage", &err);
- if (str && (!strcmp(str, "filesystem")))
- _e_fm_main_udisks_volume_add(s->udi, EINA_TRUE);
/* force it to be removable if it passed the above tests */
s->removable = EINA_TRUE;
-
-// ubuntu 10.04 - only dvd is reported as removable. usb storage and mmcblk
-// is not - but its not "system internal".
-// if (!s->removable) goto error; /* only track removable media */
- s->media_available = e_ukit_property_bool_get(ret, "DeviceIsMediaAvailable", &err);
- s->media_size = e_ukit_property_uint64_get(ret, "DeviceSize", &err);
-
- s->requires_eject = e_ukit_property_bool_get(ret, "DriveIsMediaEjectable", &err);
- s->hotpluggable = e_ukit_property_bool_get(ret, "DriveCanDetach", &err);
- s->media_check_enabled = !e_ukit_property_bool_get(ret, "DeviceIsMediaChangeDetectionInhibited", &err);
-
- s->icon.drive = e_ukit_property_string_get(ret, "DevicePresentationIconName", &err);
- if (s->icon.drive && s->icon.drive[0]) s->icon.drive = eina_stringshare_add(s->icon.drive);
- else s->icon.drive = NULL;
- s->icon.volume = e_ukit_property_string_get(ret, "DevicePresentationIconName", &err);
- if (s->icon.volume && s->icon.volume[0]) s->icon.volume = eina_stringshare_add(s->icon.volume);
- else s->icon.volume = NULL;
-
INF("++STO:\n udi: %s\n bus: %s\n drive_type: %s\n model: %s\n vendor: %s\n serial: %s\n icon.drive: %s\n icon.volume: %s\n", s->udi, s->bus, s->drive_type, s->model, s->vendor, s->serial, s->icon.drive, s->icon.volume);
s->validated = EINA_TRUE;
{
@@ -388,143 +449,204 @@ _e_fm_main_udisks_cb_store_prop(E_Storage *s,
}
}
return;
+}
-error:
-// ERR("ERR %s", s->udi);
- _e_fm_main_udisks_storage_del(s->udi);
+static Eina_Bool
+_idler_volume_del(void *data)
+{
+ const char *path = data;
+ _e_fm_main_udisks_volume_del(path);
+ return ECORE_CALLBACK_CANCEL;
}
static void
-_e_fm_main_udisks_cb_vol_prop(E_Volume *v,
- E_Ukit_Properties *ret,
- DBusError *error)
+_e_fm_main_udisks_cb_vol_prop(void *data, const EDBus_Message *msg,
+ EDBus_Pending *pending __UNUSED__)
{
+ E_Volume *v = data;
E_Storage *s = NULL;
- int err = 0;
- const char *str = NULL;
+ const char *txt, *message;
+ EDBus_Message_Iter *array, *dict;
- if ((!v) || (!ret)) goto error;
+ DBG("volume=%s",v->dbus_path);
- if (dbus_error_is_set(error))
+ if (edbus_message_error_get(msg, &txt, &message))
{
- dbus_error_free(error);
- ERR("err");
+ ERR("Error: %s %s\nVolume: %s", txt, message, v->udi);
+ return;
}
- if (e_ukit_property_bool_get(ret, "DeviceIsSystemInternal", &err)) goto error;
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
+ if (!edbus_message_arguments_get(msg, "a{sv}", &array))
+ {
+ ERR("Error getting values.");
+ return;
+ }
- /* skip volumes with volume.ignore set */
- if (e_ukit_property_bool_get(ret, "DeviceIsMediaChangeDetectionInhibited", &err)) goto error;
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- /* skip volumes that aren't filesystems */
- str = e_ukit_property_string_get(ret, "IdUsage", &err);
- EINA_SAFETY_ON_TRUE_GOTO(err || (!str), error);
- if (!str[0]) goto error; /* probably removal event */
- if (strcmp(str, "filesystem"))
+ while (edbus_message_iter_get_and_next(array, 'e', &dict))
{
- if (strcmp(str, "crypto"))
- v->encrypted = e_ukit_property_bool_get(ret, "DeviceIsLuks", &err);
+ EDBus_Message_Iter *var;
+ const char *key;
- if (!v->encrypted)
+ if (!edbus_message_iter_arguments_get(dict, "sv", &key, &var))
+ continue;
+ if (!strcmp(key, "DeviceFile"))
{
- ERR("I don't know what's going on here but I don't like it.");
- goto error;
+ const char *udi;
+ if (!edbus_message_iter_arguments_get(var, "s", &udi))
+ continue;
+ if (udi && v->first_time)
+ eina_stringshare_replace(&v->udi, udi);
}
- }
- str = NULL;
-
- eina_stringshare_replace(&v->uuid, e_ukit_property_string_get(ret, "IdUuid", &err));
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
-
- eina_stringshare_replace(&v->label, e_ukit_property_string_get(ret, "IdLabel", &err));
- if (!v->label) eina_stringshare_replace(&v->label, v->uuid);
- if (!v->label) eina_stringshare_replace(&v->label, e_ukit_property_string_get(ret, "DeviceFile", &err)); /* avoid having blank labels */
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- if (!v->encrypted)
- {
- const Eina_List *l;
+ else if (!strcmp(key, "DeviceIsSystemInternal"))
+ {
+ Eina_Bool internal;
+ edbus_message_iter_arguments_get(var, "b", &internal);
+ if (internal)
+ {
+ DBG("removing is internal %s", v->dbus_path);
+ ecore_idler_add(_idler_volume_del, v->dbus_path);
+ return;
+ }
+ }
+ else if (!strcmp(key, "DeviceIsMediaChangeDetectionInhibited"))
+ {
+ Eina_Bool inibited;
+ edbus_message_iter_arguments_get(var, "b", &inibited);
+ if (inibited)
+ {
+ /* skip volumes with volume.ignore set */
+ DBG("removing is inibited %s", v->dbus_path);
+ ecore_idler_add(_idler_volume_del, v->dbus_path);
+ return;
+ }
+ }
+ else if (!strcmp(key, "DeviceIsLuks"))
+ edbus_message_iter_arguments_get(var, "b", &v->encrypted);
+ else if (!strcmp(key, "IdUuid"))
+ {
+ const char *uuid;
+ if (!edbus_message_iter_arguments_get(var, "s", &uuid))
+ continue;
+ eina_stringshare_replace(&v->uuid, uuid);
+ }
+ else if (!strcmp(key, "IdLabel"))
+ {
+ const char *label;
+ if (!edbus_message_iter_arguments_get(var, "s", &label))
+ continue;
+ eina_stringshare_replace(&v->label, label);
+ }
+ else if (!strcmp(key, "DeviceMountPaths"))
+ {
+ EDBus_Message_Iter *inner_array;
+ const char *path;
- l = e_ukit_property_strlist_get(ret, "DeviceMountPaths", &err);
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- if (l) eina_stringshare_replace(&v->mount_point, eina_stringshare_add(l->data));
+ if (!edbus_message_iter_arguments_get(var, "as", &inner_array))
+ continue;
+ while (edbus_message_iter_get_and_next(inner_array, 's', &path))
+ {
+ eina_stringshare_replace(&v->mount_point, path);
+ break;
+ }
+ }
+ else if (!strcmp(key, "IdType"))
+ {
+ const char *type;
+ if (!edbus_message_iter_arguments_get(var, "s", &type))
+ continue;
+ eina_stringshare_replace(&v->fstype, type);
+ }
+ else if (!strcmp(key, "DeviceSize"))
+ edbus_message_iter_arguments_get(var, "t", &v->size);
+ else if (!strcmp(key, "DeviceIsMounted"))
+ edbus_message_iter_arguments_get(var, "b", &v->mounted);
+ else if (!strcmp(key, "DeviceIsLuksCleartext"))
+ edbus_message_iter_arguments_get(var, "b", &v->unlocked);
+ else if (!strcmp(key, "DeviceIsPartition"))
+ edbus_message_iter_arguments_get(var, "b", &v->partition);
+ else if (!strcmp(key, "PartitionNumber"))
+ edbus_message_iter_arguments_get(var, "i", &v->partition_number);
+ else if (!strcmp(key, "PartitionLabel"))
+ {
+ const char *partition_label;
+ if (!edbus_message_iter_arguments_get(var, "s", &partition_label))
+ continue;
+ eina_stringshare_replace(&v->partition_label, partition_label);
+ }
+ else if (!strcmp(key, "LuksCleartextSlave"))
+ {
+ const char *enc;
+ E_Volume *venc;
+ if (!edbus_message_iter_arguments_get(var, "o", &enc))
+ continue;
+ eina_stringshare_replace(&v->partition_label, enc);
+ venc = _e_fm_main_udisks_volume_find(enc);
+ if (!venc)
+ continue;
+ eina_stringshare_replace(&v->parent, venc->parent);
+ v->storage = venc->storage;
+ v->storage->volumes = eina_list_append(v->storage->volumes, v);
+ }
+ else if (!strcmp(key, "PartitionSlave"))
+ {
+ char *partition_slave;
+ if (!edbus_message_iter_arguments_get(var, "o", &partition_slave))
+ continue;
+ partition_slave = strdup(partition_slave);
+ sprintf(partition_slave, "/dev/%s",
+ partition_slave + strlen("/org/freedesktop/UDisks/devices/"));
+ eina_stringshare_replace(&v->parent, partition_slave);
+ free(partition_slave);
+ }
- eina_stringshare_replace(&v->fstype, e_ukit_property_string_get(ret, "IdType", &err));
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- v->size = e_ukit_property_uint64_get(ret, "DeviceSize", &err);
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- v->mounted = e_ukit_property_bool_get(ret, "DeviceIsMounted", &err);
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
}
- else
- v->unlocked = e_ukit_property_bool_get(ret, "DeviceIsLuksCleartext", &err);
-
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
- v->partition = e_ukit_property_bool_get(ret, "DeviceIsPartition", &err);
- EINA_SAFETY_ON_TRUE_GOTO(err, error);
-
- if (v->partition)
+ if (!v->udi)
{
- v->partition_number = e_ukit_property_int_get(ret, "PartitionNumber", NULL);
- eina_stringshare_replace(&v->partition_label, e_ukit_property_string_get(ret, "PartitionLabel", NULL));
+ ERR("!udi %s", v->dbus_path);
+ ecore_idler_add(_idler_volume_del, v);
+ return;
}
-
- if (v->unlocked)
+ if (!v->label) eina_stringshare_replace(&v->label, v->uuid);
+ if (v->parent && v->partition)
{
- const char *enc;
- E_Volume *venc;
-
- enc = e_ukit_property_string_get(ret, "LuksCleartextSlave", &err);
- venc = _e_fm_main_udisks_volume_find(enc);
- eina_stringshare_replace(&v->parent, venc->parent);
- v->storage = venc->storage;
- v->storage->volumes = eina_list_append(v->storage->volumes, v);
+ s = e_storage_find(v->parent);
+ if (s)
+ {
+ v->storage = s;
+ if (!eina_list_data_find_list(s->volumes, v))
+ s->volumes = eina_list_append(s->volumes, v);
+ }
}
else
{
- eina_stringshare_replace(&v->parent, e_ukit_property_string_get(ret, "PartitionSlave", &err));
-
- if (!err)
+ eina_stringshare_replace(&v->parent, v->udi);
+ s = e_storage_find(v->udi);
+ if (s)
{
- if (v->parent && v->partition)
- {
- s = e_storage_find(v->parent);
- if (s)
- {
- v->storage = s;
- if (!eina_list_data_find_list(s->volumes, v))
- s->volumes = eina_list_append(s->volumes, v);
- }
- }
- else
- {
- eina_stringshare_replace(&v->parent, v->udi);
- s = e_storage_find(v->udi);
- if (s)
- {
- v->storage = s;
- if (!eina_list_data_find_list(s->volumes, v))
- s->volumes = eina_list_append(s->volumes, v);
- }
- else
- {
- v->storage = _e_fm_main_udisks_storage_add(v->udi); /* disk is both storage and volume */
- if (v->storage) v->storage->volumes = eina_list_append(v->storage->volumes, v);
- }
- }
+ v->storage = s;
+ if (!eina_list_data_find_list(s->volumes, v))
+ s->volumes = eina_list_append(s->volumes, v);
+ }
+ else
+ {
+ v->storage = _e_fm_main_udisks_storage_add(
+ eina_stringshare_add(v->dbus_path));
+ /* disk is both storage and volume */
+ if (v->storage)
+ v->storage->volumes = eina_list_append(v->storage->volumes, v);
}
}
switch (v->optype)
{
case E_VOLUME_OP_TYPE_MOUNT:
- _e_fm_main_udisks_cb_vol_mounted(v, error);
+ _e_fm_main_udisks_cb_vol_mounted(v);
return;
case E_VOLUME_OP_TYPE_UNMOUNT:
- _e_fm_main_udisks_cb_vol_unmounted(v, error);
+ _e_fm_main_udisks_cb_vol_unmounted(v);
return;
case E_VOLUME_OP_TYPE_EJECT:
- _e_fm_main_udisks_cb_vol_unmounted_before_eject(v, NULL, error);
+ _e_fm_main_udisks_cb_vol_unmounted_before_eject(v);
return;
default:
break;
@@ -536,33 +658,30 @@ _e_fm_main_udisks_cb_vol_prop(E_Volume *v,
v->validated = EINA_TRUE;
e_fm_ipc_volume_add(v);
return;
-
-error:
- if (v) _e_fm_main_udisks_volume_del(v->udi);
- return;
}
static int
_e_fm_main_udisks_format_error_msg(char **buf,
E_Volume *v,
- DBusError *error)
+ const char *name,
+ const char *message)
{
int size, vu, vm, en;
char *tmp;
vu = strlen(v->udi) + 1;
vm = strlen(v->mount_point) + 1;
- en = strlen(error->name) + 1;
- size = vu + vm + en + strlen(error->message) + 1;
+ en = strlen(name) + 1;
+ size = vu + vm + en + strlen(message) + 1;
tmp = *buf = malloc(size);
strcpy(tmp, v->udi);
tmp += vu;
strcpy(tmp, v->mount_point);
tmp += vm;
- strcpy(tmp, error->name);
+ strcpy(tmp, name);
tmp += en;
- strcpy(tmp, error->message);
+ strcpy(tmp, message);
return size;
}
@@ -570,18 +689,18 @@ _e_fm_main_udisks_format_error_msg(char **buf,
static Eina_Bool
_e_fm_main_udisks_vol_mount_timeout(E_Volume *v)
{
- DBusError error;
char *buf;
int size;
v->guard = NULL;
- if (!dbus_pending_call_get_completed(v->op))
- dbus_pending_call_cancel(v->op);
+
+ if (v->op)
+ edbus_pending_cancel(v->op);
v->op = NULL;
v->optype = E_VOLUME_OP_TYPE_NONE;
- error.name = "org.enlightenment.fm2.MountTimeout";
- error.message = "Unable to mount the volume with specified time-out.";
- size = _e_fm_main_udisks_format_error_msg(&buf, v, &error);
+ size = _e_fm_main_udisks_format_error_msg(&buf, v,
+ "org.enlightenment.fm2.MountTimeout",
+ "Unable to mount the volume with specified time-out.");
ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_MOUNT_ERROR,
0, 0, 0, buf, size);
free(buf);
@@ -590,8 +709,7 @@ _e_fm_main_udisks_vol_mount_timeout(E_Volume *v)
}
static void
-_e_fm_main_udisks_cb_vol_mounted(E_Volume *v,
- DBusError *error)
+_e_fm_main_udisks_cb_vol_mounted(E_Volume *v)
{
char *buf;
int size;
@@ -602,16 +720,6 @@ _e_fm_main_udisks_cb_vol_mounted(E_Volume *v,
v->guard = NULL;
}
- if (error && dbus_error_is_set(error))
- {
- size = _e_fm_main_udisks_format_error_msg(&buf, v, error);
- ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_MOUNT_ERROR,
- 0, 0, 0, buf, size);
- dbus_error_free(error);
- free(buf);
- v->optype = E_VOLUME_OP_TYPE_NONE;
- return;
- }
if (!v->mount_point) return; /* come back later */
v->optype = E_VOLUME_OP_TYPE_NONE;
@@ -631,18 +739,17 @@ _e_fm_main_udisks_cb_vol_mounted(E_Volume *v,
static Eina_Bool
_e_fm_main_udisks_vol_unmount_timeout(E_Volume *v)
{
- DBusError error;
char *buf;
int size;
v->guard = NULL;
- if (!dbus_pending_call_get_completed(v->op))
- dbus_pending_call_cancel(v->op);
+ if (v->op)
+ edbus_pending_cancel(v->op);
v->op = NULL;
v->optype = E_VOLUME_OP_TYPE_NONE;
- error.name = "org.enlightenment.fm2.UnmountTimeout";
- error.message = "Unable to unmount the volume with specified time-out.";
- size = _e_fm_main_udisks_format_error_msg(&buf, v, &error);
+ size = _e_fm_main_udisks_format_error_msg(&buf, v,
+ "org.enlightenment.fm2.UnmountTimeout",
+ "Unable to unmount the volume with specified time-out.");
ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_UNMOUNT_ERROR,
0, 0, 0, buf, size);
free(buf);
@@ -651,8 +758,7 @@ _e_fm_main_udisks_vol_unmount_timeout(E_Volume *v)
}
static void
-_e_fm_main_udisks_cb_vol_unmounted(E_Volume *v,
- DBusError *error)
+_e_fm_main_udisks_cb_vol_unmounted(E_Volume *v)
{
char *buf;
int size;
@@ -668,15 +774,6 @@ _e_fm_main_udisks_cb_vol_unmounted(E_Volume *v,
v->optype = E_VOLUME_OP_TYPE_NONE;
v->op = NULL;
}
- if (dbus_error_is_set(error))
- {
- size = _e_fm_main_udisks_format_error_msg(&buf, v, error);
- ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_UNMOUNT_ERROR,
- 0, 0, 0, buf, size);
- dbus_error_free(error);
- free(buf);
- return;
- }
v->mounted = EINA_FALSE;
INF("UNMOUNT: %s from %s", v->udi, v->mount_point);
@@ -693,18 +790,17 @@ _e_fm_main_udisks_cb_vol_unmounted(E_Volume *v,
static Eina_Bool
_e_fm_main_udisks_vol_eject_timeout(E_Volume *v)
{
- DBusError error;
char *buf;
int size;
v->guard = NULL;
- if (!dbus_pending_call_get_completed(v->op))
- dbus_pending_call_cancel(v->op);
+ if (v->op)
+ edbus_pending_cancel(v->op);
v->op = NULL;
v->optype = E_VOLUME_OP_TYPE_NONE;
- error.name = "org.enlightenment.fm2.EjectTimeout";
- error.message = "Unable to eject the media with specified time-out.";
- size = _e_fm_main_udisks_format_error_msg(&buf, v, &error);
+ size = _e_fm_main_udisks_format_error_msg(&buf, v,
+ "org.enlightenment.fm2.EjectTimeout",
+ "Unable to eject the media with specified time-out.");
ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_EJECT_ERROR,
0, 0, 0, buf, size);
free(buf);
@@ -712,34 +808,91 @@ _e_fm_main_udisks_vol_eject_timeout(E_Volume *v)
return ECORE_CALLBACK_CANCEL;
}
+static void
+_volume_task_cb(void *data __UNUSED__, const EDBus_Message *msg __UNUSED__,
+ EDBus_Pending *pending __UNUSED__)
+{
+ /**
+ * if edbus_proxy_send has callback == NULL it will return a NULL
+ * but we need a EDBus_Pending to be able to cancel it when timeout occurs
+ */
+}
+
+static EDBus_Pending *
+_volume_umount(EDBus_Proxy *proxy)
+{
+ EDBus_Message *msg;
+ EDBus_Message_Iter *array, *main_iter;
+ EDBus_Pending *ret;
+
+ msg = edbus_proxy_method_call_new(proxy, "FilesystemUnmount");
+ main_iter = edbus_message_iter_get(msg);
+ edbus_message_iter_arguments_append(main_iter, "as", &array);
+ edbus_message_iter_container_close(main_iter, array);
+
+ ret = edbus_proxy_send(proxy, msg, _volume_task_cb, NULL, -1);
+ edbus_message_unref(msg);
+ return ret;
+}
+
+static EDBus_Pending *
+_volume_eject(EDBus_Proxy *proxy)
+{
+ EDBus_Message *msg;
+ EDBus_Message_Iter *array, *main_iter;
+ EDBus_Pending *ret;
+
+ msg = edbus_proxy_method_call_new(proxy, "DriveEject");
+ main_iter = edbus_message_iter_get(msg);
+ edbus_message_iter_arguments_append(main_iter, "as", &array);
+ edbus_message_iter_container_close(main_iter, array);
+
+ ret = edbus_proxy_send(proxy, msg, _volume_task_cb, NULL, -1);
+ edbus_message_unref(msg);
+ return ret;
+}
+
+static EDBus_Pending *
+_volume_mount(EDBus_Proxy *proxy, const char *fstype, Eina_List *opt)
+{
+ EDBus_Message *msg;
+ EDBus_Message_Iter *array, *main_iter;
+ Eina_List *l;
+ const char *opt_txt;
+ EDBus_Pending *ret;
+
+ msg = edbus_proxy_method_call_new(proxy, "FilesystemMount");
+ main_iter = edbus_message_iter_get(msg);
+ edbus_message_iter_arguments_append(main_iter, "sas", fstype, &array);
+ EINA_LIST_FOREACH(opt, l, opt_txt)
+ edbus_message_iter_basic_append(array, 's', opt_txt);
+ edbus_message_iter_container_close(main_iter, array);
+
+ ret = edbus_proxy_send(proxy, msg, _volume_task_cb, NULL, -1);
+ edbus_message_unref(msg);
+ return ret;
+}
+
static Eina_Bool
_e_fm_main_udisks_cb_vol_ejecting_after_unmount(E_Volume *v)
{
v->guard = ecore_timer_add(E_FM_EJECT_TIMEOUT, (Ecore_Task_Cb)_e_fm_main_udisks_vol_eject_timeout, v);
- v->op = e_udisks_volume_eject(_e_fm_main_udisks_conn, v->parent/*v->udi*/, NULL);
+ v->op = _volume_eject(v->storage->proxy);
return ECORE_CALLBACK_CANCEL;
}
static void
-_e_fm_main_udisks_cb_vol_unmounted_before_eject(E_Volume *v,
- void *method_return __UNUSED__,
- DBusError *error)
+_e_fm_main_udisks_cb_vol_unmounted_before_eject(E_Volume *v)
{
- Eina_Bool err;
-
- err = !!dbus_error_is_set(error);
- _e_fm_main_udisks_cb_vol_unmounted(v, error);
+ _e_fm_main_udisks_cb_vol_unmounted(v);
// delay is required for all message handlers were executed after unmount
- if (!err)
- ecore_timer_add(1.0, (Ecore_Task_Cb)_e_fm_main_udisks_cb_vol_ejecting_after_unmount, v);
+ ecore_timer_add(1.0, (Ecore_Task_Cb)_e_fm_main_udisks_cb_vol_ejecting_after_unmount, v);
}
static void
-_e_fm_main_udisks_cb_vol_ejected(E_Volume *v,
- void *method_return __UNUSED__,
- DBusError *error)
+_e_fm_main_udisks_cb_vol_ejected(E_Volume *v)
{
char *buf;
int size;
@@ -751,16 +904,6 @@ _e_fm_main_udisks_cb_vol_ejected(E_Volume *v,
}
v->optype = E_VOLUME_OP_TYPE_NONE;
- v->op = NULL;
- if (dbus_error_is_set(error))
- {
- size = _e_fm_main_udisks_format_error_msg(&buf, v, error);
- ecore_ipc_server_send(_e_fm_ipc_server, 6 /*E_IPC_DOMAIN_FM*/, E_FM_OP_EJECT_ERROR,
- 0, 0, 0, buf, size);
- dbus_error_free(error);
- free(buf);
- return;
- }
size = strlen(v->udi) + 1;
buf = alloca(size);
@@ -772,41 +915,45 @@ _e_fm_main_udisks_cb_vol_ejected(E_Volume *v,
}
E_Volume *
-_e_fm_main_udisks_volume_add(const char *udi,
+_e_fm_main_udisks_volume_add(const char *path,
Eina_Bool first_time)
{
E_Volume *v;
+ EDBus_Object *obj;
- if (!udi) return NULL;
- if (e_volume_find(udi)) return NULL;
+ if (!path) return NULL;
+ if (_volume_find_by_dbus_path(path)) return NULL;
v = calloc(1, sizeof(E_Volume));
if (!v) return NULL;
- INF("VOL+ %s", udi);
+ v->dbus_path = path;
+ INF("VOL+ %s", path);
v->efm_mode = EFM_MODE_USING_UDISKS_MOUNT;
- v->udi = eina_stringshare_add(udi);
v->icon = NULL;
v->first_time = first_time;
_e_vols = eina_list_append(_e_vols, v);
- e_udisks_get_all_properties(_e_fm_main_udisks_conn, v->udi,
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_vol_prop, v);
- v->prop_handler = e_dbus_signal_handler_add(_e_fm_main_udisks_conn,
- E_UDISKS_BUS,
- udi,
- E_UDISKS_INTERFACE,
- "Changed",
- (E_DBus_Signal_Cb)_e_fm_main_udisks_cb_prop_modified, v);
+ obj = edbus_object_get(_e_fm_main_udisks_conn, UDISKS_BUS, path);
+ v->proxy = edbus_proxy_get(obj, UDISKS_DEVICE_INTERFACE);
+ edbus_proxy_property_get_all(v->proxy, _e_fm_main_udisks_cb_vol_prop, v);
+ edbus_proxy_signal_handler_add(v->proxy, "Changed",
+ _e_fm_main_udisks_cb_prop_modified, v);
v->guard = NULL;
return v;
}
void
-_e_fm_main_udisks_volume_del(const char *udi)
+_e_fm_main_udisks_volume_del(const char *path)
{
E_Volume *v;
- v = e_volume_find(udi);
+ v = _volume_find_by_dbus_path(path);
if (!v) return;
+ _volume_del(v);
+}
+
+static void
+_volume_del(E_Volume *v)
+{
if (v->guard)
{
ecore_timer_del(v->guard);
@@ -825,7 +972,12 @@ _e_fm_main_udisks_volume_del(const char *udi)
if (v->storage && v->storage->requires_eject) return; /* udisks is stupid about ejectable media, so we have to keep stuff
* around for all eternity instead of deleting it constantly. oh noes.
*/
- if (v->prop_handler) e_dbus_signal_handler_del(_e_fm_main_udisks_conn, v->prop_handler);
+ if (v->proxy)
+ {
+ EDBus_Object *obj = edbus_proxy_object_get(v->proxy);
+ edbus_proxy_unref(v->proxy);
+ edbus_object_unref(obj);
+ }
_e_vols = eina_list_remove(_e_vols, v);
_e_fm_shared_device_volume_free(v);
}
@@ -845,6 +997,18 @@ _e_fm_main_udisks_volume_find(const char *udi)
return NULL;
}
+static E_Volume *
+_volume_find_by_dbus_path(const char *path)
+{
+ Eina_List *l;
+ E_Volume *v;
+
+ if (!path) return NULL;
+ EINA_LIST_FOREACH(_e_vols, l, v)
+ if (!strcmp(path, v->dbus_path)) return v;
+ return NULL;
+}
+
void
_e_fm_main_udisks_volume_eject(E_Volume *v)
{
@@ -852,12 +1016,12 @@ _e_fm_main_udisks_volume_eject(E_Volume *v)
if (v->mounted)
{
v->guard = ecore_timer_add(E_FM_UNMOUNT_TIMEOUT, (Ecore_Task_Cb)_e_fm_main_udisks_vol_unmount_timeout, v);
- v->op = e_udisks_volume_unmount(_e_fm_main_udisks_conn, v->udi, NULL);
+ v->op = _volume_umount(v->proxy);
}
else
{
v->guard = ecore_timer_add(E_FM_EJECT_TIMEOUT, (Ecore_Task_Cb)_e_fm_main_udisks_vol_eject_timeout, v);
- v->op = e_udisks_volume_eject(_e_fm_main_udisks_conn, v->parent/*v->udi*/, NULL);
+ v->op = _volume_eject(v->storage->proxy);
}
v->optype = E_VOLUME_OP_TYPE_EJECT;
}
@@ -865,12 +1029,12 @@ _e_fm_main_udisks_volume_eject(E_Volume *v)
void
_e_fm_main_udisks_volume_unmount(E_Volume *v)
{
- if (!v || v->guard) return;
- INF("unmount %s %s", v->udi, v->mount_point);
+ if (!v || v->guard) return;
+ INF("unmount %s %s", v->udi, v->mount_point);
- v->guard = ecore_timer_add(E_FM_UNMOUNT_TIMEOUT, (Ecore_Task_Cb)_e_fm_main_udisks_vol_unmount_timeout, v);
- v->op = e_udisks_volume_unmount(_e_fm_main_udisks_conn, v->udi, NULL);
- v->optype = E_VOLUME_OP_TYPE_UNMOUNT;
+ v->guard = ecore_timer_add(E_FM_UNMOUNT_TIMEOUT, (Ecore_Task_Cb)_e_fm_main_udisks_vol_unmount_timeout, v);
+ v->op = _volume_umount(v->proxy);
+ v->optype = E_VOLUME_OP_TYPE_UNMOUNT;
}
void
@@ -923,8 +1087,7 @@ _e_fm_main_udisks_volume_mount(E_Volume *v)
// e_udisks_volume_mount. The reason at the time was unknown and apparently never found.
// I theorize that this was due to improper mount options being passed (namely the utf8 options).
// If this still fails on Ubuntu 10.04 then an actual fix should be found.
- v->op = e_udisks_volume_mount(_e_fm_main_udisks_conn, v->udi,
- v->fstype, opt);
+ v->op = _volume_mount(v->proxy, v->fstype, opt);
eina_list_free(opt);
v->optype = E_VOLUME_OP_TYPE_MOUNT;
@@ -933,55 +1096,55 @@ _e_fm_main_udisks_volume_mount(E_Volume *v)
void
_e_fm_main_udisks_init(void)
{
- DBusMessage *msg;
-
- e_dbus_init();
- e_ukit_init();
- _e_fm_main_udisks_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ edbus_init();
+ _e_fm_main_udisks_conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SYSTEM);
if (!_e_fm_main_udisks_conn) return;
- if (!_udisks_poll)
- _udisks_poll = e_dbus_signal_handler_add(_e_fm_main_udisks_conn,
- E_DBUS_FDO_BUS, E_DBUS_FDO_PATH,
- E_DBUS_FDO_INTERFACE,
- "NameOwnerChanged", _e_fm_main_udisks_poll, NULL);
- e_dbus_get_name_owner(_e_fm_main_udisks_conn, E_UDISKS_BUS, _e_fm_main_udisks_test, NULL); /* test for already running udisks */
- msg = dbus_message_new_method_call(E_UDISKS_BUS, E_UDISKS_PATH, E_UDISKS_BUS, "suuuuuup");
- e_dbus_method_call_send(_e_fm_main_udisks_conn, msg, NULL, (E_DBus_Callback_Func)_e_fm_main_udisks_test, NULL, -1, NULL); /* test for not running udisks */
- dbus_message_unref(msg);
+ edbus_name_start(_e_fm_main_udisks_conn, UDISKS_BUS, 0,
+ _e_fm_main_udisks_name_start, NULL);
}
void
_e_fm_main_udisks_shutdown(void)
{
+ if (_e_fm_main_udisks_proxy)
+ {
+ EDBus_Object *obj;
+ obj = edbus_proxy_object_get(_e_fm_main_udisks_proxy);
+ edbus_proxy_unref(_e_fm_main_udisks_proxy);
+ edbus_object_unref(obj);
+ }
if (_e_fm_main_udisks_conn)
- e_dbus_connection_close(_e_fm_main_udisks_conn);
- e_ukit_shutdown();
- e_dbus_shutdown();
+ edbus_connection_unref(_e_fm_main_udisks_conn);
+ edbus_shutdown();
}
E_Storage *
-_e_fm_main_udisks_storage_add(const char *udi)
+_e_fm_main_udisks_storage_add(const char *path)
{
E_Storage *s;
+ EDBus_Object *obj;
- if (!udi) return NULL;
- if (e_storage_find(udi)) return NULL;
+ if (!path) return NULL;
+ if (_storage_find_by_dbus_path(path)) return NULL;
s = calloc(1, sizeof(E_Storage));
if (!s) return NULL;
- s->udi = eina_stringshare_add(udi);
+
+ DBG("STORAGE+=%s", path);
+ s->dbus_path = path;
_e_stores = eina_list_append(_e_stores, s);
- e_udisks_get_all_properties(_e_fm_main_udisks_conn, s->udi,
- (E_DBus_Callback_Func)_e_fm_main_udisks_cb_store_prop, s);
+ obj = edbus_object_get(_e_fm_main_udisks_conn, UDISKS_BUS, path);
+ s->proxy = edbus_proxy_get(obj, UDISKS_DEVICE_INTERFACE);
+ edbus_proxy_property_get_all(s->proxy, _e_fm_main_udisks_cb_store_prop, s);
return s;
}
void
-_e_fm_main_udisks_storage_del(const char *udi)
+_e_fm_main_udisks_storage_del(const char *path)
{
E_Storage *s;
- s = e_storage_find(udi);
+ s = _storage_find_by_dbus_path(path);
if (!s) return;
if (s->validated)
{
@@ -992,9 +1155,26 @@ _e_fm_main_udisks_storage_del(const char *udi)
0, 0, 0, s->udi, strlen(s->udi) + 1);
}
_e_stores = eina_list_remove(_e_stores, s);
+ if (s->proxy)
+ {
+ EDBus_Object *obj = edbus_proxy_object_get(s->proxy);
+ edbus_proxy_unref(s->proxy);
+ edbus_object_unref(obj);
+ }
_e_fm_shared_device_storage_free(s);
}
+static E_Storage *
+_storage_find_by_dbus_path(const char *path)
+{
+ Eina_List *l;
+ E_Storage *s;
+
+ EINA_LIST_FOREACH(_e_stores, l, s)
+ if (!strcmp(path, s->dbus_path)) return s;
+ return NULL;
+}
+
E_Storage *
_e_fm_main_udisks_storage_find(const char *udi)
{
@@ -1003,6 +1183,7 @@ _e_fm_main_udisks_storage_find(const char *udi)
EINA_LIST_FOREACH(_e_stores, l, s)
{
+ if (!s->udi) continue;
if (!strcmp(udi, s->udi)) return s;
}
return NULL;
diff --git a/src/bin/e_fm_shared_device.c b/src/bin/e_fm_shared_device.c
index 4937546f1..78a7e1e4a 100644
--- a/src/bin/e_fm_shared_device.c
+++ b/src/bin/e_fm_shared_device.c
@@ -18,7 +18,8 @@ _e_fm_shared_device_storage_free(E_Storage *s)
eina_stringshare_del(s->serial);
eina_stringshare_del(s->icon.drive);
eina_stringshare_del(s->icon.volume);
-#ifdef HAVE_EEZE_MOUNT
+ eina_stringshare_del(s->dbus_path);
+#if HAVE_EEZE_MOUNT
if (s->disk) eeze_disk_free(s->disk);
#endif
free(s);
@@ -30,8 +31,8 @@ _e_fm_shared_device_volume_free(E_Volume *v)
{
if (v->storage)
{
- v->storage->volumes = eina_list_remove(v->storage->volumes, v);
- v->storage = NULL;
+ 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);
@@ -41,5 +42,6 @@ _e_fm_shared_device_volume_free(E_Volume *v)
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);
+ eina_stringshare_del(v->dbus_path);
free(v);
}
diff --git a/src/bin/e_fm_shared_types.h.in b/src/bin/e_fm_shared_types.h.in
index 4f7446a5f..2ae5f2a7f 100644
--- a/src/bin/e_fm_shared_types.h.in
+++ b/src/bin/e_fm_shared_types.h.in
@@ -9,7 +9,7 @@
# include <Eeze_Disk.h>
#endif
#if @DBUS_MOUNT_CONFIG@
-# include <E_DBus.h>
+# include <EDBus.h>
#endif
# define E_DEVICE_TYPE_STORAGE 1
@@ -70,6 +70,10 @@ struct _E_Storage
Eina_Bool validated : 1;
Eina_Bool trackable : 1;
+#if @DBUS_MOUNT_CONFIG@
+ EDBus_Proxy *proxy;
+ const char *dbus_path;
+#endif
#if @EEZE_MOUNT_CONFIG@
Eeze_Disk *disk;
#endif
@@ -107,8 +111,9 @@ struct _E_Volume
Eina_Bool unlocked;
#if @DBUS_MOUNT_CONFIG@
- DBusPendingCall *op; // d-bus call handle
- void *prop_handler;
+ EDBus_Pending *op;
+ EDBus_Proxy *proxy;
+ const char *dbus_path;
#endif
#if @EEZE_MOUNT_CONFIG@
Eeze_Disk *disk;