Commit e670fe56 authored by Stef Walter's avatar Stef Walter Committed by Stef Walter
Browse files

Fix for deprecations in glib 2.31.0

parent 38031d94
......@@ -37,5 +37,6 @@ stamp*
/egg/tests/test-hkdf
/egg/tests/test-secmem
/library/gsecret-dbus-generated.[ch]
/library/tests/test-*
!/library/tests/test-*.c
......@@ -35,8 +35,8 @@ AM_GLIB_GNU_GETTEXT
#
PKG_CHECK_MODULES(GLIB,
glib-2.0 >= 2.30.0
gio-2.0 >= 2.30.0
glib-2.0 >= 2.31.0
gio-2.0 >= 2.31.0
gio-unix-2.0)
LIBS="$LIBS $GLIB_LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
......
......@@ -56,14 +56,16 @@ fatal_handler (gpointer unused, int unknown, const gchar *msg)
static int
glib_thread_mutex_init (void **lock)
{
*lock = g_mutex_new ();
*lock = g_slice_new (GMutex);
g_mutex_init (*lock);
return 0;
}
static int
glib_thread_mutex_destroy (void **lock)
{
g_mutex_free (*lock);
g_mutex_clear (*lock);
g_slice_free (GMutex, *lock);
return 0;
}
......
......@@ -25,14 +25,13 @@
#include "egg-testing.h"
#include <glib-object.h>
#include <valgrind/valgrind.h>
#include <errno.h>
#include <unistd.h>
static GCond *wait_condition = NULL;
static GCond *wait_start = NULL;
static GMutex *wait_mutex = NULL;
static gboolean wait_waiting = FALSE;
static const char HEXC[] = "0123456789ABCDEF";
static gchar*
......@@ -79,79 +78,84 @@ egg_assertion_message_cmpmem (const char *domain,
g_free (s);
}
static void (*wait_stop_impl) (void);
static gboolean (*wait_until_impl) (int timeout);
void
egg_test_wait_stop (void)
{
GTimeVal tv;
g_get_current_time (&tv);
g_time_val_add (&tv, 1000);
g_assert (wait_mutex);
g_assert (wait_condition);
g_mutex_lock (wait_mutex);
if (!wait_waiting)
g_cond_timed_wait (wait_start, wait_mutex, &tv);
g_assert (wait_waiting);
g_cond_broadcast (wait_condition);
g_mutex_unlock (wait_mutex);
g_assert (wait_stop_impl != NULL);
(wait_stop_impl) ();
}
gboolean
egg_test_wait_until (int timeout)
{
GTimeVal tv;
gboolean ret;
g_get_current_time (&tv);
g_time_val_add (&tv, timeout * 1000);
g_assert (wait_mutex);
g_assert (wait_condition);
g_mutex_lock (wait_mutex);
g_assert (!wait_waiting);
wait_waiting = TRUE;
g_cond_broadcast (wait_start);
ret = g_cond_timed_wait (wait_condition, wait_mutex, &tv);
g_assert (wait_waiting);
wait_waiting = FALSE;
g_mutex_unlock (wait_mutex);
g_assert (wait_until_impl != NULL);
return (wait_until_impl) (timeout);
}
return ret;
static GMainLoop *wait_loop = NULL;
static void
loop_wait_stop (void)
{
g_assert (wait_loop != NULL);
g_main_loop_quit (wait_loop);
}
static gpointer
testing_thread (gpointer loop)
static gboolean
on_loop_wait_timeout (gpointer data)
{
/* Must have been defined by the test including this file */
gint ret = g_test_run ();
g_main_loop_quit (loop);
return GINT_TO_POINTER (ret);
gboolean *timed_out = data;
*timed_out = TRUE;
g_assert (wait_loop != NULL);
g_main_loop_quit (wait_loop);
return TRUE; /* we remove this source later */
}
gint
egg_tests_run_in_thread_with_loop (void)
static gboolean
loop_wait_until (int timeout)
{
GThread *thread;
GMainLoop *loop;
gpointer ret;
gboolean ret = FALSE;
gboolean timed_out = FALSE;
guint source;
g_thread_init (NULL);
g_assert (wait_loop == NULL);
wait_loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
loop = g_main_loop_new (NULL, FALSE);
wait_condition = g_cond_new ();
wait_start = g_cond_new ();
wait_mutex = g_mutex_new ();
source = g_timeout_add (timeout, on_loop_wait_timeout, &timed_out);
thread = g_thread_create (testing_thread, loop, TRUE, NULL);
g_assert (thread);
g_main_loop_run (wait_loop);
g_main_loop_run (loop);
ret = g_thread_join (thread);
g_main_loop_unref (loop);
if (timed_out) {
g_source_remove (source);
ret = FALSE;
} else {
ret = TRUE;
}
g_main_loop_unref (wait_loop);
wait_loop = NULL;
return ret;
}
g_cond_free (wait_condition);
g_mutex_free (wait_mutex);
gint
egg_tests_run_with_loop (void)
{
gint ret;
return GPOINTER_TO_INT (ret);
wait_stop_impl = loop_wait_stop;
wait_until_impl = loop_wait_until;
ret = g_test_run ();
wait_stop_impl = NULL;
wait_until_impl = NULL;
while (g_main_context_iteration (NULL, FALSE));
return ret;
}
......@@ -45,8 +45,10 @@ void egg_assertion_message_cmpmem (const char *domain, const char *
void egg_test_wait_stop (void);
#define egg_test_wait() g_assert (egg_test_wait_until (20000) != FALSE)
gboolean egg_test_wait_until (int timeout);
gint egg_tests_run_in_thread_with_loop (void);
gint egg_tests_run_with_loop (void);
#endif /* EGG_DH_H_ */
This diff is collapsed.
/*
* Generated by gdbus-codegen 2.30.1. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
#ifndef __GSECRET_DBUS_GENERATED_H__
#define __GSECRET_DBUS_GENERATED_H__
#include <gio/gio.h>
G_BEGIN_DECLS
/* ------------------------------------------------------------------------ */
/* Declarations for org.freedesktop.Secret.Service */
#define GSECRET_GEN_TYPE_SERVICE (_gsecret_gen_service_get_type ())
#define GSECRET_GEN_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSECRET_GEN_TYPE_SERVICE, GSecretGenService))
#define GSECRET_GEN_IS_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSECRET_GEN_TYPE_SERVICE))
#define GSECRET_GEN_SERVICE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GSECRET_GEN_TYPE_SERVICE, GSecretGenServiceIface))
struct _GSecretGenService;
typedef struct _GSecretGenService GSecretGenService;
typedef struct _GSecretGenServiceIface GSecretGenServiceIface;
struct _GSecretGenServiceIface
{
GTypeInterface parent_iface;
gboolean (*handle_create_collection) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
GVariant *arg_properties,
const gchar *arg_alias);
gboolean (*handle_get_secrets) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *arg_items,
const gchar *arg_session);
gboolean (*handle_lock) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *arg_objects);
gboolean (*handle_open_session) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *arg_algorithm,
GVariant *arg_input);
gboolean (*handle_read_alias) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *arg_name);
gboolean (*handle_search_items) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
GVariant *arg_attributes);
gboolean (*handle_set_alias) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *arg_name,
const gchar *arg_collection);
gboolean (*handle_unlock) (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *arg_objects);
const gchar *const * (*get_collections) (GSecretGenService *object);
void (*collection_changed) (
GSecretGenService *object,
const gchar *arg_collection);
void (*collection_created) (
GSecretGenService *object,
const gchar *arg_collection);
void (*collection_deleted) (
GSecretGenService *object,
const gchar *arg_collection);
};
GType _gsecret_gen_service_get_type (void) G_GNUC_CONST;
GDBusInterfaceInfo *_gsecret_gen_service_interface_info (void);
guint _gsecret_gen_service_override_properties (GObjectClass *klass, guint property_id_begin);
/* D-Bus method call completion functions: */
void _gsecret_gen_service_complete_open_session (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
GVariant *output,
const gchar *result);
void _gsecret_gen_service_complete_create_collection (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *collection,
const gchar *prompt);
void _gsecret_gen_service_complete_search_items (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *unlocked,
const gchar *const *locked);
void _gsecret_gen_service_complete_unlock (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *unlocked,
const gchar *prompt);
void _gsecret_gen_service_complete_lock (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *const *locked,
const gchar *Prompt);
void _gsecret_gen_service_complete_get_secrets (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
GVariant *secrets);
void _gsecret_gen_service_complete_read_alias (
GSecretGenService *object,
GDBusMethodInvocation *invocation,
const gchar *collection);
void _gsecret_gen_service_complete_set_alias (
GSecretGenService *object,
GDBusMethodInvocation *invocation);
/* D-Bus signal emissions functions: */
void _gsecret_gen_service_emit_collection_created (
GSecretGenService *object,
const gchar *arg_collection);
void _gsecret_gen_service_emit_collection_deleted (
GSecretGenService *object,
const gchar *arg_collection);
void _gsecret_gen_service_emit_collection_changed (
GSecretGenService *object,
const gchar *arg_collection);
/* D-Bus method calls: */
void _gsecret_gen_service_call_open_session (
GSecretGenService *proxy,
const gchar *arg_algorithm,
GVariant *arg_input,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_open_session_finish (
GSecretGenService *proxy,
GVariant **out_output,
gchar **out_result,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_open_session_sync (
GSecretGenService *proxy,
const gchar *arg_algorithm,
GVariant *arg_input,
GVariant **out_output,
gchar **out_result,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_create_collection (
GSecretGenService *proxy,
GVariant *arg_properties,
const gchar *arg_alias,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_create_collection_finish (
GSecretGenService *proxy,
gchar **out_collection,
gchar **out_prompt,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_create_collection_sync (
GSecretGenService *proxy,
GVariant *arg_properties,
const gchar *arg_alias,
gchar **out_collection,
gchar **out_prompt,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_search_items (
GSecretGenService *proxy,
GVariant *arg_attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_search_items_finish (
GSecretGenService *proxy,
gchar ***out_unlocked,
gchar ***out_locked,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_search_items_sync (
GSecretGenService *proxy,
GVariant *arg_attributes,
gchar ***out_unlocked,
gchar ***out_locked,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_unlock (
GSecretGenService *proxy,
const gchar *const *arg_objects,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_unlock_finish (
GSecretGenService *proxy,
gchar ***out_unlocked,
gchar **out_prompt,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_unlock_sync (
GSecretGenService *proxy,
const gchar *const *arg_objects,
gchar ***out_unlocked,
gchar **out_prompt,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_lock (
GSecretGenService *proxy,
const gchar *const *arg_objects,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_lock_finish (
GSecretGenService *proxy,
gchar ***out_locked,
gchar **out_Prompt,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_lock_sync (
GSecretGenService *proxy,
const gchar *const *arg_objects,
gchar ***out_locked,
gchar **out_Prompt,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_get_secrets (
GSecretGenService *proxy,
const gchar *const *arg_items,
const gchar *arg_session,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_get_secrets_finish (
GSecretGenService *proxy,
GVariant **out_secrets,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_get_secrets_sync (
GSecretGenService *proxy,
const gchar *const *arg_items,
const gchar *arg_session,
GVariant **out_secrets,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_read_alias (
GSecretGenService *proxy,
const gchar *arg_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_read_alias_finish (
GSecretGenService *proxy,
gchar **out_collection,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_read_alias_sync (
GSecretGenService *proxy,
const gchar *arg_name,
gchar **out_collection,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_call_set_alias (
GSecretGenService *proxy,
const gchar *arg_name,
const gchar *arg_collection,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gsecret_gen_service_call_set_alias_finish (
GSecretGenService *proxy,
GAsyncResult *res,
GError **error);
gboolean _gsecret_gen_service_call_set_alias_sync (
GSecretGenService *proxy,
const gchar *arg_name,
const gchar *arg_collection,
GCancellable *cancellable,
GError **error);
/* D-Bus property accessors: */
const gchar *const *_gsecret_gen_service_get_collections (GSecretGenService *object);
gchar **_gsecret_gen_service_dup_collections (GSecretGenService *object);
void _gsecret_gen_service_set_collections (GSecretGenService *object, const gchar *const *value);
/* ---- */
#define GSECRET_GEN_TYPE_SERVICE_PROXY (_gsecret_gen_service_proxy_get_type ())
#define GSECRET_GEN_SERVICE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSECRET_GEN_TYPE_SERVICE_PROXY, GSecretGenServiceProxy))
#define GSECRET_GEN_SERVICE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GSECRET_GEN_TYPE_SERVICE_PROXY, GSecretGenServiceProxyClass))
#define GSECRET_GEN_SERVICE_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSECRET_GEN_TYPE_SERVICE_PROXY, GSecretGenServiceProxyClass))
#define GSECRET_GEN_IS_SERVICE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSECRET_GEN_TYPE_SERVICE_PROXY))
#define GSECRET_GEN_IS_SERVICE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSECRET_GEN_TYPE_SERVICE_PROXY))
typedef struct _GSecretGenServiceProxy GSecretGenServiceProxy;
typedef struct _GSecretGenServiceProxyClass GSecretGenServiceProxyClass;
typedef struct _GSecretGenServiceProxyPrivate GSecretGenServiceProxyPrivate;
struct _GSecretGenServiceProxy
{
/*< private >*/
GDBusProxy parent_instance;
GSecretGenServiceProxyPrivate *priv;
};
struct _GSecretGenServiceProxyClass
{
GDBusProxyClass parent_class;
};
GType _gsecret_gen_service_proxy_get_type (void) G_GNUC_CONST;
void _gsecret_gen_service_proxy_new (
GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GSecretGenService *_gsecret_gen_service_proxy_new_finish (
GAsyncResult *res,
GError **error);
GSecretGenService *_gsecret_gen_service_proxy_new_sync (
GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
void _gsecret_gen_service_proxy_new_for_bus (
GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GSecretGenService *_gsecret_gen_service_proxy_new_for_bus_finish (
GAsyncResult *res,
GError **error);
GSecretGenService *_gsecret_gen_service_proxy_new_for_bus_sync (
GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,