aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-02-04 21:52:28 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-06-03 11:00:41 +0800
commitc030e2f0a57ee68c5a512df0cd0cea06346a50bc (patch)
treeb3c3709228af8179c10f0183a72f79a6930f37a0 /plugins
parent1ad9dfdc9fcbb5e675210dd0de1de3b599d90bbf (diff)
downloadgsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar.gz
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar.bz2
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar.lz
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar.xz
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.tar.zst
gsoc2013-evolution-c030e2f0a57ee68c5a512df0cd0cea06346a50bc.zip
Add 'cal-config-google' module.
Registers the "Google" backend in ECalSourceConfig widgets. Replaces the 'google-account-setup' plugin.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/google-account-setup/Makefile.am37
-rw-r--r--plugins/google-account-setup/google-contacts-source.c425
-rw-r--r--plugins/google-account-setup/google-contacts-source.h37
-rw-r--r--plugins/google-account-setup/google-source.c749
-rw-r--r--plugins/google-account-setup/org-gnome-evolution-google.eplug.xml24
5 files changed, 0 insertions, 1272 deletions
diff --git a/plugins/google-account-setup/Makefile.am b/plugins/google-account-setup/Makefile.am
deleted file mode 100644
index 9842673302..0000000000
--- a/plugins/google-account-setup/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-@EVO_PLUGIN_RULE@
-
-plugin_DATA = org-gnome-evolution-google.eplug
-
-plugin_LTLIBRARIES = liborg-gnome-evolution-google.la
-
-liborg_gnome_evolution_google_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I . \
- -I$(top_srcdir) \
- -I$(top_srcdir)/widgets \
- -DCALDAV_UIDIR=\""$(uidir)"\" \
- $(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GDATA_CFLAGS)
-
-liborg_gnome_evolution_google_la_SOURCES = \
- google-source.c \
- google-contacts-source.h \
- google-contacts-source.c
-
-liborg_gnome_evolution_google_la_LIBADD = \
- $(top_builddir)/calendar/gui/libevolution-calendar.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/shell/libeshell.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GDATA_LIBS)
-
-liborg_gnome_evolution_google_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
-
-EXTRA_DIST = \
- org-gnome-evolution-google.eplug.xml
-
-CLEANFILES = org-gnome-evolution-google.eplug
-
--include $(top_srcdir)/git.mk
diff --git a/plugins/google-account-setup/google-contacts-source.c b/plugins/google-account-setup/google-contacts-source.c
deleted file mode 100644
index 9345deba57..0000000000
--- a/plugins/google-account-setup/google-contacts-source.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- * Copyright 2008, Joergen Scheibengruber <joergen.scheibengruber@googlemail.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <gtk/gtk.h>
-
-#include <e-util/e-config.h>
-#include <e-util/e-plugin.h>
-#include <shell/e-shell.h>
-#include <addressbook/gui/widgets/eab-config.h>
-
-#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-url.h>
-#include <libedataserver/e-account-list.h>
-
-#include "google-contacts-source.h"
-
-void
-ensure_google_contacts_source_group (void)
-{
- EShellBackend *backend;
- ESourceList *source_list = NULL;
-
- backend = e_shell_get_backend_by_name (e_shell_get_default (), "contacts");
- g_return_if_fail (backend != NULL);
-
- g_object_get (G_OBJECT (backend), "source-list", &source_list, NULL);
- g_return_if_fail (source_list != NULL);
-
- e_source_list_ensure_group (source_list, _("Google"), "google://", FALSE);
- g_object_unref (source_list);
-}
-
-void
-remove_google_contacts_source_group (void)
-{
- ESourceList *source_list;
- ESourceGroup *group;
- const gchar *key;
-
- key = "/apps/evolution/addressbook/sources";
- source_list = e_source_list_new_for_gconf_default (key);
-
- if (source_list == NULL)
- return;
-
- group = e_source_list_peek_group_by_base_uri (source_list, "google://");
-
- if (group) {
- GSList *sources;
-
- sources = e_source_group_peek_sources (group);
-
- if (NULL == sources) {
- e_source_list_remove_group (source_list, group);
- e_source_list_sync (source_list, NULL);
- }
- }
- g_object_unref (source_list);
-}
-
-static void
-on_username_entry_changed (GtkEntry *entry,
- gpointer user_data)
-{
- ESource *source = user_data;
- const gchar *text;
- gchar *username;
-
- text = gtk_entry_get_text (entry);
-
- if (!text || !*text) {
- username = NULL;
- } else if (strstr (text, "@")) {
- username = g_strdup (text);
- } else {
- username = g_strdup_printf ("%s@gmail.com", text);
- }
-
- e_source_set_relative_uri (source, username);
- e_source_set_property (source, "username", username);
- e_source_set_property (source, "auth", "plain/password");
- g_free (username);
-}
-
-static void
-on_ssl_cb_toggled (GtkToggleButton *tb,
- gpointer user_data)
-{
- ESource *source = user_data;
-
- if (gtk_toggle_button_get_active (tb)) {
- e_source_set_property (source, "use-ssl", "true");
- } else {
- e_source_set_property (source, "use-ssl", "false");
- }
-}
-
-typedef enum {
- MINUTES,
- HOURS,
- DAYS,
- WEEKS
-} IntervalType;
-
-static void
-seconds_to_interval (guint seconds,
- IntervalType *type,
- gint *time)
-{
- gint minutes = seconds / 60;
-
- *type = MINUTES;
- *time = minutes;
- if (minutes && !(minutes % 10080)) {
- *type = WEEKS;
- *time = minutes / 10080;
- } else if (minutes && !(minutes % 1440)) {
- *type = DAYS;
- *time = minutes / 1440;
- } else if (minutes && !(minutes % 60)) {
- *type = HOURS;
- *time = minutes / 60;
- }
-}
-
-static guint
-interval_to_seconds (IntervalType type,
- gint time)
-{
- switch (type) {
- case MINUTES:
- return time * 60;
- case HOURS:
- return time * 60 * 60;
- case DAYS:
- return time * 60 * 60 * 24;
- case WEEKS:
- return time * 60 * 60 * 24 * 7;
- default:
- g_warning ("Time unit out of range");
- break;
- }
- return 0;
-}
-
-static void
-on_interval_sb_value_changed (GtkSpinButton *sb,
- gpointer user_data)
-{
- ESource *source = user_data;
- gdouble time;
- guint seconds;
- gchar *value_string;
- GtkWidget *interval_combo;
- IntervalType type;
-
- interval_combo = g_object_get_data (G_OBJECT (sb), "interval-combo");
- type = gtk_combo_box_get_active (GTK_COMBO_BOX (interval_combo));
-
- time = gtk_spin_button_get_value (sb);
-
- seconds = interval_to_seconds (type, time);
-
- value_string = g_strdup_printf ("%u", seconds);
- e_source_set_property (source, "refresh-interval", value_string);
- g_free (value_string);
-}
-
-static void
-on_interval_combo_changed (GtkComboBox *combo,
- gpointer user_data)
-{
- ESource *source = user_data;
- gdouble time;
- guint seconds;
- gchar *value_string;
- GtkWidget *sb;
- IntervalType type;
-
- sb = g_object_get_data (G_OBJECT (combo), "interval-sb");
- type = gtk_combo_box_get_active (combo);
-
- time = gtk_spin_button_get_value (GTK_SPIN_BUTTON (sb));
-
- seconds = interval_to_seconds (type, time);
-
- value_string = g_strdup_printf ("%u", seconds);
- e_source_set_property (source, "refresh-interval", value_string);
- g_free (value_string);
-}
-
-gpointer
-check_username_filled (ESource *source)
-{
- gboolean res = TRUE;
-
- g_return_val_if_fail (source != NULL, NULL);
-
- if (g_ascii_strncasecmp (
- GOOGLE_BASE_URI, e_source_group_peek_base_uri (
- e_source_peek_group (source)), strlen (GOOGLE_BASE_URI)) == 0) {
- gchar *username;
-
- username = g_strdup (e_source_get_property (source, "username"));
-
- if (username)
- username = g_strstrip (username);
-
- res = username && *username;
-
- g_free (username);
- }
-
- return GINT_TO_POINTER (res ? 1 : 0);
-}
-
-gpointer
-plugin_google_contacts_check (EPlugin *epl,
- EConfigHookPageCheckData *data)
-{
- EABConfigTargetSource *t;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (data->target != NULL, NULL);
-
- t = (EABConfigTargetSource *) data->target;
- g_return_val_if_fail (t->source != NULL, NULL);
-
- return check_username_filled (t->source);
-}
-
-struct ui_data {
- GtkWidget *widget;
-};
-
-static void
-destroy_ui_data (gpointer data)
-{
- struct ui_data *ui = data;
-
- if (ui && ui->widget)
- gtk_widget_destroy (ui->widget);
-
- g_free (ui);
-}
-
-GtkWidget *
-plugin_google_contacts (EPlugin *epl,
- EConfigHookItemFactoryData *data)
-{
- EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
- ESource *source;
- ESourceGroup *group;
- const gchar *base_uri;
- const gchar *username;
- const gchar *refresh_interval_str;
- guint refresh_interval;
- const gchar *use_ssl_str;
- gchar *buff;
- gboolean use_ssl;
- GtkWidget *parent;
- GtkWidget *vbox;
-
- GtkWidget *section;
- GtkWidget *vbox2;
-
- GtkWidget *hbox;
- GtkWidget *spacer;
- GtkWidget *label;
- GtkWidget *username_entry;
-
- GtkWidget *interval_sb;
- GtkWidget *interval_combo;
- IntervalType type;
- gint time;
-
- GtkWidget *ssl_cb;
- struct ui_data *ui;
-
- source = t->source;
- group = e_source_peek_group (source);
-
- base_uri = e_source_group_peek_base_uri (group);
-
- g_object_set_data (G_OBJECT (epl), "gwidget", NULL);
-
- if (g_ascii_strncasecmp (GOOGLE_BASE_URI, base_uri, 9) != 0)
- return NULL;
-
- /* Build up the UI */
- parent = data->parent;
- vbox = gtk_widget_get_ancestor (
- gtk_widget_get_parent (parent), GTK_TYPE_VBOX);
-
- vbox2 = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
-
- section = gtk_label_new (NULL);
- buff = g_strconcat ("<b>", _("Server"), "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (section), buff);
- g_free (buff);
- gtk_misc_set_alignment (GTK_MISC (section), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox2), section, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 10);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
-
- spacer = gtk_label_new (" ");
- gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-
- label = gtk_label_new_with_mnemonic (_("User_name:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- username_entry = gtk_entry_new ();
- username = e_source_get_property (source, "username");
- if (username)
- gtk_entry_set_text (GTK_ENTRY (username_entry), username);
- gtk_box_pack_start (GTK_BOX (hbox), username_entry, TRUE, TRUE, 0);
-
- hbox = gtk_hbox_new (FALSE, 10);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
-
- spacer = gtk_label_new (" ");
- gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-
- use_ssl_str = e_source_get_property (source, "use-ssl");
- if (use_ssl_str && ('1' == use_ssl_str[0] ||
- 0 == g_ascii_strcasecmp (use_ssl_str, "true"))) {
- use_ssl = 1;
- } else {
- use_ssl = 0;
- }
- ssl_cb = gtk_check_button_new_with_mnemonic (_("Use _secure connection"));
- gtk_box_pack_start (GTK_BOX (hbox), ssl_cb, FALSE, FALSE, 0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ssl_cb), use_ssl);
-
- hbox = gtk_hbox_new (FALSE, 10);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
-
- spacer = gtk_label_new (" ");
- gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
-
- refresh_interval_str = e_source_get_property (source, "refresh-interval");
- if (refresh_interval_str &&
- (1 == sscanf (refresh_interval_str, "%u", &refresh_interval))) {
- } else {
- refresh_interval = -1;
- }
- seconds_to_interval (refresh_interval, &type, &time);
-
- label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- interval_sb = gtk_spin_button_new_with_range (1, 100, 1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (interval_sb), time);
- gtk_box_pack_start (GTK_BOX (hbox), interval_sb, FALSE, FALSE, 0);
-
- interval_combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (interval_combo), _("minutes"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (interval_combo), _("hours"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (interval_combo), _("days"));
- gtk_combo_box_text_append_text (
- GTK_COMBO_BOX_TEXT (interval_combo), _("weeks"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (interval_combo), type);
- gtk_box_pack_start (GTK_BOX (hbox), interval_combo, FALSE, FALSE, 0);
-
- gtk_widget_show_all (vbox2);
-
- g_object_set_data (
- G_OBJECT (interval_sb), "interval-combo", interval_combo);
- g_object_set_data (
- G_OBJECT (interval_combo), "interval-sb", interval_sb);
-
- ui = g_malloc0 (sizeof (struct ui_data));
- ui->widget = vbox2;
- g_object_set_data_full(G_OBJECT(epl), "gwidget", ui, destroy_ui_data);
- g_signal_connect (
- ui->widget, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &ui->widget);
-
- g_signal_connect (
- username_entry, "changed",
- G_CALLBACK (on_username_entry_changed), source);
- g_signal_connect (
- interval_combo, "changed",
- G_CALLBACK (on_interval_combo_changed), source);
- g_signal_connect (
- ssl_cb, "toggled",
- G_CALLBACK (on_ssl_cb_toggled), source);
- g_signal_connect (
- interval_sb, "value-changed",
- G_CALLBACK (on_interval_sb_value_changed), source);
-
- return NULL;
-}
-
diff --git a/plugins/google-account-setup/google-contacts-source.h b/plugins/google-account-setup/google-contacts-source.h
deleted file mode 100644
index 97130c1651..0000000000
--- a/plugins/google-account-setup/google-contacts-source.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- * Copyright 2008, Joergen Scheibengruber <joergen.scheibengruber@googlemail.com>
- *
- */
-
-#ifndef __GOOGLE_CONTACTS_SOURCE_H__
-#define __GOOGLE_CONTACTS_SOURCE_H__
-
-#define GOOGLE_BASE_URI "google://"
-
-GtkWidget *plugin_google_contacts (EPlugin *epl,
- EConfigHookItemFactoryData *data);
-
-gpointer plugin_google_contacts_check (EPlugin *epl, EConfigHookPageCheckData *data);
-
-gpointer check_username_filled (ESource *source);
-
-void ensure_google_contacts_source_group (void);
-
-void remove_google_contacts_source_group (void);
-
-#endif
diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c
deleted file mode 100644
index b6dde02bd5..0000000000
--- a/plugins/google-account-setup/google-source.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ebby Wiselyn <ebbywiselyn@gmail.com>
- * Philip Withnall <philip@tecnocode.co.uk>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <gtk/gtk.h>
-
-#include <e-util/e-config.h>
-#include <e-util/e-plugin.h>
-#include <e-util/e-plugin-util.h>
-#include <shell/e-shell.h>
-
-#include <calendar/gui/e-cal-config.h>
-#include <calendar/gui/e-cal-event.h>
-
-#include <libedataserver/e-url.h>
-#include <libedataserver/e-account-list.h>
-#include <libedataserver/e-proxy.h>
-#include <libecal/e-cal-client.h>
-#include <libedataserverui/e-cell-renderer-color.h>
-#include <libedataserverui/e-passwords.h>
-
-#include <gdata/gdata.h>
-
-#include "google-contacts-source.h"
-
-#define CALENDAR_LOCATION "://www.google.com/calendar/feeds/"
-#define CALENDAR_DEFAULT_PATH "/private/full"
-#define URL_GET_SUBSCRIBED_CALENDARS "://www.google.com/calendar/feeds/default/allcalendars/full"
-#define CALENDAR_CALDAV_URI "caldav://%s@www.google.com/calendar/dav/%s/events"
-
-#define d(x)
-
-/*****************************************************************************/
-/* prototypes */
-gint e_plugin_lib_enable (EPlugin *ep, gint enable);
-GtkWidget *plugin_google (EPlugin *epl, EConfigHookItemFactoryData *data);
-gpointer plugin_google_check (EPlugin *epl, EConfigHookPageCheckData *data);
-void e_calendar_google_migrate (EPlugin *epl, ECalEventTargetBackend *data);
-
-/*****************************************************************************/
-/* plugin intialization */
-
-static void
-ensure_google_source_group (void)
-{
- EShellBackend *backend;
- ESourceList *source_list = NULL;
-
- backend = e_shell_get_backend_by_name (e_shell_get_default (), "calendar");
- g_return_if_fail (backend != NULL);
-
- g_object_get (G_OBJECT (backend), "source-list", &source_list, NULL);
- g_return_if_fail (source_list != NULL);
-
- e_source_list_ensure_group (source_list, _("Google"), GOOGLE_BASE_URI, FALSE);
- g_object_unref (source_list);
-}
-
-gint
-e_plugin_lib_enable (EPlugin *ep,
- gint enable)
-{
- if (enable) {
- d(printf ("\n Google Eplugin starting up ...\n"));
- ensure_google_source_group ();
- ensure_google_contacts_source_group ();
- } else {
- remove_google_contacts_source_group ();
- }
-
- return 0;
-}
-
-/********************************************************************************************************************/
-
-static gchar *
-decode_at_back (const gchar *user)
-{
- gchar *res, *at;
-
- g_return_val_if_fail (user != NULL, NULL);
-
- res = g_strdup (user);
- while (at = strstr (res, "%40"), at != NULL) {
- *at = '@';
- memmove (at + 1, at + 3, strlen (at + 3) + 1);
- }
-
- return res;
-}
-
-static gboolean
-is_email (const gchar *address)
-{
- /* This is supposed to check if the address's domain could be
- * an FQDN but alas, it's not worth the pain and suffering. */
- const gchar *at;
-
- at = strchr (address, '@');
- /* make sure we have an '@' and that it's not the first or last gchar */
- if (!at || at == address || *(at + 1) == '\0')
- return FALSE;
-
- return TRUE;
-}
-
-static gchar *
-sanitize_user_mail (const gchar *user)
-{
- if (!user)
- return NULL;
-
- if (strstr (user, "%40") != NULL) {
- return g_strdup (user);
- } else if (!is_email (user)) {
- return g_strconcat (user, "%40gmail.com", NULL);
- } else {
- gchar *tmp = g_malloc0 (sizeof (gchar) * (1 + strlen (user) + 2));
- gchar *at = strchr (user, '@');
-
- strncpy (tmp, user, at - user);
- strcat (tmp, "%40");
- strcat (tmp, at + 1);
-
- return tmp;
- }
-}
-
-static gchar *
-construct_default_uri (const gchar *username,
- gboolean is_ssl)
-{
- gchar *user, *uri;
-
- user = sanitize_user_mail (username);
- uri = g_strconcat (is_ssl ? "https" : "http", CALENDAR_LOCATION, user, CALENDAR_DEFAULT_PATH, NULL);
- g_free (user);
-
- return uri;
-}
-
-/* checks whether the given_uri is pointing to the default user's calendar or not */
-static gboolean
-is_default_uri (const gchar *given_uri,
- const gchar *username)
-{
- gchar *uri, *at;
- gint ats, i;
- gboolean res = FALSE;
-
- if (!given_uri)
- return TRUE;
-
- for (i = 0; !res && i < 2; i++) {
- /* try both versions here, with and without ssl */
- uri = construct_default_uri (username, i == 0);
-
- /* count number of '@' in given_uri to know how much memory will be required */
- ats = 0;
- for (at = strchr (given_uri, '@'); at; at = strchr (at + 1, '@')) {
- ats++;
- }
-
- if (!ats)
- res = g_ascii_strcasecmp (given_uri, uri) == 0;
- else {
- const gchar *last;
- gchar *tmp = g_malloc0 (sizeof (gchar) * (1 + strlen (given_uri) + (2 * ats)));
-
- last = given_uri;
- for (at = strchr (last, '@'); at; at = strchr (at + 1, '@')) {
- strncat (tmp, last, at - last);
- strcat (tmp, "%40");
- last = at + 1;
- }
- strcat (tmp, last);
-
- res = g_ascii_strcasecmp (tmp, uri) == 0;
-
- g_free (tmp);
- }
-
- g_free (uri);
- }
-
- return res;
-}
-
-static void
-update_source_uris (ESource *source,
- const gchar *uri)
-{
- gchar *abs_uri, *tmp, *user_sanitized, *slash;
- const gchar *user, *feeds;
-
- g_return_if_fail (source != NULL);
- g_return_if_fail (uri != NULL);
-
- /* this also changes an absolute uri */
- e_source_set_relative_uri (source, uri);
-
- user = e_source_get_property (source, "username");
- if (!user)
- return;
-
- feeds = strstr (uri, "/feeds/");
- g_return_if_fail (feeds != NULL);
- feeds += 7;
-
- user_sanitized = sanitize_user_mail (user);
- /* no "%40" in the URL path for caldav, really */
- tmp = decode_at_back (feeds);
-
- slash = strchr (tmp, '/');
- if (slash)
- *slash = '\0';
-
- abs_uri = g_strdup_printf (CALENDAR_CALDAV_URI, user_sanitized, tmp);
- e_source_set_absolute_uri (source, abs_uri);
-
- g_free (abs_uri);
- g_free (tmp);
- g_free (user_sanitized);
-}
-
-static void init_combo_values (GtkComboBox *combo, const gchar *deftitle, const gchar *defuri);
-
-static void
-update_user_in_source (ESource *source,
- const gchar *new_user)
-{
- gchar *uri, *eml, *user;
- const gchar *ssl;
-
- /* to ensure it will not be freed before the work with it is done */
- user = g_strdup (new_user);
-
- /* two reasons why set readonly to FALSE:
- * a) the e_source_set_relative_uri does nothing for readonly sources
- * b) we are going to set default uri, which should be always writeable */
- e_source_set_readonly (source, FALSE);
-
- if (user && *user) {
- /* store the non-encoded email in the "username" property */
- if (strstr (user, "@") == NULL && strstr (user, "%40") == NULL)
- eml = g_strconcat (user, "@gmail.com", NULL);
- else
- eml = decode_at_back (user);
- } else {
- eml = NULL;
- }
-
- /* set username first, as it's used in update_source_uris */
- e_source_set_property (source, "username", eml);
-
- ssl = e_source_get_property (source, "ssl");
- uri = construct_default_uri (user, !ssl || g_str_equal (ssl, "1"));
- update_source_uris (source, uri);
- g_free (uri);
-
- /* "setup-username" is used to this plugin only, to keep what user wrote,
- * not what uses the backend */
- e_source_set_property (source, "setup-username", user);
- e_source_set_property (source, "auth", (user && *user) ? "1" : NULL);
- e_source_set_property (source, "googlename", NULL);
-
- /* delete obsolete properties */
- e_source_set_property (source, "protocol", NULL);
- e_source_set_property (source, "auth-domain", NULL);
-
- g_free (eml);
- g_free (user);
-}
-
-static void
-user_changed (GtkEntry *editable,
- ESource *source)
-{
- update_user_in_source (source, gtk_entry_get_text (GTK_ENTRY (editable)));
-
- /* we changed user, thus reset the chosen calendar combo too, because
- * other user means other calendars subscribed */
- init_combo_values (GTK_COMBO_BOX (g_object_get_data (G_OBJECT (editable), "CalendarCombo")), _("Default"), NULL);
-}
-
-enum {
- COL_COLOR = 0, /* GDK_TYPE_COLOR */
- COL_TITLE, /* G_TYPE_STRING */
- COL_URL_PATH, /* G_TYPE_STRING */
- COL_READ_ONLY, /* G_TYPE_BOOLEAN */
- NUM_COLUMNS
-};
-
-static void
-init_combo_values (GtkComboBox *combo,
- const gchar *deftitle,
- const gchar *defuri)
-{
- GtkTreeIter iter;
- GtkListStore *store;
-
- if (!combo)
- return;
-
- store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
-
- gtk_list_store_clear (store);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_COLOR, NULL,
- COL_TITLE, deftitle,
- COL_URL_PATH, defuri,
- COL_READ_ONLY, FALSE,
- -1);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
-}
-
-static void
-cal_combo_changed (GtkComboBox *combo,
- ESource *source)
-{
- GtkListStore *store;
- GtkTreeIter iter;
-
- g_return_if_fail (combo != NULL);
- g_return_if_fail (source != NULL);
-
- store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
-
- if (gtk_combo_box_get_active_iter (combo, &iter)) {
- gchar *uri = NULL, *title = NULL;
- gboolean readonly = FALSE;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_TITLE, &title, COL_URL_PATH, &uri, COL_READ_ONLY, &readonly, -1);
-
- if (!uri) {
- const gchar *ssl = e_source_get_property (source, "ssl");
- uri = construct_default_uri (e_source_get_property (source, "username"), !ssl || g_str_equal (ssl, "1"));
- }
-
- if (is_default_uri (uri, e_source_get_property (source, "username"))) {
- /* do not store title when we use default uri */
- g_free (title);
- title = NULL;
- }
-
- /* first set readonly to FALSE, otherwise if TRUE, then e_source_set_readonly does nothing */
- e_source_set_readonly (source, FALSE);
- update_source_uris (source, uri);
- e_source_set_readonly (source, readonly);
- e_source_set_property (source, "googlename", title);
-
- /* delete obsolete properties */
- e_source_set_property (source, "protocol", NULL);
- e_source_set_property (source, "auth-domain", NULL);
-
- g_free (title);
- g_free (uri);
- }
-}
-
-static void
-claim_error (GtkWindow *parent,
- const gchar *error)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s",
- error);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
-
-static void
-update_proxy_settings (GDataService *service,
- const gchar *uri)
-{
- EProxy *proxy;
- SoupURI *proxy_uri = NULL;
-
- proxy = e_proxy_new ();
- e_proxy_setup_proxy (proxy);
-
- /* use proxy if necessary */
- if (e_proxy_require_proxy_for_uri (proxy, uri)) {
- proxy_uri = e_proxy_peek_uri_for (proxy, uri);
- }
-
- gdata_service_set_proxy_uri (service, proxy_uri);
- g_object_unref (proxy);
-}
-
-static void
-retrieve_list_clicked (GtkButton *button,
- GtkComboBox *combo)
-{
- ESource *source;
- GDataClientLoginAuthorizer *authorizer;
- GDataCalendarService *service;
- GDataFeed *feed;
- gchar *user, *password, *tmp;
- const gchar *username;
- GError *error = NULL;
- GtkWindow *parent;
-
- g_return_if_fail (button != NULL);
- g_return_if_fail (combo != NULL);
-
- parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button)));
-
- source = g_object_get_data (G_OBJECT (button), "ESource");
- g_return_if_fail (source != NULL);
-
- username = e_source_get_property (source, "username");
- g_return_if_fail (username != NULL && *username != '\0');
-
- user = decode_at_back (username);
- tmp = g_strdup_printf (_("Enter password for user %s to access list of subscribed calendars."), user);
- password = e_passwords_ask_password (_("Enter password"), NULL, "", tmp,
- E_PASSWORDS_REMEMBER_NEVER | E_PASSWORDS_REPROMPT | E_PASSWORDS_SECRET | E_PASSWORDS_DISABLE_REMEMBER,
- NULL, parent);
- g_free (tmp);
-
- if (!password) {
- g_free (user);
- return;
- }
-
- authorizer = gdata_client_login_authorizer_new ("evolution-client-0.1.0", GDATA_TYPE_CALENDAR_SERVICE);
- service = gdata_calendar_service_new (GDATA_AUTHORIZER (authorizer));
- update_proxy_settings (GDATA_SERVICE (service), URL_GET_SUBSCRIBED_CALENDARS);
- if (!gdata_client_login_authorizer_authenticate (authorizer, user, password, NULL, &error)) {
- /* Error! */
- claim_error (parent, error->message);
- g_error_free (error);
- g_free (password);
- g_free (user);
- g_object_unref (service);
- return;
- }
-
- /* privacy... maybe... */
- memset (password, 0, strlen (password));
- g_free (password);
-
- feed = gdata_calendar_service_query_all_calendars (service, NULL, NULL, NULL, NULL, &error);
-
- if (feed) {
- GList *l;
- gchar *old_selected = NULL;
- gint idx, active = -1, default_idx = -1;
- GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
- GtkTreeIter iter;
-
- if (gtk_combo_box_get_active_iter (combo, &iter))
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_URL_PATH, &old_selected, -1);
-
- gtk_list_store_clear (store);
-
- for (l = gdata_feed_get_entries (feed), idx = 1; l != NULL; l = l->next) {
- const gchar *uri, *title, *access;
- GDataLink *link;
- GDataColor color;
- GDataEntry *entry = GDATA_ENTRY (l->data);
-
- if (!entry || !GDATA_IS_ENTRY (entry))
- continue;
-
- /* skip hidden entries */
- if (gdata_calendar_calendar_is_hidden (GDATA_CALENDAR_CALENDAR (entry)))
- continue;
-
- /* Find the alternate link; skip the entry if one doesn't exist */
- link = gdata_entry_look_up_link (entry, GDATA_LINK_ALTERNATE);
- if (!link)
- continue;
-
- uri = gdata_link_get_uri (link);
- title = gdata_entry_get_title (entry);
- gdata_calendar_calendar_get_color (GDATA_CALENDAR_CALENDAR (entry), &color);
- access = gdata_calendar_calendar_get_access_level (GDATA_CALENDAR_CALENDAR (entry));
-
- if (uri && title) {
- GdkColor gdkcolor;
-
- if (old_selected && g_str_equal (old_selected, uri))
- active = idx;
-
- /* Convert the GDataColor to a GdkColor */
- gdkcolor.pixel = 0;
- gdkcolor.red = color.red * 256;
- gdkcolor.green = color.green * 256;
- gdkcolor.blue = color.blue * 256;
-
- if (default_idx == -1 && is_default_uri (uri, user)) {
- /* have the default uri always NULL and first in the combo */
- uri = NULL;
- gtk_list_store_insert (store, &iter, 0);
- default_idx = idx;
- } else {
- gtk_list_store_append (store, &iter);
- }
-
- gtk_list_store_set (store, &iter,
- COL_COLOR, &gdkcolor,
- COL_TITLE, title,
- COL_URL_PATH, uri,
- COL_READ_ONLY, access && !g_str_equal (access, "owner") && !g_str_equal (access, "contributor"),
- -1);
- idx++;
- }
- }
-
- if (default_idx == -1) {
- /* Hey, why we didn't find the default uri? Did something go so wrong or what? */
- gtk_list_store_insert (store, &iter, 0);
- gtk_list_store_set (store, &iter,
- COL_COLOR, NULL,
- COL_TITLE, _("Default"),
- COL_URL_PATH, NULL,
- COL_READ_ONLY, FALSE,
- -1);
- }
-
- gtk_combo_box_set_active (combo, active == -1 ? 0 : active);
-
- g_free (old_selected);
- g_object_unref (feed);
- } else {
- tmp = g_strdup_printf (_("Cannot read data from Google server.\n%s"), (error && error->message) ? error->message : _("Unknown error."));
- claim_error (parent, tmp);
- g_free (tmp);
-
- if (error) {
- g_error_free (error);
- error = NULL;
- }
- }
-
- g_object_unref (service);
- g_object_unref (authorizer);
- g_free (user);
-}
-
-static void
-retrieve_list_sensitize (GtkEntry *username_entry,
- GtkWidget *button)
-{
- const gchar *text;
- gboolean sensitive;
-
- text = gtk_entry_get_text (username_entry);
- sensitive = (text != NULL && *text != '\0');
- gtk_widget_set_sensitive (button, sensitive);
-}
-
-gpointer
-plugin_google_check (EPlugin *epl,
- EConfigHookPageCheckData *data)
-{
- ECalConfigTargetSource *t;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (data->target != NULL, NULL);
-
- t = (ECalConfigTargetSource *) data->target;
- g_return_val_if_fail (t->source != NULL, NULL);
-
- return check_username_filled (t->source);
-}
-
-GtkWidget *
-plugin_google (EPlugin *epl,
- EConfigHookItemFactoryData *data)
-{
- ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- ESource *source;
- ESourceGroup *group;
- EUri *euri;
- GtkWidget *parent;
- GtkWidget *widget;
- GtkWidget *user;
- GtkWidget *label;
- GtkWidget *combo;
- gchar *uri;
- const gchar *username;
- guint row;
- GtkCellRenderer *renderer;
- GtkListStore *store;
-
- GtkWidget *hbox;
-
- source = t->source;
- group = e_source_peek_group (source);
-
- widget = NULL;
- if (g_ascii_strncasecmp (GOOGLE_BASE_URI, e_source_group_peek_base_uri (group), strlen (GOOGLE_BASE_URI)) != 0) {
- return NULL;
- }
-
- uri = e_source_get_uri (source);
- euri = e_uri_new (uri);
- g_free (uri);
-
- if (euri == NULL) {
- return NULL;
- }
-
- e_uri_free (euri);
-
- username = e_source_get_property (source, "setup-username");
- if (!username)
- username = e_source_get_property (source, "username");
-
- /* google's CalDAV requires SSL, thus forcing it here, and no setup for it */
- e_source_set_property (source, "ssl", "1");
-
- /* Build up the UI */
- parent = data->parent;
-
- user = e_plugin_util_add_entry (parent, _("User_name:"), NULL, NULL);
- gtk_entry_set_text (GTK_ENTRY (user), username ? username : "");
- g_signal_connect (
- user, "changed",
- G_CALLBACK (user_changed), source);
-
- e_plugin_util_add_refresh (parent, _("Re_fresh:"), source, "refresh");
-
- g_object_get (parent, "n-rows", &row, NULL);
-
- label = gtk_label_new_with_mnemonic (_("Cal_endar:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- store = gtk_list_store_new (
- NUM_COLUMNS,
- GDK_TYPE_COLOR, /* COL_COLOR */
- G_TYPE_STRING, /* COL_TITLE */
- G_TYPE_STRING, /* COL_URL_PATH */
- G_TYPE_BOOLEAN); /* COL_READ_ONLY */
-
- combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
-
- renderer = e_cell_renderer_color_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "color", COL_COLOR, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", COL_TITLE, NULL);
-
- init_combo_values (GTK_COMBO_BOX (combo),
- e_source_get_property (source, "googlename") ? e_source_get_property (source, "googlename") : _("Default"),
- e_source_get_property (source, "googlename") ? e_source_peek_relative_uri (source) : NULL);
-
- g_signal_connect (
- combo, "changed",
- G_CALLBACK (cal_combo_changed), source);
-
- g_object_set_data (G_OBJECT (user), "CalendarCombo", combo);
-
- hbox = gtk_hbox_new (FALSE, 6);
-
- gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
- label = gtk_button_new_with_mnemonic (_("Retrieve _List"));
- g_signal_connect (
- label, "clicked",
- G_CALLBACK (retrieve_list_clicked), combo);
- g_signal_connect (
- user, "changed",
- G_CALLBACK (retrieve_list_sensitize), label);
- g_object_set_data (G_OBJECT (label), "ESource", source);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_widget_set_sensitive (label, username && *username);
-
- gtk_widget_show_all (hbox);
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- return widget;
-}
-
-void
-e_calendar_google_migrate (EPlugin *epl,
- ECalEventTargetBackend *data)
-{
- ESourceList *source_list;
- ESourceGroup *google = NULL;
- gboolean changed = FALSE;
-
- source_list = data->source_list;
-
- google = e_source_list_peek_group_by_base_uri (source_list, GOOGLE_BASE_URI);
- if (google) {
- GSList *s;
-
- for (s = e_source_group_peek_sources (google); s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
-
- if (!source)
- continue;
-
- /* new source through CalDAV uses absolute uri, thus it should be migrated if not set */
- if (!e_source_peek_absolute_uri (source)) {
- update_user_in_source (source, e_source_get_property (source, "username"));
- changed = TRUE;
- }
- }
- }
-
- if (changed)
- e_source_list_sync (source_list, NULL);
-}
diff --git a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
deleted file mode 100644
index 16cd61afc8..0000000000
--- a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-<e-plugin-list>
- <e-plugin id="org.gnome.evolution.google" type="shlib" _name="Google Calendars"
- location="@PLUGINDIR@/liborg-gnome-evolution-google@SOEXT@" load-on-startup="false" localedir = "@LOCALEDIR@" system_plugin="true">
- <author name="Ebby Wiselyn" email="ebbywiselyn@gmail.com"/>
- <author name="Joergen Scheibengruber" email="joergen.scheibengruber@googlemail.com"/>
- <_description>Add Google Calendars to Evolution.</_description>
-
- <hook class="org.gnome.evolution.calendar.config:1.0">
- <group target="source" id="org.gnome.evolution.calendar.calendarProperties" check="plugin_google_check">
- <item type="item_table" path="00.general/00.source/99.google" factory="plugin_google"/>
- </group>
- </hook>
- <hook class="org.gnome.evolution.calendar.events:1.0">
- <event target="module" id="module.migration" handle="e_calendar_google_migrate"/>
- </hook>
-
- <hook class="org.gnome.evolution.addressbook.config:1.0">
- <group target="source" id="com.novell.evolution.addressbook.config.accountEditor" check="plugin_google_contacts_check">
- <item type="item" path="00.general/10.display/99.google" factory="plugin_google_contacts"/>
- </group>
- </hook>
- </e-plugin>
-</e-plugin-list>