grim/pidgin
Clone
Summary
Browse
Changes
Graph
Checking in my work in progress
draft
keyring-refresh
2020-01-23, Gary Kramlich
a3bb5f0f17ff
Checking in my work in progress
/*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_KEYRING_BACKEND_H
#define PURPLE_KEYRING_BACKEND_H
/**
* SECTION:keyringbackend
* @section_id: libpurple-keyring-backend
* @short_description: Keyring Backend Class
* @title: Keyring Backend API
*/
#include
"account.h"
#include
"request.h"
#include
<glib.h>
#include
<glib-object.h>
G_BEGIN_DECLS
#define PURPLE_TYPE_KEYRING_BACKEND (purple_keyring_backend_get_type())
G_DECLARE_DERIVABLE_TYPE
(
PurpleKeyringBackend
,
purple_keyring_backend
,
PURPLE
,
KEYRING_BACKEND
,
GObject
)
/**
* PurpleKeyringBackendClass:
* @read_password: Reads a password from the backend.
* @write_password: Writes a password to the backend.
* @close: Closes the backend.
* @read_settings: Creates a #PurpleRequestFields for the available settings.
* @write_settings: Updates the settings for backend.
*
* #PurpleKeyringBackendClass defines the interface for interacting with
* keyring backends like libsecret, kwallet, etc.
*
* Since: 3.0.0
*/
struct
_PurpleKeyringBackendClass
{
GObjectClass
parent
;
void
(
*
read_password
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
gchar
*
(
*
read_password_finish
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
void
(
*
write_password
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
const
gchar
*
password
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
gboolean
(
*
write_password_finish
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
void
(
*
clear_password
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
gboolean
(
*
clear_password_finish
)(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
void
(
*
close
)(
PurpleKeyringBackend
*
backend
);
PurpleRequestFields
*
(
*
read_settings
)(
PurpleKeyringBackend
*
backend
);
gboolean
(
*
write_settings
)(
PurpleKeyringBackend
*
backend
,
PurpleRequestFields
*
fields
);
/* a little more padding than normal */
gpointer
reserved
[
8
];
};
/**
* purple_keyring_backend_get_id:
* @backend: The keyring backend.
*
* Gets the ID of @backend.
*
* Returns: The ID of the backed.
*
* Since: 3.0.0
*/
const
gchar
*
purple_keyring_backend_get_id
(
PurpleKeyringBackend
*
backend
);
/**
* purple_keyring_backend_get_name:
* @backend: The keyring backend.
*
* Gets the friendly name name of @backend.
*
* Returns: The friendly name of the backend.
*
* Since: 3.0.0
*/
const
gchar
*
purple_keyring_backend_get_name
(
PurpleKeyringBackend
*
backend
);
/**
* purple_keyring_backend_is_valid:
* @backend: The #PurpleKeyringBackend instance.
*
* Checks whether or not @backend is setup correctly. This is primarily mean
* for #purple_keyring_register to call to avoid programming errors, but can be
* used by anyone.
*
* Returns: %FALSE on error, otherwise %TRUE.
*
* Since: 3.0.0
*/
gboolean
purple_keyring_backend_is_valid
(
PurpleKeyringBackend
*
backend
);
/**
* purple_keyring_backend_read_password:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount who's password to read.
* @cancellable: (nullable): optional GCancellable object, NULL to ignore.
* @callback: (scope async): a GAsyncReadyCallback to call when the request is satisfied.
* @data: User data to pass to @callback.
*
* Reads the password for @account from @backend.
*
* Since: 3.0.0
*/
void
purple_keyring_backend_read_password
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
/**
* purple_keyring_backend_read_password_finish:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount whose password we're looking up.
* @result: The #GAsyncResult from the previous
* #purple_keyring_backend_read_password call.
* @error: (out) (optional): Returns address for a #GError.
*
* Finishes a previous call to #purple_keyring_backend_read_password.
*
* Returns: (transfer full): The password or %NULL if successful, otherwise
* %NULL with @error set on failure.
*
* Since: 3.0.0
*/
gchar
*
purple_keyring_backend_read_password_finish
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
/**
* purple_keyring_backend_write_password:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount who's password to read.
* @password: The password to write.
* @cancellable: (nullable): optional GCancellable object, NULL to ignore.
* @callback: (scope async): a cReadyCallback to call when the request is satisfied.
* @data: User data to pass to @callback.
*
* Writes @password for @account to @backend.
*
* Since: 3.0.0
*/
void
purple_keyring_backend_write_password
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
const
gchar
*
password
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
/**
* purple_keyring_backend_write_password_finish:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount whose password we're writing.
* @result: The #GAsyncResult from the previous
* #purple_keyring_backend_write_password call.
* @error: (out) (optional): Returns address for a #GError.
*
* Finishes a previous call to #purple_keyring_backend_write_password.
*
* Returns: %TRUE if the password was writting successfully, other %FALSE with
* @error set.
*
* Since: 3.0.0
*/
gboolean
purple_keyring_backend_write_password_finish
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
/**
* purple_keyring_backend_clear_password:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount who's password to read.
* @cancellable: (nullable): optional GCancellable object, NULL to ignore.
* @callback: (scope async): a cReadyCallback to call when the request is satisfied.
* @data: User data to pass to @callback.
*
* Clears the password for @account from @backend.
*
* Since: 3.0.0
*/
void
purple_keyring_backend_clear_password
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GCancellable
*
cancellable
,
GAsyncReadyCallback
callback
,
gpointer
data
);
/**
* purple_keyring_backend_clear_password_finish:
* @backend: The #PurpleKeyringBackend instance.
* @account: The #PurpleAccount whose password we're writing.
* @result: The #GAsyncResult from the previous
* #purple_keyring_backend_clear_password call.
* @error: (out) (optional): Returns address for a #GError.
*
* Finishes a previous call to #purple_keyring_backend_clear_password.
*
* Returns: %TRUE if the password was cleared successfully, other %FALSE with
* @error set.
*
* Since: 3.0.0
*/
gboolean
purple_keyring_backend_clear_password_finish
(
PurpleKeyringBackend
*
backend
,
PurpleAccount
*
account
,
GAsyncResult
*
result
,
GError
**
error
);
/**
* purple_keyring_backend_close:
* @backend: The #PurpleKeyringBackend instance.
*
* Tells @backend to close. This is useful if you need to disconnect a socket
* or close a file to save memory.
*
* Since: 3.0.0
*/
void
purple_keyring_backend_close
(
PurpleKeyringBackend
*
backend
);
/**
* purple_keyring_backend_read_settings:
* @backend: The #PurpleKeyringBackendInstance.
*
* Reads settings from @backend.
*
* Returns: (transfer full): New copy of current settings (must be free'd with
* #purple_request_fields_destroy).
*
* Since: 3.0.0
*/
PurpleRequestFields
*
purple_keyring_backend_read_settings
(
PurpleKeyringBackend
*
backend
);
/**
* purple_keyring_backend_write_settings:
* @backend: The #PurpleKeyringBackend instance.
* @fields: Modified settings (originally taken from
* #PurpleKeyringBackendReadSettings).
*
* Write @fields to @backend.
*
* Returns: %TRUE if successful, %FALSE otherwise.
*
* Since: 3.0.0
*/
gboolean
purple_keyring_backend_write_settings
(
PurpleKeyringBackend
*
backend
,
PurpleRequestFields
*
fields
);
G_END_DECLS
#endif
/* PURPLE_KEYRING_BACKEND_H */