src/hbcore/activity/hbactivitymanager.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    30 #include <QLibrary>
    30 #include <QLibrary>
    31 #include <QDir>
    31 #include <QDir>
    32 
    32 
    33 #include "hbmainwindow.h"
    33 #include "hbmainwindow.h"
    34 #include "hbinstance.h"
    34 #include "hbinstance.h"
    35 #include "hbactivityplugininterface_p.h"
    35 #include "hbactivityplugininterface_r.h"
    36 
    36 
    37 /*!
    37 /*!
    38     @stable
    38     @stable
    39     @hbcore
    39     @hbcore
    40     \class HbActivityManager
    40     \class HbActivityManager
    41     \brief HbActivityManager is an access point for Activities features.
    41     \brief HbActivityManager is an access point for Activities features.
    42     
    42 
    43     Activities can be described as stored application states (for example bookmarks
    43     Activities can be described as stored application states (for example bookmarks
    44     in web browser) or actions that can be performed using application (play next
    44     in web browser) or actions that can be performed using application (play next
    45     song, start new game).
    45     song, start new game).
    46     
    46 
    47     The HbActivityManager class allows to use Activities features in Hb application.
    47     The HbActivityManager class allows to use Activities features in Hb application.
    48     It can be used to access, add, remove and modify activities. It also notifies the
    48     It can be used to access, add, remove and modify activities. It also notifies the
    49     application about activity change requests from other applications.
    49     application about activity change requests from other applications.
    50 */
    50 */
    51 
    51 
    67 \internal
    67 \internal
    68 */
    68 */
    69 HbActivityPluginInterface *HbActivityManagerPrivate::activityPlugin() const
    69 HbActivityPluginInterface *HbActivityManagerPrivate::activityPlugin() const
    70 {
    70 {
    71     if (!mActivityPlugin) {
    71     if (!mActivityPlugin) {
    72         foreach (const QString &path, QCoreApplication::libraryPaths()) {
    72         foreach(const QString & path, QCoreApplication::libraryPaths()) {
    73             QString pluginPath;
    73             QString pluginPath;
    74             QString libPath = QDir(path).filePath(QLatin1String("hbactivityplugin"));
    74             QString libPath = QDir(path).filePath(QLatin1String("hbactivityplugin"));
    75 #ifdef Q_OS_SYMBIAN
    75 #ifdef Q_OS_SYMBIAN
    76             libPath += QLatin1String(".qtplugin");
    76             libPath += QLatin1String(".qtplugin");
    77             QLibrary library(libPath);           
    77             QLibrary library(libPath);
    78             if (QFile::exists(libPath) && library.load()) {
    78             if (QFile::exists(libPath) && library.load()) {
    79                 library.unload();
    79                 library.unload();
    80                 pluginPath = libPath;
    80                 pluginPath = libPath;
    81             }
    81             }
    82 #else
    82 #else
    83             QLibrary library(libPath);           
    83             QLibrary library(libPath);
    84             if (library.load()) {
    84             if (library.load()) {
    85                 library.unload();
    85                 library.unload();
    86                 pluginPath = library.fileName();
    86                 pluginPath = library.fileName();
    87             }     
    87             }
    88 #endif      
    88 #endif
    89             QPluginLoader loader(pluginPath);
    89             QPluginLoader loader(pluginPath);
    90             QObject *pluginInstance = loader.instance();
    90             QObject *pluginInstance = loader.instance();
    91             if (pluginInstance) {
    91             if (pluginInstance) {
    92                 mActivityPlugin = qobject_cast<HbActivityPluginInterface*>(pluginInstance);
    92                 mActivityPlugin = qobject_cast<HbActivityPluginInterface *>(pluginInstance);
    93                 if (mActivityPlugin) {
    93                 if (mActivityPlugin) {
    94                     q->connect(pluginInstance, SIGNAL(activityRequested(QString)), q, SIGNAL(activityRequested(QString)));
    94                     q->connect(pluginInstance, SIGNAL(activityRequested(QString)), q, SIGNAL(activityRequested(QString)));
    95                 } else {
    95                 } else {
    96 #if defined(Q_OS_SYMBIAN)
    96 #if defined(Q_OS_SYMBIAN)
    97                     qWarning("Cannot load activity plugin. Features related to activities won't be available.");
    97                     qWarning("Cannot load activity plugin. Features related to activities won't be available.");
   215 }
   215 }
   216 
   216 
   217 /*!
   217 /*!
   218     Allows to save activity.
   218     Allows to save activity.
   219     \a activityId. Activity name used as identifier of activities
   219     \a activityId. Activity name used as identifier of activities
   220     \a data. Activity data that should be stored. It will allow application to restore its state later 
   220     \a data. Activity data that should be stored. It will allow application to restore its state later
   221     \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
   221     \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
   222     Returns true if activity was succesfully saved, otherwise returns false.
   222     Returns true if activity was successfully saved, otherwise returns false.
   223  */
   223  */
   224 bool HbActivityManager::addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   224 bool HbActivityManager::addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   225 {
   225 {
   226     Q_D(HbActivityManager);
   226     Q_D(HbActivityManager);
   227     return d->addActivity(activityId, data, parameters);
   227     return d->addActivity(activityId, data, parameters);
   228 }
   228 }
   229 
   229 
   230 /*!
   230 /*!
   231     Allows to delete activity.
   231     Allows to delete activity.
   232     \a activityId. Activity name used as identifier of activities
   232     \a activityId. Activity name used as identifier of activities
   233     Returns true if activity was succesfully deleted, otherwise returns false.
   233     Returns true if activity was successfully deleted, otherwise returns false.
   234  */
   234  */
   235 bool HbActivityManager::removeActivity(const QString &activityId)
   235 bool HbActivityManager::removeActivity(const QString &activityId)
   236 {
   236 {
   237     Q_D(HbActivityManager);
   237     Q_D(HbActivityManager);
   238     return d->removeActivity(activityId);
   238     return d->removeActivity(activityId);
   239 }
   239 }
   240 
   240 
   241 /*!
   241 /*!
   242     Allows to update saved activity.
   242     Allows to update saved activity.
   243     \a activityId. Activity name used as identifier of activities
   243     \a activityId. Activity name used as identifier of activities
   244     \a data. Activity data that should be stored. It will allow application to restore its state later 
   244     \a data. Activity data that should be stored. It will allow application to restore its state later
   245     \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
   245     \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
   246     Returns true if activity was succesfully updated, otherwise returns false.
   246     Returns true if activity was successfully updated, otherwise returns false.
   247  */
   247  */
   248 bool HbActivityManager::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   248 bool HbActivityManager::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   249 {
   249 {
   250     Q_D(HbActivityManager);
   250     Q_D(HbActivityManager);
   251     return d->updateActivity(activityId, data, parameters);
   251     return d->updateActivity(activityId, data, parameters);
   270 }
   270 }
   271 
   271 
   272 /*!
   272 /*!
   273     Subscribes to activity manager
   273     Subscribes to activity manager
   274  */
   274  */
   275 bool HbActivityManager::waitActivity() 
   275 bool HbActivityManager::waitActivity()
   276 {
   276 {
   277     Q_D(HbActivityManager);
   277     Q_D(HbActivityManager);
   278     return d->waitActivity();
   278     return d->waitActivity();
   279 }
   279 }
   280 
   280