/** * e_book_backend_db_cache_add_contact: * @db: DB Handle * @contact: an #EContact * * Adds @contact to @cache. * * Returns: %TRUE if the contact was cached successfully, %FALSE otherwise. **/ gboolean e_book_backend_db_cache_add_contact (DB *db, EContact *contact) { DBT uid_dbt, vcard_dbt; gint db_error; gchar *vcard_str; const gchar *uid; uid = e_contact_get_const (contact, E_CONTACT_UID); if (!uid) { printf ("no uid\n"); printf("name:%s, email:%s\n", (gchar *)e_contact_get (contact, E_CONTACT_GIVEN_NAME), (gchar *)e_contact_get (contact, E_CONTACT_EMAIL_1)); return FALSE; } string_to_dbt (uid, &uid_dbt); vcard_str = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); string_to_dbt (vcard_str, &vcard_dbt); /* db_error = db->del (db, NULL, &uid_dbt, 0); */ db_error = db->put (db, NULL, &uid_dbt, &vcard_dbt, 0); g_free (vcard_str); if (db_error != 0) { g_warning ("db->put failed with %d", db_error); return FALSE; } else return TRUE; }
static gboolean fill_book_client (EBookClient *book_client, GSList **uids) { EContact *contact; g_return_val_if_fail (book_client != NULL, FALSE); g_return_val_if_fail (uids != NULL, FALSE); *uids = NULL; if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) return FALSE; *uids = g_slist_append (*uids, e_contact_get (contact, E_CONTACT_UID)); g_object_unref (contact); if (!add_contact_from_test_case_verify (book_client, "simple-2", &contact)) return FALSE; *uids = g_slist_append (*uids, e_contact_get (contact, E_CONTACT_UID)); g_object_unref (contact); return TRUE; }
static void eds_receive_contacts_cb (EBook *book, EBookStatus status, GList *contacts, gpointer user_data) { GtkTreeIter iter; GList *l; GtkListStore *model; PlannerPlugin *plugin; PlannerPluginPriv *priv; GdkPixbuf *pixbuf; AsyncQuery *async_query; const gchar *uid; gchar *filename; async_query = (AsyncQuery *) user_data; uid = async_query->uid; plugin = async_query->plugin; priv = plugin->priv; model = GTK_LIST_STORE (priv->resources_model); g_free (async_query); if (eds_query_cancelled (plugin, uid)) { g_message ("Answer for query cancelled: %s", uid); return; } g_message ("Book status response: %d", status); g_message ("Answer for the query: %s", uid); /* Exceed limit is E_BOOK_ERROR_OTHER_ERROR :( */ if (status == E_BOOK_ERROR_OK || status == E_BOOK_ERROR_OTHER_ERROR) { filename = mrp_paths_get_image_dir ("/resources.png"); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); g_free (filename); for (l = contacts; l; l = l->next) { gchar *name, *email; name = e_contact_get (l->data, E_CONTACT_FULL_NAME); g_message ("Resource name: %s\n", name); email = e_contact_get (l->data, E_CONTACT_EMAIL_1); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, COL_RESOURCE_NAME, name, COL_RESOURCE_EMAIL, email, COL_RESOURCE_SELECTED, FALSE, COL_RESOURCE_PHOTO, pixbuf, COL_RESOURCE_OBJECT, l->data, -1); } } else { g_warning ("Problem getting contacts ..."); } eds_plugin_busy (plugin, FALSE); }
/* retrieve a list of contacts from the address book */ static int addrbook_libebook_retrieve(ship_list_t *list) { int ret = -1; contact_t *ct = 0; GError *error = 0; GList *contacts = 0, *loop; EBookQuery *query = 0; ship_lock(addrbook_lock); ASSERT_TRUE(query = e_book_query_any_field_contains(""), err); ASSERT_TRUE(e_book_get_contacts(book, query, &contacts, &error), err); ASSERT_ZERO(error, err); for (loop = contacts; loop; loop = g_list_next(loop)) { EContact *c = loop->data; char *name = 0; name = e_contact_get(c, E_CONTACT_OSSO_CONTACT_STATE); if (!name || strcmp(name, "DELETED")) { char **arrs = 0; ASSERT_TRUE(ct = ident_contact_new(), cerr); ASSERT_TRUE(ct->name = e_contact_get(c, E_CONTACT_FULL_NAME), cerr); ASSERT_TRUE(arrs = e_contact_get(c, E_CONTACT_SIP), cerr); ASSERT_TRUE(ct->sip_aor = addrbook_normalize_aor(arrs[0]), cerr); /* apparently arrs doesn't need to be free'd afterwards */ g_list_foreach((GList*)arrs, (GFunc)g_free, NULL); ship_list_add(list, ct); ct = 0; cerr: ident_contact_free(ct); } if (name) g_free(name); } ret = 0; err: if (contacts) { g_list_free(contacts); } if (query) { e_book_query_unref(query); } if (error) { LOG_ERROR("Error getting contacts: %s\n", error->message); g_error_free(error); } ship_unlock(addrbook_lock); return ret; }
static gboolean bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c) { EContactField field; GList *ims, *l; gboolean dirty = FALSE; EContactPhoto *photo = NULL; GError *error = NULL; /* Set the IM account */ field = proto_to_contact_field (b->proto); ims = e_contact_get (c, field); if (! im_list_contains_buddy (ims, b)) { ims = g_list_append (ims, (gpointer) b->account_name); e_contact_set (c, field, (gpointer) ims); dirty = TRUE; } /* Set the photo if it's not set */ if (b->icon != NULL) { photo = e_contact_get (c, E_CONTACT_PHOTO); if (photo == NULL) { gchar *contents = NULL; photo = g_new0 (EContactPhoto, 1); photo->type = E_CONTACT_PHOTO_TYPE_INLINED; if (! g_file_get_contents (b->icon, &contents, &photo->data.inlined.length, &error)) { g_warning ("bbdb: Could not read buddy icon: %s\n", error->message); g_error_free (error); for (l = ims; l != NULL; l = l->next) g_free ((char *) l->data); g_list_free (ims); return dirty; } photo->data.inlined.data = (unsigned char *)contents; e_contact_set (c, E_CONTACT_PHOTO, (gpointer) photo); dirty = TRUE; } } /* Clean up */ if (photo != NULL) e_contact_photo_free (photo); for (l = ims; l != NULL; l = l->next) g_free ((char *) l->data); g_list_free (ims); return dirty; }
static void eds_ok_button_clicked (GtkButton *button, PlannerPlugin *plugin) { GtkTreeIter iter; PlannerPluginPriv *priv = plugin->priv; GList *resources_orig; /* We are going to modify the resources. Work with a copy */ resources_orig = mrp_project_get_resources (plugin->priv->project); if (!priv->resources_model) { eds_dialog_close (plugin); return; } gtk_tree_model_get_iter_first (priv->resources_model, &iter); if (!gtk_list_store_iter_is_valid (GTK_LIST_STORE (priv->resources_model), &iter)) { eds_dialog_close (plugin); return; } /* Custom property for e-d-s resource UID */ if (!mrp_project_has_property (plugin->priv->project, MRP_TYPE_RESOURCE, "eds-uid")) { eds_create_uid_property (plugin); } do { EContact *contact; gboolean selected; gtk_tree_model_get (priv->resources_model, &iter, COL_RESOURCE_SELECTED, &selected, COL_RESOURCE_OBJECT, &contact, -1); if (selected) { gchar *name = e_contact_get (contact, E_CONTACT_FULL_NAME); gchar *email = e_contact_get (contact, E_CONTACT_EMAIL_1); gchar *eds_uid = e_contact_get (contact, E_CONTACT_UID); eds_import_resource (name, email, eds_uid, plugin, resources_orig); g_free (name); g_free (email); g_free (eds_uid); } } while (gtk_tree_model_iter_next (priv->resources_model, &iter)); eds_dialog_close (plugin); }
EABContactMatchType eab_contact_compare_email (EContact *contact1, EContact *contact2) { EABContactMatchType match = EAB_CONTACT_MATCH_NOT_APPLICABLE; GList *contact1_email, *contact2_email; GList *i1, *i2; g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); contact1_email = e_contact_get (contact1, E_CONTACT_EMAIL); contact2_email = e_contact_get (contact2, E_CONTACT_EMAIL); if (contact1_email == NULL || contact2_email == NULL) { g_list_foreach (contact1_email, (GFunc) g_free, NULL); g_list_free (contact1_email); g_list_foreach (contact2_email, (GFunc) g_free, NULL); g_list_free (contact2_email); return EAB_CONTACT_MATCH_NOT_APPLICABLE; } i1 = contact1_email; /* Do pairwise-comparisons on all of the e-mail addresses. If * we find an exact match, there is no reason to keep * checking. */ while (i1 && match != EAB_CONTACT_MATCH_EXACT) { gchar *addr1 = (gchar *) i1->data; i2 = contact2_email; while (i2 && match != EAB_CONTACT_MATCH_EXACT) { gchar *addr2 = (gchar *) i2->data; match = combine_comparisons (match, compare_email_addresses (addr1, addr2)); i2 = i2->next; } i1 = i1->next; } g_list_foreach (contact1_email, (GFunc) g_free, NULL); g_list_free (contact1_email); g_list_foreach (contact2_email, (GFunc) g_free, NULL); g_list_free (contact2_email); return match; }
static gboolean compare_im (EContact *contact, const gchar *str, gchar * (*compare) (const gchar *, const gchar *), EContactField im_field) { GList *aims, *l; gboolean found_it = FALSE; aims = e_contact_get (contact, im_field); for (l = aims; l != NULL; l = l->next) { gchar *im = (gchar *) l->data; if (im && compare (im, str)) { found_it = TRUE; break; } } g_list_foreach (aims, (GFunc) g_free, NULL); g_list_free (aims); return found_it; }
static void eds_contacts_added_cb(EBookView *view, const GList *contacts, gpointer data) { const GList *walk; GList **address_list = (GList**) data; for(walk = contacts; walk; walk = walk->next) { const char *name; GList *email_list, *email_entry; EContact *contact = walk->data; if(!E_IS_CONTACT(contact)) continue; name = e_contact_get_const(contact, E_CONTACT_FULL_NAME); email_list = e_contact_get(contact, E_CONTACT_EMAIL); for(email_entry = email_list; email_entry; email_entry = email_entry->next) { address_entry *ae; const char *email_address = email_entry->data; ae = g_new0(address_entry, 1); ae->name = g_strdup(name); ae->address = g_strdup(email_address); ae->grp_emails = NULL; *address_list = g_list_prepend(*address_list, ae); addr_compl_add_address1(name, ae); if(email_address && *email_address != '\0') addr_compl_add_address1(email_address, ae); } } }
static gchar * make_string_from_list (EContact *contact, EContactField field) { GList *values, *l; GString *string; string = g_string_new ("<span size=\"x-small\">"); values = e_contact_get (contact, field); for (l = values; l; l = l->next) { gchar *value = (gchar *) l->data; if (l->prev != NULL) g_string_append (string, ", "); g_string_append (string, value); } if (!values) g_string_append (string, " - none - "); e_contact_attr_list_free (values); g_string_append (string, "</span>"); return g_string_free (string, FALSE); }
char * gevo_get_email_for_buddy(PurpleBuddy *buddy) { EContact *contact; char *mail = NULL; contact = gevo_search_buddy_in_contacts(buddy, NULL); if (contact != NULL) { mail = g_strdup(e_contact_get(contact, E_CONTACT_EMAIL_1)); g_object_unref(contact); } if (mail == NULL) { PurpleAccount *account = purple_buddy_get_account(buddy); const char *prpl_id = purple_account_get_protocol_id(account); if (!strcmp(prpl_id, "prpl-msn")) { mail = g_strdup(purple_normalize(account, purple_buddy_get_name(buddy))); } else if (!strcmp(prpl_id, "prpl-yahoo")) { mail = g_strdup_printf("*****@*****.**", purple_normalize(account, purple_buddy_get_name(buddy))); } } return mail; }
/* This provokes the backend to handle a cross-referenced photo * between contacts, how the backend handles this is it's choice, * we should test that when deleting one of the contacts, the other * contact does not lose it's photo on disk as a result. */ static void give_james_brown_micheal_jacksons_face (EBookClient *book) { EContact *micheal = NULL, *james = NULL; EContactPhoto *micheal_face; EContactPhoto *james_face; GError *error = NULL; if (!e_book_client_get_contact_sync (book, micheal_jackson_uid, &micheal, NULL, &error)) g_error ("Unable to get micheal jackson's contact information: %s", error->message); if (!e_book_client_get_contact_sync (book, james_brown_uid, &james, NULL, &error)) g_error ("Unable to get james brown's contact information: %s", error->message); g_assert (micheal); g_assert (james); micheal_face = e_contact_get (micheal, E_CONTACT_PHOTO); g_assert (micheal_face->type == E_CONTACT_PHOTO_TYPE_URI); james_face = g_new (EContactPhoto, 1); james_face->type = E_CONTACT_PHOTO_TYPE_URI; james_face->data.uri = g_strdup (micheal_face->data.uri); e_contact_set (james, E_CONTACT_PHOTO, james_face); g_print ("Giving james brown micheal jacksons face: %s\n", micheal_face->data.uri); if (!e_book_client_modify_contact_sync (book, james, NULL, &error)) g_error ("Failed to modify contact with cross referenced photo: %s", error->message); }
static gboolean includes_contact (HitoGroup *group, EContact *contact) { HitoCategoryGroupPrivate *priv; GList *categories, *l; gboolean visible = FALSE; g_return_val_if_fail (HITO_IS_CATEGORY_GROUP (group), FALSE); g_return_val_if_fail (E_IS_CONTACT (contact), FALSE); priv = GET_PRIVATE (group); categories = e_contact_get (contact, E_CONTACT_CATEGORY_LIST); for (l = categories; l ; l = l->next) { /* TODO: strmp? or funky decomposition compare? */ if (strcmp (priv->name, l->data) == 0) { visible = TRUE; break; } } g_list_foreach (categories, (GFunc)g_free, NULL); g_list_free (categories); return visible; }
static void add_contact_inline (EBookClient *book) { EContact *contact; EContactPhoto *photo; guchar *data; gsize length = 0; contact = e_contact_new (); data = g_base64_decode (photo_data, &length); photo = g_new (EContactPhoto, 1); photo->type = E_CONTACT_PHOTO_TYPE_INLINED; photo->data.inlined.mime_type = NULL; photo->data.inlined.data = data; photo->data.inlined.length = length; /* set the photo */ e_contact_set (contact, E_CONTACT_PHOTO, photo); e_contact_set (contact, E_CONTACT_FULL_NAME, "Micheal Jackson"); if (!add_contact_verify (book, contact)) g_error ("Failed to add contact"); micheal_jackson_uid = e_contact_get (contact, E_CONTACT_UID); }
static void test_remove_contact_sync (ETestServerFixture *fixture, gconstpointer user_data) { EBookClient *book_client; GError *error = NULL; EContact *contact = NULL; gchar *uid; book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient); if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) g_error ("Failed to add contact"); uid = e_contact_get (contact, E_CONTACT_UID); if (!e_book_client_remove_contact_sync (book_client, contact, NULL, &error)) g_error ("remove contact sync: %s", error->message); g_object_unref (contact); check_removed_contact (book_client, uid); g_free (uid); }
static gint add_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, EAddrConduitContext *ctxt) { EContact *contact; int retval = 0; g_return_val_if_fail (remote != NULL, -1); LOG (g_message ( "add_record: adding %s to desktop\n", print_remote (remote) )); contact = ecard_from_remote_record (ctxt, remote, NULL); /* add the ecard to the server */ if (!e_book_add_contact (ctxt->ebook, contact, NULL)) { WARN ("add_record: failed to add card to ebook\n"); g_object_unref (contact); return -1; } e_pilot_map_insert (ctxt->map, remote->ID, e_contact_get (contact, E_CONTACT_UID), FALSE); g_object_unref (contact); return retval; }
static gboolean compare_category (EContact *contact, const gchar *str, const gchar *region, CompareFunc compare) { GList *categories; GList *iterator; gboolean ret_val = FALSE; categories = e_contact_get (contact, E_CONTACT_CATEGORY_LIST); for (iterator = categories; iterator; iterator = iterator->next) { const gchar *category = iterator->data; if (compare (category, str, region)) { ret_val = TRUE; break; } } g_list_foreach (categories, (GFunc) g_free, NULL); g_list_free (categories); return ret_val; }
static gboolean compare_im (EContact *contact, const gchar *str, const gchar *region, CompareFunc compare, EContactField im_field) { GList *aims, *l; gboolean found_it = FALSE; aims = e_contact_get (contact, im_field); for (l = aims; l != NULL; l = l->next) { gchar *im = (gchar *) l->data; if (im && compare (im, str, region)) { found_it = TRUE; break; } } e_contact_attr_list_free (aims); return found_it; }
static void test_remove_contact_async (ETestServerFixture *fixture, gconstpointer user_data) { EBookClient *book_client; EContact *contact = NULL; gchar *uid; RemoveData data; book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient); if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) g_error ("Failed to add contact"); uid = e_contact_get (contact, E_CONTACT_UID); data.uid = uid; data.loop = fixture->loop; e_book_client_remove_contact (book_client, contact, NULL, remove_contact_cb, &data); g_object_unref (contact); g_main_loop_run (fixture->loop); g_free (uid); }
static gboolean compare_address (EContact *contact, const gchar *str, const gchar *region, CompareFunc compare) { gint i; gboolean rv = FALSE; for (i = E_CONTACT_FIRST_ADDRESS_ID; i <= E_CONTACT_LAST_ADDRESS_ID; i++) { EContactAddress *address = e_contact_get (contact, i); if (address) { rv = (address->po && compare (address->po, str, region)) || (address->street && compare (address->street, str, region)) || (address->ext && compare (address->ext, str, region)) || (address->locality && compare (address->locality, str, region)) || (address->region && compare (address->region, str, region)) || (address->code && compare (address->code, str, region)) || (address->country && compare (address->country, str, region)); e_contact_address_free (address); if (rv) break; } } return rv; }
static gint replace_record (GnomePilotConduitSyncAbs *conduit, EAddrLocalRecord *local, GnomePilotRecord *remote, EAddrConduitContext *ctxt) { EContact *new_contact; EBookChange *ebc; char *old_id; int retval = 0; g_return_val_if_fail (remote != NULL, -1); LOG (g_message ("replace_record: replace %s with %s\n", print_local (local), print_remote (remote))); old_id = e_contact_get (local->contact, E_CONTACT_UID); ebc = g_hash_table_lookup (ctxt->changed_hash, old_id); new_contact = ecard_from_remote_record (ctxt, remote, local->contact); g_object_unref (local->contact); local->contact = new_contact; if (ebc && ebc->change_type == E_BOOK_CHANGE_CARD_DELETED) { if (!e_book_add_contact (ctxt->ebook, local->contact, NULL)) { WARN (G_STRLOC ": failed to add card\n"); return -1; } } else { if (!e_book_commit_contact (ctxt->ebook, local->contact, NULL)) { WARN (G_STRLOC ": failed to commit card\n"); return -1; } } /* Adding a record causes wombat to assign a new uid so we must tidy */ if (ebc && ebc->change_type == E_BOOK_CHANGE_CARD_DELETED) { const char *uid = e_contact_get_const (local->contact, E_CONTACT_UID); gboolean arch; arch = e_pilot_map_uid_is_archived (ctxt->map, uid); e_pilot_map_insert (ctxt->map, remote->ID, uid, arch); ebc = g_hash_table_lookup (ctxt->changed_hash, old_id); if (ebc) { g_hash_table_remove (ctxt->changed_hash, old_id); g_object_unref (ebc->contact); g_object_ref (local->contact); ebc->contact = local->contact; /* FIXME We should possibly be duplicating the uid */ g_hash_table_insert (ctxt->changed_hash, (gpointer) uid, ebc); } } return retval; }
static void resolve_list_card (LDIFImporter *gci, EContact *contact) { GList *email, *l; GList *email_attrs = NULL; gchar *full_name; /* set file_as to full_name so we don't later try and figure * out a first/last name for the list. */ full_name = e_contact_get (contact, E_CONTACT_FULL_NAME); if (full_name) e_contact_set (contact, E_CONTACT_FILE_AS, full_name); g_free (full_name); /* FIMXE getting might not be implemented in ebook */ email = e_contact_get (contact, E_CONTACT_EMAIL); for (l = email; l; l = l->next) { /* mozilla stuffs dn's in the EMAIL list for contact lists */ gchar *dn = l->data; EContact *dn_contact = g_hash_table_lookup (gci->dn_contact_hash, dn); /* break list chains here, since we don't support them just yet */ if (dn_contact && !e_contact_get (dn_contact, E_CONTACT_IS_LIST)) { EDestination *dest; EVCardAttribute *attr = e_vcard_attribute_new (NULL, EVC_EMAIL); /* Hard-wired for default e-mail, since * netscape only exports 1 email address. */ dest = e_destination_new (); e_destination_set_contact (dest, dn_contact, 0); e_destination_export_to_vcard_attribute (dest, attr); g_object_unref (dest); email_attrs = g_list_append (email_attrs, attr); } } e_contact_set_attributes (contact, E_CONTACT_EMAIL, email_attrs); g_list_foreach (email, (GFunc) g_free, NULL); g_list_free (email); g_list_foreach (email_attrs, (GFunc) e_vcard_attribute_free, NULL); g_list_free (email_attrs); }
/* This function returns the height of the minicontact in question */ static int addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) { EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); EAddressbookReflowAdapterPrivate *priv = adapter->priv; EContactField field; int count = 0; char *string; EContact *contact = (EContact*)eab_model_contact_at (priv->model, i); PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (parent)->canvas), ""); int height; string = e_contact_get(contact, E_CONTACT_FILE_AS); height = text_height (layout, string ? string : "") + 10.0; g_free(string); for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING && count < 5; field++) { if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME) continue; string = e_contact_get(contact, field); if (string && *string) { int this_height; int field_text_height; this_height = text_height (layout, e_contact_pretty_name(field)); field_text_height = text_height (layout, string); if (this_height < field_text_height) this_height = field_text_height; this_height += 3; height += this_height; count ++; } g_free (string); } height += 2; g_object_unref (layout); return height; }
static void print_contact (EContact *contact) { EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO); g_assert (photo != NULL); g_assert (photo->type == E_CONTACT_PHOTO_TYPE_URI); g_print ("Test passed with photo uri: %s\n", photo->data.uri); }
static void contact_draw (EContact *contact, EContactPrintContext *ctxt) { GtkPageSetup *setup; gdouble page_height; gchar *file_as; gboolean new_section = FALSE; setup = gtk_print_context_get_page_setup (ctxt->context); page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); file_as = e_contact_get (contact, E_CONTACT_FILE_AS); if (file_as != NULL) { gchar *section; gsize width; width = g_utf8_next_char (file_as) - file_as; section = g_utf8_strup (file_as, width); new_section = (ctxt->section == NULL || g_utf8_collate (ctxt->section, section) != 0); if (new_section) { g_free (ctxt->section); ctxt->section = section; } else g_free (section); } if (new_section) { if (!ctxt->first_contact) { if (ctxt->style->sections_start_new_page) e_contact_start_new_page (ctxt); else if ((ctxt->y + e_contact_get_contact_height ( contact, ctxt)) > page_height) e_contact_start_new_column (ctxt); } if (ctxt->style->letter_headings) e_contact_print_letter_heading (ctxt, ctxt->section); ctxt->first_section = FALSE; } else if (!ctxt->first_contact && ((ctxt->y + e_contact_get_contact_height (contact, ctxt)) > page_height)) { e_contact_start_new_column (ctxt); if (ctxt->style->letter_headings) e_contact_print_letter_heading (ctxt, ctxt->section); } e_contact_print_contact (contact, ctxt); ctxt->first_contact = FALSE; }
static GtkWidget * ldif_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im) { GtkWidget *preview; GSList *contacts = NULL; EContact *contact; EImportTargetURI *s = (EImportTargetURI *) target; gchar *filename; GHashTable *dn_contact_hash; FILE *file; filename = g_filename_from_uri (s->uri_src, NULL, NULL); if (filename == NULL) { g_message (G_STRLOC ": Couldn't get filename from URI '%s'", s->uri_src); return NULL; } file = g_fopen(filename, "r"); g_free (filename); if (file == NULL) { g_message (G_STRLOC ": Can't open .ldif file"); return NULL; } dn_contact_hash = g_hash_table_new_full ( g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); while (contact = getNextLDIFEntry (dn_contact_hash, file), contact != NULL) { if (!e_contact_get (contact, E_CONTACT_IS_LIST)) { add_to_notes (contact, E_CONTACT_OFFICE); add_to_notes (contact, E_CONTACT_SPOUSE); add_to_notes (contact, E_CONTACT_BLOG_URL); } contacts = g_slist_prepend (contacts, contact); } g_hash_table_destroy (dn_contact_hash); contacts = g_slist_reverse (contacts); preview = evolution_contact_importer_get_preview_widget (contacts); e_client_util_free_object_slist (contacts); fclose (file); return preview; }
void moko_contacts_get_photo (MokoContacts *contacts, MokoContact *m_contact) { MokoContactsPrivate *priv; EContact *e_contact; EContactPhoto *photo; GError *err = NULL; GdkPixbufLoader *loader; g_return_if_fail (MOKO_IS_CONTACTS (contacts)); g_return_if_fail (m_contact); priv = contacts->priv; if (!e_book_get_contact (priv->book, m_contact->uid, &e_contact, &err)) { g_warning ("%s\n", err->message); m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL); if (m_contact->photo) g_object_ref (m_contact->photo); return; } photo = e_contact_get (e_contact, E_CONTACT_PHOTO); if (!photo) { m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL); if (m_contact->photo) g_object_ref (m_contact->photo); return; } loader = gdk_pixbuf_loader_new (); gdk_pixbuf_loader_write (loader, photo->data.inlined.data, photo->data.inlined.length, NULL); gdk_pixbuf_loader_close (loader, NULL); m_contact->photo = gdk_pixbuf_loader_get_pixbuf (loader); if (GDK_IS_PIXBUF (m_contact->photo)) g_object_ref (m_contact->photo); else { m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL); if (m_contact->photo) g_object_ref (m_contact->photo); } g_object_unref (loader); e_contact_photo_free (photo); }
EABContactMatchType eab_contact_compare (EContact *contact1, EContact *contact2) { EABContactMatchType result; g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); result = EAB_CONTACT_MATCH_NONE; if (!e_contact_get (contact1, E_CONTACT_IS_LIST)) { result = combine_comparisons (result, eab_contact_compare_name (contact1, contact2)); result = combine_comparisons (result, eab_contact_compare_nickname (contact1, contact2)); if (!e_contact_get (contact2, E_CONTACT_IS_LIST)) result = combine_comparisons (result, eab_contact_compare_email (contact1, contact2)); result = combine_comparisons (result, eab_contact_compare_address (contact1, contact2)); result = combine_comparisons (result, eab_contact_compare_telephone (contact1, contact2)); } result = combine_comparisons (result, eab_contact_compare_file_as (contact1, contact2)); return result; }
static void render_address_link (GString *buffer, EContact *contact, gint map_type) { EContactAddress *adr; GString *link = g_string_new (""); adr = e_contact_get (contact, map_type); if (adr && (adr->street || adr->locality || adr->region || adr->country)) { gchar *escaped; if (adr->street && *adr->street) g_string_append_printf (link, "%s", adr->street); if (adr->locality && *adr->locality) { if (link->len) g_string_append (link, ", "); g_string_append_printf (link, "%s", adr->locality); } if (adr->region && *adr->region) { if (link->len) g_string_append (link, ", "); g_string_append_printf (link, "%s", adr->region); } if (adr->country && *adr->country) { if (link->len) g_string_append (link, ", "); g_string_append_printf (link, "%s", adr->country); } escaped = g_uri_escape_string (link->str, NULL, TRUE); g_string_assign (link, escaped); g_free (escaped); g_string_prepend (link, "<a href=\"open-map:"); g_string_append_printf (link, "\">%s</a>", _("Open map")); } if (adr) e_contact_address_free (adr); g_string_append (buffer, link->str); g_string_free (link, TRUE); }
static void accum_attribute_multival (GString *buffer, EContact *contact, const gchar *html_label, EContactField field, const gchar *icon, guint html_flags) { GList *val_list, *l; GString *val = g_string_new (""); const gchar *str; gchar *tmp; val_list = e_contact_get (contact, field); for (l = val_list; l; l = l->next) { str = l->data; if (l != val_list) g_string_append (val, "<br>"); tmp = maybe_create_url (str, html_flags); if (tmp) str = tmp; if ((html_flags & E_TEXT_TO_HTML_CONVERT_URLS) != 0) { gchar *value = e_text_to_html (str, html_flags); if (value && *value) g_string_append (val, value); g_free (value); } else { g_string_append (val, str); } g_free (tmp); } if (val->str && *val->str) { if ((html_flags & E_TEXT_TO_HTML_CONVERT_URLS) != 0) html_flags = 0; render_table_row (buffer, html_label, val->str, icon, html_flags); } g_string_free (val, TRUE); g_list_foreach (val_list, (GFunc) g_free, NULL); g_list_free (val_list); }