1 /* 2 * This file is part of libsecret-d. 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/ 7 */ 8 9 // generated automatically - do not change 10 // find conversion definition on APILookup.txt 11 12 13 module libsecret.Collection; 14 15 private import gio.AsyncInitableIF; 16 private import gio.AsyncInitableT; 17 private import gio.AsyncResultIF; 18 private import gio.Cancellable; 19 private import gio.DBusInterfaceIF; 20 private import gio.DBusInterfaceT; 21 private import gio.DBusProxy; 22 private import gio.InitableIF; 23 private import gio.InitableT; 24 private import glib.ConstructionException; 25 private import glib.ErrorG; 26 private import glib.GException; 27 private import glib.HashTable; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import libsecret.Schema; 32 private import libsecret.Service; 33 private import libsecret.c.functions; 34 public import libsecret.c.types; 35 36 37 /** 38 * A proxy object representing a collection of secrets in the Secret Service. 39 */ 40 public class Collection : DBusProxy 41 { 42 /** the main Gtk struct */ 43 protected SecretCollection* secretCollection; 44 45 /** Get the main Gtk struct */ 46 public SecretCollection* getCollectionStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return secretCollection; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected override void* getStruct() 55 { 56 return cast(void*)secretCollection; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (SecretCollection* secretCollection, bool ownedRef = false) 63 { 64 this.secretCollection = secretCollection; 65 super(cast(GDBusProxy*)secretCollection, ownedRef); 66 } 67 68 alias getFlags = DBusProxy.getFlags; 69 70 /** 71 */ 72 73 /** */ 74 public static GType getType() 75 { 76 return secret_collection_get_type(); 77 } 78 79 /** 80 * Finish asynchronous operation to get a new collection proxy for a 81 * collection in the secret service. 82 * 83 * Params: 84 * result = the asynchronous result passed to the callback 85 * 86 * Returns: the new collection, which should be unreferenced 87 * with g_object_unref() 88 * 89 * Throws: GException on failure. 90 * Throws: ConstructionException GTK+ fails to create the object. 91 */ 92 public this(AsyncResultIF result) 93 { 94 GError* err = null; 95 96 auto p = secret_collection_new_for_dbus_path_finish((result is null) ? null : result.getAsyncResultStruct(), &err); 97 98 if (err !is null) 99 { 100 throw new GException( new ErrorG(err) ); 101 } 102 103 if(p is null) 104 { 105 throw new ConstructionException("null returned by new_for_dbus_path_finish"); 106 } 107 108 this(cast(SecretCollection*) p, true); 109 } 110 111 /** 112 * Get a new collection proxy for a collection in the secret service. 113 * 114 * If @service is NULL, then secret_service_get_sync() will be called to get 115 * the default #SecretService proxy. 116 * 117 * This method may block indefinitely and should not be used in user interface 118 * threads. 119 * 120 * Params: 121 * service = a secret service object 122 * collectionPath = the D-Bus path of the collection 123 * flags = options for the collection initialization 124 * cancellable = optional cancellation object 125 * 126 * Returns: the new collection, which should be unreferenced 127 * with g_object_unref() 128 * 129 * Throws: GException on failure. 130 * Throws: ConstructionException GTK+ fails to create the object. 131 */ 132 public this(Service service, string collectionPath, SecretCollectionFlags flags, Cancellable cancellable) 133 { 134 GError* err = null; 135 136 auto p = secret_collection_new_for_dbus_path_sync((service is null) ? null : service.getServiceStruct(), Str.toStringz(collectionPath), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 137 138 if (err !is null) 139 { 140 throw new GException( new ErrorG(err) ); 141 } 142 143 if(p is null) 144 { 145 throw new ConstructionException("null returned by new_for_dbus_path_sync"); 146 } 147 148 this(cast(SecretCollection*) p, true); 149 } 150 151 /** 152 * Create a new collection in the secret service. 153 * 154 * This method returns immediately and completes asynchronously. The secret 155 * service may prompt the user. secret_service_prompt() will be used to handle 156 * any prompts that are required. 157 * 158 * An @alias is a well-known tag for a collection, such as 'default' (ie: the 159 * default collection to store items in). This allows other applications to 160 * easily identify and share a collection. If you specify an @alias, and a 161 * collection with that alias already exists, then a new collection will not 162 * be created. The previous one will be returned instead. 163 * 164 * If @service is NULL, then secret_service_get() will be called to get 165 * the default #SecretService proxy. 166 * 167 * Params: 168 * service = a secret service object 169 * label = label for the new collection 170 * alias_ = alias to assign to the collection 171 * flags = currently unused 172 * cancellable = optional cancellation object 173 * callback = called when the operation completes 174 * userData = data to pass to the callback 175 */ 176 public static void create(Service service, string label, string alias_, SecretCollectionCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 177 { 178 secret_collection_create((service is null) ? null : service.getServiceStruct(), Str.toStringz(label), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 179 } 180 181 /** 182 * Finish operation to create a new collection in the secret service. 183 * 184 * Params: 185 * result = the asynchronous result passed to the callback 186 * 187 * Returns: the new collection, which should be unreferenced 188 * with g_object_unref() 189 * 190 * Throws: GException on failure. 191 */ 192 public static Collection createFinish(AsyncResultIF result) 193 { 194 GError* err = null; 195 196 auto p = secret_collection_create_finish((result is null) ? null : result.getAsyncResultStruct(), &err); 197 198 if (err !is null) 199 { 200 throw new GException( new ErrorG(err) ); 201 } 202 203 if(p is null) 204 { 205 return null; 206 } 207 208 return ObjectG.getDObject!(Collection)(cast(SecretCollection*) p, true); 209 } 210 211 /** 212 * Create a new collection in the secret service. 213 * 214 * This method may block indefinitely and should not be used in user interface 215 * threads. The secret service may prompt the user. secret_service_prompt() 216 * will be used to handle any prompts that are required. 217 * 218 * An @alias is a well-known tag for a collection, such as 'default' (ie: the 219 * default collection to store items in). This allows other applications to 220 * easily identify and share a collection. If you specify an @alias, and a 221 * collection with that alias already exists, then a new collection will not 222 * be created. The previous one will be returned instead. 223 * 224 * If @service is NULL, then secret_service_get_sync() will be called to get 225 * the default #SecretService proxy. 226 * 227 * Params: 228 * service = a secret service object 229 * label = label for the new collection 230 * alias_ = alias to assign to the collection 231 * flags = currently unused 232 * cancellable = optional cancellation object 233 * 234 * Returns: the new collection, which should be unreferenced 235 * with g_object_unref() 236 * 237 * Throws: GException on failure. 238 */ 239 public static Collection createSync(Service service, string label, string alias_, SecretCollectionCreateFlags flags, Cancellable cancellable) 240 { 241 GError* err = null; 242 243 auto p = secret_collection_create_sync((service is null) ? null : service.getServiceStruct(), Str.toStringz(label), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 244 245 if (err !is null) 246 { 247 throw new GException( new ErrorG(err) ); 248 } 249 250 if(p is null) 251 { 252 return null; 253 } 254 255 return ObjectG.getDObject!(Collection)(cast(SecretCollection*) p, true); 256 } 257 258 /** 259 * Lookup which collection is assigned to this alias. Aliases help determine 260 * well known collections, such as 'default'. 261 * 262 * If @service is NULL, then secret_service_get() will be called to get 263 * the default #SecretService proxy. 264 * 265 * This method will return immediately and complete asynchronously. 266 * 267 * Params: 268 * service = a secret service object 269 * alias_ = the alias to lookup 270 * flags = options for the collection initialization 271 * cancellable = optional cancellation object 272 * callback = called when the operation completes 273 * userData = data to pass to the callback 274 */ 275 public static void forAlias(Service service, string alias_, SecretCollectionFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 276 { 277 secret_collection_for_alias((service is null) ? null : service.getServiceStruct(), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 278 } 279 280 /** 281 * Finish an asynchronous operation to lookup which collection is assigned 282 * to an alias. 283 * 284 * Params: 285 * result = asynchronous result passed to callback 286 * 287 * Returns: the collection, or %NULL if none assigned to the alias 288 * 289 * Throws: GException on failure. 290 */ 291 public static Collection forAliasFinish(AsyncResultIF result) 292 { 293 GError* err = null; 294 295 auto p = secret_collection_for_alias_finish((result is null) ? null : result.getAsyncResultStruct(), &err); 296 297 if (err !is null) 298 { 299 throw new GException( new ErrorG(err) ); 300 } 301 302 if(p is null) 303 { 304 return null; 305 } 306 307 return ObjectG.getDObject!(Collection)(cast(SecretCollection*) p, true); 308 } 309 310 /** 311 * Lookup which collection is assigned to this alias. Aliases help determine 312 * well known collections, such as 'default'. 313 * 314 * If @service is NULL, then secret_service_get_sync() will be called to get 315 * the default #SecretService proxy. 316 * 317 * This method may block and should not be used in user interface threads. 318 * 319 * Params: 320 * service = a secret service object 321 * alias_ = the alias to lookup 322 * flags = options for the collection initialization 323 * cancellable = optional cancellation object 324 * 325 * Returns: the collection, or %NULL if none assigned to the alias 326 * 327 * Throws: GException on failure. 328 */ 329 public static Collection forAliasSync(Service service, string alias_, SecretCollectionFlags flags, Cancellable cancellable) 330 { 331 GError* err = null; 332 333 auto p = secret_collection_for_alias_sync((service is null) ? null : service.getServiceStruct(), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 334 335 if (err !is null) 336 { 337 throw new GException( new ErrorG(err) ); 338 } 339 340 if(p is null) 341 { 342 return null; 343 } 344 345 return ObjectG.getDObject!(Collection)(cast(SecretCollection*) p, true); 346 } 347 348 /** 349 * Get a new collection proxy for a collection in the secret service. 350 * 351 * If @service is NULL, then secret_service_get() will be called to get 352 * the default #SecretService proxy. 353 * 354 * This method will return immediately and complete asynchronously. 355 * 356 * Params: 357 * service = a secret service object 358 * collectionPath = the D-Bus path of the collection 359 * flags = options for the collection initialization 360 * cancellable = optional cancellation object 361 * callback = called when the operation completes 362 * userData = data to be passed to the callback 363 */ 364 public static void newForDbusPath(Service service, string collectionPath, SecretCollectionFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 365 { 366 secret_collection_new_for_dbus_path((service is null) ? null : service.getServiceStruct(), Str.toStringz(collectionPath), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 367 } 368 369 /** 370 * Delete this collection. 371 * 372 * This method returns immediately and completes asynchronously. The secret 373 * service may prompt the user. secret_service_prompt() will be used to handle 374 * any prompts that show up. 375 * 376 * Params: 377 * cancellable = optional cancellation object 378 * callback = called when the operation completes 379 * userData = data to pass to the callback 380 */ 381 public void delet(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 382 { 383 secret_collection_delete(secretCollection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 384 } 385 386 /** 387 * Complete operation to delete this collection. 388 * 389 * Params: 390 * result = asynchronous result passed to the callback 391 * 392 * Returns: whether the collection was successfully deleted or not 393 * 394 * Throws: GException on failure. 395 */ 396 public bool deleteFinish(AsyncResultIF result) 397 { 398 GError* err = null; 399 400 auto p = secret_collection_delete_finish(secretCollection, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 401 402 if (err !is null) 403 { 404 throw new GException( new ErrorG(err) ); 405 } 406 407 return p; 408 } 409 410 /** 411 * Delete this collection. 412 * 413 * This method may block indefinitely and should not be used in user 414 * interface threads. The secret service may prompt the user. 415 * secret_service_prompt() will be used to handle any prompts that show up. 416 * 417 * Params: 418 * cancellable = optional cancellation object 419 * 420 * Returns: whether the collection was successfully deleted or not 421 * 422 * Throws: GException on failure. 423 */ 424 public bool deleteSync(Cancellable cancellable) 425 { 426 GError* err = null; 427 428 auto p = secret_collection_delete_sync(secretCollection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 429 430 if (err !is null) 431 { 432 throw new GException( new ErrorG(err) ); 433 } 434 435 return p; 436 } 437 438 /** 439 * Get the created date and time of the collection. The return value is 440 * the number of seconds since the unix epoch, January 1st 1970. 441 * 442 * Returns: the created date and time 443 */ 444 public ulong getCreated() 445 { 446 return secret_collection_get_created(secretCollection); 447 } 448 449 /** 450 * Get the flags representing what features of the #SecretCollection proxy 451 * have been initialized. 452 * 453 * Use secret_collection_load_items() to initialize further features 454 * and change the flags. 455 * 456 * Returns: the flags for features initialized 457 */ 458 public SecretCollectionFlags getFlags() 459 { 460 return secret_collection_get_flags(secretCollection); 461 } 462 463 /** 464 * Get the list of items in this collection. 465 * 466 * Returns: a list of items, 467 * when done, the list should be freed with g_list_free, and each item should 468 * be released with g_object_unref() 469 */ 470 public ListG getItems() 471 { 472 auto p = secret_collection_get_items(secretCollection); 473 474 if(p is null) 475 { 476 return null; 477 } 478 479 return new ListG(cast(GList*) p, true); 480 } 481 482 /** 483 * Get the label of this collection. 484 * 485 * Returns: the label, which should be freed with g_free() 486 */ 487 public string getLabel() 488 { 489 auto retStr = secret_collection_get_label(secretCollection); 490 491 scope(exit) Str.freeString(retStr); 492 return Str.toString(retStr); 493 } 494 495 /** 496 * Get whether the collection is locked or not. 497 * 498 * Use secret_service_lock() or secret_service_unlock() to lock or unlock the 499 * collection. 500 * 501 * Returns: whether the collection is locked or not 502 */ 503 public bool getLocked() 504 { 505 return secret_collection_get_locked(secretCollection) != 0; 506 } 507 508 /** 509 * Get the modified date and time of the collection. The return value is 510 * the number of seconds since the unix epoch, January 1st 1970. 511 * 512 * Returns: the modified date and time 513 */ 514 public ulong getModified() 515 { 516 return secret_collection_get_modified(secretCollection); 517 } 518 519 /** 520 * Get the Secret Service object that this collection was created with. 521 * 522 * Returns: the Secret Service object 523 */ 524 public Service getService() 525 { 526 auto p = secret_collection_get_service(secretCollection); 527 528 if(p is null) 529 { 530 return null; 531 } 532 533 return ObjectG.getDObject!(Service)(cast(SecretService*) p); 534 } 535 536 /** 537 * Ensure that the #SecretCollection proxy has loaded all the items present 538 * in the Secret Service. This affects the result of 539 * secret_collection_get_items(). 540 * 541 * For collections returned from secret_service_get_collections() the items 542 * will have already been loaded. 543 * 544 * This method will return immediately and complete asynchronously. 545 * 546 * Params: 547 * cancellable = optional cancellation object 548 * callback = called when the operation completes 549 * userData = data to be passed to the callback 550 */ 551 public void loadItems(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 552 { 553 secret_collection_load_items(secretCollection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 554 } 555 556 /** 557 * Complete an asynchronous operation to ensure that the #SecretCollection proxy 558 * has loaded all the items present in the Secret Service. 559 * 560 * Params: 561 * result = the asynchronous result passed to the callback 562 * 563 * Returns: whether the load was successful or not 564 * 565 * Throws: GException on failure. 566 */ 567 public bool loadItemsFinish(AsyncResultIF result) 568 { 569 GError* err = null; 570 571 auto p = secret_collection_load_items_finish(secretCollection, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 572 573 if (err !is null) 574 { 575 throw new GException( new ErrorG(err) ); 576 } 577 578 return p; 579 } 580 581 /** 582 * Ensure that the #SecretCollection proxy has loaded all the items present 583 * in the Secret Service. This affects the result of 584 * secret_collection_get_items(). 585 * 586 * For collections returned from secret_service_get_collections() the items 587 * will have already been loaded. 588 * 589 * This method may block indefinitely and should not be used in user interface 590 * threads. 591 * 592 * Params: 593 * cancellable = optional cancellation object 594 * 595 * Returns: whether the load was successful or not 596 * 597 * Throws: GException on failure. 598 */ 599 public bool loadItemsSync(Cancellable cancellable) 600 { 601 GError* err = null; 602 603 auto p = secret_collection_load_items_sync(secretCollection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 604 605 if (err !is null) 606 { 607 throw new GException( new ErrorG(err) ); 608 } 609 610 return p; 611 } 612 613 /** 614 * Refresh the properties on this collection. This fires off a request to 615 * refresh, and the properties will be updated later. 616 * 617 * Calling this method is not normally necessary, as the secret service 618 * will notify the client when properties change. 619 */ 620 public void refresh() 621 { 622 secret_collection_refresh(secretCollection); 623 } 624 625 /** 626 * Search for items matching the @attributes in the @collection. 627 * The @attributes should be a table of string keys and string values. 628 * 629 * If %SECRET_SEARCH_ALL is set in @flags, then all the items matching the 630 * search will be returned. Otherwise only the first item will be returned. 631 * This is almost always the unlocked item that was most recently stored. 632 * 633 * If %SECRET_SEARCH_UNLOCK is set in @flags, then items will be unlocked 634 * if necessary. In either case, locked and unlocked items will match the 635 * search and be returned. If the unlock fails, the search does not fail. 636 * 637 * If %SECRET_SEARCH_LOAD_SECRETS is set in @flags, then the items will have 638 * their secret values loaded and available via secret_item_get_secret(). 639 * 640 * This function returns immediately and completes asynchronously. 641 * 642 * Params: 643 * schema = the schema for the attributes 644 * attributes = search for items matching these attributes 645 * flags = search option flags 646 * cancellable = optional cancellation object 647 * callback = called when the operation completes 648 * userData = data to pass to the callback 649 */ 650 public void search(Schema schema, HashTable attributes, SecretSearchFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 651 { 652 secret_collection_search(secretCollection, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 653 } 654 655 /** 656 * Complete asynchronous operation to search for items in a collection. 657 * 658 * Params: 659 * result = asynchronous result passed to callback 660 * 661 * Returns: a list of items that matched the search 662 * 663 * Throws: GException on failure. 664 */ 665 public ListG searchFinish(AsyncResultIF result) 666 { 667 GError* err = null; 668 669 auto p = secret_collection_search_finish(secretCollection, (result is null) ? null : result.getAsyncResultStruct(), &err); 670 671 if (err !is null) 672 { 673 throw new GException( new ErrorG(err) ); 674 } 675 676 if(p is null) 677 { 678 return null; 679 } 680 681 return new ListG(cast(GList*) p, true); 682 } 683 684 /** 685 * Search for items in @collection matching the @attributes, and return their 686 * DBus object paths. Only the specified collection is searched. The @attributes 687 * should be a table of string keys and string values. 688 * 689 * This function returns immediately and completes asynchronously. 690 * 691 * When your callback is called use secret_collection_search_for_dbus_paths_finish() 692 * to get the results of this function. Only the DBus object paths of the 693 * items will be returned. If you would like #SecretItem objects to be returned 694 * instead, then use the secret_collection_search() function. 695 * 696 * Params: 697 * schema = the schema for the attributes 698 * attributes = search for items matching these attributes 699 * cancellable = optional cancellation object 700 * callback = called when the operation completes 701 * userData = data to pass to the callback 702 */ 703 public void searchForDbusPaths(Schema schema, HashTable attributes, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 704 { 705 secret_collection_search_for_dbus_paths(secretCollection, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 706 } 707 708 /** 709 * Complete asynchronous operation to search for items in a collection. 710 * 711 * DBus object paths of the items will be returned. If you would to have 712 * #SecretItem objects to be returned instead, then use the 713 * secret_collection_search() and secret_collection_search_finish() functions. 714 * 715 * Params: 716 * result = asynchronous result passed to callback 717 * 718 * Returns: an array of DBus object 719 * paths for matching items. 720 * 721 * Throws: GException on failure. 722 */ 723 public string[] searchForDbusPathsFinish(AsyncResultIF result) 724 { 725 GError* err = null; 726 727 auto retStr = secret_collection_search_for_dbus_paths_finish(secretCollection, (result is null) ? null : result.getAsyncResultStruct(), &err); 728 729 if (err !is null) 730 { 731 throw new GException( new ErrorG(err) ); 732 } 733 734 scope(exit) Str.freeStringArray(retStr); 735 return Str.toStringArray(retStr); 736 } 737 738 /** 739 * Search for items matching the @attributes in @collection, and return their 740 * DBus object paths. The @attributes should be a table of string keys and 741 * string values. 742 * 743 * This function may block indefinitely. Use the asynchronous version 744 * in user interface threads. 745 * 746 * DBus object paths of the items will be returned. If you would to have 747 * #SecretItem objects to be returned instead, then use the 748 * secret_collection_search_sync() function. 749 * 750 * Params: 751 * schema = the schema for the attributes 752 * attributes = search for items matching these attributes 753 * cancellable = optional cancellation object 754 * 755 * Returns: an array of DBus object 756 * paths for matching items. 757 * 758 * Throws: GException on failure. 759 */ 760 public string[] searchForDbusPathsSync(Schema schema, HashTable attributes, Cancellable cancellable) 761 { 762 GError* err = null; 763 764 auto retStr = secret_collection_search_for_dbus_paths_sync(secretCollection, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 765 766 if (err !is null) 767 { 768 throw new GException( new ErrorG(err) ); 769 } 770 771 scope(exit) Str.freeStringArray(retStr); 772 return Str.toStringArray(retStr); 773 } 774 775 /** 776 * Search for items matching the @attributes in the @collection. 777 * The @attributes should be a table of string keys and string values. 778 * 779 * If %SECRET_SEARCH_ALL is set in @flags, then all the items matching the 780 * search will be returned. Otherwise only the first item will be returned. 781 * This is almost always the unlocked item that was most recently stored. 782 * 783 * If %SECRET_SEARCH_UNLOCK is set in @flags, then items will be unlocked 784 * if necessary. In either case, locked and unlocked items will match the 785 * search and be returned. If the unlock fails, the search does not fail. 786 * 787 * If %SECRET_SEARCH_LOAD_SECRETS is set in @flags, then the items will have 788 * their secret values loaded and available via secret_item_get_secret(). 789 * 790 * This function may block indefinitely. Use the asynchronous version 791 * in user interface threads. 792 * 793 * Params: 794 * schema = the schema for the attributes 795 * attributes = search for items matching these attributes 796 * flags = search option flags 797 * cancellable = optional cancellation object 798 * 799 * Returns: a list of items that matched the search 800 * 801 * Throws: GException on failure. 802 */ 803 public ListG searchSync(Schema schema, HashTable attributes, SecretSearchFlags flags, Cancellable cancellable) 804 { 805 GError* err = null; 806 807 auto p = secret_collection_search_sync(secretCollection, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 808 809 if (err !is null) 810 { 811 throw new GException( new ErrorG(err) ); 812 } 813 814 if(p is null) 815 { 816 return null; 817 } 818 819 return new ListG(cast(GList*) p, true); 820 } 821 822 /** 823 * Set the label of this collection. 824 * 825 * This function returns immediately and completes asynchronously. 826 * 827 * Params: 828 * label = a new label 829 * cancellable = optional cancellation object 830 * callback = called when the operation completes 831 * userData = data to pass to the callback 832 */ 833 public void setLabel(string label, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 834 { 835 secret_collection_set_label(secretCollection, Str.toStringz(label), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 836 } 837 838 /** 839 * Complete asynchronous operation to set the label of this collection. 840 * 841 * Params: 842 * result = asynchronous result passed to callback 843 * 844 * Returns: whether the change was successful or not 845 * 846 * Throws: GException on failure. 847 */ 848 public bool setLabelFinish(AsyncResultIF result) 849 { 850 GError* err = null; 851 852 auto p = secret_collection_set_label_finish(secretCollection, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 853 854 if (err !is null) 855 { 856 throw new GException( new ErrorG(err) ); 857 } 858 859 return p; 860 } 861 862 /** 863 * Set the label of this collection. 864 * 865 * This function may block indefinitely. Use the asynchronous version 866 * in user interface threads. 867 * 868 * Params: 869 * label = a new label 870 * cancellable = optional cancellation object 871 * 872 * Returns: whether the change was successful or not 873 * 874 * Throws: GException on failure. 875 */ 876 public bool setLabelSync(string label, Cancellable cancellable) 877 { 878 GError* err = null; 879 880 auto p = secret_collection_set_label_sync(secretCollection, Str.toStringz(label), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 881 882 if (err !is null) 883 { 884 throw new GException( new ErrorG(err) ); 885 } 886 887 return p; 888 } 889 }