|
1 /* |
|
2 * Copyright (c) 2007-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: CCFCount class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CFCOUNT_H |
|
21 #define C_CFCOUNT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "cfcontextoperation.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CCFContextObject; |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * This class implements count -operation on Context Framework Scripts. |
|
33 * |
|
34 * @lib CFScriptEngine |
|
35 * @since S60 v5.0 |
|
36 */ |
|
37 NONSHARABLE_CLASS( CCFCount ): public CCFContextOperation |
|
38 { |
|
39 public: // Public types |
|
40 |
|
41 /** Count types. */ |
|
42 enum TCountType { |
|
43 ECountTypeRemain, /** Count value remains true after operation is evaluated to true. */ |
|
44 ECountTypeChange, /** Count value is changed back from true to false after receiving the next counted context. */ |
|
45 ECountTypeTrigger /** Count triggers one evaluation when count's value is true, after which count changes it's value back to false. */ |
|
46 }; |
|
47 |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** |
|
51 * Creates and parses a CCFCount instance from an xml node. |
|
52 * @param aServices is the operation services interface for nodes. |
|
53 * @param aParent is the parent of this node or NULL if this is a root. |
|
54 * The ownership of the parent is not transferred. |
|
55 * @param aNode is the node to be parsed. |
|
56 * @return a pointer to the created instance of CCFCount, or NULL if the node |
|
57 * is not this count node. May leave with any system wide error code. |
|
58 */ |
|
59 static CCFCount* ParseL( MCFOperationServices& aServices, |
|
60 CCFOperationNode* aParent, |
|
61 CMDXMLNode& aNode ); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 */ |
|
66 ~CCFCount(); |
|
67 |
|
68 public: // From CCFOperationNode |
|
69 |
|
70 /** |
|
71 * Internalizes operation. |
|
72 * @param aStream Read stream. |
|
73 * @return None. |
|
74 */ |
|
75 void InternalizeL( RReadStream& aStream ); |
|
76 |
|
77 /** |
|
78 * Externalizes operation. |
|
79 * @param aStream Write stream. |
|
80 * @return None. |
|
81 */ |
|
82 void ExternalizeL( RWriteStream& aStream ); |
|
83 |
|
84 /** |
|
85 * Cleanup deletes possible persistent data file. |
|
86 * This is called by the context framework when the script is uninstalled |
|
87 * from the system. |
|
88 * @return None. |
|
89 */ |
|
90 void Cleanup(); |
|
91 |
|
92 protected: // From CCFContextOperation |
|
93 |
|
94 /** |
|
95 * Tests if this listener requires notification of all contexts. |
|
96 * Count type trigger requires all contexts, other types do not. |
|
97 * @returns ETrue if this listener is interested in all contexts, |
|
98 * EFalse otherwise. |
|
99 */ |
|
100 TBool IsAllRequired() const; |
|
101 |
|
102 /** |
|
103 * Evaluates a node with a context. |
|
104 * @param aContext is the context for evaluation. |
|
105 * @param aContextLevelDelay contains the context level delay defined by |
|
106 * contextRef after the call. |
|
107 * @return ETrue if the operation was evaluated, EFalse otherwise. |
|
108 */ |
|
109 TBool Evaluate( const CCFContextObject& aContext, |
|
110 TInt& aContextLevelDelay ); |
|
111 |
|
112 protected: // From CCFOperationNode |
|
113 |
|
114 /** |
|
115 * Activates this node by subscribing to a context. |
|
116 * Overrides base class implementation because count must discard the |
|
117 * possible cached context used to pre-evaluate operations during subscribe |
|
118 * context. Otherwise count might be increased based on the cached context. |
|
119 * @return None. |
|
120 */ |
|
121 void ActivateL(); |
|
122 |
|
123 /** |
|
124 * Deactivates this node by removing context subscription. |
|
125 * @return None. |
|
126 */ |
|
127 void Deactivate(); |
|
128 |
|
129 protected: |
|
130 |
|
131 /** |
|
132 * C++ default constructor. |
|
133 */ |
|
134 CCFCount( MCFOperationServices& aServices, |
|
135 CCFOperationNode* aParent, |
|
136 HBufC* aName, |
|
137 HBufC* aSource, |
|
138 const CCFContextOperation::TCmpType aType, |
|
139 const TUint aCount, |
|
140 const TCountType aCountType ); |
|
141 |
|
142 /** |
|
143 * By default Symbian 2nd phase constructor is private. |
|
144 */ |
|
145 void ConstructL( const TDesC& aCmpVal ); |
|
146 |
|
147 private: // New functions |
|
148 |
|
149 /** |
|
150 * Evaluates a node with a context. |
|
151 * @param aContext is the context for evaluation. |
|
152 * @return ETrue if the operation was evaluated, EFalse otherwise. |
|
153 */ |
|
154 TBool DoEvaluateL( const CCFContextObject& aContext ); |
|
155 |
|
156 /** |
|
157 * Counts a context if appropriate. |
|
158 * @param aContext is the context for counting. |
|
159 * @return ETrue if the context was counted, otherwise EFalse. |
|
160 */ |
|
161 TBool CountContextL( const CCFContextObject& aContext ); |
|
162 |
|
163 protected: // Data |
|
164 |
|
165 CCFContextOperation::TCmpType iType; |
|
166 TUint iCurrentCount; |
|
167 TBool iActive; |
|
168 TBool iFinished; |
|
169 TUint iCmpCount; |
|
170 TCountType iCountType; |
|
171 HBufC* iCmpValue; |
|
172 HBufC* iPersistencyFile; |
|
173 TBool iReEvaluateFromNextContext; |
|
174 }; |
|
175 |
|
176 |
|
177 #endif // C_CFCOUNT_H |