omaprovisioning/provisioning/ProvisioningBC/Inc/CWPSaver.h
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Settings saver with progress note.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CWPSAVER_H
       
    20 #define CWPSAVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <AknProgressDialog.h>
       
    24 #include <ActiveApDb.h>
       
    25 #include <favouritesdbobserver.h>
       
    26 #include <favouritesdb.h>
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CWPEngine;
       
    31 class CActiveFavouritesDbNotifier;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36  * Helper class for saving Provisioning settings. Provides a progress note.
       
    37  * @since 2.0
       
    38  */
       
    39 class CWPSaver : public CActive, 
       
    40                  private MProgressDialogCallback,
       
    41                  private MActiveApDbObserver, 
       
    42                  private MFavouritesDbObserver
       
    43     {
       
    44     public:
       
    45         /**
       
    46         * C++ default constructor.
       
    47         * @param aEngine Engine to be used for saving
       
    48         * @param aSetAsDefault EFalse => call CWPEngine::SaveL, ETrue
       
    49         *        => call CWPEngine::SetAsDefaultL
       
    50         */
       
    51         CWPSaver( CWPEngine& aEngine, TBool aSetAsDefault );
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         virtual ~CWPSaver();
       
    57 
       
    58     public:
       
    59         /**
       
    60         * Prepares the object for saving.
       
    61         */
       
    62         void PrepareLC();
       
    63 
       
    64         /**
       
    65         * Executes save with a progress note. Ownership of the
       
    66         * CWPSaver object is transferred.
       
    67         * @param aNumSaved When returns, contains number of settings saved.
       
    68         * @return Status code. >= 0 if saving was completed
       
    69         */
       
    70         TInt ExecuteLD( TInt& aNumSaved );
       
    71 
       
    72         TInt GetNumAccessDenied();
       
    73         void SetNumAccessDenied(TInt aNumAccessDenied );
       
    74     protected: // From CActive
       
    75 
       
    76         void DoCancel();
       
    77         void RunL();
       
    78         TInt RunError( TInt aError );
       
    79 
       
    80     private: // From MProgressDialogCallback
       
    81 
       
    82         void DialogDismissedL( TInt aButtonId );
       
    83 
       
    84     private: // from MActiveApDbObserver
       
    85 
       
    86         void HandleApDbEventL( TEvent anEvent );
       
    87 
       
    88     private: // from MFavouritesDbObserver
       
    89 
       
    90         void HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent );
       
    91 
       
    92     private:
       
    93         /**
       
    94         * Complete the request so that RunL() gets called.
       
    95         */
       
    96         void CompleteRequest();
       
    97 
       
    98         /**
       
    99         * Complete the request so that Timeout() gets called after
       
   100         * a delay. Leaves with KErrTimeout if retry count is 
       
   101         * exceeded.
       
   102         */
       
   103         void DelayedCompleteRequestL();
       
   104 
       
   105         /**
       
   106         * Retry save now.
       
   107         */
       
   108         void Retry();
       
   109 
       
   110         /**
       
   111         * Timer timed-out.
       
   112         */
       
   113         static TInt Timeout(TAny* aSelf);
       
   114 
       
   115     private:
       
   116         /// The engine used for performing the save. Refs.
       
   117         CWPEngine& iEngine;
       
   118 
       
   119         /// ETrue if setting as default
       
   120         TBool iSetAsDefault;
       
   121 
       
   122         /// The progress dialog. Owns.
       
   123         CAknProgressDialog* iDialog;
       
   124 
       
   125         /// The item to be saved next
       
   126         TInt iCurrentItem;
       
   127 
       
   128         /// Contains result to be passed to the called of ExecuteLD
       
   129         TInt iResult;
       
   130 
       
   131         /// Active AP database. Owns.
       
   132         CActiveApDb* iApDbNotifier;
       
   133 
       
   134         /// Active Favourites Database. Owns.
       
   135         CActiveFavouritesDbNotifier* iFavouritesNotifier;
       
   136 
       
   137         /// Contains ETrue if commsdb is being waited on
       
   138         TBool iWaitCommsDb;
       
   139 
       
   140         /// Contains ETrue if favourites db is being waited on
       
   141         TBool iWaitFavourites;
       
   142 
       
   143         /// Active scheduler.
       
   144         CActiveSchedulerWait iWait;
       
   145 
       
   146         /// Timer for retry. Owns.
       
   147         CPeriodic* iRetryTimer;
       
   148 
       
   149         /// Retry counter
       
   150         TInt iRetryCount;
       
   151         
       
   152         RFavouritesDb       iBookmarkDb;
       
   153         RFavouritesSession  iSession;       
       
   154    	TInt iNumAccessDenied;
       
   155     };
       
   156 
       
   157 
       
   158 #endif // CWPSAVER_H
       
   159 
       
   160 // End of File