|
1 /* |
|
2 * Copyright (c) 2002-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 * |
|
16 */ |
|
17 |
|
18 /** @file |
|
19 @internalComponent |
|
20 @test |
|
21 */ |
|
22 |
|
23 #include "servicewatcher.h" |
|
24 #include "ncmtestconsole.h" |
|
25 #include "ncmtestdefines.hrh" |
|
26 |
|
27 CServiceWatcher* CServiceWatcher::NewL(CUsbNcmConsole& aTestConsole) |
|
28 { |
|
29 LOG_STATIC_FUNC_ENTRY |
|
30 |
|
31 CServiceWatcher* self = new(ELeave) CServiceWatcher(aTestConsole); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 CServiceWatcher::~CServiceWatcher() |
|
38 { |
|
39 Cancel(); |
|
40 } |
|
41 |
|
42 CServiceWatcher::CServiceWatcher(CUsbNcmConsole& aTestConsole) |
|
43 : CActive(EPriorityStandard), iTestConsole(aTestConsole) |
|
44 { |
|
45 CActiveScheduler::Add(this); |
|
46 } |
|
47 |
|
48 void CServiceWatcher::ConstructL() |
|
49 { |
|
50 iTestConsole.Usb().ServiceStateNotification(iServiceState, iStatus); |
|
51 SetActive(); |
|
52 |
|
53 TUsbServiceState serviceState; |
|
54 User::LeaveIfError(iTestConsole.Usb().GetServiceState(serviceState)); |
|
55 DisplayServiceState(serviceState); |
|
56 } |
|
57 |
|
58 void CServiceWatcher::DoCancel() |
|
59 { |
|
60 iTestConsole.Usb().ServiceStateNotificationCancel(); |
|
61 } |
|
62 |
|
63 void CServiceWatcher::RunL() |
|
64 { |
|
65 LOG_FUNC |
|
66 __FLOG_STATIC2(KSubSys, KLogComponent , |
|
67 _L8("CServiceWatcherCommand::RunL - iStatus = %d, iServiceState = %d"), |
|
68 iStatus.Int(), iServiceState); |
|
69 |
|
70 User::LeaveIfError(iStatus.Int()); |
|
71 |
|
72 iTestConsole.Usb().ServiceStateNotification(iServiceState, iStatus); |
|
73 SetActive(); |
|
74 |
|
75 iTestConsole.Usb().GetServiceState(iServiceState); |
|
76 //Display the service state on main console |
|
77 DisplayServiceState(iServiceState); |
|
78 |
|
79 } |
|
80 |
|
81 TInt CServiceWatcher::RunError(TInt aError) |
|
82 { |
|
83 User::Panic(_L("CServiceWatcher"), aError); |
|
84 return aError; |
|
85 } |
|
86 |
|
87 void CServiceWatcher::DisplayServiceState(TUsbServiceState aServiceState) |
|
88 /** |
|
89 Display the service state on main console |
|
90 @param aServiceState Service state |
|
91 */ |
|
92 { |
|
93 TBuf<DISPLAY_USB_SERVICE_STATE_LEN> servStatus; |
|
94 switch(aServiceState) |
|
95 { |
|
96 case EUsbServiceIdle: |
|
97 servStatus = |
|
98 // 12345678901 |
|
99 _L("Idle "); |
|
100 break; |
|
101 |
|
102 case EUsbServiceStarting: |
|
103 servStatus = |
|
104 // 12345678901 |
|
105 _L("Starting "); |
|
106 break; |
|
107 |
|
108 case EUsbServiceStarted: |
|
109 servStatus = |
|
110 // 12345678901 |
|
111 _L("Started "); |
|
112 break; |
|
113 |
|
114 case EUsbServiceStopping: |
|
115 servStatus = |
|
116 // 12345678901 |
|
117 _L("Stopping "); |
|
118 break; |
|
119 |
|
120 case EUsbServiceFatalError: |
|
121 servStatus = |
|
122 // 12345678901 |
|
123 _L("Error "); |
|
124 break; |
|
125 |
|
126 default: |
|
127 servStatus = |
|
128 _L("Unknown "); |
|
129 |
|
130 break; |
|
131 } |
|
132 |
|
133 iTestConsole.SetDisplayItem(EUsbServiceStateItem, servStatus); |
|
134 |
|
135 } |