secsrv_plat/provisioning_api/inc/ProvSC.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Reads provisioning information from Smart Card 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PROVSC_H
       
    20 #define PROVSC_H
       
    21 
       
    22 //INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 
       
    26 //FORWARD DECLARATIONS
       
    27 class RWimCertMgmt;
       
    28 class RWimMgmt;
       
    29 
       
    30 
       
    31 //TYPE DEFINITIONS
       
    32 enum TOMAType
       
    33     {
       
    34     EBootStrap,
       
    35     EConfig1,
       
    36     EConfig2
       
    37     };
       
    38 
       
    39 
       
    40 /**
       
    41 *  Reads OMA Provisioning information from Smart Card
       
    42 *
       
    43 *  @lib WimClient
       
    44 *  @since Series60 2.6
       
    45 */
       
    46 class CWimOMAProv : public CActive
       
    47     {
       
    48     public:
       
    49 
       
    50         /**
       
    51         * Two-phased constructor.
       
    52         */
       
    53         IMPORT_C static CWimOMAProv* NewL();
       
    54 
       
    55         /**
       
    56         * Destructor
       
    57         */
       
    58         IMPORT_C virtual ~CWimOMAProv();
       
    59         
       
    60         /**
       
    61         * Initializes the WIM Server cache. This is the most time consuming call. 
       
    62         * @param  aStatus  Indicates the result of this call. Values:
       
    63         *         KErrNone, call was successull
       
    64         *         KErrNotFound, no WIM was found
       
    65         *         KErrNoMemory, no memory
       
    66         *         KErrGeneral, any other error
       
    67         * @return void
       
    68         */
       
    69         IMPORT_C void Initialize( TRequestStatus& aStatus );
       
    70 
       
    71         /** 
       
    72         * Cancels outgoing Initialize operation. 
       
    73         * @return void
       
    74         */
       
    75         IMPORT_C void CancelInitialize();
       
    76 
       
    77         /**
       
    78         * Fetches the size of provisioning information string. 
       
    79         * This information can be used as a notification, does provisioning 
       
    80         * information exist. If the size is not included in Smart Card's
       
    81         * DODF-PROV file then the full length of the file containing the 
       
    82         * provisioning information is returned.
       
    83         * @param  aSize (OUT) The length of provisioning string
       
    84         * @param  aOMAType (IN) OMA provisioning file type 
       
    85         *         Pseudo values:
       
    86         *         -Bootstrap
       
    87         *         -Config 1
       
    88         *         -Config 2
       
    89         * @param  aStatus  Indicates the result of this call.
       
    90         *         KErrNone, no errors. NOTE: size can still be 0 indicating
       
    91         *                   that no provisioning information was found.
       
    92         *                   If aSize > 0 it means that provisioning information
       
    93         *                   was found.
       
    94         *         KErrNoMemory, No memory
       
    95         *         KErrGeneral, any other error
       
    96         * @return void
       
    97         */
       
    98         IMPORT_C void GetSize( TInt& aSize,
       
    99                                const TOMAType& aOMAType,
       
   100                                TRequestStatus& aStatus );
       
   101 
       
   102         /** 
       
   103         * Cancels outgoing GetSize operation.
       
   104         * @return void
       
   105         */
       
   106         IMPORT_C void CancelGetSize();
       
   107 
       
   108         /**
       
   109         * Fetches the whole data of provisioning information string. 
       
   110         * @param  aOMAType (IN) The type of provisioning string
       
   111         * @param  aOMAData (OUT) provisioning  binary data
       
   112         * @param  aStatus  Indicates the result of this call.
       
   113         *         KErrNone, no errors.
       
   114         *         KErrNoMemory, No memory
       
   115         *         KErrGeneral, any other error
       
   116         * @return void
       
   117         */
       
   118         IMPORT_C void Retrieve( const TOMAType& aOMAType, 
       
   119                                 TDes8& aOMAData,
       
   120                                 TRequestStatus& aStatus );
       
   121 
       
   122         /** 
       
   123         * Cancels outgoing Retrieve operation.
       
   124         * @return void
       
   125         */
       
   126         IMPORT_C void CancelRetrieve();
       
   127 
       
   128     private:
       
   129 
       
   130         /**
       
   131         * Symbian constructor
       
   132         * @return void
       
   133         */
       
   134         void ConstructL();
       
   135 
       
   136         /**
       
   137         * C++ default constructor.
       
   138         */
       
   139         CWimOMAProv();
       
   140 
       
   141     private: //from CActive
       
   142         
       
   143         /**
       
   144         * Different phases are handled here.
       
   145         * @return void
       
   146         */
       
   147         void RunL();
       
   148 
       
   149         /**
       
   150         * Cancellation function
       
   151         * Deallocates member variables and completes client status with
       
   152         * KErrCancel error code.
       
   153         * @return void
       
   154         */
       
   155         void DoCancel();
       
   156 
       
   157         /**
       
   158         * The active scheduler calls this function if this active 
       
   159         * object's RunL() function leaves. 
       
   160         * Handles necessary cleanup and completes request with
       
   161         * received error code.
       
   162         * @param aError -The error code which caused this function call.
       
   163         * @return TInt  -Error code to active scheduler, is always KErrNone.
       
   164         */ 
       
   165         TInt RunError( TInt aError );
       
   166 
       
   167     private:
       
   168 
       
   169         /** 
       
   170         * Sets own iStatus to KRequestPending, and signals it 
       
   171         * with User::RequestComplete() -request. This gives chance 
       
   172         * active scheduler to run other active objects. After a quick
       
   173         * visit in active scheduler, signal returns to RunL() and starts next
       
   174         * phase of operation. 
       
   175         * @return void
       
   176         */
       
   177         void SignalOwnStatusAndComplete();
       
   178 
       
   179         /** 
       
   180         * Allocates memory for member variables, which are needed
       
   181         * in OMA Provisioning struct.
       
   182         * @param aDataLength -The length of the data to be allocated
       
   183         * @return void
       
   184         */
       
   185         void AllocMemoryForOmaProvStructL( const TInt aDataLength );
       
   186 
       
   187         /** 
       
   188         * Deallocates memory from member variables
       
   189         * @return void
       
   190         */
       
   191         void DeallocMemoryFromOmaProvStruct();
       
   192 
       
   193     private:
       
   194 
       
   195         enum TOMAPhase
       
   196             {
       
   197             EInitialize,
       
   198             EConnectClientSession,
       
   199             EInitializeWim,
       
   200             EInitializeDone,
       
   201             EGetSize,
       
   202             EGetSizeDone,
       
   203             ERetrieve,
       
   204             ERetrieveDone
       
   205             };
       
   206 
       
   207         //Indicator for different phases
       
   208         TOMAPhase                       iPhase;
       
   209         
       
   210         //Client status is stored here while operation
       
   211         //on the server side is done.
       
   212         TRequestStatus*                 iClientStatus;
       
   213         
       
   214         //Handle to connection with server. Owned.
       
   215         RWimCertMgmt*                   iConnectionHandle;
       
   216 
       
   217         // Pointer to Client Session. Owned. 
       
   218         RWimMgmt*                       iClientSession;
       
   219         
       
   220         //Informs the type:EBootStrap, EConfig1, EConfig2
       
   221         TOMAType                        iOMAType;
       
   222 
       
   223         //Informs the size of provisioning string. Not owned.
       
   224         TInt*                           iSize;
       
   225         
       
   226         //Descriptor to hold provisioning data. Not owned.
       
   227         TDes8*                          iData;
       
   228 
       
   229         //Buffer to hold provisioning data for server. Owned.
       
   230         HBufC8*                         iOmaProvBuf;
       
   231     
       
   232         //Pointer to iOmaProvBuf. Owned.
       
   233         TPtr8*                          iOmaProvBufPtr;
       
   234         
       
   235         //Flag to indicate errors during WIM -initialization.
       
   236         TInt                            iWimStartErr;
       
   237     };
       
   238 
       
   239 #endif  // PROVSC_H
       
   240 
       
   241 // End of File