e_dbus_object_init(void)
{
introspectable_interface = e_dbus_interface_new("org.freedesktop.DBus.Introspectable");
- properties_interface = e_dbus_interface_new("org.freedesktop.DBus.Properties");
+ properties_interface = e_dbus_interface_new(E_DBUS_FDO_INTERFACE_PROPERTIES);
if (!introspectable_interface || !properties_interface)
{
if (introspectable_interface) e_dbus_interface_unref(introspectable_interface);
properties_interface = NULL;
}
-/**
- * Add a dbus object.
- *
- * @param conn the connection on with the object should listen
- * @param object_path a unique string identifying an object (e.g. org/enlightenment/WindowManager
- * @param data custom data to set on the object (retrievable via
- * e_dbus_object_data_get())
- */
EAPI E_DBus_Object *
e_dbus_object_add(E_DBus_Connection *conn, const char *object_path, void *data)
{
E_DBus_Object *obj;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, NULL);
+
obj = calloc(1, sizeof(E_DBus_Object));
if (!obj) return NULL;
return obj;
}
-/**
- * Free a dbus object
- *
- * @param obj the object to free
- */
EAPI void
e_dbus_object_free(E_DBus_Object *obj)
{
free(obj);
}
-/**
- * @brief Fetch the data pointer for a dbus object
- * @param obj the dbus object
- */
EAPI void *
e_dbus_object_data_get(E_DBus_Object *obj)
{
return obj->data;
}
-/**
- * @brief Get the dbus connection of a dbus object
- * @param obj the dbus object
- */
EAPI E_DBus_Connection *
e_dbus_object_conn_get(E_DBus_Object *obj)
{
return obj->conn;
}
-/**
- * @brief Get the path of a dbus object
- * @param obj the dbus object
- */
EAPI const char *
e_dbus_object_path_get(E_DBus_Object *obj)
{
return obj->path;
}
-/**
- * @brief Get the interfaces of a dbus object
- * @param obj the dbus object
- */
EAPI const Eina_List *
e_dbus_object_interfaces_get(E_DBus_Object *obj)
{
return obj->interfaces;
}
-/**
- * @brief Sets the callback to fetch properties from an object
- * @param obj the object
- * @param func the callback
- */
EAPI void
e_dbus_object_property_get_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Get_Cb func)
{
obj->cb_property_get = func;
}
-/**
- * @brief Sets the callback to set properties on an object
- * @param obj the object
- * @param func the callback
- */
EAPI void
e_dbus_object_property_set_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Set_Cb func)
{
EAPI void
e_dbus_object_interface_attach(E_DBus_Object *obj, E_DBus_Interface *iface)
{
+ EINA_SAFETY_ON_NULL_RETURN(obj);
+ EINA_SAFETY_ON_NULL_RETURN(iface);
+
e_dbus_interface_ref(iface);
obj->interfaces = eina_list_append(obj->interfaces, iface);
obj->introspection_dirty = 1;
DBG("e_dbus_object_interface_detach (%s, %s) ", obj->path, iface->name);
found = eina_list_data_find(obj->interfaces, iface);
- if (found == NULL) return;
+ if (!found) return;
obj->interfaces = eina_list_remove(obj->interfaces, iface);
obj->introspection_dirty = 1;
}
-/**
- * Add a method to an object
- *
- * @param iface the E_DBus_Interface to which this method belongs
- * @param member the name of the method
- * @param signature an optional message signature. if provided, then messages
- * with invalid signatures will be automatically rejected
- * (an Error response will be sent) and introspection data
- * will be available.
- *
- * @return 1 if successful, 0 if failed (e.g. no memory)
- */
EAPI int
e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func)
{
return 1;
}
-/**
- * Add a signal to an object
- *
- * @param iface the E_DBus_Interface to which this signal belongs
- * @param name the name of the signal
- * @param signature an optional message signature.
- *
- * @return 1 if successful, 0 if failed (e.g. no memory)
- */
EAPI int
e_dbus_interface_signal_add(E_DBus_Interface *iface, const char *name, const char *signature)
{
else
reply = m->func(obj, message);
+ /* user can choose reply later */
+ if (!reply)
+ return DBUS_HANDLER_RESULT_HANDLED;
+
dbus_connection_send(conn, reply, &serial);
dbus_message_unref(reply);
static void
_introspect_interface_append(Eina_Strbuf *buf, E_DBus_Interface *iface, int level)
{
- E_DBus_Method *method;
- E_DBus_Signal *signal;
+ E_DBus_Method *m;
+ E_DBus_Signal *s;
Eina_List *l;
_introspect_indent_append(buf, level);
level++;
DBG("introspect iface: %s", iface->name);
- EINA_LIST_FOREACH(iface->methods, l, method)
- _introspect_method_append(buf, method, level);
- EINA_LIST_FOREACH(iface->signals, l, signal)
- _introspect_signal_append(buf, signal, level);
+ EINA_LIST_FOREACH(iface->methods, l, m)
+ _introspect_method_append(buf, m, level);
+ EINA_LIST_FOREACH(iface->signals, l, s)
+ _introspect_signal_append(buf, s, level);
level--;
_introspect_indent_append(buf, level);
}
static void
-_introspect_signal_append(Eina_Strbuf *buf, E_DBus_Signal *signal, int level)
+_introspect_signal_append(Eina_Strbuf *buf, E_DBus_Signal *s, int level)
{
DBusSignatureIter iter;
char *type;
_introspect_indent_append(buf, level);
- DBG("introspect signal: %s", signal->name);
+ DBG("introspect signal: %s", s->name);
eina_strbuf_append(buf, "<signal name=\"");
- eina_strbuf_append(buf, signal->name);
+ eina_strbuf_append(buf, s->name);
eina_strbuf_append(buf, "\">\n");
level++;
/* append args */
- if (signal->signature &&
- signal->signature[0] &&
- dbus_signature_validate(signal->signature, NULL))
+ if (s->signature &&
+ s->signature[0] &&
+ dbus_signature_validate(s->signature, NULL))
{
- dbus_signature_iter_init(&iter, signal->signature);
+ dbus_signature_iter_init(&iter, s->signature);
while ((type = dbus_signature_iter_get_signature(&iter)))
{
_introspect_arg_append(buf, type, NULL, level);
eina_strbuf_append(buf, "\"/>\n");
}
+
+
+DBusConnection *e_dbus_conn_object_get(E_DBus_Connection *conn)
+{
+ if (conn!=NULL)
+ return conn->conn;
+}