src/hbservers/hbthemeserver/hbthemeserver.cpp
changeset 21 4633027730f5
parent 2 06ff229162e9
child 28 b7da29130b0e
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    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 
       
    26 #include <hbmemoryutils_p.h>
       
    27 
    25 #include "hbthemeserver_p.h"
    28 #include "hbthemeserver_p.h"
    26 #include <QLabel>
       
    27 #include <QDebug>
       
    28 
       
    29 #include "hbthemecommon_p.h"
    29 #include "hbthemecommon_p.h"
    30 #include <hbmemoryutils_p.h>
       
    31 #ifdef Q_OS_SYMBIAN
       
    32 #include "hbthemeserver_symbian_p_p.h"
    30 #include "hbthemeserver_symbian_p_p.h"
    33 #include "hbthemecommon_symbian_p.h"
    31 #include "hbthemecommon_symbian_p.h"
    34 #else
       
    35 #include "hbthemeserver_generic_p_p.h"
       
    36 #endif
       
    37 
    32 
    38 #ifdef THEME_SERVER_TRACES
    33 #include <QDebug>
    39 QLabel *testLabel = 0;
       
    40 #endif
       
    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));
    83     } else {
    62     } else {
    84 #ifdef THEME_SERVER_TRACES
    63 #ifdef THEME_SERVER_TRACES
    85         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
    64         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
    86 #endif
    65 #endif
    87     }
    66     }
    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 
    67 
   102     // Parses the device profiles and device modes and stores in the
    68     // Parses the device profiles and device modes and stores in the
   103     // shared memory.
    69     // shared memory.
   104     HbThemeServerUtils::createDeviceProfileDatabase();
    70     HbThemeServerUtils::createDeviceProfileDatabase();
   105     return success;
    71     return success;
   106 }
    72 }
   107 
    73 
   108 /**
    74 /**
   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
    75  * Destructor
   121  */
    76  */
   122 HbThemeServer::~HbThemeServer()
    77 HbThemeServer::~HbThemeServer()
   123 {
    78 {
   124     stopServer();
       
   125     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
    79     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
   126     if (manager) {
    80     if (manager) {
   127         manager->releaseInstance(HbMemoryManager::SharedMemory);
    81         manager->releaseInstance(HbMemoryManager::SharedMemory);
   128     }
    82     }
   129 }
    83 }