|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing test application. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <avkon.hrh> |
|
20 #include <aknnotewrappers.h> |
|
21 #include <stringloader.h> |
|
22 #include <Edta.rsg> |
|
23 #include <f32file.h> |
|
24 #include <s32file.h> |
|
25 #include <aiwservicehandler.h> |
|
26 #include <centralrepository.h> |
|
27 #include <easydialingcrkeys.h> |
|
28 |
|
29 #include "edta.pan" |
|
30 #include "edta_appui.h" |
|
31 #include "edta_appview.h" |
|
32 #include "edta.hrh" |
|
33 #include "edta_querydialog.h" |
|
34 #include <AknQueryDialog.h> |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 // CONSTANTS |
|
40 const TInt KSearchStringMaxLen = 64; |
|
41 |
|
42 |
|
43 // ============================ MEMBER FUNCTIONS =============================== |
|
44 |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CEdtaAppUi::ConstructL() |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CEdtaAppUi::ConstructL() |
|
52 { |
|
53 // Initialise app UI with standard value. |
|
54 BaseConstructL(CAknAppUi::EAknEnableSkin); |
|
55 |
|
56 // Create view object |
|
57 iAppView = CEdtaAppView::NewL( ClientRect() ); |
|
58 |
|
59 // TODO: remove? |
|
60 iServiceHandler = CAiwServiceHandler::NewL(); |
|
61 |
|
62 iRepository = CRepository::NewL( KCRUidEasyDialSettings ); |
|
63 |
|
64 AddToStackL(iAppView); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CEdtaAppUi::CEdtaAppUi() |
|
69 // C++ default constructor can NOT contain any code, that might leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CEdtaAppUi::CEdtaAppUi() |
|
73 { |
|
74 // No implementation required |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CEdtaAppUi::~CEdtaAppUi() |
|
79 // Destructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CEdtaAppUi::~CEdtaAppUi() |
|
83 { |
|
84 if ( iAppView ) |
|
85 { |
|
86 RemoveFromStack(iAppView); |
|
87 delete iAppView; |
|
88 iAppView = NULL; |
|
89 } |
|
90 delete iServiceHandler; |
|
91 |
|
92 if ( iRepository ) |
|
93 { |
|
94 // default setting |
|
95 iRepository->Set(KEasyDialingContactThumbnails, 1); |
|
96 } |
|
97 delete iRepository; |
|
98 } |
|
99 |
|
100 |
|
101 TInt CreateTestContactDatabaseL(); // Should be moved into correct place |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CEdtaAppUi::HandleCommandL() |
|
105 // Takes care of command handling. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CEdtaAppUi::HandleCommandL( TInt aCommand ) |
|
109 { |
|
110 DebugPrintF(_L("CEdtaAppUi::HandleCommandL enter: 0x%X"), aCommand ); |
|
111 |
|
112 switch( aCommand ) |
|
113 { |
|
114 case EEikCmdExit: |
|
115 case EAknSoftkeyExit: |
|
116 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EXIT")); |
|
117 Exit(); |
|
118 break; |
|
119 |
|
120 case EEdtaSetPluginInput: |
|
121 { |
|
122 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaSetPluginInput")); |
|
123 |
|
124 if( CheckPluginLoadedAndShowNote() ) |
|
125 { |
|
126 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( iQueryText ); |
|
127 if( dlg->ExecuteLD(R_DIALOG_TEXT_EDIT_QUERY)) |
|
128 { |
|
129 if (iAppView->GetEasyDialer()) |
|
130 { |
|
131 iAppView->GetEasyDialer()->SetInputL( iQueryText ); |
|
132 } |
|
133 } |
|
134 } |
|
135 } |
|
136 break; |
|
137 |
|
138 case EEdtaCommandShowContacts: |
|
139 { |
|
140 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaCommandShowContacts")); |
|
141 |
|
142 if( iAppView->IsPCSServerLoaded() ) |
|
143 { |
|
144 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( iQueryText ); |
|
145 if( dlg->ExecuteLD(R_DIALOG_TEXT_EDIT_QUERY)) |
|
146 { |
|
147 iAppView->ShowMatchingContactsL(iQueryText); |
|
148 } |
|
149 } |
|
150 } |
|
151 break; |
|
152 |
|
153 case EEdtaLaunchFirstContact: |
|
154 { |
|
155 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaLaunchFirstContact")); |
|
156 if( iAppView->IsPCSServerLoaded() ) |
|
157 iAppView->LaunchNthContactL( 0 ); |
|
158 } |
|
159 break; |
|
160 |
|
161 case EEdtaSelectAndLaunchContact: |
|
162 { |
|
163 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaSelectAndLaunchContact")); |
|
164 iAppView->SelectAndLaunchContactL(); |
|
165 } |
|
166 break; |
|
167 |
|
168 case EEdtaCommandCheckPCSServer: |
|
169 { |
|
170 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaCommandCheckPCSServer")); |
|
171 if( iAppView->IsPCSServerLoaded() ) |
|
172 iAppView->CheckPCSServerL(); |
|
173 } |
|
174 break; |
|
175 |
|
176 case EEdtaCommandShowNameOrdering: |
|
177 { |
|
178 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaCommandShowNameOrdering")); |
|
179 iAppView->ShowNameOrderL(); |
|
180 } |
|
181 break; |
|
182 |
|
183 case EEdtaCommandCreateTestContactBase: |
|
184 { |
|
185 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: EEdtaCommandCreateTestContactBase")); |
|
186 TInt newContactsCount = CreateTestContactDatabaseL(); |
|
187 iAppView->GetScreenBuffer()->WriteLineL(_L("Test contacts updated")); |
|
188 iAppView->GetScreenBuffer()->WriteLineL(_L("%d new contacts"), newContactsCount ); |
|
189 } |
|
190 break; |
|
191 |
|
192 case EEdtaCommandTwoConsequtiveSearchesTest: |
|
193 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: Two search test")); |
|
194 |
|
195 if( CheckPluginLoadedAndShowNote() ) |
|
196 { |
|
197 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( iQueryText ); |
|
198 if( dlg->ExecuteLD(R_DIALOG_TEXT_EDIT_QUERY)) |
|
199 { |
|
200 HBufC* anotherQueryText = HBufC::NewLC( KSearchStringMaxLen ); |
|
201 TPtr ptr = anotherQueryText->Des(); |
|
202 |
|
203 CAknTextQueryDialog* dlg2 = CAknTextQueryDialog::NewL( ptr ); |
|
204 |
|
205 if ( dlg2->ExecuteLD(R_DIALOG_TEXT_EDIT_QUERY) ) |
|
206 { |
|
207 if (iAppView->GetEasyDialer()) |
|
208 { |
|
209 iAppView->GetEasyDialer()->SetInputL( iQueryText ); |
|
210 iAppView->GetEasyDialer()->SetInputL( ptr ); |
|
211 } |
|
212 } |
|
213 CleanupStack::PopAndDestroy( anotherQueryText ); |
|
214 } |
|
215 } |
|
216 break; |
|
217 |
|
218 case EEdtaCommandMiscCoverageTest: |
|
219 |
|
220 if (iAppView->GetEasyDialer()) |
|
221 { |
|
222 iAppView->DoMiscellaneousTestsL( ); |
|
223 } |
|
224 break; |
|
225 |
|
226 case EEdtaCommandShowThumbnails: |
|
227 iRepository->Set(KEasyDialingContactThumbnails, 1); |
|
228 break; |
|
229 |
|
230 case EEdtaCommandHideThumbnails: |
|
231 iRepository->Set(KEasyDialingContactThumbnails, 0); |
|
232 break; |
|
233 |
|
234 default: |
|
235 iServiceHandler->ExecuteMenuCmdL( |
|
236 aCommand, |
|
237 iServiceHandler->InParamListL(), // No input parameters |
|
238 iServiceHandler->OutParamListL(), // No output parameters |
|
239 0, // No options used. |
|
240 NULL); // No need for callback |
|
241 |
|
242 DebugPrintF(_L("CEdtaAppUi::HandleCommandL: AIW (or unknown) menu command: 0x%X"), aCommand ); |
|
243 break; |
|
244 } |
|
245 |
|
246 DebugPrintF(_L("CEdtaAppUi::HandleCommandL exit")); |
|
247 } |
|
248 |
|
249 |
|
250 void CEdtaAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
251 { |
|
252 // First, offer menu pane to AIW framework. It might be the case, that the |
|
253 // user is opening an AIW submenu. In this case, the AIW handles the menu. |
|
254 if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) ) |
|
255 { |
|
256 return; |
|
257 } |
|
258 |
|
259 // Add your normal (non-AIW) menu initialisation code here... |
|
260 |
|
261 // Let AIW provider add its menu items to the menu. |
|
262 iServiceHandler->InitializeMenuPaneL( |
|
263 *aMenuPane, |
|
264 aResourceId, |
|
265 EEdtaCommandLast, |
|
266 iServiceHandler->InParamListL()); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // Called by the framework when the application status pane |
|
271 // size is changed. Passes the new client rectangle to the |
|
272 // AppView |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CEdtaAppUi::HandleStatusPaneSizeChange() |
|
276 { |
|
277 iAppView->SetRect( ClientRect() ); |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // Display note id easydialing plugin is not loaded |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TBool CEdtaAppUi::CheckPluginLoadedAndShowNote() |
|
287 { |
|
288 TBool plugin_loaded( ETrue ); |
|
289 |
|
290 if( !(iAppView->GetEasyDialer()) ) |
|
291 { |
|
292 plugin_loaded = EFalse; |
|
293 TBuf<KEdtaMaxLineWidth> tempStr; |
|
294 tempStr.Copy(_L("Easydialing plugin not loaded!")); |
|
295 |
|
296 TRAP_IGNORE( |
|
297 { |
|
298 CAknErrorNote* myNote = new (ELeave) CAknErrorNote(); |
|
299 myNote->SetTimeout( CAknNoteDialog::ELongTimeout ); |
|
300 myNote->ExecuteLD( tempStr ); |
|
301 } |
|
302 ); |
|
303 } |
|
304 |
|
305 DebugPrintF(_L("CEdtaAppUi::CheckPluginLoadedAndShowNote: Plugin loaded: %d"), plugin_loaded ); |
|
306 |
|
307 return plugin_loaded; |
|
308 } |
|
309 |
|
310 // End of File |