[krb5-auth-dialog] add DBus API to destroy ticket ccache



commit eede48773890ba17d15cfa93eee14cdcb276d1a0
Author: Guido Günther <agx sigxcpu org>
Date:   Tue Jun 2 01:09:04 2009 +0200

    add DBus API to destroy ticket ccache
    
    useful e.g. on laptop suspend

 ChangeLog                     |   12 ++++++++++++
 src/krb5-auth-applet-dbus.xml |    5 +++++
 src/krb5-auth-applet.c        |   24 +++++++++++++++++++-----
 src/krb5-auth-dbus.c          |   22 +++++++++++++++++-----
 src/krb5-auth-dbus.h          |    2 ++
 src/krb5-auth-dialog.c        |   11 +++++++----
 src/krb5-auth-dialog.h        |    2 +-
 7 files changed, 63 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d47a329..ad2ab9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Jun 12 18:30:03 CEST 2009 Guido Günther <agx sigxcpu org>
+
+	add DBus API to destroy ccache
+	* src/krb5-auth-applet-dbus.xml: add method
+	* src/krb5-auth-dialog.h: rename ka_dbus_destroy_cache to
+	  ka_dbus_destroy_ccache, change return value
+	* src/krb5-auth-dialog.c: likewise
+	* src/krb5-auth-dbus.h (ka_dbus_destroy_ccache): new protoype
+	* src/krb5-auth-dbus.c (ka_dbus_destroy_ccache): new function
+	* src/krb5-auth-applet.c (ka_applet_cb_destroy_ccache): use it
+	  (ka_applet_create_context_menu): use it
+
 Fri Jun 12 22:36:35 CEST 2009 Guido Günther <agx sigxcpu org>
 
 	* src/krb5-auth-applet: use _("translator-credits") in about dialog
diff --git a/src/krb5-auth-applet-dbus.xml b/src/krb5-auth-applet-dbus.xml
index eeb151d..c96126c 100644
--- a/src/krb5-auth-applet-dbus.xml
+++ b/src/krb5-auth-applet-dbus.xml
@@ -9,6 +9,11 @@
       <arg type="s" name="principal" direction="in" />
       <arg type="b" name="success" direction="out"/>
     </method>
+    <method name="destroyCCache">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="ka_dbus_destroy_ccache"/>
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg type="b" name="success" direction="out"/>
+    </method>
   </interface>
 </node>
 
diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c
index 99928c8..e4f0c1a 100644
--- a/src/krb5-auth-applet.c
+++ b/src/krb5-auth-applet.c
@@ -627,6 +627,15 @@ ka_applet_cb_show_help (GtkMenuItem* menuitem G_GNUC_UNUSED,
 }
 
 
+static void
+ka_applet_cb_destroy_ccache(GtkMenuItem* menuitem G_GNUC_UNUSED,
+			    gpointer user_data)
+{
+	KaApplet *applet = KA_APPLET(user_data);
+	ka_destroy_ccache(applet);
+}
+
+
 /* The tray icon's context menu */
 static gboolean
 ka_applet_create_context_menu (KaApplet* applet)
@@ -639,7 +648,8 @@ ka_applet_create_context_menu (KaApplet* applet)
 
 	/* kdestroy */
 	menu_item = gtk_image_menu_item_new_with_mnemonic (_("Remove Credentials _Cache"));
-	g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_destroy_cache), applet);
+	g_signal_connect (G_OBJECT (menu_item), "activate",
+			  G_CALLBACK (ka_applet_cb_destroy_ccache), applet);
 	image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, 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);
@@ -648,21 +658,24 @@ ka_applet_create_context_menu (KaApplet* applet)
 
 	/* 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);
+	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 (_("_Help"));
-	g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_show_help), applet);
+	g_signal_connect (G_OBJECT (menu_item), "activate",
+			  G_CALLBACK (ka_applet_cb_show_help), applet);
 	image = gtk_image_new_from_stock (GTK_STOCK_HELP, 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);
+	g_signal_connect (G_OBJECT (menu_item), "activate",
+			  G_CALLBACK (ka_applet_cb_about_dialog), applet);
 	image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, 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);
@@ -671,7 +684,8 @@ ka_applet_create_context_menu (KaApplet* applet)
 
 	/* Quit */
 	menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Quit"));
