Clementine Adore Mod
 All Classes Namespaces Files Functions Variables Macros Pages
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
AdoreDb Class Reference

This class handles SQLite access to the queue file. More...

#include <adoredb.h>

Inheritance diagram for AdoreDb:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

AdoreDb::AdoreDb ( )
AdoreDb::~AdoreDb ( )

Member Function Documentation

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.

See Also
Open() for field names.
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.

See Also
Open() for field names.
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.

log table structure

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.

Member Data Documentation

QSqlDatabase AdoreDb::db
private
const char * AdoreDb::kFileName = ".C3SAdore.sqlite"
staticprivate

the queue db filename is defined here.

Under Linux, the queue file is stored in ~/.config/Clementine/.C3SAdore.sqlite.

const char * AdoreDb::kLinuxPath = "/.config/Clementine"
staticprivate

under Linux the extra Clementine config path (based on the home directory) is defined here.


The documentation for this class was generated from the following files: