Commit 9c20c4d6 authored by Stef Walter's avatar Stef Walter
Browse files

Initial gobject-introspection support

parent 46137f86
......@@ -6,6 +6,9 @@
*.gcov
*.gcno
*.gcda
*.gir
*.pc
*.typelib
.deps
.cproject
.libs
......
include $(top_srcdir)/Makefile.decl
VALGRIND_CONTRIB = \
valgrind.h \
memcheck.h
memcheck.h \
$(NULL)
SUPPRESSIONS = \
gcrypt.supp \
glib.supp \
pthread.supp \
unknown.supp
unknown.supp \
$(NULL)
valgrind-suppressions: $(SUPPRESSIONS)
$(AM_V_GEN) cat $(SUPPRESSIONS) > $@
EXTRA_DIST = \
$(VALGRIND_CONTRIB) \
valgrind \
$(SUPPRESSIONS)
all-local: valgrind-suppressions
\ No newline at end of file
all-local: valgrind-suppressions
......@@ -3,6 +3,23 @@ AC_CONFIG_MACRO_DIR([build/m4])
AC_INIT([libsecret],[0.1],[http://bugzilla.gnome.org/enter_bug.cgi?product=libsecret])
dnl ****************************************************************************
dnl Library package and libtool versioning
dnl
dnl Updating the libtool versions, follow these instructions sequentially:
dnl 1. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
dnl 2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
dnl 3. If any interfaces have been added since the last public release, then increment age.
dnl 4. If any interfaces have been removed or changed since the last public release, then set age to 0.
SECRET_MAJOR=0
SECRET_MINOR=0
SECRET_MICRO=0
SECRET_CURRENT=0
SECRET_REVISION=0
SECRET_AGE=0
AC_CONFIG_SRCDIR([library/secret-value.c])
AC_CONFIG_HEADERS([config.h])
......@@ -41,6 +58,7 @@ PKG_CHECK_MODULES(GLIB,
LIBS="$LIBS $GLIB_LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
GOBJECT_INTROSPECTION_CHECK([1.29])
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
# --------------------------------------------------------------------
......@@ -120,13 +138,16 @@ if test "$enable_strict" = "yes"; then
-DGDK_DISABLE_DEPRECATED \
-DG_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED"
INTROSPECTION_FLAGS="--warn-error"
TEST_MODE="thorough"
else
TEST_MODE="quick"
INTROSPECTION_FLAGS=""
$enable_strict="no"
fi
AC_MSG_RESULT($enable_strict)
AC_SUBST(INTROSPECTION_FLAGS)
AC_SUBST(TEST_MODE)
AC_MSG_CHECKING([for debug mode])
......@@ -192,6 +213,11 @@ AC_SUBST(GENHTML)
# Results
#
SECRET_LT_RELEASE=$SECRET_CURRENT:$SECRET_REVISION:$SECRET_AGE
AC_SUBST(SECRET_LT_RELEASE)
AC_SUBST(SECRET_MAJOR)
AC_SUBST(SECRET_MINOR)
AC_CONFIG_FILES([
Makefile
build/Makefile
......@@ -200,6 +226,7 @@ AC_CONFIG_FILES([
po/Makefile.in
po/Makefile
library/Makefile
library/libsecret.pc
library/tests/Makefile
])
AC_OUTPUT
......
......@@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
SUBDIRS = . tests
module_flags = \
-version-info $(SECRET_LT_RELEASE) \
-export_dynamic \
-avoid-version \
-module \
......@@ -12,37 +13,58 @@ module_flags = \
INCLUDES = \
-DSECRET_COMPILATION
lib_LTLIBRARIES = libsecret.la
lib_LTLIBRARIES = libsecret-@SECRET_MAJOR@.la
incdir = $(includedir)/secret-@SECRET_MAJOR@/secret
HEADER_FILES = \
secret.h \
secret-collection.h \
secret-item.h \
secret-password.h \
secret-prompt.h \
secret-service.h \
secret-value.h
secret-types.h \
secret-value.h \
$(NULL)
inc_HEADERS = \
$(HEADER_FILES) \
secret-enum-types.h \
$(NULL)
BUILT_SOURCES = \
secret-dbus-generated.c secret-dbus-generated.h \
secret-enum-types.c secret-enum-types.h
secret-enum-types.c secret-enum-types.h \
$(NULL)
libsecret_la_SOURCES = \
PUBLIC_FILES = \
secret-collection.h secret-collection.c \
secret-item.h secret-item.c \
secret-methods.c \
secret-password.h secret-password.c \
secret-prompt.h secret-prompt.c \
secret-service.h secret-service.c \
secret-session.h secret-session.c \
secret-util.c \
secret-types.h \
secret-value.h secret-value.c \
$(NULL)
INTERNAL_FILES = \
secret-session.c \
secret-util.c \
$(NULL)
libsecret_@SECRET_MAJOR@_la_SOURCES = \
$(PUBLIC_FILES) \
$(INTERNAL_FILES) \
$(BUILT_SOURCES) \
$(NULL)
libsecret_la_CFLAGS = \
libsecret_@SECRET_MAJOR@_la_CFLAGS = \
$(LIBGCRYPT_CFLAGS)
libsecret_la_LIBADD = \
libsecret_@SECRET_MAJOR@_la_LIBADD = \
$(top_builddir)/egg/libegg.la \
$(LIBGCRYPT_LIBS) \
$(LIBS)
......@@ -64,9 +86,52 @@ secret-enum-types.h: secret-enum-types.h.template $(HEADER_FILES)
secret-enum-types.c: secret-enum-types.c.template $(HEADER_FILES)
$(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > $@
# ------------------------------------------------------------------
# INTROSPECTION
if HAVE_INTROSPECTION
include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS = Secret-@SECRET_MAJOR@.gir
INTROSPECTION_SCANNER_ARGS = $(INTROSPECTION_FLAGS) --warn-all --add-include-path=$(srcdir) --add-include-path=.
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=.
Secret-@SECRET_MAJOR@.gir: libsecret-@SECRET_MAJOR@.la
Secret_@SECRET_MAJOR@_gir_PACKAGES = gobject-2.0 gio-2.0
Secret_@SECRET_MAJOR@_gir_EXPORT_PACKAGES = libsecret-@SECRET_MAJOR@
Secret_@SECRET_MAJOR@_gir_INCLUDES = GObject-2.0 Gio-2.0
Secret_@SECRET_MAJOR@_gir_LIBS = libsecret-@SECRET_MAJOR@.la
Secret_@SECRET_MAJOR@_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -DSECRET_COMPILATION -DSECRET_API_SUBJECT_TO_CHANGE
Secret_@SECRET_MAJOR@_gir_FILES = $(PUBLIC_FILES)
Secret_@SECRET_MAJOR@_gir_SCANNERFLAGS = --c-include "secret.h"
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
typelibsdir = $(libdir)/girepository-1.0
typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
endif
# ------------------------------------------------------------------
# PKG CONFIG
libsecret-$(SECRET_MAJOR).pc: libsecret.pc
cp libsecret.pc libsecret-$(SECRET_MAJOR).pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libsecret-$(SECRET_MAJOR).pc
# ------------------------------------------------------------------
EXTRA_DIST = \
secret-enum-types.h.template \
secret-enum-types.c.template
secret-enum-types.c.template \
org.freedesktop.Secrets.xml \
$(NULL)
check-memory:
make -C tests check-memory
\ No newline at end of file
make -C tests check-memory
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
datarootdir=@datarootdir@
datadir=@datadir@
sysconfdir=@sysconfdir@
Name: libsecret-@SECRET_MAJOR@
Description: GObject bindings for Secret Service API
Version: @VERSION@
Requires: glib-2.0 gobject-2.0 gio-2.0
Libs: -L${libdir} -lsecret-@SECRET_MAJOR@
Cflags: -I${includedir}/secret-@SECRET_MAJOR@
......@@ -21,14 +21,6 @@
#include <glib/gi18n-lib.h>
/**
* SECTION:secret-collection
*/
/**
* SecretCollection:
*/
enum {
PROP_0,
PROP_SERVICE,
......@@ -101,9 +93,9 @@ on_set_label (GObject *source,
static void
secret_collection_set_property (GObject *obj,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SecretCollection *self = SECRET_COLLECTION (obj);
......@@ -117,8 +109,8 @@ secret_collection_set_property (GObject *obj,
break;
case PROP_LABEL:
secret_collection_set_label (self, g_value_get_string (value),
self->pv->cancellable, on_set_label,
g_object_ref (self));
self->pv->cancellable, on_set_label,
g_object_ref (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
......@@ -128,9 +120,9 @@ secret_collection_set_property (GObject *obj,
static void
secret_collection_get_property (GObject *obj,
guint prop_id,
GValue *value,
GParamSpec *pspec)
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SecretCollection *self = SECRET_COLLECTION (obj);
......@@ -296,7 +288,7 @@ collection_load_items_async (SecretCollection *self,
/* No such collection yet create a new one */
if (item == NULL) {
secret_item_new (self->pv->service, path, cancellable,
on_load_item, g_object_ref (res));
on_load_item, g_object_ref (res));
closure->items_loading++;
} else {
......@@ -349,7 +341,7 @@ collection_load_items_sync (SecretCollection *self,
/* No such collection yet create a new one */
if (item == NULL) {
item = secret_item_new_sync (self->pv->service, path,
cancellable, error);
cancellable, error);
if (item == NULL) {
ret = FALSE;
break;
......@@ -390,8 +382,8 @@ handle_property_changed (SecretCollection *self,
static void
secret_collection_properties_changed (GDBusProxy *proxy,
GVariant *changed_properties,
const gchar* const *invalidated_properties)
GVariant *changed_properties,
const gchar* const *invalidated_properties)
{
SecretCollection *self = SECRET_COLLECTION (proxy);
gchar *property_name;
......@@ -449,8 +441,8 @@ secret_collection_class_init (SecretCollectionClass *klass)
static gboolean
secret_collection_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
GCancellable *cancellable,
GError **error)
{
SecretCollection *self;
GDBusProxy *proxy;
......@@ -523,7 +515,7 @@ on_init_base (GObject *source,
GError *error = NULL;
if (!secret_collection_async_initable_parent_iface->init_finish (G_ASYNC_INITABLE (self),
result, &error)) {
result, &error)) {
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
......@@ -543,10 +535,10 @@ on_init_base (GObject *source,
static void
secret_collection_async_initable_init_async (GAsyncInitable *initable,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *res;
InitClosure *closure;
......@@ -558,17 +550,17 @@ secret_collection_async_initable_init_async (GAsyncInitable *initable,
g_simple_async_result_set_op_res_gpointer (res, closure, init_closure_free);
secret_collection_async_initable_parent_iface->init_async (initable, io_priority,
cancellable,
on_init_base,
g_object_ref (res));
cancellable,
on_init_base,
g_object_ref (res));
g_object_unref (res);
}
static gboolean
secret_collection_async_initable_init_finish (GAsyncInitable *initable,
GAsyncResult *result,
GError **error)
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (initable),
secret_collection_async_initable_init_async), FALSE);
......@@ -599,16 +591,13 @@ secret_collection_async_initable_iface (GAsyncInitableIface *iface)
* Get a new collection proxy for a collection in the secret service.
*
* This method will return immediately and complete asynchronously.
*
* Returns: (transfer full): the new collection, which should be unreferenced
* with g_object_unref()
*/
void
secret_collection_new (SecretService *service,
const gchar *collection_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
const gchar *collection_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GDBusProxy *proxy;
......@@ -641,10 +630,9 @@ secret_collection_new (SecretService *service,
* Returns: (transfer full): the new collection, which should be unreferenced
* with g_object_unref()
*/
SecretCollection *
secret_collection_new_finish (GAsyncResult *result,
GError **error)
GError **error)
{
GObject *source_object;
GObject *object;
......@@ -672,16 +660,17 @@ secret_collection_new_finish (GAsyncResult *result,
*
* Get a new collection proxy for a collection in the secret service.
*
* This method may block indefinitely.
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): the new collection, which should be unreferenced
* with g_object_unref()
*/
SecretCollection *
secret_collection_new_sync (SecretService *service,
const gchar *collection_path,
GCancellable *cancellable,
GError **error)
const gchar *collection_path,
GCancellable *cancellable,
GError **error)
{
GDBusProxy *proxy;
......@@ -704,6 +693,16 @@ secret_collection_new_sync (SecretService *service,
NULL);
}
/**
* secret_collection_refresh:
* @self: the collection
*
* Refresh the properties on this collection. This fires off a request to
* refresh, and the properties will be updated later.
*
* Calling this method is not normally necessary, as the secret service
* will notify the client when properties change.
*/
void
secret_collection_refresh (SecretCollection *self)
{
......@@ -759,7 +758,7 @@ on_create_path (GObject *source,
path = secret_service_create_collection_path_finish (service, result, &error);
if (error == NULL) {
secret_collection_new (service, path, closure->cancellable,
on_create_collection, g_object_ref (res));
on_create_collection, g_object_ref (res));
} else {
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
......@@ -801,11 +800,11 @@ collection_properties_new (const gchar *label)
*/
void
secret_collection_create (SecretService *service,
const gchar *label,
const gchar *alias,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
const gchar *label,
const gchar *alias,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *res;
CreateClosure *closure;
......@@ -824,7 +823,7 @@ secret_collection_create (SecretService *service,
properties = collection_properties_new (label);
secret_service_create_collection_path (service, properties, alias, cancellable,
on_create_path, g_object_ref (res));
on_create_path, g_object_ref (res));
g_hash_table_unref (properties);
g_object_unref (res);
......@@ -842,7 +841,7 @@ secret_collection_create (SecretService *service,
*/
SecretCollection *
secret_collection_create_finish (GAsyncResult *result,
GError **error)
GError **error)
{
GSimpleAsyncResult *res;
CreateClosure *closure;
......@@ -873,19 +872,19 @@ secret_collection_create_finish (GAsyncResult *result,
*
* Create a new collection in the secret service.
*
* This method may block indefinitely. The secret service may prompt the
* user. secret_service_prompt() will be used to handle any prompts that
* are required.
* This method may block indefinitely and should not be used in user interface
* threads. The secret service may prompt the user. secret_service_prompt()
* will be used to handle any prompts that are required.
*
* Returns: (transfer full): the new collection, which should be unreferenced
* with g_object_unref()
*/
SecretCollection *
secret_collection_create_sync (SecretService *service,
const gchar *label,
const gchar *alias,
GCancellable *cancellable,
GError **error)
const gchar *label,
const gchar *alias,
GCancellable *cancellable,
GError **error)
{
SecretCollection *collection;
GHashTable *properties;
......@@ -899,7 +898,7 @@ secret_collection_create_sync (SecretService *service,
properties = collection_properties_new (label);
path = secret_service_create_collection_path_sync (service, properties, alias,
cancellable, error);
cancellable, error);
g_hash_table_unref (properties);
......@@ -924,14 +923,12 @@ secret_collection_create_sync (SecretService *service,
* This method returns immediately and completes asynchronously. The secret
* service may prompt the user. secret_service_prompt() will be used to handle
* any prompts that show up.
*
* Returns: whether the item was successfully deleted or not
*/
void
secret_collection_delete (SecretCollection *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
const gchar *object_path;
......@@ -940,7 +937,7 @@ secret_collection_delete (SecretCollection *self,
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (self));
_secret_service_delete_path (self->pv->service, object_path, FALSE,
cancellable, callback, user_data);
cancellable, callback, user_data);
}
/**
......@@ -951,12 +948,12 @@ secret_collection_delete (SecretCollection *self,
*
* Complete operation to delete this collection.
*
* Returns: whether the item was successfully deleted or not
* Returns: whether the collection was successfully deleted or not
*/
gboolean
secret_collection_delete_finish (SecretCollection *self,
GAsyncResult *result,
GError **error)
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (SECRET_IS_COLLECTION (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
......@@ -972,16 +969,16 @@ secret_collection_delete_finish (SecretCollection *self,
*
* Delete this collection.
*
* This method may block indefinitely. The secret service may prompt the
* user. secret_service_prompt() will be used to handle any prompts that
* show up.
* This method may block indefinitely and should not be used in user
* interface threads. The secret service may prompt the user.
* secret_service_prompt() will be used to handle any prompts that show up.
*
* Returns: whether the item was successfully deleted or not
* Returns: whether the collection was successfully deleted or not
*/
gboolean
secret_collection_delete_sync (SecretCollection *self,
GCancellable *cancellable,
GError **error)
GCancellable *cancellable,
GError **error)
{
SecretSync *sync;
gboolean ret;
......@@ -1033,7 +1030,7 @@ secret_collection_get_items (SecretCollection *self)
SecretItem *
_secret_collection_find_item_instance (SecretCollection *self,
const gchar *item_path)
const gchar *item_path)
{
SecretItem *item;
......@@ -1085,18 +1082,18 @@ secret_collection_get_label (SecretCollection *self)
*/
void
secret_collection_set_label (SecretCollection *self,
const gchar *label,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
const gchar *label,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (SECRET_IS_COLLECTION (self));
g_return_if_fail (label != NULL);
_secret_util_set_property (G_DBUS_PROXY (self), "Label",
g_variant_new_string (label),
secret_collection_set_label,
cancellable, callback, user_data);
g_variant_new_string (label),
secret_collection_set_label,
cancellable, callback, user_data);
}
/**
......@@ -1111,14 +1108,14 @@ secret_collection_set_label (SecretCollection *self,
*/
gboolean
secret_collection_set_label_finish (SecretCollection *self,
GAsyncResult *result,
GError **error)
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (SECRET_IS_COLLECTION (self), FALSE);
return _secret_util_set_property_finish (G_DBUS_PROXY (self),
secret_collection_set_label,