source: appstream-generator/build/girepo/gio/DBusInterfaceSkeleton.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 11.5 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.DBusInterfaceSkeleton;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.DBusConnection;
26private import gio.DBusInterfaceIF;
27private import gio.DBusInterfaceInfo;
28private import gio.DBusInterfaceT;
29private import gio.DBusMethodInvocation;
30private import glib.ErrorG;
31private import glib.GException;
32private import glib.ListG;
33private import glib.Str;
34private import glib.Variant;
35private import gobject.ObjectG;
36private import gobject.Signals;
37private import std.algorithm;
38
39
40/**
41 * Abstract base class for D-Bus interfaces on the service side.
42 *
43 * Since: 2.30
44 */
45public class DBusInterfaceSkeleton : ObjectG, DBusInterfaceIF
46{
47        /** the main Gtk struct */
48        protected GDBusInterfaceSkeleton* gDBusInterfaceSkeleton;
49
50        /** Get the main Gtk struct */
51        public GDBusInterfaceSkeleton* getDBusInterfaceSkeletonStruct()
52        {
53                return gDBusInterfaceSkeleton;
54        }
55
56        /** the main Gtk struct as a void* */
57        protected override void* getStruct()
58        {
59                return cast(void*)gDBusInterfaceSkeleton;
60        }
61
62        protected override void setStruct(GObject* obj)
63        {
64                gDBusInterfaceSkeleton = cast(GDBusInterfaceSkeleton*)obj;
65                super.setStruct(obj);
66        }
67
68        /**
69         * Sets our main struct and passes it to the parent class.
70         */
71        public this (GDBusInterfaceSkeleton* gDBusInterfaceSkeleton, bool ownedRef = false)
72        {
73                this.gDBusInterfaceSkeleton = gDBusInterfaceSkeleton;
74                super(cast(GObject*)gDBusInterfaceSkeleton, ownedRef);
75        }
76
77        // add the DBusInterface capabilities
78        mixin DBusInterfaceT!(GDBusInterfaceSkeleton);
79
80
81        /** */
82        public static GType getType()
83        {
84                return g_dbus_interface_skeleton_get_type();
85        }
86
87        /**
88         * Exports @interface_ at @object_path on @connection.
89         *
90         * This can be called multiple times to export the same @interface_
91         * onto multiple connections however the @object_path provided must be
92         * the same for all connections.
93         *
94         * Use g_dbus_interface_skeleton_unexport() to unexport the object.
95         *
96         * Params:
97         *     connection = A #GDBusConnection to export @interface_ on.
98         *     objectPath = The path to export the interface at.
99         *
100         * Returns: %TRUE if the interface was exported on @connection, otherwise %FALSE with
101         *     @error set.
102         *
103         * Since: 2.30
104         *
105         * Throws: GException on failure.
106         */
107        public bool expor(DBusConnection connection, string objectPath)
108        {
109                GError* err = null;
110               
111                auto p = g_dbus_interface_skeleton_export(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(objectPath), &err) != 0;
112               
113                if (err !is null)
114                {
115                        throw new GException( new ErrorG(err) );
116                }
117               
118                return p;
119        }
120
121        /**
122         * If @interface_ has outstanding changes, request for these changes to be
123         * emitted immediately.
124         *
125         * For example, an exported D-Bus interface may queue up property
126         * changes and emit the
127         * `org.freedesktop.DBus.Properties::Propert``
128         * signal later (e.g. in an idle handler). This technique is useful
129         * for collapsing multiple property changes into one.
130         *
131         * Since: 2.30
132         */
133        public void flush()
134        {
135                g_dbus_interface_skeleton_flush(gDBusInterfaceSkeleton);
136        }
137
138        /**
139         * Gets the first connection that @interface_ is exported on, if any.
140         *
141         * Returns: A #GDBusConnection or %NULL if @interface_ is
142         *     not exported anywhere. Do not free, the object belongs to @interface_.
143         *
144         * Since: 2.30
145         */
146        public DBusConnection getConnection()
147        {
148                auto p = g_dbus_interface_skeleton_get_connection(gDBusInterfaceSkeleton);
149               
150                if(p is null)
151                {
152                        return null;
153                }
154               
155                return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
156        }
157
158        /**
159         * Gets a list of the connections that @interface_ is exported on.
160         *
161         * Returns: A list of
162         *     all the connections that @interface_ is exported on. The returned
163         *     list should be freed with g_list_free() after each element has
164         *     been freed with g_object_unref().
165         *
166         * Since: 2.32
167         */
168        public ListG getConnections()
169        {
170                auto p = g_dbus_interface_skeleton_get_connections(gDBusInterfaceSkeleton);
171               
172                if(p is null)
173                {
174                        return null;
175                }
176               
177                return new ListG(cast(GList*) p, true);
178        }
179
180        /**
181         * Gets the #GDBusInterfaceSkeletonFlags that describes what the behavior
182         * of @interface_
183         *
184         * Returns: One or more flags from the #GDBusInterfaceSkeletonFlags enumeration.
185         *
186         * Since: 2.30
187         */
188        public GDBusInterfaceSkeletonFlags getFlags()
189        {
190                return g_dbus_interface_skeleton_get_flags(gDBusInterfaceSkeleton);
191        }
192
193        /**
194         * Gets D-Bus introspection information for the D-Bus interface
195         * implemented by @interface_.
196         *
197         * Returns: A #GDBusInterfaceInfo (never %NULL). Do not free.
198         *
199         * Since: 2.30
200         */
201        public DBusInterfaceInfo getInfo()
202        {
203                auto p = g_dbus_interface_skeleton_get_info(gDBusInterfaceSkeleton);
204               
205                if(p is null)
206                {
207                        return null;
208                }
209               
210                return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p);
211        }
212
213        /**
214         * Gets the object path that @interface_ is exported on, if any.
215         *
216         * Returns: A string owned by @interface_ or %NULL if @interface_ is not exported
217         *     anywhere. Do not free, the string belongs to @interface_.
218         *
219         * Since: 2.30
220         */
221        public string getObjectPath()
222        {
223                return Str.toString(g_dbus_interface_skeleton_get_object_path(gDBusInterfaceSkeleton));
224        }
225
226        /**
227         * Gets all D-Bus properties for @interface_.
228         *
229         * Returns: A #GVariant of type
230         *     ['a{sv}'][G-VARIANT-TYPE-VARDICT:CAPS].
231         *     Free with g_variant_unref().
232         *
233         * Since: 2.30
234         */
235        public Variant getProperties()
236        {
237                auto p = g_dbus_interface_skeleton_get_properties(gDBusInterfaceSkeleton);
238               
239                if(p is null)
240                {
241                        return null;
242                }
243               
244                return new Variant(cast(GVariant*) p, true);
245        }
246
247        /**
248         * Gets the interface vtable for the D-Bus interface implemented by
249         * @interface_. The returned function pointers should expect @interface_
250         * itself to be passed as @user_data.
251         *
252         * Returns: A #GDBusInterfaceVTable (never %NULL).
253         *
254         * Since: 2.30
255         */
256        public GDBusInterfaceVTable* getVtable()
257        {
258                return g_dbus_interface_skeleton_get_vtable(gDBusInterfaceSkeleton);
259        }
260
261        /**
262         * Checks if @interface_ is exported on @connection.
263         *
264         * Params:
265         *     connection = A #GDBusConnection.
266         *
267         * Returns: %TRUE if @interface_ is exported on @connection, %FALSE otherwise.
268         *
269         * Since: 2.32
270         */
271        public bool hasConnection(DBusConnection connection)
272        {
273                return g_dbus_interface_skeleton_has_connection(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct()) != 0;
274        }
275
276        /**
277         * Sets flags describing what the behavior of @skeleton should be.
278         *
279         * Params:
280         *     flags = Flags from the #GDBusInterfaceSkeletonFlags enumeration.
281         *
282         * Since: 2.30
283         */
284        public void setFlags(GDBusInterfaceSkeletonFlags flags)
285        {
286                g_dbus_interface_skeleton_set_flags(gDBusInterfaceSkeleton, flags);
287        }
288
289        /**
290         * Stops exporting @interface_ on all connections it is exported on.
291         *
292         * To unexport @interface_ from only a single connection, use
293         * g_dbus_interface_skeleton_unexport_from_connection()
294         *
295         * Since: 2.30
296         */
297        public void unexport()
298        {
299                g_dbus_interface_skeleton_unexport(gDBusInterfaceSkeleton);
300        }
301
302        /**
303         * Stops exporting @interface_ on @connection.
304         *
305         * To stop exporting on all connections the interface is exported on,
306         * use g_dbus_interface_skeleton_unexport().
307         *
308         * Params:
309         *     connection = A #GDBusConnection.
310         *
311         * Since: 2.32
312         */
313        public void unexportFromConnection(DBusConnection connection)
314        {
315                g_dbus_interface_skeleton_unexport_from_connection(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct());
316        }
317
318        protected class OnGAuthorizeMethodDelegateWrapper
319        {
320                static OnGAuthorizeMethodDelegateWrapper[] listeners;
321                bool delegate(DBusMethodInvocation, DBusInterfaceSkeleton) dlg;
322                gulong handlerId;
323               
324                this(bool delegate(DBusMethodInvocation, DBusInterfaceSkeleton) dlg)
325                {
326                        this.dlg = dlg;
327                        this.listeners ~= this;
328                }
329               
330                void remove(OnGAuthorizeMethodDelegateWrapper source)
331                {
332                        foreach(index, wrapper; listeners)
333                        {
334                                if (wrapper.handlerId == source.handlerId)
335                                {
336                                        listeners[index] = null;
337                                        listeners = std.algorithm.remove(listeners, index);
338                                        break;
339                                }
340                        }
341                }
342        }
343
344        /**
345         * Emitted when a method is invoked by a remote caller and used to
346         * determine if the method call is authorized.
347         *
348         * Note that this signal is emitted in a thread dedicated to
349         * handling the method call so handlers are allowed to perform
350         * blocking IO. This means that it is appropriate to call e.g.
351         * [polkit_authority_check_authorization_sync()](http://hal.freedesktop.org/docs/polkit/PolkitAuthority.html#polkit-authority-check-authorization-sync)
352         * with the
353         * [POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION](http://hal.freedesktop.org/docs/polkit/PolkitAuthority.html#POLKIT-CHECK-AUTHORIZATION-FLAGS-ALLOW-USER-INTERACTION:CAPS)
354         * flag set.
355         *
356         * If %FALSE is returned then no further handlers are run and the
357         * signal handler must take a reference to @invocation and finish
358         * handling the call (e.g. return an error via
359         * g_dbus_method_invocation_return_error()).
360         *
361         * Otherwise, if %TRUE is returned, signal emission continues. If no
362         * handlers return %FALSE, then the method is dispatched. If
363         * @interface has an enclosing #GDBusObjectSkeleton, then the
364         * #GDBusObjectSkeleton::authorize-method signal handlers run before
365         * the handlers for this signal.
366         *
367         * The default class handler just returns %TRUE.
368         *
369         * Please note that the common case is optimized: if no signals
370         * handlers are connected and the default class handler isn't
371         * overridden (for both @interface and the enclosing
372         * #GDBusObjectSkeleton, if any) and #GDBusInterfaceSkeleton:g-flags does
373         * not have the
374         * %G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD
375         * flags set, no dedicated thread is ever used and the call will be
376         * handled in the same thread as the object that @interface belongs
377         * to was exported in.
378         *
379         * Params:
380         *     invocation = A #GDBusMethodInvocation.
381         *
382         * Returns: %TRUE if the call is authorized, %FALSE otherwise.
383         *
384         * Since: 2.30
385         */
386        gulong addOnGAuthorizeMethod(bool delegate(DBusMethodInvocation, DBusInterfaceSkeleton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
387        {
388                auto wrapper = new OnGAuthorizeMethodDelegateWrapper(dlg);
389                wrapper.handlerId = Signals.connectData(
390                        this,
391                        "g-authorize-method",
392                        cast(GCallback)&callBackGAuthorizeMethod,
393                        cast(void*)wrapper,
394                        cast(GClosureNotify)&callBackGAuthorizeMethodDestroy,
395                        connectFlags);
396                return wrapper.handlerId;
397        }
398       
399        extern(C) static int callBackGAuthorizeMethod(GDBusInterfaceSkeleton* dbusinterfaceskeletonStruct, GDBusMethodInvocation* invocation, OnGAuthorizeMethodDelegateWrapper wrapper)
400        {
401                return wrapper.dlg(ObjectG.getDObject!(DBusMethodInvocation)(invocation), wrapper.outer);
402        }
403       
404        extern(C) static void callBackGAuthorizeMethodDestroy(OnGAuthorizeMethodDelegateWrapper wrapper, GClosure* closure)
405        {
406                wrapper.remove(wrapper);
407        }
408}
Note: See TracBrowser for help on using the repository browser.