sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __CERTTOOL_COMMANDS_H_ sl@0: #define __CERTTOOL_COMMANDS_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: //#include sl@0: sl@0: #include sl@0: sl@0: #include "keytool_commands.h" sl@0: sl@0: class CCertToolController; sl@0: sl@0: /** sl@0: * Interface that every keytool command class must implement. sl@0: */ sl@0: class CCertToolCommand : public CActive sl@0: { sl@0: public: sl@0: virtual void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam) = 0; sl@0: sl@0: protected: sl@0: CCertToolCommand(CCertToolController* aController); sl@0: sl@0: protected: sl@0: CCertToolController* iController; sl@0: CKeyToolParameters* iParams; // we do not own this! sl@0: }; sl@0: sl@0: sl@0: /** sl@0: * Implements the certtool display usage action. sl@0: */ sl@0: class CCertToolUsage : public CCertToolCommand sl@0: { sl@0: public: sl@0: static CCertToolUsage* NewLC(CCertToolController* aController); sl@0: static CCertToolUsage* NewL(CCertToolController* aController); sl@0: ~CCertToolUsage(); sl@0: void ConstructL(); sl@0: sl@0: public: // From CCertToolCommand sl@0: void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: protected: sl@0: CCertToolUsage(CCertToolController* aController); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: * Implements the certtool display usage action. sl@0: */ sl@0: class CCertToolListStores : public CCertToolCommand sl@0: { sl@0: public: sl@0: static CCertToolListStores* NewLC(CCertToolController* aController); sl@0: static CCertToolListStores* NewL(CCertToolController* aController); sl@0: ~CCertToolListStores(); sl@0: void ConstructL(); sl@0: sl@0: public: // From CCertToolCommand sl@0: void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: protected: sl@0: CCertToolListStores(CCertToolController* aController); sl@0: sl@0: private: sl@0: RArray iCertStoreList; sl@0: }; sl@0: sl@0: sl@0: typedef RArray RUidArray; sl@0: sl@0: /** sl@0: * Implements the keytool list action. This is an active object as listing is asynchronous. sl@0: */ sl@0: class CCertToolList : public CCertToolCommand sl@0: { sl@0: public: sl@0: static CCertToolList* NewLC(CCertToolController* aController); sl@0: static CCertToolList* NewL(CCertToolController* aController); sl@0: ~CCertToolList(); sl@0: void ConstructL(); sl@0: void InitializeIterations(); sl@0: sl@0: public: // From CCertToolCommand sl@0: void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: protected: sl@0: CCertToolList(CCertToolController* aController); sl@0: sl@0: protected: sl@0: CUnifiedCertStore* iCertStore; sl@0: MCertStore* iCertStoreImp; sl@0: sl@0: TInt iIndex; sl@0: CCertificate* iCertificate; sl@0: sl@0: RUidArray iApps; sl@0: TBool iTrust; sl@0: RArray iCertApps; sl@0: RArray iCertTrust; sl@0: RPointerArray iParsedCerts; sl@0: RMPointerArray iCertInfos; sl@0: CCertAttributeFilter* iFilter; sl@0: sl@0: enum TState sl@0: { sl@0: EListCerts, sl@0: ERetrieve, sl@0: EGetApps, sl@0: ESetTrust, sl@0: EFinished, sl@0: EIntermediate, sl@0: EGetTrust, sl@0: } iState; sl@0: sl@0: // Number of certificates that have to be listed up to the current iteration. sl@0: TInt iCurrentListCount; sl@0: // Keeps track of the number of iterations left. sl@0: TInt iNumberOfIterationsLeft; sl@0: // List offset for the last iteration if total number of certificates is not an exact sl@0: // multiple of default LIST_COUNT. sl@0: TInt iLastIterationOffset; sl@0: // Default list offset for each iteration. sl@0: TInt iCurrentListOffset; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * Implements the keytool import action. sl@0: */ sl@0: class CCertToolAdd : public CCertToolCommand sl@0: { sl@0: public: sl@0: static CCertToolAdd* NewLC(CCertToolController* aController); sl@0: static CCertToolAdd* NewL(CCertToolController* aController); sl@0: ~CCertToolAdd(); sl@0: void ConstructL(); sl@0: sl@0: public: // From CKeyToolCommand sl@0: void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: private: sl@0: CCertToolAdd(CCertToolController* aController); sl@0: sl@0: TCertificateFormat DoRecognizeL(const TDesC8& iData); sl@0: sl@0: protected: sl@0: enum TState sl@0: { sl@0: EIntermediate, sl@0: EFinish sl@0: } iState; sl@0: sl@0: private: sl@0: HBufC8* iCertData; sl@0: CUnifiedCertStore* iCertStore; sl@0: TBool iIsDeletable; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: * Implements the certtool remove action. sl@0: */ sl@0: class CCertToolRemove : public CCertToolList sl@0: { sl@0: public: sl@0: static CCertToolRemove* NewLC(CCertToolController* aController); sl@0: static CCertToolRemove* NewL(CCertToolController* aController); sl@0: ~CCertToolRemove(); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: protected: sl@0: sl@0: private: sl@0: CCertToolRemove(CCertToolController* aController); sl@0: sl@0: private: sl@0: sl@0: }; sl@0: sl@0: sl@0: /** sl@0: * sl@0: */ sl@0: class CCertToolSetApps : public CCertToolList sl@0: { sl@0: public: sl@0: static CCertToolSetApps* NewLC(CCertToolController* aController); sl@0: static CCertToolSetApps* NewL(CCertToolController* aController); sl@0: ~CCertToolSetApps(); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: protected: sl@0: sl@0: private: sl@0: CCertToolSetApps(CCertToolController* aController); sl@0: TInt iCertIndex; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: * sl@0: */ sl@0: class CCertToolAddApps : public CCertToolList sl@0: { sl@0: public: sl@0: static CCertToolAddApps* NewLC(CCertToolController* aController); sl@0: static CCertToolAddApps* NewL(CCertToolController* aController); sl@0: ~CCertToolAddApps(); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: protected: sl@0: enum TState sl@0: { sl@0: EListCerts, sl@0: ERetrieve, sl@0: EGetApps, sl@0: ESetApps, sl@0: ESetTrust, sl@0: EFinished, sl@0: EIntermediate sl@0: } iState; sl@0: sl@0: private: sl@0: CCertToolAddApps(CCertToolController* aController); sl@0: TInt iCertIndex; sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: */ sl@0: class CCertToolRemoveApps : public CCertToolList sl@0: { sl@0: public: sl@0: static CCertToolRemoveApps* NewLC(CCertToolController* aController); sl@0: static CCertToolRemoveApps* NewL(CCertToolController* aController); sl@0: ~CCertToolRemoveApps(); sl@0: sl@0: public: // From CActive sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: protected: sl@0: enum TState sl@0: { sl@0: EListCerts, sl@0: ERetrieve, sl@0: EGetApps, sl@0: ERemoveApps, sl@0: EFinished, sl@0: EIntermediate sl@0: } iState; sl@0: sl@0: private: sl@0: CCertToolRemoveApps(CCertToolController* aController); sl@0: sl@0: }; sl@0: sl@0: #endif sl@0: