aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--modules/Makefile.am1
-rw-r--r--modules/cal-config-google/Makefile.am32
-rw-r--r--modules/cal-config-google/e-google-chooser-button.c244
-rw-r--r--modules/cal-config-google/e-google-chooser-button.h67
-rw-r--r--modules/cal-config-google/e-google-chooser-dialog.c387
-rw-r--r--modules/cal-config-google/e-google-chooser-dialog.h68
-rw-r--r--modules/cal-config-google/e-google-chooser.c623
-rw-r--r--modules/cal-config-google/e-google-chooser.h76
-rw-r--r--modules/cal-config-google/evolution-cal-config-google.c194
-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
15 files changed, 1694 insertions, 1274 deletions
diff --git a/configure.ac b/configure.ac
index db77e75844..6424e769f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1298,7 +1298,7 @@ AC_ARG_ENABLE([plugins],
[enable_plugins="$enableval"],[enable_plugins=all])
dnl Add any new plugins here
-plugins_base_always="calendar-http itip-formatter default-source mark-all-read publish-calendar imap-features google-account-setup"
+plugins_base_always="calendar-http itip-formatter default-source mark-all-read publish-calendar imap-features"
plugins_base="$plugins_base_always"
dist_plugins_base="$plugins_base_always calendar-weather"
@@ -1639,6 +1639,7 @@ modules/book-config-local/Makefile
modules/book-config-webdav/Makefile
modules/cal-config-caldav/Makefile
modules/cal-config-contacts/Makefile
+modules/cal-config-google/Makefile
modules/cal-config-local/Makefile
modules/composer-autosave/Makefile
modules/mailto-handler/Makefile
@@ -1663,7 +1664,6 @@ plugins/default-source/Makefile
plugins/email-custom-header/Makefile
plugins/external-editor/Makefile
plugins/face/Makefile
-plugins/google-account-setup/Makefile
plugins/image-inline/Makefile
plugins/imap-features/Makefile
plugins/itip-formatter/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index ecfeae7f4e..00754d8491 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -26,6 +26,7 @@ SUBDIRS = \
book-config-webdav \
cal-config-caldav \
cal-config-contacts \
+ cal-config-google \
cal-config-local \
composer-autosave \
mailto-handler \
diff --git a/modules/cal-config-google/Makefile.am b/modules/cal-config-google/Makefile.am
new file mode 100644
index 0000000000..f79565a5cc
--- /dev/null
+++ b/modules/cal-config-google/Makefile.am
@@ -0,0 +1,32 @@
+module_LTLIBRARIES = module-cal-config-google.la
+
+module_cal_config_google_la_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/widgets \
+ -DG_LOG_DOMAIN=\"evolution-cal-config-google\" \
+ $(EVOLUTION_DATA_SERVER_CFLAGS) \
+ $(GNOME_PLATFORM_CFLAGS) \
+ $(GDATA_CFLAGS)
+
+module_cal_config_google_la_SOURCES = \
+ evolution-cal-config-google.c \
+ e-google-chooser-button.c \
+ e-google-chooser-button.h \
+ e-google-chooser-dialog.c \
+ e-google-chooser-dialog.h \
+ e-google-chooser.c \
+ e-google-chooser.h
+
+module_cal_config_google_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/calendar/gui/libevolution-calendar.la \
+ $(EVOLUTION_DATA_SERVER_LIBS) \
+ $(GNOME_PLATFORM_LIBS) \
+ $(GDATA_LIBS)
+
+module_cal_config_google_la_LDFLAGS = \
+ -module -avoid-version $(NO_UNDEFINED)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/cal-config-google/e-google-chooser-button.c b/modules/cal-config-google/e-google-chooser-button.c
new file mode 100644
index 0000000000..700760811d
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser-button.c
@@ -0,0 +1,244 @@
+/*
+ * e-google-chooser-button.c
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-google-chooser-button.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-webdav.h>
+
+#include "e-google-chooser-dialog.h"
+
+#define E_GOOGLE_CHOOSER_BUTTON_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_BUTTON, EGoogleChooserButtonPrivate))
+
+struct _EGoogleChooserButtonPrivate {
+ ESource *source;
+ GtkWidget *label;
+};
+
+enum {
+ PROP_0,
+ PROP_DISPLAY_NAME,
+ PROP_SOURCE
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+ EGoogleChooserButton,
+ e_google_chooser_button,
+ GTK_TYPE_BUTTON)
+
+static void
+google_chooser_button_set_source (EGoogleChooserButton *button,
+ ESource *source)
+{
+ g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (button->priv->source == NULL);
+
+ button->priv->source = g_object_ref (source);
+}
+
+static void
+google_chooser_button_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SOURCE:
+ google_chooser_button_set_source (
+ E_GOOGLE_CHOOSER_BUTTON (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_button_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SOURCE:
+ g_value_set_object (
+ value,
+ e_google_chooser_button_get_source (
+ E_GOOGLE_CHOOSER_BUTTON (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_button_dispose (GObject *object)
+{
+ EGoogleChooserButtonPrivate *priv;
+
+ priv = E_GOOGLE_CHOOSER_BUTTON_GET_PRIVATE (object);
+
+ if (priv->source != NULL) {
+ g_object_unref (priv->source);
+ priv->source = NULL;
+ }
+
+ if (priv->label != NULL) {
+ g_object_unref (priv->label);
+ priv->label = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_google_chooser_button_parent_class)->dispose (object);
+}
+
+static void
+google_chooser_button_constructed (GObject *object)
+{
+ EGoogleChooserButton *button;
+ ESourceWebdav *webdav_extension;
+ GBindingFlags binding_flags;
+ GtkWidget *widget;
+ const gchar *display_name;
+
+ button = E_GOOGLE_CHOOSER_BUTTON (object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_google_chooser_button_parent_class)->
+ constructed (object);
+
+ widget = gtk_label_new (_("Default User Calendar"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_container_add (GTK_CONTAINER (button), widget);
+ button->priv->label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ webdav_extension = e_source_get_extension (
+ button->priv->source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
+ display_name = e_source_webdav_get_display_name (webdav_extension);
+
+ binding_flags = G_BINDING_DEFAULT;
+ if (display_name != NULL && *display_name != '\0')
+ binding_flags |= G_BINDING_SYNC_CREATE;
+
+ g_object_bind_property (
+ webdav_extension, "display-name",
+ button->priv->label, "label",
+ binding_flags);
+}
+
+static void
+google_chooser_button_clicked (GtkButton *button)
+{
+ EGoogleChooserButtonPrivate *priv;
+ GtkWidget *chooser;
+ GtkWidget *dialog;
+ gpointer parent;
+
+ priv = E_GOOGLE_CHOOSER_BUTTON_GET_PRIVATE (button);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+ chooser = e_google_chooser_new (priv->source);
+
+ dialog = e_google_chooser_dialog_new (
+ E_GOOGLE_CHOOSER (chooser), parent);
+
+ if (parent != NULL)
+ g_object_bind_property (
+ parent, "icon-name",
+ dialog, "icon-name",
+ G_BINDING_SYNC_CREATE);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
+e_google_chooser_button_class_init (EGoogleChooserButtonClass *class)
+{
+ GObjectClass *object_class;
+ GtkButtonClass *button_class;
+
+ g_type_class_add_private (class, sizeof (EGoogleChooserButtonPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = google_chooser_button_set_property;
+ object_class->get_property = google_chooser_button_get_property;
+ object_class->dispose = google_chooser_button_dispose;
+ object_class->constructed = google_chooser_button_constructed;
+
+ button_class = GTK_BUTTON_CLASS (class);
+ button_class->clicked = google_chooser_button_clicked;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SOURCE,
+ g_param_spec_object (
+ "source",
+ NULL,
+ NULL,
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+e_google_chooser_button_class_finalize (EGoogleChooserButtonClass *class)
+{
+}
+
+static void
+e_google_chooser_button_init (EGoogleChooserButton *button)
+{
+ button->priv = E_GOOGLE_CHOOSER_BUTTON_GET_PRIVATE (button);
+}
+
+void
+e_google_chooser_button_type_register (GTypeModule *type_module)
+{
+ /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+ * function, so we have to wrap it with a public function in
+ * order to register types from a separate compilation unit. */
+ e_google_chooser_button_register_type (type_module);
+}
+
+GtkWidget *
+e_google_chooser_button_new (ESource *source)
+{
+ g_return_val_if_fail (E_IS_SOURCE (source), NULL);
+
+ return g_object_new (
+ E_TYPE_GOOGLE_CHOOSER_BUTTON,
+ "source", source, NULL);
+}
+
+ESource *
+e_google_chooser_button_get_source (EGoogleChooserButton *button)
+{
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER_BUTTON (button), NULL);
+
+ return button->priv->source;
+}
+
diff --git a/modules/cal-config-google/e-google-chooser-button.h b/modules/cal-config-google/e-google-chooser-button.h
new file mode 100644
index 0000000000..29d2db098b
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser-button.h
@@ -0,0 +1,67 @@
+/*
+ * e-google-chooser-button.h
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_GOOGLE_CHOOSER_BUTTON_H
+#define E_GOOGLE_CHOOSER_BUTTON_H
+
+#include "e-google-chooser.h"
+
+/* Standard GObject macros */
+#define E_TYPE_GOOGLE_CHOOSER_BUTTON \
+ (e_google_chooser_button_get_type ())
+#define E_GOOGLE_CHOOSER_BUTTON(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_BUTTON, EGoogleChooserButton))
+#define E_GOOGLE_CHOOSER_BUTTON_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_GOOGLE_CHOOSER_BUTTON, EGoogleChooserButtonClass))
+#define E_IS_GOOGLE_CHOOSER_BUTTON(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_BUTTON))
+#define E_IS_GOOGLE_CHOOSER_BUTTON_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_GOOGLE_CHOOSER_BUTTON))
+#define E_GOOGLE_CHOOSER_BUTTON_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_BUTTON, EGoogleChooserButtonClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EGoogleChooserButton EGoogleChooserButton;
+typedef struct _EGoogleChooserButtonClass EGoogleChooserButtonClass;
+typedef struct _EGoogleChooserButtonPrivate EGoogleChooserButtonPrivate;
+
+struct _EGoogleChooserButton {
+ GtkButton parent;
+ EGoogleChooserButtonPrivate *priv;
+};
+
+struct _EGoogleChooserButtonClass {
+ GtkButtonClass parent_class;
+};
+
+GType e_google_chooser_button_get_type (void);
+void e_google_chooser_button_type_register
+ (GTypeModule *type_module);
+GtkWidget * e_google_chooser_button_new (ESource *source);
+ESource * e_google_chooser_button_get_source
+ (EGoogleChooserButton *button);
+
+G_END_DECLS
+
+#endif /* E_GOOGLE_CHOOSER_BUTTON_H */
diff --git a/modules/cal-config-google/e-google-chooser-dialog.c b/modules/cal-config-google/e-google-chooser-dialog.c
new file mode 100644
index 0000000000..acf11f2a9d
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser-dialog.c
@@ -0,0 +1,387 @@
+/*
+ * e-google-chooser-dialog.c
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-google-chooser-dialog.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#define E_GOOGLE_CHOOSER_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_DIALOG, EGoogleChooserDialogPrivate))
+
+struct _EGoogleChooserDialogPrivate {
+ EGoogleChooser *chooser;
+ GCancellable *cancellable;
+
+ GtkWidget *info_bar; /* not referenced */
+ GtkWidget *info_bar_label; /* not referenced */
+};
+
+enum {
+ PROP_0,
+ PROP_CHOOSER
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+ EGoogleChooserDialog,
+ e_google_chooser_dialog,
+ GTK_TYPE_DIALOG)
+
+static void
+google_chooser_dialog_populated_cb (EGoogleChooser *chooser,
+ GAsyncResult *result,
+ EGoogleChooserDialog *dialog)
+{
+ GdkWindow *window;
+ GError *error = NULL;
+
+ e_google_chooser_populate_finish (chooser, result, &error);
+
+ /* Ignore cancellations, and leave the mouse cursor alone
+ * since the GdkWindow may have already been destroyed. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ goto exit;
+
+ /* Reset the mouse cursor to normal. */
+ window = gtk_widget_get_window (GTK_WIDGET (dialog));
+ gdk_window_set_cursor (window, NULL);
+
+ if (error != NULL) {
+ GtkLabel *label;
+
+ label = GTK_LABEL (dialog->priv->info_bar_label);
+ gtk_label_set_text (label, error->message);
+ gtk_widget_show (dialog->priv->info_bar);
+
+ g_error_free (error);
+ goto exit;
+ }
+
+exit:
+ g_object_unref (dialog);
+}
+
+static void
+google_chooser_dialog_row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GtkDialog *dialog)
+{
+ gtk_dialog_response (dialog, GTK_RESPONSE_APPLY);
+}
+
+static void
+google_chooser_dialog_selection_changed_cb (GtkTreeSelection *selection,
+ GtkDialog *dialog)
+{
+ gboolean sensitive;
+
+ sensitive = (gtk_tree_selection_count_selected_rows (selection) > 0);
+
+ gtk_dialog_set_response_sensitive (
+ dialog, GTK_RESPONSE_APPLY, sensitive);
+}
+
+static void
+google_chooser_dialog_set_chooser (EGoogleChooserDialog *dialog,
+ EGoogleChooser *chooser)
+{
+ g_return_if_fail (E_IS_GOOGLE_CHOOSER (chooser));
+ g_return_if_fail (dialog->priv->chooser == NULL);
+
+ dialog->priv->chooser = g_object_ref_sink (chooser);
+}
+
+static void
+google_chooser_dialog_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHOOSER:
+ google_chooser_dialog_set_chooser (
+ E_GOOGLE_CHOOSER_DIALOG (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_dialog_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHOOSER:
+ g_value_set_object (
+ value,
+ e_google_chooser_dialog_get_chooser (
+ E_GOOGLE_CHOOSER_DIALOG (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_dialog_dispose (GObject *object)
+{
+ EGoogleChooserDialogPrivate *priv;
+
+ priv = E_GOOGLE_CHOOSER_DIALOG_GET_PRIVATE (object);
+
+ if (priv->chooser != NULL) {
+ g_signal_handlers_disconnect_by_func (
+ priv->chooser, google_chooser_dialog_row_activated_cb,
+ object);
+ g_object_unref (priv->chooser);
+ priv->chooser = NULL;
+ }
+
+ if (priv->cancellable != NULL) {
+ g_cancellable_cancel (priv->cancellable);
+ g_object_unref (priv->cancellable);
+ priv->cancellable = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_google_chooser_dialog_parent_class)->dispose (object);
+}
+
+static void
+google_chooser_dialog_constructed (GObject *object)
+{
+ EGoogleChooserDialog *dialog;
+ GtkTreeSelection *selection;
+ GtkWidget *container;
+ GtkWidget *widget;
+ GtkWidget *vbox;
+ const gchar *title;
+
+ dialog = E_GOOGLE_CHOOSER_DIALOG (object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_google_chooser_dialog_parent_class)->
+ constructed (object);
+
+ gtk_dialog_add_button (
+ GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (
+ GTK_DIALOG (dialog),
+ GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
+
+ gtk_dialog_set_default_response (
+ GTK_DIALOG (dialog), GTK_RESPONSE_APPLY);
+ gtk_dialog_set_response_sensitive (
+ GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, FALSE);
+
+ title = _("Choose a Calendar");
+ gtk_window_set_title (GTK_WINDOW (dialog), title);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 400);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+
+ container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ widget = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ container = vbox = widget;
+
+ widget = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (
+ GTK_SCROLLED_WINDOW (widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = GTK_WIDGET (dialog->priv->chooser);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ g_signal_connect (
+ widget, "row-activated",
+ G_CALLBACK (google_chooser_dialog_row_activated_cb), dialog);
+
+ /* Build the info bar, but hide it initially. */
+
+ container = vbox;
+
+ widget = gtk_info_bar_new ();
+ gtk_info_bar_set_message_type (
+ GTK_INFO_BAR (widget), GTK_MESSAGE_WARNING);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ dialog->priv->info_bar = widget; /* do not reference */
+ gtk_widget_hide (widget);
+
+ container = gtk_info_bar_get_content_area (GTK_INFO_BAR (widget));
+
+ widget = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_image_new_from_stock (
+ GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ dialog->priv->info_bar_label = widget; /* do not reference */
+ gtk_widget_show (widget);
+
+ /* Listen for tree view selection changes. */
+
+ selection = gtk_tree_view_get_selection (
+ GTK_TREE_VIEW (dialog->priv->chooser));
+
+ g_signal_connect (
+ selection, "changed",
+ G_CALLBACK (google_chooser_dialog_selection_changed_cb),
+ dialog);
+}
+
+static void
+google_chooser_dialog_realize (GtkWidget *widget)
+{
+ EGoogleChooserDialogPrivate *priv;
+ GdkCursor *cursor;
+ GdkWindow *window;
+ GdkDisplay *display;
+
+ priv = E_GOOGLE_CHOOSER_DIALOG_GET_PRIVATE (widget);
+
+ /* Chain up to parent's realize() method. */
+ GTK_WIDGET_CLASS (e_google_chooser_dialog_parent_class)->
+ realize (widget);
+
+ g_return_if_fail (priv->cancellable == NULL);
+ priv->cancellable = g_cancellable_new ();
+
+ /* Show a busy mouse cursor while populating. */
+ window = gtk_widget_get_window (widget);
+ display = gtk_widget_get_display (widget);
+ cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
+ gdk_window_set_cursor (window, cursor);
+ gdk_cursor_unref (cursor);
+
+ e_google_chooser_populate (
+ priv->chooser, priv->cancellable, (GAsyncReadyCallback)
+ google_chooser_dialog_populated_cb, g_object_ref (widget));
+}
+
+static void
+google_chooser_dialog_response (GtkDialog *dialog,
+ gint response_id)
+{
+ EGoogleChooserDialogPrivate *priv;
+
+ priv = E_GOOGLE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+
+ if (response_id == GTK_RESPONSE_APPLY)
+ e_google_chooser_apply_selected (priv->chooser);
+}
+
+static void
+e_google_chooser_dialog_class_init (EGoogleChooserDialogClass *class)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkDialogClass *dialog_class;
+
+ g_type_class_add_private (class, sizeof (EGoogleChooserDialogPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = google_chooser_dialog_set_property;
+ object_class->get_property = google_chooser_dialog_get_property;
+ object_class->dispose = google_chooser_dialog_dispose;
+ object_class->constructed = google_chooser_dialog_constructed;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = google_chooser_dialog_realize;
+
+ dialog_class = GTK_DIALOG_CLASS (class);
+ dialog_class->response = google_chooser_dialog_response;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CHOOSER,
+ g_param_spec_object (
+ "chooser",
+ NULL,
+ NULL,
+ E_TYPE_GOOGLE_CHOOSER,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+e_google_chooser_dialog_class_finalize (EGoogleChooserDialogClass *class)
+{
+}
+
+static void
+e_google_chooser_dialog_init (EGoogleChooserDialog *dialog)
+{
+ dialog->priv = E_GOOGLE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+}
+
+void
+e_google_chooser_dialog_type_register (GTypeModule *type_module)
+{
+ /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+ * function, so we have to wrap it with a public function in
+ * order to register types from a separate compilation unit. */
+ e_google_chooser_dialog_register_type (type_module);
+}
+
+GtkWidget *
+e_google_chooser_dialog_new (EGoogleChooser *chooser,
+ GtkWindow *parent)
+{
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER (chooser), NULL);
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
+
+ return g_object_new (
+ E_TYPE_GOOGLE_CHOOSER_DIALOG,
+ "chooser", chooser, "transient-for", parent, NULL);
+}
+
+EGoogleChooser *
+e_google_chooser_dialog_get_chooser (EGoogleChooserDialog *dialog)
+{
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER_DIALOG (dialog), NULL);
+
+ return dialog->priv->chooser;
+}
+
diff --git a/modules/cal-config-google/e-google-chooser-dialog.h b/modules/cal-config-google/e-google-chooser-dialog.h
new file mode 100644
index 0000000000..d7e3e375d9
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser-dialog.h
@@ -0,0 +1,68 @@
+/*
+ * e-google-chooser-dialog.h
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_GOOGLE_CHOOSER_DIALOG_H
+#define E_GOOGLE_CHOOSER_DIALOG_H
+
+#include "e-google-chooser.h"
+
+/* Standard GObject macros */
+#define E_TYPE_GOOGLE_CHOOSER_DIALOG \
+ (e_google_chooser_dialog_get_type ())
+#define E_GOOGLE_CHOOSER_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_DIALOG, EGoogleChooserDialog))
+#define E_GOOGLE_CHOOSER_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_GOOGLE_CHOOSER_DIALOG, EGoogleChooserDialogClass))
+#define E_IS_GOOGLE_CHOOSER_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_DIALOG))
+#define E_IS_GOOGLE_CHOOSER_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_GOOGLE_CHOOSER_DIALOG))
+#define E_GOOGLE_CHOOSER_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_GOOGLE_CHOOSER_DIALOG, EGoogleChooserDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EGoogleChooserDialog EGoogleChooserDialog;
+typedef struct _EGoogleChooserDialogClass EGoogleChooserDialogClass;
+typedef struct _EGoogleChooserDialogPrivate EGoogleChooserDialogPrivate;
+
+struct _EGoogleChooserDialog {
+ GtkDialog parent;
+ EGoogleChooserDialogPrivate *priv;
+};
+
+struct _EGoogleChooserDialogClass {
+ GtkDialogClass parent_class;
+};
+
+GType e_google_chooser_dialog_get_type (void);
+void e_google_chooser_dialog_type_register
+ (GTypeModule *type_module);
+GtkWidget * e_google_chooser_dialog_new (EGoogleChooser *chooser,
+ GtkWindow *parent);
+EGoogleChooser *e_google_chooser_dialog_get_chooser
+ (EGoogleChooserDialog *dialog);
+
+G_END_DECLS
+
+#endif /* E_GOOGLE_CHOOSER_DIALOG_H */
diff --git a/modules/cal-config-google/e-google-chooser.c b/modules/cal-config-google/e-google-chooser.c
new file mode 100644
index 0000000000..d5a4064b0f
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser.c
@@ -0,0 +1,623 @@
+/*
+ * e-google-chooser.c
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-google-chooser.h"
+
+#include <config.h>
+#include <string.h>
+#include <gdata/gdata.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-calendar.h>
+#include <libedataserver/e-source-webdav.h>
+#include <libedataserverui/e-cell-renderer-color.h>
+#include <libedataserverui/e-passwords.h>
+
+#define E_GOOGLE_CHOOSER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER, EGoogleChooserPrivate))
+
+#define CALDAV_EVENTS_PATH_FORMAT "/calendar/dav/%s/events"
+
+typedef struct _Context Context;
+
+struct _EGoogleChooserPrivate {
+ ESource *source;
+};
+
+struct _Context {
+ GCancellable *cancellable;
+ GDataCalendarService *service;
+ GDataClientLoginAuthorizer *authorizer;
+ ESource *source;
+};
+
+enum {
+ PROP_0,
+ PROP_SOURCE
+};
+
+enum {
+ COLUMN_COLOR,
+ COLUMN_PATH,
+ COLUMN_TITLE,
+ COLUMN_WRITABLE,
+ NUM_COLUMNS
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+ EGoogleChooser,
+ e_google_chooser,
+ GTK_TYPE_TREE_VIEW)
+
+static void
+context_free (Context *context)
+{
+ if (context->cancellable != NULL)
+ g_object_unref (context->cancellable);
+
+ if (context->service != NULL)
+ g_object_unref (context->service);
+
+ if (context->authorizer != NULL)
+ g_object_unref (context->authorizer);
+
+ if (context->source != NULL)
+ g_object_unref (context->source);
+
+ g_slice_free (Context, context);
+}
+
+static gchar *
+google_chooser_extract_caldav_events_path (const gchar *uri)
+{
+ SoupURI *soup_uri;
+ gchar *resource_name;
+ gchar *path;
+ gchar *cp;
+
+ soup_uri = soup_uri_new (uri);
+ g_return_val_if_fail (soup_uri != NULL, NULL);
+
+ /* Isolate the resource name in the "feeds" URI. */
+
+ cp = strstr (soup_uri->path, "/feeds/");
+ g_return_val_if_fail (cp != NULL, NULL);
+
+ /* strlen("/feeds/) == 7 */
+ resource_name = g_strdup (cp + 7);
+ cp = strchr (resource_name, '/');
+ if (cp != NULL)
+ *cp = '\0';
+
+ /* Decode any encoded 'at' symbols ('%40' -> '@'). */
+ if (strstr (resource_name, "%40") != NULL) {
+ gchar **segments;
+
+ segments = g_strsplit (resource_name, "%40", 0);
+ g_free (resource_name);
+ resource_name = g_strjoinv ("@", segments);
+ g_strfreev (segments);
+ }
+
+ /* Use the decoded resource name in the CalDAV events path. */
+ path = g_strdup_printf (CALDAV_EVENTS_PATH_FORMAT, resource_name);
+
+ g_free (resource_name);
+
+ soup_uri_free (soup_uri);
+
+ return path;
+}
+
+static void
+google_chooser_set_source (EGoogleChooser *chooser,
+ ESource *source)
+{
+ g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (chooser->priv->source == NULL);
+
+ chooser->priv->source = g_object_ref (source);
+}
+
+static void
+google_chooser_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SOURCE:
+ google_chooser_set_source (
+ E_GOOGLE_CHOOSER (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SOURCE:
+ g_value_set_object (
+ value, e_google_chooser_get_source (
+ E_GOOGLE_CHOOSER (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+google_chooser_dispose (GObject *object)
+{
+ EGoogleChooserPrivate *priv;
+
+ priv = E_GOOGLE_CHOOSER_GET_PRIVATE (object);
+
+ if (priv->source != NULL) {
+ g_object_unref (priv->source);
+ priv->source = NULL;
+ }
+
+ /* Chain up parent's dispose() method. */
+ G_OBJECT_CLASS (e_google_chooser_parent_class)->dispose (object);
+}
+
+static void
+google_chooser_constructed (GObject *object)
+{
+ GtkTreeView *tree_view;
+ GtkListStore *list_store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ tree_view = GTK_TREE_VIEW (object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_google_chooser_parent_class)->constructed (object);
+
+ list_store = gtk_list_store_new (
+ NUM_COLUMNS,
+ GDK_TYPE_COLOR, /* COLUMN_COLOR */
+ G_TYPE_STRING, /* COLUMN_PATH */
+ G_TYPE_STRING, /* COLUMN_TITLE */
+ G_TYPE_BOOLEAN); /* COLUMN_WRITABLE */
+
+ gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (list_store));
+
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_column_set_title (column, _("Name"));
+ gtk_tree_view_insert_column (tree_view, column, -1);
+
+ renderer = e_cell_renderer_color_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_add_attribute (
+ column, renderer, "color", COLUMN_COLOR);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_add_attribute (
+ column, renderer, "text", COLUMN_TITLE);
+}
+
+static void
+e_google_chooser_class_init (EGoogleChooserClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EGoogleChooserPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = google_chooser_set_property;
+ object_class->get_property = google_chooser_get_property;
+ object_class->dispose = google_chooser_dispose;
+ object_class->constructed = google_chooser_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SOURCE,
+ g_param_spec_object (
+ "source",
+ "Source",
+ "Google data source",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+e_google_chooser_class_finalize (EGoogleChooserClass *class)
+{
+}
+
+static void
+e_google_chooser_init (EGoogleChooser *chooser)
+{
+ chooser->priv = E_GOOGLE_CHOOSER_GET_PRIVATE (chooser);
+}
+
+void
+e_google_chooser_type_register (GTypeModule *type_module)
+{
+ /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+ * function, so we have to wrap it with a public function in
+ * order to register types from a separate compilation unit. */
+ e_google_chooser_register_type (type_module);
+}
+
+GtkWidget *
+e_google_chooser_new (ESource *source)
+{
+ g_return_val_if_fail (E_IS_SOURCE (source), NULL);
+
+ return g_object_new (E_TYPE_GOOGLE_CHOOSER, "source", source, NULL);
+}
+
+ESource *
+e_google_chooser_get_source (EGoogleChooser *chooser)
+{
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER (chooser), NULL);
+
+ return chooser->priv->source;
+}
+
+gchar *
+e_google_chooser_get_decoded_user (EGoogleChooser *chooser)
+{
+ ESource *source;
+ ESourceAuthentication *authentication_extension;
+ const gchar *user;
+ gchar *decoded_user;
+
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER (chooser), NULL);
+
+ source = e_google_chooser_get_source (chooser);
+
+ authentication_extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_AUTHENTICATION);
+
+ user = e_source_authentication_get_user (authentication_extension);
+ if (user == NULL || *user == '\0')
+ return NULL;
+
+ /* Decode any encoded 'at' symbols ('%40' -> '@'). */
+ if (strstr (user, "%40") != NULL) {
+ gchar **segments;
+
+ segments = g_strsplit (user, "%40", 0);
+ decoded_user = g_strjoinv ("@", segments);
+ g_strfreev (segments);
+
+ /* If no domain is given, append "@gmail.com". */
+ } else if (strstr (user, "@") == NULL) {
+ decoded_user = g_strconcat (user, "@gmail.com", NULL);
+
+ /* Otherwise the user name should be fine as is. */
+ } else {
+ decoded_user = g_strdup (user);
+ }
+
+ return decoded_user;
+}
+
+static void
+google_chooser_query_cb (GDataService *service,
+ GAsyncResult *result,
+ GSimpleAsyncResult *simple)
+{
+ GObject *object;
+ GDataFeed *feed;
+ GList *list, *link;
+ GtkTreeView *tree_view;
+ GtkListStore *list_store;
+ GtkTreeModel *tree_model;
+ GError *error = NULL;
+
+ feed = gdata_service_query_finish (service, result, &error);
+
+ if (error != NULL) {
+ g_warn_if_fail (feed == NULL);
+ g_simple_async_result_set_from_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ return;
+ }
+
+ g_return_if_fail (GDATA_IS_FEED (feed));
+
+ list = gdata_feed_get_entries (feed);
+
+ /* This returns a new reference, for reasons passing understanding. */
+ object = g_async_result_get_source_object (G_ASYNC_RESULT (simple));
+
+ tree_view = GTK_TREE_VIEW (object);
+ tree_model = gtk_tree_view_get_model (tree_view);
+ list_store = GTK_LIST_STORE (tree_model);
+
+ gtk_list_store_clear (list_store);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ GDataCalendarCalendar *calendar;
+ GDataEntry *entry;
+ GDataLink *alt;
+ GDataColor color;
+ GdkColor gdkcolor;
+ GtkTreeIter iter;
+ const gchar *uri;
+ const gchar *title;
+ const gchar *access;
+ gboolean writable;
+ gchar *path;
+
+ entry = GDATA_ENTRY (link->data);
+ calendar = GDATA_CALENDAR_CALENDAR (entry);
+
+ /* Skip hidden entries. */
+ if (gdata_calendar_calendar_is_hidden (calendar))
+ continue;
+
+ /* Look up the alternate link, skip if there is none. */
+ alt = gdata_entry_look_up_link (entry, GDATA_LINK_ALTERNATE);
+ if (alt == NULL)
+ continue;
+
+ uri = gdata_link_get_uri (alt);
+ title = gdata_entry_get_title (entry);
+ gdata_calendar_calendar_get_color (calendar, &color);
+ access = gdata_calendar_calendar_get_access_level (calendar);
+
+ if (uri == NULL || *uri == '\0')
+ continue;
+
+ if (title == NULL || *title == '\0')
+ continue;
+
+ path = google_chooser_extract_caldav_events_path (uri);
+
+ gdkcolor.pixel = 0;
+ gdkcolor.red = color.red * 256;
+ gdkcolor.green = color.green * 256;
+ gdkcolor.blue = color.blue * 256;
+
+ if (access == NULL)
+ writable = TRUE;
+ else if (g_ascii_strcasecmp (access, "owner") == 0)
+ writable = TRUE;
+ else if (g_ascii_strcasecmp (access, "contributor") == 0)
+ writable = TRUE;
+ else
+ writable = FALSE;
+
+ gtk_list_store_append (list_store, &iter);
+
+ gtk_list_store_set (
+ list_store, &iter,
+ COLUMN_COLOR, &gdkcolor,
+ COLUMN_PATH, path,
+ COLUMN_TITLE, title,
+ COLUMN_WRITABLE, writable,
+ -1);
+
+ g_free (path);
+ }
+
+ g_object_unref (object);
+ g_object_unref (feed);
+
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+static void
+google_chooser_authenticate_cb (GDataClientLoginAuthorizer *authorizer,
+ GAsyncResult *result,
+ GSimpleAsyncResult *simple)
+{
+ Context *context;
+ GError *error = NULL;
+
+ context = g_simple_async_result_get_op_res_gpointer (simple);
+
+ gdata_client_login_authorizer_authenticate_finish (
+ authorizer, result, &error);
+
+ if (error != NULL) {
+ g_simple_async_result_set_from_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ return;
+ }
+
+ /* We're authenticated, now query for all calendars. */
+
+ gdata_calendar_service_query_all_calendars_async (
+ context->service, NULL, context->cancellable,
+ NULL, NULL, NULL, (GAsyncReadyCallback)
+ google_chooser_query_cb, simple);
+}
+
+void
+e_google_chooser_populate (EGoogleChooser *chooser,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GDataClientLoginAuthorizer *authorizer;
+ GDataCalendarService *service;
+ GSimpleAsyncResult *simple;
+ Context *context;
+ ESource *source;
+ gpointer parent;
+ gchar *password;
+ gchar *prompt;
+ gchar *user;
+
+ g_return_if_fail (E_IS_GOOGLE_CHOOSER (chooser));
+
+ source = e_google_chooser_get_source (chooser);
+
+ authorizer = gdata_client_login_authorizer_new (
+ PACKAGE_NAME, GDATA_TYPE_CALENDAR_SERVICE);
+
+ service = gdata_calendar_service_new (GDATA_AUTHORIZER (authorizer));
+
+ context = g_slice_new0 (Context);
+ context->service = service; /* takes ownership */
+ context->source = g_object_ref (source);
+
+ if (G_IS_CANCELLABLE (cancellable))
+ context->cancellable = g_object_ref (cancellable);
+ else
+ context->cancellable = g_cancellable_new ();
+
+ simple = g_simple_async_result_new (
+ G_OBJECT (chooser), callback,
+ user_data, e_google_chooser_populate);
+
+ g_simple_async_result_set_op_res_gpointer (
+ simple, context, (GDestroyNotify) context_free);
+
+ /* Prompt for a password. */
+
+ user = e_google_chooser_get_decoded_user (chooser);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (chooser));
+ parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+ prompt = g_strdup_printf (
+ _("Enter Google password for user '%s'."), user);
+
+ /* XXX The 'key' (3rd) argument doesn't matter since we're
+ * passing E_PASSWORDS_REMEMBER_NEVER, it just needs to
+ * be non-NULL. This API is degenerating rapidly. */
+ password = e_passwords_ask_password (
+ "", NULL, "bogus key", prompt,
+ E_PASSWORDS_REMEMBER_NEVER |
+ E_PASSWORDS_DISABLE_REMEMBER |
+ E_PASSWORDS_SECRET, NULL, parent);
+
+ g_free (prompt);
+
+ if (password == NULL) {
+ g_cancellable_cancel (context->cancellable);
+ g_simple_async_result_set_error (
+ simple, G_IO_ERROR, G_IO_ERROR_CANCELLED,
+ "%s", _("User declined to provide a password"));
+ g_simple_async_result_complete (simple);
+ g_object_unref (authorizer);
+ g_object_unref (simple);
+ g_free (user);
+ return;
+ }
+
+ /* Try authenticating. */
+
+ gdata_client_login_authorizer_authenticate_async (
+ authorizer, user, password,
+ context->cancellable, (GAsyncReadyCallback)
+ google_chooser_authenticate_cb, simple);
+
+ g_free (password);
+ g_free (user);
+
+ g_object_unref (authorizer);
+}
+
+gboolean
+e_google_chooser_populate_finish (EGoogleChooser *chooser,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_val_if_fail (
+ g_simple_async_result_is_valid (
+ result, G_OBJECT (chooser),
+ e_google_chooser_populate), FALSE);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ /* Assume success unless a GError is set. */
+ return !g_simple_async_result_propagate_error (simple, error);
+}
+
+gboolean
+e_google_chooser_apply_selected (EGoogleChooser *chooser)
+{
+ ESourceSelectable *selectable_extension;
+ ESourceWebdav *webdav_extension;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ ESource *source;
+ GdkColor *color;
+ SoupURI *soup_uri;
+ gchar *color_spec;
+ gchar *title;
+ gchar *path;
+
+ g_return_val_if_fail (E_IS_GOOGLE_CHOOSER (chooser), FALSE);
+
+ source = e_google_chooser_get_source (chooser);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (chooser));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return FALSE;
+
+ gtk_tree_model_get (
+ model, &iter,
+ COLUMN_COLOR, &color,
+ COLUMN_PATH, &path,
+ COLUMN_TITLE, &title,
+ -1);
+
+ selectable_extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_CALENDAR);
+
+ webdav_extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
+
+ e_source_set_display_name (source, title);
+
+ e_source_webdav_set_display_name (webdav_extension, title);
+
+ /* XXX Might be easier to expose get/set_path functions? */
+ soup_uri = e_source_webdav_dup_soup_uri (webdav_extension);
+ soup_uri_set_path (soup_uri, path);
+ e_source_webdav_set_soup_uri (webdav_extension, soup_uri);
+ soup_uri_free (soup_uri);
+
+ color_spec = gdk_color_to_string (color);
+ e_source_selectable_set_color (selectable_extension, color_spec);
+ g_free (color_spec);
+
+ gdk_color_free (color);
+ g_free (title);
+ g_free (path);
+
+ return TRUE;
+}
diff --git a/modules/cal-config-google/e-google-chooser.h b/modules/cal-config-google/e-google-chooser.h
new file mode 100644
index 0000000000..f2cd28a6c5
--- /dev/null
+++ b/modules/cal-config-google/e-google-chooser.h
@@ -0,0 +1,76 @@
+/*
+ * e-google-chooser.h
+ *
+ * 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 <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_GOOGLE_CHOOSER_H
+#define E_GOOGLE_CHOOSER_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
+
+/* Standard GObject macros */
+#define E_TYPE_GOOGLE_CHOOSER \
+ (e_google_chooser_get_type ())
+#define E_GOOGLE_CHOOSER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_GOOGLE_CHOOSER, EGoogleChooser))
+#define E_GOOGLE_CHOOSER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_GOOGLE_CHOOSER, EGoogleChooserClass))
+#define E_IS_GOOGLE_CHOOSER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_GOOGLE_CHOOSER))
+#define E_IS_GOOGLE_CHOOSER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_GOOGLE_CHOOSER))
+#define E_GOOGLE_CHOOSER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_GOOGLE_CHOOSER, EGoogleChooserClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EGoogleChooser EGoogleChooser;
+typedef struct _EGoogleChooserClass EGoogleChooserClass;
+typedef struct _EGoogleChooserPrivate EGoogleChooserPrivate;
+
+struct _EGoogleChooser {
+ GtkTreeView parent;
+ EGoogleChooserPrivate *priv;
+};
+
+struct _EGoogleChooserClass {
+ GtkTreeViewClass parent_class;
+};
+
+GType e_google_chooser_get_type (void);
+void e_google_chooser_type_register
+ (GTypeModule *type_module);
+GtkWidget * e_google_chooser_new (ESource *source);
+ESource * e_google_chooser_get_source (EGoogleChooser *chooser);
+gchar * e_google_chooser_get_decoded_user
+ (EGoogleChooser *chooser);
+void e_google_chooser_populate (EGoogleChooser *chooser,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_google_chooser_populate_finish
+ (EGoogleChooser *chooser,
+ GAsyncResult *result,
+ GError **error);
+gboolean e_google_chooser_apply_selected (EGoogleChooser *chooser);
+
+#endif /* E_GOOGLE_CHOOSER_H */
diff --git a/modules/cal-config-google/evolution-cal-config-google.c b/modules/cal-config-google/evolution-cal-config-google.c
new file mode 100644
index 0000000000..589adf5aec
--- /dev/null
+++ b/modules/cal-config-google/evolution-cal-config-google.c
@@ -0,0 +1,194 @@
+/*
+ * evolution-cal-config-google.c
+ *
+ * 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/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libebackend/e-extension.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-calendar.h>
+#include <libedataserver/e-source-webdav.h>
+
+#include <misc/e-source-config-backend.h>
+#include <calendar/gui/e-cal-source-config.h>
+
+#include "e-google-chooser-button.h"
+#include "e-google-chooser-dialog.h"
+
+typedef ESourceConfigBackend ECalConfigGoogle;
+typedef ESourceConfigBackendClass ECalConfigGoogleClass;
+
+typedef struct _Context Context;
+
+struct _Context {
+ GtkWidget *google_button;
+};
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_cal_config_google_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+ ECalConfigGoogle,
+ e_cal_config_google,
+ E_TYPE_SOURCE_CONFIG_BACKEND)
+
+static void
+cal_config_google_context_free (Context *context)
+{
+ g_object_unref (context->google_button);
+
+ g_slice_free (Context, context);
+}
+
+static gboolean
+cal_config_google_allow_creation (ESourceConfigBackend *backend)
+{
+ ESourceConfig *config;
+ ECalClientSourceType source_type;
+
+ config = e_source_config_backend_get_config (backend);
+
+ source_type = e_cal_source_config_get_source_type (
+ E_CAL_SOURCE_CONFIG (config));
+
+ /* XXX Google's CalDAV interface doesn't support tasks. */
+ return (source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS);
+}
+
+static void
+cal_config_google_insert_widgets (ESourceConfigBackend *backend,
+ ESource *scratch_source)
+{
+ ESourceConfig *config;
+ GtkWidget *widget;
+ Context *context;
+ const gchar *uid;
+
+ context = g_slice_new0 (Context);
+ uid = e_source_get_uid (scratch_source);
+ config = e_source_config_backend_get_config (backend);
+
+ g_object_set_data_full (
+ G_OBJECT (backend), uid, context,
+ (GDestroyNotify) cal_config_google_context_free);
+
+ e_cal_source_config_add_offline_toggle (
+ E_CAL_SOURCE_CONFIG (config), scratch_source);
+
+ e_source_config_add_user_entry (config, scratch_source);
+
+ widget = e_google_chooser_button_new (scratch_source);
+ e_source_config_insert_widget (
+ config, scratch_source, _("Calendar:"), widget);
+ context->google_button = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ e_source_config_add_refresh_interval (config, scratch_source);
+}
+
+static void
+cal_config_google_commit_changes (ESourceConfigBackend *backend,
+ ESource *scratch_source)
+{
+ ESourceBackend *calendar_extension;
+ ESourceWebdav *webdav_extension;
+ SoupURI *soup_uri;
+
+ /* We need to hard-code a few settings. */
+
+ calendar_extension = e_source_get_extension (
+ scratch_source, E_SOURCE_EXTENSION_CALENDAR);
+
+ webdav_extension = e_source_get_extension (
+ scratch_source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
+
+ /* The backend name is actually "caldav" even though the
+ * ESource is a child of the built-in "Google" source. */
+ e_source_backend_set_backend_name (calendar_extension, "caldav");
+
+ soup_uri = e_source_webdav_dup_soup_uri (webdav_extension);
+
+ /* The host name is fixed, obviously. */
+ soup_uri_set_host (soup_uri, "www.google.com");
+
+ /* Google's CalDAV interface requires a secure connection. */
+ soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTPS);
+
+ e_source_webdav_set_soup_uri (webdav_extension, soup_uri);
+
+ soup_uri_free (soup_uri);
+}
+
+static gboolean
+cal_config_google_check_complete (ESourceConfigBackend *backend,
+ ESource *scratch_source)
+{
+ ESourceAuthentication *extension;
+ const gchar *extension_name;
+ const gchar *user;
+
+ extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+ extension = e_source_get_extension (scratch_source, extension_name);
+ user = e_source_authentication_get_user (extension);
+
+ return (user != NULL);
+}
+
+static void
+e_cal_config_google_class_init (ESourceConfigBackendClass *class)
+{
+ EExtensionClass *extension_class;
+
+ extension_class = E_EXTENSION_CLASS (class);
+ extension_class->extensible_type = E_TYPE_CAL_SOURCE_CONFIG;
+
+ class->parent_uid = "google-stub";
+ class->backend_name = "google";
+ class->allow_creation = cal_config_google_allow_creation;
+ class->insert_widgets = cal_config_google_insert_widgets;
+ class->check_complete = cal_config_google_check_complete;
+ class->commit_changes = cal_config_google_commit_changes;
+}
+
+static void
+e_cal_config_google_class_finalize (ESourceConfigBackendClass *class)
+{
+}
+
+static void
+e_cal_config_google_init (ESourceConfigBackend *backend)
+{
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+ e_google_chooser_type_register (type_module);
+ e_google_chooser_button_type_register (type_module);
+ e_google_chooser_dialog_type_register (type_module);
+ e_cal_config_google_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
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>