aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/save-calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-06-14 14:54:20 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:27 +0800
commit84339b3be5a771406fcd5898bbd21dc1c5b98c82 (patch)
tree15a9cfd61451b56d6b35541b1b1e966a34b17faf /plugins/save-calendar
parentfa4289a2f3c26112c907f283a1fd8ab3fb4f26d6 (diff)
downloadgsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.tar.gz
gsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.tar.zst
gsoc2013-evolution-84339b3be5a771406fcd5898bbd21dc1c5b98c82.zip
Do not use deprecated EBook/ECal API
Diffstat (limited to 'plugins/save-calendar')
-rw-r--r--plugins/save-calendar/csv-format.c30
-rw-r--r--plugins/save-calendar/format-handler.h4
-rw-r--r--plugins/save-calendar/ical-format.c36
-rw-r--r--plugins/save-calendar/rdf-format.c30
-rw-r--r--plugins/save-calendar/save-calendar.c12
5 files changed, 63 insertions, 49 deletions
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c
index 15ed83817e..da21588d8c 100644
--- a/plugins/save-calendar/csv-format.c
+++ b/plugins/save-calendar/csv-format.c
@@ -30,8 +30,8 @@
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
-#include "calendar/common/authentication.h"
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <string.h>
#include "format-handler.h"
@@ -300,7 +300,7 @@ userstring_to_systemstring (const gchar *userstring)
static void
do_save_calendar_csv (FormatHandler *handler,
ESourceSelector *selector,
- ECalSourceType type,
+ ECalClientSourceType type,
gchar *dest_uri)
{
@@ -314,9 +314,9 @@ do_save_calendar_csv (FormatHandler *handler,
*/
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects=NULL;
+ GSList *objects = NULL;
GOutputStream *stream;
GString *line = NULL;
CsvConfig *config = NULL;
@@ -329,12 +329,16 @@ do_save_calendar_csv (FormatHandler *handler,
primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
- source_client = e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (
gtk_widget_get_toplevel (GTK_WIDGET (selector)),
error);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
@@ -354,8 +358,8 @@ do_save_calendar_csv (FormatHandler *handler,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))),
dest_uri, &error);
- if (stream && e_cal_get_object_list_as_comp (
- source_client, "#t", &objects, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ GSList *iter;
if (config->header) {
@@ -396,7 +400,7 @@ do_save_calendar_csv (FormatHandler *handler,
g_string_free (line, TRUE);
}
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
ECalComponent *comp = objects->data;
gchar *delimiter_temp = NULL;
const gchar *temp_constchar;
@@ -521,11 +525,11 @@ do_save_calendar_csv (FormatHandler *handler,
/* It's written, so we can free it */
g_string_free (line, TRUE);
-
- objects = g_list_next (objects);
}
g_output_stream_close (stream, NULL, NULL);
+
+ e_cal_client_free_ecalcomp_slist (objects);
}
if (stream)
diff --git a/plugins/save-calendar/format-handler.h b/plugins/save-calendar/format-handler.h
index e04d95fbf1..b7376920ef 100644
--- a/plugins/save-calendar/format-handler.h
+++ b/plugins/save-calendar/format-handler.h
@@ -24,7 +24,7 @@
#include <gio/gio.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
typedef struct _FormatHandler FormatHandler;
@@ -39,7 +39,7 @@ struct _FormatHandler
void (*save) (FormatHandler *handler,
ESourceSelector *selector,
- ECalSourceType type,
+ ECalClientSourceType type,
gchar *dest_uri);
};
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index fa4f6a5515..39cac6f2e0 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -29,9 +29,9 @@
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
-#include <calendar/common/authentication.h>
#include <string.h>
#include "format-handler.h"
@@ -48,7 +48,7 @@ display_error_message (GtkWidget *parent, const gchar *message)
typedef struct {
GHashTable *zones;
- ECal *ecal;
+ ECalClient *client;
} CompTzData;
static void
@@ -65,7 +65,7 @@ insert_tz_comps (icalparameter *param, gpointer cb_data)
if (g_hash_table_lookup (tdata->zones, tzid))
return;
- if (!e_cal_get_timezone (tdata->ecal, tzid, &zone, &error)) {
+ if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) {
g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message);
g_error_free (error);
return;
@@ -82,12 +82,12 @@ append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
}
static void
-do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSourceType type, gchar *dest_uri)
+do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalClientSourceType type, gchar *dest_uri)
{
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects;
+ GSList *objects = NULL;
icalcomponent *top_level = NULL;
primary_source = e_source_selector_get_primary_selection (selector);
@@ -96,10 +96,14 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
return;
/* open source client */
- source_client = (ECal*) e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
@@ -108,21 +112,19 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
top_level = e_cal_util_new_top_level ();
error = NULL;
- if (e_cal_get_object_list (source_client, "#t", &objects, &error)) {
+ if (e_cal_client_get_object_list_sync (source_client, "#t", &objects, NULL, &error)) {
CompTzData tdata;
GOutputStream *stream;
+ GSList *iter;
tdata.zones = g_hash_table_new (g_str_hash, g_str_equal);
- tdata.ecal = source_client;
+ tdata.client = source_client;
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
icalcomponent *icalcomp = objects->data;
icalcomponent_foreach_tzid (icalcomp, insert_tz_comps, &tdata);
icalcomponent_add_component (top_level, icalcomp);
-
- /* remove item from the list */
- objects = g_list_remove (objects, icalcomp);
}
g_hash_table_foreach (tdata.zones, (GHFunc) append_tz_to_comp, top_level);
@@ -142,6 +144,8 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
g_object_unref (stream);
g_free (ical_str);
}
+
+ e_cal_client_free_icalcomp_slist (objects);
}
if (error) {
diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c
index 084250e70c..c64b31f055 100644
--- a/plugins/save-calendar/rdf-format.c
+++ b/plugins/save-calendar/rdf-format.c
@@ -27,8 +27,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
#include <libxml/xmlmemory.h>
@@ -38,7 +39,6 @@
#include <libxml/xpath.h>
#include <string.h>
-#include "calendar/common/authentication.c"
#include "format-handler.h"
static void
@@ -169,7 +169,7 @@ add_string_to_rdf (xmlNodePtr node, const gchar *tag, const gchar *value)
}
static void
-do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSourceType type, gchar *dest_uri)
+do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalClientSourceType type, gchar *dest_uri)
{
/*
@@ -182,9 +182,9 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
*/
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects=NULL;
+ GSList *objects = NULL;
gchar *temp = NULL;
GOutputStream *stream;
@@ -194,17 +194,23 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
- source_client = e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))), dest_uri, &error);
- if (stream && e_cal_get_object_list_as_comp (source_client, "#t", &objects, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ GSList *iter;
+
xmlBufferPtr buffer=xmlBufferCreate ();
xmlDocPtr doc = xmlNewDoc((xmlChar *) "1.0");
xmlNodePtr fnode;
@@ -238,7 +244,7 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
/* Version of this RDF-format */
xmlNewChild (fnode, NULL, (const guchar *)"version", (const guchar *)"2.0");
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
ECalComponent *comp = objects->data;
const gchar *temp_constchar;
gchar *tmp_str = NULL;
@@ -334,8 +340,6 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
* http://www.gnome.org/projects/evolution/developer-doc/libecal/ECalComponent.html
* #e-cal-component-get-last-modified
*/
-
- objects = g_list_next (objects);
}
/* I used a buffer rather than xmlDocDump: I want gio support */
@@ -344,6 +348,8 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
g_output_stream_write_all (stream, xmlBufferContent (buffer), xmlBufferLength (buffer), NULL, NULL, &error);
g_output_stream_close (stream, NULL, NULL);
+ e_cal_client_free_ecalcomp_slist (objects);
+
xmlBufferFree (buffer);
xmlFreeDoc (doc);
}
diff --git a/plugins/save-calendar/save-calendar.c b/plugins/save-calendar/save-calendar.c
index 8bf0067b79..a1a48be7cf 100644
--- a/plugins/save-calendar/save-calendar.c
+++ b/plugins/save-calendar/save-calendar.c
@@ -32,7 +32,7 @@
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <e-util/e-alert-dialog.h>
#include <e-util/e-plugin.h>
#include <string.h>
@@ -113,7 +113,7 @@ format_handlers_foreach_free (gpointer data, gpointer user_data)
}
static void
-ask_destination_and_save (ESourceSelector *selector, ECalSourceType type)
+ask_destination_and_save (ESourceSelector *selector, ECalClientSourceType type)
{
FormatHandler *handler = NULL;
@@ -284,7 +284,7 @@ open_for_writing (GtkWindow *parent, const gchar *uri, GError **error)
static void
save_general (EShellView *shell_view,
- ECalSourceType type)
+ ECalClientSourceType type)
{
EShellSidebar *shell_sidebar;
ESourceSelector *selector = NULL;
@@ -302,21 +302,21 @@ static void
action_calendar_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_EVENT);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_EVENTS);
}
static void
action_memo_list_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_JOURNAL);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
}
static void
action_task_list_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_TODO);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_TASKS);
}
gboolean