From 31278199dde47352127b52b44e0d879fb66ba06c Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Tue, 4 Nov 2014 10:59:26 +0100 Subject: [PATCH] SolipaMailUI: modifiche per autenticazione. --- data/libsolipa/gui/libsolipa.ui | 623 +++++++++++++++++++++----------- src/mailui.c | 229 ++++++++++-- tests/mail.c | 6 +- tests/mailui.c | 175 +++++++-- tests/tests.ui | 304 ++++++++++++++-- 5 files changed, 1033 insertions(+), 304 deletions(-) diff --git a/data/libsolipa/gui/libsolipa.ui b/data/libsolipa/gui/libsolipa.ui index 17d95b7..acfbd00 100644 --- a/data/libsolipa/gui/libsolipa.ui +++ b/data/libsolipa/gui/libsolipa.ui @@ -12,6 +12,28 @@ + + + + + + + + + + 0 + Nessuno + + + 1 + SSL/TLS + + + 2 + STARTTLS + + + False 5 @@ -68,311 +90,470 @@ - + True - False - 5 - 5 - - - True - False - 0 - Da: - - - 0 - 0 - - - - - True - False - 0 - A: - - - 0 - 1 - - - - - True - True - ● - False - False - - - 1 - 0 - - - - - True - True - ● - False - False - - - 1 - 1 - - - - - True - False - 0 - Oggetto: - - - 0 - 4 - - - - - True - True - ● - False - False - - - 1 - 4 - - - - - True - False - 0 - Cc: - - - 0 - 2 - - + True + True + True - + True False - 0 - Ccn: - - - 0 - 3 - - - - - True - True - ● - False - False - - - 1 - 2 - - - - - True - True - ● - False - False - - - 1 - 3 - - - - - True - True - etched-in + True + True + 5 + 5 + 5 - + + True + False + 0 + Da: + + + 0 + 0 + + + + + True + False + 0 + A: + + + 0 + 1 + + + + True True - word + True + ● + False + False + + 1 + 0 + + + + + True + True + True + ● + False + False + + + 1 + 1 + - - - 0 - 8 - 2 - - - - - True - True - + True False - 5 + 0 + Oggetto: + + + 0 + 4 + + + + + True + True + True + ● + False + False + + + 1 + 4 + + + + + True + False + 0 + Cc: + + + 0 + 2 + + + + + True + False + 0 + Ccn: + + + 0 + 3 + + + + + True + True + True + ● + False + False + + + 1 + 2 + + + + + True + True + True + ● + False + False + + + 1 + 3 + + + + + True + True + True + True + etched-in - + True True - etched-in - - - True - True - 5 - multiple - lstore_mail_attachments - 5 - 5 - True - - + word - - True - True - 0 - + + + 0 + 8 + 2 + + + + + True + True + True + True - + True False - vertical + True + True 5 - start - - gtk-add + True True - True - True + etched-in + + + True + True + 5 + multiple + lstore_mail_attachments + 5 + 5 + True + + - False - False + True + True 0 - - gtk-remove + True - False - True - True - True + False + vertical + 5 + start + + + gtk-add + True + True + True + True + + + False + False + 0 + + + + + gtk-remove + True + False + True + True + True + + + False + False + 1 + + False - False + True 1 + + + + True + False + Allegati + + + + + 0 + 9 + 2 + + + + + True + False + True + 5 + + + True + False + 0 + Richiedere ricevuta di ritorno + False True + 0 + + + + + True + True + False + 0 + True + + + True + True 1 + + 0 + 6 + 2 + - - + + True False - Allegati + + 0 + 5 + 2 + + + + + True + False + + + 0 + 7 + 2 + + + + + True + False + Mail + - 0 - 9 - 2 + False - + True False - 5 + 5 + 5 + 5 - + True False 0 - Richiedere ricevuta di ritorno + Server - False - True - 0 + 0 + 0 - + True True - False - 0.5 - True + True - True - True - 1 + 1 + 0 + + + + + True + False + 0 + Metodo di sicurezza + + + 0 + 1 + + + + + True + False + True + lstore_metodo_sicurezza + 0 + 0 + + + + 1 + + + + + 1 + 1 + + + + + True + False + 0 + Utente + + + 0 + 2 + + + + + True + True + True + + + 1 + 2 + + + + + True + False + 0 + Password + + + 0 + 3 + + + + + True + True + True + False + ● + + + 1 + 3 - 0 - 6 - 2 - - - - - True - False - - - 0 - 5 - 2 + 1 - - + + True False + Server - 0 - 7 - 2 + 1 + False - True + False True 1 diff --git a/src/mailui.c b/src/mailui.c index 77d9dc7..9e94028 100644 --- a/src/mailui.c +++ b/src/mailui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2013 Andrea Zagli + * Copyright (C) 2011-2014 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,9 @@ enum { PROP_0, + PROP_SHOW_SERVER_OPTIONS, PROP_SMTP_URI, + PROP_SMTP_URI_EDITABLE, PROP_FROM, PROP_FROM_EDITABLE, PROP_TO, @@ -44,7 +46,13 @@ enum PROP_WITH_NOTIFICATION_VISIBLE, PROP_BODY, PROP_BODY_EDITABLE, - PROP_WITH_ATTACHMENTS + PROP_WITH_ATTACHMENTS, + PROP_SECURITY_METHOD, + PROP_SECURITY_METHOD_EDITABLE, + PROP_USERNAME, + PROP_USERNAME_EDITABLE, + PROP_PASSWORD, + PROP_PASSWORD_EDITABLE }; enum @@ -90,12 +98,12 @@ struct _SolipaMailUIPrivate { Solipa *solipa; - gchar *smtp_uri; - GtkWidget *dialog; GtkWidget *vbox; GtkWidget *widget; + GtkWidget *notebook; + GtkWidget *from; GtkWidget *to; GtkWidget *cc; @@ -107,10 +115,16 @@ struct _SolipaMailUIPrivate GtkWidget *with_notification_lbl; GtkWidget *hseparator2; GtkWidget *body; + GtkWidget *expander_attachments; GtkWidget *iv_attachments; GtkWidget *btn_attachment_remove; GtkListStore *lstore_attachments; + + GtkWidget *server; + GtkWidget *security_method; + GtkWidget *username; + GtkWidget *password; }; G_DEFINE_TYPE (SolipaMailUI, solipa_mail_ui, G_TYPE_OBJECT) @@ -123,6 +137,13 @@ solipa_mail_ui_class_init (SolipaMailUIClass *klass) object_class->set_property = solipa_mail_ui_set_property; object_class->get_property = solipa_mail_ui_get_property; + g_object_class_install_property (object_class, PROP_SHOW_SERVER_OPTIONS, + g_param_spec_boolean ("show-server-options", + "Show server options", + "Show server options", + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_SMTP_URI, g_param_spec_string ("smtp-uri", "Smtp URI", @@ -130,6 +151,13 @@ solipa_mail_ui_class_init (SolipaMailUIClass *klass) "", G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_SMTP_URI_EDITABLE, + g_param_spec_boolean ("smtp-uri-editable", + "Server field editable", + "Server field editable", + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_FROM, g_param_spec_string ("from", "From", @@ -249,6 +277,50 @@ solipa_mail_ui_class_init (SolipaMailUIClass *klass) TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_SECURITY_METHOD, + g_param_spec_uint ("security-method", + "Security method", + "Security method", + CAMEL_NETWORK_SECURITY_METHOD_NONE, + CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT, + CAMEL_NETWORK_SECURITY_METHOD_NONE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_SECURITY_METHOD_EDITABLE, + g_param_spec_boolean ("security-method-editable", + "Security method field editable", + "Security method field editable", + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_USERNAME, + g_param_spec_string ("username", + "Username", + "Username", + "", + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_USERNAME_EDITABLE, + g_param_spec_boolean ("username-editable", + "Username field editable", + "Username field editable", + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_PASSWORD, + g_param_spec_string ("password", + "Password", + "Password", + "", + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_PASSWORD_EDITABLE, + g_param_spec_boolean ("password-editable", + "Password field editable", + "Password field editable", + TRUE, + G_PARAM_READWRITE)); + /** * SolipaMailUI::btn_cancel_clicked: * @solipa_mail_ui: @@ -323,6 +395,7 @@ SolipaMailUI gtk_builder_add_objects_from_file (builder, solipa_get_guifile (solipa), g_strsplit ("lstore_mail_attachments" + "|lstore_metodo_sicurezza" "|diag_mail", "|", -1), &error); @@ -335,24 +408,32 @@ SolipaMailUI priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "diag_mail")); priv->vbox = GTK_WIDGET (gtk_builder_get_object (builder, "dialog-vbox2")); - priv->widget = GTK_WIDGET (gtk_builder_get_object (builder, "table2")); + priv->widget = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1")); + + priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1")); priv->from = GTK_WIDGET (gtk_builder_get_object (builder, "entry3")); priv->to = GTK_WIDGET (gtk_builder_get_object (builder, "entry4")); priv->cc = GTK_WIDGET (gtk_builder_get_object (builder, "entry6")); - priv->cc_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label11")); + priv->cc_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label15")); priv->bcc = GTK_WIDGET (gtk_builder_get_object (builder, "entry7")); - priv->bcc_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label12")); + priv->bcc_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label16")); priv->subject = GTK_WIDGET (gtk_builder_get_object (builder, "entry5")); priv->with_notification = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton4")); - priv->with_notification_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label15")); - priv->hseparator2 = GTK_WIDGET (gtk_builder_get_object (builder, "hseparator2")); + priv->with_notification_lbl = GTK_WIDGET (gtk_builder_get_object (builder, "label18")); + priv->hseparator2 = GTK_WIDGET (gtk_builder_get_object (builder, "separator2")); priv->body = GTK_WIDGET (gtk_builder_get_object (builder, "textview1")); priv->lstore_attachments = GTK_LIST_STORE (gtk_builder_get_object (builder, "lstore_mail_attachments")); + priv->expander_attachments = GTK_WIDGET (gtk_builder_get_object (builder, "expander1")); priv->iv_attachments = GTK_WIDGET (gtk_builder_get_object (builder, "iconview1")); priv->btn_attachment_remove = GTK_WIDGET (gtk_builder_get_object (builder, "button10")); + priv->server = GTK_WIDGET (gtk_builder_get_object (builder, "entry9")); + priv->security_method = GTK_WIDGET (gtk_builder_get_object (builder, "combobox1")); + priv->username = GTK_WIDGET (gtk_builder_get_object (builder, "entry10")); + priv->password = GTK_WIDGET (gtk_builder_get_object (builder, "entry11")); + g_signal_connect (gtk_builder_get_object (builder, "expander1"), "notify::expanded", G_CALLBACK (solipa_mail_ui_on_exp_attachments_expanded), (gpointer)solipa_mail_ui); @@ -417,6 +498,15 @@ GtkWidget return priv->widget; } +void +solipa_mail_ui_show_server_options (SolipaMailUI *mailui, gboolean show) +{ + g_return_val_if_fail (IS_SOLIPA_MAIL_UI (mailui), NULL); + + SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (mailui); + +} + gboolean solipa_mail_ui_send (SolipaMailUI *mailui) { @@ -430,6 +520,9 @@ solipa_mail_ui_send (SolipaMailUI *mailui) gchar *subject; gboolean with_notification; gchar *body; + CamelNetworkSecurityMethod security_method; + gchar *username; + gchar *password; gchar *email; @@ -474,6 +567,9 @@ solipa_mail_ui_send (SolipaMailUI *mailui) "subject", &subject, "with-notification", &with_notification, "body", &body, + "security-method", &security_method, + "username", &username, + "password", &password, NULL); solipa_mail_set_subject (smail, subject); @@ -665,6 +761,17 @@ solipa_mail_ui_send (SolipaMailUI *mailui) } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_attachments), &iter)); } + solipa_mail_set_security_method (smail, security_method); + + if (username != NULL) + { + if (password == NULL) + { + password = g_strdup (""); + } + solipa_mail_set_username_password (smail, username, password); + } + if (g_strcmp0 (g_strstrip (smtpuri), "") != 0) { solipa_mail_send (smail, smtpuri); @@ -696,8 +803,17 @@ solipa_mail_ui_set_property (GObject *object, switch (property_id) { + case PROP_SHOW_SERVER_OPTIONS: + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), g_value_get_boolean (value)); + break; + case PROP_SMTP_URI: - priv->smtp_uri = g_strstrip (g_value_dup_string (value)); + gtk_entry_set_text (GTK_ENTRY (priv->server), g_strstrip (g_value_dup_string (value))); + break; + + case PROP_SMTP_URI_EDITABLE: + gtk_editable_set_editable (GTK_EDITABLE (priv->server), g_value_get_boolean (value)); break; case PROP_FROM: @@ -727,14 +843,6 @@ solipa_mail_ui_set_property (GObject *object, case PROP_CC_VISIBLE: gtk_widget_set_visible (priv->cc, g_value_get_boolean (value)); gtk_widget_set_visible (priv->cc_lbl, g_value_get_boolean (value)); - if (g_value_get_boolean (value)) - { - gtk_table_set_row_spacing (GTK_TABLE (priv->widget), 2, 5); - } - else - { - gtk_table_set_row_spacing (GTK_TABLE (priv->widget), 2, 0); - } break; case PROP_BCC: @@ -748,14 +856,6 @@ solipa_mail_ui_set_property (GObject *object, case PROP_BCC_VISIBLE: gtk_widget_set_visible (priv->bcc, g_value_get_boolean (value)); gtk_widget_set_visible (priv->bcc_lbl, g_value_get_boolean (value)); - if (g_value_get_boolean (value)) - { - gtk_table_set_row_spacing (GTK_TABLE (priv->widget), 3, 5); - } - else - { - gtk_table_set_row_spacing (GTK_TABLE (priv->widget), 3, 0); - } break; case PROP_SUBJECT: @@ -791,7 +891,31 @@ solipa_mail_ui_set_property (GObject *object, break; case PROP_WITH_ATTACHMENTS: - gtk_widget_set_visible (priv->iv_attachments, g_value_get_boolean (value)); + gtk_widget_set_visible (priv->expander_attachments, g_value_get_boolean (value)); + break; + + case PROP_SECURITY_METHOD: + gtk_combo_box_set_active_id (GTK_COMBO_BOX (priv->security_method), g_strdup_printf ("%d", g_value_get_uint (value))); + break; + + case PROP_SECURITY_METHOD_EDITABLE: + gtk_widget_set_sensitive (priv->security_method, g_value_get_boolean (value)); + break; + + case PROP_USERNAME: + gtk_entry_set_text (GTK_ENTRY (priv->username), g_strstrip (g_value_dup_string (value))); + break; + + case PROP_USERNAME_EDITABLE: + gtk_editable_set_editable (GTK_EDITABLE (priv->username), g_value_get_boolean (value)); + break; + + case PROP_PASSWORD: + gtk_entry_set_text (GTK_ENTRY (priv->password), g_strstrip (g_value_dup_string (value))); + break; + + case PROP_PASSWORD_EDITABLE: + gtk_editable_set_editable (GTK_EDITABLE (priv->password), g_value_get_boolean (value)); break; default: @@ -811,8 +935,16 @@ solipa_mail_ui_get_property (GObject *object, switch (property_id) { + case PROP_SHOW_SERVER_OPTIONS: + g_value_set_boolean (value, gtk_notebook_get_show_tabs (GTK_NOTEBOOK (priv->notebook))); + break; + case PROP_SMTP_URI: - g_value_set_string (value, priv->smtp_uri); + g_value_set_string (value, gtk_entry_get_text (GTK_ENTRY (priv->server))); + break; + + case PROP_SMTP_URI_EDITABLE: + g_value_set_boolean (value, gtk_editable_get_editable (GTK_EDITABLE (priv->server))); break; case PROP_FROM: @@ -889,7 +1021,42 @@ solipa_mail_ui_get_property (GObject *object, break; case PROP_WITH_ATTACHMENTS: - g_value_set_boolean (value, gtk_widget_get_visible (priv->iv_attachments)); + g_value_set_boolean (value, gtk_widget_get_visible (priv->expander_attachments)); + break; + + case PROP_SECURITY_METHOD: + { + const gchar *id; + id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (priv->security_method)); + if (id != NULL) + { + g_value_set_uint (value, strtol (id, NULL, 10)); + } + else + { + g_value_set_uint (value, 0); + } + break; + } + + case PROP_SECURITY_METHOD_EDITABLE: + g_value_set_boolean (value, gtk_widget_get_sensitive (priv->security_method)); + break; + + case PROP_USERNAME: + g_value_set_string (value, gtk_entry_get_text (GTK_ENTRY (priv->username))); + break; + + case PROP_USERNAME_EDITABLE: + g_value_set_boolean (value, gtk_editable_get_editable (GTK_EDITABLE (priv->username))); + break; + + case PROP_PASSWORD: + g_value_set_string (value, gtk_entry_get_text (GTK_ENTRY (priv->password))); + break; + + case PROP_PASSWORD_EDITABLE: + g_value_set_boolean (value, gtk_editable_get_editable (GTK_EDITABLE (priv->password))); break; default: @@ -980,8 +1147,8 @@ solipa_mail_ui_on_btn_attachment_add_clicked (GtkButton *button, dialog = gtk_file_chooser_dialog_new ("Choose a file to attach.", GTK_WINDOW (transient), GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + "_Cancel", GTK_RESPONSE_CANCEL, + "document-open", GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { diff --git a/tests/mail.c b/tests/mail.c index 8439a69..f529ac6 100644 --- a/tests/mail.c +++ b/tests/mail.c @@ -148,8 +148,12 @@ main (int argc, char **argv) strmail = solipa_mail_get_as_string (smail); g_message ("The email text:\n%s", strmail); - if (username != NULL && password != NULL) + if (username != NULL) { + if (password == NULL) + { + password = g_strdup (""); + } solipa_mail_set_username_password (smail, username, password); } diff --git a/tests/mailui.c b/tests/mailui.c index 54b2254..ab339cd 100644 --- a/tests/mailui.c +++ b/tests/mailui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2014 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,6 +26,126 @@ GtkBuilder *builder; GtkWidget *w; GtkWidget *mailui_w; +static void +on_btn_fromeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "from-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton1"))), + NULL); +} + +static void +on_btn_toeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "to-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton2"))), + NULL); +} + +static void +on_btn_cceditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "cc-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton3"))), + NULL); +} + +static void +on_btn_ccvisible_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "cc-visible", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton7"))), + NULL); +} + +static void +on_btn_bcceditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "bcc-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton4"))), + NULL); +} + +static void +on_btn_bccvisible_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "bcc-visible", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton5"))), + NULL); +} + +static void +on_btn_subjecteditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "subject-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton6"))), + NULL); +} + +static void +on_btn_withnotification_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "with-notification-visible", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton8"))), + NULL); +} + +static void +on_btn_bodyeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "body-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton9"))), + NULL); +} + +static void +on_btn_withattachments_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "with-attachments", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton10"))), + NULL); +} + +static void +on_btn_serveroptions_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "show-server-options", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton14"))), + NULL); +} + +static void +on_btn_servereditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "smtp-uri-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton11"))), + NULL); +} + +static void +on_btn_securitymethodeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "security-method-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton15"))), + NULL); +} + +static void +on_btn_usernameeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "username-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton12"))), + NULL); +} + +static void +on_btn_passwordeditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) +{ + g_object_set (G_OBJECT (mailui), + "password-editable", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "togglebutton13"))), + NULL); +} + static void on_btn_cancel_clicked (gpointer instance, gpointer user_data) { @@ -36,27 +156,8 @@ on_btn_cancel_clicked (gpointer instance, gpointer user_data) static void on_btn_ok_clicked (gpointer instance, gpointer user_data) { - gchar *smtp; - g_debug ("OK clicked"); - smtp = (gchar *)gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "entry1"))); - if (smtp == NULL) - { - smtp = g_strdup ("smtp://localhost/"); - } - else - { - if (g_strcmp0 (g_strstrip (smtp), "") == 0) - { - smtp = g_strdup ("smtp://localhost/"); - } - } - - g_object_set (G_OBJECT (mailui), - "smtp-uri", smtp, - NULL); - if (solipa_mail_ui_send (mailui)) { solipa_message_dialog (w, @@ -120,13 +221,42 @@ main (int argc, char *argv[]) w = GTK_WIDGET (gtk_builder_get_object (builder, "w_mail")); g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), (gpointer)solipa); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton1"), "toggled", + G_CALLBACK (on_btn_fromeditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton2"), "toggled", + G_CALLBACK (on_btn_toeditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton3"), "toggled", + G_CALLBACK (on_btn_cceditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton7"), "toggled", + G_CALLBACK (on_btn_ccvisible_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton4"), "toggled", + G_CALLBACK (on_btn_bcceditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton5"), "toggled", + G_CALLBACK (on_btn_bccvisible_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton6"), "toggled", + G_CALLBACK (on_btn_subjecteditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton8"), "toggled", + G_CALLBACK (on_btn_withnotification_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton9"), "toggled", + G_CALLBACK (on_btn_bodyeditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton10"), "toggled", + G_CALLBACK (on_btn_withattachments_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton14"), "toggled", + G_CALLBACK (on_btn_serveroptions_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton11"), "toggled", + G_CALLBACK (on_btn_servereditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton15"), "toggled", + G_CALLBACK (on_btn_securitymethodeditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton12"), "toggled", + G_CALLBACK (on_btn_usernameeditable_toggled), NULL); + g_signal_connect (gtk_builder_get_object (builder, "togglebutton13"), "toggled", + G_CALLBACK (on_btn_passwordeditable_toggled), NULL); + mailui_w = solipa_mail_ui_get_widget (mailui); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "vbox3")), mailui_w, TRUE, TRUE, 5); - gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "entry1")), "smtp://localhost/"); - g_signal_connect (gtk_builder_get_object (builder, "button1"), "clicked", G_CALLBACK (on_btn_cancel_clicked), NULL); g_signal_connect (gtk_builder_get_object (builder, "button2"), "clicked", @@ -142,6 +272,7 @@ main (int argc, char *argv[]) "subject", "Da SolipaMailUI", "body", "Il body della mail\n" " con a capo\t\te tab\n\nprova prova", + "security-method", CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT, NULL); gtk_widget_show (w); diff --git a/tests/tests.ui b/tests/tests.ui index 52305eb..02d3aef 100644 --- a/tests/tests.ui +++ b/tests/tests.ui @@ -1,14 +1,15 @@ - + + - - + + False Test SolipaAllegato - + - + True - vertical + False @@ -16,64 +17,308 @@ + False Test SolipaMailUI - + - + True + False 5 vertical 5 - + True - 2 - 5 - 5 + False + vertical - + + + + + False + True + 0 + + + + + True + False + 5 + start + + + From editable True - 0 - SMTP server: + True + True - GTK_FILL - GTK_FILL + True + True + 0 - + + To editable True True - + True + True - 1 - 2 - GTK_FILL + True + True + 1 + + + + + CC editable + True + True + True + True + + + True + True + 2 + + + + + CC visible + True + True + True + True + + + True + True + 3 False - 0 + True + 1 - + True - vertical + False + 5 + start - + + BCC editable + True + True + True + True + + + True + True + 0 + + + + + BCC visible + True + True + True + + + True + True + 1 + + + + + Subject editable + True + True + True + True + + + True + True + 2 + - 1 + False + True + 2 + + + + + True + False + 5 + start + + + With notification visible + True + True + True + True + + + True + True + 0 + + + + + Body editable + True + True + True + True + + + True + True + 1 + + + + + With attachments + True + True + True + True + + + True + True + 2 + + + + + False + True + 3 - + True + False + 5 + start + + + Server options visible + True + True + True + True + + + True + True + 0 + + + + + Server editable + True + True + True + True + + + True + True + 1 + + + + + Security method editable + True + True + True + True + + + True + True + 2 + + + + + False + True + 4 + + + + + True + False + 5 + start + + + Username editable + True + True + True + True + + + True + True + 0 + + + + + Password editable + True + True + True + True + + + True + True + 1 + + + + + False + True + 5 + + + + + True + False 5 end @@ -107,7 +352,8 @@ False - 2 + True + 6 -- 2.49.0