commit 42d2d2d50173c05a912a66cb2f71a8ed3cf2192c
Author: Priit Laes <plaes@plaes.org>
Date:   Mon Sep 10 18:49:43 2012 +0300

    Make Kerberos requirement optional

diff --git a/configure.ac b/configure.ac
index 8f0a905..c758dbc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -245,17 +245,23 @@ PKG_CHECK_MODULES(ISOCODES, iso-codes)
 AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
 ISO_CODES=iso-codes
 
-# Kerberos kerberos support
-AC_PATH_PROG(KRB5_CONFIG, krb5-config, no)
-if test "$KRB5_CONFIG" = "no"; then
-  AC_MSG_ERROR([krb5-config executable not found in your path - should be installed with the kerberos libraries])
-fi
-
-AC_MSG_CHECKING(for krb5 libraries and flags)
-KRB5_CFLAGS="`$KRB5_CONFIG --cflags`"
-KRB5_LIBS="`$KRB5_CONFIG --libs`"
-AC_MSG_RESULT($KRB5_CFLAGS $KRB5_LIBS)
+# Kerberos support
+AC_ARG_WITH([kerberos],
+              AS_HELP_STRING([--with-kerberos], [build with kerberos support (default: yes)]),,
+              [with_kerberos=yes])
+
+if test x"$with_kerberos" != x"no" ; then
+    AC_PATH_PROG(KRB5_CONFIG, krb5-config, no)
+    if test "$KRB5_CONFIG" = "no"; then
+      AC_MSG_ERROR([krb5-config executable not found in your path - should be installed with the kerberos libraries])
+    fi
 
+    AC_MSG_CHECKING(for krb5 libraries and flags)
+    KRB5_CFLAGS="`$KRB5_CONFIG --cflags`"
+    KRB5_LIBS="`$KRB5_CONFIG --libs`"
+    AC_MSG_RESULT($KRB5_CFLAGS $KRB5_LIBS)
+fi
+AM_CONDITIONAL(HAVE_KERBEROS, [test x"$with_kerberos" = "xyes"])
 AC_SUBST(KRB5_CFLAGS)
 AC_SUBST(KRB5_LIBS)
 
@@ -513,10 +519,15 @@ if test "x$with_libsocialweb" = "xyes"; then
 else
 	AC_MSG_NOTICE([   Background panel Flickr support disabled])
 fi
+if test "x$with_kerberos" = "xyes"; then
+    AC_MSG_NOTICE([** Kerberos (Extra authentication protocols)])
+else
+    AC_MSG_NOTICE([   Kerberos support disabled])
+fi
 if test "x$have_wacom" = "xyes"; then
-	AC_MSG_NOTICE([** wacom (Wacom tablet panel)])
+	AC_MSG_NOTICE([** libwacom (Wacom Graphics Tablet panel)])
 else
-	AC_MSG_NOTICE([   Wacom panel disabled])
+	AC_MSG_NOTICE([   Wacom Graphics Tablet panel disabled])
 fi
 if test "x$enable_ibus" == "xyes"; then
 	AC_MSG_NOTICE([** IBus (Region panel IBus support)])
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index ee85cdf..f24fe1a 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -23,9 +23,7 @@ if BUILD_CHEESE
 AM_CPPFLAGS += $(CHEESE_CFLAGS)
 endif
 
-BUILT_SOURCES = \
-       um-realm-generated.c \
-       um-realm-generated.h
+BUILT_SOURCES =
 
 libuser_accounts_la_SOURCES =		\
 	um-account-type.h		\
@@ -57,10 +55,17 @@ libuser_accounts_la_SOURCES =		\
 	um-editable-combo.c		\
 	um-user-panel.h 		\
 	um-user-panel.c			\
-	um-user-module.c		\
+	um-user-module.c
+
+if HAVE_KERBEROS
+libuser_accounts_la_SOURCES +=		\
 	um-realm-manager.c		\
