[evolution-patches] Patch to reduce the e_cal_is_read_only calls made by calendar clients.



Hi,


The patch reduces the e_cal_is_read_only calls invoked by the client(s)
while performing calendar operations like new meeting,task etc...
whenever the mode changes or the read_only value changes it is notified
thru appropriate notify methods.similarly the cal_address notification
is done.





Thanks,
Viren.
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	8 Jul 2005 15:15:04 -0000
@@ -981,6 +981,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 +990,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: 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	8 Jul 2005 15:15:06 -0000
@@ -44,6 +44,8 @@
 static gboolean
 open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarStatus *status, gboolean needs_auth);
 
+static gboolean
+get_read_only (ECal *ecal, gboolean *read_only, GError **error);
 
 
 typedef struct {
@@ -86,6 +88,8 @@ struct _ECalPrivate {
 	
 	int mode;
 	
+	gboolean read_only;
+	
 	/* The calendar factories we are contacting */
 	GList *factories;
 
@@ -387,7 +391,7 @@ cal_read_only_cb (ECalListener *listener
 	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 +414,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 = g_strdup (address);
 		return;
 	}
 
@@ -1536,13 +1540,13 @@ open_calendar (ECal *ecal, gboolean only
 	ECalendarOp *our_op;
 	const char *username = NULL;
 	char *password = NULL;
+	gboolean read_only;
 	
 	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) {
@@ -1652,10 +1656,11 @@ open_calendar (ECal *ecal, gboolean only
 	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) 
+	if (*status == E_CALENDAR_STATUS_OK) {
 		priv->load_state = E_CAL_LOAD_LOADED;
-	else
+		if (get_read_only (ecal, &read_only, NULL))
+			priv->read_only = read_only;
+	} else
 		priv->load_state = E_CAL_LOAD_NOT_LOADED;
 
 	E_CALENDAR_CHECK_STATUS (*status, error);
@@ -2030,14 +2035,24 @@ gboolean
 e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error)
 {
 	ECalPrivate *priv;
+	
+	if (!(ecal && E_IS_CAL (ecal)))
+		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
+	
+	priv = ecal->priv;
+	*read_only = priv->read_only;
+	return TRUE;
+}
+
+static gboolean
+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 +2095,9 @@ e_cal_is_read_only (ECal *ecal, gboolean
 
 	status = our_op->status;
 	*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);
 }
 
@@ -2107,10 +2120,11 @@ e_cal_get_cal_address (ECal *ecal, char 
 	ECalendarStatus status;
 	ECalendarOp *our_op;
 
-	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 (*cal_address == NULL) { 
 	g_mutex_lock (ecal->priv->mutex);
 
 	if (ecal->priv->load_state != E_CAL_LOAD_LOADED) {
@@ -2153,12 +2167,15 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 	status = our_op->status;
 	*cal_address = our_op->string;
-	
 	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);
+	} else {	
+		*cal_address = priv->cal_address;
+		return TRUE;
+	}		
 }
 
 /**
@@ -4027,7 +4044,6 @@ e_cal_create_object (ECal *ecal, icalcom
 		g_free (our_op->uid);
 		our_op->uid = NULL;
 	}
-	
 	e_calendar_remove_op (ecal, our_op);
 	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
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	8 Jul 2005 15:15:07 -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	8 Jul 2005 15:15:07 -0000
@@ -513,6 +513,34 @@ 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);
+}
+
+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);
+}
+
 /**
  * e_cal_backend_get_alarm_email_address:
  * @backend: An #ECalBackend object.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.470
diff -u -p -w -r1.470 ChangeLog
--- ChangeLog	23 Jun 2005 05:39:02 -0000	1.470
+++ ChangeLog	8 Jul 2005 15:15:10 -0000
@@ -1,3 +1,25 @@
+2005-07-07  Viren.L	<lviren novell com>
+
+	* backends/groupwise/e-cal-backend-groupwise.c:
+	(e_cal_backend_groupwise_set_mode):
+	Notify read_only to client(s).
+	* libecal/e-cal.c:
+	(e_cal_is_read_only, get_read_only):
+	Made appropriate changes and added get_read_only() method.
+	(cal_read_only_cb):
+	Check the operation our_op and assign read_only value .
+	(open_calendar):
+	Invoke get_read_only once the calendar is loaded.
+	(e_cal_get_cal_address, cal_cal_address_cb):
+	Check for address value and made necessary changes.
+	* libedata-cal/e-cal-backend.c:
+	(e_cal_backend_notify_readonly):
+	Notifies the client(s) that read_only value.
+	(e_cal_backend_notify_cal_address):
+	Notifies the address to client(s).
+	* libedata-cal/e-cal-backend.[ch]:
+	declaration of notify methods.
+	
 2005-06-23  Chenthill Palanisamy  <pchenthill novell com>
 
 	* backends/http/Makefile.am: Removed unnecessary


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