FolksDummyPersonaStore

FolksDummyPersonaStore — A persona store which allows FolksDummyPersonas to be programmatically created and manipulated, for the purposes of testing the core of libfolks itself. This should not be used in user-visible applications.

Functions

Properties

GStrv always-writeable-properties Read
FolksMaybeBool can-add-personas Read
FolksMaybeBool can-alias-personas Read
FolksMaybeBool can-group-personas Read
FolksMaybeBool can-remove-personas Read
gboolean is-prepared Read
gboolean is-quiescent Read
GType * persona-type Read / Write
GeeMap * personas Read
gchar * type-id Read

Types and Values

Object Hierarchy

    GObject
    ╰── FolksPersonaStore
        ╰── FolksDummyPersonaStore

Description

There are two sides to this class’ interface: the methods and properties declared by FolksPersonaStore, which form the normal libfolks persona store API; and the mock methods and properties (such as "add-persona-from-details-mock") which are intended to be used by test driver code to simulate the behaviour of a real backing store. Calls to these mock methods effect state changes in the store which are visible in the normal libfolks API. The update_, register_ and unregister_ prefixes and the mock suffix are commonly used for backing store methods.

The main action performed with a dummy persona store is to change its set of personas, adding and removing them dynamically to test client-side behaviour. The client-side APIs (folks_persona_store_add_persona_from_details() and folks_persona_store_remove_persona()) should not be used for this. Instead, the mock APIs should be used: folks_dummy_persona_store_freeze_personas_changed(), folks_dummy_persona_store_register_personas(), folks_dummy_persona_store_unregister_personas() and folks_dummy_persona_store_thaw_personas_changed(). These can be used to build up complex "personas-changed" signal emissions, which are only emitted after the final call to folks_dummy_persona_store_thaw_personas_changed().

The API in FolksDummy is unstable and may change wildly. It is designed mostly for use by libfolks unit tests.

Functions

FOLKS_DUMMY_TYPE_PERSONA_STORE

#define FOLKS_DUMMY_TYPE_PERSONA_STORE (folks_dummy_persona_store_get_type ())

The type for FolksDummyPersonaStore.


folks_dummy_persona_store_update_capabilities ()

void
folks_dummy_persona_store_update_capabilities
                               (FolksDummyPersonaStore *self,
                                FolksMaybeBool can_add_personas,
                                FolksMaybeBool can_alias_personas,
                                FolksMaybeBool can_remove_personas);

Set capabilities of the persona store.

This sets the capabilities of the store, as if they were changed on a backing store somewhere. This is intended to be used for testing code which depends on the values of "can-add-personas", "can-alias-personas" and "can-remove-personas".

Parameters

self

the FolksDummyPersonaStore instance

 

can_add_personas

 .

whether the store can handle adding personas

.

[in]

can_alias_personas

 .

whether the store can handle and update user-specified persona aliases

.

[in]

can_remove_personas

 .

whether the store can handle removing personas

.

[in]

Since: 0.9.7


folks_dummy_persona_store_freeze_personas_changed ()

void
folks_dummy_persona_store_freeze_personas_changed
                               (FolksDummyPersonaStore *self);

Freeze persona changes in the store.

This freezes externally-visible changes to the set of personas in the store until folks_dummy_persona_store_thaw_personas_changed() is called, at which point all pending changes are made visible in the "personas" property and by emitting "personas-changed".

Calls to folks_dummy_persona_store_freeze_personas_changed() and folks_dummy_persona_store_thaw_personas_changed() must be well-nested. Pending changes will only be committed after the final call to folks_dummy_persona_store_thaw_personas_changed().

See also: folks_dummy_persona_store_thaw_personas_changed()

Parameters

self

the FolksDummyPersonaStore instance

 

Since: 0.9.7


folks_dummy_persona_store_thaw_personas_changed ()

void
folks_dummy_persona_store_thaw_personas_changed
                               (FolksDummyPersonaStore *self);

Thaw persona changes in the store.

This thaws externally-visible changes to the set of personas in the store. If the number of calls to folks_dummy_persona_store_thaw_personas_changed() matches the number of calls to folks_dummy_persona_store_freeze_personas_changed(), all pending changes are committed and made externally-visible.