-	um-realm-manager.h		\
-	$(BUILT_SOURCES)
+	um-realm-manager.h
+BUILT_SOURCES += \
+       um-realm-generated.c \
+       um-realm-generated.h
+endif
+
 
 libuser_accounts_la_LIBADD = 		\
 	$(PANEL_LIBS)			\
@@ -89,15 +94,19 @@ frob_account_dialog_SOURCES = \
 	frob-account-dialog.c \
 	um-account-dialog.h \
 	um-account-dialog.c \
-	um-realm-manager.c \
-	um-realm-manager.h \
 	um-user.h \
 	um-user.c \
 	um-user-manager.c \
 	um-user-manager.h \
 	um-utils.h \
-	um-utils.c \
+	um-utils.c
+
+if HAVE_KERBEROS
+frob_account_dialog_SOURCES += \
+	um-realm-manager.c \
+	um-realm-manager.h \
 	$(BUILT_SOURCES)
+endif
 
 frob_account_dialog_LDADD = \
 	$(libuser_accounts_la_LIBADD)
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 36a0e43..30a37cb 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -26,13 +26,18 @@
 #include <gtk/gtk.h>
 
 #include "um-account-dialog.h"
-#include "um-realm-manager.h"
 #include "um-user-manager.h"
 #include "um-utils.h"
 
+#ifdef HAVE_KERBEROS
+#include "um-realm-manager.h"
+#endif
+
 typedef enum {
         UM_LOCAL,
+#ifdef HAVE_KERBEROS
         UM_ENTERPRISE,
+#endif /* HAVE_KERBEROS */
         NUM_MODES
 } UmAccountMode;
 
@@ -41,6 +46,7 @@ static void   mode_change          (UmAccountDialog *self,
 
 static void   dialog_validate      (UmAccountDialog *self);
 
+#ifdef HAVE_KERBEROS
 static void   on_join_login        (GObject *source,
                                     GAsyncResult *result,
                                     gpointer user_data);
@@ -48,6 +54,7 @@ static void   on_join_login        (GObject *source,
 static void   on_realm_joined      (GObject *source,
                                     GAsyncResult *result,
                                     gpointer user_data);
+#endif /* HAVE_KERBEROS */
 
 #define UM_ACCOUNT_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), UM_TYPE_ACCOUNT_DIALOG, \
                                                                     UmAccountDialogClass))
@@ -74,6 +81,7 @@ struct _UmAccountDialog {
         GtkWidget *local_name;
         GtkWidget *local_account_type;
 
+#ifdef HAVE_KERBEROS
         /* Enterprise widgets */
         guint realmd_watch;
         GtkWidget *enterprise_button;
@@ -92,6 +100,7 @@ struct _UmAccountDialog {
         GtkEntry *join_name;
         GtkEntry *join_password;
         gboolean join_prompted;
+#endif /* HAVE_KERBEROS */
 };
 
 struct _UmAccountDialogClass {
@@ -300,6 +309,7 @@ local_prepare (UmAccountDialog *self)
         gtk_combo_box_set_active (GTK_COMBO_BOX (self->local_account_type), 0);
 }
 
+#ifdef HAVE_KERBEROS
 static gboolean
 enterprise_validate (UmAccountDialog *self)
 {
@@ -504,7 +514,6 @@ on_join_response (GtkDialog *dialog,
                         on_join_login,
                         g_object_ref (self));
 }
-
 static void
 join_show_prompt (UmAccountDialog *self,
                   GError *error)
@@ -892,6 +901,7 @@ enterprise_prepare (UmAccountDialog *self)
         gtk_entry_set_text (GTK_ENTRY (self->enterprise_login), "");
         gtk_entry_set_text (GTK_ENTRY (self->enterprise_password), "");
 }
+#endif /* HAVE_KERBEROS */
 
 static void
 dialog_validate (UmAccountDialog *self)
@@ -902,9 +912,11 @@ dialog_validate (UmAccountDialog *self)
         case UM_LOCAL:
                 valid = local_validate (self);
                 break;
+#ifdef HAVE_KERBEROS
         case UM_ENTERPRISE:
                 valid = enterprise_validate (self);
                 break;
