Imported Upstream version 0.7.git7cc1d84
Guido Guenther
15 years ago
0 | 2008-06-09 Colin Walters <walters@verbum.org> | |
1 | ||
2 | Bug 534867: should use g_timeout_add_seconds | |
3 | ||
4 | * src/krb5-auth-dialog.c: Save power with | |
5 | g_timeout_add_seconds. | |
6 | Patch from from Guido Günther. | |
7 | ||
8 | 2008-06-09 Colin Walters <walters@verbum.org> | |
9 | ||
10 | Bug 534736: make i18n work | |
11 | ||
12 | * src/krb5-auth-dialog.c: Set up i18n correctly. | |
13 | * src/Makefile.am: Pass in LOCALEDIR. | |
14 | Patch from from Guido Günther. | |
15 | ||
16 | 2008-06-09 Colin Walters <walters@verbum.org> | |
17 | ||
18 | Bug 534620: password field focus | |
19 | ||
20 | * src/krb5-auth-dialog.c: Be sure we focus the | |
21 | password field every time. | |
22 | Patch from from Guido Günther. | |
23 | ||
24 | 2008-06-09 Colin Walters <walters@verbum.org> | |
25 | ||
26 | Bug 534515: cleanups | |
27 | ||
28 | * configure.in: Look for dbus-glib and not libgnome. | |
29 | Patch from from Guido Günther. | |
30 | ||
31 | 2008-06-09 Colin Walters <walters@verbum.org> | |
32 | ||
33 | Bug 534515: cleanups | |
34 | ||
35 | * src/krb5-auth-dialog.c: Cleaner use of | |
36 | gboolean. Patch from from Guido Günther. | |
37 | ||
38 | 2008-06-09 Colin Walters <walters@verbum.org> | |
39 | ||
40 | Bug 534515: cleanups | |
41 | ||
42 | * src/krb5-auth-dialog.c: Use GOption instead of | |
43 | libgnome. Patch from Guido Günther. | |
44 | ||
45 | 2008-06-09 Colin Walters <walters@verbum.org> | |
46 | ||
47 | Bug 529220: set dialog icon | |
48 | ||
49 | * src/krb5-auth-dialog.c: Set an icon so we | |
50 | look nicer in the window list. Patch from | |
51 | Guido Günther. | |
52 | ||
0 | 53 | 2008-03-22 Colin Walters <walters@verbum.org> |
1 | 54 | |
2 | 55 | * src/krb5-auth-dialog.c: Grab a name on the |
42 | 42 | EXTRA_DIST = \ |
43 | 43 | $(glade_DATA) \ |
44 | 44 | $(autostart_in_files) \ |
45 | $(schema_SOURCES) \ | |
46 | 45 | krb5-auth-dialog.1.in |
47 | 46 | |
48 | schemadir = $(sysconfdir)/gconf/schemas | |
49 | schema_SOURCES = $(PACKAGE).schemas.in | |
50 | schema_DATA = $(PACKAGE).schemas | |
51 | ||
52 | 47 | DISTCLEANFILES = krb5-auth-dialog.desktop |
53 | CLEANFILES = $(schema_DATA) | |
54 | ||
55 | %.schemas: $(srcdir)/%.schemas.in | |
56 | sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::MINIMUM_LIFETIME::,$(minimum_lifetime)," < $< > $@ | |
57 |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
27 | 27 | #include "krb5-auth-notify.h" |
28 | 28 | #endif |
29 | 29 | |
30 | #define NOTIFY_SECONDS 300 | |
30 | 31 | |
31 | 32 | /* update the tray icon's tooltip and icon */ |
32 | int | |
33 | int | |
33 | 34 | ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) |
34 | 35 | { |
35 | 36 | gchar* expiry_text; |
36 | int interval = expiry - time(0); | |
37 | int now = time(0); | |
38 | int remaining = expiry - now; | |
39 | static int last_warn = 0; | |
37 | 40 | static gboolean expiry_notified = FALSE; |
38 | 41 | |
39 | if (interval > 0) { | |
42 | if (remaining > 0) { | |
40 | 43 | int hours, minutes; |
41 | if (interval >= 3600) { | |
42 | hours = interval / 3600; | |
43 | minutes = (interval % 3600) / 60; | |
44 | if (remaining >= 3600) { | |
45 | hours = remaining / 3600; | |
46 | minutes = (remaining % 3600) / 60; | |
44 | 47 | expiry_text = g_strdup_printf (_("Your credentials expire in %.2d:%.2dh"), hours, minutes); |
45 | 48 | } else { |
46 | minutes = interval / 60; | |
49 | minutes = remaining / 60; | |
47 | 50 | expiry_text = g_strdup_printf (ngettext( |
48 | 51 | "Your credentials expire in %d minute", |
49 | 52 | "Your credentials expire in %d minutes", |
50 | 53 | minutes), minutes); |
51 | 54 | } |
52 | gtk_status_icon_set_from_icon_name (applet->tray_icon, applet->icons[1]); | |
55 | gtk_status_icon_set_from_icon_name (applet->tray_icon, applet->icons[1]); | |
53 | 56 | #ifdef HAVE_LIBNOTIFY |
54 | 57 | if (expiry_notified) { |
55 | 58 | ka_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, |
56 | 59 | _("Network credentials valid"), |
57 | 60 | _("Your Kerberos credentials have been refreshed."), NULL); |
58 | 61 | expiry_notified = FALSE; |
62 | } else if (remaining < applet->pw_prompt_secs && (now - last_warn) > NOTIFY_SECONDS) { | |
63 | ka_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, | |
64 | _("Network credentials expiring"), | |
65 | expiry_text, NULL); | |
66 | last_warn = now; | |
59 | 67 | } |
60 | 68 | #endif |
61 | 69 | } else { |
62 | 70 | expiry_text = g_strdup (_("Your credentials have expired")); |
63 | gtk_status_icon_set_from_icon_name (applet->tray_icon, applet->icons[0]); | |
71 | gtk_status_icon_set_from_icon_name (applet->tray_icon, applet->icons[0]); | |
64 | 72 | #ifdef HAVE_LIBNOTIFY |
65 | 73 | if (!expiry_notified) { |
66 | 74 | ka_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, |
67 | 75 | _("Network credentials expired"), |
68 | 76 | _("Your Kerberos credentails have expired."), NULL); |
69 | 77 | expiry_notified = TRUE; |
78 | last_warn = 0; | |
70 | 79 | } |
71 | 80 | #endif |
72 | 81 | } |
73 | 82 | |
74 | gtk_status_icon_set_tooltip(applet->tray_icon, expiry_text); | |
75 | g_free(expiry_text); | |
83 | gtk_status_icon_set_tooltip (applet->tray_icon, expiry_text); | |
84 | g_free (expiry_text); | |
76 | 85 | return 0; |
77 | 86 | } |
78 | 87 | |
79 | 88 | |
80 | static void | |
89 | static void | |
81 | 90 | ka_menu_add_separator_item (GtkWidget* menu) |
82 | 91 | { |
83 | 92 | GtkWidget* menu_item; |
89 | 98 | |
90 | 99 | |
91 | 100 | /* Free all resources and quit */ |
92 | static void | |
101 | static void | |
93 | 102 | ka_quit_applet (GtkMenuItem* menuitem, gpointer user_data) |
94 | 103 | { |
95 | 104 | Krb5AuthApplet* applet = (Krb5AuthApplet*) user_data; |
96 | ||
97 | g_free(applet->principal); | |
98 | g_free(applet); | |
99 | gtk_main_quit(); | |
100 | } | |
101 | ||
102 | ||
103 | static void | |
105 | ||
106 | g_free (applet->principal); | |
107 | g_free (applet); | |
108 | gtk_main_quit (); | |
109 | } | |
110 | ||
111 | ||
112 | static void | |
104 | 113 | ka_about_dialog (GtkMenuItem* menuitem, gpointer user_data) |
105 | 114 | { |
106 | 115 | gchar* authors[] = { "Christopher Aillon <caillon@redhat.com>", |
107 | 116 | "Colin Walters <walters@verbum.org>", |
108 | "Guido Günther <agx@sigxpcu.org>", | |
117 | "Guido Günther <agx@sigxpcu.org>", | |
109 | 118 | NULL }; |
110 | 119 | gtk_show_about_dialog (NULL, |
111 | 120 | "authors", authors, |
132 | 141 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); |
133 | 142 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
134 | 143 | |
135 | ka_menu_add_separator_item(menu); | |
144 | ka_menu_add_separator_item (menu); | |
136 | 145 | |
137 | 146 | /* About item */ |
138 | 147 | menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About")); |
141 | 150 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); |
142 | 151 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
143 | 152 | |
144 | ka_menu_add_separator_item(menu); | |
153 | ka_menu_add_separator_item (menu); | |
145 | 154 | |
146 | 155 | /* Quit */ |
147 | 156 | menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Quit")); |
157 | 166 | |
158 | 167 | |
159 | 168 | static void |
160 | ka_tray_icon_on_menu (GtkStatusIcon* status_icon, guint button, | |
169 | ka_tray_icon_on_menu (GtkStatusIcon* status_icon, guint button, | |
161 | 170 | guint activate_time, gpointer user_data) |
162 | 171 | { |
163 | 172 | Krb5AuthApplet* applet = (Krb5AuthApplet*) user_data; |
164 | ||
173 | ||
165 | 174 | KA_DEBUG("Trayicon right clicked: %d", applet->pw_prompt_secs); |
166 | gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL, | |
167 | gtk_status_icon_position_menu, applet->tray_icon, | |
175 | gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL, | |
176 | gtk_status_icon_position_menu, applet->tray_icon, | |
168 | 177 | button, activate_time); |
169 | 178 | } |
170 | 179 | |
192 | 201 | } |
193 | 202 | |
194 | 203 | |
195 | static GtkStatusIcon* | |
204 | static GtkStatusIcon* | |
196 | 205 | ka_create_tray_icon (Krb5AuthApplet* applet) |
197 | 206 | { |
198 | GtkStatusIcon* tray_icon; | |
199 | ||
200 | tray_icon = gtk_status_icon_new(); | |
201 | g_signal_connect(G_OBJECT(tray_icon), "activate", | |
202 | G_CALLBACK(ka_tray_icon_on_click), applet); | |
203 | g_signal_connect(G_OBJECT(tray_icon), | |
204 | "popup-menu", | |
205 | G_CALLBACK(ka_tray_icon_on_menu), applet); | |
207 | GtkStatusIcon* tray_icon; | |
208 | ||
209 | tray_icon = gtk_status_icon_new (); | |
210 | g_signal_connect (G_OBJECT(tray_icon), "activate", | |
211 | G_CALLBACK(ka_tray_icon_on_click), applet); | |
212 | g_signal_connect (G_OBJECT(tray_icon), | |
213 | "popup-menu", | |
214 | G_CALLBACK(ka_tray_icon_on_menu), applet); | |
206 | 215 | gtk_status_icon_set_from_icon_name (tray_icon, applet->icons[0]); |
207 | 216 | gtk_status_icon_set_tooltip (tray_icon, PACKAGE); |
208 | 217 | return tray_icon; |
209 | 218 | } |
210 | 219 | |
211 | 220 | |
212 | static void | |
213 | ka_err_dialog (const char* err) | |
214 | { | |
215 | GtkWidget* dialog = gtk_message_dialog_new (NULL, | |
216 | GTK_DIALOG_DESTROY_WITH_PARENT, | |
217 | GTK_MESSAGE_ERROR, | |
218 | GTK_BUTTONS_CLOSE, | |
219 | err); | |
220 | gtk_dialog_run (GTK_DIALOG (dialog)); | |
221 | gtk_widget_destroy (dialog); | |
222 | } | |
223 | ||
224 | ||
225 | 221 | int |
226 | 222 | ka_setup_icons (Krb5AuthApplet* applet) |
227 | 223 | { |
232 | 228 | |
233 | 229 | |
234 | 230 | /* create the tray icon applet */ |
235 | Krb5AuthApplet* | |
231 | Krb5AuthApplet* | |
236 | 232 | ka_create_applet() |
237 | 233 | { |
238 | const char* err; | |
239 | Krb5AuthApplet* applet = g_malloc0(sizeof(Krb5AuthApplet)); | |
240 | ||
241 | if(!(ka_setup_icons(applet))) { | |
242 | err = _("Failure to setup icons"); | |
243 | goto out; | |
244 | } | |
245 | ||
246 | if(!(applet->tray_icon = ka_create_tray_icon(applet))) { | |
247 | err = _("Failure to create tray icon"); | |
248 | goto out; | |
249 | } | |
250 | // FIXME: handle with signal | |
234 | Krb5AuthApplet* applet = g_malloc0 (sizeof(Krb5AuthApplet)); | |
235 | ||
236 | if (!(ka_setup_icons (applet))) | |
237 | g_error ("Failure to setup icons"); | |
238 | if (!(applet->tray_icon = ka_create_tray_icon (applet))) | |
239 | g_error ("Failure to create tray icon"); | |
240 | if (!(applet->context_menu = ka_create_context_menu (applet))) | |
241 | g_error ("Failure to create context menu"); | |
251 | 242 | ka_show_tray_icon (applet); |
252 | 243 | |
253 | if(!(applet->context_menu = ka_create_context_menu(applet))) { | |
254 | err = _("Failure to create context menu"); | |
255 | goto out; | |
256 | } | |
257 | ||
258 | 244 | return applet; |
259 | out: | |
260 | ka_err_dialog(err); | |
261 | g_free(applet); | |
262 | return NULL; | |
263 | } | |
264 | ||
245 | } | |
246 |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
0 | .TH krb5-auth-dialog 2005/11/02 "GNOME" "System Administrator's Manual" | |
0 | .TH krb5-auth-dialog 1 2005/11/02 "GNOME" "System Administrator's Manual" | |
1 | 1 | |
2 | 2 | .SH NAME |
3 | 3 | krb5-auth-dialog \- Kerberos 5 credential checking |
211 | 211 | |
212 | 212 | /* Check for things we have to do while the password dialog is open */ |
213 | 213 | static gboolean |
214 | krb5_auth_dialog_do_updates(gpointer data) | |
214 | krb5_auth_dialog_do_updates (gpointer data) | |
215 | 215 | { |
216 | 216 | Krb5AuthApplet* applet = (Krb5AuthApplet*)data; |
217 | 217 | gboolean refreshable; |
327 | 327 | errcode = KRB5_LIBOS_CANTREADPWD; |
328 | 328 | |
329 | 329 | krb5_auth_dialog_setup (applet, (gchar *) prompts[i].prompt, prompts[i].hidden); |
330 | entry = glade_xml_get_widget(applet->pw_xml, "krb5_entry"); | |
331 | gtk_widget_grab_focus(entry); | |
330 | entry = glade_xml_get_widget (applet->pw_xml, "krb5_entry"); | |
331 | gtk_widget_grab_focus (entry); | |
332 | 332 | |
333 | 333 | source_id = g_timeout_add_seconds (5, (GSourceFunc)krb5_auth_dialog_do_updates, applet); |
334 | 334 | response = gtk_dialog_run (GTK_DIALOG (applet->pw_dialog)); |
403 | 403 | Krb5AuthApplet* applet = (Krb5AuthApplet*) data; |
404 | 404 | |
405 | 405 | KA_DEBUG("Checking expiry: %d", applet->pw_prompt_secs); |
406 | if (credentials_expiring_real (applet, &renewable) && is_online) { | |
406 | if (credentials_expiring_real (applet, &renewable) && is_online && !applet->show_trayicon) { | |
407 | 407 | give_up = canceled && (creds_expiry == canceled_creds_expiry); |
408 | 408 | if (!give_up) { |
409 | 409 | do { |
613 | 613 | } |
614 | 614 | |
615 | 615 | |
616 | static void | |
616 | static void | |
617 | 617 | ka_error_dialog(int err) |
618 | 618 | { |
619 | 619 | const char* msg = error_message(err); |
620 | 620 | GtkWidget *dialog = gtk_message_dialog_new (NULL, |
621 | GTK_DIALOG_DESTROY_WITH_PARENT, | |
622 | GTK_MESSAGE_ERROR, | |
623 | GTK_BUTTONS_CLOSE, | |
624 | _("Couldn't acquire kerberos ticket: '%s'"), msg); | |
625 | gtk_dialog_run (GTK_DIALOG (dialog)); | |
621 | GTK_DIALOG_DESTROY_WITH_PARENT, | |
622 | GTK_MESSAGE_ERROR, | |
623 | GTK_BUTTONS_CLOSE, | |
624 | _("Couldn't acquire kerberos ticket: '%s'"), msg); | |
625 | gtk_dialog_run (GTK_DIALOG (dialog)); | |
626 | 626 | gtk_widget_destroy (dialog); |
627 | 627 | } |
628 | 628 | |
644 | 644 | break; |
645 | 645 | case 0: /* success */ |
646 | 646 | case KRB5_LIBOS_CANTREADPWD: /* canceled */ |
647 | retry = FALSE; | |
647 | retry = FALSE; | |
648 | 648 | break; |
649 | 649 | case KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN: |
650 | 650 | default: |
669 | 669 | if (!strcmp(name, "krb5_entry")) { |
670 | 670 | entry = gtk_secure_entry_new (); |
671 | 671 | gtk_secure_entry_set_activates_default(GTK_SECURE_ENTRY(entry), TRUE); |
672 | gtk_widget_set(entry, "invisible-char", 0x25cf, NULL); | |
672 | 673 | gtk_widget_show (entry); |
673 | 674 | } else { |
674 | 675 | g_warning("Don't know anything about widget %s", name); |
725 | 726 | g_error_free (error); |
726 | 727 | return 1; |
727 | 728 | } |
728 | textdomain(PACKAGE); | |
729 | bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
730 | bindtextdomain(PACKAGE, LOCALE_DIR); | |
729 | textdomain (PACKAGE); | |
730 | bind_textdomain_codeset (PACKAGE, "UTF-8"); | |
731 | bindtextdomain (PACKAGE, LOCALE_DIR); | |
731 | 732 | ka_secmem_init(); |
732 | 733 | |
733 | if(!ka_dbus_connect (&status)) | |
734 | if (!ka_dbus_connect (&status)) | |
734 | 735 | exit(status); |
735 | 736 | |
736 | 737 | if (run_always && !run_auto) { |
737 | 738 | always_run = TRUE; |
738 | 739 | } |
739 | 740 | if (using_krb5 () || always_run) { |
740 | applet = ka_create_applet(); | |
741 | applet = ka_create_applet (); | |
741 | 742 | if (!applet) |
742 | 743 | return 1; |
743 | if (!ka_gconf_init(applet, argc, argv)) | |
744 | if (!ka_gconf_init (applet, argc, argv)) | |
744 | 745 | return 1; |
745 | 746 | |
746 | 747 | /* setup the pw dialog */ |
750 | 751 | applet->pw_dialog = glade_xml_get_widget (applet->pw_xml, "krb5_dialog"); |
751 | 752 | |
752 | 753 | g_set_application_name (_("Network Authentication")); |
753 | gtk_window_set_default_icon_name(applet->icons[1]); | |
754 | gtk_window_set_default_icon_name (applet->icons[1]); | |
754 | 755 | |
755 | 756 | #ifdef ENABLE_NETWORK_MANAGER |
756 | 757 | nm_context = libnm_glib_init (); |
0 | 0 | [Desktop Entry] |
1 | 1 | _Name=Network Authentication |
2 | _Comments=Kerberos Network Authentication Dialog | |
3 | Exec=krb5-auth-dialog | |
2 | _Comment=Kerberos Network Authentication Dialog | |
4 | 3 | Encoding=UTF-8 |
5 | 4 | Exec=krb5-auth-dialog |
6 | 5 | Terminal=false |
115 | 115 | |
116 | 116 | <child> |
117 | 117 | <widget class="GtkLabel" id="krb5_message_label"> |
118 | <property name="width_request">333</property> | |
119 | 118 | <property name="visible">True</property> |
120 | 119 | <property name="label" translatable="no"></property> |
121 | 120 | <property name="use_underline">False</property> |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
0 | <gconfschemafile> | |
1 | <schemalist> | |
2 | <schema> | |
3 | <key>/schemas/apps/::PACKAGE::/show_trayicon</key> | |
4 | <applyto>/apps/::PACKAGE::/show_trayicon</applyto> | |
5 | <owner>::PACKAGE::</owner> | |
6 | <type>bool</type> | |
7 | <default>true</default> | |
8 | <locale name="C"> | |
9 | <short>Display trayicon</short> | |
10 | <long>Display the trayicon in the panel</long> | |
11 | </locale> | |
12 | </schema> | |
13 | ||
14 | <schema> | |
15 | <key>/schemas/apps/::PACKAGE::/prompt_minutes</key> | |
16 | <applyto>/apps/::PACKAGE::/prompt_minutes</applyto> | |
17 | <owner>::PACKAGE::</owner> | |
18 | <type>int</type> | |
19 | <default>::MINIMUM_LIFETIME::</default> | |
20 | <locale name="C"> | |
21 | <short>Minutes before ticket expires</short> | |
22 | <long>How many minutes before the ticket expires should | |
23 | prompting for the new password start</long> | |
24 | </locale> | |
25 | </schema> | |
26 | ||
27 | <schema> | |
28 | <key>/schemas/apps/::PACKAGE::/principal</key> | |
29 | <applyto>/apps/::PACKAGE::/principal</applyto> | |
30 | <type>string</type> | |
31 | <default></default> | |
32 | <locale name="C"> | |
33 | <short>default principal</short> | |
34 | <long>principal to use when no ticket cache is present</long> | |
35 | </locale> | |
36 | </schema> | |
37 | </schemalist> | |
38 | </gconfschemafile> |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
28 | 28 | #define KA_GCONF_KEY_PROMPT_MINS KA_GCONF_PATH "/prompt_minutes" |
29 | 29 | #define KA_GCONF_KEY_SHOW_TRAYICON KA_GCONF_PATH "/show_trayicon" |
30 | 30 | |
31 | static gboolean | |
32 | ka_gconf_get_string(GConfClient* client, | |
33 | const char* key, | |
34 | char** value) | |
31 | static gboolean | |
32 | ka_gconf_get_string (GConfClient* client, | |
33 | const char* key, | |
34 | char** value) | |
35 | 35 | { |
36 | 36 | GError* error = NULL; |
37 | 37 | gboolean success = FALSE; |
55 | 55 | |
56 | 56 | |
57 | 57 | static gboolean |
58 | ka_gconf_get_int(GConfClient* client, | |
58 | ka_gconf_get_int (GConfClient* client, | |
59 | 59 | const char* key, |
60 | 60 | int* value) |
61 | 61 | { |
82 | 82 | |
83 | 83 | |
84 | 84 | static gboolean |
85 | ka_gconf_get_bool(GConfClient* client, | |
85 | ka_gconf_get_bool (GConfClient* client, | |
86 | 86 | const char* key, |
87 | 87 | gboolean* value) |
88 | 88 | { |
109 | 109 | |
110 | 110 | |
111 | 111 | static gboolean |
112 | ka_gconf_set_principal(GConfClient* client, Krb5AuthApplet* applet) | |
113 | { | |
114 | g_free(applet->principal); | |
112 | ka_gconf_set_principal (GConfClient* client, Krb5AuthApplet* applet) | |
113 | { | |
114 | g_free (applet->principal); | |
115 | 115 | applet->principal = NULL; |
116 | if(!ka_gconf_get_string(client, KA_GCONF_KEY_PRINCIPAL, &applet->principal)) { | |
117 | applet->principal = g_strdup(g_get_user_name()); | |
118 | } | |
116 | if(!ka_gconf_get_string (client, KA_GCONF_KEY_PRINCIPAL, &applet->principal)) { | |
117 | applet->principal = g_strdup (g_get_user_name()); | |
118 | } | |
119 | 119 | KA_DEBUG("Setting principal to %s", applet->principal); |
120 | 120 | // FIXME: need to send set-principal signal |
121 | 121 | return TRUE; |
123 | 123 | |
124 | 124 | |
125 | 125 | static gboolean |
126 | ka_gconf_set_prompt_mins(GConfClient* client, Krb5AuthApplet* applet) | |
127 | { | |
128 | if(!ka_gconf_get_int(client, KA_GCONF_KEY_PROMPT_MINS, &applet->pw_prompt_secs)) { | |
126 | ka_gconf_set_prompt_mins (GConfClient* client, Krb5AuthApplet* applet) | |
127 | { | |
128 | if(!ka_gconf_get_int (client, KA_GCONF_KEY_PROMPT_MINS, &applet->pw_prompt_secs)) { | |
129 | 129 | applet->pw_prompt_secs = MINUTES_BEFORE_PROMPTING; |
130 | } | |
130 | } | |
131 | 131 | applet->pw_prompt_secs *= 60; |
132 | 132 | KA_DEBUG("Setting prompting timer to %d seconds", applet->pw_prompt_secs); |
133 | 133 | return TRUE; |
135 | 135 | |
136 | 136 | |
137 | 137 | static gboolean |
138 | ka_gconf_set_show_trayicon(GConfClient* client, Krb5AuthApplet* applet) | |
138 | ka_gconf_set_show_trayicon (GConfClient* client, Krb5AuthApplet* applet) | |
139 | 139 | { |
140 | 140 | if(!ka_gconf_get_bool(client, KA_GCONF_KEY_SHOW_TRAYICON, &applet->show_trayicon)) { |
141 | 141 | applet->show_trayicon = TRUE; |
142 | } | |
142 | } | |
143 | 143 | KA_DEBUG("Show trayicon: %s", (applet->show_trayicon ? "yes" : "no" )); |
144 | 144 | // FIXME: send show trayicon signal |
145 | 145 | ka_show_tray_icon(applet); |
161 | 161 | return; |
162 | 162 | KA_DEBUG("Key %s changed", key); |
163 | 163 | |
164 | if (g_strcmp0(key, KA_GCONF_KEY_PRINCIPAL) == 0) { | |
165 | ka_gconf_set_principal(client, applet); | |
166 | } else if (g_strcmp0(key, KA_GCONF_KEY_PROMPT_MINS) == 0) { | |
167 | ka_gconf_set_prompt_mins(client, applet); | |
168 | } else if (g_strcmp0(key, KA_GCONF_KEY_SHOW_TRAYICON) == 0) { | |
169 | ka_gconf_set_show_trayicon(client, applet); | |
164 | if (g_strcmp0 (key, KA_GCONF_KEY_PRINCIPAL) == 0) { | |
165 | ka_gconf_set_principal (client, applet); | |
166 | } else if (g_strcmp0 (key, KA_GCONF_KEY_PROMPT_MINS) == 0) { | |
167 | ka_gconf_set_prompt_mins (client, applet); | |
168 | } else if (g_strcmp0 (key, KA_GCONF_KEY_SHOW_TRAYICON) == 0) { | |
169 | ka_gconf_set_show_trayicon (client, applet); | |
170 | 170 | } else |
171 | 171 | g_warning("Received notification for unknown gconf key %s", key); |
172 | 172 | return; |
180 | 180 | GConfClient* client; |
181 | 181 | gboolean success = FALSE; |
182 | 182 | |
183 | client = gconf_client_get_default(); | |
184 | gconf_client_add_dir(client, KA_GCONF_PATH, GCONF_CLIENT_PRELOAD_ONELEVEL, &error); | |
183 | client = gconf_client_get_default (); | |
184 | gconf_client_add_dir (client, KA_GCONF_PATH, GCONF_CLIENT_PRELOAD_ONELEVEL, &error); | |
185 | 185 | if (error) |
186 | 186 | goto out; |
187 | 187 | |
188 | gconf_client_notify_add(client, KA_GCONF_PATH, | |
189 | ka_gconf_key_changed_callback, applet, NULL, &error); | |
188 | gconf_client_notify_add (client, KA_GCONF_PATH, | |
189 | ka_gconf_key_changed_callback, applet, NULL, &error); | |
190 | 190 | if (error) |
191 | 191 | goto out; |
192 | 192 | |
193 | 193 | /* setup defaults */ |
194 | ka_gconf_set_principal(client, applet); | |
195 | ka_gconf_set_prompt_mins(client, applet); | |
196 | ka_gconf_set_show_trayicon(client, applet); | |
194 | ka_gconf_set_principal (client, applet); | |
195 | ka_gconf_set_prompt_mins (client, applet); | |
196 | ka_gconf_set_show_trayicon (client, applet); | |
197 | 197 | |
198 | 198 | success = TRUE; |
199 | 199 | out: |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |
0 | 0 | /* Krb5 Auth Applet -- Acquire and release kerberos tickets |
1 | * | |
1 | * | |
2 | 2 | * (C) 2008 Guido Guenther <agx@sigxcpu.org> |
3 | * | |
3 | * | |
4 | 4 | * This program is free software; you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
6 | 6 | * the Free Software Foundation; either version 2 of the License, or |