ef66fd8d7f7d4ec7663b74ddc6f3185d55c4c6f4
[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-secureauth-picker.h"
39 #include "modest-maemo-utils.h"
40 #include "modest-hildon-includes.h"
41
42 #define PORT_MIN 1
43 #define PORT_MAX 65535
44
45 typedef struct _ModestMaemoSecurityOptionsViewPrivate ModestMaemoSecurityOptionsViewPrivate;
46 struct _ModestMaemoSecurityOptionsViewPrivate {
47         gboolean missing_data;
48 };
49
50 #define MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE(o) \
51         (G_TYPE_INSTANCE_GET_PRIVATE((o), \
52                                      MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, \
53                                      ModestMaemoSecurityOptionsViewPrivate))
54
55 static void modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj);
56 static void modest_maemo_security_options_view_finalize (GObject *obj);
57 static void modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass);
58
59 G_DEFINE_TYPE (ModestMaemoSecurityOptionsView, 
60                modest_maemo_security_options_view, 
61                MODEST_TYPE_SECURITY_OPTIONS_VIEW);
62
63 static void on_entry_changed (GtkEditable *editable, gpointer user_data);
64
65 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
66 static void on_valid_changed (ModestNumberEditor *editor, gboolean valid, ModestSecurityOptionsView *self);
67 #endif
68
69 /* Tracks changes in the incoming security picker */
70 static void
71 on_security_changed (GtkWidget *widget, 
72                      ModestMaemoSecurityOptionsView *self)
73 {
74         ModestSecurityOptionsViewPrivate* ppriv;
75         ModestProtocolType proto_type;
76         ModestProtocolRegistry *proto_registry;
77         gboolean is_secure;
78
79         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
80
81         proto_registry = modest_runtime_get_protocol_registry ();
82         proto_type = modest_serversecurity_selector_get_active_serversecurity (ppriv->security_view);
83
84         is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
85                                                                     MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
86
87         if (MODEST_SECURITY_OPTIONS_VIEW (self)->type == MODEST_SECURITY_OPTIONS_INCOMING) {
88                 /* Activate and dim checkbutton if it's secure */
89                 modest_togglable_set_active (ppriv->auth_view,
90                                              is_secure);
91                 gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
92         } else {
93
94         }
95
96         if (ppriv->full) {
97                 gint port_number = 
98                         modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
99                 
100                 if(port_number) {
101                         modest_number_entry_set_value (ppriv->port_view,
102                                                        port_number);
103                 }
104         }
105 }
106
107 static void
108 on_auth_changed (GtkWidget *widget, 
109                  ModestMaemoSecurityOptionsView *self)
110 {
111         ModestSecurityOptionsViewPrivate* ppriv;
112         ModestSecureauthPicker *picker;
113         ModestProtocolRegistry *protocol_registry;
114         ModestProtocolType auth_proto;
115         gboolean secureauth_used;
116         GtkWidget *user_caption, *pwd_caption;
117
118         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
119         protocol_registry = modest_runtime_get_protocol_registry ();
120         picker = MODEST_SECUREAUTH_PICKER (ppriv->auth_view);
121
122         auth_proto = modest_secureauth_picker_get_active_secureauth (picker);
123         secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, 
124                                                                             auth_proto);
125
126         /* Get captions, well dimm the whole widget */
127         user_caption = gtk_widget_get_parent (ppriv->user_entry);
128         pwd_caption = gtk_widget_get_parent (ppriv->pwd_entry);
129         
130         /* Enable / disable */
131         gtk_widget_set_sensitive (user_caption, secureauth_used);
132         gtk_widget_set_sensitive (pwd_caption, secureauth_used);
133
134         /* Check if mandatory data is missing */
135         on_entry_changed (GTK_EDITABLE (ppriv->user_entry), (gpointer) self);
136 }
137
138 static void
139 create_incoming_security (ModestSecurityOptionsView* self,
140                           GtkSizeGroup *title_size_group,
141                           GtkSizeGroup *value_size_group)
142 {
143         ModestSecurityOptionsViewPrivate *ppriv;
144         GtkWidget *entry_caption = NULL;
145
146         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
147
148         ppriv->auth_view = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
149                                                                        _("mcen_li_emailsetup_secure_authentication"));
150         gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
151
152         /* Create widgets for incoming security */
153         ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
154         modest_serversecurity_selector_fill (ppriv->security_view,
155                                              modest_protocol_registry_get_pop_type_id ());
156         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
157                 GtkWidget *captioned;
158
159                 captioned = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
160                                                                  _("mcen_li_emailsetup_secure_connection"), FALSE,
161                                                                  ppriv->security_view);
162                 g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
163                                   G_CALLBACK (on_security_changed), self);
164                 gtk_box_pack_start (GTK_BOX (self), captioned, FALSE, FALSE, 0);
165                 gtk_widget_show (captioned);
166         } else {
167                 modest_maemo_utils_set_hbutton_layout (title_size_group,
168                                                        value_size_group,
169                                                        _("mcen_li_emailsetup_secure_connection"), 
170                                                        ppriv->security_view);
171                 g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
172                                   G_CALLBACK (on_security_changed), self);
173                 gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
174         }
175
176         /* Pack into container & show */
177         gtk_widget_show (ppriv->security_view);
178         gtk_widget_show (ppriv->auth_view);
179
180         if (ppriv->full) {
181                 ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (),
182                                                                                PORT_MIN, PORT_MAX);
183                 entry_caption =
184                         modest_maemo_utils_create_captioned_with_size_type (title_size_group,
185                                                                             value_size_group,
186                                                                             _("mcen_fi_emailsetup_port"),
187                                                                             FALSE,
188                                                                             ppriv->port_view,
189                                                                             MODEST_EDITABLE_SIZE);
190                 /* Pack & show widgets */
191                 gtk_box_pack_start (GTK_BOX (self), entry_caption, FALSE, FALSE, 0);
192                 gtk_widget_show (ppriv->port_view);
193                 gtk_widget_show (entry_caption);
194
195                 /* Track changes in UI */
196 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
197                 g_signal_connect (G_OBJECT (ppriv->port_view), "valid-changed",
198                                             G_CALLBACK (on_valid_changed), self);
199 #endif
200         }
201 }
202
203 static void
204 on_entry_max (ModestValidatingEntry *self, 
205               gpointer user_data)
206 {
207         modest_platform_information_banner (GTK_WIDGET (self), NULL, 
208                                             _CS("ckdg_ib_maximum_characters_reached"));
209 }
210
211 /*
212  * TODO: call this whenever the auth picker changes. If we set it
213  * explicitely at the beggining to a value then there is no need to
214  * call this handler directly at the beginning
215  */
216 static void
217 on_entry_changed (GtkEditable *editable, 
218                   gpointer user_data)
219 {
220         ModestSecurityOptionsView* self;
221         ModestMaemoSecurityOptionsViewPrivate *priv;
222         ModestSecurityOptionsViewPrivate *ppriv;
223         ModestSecureauthPicker *picker;
224         gboolean is_secure = FALSE;
225         ModestProtocolRegistry *protocol_registry;
226
227         self = MODEST_SECURITY_OPTIONS_VIEW (user_data);
228         priv = MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
229         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
230         protocol_registry = modest_runtime_get_protocol_registry ();
231
232         /* Check if it's a secure protocol */
233         if (MODEST_IS_SECUREAUTH_PICKER (ppriv->auth_view)) {
234                 ModestProtocolType auth_proto;
235                 picker = MODEST_SECUREAUTH_PICKER (ppriv->auth_view);
236                 auth_proto = modest_secureauth_picker_get_active_secureauth (picker);
237                 is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
238                                                                               auth_proto);
239         } else if (modest_is_togglable (ppriv->auth_view)) {
240                 is_secure = modest_togglable_get_active (ppriv->auth_view);
241         }
242
243         if (is_secure &&
244             !g_strcmp0 (modest_entry_get_text (ppriv->user_entry), "")) {
245                 priv->missing_data = TRUE;
246         } else {
247                 priv->missing_data = FALSE;
248         }
249
250         if (!priv->missing_data &&
251             ppriv->full &&
252             !modest_number_entry_is_valid (ppriv->port_view))
253                 priv->missing_data = TRUE;
254
255         /* Emit a signal to notify if mandatory data is missing */
256         g_signal_emit_by_name (G_OBJECT (self), "missing_mandatory_data",
257                                priv->missing_data, NULL);
258 }
259
260 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
261 static void
262 on_valid_changed (ModestNumberEditor *editor,
263                   gboolean valid,
264                   ModestSecurityOptionsView *self)
265 {
266         on_entry_changed (NULL, (gpointer) self);
267 }
268 #endif
269
270 static void
271 create_outgoing_security (ModestSecurityOptionsView* self,
272                           GtkSizeGroup *title_size_group,
273                           GtkSizeGroup *value_size_group)
274 {
275         ModestSecurityOptionsViewPrivate *ppriv;
276         GtkWidget *user_caption = NULL, *security_caption = NULL;
277         GtkWidget *pwd_caption = NULL, *port_caption = NULL;
278
279         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
280         
281         /* The secure connection widgets */
282         ppriv->security_view = modest_toolkit_factory_create_serversecurity (modest_runtime_get_toolkit_factory ());
283         modest_serversecurity_selector_fill (ppriv->security_view,
284                                               MODEST_PROTOCOLS_TRANSPORT_SMTP);
285         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
286                 security_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
287                                                                  _("mcen_li_emailsetup_secure_connection"), FALSE,
288                                                                  ppriv->security_view);
289         } else {
290                 modest_maemo_utils_set_hbutton_layout (title_size_group,
291                                                        value_size_group,
292                                                        _("mcen_li_emailsetup_secure_connection"), 
293                                                        ppriv->security_view);
294                 security_caption = ppriv->security_view;
295         }
296         
297         /* The secure authentication widgets */
298         ppriv->auth_view = GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE,
299                                                                      HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
300         modest_maemo_utils_set_hbutton_layout (title_size_group,
301                                                value_size_group,
302                                                _("mcen_li_emailsetup_secure_authentication"), 
303                                                ppriv->auth_view);
304
305         if (ppriv->full) {
306                 gchar *user_label;
307
308                 /* Username widgets */
309                 ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
310
311                 /* Auto-capitalization is the default, so let's turn it off: */
312 #ifdef MODEST_TOOLKIT_HILDON2
313                 hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry), 
314                                                  HILDON_GTK_INPUT_MODE_FULL);
315 #endif
316
317                 user_label = g_strdup_printf("%s*", _("mail_fi_username"));
318                 user_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group,
319                                                                                    value_size_group,
320                                                                                    user_label,
321                                                                                    FALSE,
322                                                                                    ppriv->user_entry,
323                                                                                    MODEST_EDITABLE_SIZE);
324                 g_free (user_label);
325         
326                 /* Prevent the use of some characters. Limit the max
327                    length as well */
328                 modest_validating_entry_set_unallowed_characters_whitespace (
329                      MODEST_VALIDATING_ENTRY (ppriv->user_entry));      
330                 gtk_entry_set_max_length (GTK_ENTRY (ppriv->user_entry), 64);
331                 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (ppriv->user_entry),
332                                                       on_entry_max, self);
333                 
334                 /* Password widgets */
335                 ppriv->pwd_entry = modest_toolkit_factory_create_entry (modest_runtime_get_toolkit_factory ());
336
337                 /* Auto-capitalization is the default, so let's turn it off */
338 #ifdef MODEST_TOOLKIT_HILDON2
339                 hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
340                                                  HILDON_GTK_INPUT_MODE_FULL | 
341                                                  HILDON_GTK_INPUT_MODE_INVISIBLE);
342 #endif
343                 gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
344
345                 pwd_caption =
346                         modest_maemo_utils_create_captioned_with_size_type (title_size_group,
347                                                                             value_size_group,
348                                                                             _("mail_fi_password"),
349                                                                             FALSE,
350                                                                             ppriv->pwd_entry,
351                                                                             MODEST_EDITABLE_SIZE);
352
353                 ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (),
354                                                                                PORT_MIN, PORT_MAX);
355                 port_caption =
356                         modest_maemo_utils_create_captioned_with_size_type (title_size_group,
357                                                                             value_size_group,
358                                                                             _("mcen_fi_emailsetup_port"),
359                                                                             FALSE,
360                                                                             ppriv->port_view,
361                                                                             MODEST_EDITABLE_SIZE);
362         }
363
364         /* Track changes in UI */
365         if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
366                 g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
367                                   G_CALLBACK (on_security_changed), self);
368         } else {
369                 g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
370                                   G_CALLBACK (on_security_changed), self);
371         }
372         if (ppriv->full) {
373                 g_signal_connect (G_OBJECT (ppriv->auth_view), "value-changed",
374                                   G_CALLBACK (on_auth_changed), self);
375                 g_signal_connect (G_OBJECT (ppriv->user_entry), "changed",
376                                   G_CALLBACK (on_entry_changed), self);
377 #ifdef MODEST_NUMBER_ENTRY_SUPPORT_VALID_CHANGED
378                 g_signal_connect (G_OBJECT (ppriv->port_view), "valid-changed",
379                                             G_CALLBACK (on_valid_changed), self);
380 #endif
381         }
382
383         /* Initialize widgets */
384         modest_serversecurity_selector_set_active_serversecurity (
385                 ppriv->security_view,
386                 MODEST_PROTOCOLS_CONNECTION_NONE);
387         modest_secureauth_picker_set_active_secureauth (
388            MODEST_SECUREAUTH_PICKER (ppriv->auth_view),
389            MODEST_PROTOCOLS_AUTH_NONE);
390
391         /* Pack into container */
392         if (ppriv->full) {
393                 gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
394                 gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, 0);
395                 gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, 0);
396                 gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
397                 gtk_box_pack_start (GTK_BOX (self), port_caption, FALSE, FALSE, 0);
398         } else {
399                 gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
400                 gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
401         }
402
403         /* Show widgets */
404         if (ppriv->full) {
405                 gtk_widget_show (ppriv->pwd_entry);
406                 gtk_widget_show (ppriv->user_entry);
407                 gtk_widget_show (ppriv->port_view);
408                 gtk_widget_show (pwd_caption);
409                 gtk_widget_show (user_caption);
410                 gtk_widget_show (port_caption);
411         }
412         gtk_widget_show (ppriv->security_view);
413         gtk_widget_show (ppriv->auth_view);
414 }
415
416 GtkWidget *    
417 modest_maemo_security_options_view_new  (ModestSecurityOptionsType type,
418                                          gboolean full,
419                                          GtkSizeGroup *title_size_group,
420                                          GtkSizeGroup *value_size_group)
421 {
422         ModestSecurityOptionsView* self;
423         ModestSecurityOptionsViewPrivate *ppriv;
424
425         self = (ModestSecurityOptionsView *)
426                 g_object_new (MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, NULL);
427         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
428
429         ppriv->full = full;
430         self->type = type;
431         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
432                 create_incoming_security (self, title_size_group, value_size_group);
433         else
434                 create_outgoing_security (self, title_size_group, value_size_group);
435
436         return (GtkWidget *) self;
437 }
438
439 gboolean
440 modest_security_options_view_has_missing_mandatory_data (ModestSecurityOptionsView* self)
441 {
442         ModestMaemoSecurityOptionsViewPrivate *priv;
443
444         priv = MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
445
446         return priv->missing_data;
447 }
448
449 static void
450 modest_maemo_security_options_view_load_settings (ModestSecurityOptionsView* self,
451                                                   ModestAccountSettings *settings)
452 {
453         ModestSecurityOptionsViewPrivate *ppriv;
454         ModestServerAccountSettings *server_settings;
455         gint port_number;
456
457         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
458
459         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
460                 server_settings = modest_account_settings_get_store_settings (settings);
461         else
462                 server_settings = modest_account_settings_get_transport_settings (settings);
463         port_number = modest_server_account_settings_get_port (server_settings);
464
465         if (port_number == 0) {
466                 /* Show the appropriate port number */
467                 on_security_changed (ppriv->security_view, 
468                                      MODEST_MAEMO_SECURITY_OPTIONS_VIEW (self));
469         } else if (ppriv->full) {
470                 /* Keep the user-entered port-number, or the
471                  * already-appropriate automatic port number */
472                 modest_number_entry_set_value (ppriv->port_view,
473                                                port_number);
474         }
475         /* Frees */
476         g_object_unref (server_settings);
477 }
478
479 static void
480 modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* self, 
481                                                   ModestAccountSettings *settings)
482 {
483         ModestServerAccountSettings *server_settings;
484         ModestSecurityOptionsViewPrivate *ppriv;
485         gint server_port;
486
487         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
488
489         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
490                 server_settings = modest_account_settings_get_store_settings (settings);
491         else
492                 server_settings = modest_account_settings_get_transport_settings (settings);
493
494         if (ppriv->full) {
495                 server_port = modest_number_entry_get_value (ppriv->port_view);
496         } else {
497                 server_port = modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
498         }
499
500         modest_server_account_settings_set_port (server_settings, server_port);
501
502         /* Frees */
503         g_object_unref (server_settings);
504 }
505
506 static gboolean 
507 modest_maemo_security_options_view_changed (ModestSecurityOptionsView* self,
508                                             ModestAccountSettings *settings)
509 {
510         ModestServerAccountSettings *server_settings;
511         ModestSecurityOptionsViewPrivate *ppriv;
512         gint server_port;
513
514         ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
515         
516         /* If we're not showing the port number then it never changes */
517         if (!ppriv->full)
518                 return FALSE;
519
520         if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
521                 server_settings = modest_account_settings_get_store_settings (settings);
522         else
523                 server_settings = modest_account_settings_get_transport_settings (settings);
524         
525         server_port = 
526                 modest_number_entry_get_value (ppriv->port_view);
527
528         /* Frees */
529         g_object_unref (server_settings);
530
531         if (server_port != ppriv->initial_state.port)
532                 return TRUE;
533         else
534                 return FALSE;
535 }
536
537 static void
538 modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj)
539 {
540 }
541
542 static void
543 modest_maemo_security_options_view_finalize (GObject *obj)
544 {
545         G_OBJECT_CLASS (modest_maemo_security_options_view_parent_class)->finalize (obj);
546 }
547
548
549 static void     
550 modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass)
551 {
552         GObjectClass *gobject_class = (GObjectClass*) klass;
553
554         modest_maemo_security_options_view_parent_class = g_type_class_peek_parent (klass);
555
556         g_type_class_add_private (gobject_class, sizeof (ModestMaemoSecurityOptionsViewPrivate));
557         gobject_class->finalize = modest_maemo_security_options_view_finalize;
558
559         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->load_settings = 
560                 modest_maemo_security_options_view_load_settings;
561         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->save_settings = 
562                 modest_maemo_security_options_view_save_settings;
563         MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->changed = 
564                 modest_maemo_security_options_view_changed;
565 }