|
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: AppUi implementation, all functions here |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <avkon.hrh> |
|
20 #include <aknnotewrappers.h> |
|
21 #include <AknQueryDialog.h> |
|
22 #include <aknmessagequerydialog.h> |
|
23 #include <w32std.h> |
|
24 #include <eikmenup.h> |
|
25 #include <commdb.h> |
|
26 |
|
27 #include <HtiAdmin.rsg> |
|
28 #include <HtiCommPluginInterface.h> // for KHTICommInterfaceUid |
|
29 #include <HtiCfg.h> |
|
30 #include <HtiVersion.h> |
|
31 |
|
32 #include "HtiAdmin.pan" |
|
33 #include "HtiAdminAppUi.h" |
|
34 #include "HtiAdminAppView.h" |
|
35 #include "HtiAdmin.hrh" |
|
36 |
|
37 |
|
38 #ifdef __ENABLE_LOGGING__ |
|
39 |
|
40 #include <flogger.h> |
|
41 |
|
42 _LIT(KLogFolder, "hti"); |
|
43 _LIT(KLogFile, "htiadmin.txt"); |
|
44 #define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);} |
|
45 #define HTI_LOG_FORMAT(a1,a2) {_LIT(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, (a2));} |
|
46 #define HTI_LOG_DES(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, (a1));} |
|
47 |
|
48 #else // __ENABLE_LOGGING__ |
|
49 |
|
50 #define HTI_LOG_TEXT(a1) |
|
51 #define HTI_LOG_FORMAT(a1,a2) |
|
52 #define HTI_LOG_DES(a1) |
|
53 |
|
54 #endif // __ENABLE_LOGGING__ |
|
55 |
|
56 // CONSTANTS |
|
57 _LIT( KHtiWatchDogMatchPattern, "HtiWatchDog*" ); |
|
58 _LIT( KHtiFrameworkExe, "HtiFramework.exe" ); |
|
59 _LIT( KHtiMatchPattern, "HtiFramework*" ); |
|
60 _LIT( KHtiFrameworkCaption, "HTI status: " ); |
|
61 _LIT( KHtiAutoStartCaption, "AutoStart: " ); |
|
62 _LIT( KHtiVersionCaption, "Version: " ); |
|
63 _LIT( KHtiSelectedCommCaption, "Communication: " ); |
|
64 _LIT( KHtiAdminStartParameter, "admin" ); |
|
65 _LIT( KHtiAdminVersionFormat, "%u.%u.%u (%uwk%02u)" ); |
|
66 _LIT( KHtiAdminAboutVersionFormat, "Version %u.%u.%u - " ); |
|
67 const static TInt KTerminateReason = 1; |
|
68 |
|
69 |
|
70 const TInt32 KHTIImplUidSerial = {0x10210CCA}; |
|
71 const TInt32 KHTIImplUidBluetooth = {0x200212CC}; |
|
72 const TInt32 KHTIImplUidIPComm = {0x200212CE}; |
|
73 |
|
74 // configuration file constants |
|
75 _LIT( KCfgFilePath, "\\"); |
|
76 _LIT( KHtiCfg, "hti.cfg" ); |
|
77 _LIT( KHtiBtCommCfg, "HTIBtComm.cfg" ); |
|
78 _LIT( KHtiSerialCommCfg , "HTISerialComm.cfg" ); |
|
79 _LIT( KHtiIPCommCfg, "HTIIPComm.cfg" ); |
|
80 // hti.cfg |
|
81 _LIT8( KCommPlugin, "CommPlugin" ); |
|
82 _LIT8( KPriority, "Priority" ); |
|
83 _LIT8( KShowConsole, "ShowConsole" ); |
|
84 _LIT8( KEnableHtiWatchDog, "EnableHtiWatchDog" ); |
|
85 _LIT8( KEnableHtiAutoStart, "EnableHtiAutoStart" ); |
|
86 _LIT8( KShowErrorDialogs, "ShowErrorDialogs" ); |
|
87 // HtiBtComm.cfg |
|
88 _LIT8( KBtDeviceAddress, "BtDeviceAddress" ); |
|
89 _LIT8( KBtDeviceName, "BtDeviceName" ); |
|
90 // HtiSerialComm.cfg |
|
91 _LIT8( KCommPortNumber, "CommPort" ); |
|
92 // HTIIPComm.cfg |
|
93 _LIT8( KLocalPort, "LocalPort" ); |
|
94 _LIT8( KRemoteHost, "RemoteHost" ); |
|
95 _LIT8( KRemotePort, "RemotePort" ); |
|
96 _LIT8( KIAPName, "IAPName" ); |
|
97 |
|
98 |
|
99 // ConstructL is called by the application framework |
|
100 void CHtiAdminAppUi::ConstructL() |
|
101 { |
|
102 BaseConstructL( EAknEnableSkin ); |
|
103 iAppView = CHtiAdminAppView::NewL( ClientRect() ); |
|
104 AddToStackL( iAppView ); |
|
105 |
|
106 iAppView->SetCaption( KHtiFrameworkCaption ); |
|
107 iAppView->SetVersionCaption( KHtiVersionCaption ); |
|
108 iAppView->SetAutoStartCaption( KHtiAutoStartCaption ); |
|
109 iAppView->SetSelectedCommCaption( KHtiSelectedCommCaption ); |
|
110 UpdateVersion(); |
|
111 UpdateStatusL(); |
|
112 StartTimer(); |
|
113 iHtiCfg = CHtiCfg::NewL(); |
|
114 UpdateAutoStartStatus(); // uses iHtiCfg |
|
115 UpdateSelectedComm(); // uses iHtiCfg |
|
116 } |
|
117 |
|
118 CHtiAdminAppUi::CHtiAdminAppUi() |
|
119 { |
|
120 iHtiCfg = NULL; |
|
121 } |
|
122 |
|
123 CHtiAdminAppUi::~CHtiAdminAppUi() |
|
124 { |
|
125 KillTimer(); |
|
126 if ( iAppView ) |
|
127 { |
|
128 RemoveFromStack( iAppView ); |
|
129 delete iAppView; |
|
130 iAppView = NULL; |
|
131 } |
|
132 |
|
133 if ( iHtiCfg ) |
|
134 delete iHtiCfg; |
|
135 } |
|
136 |
|
137 void CHtiAdminAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane) |
|
138 { |
|
139 HTI_LOG_FORMAT( "DynInitMenuPaneL 0x%x", aResourceId ); |
|
140 |
|
141 if ( aResourceId == R_HTIADMIN_MENU ) |
|
142 { |
|
143 RProcess prs; |
|
144 if ( OpenHtiProcess( prs ) ) |
|
145 { |
|
146 if ( prs.ExitType() == EExitPending ) |
|
147 { |
|
148 aMenuPane->SetItemDimmed( EHtiAdminStart, ETrue ); |
|
149 aMenuPane->SetItemDimmed( EHtiAdminSubOptions, ETrue ); |
|
150 prs.Close(); |
|
151 return; |
|
152 } |
|
153 } |
|
154 aMenuPane->SetItemDimmed( EHtiAdminStop, ETrue ); |
|
155 prs.Close(); |
|
156 } |
|
157 |
|
158 else if ( aResourceId == R_HTIADMIN_SUBMENU_OPTIONS ) |
|
159 { |
|
160 #if !defined(__ENABLE_LOGGING__) |
|
161 aMenuPane->SetItemDimmed( EHtiAdminSubLogs, ETrue ); |
|
162 #endif |
|
163 } |
|
164 else if ( aResourceId == R_HTIADMIN_SUBMENU_PRIORITY ) |
|
165 { |
|
166 TInt priority = 3; // default value |
|
167 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
168 if ( !err ) |
|
169 { |
|
170 TRAP( err, priority = iHtiCfg->GetParameterIntL( KPriority ) ); |
|
171 } |
|
172 |
|
173 switch ( priority ) |
|
174 { |
|
175 case 1: |
|
176 aMenuPane->SetItemButtonState( EHtiAdminPriorityBackground, EEikMenuItemSymbolOn ); |
|
177 break; |
|
178 case 2: |
|
179 aMenuPane->SetItemButtonState( EHtiAdminPriorityForeground, EEikMenuItemSymbolOn ); |
|
180 break; |
|
181 case 4: |
|
182 aMenuPane->SetItemButtonState( EHtiAdminPriorityAbsoluteHigh, EEikMenuItemSymbolOn ); |
|
183 break; |
|
184 default: |
|
185 aMenuPane->SetItemButtonState( EHtiAdminPriorityHigh, EEikMenuItemSymbolOn ); |
|
186 break; |
|
187 } |
|
188 } |
|
189 |
|
190 else if ( aResourceId == R_HTIADMIN_SUBMENU_AUTOSTART ) |
|
191 { |
|
192 #ifdef __WINS__ |
|
193 TInt value = 0; // default value for emulator |
|
194 #else |
|
195 TInt value = 1; // default value for hardware |
|
196 #endif |
|
197 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
198 if ( !err ) |
|
199 { |
|
200 TRAP( err, value = iHtiCfg->GetParameterIntL( KEnableHtiAutoStart ) ); |
|
201 } |
|
202 |
|
203 if ( value ) |
|
204 aMenuPane->SetItemButtonState( EHtiAdminAutoStartEnable, EEikMenuItemSymbolOn ); |
|
205 else |
|
206 aMenuPane->SetItemButtonState( EHtiAdminAutoStartDisable, EEikMenuItemSymbolOn ); |
|
207 } |
|
208 |
|
209 else if ( aResourceId == R_HTIADMIN_SUBMENU_WATCHDOG ) |
|
210 { |
|
211 TInt value = 0; // default value |
|
212 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
213 if ( !err ) |
|
214 { |
|
215 TRAP( err, value = iHtiCfg->GetParameterIntL( KEnableHtiWatchDog ) ); |
|
216 } |
|
217 |
|
218 if ( value ) |
|
219 aMenuPane->SetItemButtonState( EHtiAdminWatchDogEnable, EEikMenuItemSymbolOn ); |
|
220 else |
|
221 aMenuPane->SetItemButtonState( EHtiAdminWatchDogDisable, EEikMenuItemSymbolOn ); |
|
222 } |
|
223 |
|
224 else if ( aResourceId == R_HTIADMIN_SUBMENU_CONSOLE ) |
|
225 { |
|
226 TInt value = 0; // default value |
|
227 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
228 if ( !err ) |
|
229 { |
|
230 TRAP( err, value = iHtiCfg->GetParameterIntL( KShowConsole ) ); |
|
231 } |
|
232 |
|
233 if ( value ) |
|
234 aMenuPane->SetItemButtonState( EHtiAdminConsoleEnable, EEikMenuItemSymbolOn ); |
|
235 else |
|
236 aMenuPane->SetItemButtonState( EHtiAdminConsoleDisable, EEikMenuItemSymbolOn ); |
|
237 } |
|
238 |
|
239 else if ( aResourceId == R_HTIADMIN_SUBMENU_ERROR_DIALOGS ) |
|
240 { |
|
241 TInt value = 1; // default value |
|
242 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
243 if ( !err ) |
|
244 { |
|
245 TRAP( err, value = iHtiCfg->GetParameterIntL( KShowErrorDialogs ) ); |
|
246 } |
|
247 |
|
248 if ( value ) |
|
249 aMenuPane->SetItemButtonState( EHtiAdminErrorDialogsEnable, EEikMenuItemSymbolOn ); |
|
250 else |
|
251 aMenuPane->SetItemButtonState( EHtiAdminErrorDialogsDisable, EEikMenuItemSymbolOn ); |
|
252 } |
|
253 } |
|
254 |
|
255 |
|
256 // Helper function to get data from a dialog |
|
257 TInt ShowDialog(TInt aResourceId, const TDesC &aText, TDes8 &aValue) |
|
258 { |
|
259 TBuf<KMaxParameterValueLength> data; |
|
260 |
|
261 CAknTextQueryDialog* dlg; |
|
262 dlg = new (ELeave) CAknTextQueryDialog(data); |
|
263 CleanupStack::PushL(dlg); |
|
264 dlg->SetPromptL(aText); |
|
265 dlg->SetMaxLength(KMaxParameterValueLength); |
|
266 CleanupStack::Pop(); // dlg |
|
267 |
|
268 if ( dlg->ExecuteLD( aResourceId ) ) |
|
269 { |
|
270 aValue.Copy(data); |
|
271 return KErrNone; |
|
272 } |
|
273 |
|
274 return KErrCancel; |
|
275 } |
|
276 |
|
277 void CHtiAdminAppUi::ShowBTListQueryL() |
|
278 { |
|
279 TInt selectedOption( KErrNotFound ); |
|
280 |
|
281 CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(20); |
|
282 CleanupStack::PushL(array); |
|
283 |
|
284 array->AppendL(_L("By BT address")); |
|
285 array->AppendL(_L("By BT Name")); |
|
286 array->AppendL(_L("Search when starting")); |
|
287 |
|
288 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption ); |
|
289 dlg->PrepareLC(R_QUERY_DIALOG); |
|
290 dlg->SetItemTextArray(array); |
|
291 dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
292 dlg->RunLD(); |
|
293 |
|
294 CleanupStack::PopAndDestroy(array); |
|
295 |
|
296 if(selectedOption == 0) |
|
297 { |
|
298 HandleBtByAddress(); |
|
299 } |
|
300 else if(selectedOption == 1) |
|
301 { |
|
302 HandleBtByName(); |
|
303 } |
|
304 else if (selectedOption == 2) |
|
305 { |
|
306 HandleBtSearch(); |
|
307 } |
|
308 } |
|
309 |
|
310 void CHtiAdminAppUi::ShowIPListQueryL() |
|
311 { |
|
312 TInt selectedOption( KErrNotFound ); |
|
313 |
|
314 CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(10); |
|
315 CleanupStack::PushL(array); |
|
316 |
|
317 array->AppendL(_L("Listen")); |
|
318 array->AppendL(_L("Connect")); |
|
319 |
|
320 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption ); |
|
321 dlg->PrepareLC(R_QUERY_DIALOG); |
|
322 dlg->SetItemTextArray(array); |
|
323 dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
324 dlg->RunLD(); |
|
325 |
|
326 CleanupStack::PopAndDestroy(array); |
|
327 |
|
328 if(selectedOption == 0) |
|
329 { |
|
330 HandleIPListen(); |
|
331 } |
|
332 else if(selectedOption == 1) |
|
333 { |
|
334 HandleIPConnect(); |
|
335 } |
|
336 } |
|
337 |
|
338 void CleanupRArray( TAny* object ) |
|
339 { |
|
340 ( ( RImplInfoPtrArray* ) object )->ResetAndDestroy(); |
|
341 } |
|
342 |
|
343 void CHtiAdminAppUi::ShowCommsListQueryL() |
|
344 { |
|
345 TInt selectedOption( KErrNotFound ); |
|
346 |
|
347 const TInt pluginNameArrayGranularity (15); |
|
348 CDesCArrayFlat* pluginNameArray = new (ELeave) CDesCArrayFlat(pluginNameArrayGranularity); |
|
349 CleanupStack::PushL(pluginNameArray); |
|
350 |
|
351 RImplInfoPtrArray implInfoArray; |
|
352 CleanupStack::PushL( TCleanupItem( CleanupRArray, &implInfoArray ) ); |
|
353 |
|
354 REComSession::ListImplementationsL( KHTICommInterfaceUid, implInfoArray ); |
|
355 |
|
356 for ( TInt i = 0; i < implInfoArray.Count(); ++i ) |
|
357 { |
|
358 pluginNameArray->AppendL(implInfoArray[i]->DisplayName()); |
|
359 } |
|
360 |
|
361 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption ); |
|
362 |
|
363 dlg->PrepareLC(R_QUERY_DIALOG); |
|
364 dlg->SetHeaderTextL(_L("Select communication")); |
|
365 dlg->SetItemTextArray(pluginNameArray); |
|
366 dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
367 |
|
368 if(dlg->RunLD()) |
|
369 { |
|
370 TInt32 uid = implInfoArray[selectedOption]->ImplementationUid().iUid; |
|
371 switch(uid) |
|
372 { |
|
373 case KHTIImplUidSerial: |
|
374 { |
|
375 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
376 iHtiCfg->SetParameterL( KCommPlugin, _L8( "SERIAL" ) ); |
|
377 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
378 |
|
379 TBuf8<KMaxParameterValueLength> portNum; |
|
380 if ( !ShowDialog( R_NUMERIC_QUERY, _L("Com port number:"), portNum ) ) |
|
381 { |
|
382 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiSerialCommCfg ) ); |
|
383 iHtiCfg->SetParameterL( KCommPortNumber, portNum ); |
|
384 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiSerialCommCfg ); |
|
385 } |
|
386 UpdateSelectedComm(); |
|
387 } |
|
388 break; |
|
389 |
|
390 case KHTIImplUidBluetooth: |
|
391 { |
|
392 ShowBTListQueryL(); |
|
393 } |
|
394 break; |
|
395 |
|
396 case KHTIImplUidIPComm: |
|
397 { |
|
398 ShowIPListQueryL(); |
|
399 } |
|
400 break; |
|
401 default: |
|
402 { |
|
403 //Just save the conf info for other plugins |
|
404 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
405 iHtiCfg->SetParameterL( KCommPlugin, implInfoArray[selectedOption]->DataType() ); |
|
406 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
407 UpdateSelectedComm(); |
|
408 } |
|
409 } |
|
410 } |
|
411 CleanupStack::PopAndDestroy(2, pluginNameArray); |
|
412 } |
|
413 |
|
414 void CHtiAdminAppUi::HandleBtByAddress() |
|
415 { |
|
416 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
417 iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); |
|
418 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
419 |
|
420 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); |
|
421 iHtiCfg->RemoveParameterL( KBtDeviceName ); |
|
422 iHtiCfg->RemoveParameterL( KBtDeviceAddress ); |
|
423 |
|
424 TBuf8<KMaxParameterValueLength> address; |
|
425 if ( !ShowDialog( R_TEXT_QUERY, _L("BT address:"), address) ) |
|
426 { |
|
427 iHtiCfg->SetParameterL( KBtDeviceAddress, address); |
|
428 } |
|
429 |
|
430 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg); |
|
431 UpdateSelectedComm(); |
|
432 } |
|
433 |
|
434 void CHtiAdminAppUi::HandleBtByName() |
|
435 { |
|
436 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
437 iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); |
|
438 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
439 |
|
440 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); |
|
441 iHtiCfg->RemoveParameterL( KBtDeviceName ); |
|
442 iHtiCfg->RemoveParameterL( KBtDeviceAddress ); |
|
443 |
|
444 TBuf8<KMaxParameterValueLength> name; |
|
445 if ( !ShowDialog( R_TEXT_QUERY, _L( "BT name:" ), name ) ) |
|
446 { |
|
447 iHtiCfg->SetParameterL( KBtDeviceName, name ); |
|
448 } |
|
449 |
|
450 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg ); |
|
451 UpdateSelectedComm(); |
|
452 } |
|
453 |
|
454 void CHtiAdminAppUi::HandleBtSearch() |
|
455 { |
|
456 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
457 iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); |
|
458 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
459 |
|
460 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); |
|
461 iHtiCfg->RemoveParameterL( KBtDeviceName ); |
|
462 iHtiCfg->RemoveParameterL( KBtDeviceAddress ); |
|
463 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg ); |
|
464 UpdateSelectedComm(); |
|
465 } |
|
466 |
|
467 void CHtiAdminAppUi::HandleIPListen() |
|
468 { |
|
469 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
470 iHtiCfg->SetParameterL( KCommPlugin, _L8("IPCOMM")); |
|
471 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
472 |
|
473 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); |
|
474 iHtiCfg->RemoveParameterL( KRemotePort ); |
|
475 iHtiCfg->RemoveParameterL( KRemoteHost ); |
|
476 |
|
477 TBuf8<KMaxParameterValueLength> localPort; |
|
478 if ( !ShowDialog( R_TEXT_QUERY, _L( "Local port:" ), localPort ) ) |
|
479 { |
|
480 iHtiCfg->SetParameterL( KLocalPort, localPort ); |
|
481 ShowCommsDBListQueryL(); |
|
482 } |
|
483 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiIPCommCfg ); |
|
484 UpdateSelectedComm(); |
|
485 } |
|
486 |
|
487 void CHtiAdminAppUi::HandleIPConnect() |
|
488 { |
|
489 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
490 iHtiCfg->SetParameterL( KCommPlugin, _L8( "IPCOMM" ) ); |
|
491 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
492 |
|
493 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); |
|
494 iHtiCfg->RemoveParameterL( KLocalPort ); |
|
495 TBuf8<KMaxParameterValueLength> remoteHost; |
|
496 TBuf8<KMaxParameterValueLength> remotePort; |
|
497 if ( !ShowDialog( R_TEXT_QUERY, _L("Remote host:"), remoteHost ) ) |
|
498 { |
|
499 iHtiCfg->SetParameterL( KRemoteHost, remoteHost ); |
|
500 if ( !ShowDialog( R_TEXT_QUERY, _L( "Remote port:" ), remotePort ) ) |
|
501 { |
|
502 iHtiCfg->SetParameterL( KRemotePort, remotePort ); |
|
503 ShowCommsDBListQueryL(); |
|
504 } |
|
505 } |
|
506 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiIPCommCfg ); |
|
507 UpdateSelectedComm(); |
|
508 } |
|
509 |
|
510 |
|
511 // handle any menu commands |
|
512 void CHtiAdminAppUi::HandleCommandL(TInt aCommand) |
|
513 { |
|
514 TFileName cfgFile; |
|
515 |
|
516 switch ( aCommand ) |
|
517 { |
|
518 case EEikCmdExit: |
|
519 case EAknSoftkeyExit: |
|
520 Exit(); |
|
521 break; |
|
522 |
|
523 case EHtiAdminStart: |
|
524 { |
|
525 HTI_LOG_TEXT( "Start" ); |
|
526 RProcess prs; |
|
527 TInt err; |
|
528 TBool isRunning = EFalse; |
|
529 if ( OpenHtiProcess( prs ) ) |
|
530 { |
|
531 if ( prs.ExitType() == EExitPending ) |
|
532 { |
|
533 isRunning = ETrue; |
|
534 _LIT(KText, "Already running"); |
|
535 iAppView->SetStatus( KText ); |
|
536 } |
|
537 prs.Close(); |
|
538 } |
|
539 |
|
540 if ( !isRunning ) |
|
541 { |
|
542 HTI_LOG_TEXT( "create process" ); |
|
543 err = prs.Create( KHtiFrameworkExe, KHtiAdminStartParameter ); |
|
544 if ( err == KErrNone ) |
|
545 { |
|
546 prs.Resume(); |
|
547 prs.Close(); |
|
548 UpdateStatusL(); |
|
549 HTI_LOG_TEXT("create done"); |
|
550 } |
|
551 else |
|
552 { |
|
553 TBuf<64> msg; |
|
554 msg.Format( _L("Error in starting: %d"), err ); |
|
555 iAppView->SetStatus( msg ); |
|
556 HTI_LOG_TEXT("create error"); |
|
557 } |
|
558 } |
|
559 } |
|
560 break; |
|
561 |
|
562 case EHtiAdminStop: |
|
563 { |
|
564 HTI_LOG_TEXT("Stop"); |
|
565 |
|
566 // kill the watchdog to prevent it from restarting HTI again |
|
567 KillHtiWatchDogL(); |
|
568 |
|
569 RProcess prs; |
|
570 if ( OpenHtiProcess( prs ) ) |
|
571 { |
|
572 if ( prs.ExitType() == EExitPending ) |
|
573 { |
|
574 HTI_LOG_TEXT("try to kill"); |
|
575 prs.Kill( KTerminateReason ); |
|
576 UpdateStatusL(); |
|
577 } |
|
578 else |
|
579 { |
|
580 _LIT(KText, "Already stopped"); |
|
581 iAppView->SetStatus( KText ); |
|
582 } |
|
583 prs.Close(); |
|
584 } |
|
585 } |
|
586 break; |
|
587 |
|
588 case EHtiAdminAbout: |
|
589 { |
|
590 HTI_LOG_TEXT("About"); |
|
591 TDateSuffix suffix( KHtiVersionDay - 1 ); |
|
592 TMonthName month( ( TMonth ) ( KHtiVersionMonth - 1 ) ); |
|
593 TBuf<64> msgPart1; |
|
594 msgPart1.Format( KHtiAdminAboutVersionFormat, |
|
595 KHtiVersionMajor, KHtiVersionMinor, KHtiVersionBuild ); |
|
596 msgPart1.AppendNum( KHtiVersionDay ); |
|
597 msgPart1.Append( suffix ); |
|
598 msgPart1.Append( ' ' ); |
|
599 msgPart1.Append( month ); |
|
600 msgPart1.Append( ' ' ); |
|
601 msgPart1.AppendNum( KHtiVersionYear ); |
|
602 msgPart1.Append( '.' ); |
|
603 msgPart1.Append( ' ' ); |
|
604 HBufC* msgPart2 = iEikonEnv->AllocReadResourceLC( R_HTIADMIN_ABOUT_TEXT ); |
|
605 HBufC* fullMsg = HBufC::NewLC( msgPart1.Length() + msgPart2->Length() ); |
|
606 fullMsg->Des().Append( msgPart1 ); |
|
607 fullMsg->Des().Append( *msgPart2 ); |
|
608 CAknMessageQueryDialog* dialog = new ( ELeave ) CAknMessageQueryDialog; |
|
609 dialog->PrepareLC( R_HTIADMIN_ABOUT_DIALOG ); |
|
610 dialog->SetMessageTextL( *fullMsg ); |
|
611 dialog->RunLD(); |
|
612 CleanupStack::PopAndDestroy( 2 ); // fullMsg, msgPart2 |
|
613 } |
|
614 break; |
|
615 |
|
616 case EHtiAdminSubOptions: |
|
617 break; |
|
618 |
|
619 case EHtiAdminSubLogs: |
|
620 break; |
|
621 |
|
622 case EHtiAdminCreateLogFolder: |
|
623 #ifdef __ENABLE_LOGGING__ |
|
624 { |
|
625 TInt err = KErrNone; |
|
626 RFs fs; |
|
627 err = fs.Connect(); |
|
628 if ( err == KErrNone ) |
|
629 { |
|
630 err = fs.MkDirAll(_L("c:\\logs\\hti\\")); |
|
631 } |
|
632 fs.Close(); |
|
633 } |
|
634 #endif |
|
635 break; |
|
636 |
|
637 case EHtiAdminRemoveLogFolder: |
|
638 #ifdef __ENABLE_LOGGING__ |
|
639 { |
|
640 TInt err = KErrNone; |
|
641 RFs fs; |
|
642 err = fs.Connect(); |
|
643 if ( err == KErrNone ) |
|
644 { |
|
645 CFileMan *fileman = CFileMan::NewL( fs ); |
|
646 fileman->RmDir( _L( "c:\\logs\\hti\\" ) ); |
|
647 delete fileman; |
|
648 } |
|
649 fs.Close(); |
|
650 } |
|
651 #endif |
|
652 break; |
|
653 |
|
654 case EHtiAdminClearLogs: |
|
655 #ifdef __ENABLE_LOGGING__ |
|
656 { |
|
657 TInt err = KErrNone; |
|
658 RFs fs; |
|
659 err = fs.Connect(); |
|
660 if ( err == KErrNone ) |
|
661 { |
|
662 CFileMan *fileman = CFileMan::NewL( fs ); |
|
663 fileman->Delete( _L( "c:\\logs\\hti\\*" ) ); |
|
664 fileman->Delete( _L( "c:\\HTI_*.log" ) ); |
|
665 delete fileman; |
|
666 } |
|
667 fs.Close(); |
|
668 } |
|
669 #endif |
|
670 break; |
|
671 |
|
672 case EHtiAdminSubComms: |
|
673 { |
|
674 ShowCommsListQueryL(); |
|
675 } |
|
676 break; |
|
677 |
|
678 case EHtiAdminSubPriority: |
|
679 break; |
|
680 |
|
681 case EHtiAdminPriorityBackground: |
|
682 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
683 iHtiCfg->SetParameterL( KPriority, _L8("1")); |
|
684 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
685 break; |
|
686 |
|
687 case EHtiAdminPriorityForeground: |
|
688 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
689 iHtiCfg->SetParameterL( KPriority, _L8("2")); |
|
690 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
691 break; |
|
692 |
|
693 case EHtiAdminPriorityHigh: |
|
694 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
695 iHtiCfg->SetParameterL( KPriority, _L8("3")); |
|
696 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
697 break; |
|
698 |
|
699 case EHtiAdminPriorityAbsoluteHigh: |
|
700 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
701 iHtiCfg->SetParameterL( KPriority, _L8("4")); |
|
702 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
703 break; |
|
704 |
|
705 case EHtiAdminSubAutoStart: |
|
706 break; |
|
707 |
|
708 case EHtiAdminAutoStartEnable: |
|
709 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
710 iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("1")); |
|
711 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
712 UpdateAutoStartStatus(); |
|
713 break; |
|
714 |
|
715 case EHtiAdminAutoStartDisable: |
|
716 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
717 iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("0")); |
|
718 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
719 UpdateAutoStartStatus(); |
|
720 break; |
|
721 |
|
722 case EHtiAdminSubWatchDog: |
|
723 break; |
|
724 |
|
725 case EHtiAdminWatchDogEnable: |
|
726 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
727 iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("1")); |
|
728 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
729 break; |
|
730 |
|
731 case EHtiAdminWatchDogDisable: |
|
732 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
733 iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("0")); |
|
734 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
735 break; |
|
736 |
|
737 case EHtiAdminSubConsole: |
|
738 break; |
|
739 |
|
740 case EHtiAdminConsoleEnable: |
|
741 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
742 iHtiCfg->SetParameterL( KShowConsole, _L8("1")); |
|
743 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
744 break; |
|
745 |
|
746 case EHtiAdminConsoleDisable: |
|
747 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
748 iHtiCfg->SetParameterL( KShowConsole, _L8("0")); |
|
749 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
750 break; |
|
751 |
|
752 case EHtiAdminErrorDialogsEnable: |
|
753 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
754 iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("1")); |
|
755 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
756 break; |
|
757 |
|
758 case EHtiAdminErrorDialogsDisable: |
|
759 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
760 iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("0")); |
|
761 iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); |
|
762 break; |
|
763 |
|
764 case EHtiAdminSubSetParam: |
|
765 break; |
|
766 |
|
767 case EHtiAdminHtiCfg: |
|
768 cfgFile = KHtiCfg; |
|
769 |
|
770 case EHtiAdminHtiBtCommCfg: |
|
771 if ( !cfgFile.Length() ) |
|
772 cfgFile = KHtiBtCommCfg; |
|
773 |
|
774 case EHtiAdminHtiIPCommCfg: |
|
775 if ( !cfgFile.Length() ) |
|
776 cfgFile = KHtiIPCommCfg; |
|
777 |
|
778 case EHtiAdminHtiSerialCommCfg: |
|
779 { |
|
780 if ( !cfgFile.Length() ) |
|
781 cfgFile = KHtiSerialCommCfg; |
|
782 |
|
783 TBuf8<KMaxParameterNameLength> parameterName; |
|
784 if ( !ShowDialog( R_TEXT_QUERY, _L("Parameter name:"), parameterName) ) |
|
785 { |
|
786 TBuf8<KMaxParameterValueLength> parameterValue; |
|
787 if ( !ShowDialog( R_TEXT_QUERY, _L("Parameter value:"), parameterValue ) ) |
|
788 { |
|
789 TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, cfgFile ) ); |
|
790 iHtiCfg->SetParameterL( parameterName, parameterValue ); |
|
791 iHtiCfg->SaveCfgL( KCfgFilePath, cfgFile); |
|
792 } |
|
793 } |
|
794 } |
|
795 break; |
|
796 |
|
797 default: |
|
798 { |
|
799 CAknErrorNote* dialog = new(ELeave)CAknErrorNote(ETrue); |
|
800 dialog->ExecuteLD(_L("Unknown Command Recieved")); |
|
801 } |
|
802 break; |
|
803 } |
|
804 } |
|
805 |
|
806 void CHtiAdminAppUi::HandleForegroundEventL( TBool aForeground ) |
|
807 { |
|
808 CAknAppUi::HandleForegroundEventL( aForeground ); |
|
809 |
|
810 if ( aForeground ) |
|
811 { |
|
812 UpdateStatusL(); |
|
813 UpdateAutoStartStatus(); |
|
814 StartTimer(); |
|
815 } |
|
816 else |
|
817 { |
|
818 KillTimer(); |
|
819 } |
|
820 } |
|
821 |
|
822 TBool CHtiAdminAppUi::OpenHtiProcess( RProcess& aPrs ) |
|
823 { |
|
824 HTI_LOG_TEXT( "OpenHtiProcess" ); |
|
825 |
|
826 TFullName processName; |
|
827 TInt err; |
|
828 |
|
829 TFindProcess finder( KHtiMatchPattern ); |
|
830 err = finder.Next( processName ); |
|
831 if ( err == KErrNone ) |
|
832 { |
|
833 HTI_LOG_TEXT( "try to open..." ); |
|
834 err = aPrs.Open( finder ); |
|
835 HTI_LOG_TEXT( "opened" ); |
|
836 |
|
837 if ( err == KErrNone ) |
|
838 { |
|
839 HTI_LOG_TEXT( "OpenHtiProcess OK" ); |
|
840 return ETrue; |
|
841 } |
|
842 else |
|
843 { |
|
844 HTI_LOG_TEXT( "Failed to open process" ); |
|
845 TBuf<64> msg; |
|
846 msg.Format( _L( "Error: %d" ), err ); |
|
847 iAppView->SetStatus( msg ); |
|
848 } |
|
849 } |
|
850 else if ( err == KErrNotFound ) |
|
851 { |
|
852 HTI_LOG_TEXT( "Not found" ); |
|
853 _LIT( KNotFound, "Stopped" ); |
|
854 iAppView->SetStatus( KNotFound ); |
|
855 } |
|
856 else |
|
857 { |
|
858 TBuf<64> msg; |
|
859 msg.Format( _L( "Error: %d" ), err ); |
|
860 iAppView->SetStatus( msg ); |
|
861 } |
|
862 |
|
863 HTI_LOG_TEXT( "OpenHtiProcess NOK" ); |
|
864 |
|
865 return EFalse; |
|
866 } |
|
867 |
|
868 |
|
869 void CHtiAdminAppUi::UpdateVersion() |
|
870 { |
|
871 HTI_LOG_TEXT( "UpdateVersion" ); |
|
872 TBuf<128> tmp; |
|
873 tmp.Format( KHtiAdminVersionFormat, KHtiVersionMajor, KHtiVersionMinor, |
|
874 KHtiVersionBuild, KHtiVersionYear, KHtiVersionWeek ); |
|
875 iAppView->SetVersion( tmp ); |
|
876 } |
|
877 |
|
878 |
|
879 void CHtiAdminAppUi::UpdateStatusL() |
|
880 { |
|
881 HTI_LOG_TEXT( "UpdateStatusL" ); |
|
882 RProcess prs; |
|
883 if ( OpenHtiProcess( prs ) ) |
|
884 { |
|
885 HTI_LOG_TEXT( "Update display" ); |
|
886 TExitType exT = prs.ExitType(); |
|
887 |
|
888 switch ( exT ) |
|
889 { |
|
890 case EExitPending: |
|
891 { |
|
892 _LIT( KTxt, "Running" ); |
|
893 iAppView->SetStatus( KTxt ); |
|
894 } |
|
895 break; |
|
896 |
|
897 case EExitKill: |
|
898 case EExitTerminate: |
|
899 { |
|
900 _LIT( KTxt, "Stopped" ); |
|
901 iAppView->SetStatus( KTxt ); |
|
902 } |
|
903 break; |
|
904 |
|
905 case EExitPanic: |
|
906 { |
|
907 _LIT( KTxt, "Panic" ); |
|
908 iAppView->SetStatus( KTxt ); |
|
909 } |
|
910 break; |
|
911 }; |
|
912 prs.Close(); |
|
913 } |
|
914 } |
|
915 |
|
916 void CHtiAdminAppUi::UpdateAutoStartStatus() |
|
917 { |
|
918 HTI_LOG_TEXT( "UpdateAutoStartStatus" ); |
|
919 TInt value = KErrNotFound; |
|
920 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
921 if ( !err ) |
|
922 { |
|
923 TRAP( err, value = iHtiCfg->GetParameterIntL(KEnableHtiAutoStart) ); |
|
924 } |
|
925 |
|
926 if ( value == KErrNotFound ) |
|
927 { |
|
928 // Use default values if not found from config. |
|
929 #ifdef __WINS__ |
|
930 value = 0; |
|
931 #else |
|
932 value = 1; |
|
933 #endif |
|
934 } |
|
935 |
|
936 if ( value == 0 ) |
|
937 { |
|
938 _LIT( KTxt, "Disabled" ); |
|
939 iAppView->SetAutoStartStatus( KTxt ); |
|
940 } |
|
941 else if ( value == 1 ) |
|
942 { |
|
943 _LIT( KTxt, "Enabled" ); |
|
944 iAppView->SetAutoStartStatus( KTxt ); |
|
945 } |
|
946 else |
|
947 { |
|
948 _LIT( KTxt, "Unknown" ); |
|
949 iAppView->SetAutoStartStatus( KTxt ); |
|
950 } |
|
951 } |
|
952 |
|
953 void CHtiAdminAppUi::UpdateSelectedComm() |
|
954 { |
|
955 HTI_LOG_TEXT( "UpdateSelectedComm" ); |
|
956 TBuf<64> commPlugin; |
|
957 TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); |
|
958 if ( !err ) |
|
959 { |
|
960 TBuf8<KMaxParameterValueLength> commValue; |
|
961 TRAP( err, commValue = iHtiCfg->GetParameterL( KCommPlugin ) ); |
|
962 if ( err == KErrNone ) |
|
963 { |
|
964 commPlugin.Copy( commValue ); |
|
965 } |
|
966 } |
|
967 // Use default if not found from config |
|
968 if ( commPlugin.Length() == 0 ) |
|
969 { |
|
970 commPlugin.Copy(KCommDefaultImplementation ); |
|
971 } |
|
972 iAppView->SetSelectedComm( commPlugin ); |
|
973 |
|
974 if ( commPlugin.Compare( _L( "SERIAL" ) ) == 0 ) |
|
975 { |
|
976 TInt portNum = 0; |
|
977 TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiSerialCommCfg ) ); |
|
978 if ( err == KErrNone ) |
|
979 { |
|
980 TRAP( err, portNum = iHtiCfg->GetParameterIntL( KCommPortNumber ) ); |
|
981 } |
|
982 TBuf<16> portBuf; |
|
983 portBuf.Copy( _L( "Port: " ) ); |
|
984 portBuf.AppendNum( portNum ); |
|
985 iAppView->SetCommDetails( portBuf ); |
|
986 } |
|
987 |
|
988 else if ( commPlugin.Compare( _L( "BTSERIAL" ) ) == 0 ) |
|
989 { |
|
990 TBuf<64> hostBuf; |
|
991 TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); |
|
992 if ( err == KErrNone ) |
|
993 { |
|
994 TBuf8<KMaxParameterValueLength> hostValue; |
|
995 TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceAddress ) ); |
|
996 if ( err != KErrNone ) |
|
997 { |
|
998 TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceName ) ); |
|
999 } |
|
1000 if ( err == KErrNone ) |
|
1001 { |
|
1002 hostBuf.Copy( hostValue ); |
|
1003 } |
|
1004 } |
|
1005 if ( hostBuf.Length() > 0 ) |
|
1006 { |
|
1007 hostBuf.Insert( 0, _L( "Host: " ) ); |
|
1008 } |
|
1009 iAppView->SetCommDetails( hostBuf ); |
|
1010 } |
|
1011 |
|
1012 else if ( commPlugin.Compare( _L( "IPCOMM" ) ) == 0 ) |
|
1013 { |
|
1014 TBuf<128> hostBuf; |
|
1015 TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); |
|
1016 if ( err == KErrNone ) |
|
1017 { |
|
1018 TInt localPort = 0; |
|
1019 TRAP( err, localPort = iHtiCfg->GetParameterIntL( KLocalPort ) ); |
|
1020 if ( err == KErrNone && localPort > 0 ) |
|
1021 { |
|
1022 hostBuf.Copy( _L( "Listen: " ) ); |
|
1023 hostBuf.AppendNum( localPort ); |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 TBuf8<KMaxParameterValueLength> remoteHost; |
|
1028 TInt remotePort = 0; |
|
1029 TRAP( err, remoteHost = iHtiCfg->GetParameterL( KRemoteHost ) ); |
|
1030 if ( err == KErrNone ) |
|
1031 { |
|
1032 TRAP( err, remotePort = iHtiCfg->GetParameterIntL( |
|
1033 KRemotePort ) ); |
|
1034 } |
|
1035 if ( err == KErrNone ) |
|
1036 { |
|
1037 hostBuf.Copy( remoteHost ); |
|
1038 hostBuf.Insert( 0, _L("Connect: " ) ); |
|
1039 hostBuf.Append( ':' ); |
|
1040 hostBuf.AppendNum( remotePort ); |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 hostBuf.Copy( _L( "Invalid config!" ) ); |
|
1045 } |
|
1046 } |
|
1047 } |
|
1048 iAppView->SetCommDetails( hostBuf ); |
|
1049 } |
|
1050 |
|
1051 else |
|
1052 { |
|
1053 iAppView->SetCommDetails( KNullDesC ); |
|
1054 } |
|
1055 } |
|
1056 |
|
1057 void CHtiAdminAppUi::KillHtiWatchDogL() |
|
1058 { |
|
1059 TFullName processName; |
|
1060 TFindProcess finder( KHtiWatchDogMatchPattern ); |
|
1061 TInt err = finder.Next( processName ); |
|
1062 if ( err == KErrNone ) |
|
1063 { |
|
1064 HTI_LOG_TEXT( "HTI watchdog process found. Trying to open and kill it..." ); |
|
1065 RProcess prs; |
|
1066 User::LeaveIfError( prs.Open( finder ) ); |
|
1067 prs.Kill( KTerminateReason ); |
|
1068 prs.Close(); |
|
1069 HTI_LOG_TEXT( "HTI watchdog killed" ); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 void CHtiAdminAppUi::StartTimer() |
|
1074 { |
|
1075 // start timer to watch the status |
|
1076 if ( !iPeriodic ) |
|
1077 { |
|
1078 iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
1079 iPeriodic->Start( 1 * 1000 * 1000, |
|
1080 10 * 1000 * 1000, |
|
1081 TCallBack( TimerCallBackL, this ) ); |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 void CHtiAdminAppUi::KillTimer() |
|
1086 { |
|
1087 if ( iPeriodic ) |
|
1088 { |
|
1089 iPeriodic->Cancel(); |
|
1090 delete iPeriodic; |
|
1091 iPeriodic = NULL; |
|
1092 } |
|
1093 } |
|
1094 |
|
1095 TInt CHtiAdminAppUi::TimerCallBackL( TAny* aPtr ) |
|
1096 { |
|
1097 ( (CHtiAdminAppUi*)aPtr )->UpdateStatusL(); |
|
1098 return ETrue; |
|
1099 } |
|
1100 |
|
1101 void CHtiAdminAppUi::ShowCommsDBListQueryL() |
|
1102 { |
|
1103 TInt selectedOption( KErrNotFound ); |
|
1104 TBuf<KMaxParameterValueLength> name; |
|
1105 |
|
1106 CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(16); |
|
1107 CleanupStack::PushL(array); |
|
1108 |
|
1109 // Get IAP names from the database |
|
1110 CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);; |
|
1111 CleanupStack::PushL(db); |
|
1112 db->ShowHiddenRecords(); |
|
1113 CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP)); |
|
1114 TInt res = view->GotoFirstRecord(); |
|
1115 |
|
1116 while(res == KErrNone) |
|
1117 { |
|
1118 view->ReadTextL(TPtrC(COMMDB_NAME), name); |
|
1119 array->InsertL(0, name); |
|
1120 res = view->GotoNextRecord(); |
|
1121 } |
|
1122 |
|
1123 CleanupStack::PopAndDestroy(view); //view |
|
1124 CleanupStack::PopAndDestroy(db); //db |
|
1125 |
|
1126 // Show IAP selection dialog |
|
1127 CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&selectedOption); |
|
1128 dlg->PrepareLC(R_SELECT_IAP_DIALOG); |
|
1129 dlg->SetItemTextArray(array); |
|
1130 dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
1131 dlg->RunLD(); |
|
1132 |
|
1133 if(selectedOption != KErrNotFound) |
|
1134 { |
|
1135 // Write selected IAP name to config file |
|
1136 name = array->MdcaPoint(selectedOption); |
|
1137 TBuf8<KMaxParameterValueLength> iapName; |
|
1138 iapName.Copy(name); |
|
1139 iHtiCfg->SetParameterL(KIAPName, iapName); |
|
1140 } |
|
1141 CleanupStack::PopAndDestroy(array); |
|
1142 } |
|
1143 // End of file |