Home · All Namespaces · All Classes
Classes | Signals | Public Member Functions

ApplicationPackageMonitor Class Reference

#include <applicationpackagemonitor.h>

Inheritance diagram for ApplicationPackageMonitor:
Inheritance graph
[legend]
Collaboration diagram for ApplicationPackageMonitor:
Collaboration graph
[legend]

List of all members.

Classes

class  ExtraDirWatcher
class  PackageProperties
 Stores package properties.

Signals

void downloadProgress (const QString &packageExtraPath, int bytesLoaded, int bytesTotal)
void installProgress (const QString &packageExtraPath, int percentage)
void operationSuccess (const QString &packageExtraPath)
void operationError (const QString &packageExtraPath, const QString &error)
void installExtraEntryRemoved (const QString &desktopEntryPath)

Public Member Functions

 ApplicationPackageMonitor ()
virtual ~ApplicationPackageMonitor ()
void updatePackageStates ()

Detailed Description

ApplicationPackageMonitor listens dbus signals from Package Manager and watches installer-extra folder to receive info on package installation states and signaling relevant changes.

Some events may be communicated through both dbus signal and changes in desktop entries. This can lead to same package having multiple signals for same event (like progress error). Signal listener is responsible for handling such cases.

Definition at line 37 of file applicationpackagemonitor.h.


Constructor & Destructor Documentation

ApplicationPackageMonitor::ApplicationPackageMonitor (  ) 

Initializes ApplicationPackageMonitor object. Connects dbus signals to slots.

Definition at line 64 of file applicationpackagemonitor.cpp.

: con(QDBusConnection::systemBus())
{
    con.connect(QString(),PACKAGE_MANAGER_DBUS_PATH, PACKAGE_MANAGER_DBUS_INTERFACE, "download_progress",
                    this, SLOT(packageDownloadProgress(const QString&, const QString&, const QString&, int, int)));
    con.connect(QString(),PACKAGE_MANAGER_DBUS_PATH, PACKAGE_MANAGER_DBUS_INTERFACE, "operation_started",
                    this, SLOT(packageOperationStarted(const QString&, const QString&, const QString&)));
    con.connect(QString(),PACKAGE_MANAGER_DBUS_PATH, PACKAGE_MANAGER_DBUS_INTERFACE, "operation_progress",
                    this, SLOT(packageOperationProgress(const QString&, const QString &, const QString&, int)));
    con.connect(QString(),PACKAGE_MANAGER_DBUS_PATH, PACKAGE_MANAGER_DBUS_INTERFACE, "operation_complete",
                    this, SLOT(packageOperationComplete(const QString&, const QString&, const QString&, const QString&, bool)));

    QString configPath = QDir::homePath() + CONFIG_PATH;

    if (!QDir::root().exists(configPath)) {
        QDir::root().mkpath(configPath);
    }

    QString dataStoreFileName = configPath + "/applicationpackage.data";

    dataStore = new MFileDataStore(dataStoreFileName);

    // ExtraDirWatcher takes ownership of dataStore
    extraDirWatcher = QSharedPointer<ExtraDirWatcher>(new ExtraDirWatcher(dataStore, APPLICATIONS_DIRECTORY+INSTALLER_EXTRA));

    connect(extraDirWatcher.data(), SIGNAL(desktopEntryAdded(QString)), this, SLOT(updatePackageState(QString)), Qt::UniqueConnection);
    connect(extraDirWatcher.data(), SIGNAL(desktopEntryChanged(QString)), this, SLOT(updatePackageState(QString)), Qt::UniqueConnection);
    connect(extraDirWatcher.data(), SIGNAL(desktopEntryRemoved(QString)), this, SLOT(packageRemoved(QString)), Qt::UniqueConnection);
}

ApplicationPackageMonitor::~ApplicationPackageMonitor (  )  [virtual]

Destroys ApplicationPackageMonitor.

Definition at line 94 of file applicationpackagemonitor.cpp.

{
}


Member Function Documentation

void ApplicationPackageMonitor::downloadProgress ( const QString &  packageExtraPath,
int  bytesLoaded,
int  bytesTotal 
) [signal]

Status of download progress of package being installed.

Parameters:
desktopEntryName is name of desktop entry file.
bytesLoaded is current amount of bytes downloaded.
bytesTotal is size of downloading package in bytes.
void ApplicationPackageMonitor::installExtraEntryRemoved ( const QString &  desktopEntryPath  )  [signal]

Notifes about removal of install extra desktop entry.

Parameters:
desktopEntryPath path of removed install extra file.
void ApplicationPackageMonitor::installProgress ( const QString &  packageExtraPath,
int  percentage 
) [signal]

Status of install progress of package being installed.

Parameters:
desktopEntryName is name of preliminary desktop entry file under installer-extra/.
percentage is install completion level.
void ApplicationPackageMonitor::operationError ( const QString &  packageExtraPath,
const QString &  error 
) [signal]

Notifies about error in installing and downloading package.

Parameters:
desktopEntryName is name of preliminary desktop entry file under installer-extra/.
error is string format description of error occured.
void ApplicationPackageMonitor::operationSuccess ( const QString &  packageExtraPath  )  [signal]

Notifies about success in installing a package.

Parameters:
desktopEntryName is name of the installed desktop entry file.
void ApplicationPackageMonitor::updatePackageStates (  ) 

Emit's state signals for packages in relevat states.

(eg. emits operationError() for all the packages in 'broken' state)

Definition at line 119 of file applicationpackagemonitor.cpp.

{
    QStringList keyList(dataStore->allKeys());

    foreach (QString key, keyList) {
        if (key.contains(PACKAGE_PREFIX)) {
            QString desktopEntryPath = dataStore->value(key).toString();
            QString state = dataStore->value(DESKTOPENTRY_PREFIX + desktopEntryPath).toString();
            if (state == PACKAGE_STATE_BROKEN) {
                // emit operation error for a broken package
                emit operationError(desktopEntryPath, QString());
            } else if(state == PACKAGE_STATE_DOWNLOADING) {
                emit downloadProgress(desktopEntryPath, 0, 0);
            } else if(state == PACKAGE_STATE_INSTALLING) {
                emit installProgress(desktopEntryPath, 0);
            }
        }
    }
}

Here is the call graph for this function:


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

Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:20:42
Doxygen 1.7.1
MeeGo Touch