aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-list-editor
diff options
context:
space:
mode:
authorJon Trowbridge <trow@src.gnome.org>2001-07-07 14:39:30 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-07-07 14:39:30 +0800
commitf9e0870bb8f2cee522b1d74d8d430cd898a420e5 (patch)
treeafe1ea372bafca21d8f328fd861305919fcc97a0 /addressbook/gui/contact-list-editor
parentda9c4d10641eed27263f12c7415100348991ef32 (diff)
downloadgsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.gz
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.bz2
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.lz
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.xz
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.zst
gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.zip
CVS is unhappy this evening. My commit keeps dying in the middle.
svn path=/trunk/; revision=10883
Diffstat (limited to 'addressbook/gui/contact-list-editor')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c35
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.c93
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.h24
3 files changed, 51 insertions, 101 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 86e283f0f6..805604b722 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -765,9 +765,12 @@ extract_info(EContactListEditor *editor)
NULL);
for (i = 0; i < e_table_model_row_count (editor->model); i ++) {
- char *email = e_contact_list_model_get_email (E_CONTACT_LIST_MODEL(editor->model), i);
- e_list_append (email_list, email);
- g_free (email);
+ const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i);
+ gchar *dest_xml = e_destination_export (dest);
+ if (dest_xml) {
+ e_list_append (email_list, dest_xml);
+ }
+ g_free (dest_xml);
}
}
}
@@ -802,24 +805,14 @@ fill_in_info(EContactListEditor *editor)
email_iter = e_list_get_iterator (email_list);
while (e_iterator_is_valid (email_iter)) {
- const char *email = e_iterator_get (email_iter);
-
- if (!strncmp (email, ECARD_UID_LINK_PREFIX, strlen (ECARD_UID_LINK_PREFIX))) {
- ECard *card;
- const char *uid;
- /* it's a serialized uid */
- uid = email + strlen (ECARD_UID_LINK_PREFIX);
- card = e_book_get_card (editor->book, uid);
- if (card) {
- ECardSimple *simple = e_card_simple_new (card);
- gtk_object_unref (GTK_OBJECT (card));
- e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model),
- simple);
- }
- }
- else {
- e_contact_list_model_add_email (E_CONTACT_LIST_MODEL (editor->model),
- email);
+ const char *dest_xml = e_iterator_get (email_iter);
+ EDestination *dest;
+
+ g_message ("incoming xml: [%s]", dest_xml);
+ dest = e_destination_import (dest_xml);
+
+ if (dest != NULL) {
+ e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest);
}
e_iterator_next (email_iter);
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 5a966c67d1..eb6f59741b 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c
@@ -29,7 +29,7 @@ contact_list_value_at (ETableModel *etc, int col, int row)
{
EContactListModel *model = E_CONTACT_LIST_MODEL (etc);
- return model->data[row]->string;
+ return (void *) e_destination_get_address (model->data[row]);
}
/* This function sets the value at a particular point in our ETableModel. */
@@ -85,10 +85,7 @@ contact_list_model_destroy (GtkObject *o)
int i;
for (i = 0; i < model->data_count; i ++) {
- g_free (model->data[i]->string);
- if (model->data[i]->simple)
- gtk_object_unref (GTK_OBJECT(model->data[i]->simple));
- g_free (model->data[i]);
+ gtk_object_unref (GTK_OBJECT (model->data[i]));
}
g_free (model->data);
@@ -124,7 +121,7 @@ e_contact_list_model_init (GtkObject *object)
model->data_alloc = 10;
model->data_count = 0;
- model->data = g_new (EContactListModelRow*, model->data_alloc);
+ model->data = g_new (EDestination*, model->data_alloc);
}
GtkType
@@ -168,73 +165,49 @@ e_contact_list_model_new ()
}
void
-e_contact_list_model_add_email (EContactListModel *model,
- const char *email)
+e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest)
{
- EContactListModelRow *new_row;
-
if (model->data_count + 1 >= model->data_alloc) {
model->data_alloc *= 2;
- model->data = g_renew (EContactListModelRow*, model->data, model->data_alloc);
+ model->data = g_renew (EDestination*, model->data, model->data_alloc);
}
- new_row = g_new (EContactListModelRow, 1);
- new_row->type = E_CONTACT_LIST_MODEL_ROW_EMAIL;
- new_row->simple = NULL;
- new_row->string = g_strdup (email);
-
- model->data[model->data_count ++] = new_row;
+ model->data[model->data_count ++] = dest;
+ gtk_object_ref (GTK_OBJECT (dest));
+ gtk_object_sink (GTK_OBJECT (dest));
e_table_model_changed (E_TABLE_MODEL (model));
}
void
-e_contact_list_model_add_card (EContactListModel *model,
- ECardSimple *simple)
+e_contact_list_model_add_email (EContactListModel *model,
+ const char *email)
{
- EContactListModelRow *new_row;
- char *email, *name;
-
- name = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG);
- email = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_EMAIL);
-
- if (! name && ! email) {
- /* what to do here? */
- return;
- }
-
+ EDestination *new_dest;
- if (model->data_count + 1 >= model->data_alloc) {
- model->data_alloc *= 2;
- model->data = g_renew (EContactListModelRow*, model->data, model->data_alloc);
- }
+ new_dest = e_destination_new ();
+ e_destination_set_email (new_dest, email);
- new_row = g_new (EContactListModelRow, 1);
-
- new_row->type = E_CONTACT_LIST_MODEL_ROW_CARD;
- new_row->simple = simple;
- if (FALSE /* XXX e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_EVOLUTION_LIST)*/)
- new_row->string = g_strconcat ("<", name, ">", NULL);
- else
- new_row->string = g_strconcat (name ? name : "",
- email ? " <" : "", email ? email : "", email ? ">" : "",
- NULL);
+ e_contact_list_model_add_destination (model, new_dest);
+}
- model->data[model->data_count++] = new_row;
+void
+e_contact_list_model_add_card (EContactListModel *model,
+ ECardSimple *simple)
+{
+ EDestination *new_dest;
- gtk_object_ref (GTK_OBJECT (simple));
+ new_dest = e_destination_new ();
+ e_destination_set_card (new_dest, simple->card, 0); /* Hard-wired for default e-mail */
- e_table_model_changed (E_TABLE_MODEL (model));
+ e_contact_list_model_add_destination (model, new_dest);
}
void
e_contact_list_model_remove_row (EContactListModel *model, int row)
{
- g_free (model->data[row]->string);
- if (model->data[row]->simple)
- gtk_object_unref (GTK_OBJECT(model->data[row]->simple));
- g_free (model->data[row]);
- memmove (model->data + row, model->data + row + 1, sizeof (EContactListModelRow*) * (model->data_count - row - 1));
+ gtk_object_unref (GTK_OBJECT (model->data[row]));
+ memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1));
model->data_count --;
e_table_model_changed (E_TABLE_MODEL (model));
@@ -246,10 +219,7 @@ e_contact_list_model_remove_all (EContactListModel *model)
int i;
for (i = 0; i < model->data_count; i ++) {
- g_free (model->data[i]->string);
- if (model->data[i]->simple)
- gtk_object_unref (GTK_OBJECT(model->data[i]->simple));
- g_free (model->data[i]);
+ gtk_object_unref (GTK_OBJECT (model->data[i]));
model->data[i] = NULL;
}
@@ -259,13 +229,8 @@ e_contact_list_model_remove_all (EContactListModel *model)
}
-char*
-e_contact_list_model_get_email (EContactListModel *model, int row)
+const EDestination *
+e_contact_list_model_get_destination (EContactListModel *model, int row)
{
- EContactListModelRow *data = model->data[row];
-
- if (data->type == E_CONTACT_LIST_MODEL_ROW_EMAIL)
- return g_strdup (data->string);
- else
- return g_strconcat (ECARD_UID_LINK_PREFIX, e_card_simple_get_id (data->simple), NULL);
+ return model->data[row];
}
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h
index 7b1e092944..1c2d6ac8d0 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h
@@ -6,6 +6,7 @@
#include "addressbook/backend/ebook/e-book.h"
#include "addressbook/backend/ebook/e-book-view.h"
#include "addressbook/backend/ebook/e-card-simple.h"
+#include "addressbook/backend/ebook/e-destination.h"
#define E_CONTACT_LIST_MODEL_TYPE (e_contact_list_model_get_type ())
#define E_CONTACT_LIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CONTACT_LIST_MODEL_TYPE, EContactListModel))
@@ -16,21 +17,10 @@
typedef struct _EContactListModel EContactListModel;
typedef struct _EContactListModelClass EContactListModelClass;
-typedef enum {
- E_CONTACT_LIST_MODEL_ROW_EMAIL,
- E_CONTACT_LIST_MODEL_ROW_CARD,
-} EContactListModelRowType;
-
-typedef struct {
- EContactListModelRowType type;
- ECardSimple *simple;
- char *string;
-} EContactListModelRow;
-
struct _EContactListModel {
ETableModel parent;
- EContactListModelRow **data;
+ EDestination **data;
int data_count;
int data_alloc;
};
@@ -45,11 +35,13 @@ GtkType e_contact_list_model_get_type (void);
void e_contact_list_model_construct (EContactListModel *model);
ETableModel *e_contact_list_model_new (void);
-void e_contact_list_model_add_email (EContactListModel *model, const char *email);
-void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple);
+void e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest);
+void e_contact_list_model_add_email (EContactListModel *model, const char *email);
+void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple);
+
void e_contact_list_model_remove_row (EContactListModel *model, int row);
void e_contact_list_model_remove_all (EContactListModel *model);
-char *e_contact_list_model_get_row (EContactListModel *model, ECardSimple *simple);
-char *e_contact_list_model_get_email (EContactListModel *model, int row);
+
+const EDestination *e_contact_list_model_get_destination (EContactListModel *model, int row);
#endif /* _E_CONTACT_LIST_MODEL_H_ */