aboutsummaryrefslogtreecommitdiffstats
path: root/lib/history/ephy-history-service-hosts-table.c
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/history/ephy-history-service-hosts-table.c
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/history/ephy-history-service-hosts-table.c')
-rw-r--r--lib/history/ephy-history-service-hosts-table.c50
1 files changed, 50 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);
+}