|
1 /* |
|
2 * Copyright (c) 2002 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCMSSequence_H |
|
21 #define CCMSSequence_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "MCMSModule.h" |
|
25 #include <asn1dec.h> |
|
26 #include <asn1enc.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 /** |
|
30 * Base class for sequence (or set) type of modules. |
|
31 * |
|
32 * @lib cms.lib |
|
33 * @since 2.8 |
|
34 */ |
|
35 class CCMSSequence : public CBase, public MCMSModule |
|
36 { |
|
37 public: // From MCMSModule |
|
38 /** |
|
39 * From MCMSModule |
|
40 * @since 2.8 |
|
41 * @param aResult Allocates and sets result in this variable |
|
42 * @return ?description |
|
43 */ |
|
44 void EncodeL( HBufC8*& aResult ) const; |
|
45 |
|
46 protected: // New functions |
|
47 /** |
|
48 * C++ default constructor. |
|
49 */ |
|
50 CCMSSequence(); |
|
51 |
|
52 /** |
|
53 * Decode a generic ASN1 sequence |
|
54 * @since 2.8 |
|
55 * @param aRawData raw-data to be splitted in ASN.1 Modules |
|
56 * @return Array of generic asn.1 modules. |
|
57 */ |
|
58 IMPORT_C static CArrayPtr<TASN1DecGeneric>* DecodeSequenceLC( const TDesC8& aRawData ); |
|
59 |
|
60 /** |
|
61 * Decode a generic ASN1 sequence, with a minimum/maximum number |
|
62 * of top level terms. Will leave with KErrArgument if number of terms |
|
63 * is not between valid range (including min and max) |
|
64 * @since 2.8 |
|
65 * @param aRawData raw-data to be splitted in ASN.1 Modules |
|
66 * @param aMinTerms minimum of top level terms. |
|
67 * @param aMaxTerms maximum number of top level terms. |
|
68 * @return Array of generic asn.1 modules. |
|
69 */ |
|
70 IMPORT_C static CArrayPtr<TASN1DecGeneric>* DecodeSequenceLC( const TDesC8& aRawData, |
|
71 TInt aMinTerms, |
|
72 TInt aMaxTerms ); |
|
73 /** |
|
74 * Creates DER encoded descriptor and leaves it to |
|
75 * CleanupStack |
|
76 * @since 2.8 |
|
77 * @param aEncoding base encoding to be encoded |
|
78 * @return new heap buffer containing der encoded content |
|
79 */ |
|
80 IMPORT_C static HBufC8* CreateDerEncodingL( CASN1EncBase* aEncoding ); |
|
81 |
|
82 }; |
|
83 |
|
84 // taken from MMF, did not want to make dependency to MMF |
|
85 template <class T> |
|
86 class CleanupResetAndDestroy |
|
87 { |
|
88 public: |
|
89 inline static void PushL(T& aRef); |
|
90 private: |
|
91 static void ResetAndDestroy(TAny *aPtr); |
|
92 }; |
|
93 template <class T> |
|
94 inline void CleanupResetAndDestroyPushL(T& aRef); |
|
95 template <class T> |
|
96 inline void CleanupResetAndDestroy<T>::PushL(T& aRef) |
|
97 {CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));} |
|
98 template <class T> |
|
99 void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr) |
|
100 {(STATIC_CAST(T*,aPtr))->ResetAndDestroy();} |
|
101 template <class T> |
|
102 inline void CleanupResetAndDestroyPushL(T& aRef) |
|
103 {CleanupResetAndDestroy<T>::PushL(aRef);} |
|
104 |
|
105 #endif // CCMSSequence_H |
|
106 |
|
107 // End of File |