From 6ebe03244f6bcc983e4ad3d06ab0dd09634a5937 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Thu, 8 Mar 2012 00:16:23 +0200 Subject: ephy-history-service: add API to query for hosts By now, the public API only supports filtering by time range, but filtering by string matching is also possible. --- lib/history/ephy-history-service.c | 54 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'lib/history/ephy-history-service.c') diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c index ca656c793..436aa1c18 100644 --- a/lib/history/ephy-history-service.c +++ b/lib/history/ephy-history-service.c @@ -41,7 +41,8 @@ typedef enum { GET_HOST_FOR_URL, QUERY_URLS, QUERY_VISITS, - GET_HOSTS + GET_HOSTS, + QUERY_HOSTS } EphyHistoryServiceMessageType; enum { @@ -532,6 +533,18 @@ ephy_history_service_execute_get_hosts (EphyHistoryService *self, return TRUE; } +static gboolean +ephy_history_service_execute_query_hosts (EphyHistoryService *self, + EphyHistoryQuery *query, gpointer *results) +{ + GList *hosts; + + hosts = ephy_history_service_find_host_rows (self, query); + *results = hosts; + + return TRUE; +} + void ephy_history_service_add_visit (EphyHistoryService *self, EphyHistoryPageVisit *visit, EphyHistoryJobCallback callback, gpointer user_data) { @@ -628,6 +641,23 @@ ephy_history_service_get_hosts (EphyHistoryService *self, ephy_history_service_send_message (self, message); } +void +ephy_history_service_query_hosts (EphyHistoryService *self, + EphyHistoryQuery *query, + EphyHistoryJobCallback callback, + gpointer user_data) +{ + EphyHistoryServiceMessage *message; + + g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self)); + + message = ephy_history_service_message_new (self, QUERY_HOSTS, + ephy_history_query_copy (query), + (GDestroyNotify) ephy_history_query_free, + callback, user_data); + ephy_history_service_send_message (self, message); +} + static gboolean ephy_history_service_execute_set_url_title (EphyHistoryService *self, EphyHistoryURL *url, @@ -888,7 +918,8 @@ static EphyHistoryServiceMethod methods[] = { (EphyHistoryServiceMethod)ephy_history_service_execute_get_host_for_url, (EphyHistoryServiceMethod)ephy_history_service_execute_query_urls, (EphyHistoryServiceMethod)ephy_history_service_execute_find_visits, - (EphyHistoryServiceMethod)ephy_history_service_execute_get_hosts + (EphyHistoryServiceMethod)ephy_history_service_execute_get_hosts, + (EphyHistoryServiceMethod)ephy_history_service_execute_query_hosts }; static void @@ -950,3 +981,22 @@ ephy_history_service_visit_url (EphyHistoryService *self, g_signal_emit (self, signals[VISIT_URL], 0, url, &result); } + +void +ephy_history_service_find_hosts (EphyHistoryService *self, + gint64 from, gint64 to, + EphyHistoryJobCallback callback, + gpointer user_data) +{ + EphyHistoryQuery *query; + + g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self)); + + query = ephy_history_query_new (); + + query->from = from; + query->to = to; + + ephy_history_service_query_hosts (self, + query, callback, user_data); +} -- cgit v1.2.3