[evolution-patches] ESource API changes



Hi,

I have attached the patch with the APIs to create with ESource with
absolute URI. Also modified existing set_group and get_uri APIs 
to create absolute URI only if Source is not having it, instead
of creating it whenever the group is not NULL.

I have made these changes, to show GAL folder in Contacts view for an
exchange account, where protocol differs for personal/Contacts and GAl.
("exchange" and "gal" respectively).

Please review this.

Thanks,
Sushma.


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/ChangeLog,v
retrieving revision 1.125
diff -u -r1.125 ChangeLog
--- ChangeLog	19 May 2004 18:23:23 -0000	1.125
+++ ChangeLog	22 May 2004 11:30:02 -0000
@@ -1,3 +1,15 @@
+2004-05-22  Sushma Rai <rsushma novell com>
+
+	* libedataserver/e-source.[ch] (e_source_new_with_absolute_uri)
+	(e_source_set_absolute_uri)(e_source_peek_absolute_uri):
+	Added new.
+
+	* libedataserver/e-source.c: (e_source_set_group)(e_source_get_uri):
+	Build absolute URI only if source is not having it.
+
+	* libedataserver/e-source.c: (dump_common_to_xml_node): Writing 
+	absolute URI to the file.
+ 
 2004-05-19  JP Rosevear  <jpr novell com>
 
 	* configure.in: bump version, libtool numbers
Index: libedataserver/e-source.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-source.c,v
retrieving revision 1.12
diff -u -r1.12 e-source.c
--- libedataserver/e-source.c	15 Jan 2004 17:07:25 -0000	1.12
+++ libedataserver/e-source.c	22 May 2004 11:30:19 -0000
@@ -187,6 +187,23 @@
 }
 
 ESource *
+e_source_new_with_absolute_uri (const char *name,
+				const char *absolute_uri)
+{
+	ESource *source;
+
+	g_return_val_if_fail (name != NULL, NULL);
+	g_return_val_if_fail (absolute_uri != NULL, NULL);
+
+	source = g_object_new (e_source_get_type (), NULL);
+	source->priv->uid = e_uid_new ();
+
+	e_source_set_name (source, name);
+	e_source_set_absolute_uri (source, absolute_uri);
+	return source;
+}
+
+ESource *
 e_source_new_from_xml_node (xmlNodePtr node)
 {
 	ESource *source;
@@ -297,6 +314,7 @@
 	if (source->priv->name == NULL
 	    || strcmp (name, source->priv->name) != 0
 	    || source->priv->relative_uri == NULL
+	    || relative_uri != NULL
 	    || strcmp (relative_uri, source->priv->relative_uri) != 0) {
 		g_free (source->priv->name);
 		source->priv->name = g_strdup (name);
@@ -429,10 +447,8 @@
 	if (group != NULL) {
 		g_object_weak_ref (G_OBJECT (group), (GWeakNotify) group_weak_notify, source);
 
-		if (source->priv->absolute_uri)
-			g_free (source->priv->absolute_uri);
-
-		source->priv->absolute_uri = build_absolute_uri (source);
+		if (!source->priv->absolute_uri)
+			source->priv->absolute_uri = build_absolute_uri (source);
 	}
 
 	g_signal_emit (source, signals[CHANGED], 0);
@@ -475,6 +491,24 @@
 }
 
 void
+e_source_set_absolute_uri (ESource *source,
+			   const char *absolute_uri)
+{
+	g_return_if_fail (E_IS_SOURCE (source));
+
+	if (source->priv->readonly)
+		return;
+
+	if (source->priv->absolute_uri == absolute_uri)
+		return;
+
+	g_free (source->priv->absolute_uri);
+	source->priv->absolute_uri = g_strdup (absolute_uri);
+
+	g_signal_emit (source, signals[CHANGED], 0);
+}
+
+void
 e_source_set_readonly (ESource  *source,
 		       gboolean  readonly)
 {
@@ -552,6 +586,14 @@
 	return source->priv->relative_uri;
 }
 
+const char *
+e_source_peek_absolute_uri (ESource *source)
+{
+	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
+
+	return source->priv->absolute_uri;
+}
+
 gboolean
 e_source_get_readonly (ESource *source)
 {
@@ -599,8 +641,10 @@
 		g_warning ("e_source_get_uri () called on source with no absolute URI!");
 		return NULL;
 	}
-
-	return build_absolute_uri (source);
+	else if (source->priv->absolute_uri != NULL) /* source->priv->group != NULL */
+		return g_strdup (source->priv->absolute_uri);
+	else
+		return build_absolute_uri (source);
 }
 
 
@@ -623,6 +667,7 @@
 	gboolean has_color;
 	guint32 color;
 	xmlNodePtr node;
+	const char *abs_uri = NULL, *relative_uri = NULL;
 
 	priv = source->priv;
 
@@ -633,7 +678,12 @@
 
 	xmlSetProp (node, "uid", e_source_peek_uid (source));
 	xmlSetProp (node, "name", e_source_peek_name (source));
-	xmlSetProp (node, "relative_uri", e_source_peek_relative_uri (source));
+	abs_uri = e_source_peek_absolute_uri (source);
+	relative_uri = e_source_peek_relative_uri (source);
+	if (abs_uri)
+		xmlSetProp (node, "uri", abs_uri);
+	if (relative_uri)
+		xmlSetProp (node, "relative_uri", relative_uri);
 	
 	has_color = e_source_get_color (source, &color);
 	if (has_color) {


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