[evolution/account-mgmt: 45/50] 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: 45/50] Adapt publish-calendar plugin to the new ESource API.
- Date: Sat, 1 Oct 2011 15:51:14 +0000 (UTC)
commit 1736fdd4d1acb88c96f0dfce5989b5e248159c4a
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-calendar.c | 2 +
plugins/publish-calendar/publish-format-fb.c | 22 ++++++------
plugins/publish-calendar/publish-format-ical.c | 22 ++++++------
plugins/publish-calendar/publish-location.c | 4 ++
plugins/publish-calendar/url-editor-dialog.c | 45 ++++++++++++++++++-----
plugins/publish-calendar/url-editor-dialog.h | 1 -
6 files changed, 63 insertions(+), 33 deletions(-)
---
diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c
index 1ce9f17..d938a08 100644
--- a/plugins/publish-calendar/publish-calendar.c
+++ b/plugins/publish-calendar/publish-calendar.c
@@ -314,6 +314,7 @@ ask_password (GMountOperation *op,
GAskPasswordFlags flags,
gpointer user_data)
{
+#if 0 /* ACCOUNT_MGMT */
struct mnt_struct *ms = (struct mnt_struct *) user_data;
gchar *username, *password;
gboolean req_pass = FALSE;
@@ -359,6 +360,7 @@ ask_password (GMountOperation *op,
g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
e_uri_free (euri);
+#endif /* ACCOUNT_MGMT */
}
static void
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 1059e1d..c8046be 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -27,13 +27,15 @@
#include <string.h>
#include <time.h>
#include <glib/gi18n.h>
-#include <gconf/gconf-client.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
@@ -55,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;
@@ -87,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) {
@@ -145,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 b28a57a..ebf8ba2 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -26,12 +26,14 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <gconf/gconf-client.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 {
@@ -74,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) {
@@ -139,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/publish-location.c b/plugins/publish-calendar/publish-location.c
index 4bb4271..be5b83c 100644
--- a/plugins/publish-calendar/publish-location.c
+++ b/plugins/publish-calendar/publish-location.c
@@ -36,6 +36,7 @@ static EPublishUri *
migrateURI (const gchar *xml,
xmlDocPtr doc)
{
+#if 0 /* ACCOUNT_MGMT */
GConfClient *client;
GSList *uris, *l, *events = NULL;
xmlChar *location, *enabled, *frequency, *username;
@@ -122,6 +123,9 @@ cleanup:
xmlFreeDoc (doc);
return uri;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
EPublishUri *
diff --git a/plugins/publish-calendar/url-editor-dialog.c b/plugins/publish-calendar/url-editor-dialog.c
index 9467705..9c99952 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 <libecal/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>
+
static GtkDialogClass *parent_class = NULL;
static void
@@ -344,11 +350,13 @@ 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;
+ ESourceRegistry *registry;
gconf = gconf_client_get_default ();
@@ -402,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);
@@ -434,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)) {
@@ -447,7 +460,10 @@ url_editor_dialog_construct (UrlEditorDialog *dialog)
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->publish_frequency), uri->publish_frequency);
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->type_selector), uri->publish_format);
+#if 0 /* ACCOUNT_MGMT */
uri->password = e_passwords_get_password (NULL, uri->location);
+#endif /* ACCOUNT_MGMT */
+ uri->password = NULL; /* ACCOUNT_MGMT */
if (uri->password) {
if (strlen (uri->password) != 0) {
gtk_entry_set_text (GTK_ENTRY (dialog->password_entry), uri->password);
@@ -601,16 +617,25 @@ url_editor_dialog_run (UrlEditorDialog *dialog)
dialog->uri->password = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->password_entry)));
+#if 0 /* ACCOUNT_MGMT */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->remember_pw))) {
e_passwords_add_password (dialog->uri->location, dialog->uri->password);
e_passwords_remember_password (NULL, dialog->uri->location);
} else {
e_passwords_forget_password (NULL, dialog->uri->location);
}
+#endif /* ACCOUNT_MGMT */
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]