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 * Conversion parameters: 26 * inFile = gio-Owning-Bus-Names.html 27 * outPack = gio 28 * outFile = DBusNames 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = DBusNames 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_bus_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gobject.Closure 48 * - gio.DBusConnection 49 * structWrap: 50 * - GClosure* -> Closure 51 * - GDBusConnection* -> DBusConnection 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gio.DBusNames; 58 59 public import gtkc.giotypes; 60 61 private import gtkc.gio; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import glib.Str; 66 private import gobject.Closure; 67 private import gio.DBusConnection; 68 69 70 71 /** 72 * Convenience API for owning bus names. 73 * 74 * $(DDOC_COMMENT example) 75 */ 76 public class DBusNames 77 { 78 79 /** 80 * Convenience API for watching bus names. 81 * 82 * $(DDOC_COMMENT example) 83 */ 84 85 /** 86 * Starts acquiring name on the bus specified by bus_type and calls 87 * name_acquired_handler and name_lost_handler when the name is 88 * acquired respectively lost. Callbacks will be invoked in the thread-default main 89 * loop of the thread you are calling this function from. 90 * You are guaranteed that one of the name_acquired_handler and name_lost_handler 91 * callbacks will be invoked after calling this function - there are three 92 * Since 2.26 93 * Params: 94 * busType = The type of bus to own a name on. 95 * name = The well-known name to own. 96 * flags = A set of flags from the GBusNameOwnerFlags enumeration. 97 * busAcquiredHandler = Handler to invoke when connected to the bus of type bus_type or NULL. [allow-none] 98 * nameAcquiredHandler = Handler to invoke when name is acquired or NULL. [allow-none] 99 * nameLostHandler = Handler to invoke when name is lost or NULL. [allow-none] 100 * userData = User data to pass to handlers. 101 * userDataFreeFunc = Function for freeing user_data or NULL. [allow-none] 102 * Returns: An identifier (never 0) that an be used with g_bus_unown_name() to stop owning the name. 103 */ 104 public static uint ownName(GBusType busType, string name, GBusNameOwnerFlags flags, GBusAcquiredCallback busAcquiredHandler, GBusNameAcquiredCallback nameAcquiredHandler, GBusNameLostCallback nameLostHandler, void* userData, GDestroyNotify userDataFreeFunc) 105 { 106 // guint g_bus_own_name (GBusType bus_type, const gchar *name, GBusNameOwnerFlags flags, GBusAcquiredCallback bus_acquired_handler, GBusNameAcquiredCallback name_acquired_handler, GBusNameLostCallback name_lost_handler, gpointer user_data, GDestroyNotify user_data_free_func); 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 * Since 2.26 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. [allow-none] 119 * nameLostHandler = Handler to invoke when name is lost or NULL. [allow-none] 120 * userData = User data to pass to handlers. 121 * userDataFreeFunc = Function for freeing user_data or NULL. [allow-none] 122 * Returns: An identifier (never 0) that an be used with g_bus_unown_name() to stop owning the name. 123 */ 124 public static uint ownNameOnConnection(DBusConnection connection, string name, GBusNameOwnerFlags flags, GBusNameAcquiredCallback nameAcquiredHandler, GBusNameLostCallback nameLostHandler, void* userData, GDestroyNotify userDataFreeFunc) 125 { 126 // guint g_bus_own_name_on_connection (GDBusConnection *connection, const gchar *name, GBusNameOwnerFlags flags, GBusNameAcquiredCallback name_acquired_handler, GBusNameLostCallback name_lost_handler, gpointer user_data, GDestroyNotify user_data_free_func); 127 return g_bus_own_name_on_connection((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, nameAcquiredHandler, nameLostHandler, userData, userDataFreeFunc); 128 } 129 130 /** 131 * Stops owning a name. 132 * Since 2.26 133 * Params: 134 * ownerId = An identifier obtained from g_bus_own_name() 135 */ 136 public static void unownName(uint ownerId) 137 { 138 // void g_bus_unown_name (guint owner_id); 139 g_bus_unown_name(ownerId); 140 } 141 142 /** 143 * Version of g_bus_own_name() using closures instead of callbacks for 144 * easier binding in other languages. 145 * Since 2.26 146 * Params: 147 * busType = The type of bus to own a name on. 148 * name = The well-known name to own. 149 * flags = A set of flags from the GBusNameOwnerFlags enumeration. 150 * busAcquiredClosure = GClosure to invoke when connected to 151 * the bus of type bus_type or NULL. [allow-none] 152 * nameAcquiredClosure = GClosure to invoke when name is 153 * acquired or NULL. [allow-none] 154 * nameLostClosure = GClosure to invoke when name is lost or 155 * NULL. [allow-none] 156 * Returns: An identifier (never 0) that an be used with g_bus_unown_name() to stop owning the name. Rename to: g_bus_own_name 157 */ 158 public static uint ownNameWithClosures(GBusType busType, string name, GBusNameOwnerFlags flags, Closure busAcquiredClosure, Closure nameAcquiredClosure, Closure nameLostClosure) 159 { 160 // guint g_bus_own_name_with_closures (GBusType bus_type, const gchar *name, GBusNameOwnerFlags flags, GClosure *bus_acquired_closure, GClosure *name_acquired_closure, GClosure *name_lost_closure); 161 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()); 162 } 163 164 /** 165 * Version of g_bus_own_name_on_connection() using closures instead of callbacks for 166 * easier binding in other languages. 167 * Since 2.26 168 * Params: 169 * connection = A GDBusConnection. 170 * name = The well-known name to own. 171 * flags = A set of flags from the GBusNameOwnerFlags enumeration. 172 * nameAcquiredClosure = GClosure to invoke when name is 173 * acquired or NULL. [allow-none] 174 * nameLostClosure = GClosure to invoke when name is lost or 175 * NULL. [allow-none] 176 * Returns: An identifier (never 0) that an be used with g_bus_unown_name() to stop owning the name. Rename to: g_bus_own_name_on_connection 177 */ 178 public static uint ownNameOnConnectionWithClosures(DBusConnection connection, string name, GBusNameOwnerFlags flags, Closure nameAcquiredClosure, Closure nameLostClosure) 179 { 180 // guint g_bus_own_name_on_connection_with_closures (GDBusConnection *connection, const gchar *name, GBusNameOwnerFlags flags, GClosure *name_acquired_closure, GClosure *name_lost_closure); 181 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()); 182 } 183 184 /** 185 * Starts watching name on the bus specified by bus_type and calls 186 * name_appeared_handler and name_vanished_handler when the name is 187 * known to have a owner respectively known to lose its 188 * owner. Callbacks will be invoked in the thread-default main 189 * loop of the thread you are calling this function from. 190 * You are guaranteed that one of the handlers will be invoked after 191 * calling this function. When you are done watching the name, just 192 * call g_bus_unwatch_name() with the watcher id this function 193 * returns. 194 * If the name vanishes or appears (for example the application owning 195 * the name could restart), the handlers are also invoked. If the 196 * GDBusConnection that is used for watching the name disconnects, then 197 * name_vanished_handler is invoked since it is no longer 198 * possible to access the name. 199 * Another guarantee is that invocations of name_appeared_handler 200 * and name_vanished_handler are guaranteed to alternate; that 201 * is, if name_appeared_handler is invoked then you are 202 * guaranteed that the next time one of the handlers is invoked, it 203 * will be name_vanished_handler. The reverse is also true. 204 * This behavior makes it very simple to write applications that wants 205 * to take action when a certain name exists, see Example 13, “Simple application watching a name”. Basically, the application 206 * should create object proxies in name_appeared_handler and destroy 207 * them again (if any) in name_vanished_handler. 208 * Since 2.26 209 * Params: 210 * busType = The type of bus to watch a name on. 211 * name = The name (well-known or unique) to watch. 212 * flags = Flags from the GBusNameWatcherFlags enumeration. 213 * nameAppearedHandler = Handler to invoke when name is known to exist or NULL. [allow-none] 214 * nameVanishedHandler = Handler to invoke when name is known to not exist or NULL. [allow-none] 215 * userData = User data to pass to handlers. 216 * userDataFreeFunc = Function for freeing user_data or NULL. [allow-none] 217 * Returns: An identifier (never 0) that an be used with g_bus_unwatch_name() to stop watching the name. 218 */ 219 public static uint watchName(GBusType busType, string name, GBusNameWatcherFlags flags, GBusNameAppearedCallback nameAppearedHandler, GBusNameVanishedCallback nameVanishedHandler, void* userData, GDestroyNotify userDataFreeFunc) 220 { 221 // guint g_bus_watch_name (GBusType bus_type, const gchar *name, GBusNameWatcherFlags flags, GBusNameAppearedCallback name_appeared_handler, GBusNameVanishedCallback name_vanished_handler, gpointer user_data, GDestroyNotify user_data_free_func); 222 return g_bus_watch_name(busType, Str.toStringz(name), flags, nameAppearedHandler, nameVanishedHandler, userData, userDataFreeFunc); 223 } 224 225 /** 226 * Like g_bus_watch_name() but takes a GDBusConnection instead of a 227 * GBusType. 228 * Since 2.26 229 * Params: 230 * connection = A GDBusConnection. 231 * name = The name (well-known or unique) to watch. 232 * flags = Flags from the GBusNameWatcherFlags enumeration. 233 * nameAppearedHandler = Handler to invoke when name is known to exist or NULL. [allow-none] 234 * nameVanishedHandler = Handler to invoke when name is known to not exist or NULL. [allow-none] 235 * userData = User data to pass to handlers. 236 * userDataFreeFunc = Function for freeing user_data or NULL. [allow-none] 237 * Returns: An identifier (never 0) that an be used with g_bus_unwatch_name() to stop watching the name. 238 */ 239 public static uint watchNameOnConnection(DBusConnection connection, string name, GBusNameWatcherFlags flags, GBusNameAppearedCallback nameAppearedHandler, GBusNameVanishedCallback nameVanishedHandler, void* userData, GDestroyNotify userDataFreeFunc) 240 { 241 // guint g_bus_watch_name_on_connection (GDBusConnection *connection, const gchar *name, GBusNameWatcherFlags flags, GBusNameAppearedCallback name_appeared_handler, GBusNameVanishedCallback name_vanished_handler, gpointer user_data, GDestroyNotify user_data_free_func); 242 return g_bus_watch_name_on_connection((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(name), flags, nameAppearedHandler, nameVanishedHandler, userData, userDataFreeFunc); 243 } 244 245 /** 246 * Stops watching a name. 247 * Since 2.26 248 * Params: 249 * watcherId = An identifier obtained from g_bus_watch_name() 250 */ 251 public static void unwatchName(uint watcherId) 252 { 253 // void g_bus_unwatch_name (guint watcher_id); 254 g_bus_unwatch_name(watcherId); 255 } 256 257 /** 258 * Version of g_bus_watch_name() using closures instead of callbacks for 259 * easier binding in other languages. 260 * Since 2.26 261 * Params: 262 * busType = The type of bus to watch a name on. 263 * name = The name (well-known or unique) to watch. 264 * flags = Flags from the GBusNameWatcherFlags enumeration. 265 * nameAppearedClosure = GClosure to invoke when name is known 266 * to exist or NULL. [allow-none] 267 * nameVanishedClosure = GClosure to invoke when name is known 268 * to not exist or NULL. [allow-none] 269 * Returns: An identifier (never 0) that an be used with g_bus_unwatch_name() to stop watching the name. Rename to: g_bus_watch_name 270 */ 271 public static uint watchNameWithClosures(GBusType busType, string name, GBusNameWatcherFlags flags, Closure nameAppearedClosure, Closure nameVanishedClosure) 272 { 273 // guint g_bus_watch_name_with_closures (GBusType bus_type, const gchar *name, GBusNameWatcherFlags flags, GClosure *name_appeared_closure, GClosure *name_vanished_closure); 274 return g_bus_watch_name_with_closures(busType, Str.toStringz(name), flags, (nameAppearedClosure is null) ? null : nameAppearedClosure.getClosureStruct(), (nameVanishedClosure is null) ? null : nameVanishedClosure.getClosureStruct()); 275 } 276 277 /** 278 * Version of g_bus_watch_name_on_connection() using closures instead of callbacks for 279 * easier binding in other languages. 280 * Since 2.26 281 * Params: 282 * connection = A GDBusConnection. 283 * name = The name (well-known or unique) to watch. 284 * flags = Flags from the GBusNameWatcherFlags enumeration. 285 * nameAppearedClosure = GClosure to invoke when name is known 286 * to exist or NULL. [allow-none] 287 * nameVanishedClosure = GClosure to invoke when name is known 288 * to not exist or NULL. [allow-none] 289 * Returns: An identifier (never 0) that an be used with g_bus_unwatch_name() to stop watching the name. Rename to: g_bus_watch_name_on_connection 290 */ 291 public static uint watchNameOnConnectionWithClosures(DBusConnection connection, string name, GBusNameWatcherFlags flags, Closure nameAppearedClosure, Closure nameVanishedClosure) 292 { 293 // guint g_bus_watch_name_on_connection_with_closures (GDBusConnection *connection, const gchar *name, GBusNameWatcherFlags flags, GClosure *name_appeared_closure, GClosure *name_vanished_closure); 294 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()); 295 } 296 }