From 811c5848d180e2f8b77a3b2fc7bf7be6dec73da0 Mon Sep 17 00:00:00 2001 From: POLONKAI Gergely Date: Fri, 4 Sep 2009 23:50:31 +0200 Subject: [PATCH] Initial version of GKrb5Context --- gerberos/gkrb5context.c | 97 +++++++++++++++++++++++++++++++++++++++++ gerberos/gkrb5context.h | 60 +++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 gerberos/gkrb5context.c create mode 100644 gerberos/gkrb5context.h diff --git a/gerberos/gkrb5context.c b/gerberos/gkrb5context.c new file mode 100644 index 0000000..0a68c5d --- /dev/null +++ b/gerberos/gkrb5context.c @@ -0,0 +1,97 @@ +/* Gerberos - Kerberos GLib bindings + * + * Copyright (C) 2009 Gergely Polonkai + * + */ + +#include + +#include "gkrb5context.h" + +#undef g_krb5_context + +G_DEFINE_ABSTRACT_TYPE (GKrb5Context, g_krb5_context, G_TYPE_OBJECT); + +struct _GKrb5ContextPrivate { + krb5_context kerberos_context; + + GMainContext *context; +}; + +static void +g_krb5_context_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + GKrb5Context *kerberos_context; + + kerberos_context = G_KRB5_CONTEXT(object); + + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +g_krb5_context_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GKrb5Context *kerberos_context; + GKrb5ContextPrivate *priv; + + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static guint signals[LAST_SIGNAL] = { 0 }; + +static void +g_krb5_context_finalize (GObject *object) +{ + GKrb5Context *kerberos_context; + + kerberos_context = G_KRB5_CONTEXT(object); + + if (kerberos_context->priv->context) + g_main_context_unref(kerberos_context->priv->context); + + G_OBJECT_CLASS(g_krb5_context_parent_class)->finalize(object); +} + +static void +g_krb5_context_dispose(GObject *object) +{ + GKrb5Context *kerberos_context; + GKrb5Context *priv; + + kerberos_context = G_KRB5_CONTEXT(object); + priv = kerberos_context->priv; + + G_OBJECT_CLASS(g_krb5_context_parent_class)->dispose(object); +} + +static void +g_krb5_context_class_init(GKrb5ContextClass *klass) +{ + GObjectClass *object_class; + + g_type_class_add_private(klass, sizeof(GKrb5ContextPrivate)); + + object_class = G_OBJECT_CLASS(klass); + object_class->finalize = g_krb5_context_finalize; + object_class->dispose = g_krb5_context_dispose; + object_class->get_property = g_krb5_context_get_property; + object_class->set_property = g_krb5_context_set_property; +} + +static void +g_krb5_context_init(GKrb5Context *kerberos_context) +{ + kerberos_context->priv = G_TYPE_INSTANCE_GET_PRIVATE(kerberos_context, G_TYPE_KRB5_CONTEXT, GKrb5ContextPrivate); + kertberos_context->priv->context = g_main_context_get_thread_default(); +} + diff --git a/gerberos/gkrb5context.h b/gerberos/gkrb5context.h new file mode 100644 index 0000000..fef1789 --- /dev/null +++ b/gerberos/gkrb5context.h @@ -0,0 +1,60 @@ +/* Gerberos - Kerberos GLib bindings + * + * Copyright (C) 2009 Gergely Polonkai + * + */ + +#if !defined (__GERBEROS_GERBEROS_H_INSIDE__) && !defined (GERBEROS_COMPILATION) +# error "Only can be included directly." +#endif + +#ifndef __G_KRB5_CONTEXT_H__ +#define __G_KRB5_CONTEXT_H__ + +#include + +G_BEGIN_DECLS + +#define G_TYPEKRB5_CONTEXT (g_krb5_context_get_type ()) +#define G_KRB5_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_KRB5_CONTEXT, GKrb5Context)) +#define G_KRB5_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_KRB5_CONTEXT, GKrb5ContextClass)) +#define G_IS_KRB5_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_KRB5_CONTEXT)) +#define G_IS_KRB5_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_KRB5_CONTEXT)) +#define G_KRB5_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_KRB5_CONTEXT, GKrb5ContextClass)) + +typedef struct _GKrb5ContextClass GKrb5ContextClass; +typedef struct _GKrb5ContextPrivate GKrb5ContextPrivate; + +/** + * GKrb5Context + * + * Manages krb5_contexts (per process state) + **/ +struct _GKrb5Context +{ + GObject parent_instance; + + /*< private >*/ + GKrb5ContextPrivate *priv; +}; + +struct _GKrb5ContextClass +{ + GObjectClass parent_class; + + /* Signals */ + + /*< private >*/ + /* Padding for future expansion */ + void (*_g_reserved1) (void); + void (*_g_reserved2) (void); + void (*_g_reserved3) (void); + void (*_g_reserved4) (void); + void (*_g_reserved5) (void); +}; + +GType g_krb5_context_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_KRB5_CONTEXT_H__ */