diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/GnomeCal.idl | 12 | ||||
-rw-r--r-- | calendar/calendar-conduit.c | 82 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 82 | ||||
-rw-r--r-- | calendar/corba-cal.c | 32 | ||||
-rw-r--r-- | calendar/gui/GnomeCal.idl | 12 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit.c | 82 | ||||
-rw-r--r-- | calendar/gui/corba-cal.c | 32 |
8 files changed, 192 insertions, 162 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index b5be27f69b..53ce67a947 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2000-01-05 Eskil Heyn Olsen <deity@eskil.dk> + + * GnomeCal.idl: Added an argument to get_number_of_objects, so you + can choose which state the object should have + (any/new/modified/...). Will also add one to choose type + (event/journal etc). + + * corba-cal.c (cal_repo_get_number_of_objects): Implemented the + new version of get_number_of_objects. + + * calendar-conduit.c (pre_sync): Calls various + gnome_pilot_conduit_standard_abs_set_num_yadayda to get progress bars. + +2000-01-04 Eskil Heyn Olsen <deity@eskil.dk> + + * calendar-conduit.c (start_calendar_server): Let's not call + g_error, but g_warning instead. + (pre_sync): Get record numbers info, total, new, deleted etc, and + tell gpilotd. + 1999-12-31 Eskil Heyn Olsen <deity@eskil.dk> * eventedit.c (ee_store_recur_end_to_ical): Adds 86400 secs (1 diff --git a/calendar/GnomeCal.idl b/calendar/GnomeCal.idl index 3f9a64d291..a58358f3f1 100644 --- a/calendar/GnomeCal.idl +++ b/calendar/GnomeCal.idl @@ -97,10 +97,18 @@ module GNOME { string get_updated_objects (); /* - * Returns the number of objects in the calendar + * Returns the number of objects of a specific type in the calendar * repository. */ - long get_number_of_objects(); + + enum RecordStatus { + ANY, /* This means all records */ + NEW, + MODIFIED, + DELETED + }; + + long get_number_of_objects(in RecordStatus record_status); /* * done: diff --git a/calendar/calendar-conduit.c b/calendar/calendar-conduit.c index cb7ca2b67a..9c758b3263 100644 --- a/calendar/calendar-conduit.c +++ b/calendar/calendar-conduit.c @@ -43,7 +43,7 @@ GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); -#define CONDUIT_VERSION "0.8.10p1" +#define CONDUIT_VERSION "0.8.11" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif @@ -63,6 +63,14 @@ void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); #define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e) #define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) +#define catch_ret_val(_env,ret) \ + if (_env._major != CORBA_NO_EXCEPTION) { \ + g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \ + g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \ + CORBA_exception_free(&(_env)); \ + return ret; \ + } + static int start_calendar_server (GnomePilotConduitStandardAbs *conduit, GCalConduitContext *ctxt) @@ -75,7 +83,7 @@ start_calendar_server (GnomePilotConduitStandardAbs *conduit, "IDL:GNOME:Calendar:Repository:1.0", 0, NULL); if (ctxt->calendar == CORBA_OBJECT_NIL) { - g_error ("Can not communicate with GnomeCalendar server"); + g_warning ("Can not communicate with GnomeCalendar server"); return -1; } @@ -137,56 +145,6 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit, return result; } -#if 0 -static GList * -get_calendar_objects(GnomePilotConduitStandardAbs *conduit) -{ - char *vcalendar_string; - char *error; - GList *retval,*l; - Calendar *cal; - - g_return_val_if_fail(conduit!=NULL,NULL); - - vcalendar_string = - GNOME_Calendar_Repository_get_objects (calendar, &ev); - - cal = calendar_new("Temporary"); - - error = calendar_load_from_memory(cal,vcalendar_string); - - if (ev._major == CORBA_USER_EXCEPTION){ - INFO ("Object did not exist"); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } else if(ev._major != CORBA_NO_EXCEPTION) { - WARN (_("Error while communicating with calendar server")); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } - - if(error != NULL) { - WARN ("Error while converting records"); - WARN ("Error : %s",error); - return NULL; - } - retval = NULL; - for(l=cal->events ; l ; l=l->next) { - LOG ("duping %d [%s]", - ((iCalObject*)l->data)->pilot_id, - ((iCalObject*)l->data)->summary); - retval = g_list_prepend(retval,ical_object_duplicate(l->data)); - } - - /* g_free(vcalendar_string); FIXME: this coredumps, but won't it leak without ? */ - calendar_destroy(cal); - - return retval; -} -#endif - static void local_record_from_ical_uid(GCalLocalRecord *local, char *uid, @@ -584,6 +542,7 @@ check_for_slow_setting(GnomePilotConduit *c, CORBA_long entry_number; entry_number = GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + GNOME_Calendar_Repository_ANY, &(ctxt->ev)); if (ctxt->ev._major == CORBA_USER_EXCEPTION){ @@ -608,6 +567,7 @@ pre_sync(GnomePilotConduit *c, GCalConduitContext *ctxt) { int l; + gint num_records; unsigned char *buf; g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION); @@ -621,6 +581,24 @@ pre_sync(GnomePilotConduit *c, return -1; } + /* Set the counters for the progress bar crap */ + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); /* load_records(c); */ diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index cb7ca2b67a..9c758b3263 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -43,7 +43,7 @@ GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); -#define CONDUIT_VERSION "0.8.10p1" +#define CONDUIT_VERSION "0.8.11" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif @@ -63,6 +63,14 @@ void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); #define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e) #define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) +#define catch_ret_val(_env,ret) \ + if (_env._major != CORBA_NO_EXCEPTION) { \ + g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \ + g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \ + CORBA_exception_free(&(_env)); \ + return ret; \ + } + static int start_calendar_server (GnomePilotConduitStandardAbs *conduit, GCalConduitContext *ctxt) @@ -75,7 +83,7 @@ start_calendar_server (GnomePilotConduitStandardAbs *conduit, "IDL:GNOME:Calendar:Repository:1.0", 0, NULL); if (ctxt->calendar == CORBA_OBJECT_NIL) { - g_error ("Can not communicate with GnomeCalendar server"); + g_warning ("Can not communicate with GnomeCalendar server"); return -1; } @@ -137,56 +145,6 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit, return result; } -#if 0 -static GList * -get_calendar_objects(GnomePilotConduitStandardAbs *conduit) -{ - char *vcalendar_string; - char *error; - GList *retval,*l; - Calendar *cal; - - g_return_val_if_fail(conduit!=NULL,NULL); - - vcalendar_string = - GNOME_Calendar_Repository_get_objects (calendar, &ev); - - cal = calendar_new("Temporary"); - - error = calendar_load_from_memory(cal,vcalendar_string); - - if (ev._major == CORBA_USER_EXCEPTION){ - INFO ("Object did not exist"); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } else if(ev._major != CORBA_NO_EXCEPTION) { - WARN (_("Error while communicating with calendar server")); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } - - if(error != NULL) { - WARN ("Error while converting records"); - WARN ("Error : %s",error); - return NULL; - } - retval = NULL; - for(l=cal->events ; l ; l=l->next) { - LOG ("duping %d [%s]", - ((iCalObject*)l->data)->pilot_id, - ((iCalObject*)l->data)->summary); - retval = g_list_prepend(retval,ical_object_duplicate(l->data)); - } - - /* g_free(vcalendar_string); FIXME: this coredumps, but won't it leak without ? */ - calendar_destroy(cal); - - return retval; -} -#endif - static void local_record_from_ical_uid(GCalLocalRecord *local, char *uid, @@ -584,6 +542,7 @@ check_for_slow_setting(GnomePilotConduit *c, CORBA_long entry_number; entry_number = GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + GNOME_Calendar_Repository_ANY, &(ctxt->ev)); if (ctxt->ev._major == CORBA_USER_EXCEPTION){ @@ -608,6 +567,7 @@ pre_sync(GnomePilotConduit *c, GCalConduitContext *ctxt) { int l; + gint num_records; unsigned char *buf; g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION); @@ -621,6 +581,24 @@ pre_sync(GnomePilotConduit *c, return -1; } + /* Set the counters for the progress bar crap */ + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); /* load_records(c); */ diff --git a/calendar/corba-cal.c b/calendar/corba-cal.c index 2a3a727869..74afc0e76a 100644 --- a/calendar/corba-cal.c +++ b/calendar/corba-cal.c @@ -212,10 +212,40 @@ cal_repo_get_objects (PortableServer_Servant servant, static CORBA_long cal_repo_get_number_of_objects (PortableServer_Servant servant, + GNOME_Calendar_Repository_RecordStatus record_status, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); - return g_list_length(gcal->cal->events); + CORBA_long res; + GList *l; + iCalPilotState real_record_status; + + if (record_status == GNOME_Calendar_Repository_ANY) { + return g_list_length(gcal->cal->events); + } + + switch (record_status) { + case GNOME_Calendar_Repository_NEW: + real_record_status = ICAL_PILOT_SYNC_MOD; + break; + case GNOME_Calendar_Repository_MODIFIED: + real_record_status = ICAL_PILOT_SYNC_MOD; + break; + case GNOME_Calendar_Repository_DELETED: + real_record_status = ICAL_PILOT_SYNC_DEL; + break; + } + + res = 0; + + for (l = gcal->cal->events; l; l = l->next){ + iCalObject *obj = l->data; + + if (obj->pilot_status == real_record_status) + res ++; + } + + return res; } static GNOME_Calendar_Repository_String_Sequence* diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl index 3f9a64d291..a58358f3f1 100644 --- a/calendar/gui/GnomeCal.idl +++ b/calendar/gui/GnomeCal.idl @@ -97,10 +97,18 @@ module GNOME { string get_updated_objects (); /* - * Returns the number of objects in the calendar + * Returns the number of objects of a specific type in the calendar * repository. */ - long get_number_of_objects(); + + enum RecordStatus { + ANY, /* This means all records */ + NEW, + MODIFIED, + DELETED + }; + + long get_number_of_objects(in RecordStatus record_status); /* * done: diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c index cb7ca2b67a..9c758b3263 100644 --- a/calendar/gui/calendar-conduit.c +++ b/calendar/gui/calendar-conduit.c @@ -43,7 +43,7 @@ GnomePilotConduit * conduit_get_gpilot_conduit (guint32); void conduit_destroy_gpilot_conduit (GnomePilotConduit*); void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); -#define CONDUIT_VERSION "0.8.10p1" +#define CONDUIT_VERSION "0.8.11" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif @@ -63,6 +63,14 @@ void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj); #define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e) #define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e) +#define catch_ret_val(_env,ret) \ + if (_env._major != CORBA_NO_EXCEPTION) { \ + g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \ + g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \ + CORBA_exception_free(&(_env)); \ + return ret; \ + } + static int start_calendar_server (GnomePilotConduitStandardAbs *conduit, GCalConduitContext *ctxt) @@ -75,7 +83,7 @@ start_calendar_server (GnomePilotConduitStandardAbs *conduit, "IDL:GNOME:Calendar:Repository:1.0", 0, NULL); if (ctxt->calendar == CORBA_OBJECT_NIL) { - g_error ("Can not communicate with GnomeCalendar server"); + g_warning ("Can not communicate with GnomeCalendar server"); return -1; } @@ -137,56 +145,6 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit, return result; } -#if 0 -static GList * -get_calendar_objects(GnomePilotConduitStandardAbs *conduit) -{ - char *vcalendar_string; - char *error; - GList *retval,*l; - Calendar *cal; - - g_return_val_if_fail(conduit!=NULL,NULL); - - vcalendar_string = - GNOME_Calendar_Repository_get_objects (calendar, &ev); - - cal = calendar_new("Temporary"); - - error = calendar_load_from_memory(cal,vcalendar_string); - - if (ev._major == CORBA_USER_EXCEPTION){ - INFO ("Object did not exist"); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } else if(ev._major != CORBA_NO_EXCEPTION) { - WARN (_("Error while communicating with calendar server")); - show_exception(&ev); - CORBA_exception_free(&ev); - return; - } - - if(error != NULL) { - WARN ("Error while converting records"); - WARN ("Error : %s",error); - return NULL; - } - retval = NULL; - for(l=cal->events ; l ; l=l->next) { - LOG ("duping %d [%s]", - ((iCalObject*)l->data)->pilot_id, - ((iCalObject*)l->data)->summary); - retval = g_list_prepend(retval,ical_object_duplicate(l->data)); - } - - /* g_free(vcalendar_string); FIXME: this coredumps, but won't it leak without ? */ - calendar_destroy(cal); - - return retval; -} -#endif - static void local_record_from_ical_uid(GCalLocalRecord *local, char *uid, @@ -584,6 +542,7 @@ check_for_slow_setting(GnomePilotConduit *c, CORBA_long entry_number; entry_number = GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + GNOME_Calendar_Repository_ANY, &(ctxt->ev)); if (ctxt->ev._major == CORBA_USER_EXCEPTION){ @@ -608,6 +567,7 @@ pre_sync(GnomePilotConduit *c, GCalConduitContext *ctxt) { int l; + gint num_records; unsigned char *buf; g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION); @@ -621,6 +581,24 @@ pre_sync(GnomePilotConduit *c, return -1; } + /* Set the counters for the progress bar crap */ + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev)); + catch_ret_val(ctxt->ev,-1); + gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c), + num_records); + gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi); /* load_records(c); */ diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c index 2a3a727869..74afc0e76a 100644 --- a/calendar/gui/corba-cal.c +++ b/calendar/gui/corba-cal.c @@ -212,10 +212,40 @@ cal_repo_get_objects (PortableServer_Servant servant, static CORBA_long cal_repo_get_number_of_objects (PortableServer_Servant servant, + GNOME_Calendar_Repository_RecordStatus record_status, CORBA_Environment *ev) { GnomeCalendar *gcal = gnomecal_from_servant (servant); - return g_list_length(gcal->cal->events); + CORBA_long res; + GList *l; + iCalPilotState real_record_status; + + if (record_status == GNOME_Calendar_Repository_ANY) { + return g_list_length(gcal->cal->events); + } + + switch (record_status) { + case GNOME_Calendar_Repository_NEW: + real_record_status = ICAL_PILOT_SYNC_MOD; + break; + case GNOME_Calendar_Repository_MODIFIED: + real_record_status = ICAL_PILOT_SYNC_MOD; + break; + case GNOME_Calendar_Repository_DELETED: + real_record_status = ICAL_PILOT_SYNC_DEL; + break; + } + + res = 0; + + for (l = gcal->cal->events; l; l = l->next){ + iCalObject *obj = l->data; + + if (obj->pilot_status == real_record_status) + res ++; + } + + return res; } static GNOME_Calendar_Repository_String_Sequence* |