Commit f788eea3 authored by Stefan Walter's avatar Stefan Walter

Make SeahorseSource be an interface that can be implemented on other

	* common/seahorse-registry.c:
	* common/seahorse-registry.h:
	* daemon/seahorse-service-keyset.c:
	* gkr/seahorse-gkr-source.c:
	* gkr/seahorse-gkr-source.h:
	* libseahorse/seahorse-context.c:
	* libseahorse/seahorse-context.h:
	* libseahorse/seahorse-source.c:
	* libseahorse/seahorse-source.h:
	* libseahorse/seahorse-unknown-source.c:
	* libseahorse/seahorse-unknown-source.h:
	* pgp/seahorse-hkp-source.c:
	* pgp/seahorse-ldap-source.c:
	* pgp/seahorse-pgp-source.c:
	* pgp/seahorse-pgp-source.h:
	* pgp/seahorse-server-source.c:
	* pgp/seahorse-server-source.h:
	* pkcs11/seahorse-pkcs11-source.c:
	* pkcs11/seahorse-pkcs11-source.h: 
	* ssh/seahorse-ssh-source.c:
	* ssh/seahorse-ssh-source.h: Make SeahorseSource be an 
	interface that can be implemented on other objects (ie: keyrings).

svn path=/trunk/; revision=2660
parent 75ae578c
2008-12-13 Stef Walter <stef@memberwebs.com>
2008-12-14 Stef Walter <stef@memberwebs.com>
* common/seahorse-registry.c:
* common/seahorse-registry.h:
* daemon/seahorse-service-keyset.c:
* gkr/seahorse-gkr-source.c:
* gkr/seahorse-gkr-source.h:
* libseahorse/seahorse-context.c:
* libseahorse/seahorse-context.h:
* libseahorse/seahorse-source.c:
* libseahorse/seahorse-source.h:
* libseahorse/seahorse-unknown-source.c:
* libseahorse/seahorse-unknown-source.h:
* pgp/seahorse-hkp-source.c:
* pgp/seahorse-ldap-source.c:
* pgp/seahorse-pgp-source.c:
* pgp/seahorse-pgp-source.h:
* pgp/seahorse-server-source.c:
* pgp/seahorse-server-source.h:
* pkcs11/seahorse-pkcs11-source.c:
* pkcs11/seahorse-pkcs11-source.h:
* ssh/seahorse-ssh-source.c:
* ssh/seahorse-ssh-source.h: Make SeahorseSource be an
interface that can be implemented on other objects (ie: keyrings).
2008-12-14 Stef Walter <stef@memberwebs.com>
* gkr/seahorse-gkr-item.c:
* gkr/seahorse-gkr-item-properties.c:
......
......@@ -27,6 +27,7 @@ typedef struct _SeahorseRegistryPrivate SeahorseRegistryPrivate;
struct _SeahorseRegistryPrivate {
GHashTable *types;
GHashTable *objects;
GHashTable *functions;
};
#define SEAHORSE_REGISTRY_GET_PRIVATE(o) \
......@@ -58,19 +59,18 @@ keys_to_list (gpointer key, gpointer value, gpointer user_data)
}
static void
register_value_for_category (GHashTable *table, const gchar *category,
register_value_for_category (GHashTable *table, GQuark category,
gpointer value, GDestroyNotify destroy_func)
{
GHashTable *set;
g_return_if_fail (table);
g_return_if_fail (category);
g_return_if_fail (category[0]);
set = g_hash_table_lookup (table, category);
set = g_hash_table_lookup (table, GUINT_TO_POINTER (category));
if (!set) {
set = g_hash_table_new_full (g_direct_hash, g_direct_equal, destroy_func, NULL);
g_hash_table_replace (table, g_strdup (category), set);
g_hash_table_replace (table, GUINT_TO_POINTER (category), set);
}
g_hash_table_replace (set, value, NO_VALUE);
......@@ -79,7 +79,7 @@ register_value_for_category (GHashTable *table, const gchar *category,
static GList*
lookup_category_values (GHashTable *table, const gchar *category, va_list cats)
{
GList *l, *type, *types = NULL;
GList *l, *value, *values = NULL;
GHashTable *set;
g_return_val_if_fail (table, NULL);
......@@ -87,15 +87,15 @@ lookup_category_values (GHashTable *table, const gchar *category, va_list cats)
g_return_val_if_fail (category[0], NULL);
/* Get the first category */
set = g_hash_table_lookup (table, category);
set = g_hash_table_lookup (table, g_quark_try_string (category));
if (!set)
return NULL;
/* Transfer all of that into the list */
g_hash_table_foreach (set, keys_to_list, &types);
g_hash_table_foreach (set, keys_to_list, &values);
/*
* Go through the other types and remove any in results
* Go through the other values and remove any in results
* which we don't find.
*/
for (;;) {
......@@ -105,25 +105,25 @@ lookup_category_values (GHashTable *table, const gchar *category, va_list cats)
g_return_val_if_fail (category[0], NULL);
/* Lookup this category */
set = g_hash_table_lookup (table, category);
set = g_hash_table_lookup (table, g_quark_try_string (category));
/* No category, no matches */
if (!set) {
g_list_free (types);
g_list_free (values);
return NULL;
}
/* Go through each item in list and make sure it exists in this cat */
for (l = types; l; l = l ? g_list_next (l) : types) {
type = l;
if (!g_hash_table_lookup (set, type->data)) {
for (l = values; l; l = l ? g_list_next (l) : values) {
value = l;
if (!g_hash_table_lookup (set, values->data)) {
l = g_list_previous (l);
types = g_list_delete_link (types, type);
values = g_list_delete_link (values, value);
}
}
}
return types;
return values;
}
static gpointer
......@@ -155,10 +155,12 @@ static void
seahorse_registry_init (SeahorseRegistry *obj)
{
SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (obj);
pv->types = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify)g_hash_table_destroy);
pv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify)g_hash_table_destroy);
pv->types = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify)g_hash_table_destroy);
pv->objects = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify)g_hash_table_destroy);
pv->functions = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify)g_hash_table_destroy);
}
static void
......@@ -207,7 +209,7 @@ seahorse_registry_get (void)
void
seahorse_registry_register_type (SeahorseRegistry *registry, GType type,
const gchar *category, ...)
const gchar *category, ...)
{
SeahorseRegistryPrivate *pv;
va_list cats;
......@@ -220,14 +222,14 @@ seahorse_registry_register_type (SeahorseRegistry *registry, GType type,
g_return_if_fail (category);
pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
register_value_for_category (pv->types, category, GUINT_TO_POINTER (type), NULL);
register_value_for_category (pv->types, g_quark_from_string (category), GUINT_TO_POINTER (type), NULL);
va_start (cats, category);
for (;;) {
category = va_arg (cats, const gchar*);
if (!category)
break;
register_value_for_category (pv->types, category, GUINT_TO_POINTER (type), NULL);
register_value_for_category (pv->types, g_quark_from_string (category), GUINT_TO_POINTER (type), NULL);
}
va_end (cats);
}
......@@ -247,14 +249,41 @@ seahorse_registry_register_object (SeahorseRegistry *registry, GObject *object,
g_return_if_fail (category);
pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
register_value_for_category (pv->objects, category, g_object_ref (object), g_object_unref);
register_value_for_category (pv->objects, g_quark_from_string (category), g_object_ref (object), g_object_unref);
va_start (cats, category);
for (;;) {
category = va_arg (cats, const gchar*);
if (!category)
break;
register_value_for_category (pv->objects, category, g_object_ref (object), g_object_unref);
register_value_for_category (pv->objects, g_quark_from_string (category), g_object_ref (object), g_object_unref);
}
va_end (cats);
}
void
seahorse_registry_register_function (SeahorseRegistry *registry, gpointer func,
const gchar *category, ...)
{
SeahorseRegistryPrivate *pv;
va_list cats;
if (!registry)
registry = seahorse_registry_get ();
g_return_if_fail (SEAHORSE_IS_REGISTRY (registry));
g_return_if_fail (func);
g_return_if_fail (category);
pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
register_value_for_category (pv->functions, g_quark_from_string (category), func, NULL);
va_start (cats, category);
for (;;) {
category = va_arg (cats, const gchar*);
if (!category)
break;
register_value_for_category (pv->functions, g_quark_from_string (category), func, NULL);
}
va_end (cats);
}
......@@ -358,3 +387,23 @@ seahorse_registry_object_instances (SeahorseRegistry *registry, const gchar *cat
g_list_free (types);
return objects;
}
gpointer
seahorse_registry_lookup_function (SeahorseRegistry *registry, const gchar *category, ...)
{
SeahorseRegistryPrivate *pv;
va_list cats;
gpointer func;
if (!registry)
registry = seahorse_registry_get ();
g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), 0);
pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
va_start (cats, category);
func = GPOINTER_TO_UINT (lookup_category_value (pv->functions, category, cats));
va_end (cats);
return func;
}
\ No newline at end of file
......@@ -57,6 +57,10 @@ void seahorse_registry_register_object (SeahorseRegistry *regi
GObject *object, const gchar *category,
...) G_GNUC_NULL_TERMINATED;
void seahorse_registry_register_function (SeahorseRegistry *registry,
gpointer func, const gchar *category,
...) G_GNUC_NULL_TERMINATED;
GType seahorse_registry_object_type (SeahorseRegistry *registry,
const gchar *category,
...) G_GNUC_NULL_TERMINATED;
......@@ -73,6 +77,10 @@ GList* seahorse_registry_object_instances (SeahorseRegistry *regi
const gchar *category,
...) G_GNUC_NULL_TERMINATED;
gpointer seahorse_registry_lookup_function (SeahorseRegistry *registry,
const gchar *category,
...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
#endif /*SEAHORSEREGISTRY_H_*/
......@@ -188,7 +188,7 @@ seahorse_service_keyset_discover_keys (SeahorseServiceKeyset *keyset, const gcha
/* Check to make sure the key ids are valid */
for (k = keyids; *k; k++) {
keyid = seahorse_source_canonize_id (keyset->ktype, *k);
keyid = seahorse_context_canonize_id (keyset->ktype, *k);
if (!keyid) {
g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_INVALID,
_("Invalid key id: %s"), *k);
......
......@@ -73,7 +73,10 @@ struct _SeahorseGkrSourcePrivate {
SeahorseObject *keyring_object; /* Object which represents the whole keyring */
};
G_DEFINE_TYPE (SeahorseGkrSource, seahorse_gkr_source, SEAHORSE_TYPE_SOURCE);
static void seahorse_source_iface (SeahorseSourceIface *iface);
G_DEFINE_TYPE_EXTENDED (SeahorseGkrSource, seahorse_gkr_source, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_SOURCE, seahorse_source_iface));
/* -----------------------------------------------------------------------------
* LIST OPERATION
......@@ -421,7 +424,6 @@ static void
seahorse_gkr_source_class_init (SeahorseGkrSourceClass *klass)
{
GObjectClass *gobject_class;
SeahorseSourceClass *key_class;
seahorse_gkr_source_parent_class = g_type_class_peek_parent (klass);
......@@ -432,34 +434,28 @@ seahorse_gkr_source_class_init (SeahorseGkrSourceClass *klass)
gobject_class->set_property = seahorse_gkr_source_set_property;
gobject_class->get_property = seahorse_gkr_source_get_property;
key_class = SEAHORSE_SOURCE_CLASS (klass);
key_class->load = seahorse_gkr_source_load;
key_class->import = seahorse_gkr_source_import;
g_object_class_install_property (gobject_class, PROP_KEYRING_NAME,
g_param_spec_string ("keyring-name", "Keyring Name", "GNOME Keyring name",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_KEY_TYPE,
g_param_spec_uint ("key-type", "Key Type", "Key type that originates from this key source.",
0, G_MAXUINT, SEAHORSE_TAG_INVALID, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_FLAGS,
g_param_spec_uint ("flags", "Flags", "Object Source flags.",
0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_KEY_DESC,
g_param_spec_string ("key-desc", "Key Desc", "Description for keys that originate here.",
NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_LOCATION,
g_param_spec_uint ("location", "Key Location", "Where the key is stored. See SeahorseLocation",
0, G_MAXUINT, SEAHORSE_LOCATION_INVALID, G_PARAM_READABLE));
g_object_class_override_property (gobject_class, PROP_KEY_TYPE, "key-type");
g_object_class_override_property (gobject_class, PROP_KEY_DESC, "key-desc");
g_object_class_override_property (gobject_class, PROP_LOCATION, "location");
seahorse_registry_register_type (NULL, SEAHORSE_TYPE_GKR_SOURCE, "source", "local", SEAHORSE_GKR_STR, NULL);
}
static void
seahorse_source_iface (SeahorseSourceIface *iface)
{
iface->load = seahorse_gkr_source_load;
iface->import = seahorse_gkr_source_import;
}
/* --------------------------------------------------------------------------
* PUBLIC
*/
......
......@@ -49,14 +49,12 @@ typedef struct _SeahorseGkrSourceClass SeahorseGkrSourceClass;
typedef struct _SeahorseGkrSourcePrivate SeahorseGkrSourcePrivate;
struct _SeahorseGkrSource {
SeahorseSource parent;
/*< private >*/
SeahorseGkrSourcePrivate *pv;
GObject parent;
SeahorseGkrSourcePrivate *pv;
};
struct _SeahorseGkrSourceClass {
SeahorseSourceClass parent_class;
GObjectClass parent_class;
};
GType seahorse_gkr_source_get_type (void);
......
......@@ -1090,7 +1090,7 @@ seahorse_context_discover_objects (SeahorseContext *sctx, GQuark ktype,
/* Check all the ids */
for (l = rawids; l; l = g_slist_next (l)) {
id = seahorse_source_canonize_id (ktype, (gchar*)l->data);
id = seahorse_context_canonize_id (ktype, (gchar*)l->data);
if (!id) {
/* TODO: Try and match this partial id */
g_warning ("invalid id: %s", (gchar*)l->data);
......@@ -1185,3 +1185,17 @@ seahorse_context_id_to_dbus (SeahorseContext* sctx, GQuark id)
{
return g_strdup (g_quark_to_string (id));
}
GQuark
seahorse_context_canonize_id (GQuark ktype, const gchar *id)
{
SeahorseCanonizeFunc canonize;
g_return_val_if_fail (id != NULL, 0);
canonize = seahorse_registry_lookup_function (NULL, "canonize", g_quark_to_string (ktype), NULL);
if (!canonize)
return 0;
return (canonize) (id);
}
......@@ -196,4 +196,9 @@ gchar* seahorse_context_object_to_dbus (SeahorseContext *sct
gchar* seahorse_context_id_to_dbus (SeahorseContext *sctx,
GQuark id);
typedef GQuark (*SeahorseCanonizeFunc) (const gchar *id);
GQuark seahorse_context_canonize_id (GQuark ktype, const gchar *id);
#endif /* __SEAHORSE_CONTEXT_H__ */
......@@ -29,46 +29,59 @@
#include "common/seahorse-registry.h"
G_DEFINE_TYPE (SeahorseSource, seahorse_source, G_TYPE_OBJECT);
/* GObject handlers */
static void seahorse_source_dispose (GObject *gobject);
static void seahorse_source_finalize (GObject *gobject);
static GObjectClass *parent_class = NULL;
static void
seahorse_source_class_init (SeahorseSourceClass *klass)
{
GObjectClass *gobject_class;
parent_class = g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = seahorse_source_dispose;
gobject_class->finalize = seahorse_source_finalize;
}
/* ---------------------------------------------------------------------------------
* INTERFACE
*/
/* Initialize the object */
static void
seahorse_source_init (SeahorseSource *sksrc)
seahorse_source_base_init (gpointer gobject_class)
{
static gboolean initialized = FALSE;
if (!initialized) {
/* Add properties and signals to the interface */
g_object_interface_install_property (gobject_class,
g_param_spec_uint ("key-type", "Key Type", "Key type that originates from this key source.",
0, G_MAXUINT, SEAHORSE_TAG_INVALID, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_interface_install_property (gobject_class,
g_param_spec_string ("key-desc", "Key Desc", "Description for keys that originate here.",
NULL, G_PARAM_READABLE));
g_object_interface_install_property (gobject_class,
g_param_spec_uint ("location", "Key Location", "Where the key is stored. See SeahorseLocation",
0, G_MAXUINT, SEAHORSE_LOCATION_MISSING, G_PARAM_READABLE));
initialized = TRUE;
}
}
/* dispose of all our internal references */
static void
seahorse_source_dispose (GObject *gobject)
GType
seahorse_source_get_type (void)
{
G_OBJECT_CLASS (parent_class)->dispose (gobject);
static GType type = 0;
if (!type) {
static const GTypeInfo info = {
sizeof (SeahorseSourceIface),
seahorse_source_base_init, /* base init */
NULL, /* base finalize */
NULL, /* class_init */
NULL, /* class finalize */
NULL, /* class data */
0,
0, /* n_preallocs */
NULL, /* instance init */
};
type = g_type_register_static (G_TYPE_INTERFACE, "SeahorseSourceIface", &info, 0);
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
}
return type;
}
/* free private vars */
static void
seahorse_source_finalize (GObject *gobject)
{
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
/* ---------------------------------------------------------------------------------
* PUBLIC
*/
/**
* seahorse_source_load
......@@ -81,10 +94,10 @@ seahorse_source_finalize (GObject *gobject)
SeahorseOperation*
seahorse_source_load (SeahorseSource *sksrc)
{
SeahorseSourceClass *klass;
SeahorseSourceIface *klass;
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), NULL);
klass = SEAHORSE_SOURCE_GET_CLASS (sksrc);
klass = SEAHORSE_SOURCE_GET_INTERFACE (sksrc);
g_return_val_if_fail (klass->load != NULL, NULL);
return (*klass->load) (sksrc);
......@@ -131,10 +144,10 @@ seahorse_source_load_async (SeahorseSource *sksrc)
SeahorseOperation*
seahorse_source_search (SeahorseSource *sksrc, const gchar *match)
{
SeahorseSourceClass *klass;
SeahorseSourceIface *klass;
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), NULL);
klass = SEAHORSE_SOURCE_GET_CLASS (sksrc);
klass = SEAHORSE_SOURCE_GET_INTERFACE (sksrc);
g_return_val_if_fail (klass->search != NULL, NULL);
return (*klass->search) (sksrc, match);
......@@ -143,12 +156,12 @@ seahorse_source_search (SeahorseSource *sksrc, const gchar *match)
SeahorseOperation*
seahorse_source_import (SeahorseSource *sksrc, GInputStream *input)
{
SeahorseSourceClass *klass;
SeahorseSourceIface *klass;
g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), NULL);
klass = SEAHORSE_SOURCE_GET_CLASS (sksrc);
klass = SEAHORSE_SOURCE_GET_INTERFACE (sksrc);
g_return_val_if_fail (klass->import != NULL, NULL);
return (*klass->import) (sksrc, input);
......@@ -268,7 +281,7 @@ seahorse_source_delete_objects (GList *objects)
SeahorseOperation*
seahorse_source_export (SeahorseSource *sksrc, GList *objects, GOutputStream *output)
{
SeahorseSourceClass *klass;
SeahorseSourceIface *klass;
SeahorseOperation *op;
GSList *ids = NULL;
GList *l;
......@@ -276,7 +289,7 @@ seahorse_source_export (SeahorseSource *sksrc, GList *objects, GOutputStream *ou
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), NULL);
g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
klass = SEAHORSE_SOURCE_GET_CLASS (sksrc);
klass = SEAHORSE_SOURCE_GET_INTERFACE (sksrc);
if (klass->export)
return (*klass->export) (sksrc, objects, output);
......@@ -295,7 +308,7 @@ seahorse_source_export (SeahorseSource *sksrc, GList *objects, GOutputStream *ou
SeahorseOperation*
seahorse_source_export_raw (SeahorseSource *sksrc, GSList *ids, GOutputStream *output)
{
SeahorseSourceClass *klass;
SeahorseSourceIface *klass;
SeahorseOperation *op;
SeahorseObject *sobj;
GList *objects = NULL;
......@@ -304,7 +317,7 @@ seahorse_source_export_raw (SeahorseSource *sksrc, GSList *ids, GOutputStream *o
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), NULL);
g_return_val_if_fail (output == NULL || G_IS_OUTPUT_STREAM (output), NULL);
klass = SEAHORSE_SOURCE_GET_CLASS (sksrc);
klass = SEAHORSE_SOURCE_GET_INTERFACE (sksrc);
/* Either export or export_raw must be implemented */
if (klass->export_raw)
......@@ -341,25 +354,3 @@ seahorse_source_get_location (SeahorseSource *sksrc)
g_object_get (sksrc, "location", &loc, NULL);
return loc;
}
/* -----------------------------------------------------------------------------
* CANONICAL IDS
*/
GQuark
seahorse_source_canonize_id (GQuark ktype, const gchar *id)
{
SeahorseSourceClass *klass;
GType type;
g_return_val_if_fail (id != NULL, 0);
type = seahorse_registry_object_type (NULL, "source", g_quark_to_string (ktype), "local", NULL);
g_return_val_if_fail (type, 0);
klass = SEAHORSE_SOURCE_CLASS (g_type_class_peek (type));
g_return_val_if_fail (klass, 0);
g_return_val_if_fail (klass->canonize_id, 0);
return (klass->canonize_id) (id);
}
......@@ -48,98 +48,86 @@
#include <gio/gio.h>
#include <glib-object.h>
#define SEAHORSE_TYPE_SOURCE (seahorse_source_get_type ())
#define SEAHORSE_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_SOURCE, SeahorseSource))
#define SEAHORSE_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_SOURCE, SeahorseSourceClass))
#define SEAHORSE_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_SOURCE))
#define SEAHORSE_IS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_SOURCE))
#define SEAHORSE_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_SOURCE, SeahorseSourceClass))
#define SEAHORSE_TYPE_SOURCE (seahorse_source_get_type ())
#define SEAHORSE_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_SOURCE, SeahorseSource))
#define SEAHORSE_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_SOURCE))
#define SEAHORSE_SOURCE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SEAHORSE_TYPE_SOURCE, SeahorseSourceIface))
struct _SeahorseObject;
typedef struct _SeahorseSource {
GObject parent;
} SeahorseSource;
typedef struct _SeahorseSource SeahorseSource;
typedef struct _SeahorseSourceIface SeahorseSourceIface;
typedef struct _SeahorseSourceClass {
GtkObjectClass parent_class;
struct _SeahorseSourceIface {
GTypeInterface parent;
/* class props ----------------------------------------------------- */
const GQuark obj_tag;
const gchar *display_name;
const gchar **mime_types;
/* virtual methods ------------------------------------------------- */
/**
* load
* @sksrc: The #SeahorseSource.
*
* Loads the requested objects, and add the objects to SeahorseContext.
*
* Returns: The load operation.
*/
SeahorseOperation* (*load) (SeahorseSource *sksrc);
/**
* search
* @sksrc: The #SeahorseSource
* @match: Match text
*
* Searches for objects in the source.
*
* Returns: The search operation.
*/
SeahorseOperation* (*search) (SeahorseSource *sksrc, const gchar *match);
/* class methods --------------------------------------------------- */
GQuark (*canonize_id) (const gchar *id);
/**
* import
* @sksrc: The #SeahorseSource to import into.
* @input: The data to import.
*
* Import objects into the source. When operation is 'done' a GList of
* updated objects may be found as the operation result.
*
* Returns: The import operation
*/
SeahorseOperation* (*import) (SeahorseSource *sksrc, GInputStream *input);
/**
* export
* @sksrc: The #SeahorseSource to export from.
* @objects: A list of objects to export.
* @complete: Whether to export the secret objects too.
* @data: Output stream to export to.
*
* Import objects into the object source. When operation is 'done' the result
* of the operation will be a GOutputStream
*
* Returns: The export operation
*/
SeahorseOperation* (*export) (SeahorseSource *sksrc, GList *objects, GOutputStream *output);
/**
* export_raw
* @sksrc: The #SeahorseSource to export from.
* @objects: A list of ids to export.
* @data: output stream to export to.
*
* Import objects into the source. When operation is 'done' the result
* of the operation will be a GOutputStream
*
* Returns: The export operation
*/
SeahorseOperation* (*export_raw) (SeahorseSource *sksrc, GSList *ids,
GOutputStream *output);
/* virtual methods ------------------------------------------------- */
/**
* load
* @sksrc: The #SeahorseSource.
*
* Loads the requested objects, and add the objects to SeahorseContext.
*
* Returns: The load operation.
*/
SeahorseOperation* (*load) (SeahorseSource *sksrc);
/**
* search
* @sksrc: The #SeahorseSource
* @match: Match text
*
* Searches for objects in the source.
*
* Returns: The search operation.
*/
SeahorseOperation* (*search) (SeahorseSource *sksrc, const gchar *match);
};
/**
* import
* @sksrc: The #SeahorseSource to import into.
* @input: The data to import.
*
* Import objects into the source. When operation is 'done' a GList of
* updated objects may be found as the operation result.
*
* Returns: The import operation
*/
SeahorseOperation* (*import) (SeahorseSource *sksrc, GInputStream *input);
/**
* export
* @sksrc: The #SeahorseSource to export from.
* @objects: A list of objects to export.
* @complete: Whether to export the secret objects too.
* @data: Output stream to export to.
*
* Import objects into the object source. When operation is 'done' the result
* of the operation will be a GOutputStream
*
* Returns: The export operation
*/
SeahorseOperation* (*export) (SeahorseSource *sksrc, GList *objects, GOutputStream *output);
/**
* export_raw
* @sksrc: The #SeahorseSource to export from.
* @objects: A list of ids to export.
* @data: output stream to export to.
*
* Import objects into the source. When operation is 'done' the result
* of the operation will be a GOutputStream
*
* Returns: The export operation
*/