tsdevicedialog/tsdevicedialogplugin/src/tsdevicedialogplugin.cpp
changeset 124 e36b2f4799c0
parent 121 0b3699f6c654
equal deleted inserted replaced
121:0b3699f6c654 124:e36b2f4799c0
    21 #include <QCoreApplication>
    21 #include <QCoreApplication>
    22 #include <QLocale>
    22 #include <QLocale>
    23 #include <QtPlugin>
    23 #include <QtPlugin>
    24 
    24 
    25 #include <QValueSpacePublisher>
    25 #include <QValueSpacePublisher>
    26 #include <QServiceManager>
       
    27 
    26 
    28 #include <HbDeviceDialog>
    27 #include <HbDeviceDialog>
    29 #include <HbMainWindow>
    28 #include <HbMainWindow>
    30 
    29 
    31 #include <tspropertydefs.h>
    30 #include <tspropertydefs.h>
    46 
    45 
    47 namespace
    46 namespace
    48 {
    47 {
    49     const char KTranslationPath[] = "resource/qt/translations";
    48     const char KTranslationPath[] = "resource/qt/translations";
    50     const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0";
    49     const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0";
    51     const char KActivityManaged [] = "com.nokia.qt.activities.ActivityManager";
       
    52 }
    50 }
    53 
    51 
    54 /*!
    52 /*!
    55     Constructor.
    53     Constructor.
    56  */
    54  */
    58     :
    56     :
    59     mModel(0),
    57     mModel(0),
    60     mStorage(0),
    58     mStorage(0),
    61     mTriedToLoadTranslation(false)
    59     mTriedToLoadTranslation(false)
    62 {
    60 {
       
    61     // ensure the visibility property is set to false, so the TaskSwitcher
       
    62     // in case when hbdevicedialogappserver crashes when TS is visible.
       
    63     QValueSpacePublisher visibilityPublisher(TsProperty::KTsPath);
       
    64     visibilityPublisher.setValue(TsProperty::KVisibilityPath, static_cast<int>(false));
       
    65     visibilityPublisher.sync();
    63 }
    66 }
    64 
    67 
    65 TsDeviceDialogPlugin::~TsDeviceDialogPlugin()
    68 TsDeviceDialogPlugin::~TsDeviceDialogPlugin()
    66 {
    69 {
    67     delete mModel;
       
    68 }
    70 }
    69 /*!
    71 /*!
    70     \reimp
    72     \reimp
    71  */
    73  */
    72 bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
    74 bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
   121         }
   123         }
   122 
   124 
   123         // lazy loading of model
   125         // lazy loading of model
   124         if (!mModel) {
   126         if (!mModel) {
   125             mStorage = new TsTaskMonitor(this);
   127             mStorage = new TsTaskMonitor(this);
   126 
   128             mModel = new TsModel(*mStorage, this);
   127             QServiceManager serviceManager;
       
   128             QObject *activityManager(serviceManager.loadInterface(KActivityManaged));
       
   129             if (activityManager) {
       
   130                 activityManager->setParent(this); //make it autodestructed
       
   131             } else {
       
   132                 activityManager = this; //activity plugin is not present. provide invalid instance because its not critical functionality.
       
   133                 //QMetaObject::invokeMethod is safe to use in such a case.
       
   134             }
       
   135             mModel = new TsModel(*mStorage, *activityManager);
       
   136         }
   129         }
   137 
   130 
   138         // ensure the dismiss request property is set to false
   131         // ensure the dismiss request property is set to false
   139 
   132 
   140         QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath);
   133         QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath);