Commit 9934e8fd authored by Alexander Kanavin's avatar Alexander Kanavin

Merge branch 'less-typedef' into 'master'

Don't use custom typedefs, use annotations instead

Once the annotations are added there is no point on creating a typedef anymore.
This fixes the introspection problems (that the 3 typedef weren't real classes)

See merge request !6
parents 021141f0 a8f24bdb
......@@ -116,7 +116,7 @@ static void query_auth_mechanisms(GMainLoop* main_loop, const gchar* method)
}
static void signon_query_identities_cb (SignonAuthService *auth_service,
SignonIdentityList *identity_list, const GError *error, gpointer user_data)
GList *identity_list, const GError *error, gpointer user_data)
{
GList *iter = identity_list;
......@@ -136,7 +136,7 @@ static void signon_query_identities_cb (SignonAuthService *auth_service,
signon_identity_info_get_id (info),
signon_identity_info_get_caption (info));
SignonSecurityContextList *acl = signon_identity_info_get_access_control_list(info);
GList *acl = signon_identity_info_get_access_control_list(info);
for(acl = g_list_first(acl); acl != NULL; acl = g_list_next(acl)) {
const SignonSecurityContext *context = acl->data;
g_print(" (%s:%s)", signon_security_context_get_system_context(context),
......@@ -375,17 +375,22 @@ static void append_acl(GMainLoop* main_loop, gint identity_id, SignonSecurityCon
static void remove_acl_cb(SignonIdentity *self, SignonIdentityInfo *info, const GError *error, gpointer user_data)
{
AclModifyUserData *am_user_data = (AclModifyUserData *)user_data;
GList *old_list, *new_list, *list_iter;
if (error) {
g_warning("%s: %s", G_STRFUNC, error->message);
goto clean_user_data;
}
SignonSecurityContextList *new_list = signon_security_context_list_copy(signon_identity_info_get_access_control_list(info));
SignonSecurityContextList *list_iter = new_list;
old_list = signon_identity_info_get_access_control_list (info);
for (old_list; old_list != NULL; old_list = g_list_next (old_list)) {
SignonSecurityContext *ctx = (SignonSecurityContext *) old_list->data;
new_list = g_list_append (new_list, signon_security_context_copy (ctx));
}
gboolean list_changed = FALSE;
while(list_iter != NULL) {
list_iter = new_list;
for (list_iter; list_iter != NULL; list_iter = g_list_next (list_iter)) {
SignonSecurityContext *curr_context = list_iter->data;
if (g_strcmp0(signon_security_context_get_system_context(curr_context), am_user_data->security_context->sys_ctx) == 0
&& g_strcmp0(signon_security_context_get_application_context(curr_context), am_user_data->security_context->app_ctx) == 0) {
......@@ -394,14 +399,13 @@ static void remove_acl_cb(SignonIdentity *self, SignonIdentityInfo *info, const
list_changed = TRUE;
break;
}
list_iter = g_list_next(list_iter);
}
if (list_changed) {
signon_identity_info_set_access_control_list(info, new_list);
signon_identity_store_credentials_with_info(self, info, signon_store_identity_cb, am_user_data->main_loop);
} else {
signon_security_context_list_free(new_list);
g_list_free_full (new_list, (GDestroyNotify) signon_security_context_free);
g_main_loop_quit (am_user_data->main_loop);
}
......
......@@ -214,19 +214,19 @@ EXTRA_DIST =
# Vala bindings
if ENABLE_VAPIGEN
-include $(VAPIGEN_MAKEFILE)
libgsignon-glib.vapi: gSignon-1.0.gir libgsignon-glib.deps gSignon-1.0-custom.vala
libgsignon-glib.vapi: gSignon-1.0.gir libgsignon-glib.deps
VAPIGEN_VAPIS = libgsignon-glib.vapi
libgsignon_glib_vapi_DEPS = gio-2.0 glib-2.0
libgsignon_glib_vapi_METADATADIRS = $(srcdir)
libgsignon_glib_vapi_FILES = gSignon-1.0.gir $(srcdir)/gSignon-1.0-custom.vala
libgsignon_glib_vapi_FILES = gSignon-1.0.gir
vapidir = $(datadir)/vala/vapi
vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
CLEANFILES += $(VAPIGEN_VAPIS)
EXTRA_DIST += libgsignon-glib.deps gSignon-1.0-custom.vala
EXTRA_DIST += libgsignon-glib.deps gSignon-1.0.metadata
endif
dbusinterfacesdir = $(DBUS_INTERFACES_DIR)
......
namespace Signon {
[CCode (cheader_filename = "libgsignon-glib/signon-glib.h", free_function = "signon_security_context_list_free")]
public class SecurityContextList : GLib.List<Signon.SecurityContext> {
public GLib.Variant build_variant ();
public SecurityContextList.deconstruct_variant (GLib.Variant variant);
public SecurityContextList copy ();
public void free ();
}
[CCode (cheader_filename = "libgsignon-glib/signon-glib.h")]
public class IdentityFilter : GLib.HashTable<string, GLib.Variant> {
}
[CCode (cheader_filename = "libgsignon-glib/signon-glib.h")]
public class IdentityList : GLib.List<Signon.Identity> {
}
}
Identity.signout#method name="sign_out"
......@@ -286,7 +286,7 @@ auth_query_identities_cb (GObject *object, GAsyncResult *res,
GError *error = NULL;
GVariantIter iter;
GVariant *identity_var;
SignonIdentityList *identity_list = NULL;
GList *identity_list = NULL;
g_return_if_fail (data != NULL);
......@@ -317,7 +317,7 @@ auth_query_identities_cb (GObject *object, GAsyncResult *res,
/**
* SignonQueryIdentitiesCb:
* @auth_service: the #SignonAuthService.
* @identities: (transfer full): #GList based list of #SignonIdentityInfo.
* @identities: (element-type SignonIdentity): #GList based list of #SignonIdentityInfo.
* @error: a #GError if an error occurred, %NULL otherwise.
* @user_data: the user data that was passed when installing this callback.
*
......@@ -327,7 +327,7 @@ auth_query_identities_cb (GObject *object, GAsyncResult *res,
/**
* signon_auth_service_query_identities:
* @auth_service: the #SignonAuthService.
* @filter: filter variant dictionary based on #GHashTable.
* @filter: (element-type utf8 GVariant): filter variant dictionary based on #GHashTable.
* @application_context: application security context, can be %NULL.
* @cb: (scope async): callback to be invoked.
* @user_data: user data.
......@@ -359,7 +359,7 @@ auth_query_identities_cb (GObject *object, GAsyncResult *res,
*/
void
signon_auth_service_query_identities (SignonAuthService *auth_service,
SignonIdentityFilter *filter,
GHashTable *filter,
const gchar *application_context,
SignonQueryIdentitiesCb cb,
gpointer user_data)
......
......@@ -82,22 +82,8 @@ typedef void (*SignonClearCb) (SignonAuthService *auth_service,
const GError *error,
gpointer user_data);
/**
* SignonIdentityList:
*
* GList of #SignonIdentity items.
*/
typedef GList SignonIdentityList;
/**
* SignonIdentityFilter:
*
* #GHashTable based filter variant dictionary.
*/
typedef GHashTable SignonIdentityFilter;
typedef void (*SignonQueryIdentitiesCb) (SignonAuthService *auth_service,
SignonIdentityList *identities,
GList *identities,
const GError *error,
gpointer user_data);
......@@ -113,7 +99,7 @@ void signon_auth_service_query_mechanisms (SignonAuthService *auth_service,
gpointer user_data);
void signon_auth_service_query_identities (SignonAuthService *auth_service,
SignonIdentityFilter *filter,
GHashTable *filter,
const gchar *application_context,
SignonQueryIdentitiesCb cb,
gpointer user_data);
......
......@@ -43,8 +43,8 @@
#include "signon-utils.h"
G_DEFINE_BOXED_TYPE (SignonIdentityInfo, signon_identity_info,
(GBoxedCopyFunc)signon_identity_info_copy,
(GBoxedFreeFunc)signon_identity_info_free);
signon_identity_info_copy,
signon_identity_info_free);
static GVariant *
......@@ -343,7 +343,7 @@ void signon_identity_info_free (SignonIdentityInfo *info)
g_strfreev (info->realms);
signon_security_context_free (info->owner);
signon_security_context_list_free (info->access_control_list);
g_list_free_full (info->access_control_list, (GDestroyNotify) signon_security_context_free);
g_slice_free (SignonIdentityInfo, info);
}
......@@ -468,7 +468,7 @@ GHashTable *signon_identity_info_get_methods (const SignonIdentityInfo *info)
*
* Get an array of the allowed realms of @info.
*
* Returns: (transfer none): a %NULL terminated array of realms.
* Returns: (transfer none) (array zero-terminated=1): a %NULL terminated array of realms.
*/
const gchar* const *signon_identity_info_get_realms (const SignonIdentityInfo *info)
{
......@@ -496,9 +496,9 @@ const SignonSecurityContext *signon_identity_info_get_owner (const SignonIdentit
*
* Get an access control list associated with an identity.
*
* Returns: (transfer none): a list of ACL security contexts.
* Returns: (transfer none) (element-type SignonSecurityContext): a list of ACL security contexts.
*/
SignonSecurityContextList *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info)
GList *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->access_control_list;
......@@ -582,7 +582,7 @@ void signon_identity_info_set_caption (SignonIdentityInfo *info,
* signon_identity_info_set_method:
* @info: the #SignonIdentityInfo.
* @method: an authentication method.
* @mechanisms: a %NULL-terminated list of mechanisms.
* @mechanisms: (array zero-terminated=1): a %NULL-terminated list of mechanisms.
*
* Adds a method to the list of allowed authentication methods.
*/
......@@ -617,7 +617,7 @@ void signon_identity_info_remove_method (SignonIdentityInfo *info, const gchar *
/**
* signon_identity_info_set_realms:
* @info: the #SignonIdentityInfo.
* @realms: a %NULL-terminated list of realms.
* @realms: (array zero-terminated=1): a %NULL-terminated list of realms.
*
* Specify what realms this identity can be used in.
*/
......@@ -678,20 +678,22 @@ void signon_identity_info_set_owner_from_values (
/**
* signon_identity_info_set_access_control_list:
* @info: the #SignonIdentityInfo.
* @access_control_list: (transfer none): a list of ACL security contexts.
* @access_control_list: (element-type SignonSecurityContext): a list of ACL security contexts.
*
* Set an access control list associated with an identity.
*/
void signon_identity_info_set_access_control_list (SignonIdentityInfo *info,
SignonSecurityContextList *access_control_list)
GList *access_control_list)
{
g_return_if_fail (info != NULL);
SignonSecurityContextList *new_acl =
signon_security_context_list_copy (access_control_list);
GList *new_acl = NULL;
for (; access_control_list != NULL; access_control_list = g_list_next (access_control_list)) {
SignonSecurityContext *ctx = (SignonSecurityContext *) access_control_list->data;
new_acl = g_list_append (new_acl, signon_security_context_copy (ctx));
}
if (info->access_control_list)
signon_security_context_list_free (info->access_control_list);
g_list_free_full (info->access_control_list, (GDestroyNotify) signon_security_context_free);
info->access_control_list = new_acl;
}
......@@ -726,4 +728,4 @@ void signon_identity_info_set_identity_type (SignonIdentityInfo *info,
{
g_return_if_fail (info != NULL);
info->type = (gint) type;
}
\ No newline at end of file
}
......@@ -74,7 +74,7 @@ const gchar* const *signon_identity_info_get_realms (
const SignonIdentityInfo *info);
const SignonSecurityContext *signon_identity_info_get_owner (
const SignonIdentityInfo *info);
SignonSecurityContextList *signon_identity_info_get_access_control_list (
GList *signon_identity_info_get_access_control_list (
const SignonIdentityInfo *info);
SignonIdentityType signon_identity_info_get_identity_type (
const SignonIdentityInfo *info);
......@@ -103,7 +103,7 @@ void signon_identity_info_set_owner_from_values (SignonIdentityInfo *info,
const gchar *system_context,
const gchar *application_context);
void signon_identity_info_set_access_control_list (SignonIdentityInfo *info,
SignonSecurityContextList *access_control_list);
GList *access_control_list);
void signon_identity_info_access_control_list_append (SignonIdentityInfo *info,
SignonSecurityContext *security_context);
void signon_identity_info_set_identity_type (SignonIdentityInfo *info,
......
......@@ -962,7 +962,8 @@ signon_identity_store_credentials_with_info(SignonIdentity *self,
* @caption: (allow-none): caption.
* @realms: (allow-none): allowed realms.
* @owner: (allow-none): owner.
* @access_control_list: (allow-none) (transfer container): access control list.
* @access_control_list: (allow-none) (transfer container)
* (element-type SignonSecurityContext): access control list.
* @type: the type of the identity.
* @cb: (scope async): callback.
* @user_data: (closure): user_data.
......@@ -978,7 +979,7 @@ void signon_identity_store_credentials_with_args(SignonIdentity *self,
const gchar *caption,
const gchar* const *realms,
const SignonSecurityContext *owner,
SignonSecurityContextList *access_control_list,
GList *access_control_list,
SignonIdentityType type,
SignonIdentityStoreCredentialsCb cb,
gpointer user_data)
......
......@@ -151,7 +151,7 @@ void signon_identity_store_credentials_with_args(SignonIdentity *self,
const gchar *caption,
const gchar* const *realms,
const SignonSecurityContext *owner,
SignonSecurityContextList *access_control_list,
GList *access_control_list,
SignonIdentityType type,
SignonIdentityStoreCredentialsCb cb,
gpointer user_data);
......@@ -239,4 +239,4 @@ void signon_identity_get_auth_session(SignonIdentity *self,
G_END_DECLS
#endif /* _SIGNON_IDENTITY_H_ */
\ No newline at end of file
#endif /* _SIGNON_IDENTITY_H_ */
......@@ -137,7 +137,7 @@ struct _SignonIdentityInfo
GHashTable *methods;
gchar **realms;
SignonSecurityContext *owner;
SignonSecurityContextList *access_control_list;
GList *access_control_list;
gint type;
};
......
......@@ -62,14 +62,6 @@ G_DEFINE_BOXED_TYPE (SignonSecurityContext, signon_security_context,
(GBoxedCopyFunc) signon_security_context_copy,
(GBoxedFreeFunc) signon_security_context_free);
static void
_security_context_free (gpointer ptr)
{
SignonSecurityContext *ctx = (SignonSecurityContext *) ptr;
signon_security_context_free (ctx);
}
/**
* signon_security_context_new:
*
......@@ -269,16 +261,15 @@ signon_security_context_deconstruct_variant (GVariant *variant)
/**
* signon_security_context_list_build_variant:
* @list: #SignonSecurityContextList item.
* @list: (element-type SignonSecurityContext): #GList item of #SignonSecurityContext.
*
* Builds a GVariant of type "a(ss)" from a GList of #SignonSecurityContext
* items.
*
* Returns: (transfer full): GVariant construct of a #SignonSecurityContextList.
* Returns: (transfer full): GVariant construct of a #GList.
*/
GVariant *
signon_security_context_list_build_variant (
const SignonSecurityContextList *list)
signon_security_context_list_build_variant (const GList *list)
{
GVariantBuilder builder;
GVariant *variant;
......@@ -303,12 +294,12 @@ signon_security_context_list_build_variant (
* Builds a GList of #SignonSecurityContext items from a GVariant of type
* "a(ss)".
*
* Returns: (transfer full): #SignonSecurityContextList item.
* Returns: (transfer full) (element-type SignonSecurityContext): #GList item.
*/
SignonSecurityContextList *
GList *
signon_security_context_list_deconstruct_variant (GVariant *variant)
{
SignonSecurityContextList *list = NULL;
GList *list = NULL;
GVariantIter iter;
GVariant *value;
......@@ -324,40 +315,3 @@ signon_security_context_list_deconstruct_variant (GVariant *variant)
return list;
}
/**
* signon_security_context_list_copy:
* @src_list: source #SignonSecurityContextList.
*
* Copies a GList of #SignonSecurityContext items.
*
* Returns: (transfer full): #SignonSecurityContextList item.
*/
SignonSecurityContextList *
signon_security_context_list_copy (const SignonSecurityContextList *src_list)
{
SignonSecurityContext *ctx;
SignonSecurityContextList *dst_list = NULL;
for ( ; src_list != NULL; src_list = g_list_next (src_list))
{
ctx = (SignonSecurityContext *) src_list->data;
dst_list = g_list_append (
dst_list, signon_security_context_copy (ctx));
}
return dst_list;
}
/**
* signon_security_context_list_free:
* @seclist: (transfer full): #SignonSecurityContextList item.
*
* Frees all items and the GList of #SignonSecurityContext.
*/
void
signon_security_context_list_free (SignonSecurityContextList *seclist)
{
g_list_free_full (seclist, _security_context_free);
}
......@@ -46,13 +46,6 @@ struct _SignonSecurityContext
gchar *app_ctx;
};
/**
* SignonSecurityContextList:
*
* GList of #SignonSecurityContext items.
*/
typedef GList SignonSecurityContextList;
GType signon_security_context_get_type (void) G_GNUC_CONST;
SignonSecurityContext * signon_security_context_new ();
......@@ -76,14 +69,8 @@ GVariant * signon_security_context_build_variant (
SignonSecurityContext * signon_security_context_deconstruct_variant (
GVariant *variant);
GVariant * signon_security_context_list_build_variant (
const SignonSecurityContextList *list);
SignonSecurityContextList * signon_security_context_list_deconstruct_variant (
GVariant *variant);
SignonSecurityContextList * signon_security_context_list_copy (
const SignonSecurityContextList *src_list);
void signon_security_context_list_free (SignonSecurityContextList *seclist);
GVariant * signon_security_context_list_build_variant (const GList *list);
GList * signon_security_context_list_deconstruct_variant (GVariant *variant);
G_END_DECLS
......
......@@ -1448,9 +1448,9 @@ void free_identity_info_cb (gpointer data)
}
void query_identities_cb (SignonAuthService *auth_service,
SignonIdentityList *identity_list, const GError *error, gpointer user_data)
GList *identity_list, const GError *error, gpointer user_data)
{
SignonIdentityList *iter = identity_list;
GList *iter = identity_list;
while (iter && !error)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment