[evolution-patches] patch to reduce bonobo calls for calendar



Hi,

This patch reduces the number of bonobo calls made from calendar.




Thanks,
Viren
Index: libecal/e-cal.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.h,v
retrieving revision 1.23
diff -u -p -w -r1.23 e-cal.h
--- libecal/e-cal.h	24 Mar 2005 08:33:29 -0000	1.23
+++ libecal/e-cal.h	7 Jul 2005 17:22:51 -0000
@@ -129,6 +129,7 @@ gboolean e_cal_get_organizer_must_attend
 gboolean e_cal_get_save_schedules (ECal *ecal);
 gboolean e_cal_get_static_capability (ECal *ecal, const char *cap);
 gboolean e_cal_get_organizer_must_accept (ECal *ecal);
+static gboolean e_cal_get_read_only (ECal *ecal, gboolean *read_only, GError **error);
 
 gboolean e_cal_set_mode (ECal *ecal, CalMode mode);
 
Index: libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.103
diff -u -p -w -r1.103 e-cal.c
--- libecal/e-cal.c	2 Jul 2005 07:08:11 -0000	1.103
+++ libecal/e-cal.c	7 Jul 2005 17:22:59 -0000
@@ -86,6 +86,8 @@ struct _ECalPrivate {
 	
 	int mode;
 	
+	gboolean read_only;
+	
 	/* The calendar factories we are contacting */
 	GList *factories;
 
@@ -382,12 +384,13 @@ static void
 cal_read_only_cb (ECalListener *listener, ECalendarStatus status, gboolean read_only, gpointer data)
 {
 	ECal *ecal = data;
+
 	ECalendarOp *op;
 
 	op = e_calendar_get_op (ecal);
 
 	if (op == NULL) {
-		g_warning (G_STRLOC ": Cannot find operation ");
+		ecal->priv->read_only = read_only; 
 		return;
 	}
 
@@ -410,7 +413,7 @@ cal_cal_address_cb (ECalListener *listen
 	op = e_calendar_get_op (ecal);
 
 	if (op == NULL) {
-		g_warning (G_STRLOC ": Cannot find operation ");
+		ecal->priv->cal_address = address;
 		return;
 	}
 
@@ -1159,6 +1162,7 @@ e_cal_finalize (GObject *object)
 		g_free (priv->cal_address);
 		priv->cal_address = NULL;
 	}
+
 	if (priv->alarm_email_address) {
 		g_free (priv->alarm_email_address);
 		priv->alarm_email_address = NULL;
@@ -1536,17 +1540,19 @@ open_calendar (ECal *ecal, gboolean only
 	ECalendarOp *our_op;
 	const char *username = NULL;
 	char *password = NULL;
+	gboolean *read_only = NULL;
 	
 	e_return_error_if_fail (ecal != NULL, E_CALENDAR_STATUS_INVALID_ARG);
 	e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
 
 	priv = ecal->priv;
 	
-
 	g_mutex_lock (ecal->priv->mutex);
 
 	if (!needs_auth && priv->load_state == E_CAL_LOAD_LOADED) {
 		g_mutex_unlock (ecal->priv->mutex);
+		e_cal_get_read_only (ecal, read_only, error);
+		priv->read_only = read_only;
 		return TRUE;
 	}
 	
@@ -1653,6 +1659,8 @@ open_calendar (ECal *ecal, gboolean only
 	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
+	e_cal_get_read_only (ecal, read_only, error);
+	priv->read_only = read_only;
 	if (*status == E_CALENDAR_STATUS_OK) 
 		priv->load_state = E_CAL_LOAD_LOADED;
 	else
@@ -2030,14 +2038,25 @@ gboolean
 e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error)
 {
 	ECalPrivate *priv;
+	
+	priv = ecal->priv;
+	if (!(ecal && E_IS_CAL (ecal)))
+		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
+
+	*read_only = priv->read_only;
+
+	return TRUE;
+}
+
+static gboolean
+e_cal_get_read_only (ECal *ecal, gboolean *read_only, GError **error)
+{
+	ECalPrivate *priv;
 	CORBA_Environment ev;
 	ECalendarStatus status;
 	ECalendarOp *our_op;
 	
-	e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
-
 	priv = ecal->priv;
-	
 	g_mutex_lock (ecal->priv->mutex);
 
 	if (ecal->priv->load_state != E_CAL_LOAD_LOADED) {
@@ -2080,11 +2099,11 @@ e_cal_is_read_only (ECal *ecal, gboolean
 
 	status = our_op->status;
 	*read_only = our_op->bool;
+	priv->read_only = our_op->bool;
 	
 	e_calendar_remove_op (ecal, our_op);
 	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
-
 	E_CALENDAR_CHECK_STATUS (status, error);
 }
 
@@ -2106,11 +2125,14 @@ e_cal_get_cal_address (ECal *ecal, char 
 	CORBA_Environment ev;
 	ECalendarStatus status;
 	ECalendarOp *our_op;
+	static gboolean called;
 
-	e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);	
 
+	if (!(ecal && E_IS_CAL (ecal)))
+		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
 	priv = ecal->priv;
 	
+	if (!called)	{ 
 	g_mutex_lock (ecal->priv->mutex);
 
 	if (ecal->priv->load_state != E_CAL_LOAD_LOADED) {
@@ -2153,12 +2175,20 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 	status = our_op->status;
 	*cal_address = our_op->string;
+	priv->cal_address = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
 	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
+	if ((status) == E_CALENDAR_STATUS_OK) 
+		called = TRUE; 
+			
 	E_CALENDAR_CHECK_STATUS (status, error);
+	} else {	
+		cal_address = priv->cal_address;
+		return TRUE;
+	}		
 }
 
 /**
@@ -4023,10 +4053,6 @@ e_cal_create_object (ECal *ecal, icalcom
 	status = our_op->status;
 	if (uid)
 		*uid = our_op->uid;
-	else {
-		g_free (our_op->uid);
-		our_op->uid = NULL;
-	}
 	
 	e_calendar_remove_op (ecal, our_op);
 	g_mutex_unlock (our_op->mutex);
Index: backends/groupwise/e-cal-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.c,v
retrieving revision 1.146
diff -u -p -w -r1.146 e-cal-backend-groupwise.c
--- backends/groupwise/e-cal-backend-groupwise.c	20 Jun 2005 16:41:17 -0000	1.146
+++ backends/groupwise/e-cal-backend-groupwise.c	7 Jul 2005 17:23:03 -0000
@@ -881,6 +881,7 @@ e_cal_backend_groupwise_open (ECalBacken
 		}
 		
 		g_mutex_unlock (priv->mutex);	
+		e_cal_backend_notify_cal_address (E_CAL_BACKEND (cbgw), priv->user_email); 
 		return GNOME_Evolution_Calendar_Success;
 	}
 
@@ -981,6 +982,7 @@ e_cal_backend_groupwise_set_mode (ECalBa
 		priv->read_only = FALSE;
 		e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
 						    GNOME_Evolution_Calendar_MODE_REMOTE);
+		e_cal_backend_notify_readonly (backend, priv->read_only);
 		if(e_cal_backend_groupwise_is_loaded (backend))
 		              e_cal_backend_notify_auth_required(backend);	
 		break;
@@ -989,6 +991,7 @@ e_cal_backend_groupwise_set_mode (ECalBa
 		/* FIXME: make sure we update the cache before closing the connection */
 		priv->mode = CAL_MODE_LOCAL;
 		in_offline (cbgw);
+		e_cal_backend_notify_readonly (backend, priv->read_only);
 		e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
 					   GNOME_Evolution_Calendar_MODE_LOCAL);
 
Index: libedata-cal/e-cal-backend.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.h,v
retrieving revision 1.10
diff -u -p -w -r1.10 e-cal-backend.h
--- libedata-cal/e-cal-backend.h	28 Jan 2005 13:17:37 -0000	1.10
+++ libedata-cal/e-cal-backend.h	7 Jul 2005 17:23:04 -0000
@@ -172,7 +172,8 @@ void e_cal_backend_notify_mode      (ECa
 				     GNOME_Evolution_Calendar_CalMode mode);
 void e_cal_backend_notify_auth_required (ECalBackend *backend);
 void e_cal_backend_notify_error     (ECalBackend *backend, const char *message);
-
+void e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only);
+void e_cal_backend_notify_cal_address (ECalBackend *backend, char *address);
 
 
 G_END_DECLS
Index: libedata-cal/e-cal-backend.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.c,v
retrieving revision 1.16
diff -u -p -w -r1.16 e-cal-backend.c
--- libedata-cal/e-cal-backend.c	13 May 2005 07:13:30 -0000	1.16
+++ libedata-cal/e-cal-backend.c	7 Jul 2005 17:23:06 -0000
@@ -513,6 +513,38 @@ e_cal_backend_get_cal_address (ECalBacke
 	(* CLASS (backend)->get_cal_address) (backend, cal);
 }
 
+void
+e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only)
+{
+	ECalBackendPrivate *priv;
+	GList *l;
+
+	priv = backend->priv;
+
+	if (priv->notification_proxy) {
+		e_cal_backend_notify_readonly (priv->notification_proxy, read_only);
+		return;
+	}
+	for (l = priv->clients; l; l = l->next)
+		e_data_cal_notify_read_only (l->data, GNOME_Evolution_Calendar_Success, read_only);
+	
+	g_print ("\n\t notify_read_only called...  read_only = %d", read_only);
+}
+
+void
+e_cal_backend_notify_cal_address (ECalBackend *backend, char *address)
+{
+	ECalBackendPrivate *priv;
+	GList *l;
+
+	priv = backend->priv;
+
+	for (l = priv->clients; l; l = l->next)
+		e_data_cal_notify_cal_address (l->data, GNOME_Evolution_Calendar_Success, address);
+	
+	g_print ("\n\t notify_cal_address called...  cal_uri = %s", address);
+}
+
 /**
  * e_cal_backend_get_alarm_email_address:
  * @backend: An #ECalBackend object.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]