G_TYPE_POINTER); /* COLUMN_ABOOK_CONTACT */
for (contact = contacts; contact != NULL; contact = contact->next) {
+
EContactDate *bdate = NULL;
bdate = e_contact_get (E_CONTACT (contact->data), E_CONTACT_BIRTH_DATE);
if (bdate) {
- EContactPhoto *photo = NULL;
GError *error = NULL;
GdkPixbuf *avatar = NULL;
- gchar *fullname = NULL;
+ const gchar *fullname = NULL;
guint age = 0, next_birthday = 0;
gchar *display_column = NULL;
gchar *next_birthday_text = NULL;
struct tm birthday_tm;
gchar birthday_text[11];
- OssoABookContact *abook_contact;
-
- photo = e_contact_get (E_CONTACT (contact->data), E_CONTACT_PHOTO);
- if (photo) {
- if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
- GdkPixbufLoader *loader;
-
- loader = gdk_pixbuf_loader_new ();
- if (gdk_pixbuf_loader_write (loader, (guchar *) photo->data.inlined.data, photo->data.inlined.length, NULL))
- avatar = gdk_pixbuf_loader_get_pixbuf (loader);
-
- } else {
- gchar *avatar_filename = NULL;
-
- avatar_filename = g_filename_from_uri (photo->data.uri, NULL, NULL);
- if (avatar_filename) {
- avatar = gdk_pixbuf_new_from_file (avatar_filename, &error);
- g_free (avatar_filename);
- }
- }
-
- if (avatar) {
- gint height = gdk_pixbuf_get_height (avatar);
- if (height != 48) {
- gint new_height = 48;
- gint new_width = new_height * gdk_pixbuf_get_width (avatar) / height;
- avatar = gdk_pixbuf_scale_simple (avatar, new_width, new_height, GDK_INTERP_BILINEAR);
- }
- }
- e_contact_photo_free (photo);
- photo = NULL;
- } else {
+
+ avatar = osso_abook_avatar_get_image_rounded (OSSO_ABOOK_AVATAR (contact->data), 48, 48, TRUE, 4, NULL);
+ if (!avatar) {
avatar = gdk_pixbuf_new_from_file ("/usr/share/icons/hicolor/48x48/hildon/general_default_avatar.png", &error);
}
- fullname = e_contact_get (E_CONTACT (contact->data), E_CONTACT_FULL_NAME);
- if (!fullname) {
- fullname = e_contact_get (E_CONTACT (contact->data), E_CONTACT_GIVEN_NAME);
- if (!fullname) {
- fullname = e_contact_get (E_CONTACT (contact->data), E_CONTACT_FAMILY_NAME);
- if (!fullname) {
- fullname = e_contact_get (E_CONTACT (contact->data), E_CONTACT_NICKNAME);
- if (!fullname) {
- fullname = e_contact_get (E_CONTACT (contact->data), E_CONTACT_ORG);
- }
- }
- }
- }
+ fullname = osso_abook_contact_get_display_name (OSSO_ABOOK_CONTACT (contact->data));
birthday_tm.tm_sec = 0;
birthday_tm.tm_min = 0;
display_column = g_strdup_printf ("%s <span font_desc=\"%s\" foreground=\"%s\"><sup>(%d)</sup>\n%s, %s</span>",
fullname, text_font, text_color, age, birthday_text, next_birthday_text);
- abook_contact = osso_abook_contact_new_from_template (E_CONTACT (contact->data));
-
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_AVATAR, avatar,
COLUMN_DISPLAY, display_column,
COLUMN_FULLNAME, fullname,
COLUMN_NEXT_BIRTHDAY, next_birthday,
- COLUMN_ABOOK_CONTACT, abook_contact,
+ COLUMN_ABOOK_CONTACT, contact->data,
-1);
n_contacts++;
g_free (display_column);
display_column = NULL;
- if (fullname)
- g_free (fullname);
- fullname = NULL;
-
if (next_birthday_text)
g_free (next_birthday_text);
next_birthday_text = NULL;
create_main_window (BirthdayData *priv, GtkListStore *store)
{
HildonProgram *program = NULL;
- GtkWidget *main_vbox, *alignment, *pannable, *tree_view;
+ GtkWidget *main_vbox, *alignment, *pannable;
GtkTreeModel *filter;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
}
static GList *
-get_all_contacts (EBook *ebook)
+get_all_contacts (void)
{
GError *error = NULL;
- EBookQuery *query;
+ OssoABookAggregator *aggregator;
GList *contacts;
- ebook = e_book_new_system_addressbook (&error);
- if (!ebook) {
- g_warning ("Error opening system address book: %s", error->message);
+ aggregator = OSSO_ABOOK_AGGREGATOR (osso_abook_aggregator_get_default (&error));
+ if (!aggregator) {
+ g_warning ("Error creating default abook aggregator: %s", error->message);
g_error_free (error);
return NULL;
}
- if (!e_book_open (ebook, TRUE, &error)) {
- g_warning ("Error opening system address book: %s", error->message);
+ osso_abook_waitable_run (OSSO_ABOOK_WAITABLE (aggregator), g_main_context_default(), &error);
+ if (error) {
+ g_warning ("Error wating for abook: %s", error->message);
g_error_free (error);
return NULL;
}
- query = e_book_query_any_field_contains ("");
-
- if (!e_book_get_contacts (ebook, query, &contacts, &error)) {
- g_warning ("Error getting contacts: %s", error->message);
- g_error_free (error);
- return NULL;
- }
+ contacts = osso_abook_aggregator_list_master_contacts (aggregator);
return contacts;
}
{
BirthdayData *data;
osso_context_t *osso_context;
- EBook *ebook;
- GtkWidget *window;
GtkListStore *store;
GList *contacts;
goto exit;
}
- contacts = get_all_contacts (ebook);
+ contacts = get_all_contacts ();
store = create_bday_liststore (data, contacts);
/* create main widow */