Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support file descriptor with Gio::UnixFDList #95

Open
WooJungMo opened this issue Mar 17, 2020 · 7 comments
Open

Support file descriptor with Gio::UnixFDList #95

WooJungMo opened this issue Mar 17, 2020 · 7 comments

Comments

@WooJungMo
Copy link

WooJungMo commented Mar 17, 2020

gdbus-codegen supports file descriptors as the following anntation and GUnixFDList.

<annotation name = "org.gtk.GDBus.C.UnixFD" value = "true" />

It would be nice if gdbus-codegen-glibmm also supports file descriptors with the same annotation and Gio::UnixFDList.

I'm using glibmm's low API because the generator doesn't support it right now, so the code is unnatural.

@mardy
Copy link
Contributor

mardy commented Mar 18, 2020

In case someone wants to contribute a patch, the main file that will have to be modified is dbustypes.py.

I don't understand, though, why an annotation is needed. The file descriptors have their own signature (h), so it would be nice to know why the annotation is needed too.

@WooJungMo
Copy link
Author

I also wonder why gdbus supports file descriptors with annotation and GUnixFDList, not the dbustype 'h'.

In my opinion, glib(gdbus) supports multiple OS platforms, unlike libdbus. So it seems to separate what is supported on UNIX platforms such as FD passing.

@martin-ejdestig
Copy link
Contributor

martin-ejdestig commented Mar 19, 2020

I am not sure why the annotation was originally added (https://gitlab.gnome.org/GNOME/glib/commit/c404dbed11bc8bf4212d15719ef3a87ebf76efff in GLib does not say), but behavior in gdbus-codegen changed recently to generate GUnixFDList for h if --glib-min-version 2.64 is passed. See https://gitlab.gnome.org/GNOME/glib/commit/e3f80b925405359ed70530f5a478d0e70ed78a4d and discussion in https://gitlab.gnome.org/GNOME/glib/issues/1726 .

I do not see why an annotation would be needed for gdbus-codegen-glibmm (nor in gdbus-codegen) but perhaps I am missing something.

@martin-ejdestig
Copy link
Contributor

martin-ejdestig commented Mar 19, 2020

In my opinion, glib(gdbus) supports multiple OS platforms, unlike libdbus. So it seems to separate what is supported on UNIX platforms such as FD passing.

That h is a UNIX file descriptor is in the D-Bus specification though. Platform does not matter.

@WooJungMo
Copy link
Author

Thank you for the detailed explanation.

@martin-ejdestig
Copy link
Contributor

martin-ejdestig commented Mar 19, 2020

One gets all fd:s in a single GUnixFdList though, it seems like... in same order as arguments and have to map index in that list to argument... ??? Am I missing something? If not, I wonder why they have designed the Glib API like this. Seems to be better handled in Qt where they map directly to QDBusUnixFileDescriptor.

@WooJungMo
Copy link
Author

Before the commit(https://gitlab.gnome.org/GNOME/glib/commit/e3f80b925405359ed70530f5a478d0e70ed78a4d ) was applied, GUnixFDList was not related to arguments.

I haven't tried the latest glib version yet, so I'm not sure how 'h' works with GUnixFDList. However, this is a very interesting topic.

I am wondering what will be the index of the GUnixFDList and the index of the 'h' arguments, assuming the method below.

<method name="NoAnnotation"> <arg name="greeting" direction="in" type="h"/> <arg name="greeting_locale" direction="in" type="s"/> <arg name="response" direction="out" type="h"/> <arg name="response_locale" direction="out" type="s"/> </method>
https://github.com/GNOME/glib/blob/mainline/gio/tests/test-codegen.xml#L484

#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 static gboolean handle_no_annotation (FooiGenFDPassing *object, GDBusMethodInvocation *invocation, GUnixFDList *fd_list, GVariant *arg_greeting, const gchar *arg_greeting_locale) { foo_igen_fdpassing_complete_no_annotation (object, invocation, fd_list, arg_greeting, arg_greeting_locale); return TRUE; }
https://github.com/GNOME/glib/blob/mainline/gio/tests/gdbus-test-codegen.c#L2653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants