26 #include <hbmainwindow.h> |
26 #include <hbmainwindow.h> |
27 #include <qtcontacts.h> |
27 #include <qtcontacts.h> |
28 #include <hbview.h> |
28 #include <hbview.h> |
29 #include <QGraphicsLinearLayout> |
29 #include <QGraphicsLinearLayout> |
30 #include <QDebug> |
30 #include <QDebug> |
|
31 #include <HbAction> |
31 |
32 |
32 #include "cntdebug.h" |
33 #include "cntdebug.h" |
33 |
34 |
34 |
35 |
35 testPbkServices::testPbkServices(HbMainWindow *aParent) |
36 testPbkServices::testPbkServices(HbMainWindow *aParent) : |
36 { |
37 mRequest(NULL), |
37 mRequest=NULL; |
38 mMainWindow(aParent), |
38 mMainWindow=aParent; |
39 mPopup(NULL) |
|
40 { |
39 setParent(aParent); |
41 setParent(aParent); |
40 |
|
41 } |
42 } |
42 |
43 |
43 testPbkServices::~testPbkServices() |
44 testPbkServices::~testPbkServices() |
44 { |
45 { |
45 delete mRequest; |
46 delete mRequest; |
136 QContactPhoneNumber::DefinitionName, // aDetailType |
137 QContactPhoneNumber::DefinitionName, // aDetailType |
137 "1234567"); // aFieldContent |
138 "1234567"); // aFieldContent |
138 CNT_EXIT |
139 CNT_EXIT |
139 } |
140 } |
140 |
141 |
|
142 void testPbkServices::launchEditCreateNew_numberWithSubtype() |
|
143 { |
|
144 CNT_ENTRY |
|
145 launchEditCreateNew( |
|
146 true, // aNewInterface |
|
147 QContactPhoneNumber::DefinitionName, // aDetailType |
|
148 "1234567", // aFieldContent |
|
149 QContactPhoneNumber::SubTypeLandline); //aDetailSubtype |
|
150 CNT_EXIT |
|
151 } |
|
152 |
|
153 void testPbkServices::launchEditCreateNew_numberWithSubtype_old() |
|
154 { |
|
155 CNT_ENTRY |
|
156 launchEditCreateNew( |
|
157 false, // aNewInterface |
|
158 QContactPhoneNumber::DefinitionName, // aDetailType |
|
159 "1234567", // aFieldContent |
|
160 QContactPhoneNumber::SubTypeLandline); //aDetailSubtype |
|
161 CNT_EXIT |
|
162 } |
|
163 |
141 void testPbkServices::launchEditCreateNew_email() |
164 void testPbkServices::launchEditCreateNew_email() |
142 { |
165 { |
143 CNT_ENTRY |
166 CNT_ENTRY |
144 launchEditCreateNew( |
167 launchEditCreateNew( |
145 true, // aNewInterface |
168 true, // aNewInterface |
176 QContactOnlineAccount::DefinitionName, // aDetailType |
199 QContactOnlineAccount::DefinitionName, // aDetailType |
177 "account@provider.com"); // aFieldContent |
200 "account@provider.com"); // aFieldContent |
178 CNT_EXIT |
201 CNT_EXIT |
179 } |
202 } |
180 |
203 |
|
204 void testPbkServices::launchEditCreateNew_onlineAccountWithSubtype() |
|
205 { |
|
206 CNT_ENTRY |
|
207 launchEditCreateNew( |
|
208 true, // aNewInterface |
|
209 QContactOnlineAccount::DefinitionName, // aDetailType |
|
210 "provider:account@provider.com", // aFieldContent |
|
211 QContactOnlineAccount::SubTypeImpp); // aDetailSubtype |
|
212 CNT_EXIT |
|
213 } |
|
214 |
|
215 void testPbkServices::launchEditCreateNew_onlineAccountWithSubtype_old() |
|
216 { |
|
217 CNT_ENTRY |
|
218 launchEditCreateNew( |
|
219 false, // aNewInterface |
|
220 QContactOnlineAccount::DefinitionName, // aDetailType |
|
221 "provider:account@provider.com", // aFieldContent |
|
222 QContactOnlineAccount::SubTypeImpp); // aDetailSubtype |
|
223 CNT_EXIT |
|
224 } |
|
225 |
181 void testPbkServices::launchEditorVCard() |
226 void testPbkServices::launchEditorVCard() |
182 { |
227 { |
183 CNT_ENTRY |
228 CNT_ENTRY |
184 launchEditorVCard( |
229 launchEditorVCard( |
185 true); // aNewInterface |
230 true); // aNewInterface |
212 QContactPhoneNumber::DefinitionName, // aDetailType |
257 QContactPhoneNumber::DefinitionName, // aDetailType |
213 "1234567"); // aDetailValue |
258 "1234567"); // aDetailValue |
214 CNT_EXIT |
259 CNT_EXIT |
215 } |
260 } |
216 |
261 |
|
262 void testPbkServices::launchEditUpdateExisting_numberWithSubtype() |
|
263 { |
|
264 CNT_ENTRY |
|
265 launchEditUpdateExisting( |
|
266 true, // aNewInterface |
|
267 QContactPhoneNumber::DefinitionName, // aDetailType |
|
268 "1234567", // aDetailValue |
|
269 QContactPhoneNumber::SubTypeLandline);// aDetailSubtype |
|
270 CNT_EXIT |
|
271 } |
|
272 |
|
273 void testPbkServices::launchEditUpdateExisting_numberWithSubtype_old() |
|
274 { |
|
275 CNT_ENTRY |
|
276 launchEditUpdateExisting( |
|
277 false, // aNewInterface |
|
278 QContactPhoneNumber::DefinitionName, // aDetailType |
|
279 "1234567", // aDetailValue |
|
280 QContactPhoneNumber::SubTypeLandline);// aDetailSubtype |
|
281 CNT_EXIT |
|
282 } |
|
283 |
217 void testPbkServices::launchEditUpdateExisting_email() |
284 void testPbkServices::launchEditUpdateExisting_email() |
218 { |
285 { |
219 CNT_ENTRY |
286 CNT_ENTRY |
220 launchEditUpdateExisting( |
287 launchEditUpdateExisting( |
221 true, // aNewInterface |
288 true, // aNewInterface |
252 QContactOnlineAccount::DefinitionName, // aDetailType |
319 QContactOnlineAccount::DefinitionName, // aDetailType |
253 "account@provider.com"); // aDetailValue |
320 "account@provider.com"); // aDetailValue |
254 CNT_EXIT |
321 CNT_EXIT |
255 } |
322 } |
256 |
323 |
|
324 void testPbkServices::launchEditUpdateExisting_onlineAccountWithSubtype() |
|
325 { |
|
326 CNT_ENTRY |
|
327 launchEditUpdateExisting( |
|
328 true, // aNewInterface |
|
329 QContactOnlineAccount::DefinitionName, // aDetailType |
|
330 "provider:account@provider.com", // aDetailValue |
|
331 QContactOnlineAccount::SubTypeImpp); // aDetailSubtype |
|
332 CNT_EXIT |
|
333 } |
|
334 |
|
335 void testPbkServices::launchEditUpdateExisting_onlineAccountWithSubtype_old() |
|
336 { |
|
337 CNT_ENTRY |
|
338 launchEditUpdateExisting( |
|
339 false, // aNewInterface |
|
340 QContactOnlineAccount::DefinitionName, // aDetailType |
|
341 "provider:account@provider.com", // aDetailValue |
|
342 QContactOnlineAccount::SubTypeImpp); // aDetailSubtype |
|
343 CNT_EXIT |
|
344 } |
|
345 |
257 void testPbkServices::launchContactCard() |
346 void testPbkServices::launchContactCard() |
258 { |
347 { |
259 CNT_ENTRY |
348 CNT_ENTRY |
260 launchContactCard( |
349 launchContactCard( |
261 true ); // aNewInterface |
350 true ); // aNewInterface |
326 CNT_ENTRY |
415 CNT_ENTRY |
327 launchContactCard( |
416 launchContactCard( |
328 true, // aNewInterface |
417 true, // aNewInterface |
329 QContactOnlineAccount::DefinitionName, // aDetailType |
418 QContactOnlineAccount::DefinitionName, // aDetailType |
330 "account@provider.com" ); // aDetailValue |
419 "account@provider.com" ); // aDetailValue |
|
420 CNT_EXIT |
|
421 } |
|
422 |
|
423 void testPbkServices::launchGroupMemberView() |
|
424 { |
|
425 CNT_ENTRY |
|
426 delete mRequest; |
|
427 mRequest=0; |
|
428 |
|
429 // save test contact |
|
430 QContactManager mgr("symbian"); |
|
431 QContact contact; |
|
432 QContactName name; |
|
433 QContactPhoneNumber number; |
|
434 |
|
435 name.setFirstName("Test_Contact"); |
|
436 number.setNumber("0202223344"); |
|
437 contact.saveDetail(&name); |
|
438 contact.saveDetail(&number); |
|
439 mgr.saveContact(&contact); |
|
440 |
|
441 // save test group |
|
442 QString text("Work"); |
|
443 QContact groupContact; |
|
444 groupContact.setType(QContactType::TypeGroup); |
|
445 QContactName groupName; |
|
446 groupName.setCustomLabel(text); |
|
447 groupContact.saveDetail(&groupName); |
|
448 mgr.saveContact(&groupContact); |
|
449 QContactRelationship relationship; |
|
450 relationship.setRelationshipType(QContactRelationship::HasMember); |
|
451 relationship.setFirst(groupContact.id()); |
|
452 relationship.setSecond(contact.id()); |
|
453 // Save relationship |
|
454 mgr.saveRelationship(&relationship); |
|
455 |
|
456 // get contact id |
|
457 int id = groupContact.id().localId(); |
|
458 |
|
459 QVariantList args; |
|
460 XQApplicationManager appMng; |
|
461 QString interface("com.nokia.symbian.IContactsView"); |
|
462 QString operation("openGroup(int)"); |
|
463 // interface name is not needed |
|
464 mRequest = appMng.create( interface, operation, true); // embedded |
|
465 if ( mRequest ) |
|
466 { |
|
467 CNT_LOG_ARGS("Request created.") |
|
468 // Result handlers |
|
469 connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&))); |
|
470 |
|
471 args << id; |
|
472 |
|
473 mRequest->setArguments(args); |
|
474 mRequest->send(); |
|
475 CNT_LOG_ARGS("Request sent.") |
|
476 } |
|
477 else |
|
478 { |
|
479 CNT_LOG_ARGS("Failed to create request") |
|
480 } |
331 CNT_EXIT |
481 CNT_EXIT |
332 } |
482 } |
333 |
483 |
334 void testPbkServices::onEditCompleted(const QVariant& value) |
484 void testPbkServices::onEditCompleted(const QVariant& value) |
335 { |
485 { |
394 |
544 |
395 QString contactId = QString("id: %1").arg(retValue[i].mContactId); |
545 QString contactId = QString("id: %1").arg(retValue[i].mContactId); |
396 listWidget->addItem( contactId ); |
546 listWidget->addItem( contactId ); |
397 |
547 |
398 } |
548 } |
399 HbDialog *popup = new HbDialog(); |
549 mPopup = new HbDialog(); |
400 popup->setAttribute(Qt::WA_DeleteOnClose, true); |
550 mPopup->setAttribute(Qt::WA_DeleteOnClose, true); |
401 |
551 |
402 // Set dismiss policy that determines what tap events will cause the popup |
552 // Set dismiss policy that determines what tap events will cause the popup |
403 // to be dismissed |
553 // to be dismissed |
404 popup->setDismissPolicy(HbDialog::NoDismiss); |
554 mPopup->setDismissPolicy(HbDialog::NoDismiss); |
|
555 mPopup->setModal(true); |
405 |
556 |
406 // Set the label as heading widget |
557 // Set the label as heading widget |
407 popup->setHeadingWidget(new HbLabel(tr("Contact"))); |
558 mPopup->setHeadingWidget(new HbLabel(tr("Contact"))); |
408 |
559 |
409 // Set a list widget as content widget in the popup |
560 // Set a list widget as content widget in the popup |
410 popup->setContentWidget(listWidget); |
561 mPopup->setContentWidget(listWidget); |
411 |
562 |
412 // Sets the primary action and secondary action |
563 // Add an OK action to dismiss the popup |
413 //popup.setPrimaryAction(new HbAction(tr("Ok"),&popup)); |
564 HbAction *okAction = new HbAction(tr("Ok"), mPopup); |
414 //popup.setSecondaryAction(new HbAction(tr("Cancel"),&popup)); |
565 mPopup->addAction(okAction); |
415 |
566 |
416 // Launch popup asyncronously |
567 // Launch popup asyncronously |
417 popup->setTimeout(15000); |
568 mPopup->open(); |
418 popup->open(); |
|
419 } |
569 } |
420 CNT_EXIT |
570 CNT_EXIT |
421 } |
571 } |
422 |
572 |
423 void testPbkServices::launchMultiFetch( bool aNewInterface, QString aAction ) |
573 void testPbkServices::launchMultiFetch( bool aNewInterface, QString aAction ) |
429 QVariantList args; |
579 QVariantList args; |
430 |
580 |
431 XQApplicationManager appMng; |
581 XQApplicationManager appMng; |
432 if ( aNewInterface ) |
582 if ( aNewInterface ) |
433 { |
583 { |
434 QString interface("com.nokia.symbian.IContactFetch"); |
584 QString interface("com.nokia.symbian.IContactsFetch"); |
435 QString operation("multiFetch(QString,QString,QString)"); |
585 QString operation("multiFetch(QString,QString)"); |
436 // There are two kinds of create() methods in XQApplicationManager. The one with four arguments |
586 // There are two kinds of create() methods in XQApplicationManager. The one with four arguments |
437 // takes the service name also. The one with three arguments (used below) does not take the service name. |
587 // takes the service name also. The one with three arguments (used below) does not take the service name. |
438 // The interface name is enough for finding the correct provider at run time. |
588 // The interface name is enough for finding the correct provider at run time. |
439 mRequest = appMng.create(interface, operation, true); // embedded |
589 mRequest = appMng.create(interface, operation, true); // embedded |
440 } |
590 } |
475 |
625 |
476 QVariantList args; |
626 QVariantList args; |
477 XQApplicationManager appMng; |
627 XQApplicationManager appMng; |
478 if ( aNewInterface ) |
628 if ( aNewInterface ) |
479 { |
629 { |
480 QString interface("com.nokia.symbian.IContactFetch"); |
630 QString interface("com.nokia.symbian.IContactsFetch"); |
481 QString operation("singleFetch(QString,QString,QString)"); |
631 QString operation("singleFetch(QString,QString)"); |
482 // There are two kinds of create() methods in XQApplicationManager. The one with four arguments |
632 // There are two kinds of create() methods in XQApplicationManager. The one with four arguments |
483 // takes the service name also. The one with three arguments (used below) does not take the service name. |
633 // takes the service name also. The one with three arguments (used below) does not take the service name. |
484 // The interface name is enough for finding the correct provider at run time. |
634 // The interface name is enough for finding the correct provider at run time. |
485 mRequest = appMng.create(interface, operation, true); // embedded |
635 mRequest = appMng.create(interface, operation, true); // embedded |
486 } |
636 } |
515 CNT_LOG_ARGS("Failed to create request.") |
665 CNT_LOG_ARGS("Failed to create request.") |
516 } |
666 } |
517 CNT_EXIT |
667 CNT_EXIT |
518 } |
668 } |
519 |
669 |
520 void testPbkServices::launchEditCreateNew( bool aNewInterface, QString aDetailType, QString aFieldContent ) |
670 void testPbkServices::launchEditCreateNew( bool aNewInterface, QString aDetailType, QString aFieldContent, QString aDetailSubtype ) |
521 { |
671 { |
522 CNT_ENTRY |
672 CNT_ENTRY |
523 delete mRequest; |
673 delete mRequest; |
524 mRequest=0; |
674 mRequest=0; |
525 |
675 |
526 QVariantList args; |
676 QVariantList args; |
527 XQApplicationManager appMng; |
677 XQApplicationManager appMng; |
528 QString operation("editCreateNew(QString,QString)"); |
678 QString operation("editCreateNew(QString,QString)"); |
|
679 if ( !aDetailSubtype.isEmpty() ) |
|
680 { |
|
681 operation = "editCreateNew(QString,QString,QString)"; |
|
682 } |
|
683 |
529 if ( aNewInterface ) |
684 if ( aNewInterface ) |
530 { |
685 { |
531 QString interface("com.nokia.symbian.IContactFetch"); |
686 QString interface("com.nokia.symbian.IContactsFetch"); |
532 // service name is not needed |
687 // service name is not needed |
533 mRequest = appMng.create( interface, operation, true); // embedded |
688 mRequest = appMng.create( interface, operation, true); // embedded |
534 } |
689 } |
535 else |
690 else |
536 { |
691 { |
546 // Result handlers |
701 // Result handlers |
547 connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&))); |
702 connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&))); |
548 |
703 |
549 args << aDetailType; |
704 args << aDetailType; |
550 args << aFieldContent; |
705 args << aFieldContent; |
|
706 if ( !aDetailSubtype.isEmpty() ) |
|
707 { |
|
708 args << aDetailSubtype; |
|
709 } |
551 |
710 |
552 mRequest->setArguments(args); |
711 mRequest->setArguments(args); |
553 mRequest->send(); |
712 mRequest->send(); |
554 CNT_LOG_ARGS("Sent request.") |
713 CNT_LOG_ARGS("Sent request.") |
555 } |
714 } |
568 |
727 |
569 QVariantList args; |
728 QVariantList args; |
570 XQApplicationManager appMng; |
729 XQApplicationManager appMng; |
571 if ( aNewInterface ) |
730 if ( aNewInterface ) |
572 { |
731 { |
573 QString interface("com.nokia.symbian.IContactEdit"); |
732 QString interface("com.nokia.symbian.IContactsEdit"); |
574 QString operation("editCreateNewFromVCard(QString)"); |
733 QString operation("editCreateNewFromVCard(QString)"); |
575 // service name is not needed |
734 // service name is not needed |
576 mRequest = appMng.create( interface, operation, true); // embedded |
735 mRequest = appMng.create( interface, operation, true); // embedded |
577 } |
736 } |
578 else |
737 else |
601 CNT_LOG_ARGS("Failed to create request.") |
760 CNT_LOG_ARGS("Failed to create request.") |
602 } |
761 } |
603 CNT_EXIT |
762 CNT_EXIT |
604 } |
763 } |
605 |
764 |
606 void testPbkServices::launchEditUpdateExisting( bool aNewInterface, QString aDetailType, QString aDetailValue ) |
765 void testPbkServices::launchEditUpdateExisting( bool aNewInterface, QString aDetailType, QString aDetailValue, QString aDetailSubtype ) |
607 { |
766 { |
608 CNT_ENTRY |
767 CNT_ENTRY |
609 delete mRequest; |
768 delete mRequest; |
610 mRequest=0; |
769 mRequest=0; |
611 |
770 |
612 QVariantList args; |
771 QVariantList args; |
613 XQApplicationManager appMng; |
772 XQApplicationManager appMng; |
614 QString operation("editUpdateExisting(QString,QString)"); |
773 QString operation("editUpdateExisting(QString,QString)"); |
|
774 if ( !aDetailSubtype.isEmpty() ) |
|
775 { |
|
776 operation = "editUpdateExisting(QString,QString,QString)"; |
|
777 } |
|
778 |
615 if ( aNewInterface ) |
779 if ( aNewInterface ) |
616 { |
780 { |
617 QString interface("com.nokia.symbian.IContactEdit"); |
781 QString interface("com.nokia.symbian.IContactsEdit"); |
618 // service name is not needed |
782 // service name is not needed |
619 mRequest = appMng.create(interface, operation, true); // embedded |
783 mRequest = appMng.create(interface, operation, true); // embedded |
620 } |
784 } |
621 else |
785 else |
622 { |
786 { |
631 // Result handlers |
795 // Result handlers |
632 connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&))); |
796 connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&))); |
633 |
797 |
634 args << aDetailType; |
798 args << aDetailType; |
635 args << aDetailValue; |
799 args << aDetailValue; |
|
800 if ( !aDetailSubtype.isEmpty() ) |
|
801 { |
|
802 args << aDetailSubtype; |
|
803 } |
636 |
804 |
637 mRequest->setArguments(args); |
805 mRequest->setArguments(args); |
638 mRequest->send(); |
806 mRequest->send(); |
639 CNT_LOG_ARGS("Sent request.") |
807 CNT_LOG_ARGS("Sent request.") |
640 } |
808 } |
668 |
836 |
669 QVariantList args; |
837 QVariantList args; |
670 XQApplicationManager appMng; |
838 XQApplicationManager appMng; |
671 if ( aNewInterface ) |
839 if ( aNewInterface ) |
672 { |
840 { |
673 QString interface("com.nokia.symbian.IContactView"); |
841 QString interface("com.nokia.symbian.IContactsView"); |
674 QString operation("openContactCard(int)"); |
842 QString operation("openContactCard(int)"); |
675 // interface name is not needed |
843 // interface name is not needed |
676 mRequest = appMng.create( interface, operation, true); // embedded |
844 mRequest = appMng.create( interface, operation, true); // embedded |
677 } |
845 } |
678 else |
846 else |
709 |
877 |
710 QVariantList args; |
878 QVariantList args; |
711 XQApplicationManager appMng; |
879 XQApplicationManager appMng; |
712 if ( aNewInterface ) |
880 if ( aNewInterface ) |
713 { |
881 { |
714 QString interface("com.nokia.symbian.IContactView"); |
882 QString interface("com.nokia.symbian.IContactsView"); |
715 QString operation("openContactCard(QString,QString)"); |
883 QString operation("openTemporaryContactCard(QString,QString)"); |
716 // service name is not needed |
884 // service name is not needed |
717 mRequest = appMng.create(interface, operation, true); // embedded |
885 mRequest = appMng.create(interface, operation, true); // embedded |
718 } |
886 } |
719 else |
887 else |
720 { |
888 { |