[evolution/account-mgmt: 47/51] Adapt publish-calendar plugin to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 47/51] Adapt publish-calendar plugin to the new ESource API.
- Date: Fri, 6 Apr 2012 03:02:47 +0000 (UTC)
commit b96f4d68460f630f1a2e8ffd881c3f0e46a55a7d
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Mar 28 10:16:00 2011 -0400
Adapt publish-calendar plugin to the new ESource API.
plugins/publish-calendar/publish-format-fb.c | 25 ++++++-------
plugins/publish-calendar/publish-format-ical.c | 25 ++++++-------
plugins/publish-calendar/url-editor-dialog.c | 45 ++++++++++++++++--------
plugins/publish-calendar/url-editor-dialog.h | 1 -
4 files changed, 52 insertions(+), 44 deletions(-)
---
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 7b9e3e1..636e2c6 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,7 +90,10 @@ write_calendar (const gchar *uid,
break;
}
- source = e_source_list_peek_source_by_uid (source_list, uid);
+ shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
if (source)
client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
if (!client) {
@@ -95,10 +102,6 @@ write_calendar (const gchar *uid,
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 +151,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 171fd6c..831a5c8 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,17 +76,21 @@ 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);
+ shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
if (source)
client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
if (!client) {
@@ -92,10 +99,6 @@ write_calendar (const gchar *uid,
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 +143,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 db3dd28..24afc7b 100644
--- a/plugins/publish-calendar/url-editor-dialog.c
+++ b/plugins/publish-calendar/url-editor-dialog.c
@@ -25,13 +25,19 @@
#endif
#include "url-editor-dialog.h"
+
+#include <string.h>
+#include <glib/gi18n.h>
+
+#include <libedataserver/e-source-calendar.h>
#include <libedataserverui/e-passwords.h>
#include <libedataserver/e-url.h>
-#include <glib/gi18n.h>
-#include <string.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,
@@ -347,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");
@@ -405,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);
@@ -437,10 +444,13 @@ 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_lookup_by_uid (
+ registry, uid);
+ e_source_selector_select_source (
+ E_SOURCE_SELECTOR (dialog->events_selector),
+ source);
}
if (uri->location && strlen (uri->location)) {
@@ -500,8 +510,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;
@@ -588,8 +596,15 @@ url_editor_dialog_run (UrlEditorDialog *dialog)
}
l = e_source_selector_get_selection (E_SOURCE_SELECTOR (dialog->events_selector));
- for (p = l; p; p = g_slist_next (p))
- dialog->uri->events = g_slist_append (dialog->uri->events, g_strdup (e_source_peek_uid (p->data)));
+ for (p = l; p; p = g_slist_next (p)) {
+ ESource *source;
+ const gchar *uid;
+
+ source = E_SOURCE (p->data);
+ uid = e_source_get_uid (source);
+ dialog->uri->events = g_slist_append (
+ dialog->uri->events, g_strdup (uid));
+ }
}
gtk_widget_hide (GTK_WIDGET (dialog));
diff --git a/plugins/publish-calendar/url-editor-dialog.h b/plugins/publish-calendar/url-editor-dialog.h
index d222354..7283c6f 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]