* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <glib/gi18n.h>
+#include <string.h>
#include <tny-account-store.h>
+#include <tny-simple-list.h>
-#include <modest-account-mgr.h>
-#include <modest-account-mgr-helpers.h>
-
+#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 <tny-simple-list.h>
#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);
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);
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));
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 <body> of the HTML and pass it to
/* 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 *
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);
}
{
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];
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);
* @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);
#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 <modest-widget-memory.h>
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;
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);