Commit dd9b57a6 authored by Stefan Walter's avatar Stefan Walter

Simplify initialization of modules, and make modules add sources to

	* common/seahorse-registry.c:
	* common/seahorse-registry.h:
	* daemon/seahorse-daemon.c:
	* gkr/seahorse-gkr-module.c:
	* gkr/seahorse-gkr-module.h:
	* libseahorse/seahorse-context.c:
	* libseahorse/seahorse-context.h:
	* pgp/seahorse-hkp-source.c:
	* pgp/seahorse-ldap-source.c:
	* pgp/seahorse-pgp-module.c:
	* pgp/seahorse-pgp-module.h:
	* pgp/seahorse-pgp-source.c:
	* pkcs11/seahorse-pkcs11-module.c:
	* pkcs11/seahorse-pkcs11-module.h:
	* src/main.c:
	* src/seahorse-keyserver-search.c:
	* ssh/seahorse-ssh-module.c:
	* ssh/seahorse-ssh-module.h:
	* ssh/seahorse-ssh-source.c: Simplify initialization of modules,
	and make modules add sources to context explicitly.

svn path=/trunk/; revision=2319
parent c68f0618
......@@ -182,23 +182,6 @@ seahorse_registry_get (void)
return registry_singleton;
}
void
seahorse_registry_load_types (SeahorseRegistry *registry, const SeahorseRegisterType *types)
{
GType type;
gpointer klass;
while (*types) {
type = (*types) ();
g_return_if_fail (type);
klass = g_type_class_ref (type);
g_type_class_unref (klass);
++types;
}
}
void
seahorse_registry_register_type (SeahorseRegistry *registry, GType type,
const gchar *category, ...)
......
......@@ -26,8 +26,6 @@
G_BEGIN_DECLS
typedef GType (*SeahorseRegisterType) (void);
#define SEAHORSE_TYPE_REGISTRY (seahorse_registry_get_type())
#define SEAHORSE_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SEAHORSE_TYPE_REGISTRY, SeahorseRegistry))
#define SEAHORSE_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SEAHORSE_TYPE_REGISTRY, GObject))
......@@ -51,9 +49,6 @@ GType seahorse_registry_get_type (void) G_GNUC_CONST;
SeahorseRegistry* seahorse_registry_get (void);
void seahorse_registry_load_types (SeahorseRegistry *registry,
const SeahorseRegisterType *types);
void seahorse_registry_register_type (SeahorseRegistry *registry,
GType type, const gchar *category,
...) G_GNUC_NULL_TERMINATED;
......
......@@ -211,17 +211,18 @@ int main(int argc, char* argv[])
seahorse_gtkstock_init ();
seahorse_gtkstock_add_icons (daemon_icons);
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP | SEAHORSE_CONTEXT_DAEMON);
/* Load the various components */
#ifdef WITH_PGP
seahorse_registry_load_types (NULL, SEAHORSE_PGP_REGISTRY);
seahorse_pgp_module_init ();
#endif
#ifdef WITH_SSH
seahorse_registry_load_types (NULL, SEAHORSE_SSH_REGISTRY);
seahorse_ssh_module_init ();
#endif
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP | SEAHORSE_CONTEXT_DAEMON, 0);
op = seahorse_context_load_local_objects (SCTX_APP ());
op = seahorse_context_refresh_local (NULL);
g_object_unref (op);
/* Initialize the various daemon components */
......
......@@ -26,8 +26,18 @@
#include "seahorse-gkr-commands.h"
#include "seahorse-gkeyring-source.h"
const SeahorseRegisterType SEAHORSE_GKR_REGISTRY[] = {
seahorse_gkeyring_source_get_type,
seahorse_gkeyring_commands_get_type,
NULL
};
#include "seahorse-context.h"
void
seahorse_gkr_module_init (void)
{
SeahorseSource *source;
/* Always have a default keyring source added */
source = g_object_new (SEAHORSE_TYPE_GKEYRING_SOURCE, NULL);
seahorse_context_take_source (NULL, source);
/* Let these classes register themselves */
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_GKEYRING_SOURCE));
g_type_class_unref (g_type_class_ref (SEAHORSE_GKEYRING_TYPE_COMMANDS));
}
......@@ -22,11 +22,9 @@
#ifndef SEAHORSEGKR_H_
#define SEAHORSEGKR_H_
#include "common/seahorse-registry.h"
#define SEAHORSE_GKR_STR "gnome-keyring"
#define SEAHORSE_GKR (g_quark_from_static_string (SEAHORSE_GKR_STR))
extern const SeahorseRegisterType SEAHORSE_GKR_REGISTRY[];
void seahorse_gkr_module_init (void);
#endif /*SEAHORSEGKR_H_*/
This diff is collapsed.
......@@ -25,7 +25,8 @@
* together.
*
* - Usually there's only one SeahorseContext per process created by passing
* |TRUE| to |seahorse_context_new|, and accessed via the |SCTX_APP| macro.
* |SEAHORSE_CONTEXT_APP| to |seahorse_context_new|, and accessed via
* the |SCTX_APP| macro.
* - Retains the list of all valid struct _SeahorseObject objects.
* - Has a collection of SeahorseSource objects which add objects to the
* SeahorseContext.
......@@ -96,8 +97,7 @@ GType seahorse_context_get_type (void);
SeahorseContext* seahorse_context_for_app (void);
SeahorseContext* seahorse_context_new (guint flags,
guint ktype);
SeahorseContext* seahorse_context_new (guint flags);
void seahorse_context_destroy (SeahorseContext *sctx);
......@@ -162,12 +162,12 @@ SeahorseServiceDiscovery*
struct _SeahorseKey* seahorse_context_get_default_key (SeahorseContext *sctx);
SeahorseOperation* seahorse_context_load_local_objects (SeahorseContext *sctx);
SeahorseOperation* seahorse_context_refresh_local (SeahorseContext *sctx);
void seahorse_context_load_local_objects_async (SeahorseContext *sctx);
void seahorse_context_refresh_local_async (SeahorseContext *sctx);
SeahorseOperation* seahorse_context_load_remote_objects (SeahorseContext *sctx,
const gchar *search);
SeahorseOperation* seahorse_context_search_remote (SeahorseContext *sctx,
const gchar *search);
SeahorseOperation* seahorse_context_transfer_objects (SeahorseContext *sctx,
GList *objs,
......
......@@ -36,6 +36,8 @@
#include "seahorse-servers.h"
#include "seahorse-util.h"
#include "common/seahorse-registry.h"
#include <libsoup/soup.h>
#ifdef WITH_HKP
......
......@@ -36,6 +36,8 @@
#include "seahorse-servers.h"
#include "seahorse-util.h"
#include "common/seahorse-registry.h"
#include <ldap.h>
#ifdef WITH_SOUP
......
......@@ -33,16 +33,25 @@
#ifdef WITH_HKP
#include "seahorse-hkp-source.h"
#endif
#include "seahorse-context.h"
const SeahorseRegisterType SEAHORSE_PGP_REGISTRY[] = {
seahorse_pgp_source_get_type,
seahorse_pgp_commands_get_type,
seahorse_pgp_generator_get_type,
void
seahorse_pgp_module_init (void)
{
SeahorseSource *source;
/* Always have a default pgp source added */
source = g_object_new (SEAHORSE_TYPE_PGP_SOURCE, NULL);
seahorse_context_take_source (NULL, source);
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_PGP_SOURCE));
g_type_class_unref (g_type_class_ref (SEAHORSE_PGP_TYPE_COMMANDS));
g_type_class_unref (g_type_class_ref (SEAHORSE_PGP_TYPE_GENERATOR));
#ifdef WITH_LDAP
seahorse_ldap_source_get_type,
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_LDAP_SOURCE));
#endif
#ifdef WITH_HKP
seahorse_hkp_source_get_type,
#endif
NULL
};
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_HKP_SOURCE));
#endif
}
......@@ -22,11 +22,9 @@
#ifndef SEAHORSEPGP_H_
#define SEAHORSEPGP_H_
#include "common/seahorse-registry.h"
#define SEAHORSE_PGP_STR "openpgp"
#define SEAHORSE_PGP (g_quark_from_static_string (SEAHORSE_PGP_STR))
extern const SeahorseRegisterType SEAHORSE_PGP_REGISTRY[];
void seahorse_pgp_module_init (void);
#endif /*SEAHORSEPGP_H_*/
......@@ -37,6 +37,8 @@
#include "seahorse-libdialogs.h"
#include "seahorse-passphrase.h"
#include "common/seahorse-registry.h"
#include <gio/gio.h>
#include <stdlib.h>
......
......@@ -23,6 +23,8 @@
#include "seahorse-pkcs11-module.h"
const SeahorseRegisterType SEAHORSE_PKCS11_REGISTRY[] = {
NULL
};
void
seahorse_pkcs11_module_init (void)
{
}
......@@ -22,11 +22,9 @@
#ifndef SEAHORSE_PKCS11_H_
#define SEAHORSE_PKCS11_H_
#include "common/seahorse-registry.h"
#define SEAHORSE_PKCS11_STR "pkcs11"
#define SEAHORSE_PKCS11 (g_quark_from_static_string (SEAHORSE_PKCS11_STR))
extern const SeahorseRegisterType SEAHORSE_PKCS11_REGISTRY[];
void seahorse_pkcs11_module_init (void);
#endif /*SEAHORSE_PKCS11_H_*/
......@@ -68,20 +68,21 @@ main (int argc, char **argv)
/* Insert Icons into Stock */
seahorse_gtkstock_init ();
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP);
/* Initialize the various components */
#ifdef WITH_PGP
seahorse_registry_load_types (NULL, SEAHORSE_PGP_REGISTRY);
seahorse_pgp_module_init ();
#endif
#ifdef WITH_SSH
seahorse_registry_load_types (NULL, SEAHORSE_SSH_REGISTRY);
seahorse_ssh_module_init ();
#endif
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP, 0);
op = seahorse_context_load_local_objects (SCTX_APP ());
op = seahorse_context_refresh_local (SCTX_APP ());
/* Load these components after loading local keys */
seahorse_registry_load_types (NULL, SEAHORSE_GKR_REGISTRY);
seahorse_gkr_module_init ();
seahorse_key_manager_show (op);
g_signal_connect_after (SCTX_APP (), "destroy", gtk_main_quit, NULL);
......
......@@ -312,7 +312,7 @@ ok_clicked (GtkButton *button, SeahorseWidget *swidget)
seahorse_gconf_set_string_list (LASTSERVERS_KEY,
selection->all ? NULL : selection->names);
op = seahorse_context_load_remote_objects (SCTX_APP(), search);
op = seahorse_context_search_remote (SCTX_APP(), search);
/* Open the new result window */
seahorse_keyserver_results_show (op,
......
......@@ -27,9 +27,18 @@
#include "seahorse-ssh-generator.h"
#include "seahorse-ssh-source.h"
const SeahorseRegisterType SEAHORSE_SSH_REGISTRY[] = {
seahorse_ssh_source_get_type,
seahorse_ssh_commands_get_type,
seahorse_ssh_generator_get_type,
NULL
};
#include "seahorse-context.h"
void
seahorse_ssh_module_init (void)
{
SeahorseSource *source;
/* Always have a default pgp source added */
source = g_object_new (SEAHORSE_TYPE_SSH_SOURCE, NULL);
seahorse_context_take_source (NULL, source);
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_SSH_SOURCE));
g_type_class_unref (g_type_class_ref (SEAHORSE_SSH_TYPE_COMMANDS));
g_type_class_unref (g_type_class_ref (SEAHORSE_SSH_TYPE_GENERATOR));
}
......@@ -22,11 +22,9 @@
#ifndef SEASSH_H_
#define SEASSH_H_
#include "common/seahorse-registry.h"
#define SEAHORSE_SSH_STR "openssh"
#define SEAHORSE_SSH (g_quark_from_static_string (SEAHORSE_SSH_STR))
extern const SeahorseRegisterType SEAHORSE_SSH_REGISTRY[];
void seahorse_ssh_module_init (void);
#endif /*SEASSH_H_*/
......@@ -30,6 +30,8 @@
#include "seahorse-operation.h"
#include "seahorse-util.h"
#include "common/seahorse-registry.h"
#include <glib/gstdio.h>
#include <string.h>
......
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