Guest User

Untitled

a guest
Jul 16th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <gnome-keyring.h>
  3.  
  4. int main() {
  5. GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
  6. if (lock_result == GNOME_KEYRING_RESULT_OK) {
  7. printf("Successfully lockedn");
  8. return 0;
  9. } else {
  10. printf("Error locking keyring: %dn", lock_result);
  11. return 1;
  12. }
  13. }
  14.  
  15. #include <stdio.h>
  16. #include <gnome-keyring.h>
  17.  
  18. int main() {
  19. GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
  20. if (lock_result == GNOME_KEYRING_RESULT_OK) {
  21. printf("Successfully unlockedn");
  22. return 0;
  23. } else {
  24. printf("Error unlocking keyring: %dn", lock_result);
  25. return 1;
  26. }
  27. }
  28.  
  29. #include <stdio.h>
  30. #include <gnome-keyring.h>
  31.  
  32. int main() {
  33.  
  34. GnomeKeyringInfo *info;
  35. GnomeKeyringResult gkr;
  36.  
  37. gkr = gnome_keyring_get_info_sync(NULL, &info);
  38. if (gkr != GNOME_KEYRING_RESULT_OK) {
  39. printf("errorn");
  40. return -1;
  41. }
  42. if (gnome_keyring_info_get_is_locked(info)) {
  43. printf("lockedn");
  44. return 0;
  45. }
  46. else {
  47. printf("unlockedn");
  48. return -1;
  49. }
  50. gnome_keyring_info_free(info);
  51.  
  52. }
  53.  
  54. import gnomekeyring
  55. print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()
  56.  
  57. cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
Add Comment
Please, Sign In to add comment