Commit d502cc9f authored by Matthew Barnes's avatar Matthew Barnes
Browse files

Adapt publish-calendar plugin to the new ESource API.

parent aa081cc6
......@@ -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);
}
......@@ -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);
}
......@@ -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;
......
......@@ -71,7 +71,6 @@ struct _UrlEditorDialog {
GtkWidget *events_swin;
ESourceList *events_source_list;
GtkWidget *events_selector;
GtkWidget *publish_service;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment