Re: [evolution-patches] calendar patch for 309420



Hi,

Incorporated some more changes and sending another patch.

-- Sarfraaz

On Mon, 2005-08-22 at 15:31 +0530, Sarfraaz Ahmed wrote:
> This is a more improved patch. Please ignore the previous one and review
> this instead.
> 
> Thanks
> -- Sarfraaz
> 
> 
> 
> On Sat, 2005-08-20 at 17:20 +0530, Sarfraaz Ahmed wrote:
> > Hi,
> > 
> > Since Exchange can have multiple calendars, the key for remembering the
> > password, should be the same for a given account. This fixes this in
> > e-cal.c, whcih is needed as part of the fix for #309420.
> > 
> > Please let me know if this is fine to commit.
> > 
> > Thanks
> > -- Sarfraaz
> > _______________________________________________
> > evolution-patches mailing list
> > evolution-patches lists ximian com
> > http://lists.ximian.com/mailman/listinfo/evolution-patches
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.506
diff -u -p -u -p -r1.506 ChangeLog
--- ChangeLog	21 Aug 2005 17:35:14 -0000	1.506
+++ ChangeLog	22 Aug 2005 11:19:23 -0000
@@ -1,3 +1,8 @@
+2005-08-22  Sarfraaz Ahmed <asarfraaz novell com>
+
+	* libecal/e-cal.c (build_pass_key) : Builds the password key. Added new
+	(get_host_from_uri) : Fetches the hostname from the esource. Added new
+
 2005-08-21  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #271969
Index: libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.110
diff -u -p -u -p -r1.110 e-cal.c
--- libecal/e-cal.c	17 Aug 2005 03:58:47 -0000	1.110
+++ libecal/e-cal.c	22 Aug 2005 11:19:24 -0000
@@ -1582,13 +1582,60 @@ e_cal_set_auth_func (ECal *ecal, ECalAut
 	ecal->priv->auth_user_data = data;
 }
 
+static char *
+get_host_from_uri (const char *uri)
+{
+	char *at = strchr (uri, '@');
+	char *slash;
+	int length;
+
+	if (!at)
+		return NULL;
+	at++; /* Parse over the @ symbol */
+	slash = strchr (at, '/');
+	if (!slash)
+		return NULL;
+	slash --; /* Walk back */
+
+	length = slash - at;
+
+	return g_strndup (at, length);
+}
+
+static char *
+build_pass_key (ESource *source)
+{
+	const char *base_uri, *user_name, *auth_type;
+	char *uri, *new_uri, *host_name;
+	ESourceGroup *es_grp;
+
+	uri = e_source_get_uri (source);
+
+	es_grp = e_source_peek_group (source);
+	base_uri = e_source_group_peek_base_uri (es_grp);
+	if (base_uri) {
+		user_name = e_source_get_property (source, "username");
+		auth_type = e_source_get_property (source, "auth-type");
+		host_name = get_host_from_uri (uri);
+		if (user_name && host_name && auth_type) {
+			new_uri = g_strdup_printf ("%s%s;%s %s/", base_uri, user_name, auth_type, host_name);
+			g_free (uri);
+			g_free (host_name);
+
+			return new_uri;
+		}
+	}
+
+	return uri;
+}
+
 static gboolean
 open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarStatus *status, gboolean needs_auth)
 {
 	ECalPrivate *priv;
 	CORBA_Environment ev;
 	ECalendarOp *our_op;
-	const char *username = NULL;
+	const char *username = NULL, *auth_type = NULL;
 	char *password = NULL;
 	gboolean read_only;
 	
@@ -1617,7 +1664,8 @@ open_calendar (ECal *ecal, gboolean only
 
 	/* see if the backend needs authentication */
 	if ( (priv->mode !=  CAL_MODE_LOCAL) && e_source_get_property (priv->source, "auth")) {
-		char *prompt, *key, *parent_source_url, *parent_user;
+		char *prompt, *key;
+		const char *parent_user;
 
 		priv->load_state = E_CAL_LOAD_AUTHENTICATING;
 
@@ -1650,7 +1698,12 @@ open_calendar (ECal *ecal, gboolean only
 			prompt = g_strdup_printf (_("Enter password for %s (user %s)"),
 					e_source_peek_name (priv->source), username);
 		}
-		key = e_source_get_uri (priv->source);
+		auth_type = e_source_get_property (priv->source, "auth-type");
+		if (auth_type)
+			key = build_pass_key (priv->source);
+		else
+			key = e_source_get_uri (priv->source);
+
 		if (!key) {
 			e_calendar_remove_op (ecal, our_op);
 			g_mutex_unlock (our_op->mutex);


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