From: Sergio Villar Senin Date: Tue, 26 Dec 2006 10:52:06 +0000 (+0000) Subject: * Added a new account key called type for server accounts X-Git-Tag: git_migration_finished~4299 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=b09daad954384d34091b51a04eda7fd3a57a5f22 * Added a new account key called type for server accounts * Added "data_changed" signal to the store widget * Added username entry to the transport widget * Added _get_requires_auth method to the transport widget * Added support to check completeness of some pages in the account assistant * The transport account is now created with the account assistant * The account manager now stores the type configuration key for server accounts * Updated the platform factory to the new tinymail API (added 3 new methods) * Replaced camel calls by the new platform factory calls in ModestFormatter & ModestMailOperation * Added ModestProto to the Makefiles pmo-trunk-r580 --- diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 810515f..14fbb5f 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -84,6 +84,7 @@ GTKDOC_LIBS=\ ${top_builddir}/src/modest-account-mgr.o \ ${top_builddir}/src/modest-tny-platform-factory.o \ ${top_builddir}/src/modest-protocol-mgr.o \ + ${top_builddir}/src/modest-proto.o \ ${top_builddir}/src/modest-pair.o \ ${top_builddir}/src/modest-marshal.o \ ${top_builddir}/src/modest-tny-account-store.o \ diff --git a/docs/reference/tmpl/modest-account-keys.sgml b/docs/reference/tmpl/modest-account-keys.sgml index 8fc90bd..1e4a518 100644 --- a/docs/reference/tmpl/modest-account-keys.sgml +++ b/docs/reference/tmpl/modest-account-keys.sgml @@ -2,7 +2,7 @@ modest-account-keys -Some configuration keys related to account management + diff --git a/docs/reference/tmpl/modest-account-mgr.sgml b/docs/reference/tmpl/modest-account-mgr.sgml index 6fa8f2a..0c8a6a2 100644 --- a/docs/reference/tmpl/modest-account-mgr.sgml +++ b/docs/reference/tmpl/modest-account-mgr.sgml @@ -2,7 +2,7 @@ ModestAccountMgr -Manages email accounts + @@ -44,6 +44,25 @@ Manages email accounts @: @: + + + + + +@: +@: +@: +@: + + + + + + +@: +@: +@: + diff --git a/docs/reference/tmpl/modest-conf-keys.sgml b/docs/reference/tmpl/modest-conf-keys.sgml index 1913ecb..642163d 100644 --- a/docs/reference/tmpl/modest-conf-keys.sgml +++ b/docs/reference/tmpl/modest-conf-keys.sgml @@ -2,7 +2,7 @@ modest-conf-keys -Some Modest configuration keys + diff --git a/docs/reference/tmpl/modest-conf.sgml b/docs/reference/tmpl/modest-conf.sgml index 8de1cfe..c4a1dc7 100644 --- a/docs/reference/tmpl/modest-conf.sgml +++ b/docs/reference/tmpl/modest-conf.sgml @@ -2,7 +2,7 @@ ModestConf -A wrapper to the underlying configuration system (currently GConf) + @@ -52,6 +52,15 @@ A wrapper to the underlying configuration system (currently GConf) @: @: + + + + + +@: +@: +@: + diff --git a/docs/reference/tmpl/modest-main-window.sgml b/docs/reference/tmpl/modest-main-window.sgml index c7e7f59..45fea64 100644 --- a/docs/reference/tmpl/modest-main-window.sgml +++ b/docs/reference/tmpl/modest-main-window.sgml @@ -2,7 +2,7 @@ ModestMainWindow -A widget that shows the Modest main window + diff --git a/docs/reference/tmpl/modest-proto.sgml b/docs/reference/tmpl/modest-proto.sgml index 807c492..6c2544d 100644 --- a/docs/reference/tmpl/modest-proto.sgml +++ b/docs/reference/tmpl/modest-proto.sgml @@ -2,7 +2,7 @@ modest-proto -An object that provides lists with the supported email protocols + diff --git a/docs/reference/tmpl/modest-tny-account-store.sgml b/docs/reference/tmpl/modest-tny-account-store.sgml index d6b5749..7472858 100644 --- a/docs/reference/tmpl/modest-tny-account-store.sgml +++ b/docs/reference/tmpl/modest-tny-account-store.sgml @@ -2,7 +2,7 @@ ModestTnyAccountStore -An implementation of #TnyAccountStore + @@ -50,6 +50,25 @@ An implementation of #TnyAccountStore @: @Param5: + + + + + +@: +@: + + + + + + +@: +@: +@: +@: +@Param5: + diff --git a/docs/reference/tmpl/modest-ui.sgml b/docs/reference/tmpl/modest-ui.sgml index 2e265dc..9d0df49 100644 --- a/docs/reference/tmpl/modest-ui.sgml +++ b/docs/reference/tmpl/modest-ui.sgml @@ -2,7 +2,7 @@ ModestUI -An object that creates the main window + diff --git a/docs/reference/tmpl/modest-unused.sgml b/docs/reference/tmpl/modest-unused.sgml index 5f36a11..22a3922 100644 --- a/docs/reference/tmpl/modest-unused.sgml +++ b/docs/reference/tmpl/modest-unused.sgml @@ -83,7 +83,7 @@ ModestTnyHeaderTreeView - +A widget that displays the body of a message diff --git a/src/Makefile.am b/src/Makefile.am index 4e58386..766f8b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,8 @@ modest_SOURCES=\ modest-presets.h\ modest-protocol-mgr.h\ modest-protocol-mgr.c\ + modest-proto.h\ + modest-proto.c\ modest-ui.h\ modest-text-utils.h\ modest-text-utils.c\ diff --git a/src/gtk/modest-account-assistant.c b/src/gtk/modest-account-assistant.c index 3ea6a80..cc4265a 100644 --- a/src/gtk/modest-account-assistant.c +++ b/src/gtk/modest-account-assistant.c @@ -31,6 +31,7 @@ #include "modest-account-assistant.h" #include "modest-store-widget.h" #include "modest-transport-widget.h" +#include "modest-proto.h" #include @@ -228,6 +229,29 @@ add_identity_page (ModestAccountAssistant *self) static void +receiving_page_update_completeness (GtkEditable *editable, + ModestAccountAssistant *self) +{ + ModestAccountAssistantPrivate *priv; + const gchar *txt; + + priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(self); + + txt = modest_store_widget_get_username (priv->store_widget); + if (!txt || strlen(txt) == 0) { + set_current_page_complete (self, FALSE); + return; + } + + txt = modest_store_widget_get_servername (priv->store_widget); + if (!txt || strlen(txt) == 0) { + set_current_page_complete (self, FALSE); + return; + } + set_current_page_complete (self, TRUE); +} + +static void on_receiving_combo_box_changed (GtkComboBox *combo, ModestAccountAssistant *self) { ModestAccountAssistantPrivate *priv; @@ -240,7 +264,17 @@ on_receiving_combo_box_changed (GtkComboBox *combo, ModestAccountAssistant *self gtk_container_remove (GTK_CONTAINER(priv->store_holder), priv->store_widget); + /* FIXME: we could have these widgets cached instead of + creating them every time */ priv->store_widget = modest_store_widget_new (priv->factory, chosen); + if (!strcmp (chosen, MODEST_PROTO_POP) || !strcmp (chosen, MODEST_PROTO_IMAP)) { + g_signal_connect (priv->store_widget, + "data_changed", + receiving_page_update_completeness, + self); + set_current_page_complete (self, FALSE); + } else + set_current_page_complete (self, TRUE); gtk_container_add (GTK_CONTAINER(priv->store_holder), priv->store_widget); @@ -275,12 +309,15 @@ add_receiving_page (ModestAccountAssistant *self) gtk_box_pack_start (GTK_BOX(box), combo, FALSE,FALSE,6); gtk_box_pack_start (GTK_BOX(page), box, FALSE,FALSE, 6); - + gtk_box_pack_start (GTK_BOX(page), gtk_hseparator_new(), FALSE, FALSE, 0); priv->store_holder = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX(page), priv->store_holder, TRUE, TRUE, 0); + + /* Force the selection */ + on_receiving_combo_box_changed (combo, self); gtk_assistant_append_page (GTK_ASSISTANT(self), page); @@ -289,7 +326,7 @@ add_receiving_page (ModestAccountAssistant *self) gtk_assistant_set_page_type (GTK_ASSISTANT(self), page, GTK_ASSISTANT_PAGE_INTRO); gtk_assistant_set_page_complete (GTK_ASSISTANT(self), - page, TRUE); + page, FALSE); gtk_widget_show_all (page); } @@ -347,13 +384,16 @@ add_sending_page (ModestAccountAssistant *self) gtk_box_pack_start (GTK_BOX(box), combo, FALSE,FALSE,0); gtk_box_pack_start (GTK_BOX(page), box, FALSE,FALSE, 0); - + gtk_box_pack_start (GTK_BOX(page), gtk_hseparator_new(), FALSE, FALSE, 0); priv->transport_holder = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX(page), priv->transport_holder, FALSE, FALSE, 0); - + + /* Force the selection */ + on_sending_combo_box_changed (combo, self); + gtk_assistant_append_page (GTK_ASSISTANT(self), page); gtk_assistant_set_page_title (GTK_ASSISTANT(self), page, @@ -519,29 +559,48 @@ static void on_apply (ModestAccountAssistant *self, gpointer user_data) { ModestAccountAssistantPrivate *priv; - gchar *store_name; - const gchar *account_name; + gchar *store_name, *transport_name; + const gchar *account_name, *username, *servername, *proto; ModestStoreWidget *store; + ModestTransportWidget *transport; priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(self); - /* create account */ - /* create server account -> store */ store = MODEST_STORE_WIDGET(priv->store_widget); - store_name = g_strdup_printf ("%s:%s@%s", - modest_store_widget_get_proto (store), - modest_store_widget_get_username (store), - modest_store_widget_get_servername (store)); + proto = modest_store_widget_get_proto (store); + username = modest_store_widget_get_username (store); + servername = modest_store_widget_get_servername (store); + store_name = g_strdup_printf ("%s:%s@%s", proto, username, servername); + + modest_account_mgr_add_server_account (priv->account_mgr, store_name, servername, + username, NULL, proto); + + /* create server account -> transport */ + transport = MODEST_TRANSPORT_WIDGET(priv->transport_widget); + proto = modest_transport_widget_get_proto (transport); + + if (!strcmp (proto, MODEST_PROTO_SMTP)) { + servername = modest_transport_widget_get_servername (transport); + if (modest_transport_widget_get_requires_auth (transport)) + username = modest_transport_widget_get_username (transport); + else + username = g_get_user_name (); + } else { + username = g_get_user_name (); + servername = "localhost"; + + } + transport_name = g_strdup_printf ("%s:%s@%s", proto, username, servername); modest_account_mgr_add_server_account (priv->account_mgr, - store_name, - modest_store_widget_get_servername (store), - modest_store_widget_get_username (store), + transport_name, + servername, + username, NULL, - modest_store_widget_get_proto (store)); + proto); - /* create server account -> transport */ + /* create account */ account_name = get_account_name (self); modest_account_mgr_add_account (priv->account_mgr, account_name, @@ -555,8 +614,10 @@ on_apply (ModestAccountAssistant *self, gpointer user_data) account_name, MODEST_ACCOUNT_EMAIL, get_email(self), FALSE, NULL); - + + /* Frees */ g_free (store_name); + g_free (transport_name); } diff --git a/src/gtk/modest-store-widget.c b/src/gtk/modest-store-widget.c index 9054bf9..c10216e 100644 --- a/src/gtk/modest-store-widget.c +++ b/src/gtk/modest-store-widget.c @@ -37,8 +37,7 @@ static void modest_store_widget_init (ModestStoreWidget *obj); static void modest_store_widget_finalize (GObject *obj); /* list my signals */ enum { - /* MY_SIGNAL_1, */ - /* MY_SIGNAL_2, */ + DATA_CHANGED_SIGNAL, LAST_SIGNAL }; @@ -63,7 +62,7 @@ struct _ModestStoreWidgetPrivate { static GtkContainerClass *parent_class = NULL; /* uncomment the following if you have defined any signals */ -/* static guint signals[LAST_SIGNAL] = {0}; */ +static guint signals[LAST_SIGNAL] = {0}; GType modest_store_widget_get_type (void) @@ -101,11 +100,14 @@ modest_store_widget_class_init (ModestStoreWidgetClass *klass) g_type_class_add_private (gobject_class, sizeof(ModestStoreWidgetPrivate)); /* signal definitions go here, e.g.: */ -/* signals[MY_SIGNAL_1] = */ -/* g_signal_new ("my_signal_1",....); */ -/* signals[MY_SIGNAL_2] = */ -/* g_signal_new ("my_signal_2",....); */ -/* etc. */ + signals[DATA_CHANGED_SIGNAL] = + g_signal_new ("data_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(ModestStoreWidgetClass, data_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -186,6 +188,11 @@ mbox_configuration (ModestStoreWidget *self) return box; } +static void +on_entry_changed (GtkEntry *entry, gpointer user_data) +{ + g_signal_emit (MODEST_STORE_WIDGET (user_data), signals[DATA_CHANGED_SIGNAL], 0); +} static GtkWidget* imap_pop_configuration (ModestStoreWidget *self) @@ -245,6 +252,10 @@ imap_pop_configuration (ModestStoreWidget *self) gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0); + /* Handle entry modifications */ + g_signal_connect (priv->username, "changed", on_entry_changed, self); + g_signal_connect (priv->servername, "changed", on_entry_changed, self); + return box; } @@ -306,7 +317,6 @@ modest_store_widget_new (ModestWidgetFactory *factory, const gchar *proto) return GTK_WIDGET(self); } - gboolean modest_store_widget_get_remember_password (ModestStoreWidget *self) { diff --git a/src/gtk/modest-store-widget.h b/src/gtk/modest-store-widget.h index b6e3f96..f82c7cd 100644 --- a/src/gtk/modest-store-widget.h +++ b/src/gtk/modest-store-widget.h @@ -27,8 +27,8 @@ struct _ModestStoreWidget { struct _ModestStoreWidgetClass { GtkVBoxClass parent_class; - /* insert signal callback declarations, eg. */ - /* void (* my_event) (ModestStoreWidget* obj); */ + + void (* data_changed) (ModestStoreWidget* obj); }; /* member functions */ diff --git a/src/gtk/modest-transport-widget.c b/src/gtk/modest-transport-widget.c index 20a6681..362e557 100644 --- a/src/gtk/modest-transport-widget.c +++ b/src/gtk/modest-transport-widget.c @@ -109,6 +109,19 @@ modest_transport_widget_finalize (GObject *obj) G_OBJECT_CLASS(parent_class)->finalize (obj); } +static void +on_button_toggled (GtkToggleButton *button, gpointer user_data) +{ + ModestTransportWidgetPrivate *priv; + + priv = (ModestTransportWidgetPrivate *) user_data; + + if (gtk_toggle_button_get_active (button)) + gtk_widget_set_sensitive (gtk_widget_get_parent (priv->username), TRUE); + else + gtk_widget_set_sensitive (gtk_widget_get_parent (priv->username), FALSE); +} + static GtkWidget* smtp_configuration (ModestTransportWidget *self) @@ -125,17 +138,30 @@ smtp_configuration (ModestTransportWidget *self) gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 6); priv->servername = gtk_entry_new_with_max_length (40); - + priv->username = gtk_entry_new_with_max_length (40); + + /* Servername */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new (_("Servername: ")), FALSE, FALSE, 6); - gtk_box_pack_start (GTK_BOX(hbox), priv->servername, - TRUE, TRUE, 6); + gtk_box_pack_start (GTK_BOX(hbox), priv->servername, TRUE, TRUE, 6); gtk_box_pack_start (GTK_BOX(box), hbox, TRUE, TRUE, 6); + /* Auth */ priv->auth = gtk_check_button_new_with_label (_("Requires authentication")); gtk_box_pack_start (GTK_BOX(box), priv->auth, TRUE, FALSE, 6); + + g_signal_connect (priv->auth, "toggled", G_CALLBACK (on_button_toggled), priv); + /* Username */ + hbox = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new (_("Username: ")), + FALSE, FALSE, 6); + gtk_box_pack_start (GTK_BOX(hbox), priv->username, TRUE, TRUE, 6); + gtk_widget_set_sensitive (hbox, FALSE); + gtk_box_pack_start (GTK_BOX(box), hbox, TRUE, TRUE, 6); + + /* Security */ label = gtk_label_new(NULL); gtk_label_set_markup (GTK_LABEL(label),_("Security")); gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0); @@ -148,6 +174,7 @@ smtp_configuration (ModestTransportWidget *self) (priv->factory, MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS), FALSE, FALSE,0); gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0); + hbox = gtk_hbox_new (FALSE, 6); label = gtk_label_new(NULL); @@ -209,6 +236,16 @@ modest_transport_widget_get_remember_password (ModestTransportWidget *self) return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(priv->remember_pwd)); } +gboolean +modest_transport_widget_get_requires_auth (ModestTransportWidget *self) +{ + ModestTransportWidgetPrivate *priv; + + g_return_val_if_fail (self, FALSE); + priv = MODEST_TRANSPORT_WIDGET_GET_PRIVATE(self); + + return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(priv->auth)); +} const gchar* modest_transport_widget_get_username (ModestTransportWidget *self) diff --git a/src/gtk/modest-transport-widget.h b/src/gtk/modest-transport-widget.h index f72e971..b7e5c41 100644 --- a/src/gtk/modest-transport-widget.h +++ b/src/gtk/modest-transport-widget.h @@ -37,6 +37,7 @@ GType modest_transport_widget_get_type (void) G_GNUC_CONST; GtkWidget* modest_transport_widget_new (ModestWidgetFactory *factory, const gchar *proto); gboolean modest_transport_widget_get_remember_password (ModestTransportWidget *self); +gboolean modest_transport_widget_get_requires_auth (ModestTransportWidget *self); const gchar* modest_transport_widget_get_username (ModestTransportWidget *self); const gchar* modest_transport_widget_get_servername (ModestTransportWidget *self); const gchar* modest_transport_widget_get_proto (ModestTransportWidget *self); diff --git a/src/modest-account-keys.h b/src/modest-account-keys.h index ab3c8ce..ed9d301 100644 --- a/src/modest-account-keys.h +++ b/src/modest-account-keys.h @@ -56,6 +56,7 @@ #define MODEST_ACCOUNT_USERNAME "username" /* string */ #define MODEST_ACCOUNT_PROTO "proto" /* string */ #define MODEST_ACCOUNT_ENABLED "enabled" /* boolean */ +#define MODEST_ACCOUNT_TYPE "type" /* string */ #define MODEST_ACCOUNT_LEAVE_ON_SERVER "leave_on_server" /* boolean */ #define MODEST_ACCOUNT_PREFERRED_CNX "preferred_cnx" /* string */ diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index 7a18d51..1338304 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -28,9 +28,10 @@ */ #include -#include -#include -#include +#include "modest-proto.h" +#include "modest-marshal.h" +#include "modest-account-keys.h" +#include "modest-account-mgr.h" /* 'private'/'protected' functions */ static void modest_account_mgr_class_init (ModestAccountMgrClass * klass); @@ -357,6 +358,7 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, { ModestAccountMgrPrivate *priv; gchar *key; + ModestProtoType proto_type = MODEST_PROTO_TYPE_ANY; g_return_val_if_fail (self, FALSE); g_return_val_if_fail (name, FALSE); @@ -390,6 +392,14 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, modest_conf_set_string (priv->modest_conf, key, null_means_empty (proto), NULL); g_free (key); + /* type */ + key = get_account_keyname (name, MODEST_ACCOUNT_TYPE, TRUE); + proto_type = modest_proto_type (proto); + modest_conf_set_string (priv->modest_conf, key, + (proto_type == MODEST_PROTO_TYPE_TRANSPORT) ? "transport" : "store", + NULL); + g_free (key); + return TRUE; } diff --git a/src/modest-formatter.c b/src/modest-formatter.c index 0375b18..7a23329 100644 --- a/src/modest-formatter.c +++ b/src/modest-formatter.c @@ -33,10 +33,10 @@ #include #include #include -#include #include #include "modest-formatter.h" #include "modest-text-utils.h" +#include "modest-tny-platform-factory.h" typedef struct _ModestFormatterPrivate ModestFormatterPrivate; struct _ModestFormatterPrivate { @@ -128,6 +128,7 @@ modest_formatter_do (ModestFormatter *self, TnyMsg *new_msg; gchar *body_text = NULL, *txt = NULL; ModestFormatterPrivate *priv; + TnyPlatformFactory *fact; g_return_val_if_fail (self, NULL); g_return_val_if_fail (body, NULL); @@ -135,7 +136,8 @@ modest_formatter_do (ModestFormatter *self, g_return_val_if_fail (func, NULL); /* Build new part */ - new_msg = TNY_MSG (tny_camel_msg_new ()); + fact = modest_tny_platform_factory_get_instance (); + new_msg = tny_platform_factory_new_msg (fact); body_text = extract_text (self, body); txt = (gchar *) func (self, (const gchar*) body_text, header); priv = MODEST_FORMATTER_GET_PRIVATE (self); @@ -173,11 +175,13 @@ modest_formatter_attach (ModestFormatter *self, TnyMimePart *body, TnyHeader *he gchar *attach_text = NULL; TnyMimePart *body_part = NULL, *attach_part = NULL; ModestFormatterPrivate *priv; + TnyPlatformFactory *fact; + fact = modest_tny_platform_factory_get_instance (); /* Build new part */ - new_msg = TNY_MSG (tny_camel_msg_new ()); - body_part = TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new())); - attach_part = TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new())); + new_msg = tny_platform_factory_new_msg (fact); + body_part = tny_platform_factory_new_mime_part (fact); + attach_part = tny_platform_factory_new_mime_part (fact); /* Create the two parts */ priv = MODEST_FORMATTER_GET_PRIVATE (self); diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 705cb9a..e0068b3 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -35,10 +35,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -237,6 +234,7 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self, const gchar *body, const GList *attachments_list) { + TnyPlatformFactory *fact; TnyMsg *new_msg; TnyHeader *header; gchar *content_type; @@ -256,8 +254,9 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self, } /* Create new msg */ - new_msg = TNY_MSG (tny_camel_msg_new ()); - header = TNY_HEADER (tny_camel_header_new ()); + fact = modest_tny_platform_factory_get_instance (); + new_msg = tny_platform_factory_new_msg (fact); + header = tny_platform_factory_new_header (fact); /* WARNING: set the header before assign values to it */ tny_msg_set_header (new_msg, header); @@ -303,6 +302,7 @@ add_if_attachment (gpointer data, gpointer user_data) static TnyMsg * create_reply_forward_mail (TnyMsg *msg, const gchar *from, gboolean is_reply, guint type) { + TnyPlatformFactory *fact; TnyMsg *new_msg; TnyHeader *new_header, *header; gchar *new_subject; @@ -341,14 +341,16 @@ create_reply_forward_mail (TnyMsg *msg, const gchar *from, gboolean is_reply, gu g_object_unref (G_OBJECT (formatter)); /* Fill the header */ - new_header = TNY_HEADER (tny_camel_header_new ()); - tny_msg_set_header (new_msg, new_header); + fact = modest_tny_platform_factory_get_instance (); + new_header = TNY_HEADER (tny_platform_factory_new_header (fact)); + tny_msg_set_header (new_msg, new_header); tny_header_set_from (new_header, from); tny_header_set_replyto (new_header, from); /* Change the subject */ - new_subject = (gchar *) modest_text_utils_derived_subject (tny_header_get_subject(header), - (is_reply) ? _("Re:") : _("Fwd:")); + new_subject = + (gchar *) modest_text_utils_derived_subject (tny_header_get_subject(header), + (is_reply) ? _("Re:") : _("Fwd:")); tny_header_set_subject (new_header, (const gchar *) new_subject); g_free (new_subject); @@ -963,13 +965,15 @@ add_attachments (TnyMsg *msg, GList *attachments_list) const gchar *attachment_content_type; const gchar *attachment_filename; TnyStream *attachment_stream; + TnyPlatformFactory *fact; + fact = modest_tny_platform_factory_get_instance (); for (pos = (GList *)attachments_list; pos; pos = pos->next) { old_attachment = pos->data; attachment_filename = tny_mime_part_get_filename (old_attachment); attachment_stream = tny_mime_part_get_stream (old_attachment); - attachment_part = TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new())); + attachment_part = tny_platform_factory_new_mime_part (fact); attachment_content_type = tny_mime_part_get_content_type (old_attachment); @@ -994,6 +998,9 @@ add_body_part (TnyMsg *msg, { TnyMimePart *text_body_part = NULL; TnyStream *text_body_stream; + TnyPlatformFactory *fact; + + fact = modest_tny_platform_factory_get_instance (); /* Create the stream */ text_body_stream = TNY_STREAM (tny_camel_stream_new @@ -1002,8 +1009,7 @@ add_body_part (TnyMsg *msg, /* Create body part if needed */ if (has_attachments) - text_body_part = - TNY_MIME_PART (tny_camel_mime_part_new (camel_mime_part_new())); + text_body_part = tny_platform_factory_new_mime_part (fact); else text_body_part = TNY_MIME_PART(msg); diff --git a/src/modest-proto.h b/src/modest-proto.h index 8b3d91c..63bcddc 100644 --- a/src/modest-proto.h +++ b/src/modest-proto.h @@ -122,8 +122,5 @@ const gchar** modest_proto_security_protos (void); */ const gchar** modest_proto_auth_protos (void); - - - #endif /*__MODEST_SERVER_PROTO_H__*/ diff --git a/src/modest-tny-platform-factory.c b/src/modest-tny-platform-factory.c index 0f664c6..3512312 100644 --- a/src/modest-tny-platform-factory.c +++ b/src/modest-tny-platform-factory.c @@ -47,9 +47,14 @@ static void modest_tny_platform_factory_finalize (GObject *obj); static GObject *modest_tny_platform_factory_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params); static void tny_platform_factory_init (gpointer g, gpointer iface_data); -static TnyAccountStore *modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self); -static TnyDevice *modest_tny_platform_factory_new_device (TnyPlatformFactory *self); -static TnyMsgView *modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self); + +static TnyAccountStore* modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self); +static TnyDevice* modest_tny_platform_factory_new_device (TnyPlatformFactory *self); +static TnyMsgView* modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self); +static TnyMsg* modest_tny_platform_factory_new_msg (TnyPlatformFactory *self); +static TnyMimePart* modest_tny_platform_factory_new_mime_part (TnyPlatformFactory *self); +static TnyHeader* modest_tny_platform_factory_new_header (TnyPlatformFactory *self); + /* list my signals */ enum { @@ -185,6 +190,9 @@ tny_platform_factory_init (gpointer g, gpointer iface_data) klass->new_account_store_func = modest_tny_platform_factory_new_account_store; klass->new_device_func = modest_tny_platform_factory_new_device; klass->new_msg_view_func = modest_tny_platform_factory_new_msg_view; + klass->new_msg_func = modest_tny_platform_factory_new_msg; + klass->new_mime_part_func = modest_tny_platform_factory_new_mime_part; + klass->new_header_func = modest_tny_platform_factory_new_header; return; } @@ -234,6 +242,27 @@ modest_tny_platform_factory_new_msg_view (TnyPlatformFactory *self) return NULL; } +static TnyMsg* +modest_tny_platform_factory_new_msg (TnyPlatformFactory *self) +{ + return tny_camel_msg_new (); +} + + +static TnyMimePart* +modest_tny_platform_factory_new_mime_part (TnyPlatformFactory *self) +{ + return tny_camel_mime_part_new (); +} + + +static TnyHeader* +modest_tny_platform_factory_new_header (TnyPlatformFactory *self) +{ + return tny_camel_header_new (); +} + + ModestAccountMgr * modest_tny_platform_factory_get_modest_account_mgr_instance (TnyPlatformFactory *fact) { diff --git a/tests/Makefile.am b/tests/Makefile.am index dada03e..2c54691 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,6 +44,7 @@ objects=\ ${top_srcdir}/src/modest-tny-platform-factory.o \ ${top_srcdir}/src/modest-conf.o \ ${top_srcdir}/src/modest-protocol-mgr.o \ + ${top_srcdir}/src/modest-proto.o \ ${top_srcdir}/src/modest-formatter.o \ ${top_srcdir}/src/modest-presets.o \ ${top_srcdir}/src/modest-pair.o \