Commit 6c406287 authored by Stefan Walter's avatar Stefan Walter

Make SeahorseGkrKeyring be both a SeahorseObject and a SeahorseSource.

	* daemon/seahorse-daemon.c:
	* gkr/seahorse-gkr-item-properties.c:
	* gkr/seahorse-gkr-keyring.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-unknown-source.c:
	* pgp/seahorse-hkp-source.c:
	* pgp/seahorse-ldap-source.c:
	* pgp/seahorse-pgp-source.c:
	* pgp/seahorse-server-source.c:
	* pkcs11/seahorse-pkcs11-source.c:
	* src/main.c:
	* src/seahorse-key-manager.h:
	* src/seahorse-key-manager.c:
	* ssh/seahorse-ssh-source.c: Make SeahorseGkrKeyring be both
	a SeahorseObject and a SeahorseSource. Enumerate keyrings 
	properly. Don't list items in locked keyrings. Refresh 
	sources as they're added to the context.

svn path=/trunk/; revision=2663
parent a85d8e36
2008-12-14 Stef Walter <stef@memberwebs.com>
* daemon/seahorse-daemon.c:
* gkr/seahorse-gkr-item-properties.c:
* gkr/seahorse-gkr-keyring.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-unknown-source.c:
* pgp/seahorse-hkp-source.c:
* pgp/seahorse-ldap-source.c:
* pgp/seahorse-pgp-source.c:
* pgp/seahorse-server-source.c:
* pkcs11/seahorse-pkcs11-source.c:
* src/main.c:
* src/seahorse-key-manager.h:
* src/seahorse-key-manager.c:
* ssh/seahorse-ssh-source.c: Make SeahorseGkrKeyring be both
a SeahorseObject and a SeahorseSource. Enumerate keyrings
properly. Don't list items in locked keyrings. Refresh
sources as they're added to the context.
2008-12-14 Adam Schreiber <sadam@clemson.edu>
* libseahorse/seahorse-transfer-operation.c:
......
......@@ -182,7 +182,6 @@ prepare_logging ()
int main(int argc, char* argv[])
{
SeahorseOperation *op;
GOptionContext *octx = NULL;
GError *error = NULL;
......@@ -233,8 +232,7 @@ int main(int argc, char* argv[])
seahorse_ssh_module_init ();
#endif
op = seahorse_context_refresh_local (NULL);
g_object_unref (op);
seahorse_context_refresh_auto (NULL);
/* Initialize the various daemon components */
seahorse_dbus_server_init ();
......
......@@ -298,7 +298,7 @@ description_activate (GtkWidget *entry, SeahorseWidget *swidget)
SeahorseOperation *op = NULL;
GnomeKeyringItemInfo *info;
const gchar *text;
gchar *original;
const gchar *original;
object = SEAHORSE_OBJECT_WIDGET (swidget)->object;
if (!object)
......@@ -340,7 +340,6 @@ description_activate (GtkWidget *entry, SeahorseWidget *swidget)
gtk_widget_set_sensitive (entry, TRUE);
g_object_unref (entry);
g_object_unref (git);
g_free (original);
if (op) {
if (!seahorse_operation_is_successful (op))
......
This diff is collapsed.
......@@ -33,26 +33,10 @@
void
seahorse_gkr_module_init (void)
{
GnomeKeyringResult result;
SeahorseSource *source;
const gchar *keyring_name;
GList *l, *keyrings = NULL;
/* List the keyrings and add one per */
result = gnome_keyring_list_keyring_names_sync (&keyrings);
if (result != GNOME_KEYRING_RESULT_OK) {
g_warning ("couldn't get list gnome-keyring keyrings: %s",
gnome_keyring_result_to_message (result));
} else {
for (l = keyrings; l; l = g_list_next (l)) {
keyring_name = (const gchar*)l->data;
source = SEAHORSE_SOURCE (seahorse_gkr_source_new (keyring_name));
seahorse_context_take_source (NULL, source);
}
gnome_keyring_string_list_free (keyrings);
}
source = SEAHORSE_SOURCE (seahorse_gkr_source_new ());
seahorse_context_take_source (NULL, source);
/* Let these classes register themselves */
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_GKR_SOURCE));
......
This diff is collapsed.
......@@ -59,8 +59,6 @@ struct _SeahorseGkrSourceClass {
GType seahorse_gkr_source_get_type (void);
SeahorseGkrSource* seahorse_gkr_source_new (const gchar *keyring_name);
const gchar* seahorse_gkr_source_get_keyring_name (SeahorseGkrSource *gsrc);
SeahorseGkrSource* seahorse_gkr_source_new (void);
#endif /* __SEAHORSE_GKR_SOURCE_H__ */
......@@ -51,6 +51,7 @@ enum {
ADDED,
REMOVED,
CHANGED,
REFRESHING,
LAST_SIGNAL
};
......@@ -75,6 +76,7 @@ struct _SeahorseContextPrivate {
GHashTable *objects_by_source; /* See explanation above */
GHashTable *objects_by_type; /* See explanation above */
guint notify_id; /* Notify for GConf watch */
SeahorseMultiOperation *refresh_ops; /* Operations for refreshes going on */
SeahorseServiceDiscovery *discovery; /* Adds sources from DNS-SD */
};
......@@ -105,6 +107,9 @@ seahorse_context_class_init (SeahorseContextClass *klass)
signals[CHANGED] = g_signal_new ("changed", SEAHORSE_TYPE_CONTEXT,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseContextClass, changed),
NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SEAHORSE_TYPE_OBJECT);
signals[REFRESHING] = g_signal_new ("refreshing", SEAHORSE_TYPE_CONTEXT,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseContextClass, refreshing),
NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SEAHORSE_TYPE_OPERATION);
}
/* init context, private vars, set prefs, connect signals */
......@@ -126,7 +131,6 @@ seahorse_context_init (SeahorseContext *sctx)
/* The context is explicitly destroyed */
g_object_ref (sctx);
}
static void
......@@ -172,6 +176,10 @@ seahorse_context_dispose (GObject *gobject)
g_slist_free (sctx->pv->sources);
sctx->pv->sources = NULL;
if (sctx->pv->refresh_ops)
g_object_unref (sctx->pv->refresh_ops);
sctx->pv->refresh_ops = NULL;
G_OBJECT_CLASS (seahorse_context_parent_class)->dispose (gobject);
}
......@@ -191,6 +199,7 @@ seahorse_context_finalize (GObject *gobject)
g_assert (sctx->pv->sources == NULL);
g_assert (sctx->pv->auto_sources == NULL);
g_assert (sctx->pv->discovery == NULL);
g_assert (sctx->pv->refresh_ops == NULL);
g_free (sctx->pv);
G_OBJECT_CLASS (seahorse_context_parent_class)->finalize (gobject);
......@@ -254,33 +263,49 @@ seahorse_context_destroy (SeahorseContext *sctx)
app_context = NULL;
}
static gboolean
take_source (SeahorseContext *sctx, SeahorseSource *sksrc)
{
SeahorseOperation *operation;
g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), FALSE);
if (!g_slist_find (sctx->pv->sources, sksrc)) {
sctx->pv->sources = g_slist_append (sctx->pv->sources, sksrc);
if (sctx->pv->refresh_ops) {
operation = seahorse_source_load (sksrc);
g_return_val_if_fail (operation, TRUE);
seahorse_multi_operation_take (sctx->pv->refresh_ops, operation);
g_signal_emit (sctx, signals[REFRESHING], 0, sctx->pv->refresh_ops);
}
return TRUE;
}
return FALSE;
}
void
seahorse_context_take_source (SeahorseContext *sctx, SeahorseSource *sksrc)
{
g_return_if_fail (SEAHORSE_IS_SOURCE (sksrc));
g_return_if_fail (SEAHORSE_IS_SOURCE (sksrc));
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_if_fail (SEAHORSE_IS_CONTEXT (sctx));
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_if_fail (SEAHORSE_IS_CONTEXT (sctx));
if (!g_slist_find (sctx->pv->sources, sksrc))
sctx->pv->sources = g_slist_append (sctx->pv->sources, sksrc);
take_source (sctx, sksrc);
}
void
seahorse_context_add_source (SeahorseContext *sctx, SeahorseSource *sksrc)
{
g_return_if_fail (SEAHORSE_IS_SOURCE (sksrc));
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_if_fail (SEAHORSE_IS_CONTEXT (sctx));
if (g_slist_find (sctx->pv->sources, sksrc))
return;
g_return_if_fail (SEAHORSE_IS_SOURCE (sksrc));
sctx->pv->sources = g_slist_append (sctx->pv->sources, sksrc);
g_object_ref (sksrc);
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_if_fail (SEAHORSE_IS_CONTEXT (sctx));
if (take_source (sctx, sksrc))
g_object_ref (sksrc);
}
void
......@@ -767,53 +792,35 @@ seahorse_context_get_discovery (SeahorseContext *sctx)
return sctx->pv->discovery;
}
SeahorseOperation*
seahorse_context_refresh_local (SeahorseContext *sctx)
void
seahorse_context_refresh_auto (SeahorseContext *sctx)
{
SeahorseSource *ks;
SeahorseMultiOperation *mop = NULL;
SeahorseOperation *op = NULL;
GSList *l;
SeahorseSource *ks;
SeahorseOperation *op = NULL;
GSList *l;
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_val_if_fail (SEAHORSE_IS_CONTEXT (sctx), NULL);
if (!sctx)
sctx = seahorse_context_for_app ();
g_return_if_fail (SEAHORSE_IS_CONTEXT (sctx));
if (!sctx->pv->refresh_ops)
sctx->pv->refresh_ops = seahorse_multi_operation_new ();
for (l = sctx->pv->sources; l; l = g_slist_next (l)) {
ks = SEAHORSE_SOURCE (l->data);
for (l = sctx->pv->sources; l; l = g_slist_next (l)) {
ks = SEAHORSE_SOURCE (l->data);
if (seahorse_source_get_location (ks) == SEAHORSE_LOCATION_LOCAL) {
if (mop == NULL && op != NULL) {
mop = seahorse_multi_operation_new ();
seahorse_multi_operation_take (mop, op);
}
op = seahorse_source_load (ks);
if (mop != NULL)
seahorse_multi_operation_take (mop, op);
}
}
if (seahorse_source_get_location (ks) == SEAHORSE_LOCATION_LOCAL) {
return mop ? SEAHORSE_OPERATION (mop) : op;
}
static gboolean
refresh_local (SeahorseContext *sctx)
{
SeahorseOperation *op = seahorse_context_refresh_local (sctx);
g_return_val_if_fail (op != NULL, FALSE);
g_object_unref (op);
return FALSE;
}
void
seahorse_context_refresh_local_async (SeahorseContext *sctx)
{
g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)refresh_local, sctx, NULL);
op = seahorse_source_load (ks);
g_return_if_fail (op);
seahorse_multi_operation_take (sctx->pv->refresh_ops, op);
}
}
g_signal_emit (sctx, signals[REFRESHING], 0, sctx->pv->refresh_ops);
}
SeahorseOperation*
seahorse_context_search_remote (SeahorseContext *sctx, const gchar *search)
{
......
......@@ -84,6 +84,9 @@ struct _SeahorseContextClass {
/* This object has changed */
void (*changed) (SeahorseContext *sctx, struct _SeahorseObject *sobj);
/* The source is being refreshed */
void (*refreshing) (SeahorseContext *sctx, SeahorseOperation *op);
};
enum SeahorseContextType {
......@@ -167,12 +170,10 @@ SeahorseServiceDiscovery*
struct _SeahorseObject*
seahorse_context_get_default_key (SeahorseContext *sctx);
SeahorseOperation* seahorse_context_refresh_local (SeahorseContext *sctx);
void seahorse_context_refresh_local_async (SeahorseContext *sctx);
void seahorse_context_refresh_auto (SeahorseContext *sctx);
SeahorseOperation* seahorse_context_search_remote (SeahorseContext *sctx,
const gchar *search);
SeahorseOperation* seahorse_context_search_remote (SeahorseContext *sctx,
const gchar *search);
SeahorseOperation* seahorse_context_transfer_objects (SeahorseContext *sctx,
GList *objs,
......
......@@ -2,3 +2,4 @@ VOID:STRING,DOUBLE
VOID:OBJECT,UINT
VOID:OBJECT,POINTER
VOID:OBJECT,UINT,POINTER
VOID:OBJECT,OBJECT
......@@ -42,15 +42,15 @@ seahorse_source_base_init (gpointer gobject_class)
/* 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));
0, G_MAXUINT, SEAHORSE_TAG_INVALID, G_PARAM_READABLE));
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));
g_param_spec_enum ("location", "Key Location", "Where the key is stored. See SeahorseLocation",
SEAHORSE_TYPE_LOCATION, SEAHORSE_LOCATION_LOCAL, G_PARAM_READABLE));
initialized = TRUE;
}
......
......@@ -89,7 +89,7 @@ seahorse_unknown_source_get_property (GObject *object, guint prop_id, GValue *va
g_value_set_string (value, _("Unavailable Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_MISSING);
g_value_set_enum (value, SEAHORSE_LOCATION_MISSING);
break;
}
}
......
......@@ -737,7 +737,7 @@ seahorse_hkp_source_get_property (GObject *object, guint prop_id, GValue *value,
g_value_set_string (value, _("PGP Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_REMOTE);
g_value_set_enum (value, SEAHORSE_LOCATION_REMOTE);
break;
};
}
......
......@@ -1280,7 +1280,7 @@ seahorse_ldap_source_get_property (GObject *object, guint prop_id, GValue *value
g_value_set_string (value, _("PGP Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_REMOTE);
g_value_set_enum (value, SEAHORSE_LOCATION_REMOTE);
break;
};
}
......
......@@ -438,7 +438,7 @@ seahorse_pgp_source_get_property (GObject *object, guint prop_id, GValue *value,
g_value_set_string (value, _("PGP Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_LOCAL);
g_value_set_enum (value, SEAHORSE_LOCATION_LOCAL);
break;
}
}
......
......@@ -206,7 +206,7 @@ seahorse_server_get_property (GObject *object, guint prop_id, GValue *value,
g_value_set_string (value, _("PGP Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_REMOTE);
g_value_set_enum (value, SEAHORSE_LOCATION_REMOTE);
break;
}
}
......
......@@ -102,7 +102,7 @@ seahorse_pkcs11_source_get_property (GObject *object, guint prop_id, GValue *val
g_value_set_string (value, _("X509 Certificates"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_LOCAL);
g_value_set_enum (value, SEAHORSE_LOCATION_LOCAL);
break;
}
}
......
......@@ -56,7 +56,6 @@
int
main (int argc, char **argv)
{
SeahorseOperation *op = NULL;
GError *error = NULL;
int ret = 0;
......@@ -94,9 +93,11 @@ main (int argc, char **argv)
#endif
seahorse_gkr_module_init ();
op = seahorse_context_refresh_local (SCTX_APP ());
seahorse_key_manager_show ();
/* Start the refreshing of the keys */
seahorse_context_refresh_auto (NULL);
seahorse_key_manager_show (op);
g_signal_connect_after (SCTX_APP (), "destroy", gtk_main_quit, NULL);
gtk_main ();
......
......@@ -725,6 +725,11 @@ on_gconf_notify (GConfClient* client, guint cnxn_id, GConfEntry* entry, Seahorse
gtk_toggle_action_set_active (action, gconf_value_get_bool (entry->value));
}
static void
on_refreshing (SeahorseContext *sctx, SeahorseOperation *operation, SeahorseWidget *swidget)
{
seahorse_progress_status_set_operation (swidget, operation);
}
static const GtkActionEntry GENERAL_ENTRIES[] = {
......@@ -976,6 +981,7 @@ seahorse_key_manager_constructor (GType type, guint n_props, GObjectConstructPar
g_timeout_add_seconds (1, (GSourceFunc)on_first_timer, self);
g_signal_emit_by_name (self, "selection-changed");
g_signal_connect (seahorse_context_for_app (), "refreshing", G_CALLBACK (on_refreshing), self);
return G_OBJECT (self);
}
......@@ -1076,9 +1082,8 @@ seahorse_key_manager_class_init (SeahorseKeyManagerClass *klass)
GtkWindow*
seahorse_key_manager_show (SeahorseOperation* op)
seahorse_key_manager_show (void)
{
SeahorseKeyManager *man = g_object_new (SEAHORSE_TYPE_KEY_MANAGER, "name", "key-manager", NULL);
seahorse_progress_status_set_operation (SEAHORSE_WIDGET (man), op);
return GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (man)));
}
......@@ -56,7 +56,7 @@ struct _SeahorseKeyManagerClass {
* logic throughout this file.
*/
GtkWindow* seahorse_key_manager_show (SeahorseOperation *op);
GtkWindow* seahorse_key_manager_show (void);
GType seahorse_key_manager_get_type (void);
......
......@@ -616,7 +616,7 @@ seahorse_ssh_source_get_property (GObject *object, guint prop_id, GValue *value,
g_value_set_string (value, _("Secure Shell Key"));
break;
case PROP_LOCATION:
g_value_set_uint (value, SEAHORSE_LOCATION_LOCAL);
g_value_set_enum (value, SEAHORSE_LOCATION_LOCAL);
break;
case PROP_BASE_DIRECTORY:
g_value_set_string (value, ssrc->priv->ssh_homedir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment