diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/Makefile.am | 9 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit.c | 210 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit.h | 13 | ||||
-rw-r--r-- | calendar/gui/corba-cal.c | 23 |
4 files changed, 199 insertions, 56 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index b4d349f936..ed17a8aa6c 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -106,7 +106,8 @@ calendar_pilot_sync_SOURCES = \ LINK_FLAGS = \ $(GNOME_LIBDIR) \ $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) ../libversit/libversit.a + $(INTLLIBS) \ + ../libversit/libversit.la calendar_pilot_sync_LDADD = \ $(PISOCK_LIBS) \ @@ -126,15 +127,13 @@ libcalendar_conduit_la_SOURCES = \ GnomeCal-common.c \ GnomeCal-stubs.c \ calendar.c \ - vcc.c \ - vcaltmp.c \ - vobject.c \ timeutil.c libcalendar_conduit_la_LDFLAGS = \ -rpath $(libdir) libcalendar_conduit_la_LIBADD = \ + ../libversit/libversit.la \ $(PISOCK_LIBS) \ $(GNOME_LIBDIR) \ $(GNOME_LIBS) @@ -199,7 +198,7 @@ EXTRA_DIST = \ bell.xpm \ recur.xpm \ $(idl_DATA) \ - $(gnorba_DATA) \ + $(gnorba_DATA) Productivitydir = $(datadir)/gnome/apps/Applications diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c index 8f5835e4ef..c931b15174 100644 --- a/calendar/gui/calendar-conduit.c +++ b/calendar/gui/calendar-conduit.c @@ -49,8 +49,6 @@ CORBA_ORB orb; static GNOME_Calendar_Repository calendar_server (void) { - int n =0; - calendar = goad_server_activate_with_id (NULL, "IDL:GNOME:Calendar:Repository:1.0", 0, NULL); if (calendar == CORBA_OBJECT_NIL) @@ -71,6 +69,64 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data) { } +static void +local_from_ical(CalLocalRecord **local,iCalObject *obj) { + g_return_if_fail(local!=NULL); + g_return_if_fail(*local!=NULL); + g_return_if_fail(obj!=NULL); + + (*local)->ical = obj; + (*local)->ID = (*local)->ical->pilot_id; + + g_message("(*local)->Id = %ld",(*local)->ID); + switch((*local)->ical->pilot_status) { + case ICAL_PILOT_SYNC_NONE: (*local)->local.attr = RecordNothing; break; + case ICAL_PILOT_SYNC_MOD: (*local)->local.attr = RecordNew; break; + case ICAL_PILOT_SYNC_DEL: (*local)->local.attr = RecordDeleted; break; + } + + (*local)->local.secret = 0; + if(obj->class!=NULL) + if(strcmp(obj->class,"PRIVATE")==0) + (*local)->local.secret = 1; + + (*local)->local.archived = 0; + + /* used by iterations */ + (*local)->list_ptr = NULL; +} + +static CalLocalRecord * +match_record_from_repository(PilotRecord *remote) { + char *vcal_string; + CalLocalRecord *loc; + + g_return_val_if_fail(remote!=NULL,NULL); + + printf ("requesting %ld []\n", remote->ID); + + /* FIXME: ehm, who frees this string ? */ + vcal_string = + GNOME_Calendar_Repository_get_object_by_pilot_id (calendar, remote->ID, &ev); + + if (ev._major == CORBA_USER_EXCEPTION){ + printf (_("\tObject did not exist\n")); + return NULL; + } else if(ev._major != CORBA_NO_EXCEPTION) { + printf(_("\tError while communicating with calendar server\n")); + CORBA_exception_free(&ev); + return NULL; + } else { + printf ("\tFound\n"); + loc = g_new0(CalLocalRecord,1); + /* memory allocated in new_from_string is freed in free_match */ + local_from_ical(&loc,ical_object_new_from_string (vcal_string)); + return loc; + } + + return NULL; +} + /* Code blatantly stolen from * calendar-pilot-sync.c: * @@ -97,7 +153,8 @@ update_record (PilotRecord *remote) g_get_user_name (), a.description ? a.description : ""); - printf ("requesting %d [%s]\n", remote->ID, a.description); + printf ("requesting %ld [%s]\n", remote->ID, a.description); + /* FIXME: ehm, who frees this string ? */ vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (calendar, remote->ID, &ev); if (ev._major == CORBA_USER_EXCEPTION){ @@ -277,7 +334,7 @@ load_records(GnomePilotConduit *c) ConduitData *cd; vcalendar_string = - GNOME_Calendar_Repository_get_updated_objects (calendar, &ev); + GNOME_Calendar_Repository_get_objects (calendar, &ev); cd = GET_DATA(c); g_assert(cd!=NULL); @@ -314,46 +371,69 @@ pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) return 1; } +/** + * Find (if possible) the local record which matches + * the given PilotRecord. + * if successfull, return non-zero and set *local to + * a non-null value (the located local record), + * otherwise return 0 and set *local = NULL; + */ + static gint -match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord **local, +match_record (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord **local, PilotRecord *remote, gpointer data) { g_return_val_if_fail(remote!=NULL,0); - g_print ("in match_record\n"); - *local = NULL; - return 1; + g_print ("in match_record\n"); + + *local = match_record_from_repository(remote); + + return 1; } + +/** + * Free the data allocated by a previous match_record call. + * If successfull, return non-zero and ser *local=NULL, otherwise + * return 0. + */ static gint -free_match (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord **local, +free_match (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord **local, gpointer data) { g_print ("entering free_match\n"); + ical_object_destroy (CALLOCALRECORD(*local)->ical); + g_free(*local); + *local = NULL; - return 0; + return 1; } + + static gint -archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +archive_local (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, gpointer data) { g_print ("entering archive_local\n"); return 1; } + static gint -archive_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +archive_remote (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, PilotRecord *remote, gpointer data) { g_print ("entering archive_remote\n"); return 1; } + static gint -store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, +store_remote (GnomePilotConduitStandardAbs *conduit, PilotRecord *remote, gpointer data) { @@ -364,103 +444,147 @@ store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, return 1; } + static gint -clear_status_archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +clear_status_archive_local (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, gpointer data) { g_print ("entering clear_status_archive_local\n"); return 1; } + static gint -iterate (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord **local, +iterate (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord **local, gpointer data) { - g_print ("entering iterate\n"); - return 1; + g_return_val_if_fail(local!=NULL,0); + + if(*local==NULL) { + g_message("calconduit: beginning iteration"); + if(GET_DATA(conduit)->cal->events!=NULL) { + *local = g_new0(CalLocalRecord,1); + + local_from_ical(local,(iCalObject*)GET_DATA(conduit)->cal->events->data); + (*local)->list_ptr = GET_DATA(conduit)->cal->events; + } else { + g_message("calconduit: no events"); + (*local) = NULL; + } + } else { + g_message("calconduit: continuing iteration"); + if(g_list_next((*local)->list_ptr)==NULL) { + g_message("calconduit: ending"); + g_free((*local)); + (*local) = NULL; /* ends iteration */ + } else { + local_from_ical(local,(iCalObject*)(g_list_next((*local)->list_ptr)->data)); + (*local)->list_ptr = g_list_next((*local)->list_ptr); + } + } + return 1; } + static gint -iterate_specific (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord **local, +iterate_specific (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord **local, gint flag, gint archived, gpointer data) { - g_print ("entering iterate_specific\n"); - return 1; + g_return_val_if_fail(local!=NULL,0); + + g_print ("entering iterate_specific\n"); + do { + gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local); + if((*local)==NULL) break; + if(archived && ((*local)->local.archived==archived)) break; + if((*local)->local.attr == flag) break; + } while((*local)!=NULL); + + return 1; } + static gint -purge (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, +purge (GnomePilotConduitStandardAbs *conduit, gpointer data) { g_print ("entering purge\n"); return 1; } + static gint -set_status (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +set_status (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, gint status, gpointer data) { g_print ("entering set_status\n"); return 0; } + static gint -set_archived (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +set_archived (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, gint archived, gpointer data) { g_print ("entering set_archived\n"); return 1; } + static gint -set_pilot_id (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +set_pilot_id (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, guint32 ID, gpointer data) { g_print ("entering set_pilot_id\n"); return 1; } + static gint -compare (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +compare (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, PilotRecord *remote, gpointer data) { g_print ("entering compare\n"); return 1; } + static gint -compare_backup (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +compare_backup (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, PilotRecord *remote, gpointer data) { g_print ("entering compare_backup\n"); return 1; } + static gint -free_transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +free_transmit (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, PilotRecord *remote, gpointer data) { g_print ("entering free_transmit\n"); return 1; } + static gint -delete_all (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, +delete_all (GnomePilotConduitStandardAbs *conduit, gpointer data) { g_print ("entering delete_all\n"); return 1; } + static PilotRecord * -transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs, - LocalRecord *local, +transmit (GnomePilotConduitStandardAbs *conduit, + CalLocalRecord *local, gpointer data) { g_print ("entering transmit\n"); diff --git a/calendar/gui/calendar-conduit.h b/calendar/gui/calendar-conduit.h index 5b7be2367d..2f5cc0c7da 100644 --- a/calendar/gui/calendar-conduit.h +++ b/calendar/gui/calendar-conduit.h @@ -9,6 +9,19 @@ #include <pi-datebook.h> #include <gnome.h> +#define CALLOCALRECORD(s) ((CalLocalRecord*)(s)) +typedef struct _CalLocalRecord CalLocalRecord; + +struct _CalLocalRecord { + /* The stuff from gnome-pilot-conduit-standard-abs.h */ + LocalRecord local; + /* The Pilot ID of the record */ + recordid_t ID; + /* The corresponding iCal object */ + iCalObject *ical; + /* used by iterations, points to a GList element */ + GList *list_ptr; +}; typedef struct _ConduitCfg ConduitCfg; diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c index 787c913418..8c6246da14 100644 --- a/calendar/gui/corba-cal.c +++ b/calendar/gui/corba-cal.c @@ -45,7 +45,7 @@ gnomecal_from_servant (PortableServer_Servant servant) static CORBA_char * cal_repo_get_object (PortableServer_Servant servant, - CORBA_char *uid, + const CORBA_char *uid, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); @@ -131,7 +131,7 @@ cal_repo_get_id_from_pilot_id (PortableServer_Servant servant, static void cal_repo_delete_object (PortableServer_Servant servant, - CORBA_char *uid, + const CORBA_char *uid, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); @@ -153,8 +153,8 @@ cal_repo_delete_object (PortableServer_Servant servant, static void cal_repo_update_object (PortableServer_Servant servant, - CORBA_char *uid, - CORBA_char *vcalendar_object, + const CORBA_char *uid, + const CORBA_char *vcalendar_object, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); @@ -173,9 +173,9 @@ cal_repo_update_object (PortableServer_Servant servant, static void cal_repo_update_pilot_id (PortableServer_Servant servant, - CORBA_char *uid, - CORBA_long pilot_id, - CORBA_long pilot_status, + const CORBA_char *uid, + const CORBA_long pilot_id, + const CORBA_long pilot_status, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); @@ -207,7 +207,10 @@ cal_repo_get_objects (PortableServer_Servant servant, GList *l; char *str; CORBA_char *res; - + + int items_dbg=0; + g_message("in cal_repo_get_objects"); + dirty_cal = calendar_new ("Temporal"); for (l = gcal->cal->events; l; l = l->next){ @@ -216,12 +219,16 @@ cal_repo_get_objects (PortableServer_Servant servant, obj = ical_object_duplicate (l->data); calendar_add_object (dirty_cal, obj); + + items_dbg++; } str = calendar_get_as_vcal_string (dirty_cal); res = CORBA_string_dup (str); g_free (str); calendar_destroy (dirty_cal); + g_message("added %d items to return value",items_dbg); + return res; } |