• Modules
  • DbManager
  • Contents

    DbManager Class Reference

    The DbManager class is a singleton class to read and write transfers database. More...

     #include <DbManager>

    Public Functions

    ~DbManager ()
    QStringList callback ( int key ) const
    bool callbackMethods ( int key, QString & cancelMethod, QString & restartMethod ) const
    bool clearTransfers ()
    int createCallbackEntry ( int key, const QString & service, const QString & path, const QString & interface, const QString & cancelMethod, const QString & restartMethod )
    int createMetadataEntry ( int key, const QString & title, const QString & description )
    int createTransferEntry ( MediaItem * mediaItem )
    MediaItem * mediaItem ( int key ) const
    bool removeTransfer ( int key )
    TransferEngineData::TransferStatus transferStatus ( int key ) const
    TransferEngineData::TransferType transferType ( int key ) const
    QList<TransferDBRecord> transfers () const
    bool updateProgress ( int key, qreal progress )
    bool updateTransferStatus ( int key, TransferEngineData::TransferStatus status )

    Static Public Members

    DbManager * instance ()

    Detailed Description

    The DbManager class is a singleton class to read and write transfers database.

    DbManager class takes care of reading and writing transfer database used by Nemo Transfer Engine. It's a singleton class and it can be instantiated using DbManager::instance() method.

    Member Function Documentation

    DbManager::~DbManager ()

    Destructor.

    QStringList DbManager::callback ( int key ) const

    Get a DBus callback interface and method for the transfer with key. If there is no callback for the key then an empty QStringList is returned.

    In a case there is a DBus callback, then QStringList contains the following items:

    bool DbManager::callbackMethods ( int key, QString & cancelMethod, QString & restartMethod ) const

    Get the callback method names for the transfer with key. The method names are set to the output arguments cancelMethod and restartMethod.

    This method returns true on success, false on failure.

    bool DbManager::clearTransfers ()

    Clear all finished, canceled or failed transfers from the database.

    This method returns true on success, false on failure.

    int DbManager::createCallbackEntry ( int key, const QString & service, const QString & path, const QString & interface, const QString & cancelMethod, const QString & restartMethod )

    Create a callback entry to the callback table for the existing transfer with a key.

    The callback is a dbus interface so it must contain the following attributes:

    This method returns a key of the created callback record in a callback table or -1 on failure.

    NOTE: Deleting the record from the transfer which has a key, also deletes related callback entry.

    int DbManager::createMetadataEntry ( int key, const QString & title, const QString & description )

    Create a metadata entry for the existing transfer with key. Metadata can contain only title and/or \description.

    Metadata entry will be created to the metadata table. Argument key must point to the existing entry in transfers table.

    This method returns a key of the created record in metadata table or -1 on failure.

    NOTE: Deleting the record from the transfer which has a key, also deletes related metadata entry.

    int DbManager::createTransferEntry ( MediaItem * mediaItem )

    Create a transfer entry to the transfers table bsaed on mediaItem content.

    MediaItem instance contains all the required information for the single Upload, Download or a Sync item. Based on this information, DbManager creates a record to the transfers table, but also to the callback and metadata tables if these are defined.

    This method returns a key of the created transfer or -1 on failure.

    See also MediaItem.

    DbManager * DbManager::instance () [static]

    Return a singleton instance of this DbManager. Note that caller is NOT responsible of deleting the instance. It will be deleted automatically when application stack is cleaned.

    MediaItem * DbManager::mediaItem ( int key ) const

    Returns a MediaItem instance from the transfer data with a key.

    bool DbManager::removeTransfer ( int key )

    Remove an existing transfer with a key from the transfers table. If this transfer has metadata or callback defined, they will be removed too.

    This method returns true on success, false on failure.

    TransferEngineData::TransferStatus DbManager::transferStatus ( int key ) const

    Returns the transfer status of the transfer with key. In a case of error the TransferEngineData::Unknown is returned.

    TransferEngineData::TransferType DbManager::transferType ( int key ) const

    Returns the transfer type e.g. Sync, Download or Upload of the transfer with a key.

    If there is no transfer record with key or error occurs, this method returns TransferEngineData::Undefined.

    QList<TransferDBRecord> DbManager::transfers () const

    Returns all the transfers from the database. This method doesn't fetch all the fields from all the tables, instead it returns what is required to fill fields in TransferDBRecord class.

    bool DbManager::updateProgress ( int key, qreal progress )

    Update a transfer progress of the existing transfer with key.

    This method returns true on success, false on failure.

    bool DbManager::updateTransferStatus ( int key, TransferEngineData::TransferStatus status )

    Update a transfer status of the existing transfer with key. Changing the status updates the timestamp too.

    This method returns true on success, false on failure.