Modified webpage: now tinymail repository is in gitorious.
[modest] / src / hildon2 / modest-maemo-security-options-view.c
1 /* Copyright (c) 2008, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "modest-runtime.h"
31 #include "modest-security-options-view-priv.h"
32 #include "modest-maemo-security-options-view.h"
33 #include "modest-text-utils.h"
34 #include "modest-platform.h"
35 #include "modest-account-protocol.h"
36 #include "widgets/modest-ui-constants.h"
37 #include "widgets/modest-validating-entry.h"
38 #include "modest-maemo-utils.h"
39 #include "modest-hildon-includes.h"
40 #include <modest-toolkit-factory.h>
41 #include <modest-toolkit-utils.h>
42
43 #define PORT_MIN 1
44 #define PORT_MAX 65535
45
46 typedef struct _ModestMaemoSecurityOptionsViewPrivate ModestMaemoSecurityOptionsViewPrivate;
47 struct _ModestMaemoSecurityOptionsViewPrivate {
48         gboolean missing_data;
49 };
50
51 #define MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE(o) \
52         (G_TYPE_INSTANCE_GET_PRIVATE((o), \
53                                      MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, \
54                                      ModestMaemoSecurityOptionsViewPrivate))
55
56 static void modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj);
57 static void modest_maemo_security_options_view_finalize (GObject *obj);
58 static void modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass);
59
60 G_DEFINE_TYPE (ModestMaemoSecurityOptionsView, 
61                modest_maemo_security_options_view, 
62                MODEST_TYPE_SECURITY_OPTIONS_VIEW);
63
64 static void on_entry_changed (GtkEditable *editable, gpointer user_data);
65
66 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
67 static void on_valid_changed (ModestNumberEditor *editor, gboolean valid, ModestSecurityOptionsView *self);
68 #endif
69
70 /* Tracks changes in the incoming security picker */
71 static void
72 on_security_changed (GtkWidget *widget, 
73                      ModestMaemoSecurityOptionsView *self)
74 {
75         ModestSecurityOptionsViewPrivate* ppriv;
76         ModestProtocolType proto_type;
77         ModestProtocolRegistry *proto_registry;
78         gboolean is_secure;
79
80         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
81
82         proto_registry = modest_runtime_get_protocol_registry ();
83         proto_type = modest_serversecurity_selector_get_active_serversecurity (ppriv->security_view);
84
85         is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
86                                                                     MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
87
88         if (ppriv->full) {
89                 gint port_number =
90                         modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
91
92                 if(port_number) {
93                         modest_number_entry_set_value (ppriv->port_view,
94                                                        port_number);
95                 }
96         }
97 }
98
99 static void
100 on_auth_changed (GtkWidget *widget, 
101                  ModestMaemoSecurityOptionsView *self)
102 {
103         ModestSecurityOptionsViewPrivate* ppriv;
104         ModestProtocolRegistry *protocol_registry;
105         ModestProtocolType auth_proto;
106         gboolean secureauth_used;
107         GtkWidget *user_caption, *pwd_caption;
108
109         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
110         protocol_registry = modest_runtime_get_protocol_registry ();
111
112         auth_proto = modest_secureauth_selector_get_active_secureauth (ppriv->auth_view);
113         secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, 
114                                                                             auth_proto);
115
116         /* Get captions, well dimm the whole widget */
117         user_caption = gtk_widget_get_parent (ppriv->user_entry);
118         pwd_caption = gtk_widget_get_parent (ppriv->pwd_entry);
119
120         /* Enable / disable */
121         gtk_widget_set_sensitive (user_caption, secureauth_used);
122         gtk_widget_set_sensitive (pwd_caption, secureauth_used);
123
124         /* Check if mandatory data is missing */
125         on_entry_changed (GTK_EDITABLE (ppriv->user_entry), (gpointer) self);
126 }
127
128 static void
129 create_incoming_security (ModestSecurityOptionsView* self,
130                           GtkSizeGroup *title_size_group,
131                           GtkSizeGroup *value_size_group)
132 {
133         ModestSecurityOptionsViewPrivate *ppriv;
134         GtkWidget *entry_caption = NULL;
135
136         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
137
138         ppriv->auth_view = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
139                                                                        _("mcen_li_emailsetup_secure_authentication"));
140         gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
141
142         /* Create widgets for incoming security */
143         ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
144         modest_serversecurity_selector_fill (ppriv->security_view,
145                                              modest_protocol_registry_get_pop_type_id ());
146         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
147                 GtkWidget *captioned;
148
149                 captioned = modest_toolkit_utils_create_captioned (title_size_group, value_size_group,
150                                                                    _("mcen_li_emailsetup_secure_connection"), FALSE,
151                                                                    ppriv->security_view);
152                 g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
153                                   G_CALLBACK (on_security_changed), self);
154                 gtk_box_pack_start (GTK_BOX (self), captioned, FALSE, FALSE, 0);
155                 gtk_widget_show (captioned);
156         } else {
157                 modest_toolkit_utils_set_hbutton_layout (title_size_group,
158                                                          value_size_group,
159                                                          _("mcen_li_emailsetup_secure_connection"), 
160                                                          ppriv->security_view);
161                 g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
162                                   G_CALLBACK (on_security_changed), self);
163                 gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
164         }
165
166         /* Pack into container & show */
167         gtk_widget_show (ppriv->security_view);
168         gtk_widget_show (ppriv->auth_view);
169
170         if (ppriv->full) {
171                 ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (),
172                                                                                PORT_MIN, PORT_MAX);
173                 entry_caption =
174                         modest_toolkit_utils_create_captioned_with_size_type (title_size_group,
175                                                                               value_size_group,
176                                                                               _("mcen_fi_emailsetup_port"),
177                                                                               FALSE,
178                                                                               ppriv->port_view,
179                                                                               MODEST_EDITABLE_SIZE);
180                 /* Pack & show widgets */
181                 gtk_box_pack_start (GTK_BOX (self), entry_caption, FALSE, FALSE, 0);
182                 gtk_widget_show (ppriv->port_view);
183                 gtk_widget_show (entry_caption);
184
185                 /* Track changes in UI */
186 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
187                 g_signal_connect (G_OBJECT (ppriv->port_view), "valid-changed",
188                                             G_CALLBACK (on_valid_changed), self);
189 #endif
190         }
191 }
192
193 static void
194 on_entry_max (ModestValidatingEntry *self, 
195               gpointer user_data)
196 {
197         modest_platform_information_banner (GTK_WIDGET (self), NULL, 
198                                             _CS_MAXIMUM_CHARACTERS_REACHED);
199 }
200
201 /*
202  * TODO: call this whenever the auth picker changes. If we set it
203  * explicitely at the beggining to a value then there is no need to
204  * call this handler directly at the beginning
205  */
206 static void
207 on_entry_changed (GtkEditable *editable, 
208                   gpointer user_data)
209 {
210         ModestSecurityOptionsView* self;
211         ModestMaemoSecurityOptionsViewPrivate *priv;
212         ModestSecurityOptionsViewPrivate *ppriv;
213         gboolean is_secure = FALSE;
214         ModestProtocolRegistry *protocol_registry;
215
216         self = MODEST_SECURITY_OPTIONS_VIEW (user_data);
217         priv = MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
218         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
219         protocol_registry = modest_runtime_get_protocol_registry ();
220
221         /* Check if it's a secure protocol */
222         if (modest_is_secureauth_selector (ppriv->auth_view)) {
223                 ModestProtocolType auth_proto;
224                 auth_proto = modest_secureauth_selector_get_active_secureauth (ppriv->auth_view);
225                 is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
226                                                                               auth_proto);
227         } else if (modest_is_togglable (ppriv->auth_view)) {
228                 is_secure = modest_togglable_get_active (ppriv->auth_view);
229         }
230
231         if (is_secure &&
232             !g_strcmp0 (modest_entry_get_text (ppriv->user_entry), "")) {
233                 priv->missing_data = TRUE;
234         } else {
235                 priv->missing_data = FALSE;
236         }
237
238         if (!priv->missing_data &&
239             ppriv->full &&
240             !modest_number_entry_is_valid (ppriv->port_view))
241                 priv->missing_data = TRUE;
242
243         /* Emit a signal to notify if mandatory data is missing */
244         g_signal_emit_by_name (G_OBJECT (self), "missing_mandatory_data",
245                                priv->missing_data, NULL);
246 }
247
248 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
249 static void
250 on_valid_changed (ModestNumberEditor *editor,
251                   gboolean valid,
252                   ModestSecurityOptionsView *self)
253 {
254         on_entry_changed (NULL, (gpointer) self);
255 }
256 #endif
257
258 static void
259 create_outgoing_security (ModestSecurityOptionsView* self,
260                           GtkSizeGroup *title_size_group,
261                           GtkSizeGroup *value_size_group)
262 {
263         ModestSecurityOptionsViewPrivate *ppriv;
264         GtkWidget *user_caption = NULL, *security_caption = NULL, *auth_caption = NULL;
265         GtkWidget *pwd_caption = NULL, *port_caption = NULL;
266
267         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
268         
269         /* The secure connection widgets */
270         ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
271         modest_serversecurity_selector_fill (ppriv->security_view,
272                                               MODEST_PROTOCOLS_TRANSPORT_SMTP);
273         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
274                 security_caption = modest_toolkit_utils_create_captioned (title_size_group, value_size_group,
275                                                                           _("mcen_li_emailsetup_secure_connection"), FALSE,
276                                                                           ppriv->security_view);
277                 gtk_widget_show (security_caption);
278         } else {
279                 modest_toolkit_utils_set_hbutton_layout (title_size_group,
280                                                          value_size_group,
281                                                          _("mcen_li_emailsetup_secure_connection"), 
282                                                          ppriv->security_view);
283                 security_caption = ppriv->security_view;
284         }
285         
286         /* The secure authentication widgets */
287         ppriv->auth_view = modest_toolkit_factory_create_secureauth_selector (modest_runtime_get_toolkit_factory ());
288         if (GTK_IS_COMBO_BOX (ppriv->auth_view)) {
289                 auth_caption = modest_toolkit_utils_create_captioned (title_size_group, value_size_group,
290                                                                       _("mcen_li_emailsetup_secure_authentication"), FALSE,
291                                                                       ppriv->auth_view);
292                 gtk_widget_show (auth_caption);
293         } else {
294                 modest_toolkit_utils_set_hbutton_layout (title_size_group,
295                                                          value_size_group,
296                                                          _("mcen_li_emailsetup_secure_authentication"), 
297                                                          ppriv->auth_view);
298                 auth_caption = ppriv->auth_view;
299         }
300
301         if (ppriv->full) {
302                 gchar *user_label;
303
304                 /* Username widgets */
305                 ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
306
307                 /* Auto-capitalization is the default, so let's turn it off: */
308 #ifdef MODEST_TOOLKIT_HILDON2
309                 hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry), 
310                                                  HILDON_GTK_INPUT_MODE_FULL);
311 #endif
312
313                 user_label = g_strdup_printf("%s*", _("mail_fi_username"));
314                 user_caption = modest_toolkit_utils_create_captioned_with_size_type (title_size_group,
315                                                                                      value_size_group,
316                                                                                      user_label,
317                                                                                      FALSE,
318                                                                                      ppriv->user_entry,
319                                                                                      MODEST_EDITABLE_SIZE);
320                 g_free (user_label);
321         
322                 /* Prevent the use of some characters. Limit the max
323                    length as well */
324                 modest_validating_entry_set_unallowed_characters_whitespace (
325                      MODEST_VALIDATING_ENTRY (ppriv->user_entry));      
326                 gtk_entry_set_max_length (GTK_ENTRY (ppriv->user_entry), 64);
327                 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (ppriv->user_entry),
328                                                       on_entry_max, self);
329                 
330                 /* Password widgets */
331                 ppriv->pwd_entry = modest_toolkit_factory_create_entry (modest_runtime_get_toolkit_factory ());
332
333                 /* Auto-capitalization is the default, so let's turn it off */
334 #ifdef MODEST_TOOLKIT_HILDON2
335                 hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
336                                                  HILDON_GTK_INPUT_MODE_FULL | 
337                                                  HILDON_GTK_INPUT_MODE_INVISIBLE);
338 #endif
339                 gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
340
341                 pwd_caption =
342                         modest_toolkit_utils_create_captioned_with_size_type (title_size_group,
343                                                                               value_size_group,
344                                                                               _("mail_fi_password"),
345                                                                               FALSE,
346                                                                               ppriv->pwd_entry,
347                                                                               MODEST_EDITABLE_SIZE);
348
349                 ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (),
350                                                                                PORT_MIN, PORT_MAX);
351                 port_caption =
352                         modest_toolkit_utils_create_captioned_with_size_type (title_size_group,
353                                                                               value_size_group,
354                                                                               _("mcen_fi_emailsetup_port"),
355                                                                               FALSE,
356                                                                               ppriv->port_view,
357                                                                               MODEST_EDITABLE_SIZE);
358         }
359
360         /* Track changes in UI */
361         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
362                 g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
363                                   G_CALLBACK (on_security_changed), self);
364         } else {
365                 g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
366                                   G_CALLBACK (on_security_changed), self);
367         }
368         if (ppriv->full) {
369                 if (GTK_IS_COMBO_BOX (ppriv->auth_view)) {
370                         g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
371                                           G_CALLBACK (on_auth_changed), self);
372                 } else {
373                         g_signal_connect (G_OBJECT (ppriv->auth_view), "value-changed",
374                                           G_CALLBACK (on_auth_changed), self);
375                 }
376                 g_signal_connect (G_OBJECT (ppriv->user_entry), "changed",
377                                   G_CALLBACK (on_entry_changed), self);
378 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
379                 g_signal_connect (G_OBJECT (ppriv->port_view), "valid-changed",
380                                             G_CALLBACK (on_valid_changed), self);
381 #endif
382         }
383
384         /* Initialize widgets */
385         modest_serversecurity_selector_set_active_serversecurity (
386                 ppriv->security_view,
387                 MODEST_PROTOCOLS_CONNECTION_NONE);
388         modest_secureauth_selector_set_active_secureauth (
389            ppriv->auth_view,
390            MODEST_PROTOCOLS_AUTH_NONE);
391
392         /* Pack into container */
393         if (ppriv->full) {
394                 gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, 0);
395                 gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, 0);
396                 gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, 0);
397                 gtk_box_pack_start (GTK_BOX (self), security_caption, FALSE, FALSE, 0);
398                 gtk_box_pack_start (GTK_BOX (self), port_caption, FALSE, FALSE, 0);
399         } else {
400                 gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, 0);
401                 gtk_box_pack_start (GTK_BOX (self), security_caption, FALSE, FALSE, 0);
402         }
403
404         /* Show widgets */
405         if (ppriv->full) {
406                 gtk_widget_show (ppriv->pwd_entry);
407                 gtk_widget_show (ppriv->user_entry);
408                 gtk_widget_show (ppriv->port_view);
409                 gtk_widget_show (pwd_caption);
410                 gtk_widget_show (user_caption);
411                 gtk_widget_show (port_caption);
412         }
413         gtk_widget_show (ppriv->security_view);
414         gtk_widget_show (ppriv->auth_view);
415 }
416
417 GtkWidget *    
418 modest_maemo_security_options_view_new  (ModestSecurityOptionsType type,
419                                          gboolean full,
420                                          GtkSizeGroup *title_size_group,
421                                          GtkSizeGroup *value_size_group)
422 {
423         ModestSecurityOptionsView* self;
424         ModestSecurityOptionsViewPrivate *ppriv;
425
426         self = (ModestSecurityOptionsView *)
427                 g_object_new (MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, NULL);
428         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
429
430         ppriv->full = full;
431         self->type = type;
432         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
433                 create_incoming_security (self, title_size_group, value_size_group);
434         else
435                 create_outgoing_security (self, title_size_group, value_size_group);
436
437         return (GtkWidget *) self;
438 }
439
440 gboolean
441 modest_security_options_view_has_missing_mandatory_data (ModestSecurityOptionsView* self)
442 {
443         ModestMaemoSecurityOptionsViewPrivate *priv;
444
445         priv = MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
446
447         return priv->missing_data;
448 }
449
450 static void
451 modest_maemo_security_options_view_load_settings (ModestSecurityOptionsView* self,
452                                                   ModestAccountSettings *settings)
453 {
454         ModestSecurityOptionsViewPrivate *ppriv;
455         ModestServerAccountSettings *server_settings;
456         gint port_number;
457
458         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
459
460         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
461                 server_settings = modest_account_settings_get_store_settings (settings);
462         else
463                 server_settings = modest_account_settings_get_transport_settings (settings);
464         port_number = modest_server_account_settings_get_port (server_settings);
465
466         if (port_number == 0) {
467                 /* Show the appropriate port number */
468                 on_security_changed (ppriv->security_view, 
469                                      MODEST_MAEMO_SECURITY_OPTIONS_VIEW (self));
470         } else if (ppriv->full) {
471                 /* Keep the user-entered port-number, or the
472                  * already-appropriate automatic port number */
473                 modest_number_entry_set_value (ppriv->port_view,
474                                                port_number);
475         }
476         /* Frees */
477         g_object_unref (server_settings);
478 }
479
480 static void
481 modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* self, 
482                                                   ModestAccountSettings *settings)
483 {
484         ModestServerAccountSettings *server_settings;
485         ModestSecurityOptionsViewPrivate *ppriv;
486         gint server_port;
487
488         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
489
490         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
491                 server_settings = modest_account_settings_get_store_settings (settings);
492         else
493                 server_settings = modest_account_settings_get_transport_settings (settings);
494
495         if (ppriv->full) {
496                 server_port = modest_number_entry_get_value (ppriv->port_view);
497         } else {
498                 server_port = modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
499         }
500
501         modest_server_account_settings_set_port (server_settings, server_port);
502
503         /* Frees */
504         g_object_unref (server_settings);
505 }
506
507 static gboolean 
508 modest_maemo_security_options_view_changed (ModestSecurityOptionsView* self,
509                                             ModestAccountSettings *settings)
510 {
511         ModestServerAccountSettings *server_settings;
512         ModestSecurityOptionsViewPrivate *ppriv;
513         gint server_port;
514
515         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
516         
517         /* If we're not showing the port number then it never changes */
518         if (!ppriv->full)
519                 return FALSE;
520
521         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
522                 server_settings = modest_account_settings_get_store_settings (settings);
523         else
524                 server_settings = modest_account_settings_get_transport_settings (settings);
525         
526         server_port = 
527                 modest_number_entry_get_value (ppriv->port_view);
528
529         /* Frees */
530         g_object_unref (server_settings);
531
532         if (server_port != ppriv->initial_state.port)
533                 return TRUE;
534         else
535                 return FALSE;
536 }
537
538 static void
539 modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj)
540 {
541 }
542
543 static void
544 modest_maemo_security_options_view_finalize (GObject *obj)
545 {
546         G_OBJECT_CLASS (modest_maemo_security_options_view_parent_class)->finalize (obj);
547 }
548
549
550 static void     
551 modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass)
552 {
553         GObjectClass *gobject_class = (GObjectClass*) klass;
554
555         modest_maemo_security_options_view_parent_class = g_type_class_peek_parent (klass);
556
557         g_type_class_add_private (gobject_class, sizeof (ModestMaemoSecurityOptionsViewPrivate));
558         gobject_class->finalize = modest_maemo_security_options_view_finalize;
559
560         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->load_settings = 
561                 modest_maemo_security_options_view_load_settings;
562         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->save_settings = 
563                 modest_maemo_security_options_view_save_settings;
564         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->changed = 
565                 modest_maemo_security_options_view_changed;
566 }