[Vala] Question about DBusConnection.add_filter()



Hi everybody,

as an absolute beginner to vala I'm having a hard time to understand how
I should use the add_filter() method in DBusConnection class.

Excuse me if they are a lot of questions ...

1) The valadoc gives the following description for
DBusConnection.add_filter():

public uint add_filter (DBusMessageFilterFunction filter_function,
DestroyNotify user_data_free_func)

but this doesn't seem to match the corresponding method in gio:

guint g_dbus_connection_add_filter (GDBusConnection *connection,
GDBusMessageFilterFunction filter_function, gpointer user_data,
GDestroyNotify user_data_free_func);

where is the user_data pointer in the vala's equivalent method?

2) About the FilterFunction to be passed to add_event(), valadoc gives
the following description:

public bool DBusMessageFilterFunction (DBusConnection connection,
DBusMessage message, bool incoming)

but again this doesn't seem to match the corresponding method in gio:

GDBusMessage *(*GDBusMessageFilterFunction) (GDBusConnection
*connection, GDBusMessage *message, gboolean incoming, gpointer
user_data);

again due to the user_data parameter being missing in the vala's method.
And when should it return true or false?

3) Moreover, how should I define the filter_function? I've tried the
following:

  private bool MyFilterMsg (DBusConnection connection, 
                             DBusMessage message,
                             bool incoming)
  {
        return true;    
  }                  
  ...
  uint filter_uid = connection.add_filter (MyFilterMsg, ...)

but then the compiler complains that it cannot convert from MyFilterMsg
to GLib.DBusMessageFilter.

Thanks in advance.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]