|
1 /* |
|
2 * Copyright (c) 2004-2008 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: CCFBasicScriptRoot class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CFBASICSCRIPTROOT_H |
|
21 #define C_CFBASICSCRIPTROOT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32cmn.h> |
|
26 #include <cfscriptroot.h> |
|
27 |
|
28 #include "cfdelayexpired.h" |
|
29 |
|
30 // FORWARD DECLARATION |
|
31 class MCFOperationServices; |
|
32 class CCFClauseNode; |
|
33 class CCFDelay; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * This class implements script XML node of CFW script in Script Engine |
|
39 * scripts. |
|
40 * |
|
41 * @lib CFScriptEngine |
|
42 * @since Series 60 2.6 |
|
43 */ |
|
44 NONSHARABLE_CLASS( CCFBasicScriptRoot ): public CCFScriptRoot, |
|
45 public MCFDelayExpired |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Creates a CCFBasicScriptRoot object |
|
51 * @param aServices is the operation services interface for nodes. |
|
52 * @param aParent parent of this node or NULL if this is a root. The |
|
53 * ownership of the parent is not transferred. |
|
54 * @return a pointer to the created instance of CCFBasicScriptRoot |
|
55 */ |
|
56 static CCFBasicScriptRoot* NewL( MCFOperationServices& aServices, |
|
57 CCFOperationNode* aParent ); |
|
58 |
|
59 /** |
|
60 * Creates a CCFBasicScriptRoot object |
|
61 * @param aServices is the operation services interface for nodes. |
|
62 * @param aParent parent of this node or NULL if this is a root. The |
|
63 * ownership of the parent is not transferred. |
|
64 * @return a pointer to the created instance of CCFBasicScriptRoot |
|
65 */ |
|
66 static CCFBasicScriptRoot* NewLC( MCFOperationServices& aServices, |
|
67 CCFOperationNode* aParent ); |
|
68 |
|
69 /** |
|
70 * Creates and parses a CCFBasicScriptRoot instance from an xml node. |
|
71 * @param aServices is the operation services interface for nodes. |
|
72 * @param aParent is the parent of this node or NULL if this is a root. |
|
73 * The ownership of the parent is not transferred. |
|
74 * @param aNode is the node to be parsed. |
|
75 * @return a pointer to the created instance of CCFBasicScriptRoot, or NULL |
|
76 * if the node is not basic script root node. May leave with any system |
|
77 * wide error code. |
|
78 */ |
|
79 static CCFBasicScriptRoot* ParseL( MCFOperationServices& aServices, |
|
80 CCFOperationNode* aParent, |
|
81 CMDXMLNode& aNode ); |
|
82 |
|
83 /** |
|
84 * Destructor. |
|
85 */ |
|
86 ~CCFBasicScriptRoot(); |
|
87 |
|
88 public: // Functions from CCFScriptRoot |
|
89 |
|
90 /** |
|
91 * Signals the root that evaluation was made with a context. Checks whether |
|
92 * delay should should be activated or actions fired immediately. |
|
93 * @param aContextLevelDelay is the context level delay requirement from the |
|
94 * evaluation. |
|
95 * @return None. |
|
96 */ |
|
97 void ContextEvaluatedL( TInt aContextLevelDelay ); |
|
98 |
|
99 /** |
|
100 * Signals the root that evaluation was made without a context, i.e. |
|
101 * originating from a timer event. |
|
102 * @note If actions should be fired (any child is true), possible ongoing |
|
103 * evaluation delay is cancelled before firing the actions. |
|
104 * @return None. |
|
105 */ |
|
106 void EvaluatedL(); |
|
107 |
|
108 /** |
|
109 * Determines whether the client has the needed security level |
|
110 * to upgrade script located in rom. |
|
111 * @param aSet Capability set needed for upgrade. |
|
112 * @return KErrNone if security check has passed. |
|
113 */ |
|
114 const TCapabilitySet& UpgradeSecurity() const; |
|
115 |
|
116 public: // Functions from CCFOperationNode |
|
117 |
|
118 /** |
|
119 * Activates this node by passing the activate call to its' children. |
|
120 * @return None. |
|
121 */ |
|
122 void ActivateL(); |
|
123 |
|
124 /** |
|
125 * Deactivates this node by passing the deactivate call to its' children. |
|
126 * @return None. |
|
127 */ |
|
128 void Deactivate(); |
|
129 |
|
130 /** |
|
131 * Asks this node to check its security (via services interface). For |
|
132 * example, the security of contexts to be subscribed or actions to be |
|
133 * performed. |
|
134 * @return KErrNone if security check passed, otherwise any of the system |
|
135 * wide error codes. |
|
136 */ |
|
137 TInt CheckSecurity(); |
|
138 |
|
139 /** |
|
140 * Cleanup long term resources like persistent data files. |
|
141 * This is called by the context framework when the script is uninstalled |
|
142 * from the system. |
|
143 */ |
|
144 void Cleanup(); |
|
145 |
|
146 public: // Functions from MCFDelayExpired |
|
147 |
|
148 /** @see MCFDelayExpired::ExpiredL. */ |
|
149 void ExpiredL(); |
|
150 |
|
151 protected: // Functions from CCFOperationNode |
|
152 |
|
153 /** |
|
154 * Called by child node, to ask the parent to re-evaluate its value, since |
|
155 * the child's value has changed. |
|
156 * @return None. |
|
157 */ |
|
158 void Evaluate(); |
|
159 |
|
160 private: |
|
161 |
|
162 /** |
|
163 * C++ default constructor. |
|
164 */ |
|
165 CCFBasicScriptRoot( MCFOperationServices& aServices, |
|
166 CCFOperationNode* aParent ); |
|
167 |
|
168 /** |
|
169 * By default Symbian 2nd phase constructor is private. |
|
170 */ |
|
171 void ConstructL(); |
|
172 |
|
173 private: // New functions |
|
174 |
|
175 /** |
|
176 * Fires actions of the first clause node having true value. |
|
177 * @return None. |
|
178 */ |
|
179 void FireActionsL(); |
|
180 |
|
181 /** |
|
182 * Add capability set for upgrading. |
|
183 * @param aCapabilitySet Set of capabilities. |
|
184 */ |
|
185 void SetCapabilitites( TCapabilitySet& aSet ); |
|
186 |
|
187 /** |
|
188 * Create a capability from descriptor. |
|
189 * @param aCapDesc Capability as descriptor. |
|
190 * @return TCapability Capability enum. |
|
191 */ |
|
192 static TCapability CapabilityFromDesC( const TDesC8& aCapDesc ); |
|
193 |
|
194 /** |
|
195 * Resolves upgrade security from the script XML. |
|
196 * @param aRoot Root where the security is associated. |
|
197 * @param aNode XML node where the security is parsed. |
|
198 */ |
|
199 static void ResolveSecurity( CCFBasicScriptRoot& aRoot, CMDXMLNode& aNode ); |
|
200 |
|
201 private: // Data |
|
202 |
|
203 // Script level delay for firing actions after evaluation. |
|
204 TInt iScriptLevelDelay; |
|
205 |
|
206 // Delay action firing. |
|
207 CCFDelay* iDelayActionFiring; |
|
208 |
|
209 // Node children. |
|
210 RPointerArray<CCFClauseNode> iChildren; |
|
211 |
|
212 // Capability set |
|
213 TCapabilitySet iCapabilitySet; |
|
214 }; |
|
215 |
|
216 #endif // C_CFBASICSCRIPTROOT_H |