-	g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (ka_applet_cb_quit), applet);
+	g_signal_connect (G_OBJECT (menu_item), "activate",
+			  G_CALLBACK (ka_applet_cb_quit), applet);
 	image = gtk_image_new_from_stock (GTK_STOCK_QUIT, 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);
diff --git a/src/krb5-auth-dbus.c b/src/krb5-auth-dbus.c
index 52dab46..4fd7e74 100644
--- a/src/krb5-auth-dbus.c
+++ b/src/krb5-auth-dbus.c
@@ -32,12 +32,24 @@ gboolean
 ka_dbus_acquire_tgt (KaApplet *applet,
 		     const gchar *principal, DBusGMethodInvocation *context)
 {
-       gboolean success;
+	 gboolean success;
 
-       KA_DEBUG("Getting TGT for '%s'", principal);
-       success = ka_check_credentials(applet, principal);
-       dbus_g_method_return(context, success);
-       return TRUE;
+	 KA_DEBUG("Getting TGT for '%s'", principal);
+	 success = ka_check_credentials(applet, principal);
+	 dbus_g_method_return(context, success);
+	 return TRUE;
+}
+
+
+gboolean
+ka_dbus_destroy_ccache(KaApplet* applet, DBusGMethodInvocation *context)
+{
+	gboolean success;
+
+	KA_DEBUG("Destroying ticket cache");
+	success = ka_destroy_ccache (applet);
+	dbus_g_method_return(context, success);
+	return TRUE;
 }
 
 
diff --git a/src/krb5-auth-dbus.h b/src/krb5-auth-dbus.h
index 2f0af61..0d3acd0 100644
--- a/src/krb5-auth-dbus.h
+++ b/src/krb5-auth-dbus.h
@@ -31,5 +31,7 @@ gboolean ka_dbus_service(KaApplet* applet);
 gboolean ka_dbus_acquire_tgt (KaApplet *applet,
 			      const gchar *principal,
 			      DBusGMethodInvocation *context);
+gboolean ka_dbus_destroy_ccache(KaApplet* applet,
+			        DBusGMethodInvocation *context);
 
 #endif /* KRB5_AUTH_DBUS_H */
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c
index 7415b47..f163cd7 100644
--- a/src/krb5-auth-dialog.c
+++ b/src/krb5-auth-dialog.c
@@ -787,11 +787,9 @@ using_krb5(void)
 }
 
 
-void
-ka_destroy_cache (GtkMenuItem  *menuitem G_GNUC_UNUSED,
-		  gpointer data)
+gboolean
+ka_destroy_ccache (KaApplet *applet)
 {
-	KaApplet *applet = KA_APPLET(data);
 	krb5_ccache  ccache;
 	const char* cache;
 	krb5_error_code ret;
@@ -801,6 +799,11 @@ ka_destroy_cache (GtkMenuItem  *menuitem G_GNUC_UNUSED,
 	ret = krb5_cc_destroy (kcontext, ccache);
 
 	credentials_expiring_real(applet);
+
+	if (ret)
+		return FALSE;
+	else
+		return TRUE;
 }
 
 
diff --git a/src/krb5-auth-dialog.h b/src/krb5-auth-dialog.h
index 3e1219d..814f617 100644
--- a/src/krb5-auth-dialog.h
+++ b/src/krb5-auth-dialog.h
@@ -23,7 +23,7 @@
 
 #include "krb5-auth-applet.h"
 
-void ka_destroy_cache (GtkMenuItem  *menuitem, gpointer user_data);
+gboolean ka_destroy_ccache (KaApplet* applet);
 gboolean ka_grab_credentials(KaApplet* applet);
 gboolean ka_check_credentials (KaApplet *applet, const char* principal);
 int ka_tgt_valid_seconds(void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]