[epiphany/history-rewrite: 7/11] Add an EphyHistoryQuery object and switch current query method to use it.



commit 0c1e26c1523386aee5f7ac918880af6f144b9f80
Author: Martin Robinson <mrobinson igalia com>
Date:   Fri May 13 14:26:31 2011 -0700

    Add an EphyHistoryQuery object and switch current query method to use it.

 embed/history/ephy-history-service-private.h      |    2 +-
 embed/history/ephy-history-service-visits-table.c |    6 +++---
 embed/history/ephy-history-service.c              |   14 +++++++-------
 embed/history/ephy-history-types.c                |   12 ++++++++++++
 embed/history/ephy-history-types.h                |   11 +++++++++++
 5 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/embed/history/ephy-history-service-private.h b/embed/history/ephy-history-service-private.h
index a940bb0..1f8cd7d 100644
--- a/embed/history/ephy-history-service-private.h
+++ b/embed/history/ephy-history-service-private.h
@@ -41,6 +41,6 @@ void                     ephy_history_service_update_url_row          (EphyHisto
 
 gboolean                 ephy_history_service_initialize_visits_table (EphyHistoryService *self);
 void                     ephy_history_service_add_visit_row           (EphyHistoryService *self, EphyHistoryPageVisit *visit);
-GList *                  ephy_history_service_find_visit_rows_in_time (EphyHistoryService *self, gint64 from, gint64 to);
+GList *                  ephy_history_service_find_visit_rows         (EphyHistoryService *self, EphyHistoryQuery *query);
 
 #endif /* EPHY_HISTORY_SERVICE_PRIVATE_H */
diff --git a/embed/history/ephy-history-service-visits-table.c b/embed/history/ephy-history-service-visits-table.c
index 94fa8c7..90de320 100644
--- a/embed/history/ephy-history-service-visits-table.c
+++ b/embed/history/ephy-history-service-visits-table.c
@@ -101,7 +101,7 @@ create_page_visit_from_statement (EphySQLiteStatement *statement)
 }
 
 GList *
-ephy_history_service_find_visit_rows_in_time (EphyHistoryService *self, gint64 from, gint64 to)
+ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery *query)
 {
   EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
   EphySQLiteStatement *statement = NULL;
@@ -119,8 +119,8 @@ ephy_history_service_find_visit_rows_in_time (EphyHistoryService *self, gint64 f
     return NULL;
   }
 
-  if (FALSE == ephy_sqlite_statement_bind_int (statement, 0, (int) from, &error) ||
-      FALSE == ephy_sqlite_statement_bind_int (statement, 1, (int) to, &error)) {
+  if (FALSE == ephy_sqlite_statement_bind_int (statement, 0, (int) query->from, &error) ||
+      FALSE == ephy_sqlite_statement_bind_int (statement, 1, (int) query->to, &error)) {
     g_error ("Could not build urls table query statement: %s", error->message);
     g_error_free (error);
     g_object_unref (statement);
diff --git a/embed/history/ephy-history-service.c b/embed/history/ephy-history-service.c
index c020c71..d07f374 100644
--- a/embed/history/ephy-history-service.c
+++ b/embed/history/ephy-history-service.c
@@ -436,9 +436,9 @@ ephy_history_service_execute_add_visits (EphyHistoryService *self, GList *visits
 }
 
 static gboolean
-ephy_history_service_execute_find_visits_in_time (EphyHistoryService *self, gint64 *times, gpointer *result)
+ephy_history_service_execute_find_visits (EphyHistoryService *self, EphyHistoryQuery *query, gpointer *result)
 {
-  GList *visits = ephy_history_service_find_visit_rows_in_time (self, times[0], times[1]);
+  GList *visits = ephy_history_service_find_visit_rows (self, query);
   GList *current = visits;
 
   /* FIXME: We don't have a good way to tell the difference between failures and empty returns */
@@ -491,13 +491,13 @@ ephy_history_service_find_visits_in_time (EphyHistoryService *self, gint64 from,
 {
   EphyHistoryThreadJobDetails *details;
 
-  gint64 *times = g_malloc(2 * sizeof(gint64));
-  times[0] = from;
-  times[1] = to;
+  EphyHistoryQuery *query = ephy_history_query_new ();
+  query->from = from;
+  query->to = to;
 
   details = ephy_history_thread_job_details_new (self, 
-                                                 (EphyHistoryJobMethod) ephy_history_service_execute_find_visits_in_time,
-                                                 times, g_free, callback, user_data);
+                                                 (EphyHistoryJobMethod) ephy_history_service_execute_find_visits,
+                                                 query, (GDestroyNotify) ephy_history_query_free, callback, user_data);
   ephy_history_service_schedule_idle (self, G_PRIORITY_DEFAULT, 
                                       ephy_history_service_execute_job_on_history_thread, 
                                       details);
diff --git a/embed/history/ephy-history-types.c b/embed/history/ephy-history-types.c
index 2a8ce38..b27f6cf 100644
--- a/embed/history/ephy-history-types.c
+++ b/embed/history/ephy-history-types.c
@@ -117,3 +117,15 @@ ephy_history_url_free (EphyHistoryURL *url)
   g_slice_free1 (sizeof (EphyHistoryURL), url);
 }
 
+EphyHistoryQuery *
+ephy_history_query_new ()
+{
+  return (EphyHistoryQuery*) g_slice_alloc0 (sizeof (EphyHistoryQuery));
+}
+
+void
+ephy_history_query_free (EphyHistoryQuery *query)
+{
+  g_list_free_full (query->substring_list, g_free);
+  g_slice_free1 (sizeof (EphyHistoryQuery), query);
+}
diff --git a/embed/history/ephy-history-types.h b/embed/history/ephy-history-types.h
index 3e77bd7..8ced7f9 100644
--- a/embed/history/ephy-history-types.h
+++ b/embed/history/ephy-history-types.h
@@ -55,6 +55,14 @@ typedef struct _EphyHistoryPageVisit
   EphyHistoryPageVisitType visit_type;
 } EphyHistoryPageVisit;
 
+typedef struct _EphyHistoryQuery
+{
+  gint64 from;
+  gint64 to;
+  guint limit;
+  GList* substring_list;
+} EphyHistoryQuery;
+
 EphyHistoryPageVisit *          ephy_history_page_visit_new (const char *url, gint64 visit_time, EphyHistoryPageVisitType visit_type);
 EphyHistoryPageVisit *          ephy_history_page_visit_new_with_url (EphyHistoryURL *url, gint64 visit_time, EphyHistoryPageVisitType visit_type);
 EphyHistoryPageVisit *          ephy_history_page_visit_copy (EphyHistoryPageVisit *visit);
@@ -67,6 +75,9 @@ EphyHistoryURL *                ephy_history_url_new (const char *url, const cha
 EphyHistoryURL *                ephy_history_url_copy (EphyHistoryURL *url);
 void                            ephy_history_url_free (EphyHistoryURL *url);
 
+EphyHistoryQuery *              ephy_history_query_new ();
+void                            ephy_history_query_free (EphyHistoryQuery *query);
+
 G_END_DECLS
 
 #endif /* EPHY_HISTORY_TYPES_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]