+#endif /* HAVE_KERBEROS */
         default:
                 valid = FALSE;
                 break;
@@ -990,12 +1002,14 @@ on_local_toggle (GtkToggleButton *toggle,
         mode_toggled (UM_ACCOUNT_DIALOG (user_data), toggle, UM_LOCAL);
 }
 
+#ifdef HAVE_KERBEROS
 static void
 on_enterprise_toggle (GtkToggleButton *toggle,
                       gpointer user_data)
 {
         mode_toggled (UM_ACCOUNT_DIALOG (user_data), toggle, UM_ENTERPRISE);
 }
+#endif /* HAVE_KERBEROS */
 
 static void
 mode_init (UmAccountDialog *self,
@@ -1007,15 +1021,19 @@ mode_init (UmAccountDialog *self,
 
         widget = (GtkWidget *) gtk_builder_get_object (builder, "local-area");
         self->mode_areas[UM_LOCAL] = widget;
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-area");
-        self->mode_areas[UM_ENTERPRISE] = widget;
 
         widget = (GtkWidget *) gtk_builder_get_object (builder, "local-button");
         g_signal_connect (widget, "toggled", G_CALLBACK (on_local_toggle), self);
         self->mode_buttons[UM_LOCAL] = widget;
+
+#ifdef HAVE_KERBEROS
+        widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-area");
+        self->mode_areas[UM_ENTERPRISE] = widget;
+
         widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-button");
         g_signal_connect (widget, "toggled", G_CALLBACK (on_enterprise_toggle), self);
         self->mode_buttons[UM_ENTERPRISE] = widget;
+#endif /* HAVE_KERBEROS */
 }
 
 static void
@@ -1075,8 +1093,10 @@ um_account_dialog_init (UmAccountDialog *self)
         self->container_widget = widget;
 
         local_init (self, builder);
+#ifdef HAVE_KERBEROS
         enterprise_init (self, builder);
         join_init (self, builder);
+#endif /* HAVE_KERBEROS */
         mode_init (self, builder);
 
         g_object_unref (builder);
@@ -1094,9 +1114,11 @@ um_account_dialog_response (GtkDialog *dialog,
                 case UM_LOCAL:
                         local_create_user (self);
                         break;
+#ifdef HAVE_KERBEROS
                 case UM_ENTERPRISE:
                         enterprise_add_user (self);
                         break;
+#endif /* HAVE_KERBEROS */
                 default:
                         g_assert_not_reached ();
                 }
@@ -1117,6 +1139,7 @@ um_account_dialog_dispose (GObject *obj)
         if (self->cancellable)
                 g_cancellable_cancel (self->cancellable);
 
+#ifdef HAVE_KERBEROS
         if (self->realmd_watch)
                 g_bus_unwatch_name (self->realmd_watch);
         self->realmd_watch = 0;
@@ -1128,6 +1151,7 @@ um_account_dialog_dispose (GObject *obj)
                 g_object_unref (self->realm_manager);
                 self->realm_manager = NULL;
         }
+#endif /* HAVE_KERBEROS */
 
         G_OBJECT_CLASS (um_account_dialog_parent_class)->dispose (obj);
 }
@@ -1139,7 +1163,9 @@ um_account_dialog_finalize (GObject *obj)
 
         if (self->cancellable)
                 g_object_unref (self->cancellable);
+#ifdef HAVE_KERBEROS
         g_object_unref (self->enterprise_realms);
+#endif /* HAVE_KERBEROS */
 
         G_OBJECT_CLASS (um_account_dialog_parent_class)->finalize (obj);
 }
@@ -1181,7 +1207,9 @@ um_account_dialog_show (UmAccountDialog     *self,
         self->cancellable = g_cancellable_new ();
 
         local_prepare (self);
+#ifdef HAVE_KERBEROS
         enterprise_prepare (self);
+#endif /* HAVE_KERBEROS */
         mode_change (self, UM_LOCAL);
         dialog_validate (self);
 
