diff options
author | Eskil Heyn Olsen <eskil@src.gnome.org> | 1999-09-08 21:06:07 +0800 |
---|---|---|
committer | Eskil Heyn Olsen <eskil@src.gnome.org> | 1999-09-08 21:06:07 +0800 |
commit | 8550ca3f28108f315db18a0edc508f6e682b66fd (patch) | |
tree | dc34b88b0922da48c1acb8f19eb2f17d3c7846ad /calendar/calendar-conduit.c | |
parent | 4a3be146661da5d5267af57482ba0a22656166f5 (diff) | |
download | gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.gz gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.bz2 gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.lz gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.xz gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.tar.zst gsoc2013-evolution-8550ca3f28108f315db18a0edc508f6e682b66fd.zip |
uses GNOME_PILOT_CHECK
* configure.in: uses GNOME_PILOT_CHECK
* gncal/GnomeCal.idl: added a get_objects() call,
which returns all the objects in the calendar.
* gncal/Makefile.am: added two conduits with
control-applets. Compiled only if configure sets
HAVE_GNOME_PILOT
* gncal/calender-conduit.[ch]: began implementing conduit.
* gncal/todo-conduit.[ch]: begin implementing conduit.
* gncal/corba-cal.c: implemented the get_objects() call.
svn path=/trunk/; revision=1216
Diffstat (limited to 'calendar/calendar-conduit.c')
-rw-r--r-- | calendar/calendar-conduit.c | 126 |
1 files changed, 121 insertions, 5 deletions
diff --git a/calendar/calendar-conduit.c b/calendar/calendar-conduit.c index d9658f08a3..f7d1ebdd71 100644 --- a/calendar/calendar-conduit.c +++ b/calendar/calendar-conduit.c @@ -16,9 +16,93 @@ #include <pwd.h> #include <signal.h> #include <errno.h> + +#include <libgnorba/gnorba.h> +#include <libgnorba/gnome-factory.h> + #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-standard-abs.h> +#include "GnomeCal.h" +#include "calobj.h" +#include "calendar.h" + +#include "calendar-conduit.h" + +typedef struct _ConduitData ConduitData; + +struct _ConduitData { + struct AppointmentAppInfo ai; + Calendar *cal; +}; + +#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data")) + +GNOME_Calendar_Repository calendar; +CORBA_Environment ev; + +static GNOME_Calendar_Repository +calendar_server (void) +{ + if(calendar!=CORBA_OBJECT_NIL) return calendar; + + calendar = goad_server_activate_with_id (NULL, "IDL:GNOME:Calendar:Repository:1.0", + 0, NULL); + + if (calendar == CORBA_OBJECT_NIL) + g_error ("Can not communicate with GnomeCalendar server"); + + if (ev._major != CORBA_NO_EXCEPTION){ + printf ("Exception: %s\n", CORBA_exception_id (&ev)); + abort (); + } + + return calendar; +} + +static gint +load_records(GnomePilotConduit *c) +{ + char *vcalendar_string; + char *error; + ConduitData *cd; + + vcalendar_string = + GNOME_Calendar_Repository_get_updated_objects (calendar_server(), &ev); + + cd = GET_DATA(c); + cd->cal = calendar_new("Temporary"); + + error = calendar_load_from_memory(cd->cal,vcalendar_string); + + return 0; +} + +static gint +pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) +{ + int l; + unsigned char *buf; + + gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); + + load_records(c); + + buf = (unsigned char*)g_malloc(0xffff); + if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) { + return -1; + } + unpack_AppointmentAppInfo(&(GET_DATA(c)->ai),buf,l); + g_free(buf); + + return 0; +} + +static gint +post_sync(GnomePilotConduit *c) +{ + return 0; +} static gint match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, @@ -169,15 +253,31 @@ transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, return NULL; } -GnomePilotConduit * +static GnomePilotConduit * conduit_get_gpilot_conduit (guint32 pilotId) { GtkObject *retval; + ConduitCfg *cfg; + ConduitData *cdata; + + CORBA_exception_init (&ev); g_print ("creating our new conduit\n"); retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465); - g_assert (retval != NULL); + gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"calendar"); + + cfg = g_new0(ConduitCfg,1); + g_assert(cfg != NULL); + gtk_object_set_data(retval,"conduit_cfg",cfg); + + cdata = g_new0(ConduitData,1); + g_assert(cdata != NULL); + cdata = NULL; + gtk_object_set_data(retval,"conduit_data",cdata); + + calendar = CORBA_OBJECT_NIL; + gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL); gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL); @@ -195,14 +295,30 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL); gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL); gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL); - g_print ("*\n*\n Done connecting signals\n\n"); + gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL); + gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL); + + load_configuration(&cfg,pilotId); return GNOME_PILOT_CONDUIT (retval); } -void + +static void conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit) -{ +{ + ConduitCfg *cc; + ConduitData *cd; + + cc = GET_CONFIG(conduit); + destroy_configuration(&cc); + + cd = GET_DATA(conduit); + if(cd->cal!=NULL) calendar_destroy(cd->cal); + gtk_object_destroy (GTK_OBJECT (conduit)); + + GNOME_Calendar_Repository_done (calendar_server(), &ev); + } |