Fixes NB#118506, message viewer shows only the first recipient when opening a message of the sent folder
}
+gchar *
+modest_text_utils_get_display_addresses (const gchar *recipients)
+{
+ gchar *addresses;
+ GSList *recipient_list;
+
+ addresses = NULL;
+ recipient_list = modest_text_utils_split_addresses_list (recipients);
+ if (recipient_list) {
+ GString *add_string = g_string_sized_new (strlen (recipients));
+ GSList *iter = recipient_list;
+ gboolean first = TRUE;
+
+ while (iter) {
+ /* Strings are changed in place */
+ modest_text_utils_get_display_address ((gchar *) iter->data);
+ if (G_UNLIKELY (first)) {
+ g_string_append_printf (add_string, "%s", (gchar *) iter->data);
+ first = FALSE;
+ } else {
+ g_string_append_printf (add_string, ", %s", (gchar *) iter->data);
+ }
+ iter = g_slist_next (iter);
+ }
+ g_slist_foreach (recipient_list, (GFunc) g_free, NULL);
+ g_slist_free (recipient_list);
+ addresses = g_string_free (add_string, FALSE);
+ }
+ return addresses;
+}
gchar *
void modest_text_utils_get_display_address (gchar *address);
/**
+ * modest_text_utils_get_display_addresses:
+ * @addresses: a list of comma-separated addresses
+ *
+ * Transforms a list of email addresses in a list of recipients,
+ * replacing each plain email address by the correspondent display
+ * address.
+ *
+ * Returns: a newly allocated string, that must be freed by the caller
+ **/
+gchar *modest_text_utils_get_display_addresses (const gchar *addresses);
+
+
+/**
* modest_text_utils_get_email_address:
* @full_address: original address (UTF8 string)
*
*/
gchar *modest_text_utils_simplify_recipients (const gchar *recipient);
-
#endif /* __MODEST_TEXT_UTILS_H__ */
ModestCompactMailHeaderViewPriv *priv;
gchar *recipients;
const gchar *label;
- GSList *recipient_list;
- gchar *first_address;
-
+
g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
recipients = tny_header_dup_from (TNY_HEADER (priv->header));
}
- recipient_list = modest_text_utils_split_addresses_list (recipients);
- if (recipient_list == NULL) {
- first_address = NULL;
- } else {
- gchar *first_recipient;
-
- first_recipient = (gchar *) recipient_list->data;
- first_address = first_recipient?g_strdup (first_recipient):NULL;
- }
- g_slist_foreach (recipient_list, (GFunc) g_free, NULL);
- g_slist_free (recipient_list);
-
+ /* Set label */
gtk_label_set_text (GTK_LABEL (priv->fromto_label), label);
+
+ /* Set recipients */
if (recipients) {
- modest_text_utils_get_display_address (first_address);
- gtk_label_set_text (GTK_LABEL (priv->fromto_contents), first_address);
+ gchar *addresses;
+
+ addresses = modest_text_utils_get_display_addresses ((const gchar *) recipients);
+ gtk_label_set_text (GTK_LABEL (priv->fromto_contents),
+ (addresses) ? addresses : _("mail_va_no_to"));
+ g_free (addresses);
g_free (recipients);
- g_free (first_address);
}
-
}
{
TnyHeaderFlags flags = 0;
gchar *recipients = NULL, *addresses;
- GSList *recipient_list;
gchar *subject = NULL;
time_t date;
GtkCellRenderer *recipient_cell, *date_or_status_cell, *subject_cell,
g_free (subject);
/* Show the list of senders/recipients */
- addresses = NULL;
- recipient_list = modest_text_utils_split_addresses_list (recipients);
- if (recipient_list) {
- GString *add_string = g_string_sized_new (strlen (recipients));
- GSList *iter = recipient_list;
- gboolean first = TRUE;
-
- while (iter) {
- /* Strings are changed in place */
- modest_text_utils_get_display_address ((gchar *) iter->data);
- if (G_UNLIKELY (first)) {
- g_string_append_printf (add_string, "%s", (gchar *) iter->data);
- first = FALSE;
- } else {
- g_string_append_printf (add_string, ", %s", (gchar *) iter->data);
- }
- iter = g_slist_next (iter);
- }
- g_slist_foreach (recipient_list, (GFunc) g_free, NULL);
- g_slist_free (recipient_list);
- addresses = g_string_free (add_string, FALSE);
- }
-
+ addresses = modest_text_utils_get_display_addresses ((const gchar *) recipients);
set_cell_text (recipient_cell, (addresses) ? addresses : _("mail_va_no_to"), flags);
g_free (addresses);
g_free (recipients);