phonebookui/phonebookservices/tsrc/qtpbkservicestestapp/testpbkservices.cpp
changeset 59 a642906a277a
parent 46 efe85016a067
child 71 7cc7d74059f9
--- a/phonebookui/phonebookservices/tsrc/qtpbkservicestestapp/testpbkservices.cpp	Tue Jul 06 14:05:47 2010 +0300
+++ b/phonebookui/phonebookservices/tsrc/qtpbkservicestestapp/testpbkservices.cpp	Wed Aug 18 09:39:00 2010 +0300
@@ -28,16 +28,17 @@
 #include <hbview.h>
 #include <QGraphicsLinearLayout>
 #include <QDebug>
+#include <HbAction>
 
 #include "cntdebug.h"
 
 
-testPbkServices::testPbkServices(HbMainWindow *aParent)
+testPbkServices::testPbkServices(HbMainWindow *aParent) :
+mRequest(NULL),
+mMainWindow(aParent),
+mPopup(NULL)
 {
-    mRequest=NULL;
-    mMainWindow=aParent;
     setParent(aParent);
-
 }
 
 testPbkServices::~testPbkServices()
@@ -138,6 +139,28 @@
     CNT_EXIT
 }
 
+void testPbkServices::launchEditCreateNew_numberWithSubtype()
+{
+    CNT_ENTRY
+    launchEditCreateNew(
+        true,                                // aNewInterface
+        QContactPhoneNumber::DefinitionName, // aDetailType
+        "1234567",                           // aFieldContent
+        QContactPhoneNumber::SubTypeLandline); //aDetailSubtype
+    CNT_EXIT
+}
+
+void testPbkServices::launchEditCreateNew_numberWithSubtype_old()
+{
+    CNT_ENTRY
+    launchEditCreateNew(
+        false,                               // aNewInterface
+        QContactPhoneNumber::DefinitionName, // aDetailType
+        "1234567",                          // aFieldContent
+        QContactPhoneNumber::SubTypeLandline); //aDetailSubtype
+    CNT_EXIT
+}
+
 void testPbkServices::launchEditCreateNew_email()
 {
     CNT_ENTRY
@@ -178,6 +201,28 @@
     CNT_EXIT
 }
 
+void testPbkServices::launchEditCreateNew_onlineAccountWithSubtype()
+{
+    CNT_ENTRY
+    launchEditCreateNew(
+        true,                                  // aNewInterface
+        QContactOnlineAccount::DefinitionName, // aDetailType
+        "provider:account@provider.com",                // aFieldContent
+        QContactOnlineAccount::SubTypeImpp); // aDetailSubtype
+    CNT_EXIT
+}
+
+void testPbkServices::launchEditCreateNew_onlineAccountWithSubtype_old()
+{
+    CNT_ENTRY
+    launchEditCreateNew(
+        false,                                  // aNewInterface
+        QContactOnlineAccount::DefinitionName, // aDetailType
+        "provider:account@provider.com",                // aFieldContent
+        QContactOnlineAccount::SubTypeImpp); // aDetailSubtype
+    CNT_EXIT
+}
+
 void testPbkServices::launchEditorVCard()
 {
     CNT_ENTRY
@@ -214,6 +259,28 @@
     CNT_EXIT
 }
 
+void testPbkServices::launchEditUpdateExisting_numberWithSubtype()
+{
+    CNT_ENTRY
+    launchEditUpdateExisting(
+        true,                                // aNewInterface
+        QContactPhoneNumber::DefinitionName, // aDetailType
+        "1234567",                           // aDetailValue
+        QContactPhoneNumber::SubTypeLandline);// aDetailSubtype 
+    CNT_EXIT
+}
+
+void testPbkServices::launchEditUpdateExisting_numberWithSubtype_old()
+{
+    CNT_ENTRY
+    launchEditUpdateExisting(
+        false,                               // aNewInterface
+        QContactPhoneNumber::DefinitionName, // aDetailType
+        "1234567",                           // aDetailValue
+        QContactPhoneNumber::SubTypeLandline);// aDetailSubtype    
+    CNT_EXIT
+}
+
 void testPbkServices::launchEditUpdateExisting_email()
 {
     CNT_ENTRY
@@ -254,6 +321,28 @@
     CNT_EXIT
 }
 
