src/hbservers/hbthemeserver/hbthemeserver.cpp
changeset 34 ed14f46c0e55
parent 2 06ff229162e9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
       
    25 
    25 #include "hbthemeserver_p.h"
    26 #include "hbthemeserver_p.h"
    26 #include <QLabel>
       
    27 #include <QDebug>
       
    28 
       
    29 #include "hbthemecommon_p.h"
    27 #include "hbthemecommon_p.h"
    30 #include <hbmemoryutils_p.h>
       
    31 #ifdef Q_OS_SYMBIAN
       
    32 #include "hbthemeserver_symbian_p_p.h"
    28 #include "hbthemeserver_symbian_p_p.h"
    33 #include "hbthemecommon_symbian_p.h"
    29 #include "hbthemecommon_symbian_p.h"
    34 #else
       
    35 #include "hbthemeserver_generic_p_p.h"
       
    36 #endif
       
    37 
    30 
    38 #ifdef THEME_SERVER_TRACES
    31 #include <hbmemoryutils_p.h>
    39 QLabel *testLabel = 0;
    32 
    40 #endif
    33 #include <QDebug>
    41 
    34 
    42 /**
    35 /**
    43  * Constructor
    36  * Constructor
    44  */
    37  */
    45 
    38 
    46 HbThemeServer::HbThemeServer(QWidget *parent) :
    39 HbThemeServer::HbThemeServer() :
    47 #ifndef Q_OS_SYMBIAN
       
    48     QMainWindow(parent),
       
    49 #endif
       
    50     themeServer(0)
    40     themeServer(0)
    51 {
    41 {
    52 #ifdef Q_OS_SYMBIAN
       
    53     Q_UNUSED(parent);
       
    54 #else
       
    55     statusLabel = new QLabel;
       
    56     statusLabel->setText("Theme Server Started");
       
    57     setCentralWidget(statusLabel);
       
    58     setWindowTitle("Theme Server");
       
    59 #ifdef THEME_SERVER_TRACES
       
    60     testLabel = statusLabel;
       
    61 #endif
       
    62 #endif
       
    63 }
    42 }
    64 
    43 
    65 /**
    44 /**
    66  * startServer
    45  * startServer
    67  */
    46  */
    70     bool success = false;
    49     bool success = false;
    71     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
    50     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
    72     if (!manager) {
    51     if (!manager) {
    73         return success;
    52         return success;
    74     }
    53     }
    75 #ifdef Q_OS_SYMBIAN
    54 
    76     TRAPD(err, themeServer =  HbThemeServerPrivate::NewL(CActive::EPriorityStandard));
    55     TRAPD(err, themeServer =  HbThemeServerPrivate::NewL(CActive::EPriorityStandard));
    77     if (KErrNone != err) {
    56     if (KErrNone != err) {
    78         return success;
    57         return success;
    79     }
    58     }
    80     TRAPD(error, themeServer->StartL(KThemeServerName));
    59     TRAPD(error, themeServer->StartL(KThemeServerName));
    81     if (KErrNone == error) {
    60     if (KErrNone == error) {
    82         success = true;
    61         success = true;
    83     } else {
    62     } else {
    84 #ifdef THEME_SERVER_TRACES
    63         THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "Error Starting SERVER";
    85         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
       
    86 #endif
       
    87     }
    64     }
    88 #else
       
    89     QT_TRY {
       
    90         themeServer = new HbThemeServerPrivate();
       
    91     } QT_CATCH(const std::bad_alloc &) {
       
    92         return success;
       
    93     }
       
    94     success = themeServer->start();
       
    95     if (!success) {
       
    96 #ifdef THEME_SERVER_TRACES
       
    97         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
       
    98 #endif
       
    99     }
       
   100 #endif
       
   101 
    65 
   102     // Parses the device profiles and device modes and stores in the
    66     // Parses the device profiles and device modes and stores in the
   103     // shared memory.
    67     // shared memory.
   104     HbThemeServerUtils::createDeviceProfileDatabase();
    68     HbThemeServerUtils::createDeviceProfileDatabase();
   105     return success;
    69     return success;
   106 }
    70 }
   107 
    71 
   108 /**
    72 /**
   109  * stopServer
       
   110  */
       
   111 void HbThemeServer::stopServer()
       
   112 {
       
   113 #ifndef Q_OS_SYMBIAN
       
   114     delete themeServer;
       
   115     themeServer = 0;
       
   116 #endif // Q_OS_SYMBIAN
       
   117 }
       
   118 
       
   119 /**
       
   120  * Destructor
    73  * Destructor
   121  */
    74  */
   122 HbThemeServer::~HbThemeServer()
    75 HbThemeServer::~HbThemeServer()
   123 {
    76 {
   124     stopServer();
       
   125     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
    77     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
   126     if (manager) {
    78     if (manager) {
   127         manager->releaseInstance(HbMemoryManager::SharedMemory);
    79         manager->releaseInstance(HbMemoryManager::SharedMemory);
   128     }
    80     }
   129 }
    81 }