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