See also: folks_dummy_persona_store_freeze_personas_changed()

Parameters

self

the FolksDummyPersonaStore instance

 

Since: 0.9.7


folks_dummy_persona_store_register_personas ()

void
folks_dummy_persona_store_register_personas
                               (FolksDummyPersonaStore *self,
                                GeeSet *personas);

Register new personas with the persona store.

This registers a set of personas as if they had just appeared in the backing store. If the persona store is not frozen (see folks_dummy_persona_store_freeze_personas_changed()) the changes are made externally visible on the store immediately (e.g. in the "personas" property and through a "personas-changed" signal). If the store is frozen, the changes will be pending until the store is next unfrozen.

All elements in the personas set be of type "persona-type".

Parameters

self

the FolksDummyPersonaStore instance

 

personas

 .

set of personas to register

.

[in]

Since: 0.9.7


folks_dummy_persona_store_unregister_personas ()

void
folks_dummy_persona_store_unregister_personas
                               (FolksDummyPersonaStore *self,
                                GeeSet *personas);

Unregister existing personas with the persona store.

This unregisters a set of personas as if they had just disappeared from the backing store. If the persona store is not frozen (see folks_dummy_persona_store_freeze_personas_changed()) the changes are made externally visible on the store immediately (e.g. in the "personas" property and through a "personas-changed" signal). If the store is frozen, the changes will be pending until the store is next unfrozen.

Parameters

self

the FolksDummyPersonaStore instance

 

personas

 .

set of personas to unregister

.

[in]

Since: 0.9.7


folks_dummy_persona_store_reach_quiescence ()

void
folks_dummy_persona_store_reach_quiescence
                               (FolksDummyPersonaStore *self);

Reach quiescence on the store.

If the folks_persona_store_prepare() method has already been called on the store, this causes the store to signal that it has reached quiescence immediately. If the store has not yet been prepared, this will set a flag to ensure that quiescence is reached as soon as folks_persona_store_prepare() is called.

This must be called before the store will reach quiescence.

Parameters

self

the FolksDummyPersonaStore instance

 

Since: 0.9.7


folks_dummy_persona_store_update_is_user_set_default ()

void
folks_dummy_persona_store_update_is_user_set_default
                               (FolksDummyPersonaStore *self,
                                gboolean is_user_set_default);

Update the "is-user-set-default" property.

Backend method for use by test code to simulate a backing-store-driven change in the "is-user-set-default" property.

Parameters

self

the FolksDummyPersonaStore instance

 

is_user_set_default

 .

new value for the property

.

[in]

Since: 0.9.7


folks_dummy_persona_store_update_trust_level ()

void
folks_dummy_persona_store_update_trust_level
                               (FolksDummyPersonaStore *self,
                                FolksPersonaStoreTrust trust_level);

Update the "trust-level" property.

Backend method for use by test code to simulate a backing-store-driven change in the "trust-level" property.

Parameters

self

the FolksDummyPersonaStore instance

 

trust_level

 .

new value for the property

.

[in]

Since: 0.9.7


folks_dummy_persona_store_new ()

FolksDummyPersonaStore *
folks_dummy_persona_store_new (const gchar *id,
                               const gchar *display_name,
                               gchar **always_writeable_properties,
                               int always_writeable_properties_length1);

Create a new persona store.

This store will have no personas to begin with; use folks_dummy_persona_store_register_personas() to add some, then call folks_dummy_persona_store_reach_quiescence() to signal the store reaching quiescence.

Parameters

id

 .

The new store's ID.

.

[in]

display_name

 .

The new store's display name.

.

[in]

always_writeable_properties

 .

The set of always writeable properties.

.

[in][array length=always_writeable_properties_length1]

always_writeable_properties_length1

length of the always_writeable_properties array

 

Since: 0.9.7


folks_dummy_persona_store_get_add_persona_from_details_mock ()

FolksDummyPersonaStoreAddPersonaFromDetailsMock
folks_dummy_persona_store_get_add_persona_from_details_mock
                               (FolksDummyPersonaStore *self,
                                gpointer *result_target);

Get and return the current value of the "add-persona-from-details-mock" property.

Mock function for folks_persona_store_add_persona_from_details().

