|
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: Base classes for Usb notifier wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cusbnotifmanager.h" |
|
20 #include "cusbnotenotifier.h" |
|
21 |
|
22 #include "debug.h" |
|
23 #include "panic.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // C++ constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CUsbNoteNotifier::CUsbNoteNotifier(RNotifier& aNotifier, |
|
32 CUsbNotifManager* aNotifManager, TUid aCat, TUint aNotifId) : |
|
33 CUsbNotifier(aNotifManager, aCat, aNotifId), |
|
34 iNotifier(aNotifier) |
|
35 { |
|
36 FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CUsbNoteNotifier" ) ); |
|
37 |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // Second-phase constructor |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CUsbNoteNotifier::ConstructL() |
|
45 { |
|
46 FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ConstructL" ) ); |
|
47 |
|
48 iNotifierActive = new(ELeave)CUsbNoteNotifier::CNotifierActive(iNotifier, this); |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Destructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CUsbNoteNotifier::~CUsbNoteNotifier() |
|
56 { |
|
57 FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::~CUsbNoteNotifier" ) ); |
|
58 |
|
59 delete iNotifierActive; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // From base class CUsbNotifier |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CUsbNoteNotifier::ShowL() |
|
67 { |
|
68 FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ShowL aCat = 0x%X aNotifId = 0x%X" ), iCat, iNotifId)); |
|
69 |
|
70 iNotifierActive->StartL(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // From base class CUsbNotifier |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CUsbNoteNotifier::Close() |
|
78 { |
|
79 FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::Close" ) ); |
|
80 } |
|
81 |
|
82 |
|
83 // ======== MEMBER FUNCTIONS ======== |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // C++ default constructor |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier, |
|
90 CUsbNoteNotifier* aUsbNoteNotifier) : |
|
91 CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard), |
|
92 iUsbNoteNotifier(aUsbNoteNotifier), |
|
93 iNotifier(aNotifier), |
|
94 iRes(0) |
|
95 { |
|
96 CActiveScheduler::Add(this); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Destructor |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CUsbNoteNotifier::CNotifierActive::~CNotifierActive() |
|
104 { |
|
105 Cancel(); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // Start to show the notifier |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CUsbNoteNotifier::CNotifierActive::StartL() |
|
113 { |
|
114 FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::ShowL aCat = 0x%X aNotifId = 0x%X" ), |
|
115 iUsbNoteNotifier->iCat, iUsbNoteNotifier->iNotifId)); |
|
116 |
|
117 if (IsActive()) |
|
118 { |
|
119 Panic(ENotifierIsActiveAlready); |
|
120 return; |
|
121 } |
|
122 |
|
123 TPckgBuf<TInt> pckg; |
|
124 pckg() = iUsbNoteNotifier->iNotifId; |
|
125 |
|
126 iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier->iCat, pckg, iRes); |
|
127 SetActive(); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // From base class CActive |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CUsbNoteNotifier::CNotifierActive::RunL() |
|
135 { |
|
136 FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCCUsbNoteNotifier::CNotifierActive::RunL iStatus = %d" ), iStatus.Int())); |
|
137 |
|
138 // if error occured, deal with it in RunError |
|
139 User::LeaveIfError(iStatus.Int()); |
|
140 |
|
141 iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); |
|
142 |
|
143 // report to owner that show is over |
|
144 iUsbNoteNotifier->iNotifManager->NotifierShowCompletedL(iUsbNoteNotifier, KErrNone, iRes()); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // From base class CActive |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CUsbNoteNotifier::CNotifierActive::DoCancel() |
|
152 { |
|
153 FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::DoCancel" ) ); |
|
154 |
|
155 iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // From base class CActive |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError) |
|
163 { |
|
164 FTRACE( FPrint(_L("[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::RunError aError = %d" ), aError)); |
|
165 |
|
166 iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); |
|
167 |
|
168 // try to continue |
|
169 return KErrNone; |
|
170 } |
|
171 |
|
172 // End of file |