[epiphany] history-service: Use G_DECLARE_FINAL_TYPE
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] history-service: Use G_DECLARE_FINAL_TYPE
- Date: Wed, 10 Feb 2016 06:21:19 +0000 (UTC)
commit 9b3e45f56d41b383749c10e550561b43007525a0
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Feb 9 22:55:15 2016 -0600
history-service: Use G_DECLARE_FINAL_TYPE
lib/history/ephy-history-service-hosts-table.c | 58 ++++-----
lib/history/ephy-history-service-private.h | 3 +-
lib/history/ephy-history-service-urls-table.c | 44 +++----
lib/history/ephy-history-service-visits-table.c | 21 ++--
lib/history/ephy-history-service.c | 152 ++++++++++-------------
lib/history/ephy-history-service.h | 26 +----
6 files changed, 126 insertions(+), 178 deletions(-)
---
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index f01d3c9..2cfeeaa 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -27,13 +27,12 @@
gboolean
ephy_history_service_initialize_hosts_table (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- if (ephy_sqlite_connection_table_exists (priv->history_database, "hosts")) {
+ if (ephy_sqlite_connection_table_exists (self->history_database, "hosts")) {
return TRUE;
}
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"CREATE TABLE hosts ("
"id INTEGER PRIMARY KEY,"
"url LONGVARCAR,"
@@ -53,14 +52,13 @@ ephy_history_service_initialize_hosts_table (EphyHistoryService *self)
void
ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *host)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"INSERT INTO hosts (url, title, visit_count, zoom_level) "
"VALUES (?, ?, ?, ?)", &error);
@@ -85,7 +83,7 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
g_warning ("Could not insert host into hosts table: %s", error->message);
g_error_free (error);
} else {
- host->id = ephy_sqlite_connection_get_last_insert_id (priv->history_database);
+ host->id = ephy_sqlite_connection_get_last_insert_id (self->history_database);
}
g_object_unref (statement);
@@ -94,14 +92,13 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
void
ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost *host)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"UPDATE hosts SET url=?, title=?, visit_count=?, zoom_level=?"
"WHERE id=?", &error);
if (error) {
@@ -132,12 +129,11 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
EphyHistoryHost*
ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_string, EphyHistoryHost *host)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
if (host_string == NULL && host != NULL)
host_string = host->url;
@@ -145,11 +141,11 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
g_assert (host_string || host->id !=-1);
if (host != NULL && host->id != -1) {
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"SELECT id, url, title, visit_count, zoom_level FROM hosts "
"WHERE id=?", &error);
} else {
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"SELECT id, url, title, visit_count, zoom_level FROM hosts "
"WHERE url=?", &error);
}
@@ -214,15 +210,14 @@ create_host_from_statement (EphySQLiteStatement *statement)
GList*
ephy_history_service_get_all_hosts (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GList *hosts = NULL;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"SELECT id, url, title, visit_count, zoom_level FROM hosts", &error);
if (error) {
@@ -248,7 +243,6 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self)
GList*
ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery *query)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GList *substring;
GString *statement_str;
@@ -266,8 +260,8 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
int i = 0;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
statement_str = g_string_new (base_statement);
@@ -292,7 +286,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1 ");
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
statement_str->str, &error);
g_string_free (statement_str, TRUE);
@@ -428,13 +422,12 @@ 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 (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
g_assert (host->id != -1 || host->url);
@@ -443,7 +436,7 @@ ephy_history_service_delete_host_row (EphyHistoryService *self,
else
sql_statement = g_strdup ("DELETE FROM hosts WHERE url=?");
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
sql_statement, &error);
g_free (sql_statement);
@@ -476,18 +469,17 @@ ephy_history_service_delete_host_row (EphyHistoryService *self,
void
ephy_history_service_delete_orphan_hosts (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
/* Where a JOIN would give us all hosts with urls associated, a LEFT
JOIN also gives us those hosts for which there are no urls. By
means of urls.host == NULL we filter out anything else and
retrieve only the ids of the hosts without associated urls. Then,
we delete all these rows from the hosts table. */
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"DELETE FROM hosts WHERE hosts.id IN "
" (SELECT hosts.id FROM hosts LEFT JOIN urls "
" ON hosts.id = urls.host WHERE urls.host is NULL);",
diff --git a/lib/history/ephy-history-service-private.h b/lib/history/ephy-history-service-private.h
index fc55d98..668de58 100644
--- a/lib/history/ephy-history-service-private.h
+++ b/lib/history/ephy-history-service-private.h
@@ -21,7 +21,8 @@
#include "ephy-sqlite-connection.h"
-struct _EphyHistoryServicePrivate {
+struct _EphyHistoryService {
+ GObject parent_instance;
char *history_filename;
EphySQLiteConnection *history_database;
GThread *history_thread;
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index 529d320..ead8475 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -25,13 +25,12 @@
gboolean
ephy_history_service_initialize_urls_table (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- if (ephy_sqlite_connection_table_exists (priv->history_database, "visits")) {
+ if (ephy_sqlite_connection_table_exists (self->history_database, "visits")) {
return TRUE;
}
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"CREATE TABLE urls ("
"id INTEGER PRIMARY KEY,"
"host INTEGER NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,"
@@ -55,12 +54,11 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self)
EphyHistoryURL *
ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_string, EphyHistoryURL *url)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
if (url_string == NULL && url != NULL)
url_string = url->url;
@@ -68,11 +66,11 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
g_return_val_if_fail (url_string || url->id != -1, NULL);
if (url != NULL && url->id != -1) {
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview,
thumbnail_update_time FROM urls "
"WHERE id=?", &error);
} else {
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview,
thumbnail_update_time FROM urls "
"WHERE url=?", &error);
}
@@ -126,14 +124,13 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
void
ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, host) "
" VALUES (?, ?, ?, ?, ?, ?)", &error);
if (error) {
@@ -159,7 +156,7 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
g_warning ("Could not insert URL into urls table: %s", error->message);
g_error_free (error);
} else {
- url->id = ephy_sqlite_connection_get_last_insert_id (priv->history_database);
+ url->id = ephy_sqlite_connection_get_last_insert_id (self->history_database);
}
g_object_unref (statement);
@@ -168,14 +165,13 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
void
ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *url)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
"UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=?, hidden_from_overview=?,
thumbnail_update_time=? "
"WHERE id=?", &error);
if (error) {
@@ -226,7 +222,6 @@ create_url_from_statement (EphySQLiteStatement *statement)
GList *
ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *query)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GList *substring;
GString *statement_str;
@@ -248,8 +243,8 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
int i = 0;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
statement_str = g_string_new (base_statement);
@@ -311,7 +306,7 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
statement_str = g_string_append (statement_str, "LIMIT ? ");
}
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
statement_str->str, &error);
g_string_free (statement_str, TRUE);
@@ -392,13 +387,12 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
void
ephy_history_service_delete_url (EphyHistoryService *self, EphyHistoryURL *url)
{
- 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 (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
g_return_if_fail (url->id != -1 || url->url);
@@ -407,7 +401,7 @@ ephy_history_service_delete_url (EphyHistoryService *self, EphyHistoryURL *url)
else
sql_statement = g_strdup ("DELETE FROM urls WHERE url=?");
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
sql_statement, &error);
g_free (sql_statement);
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index 8d38df4..5438ffc 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -23,13 +23,12 @@
gboolean
ephy_history_service_initialize_visits_table (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- if (ephy_sqlite_connection_table_exists (priv->history_database, "visits"))
+ if (ephy_sqlite_connection_table_exists (self->history_database, "visits"))
return TRUE;
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"CREATE TABLE visits ("
"id INTEGER PRIMARY KEY,"
"url INTEGER NOT NULL REFERENCES urls(id) ON DELETE CASCADE,"
@@ -49,15 +48,14 @@ ephy_history_service_initialize_visits_table (EphyHistoryService *self)
void
ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVisit *visit)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (
- priv->history_database,
+ self->history_database,
"INSERT INTO visits (url, visit_time, visit_type) "
" VALUES (?, ?, ?) ", &error);
if (error) {
@@ -80,7 +78,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
g_warning ("Could not insert URL into visits table: %s", error->message);
g_error_free (error);
} else {
- visit->id = ephy_sqlite_connection_get_last_insert_id (priv->history_database);
+ visit->id = ephy_sqlite_connection_get_last_insert_id (self->history_database);
}
ephy_history_service_schedule_commit (self);
@@ -101,7 +99,6 @@ create_page_visit_from_statement (EphySQLiteStatement *statement)
GList *
ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery *query)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
EphySQLiteStatement *statement = NULL;
GList *substring;
GString *statement_str;
@@ -121,8 +118,8 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
int i = 0;
- g_assert (priv->history_thread == g_thread_self ());
- g_assert (priv->history_database != NULL);
+ g_assert (self->history_thread == g_thread_self ());
+ g_assert (self->history_database != NULL);
statement_str = g_string_new (base_statement);
@@ -147,7 +144,7 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1");
- statement = ephy_sqlite_connection_create_statement (priv->history_database,
+ statement = ephy_sqlite_connection_create_statement (self->history_database,
statement_str->str, &error);
g_string_free (statement_str, TRUE);
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 55118b6..ba30900 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -85,8 +85,6 @@ enum {
static GParamSpec *obj_properties[LAST_PROP];
-#define EPHY_HISTORY_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), EPHY_TYPE_HISTORY_SERVICE,
EphyHistoryServicePrivate))
-
G_DEFINE_TYPE (EphyHistoryService, ephy_history_service, G_TYPE_OBJECT);
static void
@@ -96,11 +94,11 @@ ephy_history_service_set_property (GObject *object, guint property_id, const GVa
switch (property_id) {
case PROP_HISTORY_FILENAME:
- g_free (self->priv->history_filename);
- self->priv->history_filename = g_strdup (g_value_get_string (value));
+ g_free (self->history_filename);
+ self->history_filename = g_strdup (g_value_get_string (value));
break;
case PROP_READ_ONLY:
- self->priv->read_only = g_value_get_boolean (value);
+ self->read_only = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
@@ -114,7 +112,7 @@ ephy_history_service_get_property (GObject *object, guint property_id, GValue *v
EphyHistoryService *self = EPHY_HISTORY_SERVICE (object);
switch (property_id) {
case PROP_HISTORY_FILENAME:
- g_value_set_string (value, self->priv->history_filename);
+ g_value_set_string (value, self->history_filename);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -123,28 +121,28 @@ ephy_history_service_get_property (GObject *object, guint property_id, GValue *v
}
static void
-ephy_history_service_finalize (GObject *self)
+ephy_history_service_finalize (GObject *object)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
+ EphyHistoryService *self = EPHY_HISTORY_SERVICE (object);
- ephy_history_service_quit (EPHY_HISTORY_SERVICE (self), NULL, NULL);
+ ephy_history_service_quit (self, NULL, NULL);
- if (priv->history_thread)
- g_thread_join (priv->history_thread);
+ if (self->history_thread)
+ g_thread_join (self->history_thread);
- g_free (priv->history_filename);
+ g_free (self->history_filename);
- G_OBJECT_CLASS (ephy_history_service_parent_class)->finalize (self);
+ G_OBJECT_CLASS (ephy_history_service_parent_class)->finalize (object);
}
static void
-ephy_history_service_dispose (GObject *self)
+ephy_history_service_dispose (GObject *object)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
+ EphyHistoryService *self = EPHY_HISTORY_SERVICE (object);
- if (priv->queue_urls_visited_id) {
- g_source_remove (priv->queue_urls_visited_id);
- priv->queue_urls_visited_id = 0;
+ if (self->queue_urls_visited_id) {
+ g_source_remove (self->queue_urls_visited_id);
+ self->queue_urls_visited_id = 0;
}
}
@@ -152,7 +150,7 @@ static gboolean
emit_urls_visited (EphyHistoryService *self)
{
g_signal_emit (self, signals[URLS_VISITED], 0);
- self->priv->queue_urls_visited_id = 0;
+ self->queue_urls_visited_id = 0;
return FALSE;
}
@@ -160,10 +158,10 @@ emit_urls_visited (EphyHistoryService *self)
static void
ephy_history_service_queue_urls_visited (EphyHistoryService *self)
{
- if (self->priv->queue_urls_visited_id)
+ if (self->queue_urls_visited_id)
return;
- self->priv->queue_urls_visited_id =
+ self->queue_urls_visited_id =
g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)emit_urls_visited, self, NULL);
}
@@ -261,17 +259,13 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, LAST_PROP, obj_properties);
-
- g_type_class_add_private (gobject_class, sizeof (EphyHistoryServicePrivate));
}
static void
ephy_history_service_init (EphyHistoryService *self)
{
- self->priv = EPHY_HISTORY_SERVICE_GET_PRIVATE (self);
-
- self->priv->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc) run_history_service_thread,
self);
- self->priv->queue = g_async_queue_new ();
+ self->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc) run_history_service_thread, self);
+ self->queue = g_async_queue_new ();
}
EphyHistoryService *
@@ -327,48 +321,44 @@ ephy_history_service_message_free (EphyHistoryServiceMessage *message)
static void
ephy_history_service_send_message (EphyHistoryService *self, EphyHistoryServiceMessage *message)
{
- EphyHistoryServicePrivate *priv = self->priv;
-
- g_async_queue_push_sorted (priv->queue, message, (GCompareDataFunc)sort_messages, NULL);
+ g_async_queue_push_sorted (self->queue, message, (GCompareDataFunc)sort_messages, NULL);
}
static void
ephy_history_service_commit (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = self->priv;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
- if (NULL == priv->history_database)
+ if (NULL == self->history_database)
return;
- if (priv->read_only)
+ if (self->read_only)
return;
- ephy_sqlite_connection_commit_transaction (priv->history_database, &error);
+ ephy_sqlite_connection_commit_transaction (self->history_database, &error);
if (NULL != error) {
g_warning ("Could not commit idle history database transaction: %s", error->message);
g_error_free (error);
}
- ephy_sqlite_connection_begin_transaction (priv->history_database, &error);
+ ephy_sqlite_connection_begin_transaction (self->history_database, &error);
if (NULL != error) {
g_warning ("Could not start long-running history database transaction: %s", error->message);
g_error_free (error);
}
- self->priv->scheduled_to_commit = FALSE;
+ self->scheduled_to_commit = FALSE;
}
static void
ephy_history_service_enable_foreign_keys (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- if (NULL == priv->history_database)
+ if (NULL == self->history_database)
return;
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"PRAGMA foreign_keys = ON", &error);
if (error) {
@@ -380,27 +370,26 @@ ephy_history_service_enable_foreign_keys (EphyHistoryService *self)
static gboolean
ephy_history_service_open_database_connections (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
GError *error = NULL;
- g_assert (priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
- priv->history_database = ephy_sqlite_connection_new ();
- ephy_sqlite_connection_open (priv->history_database, priv->history_filename, &error);
+ self->history_database = ephy_sqlite_connection_new ();
+ ephy_sqlite_connection_open (self->history_database, self->history_filename, &error);
if (error) {
- g_object_unref (priv->history_database);
- priv->history_database = NULL;
- g_warning ("Could not open history database at %s: %s", priv->history_filename, error->message);
+ g_object_unref (self->history_database);
+ self->history_database = NULL;
+ g_warning ("Could not open history database at %s: %s", self->history_filename, error->message);
g_error_free (error);
return FALSE;
}
ephy_history_service_enable_foreign_keys (self);
- if (priv->read_only)
+ if (self->read_only)
return TRUE;
- ephy_sqlite_connection_begin_transaction (priv->history_database, &error);
+ ephy_sqlite_connection_begin_transaction (self->history_database, &error);
if (error) {
g_warning ("Could not begin long running transaction in history database: %s", error->message);
g_error_free (error);
@@ -418,28 +407,25 @@ ephy_history_service_open_database_connections (EphyHistoryService *self)
static void
ephy_history_service_close_database_connections (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
-
- g_assert (priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
- ephy_sqlite_connection_close (priv->history_database);
- g_object_unref (priv->history_database);
- priv->history_database = NULL;
+ ephy_sqlite_connection_close (self->history_database);
+ g_object_unref (self->history_database);
+ self->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)
+ if (NULL == self->history_database)
return;
- if (priv->read_only)
+ if (self->read_only)
return;
- ephy_sqlite_connection_execute (priv->history_database,
+ ephy_sqlite_connection_execute (self->history_database,
"DELETE FROM hosts;", &error);
if (error) {
g_warning ("Couldn't clear history database: %s", error->message);
@@ -450,34 +436,33 @@ ephy_history_service_clear_all (EphyHistoryService *self)
static gboolean
ephy_history_service_is_scheduled_to_quit (EphyHistoryService *self)
{
- return self->priv->scheduled_to_quit;
+ return self->scheduled_to_quit;
}
static gboolean
ephy_history_service_is_scheduled_to_commit (EphyHistoryService *self)
{
- return self->priv->scheduled_to_commit;
+ return self->scheduled_to_commit;
}
void
ephy_history_service_schedule_commit (EphyHistoryService *self)
{
- if (!self->priv->read_only)
- self->priv->scheduled_to_commit = TRUE;
+ if (!self->read_only)
+ self->scheduled_to_commit = TRUE;
}
static gboolean
ephy_history_service_execute_quit (EphyHistoryService *self, gpointer data, gpointer *result)
{
- EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
- g_assert (priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
if (ephy_history_service_is_scheduled_to_commit (self))
ephy_history_service_commit (self);
- g_async_queue_unref (priv->queue);
+ g_async_queue_unref (self->queue);
- self->priv->scheduled_to_quit = TRUE;
+ self->scheduled_to_quit = TRUE;
return FALSE;
}
@@ -485,23 +470,22 @@ ephy_history_service_execute_quit (EphyHistoryService *self, gpointer data, gpoi
static gpointer
run_history_service_thread (EphyHistoryService *self)
{
- EphyHistoryServicePrivate *priv = self->priv;
EphyHistoryServiceMessage *message;
- g_assert (priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
if (ephy_history_service_open_database_connections (self) == FALSE)
return NULL;
do {
- message = g_async_queue_try_pop (priv->queue);
+ message = g_async_queue_try_pop (self->queue);
if (!message) {
/* Schedule commit if needed. */
if (ephy_history_service_is_scheduled_to_commit (self))
ephy_history_service_commit (self);
/* Block the thread until there's data in the queue. */
- message = g_async_queue_pop (priv->queue);
+ message = g_async_queue_pop (self->queue);
}
/* Process item. */
@@ -613,9 +597,9 @@ static gboolean
ephy_history_service_execute_add_visit (EphyHistoryService *self, EphyHistoryPageVisit *visit, gpointer
*result)
{
gboolean success;
- g_assert (self->priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
success = ephy_history_service_execute_add_visit_helper (self, visit);
@@ -626,9 +610,9 @@ static gboolean
ephy_history_service_execute_add_visits (EphyHistoryService *self, GList *visits, gpointer *result)
{
gboolean success = TRUE;
- g_assert (self->priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
while (visits) {
@@ -820,7 +804,7 @@ ephy_history_service_execute_set_url_title (EphyHistoryService *self,
{
char *title = g_strdup (url->title);
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
if (NULL == ephy_history_service_get_url_row (self, NULL, url)) {
@@ -877,7 +861,7 @@ ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self,
double zoom_level;
EphyHistoryHost *host;
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
g_variant_get (variant, "(sd)", &url_string, &zoom_level);
@@ -923,7 +907,7 @@ ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
{
gboolean hidden;
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
hidden = url->hidden;
@@ -969,7 +953,7 @@ ephy_history_service_execute_set_url_thumbnail_time (EphyHistoryService *self,
{
int thumbnail_time;
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
thumbnail_time = url->thumbnail_time;
@@ -1090,7 +1074,7 @@ ephy_history_service_execute_delete_urls (EphyHistoryService *self,
EphyHistoryURL *url;
SignalEmissionContext *ctx;
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
for (l = urls; l != NULL; l = l->next) {
@@ -1129,7 +1113,7 @@ ephy_history_service_execute_delete_host (EphyHistoryService *self,
{
SignalEmissionContext *ctx;
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
ephy_history_service_delete_host_row (self, host);
@@ -1150,7 +1134,7 @@ ephy_history_service_execute_clear (EphyHistoryService *self,
gpointer pointer,
gpointer *result)
{
- if (self->priv->read_only)
+ if (self->read_only)
return FALSE;
ephy_history_service_clear_all (self);
@@ -1250,7 +1234,7 @@ ephy_history_service_process_message (EphyHistoryService *self,
{
EphyHistoryServiceMethod method;
- g_assert (self->priv->history_thread == g_thread_self ());
+ g_assert (self->history_thread == g_thread_self ());
if (g_cancellable_is_cancelled (message->cancellable) &&
!ephy_history_service_message_is_write (message)) {
@@ -1260,7 +1244,7 @@ ephy_history_service_process_message (EphyHistoryService *self,
method = methods[message->type];
message->result = NULL;
- if (message->service->priv->history_database)
+ if (message->service->history_database)
message->success = method (message->service, message->method_argument, &message->result);
else
message->success = FALSE;
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index 48901b6..0436fdc 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -26,32 +26,12 @@
G_BEGIN_DECLS
-/* convenience macros */
-#define EPHY_TYPE_HISTORY_SERVICE (ephy_history_service_get_type())
-#define EPHY_HISTORY_SERVICE(obj)
(G_TYPE_CHECK_INSTANCE_CAST((obj),EPHY_TYPE_HISTORY_SERVICE,EphyHistoryService))
-#define EPHY_HISTORY_SERVICE_CLASS(klass)
(G_TYPE_CHECK_CLASS_CAST((klass),EPHY_TYPE_HISTORY_SERVICE,EphyHistoryServiceClass))
-#define EPHY_IS_HISTORY_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),EPHY_TYPE_HISTORY_SERVICE))
-#define EPHY_IS_HISTORY_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),EPHY_TYPE_HISTORY_SERVICE))
-#define EPHY_HISTORY_SERVICE_GET_CLASS(obj)
(G_TYPE_INSTANCE_GET_CLASS((obj),EPHY_TYPE_HISTORY_SERVICE,EphyHistoryServiceClass))
+#define EPHY_TYPE_HISTORY_SERVICE (ephy_history_service_get_type())
-typedef struct _EphyHistoryService EphyHistoryService;
-typedef struct _EphyHistoryServiceClass EphyHistoryServiceClass;
-typedef struct _EphyHistoryServicePrivate EphyHistoryServicePrivate;
+G_DECLARE_FINAL_TYPE (EphyHistoryService, ephy_history_service, EPHY, HISTORY_SERVICE, GObject)
typedef void (*EphyHistoryJobCallback) (EphyHistoryService *service, gboolean success, gpointer
result_data, gpointer user_data);
-struct _EphyHistoryService {
- GObject parent;
-
- /* private */
- EphyHistoryServicePrivate *priv;
-};
-
-struct _EphyHistoryServiceClass {
- GObjectClass parent_class;
-};
-
-GType ephy_history_service_get_type (void);
EphyHistoryService * ephy_history_service_new (const char *history_filename,
gboolean read_only);
void ephy_history_service_add_visit (EphyHistoryService *self,
EphyHistoryPageVisit *visit, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]