This function is called whenever this store's folks_persona_store_add_persona_from_details() method is called. It allows the caller to determine whether adding the given persona should fail, by throwing an error from this mock function. If no error is thrown from this function, adding the given persona will succeed. This is useful for testing error handling of calls to folks_persona_store_add_persona_from_details().

The value returned by this function gives a delay which is imposed for completion of the folks_persona_store_add_persona_from_details() call. Negative or zero delays result in completion in an idle callback, and positive delays result in completion after that many milliseconds.

If this is null, all calls to folks_persona_store_add_persona_from_details() will succeed.

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_add_persona_from_details().

Parameters

self

the FolksDummyPersonaStore instance to query

 

Returns

the value of the "add-persona-from-details-mock" property

Since: 0.9.7


folks_dummy_persona_store_set_add_persona_from_details_mock ()

void
folks_dummy_persona_store_set_add_persona_from_details_mock
                               (FolksDummyPersonaStore *self,
                                FolksDummyPersonaStoreAddPersonaFromDetailsMock value,
                                gpointer value_target);

Set the value of the "add-persona-from-details-mock" property to value .

Mock function for folks_persona_store_add_persona_from_details().

This function is called whenever this store's folks_persona_store_add_persona_from_details() method is called. It allows the caller to determine whether adding the given persona should fail, by throwing an error from this mock function. If no error is thrown from this function, adding the given persona will succeed. This is useful for testing error handling of calls to folks_persona_store_add_persona_from_details().

The value returned by this function gives a delay which is imposed for completion of the folks_persona_store_add_persona_from_details() call. Negative or zero delays result in completion in an idle callback, and positive delays result in completion after that many milliseconds.

If this is null, all calls to folks_persona_store_add_persona_from_details() will succeed.

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_add_persona_from_details().

Parameters

self

the FolksDummyPersonaStore instance to modify

 

value

the new value of the "add-persona-from-details-mock" property

 

Since: 0.9.7


folks_dummy_persona_store_get_remove_persona_mock ()

FolksDummyPersonaStoreRemovePersonaMock
folks_dummy_persona_store_get_remove_persona_mock
                               (FolksDummyPersonaStore *self,
                                gpointer *result_target);

Get and return the current value of the "remove-persona-mock" property.

Mock function for folks_persona_store_remove_persona().

This function is called whenever this store's folks_persona_store_remove_persona() method is called. It allows the caller to determine whether removing the given persona should fail, by throwing an error from this mock function. If no error is thrown from this function, removing the given persona will succeed. This is useful for testing error handling of calls to folks_persona_store_remove_persona().

See "add-persona-from-details-mock".

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_remove_persona().

Parameters

self

the FolksDummyPersonaStore instance to query

 

Returns

the value of the "remove-persona-mock" property

Since: 0.9.7


folks_dummy_persona_store_set_remove_persona_mock ()

void
folks_dummy_persona_store_set_remove_persona_mock
                               (FolksDummyPersonaStore *self,
                                FolksDummyPersonaStoreRemovePersonaMock value,
                                gpointer value_target);

Set the value of the "remove-persona-mock" property to value .

Mock function for folks_persona_store_remove_persona().

This function is called whenever this store's folks_persona_store_remove_persona() method is called. It allows the caller to determine whether removing the given persona should fail, by throwing an error from this mock function. If no error is thrown from this function, removing the given persona will succeed. This is useful for testing error handling of calls to folks_persona_store_remove_persona().

See "add-persona-from-details-mock".

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_remove_persona().

Parameters

self

the FolksDummyPersonaStore instance to modify

 

value

the new value of the "remove-persona-mock" property

 

Since: 0.9.7


folks_dummy_persona_store_get_prepare_mock ()

FolksDummyPersonaStorePrepareMock
folks_dummy_persona_store_get_prepare_mock
                               (FolksDummyPersonaStore *self,
                                gpointer *result_target);

Get and return the current value of the "prepare-mock" property.

Mock function for folks_persona_store_prepare().

This function is called whenever this store's folks_persona_store_prepare() method is called on an unprepared store. It allows the caller to determine whether preparing the store should fail, by throwing an error from this mock function. If no error is thrown from this function, preparing the store will succeed (and all future calls to folks_persona_store_prepare() will return immediately without calling this mock function). This is useful for testing error handling of calls to folks_persona_store_prepare().

