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.Service; 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.ErrorG; 25 private import glib.GException; 26 private import glib.HashTable; 27 private import glib.ListG; 28 private import glib.Str; 29 private import glib.Variant; 30 private import glib.VariantType; 31 private import gobject.ObjectG; 32 private import libsecret.Collection; 33 private import libsecret.Prompt; 34 private import libsecret.Schema; 35 private import libsecret.Value; 36 private import libsecret.c.functions; 37 public import libsecret.c.types; 38 39 40 /** 41 * A proxy object representing the Secret Service. 42 */ 43 public class Service : DBusProxy 44 { 45 /** the main Gtk struct */ 46 protected SecretService* secretService; 47 48 /** Get the main Gtk struct */ 49 public SecretService* getServiceStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return secretService; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)secretService; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (SecretService* secretService, bool ownedRef = false) 66 { 67 this.secretService = secretService; 68 super(cast(GDBusProxy*)secretService, ownedRef); 69 } 70 71 alias getFlags = DBusProxy.getFlags; 72 73 /** 74 */ 75 76 /** */ 77 public static GType getType() 78 { 79 return secret_service_get_type(); 80 } 81 82 /** 83 * Disconnect the default #SecretService proxy returned by secret_service_get() 84 * and secret_service_get_sync(). 85 * 86 * It is not necessary to call this function, but you may choose to do so at 87 * program exit. It is useful for testing that memory is not leaked. 88 * 89 * This function is safe to call at any time. But if other objects in this 90 * library are still referenced, then this will not result in all memory 91 * being freed. 92 */ 93 public static void disconnect() 94 { 95 secret_service_disconnect(); 96 } 97 98 /** 99 * Get a #SecretService proxy for the Secret Service. If such a proxy object 100 * already exists, then the same proxy is returned. 101 * 102 * If @flags contains any flags of which parts of the secret service to 103 * ensure are initialized, then those will be initialized before completing. 104 * 105 * This method will return immediately and complete asynchronously. 106 * 107 * Params: 108 * flags = flags for which service functionality to ensure is initialized 109 * cancellable = optional cancellation object 110 * callback = called when the operation completes 111 * userData = data to be passed to the callback 112 */ 113 public static void get(SecretServiceFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 114 { 115 secret_service_get(flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 116 } 117 118 /** 119 * Complete an asynchronous operation to get a #SecretService proxy for the 120 * Secret Service. 121 * 122 * Params: 123 * result = the asynchronous result passed to the callback 124 * 125 * Returns: a new reference to a #SecretService proxy, which 126 * should be released with g_object_unref(). 127 * 128 * Throws: GException on failure. 129 */ 130 public static Service getFinish(AsyncResultIF result) 131 { 132 GError* err = null; 133 134 auto p = secret_service_get_finish((result is null) ? null : result.getAsyncResultStruct(), &err); 135 136 if (err !is null) 137 { 138 throw new GException( new ErrorG(err) ); 139 } 140 141 if(p is null) 142 { 143 return null; 144 } 145 146 return ObjectG.getDObject!(Service)(cast(SecretService*) p, true); 147 } 148 149 /** 150 * Get a #SecretService proxy for the Secret Service. If such a proxy object 151 * already exists, then the same proxy is returned. 152 * 153 * If @flags contains any flags of which parts of the secret service to 154 * ensure are initialized, then those will be initialized before returning. 155 * 156 * This method may block indefinitely and should not be used in user interface 157 * threads. 158 * 159 * Params: 160 * flags = flags for which service functionality to ensure is initialized 161 * cancellable = optional cancellation object 162 * 163 * Returns: a new reference to a #SecretService proxy, which 164 * should be released with g_object_unref(). 165 * 166 * Throws: GException on failure. 167 */ 168 public static Service getSync(SecretServiceFlags flags, Cancellable cancellable) 169 { 170 GError* err = null; 171 172 auto p = secret_service_get_sync(flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 173 174 if (err !is null) 175 { 176 throw new GException( new ErrorG(err) ); 177 } 178 179 if(p is null) 180 { 181 return null; 182 } 183 184 return ObjectG.getDObject!(Service)(cast(SecretService*) p, true); 185 } 186 187 /** 188 * Create a new #SecretService proxy for the Secret Service. 189 * 190 * This function is rarely used, see secret_service_get() instead. 191 * 192 * The @service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the type 193 * of a derived class. 194 * 195 * If @flags contains any flags of which parts of the secret service to 196 * ensure are initialized, then those will be initialized before returning. 197 * 198 * If @service_bus_name is %NULL then the default is used. 199 * 200 * This method will return immediately and complete asynchronously. 201 * 202 * Params: 203 * serviceGtype = the GType of the new secret service 204 * serviceBusName = the D-Bus service name of the secret service 205 * flags = flags for which service functionality to ensure is initialized 206 * cancellable = optional cancellation object 207 * callback = called when the operation completes 208 * userData = data to be passed to the callback 209 */ 210 public static void open(GType serviceGtype, string serviceBusName, SecretServiceFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 211 { 212 secret_service_open(serviceGtype, Str.toStringz(serviceBusName), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 213 } 214 215 /** 216 * Complete an asynchronous operation to create a new #SecretService proxy for 217 * the Secret Service. 218 * 219 * Params: 220 * result = the asynchronous result passed to the callback 221 * 222 * Returns: a new reference to a #SecretService proxy, which 223 * should be released with g_object_unref(). 224 * 225 * Throws: GException on failure. 226 */ 227 public static Service openFinish(AsyncResultIF result) 228 { 229 GError* err = null; 230 231 auto p = secret_service_open_finish((result is null) ? null : result.getAsyncResultStruct(), &err); 232 233 if (err !is null) 234 { 235 throw new GException( new ErrorG(err) ); 236 } 237 238 if(p is null) 239 { 240 return null; 241 } 242 243 return ObjectG.getDObject!(Service)(cast(SecretService*) p, true); 244 } 245 246 /** 247 * Create a new #SecretService proxy for the Secret Service. 248 * 249 * This function is rarely used, see secret_service_get_sync() instead. 250 * 251 * The @service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the 252 * type of a derived class. 253 * 254 * If @flags contains any flags of which parts of the secret service to 255 * ensure are initialized, then those will be initialized before returning. 256 * 257 * If @service_bus_name is %NULL then the default is used. 258 * 259 * This method may block indefinitely and should not be used in user interface 260 * threads. 261 * 262 * Params: 263 * serviceGtype = the GType of the new secret service 264 * serviceBusName = the D-Bus service name of the secret service 265 * flags = flags for which service functionality to ensure is initialized 266 * cancellable = optional cancellation object 267 * 268 * Returns: a new reference to a #SecretService proxy, which 269 * should be released with g_object_unref(). 270 * 271 * Throws: GException on failure. 272 */ 273 public static Service openSync(GType serviceGtype, string serviceBusName, SecretServiceFlags flags, Cancellable cancellable) 274 { 275 GError* err = null; 276 277 auto p = secret_service_open_sync(serviceGtype, Str.toStringz(serviceBusName), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 278 279 if (err !is null) 280 { 281 throw new GException( new ErrorG(err) ); 282 } 283 284 if(p is null) 285 { 286 return null; 287 } 288 289 return ObjectG.getDObject!(Service)(cast(SecretService*) p, true); 290 } 291 292 /** 293 * Remove unlocked items which match the attributes from the secret service. 294 * 295 * The @attributes should be a set of key and value string pairs. 296 * 297 * If @service is NULL, then secret_service_get() will be called to get 298 * the default #SecretService proxy. 299 * 300 * This method will return immediately and complete asynchronously. 301 * 302 * Params: 303 * schema = the schema for the attributes 304 * attributes = the attribute keys and values 305 * cancellable = optional cancellation object 306 * callback = called when the operation completes 307 * userData = data to be passed to the callback 308 */ 309 public void clear(Schema schema, HashTable attributes, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 310 { 311 secret_service_clear(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 312 } 313 314 /** 315 * Finish asynchronous operation to remove items from the secret 316 * service. 317 * 318 * Params: 319 * result = the asynchronous result passed to the callback 320 * 321 * Returns: whether items were removed or not 322 * 323 * Throws: GException on failure. 324 */ 325 public bool clearFinish(AsyncResultIF result) 326 { 327 GError* err = null; 328 329 auto p = secret_service_clear_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 330 331 if (err !is null) 332 { 333 throw new GException( new ErrorG(err) ); 334 } 335 336 return p; 337 } 338 339 /** 340 * Remove unlocked items which match the attributes from the secret service. 341 * 342 * The @attributes should be a set of key and value string pairs. 343 * 344 * If @service is NULL, then secret_service_get_sync() will be called to get 345 * the default #SecretService proxy. 346 * 347 * This method may block indefinitely and should not be used in user interface 348 * threads. 349 * 350 * Params: 351 * schema = the schema for the attributes 352 * attributes = the attribute keys and values 353 * cancellable = optional cancellation object 354 * 355 * Returns: whether items were removed or not 356 * 357 * Throws: GException on failure. 358 */ 359 public bool clearSync(Schema schema, HashTable attributes, Cancellable cancellable) 360 { 361 GError* err = null; 362 363 auto p = secret_service_clear_sync(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 364 365 if (err !is null) 366 { 367 throw new GException( new ErrorG(err) ); 368 } 369 370 return p; 371 } 372 373 /** 374 * Create a new collection in the secret service, and return its path. 375 * 376 * Using this method requires that you setup a correct hash table of D-Bus 377 * properties for the new collection. You may prefer to use 378 * secret_collection_create() which does handles this for you. 379 * 380 * An @alias is a well-known tag for a collection, such as 'default' (ie: the 381 * default collection to store items in). This allows other applications to 382 * easily identify and share a collection. If a collection with the @alias 383 * already exists, then instead of creating a new collection, the existing 384 * collection will be returned. If no collection with this alias exists, then a 385 * new collection will be created and this alias will be assigned to it. 386 * 387 * @properties is a set of properties for the new collection. The keys in the 388 * hash table should be interface.property strings like 389 * <literal>org.freedesktop.Secret.Collection.Label</literal>. The values 390 * in the hash table should be #GVariant values of the properties. 391 * 392 * If you wish to have a 393 * 394 * This method will return immediately and complete asynchronously. The secret 395 * service may prompt the user. secret_service_prompt() will be used to handle 396 * any prompts that are required. 397 * 398 * Params: 399 * properties = hash table of properties for 400 * the new collection 401 * alias_ = an alias to check for before creating the new 402 * collection, or to assign to the new collection 403 * flags = not currently used 404 * cancellable = optional cancellation object 405 * callback = called when the operation completes 406 * userData = data to be passed to the callback 407 */ 408 public void createCollectionDbusPath(HashTable properties, string alias_, SecretCollectionCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 409 { 410 secret_service_create_collection_dbus_path(secretService, (properties is null) ? null : properties.getHashTableStruct(), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 411 } 412 413 /** 414 * Finish asynchronous operation to create a new collection in the secret 415 * service. 416 * 417 * Params: 418 * result = the asynchronous result passed to the callback 419 * 420 * Returns: a new string containing the D-Bus object path 421 * of the collection 422 * 423 * Throws: GException on failure. 424 */ 425 public string createCollectionDbusPathFinish(AsyncResultIF result) 426 { 427 GError* err = null; 428 429 auto retStr = secret_service_create_collection_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 430 431 if (err !is null) 432 { 433 throw new GException( new ErrorG(err) ); 434 } 435 436 scope(exit) Str.freeString(retStr); 437 return Str.toString(retStr); 438 } 439 440 /** 441 * Create a new collection in the secret service and return its path. 442 * 443 * Using this method requires that you setup a correct hash table of D-Bus 444 * properties for the new collection. You may prefer to use 445 * secret_collection_create() which does handles this for you. 446 * 447 * An @alias is a well-known tag for a collection, such as 'default' (ie: the 448 * default collection to store items in). This allows other applications to 449 * easily identify and share a collection. If a collection with the @alias 450 * already exists, then instead of creating a new collection, the existing 451 * collection will be returned. If no collection with this alias exists, then 452 * a new collection will be created and this alias will be assigned to it. 453 * 454 * @properties is a set of properties for the new collection. The keys in the 455 * hash table should be interface.property strings like 456 * <literal>org.freedesktop.Secret.Collection.Label</literal>. The values 457 * in the hash table should be #GVariant values of the properties. 458 * 459 * This method may block indefinitely and should not be used in user interface 460 * threads. The secret service may prompt the user. secret_service_prompt() 461 * will be used to handle any prompts that are required. 462 * 463 * Params: 464 * properties = hash table of D-Bus properties 465 * for the new collection 466 * alias_ = an alias to check for before creating the new 467 * collection, or to assign to the new collection 468 * flags = not currently used 469 * cancellable = optional cancellation object 470 * 471 * Returns: a new string containing the D-Bus object path 472 * of the collection 473 * 474 * Throws: GException on failure. 475 */ 476 public string createCollectionDbusPathSync(HashTable properties, string alias_, SecretCollectionCreateFlags flags, Cancellable cancellable) 477 { 478 GError* err = null; 479 480 auto retStr = secret_service_create_collection_dbus_path_sync(secretService, (properties is null) ? null : properties.getHashTableStruct(), Str.toStringz(alias_), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 481 482 if (err !is null) 483 { 484 throw new GException( new ErrorG(err) ); 485 } 486 487 scope(exit) Str.freeString(retStr); 488 return Str.toString(retStr); 489 } 490 491 /** 492 * Create a new item in a secret service collection and return its D-Bus 493 * object path. 494 * 495 * It is often easier to use secret_password_store() or secret_item_create() 496 * rather than using this function. Using this method requires that you setup 497 * a correct hash table of D-Bus @properties for the new collection. 498 * 499 * If the @flags contains %SECRET_ITEM_CREATE_REPLACE, then the secret 500 * service will search for an item matching the @attributes, and update that item 501 * instead of creating a new one. 502 * 503 * @properties is a set of properties for the new collection. The keys in the 504 * hash table should be interface.property strings like 505 * <literal>org.freedesktop.Secret.Item.Label</literal>. The values 506 * in the hash table should be #GVariant values of the properties. 507 * 508 * This method will return immediately and complete asynchronously. The secret 509 * service may prompt the user. secret_service_prompt() will be used to handle 510 * any prompts that are required. 511 * 512 * Params: 513 * collectionPath = the D-Bus object path of the collection in which to create item 514 * properties = hash table of D-Bus properties 515 * for the new collection 516 * value = the secret value to store in the item 517 * flags = flags for the creation of the new item 518 * cancellable = optional cancellation object 519 * callback = called when the operation completes 520 * userData = data to be passed to the callback 521 */ 522 public void createItemDbusPath(string collectionPath, HashTable properties, Value value, SecretItemCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 523 { 524 secret_service_create_item_dbus_path(secretService, Str.toStringz(collectionPath), (properties is null) ? null : properties.getHashTableStruct(), (value is null) ? null : value.getValueStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 525 } 526 527 /** 528 * Finish asynchronous operation to create a new item in the secret 529 * service. 530 * 531 * Params: 532 * result = the asynchronous result passed to the callback 533 * 534 * Returns: a new string containing the D-Bus object path 535 * of the item 536 * 537 * Throws: GException on failure. 538 */ 539 public string createItemDbusPathFinish(AsyncResultIF result) 540 { 541 GError* err = null; 542 543 auto retStr = secret_service_create_item_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 544 545 if (err !is null) 546 { 547 throw new GException( new ErrorG(err) ); 548 } 549 550 scope(exit) Str.freeString(retStr); 551 return Str.toString(retStr); 552 } 553 554 /** 555 * Create a new item in a secret service collection and return its D-Bus 556 * object path. 557 * 558 * It is often easier to use secret_password_store_sync() or secret_item_create_sync() 559 * rather than using this function. Using this method requires that you setup 560 * a correct hash table of D-Bus @properties for the new collection. 561 * 562 * If the @flags contains %SECRET_ITEM_CREATE_REPLACE, then the secret 563 * service will search for an item matching the @attributes, and update that item 564 * instead of creating a new one. 565 * 566 * @properties is a set of properties for the new collection. The keys in the 567 * hash table should be interface.property strings like 568 * <literal>org.freedesktop.Secret.Item.Label</literal>. The values 569 * in the hash table should be #GVariant values of the properties. 570 * 571 * This method may block indefinitely and should not be used in user interface 572 * threads. The secret service may prompt the user. secret_service_prompt() 573 * will be used to handle any prompts that are required. 574 * 575 * Params: 576 * collectionPath = the D-Bus path of the collection in which to create item 577 * properties = hash table of D-Bus properties 578 * for the new collection 579 * value = the secret value to store in the item 580 * flags = flags for the creation of the new item 581 * cancellable = optional cancellation object 582 * 583 * Returns: a new string containing the D-Bus object path 584 * of the item 585 * 586 * Throws: GException on failure. 587 */ 588 public string createItemDbusPathSync(string collectionPath, HashTable properties, Value value, SecretItemCreateFlags flags, Cancellable cancellable) 589 { 590 GError* err = null; 591 592 auto retStr = secret_service_create_item_dbus_path_sync(secretService, Str.toStringz(collectionPath), (properties is null) ? null : properties.getHashTableStruct(), (value is null) ? null : value.getValueStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 593 594 if (err !is null) 595 { 596 throw new GException( new ErrorG(err) ); 597 } 598 599 scope(exit) Str.freeString(retStr); 600 return Str.toString(retStr); 601 } 602 603 /** 604 * Decode a #SecretValue into GVariant received with the Secret Service 605 * DBus API. 606 * 607 * The GVariant should have a <literal>(oayays)</literal> signature. 608 * 609 * A session must have already been established by the #SecretService, and 610 * the encoded secret must be valid for that session. 611 * 612 * Params: 613 * value = the encoded secret 614 * 615 * Returns: the decoded secret value 616 */ 617 public Value decodeDbusSecret(Variant value) 618 { 619 auto p = secret_service_decode_dbus_secret(secretService, (value is null) ? null : value.getVariantStruct()); 620 621 if(p is null) 622 { 623 return null; 624 } 625 626 return ObjectG.getDObject!(Value)(cast(SecretValue*) p, true); 627 } 628 629 /** 630 * Delete a secret item from the secret service. 631 * 632 * The item is represented by its D-Bus object path. If you already have a 633 * #SecretItem proxy objects, use use secret_item_delete() instead. 634 * 635 * This method will return immediately and complete asynchronously. 636 * 637 * Params: 638 * itemPath = the D-Bus path of item to delete 639 * cancellable = optional cancellation object 640 * callback = called when the operation completes 641 * userData = data to be passed to the callback 642 */ 643 public void deleteItemDbusPath(string itemPath, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 644 { 645 secret_service_delete_item_dbus_path(secretService, Str.toStringz(itemPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 646 } 647 648 /** 649 * Complete an asynchronous operation to delete a secret item from the secret 650 * service. 651 * 652 * Params: 653 * result = the asynchronous result passed to the callback 654 * 655 * Returns: whether the deletion was successful or not 656 * 657 * Throws: GException on failure. 658 */ 659 public bool deleteItemDbusPathFinish(AsyncResultIF result) 660 { 661 GError* err = null; 662 663 auto p = secret_service_delete_item_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 664 665 if (err !is null) 666 { 667 throw new GException( new ErrorG(err) ); 668 } 669 670 return p; 671 } 672 673 /** 674 * Delete a secret item from the secret service. 675 * 676 * The item is represented by its D-Bus object path. If you already have a 677 * #SecretItem proxy objects, use use secret_item_delete_sync() instead. 678 * 679 * This method may block indefinitely and should not be used in user interface 680 * threads. 681 * 682 * Params: 683 * itemPath = the D-Bus path of item to delete 684 * cancellable = optional cancellation object 685 * 686 * Returns: whether the deletion was successful or not 687 * 688 * Throws: GException on failure. 689 */ 690 public bool deleteItemDbusPathSync(string itemPath, Cancellable cancellable) 691 { 692 GError* err = null; 693 694 auto p = secret_service_delete_item_dbus_path_sync(secretService, Str.toStringz(itemPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 695 696 if (err !is null) 697 { 698 throw new GException( new ErrorG(err) ); 699 } 700 701 return p; 702 } 703 704 /** 705 * Encodes a #SecretValue into GVariant for use with the Secret Service 706 * DBus API. 707 * 708 * The resulting GVariant will have a <literal>(oayays)</literal> signature. 709 * 710 * A session must have already been established by the #SecretService. 711 * 712 * Params: 713 * value = the secret value 714 * 715 * Returns: the encoded secret 716 */ 717 public Variant encodeDbusSecret(Value value) 718 { 719 auto p = secret_service_encode_dbus_secret(secretService, (value is null) ? null : value.getValueStruct()); 720 721 if(p is null) 722 { 723 return null; 724 } 725 726 return new Variant(cast(GVariant*) p); 727 } 728 729 /** 730 * Ensure that the #SecretService proxy has established a session with the 731 * Secret Service. This session is used to transfer secrets. 732 * 733 * It is not normally necessary to call this method, as the session is 734 * established as necessary. You can also pass the %SECRET_SERVICE_OPEN_SESSION 735 * to secret_service_get() in order to ensure that a session has been established 736 * by the time you get the #SecretService proxy. 737 * 738 * This method will return immediately and complete asynchronously. 739 * 740 * Params: 741 * cancellable = optional cancellation object 742 * callback = called when the operation completes 743 * userData = data to be passed to the callback 744 */ 745 public void ensureSession(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 746 { 747 secret_service_ensure_session(secretService, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 748 } 749 750 /** 751 * Finish an asynchronous operation to ensure that the #SecretService proxy 752 * has established a session with the Secret Service. 753 * 754 * Params: 755 * result = the asynchronous result passed to the callback 756 * 757 * Returns: whether a session is established or not 758 * 759 * Throws: GException on failure. 760 */ 761 public bool ensureSessionFinish(AsyncResultIF result) 762 { 763 GError* err = null; 764 765 auto p = secret_service_ensure_session_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 766 767 if (err !is null) 768 { 769 throw new GException( new ErrorG(err) ); 770 } 771 772 return p; 773 } 774 775 /** 776 * Ensure that the #SecretService proxy has established a session with the 777 * Secret Service. This session is used to transfer secrets. 778 * 779 * It is not normally necessary to call this method, as the session is 780 * established as necessary. You can also pass the %SECRET_SERVICE_OPEN_SESSION 781 * to secret_service_get_sync() in order to ensure that a session has been 782 * established by the time you get the #SecretService proxy. 783 * 784 * This method may block indefinitely and should not be used in user interface 785 * threads. 786 * 787 * Params: 788 * cancellable = optional cancellation object 789 * 790 * Returns: whether a session is established or not 791 * 792 * Throws: GException on failure. 793 */ 794 public bool ensureSessionSync(Cancellable cancellable) 795 { 796 GError* err = null; 797 798 auto p = secret_service_ensure_session_sync(secretService, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 799 800 if (err !is null) 801 { 802 throw new GException( new ErrorG(err) ); 803 } 804 805 return p; 806 } 807 808 /** 809 * Get the GObject type for collections instantiated by this service. 810 * This will always be either #SecretCollection or derived from it. 811 * 812 * Returns: the gobject type for collections 813 */ 814 public GType getCollectionGtype() 815 { 816 return secret_service_get_collection_gtype(secretService); 817 } 818 819 /** 820 * Get a list of #SecretCollection objects representing all the collections 821 * in the secret service. 822 * 823 * If the %SECRET_SERVICE_LOAD_COLLECTIONS flag was not specified when 824 * initializing #SecretService proxy object, then this method will return 825 * %NULL. Use secret_service_load_collections() to load the collections. 826 * 827 * Returns: a 828 * list of the collections in the secret service 829 */ 830 public ListG getCollections() 831 { 832 auto p = secret_service_get_collections(secretService); 833 834 if(p is null) 835 { 836 return null; 837 } 838 839 return new ListG(cast(GList*) p, true); 840 } 841 842 /** 843 * Get the flags representing what features of the #SecretService proxy 844 * have been initialized. 845 * 846 * Use secret_service_ensure_session() or secret_service_load_collections() 847 * to initialize further features and change the flags. 848 * 849 * Returns: the flags for features initialized 850 */ 851 public SecretServiceFlags getFlags() 852 { 853 return secret_service_get_flags(secretService); 854 } 855 856 /** 857 * Get the GObject type for items instantiated by this service. 858 * This will always be either #SecretItem or derived from it. 859 * 860 * Returns: the gobject type for items 861 */ 862 public GType getItemGtype() 863 { 864 return secret_service_get_item_gtype(secretService); 865 } 866 867 /** 868 * Get the secret value for a secret item stored in the service. 869 * 870 * The item is represented by its D-Bus object path. If you already have a 871 * #SecretItem proxy object, use use secret_item_get_secret() to more simply 872 * get its secret value. 873 * 874 * This function returns immediately and completes asynchronously. 875 * 876 * Params: 877 * itemPath = the D-Bus path to item to retrieve secret for 878 * cancellable = optional cancellation object 879 * callback = called when the operation completes 880 * userData = data to pass to the callback 881 */ 882 public void getSecretForDbusPath(string itemPath, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 883 { 884 secret_service_get_secret_for_dbus_path(secretService, Str.toStringz(itemPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 885 } 886 887 /** 888 * Complete asynchronous operation to get the secret value for an 889 * secret item stored in the service. 890 * 891 * Will return %NULL if the item is locked. 892 * 893 * Params: 894 * result = asynchronous result passed to callback 895 * 896 * Returns: the newly allocated secret value 897 * for the item, which should be released with secret_value_unref() 898 * 899 * Throws: GException on failure. 900 */ 901 public Value getSecretForDbusPathFinish(AsyncResultIF result) 902 { 903 GError* err = null; 904 905 auto p = secret_service_get_secret_for_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 906 907 if (err !is null) 908 { 909 throw new GException( new ErrorG(err) ); 910 } 911 912 if(p is null) 913 { 914 return null; 915 } 916 917 return ObjectG.getDObject!(Value)(cast(SecretValue*) p, true); 918 } 919 920 /** 921 * Get the secret value for a secret item stored in the service. 922 * 923 * The item is represented by its D-Bus object path. If you already have a 924 * #SecretItem proxy object, use use secret_item_load_secret_sync() to more simply 925 * get its secret value. 926 * 927 * This method may block indefinitely and should not be used in user interface 928 * threads. 929 * 930 * Will return %NULL if the item is locked. 931 * 932 * Params: 933 * itemPath = the D-Bus path to item to retrieve secret for 934 * cancellable = optional cancellation object 935 * 936 * Returns: the newly allocated secret value 937 * for the item, which should be released with secret_value_unref() 938 * 939 * Throws: GException on failure. 940 */ 941 public Value getSecretForDbusPathSync(string itemPath, Cancellable cancellable) 942 { 943 GError* err = null; 944 945 auto p = secret_service_get_secret_for_dbus_path_sync(secretService, Str.toStringz(itemPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 946 947 if (err !is null) 948 { 949 throw new GException( new ErrorG(err) ); 950 } 951 952 if(p is null) 953 { 954 return null; 955 } 956 957 return ObjectG.getDObject!(Value)(cast(SecretValue*) p, true); 958 } 959 960 /** 961 * Get the secret values for a secret item stored in the service. 962 * 963 * The items are represented by their D-Bus object paths. If you already have 964 * #SecretItem proxy objects, use use secret_item_load_secrets() to more simply 965 * get their secret values. 966 * 967 * This function returns immediately and completes asynchronously. 968 * 969 * Params: 970 * itemPaths = the D-Bus paths to items to retrieve secrets for 971 * cancellable = optional cancellation object 972 * callback = called when the operation completes 973 * userData = data to pass to the callback 974 */ 975 public void getSecretsForDbusPaths(string[] itemPaths, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 976 { 977 secret_service_get_secrets_for_dbus_paths(secretService, Str.toStringzArray(itemPaths), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 978 } 979 980 /** 981 * Complete asynchronous operation to get the secret values for an 982 * secret items stored in the service. 983 * 984 * Items that are locked will not be included the results. 985 * 986 * Params: 987 * result = asynchronous result passed to callback 988 * 989 * Returns: a newly 990 * allocated hash table of item_path keys to #SecretValue 991 * values. 992 * 993 * Throws: GException on failure. 994 */ 995 public HashTable getSecretsForDbusPathsFinish(AsyncResultIF result) 996 { 997 GError* err = null; 998 999 auto p = secret_service_get_secrets_for_dbus_paths_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1000 1001 if (err !is null) 1002 { 1003 throw new GException( new ErrorG(err) ); 1004 } 1005 1006 if(p is null) 1007 { 1008 return null; 1009 } 1010 1011 return new HashTable(cast(GHashTable*) p, true); 1012 } 1013 1014 /** 1015 * Get the secret values for a secret item stored in the service. 1016 * 1017 * The items are represented by their D-Bus object paths. If you already have 1018 * #SecretItem proxy objects, use use secret_item_load_secrets_sync() to more 1019 * simply get their secret values. 1020 * 1021 * This method may block indefinitely and should not be used in user interface 1022 * threads. 1023 * 1024 * Items that are locked will not be included the results. 1025 * 1026 * Params: 1027 * itemPaths = the D-Bus paths to items to retrieve secrets for 1028 * cancellable = optional cancellation object 1029 * 1030 * Returns: a newly 1031 * allocated hash table of item_path keys to #SecretValue 1032 * values. 1033 * 1034 * Throws: GException on failure. 1035 */ 1036 public HashTable getSecretsForDbusPathsSync(string[] itemPaths, Cancellable cancellable) 1037 { 1038 GError* err = null; 1039 1040 auto p = secret_service_get_secrets_for_dbus_paths_sync(secretService, Str.toStringzArray(itemPaths), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1041 1042 if (err !is null) 1043 { 1044 throw new GException( new ErrorG(err) ); 1045 } 1046 1047 if(p is null) 1048 { 1049 return null; 1050 } 1051 1052 return new HashTable(cast(GHashTable*) p, true); 1053 } 1054 1055 /** 1056 * Get the set of algorithms being used to transfer secrets between this 1057 * secret service proxy and the Secret Service itself. 1058 * 1059 * This will be %NULL if no session has been established. Use 1060 * secret_service_ensure_session() to establish a session. 1061 * 1062 * Returns: a string representing the algorithms for transferring 1063 * secrets 1064 */ 1065 public string getSessionAlgorithms() 1066 { 1067 return Str.toString(secret_service_get_session_algorithms(secretService)); 1068 } 1069 1070 /** 1071 * Get the D-Bus object path of the session object being used to transfer 1072 * secrets between this secret service proxy and the Secret Service itself. 1073 * 1074 * This will be %NULL if no session has been established. Use 1075 * secret_service_ensure_session() to establish a session. 1076 * 1077 * Returns: a string representing the D-Bus object path of the 1078 * session 1079 */ 1080 public string getSessionDbusPath() 1081 { 1082 return Str.toString(secret_service_get_session_dbus_path(secretService)); 1083 } 1084 1085 /** 1086 * Ensure that the #SecretService proxy has loaded all the collections present 1087 * in the Secret Service. This affects the result of 1088 * secret_service_get_collections(). 1089 * 1090 * You can also pass the %SECRET_SERVICE_LOAD_COLLECTIONS to 1091 * secret_service_get_sync() in order to ensure that the collections have been 1092 * loaded by the time you get the #SecretService proxy. 1093 * 1094 * This method will return immediately and complete asynchronously. 1095 * 1096 * Params: 1097 * cancellable = optional cancellation object 1098 * callback = called when the operation completes 1099 * userData = data to be passed to the callback 1100 */ 1101 public void loadCollections(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1102 { 1103 secret_service_load_collections(secretService, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1104 } 1105 1106 /** 1107 * Complete an asynchronous operation to ensure that the #SecretService proxy 1108 * has loaded all the collections present in the Secret Service. 1109 * 1110 * Params: 1111 * result = the asynchronous result passed to the callback 1112 * 1113 * Returns: whether the load was successful or not 1114 * 1115 * Throws: GException on failure. 1116 */ 1117 public bool loadCollectionsFinish(AsyncResultIF result) 1118 { 1119 GError* err = null; 1120 1121 auto p = secret_service_load_collections_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 1122 1123 if (err !is null) 1124 { 1125 throw new GException( new ErrorG(err) ); 1126 } 1127 1128 return p; 1129 } 1130 1131 /** 1132 * Ensure that the #SecretService proxy has loaded all the collections present 1133 * in the Secret Service. This affects the result of 1134 * secret_service_get_collections(). 1135 * 1136 * You can also pass the %SECRET_SERVICE_LOAD_COLLECTIONS to 1137 * secret_service_get_sync() in order to ensure that the collections have been 1138 * loaded by the time you get the #SecretService proxy. 1139 * 1140 * This method may block indefinitely and should not be used in user interface 1141 * threads. 1142 * 1143 * Params: 1144 * cancellable = optional cancellation object 1145 * 1146 * Returns: whether the load was successful or not 1147 * 1148 * Throws: GException on failure. 1149 */ 1150 public bool loadCollectionsSync(Cancellable cancellable) 1151 { 1152 GError* err = null; 1153 1154 auto p = secret_service_load_collections_sync(secretService, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1155 1156 if (err !is null) 1157 { 1158 throw new GException( new ErrorG(err) ); 1159 } 1160 1161 return p; 1162 } 1163 1164 /** 1165 * Lock items or collections in the secret service. 1166 * 1167 * The secret service may not be able to lock items individually, and may 1168 * lock an entire collection instead. 1169 * 1170 * If @service is NULL, then secret_service_get() will be called to get 1171 * the default #SecretService proxy. 1172 * 1173 * This method returns immediately and completes asynchronously. The secret 1174 * service may prompt the user. secret_service_prompt() will be used to handle 1175 * any prompts that show up. 1176 * 1177 * Params: 1178 * objects = the items or collections to lock 1179 * cancellable = optional cancellation object 1180 * callback = called when the operation completes 1181 * userData = data to pass to the callback 1182 */ 1183 public void lock(ListG objects, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1184 { 1185 secret_service_lock(secretService, (objects is null) ? null : objects.getListGStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1186 } 1187 1188 /** 1189 * Lock items or collections in the secret service. 1190 * 1191 * The items or collections are represented by their D-Bus object paths. If you 1192 * already have #SecretItem and #SecretCollection proxy objects, use use 1193 * secret_service_lock() instead. 1194 * 1195 * The secret service may not be able to lock items individually, and may 1196 * lock an entire collection instead. 1197 * 1198 * This method returns immediately and completes asynchronously. The secret 1199 * service may prompt the user. secret_service_prompt() will be used to handle 1200 * any prompts that show up. 1201 * 1202 * Params: 1203 * paths = the D-Bus paths for items or collections to lock 1204 * cancellable = optional cancellation object 1205 * callback = called when the operation completes 1206 * userData = data to pass to the callback 1207 */ 1208 public void lockDbusPaths(string[] paths, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1209 { 1210 secret_service_lock_dbus_paths(secretService, Str.toStringzArray(paths), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1211 } 1212 1213 /** 1214 * Complete asynchronous operation to lock items or collections in the secret 1215 * service. 1216 * 1217 * The secret service may not be able to lock items individually, and may 1218 * lock an entire collection instead. 1219 * 1220 * Params: 1221 * result = asynchronous result passed to the callback 1222 * locked = location to place array of D-Bus paths of items or collections 1223 * that were locked 1224 * 1225 * Returns: the number of items or collections that were locked 1226 * 1227 * Throws: GException on failure. 1228 */ 1229 public int lockDbusPathsFinish(AsyncResultIF result, out string[] locked) 1230 { 1231 char** outlocked = null; 1232 GError* err = null; 1233 1234 auto p = secret_service_lock_dbus_paths_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &outlocked, &err); 1235 1236 if (err !is null) 1237 { 1238 throw new GException( new ErrorG(err) ); 1239 } 1240 1241 locked = Str.toStringArray(outlocked); 1242 1243 return p; 1244 } 1245 1246 /** 1247 * Lock items or collections in the secret service. 1248 * 1249 * The items or collections are represented by their D-Bus object paths. If you 1250 * already have #SecretItem and #SecretCollection proxy objects, use use 1251 * secret_service_lock_sync() instead. 1252 * 1253 * The secret service may not be able to lock items individually, and may 1254 * lock an entire collection instead. 1255 * 1256 * This method may block indefinitely and should not be used in user 1257 * interface threads. The secret service may prompt the user. 1258 * secret_service_prompt() will be used to handle any prompts that show up. 1259 * 1260 * Params: 1261 * paths = the D-Bus object paths of the items or collections to lock 1262 * cancellable = optional cancellation object 1263 * locked = location to place array of D-Bus paths of items or collections 1264 * that were locked 1265 * 1266 * Returns: the number of items or collections that were locked 1267 * 1268 * Throws: GException on failure. 1269 */ 1270 public int lockDbusPathsSync(string[] paths, Cancellable cancellable, out string[] locked) 1271 { 1272 char** outlocked = null; 1273 GError* err = null; 1274 1275 auto p = secret_service_lock_dbus_paths_sync(secretService, Str.toStringzArray(paths), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outlocked, &err); 1276 1277 if (err !is null) 1278 { 1279 throw new GException( new ErrorG(err) ); 1280 } 1281 1282 locked = Str.toStringArray(outlocked); 1283 1284 return p; 1285 } 1286 1287 /** 1288 * Complete asynchronous operation to lock items or collections in the secret 1289 * service. 1290 * 1291 * The secret service may not be able to lock items individually, and may 1292 * lock an entire collection instead. 1293 * 1294 * Params: 1295 * result = asynchronous result passed to the callback 1296 * locked = location to place list of items or collections that were locked 1297 * 1298 * Returns: the number of items or collections that were locked 1299 * 1300 * Throws: GException on failure. 1301 */ 1302 public int lockFinish(AsyncResultIF result, out ListG locked) 1303 { 1304 GList* outlocked = null; 1305 GError* err = null; 1306 1307 auto p = secret_service_lock_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &outlocked, &err); 1308 1309 if (err !is null) 1310 { 1311 throw new GException( new ErrorG(err) ); 1312 } 1313 1314 locked = new ListG(outlocked); 1315 1316 return p; 1317 } 1318 1319 /** 1320 * Lock items or collections in the secret service. 1321 * 1322 * The secret service may not be able to lock items individually, and may 1323 * lock an entire collection instead. 1324 * 1325 * If @service is NULL, then secret_service_get_sync() will be called to get 1326 * the default #SecretService proxy. 1327 * 1328 * This method may block indefinitely and should not be used in user 1329 * interface threads. The secret service may prompt the user. 1330 * secret_service_prompt() will be used to handle any prompts that show up. 1331 * 1332 * Params: 1333 * objects = the items or collections to lock 1334 * cancellable = optional cancellation object 1335 * locked = location to place list of items or collections that were locked 1336 * 1337 * Returns: the number of items or collections that were locked 1338 * 1339 * Throws: GException on failure. 1340 */ 1341 public int lockSync(ListG objects, Cancellable cancellable, out ListG locked) 1342 { 1343 GList* outlocked = null; 1344 GError* err = null; 1345 1346 auto p = secret_service_lock_sync(secretService, (objects is null) ? null : objects.getListGStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outlocked, &err); 1347 1348 if (err !is null) 1349 { 1350 throw new GException( new ErrorG(err) ); 1351 } 1352 1353 locked = new ListG(outlocked); 1354 1355 return p; 1356 } 1357 1358 /** 1359 * Lookup a secret value in the secret service. 1360 * 1361 * The @attributes should be a set of key and value string pairs. 1362 * 1363 * If @service is NULL, then secret_service_get() will be called to get 1364 * the default #SecretService proxy. 1365 * 1366 * This method will return immediately and complete asynchronously. 1367 * 1368 * Params: 1369 * schema = the schema for the attributes 1370 * attributes = the attribute keys and values 1371 * cancellable = optional cancellation object 1372 * callback = called when the operation completes 1373 * userData = data to be passed to the callback 1374 */ 1375 public void lookup(Schema schema, HashTable attributes, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1376 { 1377 secret_service_lookup(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1378 } 1379 1380 /** 1381 * Finish asynchronous operation to lookup a secret value in the secret service. 1382 * 1383 * If no secret is found then %NULL is returned. 1384 * 1385 * Params: 1386 * result = the asynchronous result passed to the callback 1387 * 1388 * Returns: a newly allocated #SecretValue, which should be 1389 * released with secret_value_unref(), or %NULL if no secret found 1390 * 1391 * Throws: GException on failure. 1392 */ 1393 public Value lookupFinish(AsyncResultIF result) 1394 { 1395 GError* err = null; 1396 1397 auto p = secret_service_lookup_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1398 1399 if (err !is null) 1400 { 1401 throw new GException( new ErrorG(err) ); 1402 } 1403 1404 if(p is null) 1405 { 1406 return null; 1407 } 1408 1409 return ObjectG.getDObject!(Value)(cast(SecretValue*) p, true); 1410 } 1411 1412 /** 1413 * Lookup a secret value in the secret service. 1414 * 1415 * The @attributes should be a set of key and value string pairs. 1416 * 1417 * If @service is NULL, then secret_service_get_sync() will be called to get 1418 * the default #SecretService proxy. 1419 * 1420 * This method may block indefinitely and should not be used in user interface 1421 * threads. 1422 * 1423 * Params: 1424 * schema = the schema for the attributes 1425 * attributes = the attribute keys and values 1426 * cancellable = optional cancellation object 1427 * 1428 * Returns: a newly allocated #SecretValue, which should be 1429 * released with secret_value_unref(), or %NULL if no secret found 1430 * 1431 * Throws: GException on failure. 1432 */ 1433 public Value lookupSync(Schema schema, HashTable attributes, Cancellable cancellable) 1434 { 1435 GError* err = null; 1436 1437 auto p = secret_service_lookup_sync(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1438 1439 if (err !is null) 1440 { 1441 throw new GException( new ErrorG(err) ); 1442 } 1443 1444 if(p is null) 1445 { 1446 return null; 1447 } 1448 1449 return ObjectG.getDObject!(Value)(cast(SecretValue*) p, true); 1450 } 1451 1452 /** 1453 * Perform prompting for a #SecretPrompt. 1454 * 1455 * This function is called by other parts of this library to handle prompts 1456 * for the various actions that can require prompting. 1457 * 1458 * Override the #SecretServiceClass <literal>prompt_async</literal> virtual method 1459 * to change the behavior of the prompting. The default behavior is to simply 1460 * run secret_prompt_perform() on the prompt. 1461 * 1462 * Params: 1463 * prompt = the prompt 1464 * returnType = the variant type of the prompt result 1465 * cancellable = optional cancellation object 1466 * callback = called when the operation completes 1467 * userData = data to be passed to the callback 1468 */ 1469 public void prompt(Prompt prompt, VariantType returnType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1470 { 1471 secret_service_prompt(secretService, (prompt is null) ? null : prompt.getPromptStruct(), (returnType is null) ? null : returnType.getVariantTypeStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1472 } 1473 1474 /** 1475 * Perform prompting for a #SecretPrompt. 1476 * 1477 * This function is called by other parts of this library to handle prompts 1478 * for the various actions that can require prompting. 1479 * 1480 * Override the #SecretServiceClass <literal>prompt_async</literal> virtual method 1481 * to change the behavior of the propmting. The default behavior is to simply 1482 * run secret_prompt_perform() on the prompt. 1483 * 1484 * Params: 1485 * promptPath = the D-Bus object path of the prompt 1486 * returnType = the variant type of the prompt result 1487 * cancellable = optional cancellation object 1488 * callback = called when the operation completes 1489 * userData = data to be passed to the callback 1490 */ 1491 public void promptAtDbusPath(string promptPath, VariantType returnType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1492 { 1493 secret_service_prompt_at_dbus_path(secretService, Str.toStringz(promptPath), (returnType is null) ? null : returnType.getVariantTypeStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1494 } 1495 1496 /** 1497 * Complete asynchronous operation to perform prompting for a #SecretPrompt. 1498 * 1499 * Returns a variant result if the prompt was completed and not dismissed. The 1500 * type of result depends on the action the prompt is completing, and is defined 1501 * in the Secret Service DBus API specification. 1502 * 1503 * Params: 1504 * result = the asynchronous result passed to the callback 1505 * 1506 * Returns: %NULL if the prompt was dismissed or an error occurred, 1507 * a variant result if the prompt was successful 1508 * 1509 * Throws: GException on failure. 1510 */ 1511 public Variant promptAtDbusPathFinish(AsyncResultIF result) 1512 { 1513 GError* err = null; 1514 1515 auto p = secret_service_prompt_at_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1516 1517 if (err !is null) 1518 { 1519 throw new GException( new ErrorG(err) ); 1520 } 1521 1522 if(p is null) 1523 { 1524 return null; 1525 } 1526 1527 return new Variant(cast(GVariant*) p, true); 1528 } 1529 1530 /** 1531 * Perform prompting for a #SecretPrompt. 1532 * 1533 * Override the #SecretServiceClass <literal>prompt_async</literal> virtual method 1534 * to change the behavior of the propmting. The default behavior is to simply 1535 * run secret_prompt_perform() on the prompt. 1536 * 1537 * Returns a variant result if the prompt was completed and not dismissed. The 1538 * type of result depends on the action the prompt is completing, and is defined 1539 * in the Secret Service DBus API specification. 1540 * 1541 * This method may block and should not be used in user interface threads. 1542 * 1543 * Params: 1544 * promptPath = the D-Bus object path of the prompt 1545 * cancellable = optional cancellation object 1546 * returnType = the variant type of the prompt result 1547 * 1548 * Returns: %NULL if the prompt was dismissed or an error occurred, 1549 * a variant result if the prompt was successful 1550 * 1551 * Throws: GException on failure. 1552 */ 1553 public Variant promptAtDbusPathSync(string promptPath, Cancellable cancellable, VariantType returnType) 1554 { 1555 GError* err = null; 1556 1557 auto p = secret_service_prompt_at_dbus_path_sync(secretService, Str.toStringz(promptPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), (returnType is null) ? null : returnType.getVariantTypeStruct(), &err); 1558 1559 if (err !is null) 1560 { 1561 throw new GException( new ErrorG(err) ); 1562 } 1563 1564 if(p is null) 1565 { 1566 return null; 1567 } 1568 1569 return new Variant(cast(GVariant*) p, true); 1570 } 1571 1572 /** 1573 * Complete asynchronous operation to perform prompting for a #SecretPrompt. 1574 * 1575 * Returns a variant result if the prompt was completed and not dismissed. The 1576 * type of result depends on the action the prompt is completing, and is defined 1577 * in the Secret Service DBus API specification. 1578 * 1579 * Params: 1580 * result = the asynchronous result passed to the callback 1581 * 1582 * Returns: %NULL if the prompt was dismissed or an error occurred, 1583 * a variant result if the prompt was successful 1584 * 1585 * Throws: GException on failure. 1586 */ 1587 public Variant promptFinish(AsyncResultIF result) 1588 { 1589 GError* err = null; 1590 1591 auto p = secret_service_prompt_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1592 1593 if (err !is null) 1594 { 1595 throw new GException( new ErrorG(err) ); 1596 } 1597 1598 if(p is null) 1599 { 1600 return null; 1601 } 1602 1603 return new Variant(cast(GVariant*) p, true); 1604 } 1605 1606 /** 1607 * Perform prompting for a #SecretPrompt. 1608 * 1609 * Runs a prompt and performs the prompting. Returns a variant result if the 1610 * prompt was completed and not dismissed. The type of result depends on the 1611 * action the prompt is completing, and is defined in the Secret Service DBus 1612 * API specification. 1613 * 1614 * This function is called by other parts of this library to handle prompts 1615 * for the various actions that can require prompting. 1616 * 1617 * Override the #SecretServiceClass <literal>prompt_sync</literal> virtual method 1618 * to change the behavior of the prompting. The default behavior is to simply 1619 * run secret_prompt_perform_sync() on the prompt with a %NULL <literal>window_id</literal>. 1620 * 1621 * Params: 1622 * prompt = the prompt 1623 * cancellable = optional cancellation object 1624 * returnType = the variant type of the prompt result 1625 * 1626 * Returns: %NULL if the prompt was dismissed or an error occurred, 1627 * a variant result if the prompt was successful 1628 * 1629 * Throws: GException on failure. 1630 */ 1631 public Variant promptSync(Prompt prompt, Cancellable cancellable, VariantType returnType) 1632 { 1633 GError* err = null; 1634 1635 auto p = secret_service_prompt_sync(secretService, (prompt is null) ? null : prompt.getPromptStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), (returnType is null) ? null : returnType.getVariantTypeStruct(), &err); 1636 1637 if (err !is null) 1638 { 1639 throw new GException( new ErrorG(err) ); 1640 } 1641 1642 if(p is null) 1643 { 1644 return null; 1645 } 1646 1647 return new Variant(cast(GVariant*) p, true); 1648 } 1649 1650 /** 1651 * Lookup which collection is assigned to this alias. Aliases help determine 1652 * well known collections, such as 'default'. This method looks up the 1653 * dbus object path of the well known collection. 1654 * 1655 * This method will return immediately and complete asynchronously. 1656 * 1657 * Params: 1658 * alias_ = the alias to lookup 1659 * cancellable = optional cancellation object 1660 * callback = called when the operation completes 1661 * userData = data to pass to the callback 1662 */ 1663 public void readAliasDbusPath(string alias_, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1664 { 1665 secret_service_read_alias_dbus_path(secretService, Str.toStringz(alias_), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1666 } 1667 1668 /** 1669 * Finish an asynchronous operation to lookup which collection is assigned 1670 * to an alias. This method returns the DBus object path of the collection 1671 * 1672 * Params: 1673 * result = asynchronous result passed to callback 1674 * 1675 * Returns: the collection dbus object path, or %NULL if 1676 * none assigned to the alias 1677 * 1678 * Throws: GException on failure. 1679 */ 1680 public string readAliasDbusPathFinish(AsyncResultIF result) 1681 { 1682 GError* err = null; 1683 1684 auto retStr = secret_service_read_alias_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1685 1686 if (err !is null) 1687 { 1688 throw new GException( new ErrorG(err) ); 1689 } 1690 1691 scope(exit) Str.freeString(retStr); 1692 return Str.toString(retStr); 1693 } 1694 1695 /** 1696 * Lookup which collection is assigned to this alias. Aliases help determine 1697 * well known collections, such as 'default'. This method returns the dbus 1698 * object path of the collection. 1699 * 1700 * This method may block and should not be used in user interface threads. 1701 * 1702 * Params: 1703 * alias_ = the alias to lookup 1704 * cancellable = optional cancellation object 1705 * 1706 * Returns: the collection dbus object path, or %NULL if 1707 * none assigned to the alias 1708 * 1709 * Throws: GException on failure. 1710 */ 1711 public string readAliasDbusPathSync(string alias_, Cancellable cancellable) 1712 { 1713 GError* err = null; 1714 1715 auto retStr = secret_service_read_alias_dbus_path_sync(secretService, Str.toStringz(alias_), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1716 1717 if (err !is null) 1718 { 1719 throw new GException( new ErrorG(err) ); 1720 } 1721 1722 scope(exit) Str.freeString(retStr); 1723 return Str.toString(retStr); 1724 } 1725 1726 /** 1727 * Search for items matching the @attributes. All collections are searched. 1728 * The @attributes should be a table of string keys and string values. 1729 * 1730 * If @service is NULL, then secret_service_get() will be called to get 1731 * the default #SecretService proxy. 1732 * 1733 * If %SECRET_SEARCH_ALL is set in @flags, then all the items matching the 1734 * search will be returned. Otherwise only the first item will be returned. 1735 * This is almost always the unlocked item that was most recently stored. 1736 * 1737 * If %SECRET_SEARCH_UNLOCK is set in @flags, then items will be unlocked 1738 * if necessary. In either case, locked and unlocked items will match the 1739 * search and be returned. If the unlock fails, the search does not fail. 1740 * 1741 * If %SECRET_SEARCH_LOAD_SECRETS is set in @flags, then the items will have 1742 * their secret values loaded and available via secret_item_get_secret(). 1743 * 1744 * This function returns immediately and completes asynchronously. 1745 * 1746 * Params: 1747 * schema = the schema for the attributes 1748 * attributes = search for items matching these attributes 1749 * flags = search option flags 1750 * cancellable = optional cancellation object 1751 * callback = called when the operation completes 1752 * userData = data to pass to the callback 1753 */ 1754 public void search(Schema schema, HashTable attributes, SecretSearchFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1755 { 1756 secret_service_search(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1757 } 1758 1759 /** 1760 * Complete asynchronous operation to search for items. 1761 * 1762 * Params: 1763 * result = asynchronous result passed to callback 1764 * 1765 * Returns: a list of items that matched the search 1766 * 1767 * Throws: GException on failure. 1768 */ 1769 public ListG searchFinish(AsyncResultIF result) 1770 { 1771 GError* err = null; 1772 1773 auto p = secret_service_search_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err); 1774 1775 if (err !is null) 1776 { 1777 throw new GException( new ErrorG(err) ); 1778 } 1779 1780 if(p is null) 1781 { 1782 return null; 1783 } 1784 1785 return new ListG(cast(GList*) p, true); 1786 } 1787 1788 /** 1789 * Search for items matching the @attributes, and return their D-Bus object paths. 1790 * All collections are searched. The @attributes should be a table of string keys 1791 * and string values. 1792 * 1793 * This function returns immediately and completes asynchronously. 1794 * 1795 * When your callback is called use secret_service_search_for_dbus_paths_finish() 1796 * to get the results of this function. Only the D-Bus object paths of the 1797 * items will be returned. If you would like #SecretItem objects to be returned 1798 * instead, then use the secret_service_search() function. 1799 * 1800 * Params: 1801 * schema = the schema for the attributes 1802 * attributes = search for items matching these attributes 1803 * cancellable = optional cancellation object 1804 * callback = called when the operation completes 1805 * userData = data to pass to the callback 1806 */ 1807 public void searchForDbusPaths(Schema schema, HashTable attributes, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1808 { 1809 secret_service_search_for_dbus_paths(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1810 } 1811 1812 /** 1813 * Complete asynchronous operation to search for items, and return their 1814 * D-Bus object paths. 1815 * 1816 * Matching items that are locked or unlocked, have their D-Bus paths placed 1817 * in the @locked or @unlocked arrays respectively. 1818 * 1819 * D-Bus object paths of the items will be returned in the @unlocked or 1820 * @locked arrays. If you would to have #SecretItem objects to be returned 1821 * instead, then us the secret_service_search() and 1822 * secret_service_search_finish() functions. 1823 * 1824 * Params: 1825 * result = asynchronous result passed to callback 1826 * unlocked = location to place an array of D-Bus object paths for matching 1827 * items which were locked. 1828 * locked = location to place an array of D-Bus object paths for matching 1829 * items which were locked. 1830 * 1831 * Returns: whether the search was successful or not 1832 * 1833 * Throws: GException on failure. 1834 */ 1835 public bool searchForDbusPathsFinish(AsyncResultIF result, out string[] unlocked, out string[] locked) 1836 { 1837 char** outunlocked = null; 1838 char** outlocked = null; 1839 GError* err = null; 1840 1841 auto p = secret_service_search_for_dbus_paths_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &outunlocked, &outlocked, &err) != 0; 1842 1843 if (err !is null) 1844 { 1845 throw new GException( new ErrorG(err) ); 1846 } 1847 1848 unlocked = Str.toStringArray(outunlocked); 1849 locked = Str.toStringArray(outlocked); 1850 1851 return p; 1852 } 1853 1854 /** 1855 * Search for items matching the @attributes, and return their D-Bus object 1856 * paths. All collections are searched. The @attributes should be a table of 1857 * string keys and string values. 1858 * 1859 * This function may block indefinitely. Use the asynchronous version 1860 * in user interface threads. 1861 * 1862 * Matching items that are locked or unlocked, have their D-Bus paths placed 1863 * in the @locked or @unlocked arrays respectively. 1864 * 1865 * D-Bus object paths of the items will be returned in the @unlocked or 1866 * @locked arrays. If you would to have #SecretItem objects to be returned 1867 * instead, then use the secret_service_search_sync() function. 1868 * 1869 * Params: 1870 * schema = the schema for the attributes 1871 * attributes = search for items matching these attributes 1872 * cancellable = optional cancellation object 1873 * unlocked = location to place an array of D-Bus object paths for matching 1874 * items which were locked. 1875 * locked = location to place an array of D-Bus object paths for matching 1876 * items which were locked. 1877 * 1878 * Returns: whether the search was successful or not 1879 * 1880 * Throws: GException on failure. 1881 */ 1882 public bool searchForDbusPathsSync(Schema schema, HashTable attributes, Cancellable cancellable, out string[] unlocked, out string[] locked) 1883 { 1884 char** outunlocked = null; 1885 char** outlocked = null; 1886 GError* err = null; 1887 1888 auto p = secret_service_search_for_dbus_paths_sync(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outunlocked, &outlocked, &err) != 0; 1889 1890 if (err !is null) 1891 { 1892 throw new GException( new ErrorG(err) ); 1893 } 1894 1895 unlocked = Str.toStringArray(outunlocked); 1896 locked = Str.toStringArray(outlocked); 1897 1898 return p; 1899 } 1900 1901 /** 1902 * Search for items matching the @attributes. All collections are searched. 1903 * The @attributes should be a table of string keys and string values. 1904 * 1905 * If @service is NULL, then secret_service_get_sync() will be called to get 1906 * the default #SecretService proxy. 1907 * 1908 * If %SECRET_SEARCH_ALL is set in @flags, then all the items matching the 1909 * search will be returned. Otherwise only the first item will be returned. 1910 * This is almost always the unlocked item that was most recently stored. 1911 * 1912 * If %SECRET_SEARCH_UNLOCK is set in @flags, then items will be unlocked 1913 * if necessary. In either case, locked and unlocked items will match the 1914 * search and be returned. If the unlock fails, the search does not fail. 1915 * 1916 * If %SECRET_SEARCH_LOAD_SECRETS is set in @flags, then the items' secret 1917 * values will be loaded for any unlocked items. Loaded item secret values 1918 * are available via secret_item_get_secret(). If the load of a secret values 1919 * fail, then the 1920 * 1921 * This function may block indefinitely. Use the asynchronous version 1922 * in user interface threads. 1923 * 1924 * Params: 1925 * schema = the schema for the attributes 1926 * attributes = search for items matching these attributes 1927 * flags = search option flags 1928 * cancellable = optional cancellation object 1929 * 1930 * Returns: a list of items that matched the search 1931 * 1932 * Throws: GException on failure. 1933 */ 1934 public ListG searchSync(Schema schema, HashTable attributes, SecretSearchFlags flags, Cancellable cancellable) 1935 { 1936 GError* err = null; 1937 1938 auto p = secret_service_search_sync(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1939 1940 if (err !is null) 1941 { 1942 throw new GException( new ErrorG(err) ); 1943 } 1944 1945 if(p is null) 1946 { 1947 return null; 1948 } 1949 1950 return new ListG(cast(GList*) p, true); 1951 } 1952 1953 /** 1954 * Assign a collection to this alias. Aliases help determine 1955 * well known collections, such as 'default'. 1956 * 1957 * If @service is NULL, then secret_service_get() will be called to get 1958 * the default #SecretService proxy. 1959 * 1960 * This method will return immediately and complete asynchronously. 1961 * 1962 * Params: 1963 * alias_ = the alias to assign the collection to 1964 * collection = the collection to assign to the alias 1965 * cancellable = optional cancellation object 1966 * callback = called when the operation completes 1967 * userData = data to pass to the callback 1968 */ 1969 public void setAlias(string alias_, Collection collection, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1970 { 1971 secret_service_set_alias(secretService, Str.toStringz(alias_), (collection is null) ? null : collection.getCollectionStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1972 } 1973 1974 /** 1975 * Finish an asynchronous operation to assign a collection to an alias. 1976 * 1977 * Params: 1978 * result = asynchronous result passed to callback 1979 * 1980 * Returns: %TRUE if successful 1981 * 1982 * Throws: GException on failure. 1983 */ 1984 public bool setAliasFinish(AsyncResultIF result) 1985 { 1986 GError* err = null; 1987 1988 auto p = secret_service_set_alias_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 1989 1990 if (err !is null) 1991 { 1992 throw new GException( new ErrorG(err) ); 1993 } 1994 1995 return p; 1996 } 1997 1998 /** 1999 * Assign a collection to this alias. Aliases help determine 2000 * well known collections, such as 'default'. 2001 * 2002 * If @service is NULL, then secret_service_get_sync() will be called to get 2003 * the default #SecretService proxy. 2004 * 2005 * This method may block and should not be used in user interface threads. 2006 * 2007 * Params: 2008 * alias_ = the alias to assign the collection to 2009 * collection = the collection to assign to the alias 2010 * cancellable = optional cancellation object 2011 * 2012 * Returns: %TRUE if successful 2013 * 2014 * Throws: GException on failure. 2015 */ 2016 public bool setAliasSync(string alias_, Collection collection, Cancellable cancellable) 2017 { 2018 GError* err = null; 2019 2020 auto p = secret_service_set_alias_sync(secretService, Str.toStringz(alias_), (collection is null) ? null : collection.getCollectionStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 2021 2022 if (err !is null) 2023 { 2024 throw new GException( new ErrorG(err) ); 2025 } 2026 2027 return p; 2028 } 2029 2030 /** 2031 * Assign a collection to this alias. Aliases help determine 2032 * well known collections, such as 'default'. This method takes the dbus object 2033 * path of the collection to assign to the alias. 2034 * 2035 * This method will return immediately and complete asynchronously. 2036 * 2037 * Params: 2038 * alias_ = the alias to assign the collection to 2039 * collectionPath = the dbus object path of the collection to assign to the alias 2040 * cancellable = optional cancellation object 2041 * callback = called when the operation completes 2042 * userData = data to pass to the callback 2043 */ 2044 public void setAliasToDbusPath(string alias_, string collectionPath, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2045 { 2046 secret_service_set_alias_to_dbus_path(secretService, Str.toStringz(alias_), Str.toStringz(collectionPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2047 } 2048 2049 /** 2050 * Finish an asynchronous operation to assign a collection to an alias. 2051 * 2052 * Params: 2053 * result = asynchronous result passed to callback 2054 * 2055 * Returns: %TRUE if successful 2056 * 2057 * Throws: GException on failure. 2058 */ 2059 public bool setAliasToDbusPathFinish(AsyncResultIF result) 2060 { 2061 GError* err = null; 2062 2063 auto p = secret_service_set_alias_to_dbus_path_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2064 2065 if (err !is null) 2066 { 2067 throw new GException( new ErrorG(err) ); 2068 } 2069 2070 return p; 2071 } 2072 2073 /** 2074 * Assign a collection to this alias. Aliases help determine 2075 * well known collections, such as 'default'. This method takes the dbus object 2076 * path of the collection to assign to the alias. 2077 * 2078 * This method may block and should not be used in user interface threads. 2079 * 2080 * Params: 2081 * alias_ = the alias to assign the collection to 2082 * collectionPath = the dbus object path of the collection to assign to the alias 2083 * cancellable = optional cancellation object 2084 * 2085 * Returns: %TRUE if successful 2086 * 2087 * Throws: GException on failure. 2088 */ 2089 public bool setAliasToDbusPathSync(string alias_, string collectionPath, Cancellable cancellable) 2090 { 2091 GError* err = null; 2092 2093 auto p = secret_service_set_alias_to_dbus_path_sync(secretService, Str.toStringz(alias_), Str.toStringz(collectionPath), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 2094 2095 if (err !is null) 2096 { 2097 throw new GException( new ErrorG(err) ); 2098 } 2099 2100 return p; 2101 } 2102 2103 /** 2104 * Store a secret value in the secret service. 2105 * 2106 * The @attributes should be a set of key and value string pairs. 2107 * 2108 * If the attributes match a secret item already stored in the collection, then 2109 * the item will be updated with these new values. 2110 * 2111 * If @service is NULL, then secret_service_get() will be called to get 2112 * the default #SecretService proxy. 2113 * 2114 * If @collection is not specified, then the default collection will be 2115 * used. Use #SECRET_COLLECTION_SESSION to store the password in the session 2116 * collection, which doesn't get stored across login sessions. 2117 * 2118 * This method will return immediately and complete asynchronously. 2119 * 2120 * Params: 2121 * schema = the schema to use to check attributes 2122 * attributes = the attribute keys and values 2123 * collection = a collection alias, or D-Bus object path of the collection where to store the secret 2124 * label = label for the secret 2125 * value = the secret value 2126 * cancellable = optional cancellation object 2127 * callback = called when the operation completes 2128 * userData = data to be passed to the callback 2129 */ 2130 public void store(Schema schema, HashTable attributes, string collection, string label, Value value, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2131 { 2132 secret_service_store(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), Str.toStringz(collection), Str.toStringz(label), (value is null) ? null : value.getValueStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2133 } 2134 2135 /** 2136 * Finish asynchronous operation to store a secret value in the secret service. 2137 * 2138 * Params: 2139 * result = the asynchronous result passed to the callback 2140 * 2141 * Returns: whether the storage was successful or not 2142 * 2143 * Throws: GException on failure. 2144 */ 2145 public bool storeFinish(AsyncResultIF result) 2146 { 2147 GError* err = null; 2148 2149 auto p = secret_service_store_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2150 2151 if (err !is null) 2152 { 2153 throw new GException( new ErrorG(err) ); 2154 } 2155 2156 return p; 2157 } 2158 2159 /** 2160 * Store a secret value in the secret service. 2161 * 2162 * The @attributes should be a set of key and value string pairs. 2163 * 2164 * If the attributes match a secret item already stored in the collection, then 2165 * the item will be updated with these new values. 2166 * 2167 * If @collection is %NULL, then the default collection will be 2168 * used. Use #SECRET_COLLECTION_SESSION to store the password in the session 2169 * collection, which doesn't get stored across login sessions. 2170 * 2171 * If @service is NULL, then secret_service_get_sync() will be called to get 2172 * the default #SecretService proxy. 2173 * 2174 * This method may block indefinitely and should not be used in user interface 2175 * threads. 2176 * 2177 * Params: 2178 * schema = the schema for the attributes 2179 * attributes = the attribute keys and values 2180 * collection = a collection alias, or D-Bus object path of the collection where to store the secret 2181 * label = label for the secret 2182 * value = the secret value 2183 * cancellable = optional cancellation object 2184 * 2185 * Returns: whether the storage was successful or not 2186 * 2187 * Throws: GException on failure. 2188 */ 2189 public bool storeSync(Schema schema, HashTable attributes, string collection, string label, Value value, Cancellable cancellable) 2190 { 2191 GError* err = null; 2192 2193 auto p = secret_service_store_sync(secretService, (schema is null) ? null : schema.getSchemaStruct(), (attributes is null) ? null : attributes.getHashTableStruct(), Str.toStringz(collection), Str.toStringz(label), (value is null) ? null : value.getValueStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 2194 2195 if (err !is null) 2196 { 2197 throw new GException( new ErrorG(err) ); 2198 } 2199 2200 return p; 2201 } 2202 2203 /** 2204 * Unlock items or collections in the secret service. 2205 * 2206 * The secret service may not be able to unlock items individually, and may 2207 * unlock an entire collection instead. 2208 * 2209 * If @service is NULL, then secret_service_get() will be called to get 2210 * the default #SecretService proxy. 2211 * 2212 * This method may block indefinitely and should not be used in user 2213 * interface threads. The secret service may prompt the user. 2214 * secret_service_prompt() will be used to handle any prompts that show up. 2215 * 2216 * Params: 2217 * objects = the items or collections to unlock 2218 * cancellable = optional cancellation object 2219 * callback = called when the operation completes 2220 * userData = data to pass to the callback 2221 */ 2222 public void unlock(ListG objects, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2223 { 2224 secret_service_unlock(secretService, (objects is null) ? null : objects.getListGStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2225 } 2226 2227 /** 2228 * Unlock items or collections in the secret service. 2229 * 2230 * The items or collections are represented by their D-Bus object paths. If you 2231 * already have #SecretItem and #SecretCollection proxy objects, use use 2232 * secret_service_unlock() instead. 2233 * 2234 * The secret service may not be able to unlock items individually, and may 2235 * unlock an entire collection instead. 2236 * 2237 * This method returns immediately and completes asynchronously. The secret 2238 * service may prompt the user. secret_service_prompt() will be used to handle 2239 * any prompts that show up. 2240 * 2241 * Params: 2242 * paths = the D-Bus paths for items or collections to unlock 2243 * cancellable = optional cancellation object 2244 * callback = called when the operation completes 2245 * userData = data to pass to the callback 2246 */ 2247 public void unlockDbusPaths(string[] paths, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2248 { 2249 secret_service_unlock_dbus_paths(secretService, Str.toStringzArray(paths), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2250 } 2251 2252 /** 2253 * Complete asynchronous operation to unlock items or collections in the secret 2254 * service. 2255 * 2256 * The secret service may not be able to unlock items individually, and may 2257 * unlock an entire collection instead. 2258 * 2259 * Params: 2260 * result = asynchronous result passed to the callback 2261 * unlocked = location to place array of D-Bus paths of items or collections 2262 * that were unlocked 2263 * 2264 * Returns: the number of items or collections that were unlocked 2265 * 2266 * Throws: GException on failure. 2267 */ 2268 public int unlockDbusPathsFinish(AsyncResultIF result, out string[] unlocked) 2269 { 2270 char** outunlocked = null; 2271 GError* err = null; 2272 2273 auto p = secret_service_unlock_dbus_paths_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &outunlocked, &err); 2274 2275 if (err !is null) 2276 { 2277 throw new GException( new ErrorG(err) ); 2278 } 2279 2280 unlocked = Str.toStringArray(outunlocked); 2281 2282 return p; 2283 } 2284 2285 /** 2286 * Unlock items or collections in the secret service. 2287 * 2288 * The items or collections are represented by their D-Bus object paths. If you 2289 * already have #SecretItem and #SecretCollection proxy objects, use use 2290 * secret_service_unlock_sync() instead. 2291 * 2292 * The secret service may not be able to unlock items individually, and may 2293 * unlock an entire collection instead. 2294 * 2295 * This method may block indefinitely and should not be used in user 2296 * interface threads. The secret service may prompt the user. 2297 * secret_service_prompt() will be used to handle any prompts that show up. 2298 * 2299 * Params: 2300 * paths = the D-Bus object paths of the items or collections to unlock 2301 * cancellable = optional cancellation object 2302 * unlocked = location to place array of D-Bus paths of items or collections 2303 * that were unlocked 2304 * 2305 * Returns: the number of items or collections that were unlocked 2306 * 2307 * Throws: GException on failure. 2308 */ 2309 public int unlockDbusPathsSync(string[] paths, Cancellable cancellable, out string[] unlocked) 2310 { 2311 char** outunlocked = null; 2312 GError* err = null; 2313 2314 auto p = secret_service_unlock_dbus_paths_sync(secretService, Str.toStringzArray(paths), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outunlocked, &err); 2315 2316 if (err !is null) 2317 { 2318 throw new GException( new ErrorG(err) ); 2319 } 2320 2321 unlocked = Str.toStringArray(outunlocked); 2322 2323 return p; 2324 } 2325 2326 /** 2327 * Complete asynchronous operation to unlock items or collections in the secret 2328 * service. 2329 * 2330 * The secret service may not be able to unlock items individually, and may 2331 * unlock an entire collection instead. 2332 * 2333 * Params: 2334 * result = asynchronous result passed to the callback 2335 * unlocked = location to place list of items or collections that were unlocked 2336 * 2337 * Returns: the number of items or collections that were unlocked 2338 * 2339 * Throws: GException on failure. 2340 */ 2341 public int unlockFinish(AsyncResultIF result, out ListG unlocked) 2342 { 2343 GList* outunlocked = null; 2344 GError* err = null; 2345 2346 auto p = secret_service_unlock_finish(secretService, (result is null) ? null : result.getAsyncResultStruct(), &outunlocked, &err); 2347 2348 if (err !is null) 2349 { 2350 throw new GException( new ErrorG(err) ); 2351 } 2352 2353 unlocked = new ListG(outunlocked); 2354 2355 return p; 2356 } 2357 2358 /** 2359 * Unlock items or collections in the secret service. 2360 * 2361 * The secret service may not be able to unlock items individually, and may 2362 * unlock an entire collection instead. 2363 * 2364 * If @service is NULL, then secret_service_get_sync() will be called to get 2365 * the default #SecretService proxy. 2366 * 2367 * This method may block indefinitely and should not be used in user 2368 * interface threads. The secret service may prompt the user. 2369 * secret_service_prompt() will be used to handle any prompts that show up. 2370 * 2371 * Params: 2372 * objects = the items or collections to unlock 2373 * cancellable = optional cancellation object 2374 * unlocked = location to place list of items or collections that were unlocked 2375 * 2376 * Returns: the number of items or collections that were unlocked 2377 * 2378 * Throws: GException on failure. 2379 */ 2380 public int unlockSync(ListG objects, Cancellable cancellable, out ListG unlocked) 2381 { 2382 GList* outunlocked = null; 2383 GError* err = null; 2384 2385 auto p = secret_service_unlock_sync(secretService, (objects is null) ? null : objects.getListGStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outunlocked, &err); 2386 2387 if (err !is null) 2388 { 2389 throw new GException( new ErrorG(err) ); 2390 } 2391 2392 unlocked = new ListG(outunlocked); 2393 2394 return p; 2395 } 2396 }