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-D-Bus-Utilities.html 27 * outPack = gio 28 * outFile = DBusUtilities 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = DBusUtilities 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_dbus_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - glib.StringG 50 * - gio.AsyncResultIF 51 * - gio.Cancellable 52 * - gio.IOStream 53 * structWrap: 54 * module aliases: 55 * local aliases: 56 * overrides: 57 */ 58 59 module gio.DBusUtilities; 60 61 public import gtkc.giotypes; 62 63 private import gtkc.gio; 64 private import glib.ConstructionException; 65 private import gobject.ObjectG; 66 67 68 private import glib.Str; 69 private import glib.ErrorG; 70 private import glib.GException; 71 private import glib.StringG; 72 private import gio.AsyncResultIF; 73 private import gio.Cancellable; 74 private import gio.IOStream; 75 76 77 78 79 /** 80 * Description 81 * Various utility routines related to D-Bus. 82 */ 83 public class DBusUtilities 84 { 85 86 /** 87 * Description 88 * Routines for working with D-Bus addresses. A D-Bus address is a string 89 * like "unix:tmpdir=/tmp/my-app-name". The exact format of addresses 90 * is explained in detail in the D-Bus specification. 91 */ 92 93 /** 94 * Description 95 * Various data structures and convenience routines to parse and 96 * generate D-Bus introspection XML. Introspection information is 97 * used when registering objects with g_dbus_connection_register_object(). 98 * The format of D-Bus introspection XML is specified in the 99 * D-Bus specification. 100 */ 101 102 /** 103 * Generate a D-Bus GUID that can be used with 104 * e.g. g_dbus_connection_new(). 105 * See the D-Bus specification regarding what strings are valid D-Bus 106 * GUID (for example, D-Bus GUIDs are not RFC-4122 compliant). 107 * Since 2.26 108 * Returns: A valid D-Bus GUID. Free with g_free(). 109 */ 110 public static string generateGuid() 111 { 112 // gchar * g_dbus_generate_guid (void); 113 return Str.toString(g_dbus_generate_guid()); 114 } 115 116 /** 117 * Checks if string is a D-Bus GUID. 118 * See the D-Bus specification regarding what strings are valid D-Bus 119 * GUID (for example, D-Bus GUIDs are not RFC-4122 compliant). 120 * Since 2.26 121 * Params: 122 * string = The string to check. 123 * Returns: TRUE if string is a guid, FALSE otherwise. 124 */ 125 public static int isGuid(string string) 126 { 127 // gboolean g_dbus_is_guid (const gchar *string); 128 return g_dbus_is_guid(Str.toStringz(string)); 129 } 130 131 /** 132 * Checks if string is a valid D-Bus bus name (either unique or well-known). 133 * Since 2.26 134 * Params: 135 * string = The string to check. 136 * Returns: TRUE if valid, FALSE otherwise. 137 */ 138 public static int isName(string string) 139 { 140 // gboolean g_dbus_is_name (const gchar *string); 141 return g_dbus_is_name(Str.toStringz(string)); 142 } 143 144 /** 145 * Checks if string is a valid D-Bus unique bus name. 146 * Since 2.26 147 * Params: 148 * string = The string to check. 149 * Returns: TRUE if valid, FALSE otherwise. 150 */ 151 public static int isUniqueName(string string) 152 { 153 // gboolean g_dbus_is_unique_name (const gchar *string); 154 return g_dbus_is_unique_name(Str.toStringz(string)); 155 } 156 157 /** 158 * Checks if string is a valid D-Bus member (e.g. signal or method) name. 159 * Since 2.26 160 * Params: 161 * string = The string to check. 162 * Returns: TRUE if valid, FALSE otherwise. 163 */ 164 public static int isMemberName(string string) 165 { 166 // gboolean g_dbus_is_member_name (const gchar *string); 167 return g_dbus_is_member_name(Str.toStringz(string)); 168 } 169 170 /** 171 * Checks if string is a valid D-Bus interface name. 172 * Since 2.26 173 * Params: 174 * string = The string to check. 175 * Returns: TRUE if valid, FALSE otherwise. 176 */ 177 public static int isInterfaceName(string string) 178 { 179 // gboolean g_dbus_is_interface_name (const gchar *string); 180 return g_dbus_is_interface_name(Str.toStringz(string)); 181 } 182 183 /** 184 * Checks if string is a D-Bus address. 185 * This doesn't check if string is actually supported by GDBusServer 186 * or GDBusConnection - use g_dbus_is_supported_address() to do more 187 * checks. 188 * Since 2.26 189 * Params: 190 * string = A string. 191 * Returns: TRUE if string is a valid D-Bus address, FALSE otherwise. 192 */ 193 public static int isAddress(string string) 194 { 195 // gboolean g_dbus_is_address (const gchar *string); 196 return g_dbus_is_address(Str.toStringz(string)); 197 } 198 199 /** 200 * Like g_dbus_is_address() but also checks if the library suppors the 201 * transports in string and that key/value pairs for each transport 202 * are valid. 203 * Since 2.26 204 * Params: 205 * string = A string. 206 * Returns: TRUE if string is a valid D-Bus address that is supported by this library, FALSE if error is set. 207 * Throws: GException on failure. 208 */ 209 public static int isSupportedAddress(string string) 210 { 211 // gboolean g_dbus_is_supported_address (const gchar *string, GError **error); 212 GError* err = null; 213 214 auto p = g_dbus_is_supported_address(Str.toStringz(string), &err); 215 216 if (err !is null) 217 { 218 throw new GException( new ErrorG(err) ); 219 } 220 221 return p; 222 } 223 224 /** 225 * Asynchronously connects to an endpoint specified by address and 226 * sets up the connection so it is in a state to run the client-side 227 * of the D-Bus authentication conversation. 228 * When the operation is finished, callback will be invoked. You can 229 * then call g_dbus_address_get_stream_finish() to get the result of 230 * the operation. 231 * This is an asynchronous failable function. See 232 * g_dbus_address_get_stream_sync() for the synchronous version. 233 * Since 2.26 234 * Params: 235 * address = A valid D-Bus address. 236 * cancellable = A GCancellable or NULL. 237 * callback = A GAsyncReadyCallback to call when the request is satisfied. 238 * userData = Data to pass to callback. 239 */ 240 public static void addressGetStream(string address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 241 { 242 // void g_dbus_address_get_stream (const gchar *address, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 243 g_dbus_address_get_stream(Str.toStringz(address), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 244 } 245 246 /** 247 * Finishes an operation started with g_dbus_address_get_stream(). 248 * Since 2.26 249 * Params: 250 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_address_get_stream(). 251 * outGuid = NULL or return location to store the GUID extracted from address, if any. 252 * Returns: A GIOStream or NULL if error is set. [transfer full] 253 * Throws: GException on failure. 254 */ 255 public static IOStream addressGetStreamFinish(AsyncResultIF res, out string outGuid) 256 { 257 // GIOStream * g_dbus_address_get_stream_finish (GAsyncResult *res, gchar **out_guid, GError **error); 258 char* outoutGuid = null; 259 GError* err = null; 260 261 auto p = g_dbus_address_get_stream_finish((res is null) ? null : res.getAsyncResultTStruct(), &outoutGuid, &err); 262 263 if (err !is null) 264 { 265 throw new GException( new ErrorG(err) ); 266 } 267 268 outGuid = Str.toString(outoutGuid); 269 270 if(p is null) 271 { 272 return null; 273 } 274 275 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p); 276 } 277 278 /** 279 * Synchronously connects to an endpoint specified by address and 280 * sets up the connection so it is in a state to run the client-side 281 * of the D-Bus authentication conversation. 282 * This is a synchronous failable function. See 283 * g_dbus_address_get_stream() for the asynchronous version. 284 * Since 2.26 285 * Params: 286 * address = A valid D-Bus address. 287 * outGuid = NULL or return location to store the GUID extracted from address, if any. 288 * cancellable = A GCancellable or NULL. 289 * Returns: A GIOStream or NULL if error is set. [transfer full] 290 * Throws: GException on failure. 291 */ 292 public static IOStream addressGetStreamSync(string address, out string outGuid, Cancellable cancellable) 293 { 294 // GIOStream * g_dbus_address_get_stream_sync (const gchar *address, gchar **out_guid, GCancellable *cancellable, GError **error); 295 char* outoutGuid = null; 296 GError* err = null; 297 298 auto p = g_dbus_address_get_stream_sync(Str.toStringz(address), &outoutGuid, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 299 300 if (err !is null) 301 { 302 throw new GException( new ErrorG(err) ); 303 } 304 305 outGuid = Str.toString(outoutGuid); 306 307 if(p is null) 308 { 309 return null; 310 } 311 312 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p); 313 } 314 315 /** 316 * Synchronously looks up the D-Bus address for the well-known message 317 * bus instance specified by bus_type. This may involve using various 318 * platform specific mechanisms. 319 * Since 2.26 320 * Params: 321 * busType = A GBusType. 322 * cancellable = A GCancellable or NULL. 323 * Returns: A valid D-Bus address string for bus_type or NULL if error is set. 324 * Throws: GException on failure. 325 */ 326 public static string addressGetForBusSync(GBusType busType, Cancellable cancellable) 327 { 328 // gchar * g_dbus_address_get_for_bus_sync (GBusType bus_type, GCancellable *cancellable, GError **error); 329 GError* err = null; 330 331 auto p = g_dbus_address_get_for_bus_sync(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 332 333 if (err !is null) 334 { 335 throw new GException( new ErrorG(err) ); 336 } 337 338 return Str.toString(p); 339 } 340 341 /** 342 * Looks up the value of an annotation. 343 * This cost of this function is O(n) in number of annotations. 344 * Since 2.26 345 * Params: 346 * annotations = A NULL-terminated array of annotations or NULL. 347 * name = The name of the annotation to look up. 348 * Returns: The value or NULL if not found. Do not free, it is owned by annotations. 349 */ 350 public static string annotationInfoLookup(GDBusAnnotationInfo** annotations, string name) 351 { 352 // const gchar * g_dbus_annotation_info_lookup (GDBusAnnotationInfo **annotations, const gchar *name); 353 return Str.toString(g_dbus_annotation_info_lookup(annotations, Str.toStringz(name))); 354 } 355 356 /** 357 * Looks up information about a method. 358 * This cost of this function is O(n) in number of methods. 359 * Since 2.26 360 * Params: 361 * info = A GDBusInterfaceInfo. 362 * name = A D-Bus method name (typically in CamelCase) 363 * Returns: A GDBusMethodInfo or NULL if not found. Do not free, it is owned by info. 364 */ 365 public static GDBusMethodInfo* interfaceInfoLookupMethod(GDBusInterfaceInfo* info, string name) 366 { 367 // GDBusMethodInfo * g_dbus_interface_info_lookup_method (GDBusInterfaceInfo *info, const gchar *name); 368 return g_dbus_interface_info_lookup_method(info, Str.toStringz(name)); 369 } 370 371 /** 372 * Looks up information about a signal. 373 * This cost of this function is O(n) in number of signals. 374 * Since 2.26 375 * Params: 376 * info = A GDBusInterfaceInfo. 377 * name = A D-Bus signal name (typically in CamelCase) 378 * Returns: A GDBusSignalInfo or NULL if not found. Do not free, it is owned by info. 379 */ 380 public static GDBusSignalInfo* interfaceInfoLookupSignal(GDBusInterfaceInfo* info, string name) 381 { 382 // GDBusSignalInfo * g_dbus_interface_info_lookup_signal (GDBusInterfaceInfo *info, const gchar *name); 383 return g_dbus_interface_info_lookup_signal(info, Str.toStringz(name)); 384 } 385 386 /** 387 * Looks up information about a property. 388 * This cost of this function is O(n) in number of properties. 389 * Since 2.26 390 * Params: 391 * info = A GDBusInterfaceInfo. 392 * name = A D-Bus property name (typically in CamelCase). 393 * Returns: A GDBusPropertyInfo or NULL if not found. Do not free, it is owned by info. 394 */ 395 public static GDBusPropertyInfo* interfaceInfoLookupProperty(GDBusInterfaceInfo* info, string name) 396 { 397 // GDBusPropertyInfo * g_dbus_interface_info_lookup_property (GDBusInterfaceInfo *info, const gchar *name); 398 return g_dbus_interface_info_lookup_property(info, Str.toStringz(name)); 399 } 400 401 /** 402 * Appends an XML representation of info (and its children) to string_builder. 403 * This function is typically used for generating introspection XML 404 * documents at run-time for handling the 405 * org.freedesktop.DBus.Introspectable.Introspect 406 * method. 407 * Since 2.26 408 * Params: 409 * info = A GDBusNodeInfo 410 * indent = Indentation level. 411 * stringBuilder = A GString to to append XML data to. 412 */ 413 public static void interfaceInfoGenerateXml(GDBusInterfaceInfo* info, uint indent, StringG stringBuilder) 414 { 415 // void g_dbus_interface_info_generate_xml (GDBusInterfaceInfo *info, guint indent, GString *string_builder); 416 g_dbus_interface_info_generate_xml(info, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct()); 417 } 418 419 /** 420 * Parses xml_data and returns a GDBusNodeInfo representing the data. 421 * Since 2.26 422 * Params: 423 * xmlData = Valid D-Bus introspection XML. 424 * Returns: A GDBusNodeInfo structure or NULL if error is set. Free with g_dbus_node_info_unref(). 425 * Throws: GException on failure. 426 */ 427 public static GDBusNodeInfo* nodeInfoNewForXml(string xmlData) 428 { 429 // GDBusNodeInfo * g_dbus_node_info_new_for_xml (const gchar *xml_data, GError **error); 430 GError* err = null; 431 432 auto p = g_dbus_node_info_new_for_xml(Str.toStringz(xmlData), &err); 433 434 if (err !is null) 435 { 436 throw new GException( new ErrorG(err) ); 437 } 438 439 return p; 440 } 441 442 /** 443 * Looks up information about an interface. 444 * This cost of this function is O(n) in number of interfaces. 445 * Since 2.26 446 * Params: 447 * info = A GDBusNodeInfo. 448 * name = A D-Bus interface name. 449 * Returns: A GDBusInterfaceInfo or NULL if not found. Do not free, it is owned by info. 450 */ 451 public static GDBusInterfaceInfo* nodeInfoLookupInterface(GDBusNodeInfo* info, string name) 452 { 453 // GDBusInterfaceInfo * g_dbus_node_info_lookup_interface (GDBusNodeInfo *info, const gchar *name); 454 return g_dbus_node_info_lookup_interface(info, Str.toStringz(name)); 455 } 456 457 /** 458 * Appends an XML representation of info (and its children) to string_builder. 459 * This function is typically used for generating introspection XML documents at run-time for 460 * handling the org.freedesktop.DBus.Introspectable.Introspect method. 461 * Since 2.26 462 * Params: 463 * info = A GDBusNodeInfo. 464 * indent = Indentation level. 465 * stringBuilder = A GString to to append XML data to. 466 */ 467 public static void nodeInfoGenerateXml(GDBusNodeInfo* info, uint indent, StringG stringBuilder) 468 { 469 // void g_dbus_node_info_generate_xml (GDBusNodeInfo *info, guint indent, GString *string_builder); 470 g_dbus_node_info_generate_xml(info, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct()); 471 } 472 473 /** 474 * If info is statically allocated does nothing. Otherwise increases 475 * the reference count. 476 * Since 2.26 477 * Params: 478 * info = A GDBusNodeInfo 479 * Returns: The same info. 480 */ 481 public static GDBusNodeInfo* nodeInfoRef(GDBusNodeInfo* info) 482 { 483 // GDBusNodeInfo * g_dbus_node_info_ref (GDBusNodeInfo *info); 484 return g_dbus_node_info_ref(info); 485 } 486 487 /** 488 * If info is statically allocated does nothing. Otherwise increases 489 * the reference count. 490 * Since 2.26 491 * Params: 492 * info = A GDBusInterfaceInfo 493 * Returns: The same info. 494 */ 495 public static GDBusInterfaceInfo* interfaceInfoRef(GDBusInterfaceInfo* info) 496 { 497 // GDBusInterfaceInfo * g_dbus_interface_info_ref (GDBusInterfaceInfo *info); 498 return g_dbus_interface_info_ref(info); 499 } 500 501 /** 502 * If info is statically allocated does nothing. Otherwise increases 503 * the reference count. 504 * Since 2.26 505 * Params: 506 * info = A GDBusMethodInfo 507 * Returns: The same info. 508 */ 509 public static GDBusMethodInfo* methodInfoRef(GDBusMethodInfo* info) 510 { 511 // GDBusMethodInfo * g_dbus_method_info_ref (GDBusMethodInfo *info); 512 return g_dbus_method_info_ref(info); 513 } 514 515 /** 516 * If info is statically allocated does nothing. Otherwise increases 517 * the reference count. 518 * Since 2.26 519 * Params: 520 * info = A GDBusSignalInfo 521 * Returns: The same info. 522 */ 523 public static GDBusSignalInfo* signalInfoRef(GDBusSignalInfo* info) 524 { 525 // GDBusSignalInfo * g_dbus_signal_info_ref (GDBusSignalInfo *info); 526 return g_dbus_signal_info_ref(info); 527 } 528 529 /** 530 * If info is statically allocated does nothing. Otherwise increases 531 * the reference count. 532 * Since 2.26 533 * Params: 534 * info = A GDBusPropertyInfo 535 * Returns: The same info. 536 */ 537 public static GDBusPropertyInfo* propertyInfoRef(GDBusPropertyInfo* info) 538 { 539 // GDBusPropertyInfo * g_dbus_property_info_ref (GDBusPropertyInfo *info); 540 return g_dbus_property_info_ref(info); 541 } 542 543 /** 544 * If info is statically allocated does nothing. Otherwise increases 545 * the reference count. 546 * Since 2.26 547 * Params: 548 * info = A GDBusArgInfo 549 * Returns: The same info. 550 */ 551 public static GDBusArgInfo* argInfoRef(GDBusArgInfo* info) 552 { 553 // GDBusArgInfo * g_dbus_arg_info_ref (GDBusArgInfo *info); 554 return g_dbus_arg_info_ref(info); 555 } 556 557 /** 558 * If info is statically allocated does nothing. Otherwise increases 559 * the reference count. 560 * Since 2.26 561 * Params: 562 * info = A GDBusNodeInfo 563 * Returns: The same info. 564 */ 565 public static GDBusAnnotationInfo* annotationInfoRef(GDBusAnnotationInfo* info) 566 { 567 // GDBusAnnotationInfo * g_dbus_annotation_info_ref (GDBusAnnotationInfo *info); 568 return g_dbus_annotation_info_ref(info); 569 } 570 571 /** 572 * If info is statically allocated, does nothing. Otherwise decreases 573 * the reference count of info. When its reference count drops to 0, 574 * the memory used is freed. 575 * Since 2.26 576 * Params: 577 * info = A GDBusNodeInfo. 578 */ 579 public static void nodeInfoUnref(GDBusNodeInfo* info) 580 { 581 // void g_dbus_node_info_unref (GDBusNodeInfo *info); 582 g_dbus_node_info_unref(info); 583 } 584 585 /** 586 * If info is statically allocated, does nothing. Otherwise decreases 587 * the reference count of info. When its reference count drops to 0, 588 * the memory used is freed. 589 * Since 2.26 590 * Params: 591 * info = A GDBusInterfaceInfo. 592 */ 593 public static void interfaceInfoUnref(GDBusInterfaceInfo* info) 594 { 595 // void g_dbus_interface_info_unref (GDBusInterfaceInfo *info); 596 g_dbus_interface_info_unref(info); 597 } 598 599 /** 600 * If info is statically allocated, does nothing. Otherwise decreases 601 * the reference count of info. When its reference count drops to 0, 602 * the memory used is freed. 603 * Since 2.26 604 * Params: 605 * info = A GDBusMethodInfo. 606 */ 607 public static void methodInfoUnref(GDBusMethodInfo* info) 608 { 609 // void g_dbus_method_info_unref (GDBusMethodInfo *info); 610 g_dbus_method_info_unref(info); 611 } 612 613 /** 614 * If info is statically allocated, does nothing. Otherwise decreases 615 * the reference count of info. When its reference count drops to 0, 616 * the memory used is freed. 617 * Since 2.26 618 * Params: 619 * info = A GDBusSignalInfo. 620 */ 621 public static void signalInfoUnref(GDBusSignalInfo* info) 622 { 623 // void g_dbus_signal_info_unref (GDBusSignalInfo *info); 624 g_dbus_signal_info_unref(info); 625 } 626 627 /** 628 * If info is statically allocated, does nothing. Otherwise decreases 629 * the reference count of info. When its reference count drops to 0, 630 * the memory used is freed. 631 * Since 2.26 632 * Params: 633 * info = A GDBusPropertyInfo. 634 */ 635 public static void propertyInfoUnref(GDBusPropertyInfo* info) 636 { 637 // void g_dbus_property_info_unref (GDBusPropertyInfo *info); 638 g_dbus_property_info_unref(info); 639 } 640 641 /** 642 * If info is statically allocated, does nothing. Otherwise decreases 643 * the reference count of info. When its reference count drops to 0, 644 * the memory used is freed. 645 * Since 2.26 646 * Params: 647 * info = A GDBusArgInfo. 648 */ 649 public static void argInfoUnref(GDBusArgInfo* info) 650 { 651 // void g_dbus_arg_info_unref (GDBusArgInfo *info); 652 g_dbus_arg_info_unref(info); 653 } 654 655 /** 656 * If info is statically allocated, does nothing. Otherwise decreases 657 * the reference count of info. When its reference count drops to 0, 658 * the memory used is freed. 659 * Since 2.26 660 * Params: 661 * info = A GDBusAnnotationInfo. 662 */ 663 public static void annotationInfoUnref(GDBusAnnotationInfo* info) 664 { 665 // void g_dbus_annotation_info_unref (GDBusAnnotationInfo *info); 666 g_dbus_annotation_info_unref(info); 667 } 668 }