qthighway/xqservice/src/xqappmgr_p.cpp
branchRCL_3
changeset 23 cd2778e5acfe
parent 22 5d007b20cfd0
child 25 19a54be74e5e
equal deleted inserted replaced
22:5d007b20cfd0 23:cd2778e5acfe
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #include <xqservicerequest.h>
       
    23 #include <xqservicemanager.h>
       
    24 #include <QList>
       
    25 #include <xqsettingsmanager.h>
       
    26 #include <xqsettingskey.h>
       
    27 #include <e32std.h>
       
    28 
       
    29 #include "xqservicelog.h"
       
    30 #include "xqaiwutils.h"
       
    31 #include "xqaiwuridriver.h"
       
    32 #include "xqaiwdecl.h"
       
    33 #include "xqappmgr_p.h"
       
    34 
       
    35 /*!
       
    36     \class XQApplicationManagerPrivate
       
    37     \brief Private implementation of the XQApplicationManager
       
    38 */
       
    39 
       
    40 XQApplicationManagerPrivate::XQApplicationManagerPrivate():
       
    41    serviceMgr(0),
       
    42    aiwUtilities(0)
       
    43    
       
    44 {
       
    45     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate");
       
    46     serviceMgr = new XQServiceManager();
       
    47 }
       
    48 
       
    49 XQApplicationManagerPrivate::~XQApplicationManagerPrivate()
       
    50 {
       
    51     XQSERVICE_DEBUG_PRINT("~XQApplicationManagerPrivate");
       
    52     delete serviceMgr;
       
    53     delete aiwUtilities;
       
    54 }
       
    55 
       
    56 XQAiwRequest* XQApplicationManagerPrivate::create( const QString &interface, const QString &operation, bool embedded)
       
    57 {
       
    58     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(interface)");
       
    59     return create("", interface, operation, embedded);
       
    60 }
       
    61 
       
    62 XQAiwRequest* XQApplicationManagerPrivate::create(
       
    63     const QString &service, const QString &interface, const QString &operation, bool embedded)
       
    64 {
       
    65     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(service+interface)");
       
    66 
       
    67     QList<XQAiwInterfaceDescriptor> impls;
       
    68     if (service.isEmpty())
       
    69         impls = serviceMgr->findFirstInterface(interface);
       
    70     else
       
    71         impls = serviceMgr->findFirstInterface(service, interface);
       
    72 
       
    73     // Pick up the first implementation
       
    74     if (impls.count())
       
    75     {
       
    76         return new XQAiwRequest(impls[0], operation, embedded);
       
    77     }
       
    78     return 0;
       
    79 }
       
    80 
       
    81 
       
    82 XQAiwRequest* XQApplicationManagerPrivate::create(
       
    83     const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded)
       
    84 {
       
    85     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create (impl)");
       
    86     return new XQAiwRequest(implementation, operation, embedded);
       
    87 }
       
    88 
       
    89 XQAiwRequest* XQApplicationManagerPrivate::create(
       
    90     const QUrl &uri, const XQAiwInterfaceDescriptor *implementation, bool embedded)
       
    91 {
       
    92     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create (uri)");
       
    93     XQSERVICE_DEBUG_PRINT("uri=%s", qPrintable(uri.toString()));
       
    94     
       
    95     if (!uri.isValid())
       
    96     {
       
    97         XQSERVICE_CRITICAL_PRINT("Invalid URI %s", qPrintable(uri.toString()));
       
    98         return 0;
       
    99     }
       
   100 
       
   101     if (hasCustomHandler(uri))
       
   102     {
       
   103         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::custom handler applied");
       
   104         XQAiwInterfaceDescriptor nullDescr;
       
   105         return new XQAiwRequest(uri, nullDescr, XQOP_URI_VIEW);
       
   106     }
       
   107     
       
   108     const XQAiwInterfaceDescriptor *impl = implementation;
       
   109     QList<XQAiwInterfaceDescriptor> impls;
       
   110     if (impl == 0) 
       
   111     {
       
   112         // Implementation not given, find first one        
       
   113         impls = list(uri);
       
   114         if (impls.count())
       
   115         {
       
   116             impl = &impls[0];
       
   117             XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create (impl) use first)");
       
   118         }
       
   119     }
       
   120 
       
   121     XQAiwRequest *req = 0;
       
   122     if (impl != 0)
       
   123     {
       
   124         // Create service request for viewing the URI
       
   125         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create (impl) creating request)");
       
   126         req = new XQAiwRequest(uri, *impl, XQOP_URI_VIEW);
       
   127         if (req)
       
   128         {
       
   129             req->setEmbedded(embedded);
       
   130         }
       
   131     }
       
   132 
       
   133     return req;
       
   134 
       
   135     
       
   136 }
       
   137 
       
   138 XQAiwRequest* XQApplicationManagerPrivate::create(
       
   139      const QFile &file, const XQAiwInterfaceDescriptor *implementation, bool embedded)
       
   140 {
       
   141     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(file)");
       
   142     XQSERVICE_DEBUG_PRINT("file=%s", qPrintable(file.fileName()));
       
   143 
       
   144     const XQAiwInterfaceDescriptor *impl = implementation;
       
   145     QList<XQAiwInterfaceDescriptor> impls;
       
   146     if (impl == 0) 
       
   147     {
       
   148         // Implementation not given, find services capable of handling the "file"
       
   149         impls = list(file);
       
   150         if (impls.count())
       
   151         {
       
   152             impl = &impls[0];
       
   153         }
       
   154     }
       
   155 
       
   156     XQAiwRequest * req = 0;
       
   157     if (impl != 0)
       
   158     {
       
   159         QVariant v = impl->property(XQAiwInterfaceDescriptor::ImplementationId);
       
   160         req = new XQAiwRequest(file, *impl, XQOP_FILE_VIEW);
       
   161         if (req)
       
   162         {
       
   163             req->setEmbedded(embedded);
       
   164             XQSERVICE_DEBUG_PRINT("File handled by %x", v.toInt());
       
   165         }
       
   166     }
       
   167     
       
   168     return req;
       
   169 }
       
   170 
       
   171 XQAiwRequest* XQApplicationManagerPrivate::create(
       
   172     const XQSharableFile &file, const XQAiwInterfaceDescriptor *implementation, bool embedded)
       
   173 {
       
   174     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::create(XQSharableFile)");
       
   175     if (!file.isValid())
       
   176     {
       
   177         XQSERVICE_DEBUG_PRINT("\tInvalid XQSharableFile)");
       
   178         return 0;
       
   179     }
       
   180     
       
   181     const XQAiwInterfaceDescriptor *impl = implementation;
       
   182     QList<XQAiwInterfaceDescriptor> impls;
       
   183     if (impl == 0) 
       
   184     {
       
   185         // Implementation not given, find services capable of handling the "file"
       
   186         impls = list(file);
       
   187         if (impls.count())
       
   188         {
       
   189             impl = &impls[0];
       
   190         }
       
   191     }
       
   192 
       
   193     XQAiwRequest * req = 0;
       
   194     if (impl != 0)
       
   195     {
       
   196         QVariant v = impl->property(XQAiwInterfaceDescriptor::ImplementationId);
       
   197         req = new XQAiwRequest(file, *impl, XQOP_FILE_VIEW_SHARABLE);
       
   198         if (req)
       
   199         {
       
   200             req->setEmbedded(embedded);
       
   201             XQSERVICE_DEBUG_PRINT("File handled by %x", v.toInt());
       
   202         }
       
   203     }
       
   204 
       
   205     return req;
       
   206 }
       
   207 
       
   208 
       
   209 
       
   210 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
       
   211     const QString &interface, const QString& operation)
       
   212 {
       
   213 
       
   214     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list(interface)");
       
   215     Q_UNUSED(operation);
       
   216 
       
   217     return serviceMgr->findInterfaces(interface);
       
   218 }
       
   219 
       
   220 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
       
   221     const QString &service, const QString& interface, const QString& operation)
       
   222 {
       
   223     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (service+interface)");
       
   224     Q_UNUSED(operation);
       
   225 
       
   226     return serviceMgr->findInterfaces(service, interface);
       
   227 }
       
   228 
       
   229 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(
       
   230     const QUrl &uri)
       
   231 {
       
   232     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (uri) %s", qPrintable(uri.toString()));
       
   233 
       
   234     QList<XQAiwInterfaceDescriptor> result;
       
   235     if (!uri.isValid())
       
   236     {
       
   237         XQSERVICE_CRITICAL_PRINT("Invalid URI %s", qPrintable(uri.toString()));
       
   238         return result; // Empty
       
   239     }
       
   240 
       
   241     QString scheme = uri.scheme();
       
   242     
       
   243     if (scheme.compare(XQURI_SCHEME_FILE,Qt::CaseInsensitive) == 0)
       
   244     {
       
   245         QFile file (uri.toLocalFile());
       
   246         return list(file);  // Apply file based listing
       
   247     }
       
   248     
       
   249     //  Find all services implementing URI interface and support URI scheme
       
   250     QList<XQAiwInterfaceDescriptor> uriHandlers;
       
   251     uriHandlers = list(XQI_URI_VIEW, "");
       
   252 
       
   253     // Pick up services supporting the required scheme
       
   254     foreach (XQAiwInterfaceDescriptor uh, uriHandlers)
       
   255     {
       
   256         //  Find services that support the scheme
       
   257         if (uh.customProperty(XQCUSTOM_PROP_SCHEMES).contains(scheme,Qt::CaseInsensitive))  // Allow multiple schemes in same string
       
   258         {
       
   259             XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Service %s can handle scheme %s",
       
   260                                   qPrintable(uh.serviceName()), qPrintable(scheme))
       
   261             result.append(uh);
       
   262         }
       
   263     }
       
   264 
       
   265     return result;
       
   266 }
       
   267 
       
   268 //
       
   269 // List services capable of handling the file by MIME type
       
   270 //
       
   271 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(const QFile &file)
       
   272 {
       
   273 
       
   274     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (file) %s", qPrintable(file.fileName()));
       
   275 
       
   276     // List first MIME handlers for file
       
   277     QList<XQAiwInterfaceDescriptor> mimeHandlers;
       
   278     mimeHandlers = listMimeHandlers(file);
       
   279 
       
   280     // Then list those file services that can support the MIME type
       
   281     return listFileHandlers(mimeHandlers);
       
   282 }
       
   283 
       
   284 //
       
   285 // List services capable of handling the sharable file by MIME type
       
   286 //
       
   287 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::list(const XQSharableFile &file)
       
   288 {
       
   289 
       
   290     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::list (handle)");
       
   291 
       
   292     // List first MIME handlers for the sharable file
       
   293     QList<XQAiwInterfaceDescriptor> mimeHandlers;
       
   294     if (!file.isValid())
       
   295     {
       
   296         return mimeHandlers; // Empty set
       
   297     }
       
   298     mimeHandlers = listMimeHandlers(file);
       
   299 
       
   300     // Then list those file services that can support the MIME type
       
   301     return listFileHandlers(mimeHandlers);
       
   302 }
       
   303 
       
   304 
       
   305 int XQApplicationManagerPrivate::lastError() const
       
   306 {
       
   307     int err=0;
       
   308     err = serviceMgr->latestError();
       
   309     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: lastError=%d", err);
       
   310     return err;
       
   311 }
       
   312 
       
   313 bool XQApplicationManagerPrivate::isRunning(const XQAiwInterfaceDescriptor& implementation) const
       
   314 {
       
   315     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate isRunning");
       
   316     return serviceMgr->isRunning(implementation);
       
   317 }
       
   318 
       
   319 bool XQApplicationManagerPrivate::getDrmAttributes(const QFile &file, const QList<int> &attributeNames, QVariantList &attributeValues)
       
   320 {
       
   321     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate drmAttributes");
       
   322     if (aiwUtilities == 0)
       
   323         aiwUtilities = new XQAiwUtils();
       
   324     return aiwUtilities->getDrmAttributes(file.fileName(), attributeNames, attributeValues);
       
   325 }
       
   326 
       
   327 bool XQApplicationManagerPrivate::getDrmAttributes(const XQSharableFile &file, const QList<int> &attributeNames, QVariantList &attributeValues)
       
   328 {
       
   329     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate drmAttributes");
       
   330     if (aiwUtilities == 0)
       
   331         aiwUtilities = new XQAiwUtils();
       
   332     return aiwUtilities->getDrmAttributes(file,attributeNames, attributeValues);
       
   333 }
       
   334 
       
   335 int XQApplicationManagerPrivate::status(const XQAiwInterfaceDescriptor& implementation)
       
   336 {
       
   337     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate status");
       
   338     QString statusKeyValue = implementation.customProperty(XQCUSTOM_PROP_AIW_SERVICE_STATUS);
       
   339     if (statusKeyValue.isEmpty())
       
   340     {
       
   341         // No custom property,  have to assume service is enabled
       
   342         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate no custom property %s",
       
   343                               XQCUSTOM_PROP_AIW_SERVICE_STATUS);
       
   344         return XQApplicationManager::Unknown;
       
   345     }
       
   346 
       
   347     if (aiwUtilities == 0)
       
   348         aiwUtilities = new XQAiwUtils();
       
   349     
       
   350     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate custom property value=%s",
       
   351                           qPrintable(statusKeyValue));
       
   352     
       
   353     bool b=false;
       
   354     int keyId = aiwUtilities->toIntFromHex(statusKeyValue, &b);
       
   355     if (!b)
       
   356     {
       
   357         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate bad custom property value");
       
   358         return XQApplicationManager::Unknown;
       
   359     }
       
   360     
       
   361     XQSettingsManager settingsManager;
       
   362     int implId = implementation.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
       
   363     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate %x,%x", keyId, implId);
       
   364     
       
   365     XQSettingsKey statusKey (XQSettingsKey::TargetCentralRepository, implId, keyId);
       
   366     QVariant value = settingsManager.readItemValue(statusKey);
       
   367     if (value.isNull())
       
   368     {
       
   369         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate Cenrep %x does not contain key %x",
       
   370                               implId, keyId);
       
   371         return XQApplicationManager::Unknown;
       
   372     }
       
   373 
       
   374     
       
   375     int status = value.toInt(&b);
       
   376     if (!b)
       
   377     {
       
   378         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate invalid status value %s",
       
   379                               qPrintable(value.toString()));
       
   380         return XQApplicationManager::Unknown;
       
   381     }
       
   382         
       
   383     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate status=%d", status);
       
   384     
       
   385     return status;
       
   386    
       
   387 }
       
   388 
       
   389 // ---- PRIVATE FUNCTIONS ----
       
   390 
       
   391 bool XQApplicationManagerPrivate::hasCustomHandler(const QUrl &uri) const
       
   392 {
       
   393     return XQAiwUriDriver::hasCustomHandler(uri);
       
   394 }
       
   395 
       
   396 //
       
   397 // Get file handlers
       
   398 // TODO: Currently only one, default handler is returned !!!
       
   399 //       Possibly later all handlers need to be returned.
       
   400 //
       
   401 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::listMimeHandlers(const QFile &file)
       
   402 {
       
   403 
       
   404     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::listMimeHandlers %s", qPrintable(file.fileName()));
       
   405     QList<XQAiwInterfaceDescriptor> mimeHandlers;
       
   406 
       
   407     if (aiwUtilities == 0)
       
   408         aiwUtilities = new XQAiwUtils();
       
   409     if (aiwUtilities == 0)
       
   410     {
       
   411         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create aiw utils");
       
   412         return mimeHandlers;
       
   413     }
       
   414 
       
   415     XQAiwInterfaceDescriptor descriptor;
       
   416 
       
   417     // Find default application that can handle MIME type (only one at the moment)
       
   418     int applicationId = 0;
       
   419     if (aiwUtilities->findApplication(file, applicationId) != XQService::ENoError)
       
   420     {
       
   421         return mimeHandlers;  // Empty set
       
   422     }
       
   423 
       
   424     // Set incomplete descriptor
       
   425     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Found file handler %x", applicationId);
       
   426     descriptor.setProperty(XQAiwInterfaceDescriptor::ImplementationId, QVariant(applicationId));
       
   427     
       
   428     mimeHandlers.append(descriptor);
       
   429 
       
   430     return mimeHandlers;
       
   431 }
       
   432 
       
   433 //
       
   434 // Get handlers for sharable file
       
   435 // TODO: Currently only one, default handler is returned !!!
       
   436 //       Possibly later all handlers need to be returned.
       
   437 //
       
   438 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::listMimeHandlers(const XQSharableFile &file)
       
   439 {
       
   440 
       
   441     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::listMimeHandlers (handle)");
       
   442     QList<XQAiwInterfaceDescriptor> mimeHandlers;
       
   443 
       
   444     if (aiwUtilities == 0)
       
   445         aiwUtilities = new XQAiwUtils();
       
   446     if (aiwUtilities == 0)
       
   447     {
       
   448         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create aiw utils");
       
   449         return mimeHandlers;
       
   450     }
       
   451 
       
   452     XQAiwInterfaceDescriptor descriptor;
       
   453 
       
   454     // Find default application that can handle MIME type (only one at the moment)
       
   455     int applicationId = 0;
       
   456     if (aiwUtilities->findApplication(file, applicationId) != XQService::ENoError)
       
   457     {
       
   458         return mimeHandlers;  // Empty set
       
   459     }
       
   460 
       
   461     // Set incomplete descriptor
       
   462     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Found file handler %x", applicationId);
       
   463     descriptor.setProperty(XQAiwInterfaceDescriptor::ImplementationId, QVariant(applicationId));
       
   464 
       
   465     mimeHandlers.append(descriptor);
       
   466 
       
   467     return mimeHandlers;
       
   468 }
       
   469 
       
   470 
       
   471 // To be called only for URI having scheme XQURI_SCHEME_ACTIVITY
       
   472 // Check that application exists and fill in only the implementationId
       
   473 bool XQApplicationManagerPrivate::getAppDescriptor(const QUrl &uri,  XQAiwInterfaceDescriptor *descriptor)
       
   474 {
       
   475 
       
   476     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::getAppDescriptor %s)", qPrintable(uri.toString()));
       
   477 
       
   478     if (aiwUtilities == 0)
       
   479         aiwUtilities = new XQAiwUtils();
       
   480     if (aiwUtilities == 0)
       
   481     {
       
   482         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Can not create aiw utils");
       
   483         return false;
       
   484     }
       
   485 
       
   486     int applicationId = 0;
       
   487     if (aiwUtilities->findApplication(uri, applicationId) != XQService::ENoError)
       
   488     {
       
   489         return false;  // No application registered for file
       
   490     }
       
   491 
       
   492     // Create incomplete descriptor
       
   493     descriptor->setProperty(XQAiwInterfaceDescriptor::ImplementationId, QVariant(applicationId));
       
   494     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Found uri handler %x", applicationId);
       
   495 
       
   496     return  true; 
       
   497 }
       
   498 
       
   499 
       
   500 //
       
   501 // Get file handlers that can support the give MIME type
       
   502 //
       
   503 QList<XQAiwInterfaceDescriptor> XQApplicationManagerPrivate::listFileHandlers(
       
   504     const QList<XQAiwInterfaceDescriptor> &mimeHandlers)
       
   505 {
       
   506     XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate::listFileHandlers");
       
   507 
       
   508     //  Find all services implementing URI interface, support "file" scheme and can handle the file
       
   509     //  by MIME type
       
   510     QList<XQAiwInterfaceDescriptor> fileServices;
       
   511     fileServices = list(XQI_FILE_VIEW, "");
       
   512     if (fileServices.count() == 0)
       
   513     {
       
   514         return fileServices; // Empty set
       
   515     }
       
   516 
       
   517     QList<XQAiwInterfaceDescriptor> result;
       
   518     foreach (XQAiwInterfaceDescriptor fs, fileServices)
       
   519     {
       
   520         //  Find services that support the file scheme
       
   521         XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Service %s can handle file", qPrintable(fs.serviceName()));
       
   522         int serviceAppId = fs.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
       
   523         foreach (XQAiwInterfaceDescriptor mh, mimeHandlers)
       
   524         {
       
   525             int mimeAppId = mh.property(XQAiwInterfaceDescriptor::ImplementationId).toInt();
       
   526             if (mimeAppId == serviceAppId)
       
   527             {
       
   528                 // Return only those services that support file scheme and claim to support also MIME type
       
   529                 XQSERVICE_DEBUG_PRINT("XQApplicationManagerPrivate:: Service %s (UID=%x) can handle file and MIME type",
       
   530                                       qPrintable(fs.serviceName()), serviceAppId);
       
   531                 result.append(fs);
       
   532             }
       
   533         }
       
   534     }
       
   535 
       
   536     if (result.isEmpty())
       
   537     {
       
   538         // No service support present, try using the MIME handlers via old way
       
   539         return mimeHandlers;
       
   540     }
       
   541     return result;
       
   542 }