1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Implementation |
14 * Description: Implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <usbuinotif.h> |
18 #include <usbuinotif.h> |
19 |
19 |
20 #include "cusbnotifmanager.h" |
20 #include "cusbnotifmanager.h" |
21 #include "cusbwaitnotifier.h" |
21 #include "cusbwaitnotifier.h" |
28 // --------------------------------------------------------------------------- |
28 // --------------------------------------------------------------------------- |
29 // |
29 // |
30 // --------------------------------------------------------------------------- |
30 // --------------------------------------------------------------------------- |
31 // |
31 // |
32 CWaitNotifierInfo::CWaitNotifierInfo(CUsbNotifier* aWaitNotifier, |
32 CWaitNotifierInfo::CWaitNotifierInfo(CUsbNotifier* aWaitNotifier, |
33 MWaitNotifierObserver* aObserver) : |
33 MWaitNotifierObserver& aObserver) : |
34 iWaitNotifier(aWaitNotifier), iObserver(aObserver) |
34 iWaitNotifier(aWaitNotifier), iObserver(aObserver) |
35 { |
35 { |
36 } |
36 } |
37 |
37 |
38 // --------------------------------------------------------------------------- |
38 // --------------------------------------------------------------------------- |
39 // |
39 // |
40 // --------------------------------------------------------------------------- |
40 // --------------------------------------------------------------------------- |
41 // |
41 // |
42 void CWaitNotifierInfo::ConstructL() |
42 void CWaitNotifierInfo::ConstructL() |
43 { |
43 { |
44 FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::ConstructL" ) ); |
44 LOG_FUNC |
45 // owenrship for iWaitNotifier transferred in default constructor. |
45 // owenrship for iWaitNotifier transferred in default constructor. |
46 // this object is responsible for deletion of the iWaitNotifier then |
46 // this object is responsible for deletion of the iWaitNotifier then |
47 } |
47 } |
48 |
48 |
49 // --------------------------------------------------------------------------- |
49 // --------------------------------------------------------------------------- |
50 // |
50 // |
51 // --------------------------------------------------------------------------- |
51 // --------------------------------------------------------------------------- |
52 // |
52 // |
53 CWaitNotifierInfo* CWaitNotifierInfo::NewL(CUsbNotifier* aWaitNotifier, |
53 CWaitNotifierInfo* CWaitNotifierInfo::NewL(CUsbNotifier* aWaitNotifier, |
54 MWaitNotifierObserver* aObserver) |
54 MWaitNotifierObserver& aObserver) |
55 { |
55 { |
56 FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::NewL" ) ); |
56 LOG_FUNC |
|
57 |
57 CWaitNotifierInfo* self = new (ELeave) CWaitNotifierInfo(aWaitNotifier, |
58 CWaitNotifierInfo* self = new (ELeave) CWaitNotifierInfo(aWaitNotifier, |
58 aObserver); |
59 aObserver); |
59 CleanupStack::PushL(self); |
60 CleanupStack::PushL(self); |
60 self->ConstructL(); |
61 self->ConstructL(); |
61 CleanupStack::Pop(self); |
62 CleanupStack::Pop(self); |
85 // |
86 // |
86 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
87 // |
88 // |
88 MWaitNotifierObserver* CWaitNotifierInfo::Observer() const |
89 MWaitNotifierObserver* CWaitNotifierInfo::Observer() const |
89 { |
90 { |
90 return iObserver; |
91 return &iObserver; |
91 } |
92 } |
92 |
93 |
93 |
94 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
95 // |
95 // |
96 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
97 // |
97 // |
98 CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher& aOtgWatcher) |
98 CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher* aOtgWatcher) |
99 { |
99 { |
100 LOG_FUNC |
100 |
|
101 FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::NewL" ) ); |
|
102 |
101 |
103 CUsbNotifManager* self = new (ELeave) CUsbNotifManager(); |
102 CUsbNotifManager* self = new (ELeave) CUsbNotifManager(); |
104 CleanupStack::PushL(self); |
103 CleanupStack::PushL(self); |
105 self->ConstructL(aOtgWatcher); |
104 self->ConstructL(aOtgWatcher); |
106 CleanupStack::Pop(self); |
105 CleanupStack::Pop(self); |
109 |
108 |
110 // --------------------------------------------------------------------------- |
109 // --------------------------------------------------------------------------- |
111 // |
110 // |
112 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
113 // |
112 // |
114 void CUsbNotifManager::ConstructL(CUsbOtgWatcher* aOtgWatcher) |
113 void CUsbNotifManager::ConstructL(CUsbOtgWatcher& aOtgWatcher) |
115 { |
114 { |
116 |
115 LOG_FUNC |
117 FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ConstructL" ) ); |
|
118 |
116 |
119 User::LeaveIfError(iNotifier.Connect()); |
117 User::LeaveIfError(iNotifier.Connect()); |
120 |
118 |
121 iIndicatorNotifier = CUsbIndicatorNotifier::NewL(this, aOtgWatcher); |
119 iIndicatorNotifier = CUsbIndicatorNotifier::NewL(*this, aOtgWatcher); |
122 |
120 |
123 } |
121 } |
124 |
122 |
125 // --------------------------------------------------------------------------- |
123 // --------------------------------------------------------------------------- |
126 // |
124 // |
127 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
128 // |
126 // |
129 CUsbNotifManager::CUsbNotifManager() |
127 CUsbNotifManager::CUsbNotifManager() |
130 { |
128 { |
131 |
|
132 } |
129 } |
133 |
130 |
134 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
135 // |
132 // |
136 // --------------------------------------------------------------------------- |
133 // --------------------------------------------------------------------------- |
137 // |
134 // |
138 CUsbNotifManager::~CUsbNotifManager() |
135 CUsbNotifManager::~CUsbNotifManager() |
139 { |
136 { |
140 |
137 LOG_FUNC |
141 FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::~CUsbNotifManager" ) ); |
|
142 |
138 |
143 CloseAllNotifiers(); |
139 CloseAllNotifiers(); |
144 |
140 |
145 delete iIndicatorNotifier; |
141 delete iIndicatorNotifier; |
146 |
142 |
147 iNotifier.Close(); |
143 iNotifier.Close(); |
148 |
144 |
149 } |
145 } |
150 |
146 |
151 // --------------------------------------------------------------------------- |
147 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
149 // --------------------------------------------------------------------------- |
154 // |
150 // |
155 void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId, |
151 void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId, |
156 MWaitNotifierObserver* aObserver) |
152 MWaitNotifierObserver* aObserver) |
157 { |
153 { |
158 FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifier aCat = 0x%X aNotifId = %d, aObserver=0x%X" ), |
154 LOG_FUNC |
159 aCat, aNotifId, aObserver)); |
155 |
|
156 LOG3( "aCat = 0x%X aNotifId = %d, aObserver=0x%X" , aCat, aNotifId, aObserver); |
160 |
157 |
161 // remove non-feedback notifiers from the list |
158 // remove non-feedback notifiers from the list |
162 for (TUint i(0); i < iWaitNotifiers.Count(); ++i) |
159 for (TUint i(0); i < iWaitNotifiers.Count(); ++i) |
163 { |
160 { |
164 CWaitNotifierInfo* waitNotifier = iWaitNotifiers[i]; |
161 CWaitNotifierInfo* waitNotifierInfo = iWaitNotifiers[i]; |
165 if (!(waitNotifier->WaitNotifier()->IsFeedbackNeeded())) |
162 if (!(waitNotifierInfo->WaitNotifier()->IsFeedbackNeeded())) |
166 { |
163 { |
167 delete waitNotifier; |
164 delete waitNotifierInfo; |
168 iWaitNotifiers.Remove(i); |
165 iWaitNotifiers.Remove(i); |
169 } |
166 } |
170 } |
167 } |
171 //If not suspened a short while between closing a present note and showing a new one, |
168 //If not suspened a short while between closing a present note and showing a new one, |
172 //error - CUsbWaitNotifier::RunL iStatus = 4 - will happen. Necessary here to pause a while |
169 //error - CUsbWaitNotifier::RunL iStatus = 4 - will happen. Necessary here to pause a while |
181 // to create concret notifiers according to categories instead of checking aObserver null |
178 // to create concret notifiers according to categories instead of checking aObserver null |
182 CUsbNotifier* notifier(NULL); |
179 CUsbNotifier* notifier(NULL); |
183 if (aCat == KUsbUiNotifOtgError) |
180 if (aCat == KUsbUiNotifOtgError) |
184 { |
181 { |
185 __ASSERT_ALWAYS(aObserver != NULL, Panic(EWrongNotifierCategory)); |
182 __ASSERT_ALWAYS(aObserver != NULL, Panic(EWrongNotifierCategory)); |
186 notifier = CUsbWaitNotifier::NewL(iNotifier, this, aNotifId); |
183 notifier = CUsbWaitNotifier::NewL(iNotifier, *this, aNotifId); |
187 } |
184 } |
188 else if (aCat == KUsbUiNotifOtgWarning) |
185 else if (aCat == KUsbUiNotifOtgWarning) |
189 { |
186 { |
190 notifier = CUsbWarningNotifier::NewL(iNotifier, this, aNotifId); |
187 notifier = CUsbWarningNotifier::NewL(iNotifier, *this, aNotifId); |
191 } |
188 } |
192 else |
189 else |
193 { |
190 { |
194 FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Unexpected aCat" ) ); |
191 LOG1("Unexpected aCat = 0x%X", aCat ); |
195 Panic(EWrongNotifierCategory); |
192 Panic(EWrongNotifierCategory); |
196 } |
193 } |
197 |
194 |
198 CleanupStack::PushL(notifier); |
195 CleanupStack::PushL(notifier); |
199 |
196 |
200 iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, aObserver)); |
197 iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, *aObserver)); |
201 |
198 |
202 FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Start to show note" ) ); |
|
203 notifier->ShowL(); |
199 notifier->ShowL(); |
204 |
200 |
205 CleanupStack::Pop(notifier); |
201 CleanupStack::Pop(notifier); |
206 } |
202 } |
207 |
203 |
208 // --------------------------------------------------------------------------- |
204 // --------------------------------------------------------------------------- |
209 // |
205 // |
210 // --------------------------------------------------------------------------- |
206 // --------------------------------------------------------------------------- |
211 // |
207 // |
212 void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier* aWaitNotifier, |
208 void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, |
213 TInt aResult, TInt aFeedback) |
209 TInt aResult, TInt aFeedback) |
214 { |
210 { |
215 FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::NotifierShowCompleted aResult = %d" ), aResult)); |
211 LOG_FUNC |
|
212 |
|
213 LOG1( "aResult = %d", aResult); |
216 |
214 |
217 // remove Notifier from the list |
215 // remove Notifier from the list |
218 for (TUint i(0); i < iWaitNotifiers.Count(); ++i) |
216 for (TUint i(0); i < iWaitNotifiers.Count(); ++i) |
219 { |
217 { |
220 if (aWaitNotifier == iWaitNotifiers[i]->WaitNotifier()) |
218 if (&aWaitNotifier == iWaitNotifiers[i]->WaitNotifier()) |
221 { |
219 { |
222 MWaitNotifierObserver* observer = iWaitNotifiers[i]->Observer(); |
220 MWaitNotifierObserver* observer = iWaitNotifiers[i]->Observer(); |
223 |
221 |
224 delete iWaitNotifiers[i]; |
222 delete iWaitNotifiers[i]; |
225 iWaitNotifiers.Remove(i); |
223 iWaitNotifiers.Remove(i); |