src/hbservers/hbthemeserver/hbthemeserver.cpp
changeset 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbServers module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 #include "hbthemeserver_p.h"
       
    26 #include <QLabel>
       
    27 #include <QDebug>
       
    28 
       
    29 #include "hbthemecommon_p.h"
       
    30 #include <hbmemoryutils_p.h>
       
    31 #ifdef Q_OS_SYMBIAN
       
    32 #include "hbthemeserver_symbian_p_p.h"
       
    33 #include "hbthemecommon_symbian_p.h"
       
    34 #else
       
    35 #include "hbthemeserver_generic_p_p.h"
       
    36 #endif
       
    37 
       
    38 #ifdef THEME_SERVER_TRACES
       
    39 QLabel *testLabel = 0;
       
    40 #endif
       
    41 
       
    42 /**
       
    43  * Constructor
       
    44  */
       
    45 
       
    46 #ifdef Q_OS_SYMBIAN
       
    47 HbThemeServer::HbThemeServer(): themeServer(0)
       
    48 #else
       
    49 HbThemeServer::HbThemeServer(QWidget *parent): QMainWindow(parent), themeServer(0)
       
    50 #endif
       
    51 {
       
    52 #ifndef Q_OS_SYMBIAN
       
    53     statusLabel = new QLabel;
       
    54     statusLabel->setText("Theme Server Started");
       
    55     setCentralWidget(statusLabel);
       
    56     setWindowTitle("Theme Server");
       
    57 #ifdef THEME_SERVER_TRACES
       
    58     testLabel = statusLabel;
       
    59 #endif
       
    60 #endif
       
    61 }
       
    62 
       
    63 /**
       
    64  * startServer
       
    65  */
       
    66 bool HbThemeServer::startServer()
       
    67 {
       
    68     bool success = false;
       
    69     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
       
    70     if (!manager) {
       
    71         return success;
       
    72     }
       
    73 #ifdef Q_OS_SYMBIAN
       
    74     TRAPD(err, themeServer =  HbThemeServerPrivate::NewL(CActive::EPriorityStandard));
       
    75     if (KErrNone != err) {
       
    76         return success;
       
    77     }
       
    78     TRAPD(error, themeServer->StartL(KThemeServerName));
       
    79     if (KErrNone == error) {
       
    80         success = true;
       
    81     } else {
       
    82 #ifdef THEME_SERVER_TRACES
       
    83         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
       
    84 #endif
       
    85     }
       
    86 #else
       
    87     QT_TRY {
       
    88         themeServer = new HbThemeServerPrivate();
       
    89     } QT_CATCH(const std::bad_alloc &) {
       
    90         return success;
       
    91     }
       
    92     success = themeServer->start();
       
    93     if (!success) {
       
    94 #ifdef THEME_SERVER_TRACES
       
    95         qDebug() << Q_FUNC_INFO << "Error Starting SERVER";
       
    96 #endif
       
    97     }
       
    98 #endif
       
    99 
       
   100     // Parses the device profiles and device modes and stores in the
       
   101     // shared memory.
       
   102     HbThemeServerUtils::createDeviceProfileDatabase();
       
   103 
       
   104     //Creates the secondary Cache.
       
   105     HbThemeServerUtils::createSharedCache();
       
   106     return success;
       
   107 }
       
   108 
       
   109 /**
       
   110  * Destructor
       
   111  */
       
   112 HbThemeServer::~HbThemeServer()
       
   113 {
       
   114     delete themeServer;
       
   115     GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory)
       
   116     if (manager) {
       
   117         manager->releaseInstance(HbMemoryManager::SharedMemory);
       
   118     }
       
   119 }