aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-account-setup
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
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')
-rw-r--r--plugins/groupwise-account-setup/ChangeLog13
-rw-r--r--plugins/groupwise-account-setup/camel-gw-listener.c53
-rw-r--r--plugins/groupwise-account-setup/groupwise-account-setup.c88
-rw-r--r--plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml12
4 files changed, 151 insertions, 15 deletions
diff --git a/plugins/groupwise-account-setup/ChangeLog b/plugins/groupwise-account-setup/ChangeLog
index 817b28a694..6e158a510c 100644
--- a/plugins/groupwise-account-setup/ChangeLog
+++ b/plugins/groupwise-account-setup/ChangeLog
@@ -1,3 +1,16 @@
+2008-04-30 Chenthill Palanisamy <pchenthill@novell.com>
+
+ ** Fixes #358644 (bnc)
+ Retracted groupwise appointments should disappear as soon as they are
+ retracted.
+
+ * camel-gw-listener.c: (add_esource), (modify_esource),
+ (add_calendar_tasks_sources), (add_proxy_sources), (account_added),
+ (account_changed):
+ * groupwise-account-setup.c: (is_groupwise_account),
+ (set_esource_props), (ensure_mandatory_esource_properties):
+ * org-gnome-gw-account-setup.eplug.xml:
+
2007-10-26 Kjartan Maraas <kmaraas@gnome.org>
* camel-gw-listener.c: (camel_gw_listener_new):
diff --git a/plugins/groupwise-account-setup/camel-gw-listener.c b/plugins/groupwise-account-setup/camel-gw-listener.c
index 8b3d8c85bd..66df661457 100644
--- a/plugins/groupwise-account-setup/camel-gw-listener.c
+++ b/plugins/groupwise-account-setup/camel-gw-listener.c
@@ -49,6 +49,8 @@ struct _GwAccountInfo {
char *uid;
char *name;
char *source_url;
+ gboolean auto_check;
+ guint auto_check_time;
};
typedef struct _GwAccountInfo GwAccountInfo;
@@ -168,7 +170,7 @@ lookup_account_info (const char *key)
#define SELECTED_NOTES "/apps/evolution/calendar/memos/selected_memos"
static void
-add_esource (const char *conf_key, const char *group_name, const char *source_name, CamelURL *url, const char* parent_id_name, gboolean can_create)
+add_esource (const char *conf_key, GwAccountInfo *info, const char *source_name, CamelURL *url, const char* parent_id_name, gboolean can_create)
{
ESourceList *source_list;
ESourceGroup *group;
@@ -181,11 +183,14 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
const char * use_ssl;
const char *poa_address;
const char *offline_sync;
+ const char *group_name;
poa_address = url->host;
if (!poa_address || strlen (poa_address) ==0)
return;
+ group_name = info->name;
+
soap_port = camel_url_get_param (url, "soap_port");
if (!soap_port || strlen (soap_port) == 0)
@@ -206,6 +211,7 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
if (!can_create)
e_source_group_set_property (group, "create_source", "no");
+
relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address);
source = e_source_new (source_name, relative_uri);
e_source_set_property (source, "auth", "1");
@@ -213,6 +219,15 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
e_source_set_property (source, "port", camel_url_get_param (url, "soap_port"));
e_source_set_property (source, "auth-domain", "Groupwise");
e_source_set_property (source, "use_ssl", use_ssl);
+
+ if (info->auto_check) {
+ char *str = g_strdup_printf ("%d", info->auto_check_time);
+
+ e_source_set_property (source, "refresh", str);
+ g_free (str);
+ } else
+ e_source_set_property (source, "refresh", NULL);
+
e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" );
e_source_set_property (source, "delete", "no");
if (parent_id_name) {
@@ -324,7 +339,7 @@ remove_esource (const char *conf_key, const char *group_name, char* source_name,
/* looks up for e-source with having same info as old_account_info and changes its values passed in new values */
static void
-modify_esource (const char* conf_key, GwAccountInfo *old_account_info, const char* new_group_name, CamelURL *new_url)
+modify_esource (const char* conf_key, GwAccountInfo *old_account_info, EAccount *a, CamelURL *new_url)
{
ESourceList *list;
GSList *groups;
@@ -334,7 +349,8 @@ modify_esource (const char* conf_key, GwAccountInfo *old_account_info, const cha
GConfClient* client;
const char *poa_address;
const char *new_poa_address;
-
+ const char* new_group_name = a->name;
+
url = camel_url_new (old_account_info->source_url, NULL);
poa_address = url->host;
if (!poa_address || strlen (poa_address) ==0)
@@ -372,6 +388,15 @@ modify_esource (const char* conf_key, GwAccountInfo *old_account_info, const cha
e_source_set_property (source, "port", camel_url_get_param (new_url,"soap_port"));
e_source_set_property (source, "use_ssl", camel_url_get_param (url, "use_ssl"));
e_source_set_property (source, "offline_sync", camel_url_get_param (url, "offline_sync") ? "1" : "0");
+
+ 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);
+
e_source_list_sync (list, NULL);
found_group = TRUE;
g_free (new_relative_uri);
@@ -397,10 +422,10 @@ add_calendar_tasks_sources (GwAccountInfo *info)
CamelURL *url;
url = camel_url_new (info->source_url, NULL);
- add_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), url, NULL, FALSE);
- add_esource ("/apps/evolution/tasks/sources", info->name, _("Tasks"), url, NULL, FALSE);
- add_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), url, NULL, TRUE);
-
+ add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, NULL, FALSE);
+ add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, NULL, FALSE);
+ add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, NULL, TRUE);
+
camel_url_free (url);
@@ -541,9 +566,9 @@ add_proxy_sources (GwAccountInfo *info, const char *parent_name)
camel_url_set_param (url, "color", color);
- add_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), url, parent_name, FALSE);
- add_esource ("/apps/evolution/tasks/sources", info->name, _("Tasks"), url, parent_name, FALSE);
- add_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), url, parent_name, TRUE);
+ add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, parent_name, FALSE);
+ add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, parent_name, FALSE);
+ add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, parent_name, TRUE);
g_free (color);
camel_url_free (url);
@@ -793,6 +818,8 @@ account_added (EAccountList *account_listener, EAccount *account)
info->uid = g_strdup (account->uid);
info->name = g_strdup (account->name);
info->source_url = g_strdup (account->source->url);
+ info->auto_check = account->source->auto_check;
+ info->auto_check_time = account->source->auto_check_time;
if (account->parent_uid) {
parent = (EAccount *)e_account_list_find (account_listener, E_ACCOUNT_FIND_UID, account->parent_uid);
@@ -900,9 +927,9 @@ account_changed (EAccountList *account_listener, EAccount *account)
account_added (account_listener, account);
} else if (strcmp (existing_account_info->name, account->name)) {
- modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account->name, new_url);
- modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account->name, new_url);
- modify_esource ("/apps/evolution/memos/sources", existing_account_info, account->name, new_url);
+ modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account, new_url);
+ modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account, new_url);
+ modify_esource ("/apps/evolution/memos/sources", existing_account_info, account, new_url);
modify_addressbook_sources (account, existing_account_info);
}
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 )
diff --git a/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml b/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml
index 4555957ba9..dd7886348c 100644
--- a/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml
+++ b/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml
@@ -20,7 +20,15 @@
<group target="account" id="org.gnome.evolution.mail.config.accountWizard">
<item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
</group>
- </hook>
-
+ </hook>
+
+ <hook class="org.gnome.evolution.shell.events:1.0">
+ <event
+ id="upgrade.done"
+ handle="ensure_mandatory_esource_properties"
+ target="upgrade"
+ />
+ </hook>
+
</e-plugin>
</e-plugin-list>