aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-07-28 23:12:12 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-07-28 23:12:12 +0800
commitc2c3a8ce6a51126ce0a5f368801b9af33372fb79 (patch)
tree6849aed7ed360f6cf933e65c5fe3bab49d2591af
parente49e9cc1755266dade86ce33662ceff466f5ca07 (diff)
downloadgsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar.gz
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar.bz2
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar.lz
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar.xz
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.tar.zst
gsoc2013-evolution-c2c3a8ce6a51126ce0a5f368801b9af33372fb79.zip
Add the missing files -miguel
svn path=/trunk/; revision=1039
-rw-r--r--calendar/.cvsignore4
-rw-r--r--calendar/GnomeCal.idl55
-rw-r--r--calendar/corba-cal-factory.c130
-rw-r--r--calendar/corba-cal-factory.h11
-rw-r--r--calendar/corba-cal.c209
-rw-r--r--calendar/corba-cal.h6
-rw-r--r--calendar/gnomecal.gnorba11
-rw-r--r--calendar/gui/GnomeCal.idl55
-rw-r--r--calendar/gui/corba-cal-factory.c130
-rw-r--r--calendar/gui/corba-cal-factory.h11
-rw-r--r--calendar/gui/corba-cal.c209
-rw-r--r--calendar/gui/corba-cal.h6
-rw-r--r--calendar/gui/gnomecal.gnorba11
13 files changed, 848 insertions, 0 deletions
diff --git a/calendar/.cvsignore b/calendar/.cvsignore
index 2664490d31..7f966ac096 100644
--- a/calendar/.cvsignore
+++ b/calendar/.cvsignore
@@ -6,3 +6,7 @@ _libs
gncal
gnomecal
getdate.c
+GnomeCal-skels.c
+GnomeCal-common.c
+GnomeCal.h
+calendar-pilot-sync
diff --git a/calendar/GnomeCal.idl b/calendar/GnomeCal.idl
new file mode 100644
index 0000000000..bfeb502518
--- /dev/null
+++ b/calendar/GnomeCal.idl
@@ -0,0 +1,55 @@
+module GNOME {
+
+ module Calendar {
+
+ interface Repository {
+
+ exception NotFound {};
+
+ /*
+ * get_object:
+ * @uid: Unique Identifier for the object
+ *
+ * Returns a vCalendar object for the object
+ * that matches the UID @uid
+ */
+ string get_object (in string uid)
+ raises (NotFound);
+
+ /*
+ * get_object_by_pilot_id:
+ * @pilot_id: the pilot id
+ *
+ * Returns the object that has the @pilot_id
+ * identifier.
+ */
+ string get_object_by_pilot_id (in long pilot_id)
+ raises (NotFound);
+
+ string get_id_from_pilot_id (in long pilot_id)
+ raises (NotFound);
+
+ /*
+ * delete_object:
+ * @uid: Unique Identifier for the object
+ */
+ void delete_object (in string uid)
+ raises (NotFound);
+
+ /*
+ * update_object:
+ * @uid: uid of object to update
+ * @object: vcard object to update
+ */
+ void update_object (in string uid, in string object);
+
+ /*
+ * done:
+ *
+ * Informs the calendar that we are done using it,
+ * gets a chance to destroy windows and save information.
+ */
+ void done ();
+ };
+ };
+};
diff --git a/calendar/corba-cal-factory.c b/calendar/corba-cal-factory.c
new file mode 100644
index 0000000000..49a2c5ac76
--- /dev/null
+++ b/calendar/corba-cal-factory.c
@@ -0,0 +1,130 @@
+/*
+ * corba-cal-factory.c: Service that provides access to the calendar repositories.
+ *
+ * Author:
+ * Miguel de Icaza (miguel@gnu.org)
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "gnome-cal.h"
+#include "main.h"
+#include "alarm.h"
+#include "timeutil.h"
+#include "../libversit/vcc.h"
+#include <libgnorba/gnome-factory.h>
+#include <libgnorba/gnorba.h>
+#include "GnomeCal.h"
+#include "corba-cal-factory.h"
+#include "corba-cal.h"
+
+CORBA_ORB orb;
+PortableServer_POA poa;
+PortableServer_POAManager poa_manager;
+
+static POA_GNOME_GenericFactory__epv calendar_epv;
+static POA_GNOME_GenericFactory__vepv calendar_vepv;
+
+/*
+ * Servant and Object Factory
+ */
+static POA_GNOME_GenericFactory calendar_servant;
+static GNOME_GenericFactory calendar_factory;
+
+static CORBA_boolean
+calendar_supports (PortableServer_Servant servant,
+ const CORBA_char * obj_goad_id,
+ CORBA_Environment * ev)
+{
+ if (strcmp (obj_goad_id, "IDL:GNOME:Calendar:Repository:1.0") == 0)
+ return CORBA_TRUE;
+ else
+ return CORBA_FALSE;
+}
+
+static CORBA_Object
+calendar_create_object (PortableServer_Servant servant,
+ const CORBA_char *goad_id,
+ const GNOME_stringlist *params,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal;
+ struct stat s;
+ char *name;
+
+ if (params->_length == 1)
+ name = params->_buffer [0];
+ else
+ name = NULL;
+
+ if (strcmp (goad_id, "IDL:GNOME:Calendar:Repository:1.0") != 0){
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_GenericFactory_CannotActivate,
+ NULL);
+ return CORBA_OBJECT_NIL;
+ }
+
+ gcal = gnome_calendar_locate (name);
+ if (gcal != NULL)
+ return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+
+ if (stat (name, &s) != 0){
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_GenericFactory_CannotActivate,
+ NULL);
+ return CORBA_OBJECT_NIL;
+ }
+
+ gcal = new_calendar ("", name, NULL, NULL, FALSE);
+
+ return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+}
+
+void
+init_corba_server (void)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION){
+ g_warning ("Can not get the POA manager");
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ PortableServer_POAManager_activate (poa_manager, &ev);
+
+ /* First create the locator for the repositories as a factory object */
+ calendar_vepv.GNOME_GenericFactory_epv = &calendar_epv;
+ calendar_epv.supports = calendar_supports;
+ calendar_epv.create_object = calendar_create_object;
+
+ calendar_servant.vepv = &calendar_vepv;
+ POA_GNOME_GenericFactory__init ((PortableServer_Servant) &calendar_servant, &ev);
+ CORBA_free (PortableServer_POA_activate_object (
+ poa, (PortableServer_Servant)&calendar_servant, &ev));
+
+ calendar_factory = PortableServer_POA_servant_to_reference (
+ poa, (PortableServer_Servant) &calendar_servant, &ev);
+
+ goad_server_register (
+ CORBA_OBJECT_NIL, calendar_factory,
+ "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
+ CORBA_exception_free (&ev);
+}
+
+void
+unregister_calendar_services (void)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ goad_server_unregister (
+ CORBA_OBJECT_NIL,
+ "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
+ CORBA_exception_free (&ev);
+}
diff --git a/calendar/corba-cal-factory.h b/calendar/corba-cal-factory.h
new file mode 100644
index 0000000000..5d3bcb3140
--- /dev/null
+++ b/calendar/corba-cal-factory.h
@@ -0,0 +1,11 @@
+#ifndef _CORBA_CAL_FACTORY_H_
+#define _CORBA_CAL_FACTORY_H_
+
+/* The CORBA globals */
+CORBA_ORB orb;
+PortableServer_POA poa;
+
+void corba_server_init (void);
+void unregister_calendar_services (void);
+
+#endif /* _CORBA_CAL_FACTORY_H_ */
diff --git a/calendar/corba-cal.c b/calendar/corba-cal.c
new file mode 100644
index 0000000000..d78685bf90
--- /dev/null
+++ b/calendar/corba-cal.c
@@ -0,0 +1,209 @@
+/*
+ * corba-cal.c: Service that provides access to the calendar repository
+ *
+ * Author:
+ * Miguel de Icaza (miguel@gnu.org)
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+#include "alarm.h"
+#include "timeutil.h"
+#include "../libversit/vcc.h"
+#include <libgnorba/gnome-factory.h>
+#include "GnomeCal.h"
+#include "corba-cal-factory.h"
+#include "corba-cal.h"
+
+typedef struct {
+ POA_GNOME_Calendar_Repository servant;
+ GnomeCalendar *calendar;
+} CalendarServant;
+
+/*
+ * Vectors
+ */
+static POA_GNOME_Calendar_Repository__epv calendar_repository_epv;
+static POA_GNOME_Calendar_Repository__vepv calendar_repository_vepv;
+
+/*
+ * Servant and Object Factory
+ */
+static POA_GNOME_Calendar_Repository calendar_repository_servant;
+
+static inline GnomeCalendar *
+gnomecal_from_servant (PortableServer_Servant servant)
+{
+ CalendarServant *cs = (CalendarServant *) servant;
+
+ return cs->calendar;
+}
+
+static CORBA_char *
+cal_repo_get_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ char *buffer;
+ CORBA_char *ret;
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj == NULL){
+ CORBA_exception_set (
+ ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound,
+ "");
+ return NULL;
+ }
+
+ buffer = calendar_string_from_object (obj);
+ ret = CORBA_string_dup (buffer);
+ free (buffer);
+
+ return ret;
+}
+
+static CORBA_char *
+cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
+ CORBA_long pilot_id,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ char *buffer;
+ CORBA_char *ret;
+
+ obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, "");
+ return NULL;
+ }
+
+ buffer = calendar_string_from_object (obj);
+ ret = CORBA_string_dup (buffer);
+ free (buffer);
+
+ return ret;
+
+}
+
+static CORBA_char *
+cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
+ CORBA_long pilot_id,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+
+ obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, "");
+ return NULL;
+ }
+
+ return CORBA_string_dup (obj->uid);
+}
+
+static void
+cal_repo_delete_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, NULL);
+ return;
+ }
+
+ gnome_calendar_remove_object (gcal, obj);
+}
+
+static void
+cal_repo_update_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_char *vcalendar_object,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ iCalObject *new_object;
+
+ new_object = ical_object_new_from_string (vcalendar_object);
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj != NULL){
+ calendar_remove_object (gcal->cal, obj);
+ }
+
+ calendar_add_object (gcal->cal, new_object);
+}
+
+static void
+cal_repo_done (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+
+ calendar_save (gcal->cal, NULL);
+}
+
+static void
+init_calendar_repo_class (void)
+{
+ calendar_repository_epv.get_object = cal_repo_get_object;
+ calendar_repository_epv.get_object_by_pilot_id = cal_repo_get_object_by_pilot_id;
+ calendar_repository_epv.get_id_from_pilot_id = cal_repo_get_id_from_pilot_id;
+ calendar_repository_epv.delete_object = cal_repo_delete_object;
+ calendar_repository_epv.update_object = cal_repo_update_object;
+ calendar_repository_epv.done = cal_repo_done;
+
+ calendar_repository_vepv.GNOME_Calendar_Repository_epv =
+ &calendar_repository_epv;
+
+ calendar_repository_servant.vepv = &calendar_repository_vepv;
+}
+
+/*
+ * Initializes the CORBA parts of the @calendar object
+ */
+void
+gnome_calendar_create_corba_server (GnomeCalendar *calendar)
+{
+ static gboolean class_inited = FALSE;
+ CalendarServant *calendar_servant;
+ CORBA_Environment ev;
+
+ if (!class_inited){
+ init_calendar_repo_class ();
+ class_inited = TRUE;
+ }
+
+ calendar_servant = g_new0 (CalendarServant, 1);
+ calendar_servant->servant.vepv = &calendar_repository_vepv;
+ calendar_servant->calendar = calendar;
+
+ CORBA_exception_init (&ev);
+ POA_GNOME_Calendar_Repository__init ((PortableServer_Servant) calendar_servant, &ev);
+ CORBA_free (
+ PortableServer_POA_activate_object (poa, calendar_servant, &ev));
+ calendar->cal->corba_server = PortableServer_POA_servant_to_reference (
+ poa, calendar_servant, &ev);
+ CORBA_exception_free (&ev);
+}
+
diff --git a/calendar/corba-cal.h b/calendar/corba-cal.h
new file mode 100644
index 0000000000..47caacba70
--- /dev/null
+++ b/calendar/corba-cal.h
@@ -0,0 +1,6 @@
+#ifndef _CORBA_CAL_H_
+#define _CORBA_CAL_H_
+
+void gnome_calendar_create_corba_server (GnomeCalendar *calendar);
+
+#endif /* _CORBA_CAL_H_ */
diff --git a/calendar/gnomecal.gnorba b/calendar/gnomecal.gnorba
new file mode 100644
index 0000000000..ec970fc046
--- /dev/null
+++ b/calendar/gnomecal.gnorba
@@ -0,0 +1,11 @@
+[IDL:GNOME:Calendar:Repository:1.0]
+type=factory
+repo_id=IDL:Gnome/Calendar/Repository:1.0
+description=Calendar Repository
+location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0
+
+[IDL:GNOME:Calendar:RepositoryLocator:1.0]
+type=exe
+repo_id=IDL:GNOME/GenericFactoy:1.0
+description=Calendar Server
+location_info=gnomecal
diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl
new file mode 100644
index 0000000000..bfeb502518
--- /dev/null
+++ b/calendar/gui/GnomeCal.idl
@@ -0,0 +1,55 @@
+module GNOME {
+
+ module Calendar {
+
+ interface Repository {
+
+ exception NotFound {};
+
+ /*
+ * get_object:
+ * @uid: Unique Identifier for the object
+ *
+ * Returns a vCalendar object for the object
+ * that matches the UID @uid
+ */
+ string get_object (in string uid)
+ raises (NotFound);
+
+ /*
+ * get_object_by_pilot_id:
+ * @pilot_id: the pilot id
+ *
+ * Returns the object that has the @pilot_id
+ * identifier.
+ */
+ string get_object_by_pilot_id (in long pilot_id)
+ raises (NotFound);
+
+ string get_id_from_pilot_id (in long pilot_id)
+ raises (NotFound);
+
+ /*
+ * delete_object:
+ * @uid: Unique Identifier for the object
+ */
+ void delete_object (in string uid)
+ raises (NotFound);
+
+ /*
+ * update_object:
+ * @uid: uid of object to update
+ * @object: vcard object to update
+ */
+ void update_object (in string uid, in string object);
+
+ /*
+ * done:
+ *
+ * Informs the calendar that we are done using it,
+ * gets a chance to destroy windows and save information.
+ */
+ void done ();
+ };
+ };
+};
diff --git a/calendar/gui/corba-cal-factory.c b/calendar/gui/corba-cal-factory.c
new file mode 100644
index 0000000000..49a2c5ac76
--- /dev/null
+++ b/calendar/gui/corba-cal-factory.c
@@ -0,0 +1,130 @@
+/*
+ * corba-cal-factory.c: Service that provides access to the calendar repositories.
+ *
+ * Author:
+ * Miguel de Icaza (miguel@gnu.org)
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "gnome-cal.h"
+#include "main.h"
+#include "alarm.h"
+#include "timeutil.h"
+#include "../libversit/vcc.h"
+#include <libgnorba/gnome-factory.h>
+#include <libgnorba/gnorba.h>
+#include "GnomeCal.h"
+#include "corba-cal-factory.h"
+#include "corba-cal.h"
+
+CORBA_ORB orb;
+PortableServer_POA poa;
+PortableServer_POAManager poa_manager;
+
+static POA_GNOME_GenericFactory__epv calendar_epv;
+static POA_GNOME_GenericFactory__vepv calendar_vepv;
+
+/*
+ * Servant and Object Factory
+ */
+static POA_GNOME_GenericFactory calendar_servant;
+static GNOME_GenericFactory calendar_factory;
+
+static CORBA_boolean
+calendar_supports (PortableServer_Servant servant,
+ const CORBA_char * obj_goad_id,
+ CORBA_Environment * ev)
+{
+ if (strcmp (obj_goad_id, "IDL:GNOME:Calendar:Repository:1.0") == 0)
+ return CORBA_TRUE;
+ else
+ return CORBA_FALSE;
+}
+
+static CORBA_Object
+calendar_create_object (PortableServer_Servant servant,
+ const CORBA_char *goad_id,
+ const GNOME_stringlist *params,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal;
+ struct stat s;
+ char *name;
+
+ if (params->_length == 1)
+ name = params->_buffer [0];
+ else
+ name = NULL;
+
+ if (strcmp (goad_id, "IDL:GNOME:Calendar:Repository:1.0") != 0){
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_GenericFactory_CannotActivate,
+ NULL);
+ return CORBA_OBJECT_NIL;
+ }
+
+ gcal = gnome_calendar_locate (name);
+ if (gcal != NULL)
+ return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+
+ if (stat (name, &s) != 0){
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_GenericFactory_CannotActivate,
+ NULL);
+ return CORBA_OBJECT_NIL;
+ }
+
+ gcal = new_calendar ("", name, NULL, NULL, FALSE);
+
+ return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+}
+
+void
+init_corba_server (void)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION){
+ g_warning ("Can not get the POA manager");
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ PortableServer_POAManager_activate (poa_manager, &ev);
+
+ /* First create the locator for the repositories as a factory object */
+ calendar_vepv.GNOME_GenericFactory_epv = &calendar_epv;
+ calendar_epv.supports = calendar_supports;
+ calendar_epv.create_object = calendar_create_object;
+
+ calendar_servant.vepv = &calendar_vepv;
+ POA_GNOME_GenericFactory__init ((PortableServer_Servant) &calendar_servant, &ev);
+ CORBA_free (PortableServer_POA_activate_object (
+ poa, (PortableServer_Servant)&calendar_servant, &ev));
+
+ calendar_factory = PortableServer_POA_servant_to_reference (
+ poa, (PortableServer_Servant) &calendar_servant, &ev);
+
+ goad_server_register (
+ CORBA_OBJECT_NIL, calendar_factory,
+ "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
+ CORBA_exception_free (&ev);
+}
+
+void
+unregister_calendar_services (void)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ goad_server_unregister (
+ CORBA_OBJECT_NIL,
+ "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
+ CORBA_exception_free (&ev);
+}
diff --git a/calendar/gui/corba-cal-factory.h b/calendar/gui/corba-cal-factory.h
new file mode 100644
index 0000000000..5d3bcb3140
--- /dev/null
+++ b/calendar/gui/corba-cal-factory.h
@@ -0,0 +1,11 @@
+#ifndef _CORBA_CAL_FACTORY_H_
+#define _CORBA_CAL_FACTORY_H_
+
+/* The CORBA globals */
+CORBA_ORB orb;
+PortableServer_POA poa;
+
+void corba_server_init (void);
+void unregister_calendar_services (void);
+
+#endif /* _CORBA_CAL_FACTORY_H_ */
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
new file mode 100644
index 0000000000..d78685bf90
--- /dev/null
+++ b/calendar/gui/corba-cal.c
@@ -0,0 +1,209 @@
+/*
+ * corba-cal.c: Service that provides access to the calendar repository
+ *
+ * Author:
+ * Miguel de Icaza (miguel@gnu.org)
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+#include "alarm.h"
+#include "timeutil.h"
+#include "../libversit/vcc.h"
+#include <libgnorba/gnome-factory.h>
+#include "GnomeCal.h"
+#include "corba-cal-factory.h"
+#include "corba-cal.h"
+
+typedef struct {
+ POA_GNOME_Calendar_Repository servant;
+ GnomeCalendar *calendar;
+} CalendarServant;
+
+/*
+ * Vectors
+ */
+static POA_GNOME_Calendar_Repository__epv calendar_repository_epv;
+static POA_GNOME_Calendar_Repository__vepv calendar_repository_vepv;
+
+/*
+ * Servant and Object Factory
+ */
+static POA_GNOME_Calendar_Repository calendar_repository_servant;
+
+static inline GnomeCalendar *
+gnomecal_from_servant (PortableServer_Servant servant)
+{
+ CalendarServant *cs = (CalendarServant *) servant;
+
+ return cs->calendar;
+}
+
+static CORBA_char *
+cal_repo_get_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ char *buffer;
+ CORBA_char *ret;
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj == NULL){
+ CORBA_exception_set (
+ ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound,
+ "");
+ return NULL;
+ }
+
+ buffer = calendar_string_from_object (obj);
+ ret = CORBA_string_dup (buffer);
+ free (buffer);
+
+ return ret;
+}
+
+static CORBA_char *
+cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
+ CORBA_long pilot_id,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ char *buffer;
+ CORBA_char *ret;
+
+ obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, "");
+ return NULL;
+ }
+
+ buffer = calendar_string_from_object (obj);
+ ret = CORBA_string_dup (buffer);
+ free (buffer);
+
+ return ret;
+
+}
+
+static CORBA_char *
+cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
+ CORBA_long pilot_id,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+
+ obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, "");
+ return NULL;
+ }
+
+ return CORBA_string_dup (obj->uid);
+}
+
+static void
+cal_repo_delete_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj == NULL){
+ CORBA_exception_set (ev,
+ CORBA_USER_EXCEPTION,
+ ex_GNOME_Calendar_Repository_NotFound, NULL);
+ return;
+ }
+
+ gnome_calendar_remove_object (gcal, obj);
+}
+
+static void
+cal_repo_update_object (PortableServer_Servant servant,
+ CORBA_char *uid,
+ CORBA_char *vcalendar_object,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ iCalObject *obj;
+ iCalObject *new_object;
+
+ new_object = ical_object_new_from_string (vcalendar_object);
+
+ obj = calendar_object_find_event (gcal->cal, uid);
+ if (obj != NULL){
+ calendar_remove_object (gcal->cal, obj);
+ }
+
+ calendar_add_object (gcal->cal, new_object);
+}
+
+static void
+cal_repo_done (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+
+ calendar_save (gcal->cal, NULL);
+}
+
+static void
+init_calendar_repo_class (void)
+{
+ calendar_repository_epv.get_object = cal_repo_get_object;
+ calendar_repository_epv.get_object_by_pilot_id = cal_repo_get_object_by_pilot_id;
+ calendar_repository_epv.get_id_from_pilot_id = cal_repo_get_id_from_pilot_id;
+ calendar_repository_epv.delete_object = cal_repo_delete_object;
+ calendar_repository_epv.update_object = cal_repo_update_object;
+ calendar_repository_epv.done = cal_repo_done;
+
+ calendar_repository_vepv.GNOME_Calendar_Repository_epv =
+ &calendar_repository_epv;
+
+ calendar_repository_servant.vepv = &calendar_repository_vepv;
+}
+
+/*
+ * Initializes the CORBA parts of the @calendar object
+ */
+void
+gnome_calendar_create_corba_server (GnomeCalendar *calendar)
+{
+ static gboolean class_inited = FALSE;
+ CalendarServant *calendar_servant;
+ CORBA_Environment ev;
+
+ if (!class_inited){
+ init_calendar_repo_class ();
+ class_inited = TRUE;
+ }
+
+ calendar_servant = g_new0 (CalendarServant, 1);
+ calendar_servant->servant.vepv = &calendar_repository_vepv;
+ calendar_servant->calendar = calendar;
+
+ CORBA_exception_init (&ev);
+ POA_GNOME_Calendar_Repository__init ((PortableServer_Servant) calendar_servant, &ev);
+ CORBA_free (
+ PortableServer_POA_activate_object (poa, calendar_servant, &ev));
+ calendar->cal->corba_server = PortableServer_POA_servant_to_reference (
+ poa, calendar_servant, &ev);
+ CORBA_exception_free (&ev);
+}
+
diff --git a/calendar/gui/corba-cal.h b/calendar/gui/corba-cal.h
new file mode 100644
index 0000000000..47caacba70
--- /dev/null
+++ b/calendar/gui/corba-cal.h
@@ -0,0 +1,6 @@
+#ifndef _CORBA_CAL_H_
+#define _CORBA_CAL_H_
+
+void gnome_calendar_create_corba_server (GnomeCalendar *calendar);
+
+#endif /* _CORBA_CAL_H_ */
diff --git a/calendar/gui/gnomecal.gnorba b/calendar/gui/gnomecal.gnorba
new file mode 100644
index 0000000000..ec970fc046
--- /dev/null
+++ b/calendar/gui/gnomecal.gnorba
@@ -0,0 +1,11 @@
+[IDL:GNOME:Calendar:Repository:1.0]
+type=factory
+repo_id=IDL:Gnome/Calendar/Repository:1.0
+description=Calendar Repository
+location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0
+
+[IDL:GNOME:Calendar:RepositoryLocator:1.0]
+type=exe
+repo_id=IDL:GNOME/GenericFactoy:1.0
+description=Calendar Server
+location_info=gnomecal