author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:48:20 +0300 | |
changeset 75 | 809df41c314e |
parent 57 | 62e6d990246c |
child 63 | ef2686f7597e |
permissions | -rw-r--r-- |
35 | 1 |
/* |
2 |
* Copyright (c) 2006 - 2010 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: Active object class used to manage asynchronous request. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <e32property.h> |
|
20 |
#include "usblcdactive.h" |
|
21 |
#include <UsbWatcherInternalPSKeys.h> |
|
22 |
#include <usbpersonalityids.h> |
|
57
62e6d990246c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
23 |
#include "debug.h" |
35 | 24 |
|
25 |
||
26 |
// ======== MEMBER FUNCTIONS ======== |
|
27 |
||
28 |
// --------------------------------------------------------------------------- |
|
29 |
// Constructs a CUsbLcdActive object. |
|
30 |
// --------------------------------------------------------------------------- |
|
31 |
// |
|
32 |
CUsbLcdActive* CUsbLcdActive::NewL(MLocodBearerPluginObserver& aObserver) |
|
33 |
{ |
|
57
62e6d990246c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
34 |
LOG_FUNC |
35 | 35 |
CUsbLcdActive* self = new (ELeave) CUsbLcdActive(aObserver); |
36 |
CleanupStack::PushL(self); |
|
37 |
self->ConstructL(); |
|
38 |
CleanupStack::Pop(self); |
|
39 |
return self; |
|
40 |
} |
|
41 |
||
42 |
// --------------------------------------------------------------------------- |
|
43 |
// Destructor |
|
44 |
// --------------------------------------------------------------------------- |
|
45 |
// |
|
46 |
CUsbLcdActive::~CUsbLcdActive() |
|
47 |
{ |
|
48 |
LOG_FUNC |
|
49 |
Cancel(); |
|
50 |
iProperty.Close(); |
|
51 |
} |
|
52 |
||
53 |
||
54 |
// --------------------------------------------------------------------------- |
|
55 |
// From class CActive |
|
56 |
// --------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
void CUsbLcdActive::DoCancel() |
|
59 |
{ |
|
60 |
iProperty.Cancel(); |
|
61 |
} |
|
62 |
||
63 |
// --------------------------------------------------------------------------- |
|
64 |
// RunL() From class CActive |
|
65 |
// --------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
||
68 |
void CUsbLcdActive::RunL() |
|
69 |
{ |
|
70 |
LOG_FUNC |
|
71 |
TInt value; |
|
72 |
||
73 |
if( iStatus != KErrNone ) |
|
74 |
{ |
|
57
62e6d990246c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
75 |
LOG1("CUsbLcdActive::RunL() iStatus = %d",iStatus.Int()); |
35 | 76 |
} |
77 |
else |
|
78 |
{ |
|
79 |
||
80 |
TInt ret = iProperty.Get( value ); |
|
57
62e6d990246c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
81 |
LOG2("Personality: %d, ret: %d", value, ret); |
35 | 82 |
iProperty.Subscribe(iStatus); |
83 |
SetActive(); |
|
84 |
if (ret == KErrNone) |
|
85 |
{ |
|
86 |
HandleUsbPersonalityChange( value ); |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
// --------------------------------------------------------------------------- |
|
92 |
// From class CActive |
|
93 |
// --------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
||
96 |
TInt CUsbLcdActive::RunError( TInt /*aError*/ ) |
|
97 |
{ |
|
98 |
LOG_FUNC |
|
99 |
return KErrNone; |
|
100 |
} |
|
101 |
||
102 |
// --------------------------------------------------------------------------- |
|
103 |
// Constructor |
|
104 |
// --------------------------------------------------------------------------- |
|
105 |
// |
|
106 |
CUsbLcdActive::CUsbLcdActive(MLocodBearerPluginObserver& aObserver) |
|
107 |
: CActive(EPriorityStandard), iObserver(aObserver) |
|
108 |
{ |
|
109 |
LOG_FUNC |
|
110 |
CActiveScheduler::Add( this ); |
|
111 |
} |
|
112 |
||
113 |
||
114 |
// --------------------------------------------------------------------------- |
|
115 |
// Method to perform second phase construction. |
|
116 |
// --------------------------------------------------------------------------- |
|
117 |
// |
|
118 |
void CUsbLcdActive::ConstructL() |
|
119 |
{ |
|
120 |
LOG_FUNC |
|
121 |
User::LeaveIfError(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality)); |
|
122 |
Start(); |
|
123 |
} |
|
124 |
||
125 |
// --------------------------------------------------------------------------- |
|
126 |
// Start() function is called to initiate RProperty subscription |
|
127 |
// --------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
void CUsbLcdActive::Start() |
|
130 |
{ |
|
131 |
LOG_FUNC |
|
132 |
iProperty.Subscribe(iStatus); |
|
133 |
SetActive(); |
|
134 |
// Check the starting state |
|
135 |
TInt usbPersonalityId( KUsbWatcherSelectedPersonalityNone ); |
|
136 |
TInt ret = iProperty.Get( usbPersonalityId ); |
|
137 |
if ( ( ret == KErrNone ) && |
|
138 |
( usbPersonalityId != KUsbWatcherSelectedPersonalityNone ) ) |
|
139 |
{ |
|
140 |
HandleUsbPersonalityChange( usbPersonalityId ); |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
||
145 |
// --------------------------------------------------------------------------- |
|
146 |
// This function handles the USB active personality change, and notify LoCoD |
|
147 |
// framework whether PC Suite is active |
|
148 |
// --------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
void CUsbLcdActive::HandleUsbPersonalityChange( TInt aNewPersonalityId ) |
|
151 |
{ |
|
152 |
LOG_FUNC |
|
57
62e6d990246c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
153 |
LOG1( "aNewPersonalityId: %d", aNewPersonalityId ); |
35 | 154 |
TBool isPcSuiteActive( EFalse ); |
155 |
if ( ( aNewPersonalityId == KUsbPersonalityIdPCSuite ) || |
|
156 |
( aNewPersonalityId == KUsbPersonalityIdPCSuiteMTP ) ) |
|
157 |
{ |
|
158 |
isPcSuiteActive = ETrue; |
|
159 |
} |
|
160 |
iObserver.NotifyBearerStatus( ELocodBearerUSB, isPcSuiteActive ); |
|
161 |
} |
|
162 |
||
163 |
//End of file |