vpnengine/ikev1lib/inc/ikev1dialog.h
changeset 0 33413c0669b9
child 17 d1a0d37b52a1
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2005-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:   CIkeDialog class headers
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_IKEV1DIALOG_H
       
    19 #define C_IKEV1DIALOG_H
       
    20 
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 #include "vpnnotifierdefs.h"
       
    25 
       
    26 class CIkev1Dialog;
       
    27 class CIkev1PluginSession;
       
    28 class RFs;
       
    29 class MIkeDebug;
       
    30 
       
    31 /** 
       
    32 * IKE dialog complete
       
    33 * @internalComponent
       
    34 */
       
    35 class MIkeDialogComplete
       
    36 {
       
    37 	public:
       
    38 		/** 
       
    39          * IKE dialog completed 
       
    40          * @internalComponent
       
    41          * 
       
    42          */
       
    43 		virtual TInt DialogCompleteL(CIkev1Dialog* aDialog, TAny* aUserInfo, HBufC8* aUsername, HBufC8* aSecret, HBufC8* aDomain)=0; 
       
    44 };
       
    45 
       
    46 
       
    47 
       
    48 NONSHARABLE_CLASS(CDialogTimeout) : public CTimer
       
    49 {
       
    50 public:
       
    51     CDialogTimeout( MIkeDebug& aDebug );
       
    52     ~CDialogTimeout();
       
    53     void ConstructL(CIkev1Dialog* aDialog);
       
    54     
       
    55 protected:
       
    56     // will cancel the current dialog
       
    57     void RunL();
       
    58     void DoCancel();
       
    59     
       
    60 protected: // data
       
    61     CIkev1Dialog* iDialog; //Needed to cancel a dialog
       
    62     
       
    63 private: // data
       
    64     MIkeDebug& iDebug;
       
    65 };
       
    66 
       
    67 
       
    68 NONSHARABLE_CLASS(CIkev1Dialog) : public CActive
       
    69 {
       
    70 public:
       
    71     static CIkev1Dialog* NewL( CIkev1PluginSession* aPluginSession,
       
    72                                CIkev1Dialog** aToQueAnchor,
       
    73                                MIkeDebug& aDebug );
       
    74     CIkev1Dialog( MIkeDebug& aDebug );
       
    75     ~CIkev1Dialog();
       
    76 
       
    77     void GetAsyncUNPWDialogL(TAny *aUserInfo, MIkeDialogComplete* aCallback);
       
    78     void GetAsyncUNAMEDialog(TAny *aUserInfo, MIkeDialogComplete* aCallback);    
       
    79     void GetAsyncSecureidDialogL(TAny *aUserInfo, MIkeDialogComplete*  aCallback);
       
    80     void GetAsyncSecureNextPinDialogL(TAny *aUserInfo, MIkeDialogComplete* aCallback);    
       
    81     void GetAsyncRespDialog(TPtr8 aChallenge, TAny *aUserInfo, MIkeDialogComplete* aCallback);
       
    82     void ShowErrorDialogL(TInt aDialogType, TAny *aUserInfo, MIkeDialogComplete*  aCallback);
       
    83 	void StoreUserNameL(TPtr8 aUserName);
       
    84 	void StartDialogL();
       
    85 	TInt GetSyncUNPWCacheDialog(TDes& aUserName, TDes& aPassword);
       
    86 	
       
    87     static TInt GetSyncUNPWDialog(TDes& aUserName, TDes& aPassword);
       
    88     static void PurgeDialogQueue(CIkev1Dialog* aQueuedDialog);
       
    89 	
       
    90 	inline CIkev1PluginSession* PluginSession() { return iPluginSession;}
       
    91 	inline CIkev1Dialog* NextDialog() { return iNext;}
       
    92 	inline MIkeDialogComplete* Callback() { return iCallback;}
       
    93 	inline TAny* UserInfo() { return iUserInfo;}		
       
    94 	
       
    95 protected:
       
    96     // active object stuff, completion and cancel callback functions
       
    97     void RunL();
       
    98     void DoCancel();
       
    99     
       
   100 private:
       
   101     void ConstructL(CIkev1PluginSession* aPluginSession, CIkev1Dialog* *aToQueAnchor);
       
   102     void LaunchDialogL();
       
   103     TInt QueueDialog(CIkev1Dialog* aDialog);
       
   104     void DeQueueDialog(CIkev1Dialog* aDialog);
       
   105 	HBufC8* CreateDialogInput(TIPSecDialogInfo& aDialogInfo, TBool aUserNameCache);
       
   106 	HBufC8* GetUserNameFromFile();
       
   107 	static TBool BuildEncryptionKey(const TDesC8& aSalt, TDes8& aEncryptionKey);		
       
   108     static TInt LauchSyncDialog(const TDesC8& aInput, TDes8& aOutput);  
       
   109     static HBufC8* ConvertPwdToOctetString(TDesC &aUnicodeBfr);
       
   110     
       
   111 private:
       
   112     CIkev1PluginSession*   iPluginSession;
       
   113     RFs             iFs;
       
   114     CIkev1Dialog**  iToQueAnchor;   // Waiting queue anchor
       
   115     CIkev1Dialog*   iNext;          // For waiting queue
       
   116     TAny*           iUserInfo;
       
   117     MIkeDialogComplete* iCallback;
       
   118     TInt           iDialogType;
       
   119     CDialogTimeout* iTimeout;   
       
   120     RNotifier      iNotifier;
       
   121     HBufC8*        iInputData;
       
   122     TPckgBuf<TIPSecDialogOutput> iResponseBuf;
       
   123     MIkeDebug& iDebug;
       
   124 };
       
   125 
       
   126 /**--------------------------------------------------------------------------
       
   127  *
       
   128  * Structure TUserNameFileHdr
       
   129  * User name (encrypted) cache file header.
       
   130  * In this file is cached the last user name used in legacy
       
   131  * authentication. 
       
   132  *
       
   133  *--------------------------------------------------------------------------*/
       
   134 #define USER_NAME_FILE_ID     0xcccccccc
       
   135 struct TUserNameFileHdr
       
   136 {
       
   137 	TUint8      iSalt[8];
       
   138 	TUint8      iIV[8];
       
   139 	TUint32     iFileId;
       
   140 };
       
   141 
       
   142 #endif // C_IKEV1DIALOG_H