+void testPbkServices::launchEditUpdateExisting_onlineAccountWithSubtype()
+{
+    CNT_ENTRY
+    launchEditUpdateExisting(
+        true,                                  // aNewInterface
+        QContactOnlineAccount::DefinitionName, // aDetailType
+        "provider:account@provider.com",       // aDetailValue
+        QContactOnlineAccount::SubTypeImpp); // aDetailSubtype              
+    CNT_EXIT
+}
+
+void testPbkServices::launchEditUpdateExisting_onlineAccountWithSubtype_old()
+{
+    CNT_ENTRY
+    launchEditUpdateExisting(
+        false,                                 // aNewInterface
+        QContactOnlineAccount::DefinitionName, // aDetailType
+        "provider:account@provider.com",       // aDetailValue
+        QContactOnlineAccount::SubTypeImpp); // aDetailSubtype    
+    CNT_EXIT
+}
+
 void testPbkServices::launchContactCard()
 {
     CNT_ENTRY
@@ -331,6 +420,67 @@
     CNT_EXIT
 }
 
+void testPbkServices::launchGroupMemberView()
+{
+    CNT_ENTRY
+    delete mRequest;
+    mRequest=0;
+
+    // save test contact
+    QContactManager mgr("symbian");
+    QContact contact;
+    QContactName name;
+    QContactPhoneNumber number;
+    
+    name.setFirstName("Test_Contact");
+    number.setNumber("0202223344");
+    contact.saveDetail(&name);
+    contact.saveDetail(&number);
+    mgr.saveContact(&contact);
+    
+    // save test group
+    QString text("Work");
+    QContact groupContact;
+    groupContact.setType(QContactType::TypeGroup);
+    QContactName groupName;
+    groupName.setCustomLabel(text);
+    groupContact.saveDetail(&groupName);
+    mgr.saveContact(&groupContact);
+    QContactRelationship relationship;
+    relationship.setRelationshipType(QContactRelationship::HasMember);
+    relationship.setFirst(groupContact.id());
+    relationship.setSecond(contact.id());
+    // Save relationship
+    mgr.saveRelationship(&relationship);
+    
+    // get contact id
+    int id = groupContact.id().localId();
+        
+    QVariantList args; 
+    XQApplicationManager appMng;
+    QString interface("com.nokia.symbian.IContactsView");
+    QString operation("openGroup(int)");
+    // interface name is not needed
+    mRequest = appMng.create( interface, operation, true); // embedded 
+    if ( mRequest )
+    {    
+        CNT_LOG_ARGS("Request created.")
+        // Result handlers 
+        connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
+        
+        args << id;
+        
+        mRequest->setArguments(args); 
+        mRequest->send();
+        CNT_LOG_ARGS("Request sent.")
+    }
+    else
+    {
+        CNT_LOG_ARGS("Failed to create request")
+    }
+    CNT_EXIT
+}
+
 void testPbkServices::onEditCompleted(const QVariant& value)
 {
     CNT_ENTRY
@@ -396,26 +546,26 @@
             listWidget->addItem( contactId );
 
             }
-            HbDialog *popup = new HbDialog();
-            popup->setAttribute(Qt::WA_DeleteOnClose, true);
+            mPopup = new HbDialog();
+            mPopup->setAttribute(Qt::WA_DeleteOnClose, true);
 
             // Set dismiss policy that determines what tap events will cause the popup
             // to be dismissed
-            popup->setDismissPolicy(HbDialog::NoDismiss);
+            mPopup->setDismissPolicy(HbDialog::NoDismiss);
+            mPopup->setModal(true);
 
             // Set the label as heading widget
-            popup->setHeadingWidget(new HbLabel(tr("Contact")));
+            mPopup->setHeadingWidget(new HbLabel(tr("Contact")));
 
             // Set a list widget as content widget in the popup
-            popup->setContentWidget(listWidget);
-
-            // Sets the primary action and secondary action
-            //popup.setPrimaryAction(new HbAction(tr("Ok"),&popup));
-            //popup.setSecondaryAction(new HbAction(tr("Cancel"),&popup));
+            mPopup->setContentWidget(listWidget);
+            
+            // Add an OK action to dismiss the popup
+            HbAction *okAction = new HbAction(tr("Ok"), mPopup);
+            mPopup->addAction(okAction);
 
             // Launch popup asyncronously
-            popup->setTimeout(15000);
-            popup->open();
+            mPopup->open();
     }
     CNT_EXIT
 }
