phonebookui/phonebookservices/tsrc/qtpbkservicestestapp/testpbkservices.cpp
changeset 46 efe85016a067
parent 40 b46a585f6909
child 50 77bc263e1626
child 59 a642906a277a
equal deleted inserted replaced
40:b46a585f6909 46:efe85016a067
    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 
    31 
       
    32 #include "cntdebug.h"
       
    33 
    32 
    34 
    33 testPbkServices::testPbkServices(HbMainWindow *aParent)
    35 testPbkServices::testPbkServices(HbMainWindow *aParent)
    34 {
    36 {
    35     mRequest=NULL;
    37     mRequest=NULL;
    36     mMainWindow=aParent;
    38     mMainWindow=aParent;
    38 
    40 
    39 }
    41 }
    40 
    42 
    41 testPbkServices::~testPbkServices()
    43 testPbkServices::~testPbkServices()
    42 {
    44 {
    43     if (mRequest)
    45     delete mRequest;
    44     {
    46     mRequest=0;
    45         delete mRequest;
    47 }
    46         mRequest=0;
    48 
    47     }
    49 void testPbkServices::launchMultiFetch()
    48 }
    50 {
    49 
    51     CNT_ENTRY
    50 void testPbkServices::launchEditorNumber()
    52     launchMultiFetch(
    51 {
    53         true,           // aNewInterface = true
    52     if (mRequest)
    54         KCntActionAll);  // aAction (all actions in this case)
    53     {
    55     CNT_EXIT
    54         delete mRequest;
    56 }
    55         mRequest=0;
    57 
    56     }
    58 void testPbkServices::launchMultiFetch_old()
    57 
    59 {
    58     QVariantList args; 
    60     CNT_ENTRY
    59     QString serviceName("com.nokia.services.phonebookservices"); 
    61     launchMultiFetch(
    60     QString operation("editCreateNew(QString,QString)");
    62         false,           // aNewInterface = false
    61     XQApplicationManager appMng;
    63         KCntActionAll);  // aAction (all actions in this case)
    62     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
    64     CNT_EXIT
    63     
    65 }
    64     // Result handlers 
    66 
    65     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
    67 void testPbkServices::launchMultiFetch_sms()
    66     
    68 {
    67     args << QContactPhoneNumber::DefinitionName.operator QVariant();
    69     CNT_ENTRY
    68     args << "1234567";
    70     launchMultiFetch(
    69     
    71         true,           // aNewInterface = false
    70     mRequest->setArguments(args); 
    72         KCntActionSms);  // aAction
    71     mRequest->send();
    73     CNT_EXIT
    72 }
    74 }
    73 
    75 
    74 void testPbkServices::launchEditorEmail()
    76 void testPbkServices::launchMultiFetch_sms_old()
    75 {
    77 {
    76     if (mRequest)
    78     CNT_ENTRY
    77     {
    79     launchMultiFetch(
    78         delete mRequest;
    80         false,           // aNewInterface
    79         mRequest=0;
    81         KCntActionSms);  // aAction
    80     }
    82     CNT_EXIT
    81 
    83 }
    82     QVariantList args; 
    84 
    83     QString serviceName("com.nokia.services.phonebookservices"); 
    85 void testPbkServices::launchMultiFetch_email()
    84     QString operation("editCreateNew(QString,QString)");
    86 {
    85     XQApplicationManager appMng;
    87     CNT_ENTRY
    86     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
    88     launchMultiFetch(
    87     
    89         true,              // aNewInterface
    88     // Result handlers 
    90         KCntActionEmail);  // aAction
    89     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
    91     CNT_EXIT
    90     
    92 }
    91     args << QContactEmailAddress::DefinitionName.operator QVariant();
    93 
    92     args << "email@mailprovider.com";
    94 void testPbkServices::launchMultiFetch_email_old()
    93     
    95 {
    94     mRequest->setArguments(args); 
    96     CNT_ENTRY
    95     mRequest->send();
    97     launchMultiFetch(
    96 }
    98         false,             // aNewInterface
    97 
    99         KCntActionEmail);  // aAction
    98 void testPbkServices::launchEditorOnlineAccount()
   100     CNT_EXIT
    99 {
   101 }
   100     if (mRequest)
   102 
   101     {
   103 void testPbkServices::launchSingleFetch()
   102         delete mRequest;
   104 {
   103         mRequest=0;
   105     CNT_ENTRY
   104     }
   106     launchSingleFetch(
   105 
   107         true,           // aNewInterface
   106     QVariantList args; 
   108         KCntActionAll ); // aAction
   107     QString serviceName("com.nokia.services.phonebookservices"); 
   109     CNT_EXIT
   108     QString operation("editCreateNew(QString,QString)");
   110 }
   109     XQApplicationManager appMng;
   111 
   110     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
   112 void testPbkServices::launchSingleFetch_old()
   111     
   113 {
   112     // Result handlers 
   114     CNT_ENTRY
   113     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
   115     launchSingleFetch(
   114     
   116         false,           // aNewInterface
   115     args << QContactOnlineAccount::DefinitionName.operator QVariant();
   117         KCntActionAll ); // aAction
   116     args << "account@provider.com";
   118     CNT_EXIT
   117     
   119 }
   118     mRequest->setArguments(args); 
   120 
   119     mRequest->send();
   121 void testPbkServices::launchEditCreateNew_number()
       
   122 {
       
   123     CNT_ENTRY
       
   124     launchEditCreateNew(
       
   125         true,                                // aNewInterface
       
   126         QContactPhoneNumber::DefinitionName, // aDetailType
       
   127         "1234567");                          // aFieldContent
       
   128     CNT_EXIT
       
   129 }
       
   130 
       
   131 void testPbkServices::launchEditCreateNew_number_old()
       
   132 {
       
   133     CNT_ENTRY
       
   134     launchEditCreateNew(
       
   135         false,                               // aNewInterface
       
   136         QContactPhoneNumber::DefinitionName, // aDetailType
       
   137         "1234567");                          // aFieldContent
       
   138     CNT_EXIT
       
   139 }
       
   140 
       
   141 void testPbkServices::launchEditCreateNew_email()
       
   142 {
       
   143     CNT_ENTRY
       
   144     launchEditCreateNew(
       
   145         true,                                 // aNewInterface
       
   146         QContactEmailAddress::DefinitionName, // aDetailType
       
   147         "email@mailprovider.com");            // aFieldContent
       
   148     CNT_EXIT
       
   149 }
       
   150 
       
   151 void testPbkServices::launchEditCreateNew_email_old()
       
   152 {
       
   153     CNT_ENTRY
       
   154     launchEditCreateNew(
       
   155         false,                                // aNewInterface
       
   156         QContactEmailAddress::DefinitionName, // aDetailType
       
   157         "email@mailprovider.com");            // aFieldContent
       
   158     CNT_EXIT
       
   159 }
       
   160 
       
   161 void testPbkServices::launchEditCreateNew_onlineAccount()
       
   162 {
       
   163     CNT_ENTRY
       
   164     launchEditCreateNew(
       
   165         true,                                  // aNewInterface
       
   166         QContactOnlineAccount::DefinitionName, // aDetailType
       
   167         "account@provider.com");               // aFieldContent
       
   168     CNT_EXIT
       
   169 }
       
   170 
       
   171 void testPbkServices::launchEditCreateNew_onlineAccount_old()
       
   172 {
       
   173     CNT_ENTRY
       
   174     launchEditCreateNew(
       
   175         false,                                 // aNewInterface
       
   176         QContactOnlineAccount::DefinitionName, // aDetailType
       
   177         "account@provider.com");            // aFieldContent
       
   178     CNT_EXIT
   120 }
   179 }
   121 
   180 
   122 void testPbkServices::launchEditorVCard()
   181 void testPbkServices::launchEditorVCard()
   123 {
   182 {
   124     if (mRequest)
   183     CNT_ENTRY
   125     {
   184     launchEditorVCard(
   126         delete mRequest;
   185         true); // aNewInterface
   127         mRequest=0;
   186     CNT_EXIT
   128     }
   187 }
   129 
   188 
   130     QVariantList args; 
   189 void testPbkServices::launchEditorVCard_old()
   131     QString serviceName("com.nokia.services.phonebookservices"); 
   190 {
   132     QString operation("editCreateNew(QString)");
   191     CNT_ENTRY
   133     XQApplicationManager appMng;
   192     launchEditorVCard(
   134     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
   193         false); // aNewInterface
   135     
   194     CNT_EXIT
   136     // Result handlers 
   195 }
   137     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
   196 
   138     
   197 void testPbkServices::launchEditUpdateExisting_number()
   139     args << "C:\\data\\Others\\testvcard.vcf";
   198 {
   140     
   199     CNT_ENTRY
   141     mRequest->setArguments(args); 
   200     launchEditUpdateExisting(
   142     mRequest->send();
   201         true,                                // aNewInterface
   143 }
   202         QContactPhoneNumber::DefinitionName, // aDetailType
   144 
   203         "1234567");                          // aDetailValue
   145 void testPbkServices::launchUpdateEditorNumber()
   204     CNT_EXIT
   146 {
   205 }
   147     if (mRequest)
   206 
   148     {
   207 void testPbkServices::launchEditUpdateExisting_number_old()
   149         delete mRequest;
   208 {
   150         mRequest=0;
   209     CNT_ENTRY
   151     }
   210     launchEditUpdateExisting(
   152 
   211         false,                               // aNewInterface
   153     QVariantList args; 
   212         QContactPhoneNumber::DefinitionName, // aDetailType
   154     QString serviceName("com.nokia.services.phonebookservices"); 
   213         "1234567");                          // aDetailValue
   155     QString operation("editUpdateExisting(QString,QString)");
   214     CNT_EXIT
   156     XQApplicationManager appMng;
   215 }
   157     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
   216 
   158     
   217 void testPbkServices::launchEditUpdateExisting_email()
   159     // Result handlers 
   218 {
   160     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
   219     CNT_ENTRY
   161     
   220     launchEditUpdateExisting(
   162     args << QContactPhoneNumber::DefinitionName.operator QVariant();
   221         true,                                // aNewInterface
   163     args << "1234567";
   222         QContactEmailAddress::DefinitionName, // aDetailType
   164     
   223         "email@mailprovider.com");                          // aDetailValue
   165     mRequest->setArguments(args); 
   224     CNT_EXIT
   166     mRequest->send();
   225 }
   167 }
   226 
   168 
   227 void testPbkServices::launchEditUpdateExisting_email_old()
   169 void testPbkServices::launchUpdateEditorEmail()
   228 {
   170 {
   229     CNT_ENTRY
   171     if (mRequest)
   230     launchEditUpdateExisting(
   172     {
   231         false,                                // aNewInterface
   173         delete mRequest;
   232         QContactEmailAddress::DefinitionName, // aDetailType
   174         mRequest=0;
   233         "email@mailprovider.com");            // aDetailValue
   175     }
   234     CNT_EXIT
   176 
   235 }
   177     QVariantList args; 
   236 
   178     QString serviceName("com.nokia.services.phonebookservices"); 
   237 void testPbkServices::launchEditUpdateExisting_onlineAccount()
   179     QString operation("editUpdateExisting(QString,QString)");
   238 {
   180     XQApplicationManager appMng;
   239     CNT_ENTRY
   181     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
   240     launchEditUpdateExisting(
   182     
   241         true,                                  // aNewInterface
   183     // Result handlers 
   242         QContactOnlineAccount::DefinitionName, // aDetailType
   184     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
   243         "account@provider.com");               // aDetailValue
   185     
   244     CNT_EXIT
   186     args << QContactEmailAddress::DefinitionName.operator QVariant();
   245 }
   187     args << "email@mailprovider.com";
   246 
   188     
   247 void testPbkServices::launchEditUpdateExisting_onlineAccount_old()
   189     mRequest->setArguments(args); 
   248 {
   190     mRequest->send();
   249     CNT_ENTRY
   191 }
   250     launchEditUpdateExisting(
   192 
   251         false,                                 // aNewInterface
   193 void testPbkServices::launchUpdateEditorOnlineAccount()
   252         QContactOnlineAccount::DefinitionName, // aDetailType
   194 {
   253         "account@provider.com");               // aDetailValue
   195     if (mRequest)
   254     CNT_EXIT
   196     {
   255 }
   197         delete mRequest;
   256 
   198         mRequest=0;
   257 void testPbkServices::launchContactCard()
   199     }
   258 {
   200 
   259     CNT_ENTRY
   201     QVariantList args; 
   260     launchContactCard(
   202     QString serviceName("com.nokia.services.phonebookservices"); 
   261         true ); // aNewInterface
   203     QString operation("editUpdateExisting(QString,QString)");
   262     CNT_EXIT
   204     XQApplicationManager appMng;
   263 }
   205     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
   264 
   206     
   265 void testPbkServices::launchContactCard_old()
   207     // Result handlers 
   266 {
   208     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
   267     CNT_ENTRY
   209     
   268     launchContactCard(
   210     args << QContactOnlineAccount::DefinitionName.operator QVariant();
   269         false ); // aNewInterface
   211     args << "account@provider.com";
   270     CNT_EXIT
   212     
   271 }
   213     mRequest->setArguments(args); 
   272 
   214     mRequest->send();
   273 void testPbkServices::launchContactCardNumber()
       
   274 {
       
   275     CNT_ENTRY
       
   276     launchContactCard(
       
   277         true,                                // aNewInterface
       
   278         QContactPhoneNumber::DefinitionName, // aDetailType
       
   279         "777555669" );                       // aDetailValue
       
   280     CNT_EXIT
       
   281 }
       
   282 
       
   283 void testPbkServices::launchContactCardNumber_old()
       
   284 {
       
   285     CNT_ENTRY
       
   286     launchContactCard(
       
   287         false,                               // aNewInterface
       
   288         QContactPhoneNumber::DefinitionName, // aDetailType
       
   289         "777555669" );                       // aDetailValue
       
   290     CNT_EXIT
       
   291 }
       
   292 
       
   293 void testPbkServices::launchContactCardEmail()
       
   294 {
       
   295     CNT_ENTRY
       
   296     launchContactCard(
       
   297         true,                                 // aNewInterface
       
   298         QContactEmailAddress::DefinitionName, // aDetailType
       
   299         "aa.jj@aajj.com" );                   // aDetailValue
       
   300     CNT_EXIT
       
   301 }
       
   302 
       
   303 void testPbkServices::launchContactCardEmail_old()
       
   304 {
       
   305     CNT_ENTRY
       
   306     launchContactCard(
       
   307         false,                                // aNewInterface
       
   308         QContactEmailAddress::DefinitionName, // aDetailType
       
   309         "aa.jj@aajj.com" );                   // aDetailValue
       
   310     CNT_EXIT
       
   311     CNT_EXIT
       
   312 }
       
   313 
       
   314 void testPbkServices::launchContactCardOnlineAccount()
       
   315 {
       
   316     CNT_ENTRY
       
   317     launchContactCard(
       
   318         true,                                  // aNewInterface
       
   319         QContactOnlineAccount::DefinitionName, // aDetailType
       
   320         "account@provider.com" );              // aDetailValue
       
   321     CNT_EXIT
       
   322 }
       
   323 
       
   324 void testPbkServices::launchContactCardOnlineAccount_old()
       
   325 {
       
   326     CNT_ENTRY
       
   327     launchContactCard(
       
   328         true,                                  // aNewInterface
       
   329         QContactOnlineAccount::DefinitionName, // aDetailType
       
   330         "account@provider.com" );              // aDetailValue
       
   331     CNT_EXIT
   215 }
   332 }
   216 
   333 
   217 void testPbkServices::onEditCompleted(const QVariant& value)
   334 void testPbkServices::onEditCompleted(const QVariant& value)
   218 {
   335 {
       
   336     CNT_ENTRY
   219     mMainWindow->activateWindow();
   337     mMainWindow->activateWindow();
   220     
   338     
   221     if (value.toInt() == 1)
   339     if (value.toInt() == 1)
   222     {
   340     {
   223         HbMessageBox::information("Contact saved");
   341         HbMessageBox::information("Contact saved");
       
   342         CNT_LOG_ARGS("test: Contact saved")
   224     }
   343     }
   225     else
   344     else
   226     {
   345     {
   227         HbMessageBox::information("Contact saving failed");
   346         HbMessageBox::information("Contact saving failed");
   228     }
   347         CNT_LOG_ARGS("test: Contact saving failed")
   229 }
   348     }
   230 
   349     CNT_EXIT
   231 void testPbkServices::launchFetch()
   350 }
   232 {
       
   233     if (mRequest)
       
   234     {
       
   235         delete mRequest;
       
   236         mRequest=0;
       
   237     }
       
   238 
       
   239     QVariantList args; 
       
   240     QString serviceName("com.nokia.services.phonebookservices"); 
       
   241     QString operation("fetch(QString,QString,QString)");
       
   242     XQApplicationManager appMng;
       
   243     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
       
   244     
       
   245     // Result handlers 
       
   246     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   247     
       
   248     args << "Non-filtered multi-fetch";
       
   249     args << KCntActionAll; 
       
   250     args << KCntFilterDisplayAll; 
       
   251     
       
   252     mRequest->setArguments(args); 
       
   253     mRequest->send();
       
   254 }
       
   255 
       
   256 void testPbkServices::launchSingleFetch()
       
   257 {
       
   258     if (mRequest)
       
   259     {
       
   260         delete mRequest;
       
   261         mRequest=0;
       
   262     }
       
   263 
       
   264     QVariantList args; 
       
   265     QString serviceName("com.nokia.services.phonebookservices"); 
       
   266     QString operation("Dofetch(QString,QString,QString,QString)");
       
   267     XQApplicationManager appMng;
       
   268     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
       
   269     
       
   270     // Result handlers 
       
   271     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   272     
       
   273     args << "Single-fetching";
       
   274     args << KCntActionAll; 
       
   275     args << KCntFilterDisplayAll;
       
   276     args << KCntSingleSelectionMode;
       
   277     
       
   278     mRequest->setArguments(args); 
       
   279     mRequest->send();
       
   280 }
       
   281 
       
   282 void testPbkServices::launchSmsFilteredFetch()
       
   283 {
       
   284     if (mRequest)
       
   285     {
       
   286         delete mRequest;
       
   287         mRequest=0;
       
   288     }
       
   289 
       
   290     QVariantList args; 
       
   291     QString serviceName("com.nokia.services.phonebookservices"); 
       
   292     QString operation("fetch(QString,QString,QString)");
       
   293     XQApplicationManager appMng;
       
   294     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
       
   295     
       
   296     // Result handlers 
       
   297     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   298     
       
   299     args << "Filtered multi-fetch";
       
   300     args << KCntActionSms; 
       
   301     args << KCntFilterDisplayAll;
       
   302     
       
   303     mRequest->setArguments(args); 
       
   304     mRequest->send();
       
   305 }
       
   306 
       
   307 void testPbkServices::launchEmailFilteredFetch()
       
   308 {
       
   309     if (mRequest)
       
   310     {
       
   311         delete mRequest;
       
   312         mRequest=0;
       
   313     }
       
   314 
       
   315     QVariantList args; 
       
   316     QString serviceName("com.nokia.services.phonebookservices"); 
       
   317     QString operation("fetch(QString,QString,QString)");
       
   318     XQApplicationManager appMng;
       
   319     mRequest = appMng.create(serviceName, "Fetch", operation, true); // embedded 
       
   320     
       
   321     // Result handlers 
       
   322     connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   323     
       
   324     args << "Filtered multi-fetch";
       
   325     args << KCntActionEmail; 
       
   326     args << KCntFilterDisplayAll;
       
   327     
       
   328     mRequest->setArguments(args); 
       
   329     mRequest->send();
       
   330 }
       
   331 
       
   332 
   351 
   333 
   352 
   334 void testPbkServices::onRequestCompleted(const QVariant& value)
   353 void testPbkServices::onRequestCompleted(const QVariant& value)
   335 {
   354 {
   336 
   355     CNT_ENTRY
   337     mMainWindow->activateWindow();
   356     mMainWindow->activateWindow();
   338 
   357 
   339     CntServicesContactList retValue;
   358     CntServicesContactList retValue;
   340     retValue=qVariantValue<CntServicesContactList>(value);
   359     retValue=qVariantValue<CntServicesContactList>(value);
   341 
   360 
   342 
   361 
   343     if (retValue.count() == 0)
   362     if (retValue.count() == 0)
   344     {
   363     {
   345         HbMessageBox::information("Nothing returned");
   364         HbMessageBox::information("test: Nothing returned");
       
   365         CNT_LOG_ARGS("No data returned.")
   346     }
   366     }
   347 
   367 
   348     else
   368     else
   349     {
   369     {
   350         HbListWidget *listWidget = new HbListWidget();
   370         HbListWidget *listWidget = new HbListWidget();
   351         for(int i = 0; i < retValue.count(); i++ )
   371         for(int i = 0; i < retValue.count(); i++ )
   352             {
   372             {
   353             QString name      = retValue[i].mDisplayName;
   373             QString name      = retValue[i].mDisplayName;
   354             listWidget->addItem("name:" );
   374             listWidget->addItem("name:" );
   355             listWidget->addItem(name);
   375             listWidget->addItem(name);
       
   376             CNT_LOG_ARGS("Returned name: " << name)
   356 
   377 
   357             QString number    = retValue[i].mPhoneNumber;
   378             QString number    = retValue[i].mPhoneNumber;
   358             if (number!="")
   379             if (number!="")
   359                 {
   380                 {
   360                 listWidget->addItem("number:");
   381                 listWidget->addItem("number:");
   361                 listWidget->addItem(number);
   382                 listWidget->addItem(number);
       
   383                 CNT_LOG_ARGS("Returned number: " << number)
   362                 }
   384                 }
   363 
   385 
   364             QString emailAddress    = retValue[i].mEmailAddress;
   386             QString emailAddress    = retValue[i].mEmailAddress;
   365             if (emailAddress!="")
   387             if (emailAddress!="")
   366                 {
   388                 {
   367                 listWidget->addItem("emailAddress:");
   389                 listWidget->addItem("emailAddress:");
   368                 listWidget->addItem(emailAddress);
   390                 listWidget->addItem(emailAddress);
       
   391                 CNT_LOG_ARGS("Returned email: " << emailAddress)
   369                 }
   392                 }
   370 
   393 
   371 
   394 
   372             QString contactId = QString("id: %1").arg(retValue[i].mContactId);
   395             QString contactId = QString("id: %1").arg(retValue[i].mContactId);
   373             listWidget->addItem( contactId );
   396             listWidget->addItem( contactId );
   392 
   415 
   393             // Launch popup asyncronously
   416             // Launch popup asyncronously
   394             popup->setTimeout(15000);
   417             popup->setTimeout(15000);
   395             popup->open();
   418             popup->open();
   396     }
   419     }
   397 
   420     CNT_EXIT
   398 }
   421 }
   399 
   422 
       
   423 void testPbkServices::launchMultiFetch( bool aNewInterface, QString aAction )
       
   424 {
       
   425     CNT_ENTRY
       
   426     delete mRequest;
       
   427     mRequest=0;
       
   428 
       
   429     QVariantList args; 
       
   430 
       
   431     XQApplicationManager appMng;
       
   432     if ( aNewInterface )
       
   433     {
       
   434         QString interface("com.nokia.symbian.IContactFetch"); 
       
   435         QString operation("multiFetch(QString,QString,QString)");
       
   436         // 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.
       
   438         // The interface name is enough for finding the correct provider at run time.
       
   439         mRequest = appMng.create(interface, operation, true); // embedded
       
   440     }
       
   441     else
       
   442     {
       
   443         mRequest = appMng.create(
       
   444             "com.nokia.services.phonebookservices",// service
       
   445             "Fetch",                             // interface
       
   446             "fetch(QString,QString,QString)",  // operation
       
   447             true); // embedded 
       
   448     }
       
   449 
       
   450     if (mRequest)
       
   451         {
       
   452         CNT_LOG_ARGS("Created request.")
       
   453         // Result handlers 
       
   454         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   455         
       
   456         args << "My own title"; // This is the title for the view
       
   457         args << aAction; 
       
   458         args << KCntFilterDisplayAll; 
       
   459         
       
   460         mRequest->setArguments(args); 
       
   461         mRequest->send();
       
   462         }
       
   463     else
       
   464         {
       
   465         CNT_LOG_ARGS("Failed to create request.")
       
   466         }
       
   467     CNT_EXIT
       
   468 }
       
   469 
       
   470 void testPbkServices::launchSingleFetch( bool aNewInterface, QString aAction )
       
   471 {
       
   472     CNT_ENTRY
       
   473     delete mRequest;
       
   474     mRequest=0;
       
   475 
       
   476     QVariantList args; 
       
   477     XQApplicationManager appMng;
       
   478     if ( aNewInterface )
       
   479     {
       
   480         QString interface("com.nokia.symbian.IContactFetch"); 
       
   481         QString operation("singleFetch(QString,QString,QString)");
       
   482         // 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.
       
   484         // The interface name is enough for finding the correct provider at run time.
       
   485         mRequest = appMng.create(interface, operation, true); // embedded
       
   486     }
       
   487     else
       
   488     {
       
   489         QString serviceName("com.nokia.services.phonebookservices");
       
   490         QString interface("Fetch");
       
   491         QString operation("Dofetch(QString,QString,QString,QString)");
       
   492         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   493     }
       
   494 
       
   495     if ( mRequest )
       
   496     {
       
   497         CNT_LOG_ARGS("Created request.")        
       
   498         // Result handlers 
       
   499         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   500         
       
   501         args << "Single-fetching";
       
   502         args << aAction; 
       
   503         args << KCntFilterDisplayAll;
       
   504         if ( !aNewInterface )
       
   505         {
       
   506             // Only the old interface takes this useless argument.
       
   507             args << KCntSingleSelectionMode;
       
   508         }
       
   509         
       
   510         mRequest->setArguments(args); 
       
   511         mRequest->send();
       
   512     }
       
   513     else
       
   514     {
       
   515         CNT_LOG_ARGS("Failed to create request.")
       
   516     }
       
   517     CNT_EXIT
       
   518 }
       
   519 
       
   520 void testPbkServices::launchEditCreateNew( bool aNewInterface, QString aDetailType, QString aFieldContent )
       
   521 {
       
   522     CNT_ENTRY
       
   523     delete mRequest;
       
   524     mRequest=0;
       
   525 
       
   526     QVariantList args; 
       
   527     XQApplicationManager appMng;
       
   528     QString operation("editCreateNew(QString,QString)");
       
   529     if ( aNewInterface )
       
   530     {
       
   531         QString interface("com.nokia.symbian.IContactFetch"); 
       
   532         // service name is not needed
       
   533         mRequest = appMng.create( interface, operation, true); // embedded
       
   534     }
       
   535     else
       
   536     {
       
   537         QString interface("Fetch");
       
   538         QString serviceName("com.nokia.services.phonebookservices"); 
       
   539         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   540     }
       
   541 
       
   542     if ( mRequest )
       
   543     {
       
   544         CNT_LOG_ARGS("Created request.")
       
   545         
       
   546         // Result handlers 
       
   547         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
       
   548         
       
   549         args << aDetailType;
       
   550         args << aFieldContent;
       
   551         
       
   552         mRequest->setArguments(args); 
       
   553         mRequest->send();
       
   554         CNT_LOG_ARGS("Sent request.")
       
   555     }
       
   556     else
       
   557     {
       
   558         CNT_LOG_ARGS("Failed to create request.")
       
   559     }
       
   560     CNT_EXIT
       
   561 }
       
   562 
       
   563 void testPbkServices::launchEditorVCard( bool aNewInterface )
       
   564 {
       
   565     CNT_ENTRY
       
   566     delete mRequest;
       
   567     mRequest=0;
       
   568 
       
   569     QVariantList args; 
       
   570     XQApplicationManager appMng;
       
   571     if ( aNewInterface )
       
   572     {
       
   573         QString interface("com.nokia.symbian.IContactEdit"); 
       
   574         QString operation("editCreateNewFromVCard(QString)");
       
   575         // service name is not needed
       
   576         mRequest = appMng.create( interface, operation, true); // embedded 
       
   577     }
       
   578     else
       
   579     {
       
   580         QString interface("Fetch");
       
   581         QString operation("editCreateNew(QString)");
       
   582         QString serviceName("com.nokia.services.phonebookservices");
       
   583         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   584     }
       
   585 
       
   586     if ( mRequest )
       
   587     {
       
   588         CNT_LOG_ARGS("Created request.")
       
   589         
       
   590         // Result handlers 
       
   591         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
       
   592         
       
   593         args << "C:\\data\\Others\\testvcard.vcf";
       
   594         
       
   595         mRequest->setArguments(args); 
       
   596         mRequest->send();
       
   597         CNT_LOG_ARGS("Sent request.")
       
   598     }
       
   599     else
       
   600     {
       
   601         CNT_LOG_ARGS("Failed to create request.")
       
   602     }
       
   603     CNT_EXIT
       
   604 }
       
   605 
       
   606 void testPbkServices::launchEditUpdateExisting( bool aNewInterface, QString aDetailType, QString aDetailValue )
       
   607 {
       
   608     CNT_ENTRY
       
   609     delete mRequest;
       
   610     mRequest=0;
       
   611 
       
   612     QVariantList args; 
       
   613     XQApplicationManager appMng;
       
   614     QString operation("editUpdateExisting(QString,QString)");
       
   615     if ( aNewInterface )
       
   616     {
       
   617         QString interface("com.nokia.symbian.IContactEdit");
       
   618         // service name is not needed
       
   619         mRequest = appMng.create(interface, operation, true); // embedded 
       
   620     }
       
   621     else
       
   622     {
       
   623         QString interface("Fetch");
       
   624         QString serviceName("com.nokia.services.phonebookservices"); 
       
   625         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   626     }
       
   627     if ( mRequest )
       
   628     {
       
   629         CNT_LOG_ARGS("Created request.")
       
   630         
       
   631         // Result handlers 
       
   632         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onEditCompleted(const QVariant&)));
       
   633         
       
   634         args << aDetailType;
       
   635         args << aDetailValue;
       
   636         
       
   637         mRequest->setArguments(args); 
       
   638         mRequest->send();
       
   639         CNT_LOG_ARGS("Sent request.")
       
   640     }
       
   641     else
       
   642     {
       
   643         CNT_LOG_ARGS("Failed to create request.")
       
   644     }
       
   645     CNT_EXIT
       
   646 }
       
   647 
       
   648 void testPbkServices::launchContactCard( bool aNewInterface )
       
   649 {
       
   650     CNT_ENTRY
       
   651     delete mRequest;
       
   652     mRequest=0;
       
   653 
       
   654     // save test contact
       
   655     QContact contact;
       
   656     QContactName name;
       
   657     QContactPhoneNumber number;
       
   658     QContactManager mgr("symbian");
       
   659     
       
   660     name.setFirstName("Test launchContactCard");
       
   661     number.setNumber("0202221111");
       
   662     contact.saveDetail(&name);
       
   663     contact.saveDetail(&number);
       
   664     mgr.saveContact(&contact);
       
   665     
       
   666     // get contact id
       
   667     int id = contact.id().localId();
       
   668         
       
   669     QVariantList args; 
       
   670     XQApplicationManager appMng;
       
   671     if ( aNewInterface )
       
   672     {
       
   673         QString interface("com.nokia.symbian.IContactView");
       
   674         QString operation("openContactCard(int)");
       
   675         // interface name is not needed
       
   676         mRequest = appMng.create( interface, operation, true); // embedded 
       
   677     }
       
   678     else
       
   679     {
       
   680         QString interface("Fetch");
       
   681         QString operation("open(int)");
       
   682         QString serviceName("com.nokia.services.phonebookservices");
       
   683         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   684     }
       
   685     if ( mRequest )
       
   686     {    
       
   687         CNT_LOG_ARGS("Request created.")
       
   688         // Result handlers 
       
   689         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   690         
       
   691         args << id;
       
   692         
       
   693         mRequest->setArguments(args); 
       
   694         mRequest->send();
       
   695         CNT_LOG_ARGS("Request sent.")
       
   696     }
       
   697     else
       
   698     {
       
   699         CNT_LOG_ARGS("Failed to create request")
       
   700     }
       
   701     CNT_EXIT
       
   702 }
       
   703 
       
   704 void testPbkServices::launchContactCard( bool aNewInterface, QString aDetailType, QString aDetailValue )
       
   705 {
       
   706     CNT_ENTRY
       
   707     delete mRequest;
       
   708     mRequest=0;
       
   709         
       
   710     QVariantList args; 
       
   711     XQApplicationManager appMng;
       
   712     if ( aNewInterface )
       
   713     {
       
   714         QString interface("com.nokia.symbian.IContactView");
       
   715         QString operation("openContactCard(QString,QString)");
       
   716         // service name is not needed
       
   717         mRequest = appMng.create(interface, operation, true); // embedded 
       
   718     }
       
   719     else
       
   720     {
       
   721         QString interface("Fetch");
       
   722         QString operation("open(QString,QString)");
       
   723         QString serviceName("com.nokia.services.phonebookservices");
       
   724         mRequest = appMng.create(serviceName, interface, operation, true); // embedded 
       
   725     }
       
   726     if ( mRequest )
       
   727     {    
       
   728         CNT_LOG_ARGS("Request created.")
       
   729         // Result handlers 
       
   730         connect (mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(onRequestCompleted(const QVariant&)));
       
   731 
       
   732         args << aDetailType;
       
   733         args << aDetailValue;
       
   734 
       
   735         mRequest->setArguments(args); 
       
   736         mRequest->send();
       
   737     }
       
   738     else
       
   739     {
       
   740         CNT_LOG_ARGS("Failed to create request")
       
   741     }
       
   742     CNT_EXIT
       
   743 }
   400 
   744 
   401 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
   745 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
   402 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)
   746 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)