aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-03-03 03:24:58 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:46 +0800
commitf9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2 (patch)
tree906cc10f6f9373aee811d86d5da79dbda64bf3f4 /lib
parent2f19776788cd479963afcf53235190c79f3c1402 (diff)
downloadgsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar.gz
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar.bz2
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar.lz
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar.xz
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.tar.zst
gsoc2013-epiphany-f9ac9eaf73b94ca0ee3b7cf3a129500161f58ea2.zip
ephy-history-service: add a method to clear the entire history
Diffstat (limited to 'lib')
-rw-r--r--lib/history/ephy-history-service.c43
-rw-r--r--lib/history/ephy-history-service.h1
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 1d5f06ac2..8d4e188fb 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 */
@@ -287,6 +288,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)
{
@@ -688,6 +706,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,
@@ -701,6 +731,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,
@@ -719,6 +761,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 50d79f31f..64cab0cb9 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -70,6 +70,7 @@ 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_find_urls (EphyHistoryService *self, gint64 from, gint64 to, guint limit, GList *substring_list, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_visit_url (EphyHistoryService *self, const char *orig_url);
+void ephy_history_service_clear (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data);
G_END_DECLS