diff options
author | Guido Günther <agx@sigxcpu.org> | 2009-04-04 15:00:44 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2009-04-04 15:00:44 +0200 |
commit | 61675c0b44f15c2f1760c7f192321e61f174daaa (patch) | |
tree | 1d8e5cc6f09fd48a8b695be575b200224af8341f | |
parent | Imported Upstream version 0.8+svn136 (diff) | |
download | krb5-auth-dialog-61675c0b44f15c2f1760c7f192321e61f174daaa.tar.gz krb5-auth-dialog-61675c0b44f15c2f1760c7f192321e61f174daaa.tar.bz2 krb5-auth-dialog-61675c0b44f15c2f1760c7f192321e61f174daaa.zip |
Imported Upstream version 0.8+svn141
-rw-r--r-- | .cvsignore | 31 | ||||
-rw-r--r-- | ChangeLog | 64 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | etpo/.cvsignore | 6 | ||||
-rw-r--r-- | gtksecentry/gtksecentry.c | 120 | ||||
-rw-r--r-- | gtksecentry/gtksecentry.h | 8 | ||||
-rw-r--r-- | po/.cvsignore | 10 | ||||
-rw-r--r-- | po/POTFILES.in | 5 | ||||
-rw-r--r-- | preferences/Makefile.am | 42 | ||||
-rw-r--r-- | preferences/krb5-auth-dialog-preferences.c | 627 | ||||
-rw-r--r-- | preferences/krb5-auth-dialog-preferences.desktop.in | 12 | ||||
-rw-r--r-- | preferences/krb5-auth-dialog-preferences.glade | 573 | ||||
-rw-r--r-- | src/.cvsignore | 5 | ||||
-rw-r--r-- | src/Makefile.am | 14 | ||||
-rw-r--r-- | src/krb5-auth-applet.c | 83 | ||||
-rw-r--r-- | src/krb5-auth-dialog.c | 49 | ||||
-rw-r--r-- | src/krb5-auth-dialog.schemas.in | 39 | ||||
-rw-r--r-- | src/krb5-auth-gconf-tools.c | 102 | ||||
-rw-r--r-- | src/krb5-auth-gconf-tools.h | 41 | ||||
-rw-r--r-- | src/krb5-auth-gconf.c | 135 | ||||
-rw-r--r-- | src/org.gnome.KrbAuthDialog.service.in | 3 |
22 files changed, 1771 insertions, 201 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..e3410ea --- /dev/null +++ b/.cvsignore @@ -0,0 +1,31 @@ +aclocal.m4 +autom4te.cache +COPYING +INSTALL +configure +config.log +config.status +config.h +config.h.in +compile +config.guess +config.sub +depcomp +Makefile +Makefile.in +intltool-extract +intltool-merge +intltool-update +intltool-extract.in +intltool-merge.in +intltool-update.in +libtool* +ltmain.sh +install-sh +missing +mkinstalldirs +stamp-h1 +krb5-auth-dialog.spec +krb5-auth-dialog*.tar.bz2 +krb5-auth-dialog*.tar.gz + @@ -1,3 +1,67 @@ +Sa Apr 4 11:15:39 CEST 2009 Guido Günther <agx@sigxcpu.org> + + GtkSecureEntry warning fixes: + * gtksecentry/gtksecentry.c (gtk_secure_entry_state_changed: drop + duplicate declaration + (g_malloc): use G_SIZE_FORMAT for gsize type + (g_malloc0): likewise + (gtk_secure_entry_get_type): add missing initializer + (gtk_secure_entry_delete_cb): drop, unused static function + (gtk_secure_entry_toggle_overwrite): likewise + (activate_cb): likewise + (unichar_chosen_func): likewise + (gtk_secure_entry_append_text: drop, deprecated in GtkEntry since + 2.0 and missing declaration in gtksecentry.h + (gtk_secure_entry_prepend_text): likewise + (gtk_entry_set_position): likewise + (gtk_entry_select_region): likewise + declare unused parameters as G_GNUC_UNUSED + * gtksecentry/gtksecentry.h (gtk_secure_entry_new_with_max_length): + add missing declaration + (gtk_secure_entry_layout_index_to_text_index): likewise + (gtk_secure_entry_text_index_to_layout_index): likewise + +Sa Apr 4 11:06:45 CEST 2009 Guido Günther <agx@sigxcpu.org> + + add preferences capplet + * preferences/{krb5-auth-dialog-preferences.{c,glade,desktop.in}, + preferences/Makefile.am: new files + * po/POTFILES.in: add the above + * Makefile.am, configure.ac: process preferences/ + * src/krb5-auth-applet.c (ka_applet_cb_preferences): callback to open + preferences + (ka_applet_create_context_menu): add preferences context menu entry + +Sa Apr 4 10:57:23 CEST 2009 Guido Günther <agx@sigxcpu.org> + + allow to set ticket proxiable, renewable and forwardable ticket flags + via gconf + * src/krb5-auth-applet.c (_KaApplet): add tgt_{forwardable,proxiable, + renewable) + (ka_applet_set_property): set via properties + (ka_applet_class_init): add properties + * src/krb5-auth-dialog.c (ka_set_ticket_options): new function + (set_options_from_creds): use parameter instead of global var + (ka_grab_credentials): remove unused variable + * src/krb5-auth-gconf.c (forwardable,renewable,proxiable): add new + boolean gconf keys + * src/krb5-auth-dialog.schemas.in: add new gconf keys to schema + +Sa Apr 4 10:52:53 CEST 2009 Guido Günther <agx@sigxcpu.org> + + split out gconf tool functions + * src/krb5-auth-gconf-tools.h: new file + * src/krb5-auth-gconf-tools.c: new file + * src/krb5-auth-gconf.c (ka_gconf_get*): move to + src/krb5-auth-gconf-tools.c + (KA_GCONF_*): move to src/krb5-auth-gconf-tools.h + +Sa Mär 28 14:17:49 CET 2009 Guido Günther <agx@sigxcpu.org> + + add dbus service file + * src/org.gnome.KrbAuthDialog.service.in: new file + * src/Makefile.am (service_DATA): process annd install service file + Di Mär 24 00:04:50 CET 2009 Guido Günther <agx@sigxcpu.org> monitor ccache via GFileMontor diff --git a/Makefile.am b/Makefile.am index 51c4e5b..2be06e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = secmem gtksecentry src po etpo icons +SUBDIRS = secmem gtksecentry src po etpo icons preferences EXTRA_DIST = \ krb5-auth-dialog.spec diff --git a/configure.ac b/configure.ac index 89fb2fa..be95999 100644 --- a/configure.ac +++ b/configure.ac @@ -218,6 +218,7 @@ gtksecentry/Makefile icons/Makefile etpo/Makefile po/Makefile.in +preferences/Makefile ]) AC_MSG_NOTICE([]) diff --git a/etpo/.cvsignore b/etpo/.cvsignore new file mode 100644 index 0000000..dff7314 --- /dev/null +++ b/etpo/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +etpo +grammar.c +grammar.h +lexer.c diff --git a/gtksecentry/gtksecentry.c b/gtksecentry/gtksecentry.c index 938479c..4ad0e97 100644 --- a/gtksecentry/gtksecentry.c +++ b/gtksecentry/gtksecentry.c @@ -224,8 +224,6 @@ static gint gtk_secure_entry_move_logically(GtkSecureEntry * entry, gint start, gint count); static gboolean gtk_secure_entry_mnemonic_activate(GtkWidget * widget, gboolean group_cycling); -static void gtk_secure_entry_state_changed(GtkWidget * widget, - GtkStateType previous_state); static void gtk_secure_entry_check_cursor_blink(GtkSecureEntry * entry); static void gtk_secure_entry_pend_cursor_blink(GtkSecureEntry * entry); static void get_text_area_size(GtkSecureEntry * entry, @@ -282,7 +280,7 @@ g_malloc(gsize size) else p = (gpointer) malloc(size); if (!p) - g_error("could not allocate %ld bytes", size); + g_error("could not allocate %"G_GSIZE_FORMAT" bytes", size); return p; } @@ -302,7 +300,7 @@ g_malloc0(gsize size) } else p = (gpointer) calloc(size, 1); if (!p) - g_error("could not allocate %ld bytes", size); + g_error("could not allocate %"G_GSIZE_FORMAT" bytes", size); return p; } @@ -364,6 +362,7 @@ gtk_secure_entry_get_type(void) sizeof(GtkSecureEntry), 0, /* n_preallocs */ (GInstanceInitFunc) gtk_secure_entry_init, + NULL, }; static const GInterfaceInfo editable_info = { @@ -1326,7 +1325,8 @@ gtk_secure_entry_key_release(GtkWidget * widget, GdkEventKey * event) } static gint -gtk_secure_entry_focus_in(GtkWidget * widget, GdkEventFocus * event) +gtk_secure_entry_focus_in(GtkWidget * widget, + GdkEventFocus * event G_GNUC_UNUSED) { GtkSecureEntry *entry = GTK_SECURE_ENTRY(widget); @@ -1346,7 +1346,8 @@ gtk_secure_entry_focus_in(GtkWidget * widget, GdkEventFocus * event) } static gint -gtk_secure_entry_focus_out(GtkWidget * widget, GdkEventFocus * event) +gtk_secure_entry_focus_out(GtkWidget * widget, + GdkEventFocus * event G_GNUC_UNUSED) { GtkSecureEntry *entry = GTK_SECURE_ENTRY(widget); @@ -1395,7 +1396,7 @@ gtk_secure_entry_direction_changed(GtkWidget * widget, static void gtk_secure_entry_state_changed(GtkWidget * widget, - GtkStateType previous_state) + GtkStateType previous_state G_GNUC_UNUSED) { GtkSecureEntry *entry = GTK_SECURE_ENTRY(widget); @@ -1418,7 +1419,8 @@ gtk_secure_entry_state_changed(GtkWidget * widget, } static void -gtk_secure_entry_screen_changed(GtkWidget * widget, GdkScreen * old_screen) +gtk_secure_entry_screen_changed(GtkWidget * widget, + GdkScreen * old_screen G_GNUC_UNUSED) { gtk_secure_entry_recompute(GTK_SECURE_ENTRY(widget)); } @@ -1549,7 +1551,8 @@ gtk_secure_entry_style_set(GtkWidget * widget, GtkStyle * previous_style) /* GtkCellEditable method implementations */ static void -gtk_cell_editable_secure_entry_activated(GtkSecureEntry * entry, gpointer data) +gtk_cell_editable_secure_entry_activated(GtkSecureEntry * entry, + gpointer data G_GNUC_UNUSED) { gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(entry)); gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(entry)); @@ -1557,7 +1560,8 @@ gtk_cell_editable_secure_entry_activated(GtkSecureEntry * entry, gpointer data) static gboolean gtk_cell_editable_key_press_event(GtkSecureEntry * entry, - GdkEventKey * key_event, gpointer data) + GdkEventKey * key_event, + gpointer data G_GNUC_UNUSED) { if (key_event->keyval == GDK_Escape) { entry->editing_canceled = TRUE; @@ -1580,7 +1584,7 @@ gtk_cell_editable_key_press_event(GtkSecureEntry * entry, static void gtk_secure_entry_start_editing(GtkCellEditable * cell_editable, - GdkEvent * event) + GdkEvent * event G_GNUC_UNUSED) { GTK_SECURE_ENTRY(cell_editable)->is_cell_renderer = TRUE; @@ -1882,22 +1886,6 @@ gtk_secure_entry_delete_from_cursor(GtkSecureEntry * entry, } static void -gtk_secure_entry_delete_cb(GtkSecureEntry * entry) -{ - GtkEditable *editable = GTK_EDITABLE(entry); - gint start, end; - - if (gtk_editable_get_selection_bounds(editable, &start, &end)) - gtk_editable_delete_text(editable, start, end); -} - -static void -gtk_secure_entry_toggle_overwrite(GtkSecureEntry * entry) -{ - entry->overwrite_mode = !entry->overwrite_mode; -} - -static void gtk_secure_entry_real_activate(GtkSecureEntry * entry) { GtkWindow *window; @@ -1922,7 +1910,7 @@ gtk_secure_entry_real_activate(GtkSecureEntry * entry) } static void -gtk_secure_entry_keymap_direction_changed(GdkKeymap * keymap, +gtk_secure_entry_keymap_direction_changed(GdkKeymap * keymap G_GNUC_UNUSED, GtkSecureEntry * entry) { gtk_secure_entry_recompute(entry); @@ -1932,14 +1920,14 @@ gtk_secure_entry_keymap_direction_changed(GdkKeymap * keymap, */ static void -gtk_secure_entry_commit_cb(GtkIMContext * context, +gtk_secure_entry_commit_cb(GtkIMContext * context G_GNUC_UNUSED, const gchar * str, GtkSecureEntry * entry) { gtk_secure_entry_enter_text(entry, str); } static void -gtk_secure_entry_preedit_changed_cb(GtkIMContext * context, +gtk_secure_entry_preedit_changed_cb(GtkIMContext * context G_GNUC_UNUSED, GtkSecureEntry * entry) { gchar *preedit_string; @@ -1971,7 +1959,7 @@ gtk_secure_entry_retrieve_surrounding_cb(GtkIMContext * context, } static gboolean -gtk_secure_entry_delete_surrounding_cb(GtkIMContext * slave, +gtk_secure_entry_delete_surrounding_cb(GtkIMContext * slave G_GNUC_UNUSED, gint offset, gint n_chars, GtkSecureEntry * entry) @@ -2736,38 +2724,6 @@ gtk_secure_entry_set_text(GtkSecureEntry * entry, const gchar * text) &tmp_pos); } -void -gtk_secure_entry_append_text(GtkSecureEntry * entry, const gchar * text) -{ - gint tmp_pos; - - g_return_if_fail(GTK_IS_SECURE_ENTRY(entry)); - g_return_if_fail(text != NULL); - - tmp_pos = entry->text_length; - gtk_editable_insert_text(GTK_EDITABLE(entry), text, -1, &tmp_pos); -} - -void -gtk_secure_entry_prepend_text(GtkSecureEntry * entry, const gchar * text) -{ - gint tmp_pos; - - g_return_if_fail(GTK_IS_SECURE_ENTRY(entry)); - g_return_if_fail(text != NULL); - - tmp_pos = 0; - gtk_editable_insert_text(GTK_EDITABLE(entry), text, -1, &tmp_pos); -} - -void -gtk_secure_entry_set_position(GtkSecureEntry * entry, gint position) -{ - g_return_if_fail(GTK_IS_SECURE_ENTRY(entry)); - - gtk_editable_set_position(GTK_EDITABLE(entry), position); -} - /** * gtk_secure_entry_set_invisible_char: * @entry: a #GtkSecureEntry @@ -2833,13 +2789,6 @@ gtk_secure_entry_get_text(GtkSecureEntry * entry) return entry->text; } -void -gtk_secure_entry_select_region(GtkSecureEntry * entry, - gint start, gint end) -{ - gtk_editable_select_region(GTK_EDITABLE(entry), start, end); -} - /** * gtk_secure_entry_set_max_length: * @entry: a #GtkSecureEntry. @@ -3153,35 +3102,14 @@ gtk_secure_entry_get_layout_offsets(GtkSecureEntry * entry, *y += text_area_y; } - -/* Quick hack of a popup menu - */ -static void -activate_cb(GtkWidget * menuitem, GtkSecureEntry * entry) -{ - const gchar *signal = - g_object_get_data(G_OBJECT(menuitem), "gtk-signal"); - g_signal_emit_by_name(entry, signal); -} - - static gboolean gtk_secure_entry_mnemonic_activate(GtkWidget * widget, - gboolean group_cycling) + gboolean group_cycling G_GNUC_UNUSED) { gtk_widget_grab_focus(widget); return TRUE; } - -static void -unichar_chosen_func(const char *text, gpointer data) -{ - GtkSecureEntry *entry = GTK_SECURE_ENTRY(data); - - gtk_secure_entry_enter_text(entry, text); -} - /* We display the cursor when * * - the selection is empty, AND @@ -3343,10 +3271,10 @@ keyval_is_cursor_move(guint keyval) /* VOID:ENUM,INT,BOOLEAN (gtkmarshalers.list:64) */ static void _gtk_marshal_VOID__ENUM_INT_BOOLEAN(GClosure * closure, - GValue * return_value, + GValue * return_value G_GNUC_UNUSED, guint n_param_values, const GValue * param_values, - gpointer invocation_hint, + gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) { typedef void (*GMarshalFunc_VOID__ENUM_INT_BOOLEAN) (gpointer data1, @@ -3379,10 +3307,10 @@ _gtk_marshal_VOID__ENUM_INT_BOOLEAN(GClosure * closure, static void _gtk_marshal_VOID__ENUM_INT(GClosure * closure, - GValue * return_value, + GValue * return_value G_GNUC_UNUSED, guint n_param_values, const GValue * param_values, - gpointer invocation_hint, + gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) { typedef void (*GMarshalFunc_VOID__ENUM_INT) (gpointer data1, diff --git a/gtksecentry/gtksecentry.h b/gtksecentry/gtksecentry.h index 12736cd..273a4f2 100644 --- a/gtksecentry/gtksecentry.h +++ b/gtksecentry/gtksecentry.h @@ -135,6 +135,8 @@ gtk_secure_entry_get_type(void) G_GNUC_CONST; GtkWidget * gtk_secure_entry_new(void); +GtkWidget * +gtk_secure_entry_new_with_max_length(gint max); void gtk_secure_entry_set_invisible_char(GtkSecureEntry * entry, gunichar ch); gunichar @@ -169,6 +171,12 @@ gtk_secure_entry_get_text(GtkSecureEntry * entry); PangoLayout * gtk_secure_entry_get_layout(GtkSecureEntry * entry); +gint +gtk_secure_entry_layout_index_to_text_index(GtkSecureEntry * entry, + gint layout_index); +gint +gtk_secure_entry_text_index_to_layout_index(GtkSecureEntry * entry, + gint text_index); void gtk_secure_entry_get_layout_offsets(GtkSecureEntry * entry, gint * x, gint * y); diff --git a/po/.cvsignore b/po/.cvsignore new file mode 100644 index 0000000..216b8fc --- /dev/null +++ b/po/.cvsignore @@ -0,0 +1,10 @@ +*.gmo +*.mo +*.pot +Makefile +Makefile.in +Makefile.in.in +POTFILES +messages +missing +notexist diff --git a/po/POTFILES.in b/po/POTFILES.in index 8ee65fd..70977d4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,6 +4,9 @@ src/krb5-auth-pwdialog.c src/dummy-strings.c src/krb5-auth-applet.c src/krb5-auth-dialog.desktop.in +src/krb5-auth-dialog.schemas.in gtksecentry/gtksecentry.c secmem/util.c -src/krb5-auth-dialog.schemas.in +preferences/krb5-auth-dialog-preferences.c +preferences/krb5-auth-dialog-preferences.desktop.in +preferences/krb5-auth-dialog-preferences.glade diff --git a/preferences/Makefile.am b/preferences/Makefile.am new file mode 100644 index 0000000..83541ea --- /dev/null +++ b/preferences/Makefile.am @@ -0,0 +1,42 @@ +NULL = + +INCLUDES = \ + -I $(top_srcdir)/src/ \ + -DKA_DATA_DIR=\""$(pkgdatadir)"\" \ + -DLOCALE_DIR=\""$(localedir)/"\" \ + $(NULL) + +bin_PROGRAMS = krb5-auth-dialog-preferences + +schemadir = $(sysconfdir)/gconf/schemas + +krb5_auth_dialog_preferences_SOURCES = \ + krb5-auth-dialog-preferences.c \ + ../src/krb5-auth-gconf-tools.c \ + ../src/krb5-auth-gconf-tools.h \ + $(NULL) + +krb5_auth_dialog_preferences_LDADD = \ + @GCONF_LIBS@ \ + @GLADE_LIBS@ \ + @GTK_LIBS@ \ + $(NULL) + +desktopdir = $(datadir)/applications +desktop_in_files = krb5-auth-dialog-preferences.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) + +@INTLTOOL_DESKTOP_RULE@ + +pkgdatadir = $(datadir)/krb5-auth-dialog +pkgdata_DATA = \ + krb5-auth-dialog-preferences.glade + +CLEANFILES = \ + $(desktop_DATA) \ + $(NULL) + +EXTRA_DIST = \ + $(desktop_in_files) \ + $(pkgdata_DATA) \ + $(NULL) diff --git a/preferences/krb5-auth-dialog-preferences.c b/preferences/krb5-auth-dialog-preferences.c new file mode 100644 index 0000000..caf9ed9 --- /dev/null +++ b/preferences/krb5-auth-dialog-preferences.c @@ -0,0 +1,627 @@ +/* + * Copyright (C) 2009 Guido Guenther <agx@sigxcup.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Author: + * Guido Guenther <agx@sigxcpu.org> + * + * based on the vino capplet which is: + * + * Copyright (C) 2003 Sun Microsystems, Inc. + * Copyright (C) 2006 Jonh Wendell <wendell@bani.com.br> + * + * Authors: + * Mark McLoughlin <mark@skynet.ie> + * Jonh Wendell <wendell@bani.com.br> + */ + +#include "config.h" + +#include <gtk/gtk.h> +#include <glib/gi18n.h> +#include <glade/glade.h> + +#include "krb5-auth-gconf-tools.h" + +#define N_LISTENERS 7 + +typedef struct { + GladeXML *xml; + GConfClient *client; + + GtkWidget *dialog; + GtkWidget *principal_entry; + GtkWidget *pkuserid_entry; + GtkWidget *forwardable_toggle; + GtkWidget *proxiable_toggle; + GtkWidget *renewable_toggle; + GtkWidget *trayicon_toggle; + GtkWidget *prompt_mins_entry; + + guint listeners [N_LISTENERS]; + int n_listeners; +} KaPreferencesDialog; + + +static void +ka_preferences_principal_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + const char *principal; + + if (!entry->value || entry->value->type != GCONF_VALUE_STRING) + return; + + principal = gconf_value_get_string (entry->value); + + if (!principal || !strlen(principal)) + gtk_entry_set_text (GTK_ENTRY (dialog->principal_entry), ""); + else { + const char *old_principal; + + old_principal = gtk_entry_get_text (GTK_ENTRY (dialog->principal_entry)); + if (!old_principal || (old_principal && strcmp (old_principal, principal))) + gtk_entry_set_text (GTK_ENTRY (dialog->principal_entry), principal); + } +} + + +static void +ka_preferences_dialog_principal_changed (GtkEntry *entry, + KaPreferencesDialog *dialog) +{ + const char *principal; + + principal = gtk_entry_get_text (entry); + + if (!principal || !strlen(principal)) + gconf_client_unset (dialog->client, KA_GCONF_KEY_PRINCIPAL, NULL); + else + gconf_client_set_string (dialog->client, KA_GCONF_KEY_PRINCIPAL, principal, NULL); +} + + +static void +ka_preferences_dialog_setup_principal_entry (KaPreferencesDialog *dialog) +{ + char *principal = NULL; + + dialog->principal_entry = glade_xml_get_widget (dialog->xml, "principal_entry"); + g_assert (dialog->principal_entry != NULL); + + if (!ka_gconf_get_string (dialog->client, KA_GCONF_KEY_PRINCIPAL, &principal)) + g_warning ("Getting principal failed"); + + if (principal && strlen(principal)) + gtk_entry_set_text (GTK_ENTRY (dialog->principal_entry), principal); + if (principal) + g_free (principal); + + g_signal_connect (dialog->principal_entry, "changed", + G_CALLBACK (ka_preferences_dialog_principal_changed), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_PRINCIPAL, NULL)) { + gtk_widget_set_sensitive (dialog->principal_entry, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_PRINCIPAL, + (GConfClientNotifyFunc) ka_preferences_principal_notify, + dialog, NULL, NULL); + dialog->n_listeners++; +} + + +static void +ka_preferences_pkuserid_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + const char *pkuserid; + + if (!entry->value || entry->value->type != GCONF_VALUE_STRING) + return; + + pkuserid = gconf_value_get_string (entry->value); + + if (!pkuserid || !strlen(pkuserid)) + gtk_entry_set_text (GTK_ENTRY (dialog->pkuserid_entry), ""); + else { + const char *old_pkuserid; + + old_pkuserid = gtk_entry_get_text (GTK_ENTRY (dialog->pkuserid_entry)); + if (!old_pkuserid || (old_pkuserid && strcmp (old_pkuserid, pkuserid))) + gtk_entry_set_text (GTK_ENTRY (dialog->pkuserid_entry), pkuserid); + } +} + + +static void +ka_preferences_dialog_pkuserid_changed (GtkEntry *entry, + KaPreferencesDialog *dialog) +{ + const char *pkuserid; + + pkuserid = gtk_entry_get_text (entry); + + if (!pkuserid || !strlen(pkuserid)) + gconf_client_unset (dialog->client, KA_GCONF_KEY_PK_USERID, NULL); + else + gconf_client_set_string (dialog->client, KA_GCONF_KEY_PK_USERID, pkuserid, NULL); +} + + +static void +ka_preferences_dialog_setup_pkuserid_entry (KaPreferencesDialog *dialog) +{ + char *pkuserid = NULL; + + dialog->pkuserid_entry = glade_xml_get_widget (dialog->xml, "pkuserid_entry"); + g_assert (dialog->pkuserid_entry != NULL); + + if (!ka_gconf_get_string (dialog->client, KA_GCONF_KEY_PK_USERID, &pkuserid)) + g_warning ("Getting pkuserid failed"); + + if (pkuserid && strlen(pkuserid)) + gtk_entry_set_text (GTK_ENTRY (dialog->pkuserid_entry), pkuserid); + if (pkuserid) + g_free (pkuserid); + + g_signal_connect (dialog->pkuserid_entry, "changed", + G_CALLBACK (ka_preferences_dialog_pkuserid_changed), dialog); + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_PK_USERID, NULL)) { + gtk_widget_set_sensitive (dialog->pkuserid_entry, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_PK_USERID, + (GConfClientNotifyFunc) ka_preferences_pkuserid_notify, + dialog, NULL, NULL); + dialog->n_listeners++; +} + + +static void +ka_preferences_dialog_forwardable_toggled (GtkToggleButton *toggle, + KaPreferencesDialog *dialog) +{ + gboolean forwardable; + + forwardable = gtk_toggle_button_get_active (toggle); + + gconf_client_set_bool (dialog->client, KA_GCONF_KEY_FORWARDABLE, forwardable, NULL); +} + + +static void +ka_preferences_dialog_forwardable_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + gboolean forwardable; + + if (!entry->value || entry->value->type != GCONF_VALUE_BOOL) + return; + + forwardable = gconf_value_get_bool (entry->value) != FALSE; + + if (forwardable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->forwardable_toggle))) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->forwardable_toggle), forwardable); +} + + +static gboolean +ka_preferences_dialog_setup_forwardable_toggle (KaPreferencesDialog *dialog) +{ + gboolean forwardable; + + dialog->forwardable_toggle = glade_xml_get_widget (dialog->xml, "forwardable_toggle"); + g_assert (dialog->forwardable_toggle != NULL); + + forwardable = gconf_client_get_bool (dialog->client, KA_GCONF_KEY_FORWARDABLE, NULL); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->forwardable_toggle), forwardable); + + g_signal_connect (dialog->forwardable_toggle, "toggled", + G_CALLBACK (ka_preferences_dialog_forwardable_toggled), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_FORWARDABLE, NULL)) { + gtk_widget_set_sensitive (dialog->forwardable_toggle, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_FORWARDABLE, + (GConfClientNotifyFunc) ka_preferences_dialog_forwardable_notify, + dialog, NULL, NULL); + dialog->n_listeners++; + return forwardable; +} + + +static void +ka_preferences_dialog_proxiable_toggled (GtkToggleButton *toggle, + KaPreferencesDialog *dialog) +{ + gboolean proxiable; + + proxiable = gtk_toggle_button_get_active (toggle); + + gconf_client_set_bool (dialog->client, KA_GCONF_KEY_PROXIABLE, proxiable, NULL); +} + + +static void +ka_preferences_dialog_proxiable_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + gboolean proxiable; + + if (!entry->value || entry->value->type != GCONF_VALUE_BOOL) + return; + + proxiable = gconf_value_get_bool (entry->value) != FALSE; + + if (proxiable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->proxiable_toggle))) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->proxiable_toggle), proxiable); +} + + +static gboolean +ka_preferences_dialog_setup_proxiable_toggle (KaPreferencesDialog *dialog) +{ + gboolean proxiable; + + dialog->proxiable_toggle = glade_xml_get_widget (dialog->xml, "proxiable_toggle"); + g_assert (dialog->proxiable_toggle != NULL); + + proxiable = gconf_client_get_bool (dialog->client, KA_GCONF_KEY_PROXIABLE, NULL); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->proxiable_toggle), proxiable); + + g_signal_connect (dialog->proxiable_toggle, "toggled", + G_CALLBACK (ka_preferences_dialog_proxiable_toggled), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_PROXIABLE, NULL)) { + gtk_widget_set_sensitive (dialog->proxiable_toggle, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_PROXIABLE, + (GConfClientNotifyFunc) ka_preferences_dialog_proxiable_notify, + dialog, NULL, NULL); + dialog->n_listeners++; + return proxiable; +} + + +static void +ka_preferences_dialog_renewable_toggled (GtkToggleButton *toggle, + KaPreferencesDialog *dialog) +{ + gboolean renewable; + + renewable = gtk_toggle_button_get_active (toggle); + + gconf_client_set_bool (dialog->client, KA_GCONF_KEY_RENEWABLE, renewable, NULL); +} + + +static void +ka_preferences_dialog_renewable_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + gboolean renewable; + + if (!entry->value || entry->value->type != GCONF_VALUE_BOOL) + return; + + renewable = gconf_value_get_bool (entry->value) != FALSE; + + if (renewable != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->renewable_toggle))) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->renewable_toggle), renewable); +} + + +static gboolean +ka_preferences_dialog_setup_renewable_toggle (KaPreferencesDialog *dialog) +{ + gboolean renewable; + + dialog->renewable_toggle = glade_xml_get_widget (dialog->xml, "renewable_toggle"); + g_assert (dialog->renewable_toggle != NULL); + + renewable = gconf_client_get_bool (dialog->client, KA_GCONF_KEY_RENEWABLE, NULL); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->renewable_toggle), renewable); + + g_signal_connect (dialog->renewable_toggle, "toggled", + G_CALLBACK (ka_preferences_dialog_renewable_toggled), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_RENEWABLE, NULL)) { + gtk_widget_set_sensitive (dialog->renewable_toggle, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_RENEWABLE, + (GConfClientNotifyFunc) ka_preferences_dialog_renewable_notify, + dialog, NULL, NULL); + dialog->n_listeners++; + return renewable; +} + +static void +ka_preferences_dialog_trayicon_toggled (GtkToggleButton *toggle, + KaPreferencesDialog *dialog) +{ + gboolean trayicon; + + trayicon = gtk_toggle_button_get_active (toggle); + gconf_client_set_bool (dialog->client, KA_GCONF_KEY_SHOW_TRAYICON, trayicon, NULL); +} + + +static void +ka_preferences_dialog_trayicon_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + gboolean trayicon; + + if (!entry->value || entry->value->type != GCONF_VALUE_BOOL) + return; + + trayicon = gconf_value_get_bool (entry->value) != FALSE; + + if (trayicon != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->trayicon_toggle))) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->trayicon_toggle), trayicon); +} + + +static gboolean +ka_preferences_dialog_setup_trayicon_toggle (KaPreferencesDialog *dialog) +{ + gboolean trayicon; + + dialog->trayicon_toggle = glade_xml_get_widget (dialog->xml, "trayicon_toggle"); + g_assert (dialog->trayicon_toggle != NULL); + + trayicon = gconf_client_get_bool (dialog->client, KA_GCONF_KEY_SHOW_TRAYICON, NULL); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->trayicon_toggle), trayicon); + + g_signal_connect (dialog->trayicon_toggle, "toggled", + G_CALLBACK (ka_preferences_dialog_trayicon_toggled), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_SHOW_TRAYICON, NULL)) { + gtk_widget_set_sensitive (dialog->trayicon_toggle, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_SHOW_TRAYICON, + (GConfClientNotifyFunc) ka_preferences_dialog_trayicon_notify, + dialog, NULL, NULL); + dialog->n_listeners++; + return trayicon; +} + + +static void +ka_preferences_dialog_prompt_mins_changed (GtkSpinButton *button, + KaPreferencesDialog *dialog) +{ + gint prompt_mins; + + prompt_mins = gtk_spin_button_get_value_as_int (button); + gconf_client_set_int (dialog->client, KA_GCONF_KEY_PROMPT_MINS, prompt_mins, NULL); +} + + +static void +ka_preferences_dialog_prompt_mins_notify (GConfClient *client G_GNUC_UNUSED, + guint cnx_id G_GNUC_UNUSED, + GConfEntry *entry, + KaPreferencesDialog *dialog) +{ + gint prompt_mins; + + if (!entry->value || entry->value->type != GCONF_VALUE_INT) + return; + + prompt_mins = gconf_value_get_int (entry->value); + + if (prompt_mins != gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->prompt_mins_entry))) + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prompt_mins_entry), prompt_mins); +} + + +static gint +ka_preferences_dialog_setup_prompt_mins_entry (KaPreferencesDialog *dialog) +{ + gint prompt_mins; + + dialog->prompt_mins_entry = glade_xml_get_widget (dialog->xml, "prompt_mins_entry"); + g_assert (dialog->prompt_mins_entry != NULL); + + prompt_mins = gconf_client_get_int (dialog->client, KA_GCONF_KEY_PROMPT_MINS, NULL); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->prompt_mins_entry), prompt_mins); + + g_signal_connect (dialog->prompt_mins_entry, "value-changed", + G_CALLBACK (ka_preferences_dialog_prompt_mins_changed), dialog); + + if (!gconf_client_key_is_writable (dialog->client, KA_GCONF_KEY_PROMPT_MINS, NULL)) { + gtk_widget_set_sensitive (dialog->prompt_mins_entry, FALSE); + } + + dialog->listeners [dialog->n_listeners] = gconf_client_notify_add (dialog->client, + KA_GCONF_KEY_PROMPT_MINS, + (GConfClientNotifyFunc) ka_preferences_dialog_prompt_mins_notify, + dialog, NULL, NULL); + dialog->n_listeners++; + return prompt_mins; +} + + + +static void +ka_preferences_dialog_response (GtkWidget *widget, + int response, + KaPreferencesDialog *dialog) +{ + GError *error = NULL; + + if (response != GTK_RESPONSE_HELP) { + gtk_widget_destroy (widget); + return; + } + + gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog->dialog)), + "ghelp:krb5-auth-dialog#preferences", + gtk_get_current_event_time (), &error); + + if (error) { + GtkWidget *message_dialog; + + + message_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog->dialog), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("There was an error displaying help:\n%s"), + error->message); + gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE); + + g_signal_connect (message_dialog, "response", + G_CALLBACK (gtk_widget_destroy), + NULL); + + gtk_widget_show (message_dialog); + g_error_free (error); + } +} + + +static void +ka_preferences_dialog_destroyed (GtkWidget *widget G_GNUC_UNUSED, + KaPreferencesDialog *dialog) +{ + dialog->dialog = NULL; + + gtk_main_quit (); +} + + +static gboolean +ka_preferences_dialog_init(KaPreferencesDialog* dialog) +{ + dialog->xml = glade_xml_new (KA_DATA_DIR G_DIR_SEPARATOR_S + PACKAGE "-preferences.glade", NULL, NULL); + + dialog->dialog = glade_xml_get_widget (dialog->xml, "krb5_auth_dialog_prefs"); + g_assert (dialog->dialog); + + g_signal_connect (dialog->dialog, "response", + G_CALLBACK (ka_preferences_dialog_response), dialog); + g_signal_connect (dialog->dialog, "destroy", + G_CALLBACK (ka_preferences_dialog_destroyed), dialog); + + dialog->client = gconf_client_get_default (); + gconf_client_add_dir (dialog->client, KA_GCONF_PATH, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + ka_preferences_dialog_setup_principal_entry (dialog); + ka_preferences_dialog_setup_pkuserid_entry (dialog); + ka_preferences_dialog_setup_forwardable_toggle (dialog); + ka_preferences_dialog_setup_proxiable_toggle (dialog); + ka_preferences_dialog_setup_renewable_toggle (dialog); + ka_preferences_dialog_setup_trayicon_toggle (dialog); + ka_preferences_dialog_setup_prompt_mins_entry (dialog); + + g_assert (dialog->n_listeners == N_LISTENERS); + + gtk_widget_show (dialog->dialog); + return TRUE; +} + + +static void +ka_preferences_dialog_finalize (KaPreferencesDialog *dialog) +{ + if (dialog->dialog) + gtk_widget_destroy (dialog->dialog); + dialog->dialog = NULL; + + if (dialog->client) { + int i; + + for (i = 0; i < dialog->n_listeners; i++) { + if (dialog->listeners [i]) + gconf_client_notify_remove (dialog->client, dialog->listeners [i]); + dialog->listeners [i] = 0; + } + dialog->n_listeners = 0; + + gconf_client_remove_dir (dialog->client, KA_GCONF_PATH, NULL); + + g_object_unref (dialog->client); + dialog->client = NULL; + } + + if (dialog->xml) + g_object_unref (dialog->xml); + dialog->xml = NULL; +} + +int +main (int argc, char *argv[]) +{ + GOptionContext *context; + GError *error = NULL; + KaPreferencesDialog dialog = { NULL, }; + + const char *help_msg = "Run '" PACKAGE " --help' to see a full list of available command line options"; + const GOptionEntry options [] = { + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } + }; + + context = g_option_context_new ("- Kerberos Authentication Configuration"); + g_option_context_add_main_entries (context, options, NULL); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + g_option_context_parse (context, &argc, &argv, &error); + if (error) { + g_print ("%s\n%s\n", + error->message, + help_msg); + g_error_free (error); + return 1; + } + textdomain (PACKAGE); + bind_textdomain_codeset (PACKAGE, "UTF-8"); + bindtextdomain (PACKAGE, LOCALE_DIR); + + ka_preferences_dialog_init(&dialog); + gtk_main (); + ka_preferences_dialog_finalize(&dialog); + return 0; +} diff --git a/preferences/krb5-auth-dialog-preferences.desktop.in b/preferences/krb5-auth-dialog-preferences.desktop.in new file mode 100644 index 0000000..d87e1e7 --- /dev/null +++ b/preferences/krb5-auth-dialog-preferences.desktop.in @@ -0,0 +1,12 @@ +[Desktop Entry] +_Name=Network Authentication +_Comment=Set your Kerberos network authenticaion preferences +Exec=krb5-auth-dialog-preferences +Icon=gtk-dialog-authentication +Terminal=false +Type=Application +StartupNotify=true +Categories=GNOME;GTK;Settings;X-GNOME-NetworkSettings; +OnlyShowIn=GNOME; +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=krb5-auth-dialog diff --git a/preferences/krb5-auth-dialog-preferences.glade b/preferences/krb5-auth-dialog-preferences.glade new file mode 100644 index 0000000..b4e5cd5 --- /dev/null +++ b/preferences/krb5-auth-dialog-preferences.glade @@ -0,0 +1,573 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> +<!--Generated with glade3 3.4.5 on Thu Apr 2 18:10:14 2009 --> +<glade-interface> + <widget class="GtkDialog" id="krb5_auth_dialog_prefs"> + <property name="border_width">5</property> + <property name="title" translatable="yes">Kerberos Authentication Configuration</property> + <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="icon_name">gtk-dialog-authentication</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="has_separator">False</property> + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="spacing">2</property> + <child> + <widget class="GtkNotebook" id="notebook1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="spacing">18</property> + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Kerberos User</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkImage" id="access"> + <property name="visible">True</property> + <property name="yalign">0</property> + <property name="icon_size">6</property> + <property name="icon_name">gtk-dialog-authentication</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox5"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Kerberos principal:</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="principal_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">PKINIT userid: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox6"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="pkuserid_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">The principal's public/private/certificate identifier. Leave empty if not using PKINIT.</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">3</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Ticket Options</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="yalign">0</property> + <property name="icon_size">6</property> + <property name="icon_name">system-lock-screen</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="label" translatable="yes">Requested Kerberos tickets should be:</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label11"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="forwardable_toggle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">If checked, request forwardable tickets</property> + <property name="label" translatable="yes">forwardable</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="renewable_toggle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">If checked, request renewable tickets</property> + <property name="label" translatable="yes">renewable</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox11"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label19"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="proxiable_toggle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">If checked, request proxiable tickets</property> + <property name="label" translatable="yes">proxiable</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">3</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Kerberos</property> + </widget> + <packing> + <property name="type">tab</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox9"> + <property name="visible">True</property> + <property name="border_width">12</property> + <property name="spacing">18</property> + <child> + <widget class="GtkVBox" id="vbox8"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkLabel" id="label17"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Notifications</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox9"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="yalign">0</property> + <property name="stock">gtk-dialog-warning</property> + <property name="icon_size">6</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox8"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label14"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label15"> + <property name="visible">True</property> + <property name="label" translatable="yes">Warn</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="prompt_mins_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">Send notification about ticket expiry that many minutes before it finally expires. </property> + <property name="adjustment">0 0 100 1 10 10</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label16"> + <property name="visible">True</property> + <property name="label" translatable="yes">minutes before expiry</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox10"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkLabel" id="label18"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Appearance</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox10"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-zoom-in</property> + <property name="icon_size">6</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkVBox" id="vbox7"> + <property name="visible">True</property> + <child> + <widget class="GtkHBox" id="hbox7"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <widget class="GtkLabel" id="label13"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkCheckButton" id="trayicon_toggle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">If checked, display the tray icon in the status bar.</property> + <property name="label" translatable="yes">Show tray icon</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Applet</property> + </widget> + <packing> + <property name="type">tab</property> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <child> + <widget class="GtkButton" id="button2"> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="label" translatable="yes">gtk-help</property> + <property name="use_stock">True</property> + <property name="response_id">-11</property> + </widget> + </child> + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="label" translatable="yes">gtk-close</property> + <property name="use_stock">True</property> + <property name="response_id">0</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + </widget> + </child> + </widget> +</glade-interface> diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 0000000..b18d7e7 --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +krb5-auth-dialog +krb5-auth-dialog.1 +krb5-auth-dialog.desktop diff --git a/src/Makefile.am b/src/Makefile.am index a0db9ec..43fd121 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,11 +12,18 @@ autostart_DATA = $(autostart_in_files:.desktop.in=.desktop) schemadir = $(sysconfdir)/gconf/schemas schema_in_files = $(PACKAGE).schemas.in -schema_DATA = $(PACKAGE).schemas +schema_DATA = $(schema_in_files:.schemas.in=.schemas) %.schemas: $(srcdir)/%.schemas.in sed -e "s,::PACKAGE::,$(PACKAGE)," < $< > $@ +servicedir = $(datadir)/dbus-1/services +service_in_files = org.gnome.KrbAuthDialog.service.in +service_DATA = $(service_in_files:.service.in=.service) + +$(service_DATA): $(service_in_files) Makefile + sed -e "s|\@BINDIR\@|$(bindir)|" $< > $@ + krb5_auth_dialog_SOURCES = \ krb5-auth-dialog.c \ krb5-auth-dialog.h \ @@ -26,6 +33,8 @@ krb5_auth_dialog_SOURCES = \ krb5-auth-pwdialog.h \ krb5-auth-gconf.c \ krb5-auth-gconf.h \ + krb5-auth-gconf-tools.c \ + krb5-auth-gconf-tools.h \ krb5-auth-dbus.c \ krb5-auth-dbus.h \ dummy-strings.c @@ -60,9 +69,10 @@ EXTRA_DIST = \ $(pkgdata_DATA) \ $(schema_in_files) \ $(autostart_in_files) \ + $(service_in_files) \ krb5-auth-dialog.1.in -CLEANFILES = $(schema_DATA) +CLEANFILES = $(schema_DATA) $(service_DATA) DISTCLEANFILES = \ krb5-auth-dialog.desktop \ krb5-auth-applet-dbus-glue.h diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c index 34524df..daaef2e 100644 --- a/src/krb5-auth-applet.c +++ b/src/krb5-auth-applet.c @@ -43,6 +43,9 @@ enum KA_PROP_PK_USERID, KA_PROP_TRAYICON, KA_PROP_PW_PROMPT_MINS, + KA_PROP_TGT_FORWARDABLE, + KA_PROP_TGT_PROXIABLE, + KA_PROP_TGT_RENEWABLE, }; struct _KaApplet { @@ -73,6 +76,9 @@ struct _KaAppletPrivate char* principal; /* the principal to request */ gboolean renewable; /* credentials renewable? */ char* pk_userid; /* "userid" for pkint */ + gboolean tgt_forwardable; /* request a forwardable ticket */ + gboolean tgt_renewable; /* request a renewable ticket */ + gboolean tgt_proxiable; /* request a proxiable ticket */ }; static void @@ -106,6 +112,21 @@ ka_applet_set_property (GObject *object, KA_DEBUG ("%s: %d", pspec->name, self->priv->pw_prompt_secs/60); break; + case KA_PROP_TGT_FORWARDABLE: + self->priv->tgt_forwardable = g_value_get_boolean (value); + KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_forwardable ? "True" : "False"); + break; + + case KA_PROP_TGT_PROXIABLE: + self->priv->tgt_proxiable = g_value_get_boolean (value); + KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_proxiable ? "True" : "False"); + break; + + case KA_PROP_TGT_RENEWABLE: + self->priv->tgt_renewable = g_value_get_boolean (value); + KA_DEBUG ("%s: %s", pspec->name, self->priv->tgt_renewable ? "True" : "False"); + break; + default: /* We don't have any other property... */ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -139,6 +160,18 @@ ka_applet_get_property (GObject *object, g_value_set_uint (value, self->priv->pw_prompt_secs / 60); break; + case KA_PROP_TGT_FORWARDABLE: + g_value_set_boolean (value, self->priv->tgt_forwardable); + break; + + case KA_PROP_TGT_PROXIABLE: + g_value_set_boolean (value, self->priv->tgt_proxiable); + break; + + case KA_PROP_TGT_RENEWABLE: + g_value_set_boolean (value, self->priv->tgt_renewable); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -203,7 +236,7 @@ ka_applet_class_init(KaAppletClass *klass) pspec = g_param_spec_string ("principal", "Principal", - "Get/Set Kerberos Principal", + "Get/Set Kerberos principal", "", G_PARAM_CONSTRUCT | G_PARAM_READWRITE); g_object_class_install_property (object_class, @@ -211,7 +244,7 @@ ka_applet_class_init(KaAppletClass *klass) pspec); pspec = g_param_spec_string ("pk-userid", - "PKinit Identifier", + "PKinit identifier", "Get/Set Pkinit identifier", "", G_PARAM_CONSTRUCT | G_PARAM_READWRITE); @@ -229,13 +262,40 @@ ka_applet_class_init(KaAppletClass *klass) pspec); pspec = g_param_spec_uint ("pw-prompt-mins", - "Password Prompting Interval", - "Password Prompting Interval in Minutes", + "Password prompting interval", + "Password prompting interval in minutes", 0, G_MAXUINT, MINUTES_BEFORE_PROMPTING, G_PARAM_CONSTRUCT | G_PARAM_READWRITE); g_object_class_install_property (object_class, KA_PROP_PW_PROMPT_MINS, pspec); + + pspec = g_param_spec_boolean("tgt-forwardable", + "Forwardable ticket", + "wether to request forwardable tickets", + FALSE, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + g_object_class_install_property (object_class, + KA_PROP_TGT_FORWARDABLE, + pspec); + + pspec = g_param_spec_boolean("tgt-proxiable", + "Proxiable ticket", + "wether to request proxiable tickets", + FALSE, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + g_object_class_install_property (object_class, + KA_PROP_TGT_PROXIABLE, + pspec); + + pspec = g_param_spec_boolean("tgt-renewable", + "Renewable ticket", + "wether to request renewable tickets", + FALSE, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + g_object_class_install_property (object_class, + KA_PROP_TGT_RENEWABLE, + pspec); } @@ -372,6 +432,13 @@ ka_applet_menu_add_separator_item (GtkWidget* menu) gtk_widget_show (menu_item); } +static void +ka_applet_cb_preferences (GtkWidget* menuitem G_GNUC_UNUSED, + gpointer user_data G_GNUC_UNUSED) +{ + g_spawn_command_line_async ("krb5-auth-dialog-preferences", NULL); +} + /* Free all resources and quit */ static void @@ -421,6 +488,14 @@ ka_applet_create_context_menu (KaApplet* applet) ka_applet_menu_add_separator_item (menu); + /* Preferences */ + menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences")); + g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_preferences), applet); + image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + /* About item */ menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About")); g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_about_dialog), applet); diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c index a45c480..c443cd3 100644 --- a/src/krb5-auth-dialog.c +++ b/src/krb5-auth-dialog.c @@ -378,9 +378,40 @@ out: } +/* + * set ticket options by looking at krb5.conf and gconf + */ +static void +ka_set_ticket_options(KaApplet* applet, + krb5_get_init_creds_opt *out) +{ + gboolean flag; + +#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS + krb5_get_init_creds_opt_set_default_flags(kcontext, PACKAGE, + krb5_principal_get_realm(kcontext, kprincipal), out); +#endif + g_object_get(applet, "tgt-forwardable", &flag, NULL); + if (flag) + krb5_get_init_creds_opt_set_forwardable(out, flag); + g_object_get(applet, "tgt-proxiable", &flag, NULL); + if (flag) + krb5_get_init_creds_opt_set_proxiable(out, flag); + g_object_get(applet, "tgt-renewable", &flag, NULL); + if (flag) { + krb5_deltat r = 3600*24*30; /* 1 month */ + krb5_get_init_creds_opt_set_renew_life (out, r); + } +} + + +/* + * set ticket options + * by looking at krb5.conf, the passed in creds and gconf + */ static void set_options_from_creds(const KaApplet* applet, - krb5_context context G_GNUC_UNUSED, + krb5_context context, krb5_creds *in, krb5_get_init_creds_opt *out) { @@ -388,8 +419,8 @@ set_options_from_creds(const KaApplet* applet, int flag; #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS - krb5_get_init_creds_opt_set_default_flags(kcontext, PACKAGE, - krb5_principal_get_realm(kcontext, kprincipal), out); + krb5_get_init_creds_opt_set_default_flags(context, PACKAGE, + krb5_principal_get_realm(context, kprincipal), out); #endif flag = get_cred_forwardable(in) != 0; @@ -426,7 +457,7 @@ ka_auth_pkinit(KaApplet* applet, krb5_creds* creds, const char* pk_userid) retval = krb5_get_init_creds_opt_alloc (kcontext, &opts); if (retval) goto out; - set_options_from_creds (applet, kcontext, creds, opts); + ka_set_ticket_options (applet, opts); retval = krb5_get_init_creds_opt_set_pkinit(kcontext, opts, kprincipal, @@ -461,7 +492,7 @@ ka_auth_password(KaApplet* applet, krb5_creds* creds) retval = krb5_get_init_creds_opt_alloc (kcontext, &opts); if (retval) goto out; - set_options_from_creds (applet, kcontext, creds, opts); + ka_set_ticket_options (applet, opts); retval = krb5_get_init_creds_password(kcontext, creds, kprincipal, NULL, auth_dialog_prompter, applet, 0, NULL, opts); @@ -477,9 +508,7 @@ ka_parse_name(KaApplet* applet, krb5_context krbcontext, krb5_principal* kprinc) krb5_error_code ret; gchar *principal = NULL; - g_object_get(applet, "principal", &principal, - NULL); - + g_object_get(applet, "principal", &principal, NULL); ret = krb5_parse_name(krbcontext, principal, kprinc); @@ -773,8 +802,7 @@ ka_check_credentials (KaApplet *applet, const char* newprincipal) int retval; char* principal; - g_object_get(applet, "principal", &principal, - NULL); + g_object_get(applet, "principal", &principal, NULL); if (strlen(newprincipal)) { krb5_principal knewprinc; @@ -817,7 +845,6 @@ gboolean ka_grab_credentials (KaApplet* applet) { int retval; - gboolean retry; int success = FALSE; KaPwDialog *pwdialog = ka_applet_get_pwdialog(applet); diff --git a/src/krb5-auth-dialog.schemas.in b/src/krb5-auth-dialog.schemas.in index 2a3a707..13b05b2 100644 --- a/src/krb5-auth-dialog.schemas.in +++ b/src/krb5-auth-dialog.schemas.in @@ -51,5 +51,44 @@ <long>Start prompting/displaying notifications that many minutes before expiry</long> </locale> </schema> + + <schema> + <key>/schemas/apps/::PACKAGE::/forwardable</key> + <applyto>/apps/::PACKAGE::/forwardable</applyto> + <owner>::PACKAGE::</owner> + <type>bool</type> + <default>0</default> + + <locale name="C"> + <short>Forwardable ticket</short> + <long>Requested tickets should be forwardable</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/::PACKAGE::/renewable</key> + <applyto>/apps/::PACKAGE::/renewable</applyto> + <owner>::PACKAGE::</owner> + <type>bool</type> + <default>0</default> + + <locale name="C"> + <short>Renewable ticket</short> + <long>Requested tickets should be renewable</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/::PACKAGE::/proxiable</key> + <applyto>/apps/::PACKAGE::/proxiable</applyto> + <owner>::PACKAGE::</owner> + <type>bool</type> + <default>0</default> + + <locale name="C"> + <short>Proxiable ticket</short> + <long>Requested tickets should be proxiable</long> + </locale> + </schema> </schemalist> </gconfschemafile> diff --git a/src/krb5-auth-gconf-tools.c b/src/krb5-auth-gconf-tools.c new file mode 100644 index 0000000..fb67999 --- /dev/null +++ b/src/krb5-auth-gconf-tools.c @@ -0,0 +1,102 @@ +/* Krb5 Auth Applet -- Acquire and release kerberos tickets + * + * (C) 2008,2009 Guido Guenther <agx@sigxcpu.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +#include "config.h" + +#include <gconf/gconf-client.h> +#include <krb5-auth-gconf-tools.h> + +gboolean +ka_gconf_get_string (GConfClient* client, + const char* key, + char** value) +{ + GError* error = NULL; + gboolean success = FALSE; + GConfValue* gc_value; + + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (*value == NULL, FALSE); + + if ((gc_value = gconf_client_get (client, key, &error))) { + if (gc_value->type == GCONF_VALUE_STRING) { + *value = g_strdup (gconf_value_get_string (gc_value)); + success = TRUE; + } else if (error) { + g_print (error->message); + g_error_free (error); + } + gconf_value_free (gc_value); + } + return success; +} + + +gboolean +ka_gconf_get_int (GConfClient* client, + const char* key, + int* value) +{ + GError* error = NULL; + gboolean success = FALSE; + GConfValue* gc_value; + + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + if ((gc_value = gconf_client_get (client, key, &error))) + { + if (gc_value->type == GCONF_VALUE_INT) { + *value = gconf_value_get_int (gc_value); + success = TRUE; + } else if (error) { + g_print (error->message); + g_error_free (error); + } + gconf_value_free (gc_value); + } + return success; +} + + +gboolean +ka_gconf_get_bool (GConfClient* client, + const char* key, + gboolean* value) +{ + GError* error = NULL; + gboolean success = FALSE; + GConfValue* gc_value; + + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + if ((gc_value = gconf_client_get (client, key, &error))) { + if (gc_value->type == GCONF_VALUE_BOOL) { + *value = gconf_value_get_bool (gc_value); + success = TRUE; + } else if (error) { + g_print (error->message); + g_error_free (error); + } + gconf_value_free (gc_value); + } + return success; +} + diff --git a/src/krb5-auth-gconf-tools.h b/src/krb5-auth-gconf-tools.h new file mode 100644 index 0000000..9786b2f --- /dev/null +++ b/src/krb5-auth-gconf-tools.h @@ -0,0 +1,41 @@ +/* Krb5 Auth Applet -- Acquire and release kerberos tickets + * + * (C) 2008,2009 Guido Guenther <agx@sigxcpu.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef KRB5_AUTH_GCONF_TOOLS_H +#define KRB5_AUTH_GCONF_TOOLS_H + +#include "config.h" + +#include <gconf/gconf-client.h> + +#define KA_GCONF_PATH "/apps/" PACKAGE +#define KA_GCONF_KEY_PRINCIPAL KA_GCONF_PATH "/principal" +#define KA_GCONF_KEY_PK_USERID KA_GCONF_PATH "/pk_userid" +#define KA_GCONF_KEY_PROMPT_MINS KA_GCONF_PATH "/prompt_minutes" +#define KA_GCONF_KEY_SHOW_TRAYICON KA_GCONF_PATH "/show_trayicon" +#define KA_GCONF_KEY_FORWARDABLE KA_GCONF_PATH "/forwardable" +#define KA_GCONF_KEY_RENEWABLE KA_GCONF_PATH "/renewable" +#define KA_GCONF_KEY_PROXIABLE KA_GCONF_PATH "/proxiable" + +gboolean ka_gconf_get_string (GConfClient* client, const char* key, char** value); +gboolean ka_gconf_get_int (GConfClient* client, const char* key, int* value); +gboolean ka_gconf_get_bool (GConfClient* client, const char* key, gboolean* value); + +#endif diff --git a/src/krb5-auth-gconf.c b/src/krb5-auth-gconf.c index 1481591..25eb555 100644 --- a/src/krb5-auth-gconf.c +++ b/src/krb5-auth-gconf.c @@ -22,94 +22,9 @@ #include <gconf/gconf-client.h> #include "krb5-auth-applet.h" +#include "krb5-auth-gconf-tools.h" #include "krb5-auth-gconf.h" -#define KA_GCONF_PATH "/apps/" PACKAGE -#define KA_GCONF_KEY_PRINCIPAL KA_GCONF_PATH "/principal" -#define KA_GCONF_KEY_PK_USERID KA_GCONF_PATH "/pk_userid" -#define KA_GCONF_KEY_PROMPT_MINS KA_GCONF_PATH "/prompt_minutes" -#define KA_GCONF_KEY_SHOW_TRAYICON KA_GCONF_PATH "/show_trayicon" - -static gboolean -ka_gconf_get_string (GConfClient* client, - const char* key, - char** value) -{ - GError* error = NULL; - gboolean success = FALSE; - GConfValue* gc_value; - - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (*value == NULL, FALSE); - - if ((gc_value = gconf_client_get (client, key, &error))) { - if (gc_value->type == GCONF_VALUE_STRING) { - *value = g_strdup (gconf_value_get_string (gc_value)); - success = TRUE; - } else if (error) { - g_print (error->message); - g_error_free (error); - } - gconf_value_free (gc_value); - } - return success; -} - - -static gboolean -ka_gconf_get_int (GConfClient* client, - const char* key, - int* value) -{ - GError* error = NULL; - gboolean success = FALSE; - GConfValue* gc_value; - - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - if ((gc_value = gconf_client_get (client, key, &error))) - { - if (gc_value->type == GCONF_VALUE_INT) { - *value = gconf_value_get_int (gc_value); - success = TRUE; - } else if (error) { - g_print (error->message); - g_error_free (error); - } - gconf_value_free (gc_value); - } - return success; -} - - -static gboolean -ka_gconf_get_bool (GConfClient* client, - const char* key, - gboolean* value) -{ - GError* error = NULL; - gboolean success = FALSE; - GConfValue* gc_value; - - g_return_val_if_fail (key != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - if ((gc_value = gconf_client_get (client, key, &error))) - { - if (gc_value->type == GCONF_VALUE_BOOL) { - *value = gconf_value_get_bool (gc_value); - success = TRUE; - } else if (error) { - g_print (error->message); - g_error_free (error); - } - gconf_value_free (gc_value); - } - return success; -} - - static gboolean ka_gconf_set_principal (GConfClient* client, KaApplet* applet) { @@ -164,6 +79,45 @@ ka_gconf_set_show_trayicon (GConfClient* client, KaApplet* applet) } +static gboolean +ka_gconf_set_tgt_forwardable (GConfClient* client, KaApplet* applet) +{ + gboolean forwardable = FALSE; + + if(!ka_gconf_get_bool(client, KA_GCONF_KEY_FORWARDABLE, &forwardable)) { + forwardable = TRUE; + } + g_object_set(applet, "tgt-forwardable", forwardable, NULL); + return TRUE; +} + + +static gboolean +ka_gconf_set_tgt_renewable (GConfClient* client, KaApplet* applet) +{ + gboolean renewable = FALSE; + + if(!ka_gconf_get_bool(client, KA_GCONF_KEY_RENEWABLE, &renewable)) { + renewable = TRUE; + } + g_object_set(applet, "tgt-renewable", renewable, NULL); + return TRUE; +} + + +static gboolean +ka_gconf_set_tgt_proxiable (GConfClient* client, KaApplet* applet) +{ + gboolean proxiable = FALSE; + + if(!ka_gconf_get_bool(client, KA_GCONF_KEY_PROXIABLE, &proxiable)) { + proxiable = TRUE; + } + g_object_set(applet, "tgt-proxiable", proxiable, NULL); + return TRUE; +} + + static void ka_gconf_key_changed_callback (GConfClient* client, guint cnxn_id G_GNUC_UNUSED, @@ -186,6 +140,12 @@ ka_gconf_key_changed_callback (GConfClient* client, ka_gconf_set_show_trayicon (client, applet); } else if (g_strcmp0 (key, KA_GCONF_KEY_PK_USERID) == 0) { ka_gconf_set_pk_userid (client, applet); + } else if (g_strcmp0 (key, KA_GCONF_KEY_FORWARDABLE) == 0) { + ka_gconf_set_tgt_forwardable (client, applet); + } else if (g_strcmp0 (key, KA_GCONF_KEY_RENEWABLE) == 0) { + ka_gconf_set_tgt_renewable (client, applet); + } else if (g_strcmp0 (key, KA_GCONF_KEY_PROXIABLE) == 0) { + ka_gconf_set_tgt_proxiable (client, applet); } else g_warning("Received notification for unknown gconf key %s", key); return; @@ -216,6 +176,9 @@ ka_gconf_init (KaApplet* applet, ka_gconf_set_prompt_mins (client, applet); ka_gconf_set_show_trayicon (client, applet); ka_gconf_set_pk_userid(client, applet); + ka_gconf_set_tgt_forwardable(client, applet); + ka_gconf_set_tgt_renewable(client, applet); + ka_gconf_set_tgt_proxiable(client, applet); success = TRUE; out: diff --git a/src/org.gnome.KrbAuthDialog.service.in b/src/org.gnome.KrbAuthDialog.service.in new file mode 100644 index 0000000..f49546a --- /dev/null +++ b/src/org.gnome.KrbAuthDialog.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.gnome.KrbAuthDialog +Exec=@BINDIR@/krb5-auth-dialog -A |