terminalsecurity/SCP/SCPTimestampPlugin/inc/SCPTimestampPlugin.h
changeset 0 b497e44ab2fc
child 2 5594fba90824
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2000 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: Implementation of terminalsecurity components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CSCPPTIMESTAMPPLUGIN_H
       
    20 #define __CSCPPTIMESTAMPPLUGIN_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "SCPPlugin.h"
       
    25 #include <f32file.h>
       
    26 #include <barsc.h>
       
    27 
       
    28 #include <TerminalControl3rdPartyAPI.h>
       
    29 
       
    30 
       
    31 // LOCAL CONSTANTS
       
    32 const TInt KSCPMaxExpiration = 365;
       
    33 const TInt KSCPMaxTolerance = 8;
       
    34 const TInt KSCPMaxInterval = 1000;
       
    35 const TInt KSCPMaxMinChangeValueLen = 10; // Max length of interval+tolerance parameters
       
    36 const TInt KSCPMinAttempts = 3;
       
    37 const TInt KSCPMaxAttempts = 100;
       
    38 
       
    39 const TInt KSCPExpireImmediately = -1;
       
    40 
       
    41 const TInt KSCPLastChangeTime = 1;
       
    42 const TInt KSCPIntervalStartTime = 2;
       
    43 const TInt KSCPUsedTolerance = 3;
       
    44 const TInt KSCPFailedAttempts = 4;
       
    45 const TInt KSCPExpireOnNextCall = 5;
       
    46 
       
    47 const TInt KSCPIsAfter = 1;
       
    48 const TInt KSCPIsNotAfter = 0;
       
    49 
       
    50 const TInt KSCPTypeMinutes = 0;
       
    51 const TInt KSCPTypeHours = 1;
       
    52 const TInt KSCPTypeDays = 2;
       
    53 
       
    54 const TInt KSCPNoteTimeout = 2000000;
       
    55 
       
    56 _LIT( KSCPTSConfigFile, "SCPTimestampPlugin.ini");
       
    57 _LIT( KDriveZ, "Z:" );
       
    58 _LIT(KSCPTimestampPluginResFilename, "\\Resource\\SCPTimestampPluginLang.rsc");
       
    59 
       
    60 _LIT(KSCPFormatScript, "FORMAT %c:");
       
    61 const TInt KSCPFormatScriptMaxLen = 32;
       
    62 _LIT( KSCPDosResetCommand, "DOS 1" );
       
    63 
       
    64 
       
    65 
       
    66 // FORWARD DECLARATIONS
       
    67 class CSCPParamObject;
       
    68 
       
    69 // CLASS DECLARATION
       
    70 
       
    71 /**
       
    72 *  CSCPTimestampPlugin 
       
    73 */
       
    74 class CSCPTimestampPlugin : public CSCPPlugin
       
    75     {
       
    76     public: // Constructors, Destructor
       
    77 		/**
       
    78         * 2-phased constructor
       
    79         * @return Instance of Plug-in
       
    80         */
       
    81 	    static CSCPTimestampPlugin* NewL();
       
    82 
       
    83         /**
       
    84         * Destructor
       
    85         */
       
    86 	    virtual ~CSCPTimestampPlugin();
       
    87 
       
    88         /**
       
    89         * Event handler
       
    90         */		
       
    91 		CSCPParamObject* HandleEvent( TInt aID, CSCPParamObject& aParam );
       
    92 		
       
    93 		void SetEventHandler( MSCPPluginEventHandler* aHandler );
       
    94 
       
    95     private: // Constructors, Destructor
       
    96 		/**
       
    97         * Constructor
       
    98         */
       
    99 	    CSCPTimestampPlugin();
       
   100 
       
   101 		/**
       
   102         * 2nd phase constructor
       
   103         */
       
   104         void ConstructL();
       
   105         
       
   106         
       
   107     private : // Methods   
       
   108 		
       
   109 		/**        
       
   110         * Checks if the minimum timeout has expired since the last change
       
   111         */
       
   112 		void IsChangeAllowedL( CSCPParamObject& aParam, CSCPParamObject*& aRetParams );	 
       
   113 		
       
   114 		/**        
       
   115         * Updates the status when the password is changed
       
   116         */
       
   117         void PasswordChanged( CSCPParamObject& aParam, CSCPParamObject*& aRetParams );
       
   118         
       
   119 		/**
       
   120         * Updates the status when after an authentication attempt
       
   121         */
       
   122         void AuthenticationAttempt( TBool aIsSuccessful, 
       
   123                                     CSCPParamObject& aParam,
       
   124                                     CSCPParamObject*& aRetParams );
       
   125                                     
       
   126 		/**
       
   127         * Updates the status after successful authentication
       
   128         */
       
   129         void SuccessfulAuthenticationL( CSCPParamObject& aParam,
       
   130                                        CSCPParamObject*& aRetParams );
       
   131         
       
   132         
       
   133 		/**
       
   134         * Checks if the given time interval is after the saved time (aConfID)
       
   135         */
       
   136         TInt IsAfter( TInt aConfID, TInt aInterval, TInt aIntType );
       
   137             
       
   138         
       
   139 		/**
       
   140         * Handles the Configuration Query event
       
   141         */
       
   142         void ConfigurationQuery(    TInt aParamID, 
       
   143                                     CSCPParamObject& aParam, 
       
   144                                     CSCPParamObject*& aRetParams );
       
   145                                     
       
   146         /**
       
   147         * Initiates RFS Deep (device wipe)
       
   148         */
       
   149         void WipeDeviceL( CSCPParamObject*& aRetParams );
       
   150                                     
       
   151 		/**
       
   152         * Read the configuration from flash.
       
   153         */
       
   154         TInt ReadConfiguration();
       
   155         
       
   156 		/**
       
   157         * Writes the configuration to flash.
       
   158         */
       
   159         TInt WriteConfiguration();                                             
       
   160         
       
   161 		/**
       
   162         * Fetches the resource data from the file.
       
   163         */        
       
   164         TInt CSCPTimestampPlugin::GetResource();
       
   165         
       
   166 		/**
       
   167         * Loads a specified resource buffer.
       
   168         */
       
   169         HBufC16* CSCPTimestampPlugin::LoadResourceL( TInt aResId );
       
   170         
       
   171         void FormatResourceString(HBufC16 &aResStr);
       
   172     private: // Data
       
   173         /* A pointer to the event handler object on the server, not owned */
       
   174         MSCPPluginEventHandler* iEventHandler;
       
   175         
       
   176         /* A pointer to the configuration object, owned */
       
   177         CSCPParamObject* iConfiguration;
       
   178         
       
   179 	    /* The expiration timeout, days */
       
   180 	    TInt iExpiration;
       
   181 	    
       
   182 	    /* Minimum change interval, hours */
       
   183 	    TInt iMinInterval;
       
   184 
       
   185 	    /* Amount of changes allowed inside change interval */
       
   186 	    TInt iMinTolerance;
       
   187 
       
   188 	    /* Maximum amount of failed attempts before device wipe */
       
   189 	    TInt iMaxAttempts;  
       
   190 	    
       
   191 	    /* File server session ptr, not owned */
       
   192 	    RFs* iFsSession;
       
   193 	    
       
   194         /* Resourcefile-object */
       
   195 	    RResourceFile iResFile;
       
   196 	    
       
   197 	    /* Resource-file indicator */
       
   198 	    TBool iResOpen;   
       
   199     };
       
   200 
       
   201 #endif // __CSCPPTIMESTAMPPLUGIN_H
       
   202 
       
   203 // End of File