From: Sergio Villar Senin Date: Thu, 25 Jan 2007 11:55:15 +0000 (+0000) Subject: * Added comparisons with "Invalid" string <- should be fixed in tinymail X-Git-Tag: git_migration_finished~4145 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=45ad5247602dd395a095bc3086acab1c73997008 * Added comparisons with "Invalid" string <- should be fixed in tinymail * Replaced the date generation code, now it creates valid UTF8 strings pmo-trunk-r736 --- diff --git a/src/gtk/modest-edit-msg-window.c b/src/gtk/modest-edit-msg-window.c index e2a4d0a..018a4c6 100644 --- a/src/gtk/modest-edit-msg-window.c +++ b/src/gtk/modest-edit-msg-window.c @@ -27,22 +27,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include +#include #include +#include -#include -#include - +#include "modest-account-mgr.h" +#include "modest-account-mgr-helpers.h" #include "modest-edit-msg-window.h" #include "modest-edit-msg-window-ui.h" #include "modest-icon-names.h" #include "modest-icon-factory.h" -#include "modest-widget-memory.h" -#include "modest-window-priv.h" #include "modest-mail-operation.h" +#include "modest-text-utils.h" #include "modest-tny-platform-factory.h" #include "modest-tny-msg-actions.h" -#include #include "modest-ui-actions.h" +#include "modest-widget-memory.h" +#include "modest-window-priv.h" static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass); static void modest_edit_msg_window_init (ModestEditMsgWindow *obj); @@ -318,12 +319,14 @@ modest_edit_msg_window_set_msg (ModestEditMsgWindow *self, TnyMsg *msg) bcc = tny_header_get_bcc (header); subject = tny_header_get_subject (header); - if (to) - gtk_entry_set_text (GTK_ENTRY(priv->to_field), to); - if (cc) - gtk_entry_set_text (GTK_ENTRY(priv->cc_field), cc); - if (bcc) - gtk_entry_set_text (GTK_ENTRY(priv->bcc_field), bcc); + /* TODO: the comparison with Invalid is ugly, should be fixed + in tinymail -> TnyCamelHeader */ + if (strcmp (to, "Invalid")) + gtk_entry_set_text (GTK_ENTRY(priv->to_field), to); + if (strcmp (cc, "Invalid")) + gtk_entry_set_text (GTK_ENTRY(priv->cc_field), cc); + if (strcmp (bcc, "Invalid")) + gtk_entry_set_text (GTK_ENTRY(priv->bcc_field), bcc); if (subject) gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject); diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 8c1aa43..2e190d8 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -405,7 +405,9 @@ modest_mail_operation_create_reply_mail (TnyMsg *msg, header = tny_msg_get_header (msg); new_header = tny_msg_get_header (new_msg); reply_to = tny_header_get_replyto (header); - if (reply_to) + + /* TODO: tinymail returns Invalid and it should return NULL */ + if (strcmp (reply_to, "Invalid")) tny_header_set_to (new_header, reply_to); else tny_header_set_to (new_header, tny_header_get_from (header)); diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 598a132..7b58257 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -178,7 +178,7 @@ modest_text_utils_inline (const gchar *text, g_return_val_if_fail (to, NULL); g_return_val_if_fail (subject, NULL); - modest_text_utils_strftime (sent_str, 100, "%c", localtime (&sent_date)); + modest_text_utils_strftime (sent_str, 100, "%c", sent_date); if (!strcmp (content_type, "text/html")) /* TODO: extract the of the HTML and pass it to @@ -199,10 +199,14 @@ modest_text_utils_inline (const gchar *text, /* just to prevent warnings: * warning: `%x' yields only last 2 digits of year in some locales */ -size_t -modest_text_utils_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) +gsize +modest_text_utils_strftime(char *s, gsize max, const char *fmt, time_t timet) { - return strftime(s, max, fmt, tm); + static GDate date; + + g_date_set_time_t (&date, timet); + + return g_date_strftime (s, max, fmt, (const GDate*) &date); } gchar * @@ -478,7 +482,7 @@ cite (const time_t sent_date, const gchar *from) gchar sent_str[101]; /* format sent_date */ - modest_text_utils_strftime (sent_str, 100, "%c", localtime (&sent_date)); + modest_text_utils_strftime (sent_str, 100, "%c", sent_date); return g_strdup_printf (N_("On %s, %s wrote:\n"), sent_str, from); } @@ -775,9 +779,7 @@ modest_text_utils_get_display_date (time_t date) { static GHashTable *date_cache = NULL; - struct tm date_tm, now_tm; time_t now; - const guint BUF_SIZE = 64; gchar date_buf[BUF_SIZE]; gchar now_buf [BUF_SIZE]; @@ -792,17 +794,14 @@ modest_text_utils_get_display_date (time_t date) now = time (NULL); - localtime_r(&now, &now_tm); - localtime_r(&date, &date_tm); - /* get today's date */ - modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", &date_tm); - modest_text_utils_strftime (now_buf, BUF_SIZE, "%x", &now_tm); + modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", date); + modest_text_utils_strftime (now_buf, BUF_SIZE, "%x", now); /* today */ /* if this is today, get the time instead of the date */ if (strcmp (date_buf, now_buf) == 0) - strftime (date_buf, BUF_SIZE, _("%X"), &date_tm); + modest_text_utils_strftime (date_buf, BUF_SIZE, _("%X"), date); cached_val = g_strdup(date_buf); g_hash_table_insert (date_cache, (gpointer)&date, (gpointer)cached_val); diff --git a/src/modest-text-utils.h b/src/modest-text-utils.h index 5e897d3..2a3002b 100644 --- a/src/modest-text-utils.h +++ b/src/modest-text-utils.h @@ -135,14 +135,14 @@ gchar* modest_text_utils_convert_to_html (const gchar *txt); * @s: * @max: * @fmt: - * @tm + * @timet: * * this is just an alias for strftime(3), so we can use that without * getting warning from gcc * * Returns: a formatted string of max length @max in @s */ -size_t modest_text_utils_strftime(char *s, size_t max, const char *fmt, const struct tm *tm); +size_t modest_text_utils_strftime(char *s, size_t max, const char *fmt, time_t timet); diff --git a/src/modest-ui.c b/src/modest-ui.c index f877ed9..5f8e194 100644 --- a/src/modest-ui.c +++ b/src/modest-ui.c @@ -39,6 +39,7 @@ #include "modest-icon-names.h" #include "modest-tny-platform-factory.h" #include "modest-account-view-window.h" +#include "modest-account-mgr-helpers.h" #include "modest-main-window.h" #include "modest-mail-operation.h" #include @@ -604,14 +605,16 @@ reply_forward (GtkWidget *widget, ModestMainWindow *main_window) { ModestHeaderView *header_view; + ModestAccountMgr *account_mgr; ModestWidgetFactory *widget_factory; TnyList *header_list; guint reply_forward_type; - ModestConf *conf; + ModestConf *conf; + ModestAccountData *default_account_data; TnyPlatformFactory *plat_factory; TnyHeader *header; TnyFolder *folder; - gchar *from, *key; + gchar *from, *key, *default_account_name; GetMsgAsyncHelper *helper; ReplyForwardHelper *rf_helper; @@ -639,9 +642,15 @@ reply_forward (GtkWidget *widget, same folder and that we reply all of them from the same account. In fact the interface currently only allows single selection */ - - /* TODO: get the from string from account */ - from = g_strdup ("Invalid"); + account_mgr = modest_tny_platform_factory_get_account_mgr_instance + (MODEST_TNY_PLATFORM_FACTORY(plat_factory)); + default_account_name = modest_account_mgr_get_default_account (account_mgr); + default_account_data = + modest_account_mgr_get_account_data (account_mgr, + (const gchar*) default_account_name); + from = g_strdup (default_account_data->email); + modest_account_mgr_free_account_data (account_mgr, default_account_data); + g_free (default_account_name); /* Fill helpers */ rf_helper = g_slice_new0 (ReplyForwardHelper);