|         |      1 /* | 
|         |      2 * Copyright (c) 2009 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: | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18 //INCLUDE FILES | 
|         |     19 #include "WimCertMgmt.h" | 
|         |     20 #include "WimMgmt.h" // To initialize WimServer | 
|         |     21 #include "JavaUtils.h" | 
|         |     22 #include "WimTrace.h" | 
|         |     23  | 
|         |     24  | 
|         |     25 // ----------------------------------------------------------------------------- | 
|         |     26 // CWimJavaUtils::CWimJavaUtils() | 
|         |     27 // Default constructor | 
|         |     28 // ----------------------------------------------------------------------------- | 
|         |     29 // | 
|         |     30 CWimJavaUtils::CWimJavaUtils(): CActive( EPriorityStandard ) | 
|         |     31     { | 
|         |     32     CActiveScheduler::Add( this ); | 
|         |     33     iAuthObjsInfoList = NULL; | 
|         |     34     } | 
|         |     35  | 
|         |     36 // ----------------------------------------------------------------------------- | 
|         |     37 // CWimJavaUtils* CWimJavaUtils::NewL() | 
|         |     38 // Symbian 2 phase construction | 
|         |     39 // ----------------------------------------------------------------------------- | 
|         |     40 // | 
|         |     41 EXPORT_C CWimJavaUtils* CWimJavaUtils::NewL() | 
|         |     42     { | 
|         |     43     CWimJavaUtils* self = new( ELeave ) CWimJavaUtils(); | 
|         |     44     CleanupStack::PushL( self ); | 
|         |     45     self->ConstructL(); | 
|         |     46     CleanupStack::Pop( self ); | 
|         |     47     return self; | 
|         |     48     } | 
|         |     49  | 
|         |     50 // ----------------------------------------------------------------------------- | 
|         |     51 // CWimJavaUtils::ConstructL() | 
|         |     52 // Second phase | 
|         |     53 // ----------------------------------------------------------------------------- | 
|         |     54 // | 
|         |     55 void CWimJavaUtils::ConstructL() | 
|         |     56     { | 
|         |     57     _WIMTRACE ( _L( "CWimJavaUtils::ConstructL" ) );     | 
|         |     58     } | 
|         |     59  | 
|         |     60 // ----------------------------------------------------------------------------- | 
|         |     61 // CWimJavaUtils::~CWimJavaUtils() | 
|         |     62 // Destructor. All allocated memory is released. | 
|         |     63 // ----------------------------------------------------------------------------- | 
|         |     64 // | 
|         |     65 EXPORT_C CWimJavaUtils::~CWimJavaUtils() | 
|         |     66     { | 
|         |     67     _WIMTRACE ( _L( "CWimJavaUtils::~CWimJavaUtils" ) ); | 
|         |     68     Cancel(); | 
|         |     69     DeallocMemoryFromJavaProvStruct(); | 
|         |     70     DeallocMemoryFromPathAndLabel(); | 
|         |     71     if( iConnectionHandle ) | 
|         |     72         { | 
|         |     73         iConnectionHandle->Close(); | 
|         |     74         delete iConnectionHandle; | 
|         |     75         } | 
|         |     76      | 
|         |     77     if ( iClientSession ) | 
|         |     78         { | 
|         |     79         iClientSession->Close(); | 
|         |     80         delete iClientSession; | 
|         |     81         } | 
|         |     82 	if( iAuthObjsInfoList ) | 
|         |     83 		{ | 
|         |     84 		iAuthObjsInfoList->Close(); | 
|         |     85 		delete iAuthObjsInfoList; | 
|         |     86 		} | 
|         |     87 		 | 
|         |     88 	if( iAuthIdList ) | 
|         |     89 	    { | 
|         |     90 		iAuthIdList->Close(); | 
|         |     91 		delete iAuthIdList; | 
|         |     92 	    } | 
|         |     93     } | 
|         |     94  | 
|         |     95 // ----------------------------------------------------------------------------- | 
|         |     96 // CWimJavaUtils::Initialize() | 
|         |     97 // Initializes the WIM server cache. | 
|         |     98 // ----------------------------------------------------------------------------- | 
|         |     99 // | 
|         |    100 EXPORT_C void CWimJavaUtils::Initialize( TRequestStatus& aStatus ) | 
|         |    101     { | 
|         |    102     _WIMTRACE ( _L( "CWimJavaUtils::Initialize" ) ); | 
|         |    103     aStatus = KRequestPending; | 
|         |    104     iClientStatus = &aStatus; | 
|         |    105     iPhase = EInitialize; | 
|         |    106     SignalOwnStatusAndComplete(); | 
|         |    107     } | 
|         |    108  | 
|         |    109 // ----------------------------------------------------------------------------- | 
|         |    110 // CWimJavaUtils::CancelInitialize() | 
|         |    111 // Cancels outgoing Initialize operation. | 
|         |    112 // ----------------------------------------------------------------------------- | 
|         |    113 // | 
|         |    114 EXPORT_C void CWimJavaUtils::CancelInitialize() | 
|         |    115     { | 
|         |    116     _WIMTRACE ( _L( "CWimJavaUtils::CancelInitialize" ) ); | 
|         |    117     Cancel(); | 
|         |    118     } | 
|         |    119  | 
|         |    120 // ----------------------------------------------------------------------------- | 
|         |    121 // CWimJavaUtils::GetACIFSize() | 
|         |    122 // Fetches the size of provisioning information string. This information can | 
|         |    123 // be used as a notification, does provisioning information exist. | 
|         |    124 // ----------------------------------------------------------------------------- | 
|         |    125 // | 
|         |    126 EXPORT_C void CWimJavaUtils::GetACIFSize( TInt& aSize,  | 
|         |    127                                         TRequestStatus& aStatus ) | 
|         |    128     { | 
|         |    129     _WIMTRACE ( _L( "CWimJavaUtils::GetACIFSize" ) ); | 
|         |    130     aStatus = KRequestPending; | 
|         |    131     iClientStatus = &aStatus; | 
|         |    132  | 
|         |    133     if ( !iClientSession || !iConnectionHandle ) | 
|         |    134         { | 
|         |    135         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    136         } | 
|         |    137     else | 
|         |    138         { | 
|         |    139         iSize = &aSize; | 
|         |    140         iPhase = EGetACIFSize; | 
|         |    141         SignalOwnStatusAndComplete(); | 
|         |    142         } | 
|         |    143     } | 
|         |    144  | 
|         |    145  | 
|         |    146 // ----------------------------------------------------------------------------- | 
|         |    147 // CWimJavaUtils::GetACFSize() | 
|         |    148 // aSize ( OUT ) | 
|         |    149 // aACFPath ( IN ) | 
|         |    150 // ----------------------------------------------------------------------------- | 
|         |    151 // | 
|         |    152 EXPORT_C void CWimJavaUtils::GetACFSize( TInt& aSize,  | 
|         |    153                                         const TDesC8& aACFPath, | 
|         |    154                                         TRequestStatus& aStatus ) | 
|         |    155     { | 
|         |    156     _WIMTRACE ( _L( "CWimJavaUtils::GetACFSize" ) ); | 
|         |    157     aStatus = KRequestPending; | 
|         |    158     iClientStatus = &aStatus; | 
|         |    159  | 
|         |    160     if ( !iClientSession || !iConnectionHandle ) | 
|         |    161         { | 
|         |    162         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    163         } | 
|         |    164     else | 
|         |    165         { | 
|         |    166         iSize = &aSize; | 
|         |    167         iACFPath.Copy( aACFPath ); | 
|         |    168         iPhase = EGetACFSize; | 
|         |    169         SignalOwnStatusAndComplete(); | 
|         |    170         } | 
|         |    171     } | 
|         |    172  | 
|         |    173  | 
|         |    174  | 
|         |    175 // ----------------------------------------------------------------------------- | 
|         |    176 // CWimJavaUtils::CancelGetACIFSize() | 
|         |    177 // Cancels ongoing GetSize operation | 
|         |    178 // ----------------------------------------------------------------------------- | 
|         |    179 // | 
|         |    180 EXPORT_C void CWimJavaUtils::CancelGetACIFSize() | 
|         |    181     { | 
|         |    182     _WIMTRACE ( _L( "CWimJavaUtils::CancelGetACIFSize" ) ); | 
|         |    183     Cancel(); | 
|         |    184     } | 
|         |    185      | 
|         |    186  | 
|         |    187 // ----------------------------------------------------------------------------- | 
|         |    188 // CWimJavaUtils::CancelGetACFSize() | 
|         |    189 // Cancels ongoing GetSize operation | 
|         |    190 // ----------------------------------------------------------------------------- | 
|         |    191 // | 
|         |    192 EXPORT_C void CWimJavaUtils::CancelGetACFSize() | 
|         |    193     { | 
|         |    194     _WIMTRACE ( _L( "CWimJavaUtils::CancelGetACFSize" ) ); | 
|         |    195     Cancel(); | 
|         |    196     }     | 
|         |    197  | 
|         |    198 // ----------------------------------------------------------------------------- | 
|         |    199 // CWimJavaUtils::RetrieveACIFContent() | 
|         |    200 // Fetches the whole data of provisioning information string. | 
|         |    201 // ----------------------------------------------------------------------------- | 
|         |    202 // | 
|         |    203 EXPORT_C void CWimJavaUtils::RetrieveACIFContent( TDes8& aACIFData,  | 
|         |    204                                      TRequestStatus& aStatus ) | 
|         |    205     { | 
|         |    206     _WIMTRACE ( _L( "CWimJavaUtils::RetrieveACIFContent" ) );     | 
|         |    207     aStatus = KRequestPending; | 
|         |    208     iClientStatus = &aStatus; | 
|         |    209  | 
|         |    210     if ( !iClientSession || !iConnectionHandle ) | 
|         |    211         { | 
|         |    212         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    213         return; | 
|         |    214         } | 
|         |    215  | 
|         |    216     if ( aACIFData.MaxLength() ) | 
|         |    217         { | 
|         |    218         iData = &aACIFData; | 
|         |    219         iPhase = ERetrieveACIFContent; | 
|         |    220         SignalOwnStatusAndComplete(); | 
|         |    221         } | 
|         |    222     else | 
|         |    223         { | 
|         |    224         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    225         } | 
|         |    226     } | 
|         |    227  | 
|         |    228  | 
|         |    229 // ----------------------------------------------------------------------------- | 
|         |    230 // CWimJavaUtils::RetrieveACFContent() | 
|         |    231 // Fetches the whole data of provisioning information string. | 
|         |    232 // ----------------------------------------------------------------------------- | 
|         |    233 // | 
|         |    234 EXPORT_C void CWimJavaUtils::RetrieveACFContent( TDes8& aACFData,  | 
|         |    235                                                 const TDesC8& aACFPath, | 
|         |    236                                                 TRequestStatus& aStatus ) | 
|         |    237     { | 
|         |    238     _WIMTRACE ( _L( "CWimJavaUtils::RetrieveACFContent" ) );     | 
|         |    239     aStatus = KRequestPending; | 
|         |    240     iClientStatus = &aStatus; | 
|         |    241  | 
|         |    242     if ( !iClientSession || !iConnectionHandle ) | 
|         |    243         { | 
|         |    244         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    245         return; | 
|         |    246         } | 
|         |    247  | 
|         |    248     if ( aACFData.MaxLength() && aACFPath.Length() ) | 
|         |    249         { | 
|         |    250         iData = &aACFData; | 
|         |    251         iACFPath.Copy(aACFPath); | 
|         |    252         iPhase = ERetrieveACFContent; | 
|         |    253         SignalOwnStatusAndComplete(); | 
|         |    254         } | 
|         |    255     else | 
|         |    256         { | 
|         |    257         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    258         } | 
|         |    259     } | 
|         |    260      | 
|         |    261      | 
|         |    262 // ----------------------------------------------------------------------------- | 
|         |    263 // CWimJavaUtils::RetrieveWimLabelAndPath() | 
|         |    264 // Fetches wim label and path. | 
|         |    265 // ----------------------------------------------------------------------------- | 
|         |    266 //     | 
|         |    267 EXPORT_C void CWimJavaUtils::RetrieveWimLabelAndPath( TDes8& aWimLabel, | 
|         |    268                                                      TDes8& aPath, | 
|         |    269                                                      TRequestStatus& aStatus ) | 
|         |    270     { | 
|         |    271 	_WIMTRACE ( _L( "CWimJavaUtils::RetrieveWimLabelAndPath" ) );     | 
|         |    272     aStatus = KRequestPending; | 
|         |    273     iClientStatus = &aStatus; | 
|         |    274  | 
|         |    275     if ( !iClientSession || !iConnectionHandle ) | 
|         |    276         { | 
|         |    277         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    278         return; | 
|         |    279         } | 
|         |    280  | 
|         |    281     if( aWimLabel.MaxLength() && aPath.MaxLength() ) | 
|         |    282 	    { | 
|         |    283 	    iLabel = &aWimLabel; | 
|         |    284 	    iPath = &aPath; | 
|         |    285 	    iPhase = ERetrieveWimLabelAndPath; | 
|         |    286 	    SignalOwnStatusAndComplete();	 | 
|         |    287 	    } | 
|         |    288     else | 
|         |    289 	    { | 
|         |    290 	    User::RequestComplete( iClientStatus, KErrGeneral );	 | 
|         |    291 	    } | 
|         |    292       | 
|         |    293     } | 
|         |    294                                                       | 
|         |    295  | 
|         |    296 // ----------------------------------------------------------------------------- | 
|         |    297 // CWimJavaUtils::GetAuthObjsInfo() | 
|         |    298 // ----------------------------------------------------------------------------- | 
|         |    299 //     | 
|         |    300 EXPORT_C void CWimJavaUtils::GetAuthObjsInfo( const RArray<TInt>& aAuthIdList,  | 
|         |    301                                        RArray<TJavaPINParams>& aAuthObjsInfoList, | 
|         |    302                                        TRequestStatus& aStatus ) | 
|         |    303     { | 
|         |    304 	_WIMTRACE ( _L( "CWimOMAProv::GetAuthObjsInfo" ) ); | 
|         |    305 	aStatus = KRequestPending; | 
|         |    306 	iClientStatus = &aStatus; | 
|         |    307 	 | 
|         |    308 	if ( !iClientSession || !iConnectionHandle ) | 
|         |    309         { | 
|         |    310         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    311         return; | 
|         |    312         } | 
|         |    313  | 
|         |    314     if ( aAuthIdList.Count() ) | 
|         |    315         { | 
|         |    316         if( iAuthObjsInfoList ) | 
|         |    317             { | 
|         |    318         	delete iAuthObjsInfoList; | 
|         |    319         	iAuthObjsInfoList = NULL; | 
|         |    320             } | 
|         |    321              | 
|         |    322         TRAPD( err, iAuthObjsInfoList = new (ELeave) RArray<TJavaPINParams>( aAuthIdList.Count() ) );     | 
|         |    323          | 
|         |    324         if ( err != KErrNone ) | 
|         |    325             { | 
|         |    326             User::RequestComplete( iClientStatus, err );	 | 
|         |    327             return; | 
|         |    328         	  } | 
|         |    329          | 
|         |    330         if( iAuthIdList ) | 
|         |    331             { | 
|         |    332         	delete iAuthIdList; | 
|         |    333         	iAuthIdList = NULL; | 
|         |    334             } | 
|         |    335          | 
|         |    336         TRAP( err, iAuthIdList = new (ELeave ) RArray<TInt>( aAuthIdList.Count() ) ); | 
|         |    337          | 
|         |    338         if ( err != KErrNone ) | 
|         |    339             { | 
|         |    340             User::RequestComplete( iClientStatus, err );	 | 
|         |    341             return;	 | 
|         |    342         	  } | 
|         |    343          | 
|         |    344         for( TInt i = 0; i < aAuthIdList.Count() ; i ++ ) | 
|         |    345             { | 
|         |    346         	iAuthIdList->Append( aAuthIdList[i]); | 
|         |    347             } | 
|         |    348              | 
|         |    349         iClientsAuthObjsInfoList = &aAuthObjsInfoList; | 
|         |    350 		 | 
|         |    351 		TJavaPINParams pinp; | 
|         |    352 		for( TInt i = 0; i < aAuthIdList.Count(); i++ ) | 
|         |    353 			{ | 
|         |    354 			iAuthObjsInfoList->Append( pinp ); | 
|         |    355 			} | 
|         |    356 			 | 
|         |    357         iPhase = EGetAuthObjsInfo; | 
|         |    358         SignalOwnStatusAndComplete(); | 
|         |    359         } | 
|         |    360     else | 
|         |    361         { | 
|         |    362         User::RequestComplete( iClientStatus, KErrGeneral ); | 
|         |    363         } | 
|         |    364      | 
|         |    365      | 
|         |    366     } | 
|         |    367        | 
|         |    368  | 
|         |    369 // ----------------------------------------------------------------------------- | 
|         |    370 // CWimJavaUtils::CancelACIFRetrieveContent() | 
|         |    371 // Cancels ongoing retrieve operation | 
|         |    372 // ----------------------------------------------------------------------------- | 
|         |    373 // | 
|         |    374 EXPORT_C void CWimJavaUtils::CancelRetrieveACIFContent() | 
|         |    375     { | 
|         |    376     _WIMTRACE ( _L( "CWimJavaUtils::CancelRetrieveACIFContent" ) ); | 
|         |    377     Cancel(); | 
|         |    378     } | 
|         |    379  | 
|         |    380  | 
|         |    381 // ----------------------------------------------------------------------------- | 
|         |    382 // CWimJavaUtils::CancelACFRetrieveContent() | 
|         |    383 // Cancels ongoing retrieve operation | 
|         |    384 // ----------------------------------------------------------------------------- | 
|         |    385 // | 
|         |    386 EXPORT_C void CWimJavaUtils::CancelRetrieveACFContent() | 
|         |    387     { | 
|         |    388     _WIMTRACE ( _L( "CWimJavaUtils::CancelRetrieveACFContent" ) ); | 
|         |    389     Cancel(); | 
|         |    390     } | 
|         |    391  | 
|         |    392  | 
|         |    393 // ----------------------------------------------------------------------------- | 
|         |    394 // CWimJavaUtils::CancelACFRetrieveWimLabelAndPath() | 
|         |    395 // Cancels ongoing retrieve operation | 
|         |    396 // ----------------------------------------------------------------------------- | 
|         |    397 // | 
|         |    398 EXPORT_C void CWimJavaUtils::CancelRetrieveWimLabelAndPath() | 
|         |    399     { | 
|         |    400     _WIMTRACE ( _L( "CWimJavaUtils::CancelACFRetrieveWimLabelAndPath" ) ); | 
|         |    401     Cancel(); | 
|         |    402     } | 
|         |    403  | 
|         |    404 // ----------------------------------------------------------------------------- | 
|         |    405 // CWimJavaUtils::CancelGetAuthObjsInfo() | 
|         |    406 // ----------------------------------------------------------------------------- | 
|         |    407 //     | 
|         |    408 EXPORT_C void CWimJavaUtils::CancelGetAuthObjsInfo() | 
|         |    409     { | 
|         |    410     _WIMTRACE ( _L( "CWimJavaUtils::CancelGetAuthObjsInfo" ) ); | 
|         |    411 	Cancel(); | 
|         |    412     } | 
|         |    413      | 
|         |    414 // ----------------------------------------------------------------------------- | 
|         |    415 // CWimJavaUtils::RunL() | 
|         |    416 // Different phases are handled here | 
|         |    417 // iPhase = EInitialize: Gets ClientSession handle. Tries to connect | 
|         |    418 //          to existing session. If there is no existing session, a new session  | 
|         |    419 //          is created. | 
|         |    420 // iPhase = EConnectClientSession: If new session was needed to be created,  | 
|         |    421 //          new connecting request is needed. | 
|         |    422 // iPhase = EInitializeWim: Sends initialize request to server and waits | 
|         |    423 //          asyncronously. | 
|         |    424 // iPhase = EInitializeDone: Initialization is ready. | 
|         |    425 // iPhase = EGetACIFSize: Gets data type and data size from WIM Server | 
|         |    426 // iPhase = EGetACIFSizeDone: WIM server has sent data to client and client copies | 
|         |    427 //                        data forward to caller. | 
|         |    428 // iPhase = ERetrieveACIFContent: Retrieves binary data from WIM Server according to | 
|         |    429 //                     type | 
|         |    430 // iPhase = ERetrieveACIFContentDone: WIM Server has sent data and client copies data  | 
|         |    431 //                         forward to caller. | 
|         |    432 // ----------------------------------------------------------------------------- | 
|         |    433 // | 
|         |    434 void CWimJavaUtils::RunL() | 
|         |    435     { | 
|         |    436     switch ( iPhase )  | 
|         |    437         { | 
|         |    438         case EInitialize: | 
|         |    439             {     | 
|         |    440             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EInitialize" ) ); | 
|         |    441              //get ClientSession handle | 
|         |    442             iClientSession = RWimMgmt::ClientSessionL(); | 
|         |    443  | 
|         |    444             iPhase = EConnectClientSession; | 
|         |    445             TInt retval = 0; | 
|         |    446             iWimStartErr = iClientSession->Connect(); | 
|         |    447             if ( iWimStartErr == KErrNotFound )  | 
|         |    448                 { | 
|         |    449                 retval = iClientSession->StartWim(); | 
|         |    450                 if( retval != KErrNone ) | 
|         |    451                     { | 
|         |    452                     User::RequestComplete( iClientStatus, retval );  | 
|         |    453                     } | 
|         |    454                 else | 
|         |    455                     { | 
|         |    456                     SignalOwnStatusAndComplete(); | 
|         |    457                     } | 
|         |    458                 } | 
|         |    459             else | 
|         |    460                 { | 
|         |    461                  SignalOwnStatusAndComplete();  | 
|         |    462                 } | 
|         |    463             break; | 
|         |    464             } | 
|         |    465         case EConnectClientSession: | 
|         |    466             { | 
|         |    467             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EConnectClientSession" ) ); | 
|         |    468             //Raise iPhase | 
|         |    469             iPhase = EInitializeWim;  | 
|         |    470             if ( iWimStartErr ) | 
|         |    471                 { | 
|         |    472                 //New session was needed to be created. Try to reconnect. | 
|         |    473                 iWimStartErr = iClientSession->Connect(); | 
|         |    474                 if ( iWimStartErr ) | 
|         |    475                     { | 
|         |    476                     //Failed to connect. No reason to continue. | 
|         |    477                     User::RequestComplete( iClientStatus, iWimStartErr ); | 
|         |    478                     } | 
|         |    479                 else | 
|         |    480                     { | 
|         |    481                     SignalOwnStatusAndComplete(); | 
|         |    482                     } | 
|         |    483                 } | 
|         |    484             else | 
|         |    485                 { | 
|         |    486                 SignalOwnStatusAndComplete(); | 
|         |    487                 } | 
|         |    488             break; | 
|         |    489             } | 
|         |    490         case EInitializeWim: | 
|         |    491             { | 
|         |    492             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EInitializeWim" ) ); | 
|         |    493             //Initialize WIM | 
|         |    494             SetActive(); | 
|         |    495             iClientSession->Initialize( iStatus ); | 
|         |    496             iPhase = EInitializeDone; | 
|         |    497             break;    | 
|         |    498             } | 
|         |    499         case EInitializeDone: | 
|         |    500             { | 
|         |    501             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EInitializeDone" ) ); | 
|         |    502             if ( iStatus.Int() == KErrNone ) | 
|         |    503                 { | 
|         |    504                  //Get connection handle to WIM Server. | 
|         |    505                 iConnectionHandle = RWimCertMgmt::ClientSessionL();  | 
|         |    506                 } | 
|         |    507             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    508             break; | 
|         |    509             } | 
|         |    510         case EGetACIFSize: | 
|         |    511             { | 
|         |    512             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EGetACIFSize" ) ); | 
|         |    513             TJavaProv javaProv; | 
|         |    514                | 
|         |    515             iConnectionHandle->RetrieveACIFDataL( javaProv,  | 
|         |    516                                                  iStatus,  | 
|         |    517                                                  EGetACIFFileSize ); | 
|         |    518             iPhase = EGetACIFSizeDone; | 
|         |    519             SetActive(); | 
|         |    520             break; | 
|         |    521             } | 
|         |    522         | 
|         |    523         case EGetACFSize: | 
|         |    524             { | 
|         |    525             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EGetACFSize" ) ); | 
|         |    526             TJavaProv javaProv; | 
|         |    527             javaProv.iPath = &iACFPath; | 
|         |    528             iConnectionHandle->RetrieveACFDataL( javaProv,  | 
|         |    529                                                  iStatus,  | 
|         |    530                                                  EGetACFFileSize ); | 
|         |    531             iPhase = EGetACFSizeDone; | 
|         |    532             SetActive(); | 
|         |    533             break;	 | 
|         |    534             } | 
|         |    535          case EGetAuthObjsInfo: | 
|         |    536             { | 
|         |    537             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EGetAuthObjsInfo" ) ); | 
|         |    538              | 
|         |    539             iConnectionHandle->RetrieveAuthObjsInfoL( *iAuthIdList, | 
|         |    540                                                 *iAuthObjsInfoList, | 
|         |    541                                                 iStatus,  | 
|         |    542                                                 ERetrieveAuthObjsInfo );                         | 
|         |    543             iPhase  = EGetAuthObjsInfoDone; | 
|         |    544             SetActive(); | 
|         |    545         	break; | 
|         |    546         	 | 
|         |    547             } | 
|         |    548         case EGetACIFSizeDone: | 
|         |    549             { | 
|         |    550             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EGetACIFSizeDone" ) ); | 
|         |    551             if ( iStatus.Int() == KErrNone ) | 
|         |    552                 { | 
|         |    553                 TPckgBuf<TJavaProv> javaProvPckgBuf; | 
|         |    554      | 
|         |    555                 javaProvPckgBuf.operator =  | 
|         |    556                     ( *iConnectionHandle->TJavaProvPckgBuf()->PckgBuf() ); | 
|         |    557  | 
|         |    558                 *iSize = javaProvPckgBuf().iSize; | 
|         |    559                 } | 
|         |    560             iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    561             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    562             break; | 
|         |    563             } | 
|         |    564              | 
|         |    565          case EGetACFSizeDone: | 
|         |    566             { | 
|         |    567             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EGetACFSizeDone" ) ); | 
|         |    568             if ( iStatus.Int() == KErrNone ) | 
|         |    569                 { | 
|         |    570                 TPckgBuf<TJavaProv> javaProvPckgBuf; | 
|         |    571      | 
|         |    572                 javaProvPckgBuf.operator =  | 
|         |    573                     ( *iConnectionHandle->TJavaProvPckgBuf()->PckgBuf() ); | 
|         |    574  | 
|         |    575                 *iSize = javaProvPckgBuf().iSize; | 
|         |    576                 } | 
|         |    577             iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    578             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    579             break; | 
|         |    580             }    | 
|         |    581              | 
|         |    582         case ERetrieveACIFContent: | 
|         |    583             { | 
|         |    584             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EACIFRetrieve" ) ); | 
|         |    585             AllocMemoryForJavaProvStructL( iData->MaxLength() ); | 
|         |    586             TJavaProv javaProv; | 
|         |    587             javaProv.iJavaData = iJavaProvBufPtr; | 
|         |    588             iConnectionHandle->RetrieveACIFDataL( javaProv,  | 
|         |    589                                                  iStatus, | 
|         |    590                                                  EGetACIFFile ); | 
|         |    591             iPhase = ERetrieveACIFContentDone; | 
|         |    592             SetActive(); | 
|         |    593             break; | 
|         |    594             } | 
|         |    595              | 
|         |    596         case ERetrieveACFContent: | 
|         |    597             { | 
|         |    598             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EACFRetrieve" ) ); | 
|         |    599             AllocMemoryForJavaProvStructL( iData->MaxLength() ); | 
|         |    600             TJavaProv javaProv; | 
|         |    601             javaProv.iPath = &iACFPath; | 
|         |    602             javaProv.iJavaData = iJavaProvBufPtr; | 
|         |    603              | 
|         |    604             iConnectionHandle->RetrieveACFDataL( javaProv,  | 
|         |    605                                                  iStatus, | 
|         |    606                                                  EGetACFFile ); | 
|         |    607             iPhase = ERetrieveACFContentDone; | 
|         |    608             SetActive(); | 
|         |    609             break; | 
|         |    610             }    | 
|         |    611              | 
|         |    612         case ERetrieveACIFContentDone: | 
|         |    613             { | 
|         |    614             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: ERetrieveACIFContentDone" ) ); | 
|         |    615             if ( iStatus.Int() == KErrNone ) | 
|         |    616                 { | 
|         |    617                 TPtr8 ptr = iJavaProvBuf->Des(); | 
|         |    618                 iData->Copy( ptr ); | 
|         |    619                 } | 
|         |    620             DeallocMemoryFromJavaProvStruct(); | 
|         |    621             iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    622             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    623             break; | 
|         |    624             } | 
|         |    625              | 
|         |    626         case ERetrieveACFContentDone: | 
|         |    627             { | 
|         |    628             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: ERetrieveACFContentDone" ) ); | 
|         |    629             if ( iStatus.Int() == KErrNone ) | 
|         |    630                 { | 
|         |    631                 TPtr8 ptr = iJavaProvBuf->Des(); | 
|         |    632                 iData->Copy( ptr ); | 
|         |    633                 } | 
|         |    634             DeallocMemoryFromJavaProvStruct(); | 
|         |    635             iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    636             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    637             break; | 
|         |    638             }  | 
|         |    639         case EGetAuthObjsInfoDone: | 
|         |    640             { | 
|         |    641             TInt count = iAuthObjsInfoList->Count(); | 
|         |    642             for( TInt i =0; i < count ; i++ ) | 
|         |    643 	            { | 
|         |    644 	            if((*iAuthObjsInfoList)[i].iMinLength > 0 ) | 
|         |    645 		            { | 
|         |    646 		            iClientsAuthObjsInfoList->Append( (*iAuthObjsInfoList)[i] );	 | 
|         |    647 		            } | 
|         |    648 	            } | 
|         |    649             User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    650             break;	 | 
|         |    651             } | 
|         |    652              | 
|         |    653         case ERetrieveWimLabelAndPath: | 
|         |    654             { | 
|         |    655             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: EACFRetrieveWimLabelAndPath" ) ); | 
|         |    656             AllocMemoryForPathAndLabelL(); | 
|         |    657              | 
|         |    658         	iConnectionHandle->RetrieveLabelAndPathL( *iLabelBufPtr, | 
|         |    659         	                                          *iPathBufPtr,  | 
|         |    660                                                       iStatus, | 
|         |    661                                                       EGetLabelAndPath ); | 
|         |    662             iPhase = ERetrieveWimLabelAndPathDone; | 
|         |    663             SetActive(); | 
|         |    664             break; | 
|         |    665             } | 
|         |    666          | 
|         |    667         case ERetrieveWimLabelAndPathDone:   | 
|         |    668             { | 
|         |    669             _WIMTRACE ( _L( "CWimJavaUtils::RunL case: ERetrieveWimLabelAndPathDone" ) ); | 
|         |    670             if( iStatus.Int() == KErrNone ) | 
|         |    671 	            { | 
|         |    672 	            iLabel->Copy( iLabelBuf->Des() ); | 
|         |    673 	            iPath->Copy( iPathBuf->Des() ); | 
|         |    674 	            } | 
|         |    675             DeallocMemoryFromPathAndLabel();      | 
|         |    676            | 
|         |    677         	User::RequestComplete( iClientStatus, iStatus.Int() ); | 
|         |    678             break; | 
|         |    679             } | 
|         |    680                   | 
|         |    681         default: | 
|         |    682             { | 
|         |    683             break; | 
|         |    684             } | 
|         |    685         } | 
|         |    686     } | 
|         |    687  | 
|         |    688 // ----------------------------------------------------------------------------- | 
|         |    689 // CWimJavaUtils::AllocMemoryForJavaProvStructL() | 
|         |    690 // Allocates memory for Java binary data | 
|         |    691 // ----------------------------------------------------------------------------- | 
|         |    692 void CWimJavaUtils::AllocMemoryForJavaProvStructL( const TInt aDataLength ) | 
|         |    693     { | 
|         |    694     _WIMTRACE ( _L( "CWimJavaUtils::AllocMemoryForJavaProvStructL" ) ); | 
|         |    695     if ( aDataLength ) | 
|         |    696         { | 
|         |    697         iJavaProvBuf = HBufC8::NewL( aDataLength ); | 
|         |    698         iJavaProvBufPtr = new( ELeave ) TPtr8( iJavaProvBuf->Des() ); | 
|         |    699         } | 
|         |    700     } | 
|         |    701  | 
|         |    702 // ----------------------------------------------------------------------------- | 
|         |    703 // CWimJavaUtils::DeallocMemoryFromJavaProvStruct() | 
|         |    704 // Deallocates memory from member variables | 
|         |    705 // ----------------------------------------------------------------------------- | 
|         |    706 void CWimJavaUtils::DeallocMemoryFromJavaProvStruct() | 
|         |    707     { | 
|         |    708     _WIMTRACE ( _L( "CWimJavaUtils::DeallocMemoryFromJavaProvStruct" ) ); | 
|         |    709     delete iJavaProvBuf; | 
|         |    710     delete iJavaProvBufPtr; | 
|         |    711     iJavaProvBuf = NULL; | 
|         |    712     iJavaProvBufPtr = NULL; | 
|         |    713     } | 
|         |    714  | 
|         |    715 // ----------------------------------------------------------------------------- | 
|         |    716 // CWimJavaUtils::AllocMemoryForPathAndLabelBufferL() | 
|         |    717 // Allocates memory for path and label buffer | 
|         |    718 // ----------------------------------------------------------------------------- | 
|         |    719 void CWimJavaUtils::AllocMemoryForPathAndLabelL() | 
|         |    720     { | 
|         |    721     _WIMTRACE ( _L( "CWimJavaUtils::AllocMemoryForPathAndLabelL" ) ); | 
|         |    722   | 
|         |    723     iLabelBuf = HBufC8::NewL( KLabelMaxLength ); | 
|         |    724     iLabelBufPtr = new( ELeave ) TPtr8( iLabelBuf->Des() ); | 
|         |    725      | 
|         |    726     iPathBuf = HBufC8::NewL( KPathMaxLength ); | 
|         |    727     iPathBufPtr = new( ELeave ) TPtr8( iPathBuf->Des() ); | 
|         |    728     } | 
|         |    729  | 
|         |    730 // ----------------------------------------------------------------------------- | 
|         |    731 // CWimJavaUtils::DeallocMemoryFromPathAndLabel() | 
|         |    732 // Deallocates memory from path and label | 
|         |    733 // ----------------------------------------------------------------------------- | 
|         |    734 void CWimJavaUtils::DeallocMemoryFromPathAndLabel() | 
|         |    735     { | 
|         |    736     _WIMTRACE ( _L( "CWimJavaUtils::DeallocMemoryFromPathAndLabel" ) ); | 
|         |    737     delete iLabelBuf; | 
|         |    738     delete iPathBuf; | 
|         |    739     delete iLabelBufPtr; | 
|         |    740     delete iPathBufPtr; | 
|         |    741      | 
|         |    742     iLabelBuf = NULL; | 
|         |    743     iLabelBufPtr = NULL; | 
|         |    744     iPathBuf = NULL; | 
|         |    745     iPathBufPtr = NULL; | 
|         |    746     } | 
|         |    747  | 
|         |    748  | 
|         |    749 // ----------------------------------------------------------------------------- | 
|         |    750 // CWimJavaUtils::DoCancel() | 
|         |    751 // Deallocates member variables and completes client status with | 
|         |    752 // KErrCancel error code. | 
|         |    753 // ----------------------------------------------------------------------------- | 
|         |    754 // | 
|         |    755 void CWimJavaUtils::DoCancel() | 
|         |    756     { | 
|         |    757     _WIMTRACE ( _L( "CWimJavaUtils::DoCancel" ) ); | 
|         |    758     if ( iConnectionHandle &&  | 
|         |    759          ( iPhase == EGetACIFSizeDone || iPhase == ERetrieveACIFContentDone ) ) | 
|         |    760         { | 
|         |    761         iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    762         } | 
|         |    763     DeallocMemoryFromJavaProvStruct(); | 
|         |    764     User::RequestComplete( iClientStatus, KErrCancel ); | 
|         |    765     } | 
|         |    766  | 
|         |    767 // ----------------------------------------------------------------------------- | 
|         |    768 // CWimJavaUtils::RunError() | 
|         |    769 // The active scheduler calls this function if this active object's RunL()  | 
|         |    770 // function leaves. This gives this active object the opportunity to perform  | 
|         |    771 // any necessary cleanup. | 
|         |    772 // After cleanup, complete request with received error code. | 
|         |    773 // ----------------------------------------------------------------------------- | 
|         |    774 // | 
|         |    775 TInt CWimJavaUtils::RunError( TInt aError ) | 
|         |    776     { | 
|         |    777     _WIMTRACE ( _L( "CWimJavaUtils::RunError Error = %d" ) ); | 
|         |    778     if ( iConnectionHandle &&  | 
|         |    779          ( iPhase == EGetACIFSizeDone || iPhase == ERetrieveACIFContentDone ) ) | 
|         |    780         { | 
|         |    781         iConnectionHandle->DeallocJavaDataPckgBuf(); | 
|         |    782         } | 
|         |    783     DeallocMemoryFromJavaProvStruct(); | 
|         |    784     User::RequestComplete( iClientStatus, aError ); | 
|         |    785     return KErrNone; | 
|         |    786     } | 
|         |    787  | 
|         |    788 // ----------------------------------------------------------------------------- | 
|         |    789 // CWimJavaUtils::SignalOwnStatusAndComplete()        | 
|         |    790 // Sets own iStatus to KRequestPending, and signals it  | 
|         |    791 // with User::RequestComplete() -request. This gives chance  | 
|         |    792 // active scheduler to run other active objects. After a quick | 
|         |    793 // visit in actives cheduler, signal returns to RunL() and starts next | 
|         |    794 // phase of operation.  | 
|         |    795 // ----------------------------------------------------------------------------- | 
|         |    796 // | 
|         |    797 void CWimJavaUtils::SignalOwnStatusAndComplete() | 
|         |    798     { | 
|         |    799     _WIMTRACE ( _L( "CWimJavaUtils::SignalOwnStatusAndComplete" ) ); | 
|         |    800     iStatus = KRequestPending; | 
|         |    801     SetActive(); | 
|         |    802     TRequestStatus* status = &iStatus; | 
|         |    803     User::RequestComplete( status, KErrNone ); | 
|         |    804     } | 
|         |    805  | 
|         |    806 // End of File | 
|         |    807  | 
|         |    808  | 
|         |    809  | 
|         |    810  | 
|         |    811  | 
|         |    812  | 
|         |    813  | 
|         |    814  | 
|         |    815  | 
|         |    816  | 
|         |    817  | 
|         |    818  | 
|         |    819  | 
|         |    820  | 
|         |    821  | 
|         |    822  | 
|         |    823  | 
|         |    824  | 
|         |    825  |