aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-03-28 22:16:00 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-06-03 11:00:43 +0800
commitd502cc9f842d4530d11645c1c3bf5f47db7eb9db (patch)
treeafff9cb8f5b44c0af9eaaac53c6ca5b7bf05790b
parentaa081cc6e87096434eb14e639787bc0a2942d366 (diff)
downloadgsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar.gz
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar.bz2
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar.lz
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar.xz
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.tar.zst
gsoc2013-evolution-d502cc9f842d4530d11645c1c3bf5f47db7eb9db.zip
Adapt publish-calendar plugin to the new ESource API.
-rw-r--r--plugins/publish-calendar/publish-format-fb.c29
-rw-r--r--plugins/publish-calendar/publish-format-ical.c29
-rw-r--r--plugins/publish-calendar/url-editor-dialog.c28
-rw-r--r--plugins/publish-calendar/url-editor-dialog.h1
4 files changed, 45 insertions, 42 deletions
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 7b9e3e1660..d6ba7e5c74 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -28,11 +28,14 @@
#include <time.h>
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-source-registry.h>
#include <libedataserverui/e-client-utils.h>
#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
#include <libecal/e-cal-time-util.h>
+
+#include <shell/e-shell.h>
+
#include "publish-format-fb.h"
static void
@@ -54,13 +57,14 @@ free_busy_data_cb (ECalClient *client,
static gboolean
write_calendar (const gchar *uid,
- ESourceList *source_list,
GOutputStream *stream,
gint dur_type,
gint dur_value,
GError **error)
{
+ EShell *shell;
ESource *source;
+ ESourceRegistry *registry;
ECalClient *client = NULL;
GSList *objects = NULL;
icaltimezone *utc;
@@ -86,19 +90,20 @@ write_calendar (const gchar *uid,
break;
}
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source)
+ shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_ref_source (registry, uid);
+
+ if (source != NULL) {
client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
+ g_object_unref (source);
+ }
if (!client) {
if (error && !*error)
*error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
return FALSE;
}
- g_signal_connect (
- client, "authenticate",
- G_CALLBACK (e_client_utils_authenticate_handler), NULL);
-
if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
g_object_unref (client);
return FALSE;
@@ -148,19 +153,13 @@ publish_calendar_as_fb (GOutputStream *stream,
GError **error)
{
GSList *l;
- ESourceList *source_list;
-
- if (!e_cal_client_get_sources (&source_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error))
- return;
/* events */
l = uri->events;
while (l) {
gchar *uid = l->data;
- if (!write_calendar (uid, source_list, stream, uri->fb_duration_type, uri->fb_duration_value, error))
+ if (!write_calendar (uid, stream, uri->fb_duration_type, uri->fb_duration_value, error))
break;
l = g_slist_next (l);
}
-
- g_object_unref (source_list);
}
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index 171fd6c1c0..8ff029301a 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -27,10 +27,13 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-source-registry.h>
#include <libedataserverui/e-client-utils.h>
#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
+
+#include <shell/e-shell.h>
+
#include "publish-format-ical.h"
typedef struct {
@@ -73,29 +76,31 @@ append_tz_to_comp (gpointer key,
static gboolean
write_calendar (const gchar *uid,
- ESourceList *source_list,
GOutputStream *stream,
GError **error)
{
+ EShell *shell;
ESource *source;
+ ESourceRegistry *registry;
ECalClient *client = NULL;
GSList *objects;
icalcomponent *top_level;
gboolean res = FALSE;
- source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source)
+ shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_ref_source (registry, uid);
+
+ if (source != NULL) {
client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
+ g_object_unref (source);
+ }
if (!client) {
if (error && !error)
*error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
return FALSE;
}
- g_signal_connect (
- client, "authenticate",
- G_CALLBACK (e_client_utils_authenticate_handler), NULL);
-
if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
g_object_unref (client);
return FALSE;
@@ -140,19 +145,13 @@ publish_calendar_as_ical (GOutputStream *stream,
GError **error)
{
GSList *l;
- ESourceList *source_list;
/* events */
- if (!e_cal_client_get_sources (&source_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error))
- return;
-
l = uri->events;
while (l) {
gchar *uid = l->data;
- if (!write_calendar (uid, source_list, stream, error))
+ if (!write_calendar (uid, stream, error))
break;
l = g_slist_next (l);
}
-
- g_object_unref (source_list);
}
diff --git a/plugins/publish-calendar/url-editor-dialog.c b/plugins/publish-calendar/url-editor-dialog.c
index 35910db8c7..ea697fd185 100644
--- a/plugins/publish-calendar/url-editor-dialog.c
+++ b/plugins/publish-calendar/url-editor-dialog.c
@@ -29,12 +29,15 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <libedataserver/e-source-calendar.h>
#include <libedataserverui/e-passwords.h>
#include <libedataserver/e-url.h>
#include <e-util/e-util.h>
#include <e-util/e-util-private.h>
+#include <shell/e-shell.h>
+
G_DEFINE_TYPE (
UrlEditorDialog,
url_editor_dialog,
@@ -350,13 +353,12 @@ set_from_uri (UrlEditorDialog *dialog)
static gboolean
url_editor_dialog_construct (UrlEditorDialog *dialog)
{
+ EShell *shell;
GtkWidget *toplevel;
GtkWidget *content_area;
- GConfClient *gconf;
GtkSizeGroup *group;
EPublishUri *uri;
-
- gconf = gconf_client_get_default ();
+ ESourceRegistry *registry;
dialog->builder = gtk_builder_new ();
e_load_ui_builder_definition (dialog->builder, "publish-calendar.ui");
@@ -408,8 +410,10 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
- dialog->events_source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/calendar/sources");
- dialog->events_selector = e_source_selector_new (dialog->events_source_list);
+ shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
+ dialog->events_selector = e_source_selector_new (
+ registry, E_SOURCE_EXTENSION_CALENDAR);
gtk_widget_show (dialog->events_selector);
gtk_container_add (GTK_CONTAINER (dialog->events_swin), dialog->events_selector);
@@ -440,10 +444,14 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
GSList *p;
for (p = uri->events; p; p = g_slist_next (p)) {
- gchar *source_uid = g_strdup (p->data);
- source = e_source_list_peek_source_by_uid (dialog->events_source_list, source_uid);
- e_source_selector_select_source ((ESourceSelector *) dialog->events_selector, source);
- g_free (source_uid);
+ const gchar *uid = p->data;
+
+ source = e_source_registry_ref_source (
+ registry, uid);
+ e_source_selector_select_source (
+ E_SOURCE_SELECTOR (dialog->events_selector),
+ source);
+ g_object_unref (source);
}
if (uri->location && strlen (uri->location)) {
@@ -503,8 +511,6 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
dialog->remember_pw, "toggled",
G_CALLBACK (remember_pw_toggled), dialog);
- g_object_unref (gconf);
-
check_input (dialog);
return TRUE;
diff --git a/plugins/publish-calendar/url-editor-dialog.h b/plugins/publish-calendar/url-editor-dialog.h
index d2223547c8..7283c6fd1b 100644
--- a/plugins/publish-calendar/url-editor-dialog.h
+++ b/plugins/publish-calendar/url-editor-dialog.h
@@ -71,7 +71,6 @@ struct _UrlEditorDialog {
GtkWidget *events_swin;
- ESourceList *events_source_list;
GtkWidget *events_selector;
GtkWidget *publish_service;