[epiphany/history-rewrite-second] Add a method to populate a list of hosts



commit 0362c01c99a0c5ee977ffadf60e05396454468e1
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Fri Mar 2 21:27:17 2012 +0200

    Add a method to populate a list of hosts
    
    Given a list of EphyHistoryHosts containing only the host ids, this
    will query for the rest of the information from the database

 lib/history/ephy-history-service.c |   36 +++++++++++++++++++++++++++++++++++-
 lib/history/ephy-history-service.h |    3 +++
 2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 11f66ce..357d8ec 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -40,6 +40,7 @@ typedef enum {
   GET_HOST_FOR_URL,
   QUERY_URLS,
   QUERY_VISITS,
+  POPULATE_HOSTS,
 } EphyHistoryServiceMessageType;
   
 typedef struct _EphyHistoryServiceMessage {
@@ -459,6 +460,24 @@ ephy_history_service_execute_find_visits (EphyHistoryService *self, EphyHistoryQ
   return TRUE;
 }
 
+static gboolean
+ephy_history_service_execute_populate_hosts (EphyHistoryService *self,
+                                             GList *hosts, gpointer *result)
+{
+  GList *current = hosts;
+
+  while (current) {
+    EphyHistoryHost *host = (EphyHistoryHost *) current->data;
+    if (NULL == ephy_history_service_get_host_row (self, NULL, host)) {
+      g_error ("Error retrieving a host.\n");
+      return FALSE;
+    }
+    current = current->next;
+  }
+  *result = hosts;
+  return TRUE;
+}
+
 void
 ephy_history_service_add_visit (EphyHistoryService *self, EphyHistoryPageVisit *visit, EphyHistoryJobCallback callback, gpointer user_data)
 {
@@ -522,6 +541,20 @@ ephy_history_service_query_urls (EphyHistoryService *self, EphyHistoryQuery *que
   ephy_history_service_send_message (self, message);
 }
 
+void
+ephy_history_service_populate_hosts (EphyHistoryService *self,
+                                     GList *hosts,
+                                     EphyHistoryJobCallback callback,
+                                     gpointer user_data)
+{
+  EphyHistoryServiceMessage *message;
+
+  message = ephy_history_service_message_new (self, POPULATE_HOSTS,
+                                              hosts, NULL,
+                                              callback, user_data);
+  ephy_history_service_send_message (self, message);
+}
+
 static gboolean
 ephy_history_service_execute_set_url_title (EphyHistoryService *self,
                                             EphyHistoryURL *url,
@@ -730,7 +763,8 @@ static EphyHistoryServiceMethod methods[] = {
   (EphyHistoryServiceMethod)ephy_history_service_execute_get_url,
   (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_find_visits,
+  (EphyHistoryServiceMethod)ephy_history_service_execute_populate_hosts
 };
 
 static void
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index 0fb8876..228f29c 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -66,6 +66,9 @@ void                     ephy_history_service_get_url                 (EphyHisto
 void                     ephy_history_service_delete_urls             (EphyHistoryService *self, GList *urls, EphyHistoryJobCallback callback, gpointer user_data);
 
 void                     ephy_history_service_clear                   (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data);
+
+void                     ephy_history_service_populate_hosts          (EphyHistoryService *self, GList *hosts, EphyHistoryJobCallback callback, gpointer user_data);
+
 G_END_DECLS
 
 #endif /* EPHY_HISTORY_SERVICE_H */



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