TplLogStore

## TplLogStore TplLogStore — LogStore interface can register into TplLogManager as "writable" or "readable" log stores. |

## Synopsis

    #define             TPL_LOG_STORE_GET_INTERFACE         (inst)
    #define             TPL_LOG_STORE_ERROR
    enum                TplLogStoreError;
                        TplLogStore;
    gboolean            (*TplLogMessageFilter)              (TplLogEntry *message,
                                                             gpointer user_data);
    gboolean            is_writable                         (TplLogStore *self);
    gboolean            is_readable                         (TplLogStore *self);
    const gchar *       get_name                            (TplLogStore *self);
    gboolean            exists                              (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    gboolean            add_message                         (TplLogStore *self,
                                                             TplLogEntry *message,
                                                             GError **error);
    GList *             get_dates                           (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    GList *             get_messages_for_date               (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             const gchar *date);
    GList *             get_recent_messages                 (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    GList *             get_chats                           (TplLogStore *self,
                                                             TpAccount *account);
    GList *             search_new                          (TplLogStore *self,
                                                             const gchar *text);
    GList *             search_in_identifier_chats_new      (TplLogStore *self,
                                                             TpAccount *account,
                                                             gchar const *identifier,
                                                             const gchar *text);
    GList *             get_filtered_messages               (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer user_data);
    const gchar *       tpl_log_store_get_name              (TplLogStore *self);
    gboolean            tpl_log_store_exists                (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    gboolean            tpl_log_store_add_message           (TplLogStore *self,
                                                             TplLogEntry *message,
                                                             GError **error);
    GList *             tpl_log_store_get_dates             (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    GList *             tpl_log_store_get_messages_for_date (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             const gchar *date);
    GList *             tpl_log_store_get_recent_messages   (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);
    GList *             tpl_log_store_get_chats             (TplLogStore *self,
                                                             TpAccount *account);
    GList *             tpl_log_store_search_in_identifier_chats_new
                                                            (TplLogStore *self,
                                                             TpAccount *account,
                                                             gchar const *identifier,
                                                             const gchar *text);
    GList *             tpl_log_store_search_new            (TplLogStore *self,
                                                             const gchar *text);
    GList *             tpl_log_store_get_filtered_messages (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer user_data);
    gboolean            tpl_log_store_is_writable           (TplLogStore *self);
    gboolean            tpl_log_store_is_readable           (TplLogStore *self);

## Object Hierarchy

      GInterface
       +----TplLogStore

## Description

The TplLogStore defines all the public methods that a TPL Log Store has to implement in order to be used into a TplLogManager.

## Details

### TPL_LOG_STORE_GET_INTERFACE()

    #define             TPL_LOG_STORE_GET_INTERFACE(inst)

`inst` : |

### TPL_LOG_STORE_ERROR

    #define TPL_LOG_STORE_ERROR g_quark_from_static_string ("tpl-log-store-error-quark")

### enum TplLogStoreError

    typedef enum
    {
      /* generic error */
      TPL_LOG_STORE_ERROR_FAILED,
      TPL_LOG_STORE_ERROR_ADD_MESSAGE,
    } TplLogStoreError;

### TplLogStore

    typedef struct _TplLogStore TplLogStore;

### TplLogMessageFilter ()

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

`message` : |
`user_data` : |
Returns : |

### is_writable ()

    gboolean            is_writable                         (TplLogStore *self);

`self` : |
Returns : |

### is_readable ()

    gboolean            is_readable                         (TplLogStore *self);

`self` : |
Returns : |

### get_name ()

    const gchar *       get_name                            (TplLogStore *self);

`self` : |
Returns : |

### exists ()

    gboolean            exists                              (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
Returns : |

### add_message ()

    gboolean            add_message                         (TplLogStore *self,
                                                             TplLogEntry *message,
                                                             GError **error);

`self` : |
`message` : |
`error` : |
Returns : |

### get_dates ()

    GList *             get_dates                           (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
Returns : |

### get_messages_for_date ()

    GList *             get_messages_for_date               (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             const gchar *date);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
`date` : |
Returns : |

### get_recent_messages ()

    GList *             get_recent_messages                 (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
Returns : |

### get_chats ()

    GList *             get_chats                           (TplLogStore *self,
                                                             TpAccount *account);

`self` : |
`account` : |
Returns : |

### search_new ()

    GList *             search_new                          (TplLogStore *self,
                                                             const gchar *text);

`self` : |
`text` : |
Returns : |

### search_in_identifier_chats_new ()

    GList *             search_in_identifier_chats_new      (TplLogStore *self,
                                                             TpAccount *account,
                                                             gchar const *identifier,
                                                             const gchar *text);

`self` : |
`account` : |
`identifier` : |
`text` : |
Returns : |

### get_filtered_messages ()

    GList *             get_filtered_messages               (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer user_data);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
`num_messages` : |
`filter` : |
`user_data` : |
Returns : |

### tpl_log_store_get_name ()

    const gchar *       tpl_log_store_get_name              (TplLogStore *self);

`self` : |
Returns : |

### tpl_log_store_exists ()

    gboolean            tpl_log_store_exists                (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
Returns : |

### tpl_log_store_add_message ()

    gboolean            tpl_log_store_add_message           (TplLogStore *self,
                                                             TplLogEntry *message,
                                                             GError **error);

Sends `message` to the LogStore `self`, in order to be stored.

`self` : | a TplLogStore
`message` : | an instance of a subclass of TplLogEntry (ie TplLogEntryText)
`error` : | memory location used if an error occurs
Returns : | `TRUE` if succeeds, `FALSE` with `error` set otherwise

### tpl_log_store_get_dates ()

    GList *             tpl_log_store_get_dates             (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

Retrieves a list of dates, in string form YYYYMMDD, corrisponding 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 `chatroom`.

`self` : | a TplLogStore
`account` : | a TpAccount
`chat_id` : | a non-NULL chat identifier
`chatroom` : | whather if the request is related to a chatroom or not.
Returns : | a GList of (char *), to be freed using something like g_list_foreach (lst, g_free, NULL); g_list_free (lst);

### tpl_log_store_get_messages_for_date ()

    GList *             tpl_log_store_get_messages_for_date (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             const gchar *date);

Retrieves a list of text messages, with timestamp matching `date`.

`self` : | a TplLogStore
`account` : | a TpAccount
`chat_id` : | a non-NULL chat identifier
`chatroom` : | whather if the request is related to a chatroom or not.
`date` : | a date, in YYYYMMDD string form
Returns : | a GList of TplLogEntryText, to be freed using something like g_list_foreach (lst, g_object_unref, NULL); g_list_free (lst);

### tpl_log_store_get_recent_messages ()

    GList *             tpl_log_store_get_recent_messages   (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
Returns : |

### tpl_log_store_get_chats ()

    GList *             tpl_log_store_get_chats             (TplLogStore *self,
                                                             TpAccount *account);

Retrieves a list of search hits, corrisponding to each buddy/chatroom id the user exchanged at least a message with, using `account`.

`self` : | a TplLogStore
`account` : | a TpAccount
Returns : | a GList of (TplLogSearchHit *), to be freed using something like g_list_foreach (lst, tpl_log_manager_search_free, NULL); g_list_free (lst);

### tpl_log_store_search_in_identifier_chats_new ()

    GList *             tpl_log_store_search_in_identifier_chats_new
                                                            (TplLogStore *self,
                                                             TpAccount *account,
                                                             gchar const *identifier,
                                                             const gchar *text);

Filters all messages related to `chat_id`, using the boolean function `filter`. It will return at most the last (ie most recent) `num_messages` messages. Pass G_MAXUINT if all the message are needed.

`self` : | a TplLogStore
`account` : | a TpAccount
`identifier` : |
`text` : |
Returns : | a GList of TplLogEntryText, to be freed using something like g_list_foreach (lst, g_object_unref, NULL); g_list_free (lst);

### tpl_log_store_search_new ()

    GList *             tpl_log_store_search_new            (TplLogStore *self,
                                                             const gchar *text);

Searches all textual log entries (all accounts and all chat_ids) matching `text`

`self` : | a TplLogStore
`text` : | a text to be searched among `chat_id` messages
Returns : | a GList of (TplLogSearchHit *), to be freed using something like g_list_foreach (lst, tpl_log_manager_search_free, NULL); g_list_free (lst);

### tpl_log_store_get_filtered_messages ()

    GList *             tpl_log_store_get_filtered_messages (TplLogStore *self,
                                                             TpAccount *account,
                                                             const gchar *chat_id,
                                                             gboolean chatroom,
                                                             guint num_messages,
                                                             TplLogMessageFilter filter,
                                                             gpointer user_data);

`self` : |
`account` : |
`chat_id` : |
`chatroom` : |
`num_messages` : |
`filter` : |
`user_data` : |
Returns : |

### tpl_log_store_is_writable ()

    gboolean            tpl_log_store_is_writable           (TplLogStore *self);

`self` : |
Returns : |

### tpl_log_store_is_readable ()

    gboolean            tpl_log_store_is_readable           (TplLogStore *self);

`self` : |
Returns : |

## See Also

#log-entry-text:TplLogEntryText and other subclasses when they'll exist