qthighway/xqservice/src/xqappmgr.cpp
changeset 26 3d09643def13
parent 24 9d760f716ca8
equal deleted inserted replaced
24:9d760f716ca8 26:3d09643def13
    24 #include <xqaiwrequest.h>
    24 #include <xqaiwrequest.h>
    25 #include <xqaiwinterfacedescriptor.h>
    25 #include <xqaiwinterfacedescriptor.h>
    26 #include <QList>
    26 #include <QList>
    27 #include "xqappmgr_p.h"
    27 #include "xqappmgr_p.h"
    28 
    28 
       
    29 /*! \page page1 Terminology
       
    30     
       
    31     \anchor terminology
       
    32     <table border="2">
       
    33         <tr>
       
    34             <td><b>Term</b></td>
       
    35             <td><b>Definition</b></td>
       
    36             <td><b>Notes</b></td>
       
    37         </tr>
       
    38         <tr>
       
    39             <td><i>activity</i></td>
       
    40             <td>
       
    41                 UXD defined term: \n
       
    42                 "Activity always refers to the users point of view. An activity is something
       
    43                 a user engages in for a purpose. An example of an activity would be: entering
       
    44                 an email, listening to music, browsing a web page, etc. Activities are
       
    45                 synonymous with experiences, and can be continuous or discontinuous". 
       
    46             </td>
       
    47             <td>
       
    48                 See more from http://s60wiki.nokia.com/S60Wiki/QtFw_for_S60_coding_conventions/Service_name_registry#Activity.
       
    49             </td>
       
    50         </tr>
       
    51         <tr>
       
    52             <td><i>client, client application</i></td>
       
    53             <td>
       
    54                 Application that use the a service application via the QtHighway.
       
    55             </td>
       
    56             <td></td>
       
    57         </tr>
       
    58         <tr>
       
    59             <td><i>embedded</i></td>
       
    60             <td>
       
    61                 When a service application is launched as embedded, window groups of client
       
    62                 and service application are chained. The service application need to be
       
    63                 exited to return UI control back to client application. 
       
    64             </td>
       
    65             <td>
       
    66                 The embedded launch is considered as private connection between client and
       
    67                 service application. 
       
    68             </td>
       
    69         </tr>
       
    70         <tr>
       
    71             <td><i>full service name</i></td>
       
    72             <td>
       
    73                 Combined service and interface (+ optional embedding part) name as follows. \n
       
    74                 1. Service name \n
       
    75                 2. Character *.* (dot) \n
       
    76                 3. Interface name \n
       
    77                 4. Character *.* (dot) (if embedded launch) \n
       
    78                 5. Service application process name ((if embedded launch))
       
    79             </td>
       
    80             <td></td>
       
    81         </tr>
       
    82         <tr>
       
    83             <td><i>interface descriptor</i></td>
       
    84             <td>
       
    85                 Utility class to hold meta-data information constructed from the service configuration file. 
       
    86             </td>
       
    87             <td></td>
       
    88         </tr>
       
    89         <tr>
       
    90             <td><i>interface name</i></td>
       
    91             <td>
       
    92                 The name of interface as defined in the service configuration file.
       
    93             </td>
       
    94             <td>
       
    95                 See http://s60wiki.nokia.com/S60Wiki/QtFw_for_S60_coding_conventions/Service_name_registry#Service_naming_guidelines.
       
    96             </td>
       
    97         </tr>
       
    98         <tr>
       
    99             <td><i>MIME registry</i></td>
       
   100             <td>
       
   101                 The database containing published MIME datatypes applications can view.
       
   102             </td>
       
   103             <td>
       
   104                 Symbian OS Application Architecture implements the database.
       
   105             </td>
       
   106         </tr>
       
   107         <tr>
       
   108             <td><i>service application, service provider application</i></td>
       
   109             <td>
       
   110                 Qt/Orbit based based executable (.exe) that implements and hosts a service provider.
       
   111             </td>
       
   112             <td></td>
       
   113         </tr>
       
   114         <tr>
       
   115             <td><i>operation, message</i></td>
       
   116             <td>
       
   117                 Utility's function to be called. Technically Qt slot signature without extra spaces and reference (&).
       
   118             </td>
       
   119             <td></td>
       
   120         </tr>
       
   121         <tr>
       
   122             <td><i>service</i></td>
       
   123             <td>
       
   124                 Simple utilities offered via interface from an application to another other.
       
   125                 The service identified by the full service name. 
       
   126             </td>
       
   127             <td></td>
       
   128         </tr>
       
   129         <tr>
       
   130             <td><i>service configuration file</i></td>
       
   131             <td>
       
   132                 XML formatted file that describes the meta data of the service, e.g. service name,
       
   133                 interface name, custom properties, using the agreed XML schema.
       
   134             </td>
       
   135             <td></td>
       
   136         </tr>
       
   137         <tr>
       
   138             <td><i>service name</i></td>
       
   139             <td>
       
   140                 The name of service as defined in the service configuration file.
       
   141             </td>
       
   142             <td>
       
   143                 See http://s60wiki.nokia.com/S60Wiki/QtFw_for_S60_coding_conventions/Service_name_registry#Service_naming_guidelines.
       
   144             </td>
       
   145         </tr>
       
   146         <tr>
       
   147             <td><i>service provider</i></td>
       
   148             <td>
       
   149                 Instance of XQServiceProvider that is included into a service application 
       
   150             </td>
       
   151             <td>
       
   152                 In-process (.dll) providers not supported yet.
       
   153             </td>
       
   154         </tr>
       
   155         <tr>
       
   156             <td><i>service registry</i></td>
       
   157             <td>
       
   158                 The database containing published service configuration files.
       
   159             </td>
       
   160             <td>
       
   161                 Symbian OS Application Architecture implements the database.
       
   162             </td>
       
   163         </tr>
       
   164     </table>
       
   165 */
       
   166 
    29 /*!
   167 /*!
    30     \class XQApplicationManager
   168     \class XQApplicationManager
    31     \inpublicgroup QtBaseModule
   169     \inpublicgroup QtBaseModule
    32 
   170 
    33     \ingroup ipc
   171     \ingroup ipc
    34     \brief Factory class to list interface descriptors and create interworking objects (XQAiwRequest)
   172     \brief The factory class of the Qt Extension's service framework to support out-of-process application interworking use cases
       
   173     
       
   174     See \ref terminology for terms used in this documentation.
    35     
   175     
    36     XQApplicationManager lists interface descriptors by interface and /or service name. It is also used to
   176     XQApplicationManager lists interface descriptors by interface and /or service name. It is also used to
    37     create interworking objects (XQAiwRequest).
   177     create interworking objects (XQAiwRequest).
    38     
   178     
    39     This class is a part of API to be used by the applications instead of using XQServiceRequest directly.
   179     This class is a part of Application Manager API  to be used by the applications instead of using XQServiceRequest directly.
    40     
   180     
    41     The Application Manager API offers centric place for applications UIs to handle application to application interworking use cases, like:
   181     The Application Manager API offers centric place for applications UIs to handle application to application interworking use cases, like:
    42     - Synchronous out-of-process service call from client to service provider, where service provider needs to complete the request before
   182     - Synchronous out-of-process service call from client to service provider, where service provider needs to complete the request before
    43       control comes back to requesting client.
   183       control comes back to requesting client.
    44     - Asynchronous out-of-process service call from client to service provider, where Service provider completes the request whenever suitable.
   184     - Asynchronous out-of-process service call from client to service provider, where Service provider completes the request whenever suitable.
    45       The control returns back requesting as soon the service provider has received the asynchronous call (can be applied to notifications as well).
   185       The control returns back requesting as soon the service provider has received the asynchronous call (can be applied to notifications as well).
    46     - Embedded out-of-process service call. In this case window groups are chained and "Back" returns to client window.
   186     - Embedded out-of-process service call. In this case window groups are chained and "Back" returns to client window.
    47     - Any named Qt type in the Qt meta-object system can be used as a service call parameter or return value. Also own, custom meta-types are supported.
   187     - Any named Qt type in the Qt meta-object system can be used as a service call parameter or return value. Also own, custom meta-types are supported.
    48     - Launched service provider application (.exe) if not already running when client makes service call to it.
   188     - Launch service provider application (.exe) if not already running when client makes service call to it.
    49     - List and discover services dynamically.
   189     - List and discover services dynamically.
    50     - Apply UI related options upon service launch, like "launch as embedded", "launch to foreground" and "launch to backround".
   190     - Apply UI related options upon service launch, like "launch as embedded", "launch to foreground" and "launch to backround".
    51     - Opening files to be viewed by a file viewing interface.
   191     - Open files to be viewed by a file viewing interface. Both normal and sharable (data-caged) files are supported.
    52     - Opening URI to be viewed by a URI viewing interface. Includes also launching activity URIs (appto) as fire-and-forget manner.
   192     - Opening URI to be viewed by a URI viewing interface. Includes also launching activity URIs (appto) as fire-and-forget manner.
    53     - Miscellanous AIW support, like get service stasus or get DRM attributes.
   193     - Miscellanous AIW support, like get service stasus or get DRM attributes.
    54     
   194     
    55     <b>Example usage:</b> \n
   195     <b>Example usage:</b> \n
    56     
   196     
    57     The usage pattern for all the XQApplicationManager variants implemented as service providers , interface, QUrl, QFile, is similar both embedded
   197     The usage pattern for all the XQApplicationManager variants implemented as service providers , interface, QUrl, QFile, is similar both embedded
    58     and non-embedded usage:
   198     and non-embedded usage:
    59     \code
   199     \code
    60         // Recommended way is to add XQApplicationManager as member variable to class
   200         // Recommended way is to add XQApplicationManager as member variable to class
    61         // Later on when caching of services
       
    62         // You can use the class also as local variable.
   201         // You can use the class also as local variable.
    63         class Client
   202         class Client
    64         {
   203         {
    65 
   204 
    66         public:
   205         public:
    84             bool embedded=true;  // or false
   223             bool embedded=true;  // or false
    85 
   224 
    86             XQAiwRequest *request;
   225             XQAiwRequest *request;
    87             // Create request by interface name, the very first service implementation
   226             // Create request by interface name, the very first service implementation
    88             // applied.
   227             // applied.
    89             request = mAiwMgr.create("Interface", "functionName2(QString, int)", embedded);
   228             request = mAiwMgr.create("Interface", "functionName2(QString,int)", embedded);
    90 
   229 
    91             // If dedicated service is wanted, apply this 
   230             // If dedicated service is wanted, apply this 
    92             // request = mAiwMgr.create("Service", "Interface", 
   231             // request = mAiwMgr.create("Service", "Interface", 
    93             //                          "functionName2(QString, int)", embedded);
   232             //                          "functionName2(QString,int)", embedded);
    94 
   233 
    95             if (request == NULL)
   234             if (request == NULL)
    96             {
   235             {
    97                 // Service not found 
   236                 // Service not found 
    98                 return false;
   237                 return false;
   123         // ...See previous example
   262         // ...See previous example
   124         request = mAiwMgr.create(selectedImpl, embedded);
   263         request = mAiwMgr.create(selectedImpl, embedded);
   125         // ....See previous example
   264         // ....See previous example
   126     \endcode
   265     \endcode
   127     
   266     
   128     The XQApplicationManager supports opening activity (see Terminology) URIs (appto scheme) as fire-and-forget mannner:
   267     The XQApplicationManager supports opening activity URIs (appto scheme) as fire-and-forget mannner:
   129     \code
   268     \code
   130         QUrl url("appto://10207C62?activityname=MusicMainView"); 
   269         QUrl url("appto://10207C62?activityname=MusicMainView"); 
   131 
   270 
   132         // The difference to the previous example is is how request is created
   271         // The difference to the previous example is is how request is created
   133         // via application mgr.
   272         // via application mgr.
   138             return;
   277             return;
   139         }
   278         }
   140 
   279 
   141         // Set function parameters
   280         // Set function parameters
   142         QList<QVariant> args;
   281         QList<QVariant> args;
   143         args << uri.toSring();
   282         args << uri.toString();
   144         request->setArguments(args);
   283         request->setArguments(args);
   145 
   284 
   146         // Send the request
   285         // Send the request
   147         bool res = request.send();
   286         bool res = request->send();
   148         if  (!res) 
   287         if  (!res) 
   149         {
   288         {
   150             // Request failed. 
   289             // Request failed. 
   151             int error = request->lastError();
   290             int error = request->lastError();
   152             // Handle error
   291             // Handle error
   161 
   300 
   162 XQApplicationManager::XQApplicationManager()
   301 XQApplicationManager::XQApplicationManager()
   163 {
   302 {
   164     XQSERVICE_DEBUG_PRINT("XQApplicationManager::XQApplicationManager");
   303     XQSERVICE_DEBUG_PRINT("XQApplicationManager::XQApplicationManager");
   165     d = new XQApplicationManagerPrivate();
   304     d = new XQApplicationManagerPrivate();
   166     
   305     d->v_ptr = this;
   167 }
   306 }
   168 XQApplicationManager::~XQApplicationManager()
   307 XQApplicationManager::~XQApplicationManager()
   169 {
   308 {
   170     XQSERVICE_DEBUG_PRINT("XQApplicationManager::~XQApplicationManager");
   309     XQSERVICE_DEBUG_PRINT("XQApplicationManager::~XQApplicationManager");
   171     delete d;
   310     delete d;
   399 }
   538 }
   400 
   539 
   401 /*!
   540 /*!
   402     Create AIW requests to view the given file and having the MIME type attached.
   541     Create AIW requests to view the given file and having the MIME type attached.
   403     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
   542     The interface name applied implicitly is declared by the constant XQI_FILE_VIEW
   404     The first found service implementation is applied.
   543     The default service implementation  configured for the MIME type is returned.
   405     \param file The file to be viewed
   544     \param file The file to be viewed
   406     \param embedded True if embedded (window groups chained) call, false otherwise
   545     \param embedded True if embedded (window groups chained) call, false otherwise
   407     \return The application interworking request instance, or NULL if no viewer found.
   546     \return The application interworking request instance, or NULL if no viewer found.
   408     \sa xqaiwdecl.h for constants values
   547     \sa xqaiwdecl.h for constants values
   409 */
   548 */
   520     return d->isRunning(implementation);
   659     return d->isRunning(implementation);
   521 }
   660 }
   522 
   661 
   523 /*!
   662 /*!
   524     Gets the values of the DRM related \a attributeNames, like "IsProtected",
   663     Gets the values of the DRM related \a attributeNames, like "IsProtected",
   525     "IsForwardable", "MimeType" for a given \a file.
   664     "IsForwardable", "MimeType" for a given \a file. The set of supported attributes is same
       
   665     as in Symbian OS CAF (though not all declared by the API).
   526     \param file File for which DRM attributes are retrieved
   666     \param file File for which DRM attributes are retrieved
   527     \param attributeNames List of attributes that should be retrieved (check #DrmAttribute)
   667     \param attributeNames List of attributes that should be retrieved (check #DrmAttribute)
   528     \param attributeValues On success fills this list whith values, where each value is QVariant of the integer or string type.
   668     \param attributeValues On success fills this list whith values, where each value is QVariant of the integer or string type.
   529                            If attribute value does not exists or other error occurs when reading the attribute, the invalid QVariant
   669                            If attribute value does not exists or other error occurs when reading the attribute, the invalid QVariant
   530                            value is returned.
   670                            value is returned.
   552     return d->getDrmAttributes(file, attributeNames, attributeValues);
   692     return d->getDrmAttributes(file, attributeNames, attributeValues);
   553 }
   693 }
   554 
   694 
   555 /*!
   695 /*!
   556     Checks the status of the given service interface.
   696     Checks the status of the given service interface.
   557     \param implementation Interface which status is being checked.
   697     \param implementation Valid interface descriptor obtained by the list() call.
   558     \return Status of the service.
   698     \return Status of the service.
   559 */
   699 */
   560 XQApplicationManager::ServiceStatus XQApplicationManager::status(const XQAiwInterfaceDescriptor& implementation)
   700 XQApplicationManager::ServiceStatus XQApplicationManager::status(const XQAiwInterfaceDescriptor& implementation)
   561 {
   701 {
   562     XQSERVICE_DEBUG_PRINT("XQApplicationManager::status");
   702     XQSERVICE_DEBUG_PRINT("XQApplicationManager::status");
   563     return (ServiceStatus)d->status(implementation);
   703     return (ServiceStatus)d->status(implementation);
   564 }
   704 }
   565 
   705 
   566 
   706 /*!
       
   707     Start monitoring for given service.
       
   708     \param implementation Valid interface descriptor obtained by the list() call.
       
   709     \return True if operation succesful, false otherwise.
       
   710 */
       
   711 bool XQApplicationManager::notifyRunning(XQAiwInterfaceDescriptor& serviceImplDescriptor)
       
   712 {
       
   713     XQSERVICE_DEBUG_PRINT("XQApplicationManager::notifyRunning");
       
   714     return d->startNotifications(serviceImplDescriptor);
       
   715 }
       
   716 
       
   717 /*!
       
   718     Stop monitoring for given service.
       
   719     \param implementation Valid interface descriptor obtained by the list() call.
       
   720     \return True if operation succesful, false otherwise.
       
   721 */
       
   722 bool XQApplicationManager::cancelNotifyRunning(XQAiwInterfaceDescriptor& serviceImplDescriptor)
       
   723 {
       
   724     XQSERVICE_DEBUG_PRINT("XQApplicationManager::cancelNotifyRunning");
       
   725     return d->stopNotifications(serviceImplDescriptor);
       
   726 }
       
   727