diff options
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 13 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-component.c | 87 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-config.c | 6 |
3 files changed, 106 insertions, 0 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index be0156597e..9eab108cd8 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2004-02-02 Hans Petter Jansson <hpj@ximian.com> + + * gui/component/addressbook-component.c (ensure_sources): Implement + based on the create_groups () function in addressbook-migrate.c. + (addressbook_component_init): Call ensure_sources (). This will create + the necessary addressbook source groups if they somehow disappeared + from GConf. + + * gui/component/addressbook-config.c (addressbook_config_edit_source): + If we can't get any source groups, just issue a console warning and + return NULL. Creating sources without groups is meaningless. + Work around for #67411 + 2005-02-02 Rodney Dawes <dobey@novell.com> * gui/component/ldap-config.glade: Fix a small spacing issue in the diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 3e1bba599a..a0c3c58c04 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -49,6 +49,8 @@ #include "smime/gui/component.h" #endif +#define LDAP_BASE_URI "ldap://" +#define PERSONAL_RELATIVE_URI "system" #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; @@ -58,6 +60,89 @@ struct _AddressbookComponentPrivate { char *base_directory; }; +static void +ensure_sources (AddressbookComponent *component) +{ + GSList *groups; + ESourceList *source_list; + ESourceGroup *group; + ESourceGroup *on_this_computer; + ESourceGroup *on_ldap_servers; + ESource *personal_source; + char *base_uri, *base_uri_proto; + + on_this_computer = NULL; + on_ldap_servers = NULL; + personal_source = NULL; + + if (!e_book_get_addressbooks (&source_list, NULL)) { + g_warning ("Could not get addressbook source list from GConf!"); + return; + } + + base_uri = g_build_filename (addressbook_component_peek_base_directory (component), + "addressbook", "local", + NULL); + + base_uri_proto = g_strconcat ("file://", base_uri, NULL); + + groups = e_source_list_peek_groups (source_list); + if (groups) { + /* groups are already there, we need to search for things... */ + GSList *g; + + for (g = groups; g; g = g->next) { + + group = E_SOURCE_GROUP (g->data); + + if (!on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group))) + on_this_computer = group; + else if (!on_ldap_servers && !strcmp (LDAP_BASE_URI, e_source_group_peek_base_uri (group))) + on_ldap_servers = group; + } + } + + if (on_this_computer) { + /* make sure "Personal" shows up as a source under + this group */ + GSList *sources = e_source_group_peek_sources (on_this_computer); + GSList *s; + for (s = sources; s; s = s->next) { + ESource *source = E_SOURCE (s->data); + if (!strcmp (PERSONAL_RELATIVE_URI, e_source_peek_relative_uri (source))) { + personal_source = source; + break; + } + } + } + else { + /* create the local source group */ + group = e_source_group_new (_("On This Computer"), base_uri_proto); + e_source_list_add_group (source_list, group, -1); + + on_this_computer = group; + } + + if (!personal_source) { + /* Create the default Person addressbook */ + ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI); + e_source_group_add_source (on_this_computer, source, -1); + + personal_source = source; + } + + if (!on_ldap_servers) { + /* Create the LDAP source group */ + group = e_source_group_new (_("On LDAP Servers"), LDAP_BASE_URI); + e_source_list_add_group (source_list, group, -1); + + on_ldap_servers = group; + } + + g_free (base_uri_proto); + g_free (base_uri); +} + /* Evolution::Component CORBA methods. */ static void @@ -261,6 +346,8 @@ addressbook_component_init (AddressbookComponent *component) component->priv = priv; + ensure_sources (component); + #ifdef ENABLE_SMIME smime_component_init (); #endif diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index 7b69fb8c4f..980ae3bc77 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -1075,6 +1075,12 @@ addressbook_config_edit_source (GtkWidget *parent, ESource *source) gconf = gconf_client_get_default(); sdialog->source_list = e_source_list_new_for_gconf(gconf, "/apps/evolution/addressbook/sources"); l = e_source_list_peek_groups(sdialog->source_list); + if (!l) { + g_warning ("Addressbook source groups are missing! Check your GConf setup."); + g_free (sdialog); + return NULL; + } + sdialog->menu_source_groups = g_slist_copy(l); #ifndef HAVE_LDAP for (;l;l = g_slist_next(l)) |