43 \internal |
43 \internal |
44 */ |
44 */ |
45 |
45 |
46 const qint64 image_bytes_limit = 1024 * 1024 * 4; |
46 const qint64 image_bytes_limit = 1024 * 1024 * 4; |
47 |
47 |
48 static QString orientationId(HbSplash::Flags flags) |
48 static QString orientationId(HbSplashScreen::Flags flags) |
49 { |
49 { |
50 if (flags & HbSplash::FixedVertical) { |
50 if (flags & HbSplashScreen::FixedVertical) { |
51 return QString("prt"); |
51 return QString("prt"); |
52 } else if (flags & HbSplash::FixedHorizontal) { |
52 } else if (flags & HbSplashScreen::FixedHorizontal) { |
53 return QString("lsc"); |
53 return QString("lsc"); |
54 } |
54 } |
55 #ifdef Q_OS_SYMBIAN |
55 #ifdef Q_OS_SYMBIAN |
56 Qt::Orientation orientation; |
56 Qt::Orientation orientation; |
57 if (HbOrientationStatus::currentOrientation(orientation) && orientation == Qt::Horizontal) { |
57 if (HbOrientationStatus::currentOrientation(orientation) && orientation == Qt::Horizontal) { |
141 |
142 |
142 class HbSplashSrvClient : public RSessionBase |
143 class HbSplashSrvClient : public RSessionBase |
143 { |
144 { |
144 public: |
145 public: |
145 bool Connect(); |
146 bool Connect(); |
146 bool getSplash(RFile &f, const QString &ori, const QString &appId); |
147 bool getSplash(RFile &f, const QString &ori, const QString &appId, const QString &screenId); |
147 }; |
148 }; |
148 |
149 |
149 bool HbSplashSrvClient::Connect() |
150 bool HbSplashSrvClient::Connect() |
150 { |
151 { |
151 TVersion ver(hbsplash_version_major, hbsplash_version_minor, hbsplash_version_build); |
152 TVersion ver(hbsplash_version_major, hbsplash_version_minor, hbsplash_version_build); |
152 if (CreateSession(hbsplash_server_name, ver) != KErrNone) { |
153 int maxTries = 3; |
153 qWarning("[hbsplash] cannot connect to splashgen server"); |
154 while (maxTries--) { |
154 return false; |
155 TInt err = CreateSession(hbsplash_server_name, ver); |
155 } |
156 qDebug("[hbsplash] CreateSession result: %d", err); |
156 return true; |
157 if (err == KErrNone) { |
157 } |
158 return true; |
158 |
159 /* |
159 bool HbSplashSrvClient::getSplash(RFile &f, const QString &ori, const QString &appId) |
160 } else if (err == KErrNotFound || err == KErrServerTerminated) { |
|
161 qDebug("[hbsplash] Server not running"); |
|
162 TFindServer findServer(hbsplash_server_name); |
|
163 TFullName name; |
|
164 if (findServer.Next(name) != KErrNone) { |
|
165 RProcess server; |
|
166 const TUidType uid(KNullUid, KNullUid, hbsplash_server_uid3); |
|
167 err = server.Create(hbsplash_server_exe, KNullDesC, uid); |
|
168 if (err != KErrNone) { |
|
169 qWarning("[hbsplash] RProcess::Create failed (%d)", err); |
|
170 break; |
|
171 } |
|
172 TRequestStatus status; |
|
173 server.Rendezvous(status); |
|
174 if (status != KRequestPending) { |
|
175 server.Kill(0); |
|
176 } else { |
|
177 server.Resume(); |
|
178 } |
|
179 User::WaitForRequest(status); |
|
180 server.Close(); |
|
181 if (status.Int() != KErrNone) { |
|
182 qWarning("[hbsplash] Rendezvous failed (%d)", status.Int()); |
|
183 break; |
|
184 } |
|
185 qDebug("[hbsplash] Server started"); |
|
186 } |
|
187 */ |
|
188 } else { |
|
189 break; |
|
190 } |
|
191 } |
|
192 qWarning("[hbsplash] cannot connect to splashgen server"); |
|
193 return false; |
|
194 } |
|
195 |
|
196 bool HbSplashSrvClient::getSplash(RFile &f, const QString &ori, |
|
197 const QString &appId, const QString &screenId) |
160 { |
198 { |
161 TPtrC oriDes(static_cast<const TUint16 *>(ori.utf16()), ori.length()); |
199 TPtrC oriDes(static_cast<const TUint16 *>(ori.utf16()), ori.length()); |
162 TPtrC appIdDes(static_cast<const TUint16 *>(appId.utf16()), appId.length()); |
200 TPtrC appIdDes(static_cast<const TUint16 *>(appId.utf16()), appId.length()); |
|
201 TPtrC screenIdDes(static_cast<const TUint16 *>(screenId.utf16()), screenId.length()); |
163 TInt fileHandle; |
202 TInt fileHandle; |
164 TPckg<TInt> fileHandlePckg(fileHandle); |
203 TPckg<TInt> fileHandlePckg(fileHandle); |
165 TIpcArgs args(&oriDes, &appIdDes, &fileHandlePckg); |
204 TIpcArgs args(&oriDes, &appIdDes, &screenIdDes, &fileHandlePckg); |
166 TInt fsHandle = SendReceive(HbSplashSrvGetSplash, args); |
205 TInt fsHandle = SendReceive(HbSplashSrvGetSplash, args); |
167 return f.AdoptFromServer(fsHandle, fileHandle) == KErrNone; |
206 return f.AdoptFromServer(fsHandle, fileHandle) == KErrNone; |
168 } |
207 } |
169 |
208 |
170 static uchar *load_symbian(const Params ¶ms) |
209 static uchar *load_symbian(const Params ¶ms) |
210 } |
249 } |
211 |
250 |
212 static uchar *load_generic(const Params ¶ms) |
251 static uchar *load_generic(const Params ¶ms) |
213 { |
252 { |
214 QString appSpecificName("splash_%1_%2.spl"); |
253 QString appSpecificName("splash_%1_%2.spl"); |
|
254 QString appAndScreenSpecificName("splash_%1_%2_%3.spl"); |
215 QString genericName("splash_%1.spl"); |
255 QString genericName("splash_%1.spl"); |
216 QDir dir("splashscreens"); // see hbsplashgenerator |
256 QDir dir("splashscreens"); // see hbsplashgenerator |
217 QString oriStr(orientationId(params.flags)); |
257 QString oriStr(orientationId(params.flags)); |
218 uchar *data = 0; |
258 uchar *data = 0; |
219 // Try to read the app-specific screen. |
259 // Try to read the app-specific screen. |
220 if (!params.appId.isEmpty()) { |
260 if (!params.appId.isEmpty()) { |
221 data = read_file_generic(dir.filePath(appSpecificName.arg(oriStr).arg(params.appId)), params); |
261 QString name; |
|
262 if (!params.screenId.isEmpty()) { |
|
263 name = appAndScreenSpecificName.arg(oriStr).arg(params.appId).arg(params.screenId); |
|
264 } else { |
|
265 name = appSpecificName.arg(oriStr).arg(params.appId); |
|
266 } |
|
267 data = read_file_generic(dir.filePath(name), params); |
222 } |
268 } |
223 // If failed then use the common one. |
269 // If failed then use the common one. |
224 if (!data) { |
270 if (!data) { |
225 data = read_file_generic(dir.filePath(genericName.arg(oriStr)), params); |
271 data = read_file_generic(dir.filePath(genericName.arg(oriStr)), params); |
226 } |
272 } |
260 parameters: width, height, bytes-per-line, format, and the custom parameter \a |
306 parameters: width, height, bytes-per-line, format, and the custom parameter \a |
261 allocFuncParam. This means that when allocFunc is not 0 the return value of |
307 allocFuncParam. This means that when allocFunc is not 0 the return value of |
262 load() is either 0 (if there was an error) or the return value of allocFunc |
308 load() is either 0 (if there was an error) or the return value of allocFunc |
263 (in case of success). |
309 (in case of success). |
264 |
310 |
265 \sa HbSplash::Flags |
311 \sa HbSplashScreen::Flags |
266 |
312 |
267 \internal |
313 \internal |
268 */ |
314 */ |
269 uchar *HbSplash::load(int &w, int &h, int &bpl, QImage::Format &fmt, |
315 uchar *HbSplash::load(int &w, int &h, int &bpl, QImage::Format &fmt, |
270 Flags flags, const QString &appId, |
316 HbSplashScreen::Flags flags, |
|
317 const QString &appId, const QString &screenId, |
271 AllocFunc allocFunc, void *allocFuncParam) |
318 AllocFunc allocFunc, void *allocFuncParam) |
272 { |
319 { |
273 Params params; |
320 Params params; |
274 params.w = &w; |
321 params.w = &w; |
275 params.h = &h; |
322 params.h = &h; |
276 params.bpl = &bpl; |
323 params.bpl = &bpl; |
277 params.fmt = &fmt; |
324 params.fmt = &fmt; |
278 params.flags = flags; |
325 params.flags = flags; |
279 params.appId = appId; |
326 params.appId = appId; |
|
327 params.screenId = screenId; |
280 params.allocFunc = allocFunc; |
328 params.allocFunc = allocFunc; |
281 params.allocFuncParam = allocFuncParam; |
329 params.allocFuncParam = allocFuncParam; |
282 #ifdef Q_OS_SYMBIAN |
330 #ifdef Q_OS_SYMBIAN |
283 return load_symbian(params); |
331 return load_symbian(params); |
284 #else |
332 #else |