EPhotoCache

EPhotoCache — Search for photos by email address

Synopsis

#include <e-util/e-util.h>

struct              EPhotoCache;
EPhotoCache *       e_photo_cache_new                   (EClientCache *client_cache);
EClientCache *      e_photo_cache_ref_client_cache      (EPhotoCache *photo_cache);
gboolean            e_photo_cache_get_local_only        (EPhotoCache *photo_cache);
void                e_photo_cache_set_local_only        (EPhotoCache *photo_cache,
                                                         gboolean local_only);
gboolean            e_photo_cache_get_photo_sync        (EPhotoCache *photo_cache,
                                                         const gchar *email_address,
                                                         GCancellable *cancellable,
                                                         GInputStream **out_stream,
                                                         GError **error);
void                e_photo_cache_get_photo             (EPhotoCache *photo_cache,
                                                         const gchar *email_address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            e_photo_cache_get_photo_finish      (EPhotoCache *photo_cache,
                                                         GAsyncResult *result,
                                                         GInputStream **out_stream,
                                                         GError **error);
gboolean            e_photo_cache_remove                (EPhotoCache *photo_cache,
                                                         const gchar *email_address);

Object Hierarchy

  GObject
   +----EPhotoCache

Implemented Interfaces

EPhotoCache implements EExtensible.

Properties

  "client-cache"             EClientCache*         : Read / Write / Construct Only
  "local-only"               gboolean              : Read / Write

Description

EPhotoCache helps search for contact photo or logo images associated with an email address.

A limited internal cache is employed to speed up searches for recently searched email addresses. The exact caching semantics are private and subject to change.

Details

struct EPhotoCache

struct EPhotoCache;

Contains only private data that should be read and manipulated using the functions below.


e_photo_cache_new ()

EPhotoCache *       e_photo_cache_new                   (EClientCache *client_cache);

Creates a new EPhotoCache instance.

client_cache :

an EClientCache

Returns :

an EPhotoCache

e_photo_cache_ref_client_cache ()

EClientCache *      e_photo_cache_ref_client_cache      (EPhotoCache *photo_cache);

Returns the EClientCache passed to e_photo_cache_new().

The returned EClientCache is referenced for thread-safety and must be unreferenced with g_object_unref() when finished with it.

photo_cache :

an EPhotoCache

Returns :

an EClientCache

e_photo_cache_get_local_only ()

gboolean            e_photo_cache_get_local_only        (EPhotoCache *photo_cache);

Returns whether to limit photo searches to the built-in ("local") address book returned by e_source_registry_ref_builtin_address_book().

If this property is FALSE then all enabled address books are searched.

photo_cache :

an EPhotoCache

Returns :

whether to search only the built-in address book

e_photo_cache_set_local_only ()

void                e_photo_cache_set_local_only        (EPhotoCache *photo_cache,
                                                         gboolean local_only);

Sets whether to limit photo searches to the built-in ("local") address book returned by e_source_registry_ref_builtin_address_book().

If this property is FALSE then all enabled address books are searched.

photo_cache :

an EPhotoCache

local_only :

whether to search only the built-in address book

e_photo_cache_get_photo_sync ()

gboolean            e_photo_cache_get_photo_sync        (EPhotoCache *photo_cache,
                                                         const gchar *email_address,
                                                         GCancellable *cancellable,
                                                         GInputStream **out_stream,
                                                         GError **error);

Searches enabled address books (subject to the "local-only" preference) for a contact photo or logo associated with email_address.

If a match is found, a GInputStream from which to read image data is returned through the out_stream return location. If no match is found, the out_stream return location is set to NULL.

The return value indicates whether the search completed successfully, not whether a match was found. If an error occurs, the function will set error and return FALSE.

photo_cache :

an EPhotoCache

email_address :

an email address

cancellable :

optional GCancellable object, or NULL

out_stream :

return location for a GInputStream, or NULL

error :

return location for a GError, or NULL

Returns :

whether the search completed successfully

e_photo_cache_get_photo ()

void                e_photo_cache_get_photo             (EPhotoCache *photo_cache,
                                                         const gchar *email_address,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously searches enabled address books (subject to the "local-only" preference) for a contact photo or logo associated with email_address.

When the operation is finished, callback will be called. You can then call e_photo_cache_get_photo_finish() to get the result of the operation.

photo_cache :

an EPhotoCache

email_address :

an email address

cancellable :

optional GCancellable object, or NULL

callback :

a GAsyncReadyCallback to call when the request is satisfied

user_data :

data to pass to the callback function

e_photo_cache_get_photo_finish ()

gboolean            e_photo_cache_get_photo_finish      (EPhotoCache *photo_cache,
                                                         GAsyncResult *result,
                                                         GInputStream **out_stream,
                                                         GError **error);

Finishes the operation started with e_photo_cache_get_photo().

If a match was found, a GInputStream from which to read image data is returned through the out_stream return location. If no match was found, the out_stream return location is set to NULL.

The return value indicates whether the search completed successfully, not whether a match was found. If an error occurred, the function will set error and return FALSE.

photo_cache :

an EPhotoCache

result :

a GAsyncResult

out_stream :

return location for a GInputStream, or NULL

error :

return location for a GError, or NULL

Returns :

whether the search completed successfully

e_photo_cache_remove ()

gboolean            e_photo_cache_remove                (EPhotoCache *photo_cache,
                                                         const gchar *email_address);

Removes the cache entry for email_address, if such an entry exists.

photo_cache :

an EPhotoCache

email_address :

an email address

Property Details

The "client-cache" property

  "client-cache"             EClientCache*         : Read / Write / Construct Only

Cache of shared EClient instances.


The "local-only" property

  "local-only"               gboolean              : Read / Write

Whether to restrict searches to the built-in address book.

Default value: FALSE