iaupdate/IAD/api/client/inc/iaupdateclient.h
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
    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 
    23 #include <AknServerApp.h> 
    24 #include <e32std.h>
    24 #include <e32std.h>
    25 #include <e32cmn.h>
    25 #include <e32cmn.h>
    26 #include <iaupdateobserver.h>
       
    27 #include <QObject>
       
    28 
    26 
    29 class CIAUpdateParameters;
    27 class CIAUpdateParameters;
    30 class MIAUpdateObserver;
    28 
    31 class XQServiceRequest;
    29 /**
    32 
    30  * RIAUpdateClient object provides methods to delegate update actions
    33 
    31  * to the server side. Updating will be targeted to the update items that 
    34 class IAUpdateClient : public QObject
    32  * qualify the requirements of CIAUpdateParameters objects. In asynchronous 
    35 //NONSHARABLE_CLASS( IAUpdateClient ) : public QObject
    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 
    36     {
    48     {
    37     Q_OBJECT
    49 
    38 public:
    50 public:
    39     
    51 
    40     enum RequestType
    52     /**
    41         {
    53      * Constructor.
    42         /**
    54      */
    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      
    55      
    69      
    56      RIAUpdateClient();
    70     ~IAUpdateClient();
    57 
    71 
    58     /** 
    72     int initRequest(const CIAUpdateParameters* updateParameters, const QString& message, bool toBackground);
    59      * This function will open the update action.
    73 
    60      *
    74     void checkUpdates(const CIAUpdateParameters& updateParameters);
    61      * @note This has to be called before calling operation functions.
    75 
    62      *
    76     void showUpdates(const CIAUpdateParameters& updateParameters);
    63      * @return System wide error code.
    77 
    64      *
    78     void updateQuery();
    65      * @since S60 v3.2
    79     
    66      */
    80     void update();
    67     TInt Open();
       
    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     TInt OpenToBackroundAsync( TRequestStatus& aStatus );
       
    80 
       
    81     TInt ConnectToApp();
       
    82    
       
    83     void Close();
       
    84 
       
    85 
       
    86     /** 
       
    87      * @see CIAUpdate::CheckUpdates
       
    88      *
       
    89      * @note The client server connection has to be opened by calling
       
    90      * Open function before this function can be called.
       
    91      *
       
    92      * @param aAvailableUpdates Number of the updates that were found available.
       
    93      * @param aStatus The status will be updated when the operation
       
    94      * has been completed.
       
    95      * @return Informs if the initialization of server request failed.
       
    96      *         System wide error code. 
       
    97      *
       
    98      * @since S60 v3.2
       
    99      */
       
   100     TInt CheckUpdates( const CIAUpdateParameters& aUpdateParameters,
       
   101                        TInt& aAvailableUpdates,
       
   102                        TRequestStatus& aStatus );
       
   103     
    81         
   104         
    82     void broughtToForeground();
   105     /** 
    83 
   106      * @see CIAUpdate::ShowUpdates
    84 protected slots:
   107      *
    85 
   108      * @note The client server connection has to be opened by calling
    86     void requestCompleted(const QVariant& value);
   109      * Open function before this function can be called.
    87     
   110      *
    88     void requestError(int err);     
   111      * @param aNumberOfSuccessfullUpdates Number of the successfull updates 
       
   112      *                                    that were done during the update.
       
   113      * @param aNumberOfFailedUpdates Number of the failed updates 
       
   114      *                               that were done during the update.
       
   115      * @param aNumberOfCancelledUpdates Number of the cancelled updates 
       
   116      *                                  during the update.     
       
   117      * @param aStatus The status will be updated when the operation
       
   118      * has been completed.
       
   119      * @return Informs if the initialization of server request failed.
       
   120      *         System wide error code. 
       
   121      *
       
   122      * @since S60 v3.2
       
   123      */
       
   124     TInt ShowUpdates( const CIAUpdateParameters& aUpdateParameters,
       
   125                       TInt& aNumberOfSuccessfullUpdates,
       
   126                       TInt& aNumberOfFailedUpdates,
       
   127                       TInt& aNumberOfCancelledUpdates,
       
   128                       TRequestStatus& aStatus );
       
   129     
       
   130 
       
   131         
       
   132                  
       
   133     /** 
       
   134      * @see CIAUpdate::Update
       
   135      *
       
   136      * @note The client server connection has to be opened by calling
       
   137      * Open function before this function can be called.
       
   138      *
       
   139      * @param aUpdateNow  Value depending on a user's choice
       
   140      * @param aStatus The status will be updated when the operation
       
   141      * has been completed.
       
   142      * @return Informs if the initialization of server request failed.
       
   143      *         System wide error code. 
       
   144      *
       
   145      * @since S60 v3.2
       
   146      */
       
   147     TInt UpdateQuery( TBool& aUpdateNow, TRequestStatus& aStatus );
       
   148                       
       
   149     
       
   150     void BroughtToForeground();
       
   151     
       
   152     
       
   153     /**
       
   154      * Cancels the ongoing asynchronous operation.
       
   155      * The active object that has started the update operation
       
   156      * will be informed when the requested update operation 
       
   157      * has been cancelled.
       
   158      *
       
   159      * @since S60 v3.2
       
   160      */             
       
   161     void CancelAsyncRequest();
       
   162 
       
   163 
       
   164 public: // RAknAppServiceBase
       
   165 
       
   166     /**
       
   167      * @see RAknAppServiceBase::ServiceUid
       
   168      *
       
   169      * @since S60 v3.2
       
   170      */
       
   171     TUid ServiceUid() const;
    89 
   172 
    90 
   173 
    91 private:
   174 private:
    92      
   175     
    93     QString qStringFromTDesC16( const TDesC16& aDes16 ); 
   176     // These functions send the operation requests to the server.
    94      
   177     
    95     QString qStringFromTDesC8( const TDesC8& aDes8 );
   178     TInt SendCheckUpdatesRequest( TInt aUpdateFunction,
    96      
   179                                   const CIAUpdateParameters& aUpdateParameters,
    97     QString qStringFromTDesC( const TDesC& aDes );
   180                                   TInt& aCount,
    98 
   181                                   TRequestStatus& aStatus );
       
   182 
       
   183     TInt SendUpdateRequest( TInt aUpdateFunction,
       
   184                             const CIAUpdateParameters& aUpdateParameters,
       
   185                             TInt& aNumberOfSuccessfullUpdates,
       
   186                             TInt& aNumberOfFailedUdpdates,
       
   187                             TInt& aNumberOfCancelledUpdates,
       
   188                             TRequestStatus& aStatus );
       
   189     
       
   190     void ConnectNewAppToBackgroundL( TUid aAppUid );
       
   191     
       
   192     void StartNewAppToBackgroundL( TUid aAppUid, TRequestStatus& aStatus ); 
       
   193     
       
   194     void ServerName(TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator);
       
   195     
       
   196     TUint GenerateServerDifferentiatorAndName(TName& aServerName, TUid aAppServerUid);
       
   197     
    99                                
   198                                
   100 private: //data
   199 private: //data
   101     
   200 
   102     XQServiceRequest* mServiceRequest;
   201     HBufC8* iData;
   103     
   202     
   104     // Informs what kind of operation is going on.
   203     TBool iConnected;
   105     RequestType mCurrentRequestType;
   204     
   106     
   205     TInt iOwnWgId;
   107     // Observer who will be informed about the completion of the operations. 
   206     
   108     MIAUpdateObserver& mObserver; 
   207     TUint iDifferentiator;
   109          
   208     
       
   209     TPtr8 iPtr1;
       
   210     TPtr8 iPtr2;
       
   211     TPtr8 iPtr3;  
   110     };
   212     };
   111 
   213 
   112 #endif // IA_UPDATE_CLIENT_H
   214 #endif // IA_UPDATE_CLIENT_H