qthighway/examples/appmgrclient/src/appmgrclient.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    39 #include <math.h>
    39 #include <math.h>
    40 #include <QCompleter>
    40 #include <QCompleter>
    41 #include <xqserviceglobal.h>
    41 #include <xqserviceglobal.h>
    42 #include <QDir>
    42 #include <QDir>
    43 #include <QTranslator>
    43 #include <QTranslator>
       
    44 #include <cntservicescontact.h>
       
    45 
    44 #include <XQSharableFile.h>
    46 #include <XQSharableFile.h>
    45 
    47 
    46 #include <xqaiwdeclplat.h>
    48 #include <xqaiwdeclplat.h>
    47 
    49 
    48 #include "appmgrservices.h"
    50 #include "appmgrservices.h"
    49 #include "appmgrclient.h"
    51 #include "appmgrclient.h"
    50 
    52 
    51 
    53 
    52 AppMgrClient::AppMgrClient(QWidget *parent, Qt::WFlags f)
    54 AppMgrClient::AppMgrClient(QWidget *parent, Qt::WFlags f)
    53     : QWidget(parent, f),
    55     : QWidget(parent, f),
       
    56       actionButton(0),
    54       req1(0),
    57       req1(0),
    55       req2(0),
    58       req2(0),
    56       req3(0),
    59       req3(0),
    57       req4(0),
    60       req4(0),
    58       req5(0),
    61       req5(0),
    59       req6(0),
    62       req6(0),
    60       req7(0),
    63       req7(0),
    61       req8(0),
    64       req8(0),
    62       req9(0),
    65       req9(0),
    63       actionButton(0),
    66       req10(0),
    64       mImplIndex(0)      
    67       mImplIndex(0)      
    65 {
    68 {
    66     /* Adjust the palette */
    69     /* Adjust the palette */
    67 #if defined(Q_WS_S60)
    70 #if defined(Q_WS_S60)
    68     QPalette p = qApp->palette();
    71     QPalette p = qApp->palette();
    77     p.setColor(QPalette::Button, color.lighter(150));
    80     p.setColor(QPalette::Button, color.lighter(150));
    78     p.setColor(QPalette::Link, QColor(240,40,40));
    81     p.setColor(QPalette::Link, QColor(240,40,40));
    79     qApp->setPalette(p);
    82     qApp->setPalette(p);
    80 #endif
    83 #endif
    81 
    84 
       
    85     QPushButton *quitButton = new QPushButton(tr("quit"));
       
    86     connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
       
    87 
       
    88     
    82     QPushButton *testButton1 = 0;
    89     QPushButton *testButton1 = 0;
    83     QPushButton *anyTestButton = 0;
    90     QPushButton *anyTestButton = 0;
    84     
       
    85     QPushButton *quitButton = new QPushButton(tr("quit"));
       
    86     connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
       
    87 
    91 
    88     testButton1 = new QPushButton("Tests");
    92     testButton1 = new QPushButton("Tests");
    89     mMenu = new QMenu(this);
    93     mMenu = new QMenu(this);
    90     testButton1->setMenu(mMenu);
    94     testButton1->setMenu(mMenu);
    91     anyTestButton = new QPushButton(tr("Any test"));
    95     anyTestButton = new QPushButton(tr("Any test"));
    92     connect(anyTestButton, SIGNAL(clicked()), this, SLOT(anyTest()));
    96     connect(anyTestButton, SIGNAL(clicked()), this, SLOT(anyTest()));
    93 
    97 
    94     QAction *test1 = new QAction("Interface", this);
    98     QAction *test1 = new QAction("1:Interface", this);
    95     connect(test1, SIGNAL(triggered()), this, SLOT(test1()));
    99     connect(test1, SIGNAL(triggered()), this, SLOT(test1()));
    96     QAction *test2 = new QAction("Descriptor", this);
   100     QAction *test2 = new QAction("2:Descriptor", this);
    97     connect(test2, SIGNAL(triggered()), this, SLOT(test2()));
   101     connect(test2, SIGNAL(triggered()), this, SLOT(test2()));
    98     QAction *test3 = new QAction("Errors", this);
   102     QAction *test3 = new QAction("3:Errors", this);
    99     connect(test3, SIGNAL(triggered()), this, SLOT(test3()));
   103     connect(test3, SIGNAL(triggered()), this, SLOT(test3()));
   100     QAction *test4 = new QAction("QAction", this);
   104     QAction *test4 = new QAction("4:QAction", this);
   101     connect(test4, SIGNAL(triggered()), this, SLOT(test4()));
   105     connect(test4, SIGNAL(triggered()), this, SLOT(test4()));
   102     QAction *test5 = new QAction("appto:", this);
   106     QAction *test5 = new QAction("5:appto:", this);
   103     connect(test5, SIGNAL(triggered()), this, SLOT(test5()));
   107     connect(test5, SIGNAL(triggered()), this, SLOT(test5()));
   104     QAction *test6 = new QAction("testto:", this);
   108     QAction *test6 = new QAction("6:testto:", this);
   105     connect(test6, SIGNAL(triggered()), this, SLOT(test6()));
   109     connect(test6, SIGNAL(triggered()), this, SLOT(test6()));
   106     QAction *test7 = new QAction("MIME", this);
   110     QAction *test7 = new QAction("7:MIME", this);
   107     connect(test7, SIGNAL(triggered()), this, SLOT(test7()));
   111     connect(test7, SIGNAL(triggered()), this, SLOT(test7()));
   108     QAction *test8 = new QAction("URI", this);
   112     QAction *test8 = new QAction("8:URI", this);
   109     connect(test8, SIGNAL(triggered()), this, SLOT(test8()));
   113     connect(test8, SIGNAL(triggered()), this, SLOT(test8()));
   110     QAction *test9 = new QAction("XQSharableFile", this);
   114     QAction *test9 = new QAction("9:XQSharableFile", this);
   111     connect(test9, SIGNAL(triggered()), this, SLOT(test9()));
   115     connect(test9, SIGNAL(triggered()), this, SLOT(test9()));
       
   116     QAction *test10 = new QAction("10:Select contact", this);
       
   117     connect(test10, SIGNAL(triggered()), this, SLOT(test10()));
       
   118     QAction *test11 = new QAction("11:getDrmAttr", this);
       
   119     connect(test11, SIGNAL(triggered()), this, SLOT(test11()));
   112 
   120 
   113     mMenu = new QMenu(this);
   121     mMenu = new QMenu(this);
   114     mMenu->addAction(test1);
   122     mMenu->addAction(test1);
   115     mMenu->addAction(test2);
   123     mMenu->addAction(test2);
   116     mMenu->addAction(test3);
   124     mMenu->addAction(test3);
   118     mMenu->addAction(test5);
   126     mMenu->addAction(test5);
   119     mMenu->addAction(test6);
   127     mMenu->addAction(test6);
   120     mMenu->addAction(test7);
   128     mMenu->addAction(test7);
   121     mMenu->addAction(test8);
   129     mMenu->addAction(test8);
   122     mMenu->addAction(test9);
   130     mMenu->addAction(test9);
       
   131     mMenu->addAction(test10);
       
   132     mMenu->addAction(test11);
   123 
   133 
   124     testButton1->setMenu(mMenu);
   134     testButton1->setMenu(mMenu);
   125     
   135     
   126     mCheckEmbedded = new QCheckBox("Embedded");
   136     mCheckEmbedded = new QCheckBox("Embedded");
   127     mSynchronous = new QCheckBox("Synchronous");
   137     mSynchronous = new QCheckBox("Synchronous");
   128     mBackground = new QCheckBox("Background");
   138     mBackground = new QCheckBox("Background");
       
   139     mForeground = new QCheckBox("Foreground");
   129     mCheckDeleteRequest = new QCheckBox("Delete request");
   140     mCheckDeleteRequest = new QCheckBox("Delete request");
   130     mGenericSend = new QCheckBox("Use generic send()");
   141     mGenericSend = new QCheckBox("Use generic send()");
   131     mCheckEmbedded->setCheckState(Qt::Checked);
   142     mCheckEmbedded->setCheckState(Qt::Checked);
   132     mSynchronous->setCheckState(Qt::Checked);
   143     mSynchronous->setCheckState(Qt::Checked);
   133     mGenericSend->setCheckState(Qt::Checked);  // Apply one send() for both embedded/non-embedded
   144     mGenericSend->setCheckState(Qt::Checked);  // Apply one send() for both embedded/non-embedded
   134     
   145     
   135     mReqArg = new QLineEdit("0");
   146     mReqArg = new QLineEdit("0");
   136     
   147     
   137     mTextRetValue = new QLineEdit("no ret value set");
   148     mTextRetValue = new QLineEdit("no ret value set");
   138 
   149 
   139     QLabel *label = new QLabel("APPMGR CLIENT TEST");
   150     QFileInfo appinfo (qApp->applicationFilePath());
       
   151     mAppName = appinfo.baseName();
       
   152 
       
   153     QLabel *label = new QLabel(mAppName);
   140 
   154 
   141     vl = new QVBoxLayout;
   155     vl = new QVBoxLayout;
   142     vl->setMargin(0);
   156     vl->setMargin(0);
   143     vl->setSpacing(0);
   157     vl->setSpacing(0);
   144 
   158 
   145     vl->addWidget(label);
   159     vl->addWidget(label);
   146     vl->addWidget(mCheckEmbedded);
   160     vl->addWidget(mCheckEmbedded);
   147     vl->addWidget(mSynchronous);
   161     vl->addWidget(mSynchronous);
   148     vl->addWidget(mBackground);
   162     vl->addWidget(mBackground);
       
   163     vl->addWidget(mForeground);
   149     vl->addWidget(mCheckDeleteRequest);
   164     vl->addWidget(mCheckDeleteRequest);
   150     vl->addWidget(mGenericSend);
   165     vl->addWidget(mGenericSend);
   151     vl->addWidget(mReqArg);
   166     vl->addWidget(mReqArg);
   152     vl->addWidget(mTextRetValue);
   167     vl->addWidget(mTextRetValue);
   153     vl->addWidget(new QLabel(" "));
   168     vl->addWidget(new QLabel(" "));
   175     delete req5;
   190     delete req5;
   176     delete req6;
   191     delete req6;
   177     delete req7;
   192     delete req7;
   178     delete req8;
   193     delete req8;
   179     delete req9;
   194     delete req9;
       
   195     delete req10;
   180     delete mMenu;
   196     delete mMenu;
   181     
   197     
   182 }
   198 }
   183 
   199 
   184 void AppMgrClient::test(XQAiwRequest **req, const QString& interface, const QString& operation, bool embedded)
   200 void AppMgrClient::test(XQAiwRequest **req, const QString& interface, const QString& operation)
   185 {
   201 {
   186     qDebug() << "AppMgrClient::test START";    
   202     qDebug() << mAppName << " test START"; 
   187 
   203 
   188     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   204     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   189     bool sync = (mSynchronous->checkState() == Qt::Checked);
   205     bool sync = (mSynchronous->checkState() == Qt::Checked);
   190     bool background = (mBackground->checkState() == Qt::Checked);
   206     bool background = (mBackground->checkState() == Qt::Checked);
   191     
   207     
   192     qDebug() << "AppMgrClient:test: embed=" << embed << ",sync=" << sync << "background=" << background;
   208     qDebug() << mAppName << " test: embed=" << embed << ",sync=" << sync << "background=" << background;
   193     
   209     
   194     if (!*req)
   210     if (!*req)
   195     {
   211     {
   196         *req = appmgr.create(interface, operation);
   212         *req = appmgr.create(interface, operation);
       
   213         if (!*req)
       
   214         {
       
   215             return;
       
   216         }
   197         connectSignals(*req);        
   217         connectSignals(*req);        
   198     }
   218     }
   199     // Test embedded funcions
   219     // Test embedded funcions
   200     (*req)->setEmbedded(embed);
   220     (*req)->setEmbedded(embed);
   201     (*req)->setSynchronous(sync);
   221     (*req)->setSynchronous(sync);
   202     (*req)->setBackground(background);
   222     (*req)->setBackground(background);
   203     
   223     
   204     qDebug("AppMgrClient::isEmbbedded %d", (*req)->isEmbedded());
   224     
       
   225     qDebug("%s::isEmbbedded %d", qPrintable(mAppName), (*req)->isEmbedded());
   205     
   226     
   206     test(req, mReqArg->text());
   227     test(req, mReqArg->text());
   207 
   228 
   208     qDebug() << "AppMgrClient::test END";    
   229     qDebug() << mAppName << " test END";    
   209     
   230     
   210 }
   231 }
   211 
   232 
   212 
   233 
   213 void AppMgrClient::test(XQAiwRequest **req, XQAiwInterfaceDescriptor &impl, const QString& operation, bool embedded)
   234 void AppMgrClient::test(XQAiwRequest **req, XQAiwInterfaceDescriptor &impl, const QString& operation)
   214 {
   235 {
   215     qDebug() << "AppMgrClient::test START";    
   236     qDebug() << mAppName << " test START";    
   216 
   237 
   217     if (!*req)
   238     if (!*req)
   218     {
   239     {
   219         *req = appmgr.create(impl, operation);
   240         *req = appmgr.create(impl, operation);
   220         connectSignals(*req);        
   241         connectSignals(*req);        
   221     }
   242     }
   222     // Test embedded funcions
   243     // Test embedded funcions
   223     qDebug("AppMgrClient::isEmbbedded %d", (*req)->isEmbedded());
   244     qDebug("%s::isEmbbedded %d", qPrintable(mAppName),(*req)->isEmbedded());
   224 
   245 
   225     test(req, mReqArg->text());
   246     test(req, mReqArg->text());
   226 
   247 
   227     qDebug() << "AppMgrClient::test END";    
   248     qDebug() << mAppName << " test END";    
   228 
   249 
   229 }
   250 }
   230 
   251 
   231 
   252 
   232 
   253 
   233 void AppMgrClient::test(XQAiwRequest **req, const QString &arg)
   254 void AppMgrClient::test(XQAiwRequest **req, const QString &arg)
   234 {
   255 {
   235     qDebug() << "AppMgrClient::testreq START";    
   256     qDebug() << mAppName << " testreq START";    
   236 
   257 
   237     if (!req || !*req)
   258     if (!req || !*req)
   238     {
   259     {
   239         qDebug() << "AIW-ERROR:AppMgrClient::NULL request";
   260         qDebug() <<  mAppName << " AIW-ERROR::NULL request";
   240         return;
   261         return;
   241     }
   262     }
   242 
   263 
   243     
   264     
   244     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   265     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   245     bool sync = (mSynchronous->checkState() == Qt::Checked);
   266     bool sync = (mSynchronous->checkState() == Qt::Checked);
   246     bool background = (mBackground->checkState() == Qt::Checked);
   267     bool background = (mBackground->checkState() == Qt::Checked);
       
   268     bool foreground = (mForeground->checkState() == Qt::Checked);
   247     
   269     
   248     // Set arguments for request
   270     // Set arguments for request
   249     QList<QVariant> args;
   271     QList<QVariant> args;
   250     args << arg;
   272     args << arg;
   251     args << QVariant(!sync);
   273     if ((*req)->operation() == OPERATION1)
       
   274     {
       
   275         qDebug() << mAppName << " test: add bool arg" << !sync;
       
   276         args << QVariant(!sync);
       
   277     }
   252     (*req)->setArguments(args);
   278     (*req)->setArguments(args);
   253 
   279 
   254     bool genericSend = (mGenericSend->checkState() == Qt::Checked);
   280     bool genericSend = (mGenericSend->checkState() == Qt::Checked);
   255     (*req)->setEmbedded(embed);
   281     (*req)->setEmbedded(embed);
   256     (*req)->setSynchronous(sync);
   282     (*req)->setSynchronous(sync);
   257     (*req)->setBackground(background);
   283     (*req)->setBackground(background);
   258     
   284     
       
   285     // Apply additional options
       
   286     XQRequestInfo options;
       
   287     options.setForeground(foreground);
       
   288     (*req)->setInfo(options);
       
   289     
   259     // Make the request
   290     // Make the request
   260     if (genericSend || !sync)
   291     if (genericSend || !sync)
   261     {
   292     {
   262         if (!(*req)->send())
   293         if (!(*req)->send())
   263         {
   294         {
   264             qDebug() << "AIW-ERROR: AppMgrClient:test: Send failed" << (*req)->lastError();;
   295             qDebug() << mAppName << " AIW-ERROR:test: Send failed" << (*req)->lastError();;
   265         }
   296         }
   266     }
   297     }
   267     else if (!genericSend && sync)
   298     else if (!genericSend && sync)
   268     {
   299     {
   269         QVariant retValue;
   300         QVariant retValue;
   270         if (!(*req)->send(retValue))
   301         if (!(*req)->send(retValue))
   271         {
   302         {
   272             qDebug() << "AIW-ERROR: AppMgrClient:test: Send(retValue) failed" << (*req)->lastError();;
   303             qDebug() << mAppName <<  " AIW-ERROR: test: Send(retValue) failed" << (*req)->lastError();;
   273         }
   304         }
   274         else
   305         else
   275         {
   306         {
   276             if (retValue.canConvert<QString>())
   307             if (retValue.canConvert<QString>())
   277             {
   308             {
   278                 qDebug("AppMgrClient::retValue=%s,%s",
   309                 qDebug("%s::retValue=%s,%s", qPrintable(mAppName),
   279                        retValue.typeName(),
   310                        retValue.typeName(),
   280                        qPrintable(retValue.value<QString>()));
   311                        qPrintable(retValue.value<QString>()));
   281                 mTextRetValue->setText(retValue.value<QString>());
   312                 mTextRetValue->setText(retValue.value<QString>());
   282             }
   313             }
   283             else
   314             else
   284             {
   315             {
   285                 qDebug("AppMgrClient:retValue=%s",
   316                 qDebug("%s:retValue=%s", qPrintable(mAppName),
   286                        retValue.typeName());
   317                        retValue.typeName());
   287                 mTextRetValue->setText("Not displayable");
   318                 mTextRetValue->setText("Not displayable");
   288             }
   319             }
   289 
   320 
   290         }
   321         }
   299         deleteRequest = true;
   330         deleteRequest = true;
   300     }
   331     }
   301         
   332         
   302     if (deleteRequest)
   333     if (deleteRequest)
   303     {
   334     {
   304         qDebug() << "AIW-NOTE: Request deleted";
   335         qDebug() << mAppName <<  " AIW-NOTE: Request deleted";
   305         delete *req;
   336         delete *req;
   306         *req = 0;
   337         *req = 0;
   307     }
   338     }
   308 
   339 
   309     qDebug() << "AppMgrClient::test END";
   340     qDebug() << mAppName << " test END";
   310 
   341 
   311     update();
   342     update();
   312     
   343     
   313 
   344 
   314 }
   345 }
   333     qDebug() << dir;
   364     qDebug() << dir;
   334 
   365 
   335     QFile file(dir + "/" + fileName);
   366     QFile file(dir + "/" + fileName);
   336     if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
   367     if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
   337     {
   368     {
   338         qDebug() << "Creating file failed " << QString(dir + "/" + fileName);
   369         qDebug() << mAppName <<  " Creating file failed " << QString(dir + "/" + fileName);
   339         return;
   370         return;
   340     }
   371     }
   341     QTextStream out(&file);
   372     QTextStream out(&file);
   342     out << "Text in file" << "\n";
   373     out << "Text in file" << "\n";
   343     file.close();
   374     file.close();
   344     
   375     
   345 }
   376 }
   346 
   377 
       
   378 bool AppMgrClient::testRunning(const QString & service, const QString & interface)
       
   379 {
       
   380 
       
   381     QList<XQAiwInterfaceDescriptor> impls = appmgr.list(service, interface, QString(""));
       
   382     qDebug() << mAppName <<  " isRunning" << impls.count();
       
   383     if (impls.count() > 0)
       
   384     {
       
   385         bool b = appmgr.isRunning(impls[0]);
       
   386         qDebug() << mAppName <<  " isRunning=" << b;
       
   387         return b;
       
   388     }
       
   389     else
       
   390     {
       
   391         qDebug("%s isRunning: no service found (%s,%s)", qPrintable(mAppName),
       
   392                qPrintable(service),qPrintable(interface));
       
   393         return false;
       
   394     }
       
   395    
       
   396 }
       
   397 
   347 
   398 
   348 void AppMgrClient::test1()
   399 void AppMgrClient::test1()
   349 {
   400 {
   350     qDebug() << "AppMgrClient::test1 START";
   401 
       
   402     qDebug() << mAppName << " test1 START";
   351     test(&req1, IDIAL, OPERATION1);
   403     test(&req1, IDIAL, OPERATION1);
   352     qDebug() << "AppMgrClient::test1 END";
   404     qDebug() << mAppName << " test1 END";
   353 
   405 
       
   406     qDebug("%s::isRunning=%d", qPrintable(mAppName), testRunning("com.nokia.services.serviceapp", IDIAL));
       
   407     
       
   408     
   354     /*
   409     /*
   355     mReqArg->setText("77777"); 
   410     mReqArg->setText("77777"); 
   356     qDebug() << "AppMgrClient::test1 second call";
   411     qDebug() << mAppName <<  " test1 second call";
   357     test(&req1, IDIAL, OPERATION1);
   412     test(&req1, IDIAL, OPERATION1);
   358     */
   413     */
   359 }
   414 }
   360 
   415 
   361 
   416 
   362 void AppMgrClient::test2()
   417 void AppMgrClient::test2()
   363 {
   418 {
   364     qDebug() << "AppMgrClient::test2 START";
   419     qDebug() << mAppName << " test2 START";
   365     
   420     
   366     QList<XQAiwInterfaceDescriptor> list=appmgr.list(IDIAL, "");
   421     QList<XQAiwInterfaceDescriptor> list=appmgr.list(IDIAL, "");
   367     qDebug() << "AppMgrClient::Found implementations: " << list.count();
   422     qDebug() << mAppName << " list implementations: " << list.count();
   368     int i=0;
   423     int i=0;
       
   424     Q_ASSERT(list.count() > 0);
   369     foreach (XQAiwInterfaceDescriptor d, list)
   425     foreach (XQAiwInterfaceDescriptor d, list)
   370     {
   426     {
   371         qDebug("AppMgrClient::Service[%d]=%s",i,qPrintable(d.serviceName()));
   427         qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName()));
   372         qDebug("AppMgrClient::Interface[%d]=%s",i,qPrintable(d.interfaceName()));
   428         qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName()));
   373         qDebug("AppMgrClient::Implementation Id[%d]=%x",i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
   429         qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
       
   430         qDebug("%s::isRunning=%d", qPrintable(mAppName), testRunning(d.serviceName(), d.interfaceName()));
       
   431         qDebug("%s::status=%d", qPrintable(mAppName), appmgr.status(d));
   374         i++;
   432         i++;
   375     }
   433     }
       
   434 
       
   435     QList<XQAiwInterfaceDescriptor> list2=appmgr.list("com.nokia.services.serviceapp", IDIAL, "");
       
   436     qDebug() << mAppName << " list implementations 2: " << list2.count();
       
   437     i=0;
       
   438     Q_ASSERT(list2.count() > 0);
       
   439     foreach (XQAiwInterfaceDescriptor d, list2)
       
   440     {
       
   441         qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName()));
       
   442         qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName()));
       
   443         qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
       
   444         i++;
       
   445     }
       
   446 
       
   447     QList<XQAiwInterfaceDescriptor> list3=appmgr.list("serviceapp", IDIAL, "");
       
   448     qDebug() << mAppName << " New: list implementations: " << list3.count();
       
   449     i=0;
       
   450     Q_ASSERT(list3.count() > 0);
       
   451     foreach (XQAiwInterfaceDescriptor d, list3)
       
   452     {
       
   453         qDebug("%s::Service[%d]=%s",qPrintable(mAppName),i,qPrintable(d.serviceName()));
       
   454         qDebug("%s::Interface[%d]=%s",qPrintable(mAppName),i,qPrintable(d.interfaceName()));
       
   455         qDebug("%s::Implementation Id[%d]=%x",qPrintable(mAppName),i,d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
       
   456         i++;
       
   457     }
   376     
   458     
   377     if (!list.isEmpty())
   459     if (!list.isEmpty())
   378     {
   460     {
   379         // Use the first found
   461         // Use the first found
   380         qDebug() << "AppMgrClient::Using implementation nbr: " << mImplIndex;
   462         qDebug() << mAppName << " Using implementation nbr: " << mImplIndex;
   381         test(&req2,list[mImplIndex], OPERATION1);
   463         test(&req2,list[mImplIndex], OPERATION1);
   382     }
   464     }
   383 
   465 
   384     qDebug() << "AppMgrClient::test2 END";
   466     qDebug() << mAppName << " test2 END";
   385     
   467     
   386 }
   468 }
   387 
   469 
   388 void AppMgrClient::test3()
   470 void AppMgrClient::test3()
   389 {
   471 {
   390     qDebug() << "AppMgrClient::test3 START";
   472     qDebug() << mAppName << " test3 START";
   391     
   473     
   392     test(&req3,IDIAL,ERR_OPERATION1);
   474     test(&req3,IDIAL,ERR_OPERATION1);
   393     test(&req3,ERR_IDIAL,ERR_OPERATION1);
   475     test(&req3,ERR_IDIAL,ERR_OPERATION1);
   394     test(&req3,ERR_IDIAL,ERR_OPERATION1);
   476     test(&req3,ERR_IDIAL,ERR_OPERATION1);
   395     
   477     
   396     qDebug() << "AppMgrClient::test3 END";
   478     qDebug() << mAppName << " test3 END";
   397     
   479     
   398 }
   480 }
   399 
   481 
   400 void AppMgrClient::test4()
   482 void AppMgrClient::test4()
   401 {
   483 {
   402     qDebug() << "AppMgrClient::test4 START";
   484     qDebug() << mAppName << " test4 START";
   403 
   485 
   404     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   486     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   405     bool sync = (mSynchronous->checkState() == Qt::Checked);
   487     bool sync = (mSynchronous->checkState() == Qt::Checked);
       
   488     bool foreground = (mForeground->checkState() == Qt::Checked);
   406 
   489 
   407     if (req4)
   490     if (req4)
   408     {
   491     {
   409         delete req4;  // Previous
   492         delete req4;  // Previous
   410         req4 = 0;
   493         req4 = 0;
   412 
   495 
   413     // Only hbserviceprovider support localization
   496     // Only hbserviceprovider support localization
   414     req4 = appmgr.create(QLatin1String("com.nokia.services.hbserviceprovider"), IDIAL, OPERATION1);
   497     req4 = appmgr.create(QLatin1String("com.nokia.services.hbserviceprovider"), IDIAL, OPERATION1);
   415     if (!req4)
   498     if (!req4)
   416     {
   499     {
   417         qDebug() << "AIW-ERROR:AppMgrClient::NULL request";
   500         qDebug() << mAppName << " AIW-ERROR::NULL request";
   418         return;
   501         return;
   419     }
   502     }
   420 
   503 
   421     connectSignals(req4); 
   504     connectSignals(req4);
   422     req4->setEmbedded(embed);
   505     req4->setSynchronous(sync);
   423     req4->setSynchronous(embed);
   506 
       
   507     // In this test case, apply "options" for other options
       
   508     XQRequestInfo options;
       
   509     options.setEmbedded(embed);
       
   510     options.setForeground(foreground);
       
   511     req4->setInfo(options);
   424 
   512 
   425     if (actionButton)
   513     if (actionButton)
   426     {
   514     {
   427         // Previous
   515         // Previous
   428         vl->removeWidget(actionButton);
   516         vl->removeWidget(actionButton);
   430         actionButton = 0;
   518         actionButton = 0;
   431         update();
   519         update();
   432     }
   520     }
   433     
   521     
   434     QAction *action = req4->createAction();  // Also connects the triggered event to req !!!!
   522     QAction *action = req4->createAction();  // Also connects the triggered event to req !!!!
   435     qDebug() << "AppMgrClient::action:" << action->isEnabled();
   523     qDebug() << mAppName << " action:" << action->isEnabled();
   436     
   524     
   437     // Create UI
   525     // Create UI
   438     if (action)
   526     if (action)
   439     {
   527     {
   440         actionButton = new QPushButton(action->text());
   528         actionButton = new QPushButton(action->text());
   446         connect(actionButton, SIGNAL(clicked()), action, SIGNAL(triggered()));
   534         connect(actionButton, SIGNAL(clicked()), action, SIGNAL(triggered()));
   447         connect(req4, SIGNAL(triggered()), this, SLOT(test4ActionTriggered()));
   535         connect(req4, SIGNAL(triggered()), this, SLOT(test4ActionTriggered()));
   448     }
   536     }
   449     else
   537     else
   450     {
   538     {
   451         qDebug() << "AppMgrClient::test4 No action available";
   539         qDebug() << mAppName << " test4 No action available";
   452 
   540 
   453     }
   541     }
   454 
   542 
   455     qDebug() << "AppMgrClient::test4 END";
   543     qDebug() << mAppName << " test4 END";
   456     
   544     
   457 }
   545 }
   458 
   546 
   459 void AppMgrClient::test4ActionTriggered()
   547 void AppMgrClient::test4ActionTriggered()
   460 {
   548 {
   469 
   557 
   470 }
   558 }
   471 
   559 
   472 void AppMgrClient::test5()
   560 void AppMgrClient::test5()
   473 {
   561 {
   474     qDebug() << "AppMgrClient::test5 START";
   562     qDebug() << mAppName << " test5 START";
   475 
   563 
   476     // E0022E73 == ServiceApp
   564     // E0022E73 == ServiceApp
   477     QUrl uri(XQURI_SCHEME_ACTIVITY + "://E0022E73?" + XQURI_KEY_ACTIVITY_NAME + "=emailView&view=myview"); 
   565     QUrl uri(XQURI_SCHEME_ACTIVITY + "://E0022E73?" + XQURI_KEY_ACTIVITY_NAME + "=emailView&view=myview"); 
   478     qDebug() << "AppMgrClient::Uri=" << uri.toString();
   566     qDebug() << mAppName << " Uri=" << uri.toString();
   479     qDebug() << "AppMgrClient::isValid=" << uri.isValid();
   567     qDebug() << mAppName << " isValid=" << uri.isValid();
   480     qDebug() << "AppMgrClient::Uri authority=" << uri.authority();
   568     qDebug() << mAppName << " Uri authority=" << uri.authority();
   481     QString old=mReqArg->text();
   569     QString old=mReqArg->text();
   482     if (!req5)
   570     if (!req5)
   483     {
   571     {
   484         req5 = appmgr.create(uri);
   572         req5 = appmgr.create(uri);
   485         connectSignals(req5); 
   573         connectSignals(req5); 
   487     
   575     
   488     mReqArg->setText(uri.encodedQuery()); 
   576     mReqArg->setText(uri.encodedQuery()); 
   489     test(&req5, mReqArg->text());
   577     test(&req5, mReqArg->text());
   490     mReqArg->setText(old);
   578     mReqArg->setText(old);
   491     
   579     
   492     qDebug() << "AppMgrClient::test5 END";
   580     qDebug() << mAppName << " test5 END";
   493     
   581     
   494 }
   582 }
   495 
   583 
   496 void AppMgrClient::test6()
   584 void AppMgrClient::test6()
   497 {
   585 {
   498     qDebug() << "AppMgrClient::test6 START";
   586     qDebug() << mAppName << " test6 START";
   499 
   587 
   500     QUrl uri("testto://authority?param1=value1&param1=value2"); 
   588     QUrl uri("testto://authority?param1=value1&param1=value2"); 
   501     qDebug() << "AppMgrClient::Uri=" << uri.toString();
   589     qDebug() << mAppName << " Uri=" << uri.toString();
   502     qDebug() << "AppMgrClient::isValid=" << uri.isValid();
   590     qDebug() << mAppName << " isValid=" << uri.isValid();
   503     qDebug() << "AppMgrClient::Uri authority=" << uri.authority();
   591     qDebug() << mAppName << " Uri authority=" << uri.authority();
   504 
   592 
   505     QList<XQAiwInterfaceDescriptor> uriHandlers = appmgr.list(uri);
   593     QList<XQAiwInterfaceDescriptor> uriHandlers = appmgr.list(uri);
   506     // Note : Only services supporting custom property are returned
   594     // Note : Only services supporting custom property are returned
   507     foreach (XQAiwInterfaceDescriptor d, uriHandlers)
   595     foreach (XQAiwInterfaceDescriptor d, uriHandlers)
   508     {
   596     {
   509         qDebug() << "AppMgrClient::Service=" << d.serviceName();
   597         qDebug() << mAppName << " Service=" << d.serviceName();
   510         qDebug() << "AppMgrClient::Interface=" << d.interfaceName();
   598         qDebug() << mAppName << " Interface=" << d.interfaceName();
   511         qDebug("AppMgrClient::Implementation Id=%x",d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
   599         qDebug("%s::Implementation Id=%x",qPrintable(mAppName),d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt());
       
   600         qDebug("%s::isRunning=%d", qPrintable(mAppName), testRunning(d.serviceName(), d.interfaceName()));
   512     }
   601     }
   513 
   602 
   514     if (!req6)
   603     if (!req6)
   515     {
   604     {
   516         req6 = appmgr.create(uri);
   605         req6 = appmgr.create(uri);
   517         connectSignals(req6); 
   606         connectSignals(req6); 
   518     }
   607     }
   519 
   608 
   520     test(&req6, uri.toString());
   609     test(&req6, uri.toString());
   521 
   610 
   522     qDebug() << "AppMgrClient::test6 END";
   611     qDebug() << mAppName << " test6 END";
   523     
   612     
   524 }
   613 }
   525 
   614 
   526 void AppMgrClient::test7()
   615 void AppMgrClient::test7()
   527 {
   616 {
   528     qDebug() << "AppMgrClient::test7 START";
   617     qDebug() << mAppName << " test7 START";
   529     
   618     
   530     // Should launch viewer for text/plain MimeTestApp.
   619     // Should launch viewer for text/plain MimeTestApp.
   531     // Create test file
   620     // Create test file
   532     createTestFile("C:/data/Others", "test.txt");
   621     createTestFile("C:/data/Others", "test.txt");
       
   622 
   533     
   623     
   534     QFile file("C:/data/Others/test.txt");
   624     QFile file("C:/data/Others/test.txt");
   535     qDebug() << "AppMgrClient::File=" << file.fileName();
   625     qDebug() << mAppName << " File=" << file.fileName();
   536     qDebug() << "AppMgrClient::exists=" << file.exists();
   626     qDebug() << mAppName << " exists=" << file.exists();
   537 
   627 
   538     QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(file);
   628     QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(file);
   539     foreach (XQAiwInterfaceDescriptor d, fileHandlers)
   629     foreach (XQAiwInterfaceDescriptor d, fileHandlers)
   540     {
   630     {
   541         qDebug() << "AppMgrClient::Service=" << d.serviceName();
   631         qDebug() << mAppName << " Service=" << d.serviceName();
   542         qDebug() << "AppMgrClient::Interface=" << d.interfaceName();
   632         qDebug() << mAppName << " Interface=" << d.interfaceName();
   543         qDebug() << "AppMgrClient::Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
   633         qDebug() << mAppName << " Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
   544     }
   634     }
   545     
   635     
   546     if (!req7)
   636     if (!req7)
   547     {
   637     {
   548         req7 = appmgr.create(file);
   638         req7 = appmgr.create(file);
   549         connectSignals(req7); 
   639         connectSignals(req7); 
   550     }
   640     }
   551     test(&req7, file.fileName());
   641     test(&req7, file.fileName());
   552 
   642 
   553     qDebug() << "AppMgrClient::test7 END";
   643     qDebug() << mAppName << " test7 END";
   554     
   644     
   555 }
   645 }
   556 
   646 
   557 
   647 
   558 void AppMgrClient::test8()
   648 void AppMgrClient::test8()
   559 {
   649 {
   560     qDebug() << "AppMgrClient::test8 START";
   650     qDebug() << mAppName << " test8 START";
   561 
   651 
   562     // E0022E73 == ServiceApp
   652     // E0022E73 == ServiceApp
   563     QUrl uri("http://www.nokia.com"); 
   653     QUrl uri("http://www.nokia.com"); 
   564     qDebug() << "AppMgrClient::Uri=" << uri.toString();
   654     qDebug() << mAppName << " Uri=" << uri.toString();
   565     qDebug() << "AppMgrClient::isValid=" << uri.isValid();
   655     qDebug() << mAppName << " isValid=" << uri.isValid();
   566     qDebug() << "AppMgrClient::Uri authority=" << uri.authority();
   656     qDebug() << mAppName << " Uri authority=" << uri.authority();
   567 
   657 
   568     if (!req8)
   658     if (!req8)
   569     {
   659     {
   570         req8 = appmgr.create(uri);
   660         req8 = appmgr.create(uri);
   571         connectSignals(req8); 
   661         connectSignals(req8); 
   572     }
   662     }
   573     test(&req8, uri.toString());
   663     test(&req8, uri.toString());
   574 
   664 
   575     qDebug() << "AppMgrClient::test8 END";
   665     qDebug() << mAppName << " test8 END";
   576     
   666     
   577 }
   667 }
   578 
   668 
   579 void AppMgrClient::test9()
   669 void AppMgrClient::test9()
   580 {
   670 {
   581 
   671 
   582     qDebug() << "AppMgrClient::test9 START";    
   672     qDebug() << mAppName << " test9 START";    
   583 
   673 
   584     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   674     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   585     bool sync = (mSynchronous->checkState() == Qt::Checked);
   675     bool sync = (mSynchronous->checkState() == Qt::Checked);
   586     bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked);
   676     bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked);
   587 
   677 
   588 
   678 
   589     // Access data-caged file 
   679     // Access data-caged file 
   590     XQSharableFile sf;
   680     XQSharableFile sf;
   591     createTestFile("c:/private/e0022e74", "test.txt");
   681     QString fileDir = "c:/private/e0022e74";
   592     if (!sf.open("c:\\private\\e0022e74\\test.txt"))
   682     
   593     {
   683     if (mAppName == "appmgrclient2")
   594         qDebug() << "AppMgrClient:file open failed";
   684     {
       
   685         fileDir = "c:/private/e0022e76";
       
   686     }
       
   687 
       
   688     createTestFile(fileDir, "test.txt");
       
   689     if (!sf.open(fileDir + "\\test.txt"))
       
   690     {
       
   691         qDebug() << mAppName << " file open failed " << (fileDir + "/test.txt");
   595         return;
   692         return;
   596     }
   693     }
   597 
   694 
   598     // Just test listing by sharable file
   695     // Just test listing by sharable file
   599     QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(sf);
   696     QList<XQAiwInterfaceDescriptor> fileHandlers = appmgr.list(sf);
   600     if (fileHandlers.count() > 0)
   697     if (fileHandlers.count() > 0)
   601     {
   698     {
   602         XQAiwInterfaceDescriptor d = fileHandlers.first();
   699         XQAiwInterfaceDescriptor d = fileHandlers.first();
   603         qDebug() << "AppMgrClient::File Service=" << d.serviceName();
   700         qDebug() << mAppName << " File Service=" << d.serviceName();
   604         qDebug() << "AppMgrClient::File Interface=" << d.interfaceName();
   701         qDebug() << mAppName << " File Interface=" << d.interfaceName();
   605         qDebug() << "AppMgrClient::Handler Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
   702         qDebug() << mAppName << " Handler Implementation Id=" << d.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
   606         if (!req9)
   703         if (!req9)
   607         {
   704         {
   608             // Create by descriptor
   705             // Create by descriptor
   609             req9 = appmgr.create(sf, d);
   706             req9 = appmgr.create(sf, d);
   610         }
   707         }
   611         if (!req9)
   708         if (!req9)
   612         {
   709         {
   613             sf.close();
   710             sf.close();
   614             qDebug() << "AppMgrClient:anyTest: ERROR IN XQAppMgr API";
   711             qDebug() << mAppName <<  " anyTest: ERROR IN XQAppMgr API";
   615             return ;
   712             return ;
   616         }
   713         }
   617     }
   714     }
   618     else
   715     else
   619     {
   716     {
   620         sf.close();
   717         sf.close();
   621         qDebug() << "AppMgrClient:anyTest: NO HANDLER FOUND";
   718         qDebug() << mAppName <<  " anyTest: NO HANDLER FOUND";
   622     }
   719     }
   623 
   720 
   624     connectSignals(req9);        
   721     connectSignals(req9);        
   625     req9->setEmbedded(embed);
   722     req9->setEmbedded(embed);
   626     req9->setSynchronous(sync);
   723     req9->setSynchronous(sync);
   631     
   728     
   632     req9->send();
   729     req9->send();
   633     if (req9->lastError() == XQService::EMessageNotFound)
   730     if (req9->lastError() == XQService::EMessageNotFound)
   634     {
   731     {
   635         // Slot was not found
   732         // Slot was not found
   636         qDebug() << "AIW-ERROR:XQService::EMessageNotFound";
   733         qDebug() << mAppName <<  " AIW-ERROR:XQService::EMessageNotFound";
   637         deleteRequest = true;
   734         deleteRequest = true;
   638     }
   735     }
   639     // Remember to close the file !!!
   736     // Remember to close the file !!!
   640     sf.close();
   737     sf.close();
   641 
   738 
   643     {
   740     {
   644         delete req9;
   741         delete req9;
   645         req9 = 0;
   742         req9 = 0;
   646     }
   743     }
   647 
   744 
   648     qDebug() << "AppMgrClient::test9 END";
   745     qDebug() << mAppName << " test9 END";
   649     
   746     
       
   747 }
       
   748 
       
   749 // Test 10
       
   750 void AppMgrClient::test10()
       
   751 {
       
   752 
       
   753     qDebug() << mAppName << " test10 START";
       
   754 
       
   755     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
       
   756     bool sync = (mSynchronous->checkState() == Qt::Checked);
       
   757     bool background = (mBackground->checkState() == Qt::Checked);
       
   758 
       
   759     qDebug() << mAppName <<  " test10: embed=" << embed << ",sync=" << sync << "background=" << background;
       
   760 
       
   761     if (!req10)
       
   762     {
       
   763         req10 = appmgr.create(QLatin1String("com.nokia.services.phonebookservices"), QLatin1String("Fetch"), QLatin1String(""));
       
   764         connect(req10, SIGNAL(requestOk(const QVariant&)), this, SLOT(showRecipients(const QVariant&)));
       
   765         connect(req10, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&)));
       
   766     }
       
   767 
       
   768     if (!req10)
       
   769     {
       
   770         qDebug() << mAppName <<  " AIW-ERROR: NULL request";
       
   771         return;
       
   772     }
       
   773 
       
   774     // Set request attributes
       
   775     req10->setOperation("fetch(QString,QString,QString)");
       
   776     req10->setEmbedded(embed);
       
   777     req10->setSynchronous(sync);
       
   778     req10->setBackground(background);
       
   779 
       
   780     // Set arguments
       
   781     QList<QVariant> args;
       
   782     args << "Contact"; 
       
   783     args << KCntActionAll;   
       
   784     args << KCntFilterDisplayAll;
       
   785     req10->setArguments(args);
       
   786 
       
   787     // Send the request
       
   788     req10->send();
       
   789 
       
   790     bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked);
       
   791     if (deleteRequest)
       
   792     {
       
   793         delete req10;
       
   794         req10 = 0;
       
   795     }
       
   796     
       
   797     qDebug() << mAppName << " test10 END";
       
   798 
       
   799 
       
   800 }
       
   801 
       
   802 
       
   803 void AppMgrClient::test11()
       
   804 {
       
   805     qDebug() << mAppName << " test11 START";
       
   806 
       
   807     // Copy files from DrmTestFiles.zip into correct location
       
   808     QList<QString> drmFiles;
       
   809     drmFiles.append("C:/data/Others/RoAcqoffer-111-aac-i15m.ort");
       
   810     drmFiles.append("C:/data/Others/SD_Celebration_SP.dcf");
       
   811     drmFiles.append("C:/data/Others/111-test1.odf");
       
   812     drmFiles.append("C:/data/Others/SD_jpg_sun.dcf");
       
   813     drmFiles.append("C:/data/Others/STC1_128_44_16_2_CBR.wma");
       
   814     drmFiles.append("C:/data/Others/test.txt");
       
   815     drmFiles.append("C:/data/Others/foo.txt");
       
   816 
       
   817     QList<int> attrNames;
       
   818     attrNames.append(XQApplicationManager::MimeType);
       
   819     attrNames.append(XQApplicationManager::IsProtected);
       
   820     attrNames.append(XQApplicationManager::IsForwardable);
       
   821 
       
   822     // Test with file names
       
   823     foreach (QString f, drmFiles)
       
   824     {
       
   825         QFile file(f);
       
   826         QVariantList attrValues;
       
   827         bool ok = appmgr.getDrmAttributes(file, attrNames, attrValues);
       
   828         qDebug() << mAppName << " getDrmAttributes for " << f << " status=" << ok;
       
   829         int i=0;
       
   830         foreach (QVariant v, attrValues)
       
   831         {
       
   832             qDebug() << mAppName << " Attribute " << attrNames[i] << "=" << qPrintable(v.toString());
       
   833             i++;
       
   834         }
       
   835     }
       
   836 
       
   837     // Test with file handles
       
   838     foreach (QString f, drmFiles)
       
   839     {
       
   840         XQSharableFile file;
       
   841         file.open(f);  // Create handle manually
       
   842         QVariantList attrValues;
       
   843         bool ok = appmgr.getDrmAttributes(file, attrNames, attrValues);
       
   844         qDebug() << mAppName << " getDrmAttributes for file " << file.fileName() << " handle status=" << ok;
       
   845         int i=0;
       
   846         foreach (QVariant v, attrValues)
       
   847         {
       
   848             qDebug() << mAppName << " Attribute " << attrNames[i] << "=" << qPrintable(v.toString());
       
   849             i++;
       
   850         }
       
   851         file.close();
       
   852     }
       
   853     
       
   854     qDebug() << mAppName << " test11 END";
       
   855 
       
   856 }
       
   857 
       
   858 
       
   859 void AppMgrClient::showRecipients(const QVariant &value)
       
   860 {
       
   861     qDebug("%s::showRecipients::variant(%d,%s)", qPrintable(mAppName),value.type(), value.typeName());
       
   862     
       
   863     CntServicesContactList list;
       
   864     if(value.canConvert<CntServicesContactList>())
       
   865     {
       
   866         qDebug() << mAppName << " showRecipients: canConvert";
       
   867         list = qVariantValue<CntServicesContactList>(value);
       
   868     }
       
   869     else
       
   870     {
       
   871         qDebug() << mAppName << " showRecipients: canConvert NOK !!!";
       
   872         return;
       
   873     }    
       
   874 
       
   875     if (list.count() == 0)
       
   876     {
       
   877         qDebug() << mAppName << " showRecipients: Count==0";
       
   878     }
       
   879     else {
       
   880         for (int i = 0; i < list.count(); ++i)
       
   881         {
       
   882             qDebug() << mAppName << " showRecipients[" << i << "]=" << list[i].mDisplayName;
       
   883             qDebug() << mAppName << " showRecipients[" << i << "]=" << list[i].mPhoneNumber;
       
   884             qDebug() << mAppName << " showRecipients[" << i << "]=" << list[i].mEmailAddress;
       
   885 
       
   886         }
       
   887     }
   650 }
   888 }
   651 
   889 
   652 
   890 
   653 
   891 
   654 
   892 
   655 #define TXT_ID QLatin1String("txt_aiw_action_text")
   893 #define TXT_ID QLatin1String("txt_aiw_action_text")
   656 
   894 
   657 void AppMgrClient::anyTest()
   895 void AppMgrClient::anyTest()
   658 {
   896 {
   659 
   897 
   660 
   898     qDebug() << mAppName << " anyTest START";
   661     qDebug() << "AppMgrClient:name" << qApp->applicationName();
   899 
   662     qDebug() << "AppMgrClient:dirpath" << qApp->applicationDirPath();
   900     bool embed = (mCheckEmbedded->checkState() == Qt::Checked);
   663     qDebug() << "AppMgrClient:filename" << qApp->applicationFilePath();
   901     bool sync = (mSynchronous->checkState() == Qt::Checked);
   664     qDebug() << "AppMgrClient:pid" << qApp->applicationPid();
   902     bool background = (mBackground->checkState() == Qt::Checked);
   665     
   903 
       
   904     XQAiwRequest *req=0;
       
   905     req = appmgr.create(QLatin1String("com.nokia.services.serviceapp"), IDIAL, QLatin1String("testContactList(CntServicesContactList)"));
       
   906 
       
   907     if (!req)
       
   908     {
       
   909         qDebug() << mAppName << " AIW-ERROR NULL request";
       
   910         return;
       
   911     }
       
   912 
       
   913     // Comment next line  if using the operation signature given in the "create"
       
   914     req->setOperation(QLatin1String("testVariant(QVariant)"));
       
   915     
       
   916     connectSignals(req);        
       
   917 
       
   918     // Set request attributes
       
   919     req->setEmbedded(embed);
       
   920     req->setSynchronous(sync);
       
   921     req->setBackground(background);
       
   922 
       
   923     QList<QVariant> args;
       
   924     
       
   925     // Just construct dummies
       
   926     MetaDummy1 dummy1;
       
   927     MetaDummy2 dummy2;
       
   928     
       
   929     CntServicesContact cnt1;
       
   930     cnt1.mDisplayName = "Test1";
       
   931     cnt1.mPhoneNumber = "050-1111111";
       
   932     cnt1.mEmailAddress = "test1.test@nokia.com";
       
   933     
       
   934     CntServicesContact cnt2;
       
   935     cnt2.mDisplayName = "Test2";
       
   936     cnt2.mPhoneNumber = "050-2222222";
       
   937     cnt2.mEmailAddress = "test2.test@nokia.com";
       
   938 
       
   939     CntServicesContactList list;
       
   940     list.append(cnt1);
       
   941     list.append(cnt2);
       
   942     
       
   943     args.clear();
       
   944     args << qVariantFromValue(list);
       
   945     req->setArguments(args);
       
   946 
       
   947     req->send();
       
   948     
       
   949     bool deleteRequest = (mCheckDeleteRequest->checkState() == Qt::Checked);
       
   950     if (deleteRequest)
       
   951     {
       
   952         delete req;
       
   953         req = 0;
       
   954     }
       
   955 
       
   956     qDebug() << mAppName << " test END";
       
   957 
       
   958     //  ---- OLD TESTS ------
       
   959     
       
   960     /*
       
   961     qDebug() << mAppName << "  name" << qApp->applicationName();
       
   962     qDebug() << mAppName << " dirpath" << qApp->applicationDirPath();
       
   963     qDebug() << mAppName << " filename" << qApp->applicationFilePath();
       
   964     qDebug() << mAppName << " pid" << qApp->applicationPid();
       
   965 
   666     QFileInfo appinfo (qApp->applicationFilePath());
   966     QFileInfo appinfo (qApp->applicationFilePath());
   667     qDebug() << "AppMgrClient:appinfo.applicationFilePath" << qApp->applicationFilePath();
   967     qDebug() << mAppName << " appinfo.applicationFilePath" << qApp->applicationFilePath();
   668     qDebug() << "AppMgrClient:appinfo.absolutePath" << appinfo.absolutePath();
   968     qDebug() << mAppName << " appinfo.absolutePath" << appinfo.absolutePath();
   669     qDebug() << "AppMgrClient:appinfo.baseName" << appinfo.baseName();
   969     qDebug() << mAppName << " appinfo.baseName" << appinfo.baseName();
   670     
   970 
   671     QString lang = QLocale::system().name();
   971     QString lang = QLocale::system().name();
   672     qDebug() << "AppMgrClient::anyTest:" << lang;
   972     qDebug() << mAppName << " anyTest:" << lang;
   673 
   973 
   674     // QString textFile = "z:/resource/qt/translations/hbserviceprovider";
   974     // QString textFile = "z:/resource/qt/translations/hbserviceprovider";
   675     QString textFile = "hbserviceprovider";
   975     QString textFile = "hbserviceprovider";
   676     QFileInfo info(textFile);
   976     QFileInfo info(textFile);
   677     qDebug() << "AppMgrClient::base" << info.baseName();
   977     qDebug() << mAppName << " base" << info.baseName();
   678     qDebug() << "AppMgrClient::path" << info.filePath();
   978     qDebug() << mAppName << " path" << info.filePath();
   679     if (info.baseName() == info.filePath())
   979     if (info.baseName() == info.filePath())
   680     {
   980     {
   681         textFile = qApp->applicationFilePath().left(2) + "/resource/qt/translations/" + textFile;
   981         textFile = qApp->applicationFilePath().left(2) + "/resource/qt/translations/" + textFile;
   682         qDebug() << "AppMgrClient::path added" << textFile;
   982         qDebug() << mAppName << " path added" << textFile;
   683     }
   983     }
   684     
   984 
   685     textFile += "_"; 
   985     textFile += "_"; 
   686     textFile += lang;
   986     textFile += lang;
   687     qDebug() << "AppMgrClient::anyTest:" << textFile;
   987     qDebug() << mAppName << " anyTest:" << textFile;
   688 
   988 
   689     QTranslator translator;
   989     QTranslator translator;
   690     bool res = translator.load(textFile);
   990     bool res = translator.load(textFile);
   691     qDebug() << "AppMgrClient::anyTest:" << res;
   991     qDebug() << mAppName << " anyTest:" << res;
   692     if (res)
   992     if (res)
   693     {
   993     {
   694         qApp->installTranslator(&translator);
   994         qApp->installTranslator(&translator);
   695     }
   995     }
   696     
   996 
   697     QString textId = TXT_ID;
   997     QString textId = TXT_ID;
   698     QByteArray ba = textId.toLatin1();
   998     QByteArray ba = textId.toLatin1();
   699     const char *textPtr = ba.data();
   999     const char *textPtr = ba.data();
   700     
  1000 
   701     QString text = qtTrId(textPtr);  // translate
  1001     QString text = qtTrId(textPtr);  // translate
   702     qDebug() << "Translated text:" << text;
  1002     qDebug() << mAppName << " translated text:" << text;
   703 
  1003 
   704     qApp->removeTranslator(&translator);
  1004     qApp->removeTranslator(&translator);
       
  1005 
       
  1006     Q_ASSERT(0==1);
       
  1007     */
   705 
  1008 
   706 }
  1009 }
   707 
  1010 
   708 
  1011 
   709 
  1012 
   710 
  1013 
   711 // Aiw request responses
  1014 // Aiw request responses
   712 void AppMgrClient::handleOk(const QVariant& result)
  1015 void AppMgrClient::handleOk(const QVariant& result)
   713 {
  1016 {
   714     XQAiwRequest *r = (XQAiwRequest *)sender();
  1017     XQAiwRequest *r = static_cast<XQAiwRequest *>(sender());
       
  1018     
   715     int impl=-1;
  1019     int impl=-1;
   716     impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt();
  1020     impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt();
   717     
  1021     QString interface = r->descriptor().interfaceName();
   718     if (result.canConvert<QString>())
  1022     QString service = r->descriptor().serviceName();
   719     {
  1023     
   720         qDebug("AppMgrClient::%x:handleOk result=%s,%s",
  1024     if (result.canConvert<CntServicesContactList>())
       
  1025     {
       
  1026         showRecipients(result);
       
  1027     }
       
  1028     else if (result.canConvert<QString>())
       
  1029     {
       
  1030         qDebug("%s::handleOk from [%s.%s,%x]=(%s,%s)",
       
  1031                qPrintable(mAppName),
       
  1032                qPrintable(service),
       
  1033                qPrintable(interface),
   721                impl,
  1034                impl,
   722                result.typeName(),
  1035                result.typeName(),
   723                qPrintable(result.value<QString>()));
  1036                qPrintable(result.value<QString>()));
   724         mTextRetValue->setText(result.value<QString>());
  1037         mTextRetValue->setText(result.value<QString>());
   725     }
  1038     }
       
  1039 
   726     else
  1040     else
   727     {
  1041     {
   728         qDebug("AppMgrClient::%x:handleOk result=%s",
  1042         qDebug("%s::handleOk from [%s.%s,%x]=(%s)",
       
  1043                qPrintable(mAppName),
       
  1044                qPrintable(service),
       
  1045                qPrintable(interface),
   729                impl,
  1046                impl,
   730                result.typeName());
  1047                result.typeName());
   731         mTextRetValue->setText("Not displayable");
  1048         mTextRetValue->setText("Not displayable");
   732     }
  1049     }
   733 }
  1050 }
   734   
  1051   
   735 void AppMgrClient::handleError(int errorCode, const QString& errorMessage)
  1052 void AppMgrClient::handleError(int errorCode, const QString& errorMessage)
   736 {
  1053 {
   737     XQAiwRequest *r = (XQAiwRequest *)sender();
  1054     XQAiwRequest *r = static_cast<XQAiwRequest *>(sender());
       
  1055     QString interface = r->descriptor().interfaceName();
       
  1056     QString service = r->descriptor().serviceName();
       
  1057     
   738     int impl=-1;
  1058     int impl=-1;
   739     impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt();
  1059     impl = (r->descriptor().property(XQAiwInterfaceDescriptor::ImplementationId)).toInt();
   740 
  1060 
   741     qDebug("AppMgrClient::%x:handleError code=%d, errorMessage:%s",
  1061     qDebug("%s::handleError from [%s.%s,%d]=(%d,%s)",
       
  1062            qPrintable(mAppName),
       
  1063            qPrintable(service),
       
  1064            qPrintable(interface),
   742            impl, errorCode, qPrintable(errorMessage));
  1065            impl, errorCode, qPrintable(errorMessage));
   743     
  1066     
   744     mTextRetValue->setText(errorMessage);
  1067     mTextRetValue->setText(errorMessage);
   745 }
  1068 }
   746 
  1069 
   747 
  1070 
       
  1071 
       
  1072 Q_IMPLEMENT_USER_METATYPE(MetaDummy1)
       
  1073 Q_IMPLEMENT_USER_METATYPE(MetaDummy2)
       
  1074 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
       
  1075 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)