@@ -431,8 +581,8 @@
     XQApplicationManager appMng;
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactFetch"); 
-        QString operation("multiFetch(QString,QString,QString)");
+        QString interface("com.nokia.symbian.IContactsFetch"); 
+        QString operation("multiFetch(QString,QString)");
         // There are two kinds of create() methods in XQApplicationManager. The one with four arguments
         // takes the service name also. The one with three arguments (used below) does not take the service name.
         // The interface name is enough for finding the correct provider at run time.
@@ -477,8 +627,8 @@
     XQApplicationManager appMng;
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactFetch"); 
-        QString operation("singleFetch(QString,QString,QString)");
+        QString interface("com.nokia.symbian.IContactsFetch"); 
+        QString operation("singleFetch(QString,QString)");
         // There are two kinds of create() methods in XQApplicationManager. The one with four arguments
         // takes the service name also. The one with three arguments (used below) does not take the service name.
         // The interface name is enough for finding the correct provider at run time.
@@ -517,7 +667,7 @@
     CNT_EXIT
 }
 
-void testPbkServices::launchEditCreateNew( bool aNewInterface, QString aDetailType, QString aFieldContent )
+void testPbkServices::launchEditCreateNew( bool aNewInterface, QString aDetailType, QString aFieldContent, QString aDetailSubtype )
 {
     CNT_ENTRY
     delete mRequest;
@@ -526,9 +676,14 @@
     QVariantList args; 
     XQApplicationManager appMng;
     QString operation("editCreateNew(QString,QString)");
+    if ( !aDetailSubtype.isEmpty() )
+    {
+        operation = "editCreateNew(QString,QString,QString)";
+    }
+    
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactFetch"); 
+        QString interface("com.nokia.symbian.IContactsFetch"); 
         // service name is not needed
         mRequest = appMng.create( interface, operation, true); // embedded
     }
@@ -548,6 +703,10 @@
         
         args << aDetailType;
         args << aFieldContent;
+        if ( !aDetailSubtype.isEmpty() )
+        {
+            args << aDetailSubtype;
+        }
         
         mRequest->setArguments(args); 
         mRequest->send();
@@ -570,7 +729,7 @@
     XQApplicationManager appMng;
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactEdit"); 
+        QString interface("com.nokia.symbian.IContactsEdit"); 
         QString operation("editCreateNewFromVCard(QString)");
         // service name is not needed
         mRequest = appMng.create( interface, operation, true); // embedded 
@@ -603,7 +762,7 @@
     CNT_EXIT
 }
 
-void testPbkServices::launchEditUpdateExisting( bool aNewInterface, QString aDetailType, QString aDetailValue )
+void testPbkServices::launchEditUpdateExisting( bool aNewInterface, QString aDetailType, QString aDetailValue, QString aDetailSubtype )
 {
     CNT_ENTRY
     delete mRequest;
@@ -612,9 +771,14 @@
     QVariantList args; 
     XQApplicationManager appMng;
     QString operation("editUpdateExisting(QString,QString)");
+    if ( !aDetailSubtype.isEmpty() )
+    {
+        operation = "editUpdateExisting(QString,QString,QString)";
+    }
+        
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactEdit");
+        QString interface("com.nokia.symbian.IContactsEdit");
         // service name is not needed
         mRequest = appMng.create(interface, operation, true); // embedded 
     }
@@ -633,6 +797,10 @@
         
         args << aDetailType;
         args << aDetailValue;
+        if ( !aDetailSubtype.isEmpty() )
+        {
+            args << aDetailSubtype;
+        }
         
         mRequest->setArguments(args); 
         mRequest->send();
@@ -670,7 +838,7 @@
     XQApplicationManager appMng;
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactView");
+        QString interface("com.nokia.symbian.IContactsView");
         QString operation("openContactCard(int)");
         // interface name is not needed
         mRequest = appMng.create( interface, operation, true); // embedded 
@@ -711,8 +879,8 @@
     XQApplicationManager appMng;
     if ( aNewInterface )
     {
-        QString interface("com.nokia.symbian.IContactView");
-        QString operation("openContactCard(QString,QString)");
+        QString interface("com.nokia.symbian.IContactsView");
+        QString operation("openTemporaryContactCard(QString,QString)");
         // service name is not needed
         mRequest = appMng.create(interface, operation, true); // embedded 
     }