|
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 |
|
26 #include <QApplication> |
|
27 #include <QLibrary> |
|
28 #include <QDebug> |
|
29 |
|
30 #include "hbthemeserver_p.h" |
|
31 #include "hbthemecommon_p.h" |
|
32 #if defined (Q_OS_SYMBIAN) |
|
33 #include <eikenv.h> |
|
34 #include <apgwgnam.h> |
|
35 #endif |
|
36 #include <qtsingleapplication.h> |
|
37 #include <QWindowsStyle> |
|
38 |
|
39 static const QLatin1String RESOURCE_LIB_NAME("HbCore"); |
|
40 static const QLatin1String TEST_RESOURCE_LIB_NAME("HbTestResources"); |
|
41 static const QLatin1String WIN32_DEBUG_SUFFIX("d"); |
|
42 static const QLatin1String MAC_DEBUG_SUFFIX("_debug"); |
|
43 |
|
44 /* |
|
45 This function loads library which keeps resources of default theme |
|
46 */ |
|
47 bool loadResourceLibrary(QString resourceLibName) |
|
48 { |
|
49 bool loadSuccess; |
|
50 // To load resources embedded in hb library |
|
51 QLibrary hbLib(resourceLibName); |
|
52 loadSuccess = hbLib.load(); |
|
53 |
|
54 if ( !loadSuccess ) { |
|
55 // Library may not be loaded, if it was built in debug mode and the name in debug mode is |
|
56 // different, change the name to debug version in that scenario |
|
57 #ifdef Q_OS_WIN32 |
|
58 resourceLibName += WIN32_DEBUG_SUFFIX; |
|
59 #elif defined(Q_OS_MAC) |
|
60 resourceLibName += MAC_DEBUG_SUFFIX; |
|
61 #endif |
|
62 // On symbian library name in debug mode is same as that in release mode, |
|
63 // so no need to do anything for that |
|
64 hbLib.setFileName(resourceLibName); |
|
65 loadSuccess = hbLib.load(); |
|
66 } |
|
67 #ifdef THEME_SERVER_TRACES |
|
68 if (loadSuccess) { |
|
69 qDebug() << "Loaded library " << resourceLibName; |
|
70 } |
|
71 else { |
|
72 qDebug() << "Could not load library " << resourceLibName; |
|
73 } |
|
74 #endif // THEME_SERVER_TRACES |
|
75 |
|
76 return loadSuccess; |
|
77 } |
|
78 |
|
79 int main(int argc, char *argv[]) |
|
80 { |
|
81 #ifdef QT_DEBUG |
|
82 //temporary solution until Hb specific style is ready |
|
83 QApplication::setStyle( new QWindowsStyle ); |
|
84 #endif |
|
85 QtSingleApplication app( argc, argv ); |
|
86 if (app.sendMessage("Am Alive")) |
|
87 return 0; |
|
88 |
|
89 loadResourceLibrary(RESOURCE_LIB_NAME); |
|
90 #ifdef BUILD_HB_INTERNAL |
|
91 loadResourceLibrary(TEST_RESOURCE_LIB_NAME); |
|
92 #endif |
|
93 HbThemeServer server; |
|
94 bool success = server.startServer(); |
|
95 if ( !success ) { |
|
96 return -1; |
|
97 } |
|
98 |
|
99 #if defined (Q_OS_SYMBIAN) |
|
100 CEikonEnv * env = CEikonEnv::Static(); |
|
101 if ( env ) { |
|
102 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
|
103 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
|
104 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
|
105 wgName->SetCaptionL(_L("HbThemeServer")); |
|
106 wgName->SetAppUid(KNullUid); |
|
107 RWindowGroup &rootWindowGroup = env->RootWin(); |
|
108 wgName->SetWindowGroupName(rootWindowGroup); |
|
109 rootWindowGroup.SetOrdinalPosition(-1, ECoeWinPriorityNormal); //move to background. |
|
110 CleanupStack::PopAndDestroy(); |
|
111 } |
|
112 #elif defined(QT_DEBUG) |
|
113 server.showMinimized(); |
|
114 #endif |
|
115 |
|
116 return app.exec(); |
|
117 } |
|
118 |