67 |
73 |
68 qApp->setPalette(p); |
74 qApp->setPalette(p); |
69 #endif |
75 #endif |
70 |
76 |
71 QPushButton *quitButton = new QPushButton(tr("Quit")); |
77 QPushButton *quitButton = new QPushButton(tr("Quit")); |
72 QPushButton *answerButton = new QPushButton(tr("Async Answer")); |
78 QPushButton *answerButtonDial = new QPushButton(tr("Dial answer")); |
|
79 QPushButton *answerButtonUri = new QPushButton(tr("Uri answer")); |
|
80 QPushButton *answerButtonFile = new QPushButton(tr("File answer")); |
73 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); |
81 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); |
74 connect(answerButton, SIGNAL(clicked()), this, SLOT(answer())); |
82 connect(answerButtonDial, SIGNAL(clicked()), this, SLOT(answerDial())); |
|
83 connect(answerButtonUri, SIGNAL(clicked()), this, SLOT(answerUri())); |
|
84 connect(answerButtonFile, SIGNAL(clicked()), this, SLOT(answerFile())); |
75 |
85 |
76 /* |
86 /* |
77 mEndCallButton = new QPushButton(tr("End Call")); |
87 mEndCallButton = new QPushButton(tr("End Call")); |
78 mEndCallButton->setEnabled(false); |
88 mEndCallButton->setEnabled(false); |
79 connect(mEndCallButton, SIGNAL(clicked()), this, SLOT(endCall())); |
89 connect(mEndCallButton, SIGNAL(clicked()), this, SLOT(endCall())); |
80 */ |
90 */ |
81 bool isService = XQServiceUtil::isService(); |
91 bool isService = XQServiceUtil::isService(); |
|
92 QString interface = XQServiceUtil::interfaceName(); |
|
93 QString operation = XQServiceUtil::operationName(); |
82 |
94 |
83 QString t = "SERVICEAPP:\n"; |
95 QString t = "SERVICEAPP:\n"; |
84 t = t + (isService ? " LAUNCHED AS SERVICE\n" : " LAUNCHED NORMALLY\n"); |
96 t = t + (isService ? " Service launch\n" : " Normal launch\n"); |
85 t = t + (XQServiceUtil::isEmbedded() ? " EMBEDDED\n" : " NOT EMBEDDED\n"); |
97 t = t + (XQServiceUtil::isEmbedded() ? " Embedded\n" : " Not embedded\n"); |
86 |
98 t = t + (" Interface=" + interface + "\n"); |
87 QStringList args = QApplication::arguments(); |
99 t = t + (" Operation=" + operation + "\n"); |
88 foreach (QString arg, args) |
100 |
89 { |
|
90 t += "cmdline arg=" + arg + "\n"; |
|
91 } |
|
92 |
|
93 QLabel *title = new QLabel(t); |
101 QLabel *title = new QLabel(t); |
94 |
102 |
95 mLabel = new QLabel(""); |
103 mLabel = new QLabel(""); |
96 mNumber = new QLineEdit(""); |
104 mNumber = new QLineEdit(""); |
97 |
105 |
98 QVBoxLayout *vl = new QVBoxLayout; |
106 QVBoxLayout *vl = new QVBoxLayout; |
99 vl->setMargin(0); |
107 vl->setMargin(0); |
100 vl->setSpacing(0); |
108 vl->setSpacing(0); |
101 |
109 |
102 vl->addWidget(answerButton); |
|
103 vl->addWidget(quitButton); |
110 vl->addWidget(quitButton); |
|
111 vl->addWidget(answerButtonDial); |
|
112 vl->addWidget(answerButtonUri); |
|
113 vl->addWidget(answerButtonFile); |
104 vl->addWidget(title); |
114 vl->addWidget(title); |
105 vl->addWidget(mLabel); |
115 vl->addWidget(mLabel); |
106 vl->addWidget(mNumber); |
116 vl->addWidget(mNumber); |
107 |
117 |
108 setLayout(vl); |
118 setLayout(vl); |
177 |
189 |
178 // ----------DialerService--------------- |
190 // ----------DialerService--------------- |
179 |
191 |
180 DialerService::DialerService(ServiceApp* parent) |
192 DialerService::DialerService(ServiceApp* parent) |
181 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.Dialer"),parent), |
193 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.Dialer"),parent), |
182 mServiceApp(parent), |
194 mServiceApp(parent) |
183 mAsyncReqId(-1), |
|
184 mAsyncAnswer(false) |
|
185 { |
195 { |
186 XQSERVICE_DEBUG_PRINT("DialerService::DialerService"); |
196 XQSERVICE_DEBUG_PRINT("DialerService::DialerService"); |
187 publishAll(); |
197 publishAll(); |
188 connect(this, SIGNAL(returnValueDelivered()), parent, SLOT(handleAnswerDelivered())); |
|
189 } |
198 } |
190 |
199 |
191 DialerService::~DialerService() |
200 DialerService::~DialerService() |
192 { |
201 { |
193 XQSERVICE_DEBUG_PRINT("DialerService::~DialerService"); |
202 XQSERVICE_DEBUG_PRINT("DialerService::~DialerService"); |
194 } |
203 } |
195 |
204 |
196 void DialerService::complete(QString number) |
205 void DialerService::complete(QString number) |
197 { |
206 { |
198 if (mAsyncReqId == -1) |
|
199 return; |
|
200 XQSERVICE_DEBUG_PRINT("DialerService::complete"); |
207 XQSERVICE_DEBUG_PRINT("DialerService::complete"); |
201 completeRequest(mAsyncReqId,number.toInt()); |
208 |
|
209 // Complete all IDs |
|
210 foreach (quint32 reqId, mAsyncReqIds) |
|
211 { |
|
212 XQSERVICE_DEBUG_PRINT("DialerService::complete %d", reqId); |
|
213 completeRequest(reqId, number.toInt()); |
|
214 } |
202 } |
215 } |
203 |
216 |
204 int DialerService::dial(const QString& number, bool asyncAnswer) |
217 int DialerService::dial(const QString& number, bool asyncAnswer) |
205 { |
218 { |
206 XQSERVICE_DEBUG_PRINT("DialerService::dial: %s,%d", qPrintable(number), asyncAnswer); |
219 XQSERVICE_DEBUG_PRINT("DialerService::dial: %s,%d", qPrintable(number), asyncAnswer); |
207 XQRequestInfo info = requestInfo(); |
220 XQRequestInfo info = requestInfo(); |
208 |
221 |
209 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
222 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(), info.clientSecureId(), info.clientVendorId()); |
210 QSet<int> caps = info.clientCapabilities(); |
223 QSet<int> caps = info.clientCapabilities(); |
211 QSetIterator<int> i(caps); |
224 QSetIterator<int> i(caps); |
212 while (i.hasNext()) |
225 while (i.hasNext()) |
213 qDebug() << "Has capability " << i.next(); |
226 qDebug() << "Has capability " << i.next(); |
214 XQSERVICE_DEBUG_PRINT("\tRequest info: embed=%d,sync=%d", info.isEmbedded(), info.isSynchronous()); |
227 XQSERVICE_DEBUG_PRINT("\tRequest info: embed=%d,sync=%d", info.isEmbedded(), info.isSynchronous()); |
215 |
228 |
216 QString label = "Dialer::dial:\n"; |
229 QString label = "Dialer::dial:\n"; |
217 label += QString("number=%1\n").arg(number); |
230 label += QString("number=%1\n").arg(number); |
218 label += QString("asyncAnswer=%1\n").arg(asyncAnswer); |
231 label += QString("asyncAnswer=%1\n").arg(asyncAnswer); |
219 |
232 |
220 mAsyncAnswer = asyncAnswer; |
233 connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); |
|
234 |
221 mNumber = number ; |
235 mNumber = number ; |
222 mServiceApp->setLabelNumber(label, number); |
236 mServiceApp->setLabelNumber(label, number); |
223 int ret = 0; |
237 int ret = 0; |
224 if (mAsyncAnswer) |
238 if (asyncAnswer) |
225 { |
239 { |
226 mAsyncReqId = setCurrentRequestAsync(); |
240 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
227 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
241 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
228 } |
242 } |
229 else |
243 else |
230 { |
244 { |
231 ret = number.toInt(); |
245 ret = number.toInt(); |
232 } |
246 } |
233 return ret; |
247 return ret; |
234 } |
248 } |
235 |
249 |
|
250 CntServicesContactList DialerService::testContactList(CntServicesContactList list) |
|
251 { |
|
252 XQSERVICE_DEBUG_PRINT("DialerService::testContactList"); |
|
253 showRecipients(list); |
|
254 |
|
255 // Create output |
|
256 CntServicesContact cnt1; |
|
257 cnt1.mDisplayName = "Test1-Return"; |
|
258 cnt1.mPhoneNumber = "060-1111111"; |
|
259 cnt1.mEmailAddress = "test1.return@nokia.com"; |
|
260 |
|
261 CntServicesContact cnt2; |
|
262 cnt2.mDisplayName = "Test1-Return"; |
|
263 cnt2.mPhoneNumber = "060-2222222"; |
|
264 cnt2.mEmailAddress = "test2.return@nokia.com"; |
|
265 |
|
266 CntServicesContactList ret; |
|
267 ret.append(cnt1); |
|
268 ret.append(cnt2); |
|
269 |
|
270 return ret; |
|
271 |
|
272 } |
|
273 |
|
274 QVariant DialerService::testVariant(QVariant variant) |
|
275 { |
|
276 XQSERVICE_DEBUG_PRINT("DialerService::testVariant::variant(%d,%d,%s)", |
|
277 variant.type(), variant.userType(), variant.typeName()); |
|
278 XQSERVICE_DEBUG_PRINT("DialerService::testVariant::variant value=%s", qPrintable(variant.toString())); |
|
279 |
|
280 if (variant.typeName() == QLatin1String("QStringList")) |
|
281 { |
|
282 QStringList ret = variant.toStringList(); |
|
283 return qVariantFromValue(ret); |
|
284 } |
|
285 else if (variant.typeName() == QLatin1String("XQShabarableFile")) |
|
286 { |
|
287 XQSharableFile sf = variant.value<XQSharableFile>(); |
|
288 |
|
289 RFile file; |
|
290 bool ok = sf.getHandle( file ); |
|
291 if (ok) |
|
292 { |
|
293 HBufC8* data = HBufC8::NewL(100); |
|
294 TPtr8 ptr = data->Des(); |
|
295 TInt err = file.Read( ptr ); |
|
296 QString text = QString::fromUtf8((const char *)(data->Ptr()), data->Length()); |
|
297 XQSERVICE_DEBUG_PRINT("DialerService::testVariant ::file content,%d,%s", err, qPrintable(text)); |
|
298 sf.close(); |
|
299 delete data; |
|
300 } |
|
301 |
|
302 return QVariant(ok); |
|
303 |
|
304 } |
|
305 else if (variant.typeName() == QLatin1String("XQRequestInfo")) |
|
306 { |
|
307 XQRequestInfo info = variant.value<XQRequestInfo>(); |
|
308 QStringList keys = info.infoKeys(); |
|
309 foreach (QString key, keys) |
|
310 { |
|
311 XQSERVICE_DEBUG_PRINT("DialerService::testVariant: info %s=%s", |
|
312 qPrintable(key), |
|
313 qPrintable(info.info(key).toString())); |
|
314 } |
|
315 |
|
316 return qVariantFromValue(info); |
|
317 |
|
318 } |
|
319 else if (variant.typeName() == QLatin1String("CntServicesContactList")) |
|
320 { |
|
321 // Show input |
|
322 showRecipients(variant); |
|
323 |
|
324 // Create output |
|
325 CntServicesContact cnt1; |
|
326 cnt1.mDisplayName = "Test1-Return"; |
|
327 cnt1.mPhoneNumber = "060-1111111"; |
|
328 cnt1.mEmailAddress = "test1.return@nokia.com"; |
|
329 |
|
330 CntServicesContact cnt2; |
|
331 cnt2.mDisplayName = "Test1-Return"; |
|
332 cnt2.mPhoneNumber = "060-2222222"; |
|
333 cnt2.mEmailAddress = "test2.return@nokia.com"; |
|
334 |
|
335 CntServicesContactList list; |
|
336 list.append(cnt1); |
|
337 list.append(cnt2); |
|
338 |
|
339 // Return contact list back |
|
340 return qVariantFromValue(list); |
|
341 } |
|
342 else |
|
343 { |
|
344 return variant.toString(); |
|
345 } |
|
346 } |
|
347 |
236 void DialerService::handleClientDisconnect() |
348 void DialerService::handleClientDisconnect() |
237 { |
349 { |
238 XQSERVICE_DEBUG_PRINT("DialerService::handleClientDisconnect"); |
350 XQSERVICE_DEBUG_PRINT("DialerService::handleClientDisconnect"); |
|
351 |
|
352 // Get the info of the cancelled request |
|
353 XQRequestInfo info = requestInfo(); |
|
354 XQSERVICE_DEBUG_PRINT("\tDisconnected request info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
|
355 |
239 // Just quit service application if client ends |
356 // Just quit service application if client ends |
240 mAsyncAnswer = false; |
|
241 mServiceApp->quit(); |
357 mServiceApp->quit(); |
242 } |
358 } |
243 |
359 |
|
360 void DialerService::handleAnswerDelivered() |
|
361 { |
|
362 XQSERVICE_DEBUG_PRINT("DialerService::handleAnswerDelivered"); |
|
363 XQRequestInfo info = requestInfo(); |
|
364 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
365 // Done |
|
366 mAsyncReqIds.remove(info.clientSecureId()); |
|
367 } |
|
368 |
|
369 |
|
370 |
|
371 void DialerService::showRecipients(QVariant &value) |
|
372 { |
|
373 CntServicesContactList list; |
|
374 if(value.canConvert<CntServicesContactList>()) |
|
375 { |
|
376 qDebug() << "DialerService::showRecipients: canConvert"; |
|
377 list = qVariantValue<CntServicesContactList>(value); |
|
378 } |
|
379 else |
|
380 { |
|
381 qDebug() << "DialerService::showRecipients: canConvert NOK"; |
|
382 return; |
|
383 } |
|
384 |
|
385 showRecipients(list); |
|
386 } |
|
387 |
|
388 void DialerService::showRecipients(CntServicesContactList &list) |
|
389 { |
|
390 if (list.count() == 0) |
|
391 { |
|
392 qDebug() << "DialerService::showRecipients(2): Count==0"; |
|
393 } |
|
394 else |
|
395 { |
|
396 for (int i = 0; i < list.count(); ++i) |
|
397 { |
|
398 qDebug() << "DialerService::showRecipients(2)[" << i << "]=" << list[i].mDisplayName; |
|
399 qDebug() << "DialerService::showRecipients(2)[" << i << "]=" << list[i].mPhoneNumber; |
|
400 qDebug() << "DialerService::showRecipients(2)[" << i << "]=" << list[i].mEmailAddress; |
|
401 } |
|
402 } |
|
403 } |
|
404 |
|
405 |
|
406 // ----------New dialler service--------------- |
|
407 |
|
408 NewDialerService::NewDialerService(ServiceApp* parent) |
|
409 : XQServiceProvider(QLatin1String("serviceapp.Dialer"),parent), |
|
410 mServiceApp(parent) |
|
411 { |
|
412 XQSERVICE_DEBUG_PRINT("NewDialerService::NewDialerService"); |
|
413 publishAll(); |
|
414 } |
|
415 |
|
416 NewDialerService::~NewDialerService() |
|
417 { |
|
418 XQSERVICE_DEBUG_PRINT("NewDialerService::~NewDialerService"); |
|
419 } |
|
420 |
|
421 void NewDialerService::complete(QString number) |
|
422 { |
|
423 XQSERVICE_DEBUG_PRINT("NewDialerService::complete"); |
|
424 |
|
425 // Complete all IDs |
|
426 foreach (quint32 reqId, mAsyncReqIds) |
|
427 { |
|
428 XQSERVICE_DEBUG_PRINT("NewDialerService::complete %d", reqId); |
|
429 completeRequest(reqId, number.toInt()); |
|
430 } |
|
431 } |
|
432 |
|
433 int NewDialerService::dial(const QString& number, bool asyncAnswer) |
|
434 { |
|
435 XQSERVICE_DEBUG_PRINT("NewDialerService::dial: %s,%d", qPrintable(number), asyncAnswer); |
|
436 XQRequestInfo info = requestInfo(); |
|
437 |
|
438 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(), info.clientSecureId(), info.clientVendorId()); |
|
439 QSet<int> caps = info.clientCapabilities(); |
|
440 QSetIterator<int> i(caps); |
|
441 while (i.hasNext()) |
|
442 qDebug() << "Has capability " << i.next(); |
|
443 XQSERVICE_DEBUG_PRINT("\tRequest info: embed=%d,sync=%d", info.isEmbedded(), info.isSynchronous()); |
|
444 |
|
445 QString label = "NewDialer::dial:\n"; |
|
446 label += QString("number=%1\n").arg(number); |
|
447 label += QString("asyncAnswer=%1\n").arg(asyncAnswer); |
|
448 |
|
449 connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); |
|
450 |
|
451 mNumber = number ; |
|
452 mServiceApp->setLabelNumber(label, number); |
|
453 int ret = 0; |
|
454 if (asyncAnswer) |
|
455 { |
|
456 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
|
457 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
|
458 } |
|
459 else |
|
460 { |
|
461 ret = number.toInt(); |
|
462 } |
|
463 return ret; |
|
464 } |
|
465 |
|
466 CntServicesContactList NewDialerService::testContactList(CntServicesContactList list) |
|
467 { |
|
468 XQSERVICE_DEBUG_PRINT("NewDialerService::testContactList"); |
|
469 showRecipients(list); |
|
470 |
|
471 // Create output |
|
472 CntServicesContact cnt1; |
|
473 cnt1.mDisplayName = "Test1-Return"; |
|
474 cnt1.mPhoneNumber = "060-1111111"; |
|
475 cnt1.mEmailAddress = "test1.return@nokia.com"; |
|
476 |
|
477 CntServicesContact cnt2; |
|
478 cnt2.mDisplayName = "Test1-Return"; |
|
479 cnt2.mPhoneNumber = "060-2222222"; |
|
480 cnt2.mEmailAddress = "test2.return@nokia.com"; |
|
481 |
|
482 CntServicesContactList ret; |
|
483 ret.append(cnt1); |
|
484 ret.append(cnt2); |
|
485 |
|
486 return ret; |
|
487 |
|
488 } |
|
489 |
|
490 QVariant NewDialerService::testVariant(QVariant variant) |
|
491 { |
|
492 XQSERVICE_DEBUG_PRINT("NewDialerService::testVariant::variant(%d,%d,%s)", |
|
493 variant.type(), variant.userType(), variant.typeName()); |
|
494 XQSERVICE_DEBUG_PRINT("NewDialerService::testVariant::variant value=%s", qPrintable(variant.toString())); |
|
495 |
|
496 if (variant.typeName() == QLatin1String("QStringList")) |
|
497 { |
|
498 QStringList ret = variant.toStringList(); |
|
499 return qVariantFromValue(ret); |
|
500 } |
|
501 else if (variant.typeName() == QLatin1String("XQShabarableFile")) |
|
502 { |
|
503 XQSharableFile sf = variant.value<XQSharableFile>(); |
|
504 |
|
505 RFile file; |
|
506 bool ok = sf.getHandle( file ); |
|
507 if (ok) |
|
508 { |
|
509 HBufC8* data = HBufC8::NewL(100); |
|
510 TPtr8 ptr = data->Des(); |
|
511 TInt err = file.Read( ptr ); |
|
512 QString text = QString::fromUtf8((const char *)(data->Ptr()), data->Length()); |
|
513 XQSERVICE_DEBUG_PRINT("NewDialerService::testVariant ::file content,%d,%s", err, qPrintable(text)); |
|
514 sf.close(); |
|
515 delete data; |
|
516 } |
|
517 |
|
518 return QVariant(ok); |
|
519 |
|
520 } |
|
521 else if (variant.typeName() == QLatin1String("XQRequestInfo")) |
|
522 { |
|
523 XQRequestInfo info = variant.value<XQRequestInfo>(); |
|
524 QStringList keys = info.infoKeys(); |
|
525 foreach (QString key, keys) |
|
526 { |
|
527 XQSERVICE_DEBUG_PRINT("NewDialerService::testVariant: info %s=%s", |
|
528 qPrintable(key), |
|
529 qPrintable(info.info(key).toString())); |
|
530 } |
|
531 |
|
532 return qVariantFromValue(info); |
|
533 |
|
534 } |
|
535 else if (variant.typeName() == QLatin1String("CntServicesContactList")) |
|
536 { |
|
537 // Show input |
|
538 showRecipients(variant); |
|
539 |
|
540 // Create output |
|
541 CntServicesContact cnt1; |
|
542 cnt1.mDisplayName = "Test1-Return"; |
|
543 cnt1.mPhoneNumber = "060-1111111"; |
|
544 cnt1.mEmailAddress = "test1.return@nokia.com"; |
|
545 |
|
546 CntServicesContact cnt2; |
|
547 cnt2.mDisplayName = "Test1-Return"; |
|
548 cnt2.mPhoneNumber = "060-2222222"; |
|
549 cnt2.mEmailAddress = "test2.return@nokia.com"; |
|
550 |
|
551 CntServicesContactList list; |
|
552 list.append(cnt1); |
|
553 list.append(cnt2); |
|
554 |
|
555 // Return contact list back |
|
556 return qVariantFromValue(list); |
|
557 } |
|
558 else |
|
559 { |
|
560 return variant.toString(); |
|
561 } |
|
562 } |
|
563 |
|
564 void NewDialerService::handleClientDisconnect() |
|
565 { |
|
566 XQSERVICE_DEBUG_PRINT("NewDialerService::handleClientDisconnect"); |
|
567 |
|
568 // Get the info of the cancelled request |
|
569 XQRequestInfo info = requestInfo(); |
|
570 XQSERVICE_DEBUG_PRINT("\tDisconnected request info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
|
571 |
|
572 // Just quit service application if client ends |
|
573 mServiceApp->quit(); |
|
574 } |
|
575 |
|
576 void NewDialerService::handleAnswerDelivered() |
|
577 { |
|
578 XQSERVICE_DEBUG_PRINT("NewDialerService::handleAnswerDelivered"); |
|
579 XQRequestInfo info = requestInfo(); |
|
580 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
581 // Done |
|
582 mAsyncReqIds.remove(info.clientSecureId()); |
|
583 } |
|
584 |
|
585 |
|
586 |
|
587 void NewDialerService::showRecipients(QVariant &value) |
|
588 { |
|
589 CntServicesContactList list; |
|
590 if(value.canConvert<CntServicesContactList>()) |
|
591 { |
|
592 qDebug() << "NewDialerService::showRecipients: canConvert"; |
|
593 list = qVariantValue<CntServicesContactList>(value); |
|
594 } |
|
595 else |
|
596 { |
|
597 qDebug() << "NewDialerService::showRecipients: canConvert NOK"; |
|
598 return; |
|
599 } |
|
600 |
|
601 showRecipients(list); |
|
602 } |
|
603 |
|
604 void NewDialerService::showRecipients(CntServicesContactList &list) |
|
605 { |
|
606 if (list.count() == 0) |
|
607 { |
|
608 qDebug() << "NewDialerService::showRecipients(2): Count==0"; |
|
609 } |
|
610 else |
|
611 { |
|
612 for (int i = 0; i < list.count(); ++i) |
|
613 { |
|
614 qDebug() << "NewDialerService::showRecipients(2)[" << i << "]=" << list[i].mDisplayName; |
|
615 qDebug() << "NewDialerService::showRecipients(2)[" << i << "]=" << list[i].mPhoneNumber; |
|
616 qDebug() << "NewDialerService::showRecipients(2)[" << i << "]=" << list[i].mEmailAddress; |
|
617 } |
|
618 } |
|
619 } |
|
620 |
|
621 |
|
622 |
|
623 Q_IMPLEMENT_USER_METATYPE(CntServicesContact) |
|
624 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList) |
244 |
625 |
245 // ----------UriService--------------- |
626 // ----------UriService--------------- |
246 |
627 |
247 UriService::UriService(ServiceApp* parent) |
628 UriService::UriService(ServiceApp* parent) |
248 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.com.nokia.symbian.IUriView"),parent), |
629 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.com.nokia.symbian.IUriView"),parent), |
249 mServiceApp(parent), |
630 mServiceApp(parent) |
250 mAsyncReqId(-1), |
|
251 mAsyncAnswer(false) |
|
252 |
631 |
253 { |
632 { |
254 XQSERVICE_DEBUG_PRINT("UriService::UriService"); |
633 XQSERVICE_DEBUG_PRINT("UriService::UriService"); |
255 publishAll(); |
634 publishAll(); |
256 } |
635 } |
280 QString label = "IUri::view\n:"; |
662 QString label = "IUri::view\n:"; |
281 label += QString ("Uri=%1\n").arg(uri); |
663 label += QString ("Uri=%1\n").arg(uri); |
282 label += QString ("retValue=%1\n").arg(retValue); |
664 label += QString ("retValue=%1\n").arg(retValue); |
283 QString param = QString ("retValue=%1\n").arg(retValue); |
665 QString param = QString ("retValue=%1\n").arg(retValue); |
284 |
666 |
285 mAsyncAnswer = !XQServiceUtil::isEmbedded();; |
667 XQRequestInfo info = requestInfo(); |
|
668 bool asyncAnswer = !info.isSynchronous();; |
|
669 connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); |
|
670 |
286 mRetValue = retValue; |
671 mRetValue = retValue; |
287 mServiceApp->setLabelNumber(label,param); |
672 mServiceApp->setLabelNumber(label,param); |
288 if (mAsyncAnswer) |
673 if (asyncAnswer) |
289 { |
674 { |
290 mAsyncReqId = setCurrentRequestAsync(); |
675 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
291 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
676 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
292 } |
677 } |
293 |
678 |
294 return retValue; |
679 return retValue; |
295 } |
680 } |
296 |
681 |
297 void UriService::handleClientDisconnect() |
682 void UriService::handleClientDisconnect() |
298 { |
683 { |
299 XQSERVICE_DEBUG_PRINT("UriService::handleClientDisconnect"); |
684 XQSERVICE_DEBUG_PRINT("UriService::handleClientDisconnect"); |
300 |
685 XQRequestInfo info = requestInfo(); |
301 // Just quit application |
686 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
302 mAsyncAnswer = false; |
687 |
|
688 mAsyncReqIds.remove(info.clientSecureId()); |
303 mServiceApp->quit(); |
689 mServiceApp->quit(); |
|
690 } |
|
691 |
|
692 void UriService::handleAnswerDelivered() |
|
693 { |
|
694 XQSERVICE_DEBUG_PRINT("UriService::handleAnswerDelivered"); |
|
695 XQRequestInfo info = requestInfo(); |
|
696 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
697 // Done |
|
698 mAsyncReqIds.remove(info.clientSecureId()); |
|
699 |
|
700 } |
|
701 |
|
702 // ----------NewUriService--------------- |
|
703 |
|
704 NewUriService::NewUriService(ServiceApp* parent) |
|
705 : XQServiceProvider(QLatin1String("serviceapp.com.nokia.symbian.IUriView"),parent), |
|
706 mServiceApp(parent) |
|
707 |
|
708 { |
|
709 XQSERVICE_DEBUG_PRINT("NewUriService::NewUriService"); |
|
710 publishAll(); |
|
711 } |
|
712 |
|
713 NewUriService::~NewUriService() |
|
714 { |
|
715 XQSERVICE_DEBUG_PRINT("NewUriService::~NewUriService"); |
|
716 } |
|
717 |
|
718 void NewUriService::complete(bool ok) |
|
719 { |
|
720 XQSERVICE_DEBUG_PRINT("NewUriService::complete"); |
|
721 // Complete all IDs |
|
722 foreach (quint32 reqId, mAsyncReqIds) |
|
723 { |
|
724 XQSERVICE_DEBUG_PRINT("NewUriService::complete %d", reqId); |
|
725 completeRequest(reqId, QVariant(mRetValue)); |
|
726 } |
|
727 } |
|
728 |
|
729 bool NewUriService::view(const QString& uri) |
|
730 { |
|
731 XQSERVICE_DEBUG_PRINT("NewUriService::view(1)"); |
|
732 return view(uri, true); |
|
733 } |
|
734 |
|
735 bool NewUriService::view(const QString& uri, bool retValue) |
|
736 { |
|
737 XQSERVICE_DEBUG_PRINT("NewUriService::view(2)"); |
|
738 QString label = "New IUri::view\n:"; |
|
739 label += QString ("Uri=%1\n").arg(uri); |
|
740 label += QString ("retValue=%1\n").arg(retValue); |
|
741 QString param = QString ("retValue=%1\n").arg(retValue); |
|
742 |
|
743 XQRequestInfo info = requestInfo(); |
|
744 bool asyncAnswer = !info.isSynchronous();; |
|
745 connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); |
|
746 |
|
747 mRetValue = retValue; |
|
748 mServiceApp->setLabelNumber(label,param); |
|
749 if (asyncAnswer) |
|
750 { |
|
751 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
|
752 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
|
753 } |
|
754 |
|
755 return retValue; |
|
756 } |
|
757 |
|
758 void NewUriService::handleClientDisconnect() |
|
759 { |
|
760 XQSERVICE_DEBUG_PRINT("NewUriService::handleClientDisconnect"); |
|
761 XQRequestInfo info = requestInfo(); |
|
762 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
|
763 |
|
764 mAsyncReqIds.remove(info.clientSecureId()); |
|
765 mServiceApp->quit(); |
|
766 } |
|
767 |
|
768 void NewUriService::handleAnswerDelivered() |
|
769 { |
|
770 XQSERVICE_DEBUG_PRINT("NewUriService::handleAnswerDelivered"); |
|
771 XQRequestInfo info = requestInfo(); |
|
772 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
773 // Done |
|
774 mAsyncReqIds.remove(info.clientSecureId()); |
|
775 |
304 } |
776 } |
305 |
777 |
306 |
778 |
307 // ----------FileService--------------- |
779 // ----------FileService--------------- |
308 |
780 |
309 FileService::FileService(ServiceApp* parent) |
781 FileService::FileService(ServiceApp* parent) |
310 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.com.nokia.symbian.IFileView"),parent), |
782 : XQServiceProvider(QLatin1String("com.nokia.services.serviceapp.com.nokia.symbian.IFileView"),parent), |
311 mServiceApp(parent), |
783 mServiceApp(parent) |
312 mAsyncReqId(-1), |
|
313 mAsyncAnswer(false) |
|
314 |
784 |
315 { |
785 { |
316 XQSERVICE_DEBUG_PRINT("FileService::FileService"); |
786 XQSERVICE_DEBUG_PRINT("FileService::FileService"); |
317 publishAll(); |
787 publishAll(); |
318 } |
788 } |
365 XQSERVICE_DEBUG_PRINT("FileService::file read,%d,%s", err, qPrintable(text)); |
841 XQSERVICE_DEBUG_PRINT("FileService::file read,%d,%s", err, qPrintable(text)); |
366 sf.close(); |
842 sf.close(); |
367 delete data; |
843 delete data; |
368 } |
844 } |
369 |
845 |
370 mAsyncAnswer = !XQServiceUtil::isEmbedded();; |
846 XQRequestInfo info = requestInfo(); |
|
847 bool asyncAnswer = !info.isSynchronous();; |
|
848 |
371 mServiceApp->setLabelNumber(label,param); |
849 mServiceApp->setLabelNumber(label,param); |
372 if (mAsyncAnswer) |
850 if (asyncAnswer) |
373 { |
851 { |
374 mAsyncReqId = setCurrentRequestAsync(); |
852 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
375 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
853 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
376 } |
854 } |
377 return true; |
855 return true; |
378 } |
856 } |
379 |
857 |
380 |
858 |
381 void FileService::handleClientDisconnect() |
859 void FileService::handleClientDisconnect() |
382 { |
860 { |
383 XQSERVICE_DEBUG_PRINT("FileService::handleClientDisconnect"); |
861 XQSERVICE_DEBUG_PRINT("FileService::handleClientDisconnect"); |
384 |
862 XQRequestInfo info = requestInfo(); |
385 // Just quit application |
863 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
386 mAsyncAnswer = false; |
864 |
|
865 mAsyncReqIds.remove(info.clientSecureId()); |
387 mServiceApp->quit(); |
866 mServiceApp->quit(); |
388 } |
867 } |
389 |
868 |
|
869 |
|
870 void FileService::handleAnswerDelivered() |
|
871 { |
|
872 XQSERVICE_DEBUG_PRINT("FileService::handleAnswerDelivered"); |
|
873 XQRequestInfo info = requestInfo(); |
|
874 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
875 // Done |
|
876 mAsyncReqIds.remove(info.clientSecureId()); |
|
877 |
|
878 } |
|
879 |
|
880 |
|
881 // ----------NewFileService--------------- |
|
882 |
|
883 NewFileService::NewFileService(ServiceApp* parent) |
|
884 : XQServiceProvider(QLatin1String("serviceapp.com.nokia.symbian.IFileView"),parent), |
|
885 mServiceApp(parent) |
|
886 |
|
887 { |
|
888 XQSERVICE_DEBUG_PRINT("NewFileService::NewFileService"); |
|
889 publishAll(); |
|
890 } |
|
891 |
|
892 NewFileService::~NewFileService() |
|
893 { |
|
894 XQSERVICE_DEBUG_PRINT("NewFileService::~NewFileService"); |
|
895 } |
|
896 |
|
897 void NewFileService::complete(bool ok) |
|
898 { |
|
899 XQSERVICE_DEBUG_PRINT("NewFileService::complete"); |
|
900 // Complete all |
|
901 foreach (quint32 reqId, mAsyncReqIds) |
|
902 { |
|
903 XQSERVICE_DEBUG_PRINT("NewFileService::complete %d", reqId); |
|
904 completeRequest(reqId, QVariant(ok)); |
|
905 } |
|
906 } |
|
907 |
|
908 bool NewFileService::view(QString file) |
|
909 { |
|
910 XQSERVICE_DEBUG_PRINT("NewFileService::view(QString)"); |
|
911 QString label = "New IFile::view\n:"; |
|
912 QString param = QString ("File=%1\n").arg(file); |
|
913 |
|
914 XQRequestInfo info = requestInfo(); |
|
915 bool asyncAnswer = !info.isSynchronous();; |
|
916 connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); |
|
917 |
|
918 mServiceApp->setLabelNumber(label,param); |
|
919 if (asyncAnswer) |
|
920 { |
|
921 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
|
922 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
|
923 } |
|
924 |
|
925 return true; |
|
926 } |
|
927 |
|
928 |
|
929 bool NewFileService::view(XQSharableFile sf) |
|
930 { |
|
931 XQSERVICE_DEBUG_PRINT("NewFileService::view(XQSharebleFile)"); |
|
932 QString label = "IFile::view\n:"; |
|
933 QString param = QString ("File=%1\n").arg(sf.fileName()); |
|
934 |
|
935 RFile file; |
|
936 bool ok = sf.getHandle( file ); |
|
937 if (ok) |
|
938 { |
|
939 HBufC8* data = HBufC8::NewL(100); |
|
940 TPtr8 ptr = data->Des(); |
|
941 TInt err = file.Read( ptr ); |
|
942 QString text = QString::fromUtf8((const char *)(data->Ptr()), data->Length()); |
|
943 XQSERVICE_DEBUG_PRINT("NewFileService::file read,%d,%s", err, qPrintable(text)); |
|
944 sf.close(); |
|
945 delete data; |
|
946 } |
|
947 |
|
948 XQRequestInfo info = requestInfo(); |
|
949 bool asyncAnswer = !info.isSynchronous();; |
|
950 |
|
951 mServiceApp->setLabelNumber(label,param); |
|
952 if (asyncAnswer) |
|
953 { |
|
954 mAsyncReqIds.insert(info.clientSecureId(), setCurrentRequestAsync()); |
|
955 connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); |
|
956 } |
|
957 return true; |
|
958 } |
|
959 |
|
960 |
|
961 void NewFileService::handleClientDisconnect() |
|
962 { |
|
963 XQSERVICE_DEBUG_PRINT("NewFileService::handleClientDisconnect"); |
|
964 XQRequestInfo info = requestInfo(); |
|
965 XQSERVICE_DEBUG_PRINT("\tRequest info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); |
|
966 |
|
967 mAsyncReqIds.remove(info.clientSecureId()); |
|
968 mServiceApp->quit(); |
|
969 } |
|
970 |
|
971 |
|
972 void NewFileService::handleAnswerDelivered() |
|
973 { |
|
974 XQSERVICE_DEBUG_PRINT("NewFileService::handleAnswerDelivered"); |
|
975 XQRequestInfo info = requestInfo(); |
|
976 XQSERVICE_DEBUG_PRINT("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); |
|
977 // Done |
|
978 mAsyncReqIds.remove(info.clientSecureId()); |
|
979 |
|
980 } |
|
981 |