aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/hula-account-setup
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/hula-account-setup')
-rw-r--r--plugins/hula-account-setup/camel-hula-listener.c176
-rw-r--r--plugins/hula-account-setup/camel-hula-listener.h8
-rw-r--r--plugins/hula-account-setup/hula-account-setup.c8
3 files changed, 96 insertions, 96 deletions
diff --git a/plugins/hula-account-setup/camel-hula-listener.c b/plugins/hula-account-setup/camel-hula-listener.c
index df28b7e34a..4dbcb44a94 100644
--- a/plugins/hula-account-setup/camel-hula-listener.c
+++ b/plugins/hula-account-setup/camel-hula-listener.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors :
- *
+ *
* Harish Krishnaswamy <kharish@novell.com>
*
* Copyright 2005, Novell, Inc.
@@ -38,7 +38,7 @@ static GList *hula_accounts = NULL;
struct _CamelHulaListenerPrivate {
GConfClient *gconf_client;
/* we get notification about mail account changes form this object */
- EAccountList *account_list;
+ EAccountList *account_list;
};
struct _HulaAccountInfo {
@@ -61,37 +61,37 @@ static void dispose (GObject *object);
static void finalize (GObject *object);
-static void
+static void
camel_hula_listener_class_init (CamelHulaListenerClass *class)
{
GObjectClass *object_class;
-
+
parent_class = g_type_class_ref (PARENT_TYPE);
object_class = G_OBJECT_CLASS (class);
-
+
/* virtual method override */
object_class->dispose = dispose;
object_class->finalize = finalize;
}
-static void
+static void
camel_hula_listener_init (CamelHulaListener *config_listener, CamelHulaListenerClass *class)
{
- config_listener->priv = g_new0 (CamelHulaListenerPrivate, 1);
+ config_listener->priv = g_new0 (CamelHulaListenerPrivate, 1);
}
-static void
+static void
dispose (GObject *object)
{
CamelHulaListener *config_listener = CAMEL_HULA_LISTENER (object);
-
+
g_object_unref (config_listener->priv->gconf_client);
g_object_unref (config_listener->priv->account_list);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-static void
+static void
finalize (GObject *object)
{
CamelHulaListener *config_listener = CAMEL_HULA_LISTENER (object);
@@ -103,18 +103,18 @@ finalize (GObject *object)
}
for ( list = g_list_first (hula_accounts); list ; list = g_list_next (list) ) {
-
+
info = (HulaAccountInfo *) (list->data);
if (info) {
-
+
g_free (info->uid);
g_free (info->name);
g_free (info->source_url);
g_free (info);
}
}
-
+
g_list_free (hula_accounts);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -144,13 +144,13 @@ is_hula_caldav_account (EAccount *account)
/* looks up for an existing hula account info in the hula_accounts list based on uid */
-static HulaAccountInfo*
+static HulaAccountInfo*
lookup_account_info (const char *key)
{
GList *list;
HulaAccountInfo *info ;
int found = 0;
-
+
if (!key)
return NULL;
@@ -183,11 +183,11 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
char *relative_uri;
const char *cal_port = "8081";
/* const char *use_ssl = ""; */
- /* offline_sync to come soon */
-
+ /* offline_sync to come soon */
+
/* TODO use_ssl = camel_url_get_param (url, "use_ssl"); */
- client = gconf_client_get_default();
+ client = gconf_client_get_default();
if (!client) {
g_message ("could not get a valid gconf client\n");
return;
@@ -198,7 +198,7 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
result = e_source_list_add_group (source_list, group, -1);
if (result == FALSE) {
- g_warning ("Could not add Hula source group!");
+ g_warning ("Could not add Hula source group!");
} else {
e_source_list_sync (source_list, NULL);
}
@@ -207,16 +207,16 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
relative_uri = g_strdup_printf ("%s@%s:%s/dav/%s/calendar/Personal", url->user, url->host, cal_port, url->user);
g_message ("Relative uri is %s\n", relative_uri);
-
+
source = e_source_new (source_name, relative_uri);
/* e_source_set_property (source, "port", camel_url_get_param (url,
- * "port"));
+ * "port"));
e_source_set_property (source, "auth-domain", "Hula");
e_source_set_property (source, "use_ssl", use_ssl); */
e_source_group_add_source (group, source, -1);
e_source_list_sync (source_list, NULL);
- if (!strcmp (conf_key, CALENDAR_SOURCES))
+ if (!strcmp (conf_key, CALENDAR_SOURCES))
source_selection_key = SELECTED_CALENDARS;
else source_selection_key = NULL;
if (source_selection_key) {
@@ -228,7 +228,7 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
g_free (temp->data);
g_slist_free (ids);
}
-
+
g_object_unref (source);
g_object_unref (group);
g_object_unref (source_list);
@@ -237,7 +237,7 @@ add_esource (const char *conf_key, const char *group_name, const char *source_n
}
-static void
+static void
remove_esource (const char *conf_key, const char *group_name, char* source_name, const char* relative_uri)
{
ESourceList *list;
@@ -247,20 +247,20 @@ remove_esource (const char *conf_key, const char *group_name, char* source_name,
GSList *ids;
GSList *node_tobe_deleted;
char *source_selection_key;
-
+
client = gconf_client_get_default();
list = e_source_list_new_for_gconf (client, conf_key);
- groups = e_source_list_peek_groups (list);
-
+ groups = e_source_list_peek_groups (list);
+
found_group = FALSE;
-
+
for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
ESourceGroup *group = E_SOURCE_GROUP (groups->data);
-
- if (strcmp (e_source_group_peek_name (group), group_name) == 0 &&
+
+ if (strcmp (e_source_group_peek_name (group), group_name) == 0 &&
strcmp (e_source_group_peek_base_uri (group), HULA_CALDAV_URI_PREFIX ) == 0) {
GSList *sources = e_source_group_peek_sources (group);
-
+
for( ; sources != NULL; sources = g_slist_next (sources)) {
ESource *source = E_SOURCE (sources->data);
const gchar *source_relative_uri;
@@ -269,43 +269,43 @@ remove_esource (const char *conf_key, const char *group_name, char* source_name,
if (source_relative_uri == NULL)
continue;
if (strcmp (source_relative_uri, relative_uri) == 0) {
-
- if (!strcmp (conf_key, CALENDAR_SOURCES))
+
+ if (!strcmp (conf_key, CALENDAR_SOURCES))
source_selection_key = SELECTED_CALENDARS;
else source_selection_key = NULL;
if (source_selection_key) {
- ids = gconf_client_get_list (client, source_selection_key ,
+ ids = gconf_client_get_list (client, source_selection_key ,
GCONF_VALUE_STRING, NULL);
node_tobe_deleted = g_slist_find_custom (ids, e_source_peek_uid (source), (GCompareFunc) strcmp);
if (node_tobe_deleted) {
g_free (node_tobe_deleted->data);
ids = g_slist_delete_link (ids, node_tobe_deleted);
}
- gconf_client_set_list (client, source_selection_key,
+ gconf_client_set_list (client, source_selection_key,
GCONF_VALUE_STRING, ids, NULL);
}
e_source_list_remove_group (list, group);
- e_source_list_sync (list, NULL);
+ e_source_list_sync (list, NULL);
found_group = TRUE;
break;
-
+
}
}
}
-
-
+
+
}
g_object_unref (list);
- g_object_unref (client);
-
+ g_object_unref (client);
+
}
/* looks for e-source with the same info as old_account_info and changes its values to the values passed in */
-static void
+static void
modify_esource (const char* conf_key, HulaAccountInfo *old_account_info, const char* new_group_name, CamelURL *new_url)
{
ESourceList *list;
@@ -314,7 +314,7 @@ modify_esource (const char* conf_key, HulaAccountInfo *old_account_info, const c
CamelURL *url;
gboolean found_group;
GConfClient* client;
-
+
url = camel_url_new (old_account_info->source_url, NULL);
if (!url->host || strlen (url->host) ==0)
return;
@@ -322,18 +322,18 @@ modify_esource (const char* conf_key, HulaAccountInfo *old_account_info, const c
old_relative_uri = g_strdup_printf ("%s@%s:%d/dav/%s/calendar/Personal", url->user, url->host, url->port, url->user);
client = gconf_client_get_default ();
list = e_source_list_new_for_gconf (client, conf_key);
- groups = e_source_list_peek_groups (list);
+ groups = e_source_list_peek_groups (list);
found_group = FALSE;
for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
ESourceGroup *group = E_SOURCE_GROUP (groups->data);
-
- if (strcmp (e_source_group_peek_name (group), old_account_info->name) == 0 &&
+
+ if (strcmp (e_source_group_peek_name (group), old_account_info->name) == 0 &&
strcmp (e_source_group_peek_base_uri (group), HULA_CALDAV_URI_PREFIX) == 0) {
GSList *sources = e_source_group_peek_sources (group);
-
+
for ( ; sources != NULL; sources = g_slist_next (sources)) {
ESource *source = E_SOURCE (sources->data);
const gchar *source_relative_uri;
@@ -364,28 +364,28 @@ modify_esource (const char* conf_key, HulaAccountInfo *old_account_info, const c
camel_url_free (url);
g_free (old_relative_uri);
-
+
}
/* add sources for calendar if the account added is HULA account
adds the new account info to HULA accounts list */
-static void
+static void
add_calendar_sources (HulaAccountInfo *info)
{
CamelURL *url;
-
+
url = camel_url_new (info->source_url, NULL);
add_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), url);
-
+
camel_url_free (url);
}
-/* removes calendar sources if the account removed is HULA account
+/* removes calendar sources if the account removed is HULA account
removes the the account info from HULA_account list */
-static void
+static void
remove_calendar_sources (HulaAccountInfo *info)
{
CamelURL *url;
@@ -395,7 +395,7 @@ remove_calendar_sources (HulaAccountInfo *info)
url = camel_url_new (info->source_url, NULL);
- address = url->host;
+ address = url->host;
if (!address || strlen (address) ==0)
return;
@@ -410,7 +410,7 @@ remove_calendar_sources (HulaAccountInfo *info)
}
-static void
+static void
account_added (EAccountList *account_listener, EAccount *account)
{
@@ -420,7 +420,7 @@ account_added (EAccountList *account_listener, EAccount *account)
if (!is_hula_account (account) || !is_hula_caldav_account (account))
return;
-
+
info = g_new0 (HulaAccountInfo, 1);
info->uid = g_strdup (account->uid);
info->name = g_strdup (account->name);
@@ -428,26 +428,26 @@ account_added (EAccountList *account_listener, EAccount *account)
if (account->parent_uid) {
parent = (EAccount *)e_account_list_find (account_listener, E_ACCOUNT_FIND_UID, account->parent_uid);
- if (!parent)
+ if (!parent)
return;
- parent_url = camel_url_new (e_account_get_string(parent, E_ACCOUNT_SOURCE_URL), NULL);
- } else
+ parent_url = camel_url_new (e_account_get_string(parent, E_ACCOUNT_SOURCE_URL), NULL);
+ } else
add_calendar_sources (info);
-
+
hula_accounts = g_list_append (hula_accounts, info);
}
-static void
+static void
account_removed (EAccountList *account_listener, EAccount *account)
{
HulaAccountInfo *info;
-
+
if (!is_hula_account (account) || !is_hula_caldav_account (account))
return;
-
+
info = lookup_account_info (account->uid);
- if (info == NULL)
+ if (info == NULL)
return;
remove_calendar_sources (info);
@@ -468,13 +468,13 @@ account_changed (EAccountList *account_listener, EAccount *account)
HulaAccountInfo *existing_account_info;
const char *old_use_ssl, *new_use_ssl;
const char *old_address, *new_address;
-
+
is_hula = is_hula_account (account);
if (is_hula == FALSE)
is_hula = is_hula_caldav_account (account);
-
+
existing_account_info = lookup_account_info (account->uid);
-
+
if (existing_account_info == NULL && is_hula) {
if (!account->enabled)
@@ -492,21 +492,21 @@ account_changed (EAccountList *account_listener, EAccount *account)
g_free (existing_account_info->name);
g_free (existing_account_info->source_url);
g_free (existing_account_info);
-
+
} else if ( existing_account_info != NULL && is_hula ) {
-
+
if (!account->enabled) {
account_removed (account_listener, account);
return;
}
-
+
/* some info of hula account is changed. update the sources with new info if required */
old_url = camel_url_new (existing_account_info->source_url, NULL);
- old_address = old_url->host;
+ old_address = old_url->host;
old_caldav_port = camel_url_get_param (old_url, "caldav_port");
old_use_ssl = camel_url_get_param (old_url, "use_ssl");
new_url = camel_url_new (account->source->url, NULL);
- new_address = new_url->host;
+ new_address = new_url->host;
if (!new_address || strlen (new_address) ==0)
return;
@@ -519,26 +519,26 @@ account_changed (EAccountList *account_listener, EAccount *account)
new_use_ssl = camel_url_get_param (new_url, "use_ssl");
if ((old_address && strcmp (old_address, new_address))
- || (old_caldav_port && strcmp (old_caldav_port, new_caldav_port))
- || strcmp (old_url->user, new_url->user)
+ || (old_caldav_port && strcmp (old_caldav_port, new_caldav_port))
+ || strcmp (old_url->user, new_url->user)
|| strcmp (old_use_ssl, new_use_ssl)) {
-
+
account_removed (account_listener, 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);
-
+
}
-
+
g_free (existing_account_info->name);
g_free (existing_account_info->source_url);
existing_account_info->name = g_strdup (account->name);
existing_account_info->source_url = g_strdup (account->source->url);
camel_url_free (old_url);
camel_url_free (new_url);
- }
-}
+ }
+}
static void
camel_hula_listener_construct (CamelHulaListener *config_listener)
@@ -546,27 +546,27 @@ camel_hula_listener_construct (CamelHulaListener *config_listener)
EIterator *iter;
EAccount *account;
HulaAccountInfo *info ;
-
+
config_listener->priv->account_list = e_account_list_new (config_listener->priv->gconf_client);
for ( iter = e_list_get_iterator (E_LIST ( config_listener->priv->account_list) ) ; e_iterator_is_valid (iter); e_iterator_next (iter) ) {
-
+
account = E_ACCOUNT (e_iterator_get (iter));
if ( is_hula_account (account) && account->enabled) {
-
+
info = g_new0 (HulaAccountInfo, 1);
info->uid = g_strdup (account->uid);
info->name = g_strdup (account->name);
info->source_url = g_strdup (account->source->url);
hula_accounts = g_list_append (hula_accounts, info);
-
+
}
-
+
}
g_signal_connect (config_listener->priv->account_list, "account_added", G_CALLBACK (account_added), NULL);
g_signal_connect (config_listener->priv->account_list, "account_changed", G_CALLBACK (account_changed), NULL);
- g_signal_connect (config_listener->priv->account_list, "account_removed", G_CALLBACK (account_removed), NULL);
+ g_signal_connect (config_listener->priv->account_list, "account_removed", G_CALLBACK (account_removed), NULL);
}
GType
@@ -595,10 +595,10 @@ CamelHulaListener*
camel_hula_listener_new (void)
{
CamelHulaListener *config_listener;
-
+
config_listener = g_object_new (CAMEL_TYPE_HULA_LISTENER, NULL);
config_listener->priv->gconf_client = gconf_client_get_default();
-
+
camel_hula_listener_construct (config_listener);
return config_listener;
diff --git a/plugins/hula-account-setup/camel-hula-listener.h b/plugins/hula-account-setup/camel-hula-listener.h
index 6bf5c900d1..5fc1d22fb9 100644
--- a/plugins/hula-account-setup/camel-hula-listener.h
+++ b/plugins/hula-account-setup/camel-hula-listener.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors :
- *
+ *
* Harish Krishnaswamy <kharish@novell.com>
*
* Copyright 2005, Novell, Inc.
@@ -28,7 +28,7 @@
#include<libedataserver/e-source.h>
#include<libedataserver/e-source-list.h>
#include <camel/camel-url.h>
-
+
G_BEGIN_DECLS
#define CAMEL_TYPE_HULA_LISTENER (camel_hula_listener_get_type ())
@@ -42,12 +42,12 @@ typedef struct _CamelHulaListenerClass CamelHulaListenerClass;
typedef struct _CamelHulaListenerPrivate CamelHulaListenerPrivate;
struct _CamelHulaListener {
GObject parent;
-
+
CamelHulaListenerPrivate *priv;
};
struct _CamelHulaListenerClass {
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
GType camel_hula_listener_get_type (void);
diff --git a/plugins/hula-account-setup/hula-account-setup.c b/plugins/hula-account-setup/hula-account-setup.c
index 45475690c6..79440bafc9 100644
--- a/plugins/hula-account-setup/hula-account-setup.c
+++ b/plugins/hula-account-setup/hula-account-setup.c
@@ -11,10 +11,10 @@
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -35,7 +35,7 @@ static CamelHulaListener *config_listener = NULL;
int e_plugin_lib_enable (EPluginLib *ep, int enable);
GtkWidget* org_gnome_evolution_hula_account_setup (struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data);
-static void
+static void
free_hula_listener ( void )
{
g_object_unref (config_listener);
@@ -45,7 +45,7 @@ int
e_plugin_lib_enable (EPluginLib *ep, int enable)
{
if (!config_listener) {
- config_listener = camel_hula_listener_new ();
+ config_listener = camel_hula_listener_new ();
g_atexit ( free_hula_listener );
}