6 #include "e_ukit_private.h"
8 #define E_UKIT_BUS E_UDISKS_BUS
9 #define E_UKIT_PATH E_UDISKS_PATH
10 #define E_UKIT_INTERFACE E_UDISKS_INTERFACE
12 const char *e_udisks_iface="org.freedesktop.UDisks.Device";
15 static void cb_device_get_property(void *data, DBusMessage *msg, DBusError *err);
16 static void cb_device_get_all_properties(void *data, DBusMessage *msg, DBusError *err);
17 static void cb_device_query_capability(void *data, DBusMessage *msg, DBusError *err);
21 EAPI DBusPendingCall *
22 e_udisks_get_property(E_DBus_Connection *conn, const char *udi, const char *property, E_DBus_Callback_Func cb_func, void *data)
27 EINA_SAFETY_ON_NULL_RETURN_VAL(udi, NULL);
28 EINA_SAFETY_ON_TRUE_RETURN_VAL(!udi[0], NULL);
29 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
30 EINA_SAFETY_ON_NULL_RETURN_VAL(property, NULL);
32 msg = e_ukit_property_call_new(udi, "Get");
33 dbus_message_append_args(msg, DBUS_TYPE_STRING, &e_udisks_iface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
34 ret = e_dbus_method_call_send(conn, msg, unmarshal_property, cb_func, free_property, -1, data);
35 dbus_message_unref(msg);
39 /* Properties.GetAll */
40 EAPI DBusPendingCall *
41 e_udisks_get_all_properties(E_DBus_Connection *conn, const char *udi, E_DBus_Callback_Func cb_func, void *data)
46 EINA_SAFETY_ON_NULL_RETURN_VAL(udi, NULL);
47 EINA_SAFETY_ON_TRUE_RETURN_VAL(!udi[0], NULL);
48 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
50 msg = e_ukit_property_call_new(udi, "GetAll");
51 dbus_message_append_args(msg, DBUS_TYPE_STRING, &e_udisks_iface, DBUS_TYPE_INVALID);
52 ret = e_dbus_method_call_send(conn, msg, unmarshal_device_get_all_properties, cb_func, free_device_get_all_properties, -1, data);
53 dbus_message_unref(msg);
59 /* void FilesystemMount(string fstype, array{string}options) */
62 * @brief Mount a Filesystem
64 * @param conn the E_DBus_Connection
65 * @param udi the udi of the device object
66 * @param fstype the fstype of the device (e.g. volume.fstype property)
67 * @param options a list of additional options to pass to mount
69 * @return mount point of fs or error
71 EAPI DBusPendingCall *
72 e_udisks_volume_mount(E_DBus_Connection *conn, const char *udi, const char *fstype, Eina_List *options)
75 DBusMessageIter iter, subiter;
79 EINA_SAFETY_ON_NULL_RETURN_VAL(udi, NULL);
80 EINA_SAFETY_ON_TRUE_RETURN_VAL(!udi[0], NULL);
81 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
83 msg = e_ukit_device_call_new(udi, "FilesystemMount");
85 dbus_message_iter_init_append(msg, &iter);
86 dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &fstype);
87 if (dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &subiter))
93 EINA_LIST_FOREACH(options, l, opt)
94 dbus_message_iter_append_basic(&subiter, DBUS_TYPE_STRING, &opt);
96 dbus_message_iter_close_container(&iter, &subiter);
100 ERR("dbus_message_iter_open_container() failed");
103 ret = e_dbus_method_call_send(conn, msg, NULL, NULL, NULL, -1, NULL);
104 dbus_message_unref(msg);
108 /* void Unmount(array{string} options) */
111 * @brief Unmount a Volume
113 * @param conn the E_DBus_Connection
114 * @param udi the udi of the device object
115 * @param options a list of additional options (currently only 'force' is supported)
117 EAPI DBusPendingCall *
118 e_udisks_volume_unmount(E_DBus_Connection *conn, const char *udi, Eina_List *options)
121 DBusMessageIter iter, subiter;
123 DBusPendingCall *ret;
125 EINA_SAFETY_ON_NULL_RETURN_VAL(udi, NULL);
126 EINA_SAFETY_ON_TRUE_RETURN_VAL(!udi[0], NULL);
127 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
129 msg = e_ukit_device_call_new(udi, "FilesystemUnmount");
131 dbus_message_iter_init_append(msg, &iter);
132 if (dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &subiter))
138 EINA_LIST_FOREACH(options, l, opt)
139 dbus_message_iter_append_basic(&subiter, DBUS_TYPE_STRING, &opt);
141 dbus_message_iter_close_container(&iter, &subiter);
145 ERR("dbus_message_iter_open_container() failed");
148 ret = e_dbus_method_call_send(conn, msg, NULL, NULL, NULL, -1, NULL);
149 dbus_message_unref(msg);
154 * @brief Eject a Volume
156 * @param conn the E_DBus_Connection
157 * @param udi the udi of the device object
158 * @param options a list of additional options (none currently supported)
160 EAPI DBusPendingCall *
161 e_udisks_volume_eject(E_DBus_Connection *conn, const char *udi, Eina_List *options)
164 DBusMessageIter iter, subiter;
166 DBusPendingCall *ret;
168 EINA_SAFETY_ON_NULL_RETURN_VAL(udi, NULL);
169 EINA_SAFETY_ON_TRUE_RETURN_VAL(!udi[0], NULL);
170 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
172 msg = e_ukit_device_call_new(udi, "DriveEject");
174 dbus_message_iter_init_append(msg, &iter);
175 if (dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &subiter))
181 EINA_LIST_FOREACH(options, l, opt)
182 dbus_message_iter_append_basic(&subiter, DBUS_TYPE_STRING, &opt);
184 dbus_message_iter_close_container(&iter, &subiter);
188 ERR("dbus_message_iter_open_container() failed");
191 ret = e_dbus_method_call_send(conn, msg, NULL, NULL, NULL, -1, NULL);
192 dbus_message_unref(msg);
196 /* EnumerateDevices */
197 EAPI DBusPendingCall *
198 e_udisks_get_all_devices(E_DBus_Connection *conn, E_DBus_Callback_Func cb_func, void *data)
201 DBusPendingCall *ret;
203 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
205 msg = e_ukit_call_new(E_UKIT_PATH, "EnumerateDevices");
206 ret = e_dbus_method_call_send(conn, msg, unmarshal_string_list, cb_func, free_string_list, -1, data);
207 dbus_message_unref(msg);