2 * empathy-bad-password-dialog.c - Source for EmpathyBadPasswordDialog
3 * Copyright (C) 2010 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "empathy-bad-password-dialog.h"
24 #include <glib/gi18n-lib.h>
26 #define DEBUG_FLAG EMPATHY_DEBUG_SASL
27 #include <libempathy/empathy-debug.h>
28 #include <libempathy/empathy-utils.h>
30 G_DEFINE_TYPE (EmpathyBadPasswordDialog
, empathy_bad_password_dialog
,
31 EMPATHY_TYPE_BASE_PASSWORD_DIALOG
)
45 static guint signals
[LAST_SIGNAL
] = {0};
47 struct _EmpathyBadPasswordDialogPriv
{
52 empathy_bad_password_dialog_get_property (GObject
*object
,
57 EmpathyBadPasswordDialog
*self
= (EmpathyBadPasswordDialog
*) object
;
62 g_value_set_string (value
, self
->priv
->password
);
65 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
71 empathy_bad_password_dialog_set_property (GObject
*object
,
76 EmpathyBadPasswordDialog
*self
= (EmpathyBadPasswordDialog
*) object
;
81 g_assert (self
->priv
->password
== NULL
); /* construct only */
82 self
->priv
->password
= g_value_dup_string (value
);
85 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
91 empathy_bad_password_dialog_finalize (GObject
*object
)
93 EmpathyBadPasswordDialog
*self
= (EmpathyBadPasswordDialog
*) object
;
95 tp_clear_pointer (&self
->priv
->password
, g_free
);
97 G_OBJECT_CLASS (empathy_bad_password_dialog_parent_class
)->finalize (object
);
101 bad_password_dialog_response_cb (GtkDialog
*dialog
,
105 EmpathyBadPasswordDialog
*self
= (EmpathyBadPasswordDialog
*) dialog
;
106 EmpathyBasePasswordDialog
*base
= (EmpathyBasePasswordDialog
*) dialog
;
108 if (response
== GTK_RESPONSE_OK
)
110 const gchar
*password
;
112 password
= gtk_entry_get_text (GTK_ENTRY (base
->entry
));
114 g_signal_emit (self
, signals
[RETRY
], 0, base
->account
, password
);
117 gtk_widget_destroy (GTK_WIDGET (dialog
));
121 empathy_bad_password_dialog_constructed (GObject
*object
)
123 EmpathyBadPasswordDialog
*self
= (EmpathyBadPasswordDialog
*) object
;
124 EmpathyBasePasswordDialog
*base
= (EmpathyBasePasswordDialog
*) object
;
127 G_OBJECT_CLASS (empathy_bad_password_dialog_parent_class
)->constructed (
130 text
= g_strdup_printf (_("Authentification failed for account <b>%s</b>"),
131 tp_account_get_display_name (base
->account
));
132 gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (self
), text
);
135 if (self
->priv
->password
!= NULL
)
137 gtk_entry_set_text (GTK_ENTRY (base
->entry
), self
->priv
->password
);
139 gtk_editable_select_region (GTK_EDITABLE (base
->entry
), 0, -1);
142 gtk_button_set_label (GTK_BUTTON (base
->ok_button
), _("Retry"));
144 g_signal_connect (self
, "response",
145 G_CALLBACK (bad_password_dialog_response_cb
), self
);
149 empathy_bad_password_dialog_init (EmpathyBadPasswordDialog
*self
)
151 self
->priv
= G_TYPE_INSTANCE_GET_PRIVATE (self
,
152 EMPATHY_TYPE_BAD_PASSWORD_DIALOG
, EmpathyBadPasswordDialogPriv
);
156 empathy_bad_password_dialog_class_init (EmpathyBadPasswordDialogClass
*klass
)
159 GObjectClass
*oclass
= G_OBJECT_CLASS (klass
);
161 g_type_class_add_private (klass
, sizeof (EmpathyBadPasswordDialogPriv
));
163 oclass
->set_property
= empathy_bad_password_dialog_set_property
;
164 oclass
->get_property
= empathy_bad_password_dialog_get_property
;
165 oclass
->finalize
= empathy_bad_password_dialog_finalize
;
166 oclass
->constructed
= empathy_bad_password_dialog_constructed
;
168 pspec
= g_param_spec_string ("password", "Password",
169 "The wrong password",
171 G_PARAM_CONSTRUCT_ONLY
| G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
);
172 g_object_class_install_property (oclass
, PROP_PASSWORD
, pspec
);
174 signals
[RETRY
] = g_signal_new ("retry",
175 G_TYPE_FROM_CLASS (klass
),
176 G_SIGNAL_RUN_LAST
, 0,
178 g_cclosure_marshal_generic
,
179 G_TYPE_NONE
, 2, TP_TYPE_ACCOUNT
, G_TYPE_STRING
);
183 empathy_bad_password_dialog_new (TpAccount
*account
,
184 const gchar
*password
)
186 g_return_val_if_fail (TP_IS_ACCOUNT (account
), NULL
);
188 return g_object_new (EMPATHY_TYPE_BAD_PASSWORD_DIALOG
,
190 "password", password
,