aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-list-editor
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/contact-list-editor')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c83
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.c39
2 files changed, 81 insertions, 41 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 0c762ff982..22dccfcb67 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -23,9 +23,12 @@
#include "e-contact-list-editor.h"
#include <string.h>
-#include <glib.h>
+
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-window-icon.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtktogglebutton.h>
+
#include <bonobo/bonobo-ui-container.h>
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-window.h>
@@ -868,7 +871,8 @@ table_drag_data_received_cb (ETable *table, int row, int col,
if (!e_contact_get (contact, E_CONTACT_IS_LIST)) {
e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model),
- contact);
+ contact,
+ 0 /* Hard-wired for default e-mail */);
changed = TRUE;
}
@@ -916,7 +920,6 @@ extract_info(EContactListEditor *editor)
EContact *contact = editor->contact;
if (contact) {
int i;
- GList *email_list;
char *image_data;
gsize image_data_len;
char *string = gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1);
@@ -932,19 +935,19 @@ extract_info(EContactListEditor *editor)
e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES,
GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton))));
- email_list = NULL;
+ e_vcard_remove_attributes (E_VCARD (contact), "", EVC_EMAIL);
+
/* then refill it from the contact list model */
for (i = 0; i < e_table_model_row_count (editor->model); i ++) {
- const EABDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i);
- gchar *dest_xml = eab_destination_export (dest);
- if (dest_xml)
- email_list = g_list_append (email_list, dest_xml);
- }
+ const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i);
+ EVCardAttribute *attr;
- e_contact_set (contact, E_CONTACT_EMAIL, email_list);
+ attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
- g_list_foreach (email_list, (GFunc) g_free, NULL);
- g_list_free (email_list);
+ e_vcard_add_attribute (E_VCARD (contact), attr);
+
+ e_destination_export_to_vcard_attribute (dest, attr);
+ }
if (editor->image_set
&& e_image_chooser_get_image_data (E_IMAGE_CHOOSER (editor->list_image),
@@ -976,7 +979,7 @@ fill_in_info(EContactListEditor *editor)
GList *iter;
file_as = e_contact_get_const (editor->contact, E_CONTACT_FILE_AS);
- email_list = e_contact_get (editor->contact, E_CONTACT_EMAIL);
+ email_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL);
is_evolution_list = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_IS_LIST));
show_addresses = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_LIST_SHOW_ADDRESSES));
@@ -992,18 +995,54 @@ fill_in_info(EContactListEditor *editor)
e_contact_list_model_remove_all (E_CONTACT_LIST_MODEL (editor->model));
for (iter = email_list; iter; iter = iter->next) {
- char *dest_xml = iter->data;
- EABDestination *dest;
-
- /* g_message ("incoming xml: [%s]", dest_xml); */
- dest = eab_destination_import (dest_xml);
-
- if (dest != NULL) {
- e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest);
+ EVCardAttribute *attr = iter->data;
+ GList *p;
+ EDestination *list_dest = e_destination_new ();
+ char *contact_uid = NULL;
+ char *email = NULL;
+ char *name = NULL;
+ int email_num = -1;
+ gboolean html_pref = FALSE;
+
+ for (p = e_vcard_attribute_get_params (attr); p; p = p->next) {
+ EVCardAttributeParam *param = p->data;
+ const char *param_name = e_vcard_attribute_param_get_name (param);
+ if (!g_ascii_strcasecmp (param_name,
+ EVC_X_DEST_CONTACT_UID)) {
+ GList *v = e_vcard_attribute_param_get_values (param);
+ contact_uid = v ? v->data : NULL;
+ }
+ else if (!g_ascii_strcasecmp (param_name,
+ EVC_X_DEST_EMAIL_NUM)) {
+ GList *v = e_vcard_attribute_param_get_values (param);
+ email_num = v ? atoi (v->data) : -1;
+ }
+ else if (!g_ascii_strcasecmp (param_name,
+ EVC_X_DEST_NAME)) {
+ GList *v = e_vcard_attribute_param_get_values (param);
+ name = v ? v->data : NULL;
+ }
+ else if (!g_ascii_strcasecmp (param_name,
+ EVC_X_DEST_EMAIL)) {
+ GList *v = e_vcard_attribute_param_get_values (param);
+ email = v ? v->data : NULL;
+ }
+ else if (!g_ascii_strcasecmp (param_name,
+ EVC_X_DEST_HTML_MAIL)) {
+ GList *v = e_vcard_attribute_param_get_values (param);
+ html_pref = v ? !g_ascii_strcasecmp (v->data, "true") : FALSE;
+ }
}
+
+ if (contact_uid) e_destination_set_contact_uid (list_dest, contact_uid, email_num);
+ if (name) e_destination_set_name (list_dest, name);
+ if (email) e_destination_set_email (list_dest, email);
+ e_destination_set_html_mail_pref (list_dest, html_pref);
+
+ e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), list_dest);
}
- g_list_foreach (email_list, (GFunc) g_free, NULL);
+ g_list_foreach (email_list, (GFunc) e_vcard_attribute_free, NULL);
g_list_free (email_list);
photo = e_contact_get (editor->contact, E_CONTACT_LOGO);
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c
index c7fd626372..8a22da19db 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c
@@ -30,7 +30,7 @@ contact_list_value_at (ETableModel *etc, int col, int row)
{
EContactListModel *model = E_CONTACT_LIST_MODEL (etc);
- return (void *) eab_destination_get_textrep (model->data[row], TRUE);
+ return (void *) e_destination_get_textrep (model->data[row], TRUE);
}
/* This function sets the value at a particular point in our ETableModel. */
@@ -80,7 +80,7 @@ contact_list_value_to_string (ETableModel *etc, int col, const void *value)
}
static void
-contact_list_model_destroy (GtkObject *o)
+contact_list_model_dispose (GObject *o)
{
EContactListModel *model = E_CONTACT_LIST_MODEL (o);
int i;
@@ -96,17 +96,17 @@ contact_list_model_destroy (GtkObject *o)
model->data_count = 0;
model->data_alloc = 0;
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (o);
+ (* G_OBJECT_CLASS (parent_class)->dispose) (o);
}
static void
-e_contact_list_model_class_init (GtkObjectClass *object_class)
+e_contact_list_model_class_init (GObjectClass *object_class)
{
ETableModelClass *model_class = (ETableModelClass *) object_class;
parent_class = g_type_class_ref (PARENT_TYPE);
- object_class->destroy = contact_list_model_destroy;
+ object_class->dispose = contact_list_model_dispose;
model_class->column_count = contact_list_col_count;
model_class->row_count = contact_list_row_count;
@@ -121,13 +121,13 @@ e_contact_list_model_class_init (GtkObjectClass *object_class)
}
static void
-e_contact_list_model_init (GtkObject *object)
+e_contact_list_model_init (GObject *object)
{
EContactListModel *model = E_CONTACT_LIST_MODEL(object);
model->data_alloc = 10;
model->data_count = 0;
- model->data = g_new (EABDestination*, model->data_alloc);
+ model->data = g_new (EDestination*, model->data_alloc);
}
GType
@@ -172,16 +172,16 @@ e_contact_list_model_new ()
}
void
-e_contact_list_model_add_destination (EContactListModel *model, EABDestination *dest)
+e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest)
{
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
- g_return_if_fail (EAB_IS_DESTINATION (dest));
+ g_return_if_fail (E_IS_DESTINATION (dest));
e_table_model_pre_change (E_TABLE_MODEL (model));
if (model->data_count + 1 >= model->data_alloc) {
model->data_alloc *= 2;
- model->data = g_renew (EABDestination*, model->data, model->data_alloc);
+ model->data = g_renew (EDestination*, model->data, model->data_alloc);
}
model->data[model->data_count ++] = dest;
@@ -194,28 +194,29 @@ void
e_contact_list_model_add_email (EContactListModel *model,
const char *email)
{
- EABDestination *new_dest;
+ EDestination *new_dest;
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
g_return_if_fail (email != NULL);
- new_dest = eab_destination_new ();
- eab_destination_set_email (new_dest, email);
+ new_dest = e_destination_new ();
+ e_destination_set_email (new_dest, email);
e_contact_list_model_add_destination (model, new_dest);
}
void
e_contact_list_model_add_contact (EContactListModel *model,
- EContact *contact)
+ EContact *contact,
+ int email_num)
{
- EABDestination *new_dest;
+ EDestination *new_dest;
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
g_return_if_fail (E_IS_CONTACT (contact));
- new_dest = eab_destination_new ();
- eab_destination_set_contact (new_dest, contact, 0); /* Hard-wired for default e-mail */
+ new_dest = e_destination_new ();
+ e_destination_set_contact (new_dest, contact, email_num);
e_contact_list_model_add_destination (model, new_dest);
}
@@ -229,7 +230,7 @@ e_contact_list_model_remove_row (EContactListModel *model, int row)
e_table_model_pre_change (E_TABLE_MODEL (model));
g_object_unref (model->data[row]);
- memmove (model->data + row, model->data + row + 1, sizeof (EABDestination*) * (model->data_count - row - 1));
+ memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1));
model->data_count --;
e_table_model_row_deleted (E_TABLE_MODEL (model), row);
@@ -255,7 +256,7 @@ e_contact_list_model_remove_all (EContactListModel *model)
}
-const EABDestination *
+const EDestination *
e_contact_list_model_get_destination (EContactListModel *model, int row)
{
g_return_val_if_fail (E_IS_CONTACT_LIST_MODEL (model), NULL);