latest update
[hildon] / hildon-widgets / hildon-set-password-dialog.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Luc Pionchon <luc.pionchon@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 /* 
26  * @file hildon-set-password-dialog.c
27  *
28  * This file implements API for Hildon Set and Change Password dialog.
29  * 
30  *  Change password dialog:
31  *   @desc: Change Password Dialog is used to change an existing one in
32  *   situtations where the password can be removed. Unselecting the check
33  *   box dims the password fields below it. If the dialog is accepted with
34  *   'OK' while the check box is unselected, a Confirmation Note is played.
35  *   If a Confirmation Note Dialog is accepted with 'Remove', the password
36  *   protection is removed.  
37  * 
38  *  Set password dialog:
39  *   @desc: Set Password Dialog is used to define a password, or change a
40  *   password that cannot be removed.
41  *   @seealso: #HildonGetPasswordDialog
42  *
43  */
44
45 #ifdef HAVE_CONFIG_H
46 #include <config.h>
47 #endif
48
49
50 #include <gdk/gdkkeysyms.h>
51 #include <gtk/gtk.h>
52 #include <glib.h>
53
54 #include <errno.h>
55 #include <string.h>
56 #include <strings.h>
57 #include <unistd.h>
58 #include <stdio.h>
59
60 #include <hildon-widgets/hildon-caption.h>
61 #include <hildon-widgets/gtk-infoprint.h>
62 #include <hildon-widgets/hildon-set-password-dialog.h>
63 #include <hildon-widgets/hildon-note.h>
64 #include <hildon-widgets/hildon-defines.h>
65
66 #include <libintl.h>
67 #define _(String) dgettext(PACKAGE, String)
68
69 static GtkDialogClass *parent_class;
70
71 #define HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(obj)\
72  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
73   HILDON_TYPE_SET_PASSWORD_DIALOG, HildonSetPasswordDialogPrivate));
74
75 typedef struct
76 _HildonSetPasswordDialogPrivate HildonSetPasswordDialogPrivate;
77
78 static void
79 hildon_set_password_dialog_class_init(HildonSetPasswordDialogClass *
80                                       class);
81 static void hildon_set_password_dialog_init(HildonSetPasswordDialog *
82                                             dialog);
83 static void hildon_checbox_toggled(GtkWidget * widget, gpointer data);
84
85 static void
86 hildon_set_password_response_change(GtkDialog * d, gint arg1,
87                                     GtkWindow * parent);
88 static void
89 hildon_set_password_response_set(GtkDialog * d, gint arg1,
90                                  GtkWindow * parent);
91
92 static GObject *
93 hildon_set_password_dialog_constructor(GType type,
94                                        guint n_construct_properties,
95                                        GObjectConstructParam *
96                                        construct_properties);
97 static void hildon_set_password_set_property(GObject * object,
98                                              guint prop_id,
99                                              const GValue * value,
100                                              GParamSpec * pspec);
101 static void hildon_set_password_get_property(GObject * object,
102                                              guint prop_id, GValue * value,
103                                              GParamSpec * pspec);
104
105 /* Private struct */
106
107 struct _HildonSetPasswordDialogPrivate {
108     /* Checkbox tab */
109     GtkWidget *checkboxCaption;
110     GtkWidget *checkbox;
111
112     GtkLabel *domainLabel;
113
114     /* Tab one */
115     GtkWidget *pwd1stEntry;
116     GtkWidget *pwd1stCaption;
117     gchar *pwd1stCaption_string;
118
119     /* Tab two */
120     GtkWidget *pwd2ndEntry;
121     GtkWidget *pwd2ndCaption;
122     gchar *pwd2ndCaption_string;
123
124     /* OK/Cancel buttons */
125     GtkWidget *okButton;
126     GtkWidget *cancelButton;
127
128     gboolean protection;
129
130 };
131
132 enum {
133     PROP_NONE = 0,
134     PROP_DOMAIN,
135     PROP_PASSWORD,
136     PROP_HILDON_PASSWORD_DIALOG
137 };
138
139 /* Private functions */
140 static void
141 hildon_set_password_set_property(GObject * object,
142                                  guint prop_id,
143                                  const GValue * value, GParamSpec * pspec)
144 {
145     HildonSetPasswordDialog *dialog = HILDON_SET_PASSWORD_DIALOG(object);
146     HildonSetPasswordDialogPrivate *priv;
147
148     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
149     
150     switch (prop_id) {
151     case PROP_DOMAIN:
152         gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
153         break;
154     case PROP_PASSWORD:
155         gtk_entry_set_text(GTK_ENTRY(priv->pwd1stEntry), g_value_get_string(value));
156         break;
157     case PROP_HILDON_PASSWORD_DIALOG:
158         priv->protection = g_value_get_boolean(value);
159         break;
160     default:
161         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
162         break;
163     }
164 }
165
166 static void
167 hildon_set_password_get_property(GObject * object,
168                                  guint prop_id,
169                                  GValue * value, GParamSpec * pspec)
170 {
171     HildonSetPasswordDialog *dialog = HILDON_SET_PASSWORD_DIALOG(object);
172     HildonSetPasswordDialogPrivate *priv;
173     const gchar *string;
174
175     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
176     
177     switch (prop_id) {
178     case PROP_DOMAIN:
179         string = gtk_label_get_text(priv->domainLabel);
180         g_value_set_string(value, string);
181     case PROP_PASSWORD:
182         string = gtk_entry_get_text(GTK_ENTRY(priv->pwd1stEntry));
183         g_value_set_string(value, string);
184         break;
185     case PROP_HILDON_PASSWORD_DIALOG:
186         g_value_set_boolean(value, g_value_get_boolean(value));
187         break;
188     default:
189         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
190         break;
191     }
192 }
193
194 static GObject *
195 hildon_set_password_dialog_constructor(GType type,
196                                        guint n_construct_properties,
197                                        GObjectConstructParam *
198                                        construct_properties)
199 {
200     GObject *dialog;
201     GObjectClass *parent_class;
202     HildonSetPasswordDialogPrivate *priv;
203     GtkSizeGroup *group;
204
205     parent_class = G_OBJECT_CLASS(g_type_class_peek_parent
206                                   (g_type_class_peek(type)));
207     dialog = parent_class->constructor(type, n_construct_properties,
208                                        construct_properties);
209
210     gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
211
212     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
213
214     priv->checkbox = NULL;
215
216     group = GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
217
218     gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
219
220     priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
221
222     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
223                        GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
224
225     gtk_widget_show(GTK_WIDGET(priv->domainLabel));
226
227
228     if (priv->protection == TRUE) {
229         /* create checkbox */
230         priv->pwd1stCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_PASSWORD);
231         priv->pwd2ndCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_VERIFY_PASSWORD);
232
233         priv->checkbox = gtk_check_button_new();
234
235         gtk_widget_show(priv->checkbox);
236
237         priv->checkboxCaption = hildon_caption_new
238           (group,
239            _(HILDON_SET_MODIFY_PASSWORD_DIALOG_LABEL),
240            priv->checkbox,
241            NULL, HILDON_CAPTION_OPTIONAL);
242         hildon_caption_set_separator(HILDON_CAPTION(priv->checkboxCaption), "");
243
244         gtk_signal_connect(GTK_OBJECT(priv->checkbox), "toggled",
245                            G_CALLBACK(hildon_checbox_toggled), dialog);
246         
247         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
248                            priv->checkboxCaption, TRUE, TRUE, 0);
249         gtk_widget_show(priv->checkboxCaption);
250
251         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbox),
252                                      TRUE);
253
254     } else {
255         priv->pwd1stCaption_string = _(HILDON_SET_PASSWORD_DIALOG_PASSWORD);
256         priv->pwd2ndCaption_string = _(HILDON_SET_PASSWORD_DIALOG_VERIFY_PASSWORD);
257     }
258
259
260     /* create tab1 */
261     priv->pwd1stEntry = gtk_entry_new();
262     gtk_widget_show(priv->pwd1stEntry);
263
264     priv->pwd1stCaption = hildon_caption_new(group,
265                                         priv->pwd1stCaption_string,
266                                         priv->pwd1stEntry,
267                                         NULL, HILDON_CAPTION_OPTIONAL);
268     hildon_caption_set_separator(HILDON_CAPTION(priv->pwd1stCaption), "");
269
270     gtk_entry_set_visibility(GTK_ENTRY(priv->pwd1stEntry), FALSE);
271
272     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
273                        priv->pwd1stCaption, TRUE, TRUE, 0);
274     gtk_widget_show(priv->pwd1stCaption);
275
276     /* create tab2 */
277     priv->pwd2ndEntry = gtk_entry_new();
278     gtk_widget_show(priv->pwd2ndEntry);
279
280     priv->pwd2ndCaption = hildon_caption_new(group,
281                                         priv->pwd2ndCaption_string,
282                                         priv->pwd2ndEntry,
283                                         NULL, HILDON_CAPTION_OPTIONAL);
284     hildon_caption_set_separator(HILDON_CAPTION(priv->pwd2ndCaption), "");
285
286     gtk_entry_set_visibility(GTK_ENTRY(priv->pwd2ndEntry), FALSE);
287
288     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
289                        priv->pwd2ndCaption, TRUE, TRUE, 0);
290
291     gtk_widget_show(priv->pwd2ndCaption);
292
293     gtk_window_set_title(GTK_WINDOW(dialog),
294                          _(priv->protection
295                            ? HILDON_SET_MODIFY_PASSWORD_DIALOG_TITLE
296                            : HILDON_SET_PASSWORD_DIALOG_TITLE));
297
298     /* Create the OK/CANCEL buttons */
299     priv->okButton = gtk_dialog_add_button
300       (GTK_DIALOG(dialog),  _(priv->protection
301                               ? HILDON_SET_MODIFY_PASSWORD_DIALOG_OK
302                               : HILDON_SET_PASSWORD_DIALOG_OK),
303        GTK_RESPONSE_OK);
304     priv->cancelButton = gtk_dialog_add_button
305       (GTK_DIALOG(dialog), _(priv->protection
306                              ? HILDON_SET_MODIFY_PASSWORD_DIALOG_CANCEL
307                              : HILDON_SET_PASSWORD_DIALOG_CANCEL),
308        GTK_RESPONSE_CANCEL);
309     
310     /*    gtk_window_resize(GTK_WINDOW(dialog), 370, 110); */
311     /*    remove now, pixel perfection can address these majik thingys */
312
313     gtk_widget_show(priv->okButton);
314     gtk_widget_show(priv->cancelButton);
315
316
317     return dialog;
318 }
319
320 static void
321 hildon_set_password_dialog_class_init(HildonSetPasswordDialogClass * class)
322 {
323
324
325     GObjectClass *object_class = G_OBJECT_CLASS(class);
326
327     parent_class = g_type_class_peek_parent(class);
328
329     object_class->set_property = hildon_set_password_set_property;
330     object_class->get_property = hildon_set_password_get_property;
331     object_class->constructor = hildon_set_password_dialog_constructor;
332
333
334     g_object_class_install_property(object_class, 
335                      PROP_DOMAIN, 
336                      g_param_spec_string ("domain",
337                                           "Domain",
338                                           "Set Domain (content) for domain label.",
339                                           NULL,
340                                           G_PARAM_READWRITE));
341
342     g_object_class_install_property(object_class, 
343                      PROP_HILDON_PASSWORD_DIALOG, 
344                      g_param_spec_boolean ("modify_protection",
345                                           "Password type",
346                                           "Set type to dialog",
347                                           TRUE, 
348                                           G_PARAM_CONSTRUCT_ONLY |
349                                           G_PARAM_READWRITE));
350
351     g_object_class_install_property(object_class, 
352                      PROP_PASSWORD, 
353                      g_param_spec_string ("password",
354                                           "Password content",
355                                           "Set content to dialog",
356                                           "DEFAULT",
357                                           G_PARAM_READWRITE));
358
359     g_type_class_add_private(class,
360                              sizeof(HildonSetPasswordDialogPrivate));
361 }
362
363
364 static void
365 hildon_set_password_dialog_init(HildonSetPasswordDialog * dialog)
366 {
367     HildonSetPasswordDialogPrivate *priv;
368
369     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
370
371     priv->protection = FALSE;
372 }
373
374 static void
375 hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
376                                     GtkWindow * parent)
377 {
378     GtkEntry *pwd1stEntry;
379     GtkEntry *pwd2ndEntry;
380     gchar *text1;
381     gchar *text2;
382
383     HildonNote *note;
384     gint i;
385
386     HildonSetPasswordDialogPrivate *priv;
387
388     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
389
390     pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
391                             (GTK_BIN(priv->pwd1stCaption)));
392
393     pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
394                             (GTK_BIN(priv->pwd2ndCaption)));
395
396     text1 = GTK_ENTRY(pwd1stEntry)->text;
397     text2 = GTK_ENTRY(pwd2ndEntry)->text;
398     if (arg1 == GTK_RESPONSE_OK){
399       if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbox))){
400         if(strcmp(text1, "" ) != 0){
401           if(strcmp (text1, text2) == 0){
402             priv->protection = TRUE;
403           } else if(strcmp(text2, "" ) == 0){
404             g_signal_stop_emission_by_name(G_OBJECT(dialog),
405                                            "response");
406             gtk_infoprint (NULL,
407                            _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
408             gtk_widget_grab_focus(GTK_WIDGET(pwd2ndEntry));
409           } else{
410             g_signal_stop_emission_by_name(G_OBJECT(dialog),
411                                            "response");
412             gtk_entry_set_text(pwd1stEntry, "");
413             gtk_entry_set_text(pwd2ndEntry, "");
414             gtk_infoprint (NULL,
415                            _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
416             gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
417           }
418         } else {
419           g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
420           if (strcmp(text2, "") == 0) {
421             gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
422           } else {
423             gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
424             gtk_entry_set_text(pwd2ndEntry, "");
425           }
426           gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
427         }
428       } else{
429         note = HILDON_NOTE(hildon_note_new_confirmation
430                            (GTK_WINDOW(dialog),
431                             _(HILDON_SET_PASSWORD_DIALOG_REMOVE_PROTECTION
432                               )));
433       
434         hildon_note_set_button_texts
435           (HILDON_NOTE(note),
436            _(HILDON_REMOVE_PROTECTION_CONFIRMATION_REMOVE), 
437            _(HILDON_REMOVE_PROTECTION_CONFIRMATION_CANCEL));
438         
439         i = gtk_dialog_run(GTK_DIALOG(note));
440         
441         gtk_widget_destroy(GTK_WIDGET(note));
442         
443         if (i == GTK_RESPONSE_OK)
444           priv->protection = FALSE;
445         else {
446           priv->protection = TRUE;
447           g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
448         }
449       }
450
451     } else {
452       priv->protection = TRUE;
453     }
454 }
455
456 static void
457 hildon_set_password_response_set(GtkDialog * dialog, gint arg1,
458                                  GtkWindow * parent)
459 {
460     GtkEntry *pwd1stEntry;
461     GtkEntry *pwd2ndEntry;
462     gchar *text1;
463     gchar *text2;
464
465     HildonSetPasswordDialogPrivate *priv;
466
467     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
468
469     pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
470                             (GTK_BIN(priv->pwd1stCaption)));
471
472     pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
473                             (GTK_BIN(priv->pwd2ndCaption)));
474
475     text1 = GTK_ENTRY(pwd1stEntry)->text;
476     text2 = GTK_ENTRY(pwd2ndEntry)->text;
477
478     if (arg1 == GTK_RESPONSE_OK) {
479         if (strcmp (text1, "") != 0) {
480             if (strcmp (text1, text2) == 0) {
481                 priv->protection = TRUE;
482             } else if (strcmp (text2, "") == 0) {
483                 g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
484                 gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
485                 gtk_widget_grab_focus (GTK_WIDGET (priv->pwd2ndEntry));
486             } else {
487                 g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
488                 gtk_entry_set_text(pwd1stEntry, "");
489                 gtk_entry_set_text(pwd2ndEntry, "");
490                 gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH ));
491                 gtk_widget_grab_focus(GTK_WIDGET(priv->pwd1stEntry));
492             }
493         } else {
494             g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
495           if (strcmp(text2, "") == 0) {
496             gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
497           } else {
498             gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
499             gtk_entry_set_text(pwd2ndEntry, "");
500           }
501           gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
502         }
503     } else { 
504         priv->protection = FALSE;
505     }             
506 }
507
508 static void hildon_checbox_toggled(GtkWidget * widget, gpointer data)
509 {
510     HildonSetPasswordDialog *dialog;
511     HildonSetPasswordDialogPrivate *priv;
512
513     dialog = HILDON_SET_PASSWORD_DIALOG(data);
514     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
515
516     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
517         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd1stEntry), TRUE);
518         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd2ndEntry), TRUE);
519     } else {
520         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd1stEntry), FALSE);
521         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd2ndEntry), FALSE);
522     }
523 }
524
525 /* Public functions */
526
527 /**
528  * hildon_set_password_dialog_get_type:
529  *
530  * Returns GType for HildonPasswordDialog as produced by
531  * g_type_register_static().
532  *
533  * Return value: HildonSetPasswordDialog type
534  **/
535 GType hildon_set_password_dialog_get_type()
536 {
537     static GType dialog_type = 0;
538
539     if (!dialog_type) {
540         static const GTypeInfo dialog_info = {
541             sizeof(HildonSetPasswordDialogClass),
542             NULL,       /* base_init */
543             NULL,       /* base_finalize */
544             (GClassInitFunc) hildon_set_password_dialog_class_init,
545             NULL,       /* class_finalize */
546             NULL,       /* class_data */
547             sizeof(HildonSetPasswordDialog),
548             0,  /* n_preallocs */
549             (GInstanceInitFunc) hildon_set_password_dialog_init
550         };
551
552         dialog_type = g_type_register_static(GTK_TYPE_DIALOG,
553                                              "HildonSetPasswordDialog",
554                                              &dialog_info, 0);
555     }
556     return dialog_type;
557 }
558
559 /**
560  * hildon_set_password_dialog_new:
561  * @parent: parent window; can be NULL
562  * @modify_protection: TRUE creates a new change password dialog and FALSE
563  *                     creates a new set password dialog 
564  * 
565  * Construct a new HildonSetPasswordDialog.
566  *
567  * Return value: a new #GtkWidget of type HildonSetPasswordDialog
568  **/
569
570 GtkWidget *hildon_set_password_dialog_new(GtkWindow * parent,
571                                           gboolean modify_protection)
572 {
573     GtkWidget *dialog = g_object_new
574         (HILDON_TYPE_SET_PASSWORD_DIALOG, "modify_protection",
575          modify_protection, NULL);
576
577     if (modify_protection == TRUE) {
578         g_signal_connect(G_OBJECT(dialog), "response",
579                          G_CALLBACK(hildon_set_password_response_change),
580                          parent);
581     } else {
582         g_signal_connect(G_OBJECT(dialog), "response",
583                          G_CALLBACK(hildon_set_password_response_set),
584                          parent);
585     }
586     if (parent != NULL) {
587         gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
588     }
589
590     return dialog;
591 }
592
593 /**
594  * hildon_set_password_dialog_new_with_default:
595  * @parent: parent window; can be NULL
596  * @password: a default password to be shown in password field.
597  * @modify_protection: TRUE creates a new change password dialog and FALSE
598  *                     creates a new set password dialog 
599  * 
600  * Same as #hildon_set_password_dialog_new, but with a default password
601  * in password field.
602  *
603  * Return value: a new #GtkWidget of type HildonSetPasswordDialog
604  **/
605
606 GtkWidget *hildon_set_password_dialog_new_with_default
607                                          (GtkWindow *parent,
608                                           gchar *password,
609                                           gboolean modify_protection)
610 {
611     GtkWidget *dialog;
612
613     dialog = hildon_set_password_dialog_new(parent, 
614                                             modify_protection);
615     if(password != NULL)
616         g_object_set(G_OBJECT(dialog), "password", password, NULL);
617     
618     return dialog;
619 }
620
621 /**
622  * hildon_set_password_dialog_get_password:
623  * @dialog: pointer to HildonSetPasswordDialog
624  * 
625  * Returns current password.
626  *
627  * Return value: changed password ( if the dialog is successfully 
628  * accepted with 'OK' ( and when the check box is 'ON' ( in Change Password
629  * Dialog ))
630  **/
631 const gchar
632     *hildon_set_password_dialog_get_password(HildonSetPasswordDialog *
633                                              dialog)
634 {
635     HildonSetPasswordDialogPrivate *priv;
636
637     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
638
639     return GTK_ENTRY(priv->pwd1stEntry)->text;
640 }
641
642 /**
643  * hildon_set_password_dialog_get_protected:
644  * @dialog: pointer to HildonSetPasswordDialog
645  * 
646  * Returns protection mode.
647  *
648  * Return value: password protection mode ( TRUE when the protection is
649  *               'ON' and FALSE when the protection is 'OFF' )
650  **/
651 gboolean
652 hildon_set_password_dialog_get_protected(HildonSetPasswordDialog * dialog)
653 {
654     HildonSetPasswordDialogPrivate *priv;
655
656     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
657
658     return priv->protection;
659 }
660
661 /**
662  * hildon_set_password_dialog_set_domain(GtkWidget *dialog, 
663  * @dialog: the dialog
664  * @domain: the domain or some other descriptive text to be set.
665  * 
666  * sets the optional descriptive text
667  */
668
669 void hildon_set_password_dialog_set_domain(HildonSetPasswordDialog *dialog, 
670                                                 gchar *domain)
671 {
672   HildonSetPasswordDialogPrivate *priv =
673     HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
674   gtk_label_set_text(priv->domainLabel, domain);
675   
676 }