DBus学习(4)---相关接口函数

江枫思渺然 提交于 2019-12-06 08:16:48

*引用本文请注明来自 blog.csdn.net/wtz1985       

下面是常用的函数接口,使用了glib的数据类型和函数调用规范。可变参数一般是调用的方法的参数列表。

     1.获取一个连接(bus).

     DBusGConnection* dbus_g_bus_get (DBusBusType type, Gerror **error);

 

     2.获取一个对象的代理

     DBusGProxy* dbus_g_proxy_new_for_name (DBusGConnection *connection,

                                                                       const char      *bus_name,

                                                                       const char      *path_name,

                                                                           const char      *interface_name);

 

     3.同步调用对象的方法并返回结果,参数error后面是输入参数列表和输出参数列表。

     gboolean dbus_g_proxy_call (DBusGProxy        *proxy,

                                        const char        *method,

                                        GError           **error,

                                        GType           first_arg_type,

                                         ...);

 

4.异步调用对象的方法,回调函数notify由用户提供。

DBusGProxyCall * dbus_g_proxy_begin_call (DBusGProxy          *proxy,

                                                                       const char          *method,

                                                                       DBusGProxyCallNotify notify,

                                                                       gpointer             user_data,

                                                                       GDestroyNotify      destroy,

                                                                       GType              first_arg_type,

                                                                       ...);

 

5.异步调用结束获取调用结果,此函数一般在回调函数notify中调用.

gboolean dbus_g_proxy_end_call (DBusGProxy          *proxy,

                                                DBusGProxyCall      *call,

                                                GError             **error,

                                                GType                first_arg_type,

                                                ...);

 

6.取消正在处理的异步调用,参数call是从dbus_g_proxy_begin_call函数返回的。

void dbus_g_proxy_cancel_call (DBusGProxy        *proxy, DBusGProxyCall    *call);

 

7.异步调用对象的方法,不需要返回结果,相当于dbus_g_proxy_begin_call,但不需要获取结果.

void dbus_g_proxy_call_no_reply (DBusGProxy               *proxy,

                                                     const char               *method,

                                                     GType                     first_arg_type,

                                                      ...);

 

8.增加一个信号,通知对象调用者需要捕获指定的信号

void dbus_g_proxy_add_signal  (DBusGProxy        *proxy,

                                                   const char        *signal_name,

                                                   GType           first_type,

                                                   ...);

 

9.连接信号,将处理函数handler连接到指定的信号上。

void dbus_g_proxy_connect_signal (DBusGProxy             *proxy,

                                                       const char             *signal_name,

                                                       GCallback               handler,

                                                       void                   *data,

                                                       GClosureNotify          free_data_func);

 

10.解除信号的连接,解除处理函数handler和指定的信号的连接。

void dbus_g_proxy_disconnect_signal (DBusGProxy             *proxy,

                                                            const char             *signal_name,

                                                            GCallback               handler,

                                                            void                   *data);

 

11.安装对象的类型信息

void dbus_g_object_type_install_info (GType                  object_type,

                                                          const DBusGObjectInfo *info);

 

12.注册对象,Dbus的一个连接注册对象。

void dbus_g_connection_register_g_object (DBusGConnection       *connection,

                                                                    const char            *at_path,
                                                                   
GObject               *object);

这是比较常用的接口函数,有了这些函数和之前的对DBUS的介绍,可以为自己写一个测试程序了.

 

~~END~~    

 

 

 

 

 

 

 

 

 

 

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!