|
1 /* |
|
2 * Copyright (c) 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: 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> |
|
23 |
|
24 #ifdef __FLOG_ACTIVE |
|
25 _LIT8(KLogComponent, "USBLcdPlugin"); |
|
26 #endif |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // Constructs a CUsbLcdActive object. |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CUsbLcdActive* CUsbLcdActive::NewL(MLocodBearerPluginObserver& aObserver) |
|
35 { |
|
36 LOG_STATIC_FUNC_ENTRY |
|
37 CUsbLcdActive* self = new (ELeave) CUsbLcdActive(aObserver); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CUsbLcdActive::~CUsbLcdActive() |
|
49 { |
|
50 LOG_FUNC |
|
51 Cancel(); |
|
52 iProperty.Close(); |
|
53 } |
|
54 |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // From class CActive |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void CUsbLcdActive::DoCancel() |
|
61 { |
|
62 iProperty.Cancel(); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // RunL() From class CActive |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 |
|
70 void CUsbLcdActive::RunL() |
|
71 { |
|
72 LOG_FUNC |
|
73 TInt value; |
|
74 |
|
75 if( iStatus != KErrNone ) |
|
76 { |
|
77 LOGTEXT2(_L8("CUsbLcdActive::RunL() error = %d"),iStatus.Int()); |
|
78 } |
|
79 else |
|
80 { |
|
81 |
|
82 TInt ret = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, value); |
|
83 LOGTEXT2(_L8("CUsbLcdActive::RunL() Personality = %d"), value); |
|
84 iProperty.Subscribe(iStatus); |
|
85 SetActive(); |
|
86 if (ret == KErrNone) |
|
87 { |
|
88 switch (value) |
|
89 { |
|
90 case KUsbPersonalityIdPCSuite: |
|
91 case KUsbPersonalityIdPCSuiteMTP: |
|
92 NotifyLcd(ETrue); |
|
93 LOGTEXT(_L8("CUsbLcdActive::RunL() in PC Suite mode")); |
|
94 break; |
|
95 |
|
96 default: |
|
97 NotifyLcd(EFalse); |
|
98 LOGTEXT(_L8("CUsbLcdActive::RunL() mode is not PC Suite")); |
|
99 break; |
|
100 } |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // From class CActive |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 |
|
110 TInt CUsbLcdActive::RunError( TInt /*aError*/ ) |
|
111 { |
|
112 LOG_FUNC |
|
113 return KErrNone; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Constructor |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CUsbLcdActive::CUsbLcdActive(MLocodBearerPluginObserver& aObserver) |
|
121 : CActive(EPriorityStandard), iObserver(aObserver) |
|
122 { |
|
123 LOG_FUNC |
|
124 CActiveScheduler::Add( this ); |
|
125 } |
|
126 |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Method to perform second phase construction. |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CUsbLcdActive::ConstructL() |
|
133 { |
|
134 LOG_FUNC |
|
135 User::LeaveIfError(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality)); |
|
136 Start(); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // Start() function is called to initiate RProperty subscription |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CUsbLcdActive::Start() |
|
144 { |
|
145 LOG_FUNC |
|
146 iProperty.Subscribe(iStatus); |
|
147 SetActive(); |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // This function notifying LoCoD framewark about active USB personality |
|
152 // If Personality == 113 (PC Suite), then ETrue; in all other cases is EFalse |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CUsbLcdActive::NotifyLcd(TBool aUsbStatus) |
|
156 { |
|
157 LOG_FUNC |
|
158 iObserver.NotifyBearerStatus(ELocodBearerUSB, aUsbStatus); |
|
159 } |
|
160 |
|
161 //End of file |