|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * Declaration of CSsmLangSelCmd class. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef SSMLANGSELCMD_H |
|
20 #define SSMLANGSELCMD_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ssm/ssmcustomcommand.h> |
|
24 #include <ssm/ssmadaptationcli.h> |
|
25 |
|
26 class CSsmMapperUtility; |
|
27 |
|
28 /** |
|
29 * Each command is implemented in a class derived from MSsmCustomCommand. |
|
30 * It is also possible to implement multiple similar command in the same |
|
31 * class and differentiate between them based on constructor parameters |
|
32 * from the factory method. |
|
33 */ |
|
34 NONSHARABLE_CLASS( CSsmLangSelCmd ) : public CActive, public MSsmCustomCommand |
|
35 { |
|
36 |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Two-phased constructor |
|
41 */ |
|
42 static CSsmLangSelCmd* NewL(); |
|
43 |
|
44 /** |
|
45 * Destructor |
|
46 */ |
|
47 virtual ~CSsmLangSelCmd(); |
|
48 |
|
49 private: // From CActive |
|
50 |
|
51 void RunL(); |
|
52 void DoCancel(); |
|
53 |
|
54 private: // From MSsmCustomCommand |
|
55 |
|
56 /** |
|
57 * @see MSsmCustomCommand |
|
58 */ |
|
59 TInt Initialize( CSsmCustomCommandEnv* aCmdEnv ); |
|
60 |
|
61 /** |
|
62 * @see MSsmCustomCommand |
|
63 */ |
|
64 void Execute( const TDesC8& aParams, TRequestStatus& aRequest ); |
|
65 |
|
66 /** |
|
67 * @see MSsmCustomCommand |
|
68 */ |
|
69 void ExecuteCancel(); |
|
70 |
|
71 /** |
|
72 * @see MSsmCustomCommand |
|
73 */ |
|
74 void Close(); |
|
75 |
|
76 /** |
|
77 * @see MSsmCustomCommand |
|
78 */ |
|
79 void Release(); |
|
80 |
|
81 private: |
|
82 |
|
83 CSsmLangSelCmd(); |
|
84 |
|
85 void ConstructL(); |
|
86 |
|
87 void InitializeL(); |
|
88 |
|
89 /** |
|
90 * Read language code selected by user from Central Repository and return it. |
|
91 * Return 0 (automatic) in case of an error. |
|
92 */ |
|
93 TInt GetLastSelectedLang(); |
|
94 |
|
95 /** |
|
96 * Check if the language code given as parameter can be found in the |
|
97 * iValidLanguages array. |
|
98 * |
|
99 * @param aLanguage The language code to check. |
|
100 * @return ETrue if the language code was found in the list, EFalse otherwise. |
|
101 */ |
|
102 TBool IsValid(const TInt aLanguage) const; |
|
103 |
|
104 /** |
|
105 * Prepare next preferred language list for fetching. |
|
106 */ |
|
107 void PrepareNextList(); |
|
108 |
|
109 /** |
|
110 * Fetch the prepared language list. |
|
111 */ |
|
112 void FetchLanguageListL(); |
|
113 |
|
114 /** |
|
115 * Handle language list received from StartupAdaptation. |
|
116 * |
|
117 * @return Language code that was selected or KErrNotFound. |
|
118 */ |
|
119 TInt InterpretResult(); |
|
120 |
|
121 /** |
|
122 * Check all alternatives for the language given as parameter, and return |
|
123 * first language id that is valid. |
|
124 * |
|
125 * @param aLanguage The language code to check. |
|
126 * @return The language code given as parameter if it is a valid language. |
|
127 * Otherwise the first valid alternative found, or KErrNotFound if there are |
|
128 * none. |
|
129 */ |
|
130 TInt ValidAlternative(const TInt aLanguage) const; |
|
131 |
|
132 /** |
|
133 * Fetch next preferred list if there are any left. Otherwise check if |
|
134 * the last selected language can be used. If not, use the default |
|
135 * language. |
|
136 */ |
|
137 void TryNextList(); |
|
138 |
|
139 /** |
|
140 * Store a language code to Central Repository. |
|
141 * @param aLanguage The language code to store. |
|
142 */ |
|
143 void StoreLanguageToCentRep(const TInt aLanguage); |
|
144 |
|
145 /** |
|
146 * Get a language code from Central Repository. |
|
147 * |
|
148 * @return Language code from CentRep or iDefaultLanguage in case of failure. |
|
149 */ |
|
150 TInt GetLanguageFromCentRep(); |
|
151 |
|
152 /** |
|
153 * Take the language into use and signal client that language selection is |
|
154 * complete. |
|
155 * |
|
156 * @param aLang The language to use or a system-wide error code. |
|
157 */ |
|
158 void UseLanguage(const TInt aLang); |
|
159 |
|
160 private: // data |
|
161 |
|
162 /** Custom command environment. Not owned. Set in Initialise. */ |
|
163 CSsmCustomCommandEnv* iEnv; |
|
164 |
|
165 /** |
|
166 * Array of valid languages (languages that can be used). Own. Not NULL. |
|
167 */ |
|
168 CArrayFixFlat<TInt>* iValidLanguages; |
|
169 |
|
170 /** Adaptation controller for querying SIM preferred language list. */ |
|
171 RSsmMiscAdaptation iAdaptation; |
|
172 |
|
173 /** Request status to complete when language selection is ready. */ |
|
174 TRequestStatus* iClientStatus; |
|
175 |
|
176 /** |
|
177 * The language to use if any of the SIM languages or the last used |
|
178 * language is not valid. |
|
179 */ |
|
180 TInt iDefaultLanguage; |
|
181 |
|
182 /** Which language list has been queried last: 0 = the most preferred. */ |
|
183 TInt iLangListPref; |
|
184 |
|
185 /** Will receive the required language list size. */ |
|
186 TPckgBuf<TInt> iLangListSize; |
|
187 |
|
188 /** Will receive the language list contents. */ |
|
189 CArrayFix<TInt32>* iLangList; |
|
190 |
|
191 /** Internal state of the object. */ |
|
192 enum TState |
|
193 { |
|
194 EQueryListSize = 1, |
|
195 EQueryListContent |
|
196 }; |
|
197 TState iState; |
|
198 |
|
199 // The mapper utility instance, owned. |
|
200 CSsmMapperUtility* iMapperUtility; |
|
201 |
|
202 }; |
|
203 |
|
204 #endif // SSMLANGSELCMD_H |