From 4adb97eab661e553656a9da3d976cd7447e7b431 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Thu, 2 Aug 2012 13:20:55 +0300 Subject: [PATCH] Remove dependency on dbus-glib --- configure.ac | 4 +- libsignon-glib/Makefile.am | 2 - libsignon-glib/signon-errors.c | 37 ------ libsignon-glib/signon-identity-info.c | 158 -------------------------- libsignon-glib/signon-internals.h | 17 --- libsignon-glib/signon-marshal.list | 1 - libsignon-glib/signon-proxy.c | 107 ----------------- libsignon-glib/signon-proxy.h | 61 ---------- tests/check_signon.c | 3 - 9 files changed, 1 insertion(+), 389 deletions(-) delete mode 100644 libsignon-glib/signon-proxy.c delete mode 100644 libsignon-glib/signon-proxy.h diff --git a/configure.ac b/configure.ac index c513e5e..fae8e3b 100644 --- a/configure.ac +++ b/configure.ac @@ -15,9 +15,7 @@ PKG_CHECK_MODULES( gio-unix-2.0 glib-2.0 >= 2.32 gobject-2.0 - dbus-1 - dbus-glib-1 - signond >= 8.40); + signond >= 8.40); AC_SUBST(DEPS_CFLAGS) AC_SUBST(DEPS_LIBS) diff --git a/libsignon-glib/Makefile.am b/libsignon-glib/Makefile.am index 5483b21..6783003 100644 --- a/libsignon-glib/Makefile.am +++ b/libsignon-glib/Makefile.am @@ -45,8 +45,6 @@ libsignon_glib_la_SOURCES = \ signon-auth-session.c \ signon-errors.h \ signon-errors.c \ - signon-proxy.h \ - signon-proxy.c \ signon-utils.h \ signon-utils.c \ sso-auth-service.c \ diff --git a/libsignon-glib/signon-errors.c b/libsignon-glib/signon-errors.c index 622e2d6..6ecde09 100644 --- a/libsignon-glib/signon-errors.c +++ b/libsignon-glib/signon-errors.c @@ -27,7 +27,6 @@ #include "signon-enum-types.h" #include "signon-internals.h" #include "signoncommon.h" -#include #include /** @@ -51,39 +50,3 @@ GQuark signon_error_quark (void) G_N_ELEMENTS (signon_error_entries)); return (GQuark) quark; } - -GError * -_signon_errors_get_error_from_dbus (GError *error) -{ - const gchar *error_name; - const gchar *nick; - GType enum_type; - GEnumClass *enum_class; - GEnumValue *enum_value; - GError *new_error; - gint code = SIGNON_ERROR_UNKNOWN; - - if (error == NULL) - return NULL; - - error_name = dbus_g_error_get_name (error); - - if (!g_str_has_prefix (error_name, SIGNON_ERROR_PREFIX)) - return error; - - nick = error_name + sizeof(SIGNON_ERROR_PREFIX); - - enum_type = signon_error_get_type (); - enum_class = g_type_class_ref (enum_type); - enum_value = g_enum_get_value_by_nick (enum_class, nick); - - if (enum_value) - code = enum_value->value; - - new_error = g_error_new_literal (SIGNON_ERROR, code, error->message); - - g_error_free (error); - g_type_class_unref (enum_class); - - return new_error; -} diff --git a/libsignon-glib/signon-identity-info.c b/libsignon-glib/signon-identity-info.c index e0f5d76..bd7fd79 100644 --- a/libsignon-glib/signon-identity-info.c +++ b/libsignon-glib/signon-identity-info.c @@ -86,164 +86,6 @@ void signon_identity_info_set_methods (SignonIdentityInfo *info, g_hash_table_foreach ((GHashTable *)methods, identity_methods_copy, info); } -static void -add_method (gpointer key, gpointer value, gpointer user_data) -{ - gchar **stringarray = (gchar **)value; - g_hash_table_insert ((GHashTable *)user_data, g_strdup((gchar *)key), - g_strdupv (stringarray)); -} - -SignonIdentityInfo * -signon_identity_info_new_from_hash_table (GHashTable *map) -{ - if (!map) - return NULL; - - SignonIdentityInfo *info = signon_identity_info_new (); - - DEBUG("%s: ", G_STRFUNC); - GValue *value; - - /* get the id (gint) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_ID); - if (value != NULL) - { - g_assert (G_VALUE_HOLDS_UINT (value)); - identity_info_set_id (info, g_value_get_uint (value)); - } - - /* get the user name (gchar*) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_USERNAME); - if (value != NULL) - { - g_assert (G_VALUE_HOLDS_STRING (value)); - signon_identity_info_set_username (info, g_value_get_string (value)); - } - - /* get the password (gchar*) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_SECRET); - if (value != NULL) - { - GValue *v_store_secret; - gboolean store_secret; - - g_assert (G_VALUE_HOLDS_STRING (value)); - - v_store_secret = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_STORESECRET); - store_secret = (v_store_secret != NULL) ? - g_value_get_boolean (v_store_secret) : FALSE; - - signon_identity_info_set_secret (info, g_value_get_string (value), - store_secret); - } - - /* get the caption (gchar*) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_CAPTION); - if (value != NULL) - { - g_assert (G_VALUE_HOLDS_STRING (value)); - signon_identity_info_set_caption (info, g_value_get_string (value)); - } - - /* get the realms (gchar**) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_REALMS); - if (value != NULL) - { - g_assert (G_VALUE_TYPE (value) == G_TYPE_STRV); - signon_identity_info_set_realms (info, - (const gchar* const *) - g_value_get_boxed (value)); - } - - /* get the methods */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_AUTHMETHODS); - if (value != NULL) - { - g_assert (G_VALUE_HOLDS_BOXED (value)); - g_assert (G_VALUE_TYPE (value) == - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRV)); - - info->methods = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify)g_strfreev); - g_hash_table_foreach ((GHashTable *)g_value_get_boxed(value), - add_method, - info->methods); - } - - /* get the accessControlList (gchar**) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_ACL); - if (value != NULL) - { - g_assert (G_VALUE_TYPE (value) == G_TYPE_STRV); - signon_identity_info_set_access_control_list (info, - (const gchar* const *) - g_value_get_boxed (value)); - } - - /* get the type (gint) */ - value = g_hash_table_lookup (map, SIGNOND_IDENTITY_INFO_TYPE); - if (value != NULL) - { - g_assert (G_VALUE_HOLDS_INT(value)); - signon_identity_info_set_identity_type (info, g_value_get_int (value)); - } - - return info; -} - -GHashTable * -signon_identity_info_to_hash_table (const SignonIdentityInfo *self) -{ - GHashTable *map; - GValue *value; - GType type; - - map = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, - signon_gvalue_free); - - value = signon_gvalue_new (G_TYPE_UINT); - g_value_set_uint (value, self->id); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_ID, value); - - value = signon_gvalue_new (G_TYPE_STRING); - g_value_set_string (value, self->username); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_USERNAME, value); - - value = signon_gvalue_new (G_TYPE_STRING); - g_value_set_string (value, self->secret); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_SECRET, value); - - value = signon_gvalue_new (G_TYPE_STRING); - g_value_set_string (value, self->caption); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_CAPTION, value); - - value = signon_gvalue_new (G_TYPE_BOOLEAN); - g_value_set_boolean (value, self->store_secret); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_STORESECRET, value); - - type = dbus_g_type_get_map ("GHashTable", - G_TYPE_STRING, G_TYPE_STRV); - value = signon_gvalue_new (type); - g_value_set_boxed (value, self->methods); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_AUTHMETHODS, value); - - value = signon_gvalue_new (G_TYPE_STRV); - g_value_set_boxed (value, self->realms); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_REALMS, value); - - value = signon_gvalue_new (G_TYPE_STRV); - g_value_set_boxed (value, self->access_control_list); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_ACL, value); - - value = signon_gvalue_new (G_TYPE_INT); - g_value_set_int (value, self->type); - g_hash_table_insert (map, SIGNOND_IDENTITY_INFO_TYPE, value); - - return map; -} - SignonIdentityInfo * signon_identity_info_new_from_variant (GVariant *variant) { diff --git a/libsignon-glib/signon-internals.h b/libsignon-glib/signon-internals.h index 8fefbce..c93c0d6 100644 --- a/libsignon-glib/signon-internals.h +++ b/libsignon-glib/signon-internals.h @@ -37,7 +37,6 @@ #endif #include -#include #include "signon-identity.h" #include "signon-auth-session.h" @@ -57,10 +56,6 @@ struct _SignonIdentityInfo gint type; }; -G_GNUC_INTERNAL -SignonIdentityInfo * -signon_identity_info_new_from_hash_table (GHashTable *map); - G_GNUC_INTERNAL SignonIdentityInfo * signon_identity_info_new_from_variant (GVariant *variant); @@ -69,22 +64,10 @@ G_GNUC_INTERNAL GVariant * signon_identity_info_to_variant (const SignonIdentityInfo *self); -G_GNUC_INTERNAL -GHashTable * -signon_identity_info_to_hash_table (const SignonIdentityInfo *self); - G_GNUC_INTERNAL void signon_identity_info_set_methods (SignonIdentityInfo *self, const GHashTable *methods); -G_GNUC_INTERNAL -void _signon_identity_registered (SignonIdentity *identity, DBusGProxy *proxy, - char *objectPath, GPtrArray *identityArray, - GError *error); - -G_GNUC_INTERNAL -GError *_signon_errors_get_error_from_dbus (GError *error); - G_GNUC_INTERNAL void signon_auth_session_set_id(SignonAuthSession* self, gint32 id); diff --git a/libsignon-glib/signon-marshal.list b/libsignon-glib/signon-marshal.list index f9dbce5..70ef299 100644 --- a/libsignon-glib/signon-marshal.list +++ b/libsignon-glib/signon-marshal.list @@ -1,3 +1,2 @@ -VOID:POINTER,UINT,BOXED VOID:INT,STRING diff --git a/libsignon-glib/signon-proxy.c b/libsignon-glib/signon-proxy.c deleted file mode 100644 index d14bdf5..0000000 --- a/libsignon-glib/signon-proxy.c +++ /dev/null @@ -1,107 +0,0 @@ -/* vi: set et sw=4 ts=4 cino=t0,(0: */ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of libsignon-glib - * - * Copyright (C) 2009-2010 Nokia Corporation. - * - * Contact: Alberto Mardegan - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include "signon-proxy.h" -#include "signon-internals.h" -#include - -G_DEFINE_TYPE (SignonProxy, signon_proxy, DBUS_TYPE_G_PROXY); - -static SignonProxy *signon_proxy = NULL; - -static void -signon_proxy_init (SignonProxy *self) -{ -} - -static GObject * -signon_proxy_constructor (GType type, guint n_params, - GObjectConstructParam *params) -{ - GObjectClass *object_class = - (GObjectClass *)signon_proxy_parent_class; - GObject *object; - - if (!signon_proxy) - { - object = object_class->constructor (type, - n_params, - params); - signon_proxy = SIGNON_PROXY (object); - } - else - object = g_object_ref (G_OBJECT (signon_proxy)); - - return object; -} - -static void -signon_proxy_dispose (GObject *object) -{ - G_OBJECT_CLASS (signon_proxy_parent_class)->dispose (object); -} - -static void -signon_proxy_finalize (GObject *object) -{ - G_OBJECT_CLASS (signon_proxy_parent_class)->finalize (object); - signon_proxy = NULL; -} - -static void -signon_proxy_class_init (SignonProxyClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = signon_proxy_dispose; - object_class->constructor = signon_proxy_constructor; - object_class->finalize = signon_proxy_finalize; -} - -SignonProxy * -signon_proxy_new () -{ - SignonProxy *proxy; - GError *error = NULL; - - DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - - if (error) - { - g_warning ("%s returned error: %s", G_STRFUNC, error->message); - g_error_free (error); - return NULL; - } - - proxy = g_object_new (SIGNON_TYPE_PROXY, - "name", SIGNOND_SERVICE, - "path", SIGNOND_DAEMON_OBJECTPATH, - "interface", SIGNOND_DAEMON_INTERFACE, - "connection", connection, - NULL); - - dbus_g_connection_unref (connection); - - return proxy; -} diff --git a/libsignon-glib/signon-proxy.h b/libsignon-glib/signon-proxy.h deleted file mode 100644 index 4ef973b..0000000 --- a/libsignon-glib/signon-proxy.h +++ /dev/null @@ -1,61 +0,0 @@ -/* vi: set et sw=4 ts=4 cino=t0,(0: */ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of libsignon-glib - * - * Copyright (C) 2009-2010 Nokia Corporation. - * - * Contact: Alberto Mardegan - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef _SIGNON_AUTH_PROXY_H_ -#define _SIGNON_AUTH_PROXY_H_ - - -#include -#include - -#define SIGNON_TYPE_PROXY (signon_proxy_get_type ()) -#define SIGNON_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_PROXY, SignonProxy)) -#define SIGNON_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_PROXY, SignonProxyClass)) -#define SIGNON_IS_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_PROXY)) -#define SIGNON_IS_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_PROXY)) -#define SIGNON_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_PROXY, SignonProxyClass)) - - -typedef struct _SignonProxyClass SignonProxyClass; -typedef struct _SignonProxy SignonProxy; - -struct _SignonProxyClass -{ - DBusGProxyClass parent_class; -}; - -struct _SignonProxy -{ - DBusGProxyClass parent_instance; -}; - -G_GNUC_INTERNAL -GType signon_proxy_get_type (void) G_GNUC_CONST; - -G_GNUC_INTERNAL -SignonProxy *signon_proxy_new (); - -G_END_DECLS - -#endif /* _SIGNON_PROXY_H_ */ diff --git a/tests/check_signon.c b/tests/check_signon.c index 485e742..e1c2f00 100644 --- a/tests/check_signon.c +++ b/tests/check_signon.c @@ -30,15 +30,12 @@ #include "libsignon-glib/signon-auth-service.h" #include "libsignon-glib/signon-auth-session.h" #include "libsignon-glib/signon-identity.h" -#include "libsignon-glib/signon-client-glib-gen.h" -#include "libsignon-glib/signon-identity-glib-gen.h" #include "libsignon-glib/signon-errors.h" #include #include #include #include -#include static GMainLoop *main_loop = NULL; static SignonIdentity *identity = NULL; -- 2.34.1