Secure auth selector
[modest] / src / widgets / modest-toolkit-factory.c
1 /* Copyright (c) 2009, Igalia
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 <glib/gi18n.h>
31 #ifdef MODEST_TOOLKIT_HILDON2
32 #include <hildon/hildon.h>
33 #include <hildon/hildon-file-chooser-dialog.h>
34 #include <modest-number-editor.h>
35 #include <modest-ui-constants.h>
36 #endif
37 #include "modest-toolkit-factory.h"
38
39 #ifndef MODEST_TOOLKIT_HILDON2
40 #define USE_SCROLLED_WINDOW
41 #define USE_GTK_FIND_TOOLBAR
42 #define USE_GTK_CHECK_BUTTON
43 #define USE_GTK_CHECK_MENU
44 #define USE_GTK_ENTRY
45 #define USE_GTK_FILE_CHOOSER
46 #define USE_COUNTRY_COMBOBOX
47 #define USE_SERVERSECURITY_COMBOBOX
48 #define USE_SECUREAUTH_COMBOBOX
49 #define USE_GTK_SECURITY_OPTIONS_VIEW
50 #endif
51
52 #ifdef USE_SCROLLED_WINDOW
53 #include <modest-scrolled-window-scrollable.h>
54 #else
55 #include <modest-hildon-pannable-area-scrollable.h>
56 #endif
57
58 #ifdef USE_GTK_TOOLBAR
59 #include <modest-find-toolbar.h>
60 #else
61 #include <modest-hildon-find-toolbar.h>
62 #endif
63
64 #ifdef USE_COUNTRY_COMBOBOX
65 #include <modest-country-combo-box.h>
66 #else
67 #include <modest-country-picker.h>
68 #endif
69
70 #ifdef USE_PROVIDER_COMBOBOX
71 #include <modest-provider-combo-box.h>
72 #else
73 #include <modest-provider-picker.h>
74 #endif
75
76 #ifdef USE_SERVERTYPE_COMBOBOX
77 #include <modest-servertype-combo-box.h>
78 #else
79 #include <modest-servertype-picker.h>
80 #endif
81
82 #ifdef USE_SERVERSECURITY_COMBOBOX
83 #include <modest-serversecurity-combo-box.h>
84 #else
85 #include <modest-serversecurity-picker.h>
86 #endif
87
88 #ifdef USE_SECUREAUTH_COMBOBOX
89 #include <modest-secureauth-combo-box.h>
90 #else
91 #include <modest-secureauth-picker.h>
92 #endif
93
94 #ifdef USE_GTK_SECURITY_OPTIONS_VIEW
95 #include <modest-gtk-security-options-view.h>
96 #else
97 #include <modest-maemo-security-options-view.h>
98 #endif
99
100 static void modest_toolkit_factory_class_init (ModestToolkitFactoryClass *klass);
101 static void modest_toolkit_factory_init (ModestToolkitFactory *self);
102
103 /* GObject interface */
104 static GtkWidget * modest_toolkit_factory_create_scrollable_default           (ModestToolkitFactory *self);
105 static GtkWidget * modest_toolkit_factory_create_check_button_default         (ModestToolkitFactory *self,
106                                                                                const gchar *label);
107 static GtkWidget * modest_toolkit_factory_create_check_menu_default           (ModestToolkitFactory *self,
108                                                                                const gchar *label);
109 static GtkWidget * modest_toolkit_factory_create_isearch_toolbar_default      (ModestToolkitFactory *self,
110                                                                                const gchar *label);
111 static GtkWidget * modest_toolkit_factory_create_entry_default                (ModestToolkitFactory *self);
112 static GtkWidget * modest_toolkit_factory_create_number_entry_default         (ModestToolkitFactory *self,
113                                                                                gint min,
114                                                                                gint max);
115 static GtkWidget * modest_toolkit_factory_create_file_chooser_dialog_default  (ModestToolkitFactory *self,
116                                                                                const gchar *title,
117                                                                                GtkWindow *parent,
118                                                                                GtkFileChooserAction action);
119 static GtkWidget * modest_toolkit_factory_create_country_selector_default     (ModestToolkitFactory *self);
120 static GtkWidget * modest_toolkit_factory_create_provider_selector_default    (ModestToolkitFactory *self);
121 static GtkWidget * modest_toolkit_factory_create_servertype_selector_default  (ModestToolkitFactory *self,
122                                                                                gboolean filter_providers);
123 static GtkWidget * modest_toolkit_factory_create_serversecurity_selector_default (ModestToolkitFactory *self);
124 static GtkWidget * modest_toolkit_factory_create_secureauth_selector_default (ModestToolkitFactory *self);
125 static GtkWidget * modest_toolkit_factory_create_security_options_view_default (ModestToolkitFactory *self, 
126                                                                                 ModestSecurityOptionsType type,
127                                                                                 gboolean full, 
128                                                                                 GtkSizeGroup *title_size_group,
129                                                                                 GtkSizeGroup *value_size_group);
130 /* globals */
131 static GObjectClass *parent_class = NULL;
132
133 G_DEFINE_TYPE    (ModestToolkitFactory,
134                   modest_toolkit_factory,
135                   G_TYPE_OBJECT);
136
137 ModestToolkitFactory *
138 modest_toolkit_factory_get_instance                            (void)
139 {
140     GObject* self = g_object_new (MODEST_TYPE_TOOLKIT_FACTORY, NULL);
141
142     return (ModestToolkitFactory *) self;
143 }
144
145 static void
146 modest_toolkit_factory_class_init (ModestToolkitFactoryClass *klass)
147 {
148         parent_class = g_type_class_peek_parent (klass);
149
150         klass->create_scrollable = modest_toolkit_factory_create_scrollable_default;
151         klass->create_check_button = modest_toolkit_factory_create_check_button_default;
152         klass->create_check_menu = modest_toolkit_factory_create_check_menu_default;
153         klass->create_isearch_toolbar = modest_toolkit_factory_create_isearch_toolbar_default;
154         klass->create_entry = modest_toolkit_factory_create_entry_default;
155         klass->create_number_entry = modest_toolkit_factory_create_number_entry_default;
156         klass->create_file_chooser_dialog = modest_toolkit_factory_create_file_chooser_dialog_default;
157         klass->create_country_selector = modest_toolkit_factory_create_country_selector_default;
158         klass->create_provider_selector = modest_toolkit_factory_create_provider_selector_default;
159         klass->create_servertype_selector = modest_toolkit_factory_create_servertype_selector_default;
160         klass->create_serversecurity_selector = modest_toolkit_factory_create_serversecurity_selector_default;
161         klass->create_secureauth_selector = modest_toolkit_factory_create_secureauth_selector_default;
162         klass->create_security_options_view = modest_toolkit_factory_create_security_options_view_default;
163 }
164
165 static void
166 modest_toolkit_factory_init (ModestToolkitFactory *self)
167 {
168 }
169
170 GtkWidget *
171 modest_toolkit_factory_create_scrollable (ModestToolkitFactory *self)
172 {
173         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_scrollable (self);
174 }
175
176 static GtkWidget *
177 modest_toolkit_factory_create_scrollable_default (ModestToolkitFactory *self)
178 {
179 #ifdef USE_SCROLLED_WINDOW
180         return modest_scrolled_window_scrollable_new ();
181 #else
182         return modest_hildon_pannable_area_scrollable_new ();
183 #endif
184 }
185
186 GtkWidget *
187 modest_toolkit_factory_create_check_button (ModestToolkitFactory *self, const gchar *label)
188 {
189         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_check_button (self, label);
190 }
191
192 static GtkWidget *
193 modest_toolkit_factory_create_check_button_default (ModestToolkitFactory *self, const gchar *label)
194 {
195         GtkWidget *result;
196 #ifdef USE_GTK_CHECK_BUTTON
197         result = gtk_check_button_new_with_label (label);
198 #else
199         result = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
200         gtk_button_set_label (GTK_BUTTON (result), label);
201         gtk_button_set_alignment (GTK_BUTTON (result), 0.0, 0.5);
202 #endif
203         return result;
204 }
205
206 GtkWidget *
207 modest_toolkit_factory_create_check_menu (ModestToolkitFactory *self, const gchar *label)
208 {
209         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_check_menu (self, label);
210 }
211
212 static GtkWidget *
213 modest_toolkit_factory_create_check_menu_default (ModestToolkitFactory *self, const gchar *label)
214 {
215         GtkWidget *result;
216 #ifdef USE_GTK_CHECK_MENU
217         result = gtk_check_menu_item_new_with_label (label);
218 #else
219         result = hildon_check_button_new (0);
220         gtk_button_set_label (GTK_BUTTON (result), label);
221         gtk_button_set_alignment (GTK_BUTTON (result), 0.5, 0.5);
222 #endif
223         return result;
224 }
225
226 gboolean
227 modest_togglable_get_active (GtkWidget *widget)
228 {
229         if (GTK_IS_CHECK_MENU_ITEM (widget)) {
230                 return gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
231         } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
232                 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
233 #ifdef MODEST_TOOLKIT_HILDON2
234         } else if (HILDON_IS_CHECK_BUTTON (widget)) {
235                 return hildon_check_button_get_active (HILDON_CHECK_BUTTON (widget));
236 #endif
237         } else {
238                 g_return_val_if_reached (FALSE);
239         }
240 }
241
242 void
243 modest_togglable_set_active (GtkWidget *widget, gboolean active)
244 {
245         if (GTK_IS_CHECK_MENU_ITEM (widget)) {
246                 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), active);
247         } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
248                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), active);
249 #ifdef MODEST_TOOLKIT_HILDON2
250         } else if (HILDON_IS_CHECK_BUTTON (widget)) {
251                 hildon_check_button_set_active (HILDON_CHECK_BUTTON (widget), active);
252 #endif
253         }
254 }
255
256 gboolean
257 modest_is_togglable (GtkWidget *widget)
258 {
259         return GTK_IS_CHECK_MENU_ITEM (widget) 
260                 || GTK_IS_TOGGLE_BUTTON (widget)
261 #ifdef MODEST_TOOLKIT_HILDON2
262                 || HILDON_IS_CHECK_BUTTON (widget)
263 #endif
264                 ;
265 }
266
267 GtkWidget *
268 modest_toolkit_factory_create_isearch_toolbar (ModestToolkitFactory *self, const gchar *label)
269 {
270         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_isearch_toolbar (self, label);
271 }
272
273 static GtkWidget *
274 modest_toolkit_factory_create_isearch_toolbar_default (ModestToolkitFactory *self, const gchar *label)
275 {
276         GtkWidget *result;
277 #ifdef USE_GTK_FIND_TOOLBAR
278         result = modest_find_toolbar_new (label);
279 #else
280         result = modest_hildon_find_toolbar_new (label);
281 #endif
282         return result;
283 }
284
285 GtkWidget *
286 modest_toolkit_factory_create_entry (ModestToolkitFactory *self)
287 {
288         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_entry (self);
289 }
290
291 static GtkWidget *
292 modest_toolkit_factory_create_entry_default (ModestToolkitFactory *self)
293 {
294 #ifdef USE_GTK_ENTRY
295         return gtk_entry_new ();
296 #else
297         return hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
298 #endif
299 }
300
301 void
302 modest_entry_set_text (GtkWidget *widget, const gchar *text)
303 {
304 #ifdef MODEST_TOOLKIT_HILDON2
305         hildon_entry_set_text (HILDON_ENTRY (widget), text);
306 #else
307         gtk_entry_set_text (GTK_ENTRY (widget), text);
308 #endif
309 }
310
311 const gchar *
312 modest_entry_get_text (GtkWidget *widget)
313 {
314 #ifdef MODEST_TOOLKIT_HILDON2
315         return hildon_entry_get_text (HILDON_ENTRY (widget));
316 #else
317         return gtk_entry_set_text (GTK_ENTRY (widget));
318 #endif
319 }
320
321 void 
322 modest_entry_set_hint (GtkWidget *widget, const gchar *hint)
323 {
324 #ifdef MODEST_TOOLKIT_HILDON2
325         hildon_entry_set_placeholder (HILDON_ENTRY (widget), hint);
326 #else
327         gtk_widget_set_tooltip_text (widget, hint);
328 #endif
329 }
330
331 gboolean
332 modest_is_entry (GtkWidget *widget)
333 {
334 #ifdef MODEST_TOOLKIT_HILDON2
335         return HILDON_IS_ENTRY (widget);
336 #else
337         return GTK_IS_ENTRY (widget);
338 #endif
339 }
340
341 GtkWidget *
342 modest_toolkit_factory_create_number_entry (ModestToolkitFactory *self, gint min, gint max)
343 {
344         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_number_entry (self, min, max);
345 }
346
347 static GtkWidget *
348 modest_toolkit_factory_create_number_entry_default (ModestToolkitFactory *self, gint min, gint max)
349 {
350         GtkWidget *result;
351 #ifdef USE_GTK_SPIN_BUTTON
352         result = gtk_spin_button_new_with_range (min, max, 1.0);
353         gtk_spin_button_set_digits (GTK_SPIN_BUTTON (result), 0);
354 #else
355         result = modest_number_editor_new (min, max);
356 #endif
357         return result;
358 }
359
360 void
361 modest_number_entry_set_value (GtkWidget *widget, gint value)
362 {
363 #ifdef USE_GTK_SPIN_BUTTON
364         gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
365 #else
366         modest_number_editor_set_value (MODEST_NUMBER_EDITOR (widget), value);
367 #endif
368 }
369
370 gint
371 modest_number_entry_get_value (GtkWidget *widget)
372 {
373 #ifdef USE_GTK_SPIN_BUTTON
374         return gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
375 #else
376         return modest_number_editor_get_value (MODEST_NUMBER_EDITOR (widget));
377 #endif
378 }
379
380 gboolean 
381 modest_number_entry_is_valid (GtkWidget *widget)
382 {
383 #ifdef USE_GTK_SPIN_BUTTON
384         return TRUE;
385 #else
386         return modest_number_editor_is_valid (MODEST_NUMBER_EDITOR (widget));
387 #endif
388 }
389
390 gboolean
391 modest_is_number_entry (GtkWidget *widget)
392 {
393 #ifdef USE_GTK_SPIN_BUTTON
394         return GTK_IS_SPIN_BUTTON (widget);
395 #else
396         return MODEST_IS_NUMBER_EDITOR (widget);
397 #endif
398 }
399
400 GtkWidget *
401 modest_toolkit_factory_create_file_chooser_dialog (ModestToolkitFactory *self,
402                                                    const gchar *title,
403                                                    GtkWindow *parent,
404                                                    GtkFileChooserAction action)
405 {
406         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_file_chooser_dialog (self, title, parent, action);
407 }
408
409 static GtkWidget *
410 modest_toolkit_factory_create_file_chooser_dialog_default (ModestToolkitFactory *self,
411                                                            const gchar *title,
412                                                            GtkWindow *parent,
413                                                            GtkFileChooserAction action)
414 {
415         GtkWidget *result;
416 #ifdef USE_GTK_FILE_CHOOSER
417         result = gtk_file_chooser_dialog_new (title, parent, action,
418                                               (action == GTK_FILE_CHOOSER_ACTION_OPEN) ? GTK_STOCK_OPEN : GTK_STOCK_SAVE,
419                                               GTK_RESPONSE_OK,
420                                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
421                                               NULL);
422 #else
423         result = hildon_file_chooser_dialog_new (parent, action);
424         gtk_window_set_title ((GtkWindow *) result, title);
425 #endif
426         return result;
427 }
428
429 GtkWidget *
430 modest_toolkit_factory_create_country_selector (ModestToolkitFactory *self)
431 {
432         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_country_selector (self);
433 }
434
435 static GtkWidget *
436 modest_toolkit_factory_create_country_selector_default (ModestToolkitFactory *self)
437 {
438         GtkWidget *result;
439 #ifdef USE_COUNTRY_COMBOBOX
440         result = modest_country_combo_box_new ();
441 #else
442         result = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE, 
443                                                         HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
444 #endif
445         return result;
446 }
447
448 gint
449 modest_country_selector_get_active_country_mcc (GtkWidget *widget)
450 {
451 #ifdef USE_COUNTRY_COMBOBOX
452         return modest_country_combo_box_get_active_country_mcc (MODEST_COUNTRY_COMBO_BOX (widget));
453 #else
454         return modest_country_picker_get_active_country_mcc (MODEST_COUNTRY_PICKER (widget));
455 #endif
456 }
457
458 void
459 modest_country_selector_load_data (GtkWidget *widget)
460 {
461 #ifdef USE_COUNTRY_COMBOBOX
462         modest_country_combo_box_load_data (MODEST_COUNTRY_COMBO_BOX (widget));
463 #else
464         modest_country_picker_load_data (MODEST_COUNTRY_PICKER (widget));
465 #endif
466 }
467
468 gboolean
469 modest_country_selector_set_active_country_locale (GtkWidget *widget)
470 {
471 #ifdef USE_COUNTRY_COMBOBOX
472         return modest_country_combo_box_set_active_country_locale (MODEST_COUNTRY_COMBO_BOX (widget));
473 #else
474         return modest_country_picker_set_active_country_locale (MODEST_COUNTRY_PICKER (widget));
475 #endif
476 }
477
478 GtkWidget *
479 modest_toolkit_factory_create_provider_selector (ModestToolkitFactory *self)
480 {
481         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_provider_selector (self);
482 }
483
484 static GtkWidget *
485 modest_toolkit_factory_create_provider_selector_default (ModestToolkitFactory *self)
486 {
487         GtkWidget *result;
488 #ifdef USE_PROVIDER_COMBOBOX
489         result = GTK_WIDGET (modest_provider_combo_box_new ());
490 #else
491         result = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE, 
492                                                          HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
493 #endif
494         return result;
495 }
496
497 void
498 modest_provider_selector_fill (GtkWidget *widget,
499                                ModestPresets *presets,
500                                gint mcc)
501 {
502 #ifdef USE_PROVIDER_COMBOBOX
503         modest_provider_combo_box_fill (MODEST_PROVIDER_COMBO_BOX (widget),
504                                         presets,
505                                         mcc);
506 #else
507         modest_provider_picker_fill (MODEST_PROVIDER_PICKER (widget),
508                                      presets,
509                                      mcc);
510 #endif
511 }
512
513 gchar *
514 modest_provider_selector_get_active_provider_id (GtkWidget *widget)
515 {
516 #ifdef USE_PROVIDER_COMBOBOX
517         return modest_provider_combo_box_get_active_provider_id (MODEST_PROVIDER_COMBO_BOX (widget));
518 #else
519         return modest_provider_picker_get_active_provider_id (MODEST_PROVIDER_PICKER (widget));
520 #endif
521 }
522
523 gchar *
524 modest_provider_selector_get_active_provider_label (GtkWidget *widget)
525 {
526 #ifdef USE_PROVIDER_COMBOBOX
527         
528         return modest_provider_combo_box_get_active_provider_label (MODEST_PROVIDER_COMBO_BOX (widget));
529 #else
530         GtkWidget *selector;
531         
532         selector = GTK_WIDGET (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (widget)));
533         return g_strdup (hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector)));
534 #endif
535 }
536
537 ModestProviderSelectorIdType
538 modest_provider_selector_get_active_id_type (GtkWidget *widget)
539 {
540         ModestProviderSelectorIdType result;
541 #ifdef USE_PROVIDER_COMBOBOX
542         ModestProviderComboBoxIdType id_type;
543
544         id_type = modest_provider_combo_box_get_active_id_type (MODEST_PROVIDER_COMBO_BOX (widget));
545         switch (id_type) {
546         case MODEST_PROVIDER_COMBO_BOX_ID_PROVIDER:
547                 result = MODEST_PROVIDER_SELECTOR_ID_PROVIDER;
548                 break;
549         case MODEST_PROVIDER_COMBO_BOX_ID_OTHER:
550                 result = MODEST_PROVIDER_SELECTOR_ID_OTHER;
551                 break;
552         case MODEST_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL:
553                 result = MODEST_PROVIDER_SELECTOR_ID_PLUGIN_PROTOCOL;
554                 break;
555         default:
556                 result = MODEST_PROVIDER_SELECTOR_ID_OTHER;
557         }
558         return result;
559 #else
560         ModestProviderPickerIdType id_type;
561
562         id_type = modest_provider_picker_get_active_id_type (MODEST_PROVIDER_PICKER (widget));
563         switch (id_type) {
564         case MODEST_PROVIDER_PICKER_ID_PROVIDER:
565                 result = MODEST_PROVIDER_SELECTOR_ID_PROVIDER;
566                 break;
567         case MODEST_PROVIDER_PICKER_ID_OTHER:
568                 result = MODEST_PROVIDER_SELECTOR_ID_OTHER;
569                 break;
570         case MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL:
571                 result = MODEST_PROVIDER_SELECTOR_ID_PLUGIN_PROTOCOL;
572                 break;
573         default:
574                 result = MODEST_PROVIDER_SELECTOR_ID_OTHER;
575         }
576 #endif
577         return result;
578 }
579
580 void
581 modest_provider_selector_set_others_provider (GtkWidget *self)
582 {
583 #ifdef USE_PROVIDER_COMBOBOX
584         modest_provider_combo_box_set_others_provider (MODEST_PROVIDER_COMBO_BOX (self));
585 #else
586         modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (self));
587 #endif
588 }
589
590 GtkWidget *
591 modest_toolkit_factory_create_servertype_selector (ModestToolkitFactory *self, gboolean filter_providers)
592 {
593         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_servertype_selector (self, filter_providers);
594 }
595
596 static GtkWidget *
597 modest_toolkit_factory_create_servertype_selector_default (ModestToolkitFactory *self, gboolean filter_providers)
598 {
599         GtkWidget *result;
600 #ifdef USE_PROVIDER_COMBOBOX
601         result = GTK_WIDGET (modest_servertype_combo_box_new (filter_providers));
602 #else
603         result = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE, 
604                                                          HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
605                                                          filter_providers));
606 #endif
607         return result;
608 }
609
610 ModestProtocolType
611 modest_servertype_selector_get_active_servertype (GtkWidget *self)
612 {
613 #ifdef USE_SERVERTYPE_COMBOBOX
614         return modest_servertype_combo_box_get_active_servertype (MODEST_SERVERTYPE_COMBO_BOX (self));
615 #else
616         return modest_servertype_picker_get_active_servertype (MODEST_SERVERTYPE_PICKER (self));
617 #endif
618 }
619
620 void
621 modest_servertype_selector_set_active_servertype (GtkWidget *self,
622                                                   ModestProtocolType protocol_type_id)
623 {
624 #ifdef USE_SERVERTYPE_COMBOBOX
625         modest_servertype_combo_box_set_active_servertype (MODEST_SERVERTYPE_COMBO_BOX (self), protocol_type_id);
626 #else
627         modest_servertype_picker_set_active_servertype (MODEST_SERVERTYPE_PICKER (self), protocol_type_id);
628 #endif
629 }
630
631 GtkWidget *
632 modest_toolkit_factory_create_serversecurity_selector (ModestToolkitFactory *self)
633 {
634         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_serversecurity_selector (self);
635 }
636
637 static GtkWidget *
638 modest_toolkit_factory_create_serversecurity_selector_default (ModestToolkitFactory *self)
639 {
640         GtkWidget *result;
641 #ifdef USE_SERVERSECURITY_COMBOBOX
642         result = GTK_WIDGET (modest_serversecurity_combo_box_new ());
643 #else
644         result = GTK_WIDGET (modest_serversecurity_picker_new (MODEST_EDITABLE_SIZE, 
645                                                                HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
646 #endif
647         return result;
648 }
649
650 void
651 modest_serversecurity_selector_fill (GtkWidget *combobox, 
652                                      ModestProtocolType protocol)
653 {
654 #ifdef USE_SERVERSECURITY_COMBOBOX
655         modest_serversecurity_combo_box_fill (MODEST_SERVERSECURITY_COMBO_BOX (combobox),
656                                               protocol);
657 #else
658         modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (combobox),
659                                            protocol);
660 #endif
661 }
662
663 ModestProtocolType
664 modest_serversecurity_selector_get_active_serversecurity (GtkWidget *combobox)
665 {
666 #ifdef USE_SERVERSECURITY_COMBOBOX
667         return modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (combobox));
668 #else
669         return modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (combobox));
670 #endif
671 }
672
673 gboolean
674 modest_serversecurity_selector_set_active_serversecurity (GtkWidget *combobox,
675                                                           ModestProtocolType serversecurity)
676 {
677 #ifdef USE_SERVERSECURITY_COMBOBOX
678         return modest_serversecurity_combo_box_set_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (combobox),
679                                                                           serversecurity);
680 #else
681         return modest_serversecurity_picker_set_active_serversecurity (MODEST_SERVERSECURITY_PICKER (combobox),
682                                                                        serversecurity);
683 #endif
684 }
685
686 gint
687 modest_serversecurity_selector_get_active_serversecurity_port (GtkWidget *combobox)
688 {
689 #ifdef USE_SERVERSECURITY_COMBOBOX
690         return modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (combobox));
691 #else
692         return modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (combobox));
693 #endif
694 }
695
696 GtkWidget *
697 modest_toolkit_factory_create_secureauth_selector (ModestToolkitFactory *self)
698 {
699         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_secureauth_selector (self);
700 }
701
702 static GtkWidget *
703 modest_toolkit_factory_create_secureauth_selector_default (ModestToolkitFactory *self)
704 {
705         GtkWidget *result;
706 #ifdef USE_SECUREAUTH_COMBOBOX
707         result = GTK_WIDGET (modest_secureauth_combo_box_new ());
708 #else
709         result = GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE, 
710                                                            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
711 #endif
712         return result;
713 }
714
715 ModestProtocolType
716 modest_secureauth_selector_get_active_secureauth (GtkWidget *widget)
717 {
718 #ifdef USE_SECUREAUTH_COMBOBOX
719         return modest_secureauth_combo_box_get_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (widget));
720 #else
721         return modest_secureauth_picker_get_active_secureauth (MODEST_SECUREAUTH_PICKER (widget));
722 #endif
723 }
724
725 gboolean
726 modest_secureauth_selector_set_active_secureauth (GtkWidget *widget,
727                                                   ModestProtocolType secureauth)
728 {
729 #ifdef USE_SECUREAUTH_COMBOBOX
730         return modest_secureauth_combo_box_set_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (widget),
731                                                                   secureauth);
732 #else
733         return modest_secureauth_picker_set_active_secureauth (MODEST_SECUREAUTH_PICKER (widget),
734                                                                secureauth);
735 #endif
736 }
737
738 gboolean
739 modest_is_secureauth_selector (GtkWidget *widget)
740 {
741 #ifdef USE_SECUREAUTH_COMBOBOX
742         return MODEST_IS_SECUREAUTH_COMBO_BOX (widget);
743 #else
744         return MODEST_IS_SECUREAUTH_PICKER (widget);
745 #endif
746 }
747
748 GtkWidget *
749 modest_toolkit_factory_create_security_options_view (ModestToolkitFactory *self, 
750                                                      ModestSecurityOptionsType type,
751                                                      gboolean full, 
752                                                      GtkSizeGroup *title_size_group, 
753                                                      GtkSizeGroup *value_size_group)
754 {
755         return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_security_options_view (self, type, full, 
756                                                                                       title_size_group, value_size_group);
757 }
758
759 static GtkWidget *
760 modest_toolkit_factory_create_security_options_view_default (ModestToolkitFactory *self, 
761                                                              ModestSecurityOptionsType type,
762                                                              gboolean full, 
763                                                              GtkSizeGroup *title_size_group, 
764                                                              GtkSizeGroup *value_size_group)
765 {
766         GtkWidget *result;
767 #ifdef USE_GTK_SECURITY_OPTIONS_VIEW
768         result = GTK_WIDGET (modest_gtk_security_options_view_new (type, full, title_size_group, value_size_group));
769 #else
770         result = GTK_WIDGET (modest_maemo_security_options_view_new (type, full, title_size_group, value_size_group));
771 #endif
772         return result;
773 }