[evolution-patches] more misc libebook fixes.



The EContact ones are necessary to keep the new contact editor from
spitting out broken vcards.  All the others are pretty self explanatory.

Chris
? backends/groupwise/Makefile
? backends/groupwise/Makefile.in
? backends/groupwise/create-account
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.131
diff -u -r1.131 ChangeLog
--- ChangeLog	20 Apr 2004 17:12:22 -0000	1.131
+++ ChangeLog	20 Apr 2004 18:07:30 -0000
@@ -1,5 +1,28 @@
 2004-04-20  Chris Toshok  <toshok ximian com>
 
+	* libebook/e-contact.c (photo_setter): setters aren't called with
+	NULL data anymore.
+	(fn_setter): same.
+	(n_setter): same.
+	(adr_setter): same.
+	(date_setter): same.
+	(cert_setter): same.
+	(e_contact_set_property): only call struct_setter if the data is
+	non-NULL and non-empty.  otherwise remove the newly created
+	attribute.
+
+	* libebook/e-book-view-listener.h: doh, really add _start
+	prototype.
+
+	* libebook/e-book-query.c (func_exists): new function - we weren't
+	parsing the "exists" query before, so duplicating a query
+	containing one failed (duplication = unparse + parse).
+
+	* libebook/e-book-listener.c (impl_BookListener_respond_get_view):
+	don't rely on bonobo_object_dup_ref returning the same object.
+
+2004-04-20  Chris Toshok  <toshok ximian com>
+
 	* tests/ebook/Makefile.am: add test-nonexistent-id and test-query.
 	
 	* tests/ebook/test-nonexistent-id.c: test for both
Index: libebook/e-book-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-listener.c,v
retrieving revision 1.8
diff -u -r1.8 e-book-listener.c
--- libebook/e-book-listener.c	24 Feb 2004 23:44:39 -0000	1.8
+++ libebook/e-book-listener.c	20 Apr 2004 18:07:30 -0000
@@ -173,7 +173,7 @@
 
 	g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
 
-	bonobo_object_release_unref (book_view, ev);
+	bonobo_object_release_unref (response.book_view, ev);
 }
 
 static void
Index: libebook/e-book-query.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-query.c,v
retrieving revision 1.3
diff -u -r1.3 e-book-query.c
--- libebook/e-book-query.c	21 Feb 2004 01:20:46 -0000	1.3
+++ libebook/e-book-query.c	20 Apr 2004 18:07:30 -0000
@@ -484,6 +484,27 @@
 	return r;
 }
 
