|
1 /* |
|
2 * Copyright (c) 2007 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: Command policy manager class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_VTUICOMMANDPOLICYMANAGER_H |
|
20 #define C_VTUICOMMANDPOLICYMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "tvtuicmdcontexttype.h" |
|
25 |
|
26 class CVtUiCmdContext; |
|
27 class CVtUiCmdValidatorBase; |
|
28 class CVtUiCmdValidationActionBase; |
|
29 class CVtUiCmdCustomValidationActionBase; |
|
30 class CVtUiCommandManager; |
|
31 class CVtUiPrimaryCmdPolicy; |
|
32 |
|
33 /** |
|
34 * CVtUiCommandPolicyManager |
|
35 * |
|
36 * Contains pointers to all registered command contexts and commnd policy |
|
37 * instances. When validation is required, calls proper methods in proper |
|
38 * context for registered validators in validator priority order. |
|
39 * |
|
40 * @since S60 v3.2 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CVtUiCommandPolicyManager ) : public CBase |
|
43 { |
|
44 |
|
45 public: // public methods |
|
46 |
|
47 /** |
|
48 * Static constructor. |
|
49 * |
|
50 * @param aCmdManager Constant reference to command manager instance. |
|
51 * @return Newly created instance of CVtUiCommandPolicyManager class. |
|
52 */ |
|
53 static CVtUiCommandPolicyManager* |
|
54 NewL( const CVtUiCommandManager& aCmdManager ); |
|
55 |
|
56 /** |
|
57 * C++ destructor. |
|
58 */ |
|
59 ~CVtUiCommandPolicyManager(); |
|
60 |
|
61 /** |
|
62 * Registers command context. |
|
63 * |
|
64 * @param aContext Reference to command context to be registered. |
|
65 * @return KErrNone if registration succeeded. |
|
66 */ |
|
67 TInt RegisterCommandContext( CVtUiCmdContext& aContext ); |
|
68 |
|
69 /** |
|
70 * Unregisters command context. |
|
71 * |
|
72 * @param aContext Constant reference to command context to be unregistered. |
|
73 */ |
|
74 void UnregisterCommandContext( CVtUiCmdContext& aContext ); |
|
75 |
|
76 /** |
|
77 * Adds validator to policy manager and registered contexts. |
|
78 * |
|
79 * @param aValidator Reference to validator to be added. |
|
80 * @return KErrNone if add succeeded. |
|
81 */ |
|
82 TInt AddValidator( CVtUiCmdValidatorBase& aValidator ); |
|
83 |
|
84 /** |
|
85 * Removes validator from policy manager and registered contexts. |
|
86 * |
|
87 * @param aValidator Constant reference to validator to be removed. |
|
88 */ |
|
89 void RemoveValidator( CVtUiCmdValidatorBase& aValidator ); |
|
90 |
|
91 /** |
|
92 * Validates menu items for given action. |
|
93 * |
|
94 * @param aAction Reference to validation action to be carried on menu |
|
95 * commmands. |
|
96 */ |
|
97 void ValidateMenuItemsL( CVtUiCmdValidationActionBase& aAction ); |
|
98 |
|
99 /** |
|
100 * Validates softkey items for given action. |
|
101 * |
|
102 * @param aAction Reference to validation action to be carried on softkeys. |
|
103 */ |
|
104 void ValidateSoftkeyItemsL( CVtUiCmdValidationActionBase& aAction ); |
|
105 |
|
106 /** |
|
107 * Validates toolbar items for given action. |
|
108 * |
|
109 * @param aAction Reference to validation action to be carried on toolbar |
|
110 * commands. |
|
111 */ |
|
112 void ValidateToolbarItemsL( CVtUiCmdValidationActionBase& aAction ); |
|
113 |
|
114 /** |
|
115 * Custom validation for given action. |
|
116 * |
|
117 * @param Reference to custom validation action to be carried. |
|
118 */ |
|
119 void CustomValidateL( CVtUiCmdCustomValidationActionBase& aAction ); |
|
120 |
|
121 private: |
|
122 |
|
123 /** |
|
124 * Constructor |
|
125 */ |
|
126 CVtUiCommandPolicyManager( const CVtUiCommandManager& aCmdManager ); |
|
127 |
|
128 /** |
|
129 * 2nd constructor |
|
130 */ |
|
131 void ConstructL(); |
|
132 |
|
133 /** |
|
134 * Called when RegisterCommandContext() succeeds. |
|
135 */ |
|
136 void CommandContextRegistered( CVtUiCmdContext& aContext ); |
|
137 |
|
138 /** |
|
139 * Called when UnregisterCommandContext() succeeds. |
|
140 */ |
|
141 void CommandContextUnregistered( CVtUiCmdContext& aContext ); |
|
142 |
|
143 /** |
|
144 * Called when AddValidator() succeeds. |
|
145 */ |
|
146 void ValidatorAdded( CVtUiCmdValidatorBase& aValidator ); |
|
147 |
|
148 /** |
|
149 * Called when RemoveValidator() succeeds. |
|
150 */ |
|
151 void ValidatorRemoved( CVtUiCmdValidatorBase& aValidator ); |
|
152 |
|
153 /** |
|
154 * Returns command context by type. |
|
155 */ |
|
156 CVtUiCmdContext* FindCommandContextByType( |
|
157 TVtUiCmdContextType aContextType ); |
|
158 |
|
159 /** |
|
160 * Called from different validation routines. |
|
161 */ |
|
162 void ValidateL( TVtUiCmdContextType aContextType, |
|
163 CVtUiCmdValidationActionBase& aAction ); |
|
164 |
|
165 private: // data |
|
166 |
|
167 // Context list (ordered by context type) |
|
168 RPointerArray< CVtUiCmdContext > iContexts; |
|
169 |
|
170 // Validator list |
|
171 RPointerArray< CVtUiCmdValidatorBase > iValidators; |
|
172 |
|
173 // Reference to command manager |
|
174 const CVtUiCommandManager& iCommandManager; |
|
175 |
|
176 // Primary command policy, always exists. |
|
177 CVtUiPrimaryCmdPolicy* iPrimaryCommandPolicy; |
|
178 |
|
179 }; |
|
180 |
|
181 #endif // C_VTUICOMMANDPOLICYMANAGER_H |