Re: [evolution-patches] calendar patch for 309420



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
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 09:53:16 -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 09:53:17 -0000
@@ -1582,6 +1582,52 @@ 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)
+{
+	char *uri, *base_uri, user_name, auth_type, 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) {
+			g_free (uri);
+			if (auth_type)
+				return g_strdup_printf ("%s%s;%s %s/", base_uri, user_name, auth_type, host_name);
+			else
+				return g_strdup_printf ("%s%s %s/", base_uri, user_name, host_name);
+		}
+	}
+
+	return uri;
+}
+
 static gboolean
 open_calendar (ECal *ecal, gboolean only_if_exists, GError **error, ECalendarStatus *status, gboolean needs_auth)
 {
@@ -1650,7 +1696,7 @@ 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);
+		key = build_pass_key (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]