1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.DBusNames;
26 
27 private import gio.DBusConnection;
28 private import glib.Str;
29 private import gobject.Closure;
30 private import gtkc.gio;
31 public  import gtkc.giotypes;
32 
33 
34 /** */
35 public struct DBusNames
36 {
37 
38 	/**
39 	 * Starts acquiring @name on the bus specified by @bus_type and calls
40 	 * @name_acquired_handler and @name_lost_handler when the name is
41 	 * acquired respectively lost. Callbacks will be invoked in the
42 	 * [thread-default main context][g-main-context-push-thread-default]
43 	 * of the thread you are calling this function from.
44 	 *
45 	 * You are guaranteed that one of the @name_acquired_handler and @name_lost_handler
46 	 * callbacks will be invoked after calling this function - there are three
47 	 * possible cases:
48 	 *
49 	 * - @name_lost_handler with a %NULL connection (if a connection to the bus
50 	 * can't be made).
51 	 *
52 	 * - @bus_acquired_handler then @name_lost_handler (if the name can't be
53 	 * obtained)
54 	 *
55 	 * - @bus_acquired_handler then @name_acquired_handler (if the name was
56 	 * obtained).
57 	 *
58 	 * When you are done owning the name, just call g_bus_unown_name()
59 	 * with the owner id this function returns.
60 	 *
61 	 * If the name is acquired or lost (for example another application
62 	 * could acquire the name if you allow replacement or the application
63 	 * currently owning the name exits), the handlers are also invoked.
64 	 * If the #GDBusConnection that is used for attempting to own the name
65 	 * closes, then @name_lost_handler is invoked since it is no longer
66 	 * possible for other processes to access the process.
67 	 *
68 	 * You cannot use g_bus_own_name() several times for the same name (unless
69 	 * interleaved with calls to g_bus_unown_name()) - only the first call
70 	 * will work.
71 	 *
72 	 * Another guarantee is that invocations of @name_acquired_handler
73 	 * and @name_lost_handler are guaranteed to alternate; that
74 	 * is, if @name_acquired_handler is invoked then you are
75 	 * guaranteed that the next time one of the handlers is invoked, it
76 	 * will be @name_lost_handler. The reverse is also true.
77 	 *
78 	 * If you plan on exporting objects (using e.g.
79 	 * g_dbus_connection_register_object()), note that it is generally too late
80 	 * to export the objects in @name_acquired_handler. Instead, you can do this
81 	 * in @bus_acquired_handler since you are guaranteed that this will run
82 	 * before @name is requested from the bus.
83 	 *
84 	 * This behavior makes it very simple to write applications that wants
85 	 * to [own names][gdbus-owning-names] and export objects.
86 	 * Simply register objects to be exported in @bus_acquired_handler and
87 	 * unregister the objects (if any) in @name_lost_handler.
88 	 *
89 	 * Params:
90 	 *     busType = the type of bus to own a name on
91 	 *     name = the well-known name to own
92 	 *     flags = a set of flags from the #GBusNameOwnerFlags enumeration
93 	 *     busAcquiredHandler = handler to invoke when connected to the bus of type @bus_type or %NULL
94 	 *     nameAcquiredHandler = handler to invoke when @name is acquired or %NULL
95 	 *     nameLostHandler = handler to invoke when @name is lost or %NULL
96 	 *     userData = user data to pass to handlers
97 	 *     userDataFreeFunc = function for freeing @user_data or %NULL
98 	 *
99 	 * Return: an identifier (never 0) that an be used with
100 	 *     g_bus_unown_name() to stop owning the name.
101 	 *
102 	 * Since: 2.26
103 	 */
104 	public static uint ownName(GBusType busType, string name, GBusNameOwnerFlags flags, GBusAcquiredCallback busAcquiredHandler, GBusNameAcquiredCallback nameAcquiredHandler, GBusNameLostCallback nameLostHandler, void* userData, GDestroyNotify userDataFreeFunc)
105 	{
106 		return g_bus_own_name(busType, Str.toStringz(name), flags, busAcquiredHandler, nameAcquiredHandler, nameLostHandler, userData, userDataFreeFunc);
107 	}
108 
109 	/**
110 	 * Like g_bus_own_name() but takes a #GDBusConnection instead of a
111 	 * #GBusType.
112 	 *
113 	 * Params:
114 	 *     connection = a #GDBusConnection
115 	 *     name = the well-known name to own
116 	 *     flags = a set of flags from the #GBusNameOwnerFlags enumeration
117 	 *     nameAcquiredHandler = handler to invoke when @name is acquired or %NULL
118 	 *     nameLostHandler = handler to invoke when @name is lost or %NULL
119 	 *     userData = user data to pass to handlers
120 	 *     userDataFreeFunc = function for freeing @user_data or %NULL
121 	 *
122 	 * Return: an identifier (never 0) that an be used with
123 	 *     g_bus_unown_name() to stop owning the name
124 	 *
125 	 * Since: 2.26
126 	 */
127 	public static uint ownNameOnConnection(DBusConnection connection, string name, GBusNameOwnerFlags flags, GBusNameAcquiredCallback nameAcquiredHandler, GBusNameLostCallback nameLostHandler, void* userData, GDestroyNotify userDataFreeFunc)
128 	{
129 		return g_bus_own_name_on_connection((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, nameAcquiredHandler, nameLostHandler, userData, userDataFreeFunc);
130 	}
131 
132 	/**
133 	 * Version of g_bus_own_name_on_connection() using closures instead of
134 	 * callbacks for easier binding in other languages.
135 	 *
136 	 * Params:
137 	 *     connection = a #GDBusConnection
138 	 *     name = the well-known name to own
139 	 *     flags = a set of flags from the #GBusNameOwnerFlags enumeration
140 	 *     nameAcquiredClosure = #GClosure to invoke when @name is
141 	 *         acquired or %NULL
142 	 *     nameLostClosure = #GClosure to invoke when @name is lost
143 	 *         or %NULL
144 	 *
145 	 * Return: an identifier (never 0) that an be used with
146 	 *     g_bus_unown_name() to stop owning the name.
147 	 *
148 	 * Since: 2.26
149 	 */
150 	public static uint ownNameOnConnectionWithClosures(DBusConnection connection, string name, GBusNameOwnerFlags flags, Closure nameAcquiredClosure, Closure nameLostClosure)
151 	{
152 		return g_bus_own_name_on_connection_with_closures((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, (nameAcquiredClosure is null) ? null : nameAcquiredClosure.getClosureStruct(), (nameLostClosure is null) ? null : nameLostClosure.getClosureStruct());
153 	}
154 
155 	/**
156 	 * Version of g_bus_own_name() using closures instead of callbacks for
157 	 * easier binding in other languages.
158 	 *
159 	 * Params:
160 	 *     busType = the type of bus to own a name on
161 	 *     name = the well-known name to own
162 	 *     flags = a set of flags from the #GBusNameOwnerFlags enumeration
163 	 *     busAcquiredClosure = #GClosure to invoke when connected to
164 	 *         the bus of type @bus_type or %NULL
165 	 *     nameAcquiredClosure = #GClosure to invoke when @name is
166 	 *         acquired or %NULL
167 	 *     nameLostClosure = #GClosure to invoke when @name is lost or
168 	 *         %NULL
169 	 *
170 	 * Return: an identifier (never 0) that an be used with
171 	 *     g_bus_unown_name() to stop owning the name.
172 	 *
173 	 * Since: 2.26
174 	 */
175 	public static uint ownNameWithClosures(GBusType busType, string name, GBusNameOwnerFlags flags, Closure busAcquiredClosure, Closure nameAcquiredClosure, Closure nameLostClosure)
176 	{
177 		return g_bus_own_name_with_closures(busType, Str.toStringz(name), flags, (busAcquiredClosure is null) ? null : busAcquiredClosure.getClosureStruct(), (nameAcquiredClosure is null) ? null : nameAcquiredClosure.getClosureStruct(), (nameLostClosure is null) ? null : nameLostClosure.getClosureStruct());
178 	}
179 
180 	/**
181 	 * Stops owning a name.
182 	 *
183 	 * Params:
184 	 *     ownerId = an identifier obtained from g_bus_own_name()
185 	 *
186 	 * Since: 2.26
187 	 */
188 	public static void unownName(uint ownerId)
189 	{
190 		g_bus_unown_name(ownerId);
191 	}
192 
193 	/**
194 	 * Stops watching a name.
195 	 *
196 	 * Params:
197 	 *     watcherId = An identifier obtained from g_bus_watch_name()
198 	 *
199 	 * Since: 2.26
200 	 */
201 	public static void unwatchName(uint watcherId)
202 	{
203 		g_bus_unwatch_name(watcherId);
204 	}
205 
206 	/**
207 	 * Starts watching @name on the bus specified by @bus_type and calls
208 	 * @name_appeared_handler and @name_vanished_handler when the name is
209 	 * known to have a owner respectively known to lose its
210 	 * owner. Callbacks will be invoked in the
211 	 * [thread-default main context][g-main-context-push-thread-default]
212 	 * of the thread you are calling this function from.
213 	 *
214 	 * You are guaranteed that one of the handlers will be invoked after
215 	 * calling this function. When you are done watching the name, just
216 	 * call g_bus_unwatch_name() with the watcher id this function
217 	 * returns.
218 	 *
219 	 * If the name vanishes or appears (for example the application owning
220 	 * the name could restart), the handlers are also invoked. If the
221 	 * #GDBusConnection that is used for watching the name disconnects, then
222 	 * @name_vanished_handler is invoked since it is no longer
223 	 * possible to access the name.
224 	 *
225 	 * Another guarantee is that invocations of @name_appeared_handler
226 	 * and @name_vanished_handler are guaranteed to alternate; that
227 	 * is, if @name_appeared_handler is invoked then you are
228 	 * guaranteed that the next time one of the handlers is invoked, it
229 	 * will be @name_vanished_handler. The reverse is also true.
230 	 *
231 	 * This behavior makes it very simple to write applications that want
232 	 * to take action when a certain [name exists][gdbus-watching-names].
233 	 * Basically, the application should create object proxies in
234 	 * @name_appeared_handler and destroy them again (if any) in
235 	 * @name_vanished_handler.
236 	 *
237 	 * Params:
238 	 *     busType = The type of bus to watch a name on.
239 	 *     name = The name (well-known or unique) to watch.
240 	 *     flags = Flags from the #GBusNameWatcherFlags enumeration.
241 	 *     nameAppearedHandler = Handler to invoke when @name is known to exist or %NULL.
242 	 *     nameVanishedHandler = Handler to invoke when @name is known to not exist or %NULL.
243 	 *     userData = User data to pass to handlers.
244 	 *     userDataFreeFunc = Function for freeing @user_data or %NULL.
245 	 *
246 	 * Return: An identifier (never 0) that an be used with
247 	 *     g_bus_unwatch_name() to stop watching the name.
248 	 *
249 	 * Since: 2.26
250 	 */
251 	public static uint watchName(GBusType busType, string name, GBusNameWatcherFlags flags, GBusNameAppearedCallback nameAppearedHandler, GBusNameVanishedCallback nameVanishedHandler, void* userData, GDestroyNotify userDataFreeFunc)
252 	{
253 		return g_bus_watch_name(busType, Str.toStringz(name), flags, nameAppearedHandler, nameVanishedHandler, userData, userDataFreeFunc);
254 	}
255 
256 	/**
257 	 * Like g_bus_watch_name() but takes a #GDBusConnection instead of a
258 	 * #GBusType.
259 	 *
260 	 * Params:
261 	 *     connection = A #GDBusConnection.
262 	 *     name = The name (well-known or unique) to watch.
263 	 *     flags = Flags from the #GBusNameWatcherFlags enumeration.
264 	 *     nameAppearedHandler = Handler to invoke when @name is known to exist or %NULL.
265 	 *     nameVanishedHandler = Handler to invoke when @name is known to not exist or %NULL.
266 	 *     userData = User data to pass to handlers.
267 	 *     userDataFreeFunc = Function for freeing @user_data or %NULL.
268 	 *
269 	 * Return: An identifier (never 0) that an be used with
270 	 *     g_bus_unwatch_name() to stop watching the name.
271 	 *
272 	 * Since: 2.26
273 	 */
274 	public static uint watchNameOnConnection(DBusConnection connection, string name, GBusNameWatcherFlags flags, GBusNameAppearedCallback nameAppearedHandler, GBusNameVanishedCallback nameVanishedHandler, void* userData, GDestroyNotify userDataFreeFunc)
275 	{
276 		return g_bus_watch_name_on_connection((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, nameAppearedHandler, nameVanishedHandler, userData, userDataFreeFunc);
277 	}
278 
279 	/**
280 	 * Version of g_bus_watch_name_on_connection() using closures instead of callbacks for
281 	 * easier binding in other languages.
282 	 *
283 	 * Params:
284 	 *     connection = A #GDBusConnection.
285 	 *     name = The name (well-known or unique) to watch.
286 	 *     flags = Flags from the #GBusNameWatcherFlags enumeration.
287 	 *     nameAppearedClosure = #GClosure to invoke when @name is known
288 	 *         to exist or %NULL.
289 	 *     nameVanishedClosure = #GClosure to invoke when @name is known
290 	 *         to not exist or %NULL.
291 	 *
292 	 * Return: An identifier (never 0) that an be used with
293 	 *     g_bus_unwatch_name() to stop watching the name.
294 	 *
295 	 * Since: 2.26
296 	 */
297 	public static uint watchNameOnConnectionWithClosures(DBusConnection connection, string name, GBusNameWatcherFlags flags, Closure nameAppearedClosure, Closure nameVanishedClosure)
298 	{
299 		return g_bus_watch_name_on_connection_with_closures((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, (nameAppearedClosure is null) ? null : nameAppearedClosure.getClosureStruct(), (nameVanishedClosure is null) ? null : nameVanishedClosure.getClosureStruct());
300 	}
301 
302 	/**
303 	 * Version of g_bus_watch_name() using closures instead of callbacks for
304 	 * easier binding in other languages.
305 	 *
306 	 * Params:
307 	 *     busType = The type of bus to watch a name on.
308 	 *     name = The name (well-known or unique) to watch.
309 	 *     flags = Flags from the #GBusNameWatcherFlags enumeration.
310 	 *     nameAppearedClosure = #GClosure to invoke when @name is known
311 	 *         to exist or %NULL.
312 	 *     nameVanishedClosure = #GClosure to invoke when @name is known
313 	 *         to not exist or %NULL.
314 	 *
315 	 * Return: An identifier (never 0) that an be used with
316 	 *     g_bus_unwatch_name() to stop watching the name.
317 	 *
318 	 * Since: 2.26
319 	 */
320 	public static uint watchNameWithClosures(GBusType busType, string name, GBusNameWatcherFlags flags, Closure nameAppearedClosure, Closure nameVanishedClosure)
321 	{
322 		return g_bus_watch_name_with_closures(busType, Str.toStringz(name), flags, (nameAppearedClosure is null) ? null : nameAppearedClosure.getClosureStruct(), (nameVanishedClosure is null) ? null : nameVanishedClosure.getClosureStruct());
323 	}
324 }