|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #include <QtGlobal> |
|
23 #include <QApplication> |
|
24 #include <QKeyEvent> |
|
25 #include <QLabel> |
|
26 #include <QStackedWidget> |
|
27 #include <QImageReader> |
|
28 #include <QDebug> |
|
29 #include <QTimer> |
|
30 #include <QPushButton> |
|
31 #include <QList> |
|
32 #include <QLineEdit> |
|
33 #include <QString> |
|
34 #include <QCheckBox> |
|
35 #include <QAction> |
|
36 #include <QListView> |
|
37 #include <QUrl> |
|
38 #include <QFileInfo> |
|
39 #include <math.h> |
|
40 #include <QCompleter> |
|
41 #include <xqserviceglobal.h> |
|
42 #include <QDir> |
|
43 #include <QTranslator> |
|
44 #include <XQSharableFile.h> |
|
45 |
|
46 #include <xqaiwdeclplat.h> |
|
47 |
|
48 #include "appmgrservices.h" |
|
49 #include "appmgrclient.h" |
|
50 |
|
51 |
|
52 AppMgrClient::AppMgrClient(QWidget *parent, Qt::WFlags f) |
|
53 : QWidget(parent, f), |
|
54 req1(0), |
|
55 req2(0), |
|
56 req3(0), |
|
57 req4(0), |
|
58 req5(0), |
|
59 req6(0), |
|
60 req7(0), |
|
61 req8(0), |
|
62 req9(0), |
|
63 actionButton(0), |
|
64 mImplIndex(0) |
|
65 { |
|
66 /* Adjust the palette */ |
|
67 #if defined(Q_WS_S60) |
|
68 QPalette p = qApp->palette(); |
|
69 QColor color(192,192,192); |
|
70 QColor bg(0,128,192); |
|
71 p.setColor(QPalette::Highlight, color.lighter(200)); |
|
72 p.setColor(QPalette::Text, Qt::black); |
|
73 p.setColor(QPalette::Base, bg); |
|
74 p.setColor(QPalette::WindowText, Qt::black); |
|
75 p.setColor(QPalette::Window, bg); |
|
76 p.setColor(QPalette::ButtonText, Qt::black); |
|
77 p.setColor(QPalette::Button, color.lighter(150)); |
|
78 p.setColor(QPalette::Link, QColor(240,40,40)); |
|
79 qApp->setPalette(p); |
|
80 #endif |
|
81 |
|
82 QPushButton *testButton1 = 0; |
|
83 QPushButton *anyTestButton = 0; |
|
84 |
|
85 QPushButton *quitButton = new QPushButton(tr("quit")); |
|
86 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
87 |
|
88 testButton1 = new QPushButton("Tests"); |
|
89 mMenu = new QMenu(this); |
|
90 testButton1->setMenu(mMenu); |
|
91 anyTestButton = new QPushButton(tr("Any test")); |
|
92 connect(anyTestButton, SIGNAL(clicked()), this, SLOT(anyTest())); |
|
93 |
|
94 QAction *test1 = new QAction("Interface", this); |
|
95 connect(test1, SIGNAL(triggered()), this, SLOT(test1())); |
|
96 QAction *test2 = new QAction("Descriptor", this); |
|
97 connect(test2, SIGNAL(triggered()), this, SLOT(test2())); |
|
98 QAction *test3 = new QAction("Errors", this); |
|
99 connect(test3, SIGNAL(triggered()), this, SLOT(test3())); |
|
100 QAction *test4 = new QAction("QAction", this); |
|
101 connect(test4, SIGNAL(triggered()), this, SLOT(test4())); |
|
102 QAction *test5 = new QAction("appto:", this); |
|
103 connect(test5, SIGNAL(triggered()), this, SLOT(test5())); |
|
104 QAction *test6 = new QAction("testto:", this); |
|
105 connect(test6, SIGNAL(triggered()), this, SLOT(test6())); |
|
106 QAction *test7 = new QAction("MIME", this); |
|
107 connect(test7, SIGNAL(triggered()), this, SLOT(test7())); |
|
108 QAction *test8 = new QAction("URI", this); |
|
109 connect(test8, SIGNAL(triggered()), this, SLOT(test8())); |
|
110 QAction *test9 = new QAction("XQSharableFile", this); |
|
111 connect(test9, SIGNAL(triggered()), this, SLOT(test9())); |
|
112 |
|
113 mMenu = new QMenu(this); |
|
114 mMenu->addAction(test1); |
|
115 mMenu->addAction(test2); |
|
116 mMenu->addAction(test3); |
|
117 mMenu->addAction(test4); |
|
118 mMenu->addAction(test5); |
|
119 mMenu->addAction(test6); |
|
120 mMenu->addAction(test7); |
|
121 mMenu->addAction(test8); |
|
122 mMenu->addAction(test9); |
|
123 |
|
124 testButton1->setMenu(mMenu); |
|
125 |
|
126 mCheckEmbedded = new QCheckBox("Embedded"); |
|
127 mSynchronous = new QCheckBox("Synchronous"); |
|
128 mBackground = new QCheckBox("Background"); |
|
129 mCheckDeleteRequest = new QCheckBox("Delete request"); |
|
130 mGenericSend = new QCheckBox("Use generic send()"); |
|
131 mCheckEmbedded->setCheckState(Qt::Checked); |
|
132 mSynchronous->setCheckState(Qt::Checked); |
|
133 mGenericSend->setCheckState(Qt::Checked); // Apply one send() for both embedded/non-embedded |
|
134 |
|
135 mReqArg = new QLineEdit("0"); |
|
136 |
|
137 mTextRetValue = new QLineEdit("no ret value set"); |
|
138 |
|
139 QLabel *label = new QLabel("APPMGR CLIENT TEST"); |
|
140 |
|
141 vl = new QVBoxLayout; |
|
142 vl->setMargin(0); |
|
143 vl->setSpacing(0); |
|
144 |
|
145 vl->addWidget(label); |
|
146 vl->addWidget(mCheckEmbedded); |
|
147 vl->addWidget(mSynchronous); |
|
148 vl->addWidget(mBackground); |
|
149 vl->addWidget(mCheckDeleteRequest); |
|
150 vl->addWidget(mGenericSend); |
|
151 vl->addWidget(mReqArg); |
|
152 vl->addWidget(mTextRetValue); |
|
153 vl->addWidget(new QLabel(" ")); |
|
154 vl->addWidget(testButton1); |
|
155 vl->addWidget(anyTestButton); |
|
156 vl->addWidget(quitButton); |
|
157 |
|
158 setLayout(vl); |
|
159 |
|
160 #if defined(Q_WS_X11) || defined(Q_WS_WIN) |
|
161 setFixedSize(QSize(360,640)); // nHD |
|
162 #elif defined(Q_WS_S60) |
|
163 // showMaximized(); |
|
164 showFullScreen(); |
|
165 #endif |
|
166 |
|
167 } |
|
168 |
|
169 AppMgrClient::~AppMgrClient() |
|
170 { |
|
171 delete req1; |
|
172 delete req2; |
|
173 delete req3; |
|
174 delete req4; |
|
175 delete req5; |
|
176 delete req6; |
|
177 delete req7; |
|
178 delete req8; |
|
179 delete req9; |
|
180 delete mMenu; |
|
181 |
|
182 } |
|
183 |
|
184 void AppMgrClient::test(XQAiwRequest **req, const QString& interface, const QString& operation, bool embedded) |
|
185 { |
|
186 qDebug() << "AppMgrClient::test START"; |
|
187 |
|
188 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
189 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
190 bool background = (mBackground->checkState() == Qt::Checked); |
|
191 |
|
192 qDebug() << "AppMgrClient:test: embed=" << embed << ",sync=" << sync << "background=" << background; |
|
193 |
|
194 if (!*req) |
|
195 { |
|
196 *req = appmgr.create(interface, operation); |
|
197 connectSignals(*req); |
|
198 } |
|
199 // Test embedded funcions |
|
200 (*req)->setEmbedded(embed); |
|
201 (*req)->setSynchronous(sync); |
|
202 (*req)->setBackground(background); |
|
203 |
|
204 qDebug("AppMgrClient::isEmbbedded %d", (*req)->isEmbedded()); |
|
205 |
|
206 test(req, mReqArg->text()); |
|
207 |
|
208 qDebug() << "AppMgrClient::test END"; |
|
209 |
|
210 } |
|
211 |
|
212 |
|
213 void AppMgrClient::test(XQAiwRequest **req, XQAiwInterfaceDescriptor &impl, const QString& operation, bool embedded) |
|
214 { |
|
215 qDebug() << "AppMgrClient::test START"; |
|
216 |
|
217 if (!*req) |
|
218 { |
|
219 *req = appmgr.create(impl, operation); |
|
220 connectSignals(*req); |
|
221 } |
|
222 // Test embedded funcions |
|
223 qDebug("AppMgrClient::isEmbbedded %d", (*req)->isEmbedded()); |
|
224 |
|
225 test(req, mReqArg->text()); |
|
226 |
|
227 qDebug() << "AppMgrClient::test END"; |
|
228 |
|
229 } |
|
230 |
|
231 |
|
232 |
|
233 void AppMgrClient::test(XQAiwRequest **req, const QString &arg) |
|
234 { |
|
235 qDebug() << "AppMgrClient::testreq START"; |
|
236 |
|
237 if (!req || !*req) |
|
238 { |
|
239 qDebug() << "AIW-ERROR:AppMgrClient::NULL request"; |
|
240 return; |
|
241 } |
|
242 |
|
243 |
|
244 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
245 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
246 bool background = (mBackground->checkState() == Qt::Checked); |
|
247 |
|
248 // Set arguments for request |
|
249 QList<QVariant> args; |
|
250 args << arg; |
|
251 args << QVariant(!sync); |
|
252 (*req)->setArguments(args); |
|
253 |
|
254 bool genericSend = (mGenericSend->checkState() == Qt::Checked); |
|
255 (*req)->setEmbedded(embed); |
|
256 (*req)->setSynchronous(sync); |
|
257 (*req)->setBackground(background); |
|
258 |
|
259 // Make the request |
|
260 if (genericSend || !sync) |
|
261 { |
|
262 if (!(*req)->send()) |
|
263 { |
|
264 qDebug() << "AIW-ERROR: AppMgrClient:test: Send failed" << (*req)->lastError();; |
|
265 } |
|
266 } |
|
267 else if (!genericSend && sync) |
|
268 { |
|
269 QVariant retValue; |
|
270 if (!(*req)->send(retValue)) |
|
271 { |
|
272 qDebug() << "AIW-ERROR: AppMgrClient:test: Send(retValue) failed" << (*req)->lastError();; |
|
273 } |
|
274 else |
|
275 { |
|
276 if (retValue.canConvert<QString>()) |
|
277 { |
|
278 qDebug("AppMgrClient::retValue=%s,%s", |
|
279 retValue.typeName(), |
|
280 qPrintable(retValue.value<QString>())); |
|
281 mTextRetValue->setText(retValue.value<QString>()); |
|
282 } |
|
283 else |
|
284 { |
|
285 qDebug("AppMgrClient:retValue=%s", |
|
286 retValue.typeName()); |
|
287 mTextRetValue->setText("Not displayable"); |
|
288 } |
|
289 |
|
290 } |
|
291 } |
|
292 |
|
293 // Delete request if wanted |
|
294 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
295 |
|
296 if ((*req)->lastError() == XQService::EMessageNotFound) |
|
297 { |
|
298 // Slot was not found |
|
299 deleteRequest = true; |
|
300 } |
|
301 |
|
302 if (deleteRequest) |
|
303 { |
|
304 qDebug() << "AIW-NOTE: Request deleted"; |
|
305 delete *req; |
|
306 *req = 0; |
|
307 } |
|
308 |
|
309 qDebug() << "AppMgrClient::test END"; |
|
310 |
|
311 update(); |
|
312 |
|
313 |
|
314 } |
|
315 |
|
316 |
|
317 void AppMgrClient::connectSignals(XQAiwRequest *req) |
|
318 { |
|
319 if (req) |
|
320 { |
|
321 // Connect signals once |
|
322 connect(req, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
323 connect(req, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
|
324 } |
|
325 } |
|
326 |
|
327 |
|
328 void AppMgrClient::createTestFile(const QString &dir, const QString &fileName) |
|
329 { |
|
330 |
|
331 QDir d("."); |
|
332 d.mkpath(dir); |
|
333 qDebug() << dir; |
|
334 |
|
335 QFile file(dir + "/" + fileName); |
|
336 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) |
|
337 { |
|
338 qDebug() << "Creating file failed " << QString(dir + "/" + fileName); |
|
339 return; |
|
340 } |
|
341 QTextStream out(&file); |
|
342 out << "Text in file" << "\n"; |
|
343 file.close(); |
|
344 |
|
345 } |
|
346 |
|
347 |
|
348 void AppMgrClient::test1() |
|
349 { |
|
350 qDebug() << "AppMgrClient::test1 START"; |
|
351 test(&req1, IDIAL, OPERATION1); |
|
352 qDebug() << "AppMgrClient::test1 END"; |
|
353 |
|
354 /* |
|
355 mReqArg->setText("77777"); |
|
356 qDebug() << "AppMgrClient::test1 second call"; |
|
357 test(&req1, IDIAL, OPERATION1); |
|
358 */ |
|
359 } |
|
360 |
|
361 |
|
362 void AppMgrClient::test2() |
|
363 { |
|
364 qDebug() << "AppMgrClient::test2 START"; |
|
365 |
|
366 QList<XQAiwInterfaceDescriptor> list=appmgr.list(IDIAL, ""); |
|
367 qDebug() << "AppMgrClient::Found implementations: " << list.count(); |
|
368 int i=0; |
|
369 foreach (XQAiwInterfaceDescriptor d, list) |
|
370 { |
|
371 qDebug("AppMgrClient::Service[%d]=%s",i,qPrintable(d.serviceName())); |
|
372 qDebug("AppMgrClient::Interface[%d]=%s",i,qPrintable(d.interfaceName())); |
|
373 qDebug("AppMgrClient::Implementation Id[%d]=%x",i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
374 i++; |
|
375 } |
|
376 |
|
377 if (!list.isEmpty()) |
|
378 { |
|
379 // Use the first found |
|
380 qDebug() << "AppMgrClient::Using implementation nbr: " << mImplIndex; |
|
381 test(&req2,list[mImplIndex], OPERATION1); |
|
382 } |
|
383 |
|
384 qDebug() << "AppMgrClient::test2 END"; |
|
385 |
|
386 } |
|
387 |
|
388 void AppMgrClient::test3() |
|
389 { |
|
390 qDebug() << "AppMgrClient::test3 START"; |
|
391 |
|
392 test(&req3,IDIAL,ERR_OPERATION1); |
|
393 test(&req3,ERR_IDIAL,ERR_OPERATION1); |
|
394 test(&req3,ERR_IDIAL,ERR_OPERATION1); |
|
395 |
|
396 qDebug() << "AppMgrClient::test3 END"; |
|
397 |
|
398 } |
|
399 |
|
400 void AppMgrClient::test4() |
|
401 { |
|
402 qDebug() << "AppMgrClient::test4 START"; |
|
403 |
|
404 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
405 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
406 |
|
407 if (req4) |
|
408 { |
|
409 delete req4; // Previous |
|
410 req4 = 0; |
|
411 } |
|
412 |
|
413 // Only hbserviceprovider support localization |
|
414 req4 = appmgr.create(QLatin1String("com.nokia.services.hbserviceprovider"), IDIAL, OPERATION1); |
|
415 if (!req4) |
|
416 { |
|
417 qDebug() << "AIW-ERROR:AppMgrClient::NULL request"; |
|
418 return; |
|
419 } |
|
420 |
|
421 connectSignals(req4); |
|
422 req4->setEmbedded(embed); |
|
423 req4->setSynchronous(embed); |
|
424 |
|
425 if (actionButton) |
|
426 { |
|
427 // Previous |
|
428 vl->removeWidget(actionButton); |
|
429 delete actionButton; |
|
430 actionButton = 0; |
|
431 update(); |
|
432 } |
|
433 |
|
434 QAction *action = req4->createAction(); // Also connects the triggered event to req !!!! |
|
435 qDebug() << "AppMgrClient::action:" << action->isEnabled(); |
|
436 |
|
437 // Create UI |
|
438 if (action) |
|
439 { |
|
440 actionButton = new QPushButton(action->text()); |
|
441 actionButton->addAction(action); |
|
442 vl->addWidget(actionButton); |
|
443 setLayout(vl); |
|
444 // For some reason triggered does not come from request |
|
445 // Workaround... |
|
446 connect(actionButton, SIGNAL(clicked()), action, SIGNAL(triggered())); |
|
447 connect(req4, SIGNAL(triggered()), this, SLOT(test4ActionTriggered())); |
|
448 } |
|
449 else |
|
450 { |
|
451 qDebug() << "AppMgrClient::test4 No action available"; |
|
452 |
|
453 } |
|
454 |
|
455 qDebug() << "AppMgrClient::test4 END"; |
|
456 |
|
457 } |
|
458 |
|
459 void AppMgrClient::test4ActionTriggered() |
|
460 { |
|
461 XQAiwRequest *r = (XQAiwRequest *)sender(); |
|
462 |
|
463 // Set arguments for request |
|
464 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
465 QList<QVariant> args; |
|
466 args << QVariant(mReqArg->text()); |
|
467 args << QVariant(!embed); |
|
468 r->setArguments(args); |
|
469 |
|
470 } |
|
471 |
|
472 void AppMgrClient::test5() |
|
473 { |
|
474 qDebug() << "AppMgrClient::test5 START"; |
|
475 |
|
476 // E0022E73 == ServiceApp |
|
477 QUrl uri(XQURI_SCHEME_ACTIVITY + "://E0022E73?" + XQURI_KEY_ACTIVITY_NAME + "=emailView&view=myview"); |
|
478 qDebug() << "AppMgrClient::Uri=" << uri.toString(); |
|
479 qDebug() << "AppMgrClient::isValid=" << uri.isValid(); |
|
480 qDebug() << "AppMgrClient::Uri authority=" << uri.authority(); |
|
481 QString old=mReqArg->text(); |
|
482 if (!req5) |
|
483 { |
|
484 req5 = appmgr.create(uri); |
|
485 connectSignals(req5); |
|
486 } |
|
487 |
|
488 mReqArg->setText(uri.encodedQuery()); |
|
489 test(&req5, mReqArg->text()); |
|
490 mReqArg->setText(old); |
|
491 |
|
492 qDebug() << "AppMgrClient::test5 END"; |
|
493 |
|
494 } |
|
495 |
|
496 void AppMgrClient::test6() |
|
497 { |
|
498 qDebug() << "AppMgrClient::test6 START"; |
|
499 |
|
500 QUrl uri("testto://authority?param1=value1¶m1=value2"); |
|
501 qDebug() << "AppMgrClient::Uri=" << uri.toString(); |
|
502 qDebug() << "AppMgrClient::isValid=" << uri.isValid(); |
|
503 qDebug() << "AppMgrClient::Uri authority=" << uri.authority(); |
|
504 |
|
505 QList<XQAiwInterfaceDescriptor> uriHandlers = appmgr.list(uri); |
|
506 // Note : Only services supporting custom property are returned |
|
507 foreach (XQAiwInterfaceDescriptor d, uriHandlers) |
|
508 { |
|
509 qDebug() << "AppMgrClient::Service=" << d.serviceName(); |
|
510 qDebug() << "AppMgrClient::Interface=" << d.interfaceName(); |
|
511 qDebug("AppMgrClient::Implementation Id=%x",d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
512 } |
|
513 |
|
514 if (!req6) |
|
515 { |
|
516 req6 = appmgr.create(uri); |
|
517 connectSignals(req6); |
|
518 } |
|
519 |
|
520 test(&req6, uri.toString()); |
|
521 |
|
522 qDebug() << "AppMgrClient::test6 END"; |
|
523 |
|
524 } |
|
525 |
|
526 void AppMgrClient::test7() |
|
527 { |
|
528 qDebug() << "AppMgrClient::test7 START"; |
|
529 |
|
530 // Should launch viewer for text/plain MimeTestApp. |
|
531 // Create test file |
|
532 createTestFile("C:/data/Others", "test.txt"); |
|
533 |
|
534 QFile file("C:/data/Others/test.txt"); |
|
535 qDebug() << "AppMgrClient::File=" << file.fileName(); |
|
536 qDebug() << "AppMgrClient::exists=" << file.exists(); |
|
537 |
|
538 QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(file); |
|
539 foreach (XQAiwInterfaceDescriptor d, fileHandlers) |
|
540 { |
|
541 qDebug() << "AppMgrClient::Service=" << d.serviceName(); |
|
542 qDebug() << "AppMgrClient::Interface=" << d.interfaceName(); |
|
543 qDebug() << "AppMgrClient::Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt(); |
|
544 } |
|
545 |
|
546 if (!req7) |
|
547 { |
|
548 req7 = appmgr.create(file); |
|
549 connectSignals(req7); |
|
550 } |
|
551 test(&req7, file.fileName()); |
|
552 |
|
553 qDebug() << "AppMgrClient::test7 END"; |
|
554 |
|
555 } |
|
556 |
|
557 |
|
558 void AppMgrClient::test8() |
|
559 { |
|
560 qDebug() << "AppMgrClient::test8 START"; |
|
561 |
|
562 // E0022E73 == ServiceApp |
|
563 QUrl uri("http://www.nokia.com"); |
|
564 qDebug() << "AppMgrClient::Uri=" << uri.toString(); |
|
565 qDebug() << "AppMgrClient::isValid=" << uri.isValid(); |
|
566 qDebug() << "AppMgrClient::Uri authority=" << uri.authority(); |
|
567 |
|
568 if (!req8) |
|
569 { |
|
570 req8 = appmgr.create(uri); |
|
571 connectSignals(req8); |
|
572 } |
|
573 test(&req8, uri.toString()); |
|
574 |
|
575 qDebug() << "AppMgrClient::test8 END"; |
|
576 |
|
577 } |
|
578 |
|
579 void AppMgrClient::test9() |
|
580 { |
|
581 |
|
582 qDebug() << "AppMgrClient::test9 START"; |
|
583 |
|
584 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
585 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
586 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
587 |
|
588 |
|
589 // Access data-caged file |
|
590 XQSharableFile sf; |
|
591 createTestFile("c:/private/e0022e74", "test.txt"); |
|
592 if (!sf.open("c:\\private\\e0022e74\\test.txt")) |
|
593 { |
|
594 qDebug() << "AppMgrClient:file open failed"; |
|
595 return; |
|
596 } |
|
597 |
|
598 // Just test listing by sharable file |
|
599 QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(sf); |
|
600 if (fileHandlers.count() > 0) |
|
601 { |
|
602 XQAiwInterfaceDescriptor d = fileHandlers.first(); |
|
603 qDebug() << "AppMgrClient::File Service=" << d.serviceName(); |
|
604 qDebug() << "AppMgrClient::File Interface=" << d.interfaceName(); |
|
605 qDebug() << "AppMgrClient::Handler Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt(); |
|
606 if (!req9) |
|
607 { |
|
608 // Create by descriptor |
|
609 req9 = appmgr.create(sf, d); |
|
610 } |
|
611 if (!req9) |
|
612 { |
|
613 sf.close(); |
|
614 qDebug() << "AppMgrClient:anyTest: ERROR IN XQAppMgr API"; |
|
615 return ; |
|
616 } |
|
617 } |
|
618 else |
|
619 { |
|
620 sf.close(); |
|
621 qDebug() << "AppMgrClient:anyTest: NO HANDLER FOUND"; |
|
622 } |
|
623 |
|
624 connectSignals(req9); |
|
625 req9->setEmbedded(embed); |
|
626 req9->setSynchronous(sync); |
|
627 |
|
628 QList<QVariant> args; |
|
629 args << qVariantFromValue(sf); |
|
630 req9->setArguments(args); |
|
631 |
|
632 req9->send(); |
|
633 if (req9->lastError() == XQService::EMessageNotFound) |
|
634 { |
|
635 // Slot was not found |
|
636 qDebug() << "AIW-ERROR:XQService::EMessageNotFound"; |
|
637 deleteRequest = true; |
|
638 } |
|
639 // Remember to close the file !!! |
|
640 sf.close(); |
|
641 |
|
642 if (deleteRequest) |
|
643 { |
|
644 delete req9; |
|
645 req9 = 0; |
|
646 } |
|
647 |
|
648 qDebug() << "AppMgrClient::test9 END"; |
|
649 |
|
650 } |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 #define TXT_ID QLatin1String("txt_aiw_action_text") |
|
656 |
|
657 void AppMgrClient::anyTest() |
|
658 { |
|
659 |
|
660 |
|
661 qDebug() << "AppMgrClient:name" << qApp->applicationName(); |
|
662 qDebug() << "AppMgrClient:dirpath" << qApp->applicationDirPath(); |
|
663 qDebug() << "AppMgrClient:filename" << qApp->applicationFilePath(); |
|
664 qDebug() << "AppMgrClient:pid" << qApp->applicationPid(); |
|
665 |
|
666 QFileInfo appinfo (qApp->applicationFilePath()); |
|
667 qDebug() << "AppMgrClient:appinfo.applicationFilePath" << qApp->applicationFilePath(); |
|
668 qDebug() << "AppMgrClient:appinfo.absolutePath" << appinfo.absolutePath(); |
|
669 qDebug() << "AppMgrClient:appinfo.baseName" << appinfo.baseName(); |
|
670 |
|
671 QString lang = QLocale::system().name(); |
|
672 qDebug() << "AppMgrClient::anyTest:" << lang; |
|
673 |
|
674 // QString textFile = "z:/resource/qt/translations/hbserviceprovider"; |
|
675 QString textFile = "hbserviceprovider"; |
|
676 QFileInfo info(textFile); |
|
677 qDebug() << "AppMgrClient::base" << info.baseName(); |
|
678 qDebug() << "AppMgrClient::path" << info.filePath(); |
|
679 if (info.baseName() == info.filePath()) |
|
680 { |
|
681 textFile = qApp->applicationFilePath().left(2) + "/resource/qt/translations/" + textFile; |
|
682 qDebug() << "AppMgrClient::path added" << textFile; |
|
683 } |
|
684 |
|
685 textFile += "_"; |
|
686 textFile += lang; |
|
687 qDebug() << "AppMgrClient::anyTest:" << textFile; |
|
688 |
|
689 QTranslator translator; |
|
690 bool res = translator.load(textFile); |
|
691 qDebug() << "AppMgrClient::anyTest:" << res; |
|
692 if (res) |
|
693 { |
|
694 qApp->installTranslator(&translator); |
|
695 } |
|
696 |
|
697 QString textId = TXT_ID; |
|
698 QByteArray ba = textId.toLatin1(); |
|
699 const char *textPtr = ba.data(); |
|
700 |
|
701 QString text = qtTrId(textPtr); // translate |
|
702 qDebug() << "Translated text:" << text; |
|
703 |
|
704 qApp->removeTranslator(&translator); |
|
705 |
|
706 } |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 // Aiw request responses |
|
712 void AppMgrClient::handleOk(const QVariant& result) |
|
713 { |
|
714 XQAiwRequest *r = (XQAiwRequest *)sender(); |
|
715 int impl=-1; |
|
716 impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt(); |
|
717 |
|
718 if (result.canConvert<QString>()) |
|
719 { |
|
720 qDebug("AppMgrClient::%x:handleOk result=%s,%s", |
|
721 impl, |
|
722 result.typeName(), |
|
723 qPrintable(result.value<QString>())); |
|
724 mTextRetValue->setText(result.value<QString>()); |
|
725 } |
|
726 else |
|
727 { |
|
728 qDebug("AppMgrClient::%x:handleOk result=%s", |
|
729 impl, |
|
730 result.typeName()); |
|
731 mTextRetValue->setText("Not displayable"); |
|
732 } |
|
733 } |
|
734 |
|
735 void AppMgrClient::handleError(int errorCode, const QString& errorMessage) |
|
736 { |
|
737 XQAiwRequest *r = (XQAiwRequest *)sender(); |
|
738 int impl=-1; |
|
739 impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt(); |
|
740 |
|
741 qDebug("AppMgrClient::%x:handleError code=%d, errorMessage:%s", |
|
742 impl, errorCode, qPrintable(errorMessage)); |
|
743 |
|
744 mTextRetValue->setText(errorMessage); |
|
745 } |
|
746 |
|
747 |