[epiphany/history-rewrite-second] Add a history service method to clear the entire history
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/history-rewrite-second] Add a history service method to clear the entire history
- Date: Fri, 2 Mar 2012 19:44:19 +0000 (UTC)
commit 32d6f0e188e637b8035d9a5034fb6d69eedcbb99
Author: Claudio Saavedra <csaavedra igalia com>
Date: Fri Mar 2 21:24:58 2012 +0200
Add a history service method to clear the entire history
lib/history/ephy-history-service.c | 43 ++++++++++++++++++++++++++++++++++++
lib/history/ephy-history-service.h | 2 +
2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 6261a43..11f66ce 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -32,6 +32,7 @@ typedef enum {
ADD_VISIT,
ADD_VISITS,
DELETE_URLS,
+ CLEAR,
/* QUIT */
QUIT,
/* READ */
@@ -251,6 +252,23 @@ ephy_history_service_close_database_connections (EphyHistoryService *self)
priv->history_database = NULL;
}
+static void
+ephy_history_service_clear_all (EphyHistoryService *self)
+{
+ EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
+ GError *error = NULL;
+
+ if (NULL == priv->history_database)
+ return;
+
+ ephy_sqlite_connection_execute (priv->history_database,
+ "DELETE FROM hosts;", &error);
+ if (error) {
+ g_error ("Couldn't clear history database: %s", error->message);
+ g_error_free(error);
+ }
+}
+
static gboolean
ephy_history_service_is_scheduled_to_quit (EphyHistoryService *self)
{
@@ -652,6 +670,18 @@ ephy_history_service_execute_delete_urls (EphyHistoryService *self,
return TRUE;
}
+static gboolean
+ephy_history_service_execute_clear (EphyHistoryService *self,
+ gpointer pointer,
+ gpointer *result)
+{
+
+ ephy_history_service_clear_all (self);
+ ephy_history_service_schedule_commit (self);
+
+ return TRUE;
+}
+
void
ephy_history_service_delete_urls (EphyHistoryService *self,
GList *urls,
@@ -665,6 +695,18 @@ ephy_history_service_delete_urls (EphyHistoryService *self,
ephy_history_service_send_message (self, message);
}
+void
+ephy_history_service_clear (EphyHistoryService *self,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
+{
+ EphyHistoryServiceMessage *message =
+ ephy_history_service_message_new (self, CLEAR,
+ NULL, NULL,
+ callback, user_data);
+ ephy_history_service_send_message (self, message);
+}
+
static void
ephy_history_service_quit (EphyHistoryService *self,
EphyHistoryJobCallback callback,
@@ -683,6 +725,7 @@ static EphyHistoryServiceMethod methods[] = {
(EphyHistoryServiceMethod)ephy_history_service_execute_add_visit,
(EphyHistoryServiceMethod)ephy_history_service_execute_add_visits,
(EphyHistoryServiceMethod)ephy_history_service_execute_delete_urls,
+ (EphyHistoryServiceMethod)ephy_history_service_execute_clear,
(EphyHistoryServiceMethod)ephy_history_service_execute_quit,
(EphyHistoryServiceMethod)ephy_history_service_execute_get_url,
(EphyHistoryServiceMethod)ephy_history_service_execute_get_host_for_url,
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index b01dd07..0fb8876 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -64,6 +64,8 @@ void ephy_history_service_set_url_zoom_level (EphyHisto
void ephy_history_service_get_host_for_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_get_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data);
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);
G_END_DECLS
#endif /* EPHY_HISTORY_SERVICE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]