Add a getter for DBusConnection pointer from E_DBus_Connection.
[framework/uifw/edbus.git] / src / lib / dbus / e_dbus_object.c
index 6158a1b..5212f9a 100644 (file)
@@ -206,19 +206,14 @@ e_dbus_object_shutdown(void)
   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;
 
@@ -239,11 +234,6 @@ e_dbus_object_add(E_DBus_Connection *conn, const char *object_path, void *data)
   return obj;
 }
 
-/**
- * Free a dbus object
- *
- * @param obj the object to free
- */
 EAPI void
 e_dbus_object_free(E_DBus_Object *obj)
 {
@@ -264,62 +254,36 @@ 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)
 {
@@ -329,6 +293,9 @@ e_dbus_object_property_set_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Set
 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;
@@ -342,7 +309,7 @@ e_dbus_object_interface_detach(E_DBus_Object *obj, E_DBus_Interface *iface)
 
   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;
@@ -379,18 +346,6 @@ e_dbus_interface_free(E_DBus_Interface *iface)
 }
 
 
-/**
- * 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)
 {
@@ -404,15 +359,6 @@ e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const c
   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)
 {
@@ -600,8 +546,8 @@ _introspect_indent_append(Eina_Strbuf *buf, int level)
 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);
@@ -611,10 +557,10 @@ _introspect_interface_append(Eina_Strbuf *buf, E_DBus_Interface *iface, int leve
   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);
@@ -669,24 +615,24 @@ _introspect_method_append(Eina_Strbuf *buf, E_DBus_Method *method, int 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);
@@ -715,3 +661,10 @@ _introspect_arg_append(Eina_Strbuf *buf, const char *type, const char *direction
   eina_strbuf_append(buf, "\"/>\n");
 }
 
+
+
+DBusConnection *e_dbus_conn_object_get(E_DBus_Connection *conn)
+{
+   if (conn!=NULL)
+     return conn->conn;
+}