aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/backend')
-rw-r--r--addressbook/backend/ebook/e-book-listener.c7
-rw-r--r--addressbook/backend/ebook/e-book-listener.h3
-rw-r--r--addressbook/backend/ebook/e-book.c10
-rw-r--r--addressbook/backend/ebook/e-card-simple.c111
-rw-r--r--addressbook/backend/ebook/e-card-simple.h15
5 files changed, 113 insertions, 33 deletions
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 8ef9072bf6..0aaf5483a5 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -207,12 +207,17 @@ e_book_listener_queue_get_supported_fields_response (EBookListener *listener,
const GNOME_Evolution_Addressbook_stringlist *fields)
{
EBookListenerResponse *resp;
+ int i;
resp = g_new0 (EBookListenerResponse, 1);
resp->op = GetSupportedFieldsResponse;
resp->status = status;
- resp->fields = fields;
+ resp->fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL);
+
+ for (i = 0; i < fields->_length; i ++) {
+ e_list_append (resp->fields, g_strdup (fields->_buffer[i]));
+ }
e_book_listener_queue_response (listener, resp);
}
diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h
index d999d21a65..0390f7fcb2 100644
--- a/addressbook/backend/ebook/e-book-listener.h
+++ b/addressbook/backend/ebook/e-book-listener.h
@@ -16,6 +16,7 @@
#include <bonobo/bonobo-object.h>
#include <ebook/addressbook.h>
#include <ebook/e-book-types.h>
+#include <e-util/e-list.h>
BEGIN_GNOME_DECLS
@@ -70,7 +71,7 @@ typedef struct {
GNOME_Evolution_Addressbook_BookView book_view;
/* For GetSupportedFields */
- const GNOME_Evolution_Addressbook_stringlist *fields;
+ EList *fields;
/* For OpenProgressEvent */
char *msg;
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c
index 1471d67f4c..438445aa9a 100644
--- a/addressbook/backend/ebook/e-book.c
+++ b/addressbook/backend/ebook/e-book.c
@@ -336,8 +336,6 @@ e_book_do_response_get_supported_fields (EBook *book,
EBookListenerResponse *resp)
{
EBookOp *op;
- EList *list;
- int i;
op = e_book_pop_op (book);
@@ -347,14 +345,8 @@ e_book_do_response_get_supported_fields (EBook *book,
return;
}
- list = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL);
-
- for (i = 0; i < resp->fields->_length; i ++) {
- e_list_append (list, g_strdup (resp->fields->_buffer[i]));
- }
-
if (op->cb)
- ((EBookFieldsCallback) op->cb) (book, resp->status, list, op->closure);
+ ((EBookFieldsCallback) op->cb) (book, resp->status, resp->fields, op->closure);
g_free (op);
}
diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c
index ff65ff82b0..7ad1726653 100644
--- a/addressbook/backend/ebook/e-card-simple.c
+++ b/addressbook/backend/ebook/e-card-simple.c
@@ -72,30 +72,41 @@ struct _ECardSimpleFieldData {
/* This order must match the order in the .h. */
+/* the ecard_field data below should only be used for TYPE_STRING,
+ TYPE_DATE, and TYPE_SPECIAL fields. that is, it's only valid for
+ e-cards for those types. it is used as a unique name for fields
+ for the get_supported functionality. */
static ECardSimpleFieldData field_data[] =
{
- { E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", "File As", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_FULL_NAME, "full_name", "Name", "Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_FAMILY_NAME, "family_name", "Family Name", "Family Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
- { E_CARD_SIMPLE_FIELD_EMAIL, "", "Email", "Email", E_CARD_SIMPLE_EMAIL_ID_EMAIL, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
- { E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, "", "Primary", "Prim", E_CARD_SIMPLE_PHONE_ID_PRIMARY, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, "", "Business", "Bus", E_CARD_SIMPLE_PHONE_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME, "", "Home", "Home", E_CARD_SIMPLE_PHONE_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_ORG, "org", "Organization", "Org", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
- { E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS, "", "Business", "Bus", E_CARD_SIMPLE_ADDRESS_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_ADDRESS_HOME, "", "Home", "Home", E_CARD_SIMPLE_ADDRESS_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_PHONE_MOBILE, "", "Mobile", "Mobile", E_CARD_SIMPLE_PHONE_ID_MOBILE, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_CAR, "", "Car", "Car", E_CARD_SIMPLE_PHONE_ID_CAR, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, "", "Business Fax", "Bus Fax", E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME_FAX, "", "Home Fax", "Home Fax", E_CARD_SIMPLE_PHONE_ID_HOME_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_2, "", "Business 2", "Bus 2", E_CARD_SIMPLE_PHONE_ID_BUSINESS_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_HOME_2, "", "Home 2", "Home 2", E_CARD_SIMPLE_PHONE_ID_HOME_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_ISDN, "", "ISDN", "ISDN", E_CARD_SIMPLE_PHONE_ID_ISDN, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_OTHER, "", "Other", "Other", E_CARD_SIMPLE_PHONE_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_PHONE_PAGER, "", "Pager", "Pager", E_CARD_SIMPLE_PHONE_ID_PAGER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
- { E_CARD_SIMPLE_FIELD_ADDRESS_OTHER, "", "Other", "Other", E_CARD_SIMPLE_ADDRESS_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
- { E_CARD_SIMPLE_FIELD_EMAIL_2, "", "Email 2", "Email 2", E_CARD_SIMPLE_EMAIL_ID_EMAIL_2, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
- { E_CARD_SIMPLE_FIELD_EMAIL_3, "", "Email 3", "Email 3", E_CARD_SIMPLE_EMAIL_ID_EMAIL_3, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
+ { E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", "File As", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
+ { E_CARD_SIMPLE_FIELD_FULL_NAME, "full_name", "Name", "Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
+ { E_CARD_SIMPLE_FIELD_FAMILY_NAME, "family_name", "Family Name", "Family Name", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
+ { E_CARD_SIMPLE_FIELD_EMAIL, "email", "Email", "Email", E_CARD_SIMPLE_EMAIL_ID_EMAIL, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
+ { E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, "primary_phone", "Primary", "Prim", E_CARD_SIMPLE_PHONE_ID_PRIMARY, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_ASSISTANT, "assistant_phone", "Assistant", "Assistant",E_CARD_SIMPLE_PHONE_ID_ASSISTANT, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, "business_phone", "Business", "Bus", E_CARD_SIMPLE_PHONE_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_CALLBACK, "callback_phone", "Callback", "Callback", E_CARD_SIMPLE_PHONE_ID_CALLBACK, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_COMPANY, "company_phone", "Company", "Comp", E_CARD_SIMPLE_PHONE_ID_COMPANY, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_HOME, "home_phone", "Home", "Home", E_CARD_SIMPLE_PHONE_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_ORG, "org", "Organization", "Org", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
+ { E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS, "business_address","Business", "Bus", E_CARD_SIMPLE_ADDRESS_ID_BUSINESS, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
+ { E_CARD_SIMPLE_FIELD_ADDRESS_HOME, "home_address", "Home", "Home", E_CARD_SIMPLE_ADDRESS_ID_HOME, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
+ { E_CARD_SIMPLE_FIELD_PHONE_MOBILE, "mobile_phone", "Mobile", "Mobile", E_CARD_SIMPLE_PHONE_ID_MOBILE, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_CAR, "car_phone", "Car", "Car", E_CARD_SIMPLE_PHONE_ID_CAR, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, "business_fax", "Business Fax", "Bus Fax", E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_HOME_FAX, "home_fax", "Home Fax", "Home Fax", E_CARD_SIMPLE_PHONE_ID_HOME_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_2, "business_phone_2","Business 2", "Bus 2", E_CARD_SIMPLE_PHONE_ID_BUSINESS_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_HOME_2, "home_phone_2", "Home 2", "Home 2", E_CARD_SIMPLE_PHONE_ID_HOME_2, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_ISDN, "isdn", "ISDN", "ISDN", E_CARD_SIMPLE_PHONE_ID_ISDN, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_OTHER, "other_phone", "Other", "Other", E_CARD_SIMPLE_PHONE_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_OTHER_FAX, "other_fax", "Other Fax", "Other Fax", E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_PAGER, "pager", "Pager", "Pager", E_CARD_SIMPLE_PHONE_ID_PAGER, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_RADIO, "radio", "Radio", "Radio", E_CARD_SIMPLE_PHONE_ID_RADIO, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_TELEX, "telex", "Telex", "Telex", E_CARD_SIMPLE_PHONE_ID_TELEX, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_PHONE_TTYTTD, "tty", "TTY", "TTY", E_CARD_SIMPLE_PHONE_ID_TTYTTD, E_CARD_SIMPLE_INTERNAL_TYPE_PHONE },
+ { E_CARD_SIMPLE_FIELD_ADDRESS_OTHER, "other_address", "Other", "Other", E_CARD_SIMPLE_ADDRESS_ID_OTHER, E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS },
+ { E_CARD_SIMPLE_FIELD_EMAIL_2, "email_2", "Email 2", "Email 2", E_CARD_SIMPLE_EMAIL_ID_EMAIL_2, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
+ { E_CARD_SIMPLE_FIELD_EMAIL_3, "email_3", "Email 3", "Email 3", E_CARD_SIMPLE_EMAIL_ID_EMAIL_3, E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL },
{ E_CARD_SIMPLE_FIELD_URL, "url", "Web Site", "Url", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
{ E_CARD_SIMPLE_FIELD_ORG_UNIT, "org_unit", "Department", "Dep", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
{ E_CARD_SIMPLE_FIELD_OFFICE, "office", "Office", "Off", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
@@ -112,6 +123,7 @@ static ECardSimpleFieldData field_data[] =
{ E_CARD_SIMPLE_FIELD_MAILER, "mailer", "", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_STRING },
{ E_CARD_SIMPLE_FIELD_NAME_OR_ORG, "nameororg", "", "", 0, E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL },
};
+static int field_data_count = sizeof (field_data) / sizeof (field_data[0]);
static void e_card_simple_init (ECardSimple *simple);
static void e_card_simple_class_init (ECardSimpleClass *klass);
@@ -983,6 +995,12 @@ ECardSimpleType e_card_simple_type (ECardSimple *simple,
}
}
+const char *e_card_simple_get_ecard_field (ECardSimple *simple,
+ ECardSimpleField field)
+{
+ return field_data[field].ecard_field;
+}
+
const char *e_card_simple_get_name (ECardSimple *simple,
ECardSimpleField field)
{
@@ -1065,3 +1083,52 @@ void e_card_simple_set_arbitrary (ECardSimple *sim
}
}
+/* These map between the individual list types and ECardSimpleField */
+ECardSimpleField
+e_card_simple_map_phone_to_field (ECardSimplePhoneId phone_id)
+{
+ int i;
+
+ g_return_val_if_fail (phone_id < E_CARD_SIMPLE_PHONE_ID_LAST, 0);
+
+ for (i = 0; i < field_data_count; i ++)
+ if (field_data[i].list_type_index == phone_id
+ && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_PHONE)
+ return i;
+
+ g_warning ("couldn't find phone id %d, returning 0 (which is almost assuredly incorrect)\n", phone_id);
+
+ return 0;
+}
+
+ECardSimpleField
+e_card_simple_map_email_to_field (ECardSimpleEmailId email_id)
+{
+ int i;
+
+ g_return_val_if_fail (email_id < E_CARD_SIMPLE_EMAIL_ID_LAST, 0);
+
+ for (i = 0; i < field_data_count; i ++)
+ if (field_data[i].list_type_index == email_id
+ && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL)
+ return i;
+
+ g_warning ("couldn't find email id %d, returning 0 (which is almost assuredly incorrect)\n", email_id);
+ return 0;
+}
+
+ECardSimpleField
+e_card_simple_map_address_to_field (ECardSimpleAddressId address_id)
+{
+ int i;
+
+ g_return_val_if_fail (address_id < E_CARD_SIMPLE_ADDRESS_ID_LAST, 0);
+
+ for (i = 0; i < field_data_count; i ++)
+ if (field_data[i].list_type_index == address_id
+ && field_data[i].type == E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS)
+ return i;
+
+ g_warning ("couldn't find address id %d, returning 0 (which is almost assuredly incorrect)\n", address_id);
+ return 0;
+}
diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h
index e23f5fe90c..bcdc37f914 100644
--- a/addressbook/backend/ebook/e-card-simple.h
+++ b/addressbook/backend/ebook/e-card-simple.h
@@ -81,7 +81,10 @@ enum _ECardSimpleField {
E_CARD_SIMPLE_FIELD_FAMILY_NAME,
E_CARD_SIMPLE_FIELD_EMAIL,
E_CARD_SIMPLE_FIELD_PHONE_PRIMARY,
+ E_CARD_SIMPLE_FIELD_PHONE_ASSISTANT,
E_CARD_SIMPLE_FIELD_PHONE_BUSINESS,
+ E_CARD_SIMPLE_FIELD_PHONE_CALLBACK,
+ E_CARD_SIMPLE_FIELD_PHONE_COMPANY,
E_CARD_SIMPLE_FIELD_PHONE_HOME,
E_CARD_SIMPLE_FIELD_ORG,
E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS,
@@ -94,7 +97,11 @@ enum _ECardSimpleField {
E_CARD_SIMPLE_FIELD_PHONE_HOME_2,
E_CARD_SIMPLE_FIELD_PHONE_ISDN,
E_CARD_SIMPLE_FIELD_PHONE_OTHER,
+ E_CARD_SIMPLE_FIELD_PHONE_OTHER_FAX,
E_CARD_SIMPLE_FIELD_PHONE_PAGER,
+ E_CARD_SIMPLE_FIELD_PHONE_RADIO,
+ E_CARD_SIMPLE_FIELD_PHONE_TELEX,
+ E_CARD_SIMPLE_FIELD_PHONE_TTYTTD,
E_CARD_SIMPLE_FIELD_ADDRESS_OTHER,
E_CARD_SIMPLE_FIELD_EMAIL_2,
E_CARD_SIMPLE_FIELD_EMAIL_3,
@@ -151,6 +158,9 @@ void e_card_simple_set (ECardSimple
const char *data);
ECardSimpleType e_card_simple_type (ECardSimple *simple,
ECardSimpleField field);
+
+const char *e_card_simple_get_ecard_field (ECardSimple *simple,
+ ECardSimpleField field);
const char *e_card_simple_get_name (ECardSimple *simple,
ECardSimpleField field);
const char *e_card_simple_get_short_name (ECardSimple *simple,
@@ -193,6 +203,11 @@ void e_card_simple_set_arbitrary (ECardSimple
const char *value);
void e_card_simple_sync_card (ECardSimple *simple);
+/* These map between the individual list types and ECardSimpleField */
+ECardSimpleField e_card_simple_map_phone_to_field (ECardSimplePhoneId phone_id);
+ECardSimpleField e_card_simple_map_email_to_field (ECardSimpleEmailId email_id);
+ECardSimpleField e_card_simple_map_address_to_field (ECardSimpleAddressId address_id);
+
/* Standard Gtk function */
GtkType e_card_simple_get_type (void);