See "add-persona-from-details-mock".

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_prepare().

Parameters

self

the FolksDummyPersonaStore instance to query

 

Returns

the value of the "prepare-mock" property

Since: 0.9.7


folks_dummy_persona_store_set_prepare_mock ()

void
folks_dummy_persona_store_set_prepare_mock
                               (FolksDummyPersonaStore *self,
                                FolksDummyPersonaStorePrepareMock value,
                                gpointer value_target);

Set the value of the "prepare-mock" property to value .

Mock function for folks_persona_store_prepare().

This function is called whenever this store's folks_persona_store_prepare() method is called on an unprepared store. It allows the caller to determine whether preparing the store should fail, by throwing an error from this mock function. If no error is thrown from this function, preparing the store will succeed (and all future calls to folks_persona_store_prepare() will return immediately without calling this mock function). This is useful for testing error handling of calls to folks_persona_store_prepare().

See "add-persona-from-details-mock".

This mock function may be changed at any time; changes will take effect for the next call to folks_persona_store_prepare().

Parameters

self

the FolksDummyPersonaStore instance to modify

 

value

the new value of the "prepare-mock" property

 

Since: 0.9.7


folks_dummy_persona_store_get_persona_type ()

GType
folks_dummy_persona_store_get_persona_type
                               (FolksDummyPersonaStore *self);

Get and return the current value of the "persona-type" property.

Type of programmatically created personas.

This is the type used to create new personas when folks_persona_store_add_persona_from_details() is called. It must be a subtype of FolksDummyPersona.

This may be modified at any time, with modifications taking effect for the next call to folks_persona_store_add_persona_from_details() or folks_dummy_persona_store_register_personas().

Parameters

self

the FolksDummyPersonaStore instance to query

 

Returns

the value of the "persona-type" property

Since: 0.9.7


folks_dummy_persona_store_set_persona_type ()

void
folks_dummy_persona_store_set_persona_type
                               (FolksDummyPersonaStore *self,
                                GType value);

Set the value of the "persona-type" property to value .

Type of programmatically created personas.

This is the type used to create new personas when folks_persona_store_add_persona_from_details() is called. It must be a subtype of FolksDummyPersona.

This may be modified at any time, with modifications taking effect for the next call to folks_persona_store_add_persona_from_details() or folks_dummy_persona_store_register_personas().

Parameters

self

the FolksDummyPersonaStore instance to modify

 

value

the new value of the "persona-type" property

 

Since: 0.9.7


FolksDummyPersonaStoreAddPersonaFromDetailsMock ()

gint
(*FolksDummyPersonaStoreAddPersonaFromDetailsMock)
                               (FolksDummyPersona *persona,
                                void *user_data,
                                GError **error);

Type of a mock function for folks_persona_store_add_persona_from_details().

See "add-persona-from-details-mock".

FolksPersonaStoreError will be returned in error

to be thrown from folks_persona_store_add_persona_from_details()

Parameters

persona

 .

the persona being added to the store, as constructed from the details passed to folks_persona_store_add_persona_from_details().

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains FolksPersonaStoreError]

user_data

data to pass to the delegate function.

[closure]

Returns

delay to apply to the add persona operation (negative delays complete synchronously; zero delays complete in an idle callback; positive delays complete after that many milliseconds)

Since: 0.9.7


FolksDummyPersonaStoreRemovePersonaMock ()

gint
(*FolksDummyPersonaStoreRemovePersonaMock)
                               (FolksDummyPersona *persona,
                                void *user_data,
                                GError **error);

Type of a mock function for folks_persona_store_remove_persona().

See "remove-persona-mock".

FolksPersonaStoreError will be returned in error

to be thrown from folks_persona_store_remove_persona()

Parameters

persona

 .

the persona being removed from the store

.

[in]

error

location to store the error occuring, or NULL to ignore.

[error-domains FolksPersonaStoreError]

user_data

data to pass to the delegate function.

[closure]

Returns

delay to apply to the remove persona operation (negative and zero delays complete in an idle callback; positive delays complete after that many milliseconds)

