+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
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;
{ "is", func_is, 0 },
{ "beginswith", func_beginswith, 0 },
{ "endswith", func_endswith, 0 },
+ { "exists", func_exists, 0 },
};
/**
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,
{
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) {
{
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);
{
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);
EContactDate *date = data;
char *str;
- if (!date)
- return;
-
str = e_contact_date_to_string (date);
e_vcard_attribute_add_value (attr, str);
{
EContactCert *cert = data;
- if (!cert)
- return;
-
e_vcard_attribute_add_param_with_value (attr,
e_vcard_attribute_param_new (EVC_ENCODING),
"b");
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;
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);
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);
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;