iaupdate/IAD/api/client/inc/iaupdateclient.h
changeset 29 26b6f0522fd8
parent 0 ba25891c3a9e
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 
    19 
    20 #ifndef IA_UPDATE_CLIENT_H
    20 #ifndef IA_UPDATE_CLIENT_H
    21 #define IA_UPDATE_CLIENT_H
    21 #define IA_UPDATE_CLIENT_H
    22 
    22 
    23 #include <AknServerApp.h> 
    23 
    24 #include <e32std.h>
    24 #include <e32std.h>
    25 #include <e32cmn.h>
    25 #include <e32cmn.h>
       
    26 #include <iaupdateobserver.h>
       
    27 #include <QObject>
    26 
    28 
    27 class CIAUpdateParameters;
    29 class CIAUpdateParameters;
    28 
    30 class MIAUpdateObserver;
    29 /**
    31 class XQServiceRequest;
    30  * RIAUpdateClient object provides methods to delegate update actions
       
    31  * to the server side. Updating will be targeted to the update items that 
       
    32  * qualify the requirements of CIAUpdateParameters objects. In asynchronous 
       
    33  * actions, observers will be informed about the completion of update action.
       
    34  * 
       
    35  * Because this object is R-class, it does not provide constructor or destructor.
       
    36  * Usage:
       
    37  * - First, call Open-function.
       
    38  * - Second, use update functions to start update.
       
    39  * - Finally, user has to call Close-function to terminate object. 
       
    40  *   Otherwise, memory leaks may occur.
       
    41  *
       
    42  * @see CIAUpdateParameters
       
    43  * @see CIAUpdate
       
    44  *
       
    45  * @since S60 v3.2
       
    46  */
       
    47 NONSHARABLE_CLASS( RIAUpdateClient ) : public RAknAppServiceBase 
       
    48     {
       
    49 
       
    50 public:
       
    51 
       
    52     /**
       
    53      * Constructor.
       
    54      */
       
    55      
       
    56      RIAUpdateClient();
       
    57 
       
    58     /** 
       
    59      * This function will open the update action.
       
    60      *
       
    61      * @note This has to be called before calling operation functions.
       
    62      *
       
    63      * @return System wide error code.
       
    64      *
       
    65      * @since S60 v3.2
       
    66      */
       
    67     TInt Open( TBool aToBackground );
       
    68     
       
    69     /** 
       
    70      * Close releases the resources allocated by this class object.
       
    71      * After Close is called, this R-class object may go out of scope.
       
    72      *
       
    73      * @note If Close is called before asynchronous operation has finished, 
       
    74      * the operation will continue but callback functions of the observer
       
    75      * will not be called when operation progresses. 
       
    76      * 
       
    77      * @since S60 v3.2
       
    78      */
       
    79     void Close();
       
    80 
    32 
    81 
    33 
    82     /** 
    34 class IAUpdateClient : public QObject
    83      * @see CIAUpdate::CheckUpdates
    35 //NONSHARABLE_CLASS( IAUpdateClient ) : public QObject
    84      *
    36     {
    85      * @note The client server connection has to be opened by calling
    37     Q_OBJECT
    86      * Open function before this function can be called.
    38 public:
    87      *
       
    88      * @param aAvailableUpdates Number of the updates that were found available.
       
    89      * @param aStatus The status will be updated when the operation
       
    90      * has been completed.
       
    91      * @return Informs if the initialization of server request failed.
       
    92      *         System wide error code. 
       
    93      *
       
    94      * @since S60 v3.2
       
    95      */
       
    96     TInt CheckUpdates( const CIAUpdateParameters& aUpdateParameters,
       
    97                        TInt& aAvailableUpdates,
       
    98                        TRequestStatus& aStatus );
       
    99     
    39     
       
    40     enum RequestType
       
    41         {
       
    42         /**
       
    43         * No operation is going on.
       
    44         */ 
       
    45         NoOperation,       
       
    46             
       
    47         /**
       
    48         * Update check has been requested.
       
    49         */
       
    50         CheckUpdates,
       
    51 
       
    52         /**
       
    53         * Show Update operation has been requested.
       
    54         */
       
    55         ShowUpdates,     
       
    56             
       
    57         /**
       
    58         * Update query has been requested.
       
    59         */
       
    60         UpdateQuery,
       
    61         /**
       
    62         * Bring to foreground has been requested.
       
    63         */
       
    64         BroughtToForeground
       
    65         };
       
    66 
       
    67     IAUpdateClient(MIAUpdateObserver& aObserver);
       
    68      
       
    69      
       
    70     ~IAUpdateClient();
       
    71 
       
    72     int initRequest(const CIAUpdateParameters* updateParameters, const QString& message, bool toBackground);
       
    73 
       
    74     void checkUpdates(const CIAUpdateParameters& updateParameters);
       
    75 
       
    76     void showUpdates(const CIAUpdateParameters& updateParameters);
       
    77 
       
    78     void updateQuery();
       
    79     
       
    80     void update();
   100         
    81         
   101     /** 
    82     void broughtToForeground();
   102      * @see CIAUpdate::ShowUpdates
    83 
   103      *
    84 protected slots:
   104      * @note The client server connection has to be opened by calling
    85 
   105      * Open function before this function can be called.
    86     void requestCompleted(const QVariant& value);
   106      *
       
   107      * @param aNumberOfSuccessfullUpdates Number of the successfull updates 
       
   108      *                                    that were done during the update.
       
   109      * @param aNumberOfFailedUpdates Number of the failed updates 
       
   110      *                               that were done during the update.
       
   111      * @param aNumberOfCancelledUpdates Number of the cancelled updates 
       
   112      *                                  during the update.     
       
   113      * @param aStatus The status will be updated when the operation
       
   114      * has been completed.
       
   115      * @return Informs if the initialization of server request failed.
       
   116      *         System wide error code. 
       
   117      *
       
   118      * @since S60 v3.2
       
   119      */
       
   120     TInt ShowUpdates( const CIAUpdateParameters& aUpdateParameters,
       
   121                       TInt& aNumberOfSuccessfullUpdates,
       
   122                       TInt& aNumberOfFailedUpdates,
       
   123                       TInt& aNumberOfCancelledUpdates,
       
   124                       TRequestStatus& aStatus );
       
   125     
    87     
   126 
    88     void requestError(int err);     
   127         
       
   128                  
       
   129     /** 
       
   130      * @see CIAUpdate::Update
       
   131      *
       
   132      * @note The client server connection has to be opened by calling
       
   133      * Open function before this function can be called.
       
   134      *
       
   135      * @param aUpdateNow  Value depending on a user's choice
       
   136      * @param aStatus The status will be updated when the operation
       
   137      * has been completed.
       
   138      * @return Informs if the initialization of server request failed.
       
   139      *         System wide error code. 
       
   140      *
       
   141      * @since S60 v3.2
       
   142      */
       
   143     TInt UpdateQuery( TBool& aUpdateNow, TRequestStatus& aStatus );
       
   144                       
       
   145     
       
   146     void BroughtToForeground();
       
   147     
       
   148     
       
   149     /**
       
   150      * Cancels the ongoing asynchronous operation.
       
   151      * The active object that has started the update operation
       
   152      * will be informed when the requested update operation 
       
   153      * has been cancelled.
       
   154      *
       
   155      * @since S60 v3.2
       
   156      */             
       
   157     void CancelAsyncRequest();
       
   158 
       
   159 
       
   160 public: // RAknAppServiceBase
       
   161 
       
   162     /**
       
   163      * @see RAknAppServiceBase::ServiceUid
       
   164      *
       
   165      * @since S60 v3.2
       
   166      */
       
   167     TUid ServiceUid() const;
       
   168 
    89 
   169 
    90 
   170 private:
    91 private:
       
    92      
       
    93     QString qStringFromTDesC16( const TDesC16& aDes16 ); 
       
    94      
       
    95     QString qStringFromTDesC8( const TDesC8& aDes8 );
       
    96      
       
    97     QString qStringFromTDesC( const TDesC& aDes );
   171 
    98 
   172     // These functions send the operation requests to the server.
       
   173     
       
   174     TInt SendCheckUpdatesRequest( TInt aUpdateFunction,
       
   175                                   const CIAUpdateParameters& aUpdateParameters,
       
   176                                   TInt& aCount,
       
   177                                   TRequestStatus& aStatus );
       
   178 
       
   179     TInt SendUpdateRequest( TInt aUpdateFunction,
       
   180                             const CIAUpdateParameters& aUpdateParameters,
       
   181                             TInt& aNumberOfSuccessfullUpdates,
       
   182                             TInt& aNumberOfFailedUdpdates,
       
   183                             TInt& aNumberOfCancelledUpdates,
       
   184                             TRequestStatus& aStatus );
       
   185     
       
   186     void ConnectNewAppToBackgroundL( TUid aAppUid );
       
   187     
       
   188     void ServerName(TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator);
       
   189     
       
   190     TUint GenerateServerDifferentiatorAndName(TName& aServerName, TUid aAppServerUid);
       
   191     
       
   192                                
    99                                
   193 private: //data
   100 private: //data
   194 
       
   195     HBufC8* iData;
       
   196     
   101     
   197     TBool iConnected;
   102     XQServiceRequest* mServiceRequest;
   198     
   103     
   199     TInt iOwnWgId;
   104     // Informs what kind of operation is going on.
       
   105     RequestType mCurrentRequestType;
   200     
   106     
   201     TPtr8 iPtr1;
   107     // Observer who will be informed about the completion of the operations. 
   202     TPtr8 iPtr2;
   108     MIAUpdateObserver& mObserver; 
   203     TPtr8 iPtr3;  
   109          
   204     };
   110     };
   205 
   111 
   206 #endif // IA_UPDATE_CLIENT_H
   112 #endif // IA_UPDATE_CLIENT_H