Initial version of GKrb5Context
This commit is contained in:
parent
f07c00f618
commit
811c5848d1
97
gerberos/gkrb5context.c
Normal file
97
gerberos/gkrb5context.c
Normal file
@ -0,0 +1,97 @@
|
||||
/* Gerberos - Kerberos GLib bindings
|
||||
*
|
||||
* Copyright (C) 2009 Gergely Polonkai
|
||||
*
|
||||
*/
|
||||
|
||||
#include <krb5.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
60
gerberos/gkrb5context.h
Normal file
60
gerberos/gkrb5context.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* Gerberos - Kerberos GLib bindings
|
||||
*
|
||||
* Copyright (C) 2009 Gergely Polonkai
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined (__GERBEROS_GERBEROS_H_INSIDE__) && !defined (GERBEROS_COMPILATION)
|
||||
# error "Only <gerberos/gerberos.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __G_KRB5_CONTEXT_H__
|
||||
#define __G_KRB5_CONTEXT_H__
|
||||
|
||||
#include <gerberos/gerberos.h>
|
||||
|
||||
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__ */
|
Loading…
Reference in New Issue
Block a user