1 /* |
|
2 * Copyright (c) 2005 - 2006 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: An active object class that is used to receive |
|
15 * phone call related events from Publish&Subscribe and forward them |
|
16 * to an MVRUSBEventObserver instance. |
|
17 * Has to be attached to certain P&S -key, so it means having multiple |
|
18 * |
|
19 * |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include <e32base.h> |
|
26 |
|
27 #include "CVRUSBEventHandler.h" |
|
28 #include "MVRUSBEventObserver.h" |
|
29 |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================================== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CVRUSBEventHandler::CVRUSBEventHandler |
|
35 // |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CVRUSBEventHandler::CVRUSBEventHandler() : CActive( EPriorityHigh ) |
|
39 { |
|
40 CActiveScheduler::Add( this ); |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CVRUSBEventHandler::ConstructL |
|
46 // |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 void CVRUSBEventHandler::ConstructL() |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CVRUSBEventHandler::NewL |
|
57 // |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 // Two-phased constructor. |
|
61 CVRUSBEventHandler* CVRUSBEventHandler::NewL() |
|
62 { |
|
63 CVRUSBEventHandler* self = new (ELeave) CVRUSBEventHandler; |
|
64 |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CVRUSBEventHandler::~CVRUSBEventHandler |
|
75 // |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 // Destructor |
|
79 CVRUSBEventHandler::~CVRUSBEventHandler() |
|
80 { |
|
81 Cancel(); |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CVRUSBEventHandler::IssueRequest |
|
87 // |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CVRUSBEventHandler::IssueRequest() |
|
91 { |
|
92 SetActive(); |
|
93 iProperty.Subscribe( iStatus ); |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CVRUSBEventHandler::RunL |
|
99 // |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CVRUSBEventHandler::RunL() |
|
103 { |
|
104 // Event received |
|
105 |
|
106 if ( iStatus != KErrCancel ) |
|
107 { |
|
108 // Request a new event |
|
109 IssueRequest(); |
|
110 // Notify the observer |
|
111 iObserver->HandleUSBEventL(); |
|
112 } |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CVRUSBEventHandler::Listen |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CVRUSBEventHandler::Listen( TUid aUid, |
|
122 TUint aKey, |
|
123 MVRUSBEventObserver* aObserver ) |
|
124 { |
|
125 iProperty.Attach( aUid, aKey ); |
|
126 |
|
127 iObserver = aObserver; |
|
128 IssueRequest(); |
|
129 } |
|
130 |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CVRUSBEventHandler::DoCancel |
|
134 // |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CVRUSBEventHandler::DoCancel() |
|
138 { |
|
139 iProperty.Cancel(); |
|
140 } |
|
141 |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CVRUSBEventHandler::StateL |
|
145 // |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 TInt CVRUSBEventHandler::StateL( TUid aUid, TUint aKey ) |
|
149 { |
|
150 TInt value; |
|
151 User::LeaveIfError( RProperty::Get( aUid, aKey, value ) ); |
|
152 return value; |
|
153 } |
|
154 |
|
155 // End of File |
|