diff options
-rw-r--r-- | calendar/ChangeLog | 13 | ||||
-rw-r--r-- | calendar/GnomeCal.idl | 6 | ||||
-rw-r--r-- | calendar/calendar-conduit-control-applet.c | 36 | ||||
-rw-r--r-- | calendar/calendar-conduit.c | 40 | ||||
-rw-r--r-- | calendar/calendar-conduit.h | 2 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit-control-applet.c | 36 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 40 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.h | 2 | ||||
-rw-r--r-- | calendar/corba-cal.c | 9 | ||||
-rw-r--r-- | calendar/gui/GnomeCal.idl | 6 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit-control-applet.c | 36 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit.c | 40 | ||||
-rw-r--r-- | calendar/gui/calendar-conduit.h | 2 | ||||
-rw-r--r-- | calendar/gui/corba-cal.c | 9 |
14 files changed, 193 insertions, 84 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e0659cfd35..af64787794 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,16 @@ +1999-12-07 Eskil Heyn Olsen <deity@eskil.dk> + + * calendar-conduit.c (pre_sync): Check if local store is + empty. If, force slow sync. + + * GnomeCal.idl (GNOME): Added get_number_of_objects. + + * corba-cal.c (cal_repo_get_number_of_objects): implemented the + get_number_of_objects. + + * calendar-conduit-control-applet.c (setStateCfg): Fixed bug that + caused the capplet to always set the sync action to Disable upon start. + 1999-12-05 Eskil Heyn Olsen <deity@eskil.dk> * Makefile.am (Conduits_second_DATA): Also install .desktop files diff --git a/calendar/GnomeCal.idl b/calendar/GnomeCal.idl index 5c5d400d9e..3f9a64d291 100644 --- a/calendar/GnomeCal.idl +++ b/calendar/GnomeCal.idl @@ -96,6 +96,12 @@ module GNOME { */ string get_updated_objects (); + /* + * Returns the number of objects in the calendar + * repository. + */ + long get_number_of_objects(); + /* * done: * diff --git a/calendar/calendar-conduit-control-applet.c b/calendar/calendar-conduit-control-applet.c index 0950772d2e..3c5b2d1b98 100644 --- a/calendar/calendar-conduit-control-applet.c +++ b/calendar/calendar-conduit-control-applet.c @@ -29,7 +29,6 @@ GtkWidget *cfgOptionsWindow=NULL; GtkWidget *cfgStateWindow=NULL; GtkWidget *dialogWindow=NULL; -gboolean activated,org_activation_state; GnomePilotConduitMgmt *conduit; static void doTrySettings(GtkWidget *widget, gpointer); @@ -90,7 +89,7 @@ doCancelSettings(GtkWidget *widget, gpointer whatever) static void doRevertSettings(GtkWidget *widget, gpointer whatever) { - gcalconduit_destroy_configuration(curState); + gcalconduit_destroy_configuration(&curState); curState = gcalconduit_dupe_configuration(origState); setStateCfg(cfgStateWindow,curState); setSettings(curState); @@ -150,7 +149,6 @@ void about_cb (GtkWidget *widget, gpointer data) { } static void toggled_cb(GtkWidget *widget, gpointer data) { - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active); capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -168,7 +166,6 @@ static void activate_sync_type(GtkMenuItem *widget, gpointer data) { curState->sync_type = GPOINTER_TO_INT(data); - gtk_widget_set_sensitive(cfgOptionsWindow,curState->sync_type!=GnomePilotConduitSyncTypeCustom); if(!ignore_changes) capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -177,7 +174,7 @@ static GtkWidget *createStateCfgWindow(void) { GtkWidget *vbox, *table; - GtkWidget *label, *button; + GtkWidget *label; GtkWidget *optionMenu,*menuItem; GtkMenu *menu; gint i; @@ -215,20 +212,21 @@ static GtkWidget } static void -setStateCfg(GtkWidget *w,GCalConduitCfg *cfg) +setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg) { - GtkWidget *button; - gchar num[40]; -/* - button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off"); - - g_assert(button!=NULL); + GtkOptionMenu *optionMenu; + GtkMenu *menu; + + optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state"); + g_assert(optionMenu!=NULL); + menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu)); - ignore_changes = TRUE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated); - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active); - ignore_changes = FALSE; -*/ + + ignore_changes = TRUE; + /* Here were are relying on the items in menu being the same + order as in GnomePilotConduitSyncType. */ + gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type); + ignore_changes = FALSE; } @@ -348,9 +346,9 @@ main( int argc, char *argv[] ) /* put all code to set things up in here */ gcalconduit_load_configuration(&origState,pilotId); - curState = gcalconduit_dupe_configuration(origState); + gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type); - org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId); + curState = gcalconduit_dupe_configuration(origState); pilot_capplet_setup(); diff --git a/calendar/calendar-conduit.c b/calendar/calendar-conduit.c index 35a5db97ff..d7ec8083ae 100644 --- a/calendar/calendar-conduit.c +++ b/calendar/calendar-conduit.c @@ -43,14 +43,14 @@ 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.6" +#define CONDUIT_VERSION "0.8.9" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif #define G_LOG_DOMAIN "gcalconduit" #define DEBUG_CALCONDUIT -#undef DEBUG_CALCONDUIT +#undef DEBUG_CALCONDUIT #ifdef DEBUG_CALCONDUIT #define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e)) @@ -577,6 +577,30 @@ update_record (GnomePilotConduitStandardAbs *conduit, return 0; } +static void +check_for_slow_setting(GnomePilotConduit *c, + GCalConduitContext *ctxt) +{ + CORBA_long entry_number; + entry_number = + GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + &(ctxt->ev)); + + if (ctxt->ev._major == CORBA_USER_EXCEPTION){ + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) { + WARN (_("Error while communicating with calendar server")); + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else { + LOG (_("Calendar holds %d entries"),entry_number); + /* If the local base is empty, do a slow sync */ + if ( entry_number <= 0) { + gnome_pilot_conduit_standard_set_slow(c); + } + } +} static gint pre_sync(GnomePilotConduit *c, @@ -590,7 +614,7 @@ pre_sync(GnomePilotConduit *c, ctxt->calendar = CORBA_OBJECT_NIL; - if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),GET_GCALCONTEXT(c)) != 0) { + if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) { WARN(_("Could not start gnomecal server")); return -1; } @@ -601,12 +625,14 @@ pre_sync(GnomePilotConduit *c, buf = (unsigned char*)g_malloc(0xffff); if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) { - WARN(_("Could not read pilot's Appoint application block")); + WARN(_("Could not read pilot's DateBook application block")); return -1; } unpack_AppointmentAppInfo(&(ctxt->ai),buf,l); g_free(buf); + check_for_slow_setting(c,ctxt); + return 0; } @@ -1360,9 +1386,7 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_object_set_data(retval,"gcalconduit_cfg",cfg); gcalconduit_new_context(&ctxt,cfg); - /* No real need to set it, since all signal are given this - as their user data */ - gtk_object_set_data(retval,"gcalconduit_context",ctxt); + gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt); gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); @@ -1383,8 +1407,6 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt); gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); - - return GNOME_PILOT_CONDUIT (retval); } diff --git a/calendar/calendar-conduit.h b/calendar/calendar-conduit.h index 2ebf453e7e..711609e96a 100644 --- a/calendar/calendar-conduit.h +++ b/calendar/calendar-conduit.h @@ -65,6 +65,7 @@ gcalconduit_load_configuration(GCalConduitCfg **c, g_assert(*c != NULL); gnome_config_push_prefix(prefix); (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE"); + (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */ gnome_config_pop_prefix(); (*c)->pilotId = pilotId; @@ -92,6 +93,7 @@ gcalconduit_dupe_configuration(GCalConduitCfg *c) { GCalConduitCfg *retval; g_return_val_if_fail(c!=NULL,NULL); retval = g_new0(GCalConduitCfg,1); + retval->sync_type = c->sync_type; retval->open_secret = c->open_secret; retval->pilotId = c->pilotId; return retval; diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c index 0950772d2e..3c5b2d1b98 100644 --- a/calendar/conduits/calendar/calendar-conduit-control-applet.c +++ b/calendar/conduits/calendar/calendar-conduit-control-applet.c @@ -29,7 +29,6 @@ GtkWidget *cfgOptionsWindow=NULL; GtkWidget *cfgStateWindow=NULL; GtkWidget *dialogWindow=NULL; -gboolean activated,org_activation_state; GnomePilotConduitMgmt *conduit; static void doTrySettings(GtkWidget *widget, gpointer); @@ -90,7 +89,7 @@ doCancelSettings(GtkWidget *widget, gpointer whatever) static void doRevertSettings(GtkWidget *widget, gpointer whatever) { - gcalconduit_destroy_configuration(curState); + gcalconduit_destroy_configuration(&curState); curState = gcalconduit_dupe_configuration(origState); setStateCfg(cfgStateWindow,curState); setSettings(curState); @@ -150,7 +149,6 @@ void about_cb (GtkWidget *widget, gpointer data) { } static void toggled_cb(GtkWidget *widget, gpointer data) { - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active); capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -168,7 +166,6 @@ static void activate_sync_type(GtkMenuItem *widget, gpointer data) { curState->sync_type = GPOINTER_TO_INT(data); - gtk_widget_set_sensitive(cfgOptionsWindow,curState->sync_type!=GnomePilotConduitSyncTypeCustom); if(!ignore_changes) capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -177,7 +174,7 @@ static GtkWidget *createStateCfgWindow(void) { GtkWidget *vbox, *table; - GtkWidget *label, *button; + GtkWidget *label; GtkWidget *optionMenu,*menuItem; GtkMenu *menu; gint i; @@ -215,20 +212,21 @@ static GtkWidget } static void -setStateCfg(GtkWidget *w,GCalConduitCfg *cfg) +setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg) { - GtkWidget *button; - gchar num[40]; -/* - button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off"); - - g_assert(button!=NULL); + GtkOptionMenu *optionMenu; + GtkMenu *menu; + + optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state"); + g_assert(optionMenu!=NULL); + menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu)); - ignore_changes = TRUE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated); - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active); - ignore_changes = FALSE; -*/ + + ignore_changes = TRUE; + /* Here were are relying on the items in menu being the same + order as in GnomePilotConduitSyncType. */ + gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type); + ignore_changes = FALSE; } @@ -348,9 +346,9 @@ main( int argc, char *argv[] ) /* put all code to set things up in here */ gcalconduit_load_configuration(&origState,pilotId); - curState = gcalconduit_dupe_configuration(origState); + gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type); - org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId); + curState = gcalconduit_dupe_configuration(origState); pilot_capplet_setup(); diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 35a5db97ff..d7ec8083ae 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -43,14 +43,14 @@ 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.6" +#define CONDUIT_VERSION "0.8.9" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif #define G_LOG_DOMAIN "gcalconduit" #define DEBUG_CALCONDUIT -#undef DEBUG_CALCONDUIT +#undef DEBUG_CALCONDUIT #ifdef DEBUG_CALCONDUIT #define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e)) @@ -577,6 +577,30 @@ update_record (GnomePilotConduitStandardAbs *conduit, return 0; } +static void +check_for_slow_setting(GnomePilotConduit *c, + GCalConduitContext *ctxt) +{ + CORBA_long entry_number; + entry_number = + GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + &(ctxt->ev)); + + if (ctxt->ev._major == CORBA_USER_EXCEPTION){ + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) { + WARN (_("Error while communicating with calendar server")); + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else { + LOG (_("Calendar holds %d entries"),entry_number); + /* If the local base is empty, do a slow sync */ + if ( entry_number <= 0) { + gnome_pilot_conduit_standard_set_slow(c); + } + } +} static gint pre_sync(GnomePilotConduit *c, @@ -590,7 +614,7 @@ pre_sync(GnomePilotConduit *c, ctxt->calendar = CORBA_OBJECT_NIL; - if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),GET_GCALCONTEXT(c)) != 0) { + if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) { WARN(_("Could not start gnomecal server")); return -1; } @@ -601,12 +625,14 @@ pre_sync(GnomePilotConduit *c, buf = (unsigned char*)g_malloc(0xffff); if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) { - WARN(_("Could not read pilot's Appoint application block")); + WARN(_("Could not read pilot's DateBook application block")); return -1; } unpack_AppointmentAppInfo(&(ctxt->ai),buf,l); g_free(buf); + check_for_slow_setting(c,ctxt); + return 0; } @@ -1360,9 +1386,7 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_object_set_data(retval,"gcalconduit_cfg",cfg); gcalconduit_new_context(&ctxt,cfg); - /* No real need to set it, since all signal are given this - as their user data */ - gtk_object_set_data(retval,"gcalconduit_context",ctxt); + gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt); gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); @@ -1383,8 +1407,6 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt); gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); - - return GNOME_PILOT_CONDUIT (retval); } diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h index 2ebf453e7e..711609e96a 100644 --- a/calendar/conduits/calendar/calendar-conduit.h +++ b/calendar/conduits/calendar/calendar-conduit.h @@ -65,6 +65,7 @@ gcalconduit_load_configuration(GCalConduitCfg **c, g_assert(*c != NULL); gnome_config_push_prefix(prefix); (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE"); + (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */ gnome_config_pop_prefix(); (*c)->pilotId = pilotId; @@ -92,6 +93,7 @@ gcalconduit_dupe_configuration(GCalConduitCfg *c) { GCalConduitCfg *retval; g_return_val_if_fail(c!=NULL,NULL); retval = g_new0(GCalConduitCfg,1); + retval->sync_type = c->sync_type; retval->open_secret = c->open_secret; retval->pilotId = c->pilotId; return retval; diff --git a/calendar/corba-cal.c b/calendar/corba-cal.c index ddeb5ccb45..472d83008e 100644 --- a/calendar/corba-cal.c +++ b/calendar/corba-cal.c @@ -210,6 +210,14 @@ cal_repo_get_objects (PortableServer_Servant servant, return res; } +static CORBA_long +cal_repo_get_number_of_objects (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + GnomeCalendar *gcal = gnomecal_from_servant (servant); + return g_list_length(gcal->cal->events); +} + static GNOME_Calendar_Repository_String_Sequence* cal_repo_get_object_id_list(PortableServer_Servant servant, CORBA_Environment *ev) @@ -281,6 +289,7 @@ init_calendar_repo_class (void) calendar_repository_epv.delete_object = cal_repo_delete_object; calendar_repository_epv.update_object = cal_repo_update_object; calendar_repository_epv.get_objects = cal_repo_get_objects; + calendar_repository_epv.get_number_of_objects = cal_repo_get_number_of_objects; calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects; calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id; calendar_repository_epv.get_object_id_list = cal_repo_get_object_id_list; diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl index 5c5d400d9e..3f9a64d291 100644 --- a/calendar/gui/GnomeCal.idl +++ b/calendar/gui/GnomeCal.idl @@ -96,6 +96,12 @@ module GNOME { */ string get_updated_objects (); + /* + * Returns the number of objects in the calendar + * repository. + */ + long get_number_of_objects(); + /* * done: * diff --git a/calendar/gui/calendar-conduit-control-applet.c b/calendar/gui/calendar-conduit-control-applet.c index 0950772d2e..3c5b2d1b98 100644 --- a/calendar/gui/calendar-conduit-control-applet.c +++ b/calendar/gui/calendar-conduit-control-applet.c @@ -29,7 +29,6 @@ GtkWidget *cfgOptionsWindow=NULL; GtkWidget *cfgStateWindow=NULL; GtkWidget *dialogWindow=NULL; -gboolean activated,org_activation_state; GnomePilotConduitMgmt *conduit; static void doTrySettings(GtkWidget *widget, gpointer); @@ -90,7 +89,7 @@ doCancelSettings(GtkWidget *widget, gpointer whatever) static void doRevertSettings(GtkWidget *widget, gpointer whatever) { - gcalconduit_destroy_configuration(curState); + gcalconduit_destroy_configuration(&curState); curState = gcalconduit_dupe_configuration(origState); setStateCfg(cfgStateWindow,curState); setSettings(curState); @@ -150,7 +149,6 @@ void about_cb (GtkWidget *widget, gpointer data) { } static void toggled_cb(GtkWidget *widget, gpointer data) { - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active); capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -168,7 +166,6 @@ static void activate_sync_type(GtkMenuItem *widget, gpointer data) { curState->sync_type = GPOINTER_TO_INT(data); - gtk_widget_set_sensitive(cfgOptionsWindow,curState->sync_type!=GnomePilotConduitSyncTypeCustom); if(!ignore_changes) capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } @@ -177,7 +174,7 @@ static GtkWidget *createStateCfgWindow(void) { GtkWidget *vbox, *table; - GtkWidget *label, *button; + GtkWidget *label; GtkWidget *optionMenu,*menuItem; GtkMenu *menu; gint i; @@ -215,20 +212,21 @@ static GtkWidget } static void -setStateCfg(GtkWidget *w,GCalConduitCfg *cfg) +setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg) { - GtkWidget *button; - gchar num[40]; -/* - button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off"); - - g_assert(button!=NULL); + GtkOptionMenu *optionMenu; + GtkMenu *menu; + + optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state"); + g_assert(optionMenu!=NULL); + menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu)); - ignore_changes = TRUE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated); - gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active); - ignore_changes = FALSE; -*/ + + ignore_changes = TRUE; + /* Here were are relying on the items in menu being the same + order as in GnomePilotConduitSyncType. */ + gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type); + ignore_changes = FALSE; } @@ -348,9 +346,9 @@ main( int argc, char *argv[] ) /* put all code to set things up in here */ gcalconduit_load_configuration(&origState,pilotId); - curState = gcalconduit_dupe_configuration(origState); + gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type); - org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId); + curState = gcalconduit_dupe_configuration(origState); pilot_capplet_setup(); diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c index 35a5db97ff..d7ec8083ae 100644 --- a/calendar/gui/calendar-conduit.c +++ b/calendar/gui/calendar-conduit.c @@ -43,14 +43,14 @@ 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.6" +#define CONDUIT_VERSION "0.8.9" #ifdef G_LOG_DOMAIN #undef G_LOG_DOMAIN #endif #define G_LOG_DOMAIN "gcalconduit" #define DEBUG_CALCONDUIT -#undef DEBUG_CALCONDUIT +#undef DEBUG_CALCONDUIT #ifdef DEBUG_CALCONDUIT #define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e)) @@ -577,6 +577,30 @@ update_record (GnomePilotConduitStandardAbs *conduit, return 0; } +static void +check_for_slow_setting(GnomePilotConduit *c, + GCalConduitContext *ctxt) +{ + CORBA_long entry_number; + entry_number = + GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar, + &(ctxt->ev)); + + if (ctxt->ev._major == CORBA_USER_EXCEPTION){ + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) { + WARN (_("Error while communicating with calendar server")); + show_exception(&(ctxt->ev)); + CORBA_exception_free(&(ctxt->ev)); + } else { + LOG (_("Calendar holds %d entries"),entry_number); + /* If the local base is empty, do a slow sync */ + if ( entry_number <= 0) { + gnome_pilot_conduit_standard_set_slow(c); + } + } +} static gint pre_sync(GnomePilotConduit *c, @@ -590,7 +614,7 @@ pre_sync(GnomePilotConduit *c, ctxt->calendar = CORBA_OBJECT_NIL; - if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),GET_GCALCONTEXT(c)) != 0) { + if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) { WARN(_("Could not start gnomecal server")); return -1; } @@ -601,12 +625,14 @@ pre_sync(GnomePilotConduit *c, buf = (unsigned char*)g_malloc(0xffff); if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) { - WARN(_("Could not read pilot's Appoint application block")); + WARN(_("Could not read pilot's DateBook application block")); return -1; } unpack_AppointmentAppInfo(&(ctxt->ai),buf,l); g_free(buf); + check_for_slow_setting(c,ctxt); + return 0; } @@ -1360,9 +1386,7 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_object_set_data(retval,"gcalconduit_cfg",cfg); gcalconduit_new_context(&ctxt,cfg); - /* No real need to set it, since all signal are given this - as their user data */ - gtk_object_set_data(retval,"gcalconduit_context",ctxt); + gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt); gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); @@ -1383,8 +1407,6 @@ conduit_get_gpilot_conduit (guint32 pilotId) gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt); gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt); - - return GNOME_PILOT_CONDUIT (retval); } diff --git a/calendar/gui/calendar-conduit.h b/calendar/gui/calendar-conduit.h index 2ebf453e7e..711609e96a 100644 --- a/calendar/gui/calendar-conduit.h +++ b/calendar/gui/calendar-conduit.h @@ -65,6 +65,7 @@ gcalconduit_load_configuration(GCalConduitCfg **c, g_assert(*c != NULL); gnome_config_push_prefix(prefix); (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE"); + (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */ gnome_config_pop_prefix(); (*c)->pilotId = pilotId; @@ -92,6 +93,7 @@ gcalconduit_dupe_configuration(GCalConduitCfg *c) { GCalConduitCfg *retval; g_return_val_if_fail(c!=NULL,NULL); retval = g_new0(GCalConduitCfg,1); + retval->sync_type = c->sync_type; retval->open_secret = c->open_secret; retval->pilotId = c->pilotId; return retval; diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c index ddeb5ccb45..472d83008e 100644 --- a/calendar/gui/corba-cal.c +++ b/calendar/gui/corba-cal.c @@ -210,6 +210,14 @@ cal_repo_get_objects (PortableServer_Servant servant, return res; } +static CORBA_long +cal_repo_get_number_of_objects (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + GnomeCalendar *gcal = gnomecal_from_servant (servant); + return g_list_length(gcal->cal->events); +} + static GNOME_Calendar_Repository_String_Sequence* cal_repo_get_object_id_list(PortableServer_Servant servant, CORBA_Environment *ev) @@ -281,6 +289,7 @@ init_calendar_repo_class (void) calendar_repository_epv.delete_object = cal_repo_delete_object; calendar_repository_epv.update_object = cal_repo_update_object; calendar_repository_epv.get_objects = cal_repo_get_objects; + calendar_repository_epv.get_number_of_objects = cal_repo_get_number_of_objects; calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects; calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id; calendar_repository_epv.get_object_id_list = cal_repo_get_object_id_list; |