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