|
1 /* |
|
2 * Copyright (c) 2008-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: Matches JAD and JAR attributes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef JCFJADJARMATCHERSTATES_H |
|
21 #define JCFJADJARMATCHERSTATES_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32def.h> |
|
25 #include <e32std.h> |
|
26 #include <mtclreg.h> |
|
27 |
|
28 #include "jcfjadjarmatcherobservable.h" |
|
29 #include "mjavaattribute.h" |
|
30 |
|
31 enum TStates |
|
32 { |
|
33 EBegin = 0, // 0 |
|
34 EOpenSession, // 1 |
|
35 EOpenMtmRegistry, // 2 |
|
36 EOpenMtmClient, // 3 |
|
37 EOpenJarFile, // 4 |
|
38 EOpenJadFile, // 5 |
|
39 EScanJarFile, // 6 |
|
40 EScanJadFile, // 7 |
|
41 EEntrySelect, // 8 |
|
42 EScanEntries, // 9 |
|
43 EScanAttchms, // 10 |
|
44 ESeekRootEntries, // 11 |
|
45 ESeekEntries, // 12 |
|
46 EScanStores, // 13 |
|
47 EEnd // 14 |
|
48 }; |
|
49 |
|
50 enum TMode |
|
51 { |
|
52 EUseNames, |
|
53 EUseHandles |
|
54 }; |
|
55 |
|
56 |
|
57 /** |
|
58 * Base class for scanner classes. |
|
59 * Contains common funcionality of scanner classes |
|
60 * |
|
61 * @lib JcfJadJarMatcher.lib |
|
62 * @since S60 2.0 |
|
63 */ |
|
64 class CJcfJadJarMatcherState : |
|
65 public CActive, public MJcfJadJarMatcherObservable |
|
66 { |
|
67 public: |
|
68 /** |
|
69 * To construct new CJcfJadJarMatcherState. |
|
70 * |
|
71 * Preconditions. The following conditions must be true prior to calling |
|
72 * this method; otherwise, its operation is undefined. |
|
73 * - None. |
|
74 * |
|
75 * Postconditions. The following condition is true immediately after |
|
76 * returning from this method. |
|
77 * - None. |
|
78 * |
|
79 * @param aObs - an observer of this class. |
|
80 */ |
|
81 CJcfJadJarMatcherState(MJcfJadJarMatcherObserver* aObs); |
|
82 |
|
83 /** |
|
84 * To destruct CJcfJadJarMatcherState. |
|
85 * |
|
86 * Preconditions. The following conditions must be true prior to calling |
|
87 * this method; otherwise, its operation is undefined. |
|
88 * - None. |
|
89 * |
|
90 * Postconditions. The following condition is true immediately after |
|
91 * returning from this method. |
|
92 * - None. |
|
93 * |
|
94 */ |
|
95 virtual ~CJcfJadJarMatcherState(); |
|
96 |
|
97 /** |
|
98 * To execute this state. |
|
99 * |
|
100 * Preconditions. The following conditions must be true prior to calling |
|
101 * this method; otherwise, its operation is undefined. |
|
102 * - None. |
|
103 * |
|
104 * Postconditions. The following condition is true immediately after |
|
105 * returning from this method. |
|
106 * - None. |
|
107 * |
|
108 * @param aJarName - a name of the file. |
|
109 * @param aDirName - a name of the directory to be scanned. |
|
110 * @param aJadNamePtr - a pointer to the output descriptor. |
|
111 */ |
|
112 virtual void ExecuteL(const TDesC& aJarName, |
|
113 const TDesC& aDirName, |
|
114 TDes* aJadNamePtr) = 0; |
|
115 |
|
116 protected: |
|
117 /** |
|
118 * To handle errors. |
|
119 * |
|
120 * Preconditions. The following conditions must be true prior to calling |
|
121 * this method; otherwise, its operation is undefined. |
|
122 * - None. |
|
123 * |
|
124 * Postconditions. The following condition is true immediately after |
|
125 * returning from this method. |
|
126 * - None. |
|
127 * |
|
128 * @param aError - The reason of error. |
|
129 * @return KErrNone. |
|
130 */ |
|
131 virtual TInt RunError(TInt aError); |
|
132 |
|
133 /** |
|
134 * To do clean-up for next round. |
|
135 * |
|
136 * Preconditions. The following conditions must be true prior to calling |
|
137 * this method; otherwise, its operation is undefined. |
|
138 * - None. |
|
139 * |
|
140 * Postconditions. The following condition is true immediately after |
|
141 * returning from this method. |
|
142 * - iState == EBegin. |
|
143 * |
|
144 */ |
|
145 virtual void Cleanup() = 0; |
|
146 |
|
147 /** |
|
148 * To check whether JAD and JAR files match or not. |
|
149 * |
|
150 * Definition. Operation returns true if following statements are all true: |
|
151 * |
|
152 * 1) The version of JAD is same as the version of JAR. |
|
153 * 2) The vendor of JAD is same as the vendor of JAR. |
|
154 * 3) The name of JAD is same as the name of JAR. |
|
155 * 4) Suite has at least one MIDlet. |
|
156 * |
|
157 * Preconditions. The following conditions must be true prior to calling |
|
158 * this method; otherwise, its operation is undefined. |
|
159 * - None. |
|
160 * |
|
161 * Postconditions. The following condition is true immediately after |
|
162 * returning from this method. |
|
163 * - None. |
|
164 * |
|
165 */ |
|
166 TBool Match(const RPointerArray<Java::MJavaAttribute>& aJadAttributes, |
|
167 const RPointerArray<Java::MJavaAttribute>& aJarAttributes); |
|
168 |
|
169 /** |
|
170 * Check attributes with given name equals. |
|
171 * |
|
172 * @param aJadAttributes JAD attributes to look for. |
|
173 * @param aJarAttributes JAR attributes to look for. |
|
174 * @param aName Attribute name to checked. |
|
175 * @return true if attributes equal, false otherwise. |
|
176 */ |
|
177 TBool AttributesEqual( |
|
178 const RPointerArray<Java::MJavaAttribute>& aJadAttributes, |
|
179 const RPointerArray<Java::MJavaAttribute>& aJarAttributes, |
|
180 const TDesC& aName) const; |
|
181 |
|
182 /** |
|
183 * Get attribute index. Attribute is searched by name. |
|
184 * |
|
185 * @param aAttributes where to search. |
|
186 * @param aName attribute name to look for. |
|
187 * @return attribute index, KErrNotFound if not found. |
|
188 */ |
|
189 TInt AttributeIndex( |
|
190 const RPointerArray<Java::MJavaAttribute>& aAttributes, |
|
191 const TDesC& aName) const; |
|
192 |
|
193 protected: |
|
194 TStates iState; |
|
195 TInt iValue; |
|
196 }; |
|
197 |
|
198 #endif // JCFJADJARMATCHERSTATES_H |