TplLogManager

## TplLogManager TplLogManager — Fetch and search through logs |

## Synopsis

    #define             TPL_LOG_MANAGER_ERROR
    GQuark              tpl_log_manager_errors_quark        (void);
    enum                TplLogManagerError;
    gboolean            (*TplLogMessageFilter)              (TplEntry *message,
                                                             gpointer user_data);
    TplLogManager *     tpl_log_manager_dup_singleton       (void);
    gboolean            tpl_log_manager_exists              (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    gboolean            tpl_log_manager_get_dates_finish    (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **dates,
                                                             GError **error);
    void                tpl_log_manager_get_dates_async     (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            tpl_log_manager_get_messages_for_date_finish
                                                            (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **messages,
                                                             GError **error);
    void                tpl_log_manager_get_messages_for_date_async
                                                            (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             const GDate *date,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            tpl_log_manager_get_filtered_messages_finish
                                                            (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **messages,
                                                             GError **error);
    void                tpl_log_manager_get_filtered_messages_async
                                                            (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer filter_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            tpl_log_manager_get_chats_finish    (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **chats,
                                                             GError **error);
    void                tpl_log_manager_get_chats_async     (TplLogManager *self,
                                                             TpAccount *account,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            tpl_log_manager_search_finish       (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **chats,
                                                             GError **error);
    void                tpl_log_manager_search_async        (TplLogManager *manager,
                                                             const gchar *text,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    void                tpl_log_manager_search_free         (GList *hits);

## Description

The TplLogManager object allows user to fetch logs and make searches.

## Details

### TPL_LOG_MANAGER_ERROR

    #define TPL_LOG_MANAGER_ERROR tpl_log_manager_errors_quark()

The error domain for the TplLogManager.

### tpl_log_manager_errors_quark ()

    GQuark              tpl_log_manager_errors_quark        (void);

Returns : | the GQuark associated with the error domain of TplLogManager

### enum TplLogManagerError

    typedef enum
    {
      TPL_LOG_MANAGER_ERROR_ADD_MESSAGE
    } TplLogManagerError;

### TplLogMessageFilter ()

    gboolean            (*TplLogMessageFilter)              (TplEntry *message,
                                                             gpointer user_data);

`message` : | the TplEntry to filter
`user_data` : | user-supplied data
Returns : | `TRUE` if `message` should appear in the result

### tpl_log_manager_dup_singleton ()

    TplLogManager *     tpl_log_manager_dup_singleton       (void);

Returns : | a new reference on the log manager

### tpl_log_manager_exists ()

    gboolean            tpl_log_manager_exists              (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

Checks if `chat_id` does exist for `account` and - is a chatroom, if `chatroom` is `TRUE` - is not a chatroom, if `chatroom` is `FALSE`

It applies for any registered TplLogStore with the "readable" property `TRUE`.

`manager` : | TplLogManager
`account` : | TpAccount
`chat_id` : | a non-NULL chat id
`chatroom` : | whether `chat_id` is a chatroom or not
Returns : | `TRUE` if `chat_id` exists, `FALSE` otherwise

### tpl_log_manager_get_dates_finish ()

    gboolean            tpl_log_manager_get_dates_finish    (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **dates,
                                                             GError **error);

`self` : | a TplLogManager
`result` : | a GAsyncResult
`dates` : | a pointer to a GList used to return the list of GDate
`error` : | a GError to fill
Returns : | TRUE if the operation was successful, otherwise FALSE

### tpl_log_manager_get_dates_async ()

    void                tpl_log_manager_get_dates_async     (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Retrieves a list of GDate corresponding to each day at least a message was sent to or received from `chat_id`. `chat_id` may be the id of a buddy or a chatroom, depending on the value of `is_chatroom`.

It applies for any registered TplLogStore with the "readable" property `TRUE`.

`manager` : | a TplLogManager
`account` : | a TpAccount
`chat_id` : | the chat identifier (can't be `NULL`)
`is_chatroom` : | whather if the request is related to a chatroom or not.
`callback` : | a callback to call when the request is satisfied
`user_data` : | data to pass to `callback`

### tpl_log_manager_get_messages_for_date_finish ()

    gboolean            tpl_log_manager_get_messages_for_date_finish
                                                            (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **messages,
                                                             GError **error);

`self` : | a TplLogManager
`result` : | a GAsyncResult
`messages` : | a pointer to a GList used to return the list of GDate
`error` : | a GError to fill
Returns : | TRUE if the operation was successful, otherwise FALSE

### tpl_log_manager_get_messages_for_date_async ()

    void                tpl_log_manager_get_messages_for_date_async
                                                            (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             const GDate *date,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Retrieve a list of TplEntry exchanged at `date` with `chat_id`.

`manager` : | a TplLogManager
`account` : | a TpAccount
`chat_id` : | the chat identifier (can't be `NULL`)
`is_chatroom` : | `TRUE` if the request is related to a chatroom
`date` : | a GDate
`callback` : | a callback to call when the request is satisfied
`user_data` : | data to pass to `callback`

### tpl_log_manager_get_filtered_messages_finish ()

    gboolean            tpl_log_manager_get_filtered_messages_finish
                                                            (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **messages,
                                                             GError **error);

`self` : | a TplLogManager
`result` : | a GAsyncResult
`messages` : | a pointer to a GList used to return the list TplEntry
`error` : | a GError to fill
Returns : | TRUE if the operation was successful, otherwise FALSE

### tpl_log_manager_get_filtered_messages_async ()

    void                tpl_log_manager_get_filtered_messages_async
                                                            (TplLogManager *manager,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean is_chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer filter_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Retrieve the `num_messages` most recent messages exchanged with `chat_id`.

`manager` : | a TplLogManager
`account` : | a TpAccount
`chat_id` : | the chat identifier (can't be `NULL`)
`is_chatroom` : | `TRUE` if the request is related to a chatroom
`num_messages` : | number of maximum messages to fetch
`filter` : | an optionnal filter function
`filter_user_data` : | user data to pass to `filter`
`callback` : | a callback to call when the request is satisfied
`user_data` : | data to pass to `callback`

### tpl_log_manager_get_chats_finish ()

    gboolean            tpl_log_manager_get_chats_finish    (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **chats,
                                                             GError **error);

`self` : | a TplLogManager
`result` : | a GAsyncResult
`chats` : | a pointer to a GList used to return the list of chats
`error` : | a GError to fill
Returns : | TRUE if the operation was successful, otherwise FALSE

### tpl_log_manager_get_chats_async ()

    void                tpl_log_manager_get_chats_async     (TplLogManager *self,
                                                             TpAccount *account,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Start a query looking for all the conversations on `account`.

`self` : | a TplLogManager
`account` : | a TpAccount
`callback` : | a callback to call when the request is satisfied
`user_data` : | data to pass to `callback`

### tpl_log_manager_search_finish ()

    gboolean            tpl_log_manager_search_finish       (TplLogManager *self,
                                                             GAsyncResult *result,
                                                             GList **chats,
                                                             GError **error);

`self` : | a TplLogManager
`result` : | a GAsyncResult
`chats` : | a pointer to a GList used to return the list of TplLogSearchHit
`error` : | a GError to fill
Returns : | TRUE if the operation was successful, otherwise FALSE

### tpl_log_manager_search_async ()

    void                tpl_log_manager_search_async        (TplLogManager *manager,
                                                             const gchar *text,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Search for all the conversations containing `text`.

`manager` : | a TplLogManager
`text` : | the pattern to search
`callback` : | a callback to call when the request is satisfied
`user_data` : | data to pass to `callback`

### tpl_log_manager_search_free ()

    void                tpl_log_manager_search_free         (GList *hits);

Free `hits` and its content.

`hits` : | a GList of TplLogSearchHit