qthighway/xqservice/src/xqappmgr_p.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 8 71781823f776
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    20 */
    20 */
    21 
    21 
    22 #include <xqservicerequest.h>
    22 #include <xqservicerequest.h>
    23 #include <xqservicemanager.h>
    23 #include <xqservicemanager.h>
    24 #include <QList>
    24 #include <QList>
       
    25 #include <xqsettingsmanager.h>
       
    26 #include <xqsettingskey.h>
       
    27 #include <e32std.h>
       
    28 
    25 #include "xqservicelog.h"
    29 #include "xqservicelog.h"
    26 #include "xqaiwutils.h"
    30 #include "xqaiwutils.h"
    27 #include "xqaiwuridriver.h"
    31 #include "xqaiwuridriver.h"
    28 #include "xqaiwdecl.h"
    32 #include "xqaiwdecl.h"
    29 #include "xqappmgr_p.h"
    33 #include "xqappmgr_p.h"
    32    serviceMgr(0),
    36    serviceMgr(0),
    33    aiwUtilities(0)
    37    aiwUtilities(0)
    34    
    38    
    35 {
    39 {
    36     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate");
    40     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate");
       
    41     serviceMgr = new XQServiceManager();
    37 }
    42 }
    38 
    43 
    39 XQApplicationManagerPrivate::~XQApplicationManagerPrivate()
    44 XQApplicationManagerPrivate::~XQApplicationManagerPrivate()
    40 {
    45 {
    41     XQSERVICE_DEBUG_PRINT("~XQApplicationManagerPrivate");
    46     XQSERVICE_DEBUG_PRINT("~XQApplicationManagerPrivate");
    51 
    56 
    52 XQAiwRequest* XQApplicationManagerPrivate::create(
    57 XQAiwRequest* XQApplicationManagerPrivate::create(
    53     const QString &service, const QString &interface, const QString &operation, bool embedded)
    58     const QString &service, const QString &interface, const QString &operation, bool embedded)
    54 {
    59 {
    55     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(service+interface)");
    60     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(service+interface)");
    56 
       
    57     if (!serviceMgr)
       
    58         serviceMgr = new XQServiceManager();
       
    59     if (!serviceMgr)
       
    60     {
       
    61         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create service manager");
       
    62         return 0;
       
    63     }
       
    64 
    61 
    65     QList<XQAiwInterfaceDescriptor> impls;
    62     QList<XQAiwInterfaceDescriptor> impls;
    66     if (service.isEmpty())
    63     if (service.isEmpty())
    67         impls = serviceMgr->findInterfaces(interface);
    64         impls = serviceMgr->findInterfaces(interface);
    68     else
    65     else
   210 {
   207 {
   211 
   208 
   212     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list(interface)");
   209     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list(interface)");
   213     Q_UNUSED(operation);
   210     Q_UNUSED(operation);
   214 
   211 
   215     if (!serviceMgr)
       
   216         serviceMgr = new XQServiceManager();
       
   217     
       
   218     QList<XQAiwInterfaceDescriptor> result;    
       
   219     if (!serviceMgr)
       
   220     {
       
   221         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create service manager");
       
   222         return result;
       
   223     }
       
   224     
       
   225     return serviceMgr->findInterfaces(interface);
   212     return serviceMgr->findInterfaces(interface);
   226 }
   213 }
   227 
   214 
   228 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
   215 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
   229     const QString &service, const QString& interface, const QString& operation)
   216     const QString &service, const QString& interface, const QString& operation)
   230 {
   217 {
   231     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (service+interface)");
   218     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (service+interface)");
   232     Q_UNUSED(operation);
   219     Q_UNUSED(operation);
   233 
   220 
   234     if (!serviceMgr)
       
   235         serviceMgr = new XQServiceManager();
       
   236     
       
   237     QList<XQAiwInterfaceDescriptor> result;    
       
   238     if (!serviceMgr)
       
   239     {
       
   240         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create service manager");
       
   241         return result;
       
   242     }
       
   243 
       
   244     
       
   245     return serviceMgr->findInterfaces(service, interface);
   221     return serviceMgr->findInterfaces(service, interface);
   246 }
   222 }
   247 
   223 
   248 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
   224 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
   249     const QUrl &uri)
   225     const QUrl &uri)
   322 
   298 
   323 
   299 
   324 int XQApplicationManagerPrivate::lastError() const
   300 int XQApplicationManagerPrivate::lastError() const
   325 {
   301 {
   326     int err=0;
   302     int err=0;
   327     if (serviceMgr)
   303     err = serviceMgr->latestError();
   328         err = serviceMgr->latestError();
       
   329     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: lastError=%d", err);
   304     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: lastError=%d", err);
   330     return err;
   305     return err;
   331 }
   306 }
   332 
   307 
       
   308 bool XQApplicationManagerPrivate::isRunning(const XQAiwInterfaceDescriptor& implementation) const
       
   309 {
       
   310     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate isRunning");
       
   311     return serviceMgr->isRunning(implementation);
       
   312 }
       
   313 
       
   314 bool XQApplicationManagerPrivate::getDrmAttributes(const QFile &file, const QList<int> &attributeNames, QVariantList &attributeValues)
       
   315 {
       
   316     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate drmAttributes");
       
   317     if (aiwUtilities == 0)
       
   318         aiwUtilities = new XQAiwUtils();
       
   319     return aiwUtilities->getDrmAttributes(file.fileName(), attributeNames, attributeValues);
       
   320 }
       
   321 
       
   322 bool XQApplicationManagerPrivate::getDrmAttributes(const XQSharableFile &file, const QList<int> &attributeNames, QVariantList &attributeValues)
       
   323 {
       
   324     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate drmAttributes");
       
   325     if (aiwUtilities == 0)
       
   326         aiwUtilities = new XQAiwUtils();
       
   327     return aiwUtilities->getDrmAttributes(file,attributeNames, attributeValues);
       
   328 }
       
   329 
       
   330 int XQApplicationManagerPrivate::status(const XQAiwInterfaceDescriptor& implementation)
       
   331 {
       
   332     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate status");
       
   333     QString statusKeyValue = implementation.customProperty(XQCUSTOM_PROP_AIW_SERVICE_STATUS);
       
   334     if (statusKeyValue.isEmpty())
       
   335     {
       
   336         // No custom property,  have to assume service is enabled
       
   337         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate no custom property %s",
       
   338                               XQCUSTOM_PROP_AIW_SERVICE_STATUS);
       
   339         return XQApplicationManager::Unknown;
       
   340     }
       
   341 
       
   342     if (aiwUtilities == 0)
       
   343         aiwUtilities = new XQAiwUtils();
       
   344     
       
   345     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate custom property value=%s",
       
   346                           qPrintable(statusKeyValue));
       
   347     
       
   348     bool b=false;
       
   349     int keyId = aiwUtilities->toIntFromHex(statusKeyValue, &b);
       
   350     if (!b)
       
   351     {
       
   352         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate bad custom property value");
       
   353         return XQApplicationManager::Unknown;
       
   354     }
       
   355     
       
   356     XQSettingsManager settingsManager;
       
   357     int implId = implementation.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
       
   358     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate %x,%x", keyId, implId);
       
   359     
       
   360     XQSettingsKey statusKey (XQSettingsKey::TargetCentralRepository, implId, keyId);
       
   361     QVariant value = settingsManager.readItemValue(statusKey);
       
   362     if (value.isNull())
       
   363     {
       
   364         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate Cenrep %x does not contain key %x",
       
   365                               implId, keyId);
       
   366         return XQApplicationManager::Unknown;
       
   367     }
       
   368 
       
   369     
       
   370     int status = value.toInt(&b);
       
   371     if (!b)
       
   372     {
       
   373         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate invalid status value %s",
       
   374                               qPrintable(value.toString()));
       
   375         return XQApplicationManager::Unknown;
       
   376     }
       
   377         
       
   378     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate status=%d", status);
       
   379     
       
   380     return status;
       
   381    
       
   382 }
   333 
   383 
   334 // ---- PRIVATE FUNCTIONS ----
   384 // ---- PRIVATE FUNCTIONS ----
   335 
   385 
   336 bool XQApplicationManagerPrivate::hasCustomHandler(const QUrl &uri) const
   386 bool XQApplicationManagerPrivate::hasCustomHandler(const QUrl &uri) const
   337 {
   387 {