Top |
Avatars may be added to the cache, and referred to by a persistent URI from that point onwards. The avatars will be stored on disk in the user's XDG cache directory.
The avatar cache is typically used by backends where retrieving avatars is an expensive operation (for example, they have to be downloaded from the network every time they're used).
All avatars from all users of the FolksAvatarCache are stored in the same namespace, so callers must ensure that the IDs they use for avatars are globally unique (e.g. by using the corresponding "uid").
Ongoing store operations (folks_avatar_cache_store_avatar()
) are rate limited to try and prevent file descriptor exhaustion. Load operations (folks_avatar_cache_load_avatar()
) must be rate limited by the client, as the file I/O occurs when calling LoadableIcon.load rather than when retrieving the LoadableIcon from the cache.
#define FOLKS_TYPE_AVATAR_CACHE (folks_avatar_cache_get_type ())
The type for FolksAvatarCache.
void folks_avatar_cache_load_avatar (FolksAvatarCache *self
,const gchar *id
,GAsyncReadyCallback _callback_
,gpointer _user_data_
);
Fetch an avatar from the cache by its globally unique ID.
It is up to the caller to ensure that file I/O is rate-limited when loading many avatars in parallel, by limiting calls to LoadableIcon.load.
GError will be returned in error
if checking for existence of the cache file failed
See also: folks_avatar_cache_load_avatar_finish()
self |
the FolksAvatarCache instance |
|
id |
. the globally unique ID for the avatar . |
[in] |
_callback_ |
callback to call when the request is satisfied. |
[scope async] |
_user_data_ |
the data to pass to |
[closure] |
Since 0.6.0
GLoadableIcon * folks_avatar_cache_load_avatar_finish (FolksAvatarCache *self
,GAsyncResult *_res_
,GError **error
);
Fetch an avatar from the cache by its globally unique ID.
It is up to the caller to ensure that file I/O is rate-limited when loading many avatars in parallel, by limiting calls to LoadableIcon.load.
GError will be returned in error
if checking for existence of the cache file failed
See also: folks_avatar_cache_load_avatar()
self |
the FolksAvatarCache instance |
|
_res_ |
||
error |
location to store the error occuring, or |
Since 0.6.0
void folks_avatar_cache_store_avatar (FolksAvatarCache *self
,const gchar *id
,GLoadableIcon *avatar
,GAsyncReadyCallback _callback_
,gpointer _user_data_
);
Store an avatar in the cache, assigning the given globally unique ID to it, which can later be used to load and remove the avatar from the cache. For example, this ID could be the UID of a persona. The URI of the cached avatar file will be returned.
This method may be called multiple times concurrently for the same avatar ID (e.g. an asynchronous call may be made, and a subsequent asynchronous call may begin before the first has finished).
Concurrent file I/O may be rate limited within each
instance to avoid file descriptor exhaustion.folks_avatar_cache_new()
GError will be returned in error
if the avatar data couldn't be loaded, or if creating the avatar directory or cache file failed
See also: folks_avatar_cache_store_avatar_finish()
self |
the FolksAvatarCache instance |
|
id |
. the globally unique ID for the avatar . |
[in] |
avatar |
. the avatar data to cache . |
[in] |
_callback_ |
callback to call when the request is satisfied. |
[scope async] |
_user_data_ |
the data to pass to |
[closure] |
Since 0.6.0
gchar * folks_avatar_cache_store_avatar_finish (FolksAvatarCache *self
,GAsyncResult *_res_
,GError **error
);
Store an avatar in the cache, assigning the given globally unique ID to it, which can later be used to load and remove the avatar from the cache. For example, this ID could be the UID of a persona. The URI of the cached avatar file will be returned.
This method may be called multiple times concurrently for the same avatar ID (e.g. an asynchronous call may be made, and a subsequent asynchronous call may begin before the first has finished).
Concurrent file I/O may be rate limited within each
instance to avoid file descriptor exhaustion.folks_avatar_cache_new()
GError will be returned in error
if the avatar data couldn't be loaded, or if creating the avatar directory or cache file failed
See also: folks_avatar_cache_store_avatar()
self |
the FolksAvatarCache instance |
|
_res_ |
||
error |
location to store the error occuring, or |
Since 0.6.0
void folks_avatar_cache_remove_avatar (FolksAvatarCache *self
,const gchar *id
,GAsyncReadyCallback _callback_
,gpointer _user_data_
);
Remove an avatar from the cache, if it exists in the cache. If the avatar exists in the cache but there is a problem in removing it, a GError will be thrown.
GError will be returned in error
if deleting the cache file failed
See also: folks_avatar_cache_remove_avatar_finish()
self |
the FolksAvatarCache instance |
|
id |
. the globally unique ID for the avatar . |
[in] |
_callback_ |
callback to call when the request is satisfied. |
[scope async] |
_user_data_ |
the data to pass to |
[closure] |
Since 0.6.0
void folks_avatar_cache_remove_avatar_finish (FolksAvatarCache *self
,GAsyncResult *_res_
,GError **error
);
Remove an avatar from the cache, if it exists in the cache. If the avatar exists in the cache but there is a problem in removing it, a GError will be thrown.
GError will be returned in error
if deleting the cache file failed
See also: folks_avatar_cache_remove_avatar()
self |
the FolksAvatarCache instance |
|
_res_ |
||
error |
location to store the error occuring, or |
Since 0.6.0
gchar * folks_avatar_cache_build_uri_for_avatar (FolksAvatarCache *self
,const gchar *id
);
Build the URI of an avatar file in the cache from a globally unique ID. This will always succeed, even if the avatar doesn't exist in the cache.
Since 0.6.0
FolksAvatarCache *
folks_avatar_cache_dup (void
);
Create or return the singleton FolksAvatarCache class instance. If the instance doesn't exist already, it will be created.
This function is thread-safe.
Since 0.6.0
struct FolksAvatarCache;
A singleton persistent cache for avatars in folks.
Avatars may be added to the cache, and referred to by a persistent URI from that point onwards. The avatars will be stored on disk in the user's XDG cache directory.
The avatar cache is typically used by backends where retrieving avatars is an expensive operation (for example, they have to be downloaded from the network every time they're used).
All avatars from all users of the FolksAvatarCache are stored in the same namespace, so callers must ensure that the IDs they use for avatars are globally unique (e.g. by using the corresponding "uid").
Ongoing store operations (folks_avatar_cache_store_avatar()
) are rate limited to try and prevent file descriptor exhaustion. Load operations (folks_avatar_cache_load_avatar()
) must be rate limited by the client, as the file I/O occurs when calling LoadableIcon.load rather than when retrieving the LoadableIcon from the cache.
Since 0.6.0
struct FolksAvatarCacheClass { GObjectClass parent_class; };
The class structure for FOLKS_TYPE_AVATAR_CACHE
. All the fields in this structure are private and should never be accessed directly.