static EphyHistoryURL * create_url_from_statement (EphySQLiteStatement *statement) { EphyHistoryURL *url = ephy_history_url_new (ephy_sqlite_statement_get_column_as_string (statement, 1), ephy_sqlite_statement_get_column_as_string (statement, 2), ephy_sqlite_statement_get_column_as_int (statement, 3), ephy_sqlite_statement_get_column_as_int (statement, 4), ephy_sqlite_statement_get_column_as_int64 (statement, 5)); url->id = ephy_sqlite_statement_get_column_as_int (statement, 0); url->host = ephy_history_host_new (NULL, NULL, 0, 0.0); url->hidden = ephy_sqlite_statement_get_column_as_int (statement, 6); url->host->id = ephy_sqlite_statement_get_column_as_int (statement, 7); url->sync_id = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 8)); return url; }
void ephy_history_service_set_url_title (EphyHistoryService *self, const char *orig_url, const char *title, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data) { EphyHistoryURL *url; EphyHistoryServiceMessage *message; g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self)); g_return_if_fail (orig_url != NULL); url = ephy_history_url_new (orig_url, title, 0, 0, 0); message = ephy_history_service_message_new (self, SET_URL_TITLE, url, (GDestroyNotify) ephy_history_url_free, cancellable, callback, user_data); ephy_history_service_send_message (self, message); }
EphyHistoryURL * ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_string, EphyHistoryURL *url) { EphySQLiteStatement *statement = NULL; GError *error = 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; g_assert (url_string || (url != NULL && url->id != -1)); if (url != NULL && url->id != -1) { statement = ephy_sqlite_connection_create_statement (self->history_database, "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, sync_id FROM urls " "WHERE id=?", &error); } else { statement = ephy_sqlite_connection_create_statement (self->history_database, "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview, sync_id FROM urls " "WHERE url=?", &error); } if (error) { g_warning ("Could not build urls table query statement: %s", error->message); g_error_free (error); return NULL; } if (url != NULL && url->id != -1) { ephy_sqlite_statement_bind_int (statement, 0, url->id, &error); } else { ephy_sqlite_statement_bind_string (statement, 0, url_string, &error); } if (error) { g_warning ("Could not build urls table query statement: %s", error->message); g_error_free (error); g_object_unref (statement); return NULL; } if (ephy_sqlite_statement_step (statement, &error) == FALSE) { g_object_unref (statement); return NULL; } if (url == NULL) { url = ephy_history_url_new (NULL, NULL, 0, 0, 0); } url->id = ephy_sqlite_statement_get_column_as_int (statement, 0); /* Only get the URL and page title if we don't know it yet, as the version in the history could be outdated. */ if (url->url == NULL) url->url = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 1)); if (url->title == NULL) url->title = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 2)); url->visit_count = ephy_sqlite_statement_get_column_as_int (statement, 3), url->typed_count = ephy_sqlite_statement_get_column_as_int (statement, 4), url->last_visit_time = ephy_sqlite_statement_get_column_as_int64 (statement, 5); url->hidden = ephy_sqlite_statement_get_column_as_int (statement, 6); url->sync_id = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 7)); g_object_unref (statement); return url; }
EphyHistoryPageVisit * ephy_history_page_visit_new (const char *url, gint64 visit_time, EphyHistoryPageVisitType visit_type) { return ephy_history_page_visit_new_with_url (ephy_history_url_new (url, url, 0, 0, 0), visit_time, visit_type); }