qthighway/xqservice/src/xqappmgr.cpp
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     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 "xqservicelog.h"
       
    23 #include "xqappmgr.h"
       
    24 #include <xqaiwrequest.h>
       
    25 #include <xqaiwinterfacedescriptor.h>
       
    26 #include <QList>
       
    27 #include "xqappmgr_p.h"
       
    28 
       
    29 XQApplicationManager::XQApplicationManager()
       
    30 {
       
    31     XQSERVICE_DEBUG_PRINT("XQApplicationManager::XQApplicationManager");
       
    32     d = new XQApplicationManagerPrivate();
       
    33     
       
    34 }
       
    35 XQApplicationManager::~XQApplicationManager()
       
    36 {
       
    37     XQSERVICE_DEBUG_PRINT("XQApplicationManager::~XQApplicationManager");
       
    38     delete d;
       
    39 };
       
    40 
       
    41 /*!
       
    42     Create AIW request for interface and operation name.
       
    43     The first found implementation is applied. If you need to activate specific implementation
       
    44     you shall first list() implementations and use the overloaded create() with XQAiwInterfaceDescriptor
       
    45     to select the correct implementation.
       
    46     
       
    47     \param interface Interface name as mentioned in the service registry file
       
    48     \param operation The function signature to be called via the interface.
       
    49                      Can be set later via XQAiwRequest::setOperation.
       
    50     \param embedded True if embedded call, false otherwise
       
    51                      Can be set later via XQAiwRequest::setEmbedded.
       
    52     \return The application interworking request instance, NULL if no service is available
       
    53     \see list()
       
    54     \see create( const QString &service, const QString &interface, const QString &operation, bool embedded)
       
    55     \see create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
       
    56     
       
    57     Example usage:
       
    58     \code
       
    59     // componentglobal.h
       
    60     const QString photosApplication = "Photos";
       
    61     const QString imageInterface = "com.nokia.symbian.IImageFetch";
       
    62     const QString selectOperation = "select(QString&,bool)";
       
    63 
       
    64     #include <xqappmgr.h>;
       
    65     #include "componentglobal.h";
       
    66     
       
    67     // XQApplicationManager mAppMgr;  // manager as class member
       
    68     
       
    69     XQAiwRequest * req = this->mAppMgr.create(imageInterface, selectOperation);
       
    70     if (req)
       
    71     {
       
    72         // There was service available
       
    73         QList<QVariant> args;
       
    74         args << folder;
       
    75         args << previewOn;
       
    76         req->setArguments(args);
       
    77         
       
    78         connect(req, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
       
    79         connect(req, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&)));
       
    80 
       
    81         req->send();
       
    82     }
       
    83     \endcode
       
    84 */
       
    85 XQAiwRequest* XQApplicationManager::create(
       
    86     const QString &interface, const QString &operation, bool embedded)
       
    87 {
       
    88     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(interface)");
       
    89     return d->create(interface, operation, embedded);
       
    90 }
       
    91 
       
    92 
       
    93 /*!
       
    94     Create AIW request for interface implementation descriptor and operation name.
       
    95     The descriptor is got from the list() call.
       
    96     As combination [service,interface,version] shall be unique,
       
    97     the descriptor points to one implementation and thus selects correct
       
    98     implementation.
       
    99     
       
   100     \param implementation Valid interface descriptor obtained by the "list" call.
       
   101     \param operation The function signature to be called via the interface.
       
   102                      Can be set later via XQAiwRequest::setOperation.
       
   103     \param embedded True if embedded call, false otherwise
       
   104                      Can be set later via XQAiwRequest::setEmbedded.
       
   105     \return The application interworking request instance.
       
   106     \see list()
       
   107     \see create( const QString &interface, const QString &operation, bool embedded)
       
   108     \see create( const QString &service, const QString &interface, const QString &operation, bool embedded)
       
   109 
       
   110     Example usage:
       
   111     \code
       
   112     XQApplicationManager appMgr;  // Prefer one instance only 
       
   113     QList<XQAiwInterfaceDescriptor> list = appMgr.list(imageInterface, "");
       
   114     //
       
   115     // Populate a user interface widget and select proper implementation via descriptor
       
   116     // ... 
       
   117     XQAiwRequest * req = appMgr.create(selectedDescriptor, selectOperation);
       
   118     //
       
   119     // ... the rest as usual...
       
   120     //
       
   121     \endcode
       
   122 */
       
   123 XQAiwRequest* XQApplicationManager::create(
       
   124     const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded)
       
   125 {
       
   126     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create (impl.)");
       
   127     return d->create(implementation, operation, embedded);
       
   128 }
       
   129 
       
   130 
       
   131 /*!
       
   132     Create AIW request for interface and service name.
       
   133     As combination [service,interface,version] shall be unique,
       
   134     the descriptor points to one implementation and thus selects correct
       
   135     implementation.
       
   136     
       
   137     \param service Service name as mentioned in the service registry file
       
   138     \param interface Interface name as mentioned in the service registry file
       
   139     \param operation The function signature to be called via the interface.
       
   140                      Can be set later via XQAiwRequest::setOperation.
       
   141     \param embedded True if embedded call, false otherwise
       
   142                      Can be set later via XQAiwRequest::setEmbedded.
       
   143     \return The application interworking request instance
       
   144     \see XQApplicationManager::create( const QString &interface, const QString &operation, bool embedded)
       
   145     \see create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
       
   146 
       
   147     Example usage:
       
   148     \code
       
   149     // componentglobal.h
       
   150     QString photosApplication = "Photos";
       
   151     QString imageInterface = "com.nokia.symbian.IImageFetch";
       
   152     QString selectOperation = "select(QString&,bool)";
       
   153 
       
   154     #include <xqappmgr.h>;
       
   155     #include "componentglobal.h";
       
   156 
       
   157     // XQApplicationManager mAppMgr;  // manager as class member
       
   158 
       
   159     XQAiwRequest * req = this->mAppMgr.create(photosApplication, imageInterface, selectOperation);
       
   160     if (req)
       
   161     {
       
   162         ...
       
   163     }
       
   164     \endcode
       
   165 */
       
   166 XQAiwRequest* XQApplicationManager::create(
       
   167     const QString &service, const QString &interface, const QString &operation, bool embedded)
       
   168 {
       
   169     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(service+interface)");
       
   170     return d->create(service, interface, operation, embedded);
       
   171 }
       
   172 
       
   173 /*!
       
   174     List implementation descriptors by interface name.
       
   175     \param interface Interface name as mentioned in the service registry file
       
   176     \param operation The operation signature to be called.  Reserved for future use.
       
   177     \param embedded True if embedded call, false otherwise
       
   178     \return The list of implementation descriptors.
       
   179     \see list
       
   180 
       
   181     Example usage:
       
   182     \code
       
   183     \code
       
   184     // Use some variant of "list"
       
   185     QString imageInterface = "com.nokia.symbian.IImageFetch";
       
   186     QList<XQAiwInterfaceDescriptor> list = this->mAppmgr.list(imageInterface, "");
       
   187     //
       
   188     // Populate a user interface widget and select proper implementation via descriptor
       
   189     // ... 
       
   190     XQAiwRequest * req = this->mAppMgr.create(selectedDescriptor, selectOperation);
       
   191     //
       
   192     // ... the rest as usual...
       
   193     //
       
   194     \endcode
       
   195 */
       
   196 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(const QString &interface, const QString &operation)
       
   197 {
       
   198     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list");
       
   199     return d->list(interface, operation);
       
   200 }
       
   201 
       
   202 /*!
       
   203     List implementation(s) descriptors by service and interface name.
       
   204 */
       
   205 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(
       
   206     const QString &service, const QString &interface, const QString &operation)
       
   207 {
       
   208     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list");
       
   209     return d->list(service, interface, operation);
       
   210 }
       
   211 
       
   212 /*!
       
   213     Create AIW request for uri.
       
   214     The interface name applied implicitly is declared by the constant XQI_URI_VIEW
       
   215     unless there is custom handler attached to URI scheme, the 
       
   216     A service declares support for scheme(s) (CSV list) by adding the custom property key
       
   217     (see the constant XQCUSTOM_PROP_SCHEMES value) to the service XML.
       
   218     By default, the operation name declared by constant XQOP_URI_VIEW is used.
       
   219     Certain URI schemes, like "application" or "http"  have custom handling and thus they override the service handling.
       
   220      - "appto"  URIs is handled by corresponding activity framework
       
   221      - "http:" and "https: URIs are handled by QDesktopServices::openUrl()
       
   222      - "file": URIs is handled via the XQI_FILE_VIEW interface.
       
   223        Example, QFile file("C:\\data\\Others\\test.txt");
       
   224          
       
   225     \return The application interworking request instance
       
   226     \see XQAiwInterfaceDescriptor for constants values
       
   227 */
       
   228 XQAiwRequest* XQApplicationManager::create( const QUrl &uri, bool embedded)
       
   229 {
       
   230     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(url)");
       
   231     return d->create(uri, NULL, embedded);
       
   232 }
       
   233 
       
   234 XQAiwRequest* XQApplicationManager::create(
       
   235     const QUrl &uri, const XQAiwInterfaceDescriptor& implementation, bool embedded)
       
   236 {
       
   237     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(uri+impl)");
       
   238     return d->create(uri, &implementation, embedded);
       
   239 }
       
   240 
       
   241 /*!
       
   242     Create AIW request for the given file and the MIME type attached to the file.
       
   243     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
       
   244     By default, the operation name declared by constant XQOP_FILE_VIEW is used.
       
   245 */
       
   246 XQAiwRequest* XQApplicationManager::create( const QFile &file, bool embedded)
       
   247 {
       
   248     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(file)");
       
   249     return d->create(file, NULL, embedded);
       
   250 }
       
   251 
       
   252 XQAiwRequest* XQApplicationManager::create(
       
   253     const QFile &file, const XQAiwInterfaceDescriptor& implementation, bool embedded)
       
   254 {
       
   255     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(file+impl)");
       
   256     return d->create(file, &implementation, embedded);
       
   257 }
       
   258 
       
   259 
       
   260 /*!
       
   261     List implementations that support handling the URI scheme of the given uri
       
   262     The interface name applied implicitly is declared by the constant XQI_URI_VIEW
       
   263 */
       
   264 
       
   265 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(const QUrl &uri)
       
   266 {
       
   267     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list(uri)");
       
   268     return d->list(uri);
       
   269 }
       
   270 
       
   271 /*!
       
   272     List implementations that support handling the MIME type of of the given file
       
   273     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
       
   274 */
       
   275 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(const QFile &file)
       
   276 {
       
   277     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list(file)");
       
   278     return d->list(file);
       
   279 }
       
   280 
       
   281 /*!
       
   282     List implementations that support handling the MIME type of of the given sharable file
       
   283     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
       
   284 */
       
   285 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(const XQSharableFile &file)
       
   286 {
       
   287     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list(XQSharableFile)");
       
   288     return d->list(file);
       
   289 }
       
   290 
       
   291 /*!
       
   292     Create AIW request for the given file and the MIME type attached to the sharable file
       
   293     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
       
   294     By default, the operation name declared by constant XQOP_FILE_VIEW_SHARABLE is used.
       
   295 */
       
   296 XQAiwRequest* XQApplicationManager::create(const XQSharableFile &file, bool embedded)
       
   297 {
       
   298     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(XQSharableFile)");
       
   299     return d->create(file, NULL, embedded);
       
   300 }
       
   301 
       
   302 XQAiwRequest* XQApplicationManager::create(
       
   303     const XQSharableFile &file, const XQAiwInterfaceDescriptor& implementation, bool embedded)
       
   304 {
       
   305     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(XQSharableFile+impl)");
       
   306     return d->create(file, &implementation, embedded);
       
   307 }
       
   308 
       
   309 int XQApplicationManager::lastError() const
       
   310 {
       
   311     XQSERVICE_DEBUG_PRINT("XQApplicationManager::lastError");
       
   312     return d->lastError();
       
   313 }