diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-11 11:55:00 +0000 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-11 11:55:00 +0000 |
commit | ce34b27629ad00ebc5bf0e7ad7ec1df43e190f48 (patch) | |
tree | 3a1b85530736e39eeae88379bf2d83ec227fab06 | |
parent | d7d54a11b8da1f4a93f458dad06637f98fdf97bc (diff) | |
parent | 52182e96c4c1cb5eb3cef039a4d9a6b6b2f43562 (diff) | |
download | telepathy-logger-ce34b27629ad00ebc5bf0e7ad7ec1df43e190f48.tar.gz |
Merge branch 'remove-unused'
Conflicts:
telepathy-logger/log-manager-internal.h
Reviewed-by: emilio.pozuelo@collabora.co.uk
-rw-r--r-- | extensions/Logger.xml | 71 | ||||
-rw-r--r-- | src/test-api.c | 43 | ||||
-rw-r--r-- | telepathy-logger/dbus-service.c | 188 | ||||
-rw-r--r-- | telepathy-logger/log-manager-internal.h | 21 | ||||
-rw-r--r-- | telepathy-logger/log-manager.c | 117 | ||||
-rw-r--r-- | telepathy-logger/log-store-internal.h | 6 | ||||
-rw-r--r-- | telepathy-logger/log-store-pidgin.c | 33 | ||||
-rw-r--r-- | telepathy-logger/log-store-xml.c | 30 | ||||
-rw-r--r-- | telepathy-logger/log-store.c | 31 |
9 files changed, 2 insertions, 538 deletions
diff --git a/extensions/Logger.xml b/extensions/Logger.xml index af0254e..cf5e067 100644 --- a/extensions/Logger.xml +++ b/extensions/Logger.xml @@ -19,82 +19,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ </tp:license> <interface name="org.freedesktop.Telepathy.Logger.DRAFT" tp:causes-havoc="experimental"> - <tp:added version="0.2">(as a draft)</tp:added> + <tp:added version="0.3">(as a draft)</tp:added> <tp:docstring> An interface for requesting information from the Telepathy Logger service. </tp:docstring> - <tp:struct name="Chat_Message" array-name="Chat_Message_List"> - <tp:member type="s" name="Sender"> - <tp:docstring> - The identifier of the contact who originated this message. - </tp:docstring> - </tp:member> - - <tp:member type="s" name="Message"> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - The body of the message sent to a 1-1 Chat or a Chat Room. - </tp:docstring> - </tp:member> - - <tp:member type="x" name="Timestamp" tp:type="Unix_Timestamp64"> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - Unix timestamp for the log event - </tp:docstring> - </tp:member> - - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>It represents a single message, received or sent.</p> - <p>The receiver is implicit in the request: if the sender is the user, - the receiver is the identifier in chat_id paramenter, if the sender is - not the user, the user is consequently the receiver of the message</p> - </tp:docstring> - </tp:struct> - - <method name="GetRecentEvents" - tp:name-for-bindings="Get_Recent_Events"> - <arg direction="in" name="Account" type="o" tp:type="Account"> - <tp:docstring> - The account path for the TpAccount to which the conversation is related - </tp:docstring> - </arg> - - <arg direction="in" name="Identifier" type="s"> - <tp:docstring> - The buddy's identifier for the conversation - </tp:docstring> - </arg> - - <arg direction="in" name="Type" type="u"> - <tp:docstring> - The type of the events to return. - </tp:docstring> - </arg> - - <arg direction="in" name="Lines" type="u"> - <tp:docstring> - how many entries will be returned. - - NOTE: to retreive information that would generate high traffic, use - the library API approach instead of DBus. - </tp:docstring> - </arg> - - <!-- FIXME: we're returning a list of events that can be - messages (chats), but also calls and any other event - type in the future, so make the return type a list of - TplLogSearchHit or something generic than a(ssx) ? --> - <arg direction="out" name="Messages" type="a(ssx)" - tp:type="Chat_Message[]" /> - - <tp:docstring> - Request the last Lines entries of logs for the specified couple - Account+Identifier. - </tp:docstring> - </method> - <method name="GetFavouriteContacts" tp:name-for-bindings="Get_Favourite_Contacts"> <arg direction="out" name="Favourite_Contacts" type="a(oas)"> diff --git a/src/test-api.c b/src/test-api.c index 558ce90..d538e65 100644 --- a/src/test-api.c +++ b/src/test-api.c @@ -30,45 +30,6 @@ static GMainLoop *mainloop = NULL; -static void -last_events_cb (TpProxy *logger, - const GPtrArray *result, - const GError *error, - gpointer userdata, - GObject *weak_obj) -{ - /* Just do demonstrate remote exceptions versus regular GError */ - if (error != NULL) - { - g_printerr ("Error: %s\n", error->message); - return; - } - - g_print ("Names on the message bus:\n"); - - for (guint i = 0; i < result->len; ++i) - { - GValueArray *message_struct; - const gchar *message_body; - const gchar *message_sender; - guint message_timestamp; - - message_struct = g_ptr_array_index (result, i); - - message_sender = g_value_get_string ( - g_value_array_get_nth (message_struct, 0)); - message_body = g_value_get_string ( - g_value_array_get_nth (message_struct, 1)); - message_timestamp = g_value_get_int64 (g_value_array_get_nth - (message_struct, 2)); - - g_print ("%d: [%d] from=%s: %s\n", i, message_timestamp, message_sender, - message_body); - } - - g_main_loop_quit (mainloop); -} - int main (int argc, char *argv[]) { @@ -102,9 +63,7 @@ main (int argc, char *argv[]) tp_proxy_add_interface_by_id (proxy, TPL_IFACE_QUARK_LOGGER); - tpl_cli_logger_call_get_recent_events (proxy, -1, - account, identifer, FALSE, 5, - last_events_cb, NULL, NULL, NULL); + // FIXME Test favorites g_free (account); diff --git a/telepathy-logger/dbus-service.c b/telepathy-logger/dbus-service.c index 66a291d..16d2a95 100644 --- a/telepathy-logger/dbus-service.c +++ b/telepathy-logger/dbus-service.c @@ -369,193 +369,6 @@ _tpl_dbus_service_new (void) } -typedef struct -{ - TplDBusService *self; - TpAccount *account; - char *identifier; - TplEventSearchType type; - guint lines; - DBusGMethodInvocation *context; - GPtrArray *packed; - GList *dates, *ptr; -} RecentEventsContext; - -static void _lookup_next_date (RecentEventsContext *ctx); - -static void -_get_events_return (GObject *manager, - GAsyncResult *res, - gpointer user_data) -{ - RecentEventsContext *ctx = user_data; - GList *events, *ptr; - GError *error = NULL; - - if (!tpl_log_manager_get_events_for_date_finish ( - TPL_LOG_MANAGER (manager), res, &events, &error)) - { - DEBUG ("Failed to get events: %s", error->message); - - g_clear_error (&error); - events = NULL; /* just to be sure */ - } - - /* from the most recent message, backward */ - for (ptr = g_list_last (events); - ptr != NULL && ctx->lines > 0; - ptr = g_list_previous (ptr)) - { - TplEvent *log = ptr->data; - const char *message = tpl_text_event_get_message ( - TPL_TEXT_EVENT (log)); - const char *sender = tpl_entity_get_identifier ( - tpl_event_get_sender (log)); - gint64 timestamp = tpl_event_get_timestamp (log); - - DEBUG ("Message: %" G_GINT64_FORMAT " <%s> %s", - timestamp, sender, message); - - g_ptr_array_add (ctx->packed, tp_value_array_build (3, - G_TYPE_STRING, sender, - G_TYPE_STRING, message, - G_TYPE_INT64, timestamp, - G_TYPE_INVALID)); - - ctx->lines--; - } - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - _lookup_next_date (ctx); -} - - -static void -_lookup_next_date (RecentEventsContext *ctx) -{ - TplDBusServicePriv *priv = ctx->self->priv; - - if (ctx->ptr != NULL && ctx->lines > 0) - { - GDate *date = ctx->ptr->data; - - DEBUG ("Looking up date %04u-%02u-%02u", g_date_get_year (date), - g_date_get_month (date), g_date_get_day (date)); - - tpl_log_manager_get_events_for_date_async (priv->manager, - ctx->account, ctx->identifier, ctx->type, date, - _get_events_return, ctx); - - ctx->ptr = g_list_previous (ctx->ptr); - } - else - { - /* return and release */ - DEBUG ("complete, returning"); - - g_list_foreach (ctx->dates, (GFunc) g_date_free, NULL); - g_list_free (ctx->dates); - - tpl_svc_logger_return_from_get_recent_events (ctx->context, - ctx->packed); - - g_ptr_array_free (ctx->packed, TRUE); - g_free (ctx->identifier); - g_object_unref (ctx->account); - g_slice_free (RecentEventsContext, ctx); - } -} - - -static void -_get_dates_return (GObject *manager, - GAsyncResult *res, - gpointer user_data) -{ - RecentEventsContext *ctx = user_data; - GError *error = NULL; - - if (!tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager), res, - &ctx->dates, &error)) - { - DEBUG ("Failed to get dates: %s", error->message); - - dbus_g_method_return_error (ctx->context, error); - - g_clear_error (&error); - - g_free (ctx->identifier); - g_object_unref (ctx->account); - g_slice_free (RecentEventsContext, ctx); - - return; - } - - ctx->ptr = g_list_last (ctx->dates); - ctx->packed = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); - - _lookup_next_date (ctx); -} - - -static void -tpl_dbus_service_get_recent_events (TplSvcLogger *self, - const gchar *account_path, - const gchar *identifier, - TplEventSearchType type, - guint lines, - DBusGMethodInvocation *context) -{ - TplDBusServicePriv *priv = TPL_DBUS_SERVICE (self)->priv; - TpDBusDaemon *tp_dbus; - TpAccount *account; - RecentEventsContext *ctx; - GError *error = NULL; - - g_return_if_fail (TPL_IS_DBUS_SERVICE (self)); - g_return_if_fail (context != NULL); - - tp_dbus = tp_dbus_daemon_dup (&error); - if (tp_dbus == NULL) - { - DEBUG ("Unable to acquire the bus daemon: %s", error->message); - dbus_g_method_return_error (context, error); - goto out; - } - - account = tp_account_new (tp_dbus, account_path, &error); - if (account == NULL) - { - DEBUG ("Unable to acquire the account for %s: %s", account_path, - error->message); - dbus_g_method_return_error (context, error); - goto out; - } - - ctx = g_slice_new (RecentEventsContext); - ctx->self = TPL_DBUS_SERVICE (self); - ctx->account = account; - ctx->identifier = g_strdup (identifier); - ctx->type = type; - ctx->lines = lines; - ctx->context = context; - - tpl_log_manager_get_dates_async (priv->manager, - account, identifier, type, - _get_dates_return, ctx); - -out: - - if (tp_dbus != NULL) - g_object_unref (tp_dbus); - - g_clear_error (&error); -} - - static void append_favourite_contacts_account_and_contacts (const gchar *account, GHashTable *contacts, @@ -1044,7 +857,6 @@ tpl_logger_iface_init (gpointer iface, TplSvcLoggerClass *klass = (TplSvcLoggerClass *) iface; #define IMPLEMENT(x) tpl_svc_logger_implement_##x (klass, tpl_dbus_service_##x) - IMPLEMENT (get_recent_events); IMPLEMENT (get_favourite_contacts); IMPLEMENT (add_favourite_contact); IMPLEMENT (remove_favourite_contact); diff --git a/telepathy-logger/log-manager-internal.h b/telepathy-logger/log-manager-internal.h index aa976dd..86ac20a 100644 --- a/telepathy-logger/log-manager-internal.h +++ b/telepathy-logger/log-manager-internal.h @@ -59,27 +59,6 @@ GList * _tpl_log_manager_get_entities (TplLogManager *manager, GList * _tpl_log_manager_search (TplLogManager *manager, const gchar *text); -GList * _tpl_log_manager_search_in_identifier (TplLogManager *manager, - TpAccount *account, - gchar const *identifier, - TplEventSearchType type, - const gchar *text); - -void _tpl_log_manager_search_in_identifier_async ( - TplLogManager *manager, - TpAccount *account, - gchar const *id, - TplEventSearchType type, - const gchar *text, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean _tpl_log_manager_search_in_identifier_finish ( - TplLogManager *self, - GAsyncResult *result, - GList **hits, - GError **error); - void _tpl_log_manager_clear (TplLogManager *self); void _tpl_log_manager_clear_account (TplLogManager *self, TpAccount *account); diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index fdf76f8..d31a77d 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -721,36 +721,6 @@ _tpl_log_manager_get_entities (TplLogManager *manager, GList * -_tpl_log_manager_search_in_identifier (TplLogManager *manager, - TpAccount *account, - gchar const *identifier, - TplEventSearchType type, - const gchar *text) -{ - GList *l, *out = NULL; - TplLogManagerPriv *priv; - - g_return_val_if_fail (TPL_IS_LOG_MANAGER (manager), NULL); - g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); - g_return_val_if_fail (!TPL_STR_EMPTY (identifier), NULL); - g_return_val_if_fail (!TPL_STR_EMPTY (text), NULL); - - priv = manager->priv; - - for (l = priv->readable_stores; l != NULL; l = g_list_next (l)) - { - TplLogStore *store = TPL_LOG_STORE (l->data); - - out = g_list_concat (out, - _tpl_log_store_search_in_identifier - (store, account, identifier, type, text)); - } - - return out; -} - - -GList * _tpl_log_manager_search (TplLogManager *manager, const gchar *text) { @@ -1376,93 +1346,6 @@ tpl_log_manager_get_entities_finish (TplLogManager *self, static void -_search_in_identifier_async_thread (GSimpleAsyncResult *simple, - GObject *object, - GCancellable *cancellable) -{ - TplLogManagerAsyncData *async_data; - TplLogManagerEventInfo *event_info; - GList *lst; - - async_data = g_async_result_get_user_data (G_ASYNC_RESULT (simple)); - event_info = async_data->request; - - lst = _tpl_log_manager_search_in_identifier (async_data->manager, - event_info->account, event_info->id, event_info->type, - event_info->search_text); - - g_simple_async_result_set_op_res_gpointer (simple, lst, - (GDestroyNotify) tpl_log_manager_search_free); -} - - -void -_tpl_log_manager_search_in_identifier_async (TplLogManager *manager, - TpAccount *account, - gchar const *identifier, - TplEventSearchType type, - const gchar *text, - GAsyncReadyCallback callback, - gpointer user_data) -{ - TplLogManagerEventInfo *event_info = tpl_log_manager_event_info_new (); - TplLogManagerAsyncData *async_data = tpl_log_manager_async_data_new (); - GSimpleAsyncResult *simple; - - g_return_if_fail (TPL_IS_LOG_MANAGER (manager)); - g_return_if_fail (TP_IS_ACCOUNT (account)); - - event_info->account = g_object_ref (account); - event_info->id = g_strdup (identifier); - event_info->type = type; - event_info->search_text = g_strdup (text); - - async_data->manager = g_object_ref (manager); - async_data->request = event_info; - async_data->request_free = - (TplLogManagerFreeFunc) tpl_log_manager_event_info_free; - async_data->cb = callback; - async_data->user_data = user_data; - - simple = g_simple_async_result_new (G_OBJECT (manager), - _tpl_log_manager_async_operation_cb, async_data, - _tpl_log_manager_search_in_identifier_async); - - g_simple_async_result_run_in_thread (simple, - _search_in_identifier_async_thread, 0, NULL); - - g_object_unref (simple); -} - - -gboolean -_tpl_log_manager_search_in_identifier_finish (TplLogManager *self, - GAsyncResult *result, - GList **hits, - GError **error) -{ - GSimpleAsyncResult *simple; - - g_return_val_if_fail (TPL_IS_LOG_MANAGER (self), FALSE); - g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); - g_return_val_if_fail (g_simple_async_result_is_valid (result, - G_OBJECT (self), - _tpl_log_manager_search_in_identifier_async), - FALSE); - - simple = G_SIMPLE_ASYNC_RESULT (result); - - if (g_simple_async_result_propagate_error (simple, error)) - return FALSE; - - if (hits != NULL) - *hits = _take_list (g_simple_async_result_get_op_res_gpointer (simple)); - - return TRUE; -} - - -static void _search_async_thread (GSimpleAsyncResult *simple, GObject *object, GCancellable *cancellable) diff --git a/telepathy-logger/log-store-internal.h b/telepathy-logger/log-store-internal.h index c7dd8d4..591cfe2 100644 --- a/telepathy-logger/log-store-internal.h +++ b/telepathy-logger/log-store-internal.h @@ -74,9 +74,6 @@ typedef struct const gchar *id, TplEventSearchType type); GList * (*get_entities) (TplLogStore *self, TpAccount *account); GList * (*search_new) (TplLogStore *self, const gchar *text); - GList * (*search_in_identifier) (TplLogStore *self, - TpAccount *account, const gchar *identifier, TplEventSearchType type, - const gchar *text); GList * (*get_filtered_events) (TplLogStore *self, TpAccount *account, const gchar *id, TplEventSearchType type, guint num_events, TplLogEventFilter filter, gpointer user_data); @@ -101,9 +98,6 @@ GList * _tpl_log_store_get_events_for_date (TplLogStore *self, GList * _tpl_log_store_get_recent_events (TplLogStore *self, TpAccount *account, const gchar *id, TplEventSearchType type); GList * _tpl_log_store_get_entities (TplLogStore *self, TpAccount *account); -GList * _tpl_log_store_search_in_identifier (TplLogStore *self, - TpAccount *account, const gchar *identifier, TplEventSearchType type, - const gchar *text); GList * _tpl_log_store_search_new (TplLogStore *self, const gchar *text); GList * _tpl_log_store_get_filtered_events (TplLogStore *self, TpAccount *account, const gchar *id, TplEventSearchType type, diff --git a/telepathy-logger/log-store-pidgin.c b/telepathy-logger/log-store-pidgin.c index d6eb2a4..16c78c5 100644 --- a/telepathy-logger/log-store-pidgin.c +++ b/telepathy-logger/log-store-pidgin.c @@ -1180,38 +1180,6 @@ log_store_pidgin_get_filtered_events (TplLogStore *self, } -static GList * -log_store_pidgin_search_in_identifier (TplLogStore *store, - TpAccount *account, - const gchar *identifier, - TplEventSearchType type, - const gchar *text) -{ - TplLogStorePidgin *self = TPL_LOG_STORE_PIDGIN (store); - GList *files; - GList *retval; - gchar *dir; - - g_return_val_if_fail (TPL_IS_LOG_STORE_PIDGIN (self), NULL); - g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); - g_return_val_if_fail (!tp_str_empty (identifier), NULL); - g_return_val_if_fail (!tp_str_empty (text), NULL); - - dir = log_store_pidgin_get_dir (store, account, identifier, type); - - files = log_store_pidgin_get_all_files (store, dir); - DEBUG ("Found %d log files in total", g_list_length (files)); - - retval = _log_store_pidgin_search_in_files (self, text, files); - - g_free (dir); - g_list_foreach (files, (GFunc) g_free, NULL); - g_list_free (files); - - return retval; -} - - static void log_store_iface_init (gpointer g_iface, gpointer iface_data) @@ -1224,7 +1192,6 @@ log_store_iface_init (gpointer g_iface, iface->get_dates = log_store_pidgin_get_dates; iface->get_events_for_date = log_store_pidgin_get_events_for_date; iface->get_entities = log_store_pidgin_get_entities; - iface->search_in_identifier = log_store_pidgin_search_in_identifier; iface->search_new = log_store_pidgin_search_new; iface->get_filtered_events = log_store_pidgin_get_filtered_events; } diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c index fce3539..41bcc05 100644 --- a/telepathy-logger/log-store-xml.c +++ b/telepathy-logger/log-store-xml.c @@ -1070,34 +1070,6 @@ fail: static GList * -log_store_xml_search_in_identifier (TplLogStore *store, - TpAccount *account, - const gchar *identifier, - TplEventSearchType type, - const gchar *text) -{ - TplLogStoreXml *self = (TplLogStoreXml *) store; - GList *files; - gchar *dir; - - g_return_val_if_fail (TPL_IS_LOG_STORE_XML (self), NULL); - g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); - g_return_val_if_fail (!TPL_STR_EMPTY (identifier), NULL); - g_return_val_if_fail (!TPL_STR_EMPTY (text), NULL); - - dir = log_store_xml_get_dir (self, account, identifier, type); - - files = log_store_xml_get_all_files (self, dir); - DEBUG ("Found %d log files in total", g_list_length (files)); - - g_free (dir); - - return _log_store_xml_search_in_files (self, text, files); -} - - - -static GList * log_store_xml_search_new (TplLogStore *store, const gchar *text) { @@ -1444,8 +1416,6 @@ log_store_iface_init (gpointer g_iface, iface->get_dates = log_store_xml_get_dates; iface->get_events_for_date = log_store_xml_get_events_for_date; iface->get_entities = log_store_xml_get_entities; - iface->search_in_identifier = - log_store_xml_search_in_identifier; iface->search_new = log_store_xml_search_new; iface->get_filtered_events = log_store_xml_get_filtered_events; iface->clear = log_store_xml_clear; diff --git a/telepathy-logger/log-store.c b/telepathy-logger/log-store.c index 62e6698..f92e26b 100644 --- a/telepathy-logger/log-store.c +++ b/telepathy-logger/log-store.c @@ -263,37 +263,6 @@ _tpl_log_store_get_entities (TplLogStore *self, /** - * _tpl_log_store_search_in_identifier: - * @self: a TplLogStore - * @account: a TpAccount - * @id: a non-NULL identifier - * @type: the event type - * @text: a text to be searched among @id events - * - * Searches textual log entries related to @id and matching @text - * - * 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); - */ -GList * -_tpl_log_store_search_in_identifier (TplLogStore *self, - TpAccount *account, - const gchar *id, - TplEventSearchType type, - const gchar *text) -{ - g_return_val_if_fail (TPL_IS_LOG_STORE (self), NULL); - if (TPL_LOG_STORE_GET_INTERFACE (self)->search_in_identifier == - NULL) - return NULL; - - return TPL_LOG_STORE_GET_INTERFACE (self)->search_in_identifier (self, - account, id, type, text); -} - - -/** * _tpl_log_store_search_new: * @self: a TplLogStore * @text: a text to be searched among text messages |