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

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

Initial release

File size: 6.7 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.DBusObjectSkeleton;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.DBusInterfaceSkeleton;
26private import gio.DBusMethodInvocation;
27private import gio.DBusObjectIF;
28private import gio.DBusObjectT;
29private import glib.ConstructionException;
30private import glib.Str;
31private import gobject.ObjectG;
32private import gobject.Signals;
33private import std.algorithm;
34
35
36/**
37 * A #GDBusObjectSkeleton instance is essentially a group of D-Bus
38 * interfaces. The set of exported interfaces on the object may be
39 * dynamic and change at runtime.
40 *
41 * This type is intended to be used with #GDBusObjectManager.
42 *
43 * Since: 2.30
44 */
45public class DBusObjectSkeleton : ObjectG, DBusObjectIF
46{
47        /** the main Gtk struct */
48        protected GDBusObjectSkeleton* gDBusObjectSkeleton;
49
50        /** Get the main Gtk struct */
51        public GDBusObjectSkeleton* getDBusObjectSkeletonStruct()
52        {
53                return gDBusObjectSkeleton;
54        }
55
56        /** the main Gtk struct as a void* */
57        protected override void* getStruct()
58        {
59                return cast(void*)gDBusObjectSkeleton;
60        }
61
62        protected override void setStruct(GObject* obj)
63        {
64                gDBusObjectSkeleton = cast(GDBusObjectSkeleton*)obj;
65                super.setStruct(obj);
66        }
67
68        /**
69         * Sets our main struct and passes it to the parent class.
70         */
71        public this (GDBusObjectSkeleton* gDBusObjectSkeleton, bool ownedRef = false)
72        {
73                this.gDBusObjectSkeleton = gDBusObjectSkeleton;
74                super(cast(GObject*)gDBusObjectSkeleton, ownedRef);
75        }
76
77        // add the DBusObject capabilities
78        mixin DBusObjectT!(GDBusObjectSkeleton);
79
80
81        /** */
82        public static GType getType()
83        {
84                return g_dbus_object_skeleton_get_type();
85        }
86
87        /**
88         * Creates a new #GDBusObjectSkeleton.
89         *
90         * Params:
91         *     objectPath = An object path.
92         *
93         * Returns: A #GDBusObjectSkeleton. Free with g_object_unref().
94         *
95         * Since: 2.30
96         *
97         * Throws: ConstructionException GTK+ fails to create the object.
98         */
99        public this(string objectPath)
100        {
101                auto p = g_dbus_object_skeleton_new(Str.toStringz(objectPath));
102               
103                if(p is null)
104                {
105                        throw new ConstructionException("null returned by new");
106                }
107               
108                this(cast(GDBusObjectSkeleton*) p, true);
109        }
110
111        /**
112         * Adds @interface_ to @object.
113         *
114         * If @object already contains a #GDBusInterfaceSkeleton with the same
115         * interface name, it is removed before @interface_ is added.
116         *
117         * Note that @object takes its own reference on @interface_ and holds
118         * it until removed.
119         *
120         * Params:
121         *     iface = A #GDBusInterfaceSkeleton.
122         *
123         * Since: 2.30
124         */
125        public void addInterface(DBusInterfaceSkeleton iface)
126        {
127                g_dbus_object_skeleton_add_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct());
128        }
129
130        /**
131         * This method simply calls g_dbus_interface_skeleton_flush() on all
132         * interfaces belonging to @object. See that method for when flushing
133         * is useful.
134         *
135         * Since: 2.30
136         */
137        public void flush()
138        {
139                g_dbus_object_skeleton_flush(gDBusObjectSkeleton);
140        }
141
142        /**
143         * Removes @interface_ from @object.
144         *
145         * Params:
146         *     iface = A #GDBusInterfaceSkeleton.
147         *
148         * Since: 2.30
149         */
150        public void removeInterface(DBusInterfaceSkeleton iface)
151        {
152                g_dbus_object_skeleton_remove_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct());
153        }
154
155        /**
156         * Removes the #GDBusInterface with @interface_name from @object.
157         *
158         * If no D-Bus interface of the given interface exists, this function
159         * does nothing.
160         *
161         * Params:
162         *     interfaceName = A D-Bus interface name.
163         *
164         * Since: 2.30
165         */
166        public void removeInterfaceByName(string interfaceName)
167        {
168                g_dbus_object_skeleton_remove_interface_by_name(gDBusObjectSkeleton, Str.toStringz(interfaceName));
169        }
170
171        /**
172         * Sets the object path for @object.
173         *
174         * Params:
175         *     objectPath = A valid D-Bus object path.
176         *
177         * Since: 2.30
178         */
179        public void setObjectPath(string objectPath)
180        {
181                g_dbus_object_skeleton_set_object_path(gDBusObjectSkeleton, Str.toStringz(objectPath));
182        }
183
184        protected class OnAuthorizeMethodDelegateWrapper
185        {
186                static OnAuthorizeMethodDelegateWrapper[] listeners;
187                bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg;
188                gulong handlerId;
189               
190                this(bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg)
191                {
192                        this.dlg = dlg;
193                        this.listeners ~= this;
194                }
195               
196                void remove(OnAuthorizeMethodDelegateWrapper source)
197                {
198                        foreach(index, wrapper; listeners)
199                        {
200                                if (wrapper.handlerId == source.handlerId)
201                                {
202                                        listeners[index] = null;
203                                        listeners = std.algorithm.remove(listeners, index);
204                                        break;
205                                }
206                        }
207                }
208        }
209
210        /**
211         * Emitted when a method is invoked by a remote caller and used to
212         * determine if the method call is authorized.
213         *
214         * This signal is like #GDBusInterfaceSkeleton's
215         * #GDBusInterfaceSkeleton::g-authorize-method signal,
216         * except that it is for the enclosing object.
217         *
218         * The default class handler just returns %TRUE.
219         *
220         * Params:
221         *     iface = The #GDBusInterfaceSkeleton that @invocation is for.
222         *     invocation = A #GDBusMethodInvocation.
223         *
224         * Returns: %TRUE if the call is authorized, %FALSE otherwise.
225         *
226         * Since: 2.30
227         */
228        gulong addOnAuthorizeMethod(bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
229        {
230                auto wrapper = new OnAuthorizeMethodDelegateWrapper(dlg);
231                wrapper.handlerId = Signals.connectData(
232                        this,
233                        "authorize-method",
234                        cast(GCallback)&callBackAuthorizeMethod,
235                        cast(void*)wrapper,
236                        cast(GClosureNotify)&callBackAuthorizeMethodDestroy,
237                        connectFlags);
238                return wrapper.handlerId;
239        }
240       
241        extern(C) static int callBackAuthorizeMethod(GDBusObjectSkeleton* dbusobjectskeletonStruct, GDBusInterfaceSkeleton* iface, GDBusMethodInvocation* invocation, OnAuthorizeMethodDelegateWrapper wrapper)
242        {
243                return wrapper.dlg(ObjectG.getDObject!(DBusInterfaceSkeleton)(iface), ObjectG.getDObject!(DBusMethodInvocation)(invocation), wrapper.outer);
244        }
245       
246        extern(C) static void callBackAuthorizeMethodDestroy(OnAuthorizeMethodDelegateWrapper wrapper, GClosure* closure)
247        {
248                wrapper.remove(wrapper);
249        }
250}
Note: See TracBrowser for help on using the repository browser.