diff options
author | Rodrigo Moya <rodrigo@novell.com> | 2004-10-07 22:20:55 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-10-07 22:20:55 +0800 |
commit | 0943a0e436c7510c39d86ab7a72a4ebbd3a876ac (patch) | |
tree | af35abd12315ef61b1e2835c8047207fcbfffa72 /calendar/common | |
parent | bb1c2d9bd3752a4628abc746e70b4488fc4940ca (diff) | |
download | gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar.gz gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar.bz2 gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar.lz gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar.xz gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.tar.zst gsoc2013-evolution-0943a0e436c7510c39d86ab7a72a4ebbd3a876ac.zip |
Fixes #65932
2004-10-06 Rodrigo Moya <rodrigo@novell.com>
Fixes #65932
* common/authentication.c: keep a hash table of all the source lists.
(auth_new_cal_from_uri): do a search in the source list for the given
URI, and use that ESource if we find it. Also, keep the hash table of
source lists up to date.
* gui/comp-editor-factory.c (cal_opened_cb): don't assert on error
cases, just display an error dialog.
svn path=/trunk/; revision=27498
Diffstat (limited to 'calendar/common')
-rw-r--r-- | calendar/common/authentication.c | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/calendar/common/authentication.c b/calendar/common/authentication.c index 2df97e3aca..4849169e56 100644 --- a/calendar/common/authentication.c +++ b/calendar/common/authentication.c @@ -30,6 +30,8 @@ #include "e-util/e-passwords.h" #include "authentication.h" +static GHashTable *source_lists_hash = NULL; + static char * auth_func_cb (ECal *ecal, const char *prompt, const char *key, gpointer user_data) { @@ -79,24 +81,63 @@ auth_new_cal_from_source (ESource *source, ECalSourceType type) ECal * auth_new_cal_from_uri (const char *uri, ECalSourceType type) { - ESourceGroup *group; - ESource *source; + ESourceGroup *group = NULL; + ESource *source = NULL; ECal *cal; + ESourceList *source_list = NULL; + + /* try to find the source in the source list in GConf */ + source_list = g_hash_table_lookup (source_lists_hash, &type); + if (!source_list) { + if (e_cal_get_sources (&source_list, type, NULL)) { + if (!source_lists_hash) + source_lists_hash = g_hash_table_new (g_int_hash, g_int_equal); + + g_hash_table_insert (source_lists_hash, &type, source_list); + } + } - group = e_source_group_new ("", uri); - source = e_source_new ("", ""); - e_source_set_group (source, group); + if (source_list) { + GSList *gl; + + for (gl = e_source_list_peek_groups (source_list); gl != NULL && source == NULL; gl = gl->next) { + GSList *sl; + + for (sl = e_source_group_peek_sources (gl->data); sl != NULL; sl = sl->next) { + char *source_uri; + + source_uri = e_source_get_uri (sl->data); + if (source_uri) { + if (!strcmp (source_uri, uri)) { + g_free (source_uri); + source = g_object_ref (sl->data); + break; + } + + g_free (source_uri); + } + } + } + } - /* we explicitly check for groupwise:// uris, to force authentication on them */ - if (!strncmp (uri, "groupwise://", strlen ("groupwise://"))) { - e_source_set_property (source, "auth", "yes"); - /* FIXME: need to retrieve the username */ + if (!source) { + group = e_source_group_new ("", uri); + source = e_source_new ("", ""); + e_source_set_group (source, group); + + /* we explicitly check for groupwise:// uris, to force authentication on them */ + if (!strncmp (uri, "groupwise://", strlen ("groupwise://"))) { + e_source_set_property (source, "auth", "1"); + e_source_set_property (source, "auth-domain", "Groupwise"); + /* FIXME: need to retrieve the username */ + } } cal = auth_new_cal_from_source (source, type); g_object_unref (source); - g_object_unref (group); + if (group) + g_object_unref (group); return cal; } |