Initial gobject-introspection support

This commit is contained in:
Stef Walter 2012-02-02 13:40:47 +01:00
parent 46137f865b
commit 9c20c4d65e
25 changed files with 3411 additions and 1208 deletions

3
.gitignore vendored
View File

@ -6,6 +6,9 @@
*.gcov
*.gcno
*.gcda
*.gir
*.pc
*.typelib
.deps
.cproject
.libs

View File

@ -1,19 +1,22 @@
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

View File

@ -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

View File

@ -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

14
library/libsecret.pc.in Normal file
View File

@ -0,0 +1,14 @@
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@

View File

@ -21,14 +21,6 @@
#include <glib/gi18n-lib.h>
/**
* SECTION:secret-collection
*/
/**
* SecretCollection:
*/
enum {
PROP_0,
PROP_SERVICE,
@ -599,9 +591,6 @@ 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,
@ -641,7 +630,6 @@ 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)
@ -672,7 +660,8 @@ 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()
@ -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)
{
@ -873,9 +872,9 @@ 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()
@ -924,8 +923,6 @@ 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,
@ -951,7 +948,7 @@ 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,
@ -972,11 +969,11 @@ 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,

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_COLLECTION_H__
#define __SECRET_COLLECTION_H__

View File

@ -368,6 +368,18 @@ secret_item_async_initable_iface (GAsyncInitableIface *iface)
iface->init_finish = secret_item_async_initable_init_finish;
}
/**
* secret_item_new:
* @service: a secret service object
* @item_path: the dbus path of the collection
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Get a new item proxy for a secret item in the secret service.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_item_new (SecretService *service,
const gchar *item_path,
@ -395,6 +407,17 @@ secret_item_new (SecretService *service,
NULL);
}
/**
* secret_item_new_finish:
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish asynchronous operation to get a new item proxy for an secret
* item in the secret service.
*
* Returns: (transfer full): the new item, which should be unreferenced
* with g_object_unref()
*/
SecretItem *
secret_item_new_finish (GAsyncResult *result,
GError **error)
@ -413,6 +436,21 @@ secret_item_new_finish (GAsyncResult *result,
return SECRET_ITEM (object);
}
/**
* secret_item_new_sync:
* @service: a secret service object
* @item_path: the dbus path of the item
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Get a new item proxy for a secret item in the secret service.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): the new item, which should be unreferenced
* with g_object_unref()
*/
SecretItem *
secret_item_new_sync (SecretService *service,
const gchar *item_path,
@ -440,6 +478,16 @@ secret_item_new_sync (SecretService *service,
NULL);
}
/**
* secret_item_refresh:
* @self: the collection
*
* Refresh the properties on this item. 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_item_refresh (SecretItem *self)
{
@ -534,6 +582,27 @@ item_properties_new (const gchar *schema_name,
return properties;
}
/**
* secret_item_create:
* @collection: a secret collection to create this item in
* @schema_name: schema name for the new item
* @label: label for the new item
* @attributes: attributes for the new item
* @value: secret value for the new item
* @replace: whether to replace an existing item with the same attributes
* @callback: called when the operation completes
* @user_data: data to pass to the callback
*
* Create a new item in the secret service.
*
* If the @replace is set to %TRUE, then the secret service will search for
* an item matching the @attributes, and update that item instead of creating
* a new one.
*
* 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.
*/
void
secret_item_create (SecretCollection *collection,
const gchar *schema_name,
@ -577,6 +646,16 @@ secret_item_create (SecretCollection *collection,
g_object_unref (res);
}
/**
* secret_item_create_finish:
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish operation to create a new item in the secret service.
*
* Returns: (transfer full): the new item, which should be unreferenced
* with g_object_unref()
*/
SecretItem *
secret_item_create_finish (GAsyncResult *result,
GError **error)
@ -600,6 +679,30 @@ secret_item_create_finish (GAsyncResult *result,
return g_object_ref (closure->item);
}
/**
* secret_item_create_sync:
* @collection: a secret collection to create this item in
* @schema_name: schema name for the new item
* @label: label for the new item
* @attributes: attributes for the new item
* @value: secret value for the new item
* @replace: whether to replace an existing item with the same attributes
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Create a new item in the secret service.
*
* If the @replace is set to %TRUE, then the secret service will search for
* an item matching the @attributes, and update that item instead of creating
* a new one.
*
* 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 item, which should be unreferenced
* with g_object_unref()
*/
SecretItem *
secret_item_create_sync (SecretCollection *collection,
const gchar *schema_name,
@ -664,6 +767,19 @@ on_item_deleted (GObject *source,
g_object_unref (res);
}
/**
* secret_collection_delete:
* @self: a collection
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to pass to the callback
*
* Delete this collection.
*
* 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.
*/
void
secret_item_delete (SecretItem *self,
GCancellable *cancellable,
@ -686,6 +802,16 @@ secret_item_delete (SecretItem *self,
g_object_unref (res);
}
/**
* secret_item_delete_finish:
* @self: an item
* @result: asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete asynchronous operation to delete the secret item.
*
* Returns: whether the item was successfully deleted or not
*/
gboolean
secret_item_delete_finish (SecretItem *self,
GAsyncResult *result,
@ -706,6 +832,20 @@ secret_item_delete_finish (SecretItem *self,
return g_simple_async_result_get_op_res_gboolean (res);
}
/**
* secret_item_delete_sync:
* @self: an item
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Delete this secret item.
*
* 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
*/
gboolean
secret_item_delete_sync (SecretItem *self,
GCancellable *cancellable,
@ -809,6 +949,20 @@ on_get_ensure_session (GObject *source,
g_object_unref (res);
}
/**
* secret_item_get_secret:
* @self: an item
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to pass to the callback
*
* Get the secret value of this item.
*
* Each item has a single secret which might be a password or some
* other secret binary value.
*
* This function returns immediately and completes asynchronously.
*/
void
secret_item_get_secret (SecretItem *self,
GCancellable *cancellable,
@ -834,7 +988,20 @@ secret_item_get_secret (SecretItem *self,
g_object_unref (res);
}
SecretValue*
/**
* secret_item_get_secret_finish:
* @self: an item
* @result: asynchronous result passed to callback
* @error: location to place error on failure
*
* Get the secret value of this item.
*
* Complete asynchronous operation to get the secret value of this item.
*
* Returns: (transfer full): the newly allocated secret value in this
* item, which should be released with secret_value_unref()
*/
SecretValue *
secret_item_get_secret_finish (SecretItem *self,
GAsyncResult *result,
GError **error)
@ -853,7 +1020,24 @@ secret_item_get_secret_finish (SecretItem *self,
return closure->value ? secret_value_ref (closure->value) : NULL;
}
SecretValue*
/**
* secret_item_get_secret_sync:
* @self: an item
* @cancellable: optional cancellation object
* @error: location to place error on failure
*
* Get the secret value of this item.
*
* Each item has a single secret which might be a password or some
* other secret binary value.
*
* This function may block indefinetely. Use the asynchronous version
* in user interface threads.
*
* Returns: (transfer full): the newly allocated secret value in this
* item, which should be released with secret_value_unref()
*/
SecretValue *
secret_item_get_secret_sync (SecretItem *self,
GCancellable *cancellable,
GError **error)
@ -944,6 +1128,21 @@ on_set_ensure_session (GObject *source,
g_object_unref (res);
}
/**
* secret_item_set_secret:
* @self: an item
* @value: a new secret value
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to pass to the callback
*
* Set the secret value of this item.
*
* Each item has a single secret which might be a password or some
* other secret binary value.
*
* This function returns immediately and completes asynchronously.
*/
void
secret_item_set_secret (SecretItem *self,
SecretValue *value,
@ -972,6 +1171,16 @@ secret_item_set_secret (SecretItem *self,
g_object_unref (res);
}
/**
* secret_item_set_secret_finish:
* @self: an item
* @result: asynchronous result passed to callback
* @error: location to place error on failure
*
* Complete asynchronous operation to set the secret value of this item.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_secret_finish (SecretItem *self,
GAsyncResult *result,
@ -989,6 +1198,23 @@ secret_item_set_secret_finish (SecretItem *self,
return TRUE;
}
/**
* secret_item_set_secret_sync:
* @self: an item
* @value: a new secret value
* @cancellable: optional cancellation object
* @error: location to place error on failure
*
* Set the secret value of this item.
*
* Each item has a single secret which might be a password or some
* other secret binary value.
*
* This function may block indefinetely. Use the asynchronous version
* in user interface threads.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_secret_sync (SecretItem *self,
SecretValue *value,
@ -1017,6 +1243,22 @@ secret_item_set_secret_sync (SecretItem *self,
return ret;
}
/**
* secret_item_get_attributes:
* @self: an item
*
* Set the attributes of this item.
*
* The @attributes are a mapping of string keys to string values.
* Attributes are used to search for items. Attributes are not stored
* or transferred securely by the secret service.
*
* Do not modify the attributes returned by this method. Use
* secret_item_set_attributes() instead.
*
* Returns: (transfer full): a new reference to the attributes, which should
* not be modified, and released with g_hash_table_unref()
*/
GHashTable *
secret_item_get_attributes (SecretItem *self)
{
@ -1034,6 +1276,22 @@ secret_item_get_attributes (SecretItem *self)
return attributes;
}
/**
* secret_item_set_attributes:
* @self: an item
* @attributes: a new set of attributes
* @cancellable: optional cancellation object
* @callback: called when the asynchronous operation completes
* @user_data: data to pass to the callback
*
* Set the attributes of this item.
*
* The @attributes are a mapping of string keys to string values.
* Attributes are used to search for items. Attributes are not stored
* or transferred securely by the secret service.
*
* This function returns immediately and completes asynchronously.
*/
void
secret_item_set_attributes (SecretItem *self,
GHashTable *attributes,
@ -1050,6 +1308,16 @@ secret_item_set_attributes (SecretItem *self,
callback, user_data);
}
/**
* secret_item_set_attributes_finish:
* @self: an item
* @result: asynchronous result passed to the callback
* @error: location to place error on failure
*
* Complete operation to set the attributes of this item.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_attributes_finish (SecretItem *self,
GAsyncResult *result,
@ -1062,6 +1330,24 @@ secret_item_set_attributes_finish (SecretItem *self,
result, error);
}
/**
* secret_item_set_attributes_sync:
* @self: an item
* @attributes: a new set of attributes
* @cancellable: optional cancellation object
* @error: location to place error on failure
*
* Set the attributes of this item.
*
* The @attributes are a mapping of string keys to string values.
* Attributes are used to search for items. Attributes are not stored
* or transferred securely by the secret service.
*
* This function may block indefinetely. Use the asynchronous version
* in user interface threads.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_attributes_sync (SecretItem *self,
GHashTable *attributes,
@ -1076,6 +1362,17 @@ secret_item_set_attributes_sync (SecretItem *self,
cancellable, error);
}
/**
* secret_item_get_schema:
* @self: an item
*
* Get the schema of this item.
*
* The schema is a dotted string like <literal>org.freedesktop.Secret.Generic</literal>.
* A schema describes the set of attributes that should be set on this item.
*
* Returns: (transfer full): the schema, which should be freed with g_free()
*/
gchar *
secret_item_get_schema (SecretItem *self)
{
@ -1094,6 +1391,14 @@ secret_item_get_schema (SecretItem *self)
return label;
}
/**
* secret_item_get_label:
* @self: an item
*
* Get the label of this item.
*
* Returns: (transfer full): the label, which should be freed with g_free()
*/
gchar *
secret_item_get_label (SecretItem *self)
{
@ -1111,6 +1416,18 @@ secret_item_get_label (SecretItem *self)
return label;
}
/**
* secret_item_set_label:
* @self: an item
* @label: a new label
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to pass to the callback
*
* Set the label of this item.
*
* This function returns immediately and completes asynchronously.
*/
void
secret_item_set_label (SecretItem *self,
const gchar *label,
@ -1127,6 +1444,16 @@ secret_item_set_label (SecretItem *self,
cancellable, callback, user_data);
}
/**
* secret_item_set_label_finish:
* @self: an item
* @result: asynchronous result passed to callback
* @error: location to place error on failure
*
* Complete asynchronous operation to set the label of this collection.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_label_finish (SecretItem *self,
GAsyncResult *result,
@ -1139,6 +1466,20 @@ secret_item_set_label_finish (SecretItem *self,
result, error);
}
/**
* secret_item_set_label_sync:
* @self: an item
* @label: a new label
* @cancellable: optional cancellation object
* @error: location to place error on failure
*
* Set the label of this item.
*
* This function may block indefinetely. Use the asynchronous version
* in user interface threads.
*
* Returns: whether the change was successful or not
*/
gboolean
secret_item_set_label_sync (SecretItem *self,
const gchar *label,
@ -1153,6 +1494,17 @@ secret_item_set_label_sync (SecretItem *self,
cancellable, error);
}
/**
* secret_item_get_locked:
* @self: an item
*
* Get whether the item is locked or not.
*
* Depending on the secret service an item may not be able to be locked
* independently from the collection that it is in.
*
* Returns: whether the item is locked or not
*/
gboolean
secret_item_get_locked (SecretItem *self)
{
@ -1170,6 +1522,15 @@ secret_item_get_locked (SecretItem *self)
return locked;
}
/**
* secret_item_get_created:
* @self: an item
*
* Get the created date and time of the item. The return value is
* the number of seconds since the unix epoch, January 1st 1970.
*
* Returns: the created date and time
*/
guint64
secret_item_get_created (SecretItem *self)
{
@ -1187,6 +1548,15 @@ secret_item_get_created (SecretItem *self)
return created;
}
/**
* secret_item_get_modified:
* @self: an item
*
* Get the modified date and time of the item. The return value is
* the number of seconds since the unix epoch, January 1st 1970.
*
* Returns: the modified date and time
*/
guint64
secret_item_get_modified (SecretItem *self)
{

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_ITEM_H__
#define __SECRET_ITEM_H__
@ -33,7 +37,7 @@ typedef struct _SecretItemPrivate SecretItemPrivate;
struct _SecretItem {
GDBusProxy parent_instance;
SecretItemPrivate *pv;;
SecretItemPrivate *pv;
};
struct _SecretItemClass {
@ -166,4 +170,4 @@ guint64 secret_item_get_modified (SecretItem *self);
G_END_DECLS
#endif /* __G_ITEM_H___ */
#endif /* __SECRET_ITEM_H___ */

File diff suppressed because it is too large Load Diff

View File

@ -87,6 +87,29 @@ on_store_connected (GObject *source,
g_object_unref (res);
}
/**
* secret_password_store:
* @schema: the schema for attributes
* @collection_path: the dbus path to the collection where to store the secret
* @label: label for the secret
* @password: the null-terminated password to store
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
* @...: the attribute keys and values, terminated with %NULL
*
* Store a password in the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the @schema.
* The list of attribtues should be terminated with a %NULL.
*
* If the attributes match a secret item already stored in the collection, then
* the item will be updated with these new values.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_store (const SecretSchema *schema,
const gchar *collection_path,
@ -110,18 +133,38 @@ secret_password_store (const SecretSchema *schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
secret_password_storev (schema, collection_path, label, password, attributes,
secret_password_storev (schema, attributes, collection_path, label, password,
cancellable, callback, user_data);
g_hash_table_unref (attributes);
}
/**
* secret_password_storev:
* @schema: the schema for attributes
* @attributes: the attribute keys and values
* @collection_path: the dbus path to the collection where to store the secret
* @label: label for the secret
* @password: the null-terminated password to store
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Store a password in the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If the attributes match a secret item already stored in the collection, then
* the item will be updated with these new values.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_storev (const SecretSchema *schema,
GHashTable *attributes,
const gchar *collection_path,
const gchar *label,
const gchar *password,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@ -153,6 +196,16 @@ secret_password_storev (const SecretSchema *schema,
g_object_unref (res);
}
/**
* secret_service_store_finish:
* @self: the secret service
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish asynchronous operation to store a password in the secret service.
*
* Returns: whether the storage was successful or not
*/
gboolean
secret_password_store_finish (GAsyncResult *result,
GError **error)
@ -172,6 +225,31 @@ secret_password_store_finish (GAsyncResult *result,
return closure->created;
}
/**
* secret_password_store_sync:
* @schema: the schema for attributes
* @collection_path: the dbus path to the collection where to store the secret
* @label: label for the secret
* @password: the null-terminated password to store
* @cancellable: optional cancellation object
* @error: location to place an error on failure
* @...: the attribute keys and values, terminated with %NULL
*
* Store a password in the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the @schema.
* The list of attribtues should be terminated with a %NULL.
*
* If the attributes match a secret item already stored in the collection, then
* the item will be updated with these new values.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: whether the storage was successful or not
*/
gboolean
secret_password_store_sync (const SecretSchema *schema,
const gchar *collection_path,
@ -195,19 +273,41 @@ secret_password_store_sync (const SecretSchema *schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
ret = secret_password_storev_sync (schema, collection_path, label, password,
attributes, cancellable, error);
ret = secret_password_storev_sync (schema, attributes, collection_path,
label, password, cancellable, error);
g_hash_table_unref (attributes);
return ret;
}
/**
* secret_password_storev_sync:
* @schema: the schema for attributes
* @attributes: the attribute keys and values
* @collection_path: the dbus path to the collection where to store the secret
* @label: label for the secret
* @password: the null-terminated password to store
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Store a password in the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If the attributes match a secret item already stored in the collection, then
* the item will be updated with these new values.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: whether the storage was successful or not
*/
gboolean
secret_password_storev_sync (const SecretSchema *schema,
GHashTable *attributes,
const gchar *collection_path,
const gchar *label,
const gchar *password,
GHashTable *attributes,
GCancellable *cancellable,
GError **error)
{
@ -225,7 +325,7 @@ secret_password_storev_sync (const SecretSchema *schema,
sync = _secret_sync_new ();
g_main_context_push_thread_default (sync->context);
secret_password_storev (schema, collection_path, label, password, attributes,
secret_password_storev (schema, attributes, collection_path, label, password,
cancellable, _secret_sync_on_result, sync);
g_main_loop_run (sync->loop);
@ -242,6 +342,7 @@ typedef struct {
GCancellable *cancellable;
GHashTable *attributes;
SecretValue *value;
const SecretSchema *schema;
} LookupClosure;
static void
@ -255,6 +356,25 @@ lookup_closure_free (gpointer data)
g_slice_free (LookupClosure, closure);
}
/**
* secret_password_lookup:
* @schema: the schema to for attributes
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
* @...: the attribute keys and values, terminated with %NULL
*
* Lookup a password in the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the password
* @schema. The list of attribtues should be terminated with a %NULL.
*
* If no secret is found then %NULL is returned.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_lookup (const SecretSchema *schema,
GCancellable *cancellable,
@ -272,7 +392,8 @@ secret_password_lookup (const SecretSchema *schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
secret_password_lookupv (attributes, cancellable, callback, user_data);
secret_password_lookupv (schema, attributes, cancellable,
callback, user_data);
g_hash_table_unref (attributes);
}
@ -312,16 +433,34 @@ on_lookup_connected (GObject *source,
g_simple_async_result_complete (res);
} else {
secret_service_lookupv (service, closure->attributes, closure->cancellable,
on_lookup_complete, g_object_ref (res));
secret_service_lookupv (service, closure->schema, closure->attributes,
closure->cancellable, on_lookup_complete,
g_object_ref (res));
g_object_unref (service);
}
g_object_unref (res);
}
/**
* secret_password_lookupv:
* @schema: the schema for attributes
* @attributes: the attribute keys and values
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Lookup a password in the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If no secret is found then %NULL is returned.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_lookupv (GHashTable *attributes,
secret_password_lookupv (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@ -329,12 +468,14 @@ secret_password_lookupv (GHashTable *attributes,
GSimpleAsyncResult *res;
LookupClosure *closure;
g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
res = g_simple_async_result_new (NULL, callback, user_data,
secret_password_lookupv);
closure = g_slice_new0 (LookupClosure);
closure->schema = schema;
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
closure->attributes = g_hash_table_ref (attributes);
g_simple_async_result_set_op_res_gpointer (res, closure, lookup_closure_free);
@ -345,6 +486,16 @@ secret_password_lookupv (GHashTable *attributes,
g_object_unref (res);
}
/**
* secret_password_lookup_finish:
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish an asynchronous operation to lookup a password in the secret service.
*
* Returns: (transfer full): a new password string which should be freed with
* secret_password_free() when done
*/
gchar *
secret_password_lookup_finish (GAsyncResult *result,
GError **error)
@ -372,6 +523,28 @@ secret_password_lookup_finish (GAsyncResult *result,
return password;
}
/**
* secret_password_lookup_sync:
* @schema: the schema to for attributes
* @cancellable: optional cancellation object
* @error: location to place an error on failure
* @...: the attribute keys and values, terminated with %NULL
*
* Lookup a password in the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the password
* @schema. The list of attribtues should be terminated with a %NULL.
*
* If no secret is found then %NULL is returned.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): a new password string which should be freed with
* secret_password_free() when done
*/
gchar *
secret_password_lookup_sync (const SecretSchema *schema,
GCancellable *cancellable,
@ -390,21 +563,43 @@ secret_password_lookup_sync (const SecretSchema *schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
password = secret_password_lookupv_sync (attributes, cancellable, error);
password = secret_password_lookupv_sync (schema, attributes,
cancellable, error);
g_hash_table_unref (attributes);
return password;
}
/**
* secret_password_lookupv_sync:
* @schema: the schema for attributes
* @attributes: the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Lookup a password in the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If no secret is found then %NULL is returned.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): a new password string which should be freed with
* secret_password_free() when done
*/
gchar *
secret_password_lookupv_sync (GHashTable *attributes,
secret_password_lookupv_sync (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error)
{
SecretSync *sync;
gchar *password;
g_return_val_if_fail (schema != NULL, NULL);
g_return_val_if_fail (attributes != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@ -412,7 +607,7 @@ secret_password_lookupv_sync (GHashTable *attributes,
sync = _secret_sync_new ();
g_main_context_push_thread_default (sync->context);
secret_password_lookupv (attributes, cancellable,
secret_password_lookupv (schema, attributes, cancellable,
_secret_sync_on_result, sync);
g_main_loop_run (sync->loop);
@ -429,6 +624,7 @@ typedef struct {
GCancellable *cancellable;
GHashTable *attributes;
gboolean deleted;
const SecretSchema *schema;
} DeleteClosure;
static void
@ -440,6 +636,25 @@ delete_closure_free (gpointer data)
g_slice_free (DeleteClosure, closure);
}
/**
* secret_password_remove:
* @schema: the schema to for attributes
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
* @...: the attribute keys and values, terminated with %NULL
*
* Remove a password from the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the password
* @schema. The list of attribtues should be terminated with a %NULL.
*
* If multiple items match the attributes, then only one will be deleted.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_remove (const SecretSchema *schema,
GCancellable *cancellable,
@ -457,7 +672,7 @@ secret_password_remove (const SecretSchema *schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
secret_password_removev (attributes, cancellable,
secret_password_removev (schema, attributes, cancellable,
callback, user_data);
g_hash_table_unref (attributes);
@ -493,7 +708,7 @@ on_delete_connect (GObject *source,
service = secret_service_get_finish (result, &error);
if (error == NULL) {
secret_service_removev (service, closure->attributes,
secret_service_removev (service, closure->schema, closure->attributes,
closure->cancellable, on_delete_complete,
g_object_ref (res));
g_object_unref (service);
@ -506,8 +721,25 @@ on_delete_connect (GObject *source,
g_object_unref (res);
}
/**
* secret_password_removev:
* @schema: the schema to for attributes
* @attributes: the attribute keys and values
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Remove a password from the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If multiple items match the attributes, then only one will be deleted.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_password_removev (GHashTable *attributes,
secret_password_removev (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@ -515,12 +747,14 @@ secret_password_removev (GHashTable *attributes,
GSimpleAsyncResult *res;
DeleteClosure *closure;
g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
res = g_simple_async_result_new (NULL, callback, user_data,
secret_password_removev);
closure = g_slice_new0 (DeleteClosure);
closure->schema = schema;
closure->attributes = g_hash_table_ref (attributes);
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
g_simple_async_result_set_op_res_gpointer (res, closure, delete_closure_free);
@ -531,6 +765,16 @@ secret_password_removev (GHashTable *attributes,
g_object_unref (res);
}
/**
* secret_password_remove_finish
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish an asynchronous operation to remove a password from the secret
* service.
*
* Returns: whether the removal was successful or not
*/
gboolean
secret_password_remove_finish (GAsyncResult *result,
GError **error)
@ -550,6 +794,27 @@ secret_password_remove_finish (GAsyncResult *result,
return closure->deleted;
}
/**
* secret_password_remove_sync:
* @schema: the schema to for attributes
* @cancellable: optional cancellation object
* @error: location to place an error on failure
* @...: the attribute keys and values, terminated with %NULL
*
* Remove a password from the secret service.
*
* The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the password
* @schema. The list of attribtues should be terminated with a %NULL.
*
* If multiple items match the attributes, then only one will be deleted.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: whether the removal was successful or not
*/
gboolean
secret_password_remove_sync (const SecretSchema* schema,
GCancellable *cancellable,
@ -568,21 +833,42 @@ secret_password_remove_sync (const SecretSchema* schema,
attributes = _secret_util_attributes_for_varargs (schema, va);
va_end (va);
result = secret_password_removev_sync (attributes, cancellable, error);
result = secret_password_removev_sync (schema, attributes,
cancellable, error);
g_hash_table_unref (attributes);
return result;
}
/**
* secret_password_removev_sync:
* @schema: the schema to for attributes
* @attributes: the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Remove a password from the secret service.
*
* The @attributes should be a set of key and value string pairs.
*
* If multiple items match the attributes, then only one will be deleted.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: whether the removal was successful or not
*/
gboolean
secret_password_removev_sync (GHashTable *attributes,
secret_password_removev_sync (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error)
{
SecretSync *sync;
gboolean result;
g_return_val_if_fail (schema != NULL, FALSE);
g_return_val_if_fail (attributes != NULL, FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -590,7 +876,7 @@ secret_password_removev_sync (GHashTable *attributes,
sync = _secret_sync_new ();
g_main_context_push_thread_default (sync->context);
secret_password_removev (attributes, cancellable,
secret_password_removev (schema, attributes, cancellable,
_secret_sync_on_result, sync);
g_main_loop_run (sync->loop);
@ -603,6 +889,13 @@ secret_password_removev_sync (GHashTable *attributes,
return result;
}
/**
* secret_password_free:
* @password: (type utf8) (allow-none): password to free
*
* Free a password returned by secret_password_lookup_finish(),
* secret_password_lookup_sync() or secret_password_lookupv_sync().
*/
void
secret_password_free (gpointer password)
{

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_PASSWORD_H__
#define __SECRET_PASSWORD_H__
@ -29,10 +33,10 @@ void secret_password_store (const SecretSchema *sche
...) G_GNUC_NULL_TERMINATED;
void secret_password_storev (const SecretSchema *schema,
GHashTable *attributes,
const gchar *collection_path,
const gchar *label,
const gchar *password,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -49,10 +53,10 @@ gboolean secret_password_store_sync (const SecretSchema *sche
...) G_GNUC_NULL_TERMINATED;
gboolean secret_password_storev_sync (const SecretSchema *schema,
const gchar *collection_path,
const gchar *display_name,
const gchar *password,
GHashTable *attributes,
const gchar *collection_path,
const gchar *label,
const gchar *password,
GCancellable *cancellable,
GError **error);
@ -62,7 +66,8 @@ void secret_password_lookup (const SecretSchema *sche
gpointer user_data,
...) G_GNUC_NULL_TERMINATED;
void secret_password_lookupv (GHashTable *attributes,
void secret_password_lookupv (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -75,7 +80,8 @@ gchar * secret_password_lookup_sync (const SecretSchema *sche
GError **error,
...) G_GNUC_NULL_TERMINATED;
gchar * secret_password_lookupv_sync (GHashTable *attributes,
gchar * secret_password_lookupv_sync (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error);
@ -85,7 +91,8 @@ void secret_password_remove (const SecretSchema *sche
gpointer user_data,
...) G_GNUC_NULL_TERMINATED;
void secret_password_removev (GHashTable *attributes,
void secret_password_removev (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -98,7 +105,8 @@ gboolean secret_password_remove_sync (const SecretSchema* sche
GError **error,
...) G_GNUC_NULL_TERMINATED;
gboolean secret_password_removev_sync (GHashTable *attributes,
gboolean secret_password_removev_sync (const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error);
@ -106,4 +114,4 @@ void secret_password_free (gpointer password);
G_END_DECLS
#endif /* __G_SERVICE_H___ */
#endif /* __SECRET_PASSWORD_H___ */

View File

@ -49,8 +49,8 @@ void _secret_sync_on_result (GObject *source,
GAsyncResult *result,
gpointer user_data);
SecretPrompt * _secret_prompt_instance (GDBusConnection *connection,
const gchar *object_path);
SecretPrompt * _secret_prompt_instance (SecretService *service,
const gchar *prompt_path);
gchar * _secret_util_parent_path (const gchar *path);
@ -143,4 +143,4 @@ SecretValue * _secret_session_decode_secret (SecretSession *ses
G_END_DECLS
#endif /* __G_SERVICE_H___ */
#endif /* __SECRET_PRIVATE_H___ */

View File

@ -77,7 +77,7 @@ on_prompt_run_complete (GObject *source,
}
SecretPrompt *
secret_prompt_instance (SecretService *service,
_secret_prompt_instance (SecretService *service,
const gchar *prompt_path)
{
GDBusProxy *proxy;
@ -106,6 +106,28 @@ secret_prompt_instance (SecretService *service,
return prompt;
}
/**
* secret_prompt_run:
* @self: a prompt
* @window_id: XWindow id for parent window to be transient for
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Runs a prompt and performs the prompting. Returns %TRUE if the prompt
* was completed and not dismissed.
*
* If @window_id is non-zero then it is used as an XWindow id. The Secret
* Service can make its prompt transient for the window with this id. In some
* Secret Service implementations this is not possible, so the behavior
* depending on this should degrade gracefully.
*
* This runs the dialog in a recursive mainloop. When run from a user interface
* thread, this means the user interface will remain responsive. Care should be
* taken that appropriate user interface actions are disabled while running the
* prompt.
*
* Returns: %FALSE if the prompt was dismissed or an error occurred
*/
gboolean
secret_prompt_run (SecretPrompt *self,
gulong window_id,
@ -139,6 +161,26 @@ secret_prompt_run (SecretPrompt *self,
return ret;
}
/**
* secret_prompt_perform_sync:
* @self: a prompt
* @window_id: XWindow id for parent window to be transient for
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Runs a prompt and performs the prompting. Returns %TRUE if the prompt
* was completed and not dismissed.
*
* If @window_id is non-zero then it is used as an XWindow id. The Secret
* Service can make its prompt transient for the window with this id. In some
* Secret Service implementations this is not possible, so the behavior
* depending on this should degrade gracefully.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: %FALSE if the prompt was dismissed or an error occurred
*/
gboolean
secret_prompt_perform_sync (SecretPrompt *self,
gulong window_id,
@ -341,6 +383,24 @@ on_prompt_cancelled (GCancellable *cancellable,
g_object_unref (self);
}
/**
* secret_prompt_perform:
* @self: a prompt
* @window_id: XWindow id for parent window to be transient for
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Runs a prompt and performs the prompting. Returns %TRUE if the prompt
* was completed and not dismissed.
*
* If @window_id is non-zero then it is used as an XWindow id. The Secret
* Service can make its prompt transient for the window with this id. In some
* Secret Service implementations this is not possible, so the behavior
* depending on this should degrade gracefully.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_prompt_perform (SecretPrompt *self,
gulong window_id,
@ -415,6 +475,16 @@ secret_prompt_perform (SecretPrompt *self,
g_object_unref (res);
}
/**
* secret_prompt_perform_finish:
* @self: a prompt
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete asynchronous operation to run a prompt and perform the prompting.
*
* Returns: %FALSE if the prompt was dismissed or an error occurred
*/
gboolean
secret_prompt_perform_finish (SecretPrompt *self,
GAsyncResult *result,
@ -437,6 +507,23 @@ secret_prompt_perform_finish (SecretPrompt *self,
return !closure->dismissed;
}
/**
* secret_prompt_get_result_value:
* @self: a prompt
* @expected_type: (allow-none): expected variant type of the result
*
* Get the result returned from a completed prompt.
*
* After performing a prompt in the Secret Service API, the prompt can
* return a result value. The type of value returned is dependent on
* the prompt.
*
* It is not normally necessary to call this function, as this is done
* automatically by other functions in this library.
*
* Returns: (transfer full): the result value which should be released with
* g_variant_unref() when done, or %NULL if no result
*/
GVariant *
secret_prompt_get_result_value (SecretPrompt *self,
const GVariantType *expected_type)

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_PROMPT_H__
#define __SECRET_PROMPT_H__
@ -41,9 +45,6 @@ struct _SecretPromptClass {
GType secret_prompt_get_type (void) G_GNUC_CONST;
SecretPrompt * secret_prompt_instance (SecretService *service,
const gchar *prompt_path);
gboolean secret_prompt_run (SecretPrompt *self,
gulong window_id,
GCancellable *cancellable,
@ -69,4 +70,4 @@ GVariant * secret_prompt_get_result_value (SecretPrompt *self,
G_END_DECLS
#endif /* __G_SERVICE_H___ */
#endif /* __SECRET_PROMPT_H___ */

View File

@ -462,6 +462,21 @@ on_service_instance_gone (gpointer user_data,
G_UNLOCK (service_instance);
}
/**
* secret_service_get:
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Get a #SecretService proxy for the Secret Service. If such a proxy object
* already exists, then the same proxy is returned.
*
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before completing.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_service_get (SecretServiceFlags flags,
GCancellable *cancellable,
@ -506,6 +521,17 @@ secret_service_get (SecretServiceFlags flags,
}
}
/**
* secret_service_get_finish:
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete an asynchronous operation to get a #SecretService proxy for the
* Secret Service.
*
* Returns: (transfer full): a new reference to a #SecretService proxy, which
* should be released with g_object_unref().
*/
SecretService *
secret_service_get_finish (GAsyncResult *result,
GError **error)
@ -546,6 +572,24 @@ secret_service_get_finish (GAsyncResult *result,
return SECRET_SERVICE (service);
}
/**
* secret_service_get_sync:
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Get a #SecretService proxy for the Secret Service. If such a proxy object
* already exists, then the same proxy is returned.
*
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before returning.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): a new reference to a #SecretService proxy, which
* should be released with g_object_unref().
*/
SecretService *
secret_service_get_sync (SecretServiceFlags flags,
GCancellable *cancellable,
@ -588,6 +632,25 @@ secret_service_get_sync (SecretServiceFlags flags,
return service;
}
/**
* secret_service_new:
* @service_bus_name: (allow-none): dbus service name of the secret service
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Create a new #SecretService proxy for the Secret Service.
*
* This function is rarely used, see secret_service_get() instead.
*
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before returning.
*
* If @service_bus_name is %NULL then the default is used.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_service_new (const gchar *service_bus_name,
SecretServiceFlags flags,
@ -612,6 +675,17 @@ secret_service_new (const gchar *service_bus_name,
NULL);
}
/**
* secret_service_new_finish:
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete an asynchronous operation to create a new #SecretService proxy for
* the Secret Service.
*
* Returns: (transfer full): a new reference to a #SecretService proxy, which
* should be released with g_object_unref().
*/
SecretService *
secret_service_new_finish (GAsyncResult *result,
GError **error)
@ -633,6 +707,28 @@ secret_service_new_finish (GAsyncResult *result,
return SECRET_SERVICE (object);
}
/**
* secret_service_new_sync:
* @service_bus_name: (allow-none): dbus service name of the secret service
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Create a new #SecretService proxy for the Secret Service.
*
* This function is rarely used, see secret_service_get_sync() instead.
*
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before returning.
*
* If @service_bus_name is %NULL then the default is used.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: (transfer full): a new reference to a #SecretService proxy, which
* should be released with g_object_unref().
*/
SecretService *
secret_service_new_sync (const gchar *service_bus_name,
SecretServiceFlags flags,
@ -655,6 +751,18 @@ secret_service_new_sync (const gchar *service_bus_name,
NULL);
}
/**
* secret_service_get_flags:
* @self: the secret service proxy
*
* Get the flags representing what features of the #SecretService proxy
* have been initialized.
*
* Use secret_service_ensure_session() or secret_service_ensure_collections()
* to initialize further features and change the flags.
*
* Returns: the flags for features initialized
*/
SecretServiceFlags
secret_service_get_flags (SecretService *self)
{
@ -674,6 +782,20 @@ secret_service_get_flags (SecretService *self)
return flags;
}
/**
* secret_service_get_collections:
* @self: the secret service proxy
*
* Get a list of #SecretCollection objects representing all the collections
* in the secret service.
*
* If the %SECRET_SERVICE_LOAD_COLLECTIONS flag was not specified when
* initializing #SecretService proxy object, then this method will return
* %NULL. Use secret_service_ensure_collections() to load the collections.
*
* Returns: (transfer full) (element-type Secret.Collection) (allow-none): a
* list of the collections in the secret service
*/
GList *
secret_service_get_collections (SecretService *self)
{
@ -755,6 +877,19 @@ _secret_service_take_session (SecretService *self,
g_mutex_unlock (&self->pv->mutex);
}
/**
* secret_service_get_session_algorithms:
* @self: the secret service proxy
*
* Get the set of algorithms being used to transfer secrets between this
* secret service proxy and the Secret Service itself.
*
* This will be %NULL if no session has been established. Use
* secret_service_ensure_session() to establish a session.
*
* Returns: (allow-none): a string representing the algorithms for transferring
* secrets
*/
const gchar *
secret_service_get_session_algorithms (SecretService *self)
{
@ -772,6 +907,19 @@ secret_service_get_session_algorithms (SecretService *self)
return algorithms;
}
/**
* secret_service_get_session_path:
* @self: the secret service proxy
*
* Get the dbus object path of the session object being used to transfer
* secrets between this secret service proxy and the Secret Service itself.
*
* This will be %NULL if no session has been established. Use
* secret_service_ensure_session() to establish a session.
*
* Returns: (allow-none): a string representing the dbus object path of the
* session
*/
const gchar *
secret_service_get_session_path (SecretService *self)
{
@ -789,6 +937,23 @@ secret_service_get_session_path (SecretService *self)
return path;
}
/**
* secret_service_ensure_session:
* @self: the secret service
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Ensure that the #SecretService proxy has established a session with the
* Secret Service. This session is used to transfer secrets.
*
* It is not normally necessary to call this method, as the session is
* established as necessary. You can also pass the %SECRET_SERVICE_OPEN_SESSION
* to secret_service_get() in order to ensure that a session has been established
* by the time you get the #SecretService proxy.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_service_ensure_session (SecretService *self,
GCancellable *cancellable,
@ -816,6 +981,17 @@ secret_service_ensure_session (SecretService *self,
}
}
/**
* secret_service_ensure_session_finish:
* @self: the secret service
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Finish an asynchronous operation to ensure that the #SecretService proxy
* has established a session with the Secret Service.
*
* Returns: the path of the established session
*/
const gchar *
secret_service_ensure_session_finish (SecretService *self,
GAsyncResult *result,
@ -834,6 +1010,25 @@ secret_service_ensure_session_finish (SecretService *self,
return secret_service_get_session_path (self);
}
/**
* secret_service_ensure_session_sync:
* @self: the secret service
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Ensure that the #SecretService proxy has established a session with the
* Secret Service. This session is used to transfer secrets.
*
* It is not normally necessary to call this method, as the session is
* established as necessary. You can also pass the %SECRET_SERVICE_OPEN_SESSION
* to secret_service_get_sync() in order to ensure that a session has been
* established by the time you get the #SecretService proxy.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: the path of the established session
*/
const gchar *
secret_service_ensure_session_sync (SecretService *self,
GCancellable *cancellable,
@ -955,6 +1150,23 @@ on_ensure_collection (GObject *source,
g_object_unref (res);
}
/**
* secret_service_ensure_collections:
* @self: the secret service
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Ensure that the #SecretService proxy has loaded all the collections present
* in the Secret Service. This affects the result of
* secret_service_get_collections().
*
* You can also pass the %SECRET_SERVICE_LOAD_COLLECTIONS to
* secret_service_get_sync() in order to ensure that the collections have been
* loaded by the time you get the #SecretService proxy.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_service_ensure_collections (SecretService *self,
GCancellable *cancellable,
@ -1004,6 +1216,17 @@ secret_service_ensure_collections (SecretService *self,
g_object_unref (res);
}
/**
* secret_service_ensure_collections_finish:
* @self: the secret service
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete an asynchronous operation to ensure that the #SecretService proxy
* has loaded all the collections present in the Secret Service.
*
* Returns: whether the load was successful or not
*/
gboolean
secret_service_ensure_collections_finish (SecretService *self,
GAsyncResult *result,
@ -1020,6 +1243,25 @@ secret_service_ensure_collections_finish (SecretService *self,
return TRUE;
}
/**
* secret_service_ensure_collections_sync:
* @self: the secret service
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Ensure that the #SecretService proxy has loaded all the collections present
* in the Secret Service. This affects the result of
* secret_service_get_collections().
*
* You can also pass the %SECRET_SERVICE_LOAD_COLLECTIONS to
* secret_service_get_sync() in order to ensure that the collections have been
* loaded by the time you get the #SecretService proxy.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*
* Returns: whether the load was successful or not
*/
gboolean
secret_service_ensure_collections_sync (SecretService *self,
GCancellable *cancellable,
@ -1065,6 +1307,24 @@ secret_service_ensure_collections_sync (SecretService *self,
return ret;
}
/**
* secret_service_prompt_sync:
* @self: the secret service
* @prompt: the prompt
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
* Perform prompting for a #SecretPrompt.
*
* This function is called by other parts of this library to handle prompts
* for the various actions that can require prompting.
*
* Override the #SecretService <literal>prompt_sync()</literal> virtual method
* to change the behavior of the propmting. The default behavior is to simply
* run secret_prompt_perform_sync() on the prompt.
*
* Returns: %FALSE if the prompt was dismissed or an error occurred
*/
gboolean
secret_service_prompt_sync (SecretService *self,
SecretPrompt *prompt,
@ -1084,6 +1344,23 @@ secret_service_prompt_sync (SecretService *self,
return (klass->prompt_sync) (self, prompt, cancellable, error);
}
/**
* secret_service_prompt:
* @self: the secret service
* @prompt: the prompt
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
*
* Perform prompting for a #SecretPrompt.
*
* This function is called by other parts of this library to handle prompts
* for the various actions that can require prompting.
*
* Override the #SecretService <literal>prompt_async()</literal> virtual method
* to change the behavior of the propmting. The default behavior is to simply
* run secret_prompt_perform() on the prompt.
*/
void
secret_service_prompt (SecretService *self,
SecretPrompt *prompt,
@ -1103,6 +1380,16 @@ secret_service_prompt (SecretService *self,
(klass->prompt_async) (self, prompt, cancellable, callback, user_data);
}
/**
* secret_service_prompt_finish:
* @self: the secret service
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
*
* Complete asynchronous operation to perform prompting for a #SecretPrompt.
*
* Returns: %FALSE if the prompt was dismissed or an error occurred
*/
gboolean
secret_service_prompt_finish (SecretService *self,
GAsyncResult *result,

View File

@ -11,6 +11,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_SERVICE_H__
#define __SECRET_SERVICE_H__
@ -168,7 +172,7 @@ gboolean secret_service_search_for_paths_sync (SecretService
GError **error);
void secret_service_get_secret_for_path (SecretService *self,
const gchar *object_path,
const gchar *item_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -178,12 +182,12 @@ SecretValue * secret_service_get_secret_for_path_finish (SecretService
GError **error);
SecretValue * secret_service_get_secret_for_path_sync (SecretService *self,
const gchar *object_path,
const gchar *item_path,
GCancellable *cancellable,
GError **error);
void secret_service_get_secrets_for_paths (SecretService *self,
const gchar **object_paths,
const gchar **item_paths,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -193,7 +197,7 @@ GHashTable * secret_service_get_secrets_for_paths_finish (SecretService
GError **error);
GHashTable * secret_service_get_secrets_for_paths_sync (SecretService *self,
const gchar **object_paths,
const gchar **item_paths,
GCancellable *cancellable,
GError **error);
@ -345,6 +349,7 @@ void secret_service_lookup (SecretService
...) G_GNUC_NULL_TERMINATED;
void secret_service_lookupv (SecretService *self,
const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@ -361,12 +366,13 @@ SecretValue * secret_service_lookup_sync (SecretService
...) G_GNUC_NULL_TERMINATED;
SecretValue * secret_service_lookupv_sync (SecretService *self,
const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error);
void secret_service_delete_path (SecretService *self,
const gchar *object_path,
const gchar *item_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@ -376,7 +382,7 @@ gboolean secret_service_delete_path_finish (SecretService
GError **error);
gboolean secret_service_delete_path_sync (SecretService *self,
const gchar *object_path,
const gchar *item_path,
GCancellable *cancellable,
GError **error);
@ -388,6 +394,7 @@ void secret_service_remove (SecretService
...) G_GNUC_NULL_TERMINATED;
void secret_service_removev (SecretService *self,
const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@ -404,6 +411,7 @@ gboolean secret_service_remove_sync (SecretService
...) G_GNUC_NULL_TERMINATED;
gboolean secret_service_removev_sync (SecretService *self,
const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GError **error);

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_TYPES_H__
#define __SECRET_TYPES_H__

View File

@ -45,8 +45,24 @@ secret_value_get_type (void)
return type;
}
SecretValue*
secret_value_new (const gchar *secret, gssize length, const gchar *content_type)
/**
* secret_value_new_full:
* @secret: the secret data
* @length: the length of the data
* @content_type: the content type of the data
*
* Create a #SecretValue for the secret data passed in. The secret data is
* copied into non-pageable 'secure' memory.
*
* If the length is less than zero, then @secret is assumed to be
* null-terminated.
*
* Returns: (transfer full): the new #SecretValue
*/
SecretValue *
secret_value_new (const gchar *secret,
gssize length,
const gchar *content_type)
{
gchar *copy;
@ -62,9 +78,26 @@ secret_value_new (const gchar *secret, gssize length, const gchar *content_type)
return secret_value_new_full (copy, length, content_type, egg_secure_free);
}
SecretValue*
secret_value_new_full (gchar *secret, gssize length,
const gchar *content_type, GDestroyNotify destroy)
/**
* secret_value_new_full:
* @secret: the secret data
* @length: the length of the data
* @content_type: the content type of the data
* @destroy: function to call to free the secret data
*
* Create a #SecretValue for the secret data passed in. The secret data is
* not copied, and will later be freed with the @destroy function.
*
* If the length is less than zero, then @secret is assumed to be
* null-terminated.
*
* Returns: (transfer full): the new #SecretValue
*/
SecretValue *
secret_value_new_full (gchar *secret,
gssize length,
const gchar *content_type,
GDestroyNotify destroy)
{
SecretValue *value;
@ -84,8 +117,20 @@ secret_value_new_full (gchar *secret, gssize length,
return value;
}
const gchar*
secret_value_get (SecretValue *value, gsize *length)
/**
* secret_value_get:
* @value: the value
* @length: (out): the length of the secret
*
* Get the secret data in the #SecretValue. The value is not necessarily
* null-terminated unless it was created with secret_value_new() or a
* null-terminated string was passed to secret_value_new_full().
*
* Returns: (array length=length): the secret data
*/
const gchar *
secret_value_get (SecretValue *value,
gsize *length)
{
g_return_val_if_fail (value, NULL);
if (length)
@ -93,14 +138,32 @@ secret_value_get (SecretValue *value, gsize *length)
return value->secret;
}
const gchar*
/**
* secret_value_get_content_type:
* @value: the value
*
* Get the content type of the secret value, such as
* <literal>text/plain</literal>.
*
* Returns: the content type
*/
const gchar *
secret_value_get_content_type (SecretValue *value)
{
g_return_val_if_fail (value, NULL);
return value->content_type;
}
SecretValue*
/**
* secret_value_unref:
* @value: value to reference
*
* Add another reference to the #SecretValue. For each reference
* secret_value_unref() should be called to unreference the value.
*
* Returns: (transfer full): the value
*/
SecretValue *
secret_value_ref (SecretValue *value)
{
g_return_val_if_fail (value, NULL);
@ -108,6 +171,13 @@ secret_value_ref (SecretValue *value)
return value;
}
/**
* secret_value_unref:
* @value: (type Secret.Value) (allow-none): value to unreference
*
* Unreference a #SecretValue. When the last reference is gone, then
* the value will be freed.
*/
void
secret_value_unref (gpointer value)
{

View File

@ -10,6 +10,10 @@
* See the included COPYING file for more information.
*/
#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
#error "Only <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_VALUE_H__
#define __SECRET_VALUE_H__
@ -23,24 +27,24 @@ G_BEGIN_DECLS
GType secret_value_get_type (void) G_GNUC_CONST;
SecretValue* secret_value_new (const gchar *secret,
SecretValue * secret_value_new (const gchar *secret,
gssize length,
const gchar *content_type);
SecretValue* secret_value_new_full (gchar *secret,
SecretValue * secret_value_new_full (gchar *secret,
gssize length,
const gchar *content_type,
GDestroyNotify destroy);
const gchar* secret_value_get (SecretValue *value,
const gchar * secret_value_get (SecretValue *value,
gsize *length);
const gchar* secret_value_get_content_type (SecretValue *value);
const gchar * secret_value_get_content_type (SecretValue *value);
SecretValue* secret_value_ref (SecretValue *value);
SecretValue * secret_value_ref (SecretValue *value);
void secret_value_unref (gpointer value);
G_END_DECLS
#endif /* __G_SERVICE_H___ */
#endif /* __SECRET_VALUE_H___ */

34
library/secret.h Normal file
View File

@ -0,0 +1,34 @@
/* libsecret - GLib wrapper for Secret Service
*
* Copyright 2012 Red Hat Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the licence or (at
* your option) any later version.
*
* See the included COPYING file for more information.
*/
#ifndef SECRET_API_SUBJECT_TO_CHANGE
#error "This API has not yet reached stability."
#endif
#ifndef __SECRET_H__
#define __SECRET_H__
#include <glib.h>
#define __SECRET_INSIDE_HEADER__
#include <secret/secret-collection.h>
#include <secret/secret-enum-types.h>
#include <secret/secret-item.h>
#include <secret/secret-password.h>
#include <secret/secret-prompt.h>
#include <secret/secret-service.h>
#include <secret/secret-value.h>
#undef __SECRET_INSIDE_HEADER__
#endif /* __SECRET_H__ */

View File

@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
INCLUDES = \
-I$(top_srcdir)/library \
-DSRCDIR="\"@abs_srcdir@\"" \
-DSECRET_COMPILATION \
$(NULL)
noinst_LTLIBRARIES = libmock_service.la
@ -16,12 +17,12 @@ libmock_service_la_CFLAGS = \
libmock_service_la_LIBADD = \
$(top_builddir)/egg/libegg.la \
$(top_builddir)/library/libsecret.la \
$(top_builddir)/library/libsecret-@SECRET_MAJOR@.la \
$(LIBGCRYPT_LIBS)
LDADD = \
$(top_builddir)/egg/libegg.la \
$(top_builddir)/library/libsecret.la \
$(top_builddir)/library/libsecret-@SECRET_MAJOR@.la \
$(top_builddir)/library/tests/libmock_service.la \
$(NULL)

View File

@ -90,7 +90,7 @@ test_perform_sync (Test *test,
/* Verify that main loop does not run during this call */
increment_id = g_idle_add (on_idle_increment, &value);
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
ret = secret_prompt_perform_sync (prompt, 0, NULL, &error);
g_assert_no_error (error);
@ -116,7 +116,7 @@ test_perform_run (Test *test,
/* Verify that main loop does run during this call */
increment_id = g_idle_add (on_idle_increment, &value);
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
ret = secret_prompt_run (prompt, 0, NULL, &error);
g_assert_no_error (error);
@ -141,7 +141,7 @@ test_perform_async (Test *test,
GAsyncResult *result = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
secret_prompt_perform (prompt, 0, NULL, on_async_result, &result);
g_assert (result == NULL);
@ -170,7 +170,7 @@ test_perform_cancel (Test *test,
GCancellable *cancellable;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/delay");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/delay");
cancellable = g_cancellable_new ();
secret_prompt_perform (prompt, 0, cancellable, on_async_result, &result);
@ -202,7 +202,7 @@ test_perform_fail (Test *test,
GError *error = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/error");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/error");
ret = secret_prompt_perform_sync (prompt, 0, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED);
@ -220,7 +220,7 @@ test_perform_vanish (Test *test,
GError *error = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/vanish");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/vanish");
ret = secret_prompt_perform_sync (prompt, 0, NULL, &error);
g_assert_no_error (error);
@ -239,7 +239,7 @@ test_prompt_result (Test *test,
gboolean ret;
GVariant *result;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/result");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/result");
result = secret_prompt_get_result_value (prompt, NULL);
g_assert (result == NULL);
@ -266,7 +266,7 @@ test_prompt_window_id (Test *test,
gboolean ret;
GVariant *result;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/window");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/window");
ret = secret_prompt_perform_sync (prompt, 555, NULL, &error);
g_assert_no_error (error);
@ -289,7 +289,7 @@ test_service_sync (Test *test,
GError *error = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
ret = secret_service_prompt_sync (test->service, prompt, NULL, &error);
g_assert_no_error (error);
@ -308,7 +308,7 @@ test_service_async (Test *test,
GAsyncResult *result = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
secret_service_prompt (test->service, prompt, NULL, on_async_result, &result);
g_assert (result == NULL);
@ -336,7 +336,7 @@ test_service_fail (Test *test,
GAsyncResult *result = NULL;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/error");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/error");
secret_service_prompt (test->service, prompt, NULL, on_async_result, &result);
g_assert (result == NULL);
@ -364,7 +364,7 @@ test_service_path (Test *test,
SecretPrompt *prompt;
gboolean ret;
prompt = secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
secret_service_prompt (test->service, prompt, NULL, on_async_result, &result);
g_assert (result == NULL);