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 <cntservicescontact.h> |
|
45 |
|
46 #include <XQSharableFile.h> |
|
47 |
|
48 // Include declarations to see if any compilation issues |
|
49 #include <xqaiwdecl.h> |
|
50 #include <xqaiwdeclplat.h> |
|
51 |
|
52 #include "appmgrservices.h" |
|
53 #include "appmgrclient.h" |
|
54 |
|
55 |
|
56 // |
|
57 // TODO: Better UI for test cases which allows |
|
58 // more test cases. |
|
59 // |
|
60 AppMgrClient::AppMgrClient(QWidget *parent, Qt::WFlags f) |
|
61 : QWidget(parent, f), |
|
62 actionButton(0), |
|
63 req1(0), |
|
64 req2(0), |
|
65 req3(0), |
|
66 req4(0), |
|
67 req5(0), |
|
68 req6(0), |
|
69 req7(0), |
|
70 req8(0), |
|
71 req9(0), |
|
72 req10(0), |
|
73 anyReq(0), |
|
74 mImplIndex(0) |
|
75 { |
|
76 /* Adjust the palette */ |
|
77 #if defined(Q_WS_S60) |
|
78 QPalette p = qApp->palette(); |
|
79 QColor color(192,192,192); |
|
80 QColor bg(0,128,192); |
|
81 p.setColor(QPalette::Highlight, color.lighter(200)); |
|
82 p.setColor(QPalette::Text, Qt::black); |
|
83 p.setColor(QPalette::Base, bg); |
|
84 p.setColor(QPalette::WindowText, Qt::black); |
|
85 p.setColor(QPalette::Window, bg); |
|
86 p.setColor(QPalette::ButtonText, Qt::black); |
|
87 p.setColor(QPalette::Button, color.lighter(150)); |
|
88 p.setColor(QPalette::Link, QColor(240,40,40)); |
|
89 qApp->setPalette(p); |
|
90 #endif |
|
91 |
|
92 QPushButton *quitButton = new QPushButton(tr("quit")); |
|
93 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
94 |
|
95 |
|
96 QPushButton *testButton1 = 0; |
|
97 QPushButton *anyTestButton = 0; |
|
98 |
|
99 testButton1 = new QPushButton("Tests"); |
|
100 mMenu = new QMenu(this); |
|
101 testButton1->setMenu(mMenu); |
|
102 anyTestButton = new QPushButton(tr("Any test")); |
|
103 connect(anyTestButton, SIGNAL(clicked()), this, SLOT(anyTest())); |
|
104 |
|
105 QAction *test1 = new QAction("1:Interface", this); |
|
106 connect(test1, SIGNAL(triggered()), this, SLOT(test1())); |
|
107 QAction *test2 = new QAction("2:Descriptor", this); |
|
108 connect(test2, SIGNAL(triggered()), this, SLOT(test2())); |
|
109 QAction *test3 = new QAction("3:Big data", this); |
|
110 connect(test3, SIGNAL(triggered()), this, SLOT(test3())); |
|
111 QAction *test4 = new QAction("4:QAction", this); |
|
112 connect(test4, SIGNAL(triggered()), this, SLOT(test4())); |
|
113 QAction *test5 = new QAction("5:appto:", this); |
|
114 connect(test5, SIGNAL(triggered()), this, SLOT(test5())); |
|
115 QAction *test6 = new QAction("6:testto:", this); |
|
116 connect(test6, SIGNAL(triggered()), this, SLOT(test6())); |
|
117 QAction *test7 = new QAction("7:MIME", this); |
|
118 connect(test7, SIGNAL(triggered()), this, SLOT(test7())); |
|
119 QAction *test8 = new QAction("8:URI", this); |
|
120 connect(test8, SIGNAL(triggered()), this, SLOT(test8())); |
|
121 QAction *test9 = new QAction("9:XQSharableFile", this); |
|
122 connect(test9, SIGNAL(triggered()), this, SLOT(test9())); |
|
123 QAction *test10 = new QAction("10:Select contact", this); |
|
124 connect(test10, SIGNAL(triggered()), this, SLOT(test10())); |
|
125 QAction *test11 = new QAction("11:getDrmAttr", this); |
|
126 connect(test11, SIGNAL(triggered()), this, SLOT(test11())); |
|
127 |
|
128 mMenu = new QMenu(this); |
|
129 mMenu->addAction(test1); |
|
130 mMenu->addAction(test2); |
|
131 mMenu->addAction(test3); |
|
132 mMenu->addAction(test4); |
|
133 mMenu->addAction(test5); |
|
134 mMenu->addAction(test6); |
|
135 mMenu->addAction(test7); |
|
136 mMenu->addAction(test8); |
|
137 mMenu->addAction(test9); |
|
138 mMenu->addAction(test10); |
|
139 mMenu->addAction(test11); |
|
140 |
|
141 testButton1->setMenu(mMenu); |
|
142 |
|
143 mCheckEmbedded = new QCheckBox("Embedded"); |
|
144 mSynchronous = new QCheckBox("Synchronous"); |
|
145 mBackground = new QCheckBox("Background"); |
|
146 mForeground = new QCheckBox("Foreground"); |
|
147 mCheckDeleteRequest = new QCheckBox("Delete request"); |
|
148 mGenericSend = new QCheckBox("Use generic send()"); |
|
149 mCheckEmbedded->setCheckState(Qt::Checked); |
|
150 mSynchronous->setCheckState(Qt::Checked); |
|
151 mGenericSend->setCheckState(Qt::Checked); // Apply one send() for both embedded/non-embedded |
|
152 |
|
153 |
|
154 QLabel *inputData = new QLabel(tr("Data size")); |
|
155 mDataSpinBox = new QSpinBox; |
|
156 mDataSpinBox->setMinimum(0); |
|
157 mDataSpinBox->setMaximum(1024*1024); |
|
158 mDataSpinBox->setValue(1024); |
|
159 mDataSpinBox->setSingleStep(1024*10); |
|
160 |
|
161 mReqArg = new QLineEdit("0"); |
|
162 mTextRetValue = new QLineEdit("no ret value set"); |
|
163 |
|
164 QFileInfo appinfo (qApp->applicationFilePath()); |
|
165 mAppName = "XQTESTER " + appinfo.baseName(); |
|
166 |
|
167 QLabel *label = new QLabel(mAppName); |
|
168 |
|
169 vl = new QVBoxLayout; |
|
170 vl->setMargin(0); |
|
171 vl->setSpacing(0); |
|
172 |
|
173 vl->addWidget(label); |
|
174 vl->addWidget(mCheckEmbedded); |
|
175 vl->addWidget(mSynchronous); |
|
176 vl->addWidget(mBackground); |
|
177 vl->addWidget(mForeground); |
|
178 vl->addWidget(mCheckDeleteRequest); |
|
179 vl->addWidget(mGenericSend); |
|
180 vl->addWidget(inputData); |
|
181 vl->addWidget(mDataSpinBox); |
|
182 vl->addWidget(mReqArg); |
|
183 vl->addWidget(mTextRetValue); |
|
184 vl->addWidget(new QLabel(" ")); |
|
185 vl->addWidget(testButton1); |
|
186 vl->addWidget(anyTestButton); |
|
187 vl->addWidget(quitButton); |
|
188 |
|
189 setLayout(vl); |
|
190 |
|
191 #if defined(Q_WS_X11) || defined(Q_WS_WIN) |
|
192 setFixedSize(QSize(360,640)); // nHD |
|
193 #elif defined(Q_WS_S60) |
|
194 // showMaximized(); |
|
195 showFullScreen(); |
|
196 #endif |
|
197 |
|
198 } |
|
199 |
|
200 AppMgrClient::~AppMgrClient() |
|
201 { |
|
202 delete req1; |
|
203 delete req2; |
|
204 delete req3; |
|
205 delete req4; |
|
206 delete req5; |
|
207 delete req6; |
|
208 delete req7; |
|
209 delete req8; |
|
210 delete req9; |
|
211 delete req10; |
|
212 delete mMenu; |
|
213 |
|
214 } |
|
215 |
|
216 // Tester helper function |
|
217 bool AppMgrClient::test(XQAiwRequest **req, const QString& interface, const QString& operation) |
|
218 { |
|
219 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
220 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
221 bool background = (mBackground->checkState() == Qt::Checked); |
|
222 |
|
223 qDebug() << mAppName << " test options: embed=" << embed << ",sync=" << sync << "background=" << background; |
|
224 |
|
225 if (!*req) |
|
226 { |
|
227 *req = appmgr.create(interface, operation); |
|
228 assert(mTestCase + ".req != NULL", *req != NULL); |
|
229 if (!*req) |
|
230 { |
|
231 qDebug() << mAppName << " AIW-ERROR::NULL request"; |
|
232 qDebug() << mAppName << " Last error=" << appmgr.lastError(); |
|
233 return false; |
|
234 } |
|
235 connectSignals(*req); |
|
236 } |
|
237 // Test embedded funcions |
|
238 (*req)->setEmbedded(embed); |
|
239 (*req)->setSynchronous(sync); |
|
240 (*req)->setBackground(background); |
|
241 |
|
242 |
|
243 bool ret=test(req, mReqArg->text()); |
|
244 |
|
245 return ret; |
|
246 |
|
247 } |
|
248 |
|
249 |
|
250 // Tester helper function |
|
251 bool AppMgrClient::test(XQAiwRequest **req, XQAiwInterfaceDescriptor &impl, const QString& operation) |
|
252 { |
|
253 if (!*req) |
|
254 { |
|
255 *req = appmgr.create(impl, operation); |
|
256 assert(mTestCase + ".req != NULL", *req != NULL); |
|
257 connectSignals(*req); |
|
258 } |
|
259 bool ret = test(req, mReqArg->text()); |
|
260 |
|
261 return ret; |
|
262 } |
|
263 |
|
264 |
|
265 |
|
266 // Tester helper function |
|
267 bool AppMgrClient::test(XQAiwRequest **req, const QString &arg) |
|
268 { |
|
269 |
|
270 if (!req || !*req) |
|
271 { |
|
272 qDebug() << mAppName << " AIW-ERROR::NULL request"; |
|
273 return false; |
|
274 } |
|
275 |
|
276 |
|
277 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
278 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
279 bool background = (mBackground->checkState() == Qt::Checked); |
|
280 bool foreground = (mForeground->checkState() == Qt::Checked); |
|
281 qDebug() << mAppName << " test options: embed=" << embed << ",sync=" << sync << "background=" << background; |
|
282 |
|
283 bool ret=true; |
|
284 |
|
285 // Set arguments for request |
|
286 QList<QVariant> args; |
|
287 args << arg; |
|
288 if ((*req)->operation() == OPERATION1) |
|
289 { |
|
290 args << QVariant(!sync); |
|
291 } |
|
292 (*req)->setArguments(args); |
|
293 |
|
294 bool genericSend = (mGenericSend->checkState() == Qt::Checked); |
|
295 (*req)->setEmbedded(embed); |
|
296 (*req)->setSynchronous(sync); |
|
297 (*req)->setBackground(background); |
|
298 |
|
299 // Apply additional options |
|
300 XQRequestInfo options; |
|
301 options.setForeground(foreground); |
|
302 // Save the test case to options as tester data. This data is also passed to service app |
|
303 // The test case is utilized in requestOk and requestError signal handlers |
|
304 options.setInfo(TESTCASE_INFO_KEY, mTestCase); |
|
305 (*req)->setInfo(options); |
|
306 |
|
307 // Make the request |
|
308 if (genericSend || !sync) |
|
309 { |
|
310 if (!(*req)->send()) |
|
311 { |
|
312 qDebug() << mAppName << " AIW-ERROR:test: Send failed" << (*req)->lastError();; |
|
313 ret=false; |
|
314 } |
|
315 } |
|
316 else if (!genericSend && sync) |
|
317 { |
|
318 QVariant retValue; |
|
319 if (!(*req)->send(retValue)) |
|
320 { |
|
321 qDebug() << mAppName << " AIW-ERROR: test: Send(retValue) failed" << (*req)->lastError();; |
|
322 ret=false; |
|
323 } |
|
324 else |
|
325 { |
|
326 if (retValue.canConvert<QString>()) |
|
327 { |
|
328 qDebug("%s::retValue=%s,%s", qPrintable(mAppName), |
|
329 retValue.typeName(), |
|
330 qPrintable(retValue.value<QString>())); |
|
331 mTextRetValue->setText(retValue.value<QString>()); |
|
332 } |
|
333 else |
|
334 { |
|
335 qDebug("%s:retValue=%s", qPrintable(mAppName), |
|
336 retValue.typeName()); |
|
337 mTextRetValue->setText("Not displayable"); |
|
338 } |
|
339 |
|
340 } |
|
341 } |
|
342 |
|
343 assert(mTestCase + ".lastError==0", !(*req)->lastError()); |
|
344 |
|
345 // Delete request if wanted |
|
346 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
347 |
|
348 if ((*req)->lastError() == XQService::EMessageNotFound) |
|
349 { |
|
350 // Slot was not found |
|
351 deleteRequest = true; |
|
352 } |
|
353 |
|
354 if (deleteRequest) |
|
355 { |
|
356 qDebug() << mAppName << " AIW-NOTE: Request deleted"; |
|
357 delete *req; |
|
358 *req = 0; |
|
359 } |
|
360 |
|
361 update(); |
|
362 |
|
363 return ret; |
|
364 |
|
365 |
|
366 } |
|
367 |
|
368 |
|
369 // Tester helper function |
|
370 void AppMgrClient::connectSignals(XQAiwRequest *req) |
|
371 { |
|
372 if (req) |
|
373 { |
|
374 // Connect signals once |
|
375 connect(req, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
376 connect(req, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
|
377 } |
|
378 } |
|
379 |
|
380 |
|
381 // Tester helper function |
|
382 void AppMgrClient::createTestFile(const QString &dir, const QString &fileName) |
|
383 { |
|
384 |
|
385 QDir d("."); |
|
386 d.mkpath(dir); |
|
387 qDebug() << dir; |
|
388 |
|
389 QFile file(dir + "/" + fileName); |
|
390 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) |
|
391 { |
|
392 qDebug() << mAppName << " Creating file failed " << QString(dir + "/" + fileName); |
|
393 return; |
|
394 } |
|
395 QTextStream out(&file); |
|
396 out << "Text in file" << "\n"; |
|
397 file.close(); |
|
398 |
|
399 } |
|
400 |
|
401 // Tester helper function |
|
402 void AppMgrClient::assert(const QString &testName, bool testResult) |
|
403 { |
|
404 qDebug("%s,ASSERT,%s,%s", qPrintable(mAppName), qPrintable(testName),testResult?"OK" : "FAILED"); |
|
405 } |
|
406 |
|
407 |
|
408 // Tester helper function |
|
409 bool AppMgrClient::testRunning(const QString & service, const QString & interface) |
|
410 { |
|
411 |
|
412 QList<XQAiwInterfaceDescriptor> impls = appmgr.list(service, interface, QString("")); |
|
413 if (impls.count() > 0) |
|
414 { |
|
415 bool b = appmgr.isRunning(impls[0]); |
|
416 return b; |
|
417 } |
|
418 else |
|
419 { |
|
420 return false; |
|
421 } |
|
422 |
|
423 } |
|
424 |
|
425 |
|
426 /* |
|
427 * Test1: |
|
428 * - Call the first IDIAL interface found. |
|
429 * - Test XQAplicationManager::isRunning |
|
430 * See appmgrservices.h |
|
431 */ |
|
432 void AppMgrClient::test1() |
|
433 { |
|
434 |
|
435 mTestCase = "Test1"; |
|
436 qDebug() << mAppName << " test1 START"; |
|
437 assert("Test1",test(&req1, IDIAL, OPERATION1)); |
|
438 |
|
439 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
440 if (!embed) |
|
441 { |
|
442 // Works only for non-embedded cases (no point to check embedded case) |
|
443 assert("Test1.isRunning", testRunning("serviceapp", IDIAL)); |
|
444 } |
|
445 qDebug() << mAppName << " test1 END"; |
|
446 |
|
447 } |
|
448 |
|
449 /* |
|
450 * Test2: |
|
451 * - List all the IDIAL interfaces |
|
452 * - List all the IDIAL interfaces of the old serviceapp service name |
|
453 * - List all the IDIAL interfaces of the new serviceapp service name |
|
454 * See appmgrservices.h |
|
455 */ |
|
456 void AppMgrClient::test2() |
|
457 { |
|
458 mTestCase = "Test2"; |
|
459 |
|
460 qDebug() << mAppName << " test2 START"; |
|
461 |
|
462 QList<XQAiwInterfaceDescriptor> list=appmgr.list(IDIAL, ""); |
|
463 qDebug() << mAppName << " list implementations: " << list.count(); |
|
464 int i=0; |
|
465 assert("Test2.list.count() > 0", list.count() > 0); |
|
466 foreach (XQAiwInterfaceDescriptor d, list) |
|
467 { |
|
468 qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName())); |
|
469 qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName())); |
|
470 qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
471 qDebug("%s::isRunning=%d", qPrintable(mAppName), testRunning(d.serviceName(), d.interfaceName())); |
|
472 qDebug("%s::status=%d", qPrintable(mAppName), appmgr.status(d)); |
|
473 i++; |
|
474 } |
|
475 |
|
476 // Old, deprecated service name |
|
477 QList<XQAiwInterfaceDescriptor> list2=appmgr.list("com.nokia.services.serviceapp", IDIAL, ""); |
|
478 qDebug() << mAppName << " list implementations 2: " << list2.count(); |
|
479 i=0; |
|
480 assert("Test2.list2.count() > 0",list2.count() > 0); |
|
481 foreach (XQAiwInterfaceDescriptor d, list2) |
|
482 { |
|
483 qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName())); |
|
484 qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName())); |
|
485 qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
486 i++; |
|
487 } |
|
488 |
|
489 // Service name |
|
490 QList<XQAiwInterfaceDescriptor> list3=appmgr.list("serviceapp", IDIAL, ""); |
|
491 qDebug() << mAppName << " New: list implementations: " << list3.count(); |
|
492 i=0; |
|
493 assert("Test2.list3.count() > 0", list3.count() > 0); |
|
494 foreach (XQAiwInterfaceDescriptor d, list3) |
|
495 { |
|
496 qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName())); |
|
497 qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName())); |
|
498 qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
499 i++; |
|
500 } |
|
501 |
|
502 if (!list.isEmpty()) |
|
503 { |
|
504 // Use the first found |
|
505 qDebug() << mAppName << " Using implementation nbr: " << mImplIndex; |
|
506 test(&req2,list[mImplIndex], OPERATION1); |
|
507 } |
|
508 |
|
509 qDebug() << mAppName << " test2 END"; |
|
510 |
|
511 } |
|
512 |
|
513 /* |
|
514 * Test3: |
|
515 * - Using serviceapp and IDIAL interface test passing big amount of data. |
|
516 The datasize can be given in the mDataSpinBox field. |
|
517 At least 0.5 MB shall be passed OK |
|
518 * See appmgrservices.h |
|
519 */ |
|
520 void AppMgrClient::test3() |
|
521 { |
|
522 |
|
523 mTestCase = "Test3"; |
|
524 qDebug() << mAppName << " test3 START"; |
|
525 |
|
526 QByteArray data; |
|
527 qDebug() << mAppName << "Data size=" << mDataSpinBox->value(); |
|
528 data.fill('X', mDataSpinBox->value()); |
|
529 |
|
530 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
531 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
532 bool background = (mBackground->checkState() == Qt::Checked); |
|
533 |
|
534 XQAiwRequest *req=0; |
|
535 req = appmgr.create(QLatin1String("serviceapp"), IDIAL, QLatin1String("")); |
|
536 assert("Test3.req != NULL", req != NULL); |
|
537 |
|
538 if (!req) |
|
539 { |
|
540 return; |
|
541 } |
|
542 |
|
543 // Apply this operation |
|
544 req->setOperation(QLatin1String("testVariant(QVariant)")); |
|
545 |
|
546 connectSignals(req); |
|
547 |
|
548 // Set request attributes |
|
549 req->setEmbedded(embed); |
|
550 req->setSynchronous(sync); |
|
551 req->setBackground(background); |
|
552 |
|
553 XQRequestInfo info; |
|
554 // Save the test case to options as tester data. This data is also passed to service app |
|
555 // The test case is utilized in requestOk and requestError signal handlers |
|
556 info.setInfo(TESTCASE_INFO_KEY, mTestCase); |
|
557 req->setInfo(info); |
|
558 |
|
559 QList<QVariant> args; |
|
560 |
|
561 args.clear(); |
|
562 args << qVariantFromValue(data); |
|
563 req->setArguments(args); |
|
564 |
|
565 assert("Test3.send", req->send()); |
|
566 |
|
567 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
568 if (deleteRequest) |
|
569 { |
|
570 delete req; |
|
571 req = 0; |
|
572 } |
|
573 |
|
574 qDebug() << mAppName << " test3 END"; |
|
575 |
|
576 } |
|
577 |
|
578 /* |
|
579 * Test4: |
|
580 * - Test QAction creation using the service "com.nokia.services.hbserviceprovider" and IDIAL interface |
|
581 (The com.nokia.services.hbserviceprovider is implemented by the examples/hbserviceprovider |
|
582 which should be built and included in ROM) |
|
583 The successfully created QAction adds a Test button to UI. |
|
584 Pressing the button emits the signal "test4ActionTriggered" to get input args |
|
585 (the actual "send" happens after returning from the signal) |
|
586 * See appmgrservices.h |
|
587 */ |
|
588 void AppMgrClient::test4() |
|
589 { |
|
590 mTestCase = "Test4"; |
|
591 qDebug() << mAppName << " test4 START"; |
|
592 |
|
593 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
594 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
595 bool foreground = (mForeground->checkState() == Qt::Checked); |
|
596 |
|
597 if (req4) |
|
598 { |
|
599 delete req4; // Previous |
|
600 req4 = 0; |
|
601 } |
|
602 |
|
603 // Only hbserviceprovider support localization |
|
604 req4 = appmgr.create("com.nokia.services.hbserviceprovider", IDIAL, OPERATION1, true); |
|
605 assert("Test4.req4 != NULL", req4 != NULL); |
|
606 if (!req4) |
|
607 { |
|
608 return; |
|
609 } |
|
610 |
|
611 connectSignals(req4); |
|
612 req4->setSynchronous(sync); |
|
613 |
|
614 // In this test case, apply "options" for other options |
|
615 XQRequestInfo options; |
|
616 options.setEmbedded(embed); |
|
617 options.setForeground(foreground); |
|
618 // Save the test case to options as tester data. This data is also passed to service app |
|
619 // The test case is utilized in requestOk and requestError signal handlers |
|
620 options.setInfo(TESTCASE_INFO_KEY, mTestCase); |
|
621 req4->setInfo(options); |
|
622 |
|
623 if (actionButton) |
|
624 { |
|
625 // Previous |
|
626 vl->removeWidget(actionButton); |
|
627 delete actionButton; |
|
628 actionButton = 0; |
|
629 update(); |
|
630 } |
|
631 |
|
632 QAction *action = req4->createAction(); // Also connects the triggered event to req !!!! |
|
633 assert("Test4.action != NULL", action != NULL); |
|
634 |
|
635 // Create UI |
|
636 if (action) |
|
637 { |
|
638 actionButton = new QPushButton(action->text()); |
|
639 actionButton->addAction(action); |
|
640 vl->addWidget(actionButton); |
|
641 setLayout(vl); |
|
642 // For some reason triggered does not come from request |
|
643 // Workaround... |
|
644 connect(actionButton, SIGNAL(clicked()), action, SIGNAL(triggered())); |
|
645 connect(req4, SIGNAL(triggered()), this, SLOT(test4ActionTriggered())); |
|
646 qDebug() << mAppName << " Press Test button"; |
|
647 } |
|
648 |
|
649 |
|
650 } |
|
651 |
|
652 // Test button pressed from UI |
|
653 void AppMgrClient::test4ActionTriggered() |
|
654 { |
|
655 XQAiwRequest *r = (XQAiwRequest *)sender(); |
|
656 |
|
657 // Set arguments for request |
|
658 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
659 QList<QVariant> args; |
|
660 args << QVariant(mReqArg->text()); |
|
661 args << QVariant(!embed); |
|
662 r->setArguments(args); |
|
663 } |
|
664 |
|
665 /* |
|
666 * Test5: |
|
667 * - Test launching activity URI for the UID E0022E70 (fire-and-forget launch) |
|
668 (The E0022E70 is the examples/hbserviceclient which should be built and included in ROM) |
|
669 * See appmgrservices.h |
|
670 */ |
|
671 void AppMgrClient::test5() |
|
672 { |
|
673 mTestCase = "Test5"; |
|
674 qDebug() << mAppName << " test5 START"; |
|
675 |
|
676 QUrl uri(XQURI_SCHEME_ACTIVITY + "://E0022E70?" + XQURI_KEY_ACTIVITY_NAME + "=MainView&key1=data1&key2=data2"); |
|
677 qDebug() << mAppName << " Uri=" << uri.toString(); |
|
678 qDebug() << mAppName << " isValid=" << uri.isValid(); |
|
679 qDebug() << mAppName << " Uri authority=" << uri.authority(); |
|
680 QString old=mReqArg->text(); |
|
681 if (!req5) |
|
682 { |
|
683 req5 = appmgr.create(uri); |
|
684 assert("Test5.req5 != NULL", req5 != NULL); |
|
685 connectSignals(req5); |
|
686 } |
|
687 |
|
688 mReqArg->setText(uri.encodedQuery()); |
|
689 assert("Test5", test(&req5, mReqArg->text())); |
|
690 mReqArg->setText(old); |
|
691 |
|
692 qDebug() << mAppName << " test5 END"; |
|
693 |
|
694 } |
|
695 |
|
696 /* |
|
697 * Test6: |
|
698 * - Test launching URI scheme "testto" implemented by the examples/serviceapp |
|
699 */ |
|
700 void AppMgrClient::test6() |
|
701 { |
|
702 |
|
703 mTestCase = "Test5"; |
|
704 qDebug() << mAppName << " test6 START"; |
|
705 |
|
706 // QUrl uri("testto://authority?param1=value1¶m1=value2"); |
|
707 QUrl uri("testto://authority?param1=value1¶m1=value2"); |
|
708 qDebug() << mAppName << " Uri=" << uri.toString(); |
|
709 qDebug() << mAppName << " isValid=" << uri.isValid(); |
|
710 qDebug() << mAppName << " Uri authority=" << uri.authority(); |
|
711 |
|
712 QList<XQAiwInterfaceDescriptor> uriHandlers = appmgr.list(uri); |
|
713 assert("Test6.uriHandlers.count() > 0", uriHandlers.count() > 0); |
|
714 |
|
715 // Note : Only services supporting custom property are returned |
|
716 foreach (XQAiwInterfaceDescriptor d, uriHandlers) |
|
717 { |
|
718 qDebug() << mAppName << " Service=" << d.serviceName(); |
|
719 qDebug() << mAppName << " Interface=" << d.interfaceName(); |
|
720 qDebug("%s::Implementation Id=%x",qPrintable(mAppName),d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
721 qDebug("%s::isRunning=%d", qPrintable(mAppName), testRunning(d.serviceName(), d.interfaceName())); |
|
722 } |
|
723 |
|
724 if (!req6) |
|
725 { |
|
726 req6 = appmgr.create(uri); |
|
727 assert("Test5.req6 != NULL", req6 != NULL); |
|
728 connectSignals(req6); |
|
729 } |
|
730 |
|
731 assert("Test6",test(&req6, uri.toString())); |
|
732 |
|
733 qDebug() << mAppName << " test6 END"; |
|
734 |
|
735 } |
|
736 |
|
737 /* |
|
738 * Test7: |
|
739 * - Test launching com.nokia.symbian.IFileView for non-data-caged text file (MIME type text/plain) |
|
740 * At least the examples/serviceapp implements support for interface |
|
741 */ |
|
742 void AppMgrClient::test7() |
|
743 { |
|
744 mTestCase = "Test7"; |
|
745 qDebug() << mAppName << " test7 START"; |
|
746 |
|
747 // Create test file (MIME type text/plain) |
|
748 createTestFile("C:/data/Others", "test.txt"); |
|
749 |
|
750 |
|
751 QFile file("C:/data/Others/test.txt"); |
|
752 qDebug() << mAppName << " File=" << file.fileName(); |
|
753 qDebug() << mAppName << " exists=" << file.exists(); |
|
754 |
|
755 QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(file); |
|
756 assert("Test7.fileHandlers.count() > 0", fileHandlers.count() > 0); |
|
757 foreach (XQAiwInterfaceDescriptor d, fileHandlers) |
|
758 { |
|
759 qDebug() << mAppName << " Service=" << d.serviceName(); |
|
760 qDebug() << mAppName << " Interface=" << d.interfaceName(); |
|
761 qDebug("%s::Implementation Id=%x",qPrintable(mAppName),d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
762 } |
|
763 |
|
764 if (!req7) |
|
765 { |
|
766 req7 = appmgr.create(file); |
|
767 assert("Test5.req7 != NULL", req7 != NULL); |
|
768 connectSignals(req7); |
|
769 } |
|
770 assert("Test7",test(&req7, file.fileName())); |
|
771 |
|
772 qDebug() << mAppName << " test7 END"; |
|
773 |
|
774 } |
|
775 |
|
776 |
|
777 /* |
|
778 * Test8: |
|
779 * - Test launching http URI which should be implemented by the Browser |
|
780 Note ! http scheme is handled by the QDesktopServices::openUrl. |
|
781 */ |
|
782 void AppMgrClient::test8() |
|
783 { |
|
784 mTestCase = "Test8"; |
|
785 qDebug() << mAppName << " test8 START"; |
|
786 |
|
787 // E0022E73 == ServiceApp |
|
788 QUrl uri("http://www.nokia.com"); |
|
789 qDebug() << mAppName << " Uri=" << uri.toString(); |
|
790 qDebug() << mAppName << " isValid=" << uri.isValid(); |
|
791 qDebug() << mAppName << " Uri authority=" << uri.authority(); |
|
792 |
|
793 if (!req8) |
|
794 { |
|
795 req8 = appmgr.create(uri); |
|
796 assert("Test8.req8 != NULL", req8 != NULL); |
|
797 connectSignals(req8); |
|
798 } |
|
799 assert("Test8", test(&req8, uri.toString())); |
|
800 |
|
801 qDebug() << mAppName << " test8 END"; |
|
802 |
|
803 } |
|
804 |
|
805 /* |
|
806 * Test9: |
|
807 * - Test launching com.nokia.symbian.IFileView for data-caged text file (MIME type text/plain) |
|
808 * At least the examples/serviceapp implements support for interface |
|
809 */ |
|
810 void AppMgrClient::test9() |
|
811 { |
|
812 |
|
813 mTestCase = "Test9"; |
|
814 qDebug() << mAppName << " test9 START"; |
|
815 |
|
816 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
817 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
818 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
819 |
|
820 |
|
821 // Access data-caged file |
|
822 XQSharableFile sf; |
|
823 QString fileDir = "c:/private/e0022e74"; |
|
824 |
|
825 if (mAppName == "appmgrclient2") |
|
826 { |
|
827 fileDir = "c:/private/e0022e76"; |
|
828 } |
|
829 |
|
830 createTestFile(fileDir, "test.txt"); |
|
831 if (!sf.open(fileDir + "\\test.txt")) |
|
832 { |
|
833 qDebug() << mAppName << " file open failed " << (fileDir + "/test.txt"); |
|
834 return; |
|
835 } |
|
836 |
|
837 // Just test listing by sharable file |
|
838 QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(sf); |
|
839 assert("Test9.fileHandlers.count() > 0", fileHandlers.count() > 0); |
|
840 if (fileHandlers.count() > 0) |
|
841 { |
|
842 XQAiwInterfaceDescriptor d = fileHandlers.first(); |
|
843 qDebug() << mAppName << " File Service=" << d.serviceName(); |
|
844 qDebug() << mAppName << " File Interface=" << d.interfaceName(); |
|
845 qDebug("%s::Implementation Id=%x",qPrintable(mAppName),d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt()); |
|
846 if (!req9) |
|
847 { |
|
848 // Create by descriptor |
|
849 req9 = appmgr.create(sf, d); |
|
850 assert("Test9.req9 != NULL", req9 != NULL); |
|
851 } |
|
852 if (!req9) |
|
853 { |
|
854 sf.close(); |
|
855 return ; |
|
856 } |
|
857 } |
|
858 else |
|
859 { |
|
860 sf.close(); |
|
861 } |
|
862 |
|
863 connectSignals(req9); |
|
864 req9->setEmbedded(embed); |
|
865 req9->setSynchronous(sync); |
|
866 |
|
867 QList<QVariant> args; |
|
868 args << qVariantFromValue(sf); |
|
869 req9->setArguments(args); |
|
870 |
|
871 XQRequestInfo info; |
|
872 // Save the test case to options as tester data. This data is also passed to service app |
|
873 // The test case is utilized in requestOk and requestError signal handlers |
|
874 info.setInfo(TESTCASE_INFO_KEY, mTestCase); |
|
875 req9->setInfo(info); |
|
876 |
|
877 assert("Test9.send", req9->send()); |
|
878 assert(mTestCase + ".lastError==0", !req9->lastError()); |
|
879 |
|
880 // Remember to close the file !!! |
|
881 sf.close(); |
|
882 |
|
883 if (deleteRequest) |
|
884 { |
|
885 delete req9; |
|
886 req9 = 0; |
|
887 } |
|
888 |
|
889 qDebug() << mAppName << " test9 END"; |
|
890 |
|
891 } |
|
892 |
|
893 /* |
|
894 * Test10: |
|
895 * - Test fetching contacts via the "com.nokia.services.phonebookservices" interfaces |
|
896 Note ! This is deprecated interface name still used. The official name is "com.nokia.symbian.IContactFetch" |
|
897 once phonebook supports that. |
|
898 */ |
|
899 void AppMgrClient::test10() |
|
900 { |
|
901 |
|
902 mTestCase = "Test10"; |
|
903 qDebug() << mAppName << " test10 START"; |
|
904 |
|
905 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
906 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
907 bool background = (mBackground->checkState() == Qt::Checked); |
|
908 |
|
909 qDebug() << mAppName << " test10: embed=" << embed << ",sync=" << sync << "background=" << background; |
|
910 |
|
911 if (!req10) |
|
912 { |
|
913 req10 = appmgr.create(QLatin1String("com.nokia.services.phonebookservices"), QLatin1String("Fetch"), QLatin1String("")); |
|
914 assert("Test10.req10 != NULL", req10 != NULL); |
|
915 if (req10) |
|
916 { |
|
917 connect(req10, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
918 connect(req10, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
|
919 } |
|
920 } |
|
921 |
|
922 if (!req10) |
|
923 { |
|
924 return; |
|
925 } |
|
926 |
|
927 // Set request attributes |
|
928 req10->setOperation("fetch(QString,QString,QString)"); |
|
929 req10->setEmbedded(embed); |
|
930 req10->setSynchronous(sync); |
|
931 req10->setBackground(background); |
|
932 |
|
933 // Set arguments |
|
934 QList<QVariant> args; |
|
935 args << "Contact"; |
|
936 args << KCntActionAll; |
|
937 args << KCntFilterDisplayAll; |
|
938 req10->setArguments(args); |
|
939 |
|
940 XQRequestInfo info; |
|
941 // Save the test case to options as tester data. This data is also passed to service app |
|
942 // The test case is utilized in requestOk and requestError signal handlers |
|
943 info.setInfo(TESTCASE_INFO_KEY, mTestCase); |
|
944 req10->setInfo(info); |
|
945 |
|
946 // Send the request |
|
947 assert("Test10.send", req10->send()); |
|
948 assert(mTestCase + ".lastError==0", !req10->lastError()); |
|
949 |
|
950 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
951 if (deleteRequest) |
|
952 { |
|
953 delete req10; |
|
954 req10 = 0; |
|
955 } |
|
956 |
|
957 qDebug() << mAppName << " test10 END"; |
|
958 |
|
959 |
|
960 } |
|
961 |
|
962 |
|
963 /* |
|
964 * Test10: |
|
965 * - Test getting DRM attributes of the files included in the examples\appmgrclient\DrmTestFiles.zip |
|
966 (You need to unzip/transfer these files in correct location) |
|
967 */ |
|
968 void AppMgrClient::test11() |
|
969 { |
|
970 mTestCase = "Test11"; |
|
971 qDebug() << mAppName << " test11 START"; |
|
972 |
|
973 // Copy files from DrmTestFiles.zip into correct location |
|
974 QList<QString> drmFiles; |
|
975 drmFiles.append("C:/data/Others/RoAcqoffer-111-aac-i15m.ort"); |
|
976 drmFiles.append("C:/data/Others/SD_Celebration_SP.dcf"); |
|
977 drmFiles.append("C:/data/Others/111-test1.odf"); |
|
978 drmFiles.append("C:/data/Others/SD_jpg_sun.dcf"); |
|
979 drmFiles.append("C:/data/Others/STC1_128_44_16_2_CBR.wma"); |
|
980 drmFiles.append("C:/data/Others/test.txt"); |
|
981 drmFiles.append("C:/data/Others/some-nonexisting-file.txt"); // Error |
|
982 |
|
983 QList<int> attrNames; |
|
984 attrNames.append(XQApplicationManager::MimeType); |
|
985 attrNames.append(XQApplicationManager::IsProtected); |
|
986 attrNames.append(XQApplicationManager::IsForwardable); |
|
987 // See other attributes from epoc32/include/caf/caftypes.h |
|
988 |
|
989 // Test with file names |
|
990 foreach (QString f, drmFiles) |
|
991 { |
|
992 QFile file(f); |
|
993 QVariantList attrValues; |
|
994 bool ok = appmgr.getDrmAttributes(file, attrNames, attrValues); |
|
995 assert("Test11.getDrmAttributes.QFile/" + f, |
|
996 f != QString("C:/data/Others/some-nonexisting-file.txt") ? ok : !ok); |
|
997 int i=0; |
|
998 foreach (QVariant v, attrValues) |
|
999 { |
|
1000 qDebug() << mAppName << " Attribute " << attrNames[i] << "=" << qPrintable(v.toString()); |
|
1001 i++; |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 // Test with file handles |
|
1006 foreach (QString f, drmFiles) |
|
1007 { |
|
1008 XQSharableFile file; |
|
1009 file.open(f); // Create handle manually |
|
1010 QVariantList attrValues; |
|
1011 bool ok = appmgr.getDrmAttributes(file, attrNames, attrValues); |
|
1012 assert("Test11.getDrmAttributes.XQSharableFile/" + f, |
|
1013 f != QString("C:/data/Others/some-nonexisting-file.txt") ? ok : !ok); |
|
1014 int i=0; |
|
1015 foreach (QVariant v, attrValues) |
|
1016 { |
|
1017 qDebug() << mAppName << " Attribute " << attrNames[i] << "=" << qPrintable(v.toString()); |
|
1018 i++; |
|
1019 } |
|
1020 file.close(); |
|
1021 } |
|
1022 |
|
1023 qDebug() << mAppName << " test11 END"; |
|
1024 |
|
1025 } |
|
1026 |
|
1027 |
|
1028 #define TXT_ID QLatin1String("txt_aiw_action_text") |
|
1029 |
|
1030 // |
|
1031 // Miscellanous ad-hoc tests for trying bugs, etc. |
|
1032 // |
|
1033 void AppMgrClient::anyTest() |
|
1034 { |
|
1035 |
|
1036 #if 0 |
|
1037 bool embed = (mCheckEmbedded->checkState() == Qt::Checked); |
|
1038 bool sync = (mSynchronous->checkState() == Qt::Checked); |
|
1039 bool background = (mBackground->checkState() == Qt::Checked); |
|
1040 |
|
1041 XQAiwRequest *req=0; |
|
1042 req = appmgr.create(QLatin1String("serviceapp"), IDIAL, QLatin1String("")); |
|
1043 |
|
1044 if (!req) |
|
1045 { |
|
1046 qDebug() << mAppName << " AIW-ERROR NULL request"; |
|
1047 return; |
|
1048 } |
|
1049 |
|
1050 // Apply this operation |
|
1051 req->setOperation(QLatin1String("testVariant(QVariant)")); |
|
1052 |
|
1053 connectSignals(req); |
|
1054 |
|
1055 // Set request attributes |
|
1056 req->setEmbedded(embed); |
|
1057 req->setSynchronous(sync); |
|
1058 req->setBackground(background); |
|
1059 |
|
1060 QList<QVariant> args; |
|
1061 |
|
1062 /* |
|
1063 // Just construct dummies |
|
1064 MetaDummy1 dummy1; |
|
1065 MetaDummy2 dummy2; |
|
1066 */ |
|
1067 |
|
1068 /* |
|
1069 // THIS WORKS |
|
1070 CntServicesContact cnt1; |
|
1071 cnt1.mDisplayName = "Test1"; |
|
1072 cnt1.mPhoneNumber = "050-1111111"; |
|
1073 cnt1.mEmailAddress = "test1.test@nokia.com"; |
|
1074 |
|
1075 CntServicesContact cnt2; |
|
1076 cnt2.mDisplayName = "Test2"; |
|
1077 cnt2.mPhoneNumber = "050-2222222"; |
|
1078 cnt2.mEmailAddress = "test2.test@nokia.com"; |
|
1079 |
|
1080 CntServicesContactList list; |
|
1081 list.append(cnt1); |
|
1082 list.append(cnt2); |
|
1083 */ |
|
1084 |
|
1085 QVariant v1; |
|
1086 QVariant v2; |
|
1087 QVariant v3; |
|
1088 v1.setValue((int)-99); |
|
1089 v2.setValue((bool)true); |
|
1090 v3.setValue(QString("Variant3")); |
|
1091 TestServiceData data1(1, v1); |
|
1092 TestServiceData data2(2, v2); |
|
1093 TestServiceData data3(3, v3); |
|
1094 TestServiceDataList list; |
|
1095 list.append(data1); |
|
1096 list.append(data2); |
|
1097 list.append(data3); |
|
1098 |
|
1099 args.clear(); |
|
1100 args << qVariantFromValue(list); |
|
1101 req->setArguments(args); |
|
1102 |
|
1103 req->send(); |
|
1104 |
|
1105 bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked); |
|
1106 if (deleteRequest) |
|
1107 { |
|
1108 delete req; |
|
1109 req = 0; |
|
1110 } |
|
1111 |
|
1112 qDebug() << mAppName << " test END"; |
|
1113 |
|
1114 // ---- OLD TESTS ------ |
|
1115 |
|
1116 /* |
|
1117 qDebug() << mAppName << " name" << qApp->applicationName(); |
|
1118 qDebug() << mAppName << " dirpath" << qApp->applicationDirPath(); |
|
1119 qDebug() << mAppName << " filename" << qApp->applicationFilePath(); |
|
1120 qDebug() << mAppName << " pid" << qApp->applicationPid(); |
|
1121 |
|
1122 QFileInfo appinfo (qApp->applicationFilePath()); |
|
1123 qDebug() << mAppName << " appinfo.applicationFilePath" << qApp->applicationFilePath(); |
|
1124 qDebug() << mAppName << " appinfo.absolutePath" << appinfo.absolutePath(); |
|
1125 qDebug() << mAppName << " appinfo.baseName" << appinfo.baseName(); |
|
1126 |
|
1127 QString lang = QLocale::system().name(); |
|
1128 qDebug() << mAppName << " anyTest:" << lang; |
|
1129 |
|
1130 // QString textFile = "z:/resource/qt/translations/hbserviceprovider"; |
|
1131 QString textFile = "hbserviceprovider"; |
|
1132 QFileInfo info(textFile); |
|
1133 qDebug() << mAppName << " base" << info.baseName(); |
|
1134 qDebug() << mAppName << " path" << info.filePath(); |
|
1135 if (info.baseName() == info.filePath()) |
|
1136 { |
|
1137 textFile = qApp->applicationFilePath().left(2) + "/resource/qt/translations/" + textFile; |
|
1138 qDebug() << mAppName << " path added" << textFile; |
|
1139 } |
|
1140 |
|
1141 textFile += "_"; |
|
1142 textFile += lang; |
|
1143 qDebug() << mAppName << " anyTest:" << textFile; |
|
1144 |
|
1145 QTranslator translator; |
|
1146 bool res = translator.load(textFile); |
|
1147 qDebug() << mAppName << " anyTest:" << res; |
|
1148 if (res) |
|
1149 { |
|
1150 qApp->installTranslator(&translator); |
|
1151 } |
|
1152 |
|
1153 QString textId = TXT_ID; |
|
1154 QByteArray ba = textId.toLatin1(); |
|
1155 const char *textPtr = ba.data(); |
|
1156 |
|
1157 QString text = qtTrId(textPtr); // translate |
|
1158 qDebug() << mAppName << " translated text:" << text; |
|
1159 |
|
1160 qApp->removeTranslator(&translator); |
|
1161 |
|
1162 Q_ASSERT(0==1); |
|
1163 |
|
1164 QString str("e0022e70"); |
|
1165 uint ui = str.toUInt(); |
|
1166 qDebug() << mAppName << " toUInt value=" << ui; |
|
1167 bool b=false; |
|
1168 ui=str.toUInt(&b,16); |
|
1169 qDebug() << mAppName << " toUInt status=" << b << ",value=" << ui; |
|
1170 |
|
1171 |
|
1172 */ |
|
1173 |
|
1174 #endif |
|
1175 } |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 // Aiw request responses |
|
1181 void AppMgrClient::handleOk(const QVariant& result) |
|
1182 { |
|
1183 XQAiwRequest *r = static_cast<XQAiwRequest *>(sender()); |
|
1184 QString testCase = (r->info().info(TESTCASE_INFO_KEY)).toString(); |
|
1185 |
|
1186 int impl=-1; |
|
1187 impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt(); |
|
1188 QString interface = r->descriptor().interfaceName(); |
|
1189 QString service = r->descriptor().serviceName(); |
|
1190 |
|
1191 qDebug("%s,%s::requestOk,from [%s.%s,%x]", |
|
1192 qPrintable(mAppName), |
|
1193 qPrintable(testCase), |
|
1194 qPrintable(service), |
|
1195 qPrintable(interface), |
|
1196 impl); |
|
1197 qDebug("%s,%s::requestOk,result type=%s", |
|
1198 qPrintable(mAppName), |
|
1199 qPrintable(testCase), |
|
1200 result.typeName()); |
|
1201 |
|
1202 if (result.canConvert<CntServicesContactList>()) |
|
1203 { |
|
1204 CntServicesContactList list; |
|
1205 list = qVariantValue<CntServicesContactList>(result); |
|
1206 for (int i = 0; i < list.count(); ++i) |
|
1207 { |
|
1208 qDebug() << mAppName << "," << testCase << ",result[" << i << "].mDisplayName=" << list[i].mDisplayName; |
|
1209 qDebug() << mAppName << "," << testCase << " result[" << i << "].mPhoneNumber=" << list[i].mPhoneNumber; |
|
1210 qDebug() << mAppName << "," << testCase << ",result[" << i << "].mEmailAddress=" << list[i].mEmailAddress; |
|
1211 |
|
1212 } |
|
1213 } |
|
1214 else if (result.canConvert<TestServiceDataList>()) |
|
1215 { |
|
1216 TestServiceDataList list = qVariantValue<TestServiceDataList>(result); |
|
1217 for (int i = 0; i < list.count(); ++i) |
|
1218 { |
|
1219 qDebug() << mAppName << "," << testCase << ",result[" << i << "].mType=" << list[i].mType; |
|
1220 qDebug() << mAppName << "," << testCase << ",result[" << i << "].mData=" << list[i].mData.toString(); |
|
1221 } |
|
1222 |
|
1223 } |
|
1224 else if (result.canConvert<QString>()) |
|
1225 { |
|
1226 qDebug("%s,%s,result=%s", |
|
1227 qPrintable(mAppName), |
|
1228 qPrintable(testCase), |
|
1229 qPrintable(result.value<QString>())); |
|
1230 mTextRetValue->setText(result.value<QString>()); |
|
1231 } |
|
1232 |
|
1233 else |
|
1234 { |
|
1235 mTextRetValue->setText("Not displayable"); |
|
1236 } |
|
1237 } |
|
1238 |
|
1239 void AppMgrClient::handleError(int errorCode, const QString& errorMessage) |
|
1240 { |
|
1241 XQAiwRequest *r = static_cast<XQAiwRequest *>(sender()); |
|
1242 QString interface = r->descriptor().interfaceName(); |
|
1243 QString service = r->descriptor().serviceName(); |
|
1244 QString testCase = (r->info().info(TESTCASE_INFO_KEY)).toString(); |
|
1245 |
|
1246 int impl=-1; |
|
1247 impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt(); |
|
1248 |
|
1249 qDebug("%s,%s::requestError,from [%s.%s,%x]=(%d,%s)", |
|
1250 qPrintable(mAppName), |
|
1251 qPrintable(testCase), |
|
1252 qPrintable(service), |
|
1253 qPrintable(interface), |
|
1254 impl, errorCode, qPrintable(errorMessage)); |
|
1255 |
|
1256 mTextRetValue->setText(errorMessage); |
|
1257 } |
|
1258 |
|
1259 |
|
1260 |
|
1261 Q_IMPLEMENT_USER_METATYPE(MetaDummy1) |
|
1262 Q_IMPLEMENT_USER_METATYPE(MetaDummy2) |
|
1263 Q_IMPLEMENT_USER_METATYPE(CntServicesContact) |
|
1264 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList) |
|
1265 Q_IMPLEMENT_USER_METATYPE(TestServiceData) |
|
1266 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(TestServiceDataList) |
|