aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2002-07-16 03:24:27 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2002-07-16 03:24:27 +0800
commit3b8e4896e2fdf1c837743387928f5b4fd1e2d02f (patch)
treea5e1702b5a63355cc651357c089b07613b21157a /calendar
parentd503b1a1c0aad7668fc1c64555b72320611ef341 (diff)
downloadgsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar.gz
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar.bz2
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar.lz
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar.xz
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.tar.zst
gsoc2013-evolution-3b8e4896e2fdf1c837743387928f5b4fd1e2d02f.zip
Fixes #8001
2002-07-14 Rodrigo Moya <rodrigo@ximian.com> Fixes #8001 * importers/icalendar-importer.c (connect_to_shell): new function for connecting the importers (both iCal and vCal) to the shell, needed for some information retrieval about the folders we're importing to. (ical_importer_new, vcal_importer_new): call connect_to_shell. (importer_destroy_cb): unref the shell client object. (get_uri_from_folder_path): retrieve the uri from the storage registry. (check_folder_type): removed. * importers/Makefile.am: included libeshell to LIBS. svn path=/trunk/; revision=17463
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog15
-rw-r--r--calendar/importers/Makefile.am1
-rw-r--r--calendar/importers/icalendar-importer.c126
-rw-r--r--calendar/importers/main.c2
4 files changed, 107 insertions, 37 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 59d1105df2..795f424eba 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,18 @@
+2002-07-14 Rodrigo Moya <rodrigo@ximian.com>
+
+ Fixes #8001
+
+ * importers/icalendar-importer.c (connect_to_shell): new function for
+ connecting the importers (both iCal and vCal) to the shell, needed for
+ some information retrieval about the folders we're importing to.
+ (ical_importer_new, vcal_importer_new): call connect_to_shell.
+ (importer_destroy_cb): unref the shell client object.
+ (get_uri_from_folder_path): retrieve the uri from the storage
+ registry.
+ (check_folder_type): removed.
+
+ * importers/Makefile.am: included libeshell to LIBS.
+
2002-07-12 Peter Williams <peterw@ximian.com>
* pcs/cal.c: Sigh, fix for the wombat.idl -> Evolution-Wombat.idl
diff --git a/calendar/importers/Makefile.am b/calendar/importers/Makefile.am
index 4015e12f86..6266ae9f5e 100644
--- a/calendar/importers/Makefile.am
+++ b/calendar/importers/Makefile.am
@@ -24,6 +24,7 @@ evolution_calendar_importer_SOURCES = \
main.c
evolution_calendar_importer_LDADD = \
+ $(top_builddir)/shell/libeshell.la \
$(top_builddir)/shell/importer/libevolution-importer.la \
$(top_builddir)/calendar/cal-util/libcal-util.la \
$(top_builddir)/calendar/cal-client/libcal-client.la \
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index bacf9b7eff..766202de2b 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -29,11 +29,14 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-util.h>
#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-exception.h>
#include <gal/util/e-unicode-i18n.h>
#include <cal-client.h>
#include <importer/evolution-importer.h>
#include <importer/evolution-intelligent-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
+#include <shell/e-shell.h>
+#include <shell/evolution-shell-client.h>
#include "icalvcal.h"
#include "evolution-calendar-importer.h"
@@ -48,6 +51,7 @@ typedef struct {
icalcomponent *icalcomp;
gboolean folder_contains_events;
gboolean folder_contains_tasks;
+ EvolutionShellClient *shell_client;
} ICalImporter;
typedef struct {
@@ -68,11 +72,36 @@ importer_destroy_cb (GtkObject *object, gpointer user_data)
gtk_object_unref (GTK_OBJECT (ici->client));
gtk_object_unref (GTK_OBJECT (ici->tasks_client));
- if (ici->icalcomp != NULL)
+
+ if (ici->icalcomp != NULL) {
icalcomponent_free (ici->icalcomp);
+ ici->icalcomp = NULL;
+ }
+
+ if (BONOBO_IS_OBJECT (ici->shell_client)) {
+ bonobo_object_unref (BONOBO_OBJECT (ici->shell_client));
+ ici->shell_client = NULL;
+ }
+
g_free (ici);
}
+/* Connects an importer to the Evolution shell */
+static void
+connect_to_shell (ICalImporter *ici)
+{
+ CORBA_Environment ev;
+ GNOME_Evolution_Shell corba_shell;
+
+ CORBA_exception_init (&ev);
+ corba_shell = oaf_activate_from_id (E_SHELL_OAFIID, 0, NULL, &ev);
+ if (BONOBO_EX (&ev)) {
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ ici->shell_client = evolution_shell_client_new (corba_shell);
+}
/* This reads in an entire file and returns it. It returns NULL on error.
The returned string should be freed. */
@@ -116,48 +145,73 @@ read_file (const char *filename)
}
-/* Returns the URI to load given a folder path. Currently this is just a full
- pathname. The returned string should be freed. */
+/* Returns the URI to load given a folder path. The returned string should be freed. */
static char*
-get_uri_from_folder_path (const char *folderpath)
+get_uri_from_folder_path (ICalImporter *ici, const char *folderpath)
{
- const char *name;
- char *parent;
-
- if (folderpath == NULL || *folderpath == '\0') {
+ GNOME_Evolution_StorageRegistry corba_registry;
+ GNOME_Evolution_StorageRegistry_StorageList *storage_list;
+ GNOME_Evolution_Folder *corba_folder;
+ CORBA_Environment ev;
+ int i;
+ char *uri = NULL;
+
+ corba_registry = evolution_shell_client_get_storage_registry_interface (ici->shell_client);
+ if (!corba_registry) {
return g_strdup_printf ("%s/evolution/local/Calendar/calendar.ics",
g_get_home_dir ());
}
- name = strrchr (folderpath, '/');
- if (name == NULL || name == folderpath) {
- parent = "evolution/local/";
- if (folderpath[0] == '/')
- name = folderpath + 1;
- else
- name = folderpath;
- } else {
- name += 1;
- parent = "evolution/local/Calendar/subfolders/";
+ CORBA_exception_init (&ev);
+ storage_list = GNOME_Evolution_StorageRegistry_getStorageList (corba_registry, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning (_("Can't get storage list from registry: %s"), CORBA_exception_id (&ev));
+ CORBA_exception_free (&ev);
+ return NULL;
}
- return g_strdup_printf ("%s/%s%s/calendar.ics", g_get_home_dir (),
- parent, name);
-}
+ CORBA_exception_free (&ev);
+
+ for (i = 0; i < storage_list->_length; i++) {
+ CORBA_exception_init (&ev);
+ corba_folder = GNOME_Evolution_Storage_getFolderAtPath (storage_list->_buffer[i],
+ folderpath, &ev);
+ if (BONOBO_EX (&ev))
+ g_warning (_("Can't call getFolderAtPath on storage: %s"), CORBA_exception_id (&ev));
+ CORBA_exception_free (&ev);
+
+ if (corba_folder) {
+ ici->folder_contains_events = FALSE;
+ ici->folder_contains_tasks = FALSE;
+
+ if (!strncmp (corba_folder->physicalUri, "file:", 5)) {
+ if (!strcmp (corba_folder->type, "tasks")) {
+ ici->folder_contains_tasks = TRUE;
+ uri = g_strdup_printf ("%s/tasks.ics",
+ corba_folder->physicalUri);
+ }
+ else if (!strcmp (corba_folder->type, "calendar")) {
+ ici->folder_contains_events = TRUE;
+ uri = g_strdup_printf ("%s/calendar.ics",
+ corba_folder->physicalUri);
+ }
+ } else {
+ uri = g_strdup (corba_folder->physicalUri);
+
+ if (!strcmp (corba_folder->type, "tasks"))
+ ici->folder_contains_tasks = TRUE;
+ else if (!strcmp (corba_folder->type, "calendar"))
+ ici->folder_contains_events = TRUE;
+ }
+ CORBA_free (corba_folder);
+ break;
+ }
+ }
-/* Determine whether it is a calendar or tasks folder, or both. If it starts
- with 'file:' we know it is a local folder so we see if it ends with
- calendar.ics or tasks.ics. For remote folders (i.e. Exchange folders at
- present), we import both calendar events and tasks into it. */
-static void
-check_folder_type (ICalImporter *ici,
- const char *folderpath)
-{
- ici->folder_contains_events = TRUE;
- ici->folder_contains_tasks = TRUE;
+ CORBA_free (storage_list);
- /* FIXME: Finish. */
+ return uri;
}
@@ -324,8 +378,7 @@ load_file_fn (EvolutionImporter *importer,
g_return_val_if_fail (ici != NULL, FALSE);
- uri_str = get_uri_from_folder_path (folderpath);
- check_folder_type (ici, folderpath);
+ uri_str = get_uri_from_folder_path (ici, folderpath);
contents = read_file (filename);
@@ -363,6 +416,7 @@ ical_importer_new (void)
process_item_fn,
NULL,
ici);
+ connect_to_shell (ici);
gtk_signal_connect (GTK_OBJECT (ici->importer), "destroy",
GTK_SIGNAL_FUNC (importer_destroy_cb), ici);
@@ -456,8 +510,7 @@ vcal_load_file_fn (EvolutionImporter *importer,
g_return_val_if_fail (ici != NULL, FALSE);
- uri_str = get_uri_from_folder_path (folderpath);
- check_folder_type (ici, folderpath);
+ uri_str = get_uri_from_folder_path (ici, folderpath);
icalcomp = load_vcalendar_file (filename);
if (icalcomp) {
@@ -487,6 +540,7 @@ vcal_importer_new (void)
process_item_fn,
NULL,
ici);
+ connect_to_shell (ici);
gtk_signal_connect (GTK_OBJECT (ici->importer), "destroy",
GTK_SIGNAL_FUNC (importer_destroy_cb), ici);
diff --git a/calendar/importers/main.c b/calendar/importers/main.c
index f6d5788d93..d5f0de1b50 100644
--- a/calendar/importers/main.c
+++ b/calendar/importers/main.c
@@ -47,7 +47,7 @@ importer_factory_fn (BonoboGenericFactory *factory, const char *id, void *closur
else if (!strcmp (id, GNOME_CALENDAR_IMPORTER_ID))
object = gnome_calendar_importer_new ();
else
- g_warning ("Component not supporte by this factory");
+ g_warning ("Component not supported by this factory");
return object;
}