qthighway/xqservice/src/xqappmgr.cpp
changeset 14 6fbed849b4f4
parent 4 90517678cc4f
child 24 9d760f716ca8
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    37     XQSERVICE_DEBUG_PRINT("XQApplicationManager::~XQApplicationManager");
    37     XQSERVICE_DEBUG_PRINT("XQApplicationManager::~XQApplicationManager");
    38     delete d;
    38     delete d;
    39 };
    39 };
    40 
    40 
    41 /*!
    41 /*!
    42     Create AIW request for interface and operation name.
    42     Creates AIW request by interface and operation name.
    43     The first found implementation is applied. If you need to activate specific implementation
    43     The first found service implementation is returned. If you need to activate specific implementation
    44     you shall first list() implementations and use the overloaded create() with XQAiwInterfaceDescriptor
    44     you shall first list() implementations and use the overloaded create() with XQAiwInterfaceDescriptor
    45     to select the correct implementation.
    45     to select the correct implementation. 
    46     
    46     
    47     \param interface Interface name as mentioned in the service registry file
    47     \param interface Interface name as mentioned in the service registry file.
       
    48                      Apply the xqaiwdecl.h file for common constants.
    48     \param operation The function signature to be called via the interface.
    49     \param operation The function signature to be called via the interface.
    49                      Can be set later via XQAiwRequest::setOperation.
    50                      Can be set later via XQAiwRequest::setOperation.
    50     \param embedded True if embedded call, false otherwise
    51                      Apply the xqaiwdecl.h file for common constants.
    51                      Can be set later via XQAiwRequest::setEmbedded.
    52     \param embedded True if embedded (window groups chained) call, false otherwise
       
    53                     Can be set later via XQAiwRequest::setEmbedded.
    52     \return The application interworking request instance, NULL if no service is available
    54     \return The application interworking request instance, NULL if no service is available
    53     \see list()
    55     \sa list(const QString &interface, const QString &operation)
    54     \see create( const QString &service, const QString &interface, const QString &operation, bool embedded)
    56     \sa create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
    55     \see create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
    57     \sa xqaiwdecl.h for constants values
    56     
    58     
    57     Example usage:
    59     Example usage:
    58     \code
    60     \code
    59     // componentglobal.h
    61     #include <xqaiwdecl.h>
    60     const QString photosApplication = "Photos";
    62     #include <xqapplicationmanager.h>
    61     const QString imageInterface = "com.nokia.symbian.IImageFetch";
    63     
    62     const QString selectOperation = "select(QString&,bool)";
    64     // XQApplicationManager mAppMgr;  // Set manager as class member
    63 
    65     
    64     #include <xqappmgr.h>;
    66     XQAiwRequest * req = this->mAppMgr.create(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH, false);
    65     #include "componentglobal.h";
       
    66     
       
    67     // XQApplicationManager mAppMgr;  // manager as class member
       
    68     
       
    69     XQAiwRequest * req = this->mAppMgr.create(imageInterface, selectOperation);
       
    70     if (req)
    67     if (req)
    71     {
    68     {
    72         // There was service available
    69         // There was service available
    73         QList<QVariant> args;
    70         QList<QVariant> args;
    74         args << folder;
    71         args << folder;
    89     return d->create(interface, operation, embedded);
    86     return d->create(interface, operation, embedded);
    90 }
    87 }
    91 
    88 
    92 
    89 
    93 /*!
    90 /*!
    94     Create AIW request for interface implementation descriptor and operation name.
    91     Creates AIW request by interface implementation descriptor and operation name.
    95     The descriptor is got from the list() call.
    92     The descriptor is got from the list() call.
    96     As combination [service,interface,version] shall be unique,
    93     As combination [service,interface,version] shall be unique,
    97     the descriptor points to one implementation and thus selects correct
    94     the descriptor points to one implementation and thus selects correct
    98     implementation.
    95     implementation.
    99     
    96     
   100     \param implementation Valid interface descriptor obtained by the "list" call.
    97     \param implementation Valid interface descriptor obtained by the "list" call.
   101     \param operation The function signature to be called via the interface.
    98     \param operation The function signature to be called via the interface.
   102                      Can be set later via XQAiwRequest::setOperation.
    99                      Can be set later via XQAiwRequest::setOperation.
       
   100                      Apply the xqaiwdecl.h file for common constants.
   103     \param embedded True if embedded call, false otherwise
   101     \param embedded True if embedded call, false otherwise
   104                      Can be set later via XQAiwRequest::setEmbedded.
   102                      Can be set later via XQAiwRequest::setEmbedded.
   105     \return The application interworking request instance.
   103     \return The application interworking request instance, NULL if no service is available
   106     \see list()
   104     \sa list()
   107     \see create( const QString &interface, const QString &operation, bool embedded)
   105     \sa create( const QString &interface, const QString &operation, bool embedded)
   108     \see create( const QString &service, const QString &interface, const QString &operation, bool embedded)
   106     \sa create( const QString &service, const QString &interface, const QString &operation, bool embedded)
       
   107     \sa xqaiwdecl.h for constants values
   109 
   108 
   110     Example usage:
   109     Example usage:
   111     \code
   110     \code
       
   111     #include <xqaiwdecl.h>
       
   112     #include <xqapplicationmanager.h>
       
   113     
   112     XQApplicationManager appMgr;  // Prefer one instance only 
   114     XQApplicationManager appMgr;  // Prefer one instance only 
   113     QList<XQAiwInterfaceDescriptor> list = appMgr.list(imageInterface, "");
   115     QList<XQAiwInterfaceDescriptor> list = appMgr.list(XQI_CAMERA_CAPTURE, "");
   114     //
   116     //
   115     // Populate a user interface widget and select proper implementation via descriptor
   117     // Populate a user interface widget and select proper implementation via descriptor
   116     // ... 
   118     // ... 
   117     XQAiwRequest * req = appMgr.create(selectedDescriptor, selectOperation);
   119     XQAiwRequest * req = appMgr.create(selectedDescriptor, XQOP_CAMERA_CAPTURE);
   118     //
   120     //
   119     // ... the rest as usual...
   121     // ... the rest as usual...
   120     //
   122     //
   121     \endcode
   123     \endcode
   122 */
   124 */
   127     return d->create(implementation, operation, embedded);
   129     return d->create(implementation, operation, embedded);
   128 }
   130 }
   129 
   131 
   130 
   132 
   131 /*!
   133 /*!
   132     Create AIW request for interface and service name.
   134     Creates AIW request by service and interface name.  You should not normally use this
   133     As combination [service,interface,version] shall be unique,
   135     overload as typically service request are done by the interface name only.
   134     the descriptor points to one implementation and thus selects correct
   136     Internally this applies list() operation and applies the first found service
   135     implementation.
   137     implementation.
   136     
   138     
   137     \param service Service name as mentioned in the service registry file
   139     \param service Service name as mentioned in the service registry file
   138     \param interface Interface name as mentioned in the service registry file
   140     \param interface Interface name as mentioned in the service registry file
   139     \param operation The function signature to be called via the interface.
   141     \param operation The function signature to be called via the interface.
   140                      Can be set later via XQAiwRequest::setOperation.
   142                      Can be set later via XQAiwRequest::setOperation.
   141     \param embedded True if embedded call, false otherwise
   143     \param embedded True if embedded (window groups chained) call, false otherwise
   142                      Can be set later via XQAiwRequest::setEmbedded.
   144                      Can be set later via XQAiwRequest::setEmbedded.
   143     \return The application interworking request instance
   145     \return The application interworking request instance, NULL if no service is available
   144     \see XQApplicationManager::create( const QString &interface, const QString &operation, bool embedded)
   146     \sa XQApplicationManager::create( const QString &interface, const QString &operation, bool embedded)
   145     \see create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
   147     \sa create( const XQAiwInterfaceDescriptor &implementation, const QString &operation, bool embedded);
       
   148     \sa xqaiwdecl.h for constants values
   146 
   149 
   147     Example usage:
   150     Example usage:
   148     \code
   151     \code
   149     // componentglobal.h
   152     #include <xqaiwdecl.h>
   150     QString photosApplication = "Photos";
   153     #include <xqapplicationmanager.h>
   151     QString imageInterface = "com.nokia.symbian.IImageFetch";
       
   152     QString selectOperation = "select(QString&,bool)";
       
   153 
   154 
   154     #include <xqappmgr.h>;
   155     #include <xqappmgr.h>;
   155     #include "componentglobal.h";
   156     #include "componentglobal.h";
   156 
   157 
   157     // XQApplicationManager mAppMgr;  // manager as class member
   158     // XQApplicationManager mAppMgr;  // manager as class member
   158 
   159 
   159     XQAiwRequest * req = this->mAppMgr.create(photosApplication, imageInterface, selectOperation);
   160     // Use embedded call.
       
   161     XQAiwRequest * req = this->mAppMgr.create(QLatin1String("photos"), XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH, true);
   160     if (req)
   162     if (req)
   161     {
   163     {
   162         ...
   164         ...
   163     }
   165     }
   164     \endcode
   166     \endcode
   172 
   174 
   173 /*!
   175 /*!
   174     List implementation descriptors by interface name.
   176     List implementation descriptors by interface name.
   175     \param interface Interface name as mentioned in the service registry file
   177     \param interface Interface name as mentioned in the service registry file
   176     \param operation The operation signature to be called.  Reserved for future use.
   178     \param operation The operation signature to be called.  Reserved for future use.
   177     \param embedded True if embedded call, false otherwise
   179     \return The list of implementation descriptors, or empty list if no implementations found.
   178     \return The list of implementation descriptors.
   180     \sa xqaiwdecl.h for constants values
   179     \see list
       
   180 
   181 
   181     Example usage:
   182     Example usage:
   182     \code
   183     \code
   183     \code
   184     #include <xqaiwdecl.h>
   184     // Use some variant of "list"
   185     #include <xqapplicationmanager.h>
   185     QString imageInterface = "com.nokia.symbian.IImageFetch";
   186     QList<XQAiwInterfaceDescriptor> list = this->mAppmgr.list(XQI_IMAGE_FETCH, "");
   186     QList<XQAiwInterfaceDescriptor> list = this->mAppmgr.list(imageInterface, "");
       
   187     //
   187     //
   188     // Populate a user interface widget and select proper implementation via descriptor
   188     // Populate a user interface widget and select proper implementation via descriptor
   189     // ... 
   189     // ... 
   190     XQAiwRequest * req = this->mAppMgr.create(selectedDescriptor, selectOperation);
   190     XQAiwRequest * req = this->mAppMgr.create(selectedDescriptor, XQOP_IMAGE_FETCH);
   191     //
   191     //
   192     // ... the rest as usual...
   192     // ... the rest as usual...
   193     //
   193     //
   194     \endcode
   194     \endcode
   195 */
   195 */
   199     return d->list(interface, operation);
   199     return d->list(interface, operation);
   200 }
   200 }
   201 
   201 
   202 /*!
   202 /*!
   203     List implementation(s) descriptors by service and interface name.
   203     List implementation(s) descriptors by service and interface name.
       
   204     \sa list(const QString &interface, const QString &operation)
   204 */
   205 */
   205 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(
   206 QList<XQAiwInterfaceDescriptor> XQApplicationManager::list(
   206     const QString &service, const QString &interface, const QString &operation)
   207     const QString &service, const QString &interface, const QString &operation)
   207 {
   208 {
   208     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list");
   209     XQSERVICE_DEBUG_PRINT("XQApplicationManager::list");
   209     return d->list(service, interface, operation);
   210     return d->list(service, interface, operation);
   210 }
   211 }
   211 
   212 
   212 /*!
   213 /*!
   213     Create AIW request for uri.
   214     Creates AIW request to view the  given URI (having a attached scheme)
   214     The interface name applied implicitly is declared by the constant XQI_URI_VIEW
   215     The interface name applied implicitly isthe XQI_URI_VIEW (from xqaiwdecl.h),
   215     unless there is custom handler attached to URI scheme, the 
   216     unless there is custom handling attached to URI scheme.
       
   217     The first found service implementation is applied.
   216     A service declares support for scheme(s) (CSV list) by adding the custom property key
   218     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.
   219     (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.
   220     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.
   221     Custom handling for certainsoverride the default service handling:
   220      - "appto"  URIs is handled by corresponding activity framework
   222      - "http:" and "https: schemes are handled by QDesktopServices::openUrl()
   221      - "http:" and "https: URIs are handled by QDesktopServices::openUrl()
   223      - "appto"  URIs is handled by corresponding Activity Manager Framework
   222      - "file": URIs is handled via the XQI_FILE_VIEW interface.
   224      - "file": Local file scheme is handled via the XQI_FILE_VIEW interface
   223        Example, QFile file("C:\\data\\Others\\test.txt");
   225                (the same as applie to e.g. create(QFile))
   224          
   226          
   225     \return The application interworking request instance
   227     \param uri The URI to be viewed
   226     \see XQAiwInterfaceDescriptor for constants values
   228     \param embedded True if embedded (window groups chained) call, false otherwise
       
   229     \return The application interworking request instance, or NULL if no URI viewer found.
       
   230     \sa xqaiwdecl.h for constants values
   227 */
   231 */
   228 XQAiwRequest* XQApplicationManager::create( const QUrl &uri, bool embedded)
   232 XQAiwRequest* XQApplicationManager::create( const QUrl &uri, bool embedded)
   229 {
   233 {
   230     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(url)");
   234     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(url)");
   231     return d->create(uri, NULL, embedded);
   235     return d->create(uri, NULL, embedded);
   232 }
   236 }
   233 
   237 
       
   238 /*!
       
   239     Creates AIW request to view the given URI by service implementation
       
   240     The interface name applied implicitly is XQI_URI_VIEW (from xqaiwdecl.h),
       
   241     unless there is custom handling attached to URI scheme.
       
   242     A service declares support for scheme(s) (CSV list) by adding the custom property key
       
   243     (see the constant XQCUSTOM_PROP_SCHEMES value) to the service XML.
       
   244     Custom handling for certainsoverride the default service handling:
       
   245      - "http:" and "https: schemes are handled by QDesktopServices::openUrl()
       
   246      - "appto"  URIs is handled by corresponding Activity Manager Framework
       
   247      - "file": Local file scheme is handled via the XQI_FILE_VIEW interface
       
   248                (the same as applie to e.g. create(QFile))
       
   249 
       
   250     \param uri The URI to be viewed
       
   251     \param embedded True if embedded (window groups chained) call, false otherwise
       
   252     \param implementation Valid interface descriptor obtained by the "list(QUrl)" call.
       
   253     \return The application interworking request instance, or NULL if no URI viewer found.
       
   254     \sa xqaiwdecl.h for constants values
       
   255 */
   234 XQAiwRequest* XQApplicationManager::create(
   256 XQAiwRequest* XQApplicationManager::create(
   235     const QUrl &uri, const XQAiwInterfaceDescriptor& implementation, bool embedded)
   257     const QUrl &uri, const XQAiwInterfaceDescriptor& implementation, bool embedded)
   236 {
   258 {
   237     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(uri+impl)");
   259     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(uri+impl)");
   238     return d->create(uri, &implementation, embedded);
   260     return d->create(uri, &implementation, embedded);
   239 }
   261 }
   240 
   262 
   241 /*!
   263 /*!
   242     Create AIW request for the given file and the MIME type attached to the file.
   264     Create AIW requests to view the given file and having the MIME type attached.
   243     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
   265     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.
   266     The first found service implementation is applied.
       
   267     \param file The file to be viewed
       
   268     \param embedded True if embedded (window groups chained) call, false otherwise
       
   269     \return The application interworking request instance, or NULL if no viewer found.
       
   270     \sa xqaiwdecl.h for constants values
   245 */
   271 */
   246 XQAiwRequest* XQApplicationManager::create( const QFile &file, bool embedded)
   272 XQAiwRequest* XQApplicationManager::create( const QFile &file, bool embedded)
   247 {
   273 {
   248     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(file)");
   274     XQSERVICE_DEBUG_PRINT("XQApplicationManager::create(file)");
   249     return d->create(file, NULL, embedded);
   275     return d->create(file, NULL, embedded);