This class handles SQLite access to the queue file. More...
#include <adoredb.h>
Public Member Functions | |
AdoreDb () | |
~AdoreDb () | |
bool | Open () |
Opens/Creates the SQlite queue file. More... | |
bool | Delete () |
This is to delete the whole queue file. More... | |
QSqlError | LastError () |
Retrieves the last occured SQLite error. More... | |
bool | Add (QStringList &names, QStringList &values) |
Adds a new record to the log table of the queue db. More... | |
bool | GetQueued (QStringList &names, QStringList &values) |
Gets the next record not marked as TYPE_SUCCESS. More... | |
Private Attributes | |
QSqlDatabase | db |
Static Private Attributes | |
static const char * | kFileName = ".C3SAdore.sqlite" |
the queue db filename is defined here. More... | |
static const char * | kLinuxPath = "/.config/Clementine" |
under Linux the extra Clementine config path (based on the home directory) is defined here. More... | |
This class handles SQLite access to the queue file.
The queue is used e.g. when no internet access is possible and utilizations have to be stored until they can be transferred when an internet connection is available again. All member functions except LastError()
return true
upon success.
AdoreDb::AdoreDb | ( | ) |
AdoreDb::~AdoreDb | ( | ) |
bool AdoreDb::Add | ( | QStringList & | names, |
QStringList & | values | ||
) |
Adds a new record to the log table of the queue db.
If a record with the same time_played
already exists, the record is updated, otherwise a new record it being created.
Parameters: The field names and values are passed as references to two QStringList
objects.
bool AdoreDb::Delete | ( | ) |
This is to delete the whole queue file.
Currently the file isn't be deleted if all utilzations have been transferred for debugging purposes. This should be done when the first stable version is released.
bool AdoreDb::GetQueued | ( | QStringList & | names, |
QStringList & | values | ||
) |
Gets the next record not marked as TYPE_SUCCESS.
Parameters: The field names and values are passed as references to two QStringList
objects and being filled if a record was found. If no records are found, false
is being returned.
QSqlError AdoreDb::LastError | ( | ) |
Retrieves the last occured SQLite error.
If opening database has failed user can query the error description by QSqlError::text()
bool AdoreDb::Open | ( | ) |
Opens/Creates the SQlite queue file.
There is a versioning mechanism included along with the version entry in the config table. You need to maintain changes to the database structure in both, the CREATE SQL statement and the updater at the end of the function.
Field Name | Type | Description/Note |
---|---|---|
time_played | TEXT PRIMARY KEY | time a song was played |
time_submitted | TEXT | time a song was submitted |
artist | TEXT | artist extracted from metadata |
title | TEXT | track title extracted from metadata |
release | TEXT | album name extracted from metadata |
track_number | TEXT | position of the track in the album |
duration | TEXT | duration extracted from metadata |
fingerprinting_algorithm | TEXT | echoprint or chromaprint |
fingerprinting_version | TEXT | currently echoprint v4.12 is implemented |
fingerprint | TEXT | string, base64-encoded |
status | TEXT | return string from the server, e.g. 'OK' |
type | INTEGER | abstract code analog to http error codes/100 |
type
is planned to control the processing of queued utilization records. Possible values are TYPE_UNKNOWN, TYPE_DELAY, TYPE_SUCCESS, TYPE_WARNING, TYPE_ERROR.
|
private |
|
staticprivate |
the queue db filename is defined here.
Under Linux, the queue file is stored in ~/.config/Clementine/.C3SAdore.sqlite.
|
staticprivate |
under Linux the extra Clementine config path (based on the home directory) is defined here.