Since: 0.9.7


FolksDummyPersonaStorePrepareMock ()

gint
(*FolksDummyPersonaStorePrepareMock) (void *user_data,
                                      GError **error);

Type of a mock function for folks_persona_store_prepare().

See "prepare-mock".

FolksPersonaStoreError will be returned in error

to be thrown from folks_persona_store_prepare()

Parameters

error

location to store the error occuring, or NULL to ignore.

[error-domains FolksPersonaStoreError]

user_data

data to pass to the delegate function.

[closure]

Returns

delay to apply to the prepare operation (negative and zero delays complete in an idle callback; positive delays complete after that many milliseconds)

Since: 0.9.7

Types and Values

struct FolksDummyPersonaStore

struct FolksDummyPersonaStore;

A persona store which allows FolksDummyPersonas to be programmatically created and manipulated, for the purposes of testing the core of libfolks itself. This should not be used in user-visible applications.

There are two sides to this class’ interface: the methods and properties declared by FolksPersonaStore, which form the normal libfolks persona store API; and the mock methods and properties (such as "add-persona-from-details-mock") which are intended to be used by test driver code to simulate the behaviour of a real backing store. Calls to these mock methods effect state changes in the store which are visible in the normal libfolks API. The update_, register_ and unregister_ prefixes and the mock suffix are commonly used for backing store methods.

The main action performed with a dummy persona store is to change its set of personas, adding and removing them dynamically to test client-side behaviour. The client-side APIs (folks_persona_store_add_persona_from_details() and folks_persona_store_remove_persona()) should not be used for this. Instead, the mock APIs should be used: folks_dummy_persona_store_freeze_personas_changed(), folks_dummy_persona_store_register_personas(), folks_dummy_persona_store_unregister_personas() and folks_dummy_persona_store_thaw_personas_changed(). These can be used to build up complex "personas-changed" signal emissions, which are only emitted after the final call to folks_dummy_persona_store_thaw_personas_changed().

The API in FolksDummy is unstable and may change wildly. It is designed mostly for use by libfolks unit tests.

Since: 0.9.7


struct FolksDummyPersonaStoreClass

struct FolksDummyPersonaStoreClass {
	FolksPersonaStoreClass parent_class;
};

The class structure for FOLKS_DUMMY_TYPE_PERSONA_STORE. All the fields in this structure are private and should never be accessed directly.

Members

FolksPersonaStoreClass parent_class;

the parent class structure

 

Property Details

The “always-writeable-properties” property

  “always-writeable-properties” GStrv

always-writeable-properties.

Flags: Read


The “can-add-personas” property

  “can-add-personas”         FolksMaybeBool

can-add-personas.

Flags: Read

Default value: FOLKS_MAYBE_BOOL_UNSET


The “can-alias-personas” property

  “can-alias-personas”       FolksMaybeBool

can-alias-personas.

Flags: Read

Default value: FOLKS_MAYBE_BOOL_UNSET


The “can-group-personas” property

  “can-group-personas”       FolksMaybeBool

can-group-personas.

Flags: Read

Default value: FOLKS_MAYBE_BOOL_UNSET


The “can-remove-personas” property

  “can-remove-personas”      FolksMaybeBool

can-remove-personas.

Flags: Read

Default value: FOLKS_MAYBE_BOOL_UNSET


The “is-prepared” property

  “is-prepared”              gboolean

is-prepared.

Flags: Read

Default value: FALSE


The “is-quiescent” property

  “is-quiescent”             gboolean

is-quiescent.

Flags: Read

Default value: FALSE


The “persona-type” property

  “persona-type”             GType *

Type of programmatically created personas.

This is the type used to create new personas when folks_persona_store_add_persona_from_details() is called. It must be a subtype of FolksDummyPersona.

This may be modified at any time, with modifications taking effect for the next call to folks_persona_store_add_persona_from_details() or folks_dummy_persona_store_register_personas().

Flags: Read / Write

Allowed values: void

Since: 0.9.7


The “personas” property

  “personas”                 GeeMap *

personas.

Flags: Read


The “type-id” property

  “type-id”                  gchar *

type-id.

Flags: Read

Default value: NULL