aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-account-setup/groupwise-account-setup.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchenthill@novell.com>2008-04-30 16:25:32 +0800
committerBharath Acharya <abharath@src.gnome.org>2008-04-30 16:25:32 +0800
commit4ca16039ae0e04a218ff979c499ecd7cf0a0ae46 (patch)
tree71a42ff1193d4d7b0fea34d08e972b9b200da05d /plugins/groupwise-account-setup/groupwise-account-setup.c
parent9598151a10dd3bff1d658dfd8b20bb8cb2dba847 (diff)
downloadgsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar.gz
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar.bz2
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar.lz
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar.xz
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.tar.zst
gsoc2013-evolution-4ca16039ae0e04a218ff979c499ecd7cf0a0ae46.zip
Committing on behalf of Chenthill Palanisamy <pchenthill@novell.com>
2008-04-30 Chenthill Palanisamy <pchenthill@novell.com> ** Fixes #358644 (bnc) Retracted groupwise appointments should disappear as soon as they are retracted. svn path=/trunk/; revision=35449
Diffstat (limited to 'plugins/groupwise-account-setup/groupwise-account-setup.c')
-rw-r--r--plugins/groupwise-account-setup/groupwise-account-setup.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugins/groupwise-account-setup/groupwise-account-setup.c b/plugins/groupwise-account-setup/groupwise-account-setup.c
index ccdf1f4305..13a6f46d0f 100644
--- a/plugins/groupwise-account-setup/groupwise-account-setup.c
+++ b/plugins/groupwise-account-setup/groupwise-account-setup.c
@@ -28,11 +28,99 @@
#include "camel-gw-listener.h"
#include <gtk/gtk.h>
#include "mail/em-config.h"
+#include <gconf/gconf-client.h>
+#include "shell/es-event.h"
+#include <string.h>
+
+#define GROUPWISE_BASE_URI "groupwise://"
static CamelGwListener *config_listener = NULL;
int e_plugin_lib_enable (EPluginLib *ep, int enable);
GtkWidget* org_gnome_gw_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data);
+void ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target);
+
+static gboolean
+is_groupwise_account (EAccount *account)
+{
+ if (account->source->url != NULL) {
+ return g_str_has_prefix (account->source->url, GROUPWISE_BASE_URI);
+ } else {
+ return FALSE;
+ }
+}
+
+static void
+set_esource_props (const char *path, EAccount *a, GConfClient *client, const char *name)
+{
+ ESourceList *list;
+ GSList *groups;
+ char *old_relative_uri;
+ const char *poa_address;
+ CamelURL *url = camel_url_new (a->source->url, NULL);
+
+ old_relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address);
+ list = e_source_list_new_for_gconf (client, path);
+ groups = e_source_list_peek_groups (list);
+ poa_address = url->host;
+
+ if (!poa_address || !*poa_address)
+ return;
+
+ for ( ; groups != NULL; groups = g_slist_next (groups)) {
+ ESourceGroup *group = E_SOURCE_GROUP (groups->data);
+
+ if (strcmp (e_source_group_peek_name (group), name) == 0 &&
+ strcmp (e_source_group_peek_base_uri (group), GROUPWISE_BASE_URI) == 0) {
+ GSList *sources = e_source_group_peek_sources (group);
+
+ for ( ; sources != NULL; sources = g_slist_next (sources)) {
+ ESource *source = E_SOURCE (sources->data);
+
+ if (a->source->auto_check) {
+ char *str = g_strdup_printf ("%d",a->source->auto_check_time);
+
+ e_source_set_property (source, "refresh", str);
+ g_free (str);
+ } else
+ e_source_set_property (source, "refresh", NULL);
+ break;
+ }
+ }
+ }
+ e_source_list_sync (list, NULL);
+
+ g_object_unref (list);
+ g_free (old_relative_uri);
+ camel_url_free (url);
+
+}
+
+void
+ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target)
+{
+ GConfClient* client;
+ EAccountList *al;
+ EIterator *it;
+
+ client = gconf_client_get_default();
+ al = e_account_list_new (client);
+
+ for (it = e_list_get_iterator((EList *)al);
+ e_iterator_is_valid(it);
+ e_iterator_next(it)) {
+ EAccount *a;
+
+ a = (EAccount *) e_iterator_get(it);
+ if (!a->enabled || !is_groupwise_account (a))
+ continue;
+ set_esource_props ("/apps/evolution/calendar/sources", a, client, a->name);
+ set_esource_props ("/apps/evolution/tasks/sources", a, client, a->name);
+ set_esource_props ("/apps/evolution/memos/sources", a, client, a->name);
+ }
+ g_object_unref (al);
+ g_object_unref (client);
+}
static void
free_groupwise_listener ( void )