46 |
47 |
47 bool HbThemeServerApplication::Options::help = false; |
48 bool HbThemeServerApplication::Options::help = false; |
48 bool HbThemeServerApplication::Options::start = false; |
49 bool HbThemeServerApplication::Options::start = false; |
49 bool HbThemeServerApplication::Options::stop = false; |
50 bool HbThemeServerApplication::Options::stop = false; |
50 bool HbThemeServerApplication::Options::persistent = false; |
51 bool HbThemeServerApplication::Options::persistent = false; |
51 QString HbThemeServerApplication::Options::error = QString(); |
52 QString HbThemeServerApplication::Options::error; |
52 |
53 |
53 HbThemeServerApplication::HbThemeServerApplication(int &argc, char *argv[]) : |
54 HbThemeServerApplication::HbThemeServerApplication(int &argc, char *argv[]) : |
54 QtSingleApplication(argc, argv), server(0) |
55 QtSingleApplication(argc, argv), server(0) |
55 { |
56 { |
56 setApplicationName(APP_NAME); |
57 setApplicationName(APP_NAME); |
57 |
58 |
58 #ifdef QT_DEBUG |
59 #ifdef QT_DEBUG |
59 //temporary solution until Hb specific style is ready |
60 //temporary solution until Hb specific style is ready |
60 setStyle(new QWindowsStyle); |
61 setStyle(new QWindowsStyle); |
61 #endif // QT_DEBUG |
62 #endif // QT_DEBUG |
62 |
|
63 #if QT_VERSION >= 0x040601 |
|
64 setAttribute(Qt::AA_S60DontConstructApplicationPanes); |
|
65 #endif // QT_VERSION |
|
66 |
63 |
67 // ignore command line arguments on Symbian |
64 // ignore command line arguments on Symbian |
68 #ifdef Q_OS_SYMBIAN |
65 #ifdef Q_OS_SYMBIAN |
69 Options::start = true; |
66 Options::start = true; |
70 Options::persistent = true; |
67 Options::persistent = true; |
74 const bool wasEmpty = args.isEmpty(); |
71 const bool wasEmpty = args.isEmpty(); |
75 const bool restart = args.removeAll(QLatin1String("-restart")); |
72 const bool restart = args.removeAll(QLatin1String("-restart")); |
76 Options::start = args.removeAll(QLatin1String("-start")) || restart; |
73 Options::start = args.removeAll(QLatin1String("-start")) || restart; |
77 Options::stop = args.removeAll(QLatin1String("-stop")) || restart; |
74 Options::stop = args.removeAll(QLatin1String("-stop")) || restart; |
78 Options::persistent = args.removeAll(QLatin1String("-persistent")); |
75 Options::persistent = args.removeAll(QLatin1String("-persistent")); |
79 Options::help = args.removeAll(QLatin1String("-help")) || args.removeAll(QLatin1String("-h")) || !args.isEmpty() || wasEmpty; |
76 Options::help = args.removeAll(QLatin1String("-help")) |
|
77 || args.removeAll(QLatin1String("-h")) || !args.isEmpty() || wasEmpty; |
80 if (!args.isEmpty()) { |
78 if (!args.isEmpty()) { |
81 Options::error = tr("Unknown option(s): '%1'").arg(args.join(QLatin1String(" "))); |
79 Options::error = tr("Unknown option(s): '%1'").arg(args.join(QLatin1String(" "))); |
82 } |
80 } |
83 #endif // Q_OS_SYMBIAN |
81 #endif // Q_OS_SYMBIAN |
84 } |
82 } |
91 bool HbThemeServerApplication::initialize() |
89 bool HbThemeServerApplication::initialize() |
92 { |
90 { |
93 #if defined (Q_OS_SYMBIAN) |
91 #if defined (Q_OS_SYMBIAN) |
94 CEikonEnv * env = CEikonEnv::Static(); |
92 CEikonEnv * env = CEikonEnv::Static(); |
95 if ( env ) { |
93 if ( env ) { |
96 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
94 _LIT(KHbThemeServer, "HbThemeServer"); |
|
95 CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
97 env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); // avoid coming to foreground |
96 env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); // avoid coming to foreground |
98 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
97 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
99 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
98 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
100 wgName->SetCaptionL(_L("HbThemeServer")); // TODO: use QCoreApplication::applicationName() |
99 wgName->SetCaptionL(KHbThemeServer); |
101 wgName->SetAppUid(KNullUid); |
100 wgName->SetAppUid(KNullUid); |
102 wgName->SetWindowGroupName(env->RootWin()); |
101 wgName->SetWindowGroupName(env->RootWin()); |
103 CleanupStack::PopAndDestroy(); |
102 CleanupStack::PopAndDestroy(); |
104 RThread::RenameMe(_L("HbThemeServer")); // TODO: use QCoreApplication::applicationName() |
103 RThread::RenameMe(KHbThemeServer); |
105 } |
104 } |
106 #endif |
105 #endif |
107 |
|
108 // as for theme initialization, an instance needs to be created before starting the server |
|
109 HbTheme::instance(); |
|
110 |
106 |
111 // load resource libraries in order to make binary resources accessible |
107 // load resource libraries in order to make binary resources accessible |
112 bool result = loadLibrary(RESOURCE_LIB_NAME); |
108 bool result = loadLibrary(RESOURCE_LIB_NAME); |
113 #ifdef HB_DEVELOPER |
109 #ifdef HB_DEVELOPER |
114 loadLibrary(TEST_RESOURCE_LIB_NAME); |
110 loadLibrary(TEST_RESOURCE_LIB_NAME); |
137 #ifndef Q_OS_SYMBIAN |
133 #ifndef Q_OS_SYMBIAN |
138 sendMessage(STOP_MESSAGE); |
134 sendMessage(STOP_MESSAGE); |
139 #endif // Q_OS_SYMBIAN |
135 #endif // Q_OS_SYMBIAN |
140 } |
136 } |
141 |
137 |
|
138 static bool hb_loadLibraryHelper(const QString &name) |
|
139 { |
|
140 QLibrary library(name); |
|
141 // rely on dynamic loader (LD_LIBRARY_PATH) |
|
142 bool result = library.load(); |
|
143 if (!result) { |
|
144 // try from prefix/lib dir |
|
145 library.setFileName(QDir(HB_LIB_DIR).filePath(name)); |
|
146 result = library.load(); |
|
147 if (!result) { |
|
148 // try from build/lib dir |
|
149 QString path = QLatin1String(HB_BUILD_DIR) + QDir::separator() + QLatin1String("lib"); |
|
150 library.setFileName(QDir(path).filePath(name)); |
|
151 result = library.load(); |
|
152 } |
|
153 } |
|
154 #ifdef THEME_SERVER_TRACES |
|
155 if (!result) { |
|
156 qDebug() << "hb_loadLibraryHelper():" << library.errorString(); |
|
157 } |
|
158 #endif |
|
159 return result; |
|
160 } |
|
161 |
142 bool HbThemeServerApplication::loadLibrary(const QString &name) |
162 bool HbThemeServerApplication::loadLibrary(const QString &name) |
143 { |
163 { |
144 // To load resources embedded in hb library |
164 // To load resources embedded in hb library |
145 QLibrary library(name); |
165 bool result = hb_loadLibraryHelper(name); |
146 bool result = library.load(); |
|
147 |
|
148 if (!result) { |
166 if (!result) { |
149 // Library may not be loaded, if it was built in debug mode and the name in debug mode is |
167 // Library may not be loaded, if it was built in debug mode and the name in debug mode is |
150 // different, change the name to debug version in that scenario |
168 // different, change the name to debug version in that scenario |
151 QString alternateName = name; |
169 QString alternateName = name; |
152 #ifdef Q_OS_WIN32 |
170 #ifdef Q_OS_WIN32 |
154 #elif defined(Q_OS_MAC) |
172 #elif defined(Q_OS_MAC) |
155 alternateName += MAC_DEBUG_SUFFIX; |
173 alternateName += MAC_DEBUG_SUFFIX; |
156 #endif |
174 #endif |
157 // On symbian library name in debug mode is same as that in release mode, |
175 // On symbian library name in debug mode is same as that in release mode, |
158 // so no need to do anything for that |
176 // so no need to do anything for that |
159 library.setFileName(alternateName); |
177 if (alternateName != name) { |
160 result = library.load(); |
178 result = hb_loadLibraryHelper(alternateName); |
|
179 } |
161 } |
180 } |
162 #ifdef THEME_SERVER_TRACES |
181 #ifdef THEME_SERVER_TRACES |
163 if (result) { |
182 if (result) { |
164 qDebug() << "HbThemeServerApplication::loadLibrary(): loaded library " << name; |
183 qDebug() << "HbThemeServerApplication::loadLibrary(): loaded library " << name; |
165 } |
184 } |