gnomekeyring_p.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef QTKEYCHAIN_GNOME_P_H
  2. #define QTKEYCHAIN_GNOME_P_H
  3. #include <QLibrary>
  4. class GnomeKeyring : private QLibrary {
  5. Q_OBJECT
  6. public:
  7. enum Result {
  8. RESULT_OK,
  9. RESULT_DENIED,
  10. RESULT_NO_KEYRING_DAEMON,
  11. RESULT_ALREADY_UNLOCKED,
  12. RESULT_NO_SUCH_KEYRING,
  13. RESULT_BAD_ARGUMENTS,
  14. RESULT_IO_ERROR,
  15. RESULT_CANCELLED,
  16. RESULT_KEYRING_ALREADY_EXISTS,
  17. RESULT_NO_MATCH
  18. };
  19. enum ItemType {
  20. ITEM_GENERIC_SECRET = 0,
  21. ITEM_NETWORK_PASSWORD,
  22. ITEM_NOTE,
  23. ITEM_CHAINED_KEYRING_PASSWORD,
  24. ITEM_ENCRYPTION_KEY_PASSWORD,
  25. ITEM_PK_STORAGE = 0x100
  26. };
  27. enum AttributeType {
  28. ATTRIBUTE_TYPE_STRING,
  29. ATTRIBUTE_TYPE_UINT32
  30. };
  31. typedef char gchar;
  32. typedef void* gpointer;
  33. typedef bool gboolean;
  34. typedef struct {
  35. ItemType item_type;
  36. struct {
  37. const gchar* name;
  38. AttributeType type;
  39. } attributes[32];
  40. } PasswordSchema;
  41. typedef void ( *OperationGetStringCallback )( Result result, bool binary,
  42. const char* string, gpointer data );
  43. typedef void ( *OperationDoneCallback )( Result result, gpointer data );
  44. typedef void ( *GDestroyNotify )( gpointer data );
  45. static const char* GNOME_KEYRING_DEFAULT;
  46. static bool isAvailable();
  47. static gpointer store_network_password( const gchar* keyring, const gchar* display_name,
  48. const gchar* user, const gchar* server,
  49. const gchar* type, const gchar* password,
  50. OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data );
  51. static gpointer find_network_password( const gchar* user, const gchar* server,
  52. const gchar* type,
  53. OperationGetStringCallback callback,
  54. gpointer data, GDestroyNotify destroy_data );
  55. static gpointer delete_network_password( const gchar* user, const gchar* server,
  56. OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data );
  57. private:
  58. GnomeKeyring();
  59. static GnomeKeyring& instance();
  60. const PasswordSchema* NETWORK_PASSWORD;
  61. typedef gboolean ( is_available_fn )( void );
  62. typedef gpointer ( store_password_fn )( const PasswordSchema* schema, const gchar* keyring,
  63. const gchar* display_name, const gchar* password,
  64. OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data,
  65. ... );
  66. typedef gpointer ( find_password_fn )( const PasswordSchema* schema,
  67. OperationGetStringCallback callback, gpointer data, GDestroyNotify destroy_data,
  68. ... );
  69. typedef gpointer ( delete_password_fn )( const PasswordSchema* schema,
  70. OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data,
  71. ... );
  72. is_available_fn* is_available;
  73. find_password_fn* find_password;
  74. store_password_fn* store_password;
  75. delete_password_fn* delete_password;
  76. };
  77. #endif