29
|
1 |
/*
|
54
|
2 |
* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
|
29
|
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: DUN USB plugin's listener
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_CDUNUSBLISTEN_H
|
|
20 |
#define C_CDUNUSBLISTEN_H
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
#include <c32comm.h>
|
|
24 |
#include <usbman.h>
|
|
25 |
#include "DunPlugin.h"
|
|
26 |
|
|
27 |
/**
|
|
28 |
* DUN USB plugin's listener class
|
|
29 |
* This class starts listening for USB device state to change to configured.
|
|
30 |
* When change to configured is detected, parent (CDunUsbPlugin) is notified
|
|
31 |
* to create a channel. Also when device state is no longer configured,
|
|
32 |
* parent (CDunUsbPlugin) is notified to remove a channel.
|
|
33 |
*
|
|
34 |
* @lib dunusb.lib
|
|
35 |
* @since S60 v3.2
|
|
36 |
*/
|
|
37 |
NONSHARABLE_CLASS( CDunUsbListen ) : public CActive
|
|
38 |
{
|
|
39 |
|
|
40 |
public:
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Two-phased constructor.
|
|
44 |
* @param aServer Server
|
|
45 |
* @param aParent Creator of this instance
|
|
46 |
* @param aUsbServer USB server
|
|
47 |
* @return Instance of self
|
|
48 |
*/
|
|
49 |
static CDunUsbListen* NewL( MDunServerCallback* aServer,
|
|
50 |
MDunListenCallback* aParent,
|
|
51 |
RUsb& aUsbServer );
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Destructor.
|
|
55 |
*/
|
|
56 |
virtual ~CDunUsbListen();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Resets data to initial values
|
|
60 |
*
|
|
61 |
* @since S60 3.2
|
|
62 |
* @return None
|
|
63 |
*/
|
|
64 |
void ResetData();
|
|
65 |
|
|
66 |
/**
|
|
67 |
* IssueRequest to USB server for device state change notifications
|
|
68 |
*
|
|
69 |
* @return KErrAlreadyExists if device state configured,
|
|
70 |
* KErrNone otherwise
|
|
71 |
*/
|
|
72 |
TInt IssueRequestL();
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Stops listening
|
|
76 |
*
|
|
77 |
* @since S60 3.2
|
54
|
78 |
* @return None
|
29
|
79 |
*/
|
54
|
80 |
void Stop();
|
29
|
81 |
|
|
82 |
private:
|
|
83 |
|
|
84 |
CDunUsbListen( MDunServerCallback* aServer,
|
|
85 |
MDunListenCallback* aParent,
|
|
86 |
RUsb& aUsbServer );
|
|
87 |
|
|
88 |
void ConstructL();
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Initializes this class
|
|
92 |
*
|
|
93 |
* @since S60 3.2
|
|
94 |
* @return None
|
|
95 |
*/
|
|
96 |
void Initialize();
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Activates listening request
|
|
100 |
*
|
|
101 |
* @since S60 3.2
|
|
102 |
* @return KErrNotReady if already active, KErrNone otherwise
|
|
103 |
*/
|
|
104 |
TInt Activate();
|
|
105 |
|
|
106 |
// from base class CActive
|
|
107 |
|
|
108 |
/**
|
|
109 |
* From CActive.
|
|
110 |
* Called when read or write operation is ready.
|
|
111 |
*
|
|
112 |
* @since S60 3.2
|
|
113 |
* @return None
|
|
114 |
*/
|
|
115 |
void RunL();
|
|
116 |
|
|
117 |
/**
|
|
118 |
* From CActive.
|
|
119 |
* Cancel current activity.
|
|
120 |
*
|
|
121 |
* @return None
|
|
122 |
*/
|
|
123 |
void DoCancel();
|
|
124 |
|
|
125 |
private: // data
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Callback to call when notification via MDunServerCallback to be made
|
|
129 |
* Not own.
|
|
130 |
*/
|
|
131 |
MDunServerCallback* iServer;
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Callback to call when notification via MDunListenCallback to be made
|
|
135 |
* Not own.
|
|
136 |
*/
|
|
137 |
MDunListenCallback* iParent;
|
|
138 |
|
|
139 |
/**
|
|
140 |
* USB server (USB manager) needed for device state notifications
|
|
141 |
* Device states needed to create transporter channel
|
|
142 |
*/
|
|
143 |
RUsb& iUsbServer;
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Device state of USB set when RUsb::DeviceStateNotification completes
|
|
147 |
*/
|
|
148 |
TUsbDeviceState iDeviceState;
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Previous state of USB set when RUsb::DeviceStateNotification completes
|
|
152 |
*/
|
|
153 |
TUsbDeviceState iDeviceStatePrev;
|
|
154 |
|
|
155 |
};
|
|
156 |
|
|
157 |
#endif // C_CDUNUSBLISTEN_H
|