aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-03-06 23:08:50 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:47 +0800
commite9463a9dc1fd77f741d3cc6a6c335db9733ebdf1 (patch)
tree17a61a1744446a4b5af683a722e5ab82ec807043 /lib
parentfd23fbade3ef2c5490f6d3e7f0a7de7c39872fff (diff)
downloadgsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar.gz
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar.bz2
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar.lz
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar.xz
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.tar.zst
gsoc2013-epiphany-e9463a9dc1fd77f741d3cc6a6c335db9733ebdf1.zip
ephy-history-service: add a method to remove a host from the history
This method will remove all the history related to that host.
Diffstat (limited to 'lib')
-rw-r--r--lib/history/ephy-history-service-hosts-table.c50
-rw-r--r--lib/history/ephy-history-service-private.h1
-rw-r--r--lib/history/ephy-history-service.c27
-rw-r--r--lib/history/ephy-history-service.h1
4 files changed, 79 insertions, 0 deletions
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index 032764457..969154501 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -318,3 +318,53 @@ ephy_history_service_get_host_row_from_url (EphyHistoryService *self,
return host;
}
+
+void
+ephy_history_service_delete_host_row (EphyHistoryService *self,
+ EphyHistoryHost *host)
+{
+ EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
+ EphySQLiteStatement *statement = NULL;
+ gchar *sql_statement;
+ GError *error = NULL;
+
+ g_assert (priv->history_thread == g_thread_self ());
+ g_assert (priv->history_database != NULL);
+
+ g_assert (host->id != -1 || host->url);
+
+ if (host->id != -1)
+ sql_statement = g_strdup ("DELETE FROM hosts WHERE id=?");
+ else
+ sql_statement = g_strdup ("DELETE FROM hosts WHERE url=?");
+
+ statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ sql_statement, &error);
+ g_free (sql_statement);
+
+ if (error) {
+ g_error ("Could not build urls table query statement: %s", error->message);
+ g_error_free (error);
+ g_object_unref (statement);
+ return;
+ }
+
+ if (host->id != -1)
+ ephy_sqlite_statement_bind_int (statement, 0, host->id, &error);
+ else
+ ephy_sqlite_statement_bind_string (statement, 0, host->url, &error);
+
+ if (error) {
+ g_error ("Could not build hosts table query statement: %s", error->message);
+ g_error_free (error);
+ g_object_unref (statement);
+ return;
+ }
+
+ ephy_sqlite_statement_step (statement, &error);
+ if (error) {
+ g_error ("Could not modify host in hosts table: %s", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (statement);
+}
diff --git a/lib/history/ephy-history-service-private.h b/lib/history/ephy-history-service-private.h
index 4cf88d4c0..b585d403d 100644
--- a/lib/history/ephy-history-service-private.h
+++ b/lib/history/ephy-history-service-private.h
@@ -51,5 +51,6 @@ void ephy_history_service_update_host_row (EphyHisto
EphyHistoryHost * ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *url_string, EphyHistoryHost *host);
GList * ephy_history_service_get_all_hosts (EphyHistoryService *self);
EphyHistoryHost * ephy_history_service_get_host_row_from_url (EphyHistoryService *self, const gchar *url);
+void ephy_history_service_delete_host_row (EphyHistoryService *self, EphyHistoryHost *host);
#endif /* EPHY_HISTORY_SERVICE_PRIVATE_H */
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 53363bc56..4c9e44179 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,
+ DELETE_HOST,
CLEAR,
/* QUIT */
QUIT,
@@ -756,6 +757,18 @@ ephy_history_service_execute_delete_urls (EphyHistoryService *self,
}
static gboolean
+ephy_history_service_execute_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
+{
+ ephy_history_service_delete_host_row (self, host);
+ ephy_history_service_schedule_commit (self);
+
+ return TRUE;
+}
+
+static gboolean
ephy_history_service_execute_clear (EphyHistoryService *self,
gpointer pointer,
gpointer *result)
@@ -781,6 +794,19 @@ ephy_history_service_delete_urls (EphyHistoryService *self,
}
void
+ephy_history_service_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
+{
+ EphyHistoryServiceMessage *message =
+ ephy_history_service_message_new (self, DELETE_HOST,
+ ephy_history_host_copy (host), (GDestroyNotify)ephy_history_host_free,
+ callback, user_data);
+ ephy_history_service_send_message (self, message);
+}
+
+void
ephy_history_service_clear (EphyHistoryService *self,
EphyHistoryJobCallback callback,
gpointer user_data)
@@ -810,6 +836,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_delete_host,
(EphyHistoryServiceMethod)ephy_history_service_execute_clear,
(EphyHistoryServiceMethod)ephy_history_service_execute_quit,
(EphyHistoryServiceMethod)ephy_history_service_execute_get_url,
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index c9632f86b..e6c522d11 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -67,6 +67,7 @@ void ephy_history_service_set_url_title (EphyHisto
void ephy_history_service_set_url_zoom_level (EphyHistoryService *self, const char *url, const double zoom_level, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_get_host_for_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_get_hosts (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data);
+void ephy_history_service_delete_host (EphyHistoryService *self, EphyHistoryHost *host, 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_find_urls (EphyHistoryService *self, gint64 from, gint64 to, guint limit, gint host, GList *substring_list, EphyHistoryJobCallback callback, gpointer user_data);