+static ESExpResult *
+func_exists(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
+{
+	GList **list = data;
+	ESExpResult *r;
+
+	if (argc == 1
+	    && argv[0]->type == ESEXP_RES_STRING) {
+		char *propname = argv[0]->value.string;
+		EContactField field = e_contact_field_id (propname);
+
+		if (field)
+			*list = g_list_prepend (*list, e_book_query_field_exists (field));
+	}
+
+	r = e_sexp_result_new(f, ESEXP_RES_BOOL);
+	r->value.bool = FALSE;
+
+	return r;
+}
+
 /* 'builtin' functions */
 static struct {
 	char *name;
@@ -498,6 +519,7 @@
 	{ "is", func_is, 0 },
 	{ "beginswith", func_beginswith, 0 },
 	{ "endswith", func_endswith, 0 },
+	{ "exists", func_exists, 0 },
 };
 
 /**
Index: libebook/e-book-view-listener.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-view-listener.h,v
retrieving revision 1.3
diff -u -r1.3 e-book-view-listener.h
--- libebook/e-book-view-listener.h	23 Dec 2003 22:36:53 -0000	1.3
+++ libebook/e-book-view-listener.h	20 Apr 2004 18:07:30 -0000
@@ -84,6 +84,7 @@
 
 EBookViewListener         *e_book_view_listener_new            (void);
 GType                      e_book_view_listener_get_type       (void);
+void                       e_book_view_listener_start          (EBookViewListener *listener);
 void                       e_book_view_listener_stop           (EBookViewListener *listener);
 
 G_END_DECLS
Index: libebook/e-contact.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.c,v
retrieving revision 1.31
diff -u -r1.31 e-contact.c
--- libebook/e-contact.c	16 Apr 2004 22:34:58 -0000	1.31
+++ libebook/e-contact.c	20 Apr 2004 18:07:31 -0000
@@ -393,9 +393,6 @@
 	const char *mime_type;
 	char *image_type = "X-EVOLUTION-UNKNOWN";
 
-	if (!photo)
-		return;
-
 	g_return_if_fail (photo->length > 0);
 
 	e_vcard_attribute_add_param_with_value (attr,
@@ -442,10 +439,7 @@
 {
 	gchar *name_str = data;
 
-	if (!name_str)
-		return;
-
-	e_vcard_attribute_add_value (attr, (char*)data);
+	e_vcard_attribute_add_value (attr, name_str);
 
 	attr = e_contact_get_first_attr (contact, EVC_N);
 	if (!attr) {
@@ -485,9 +479,6 @@
 {
 	EContactName *name = data;
 
-	if (!name)
-		return;
-
 	e_vcard_attribute_add_value (attr, name->family);
 	e_vcard_attribute_add_value (attr, name->given);
 	e_vcard_attribute_add_value (attr, name->additional);
@@ -545,9 +536,6 @@
 {
 	EContactAddress *addr = data;
 
-	if (!addr)
-		return;
-
 	e_vcard_attribute_add_value (attr, addr->po);
 	e_vcard_attribute_add_value (attr, addr->ext);
 	e_vcard_attribute_add_value (attr, addr->street);
@@ -583,9 +571,6 @@
 	EContactDate *date = data;
 	char *str;
 
-	if (!date)
-		return;
-
 	str = e_contact_date_to_string (date);
 
 	e_vcard_attribute_add_value (attr, str);
@@ -627,9 +612,6 @@
 {
 	EContactCert *cert = data;
 
-	if (!cert)
-		return;
-
 	e_vcard_attribute_add_param_with_value (attr,
 						e_vcard_attribute_param_new (EVC_ENCODING),
 						"b");
@@ -695,7 +677,7 @@
 			int num_left = info->list_elem;
 			GList *attrs = e_vcard_get_attributes (E_VCARD (contact));
 			GList *l;
-			char *sval;
+			const char *sval;
 
 			for (l = attrs; l; l = l->next) {
 				const char *name;
@@ -813,7 +795,11 @@
 			if (info->t & E_CONTACT_FIELD_TYPE_STRUCT || info->t & E_CONTACT_FIELD_TYPE_GETSET) {
 				void *data = info->t & E_CONTACT_FIELD_TYPE_STRUCT ? g_value_get_boxed (value) : (char*)g_value_get_string (value);
 
-				info->struct_setter (contact, attr, data);
+				if ((info->t & E_CONTACT_FIELD_TYPE_STRUCT && data)
+				    || (data && *(char*)data))
+					info->struct_setter (contact, attr, data);
+				else
+					e_vcard_remove_attribute (E_VCARD (contact), attr);
 			}
 			else {
 				const char *sval = g_value_get_string (value);
@@ -896,27 +882,31 @@
 		EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name);
 		void *data = info->t & E_CONTACT_FIELD_TYPE_STRUCT ? g_value_get_boxed (value) : (char*)g_value_get_string (value);
 
-		if (attr && data) {
-			d(printf ("overwriting existing %s\n", info->vcard_field_name));
-			/* remove all existing values and parameters.
-			   the setter will add the correct ones */
-			e_vcard_attribute_remove_values (attr);
-			e_vcard_attribute_remove_params (attr);
+		if (attr) {
+			if ((info->t & E_CONTACT_FIELD_TYPE_STRUCT && data)
+			    || (data && *(char*)data)) {
+				d(printf ("overwriting existing %s\n", info->vcard_field_name));
+				/* remove all existing values and parameters.
+				   the setter will add the correct ones */
+				e_vcard_attribute_remove_values (attr);
+				e_vcard_attribute_remove_params (attr);
 
-			info->struct_setter (contact, attr, data);
+				info->struct_setter (contact, attr, data);
+			}
+			else {
+				d(printf ("removing %s\n", info->vcard_field_name));
+
+				e_vcard_remove_attribute (E_VCARD (contact), attr);
+			}
 		}
-		else if (data) {
+		else if ((info->t & E_CONTACT_FIELD_TYPE_STRUCT && data)
+			 || (data && *(char*)data)) {
 			d(printf ("adding new %s\n", info->vcard_field_name));
 			attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
 
 			e_vcard_add_attribute (E_VCARD (contact), attr);
 
 			info->struct_setter (contact, attr, data);
-		}
-		else if (attr) {
-			d(printf ("removing %s\n", info->vcard_field_name));
-
-			e_vcard_remove_attribute (E_VCARD (contact), attr);
 		}
 	}
 	else if (info->t & E_CONTACT_FIELD_TYPE_BOOLEAN) {


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