setters aren't called with NULL data anymore. (fn_setter): same.
authorChris Toshok <toshok@ximian.com>
Wed, 21 Apr 2004 18:36:00 +0000 (18:36 +0000)
committerChris Toshok <toshok@src.gnome.org>
Wed, 21 Apr 2004 18:36:00 +0000 (18:36 +0000)
2004-04-21  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.

addressbook/ChangeLog
addressbook/libebook/e-book-listener.c
addressbook/libebook/e-book-query.c
addressbook/libebook/e-book-view-listener.h
addressbook/libebook/e-contact.c

index aae9978..bba7c1c 100644 (file)
@@ -1,3 +1,26 @@
+2004-04-21  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-21  Sivaiah Nallagatla <snallagatla@novell.com>
        * backends/groupwise/e-book-backend-groupwise.c 
        (e_book_backend_groupwise_load_source) : change the separtor used between uri
index 0774e4f..027aa31 100644 (file)
@@ -173,7 +173,7 @@ impl_BookListener_respond_get_view (PortableServer_Servant servant,
 
        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 24ff6b8..2f12ef1 100644 (file)
@@ -484,6 +484,27 @@ func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data
        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 @@ static struct {
        { "is", func_is, 0 },
        { "beginswith", func_beginswith, 0 },
        { "endswith", func_endswith, 0 },
+       { "exists", func_exists, 0 },
 };
 
 /**
index b1114a9..308cdee 100644 (file)
@@ -84,6 +84,7 @@ struct _EBookViewListenerResponse {
 
 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 0bb0643..aef81f7 100644 (file)
@@ -393,9 +393,6 @@ photo_setter (EContact *contact, EVCardAttribute *attr, void *data)
        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 @@ fn_setter (EContact *contact, EVCardAttribute *attr, void *data)
 {
        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 @@ n_setter (EContact *contact, EVCardAttribute *attr, void *data)
 {
        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 @@ adr_setter (EContact *contact, EVCardAttribute *attr, void *data)
 {
        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 @@ date_setter (EContact *contact, EVCardAttribute *attr, void *data)
        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 @@ cert_setter (EContact *contact, EVCardAttribute *attr, void *data)
 {
        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 @@ e_contact_set_property (GObject *object,
                        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 @@ e_contact_set_property (GObject *object,
                        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,16 +882,25 @@ e_contact_set_property (GObject *object,
                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);
 
@@ -913,11 +908,6 @@ e_contact_set_property (GObject *object,
 
                        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) {
                EVCardAttribute *attr;