diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-06-02 05:41:12 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-06-02 05:41:12 +0800 |
commit | 068e5e40b09717f630f6bb12bc199d6a739db4e3 (patch) | |
tree | 96544d47d49b252f40fd3aaa18caf09806ee0e15 /mail | |
parent | 4823916613b56d2cf046469b466ef5c6754b8d27 (diff) | |
download | gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar.gz gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar.bz2 gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar.lz gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar.xz gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.tar.zst gsoc2013-evolution-068e5e40b09717f630f6bb12bc199d6a739db4e3.zip |
** Adds support for Contact Image in the preview pane
svn path=/trunk/; revision=33613
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 16 | ||||
-rw-r--r-- | mail/em-folder-view.c | 22 | ||||
-rw-r--r-- | mail/em-format-html.c | 31 | ||||
-rw-r--r-- | mail/em-format.c | 2 | ||||
-rw-r--r-- | mail/em-format.h | 2 | ||||
-rw-r--r-- | mail/em-mailer-prefs.c | 9 | ||||
-rw-r--r-- | mail/em-mailer-prefs.h | 2 | ||||
-rw-r--r-- | mail/em-utils.c | 94 | ||||
-rw-r--r-- | mail/em-utils.h | 1 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in.in | 27 | ||||
-rw-r--r-- | mail/mail-config.glade | 128 |
11 files changed, 330 insertions, 4 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index bd2d3c2f96..c9385fb5ce 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2007-06-02 Srinivasa Ragavan <sragavan@novell.com> + + ** Adds support for Contact Image in the preview pane + + * em-folder-view.c: (emfv_message_selected_timeout), + (emfv_setting_notify): + * em-format-html.c: (efh_format_headers): + * em-format.c: (emf_init): + * em-format.h: + * em-mailer-prefs.c: (em_mailer_prefs_construct): + * em-mailer-prefs.h: + * em-utils.c: (em_utils_in_addressbook), (em_utils_contact_photo): + * em-utils.h: + * evolution-mail.schemas.in.in: + * mail-config.glade: + 2007-05-31 Daniel Nylander <po@danielnylander.se> *default/sv : Added Swedish Welcome mail. diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 9dd72f8522..fa162af44d 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2364,7 +2364,7 @@ emfv_message_selected_timeout(void *data) g_object_ref (emfv); /* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */ e_profile_event_emit("goto.load", emfv->displayed_uid, 0); - hstream = gtk_html_begin(((EMFormatHTML *)emfv->preview)->html); +/* hstream = gtk_html_begin(((EMFormatHTML *)emfv->preview)->html); g_signal_connect(((EMFormatHTML *)emfv->preview)->html, "object_requested", G_CALLBACK(emfv_spin), NULL); @@ -2372,7 +2372,7 @@ emfv_message_selected_timeout(void *data) _("Retrieving Message"), emfv->displayed_uid); gtk_html_stream_close(hstream, GTK_HTML_STREAM_OK); - +*/ mail_get_messagex(emfv->folder, emfv->displayed_uid, emfv_list_done_message_selected, emfv, mail_thread_queued); } else { e_profile_event_emit("goto.empty", "", 0); @@ -2661,6 +2661,8 @@ enum { EMFV_SHOW_DELETED, EMFV_THREAD_LIST, EMFV_PANED_SIZE, + EMFV_SENDER_PHOTO, + EMFV_PHOTO_LOCAL, EMFV_SETTINGS /* last, for loop count */ }; @@ -2680,6 +2682,8 @@ static const char * const emfv_display_keys[] = { "show_deleted", "thread_list", "paned_size", + "sender_photo", + "photo_local", }; static GHashTable *emfv_setting_key; @@ -2770,6 +2774,20 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold if (emf->message) em_format_redraw(emf); break; } + case EMFV_SENDER_PHOTO: { + EMFormat *emf = (EMFormat *)emfv->preview; + + emf->show_photo = gconf_value_get_bool (value); + if (emf->message) + em_format_redraw(emf); + + break; } + case EMFV_PHOTO_LOCAL: { + EMFormat *emf = (EMFormat *)emfv->preview; + + emf->photo_local = gconf_value_get_bool (value); + + break; } case EMFV_SHOW_PREVIEW: { gboolean state_gconf, state_camel; char *ret; diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 66ca8885b9..3ce658cfe1 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1748,7 +1748,9 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) CamelContentType *ct; struct _camel_header_raw *header; gboolean have_icon = FALSE; - + const char *photo_name = NULL; + CamelInternetAddress *cia = NULL; + ct = camel_mime_part_get_content_type((CamelMimePart *)part); charset = camel_content_type_param (ct, "charset"); charset = e_iconv_charset_name(charset); @@ -1777,6 +1779,10 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) mailer = !g_ascii_strcasecmp (h->name, "X-Evolution-Mailer"); while (header) { + + if (emf->show_photo && !photo_name && !g_ascii_strcasecmp (header->name, "From")) + photo_name = header->value; + if (!mailer_shown && mailer && (!g_ascii_strcasecmp (header->name, "X-Mailer") || !g_ascii_strcasecmp (header->name, "User-Agent") || !g_ascii_strcasecmp (header->name, "X-Newsreader"))) { @@ -1801,6 +1807,29 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) if (!efh->simple_headers) { camel_stream_printf(stream, "</table></td>"); + if (photo_name) { + char *classid; + CamelMimePart *photopart; + + cia = camel_internet_address_new(); + camel_address_decode((CamelAddress *) cia, (const char *) photo_name); + photopart = em_utils_contact_photo (cia, emf->photo_local); + + if (photopart) { + classid = g_strdup_printf("icon:///em-format-html/%s/photo/header", + emf->part_id->str); + camel_stream_printf(stream, + "<td align=\"right\" valign=\"top\"><img width=64 src=\"%s\"></td>", + classid); + em_format_add_puri(emf, sizeof(EMFormatPURI), classid, + photopart, efh_write_image); + camel_object_unref(photopart); + + g_free(classid); + } + camel_object_unref(cia); + } + if (have_icon && efh->show_icon) { GtkIconInfo *icon_info; char *classid; diff --git a/mail/em-format.c b/mail/em-format.c index 1871e885c3..cb3f418e38 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -121,6 +121,8 @@ emf_init(GObject *o) emf->inline_table = g_hash_table_new(g_str_hash, g_str_equal); emf->composer = FALSE; + emf->show_photo = TRUE; + emf->photo_local = TRUE; e_dlist_init(&emf->header_list); em_format_default_headers(emf); emf->part_id = g_string_new(""); diff --git a/mail/em-format.h b/mail/em-format.h index 3d2a82ef67..ca3cafc53d 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -227,6 +227,8 @@ struct _EMFormat { char *charset; /* charset override */ char *default_charset; /* charset fallback */ gboolean composer; /* Formatting from composer ?*/ + gboolean show_photo; /* Want to show the photo of the sender ?*/ + gboolean photo_local; /* Photos only from local addressbooks */ }; struct _EMFormatClass { diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index 7caeee32a3..9c61eddfec 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -1084,6 +1084,15 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) /* headers */ locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/headers", NULL); + + prefs->photo_show= GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "photo_show")); + toggle_button_init (prefs, prefs->photo_show, FALSE, + "/apps/evolution/mail/display/sender_photo", + G_CALLBACK (toggle_button_toggled)); + prefs->photo_local = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "photo_local")); + toggle_button_init (prefs, prefs->photo_local, FALSE, + "/apps/evolution/mail/display/photo_local", + G_CALLBACK (toggle_button_toggled)); /* always de-sensitised until the user types something in the entry */ prefs->add_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersAdd")); diff --git a/mail/em-mailer-prefs.h b/mail/em-mailer-prefs.h index f6adc4593e..6426e3fd41 100644 --- a/mail/em-mailer-prefs.h +++ b/mail/em-mailer-prefs.h @@ -119,6 +119,8 @@ struct _EMMailerPrefs { struct _GtkEntry *entry_header; struct _GtkTreeView *header_list; struct _GtkListStore *header_list_store; + struct _GtkToggleButton *photo_show; + struct _GtkToggleButton *photo_local; /* Junk prefs */ struct _GtkToggleButton *check_incoming; diff --git a/mail/em-utils.c b/mail/em-utils.c index e4d53ba12b..cfd12c6d0c 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1927,7 +1927,7 @@ em_utils_in_addressbook(CamelInternetAddress *iaddr) stop = err->domain == E_BOOK_ERROR && err->code == E_BOOK_ERROR_CANCELLED; mail_cancel_hook_remove(hook); g_object_unref(book); - g_warning("Can't get contacts: %s", err->message); + d(g_warning("Can't get contacts: %s", err->message)); g_clear_error(&err); continue; } @@ -1959,6 +1959,98 @@ em_utils_in_addressbook(CamelInternetAddress *iaddr) return found; } +struct _CamelMimePart * +em_utils_contact_photo (struct _CamelInternetAddress *cia, gboolean local) +{ + const char *addr; + int stop = FALSE, found = FALSE; + GSList *s, *g, *addr_sources = NULL; + GError *err = NULL; + EBookQuery *query = NULL; + ESource *source = NULL; + GList *contacts = NULL; + EContact *contact = NULL; + EContactPhoto *photo = NULL; + EBook *book = NULL; + CamelMimePart *part; + + if (cia == NULL || !camel_internet_address_get(cia, 0, NULL, &addr)){ + return NULL; + } + + if (!emu_addr_list){ + if (!e_book_get_addressbooks(&emu_addr_list, &err)){ + g_error_free(err); + return NULL; + } + } + + query = e_book_query_field_test(E_CONTACT_EMAIL, E_BOOK_QUERY_IS, addr); + for (g = e_source_list_peek_groups(emu_addr_list); g; g = g_slist_next(g)) { + if (local && strcmp (e_source_group_peek_name ((ESourceGroup *)g->data), "On This Computer")) + continue; + printf("%d %s\n", local, e_source_group_peek_name ((ESourceGroup *)g->data)); + for (s = e_source_group_peek_sources((ESourceGroup *)g->data); s; s=g_slist_next(s)) { + ESource *src = s->data; + const char *completion = e_source_get_property (src, "completion"); + + if (completion && !g_ascii_strcasecmp (completion, "true")) { + addr_sources = g_slist_prepend(addr_sources, src); + g_object_ref(src); + } + } + } + + for (s = addr_sources;!stop && !found && s;s=g_slist_next(s)) { + source = s->data; + + book = e_book_new(source, &err); + if (!e_book_open(book, TRUE, &err) + || !e_book_get_contacts(book, query, &contacts, &err)) { + stop = err->domain == E_BOOK_ERROR && err->code == E_BOOK_ERROR_CANCELLED; + g_object_unref(book); + d(g_warning("Can't get contacts: %s", err->message)); + g_clear_error(&err); + continue; + } + + if (contacts != NULL) { + found = TRUE; + + /* Doesn't matter, we consider the first contact only*/ + contact = contacts->data; + photo = e_contact_get (contact, E_CONTACT_PHOTO); + if (!photo) + photo = e_contact_get (contact, E_CONTACT_LOGO); + g_list_foreach (contacts, (GFunc)g_object_unref, NULL); + g_list_free (contacts); + } + g_object_unref (source); /* Is it? */ + g_object_unref(book); + } + + g_slist_free(addr_sources); + e_book_query_unref(query); + + if (!photo) + return NULL; + + if (photo->type != E_CONTACT_PHOTO_TYPE_INLINED) { + e_contact_photo_free (photo); + return NULL; + } + + /* Form a mime part out of the photo */ + part = camel_mime_part_new(); + camel_mime_part_set_content(part, + (const char *) photo->data.inlined.data, + photo->data.inlined.length, "image/jpeg"); + + e_contact_photo_free (photo); + + return part; +} + /** * em_utils_snoop_type: * @part: diff --git a/mail/em-utils.h b/mail/em-utils.h index 97b1aedfff..3f3da78650 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -103,6 +103,7 @@ char *em_uri_to_camel (const char *euri); /* is this address in the addressbook? caches results */ gboolean em_utils_in_addressbook(struct _CamelInternetAddress *addr); +struct _CamelMimePart *em_utils_contact_photo (struct _CamelInternetAddress *addr, gboolean local); const char *em_utils_snoop_type(struct _CamelMimePart *part); diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index 6f9f66b0c0..4bffe3cb99 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -288,6 +288,33 @@ </schema> <schema> + <key>/schemas/apps/evolution/mail/display/sender_photo</key> + <applyto>/apps/evolution/mail/display/sender_photo</applyto> + <owner>evolution-mail</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Show photo of the sender</short> + <long> + Show the photo of the sender in the message reading pane. + </long> + </locale> + </schema> + <schema> + <key>/schemas/apps/evolution/mail/display/photo_local</key> + <applyto>/apps/evolution/mail/display/photo_local</applyto> + <owner>evolution-mail</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Search for the sender photo in local addressbooks </short> + <long> + This option would help in improving the speed of fetching. + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/evolution/mail/display/mime_types</key> <applyto>/apps/evolution/mail/display/mime_types</applyto> <owner>evolution-mail</owner> diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 2d94f86894..0fe68716c8 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -6361,6 +6361,134 @@ For example: "Work" or "Personal"</property> <property name="spacing">6</property> <child> + <widget class="GtkVBox" id="vbox206"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkHBox" id="hbox238"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label587"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Sender Photograph</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox206"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="hbox239"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkCheckButton" id="photo_show"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Show the photograph of sender in the email preview</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">10</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox240"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkCheckButton" id="photo_local"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">S_earch for sender photograph only in local addressbooks</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">10</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkLabel" id="label524"> <property name="visible">True</property> <property name="label" translatable="yes"><span weight="bold">Displayed Mail _Headers</span></property> |