omadm/omadmappui/inc/NSmlDMSyncHandler.h
changeset 0 3ce708148e4d
child 8 0a8136f75056
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Synchronization handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NSMLDMSYNCHANDLER_H
       
    20 #define NSMLDMSYNCHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <AknProgressDialog.h>
       
    25 #include <SyncMLObservers.h>
       
    26 #include "NSmlDMProgress.h"
       
    27 #include "NSmlDMSyncUtil.h"
       
    28 #include "NSmlDMSyncProfile.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CNSmlDMSyncState;
       
    32 class CNSmlDMActiveCaller;
       
    33 class CEikonEnv;
       
    34 class CNSmlDMSyncDocument;
       
    35 class CAknWaitDialog;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 * CNSmlDMSyncHandler class
       
    41 * 
       
    42 */
       
    43 NONSHARABLE_CLASS (CNSmlDMSyncHandler) : public CBase, 
       
    44                         public MNSmlDMProgressDialogObserver,
       
    45 						public MNSmlDMActiveCallerObserver,
       
    46 						public MSyncMLEventObserver,
       
    47 						public MSyncMLProgressObserver,
       
    48 						public MProgressDialogCallback
       
    49 						
       
    50 	{
       
    51     public:
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         */
       
    55 	    static CNSmlDMSyncHandler* NewL( RSyncMLSession* aSyncSession,
       
    56 	                                     CNSmlDMSyncAppEngine* aAppEngine,
       
    57 	                                     CNSmlDMSyncDocument* aSyncDocument );
       
    58 
       
    59 	    /**
       
    60         * Destructor.
       
    61         */
       
    62 	    virtual ~CNSmlDMSyncHandler();
       
    63 
       
    64     private:
       
    65 	    /**
       
    66         * By default Symbian 2nd phase constructor is private.
       
    67         */
       
    68 	    void ConstructL();
       
    69 
       
    70 	    /**
       
    71         * C++ default constructor.
       
    72         */
       
    73 	    CNSmlDMSyncHandler( RSyncMLSession* iSyncSession,
       
    74                             CNSmlDMSyncAppEngine* aAppEngine,
       
    75 	                        CNSmlDMSyncDocument* aSyncDocument );
       
    76 
       
    77 		
       
    78 	private:	
       
    79         /**
       
    80         * From MAspProgressDialogObserver
       
    81     	* Gets called when sync progress dialog closes.
       
    82         * @param aButtonId Button id.
       
    83         * @return None
       
    84         */
       
    85 		void HandleDialogEventL( TInt aButtonId );
       
    86 
       
    87     
       
    88 	private: // from MAspActiveCallerObserver
       
    89 		/**
       
    90         * From MAspActiveCallerObserver
       
    91 		* Called when CAspActiveCaller completes.
       
    92         * @param None
       
    93         * @return None.
       
    94         */
       
    95 		void HandleActiveCallL();
       
    96 
       
    97 
       
    98     private:    // from MSyncMLEventObserver
       
    99         
       
   100 		/**
       
   101         * From MSyncMLEventObserver
       
   102 		* Called when SyncML session events oocur.
       
   103         * @param aEvent Sync event
       
   104         * @param aIdentifier Identifier for the sync event
       
   105         * @param aError Synce event error
       
   106         * @param aAdditionalData.
       
   107         * @return None.
       
   108         */
       
   109         void OnSyncMLSessionEvent( TEvent aEvent,
       
   110                                    TInt aIdentifier,
       
   111                                    TInt aError,
       
   112                                    TInt aAdditionalData );
       
   113 	
       
   114 	
       
   115     private:  //from MSyncMLProgressObserver
       
   116 	    
       
   117 	    /**
       
   118 	    * Receives notification of a synchronisation error.
       
   119         * @param aErrorLevel  The error level.
       
   120 	    * @param aError		  The type of error. This is one of 
       
   121 	    *                     the SyncMLError error values.	
       
   122 	    * @param aTaskId      The ID of the task for which the error occurred.
       
   123 	    * @param aInfo1       An integer that can contain additional
       
   124 	    *                     information about the error. Normally 0.
       
   125 	    * @param aInfo2       An integer that can contain additional
       
   126 	    *                     information about the error. Normally 0.
       
   127 	    * @return             None.
       
   128 	    */
       
   129 	    void OnSyncMLSyncError( TErrorLevel aErrorLevel,
       
   130 	                            TInt aError,
       
   131 	                            TInt aTaskId,
       
   132 	                            TInt aInfo1,
       
   133 	                            TInt aInfo2 );
       
   134        	
       
   135        	/**
       
   136 	    * Receives notification of synchronisation progress.
       
   137 	    * @param aStatus	The current status, e.g. 'Connecting'.
       
   138 	    * @param aInfo1	    An integer that can contain additional
       
   139 	    *                   information about the progress.
       
   140 	    * @param aInfo2	    An integer that can contain additional
       
   141         *                   information about the progress.
       
   142 	    */
       
   143 	    void OnSyncMLSyncProgress( TStatus aStatus, TInt aInfo1, TInt aInfo2);
       
   144 	    
       
   145 	    /**
       
   146 	    * Receives notification of modifications to synchronisation tasks.
       
   147         * @param aTaskId               The ID of the task.
       
   148 	    * @param aClientModifications  Modifications made on 
       
   149 	    *                              the clients Data Store.
       
   150 	    * @param aServerModifications  Modifications made on
       
   151 	    *                              the server Data Store.
       
   152 	    */
       
   153 	    void OnSyncMLDataSyncModifications( 
       
   154 	                TInt /*aTaskId*/,
       
   155 	                const TSyncMLDataSyncModifications& aClientModifications,
       
   156 	                const TSyncMLDataSyncModifications& aServerModifications );
       
   157         
       
   158 	private:
       
   159 
       
   160         /**
       
   161         * Shows error dialog.
       
   162 		* @param None.
       
   163         * @return Error code.
       
   164         */
       
   165         void HandleSyncErrorL();
       
   166         
       
   167         /**
       
   168         * Called when sync completes
       
   169 		* @param aError.
       
   170         * @return None.
       
   171         */        
       
   172         void SynchronizeCompletedL(TInt aError);
       
   173 
       
   174         /**
       
   175         * Gets sync error text.
       
   176 		* @param aError.
       
   177         * @return Error text.
       
   178         */
       
   179         void GetErrorText( TDes& aErrorText,
       
   180                            TInt aErrorCode,
       
   181                            TInt aTransport );
       
   182         
       
   183         /**
       
   184         * Read sync error from CNSmlSyncLog and show error message.
       
   185 		* @param aProfileId Profile id.
       
   186         * @return Result code.
       
   187         */
       
   188 		TInt HandleSyncErrorL(TInt aProfileId);
       
   189 
       
   190         /**
       
   191         * Set synchronisation error message text.
       
   192 		* @param aError Error code.
       
   193 		* @param aMsg Error text.
       
   194         * @return None.
       
   195         */
       
   196 		void SetErrorMessageL(TInt aError, TDes& aMsg);
       
   197 	
       
   198 	
       
   199 	public:
       
   200         /**
       
   201         * Performs synchronization.
       
   202         * @param aServerName Name of the server
       
   203 		* @param aProfileId Profile identifier.
       
   204 		* @param aConnectionBearer Bearer
       
   205 		* @param aUseFotaProgressNote Should the simplified progress note used. Only
       
   206 		*                             used when checking for firmware updates.
       
   207         * @return None
       
   208         */
       
   209 		void SynchronizeL( TDesC& aServerName,
       
   210 		                   const TInt aProfileId,
       
   211 		                   const TInt aConnectionBearer,
       
   212                            const TBool aUseFotaProgressNote );
       
   213 		
       
   214         /**
       
   215         * Performs ServerInitiated synchronization.
       
   216         * @param aServerName Name of the server
       
   217 		* @param aProfileId Profile id
       
   218 		* @param aJobId Job id.
       
   219 		* @param aConnectionBearer Bearer
       
   220 		* @param aUseFotaProgressNote Should the simplified progress note used. Only
       
   221 		*                             used when checking for firmware updates.
       
   222         * @return None
       
   223         */		
       
   224 		void SynchronizeL( TDesC& aServerName, 
       
   225 		                   const TInt aProfileId,
       
   226 		                   const TInt aJobId,
       
   227 		                   const TInt aConnectionBearer,
       
   228                            const TBool aUseFotaProgressNote );
       
   229 		
       
   230         /**
       
   231         * Shows the progress dialog.
       
   232 		* @param None.
       
   233         * @return None.
       
   234         */
       
   235         void ShowProgressDialogL();
       
   236 
       
   237         /**
       
   238         * Deletes the progress dialog if it exists.
       
   239 		* @param None.
       
   240         * @return None.
       
   241         */
       
   242         void HideProgressDialogL();
       
   243         
       
   244 		/**
       
   245         * Cancel synchronization.
       
   246 		* @param None 
       
   247         * @return None
       
   248         */
       
   249 		void CancelSynchronizeL();
       
   250 		
       
   251         /**
       
   252         * From MProgressDialogCallback. Handles the situation when the dialog
       
   253         * is dismissed.
       
   254         * @param aButtonId The identifier of the button, with which the dialog
       
   255         *                  was dismissed.
       
   256         * @return None
       
   257         */
       
   258         void DialogDismissedL( TInt aButtonId );
       
   259 		
       
   260 	private:
       
   261         
       
   262         /**
       
   263         * Performs synchronization.
       
   264         * @return None
       
   265         */	
       
   266 		void SynchronizeL();
       
   267 		
       
   268 		/**
       
   269         * Utility function.
       
   270         * @return Sync session.
       
   271         */
       
   272 		RSyncMLSession& Session();
       
   273 		
       
   274 		/**
       
   275         * Utility function.
       
   276         * @return Progress dialog.
       
   277         */
       
   278 		CNSmlDMProgressDialog* Dialog();
       
   279 
       
   280 		/**
       
   281         * Utility function.
       
   282         * @return Sync state.
       
   283         */
       
   284 		CNSmlDMSyncState* State();
       
   285 
       
   286     public:
       
   287 
       
   288 		/**
       
   289         * Utility function.
       
   290         * @return ETrue if sync is currently running, EFalse otherwise.
       
   291         */
       
   292 		TBool SyncRunning();
       
   293 
       
   294     private:
       
   295     
       
   296 		/**
       
   297         * Checks the progress state and returns a corresponding
       
   298         * dialog text string.
       
   299         * @param Reference to the descriptor where the result is stored.
       
   300     	* @return None.
       
   301         */
       
   302         void GetStatusDialogTextL( TDes& aBuffer );
       
   303     
       
   304 		/**
       
   305         * Updates progress dialog.
       
   306         * @param None.
       
   307     	* @return None.
       
   308         */
       
   309 		void UpdateDialogL();
       
   310 
       
   311 		/**
       
   312         * Utility function.
       
   313         * @param aText text to show
       
   314         * @param aResourceId resource id
       
   315         * @return None.
       
   316         */
       
   317         void ReadL( TDes& aText, TInt aResourceId );
       
   318 
       
   319 		/**
       
   320         * Utility function.
       
   321         * @param aText text to show
       
   322         * @param aContent 
       
   323         * @param aCurrent Progress phase
       
   324         * @param aFinal Progress phase
       
   325         * @param aPhase Progress phase
       
   326         * @return None.
       
   327         */
       
   328         void ReadProgressTextL( TDes& aText,
       
   329                                 const TDesC& aContent,
       
   330                                 TInt aCurrent,
       
   331                                 TInt aFinal,
       
   332                                 TInt aPhase );
       
   333 
       
   334     private:
       
   335 		// session with sync server
       
   336 		RSyncMLSession*                 iSyncSession;
       
   337 		// app engine
       
   338 		CNSmlDMSyncAppEngine*           iSyncAppEngine;
       
   339         // Pointer to the application document class
       
   340         CNSmlDMSyncDocument*            iSyncDocument;
       
   341 		// profile id
       
   342 		TInt                            iProfileId;
       
   343 		// sync job id
       
   344 		TInt                            iSyncJobId;
       
   345 		// sync job
       
   346 		RSyncMLDevManJob                iSyncJob;
       
   347 		// shows sync progress dialog
       
   348 		CNSmlDMProgressDialog*          iProgressDialog;
       
   349 				
       
   350         // The alternative wait dialog used in FOTA
       
   351         CAknWaitDialog*                 iWaitDialog;
       
   352          
       
   353         // The progress wait dialog used for any session from main view
       
   354         CNSmlDMProgressDialog*          iFotaProgressDialog;
       
   355         
       
   356         // CheckUpdate state shown or Not
       
   357         TBool iCheckUpdate;
       
   358                         
       
   359 		// sync handler state
       
   360 		CNSmlDMSyncState*               iState;
       
   361 		// for making function call via active scheduler
       
   362 		CNSmlDMActiveCaller*            iActiveCaller;
       
   363 		// is sync currently running
       
   364 		TBool                           iSyncRunning;
       
   365 		// sync error code
       
   366 		TInt                            iSyncError;
       
   367 		// long buffer for string handling
       
   368 		TBuf<KBufSize256>               iBuf;
       
   369 		//Job id
       
   370         TSmlJobId                       iJobId;
       
   371         // Bearer
       
   372         TInt                            iConnectionBearer;
       
   373         // Server name
       
   374         TBuf<KNSmlMaxProfileNameLength> iServerName;
       
   375         // Server sync
       
   376         TBool                           iServerAlertedSync;
       
   377         // Should the simpler FOTA progress not be used
       
   378         TBool                           iUseFotaProgressNote;
       
   379         // Retry sync (authentication error)
       
   380         TBool							iRetrySync;
       
   381           // Variable to show whether in fotaview or not        
       
   382         TInt  iNotinFotaView;
       
   383         
       
   384         // Identifies Fota progress note launched or not
       
   385         TBool iFotaProgressLaunched;
       
   386 	};
       
   387 
       
   388 #endif  // NSMLDMSYNCHANDLER_H
       
   389 
       
   390 // End of file