author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:37:10 +0300 | |
branch | RCL_3 |
changeset 24 | 269724087bed |
parent 23 | 9386f31cc85b |
permissions | -rw-r--r-- |
23 | 1 |
/* |
2 |
* Copyright (c) 2002 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: Bluetooth visibility timeout notifier class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
||
21 |
#include <StringLoader.h> // Localisation stringloader |
|
22 |
#include <BTNotif.rsg> // Own resources |
|
23 |
#include "BTNGenericInfoNotifier.h" // Own class definition |
|
24 |
#include "btNotifDebug.h" // Debugging macros |
|
25 |
#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h> |
|
26 |
#include <e32cmn.h> |
|
27 |
#include <bluetoothuiutil.h> |
|
28 |
#include "btnotifnameutils.h" |
|
29 |
||
30 |
// ================= MEMBER FUNCTIONS ======================= |
|
31 |
||
32 |
// ---------------------------------------------------------- |
|
33 |
// CBTGenericInfoNotifier::NewL |
|
34 |
// Two-phased constructor. |
|
35 |
// ---------------------------------------------------------- |
|
36 |
// |
|
37 |
CBTGenericInfoNotifier* CBTGenericInfoNotifier::NewL() |
|
38 |
{ |
|
39 |
CBTGenericInfoNotifier* self=new (ELeave) CBTGenericInfoNotifier(); |
|
40 |
CleanupStack::PushL(self); |
|
41 |
self->ConstructL(); |
|
42 |
CleanupStack::Pop(); |
|
43 |
return self; |
|
44 |
} |
|
45 |
||
46 |
// ---------------------------------------------------------- |
|
47 |
// CBTGenericInfoNotifier::CBTGenericInfoNotifier |
|
48 |
// C++ default constructor can NOT contain any code, that |
|
49 |
// might leave. |
|
50 |
// ---------------------------------------------------------- |
|
51 |
// |
|
52 |
CBTGenericInfoNotifier::CBTGenericInfoNotifier() |
|
53 |
{ |
|
54 |
} |
|
55 |
||
56 |
// ---------------------------------------------------------- |
|
57 |
// Destructor |
|
58 |
// ---------------------------------------------------------- |
|
59 |
// |
|
60 |
CBTGenericInfoNotifier::~CBTGenericInfoNotifier() |
|
61 |
{ |
|
62 |
Cancel(); // Free own resources |
|
63 |
iQueryMessage.Close(); |
|
64 |
} |
|
65 |
||
66 |
// ---------------------------------------------------------- |
|
67 |
// CBTGenericInfoNotifier::RegisterL |
|
68 |
// Register notifier. |
|
69 |
// ---------------------------------------------------------- |
|
70 |
// |
|
71 |
CBTGenericInfoNotifier::TNotifierInfo CBTGenericInfoNotifier::RegisterL() |
|
72 |
{ |
|
73 |
iInfo.iUid=KBTGenericInfoNotifierUid; |
|
74 |
iInfo.iChannel=KBTGenericInfoNotifierUid; |
|
75 |
iInfo.iPriority=ENotifierPriorityHigh; |
|
76 |
return iInfo; |
|
77 |
} |
|
78 |
||
79 |
// ---------------------------------------------------------- |
|
80 |
// CBTGenericInfoNotifier::StartL |
|
81 |
// Synchronic notifier launch. Contructs and shows a global |
|
82 |
// note when temp visibility expire, no parameters need here. |
|
83 |
// ---------------------------------------------------------- |
|
84 |
// |
|
85 |
TPtrC8 CBTGenericInfoNotifier::StartL( const TDesC8& aBuffer ) |
|
86 |
{ |
|
87 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL()")); |
|
88 |
if( !iNotifUiUtil ) |
|
89 |
{ |
|
90 |
iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); |
|
91 |
} |
|
92 |
ProcessParamBufferL(aBuffer, ETrue); |
|
93 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); |
|
94 |
||
95 |
TPtrC8 ret(KNullDesC8); |
|
96 |
return (ret); |
|
97 |
} |
|
98 |
||
99 |
// ---------------------------------------------------------- |
|
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
100 |
// CBTGenericInfoNotifier::ProcessStartParamsL |
23 | 101 |
// Mandatory for BT Notifiers when using asynchronous launch. |
102 |
// ---------------------------------------------------------- |
|
103 |
// |
|
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
104 |
void CBTGenericInfoNotifier::ProcessStartParamsL() |
23 | 105 |
{ |
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
106 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ProcessStartParamsL")); |
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
107 |
ProcessParamBufferL(*iParamBuffer, EFalse); |
23 | 108 |
} |
109 |
||
110 |
// ---------------------------------------------------------- |
|
111 |
// CBTGenericInfoNotifier::ProcessParamBufferL |
|
112 |
// Parse the data out of the message that is sent by the |
|
113 |
// client of the notifier. |
|
114 |
// ---------------------------------------------------------- |
|
115 |
void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer, TBool aSyncCall) |
|
116 |
{ |
|
117 |
TBTGenericInfoNotifierParams bParams; |
|
118 |
TPckgC<TBTGenericInfoNotifierParams> bPckg(bParams); |
|
119 |
||
120 |
bPckg.Set( aBuffer ); |
|
121 |
iSecondaryDisplayCommand = ECmdBTnotifUnavailable; |
|
122 |
switch (bPckg().iMessageType) |
|
123 |
{ |
|
124 |
case EBTConnected: |
|
125 |
iMessageResourceId= R_BT_CONF_CONNECTED_PROMPT; |
|
126 |
iSecondaryDisplayCommand=ECmdShowBtConnectedNote; |
|
127 |
break; |
|
128 |
case EBTDisconnected: |
|
129 |
iMessageResourceId= R_BT_CONF_DISCONNECTED_PROMPT; |
|
130 |
iSecondaryDisplayCommand=ECmdShowBtDisconnectedNote; |
|
131 |
break; |
|
132 |
case EBTAudioAccessory: |
|
133 |
iMessageResourceId= R_BT_AUDIO_ACCESSORY_PROMPT; |
|
134 |
iSecondaryDisplayCommand=ECmdShowBtAudioAccessoryNote; |
|
135 |
break; |
|
136 |
case EBTAudioHandset: |
|
137 |
iMessageResourceId= R_BT_AUDIO_HANDSET_PROMPT; |
|
138 |
iSecondaryDisplayCommand=ECmdShowBtAudioHandsetNote; |
|
139 |
break; |
|
140 |
case EBTClosed: |
|
141 |
iMessageResourceId= R_BT_CONN_CLOSED_PROMPT; |
|
142 |
iSecondaryDisplayCommand=ECmdShowBtDisconnectedNote; |
|
143 |
break; |
|
144 |
case EBTDeviceNotAvailable: |
|
145 |
iMessageResourceId= R_BT_DEVICE_NOT_AVAIL; |
|
146 |
iSecondaryDisplayCommand=ECmdShowBtDeviceNotAvailableNote; |
|
147 |
break; |
|
148 |
case EBTOfflineDisabled: |
|
149 |
iMessageResourceId= R_BT_OFFLINE_DISABLED; |
|
150 |
iSecondaryDisplayCommand=ECmdShowBtOfflineDisableNote; |
|
151 |
break; |
|
152 |
case EBTVisibilityTimeout: |
|
153 |
iMessageResourceId= R_BT_HIDDEN_FROM_OTHERS_NOTE; |
|
154 |
iSecondaryDisplayCommand=ECmdShowBtHiddenFromOthersNote; |
|
155 |
break; |
|
156 |
case EBTEnterSap: |
|
157 |
iMessageResourceId= R_BT_ENTER_SAP_NOTE; |
|
158 |
iSecondaryDisplayCommand=ECmdShowBtSapEnteringNote; |
|
159 |
break; |
|
160 |
case EBTSapOk: |
|
161 |
iMessageResourceId= R_BT_ENTER_SAP_SUCCEED_NOTE; |
|
162 |
iSecondaryDisplayCommand=ECmdShowBtSapEnteringSucceededNote; |
|
163 |
break; |
|
164 |
case EBTSapFailed: |
|
165 |
iMessageResourceId= R_BT_ENTER_SAP_FAILED_NOTE; |
|
166 |
iSecondaryDisplayCommand=ECmdShowBtSapEnteringFailedNote; |
|
167 |
break; |
|
168 |
case EBTSapNoSim: |
|
169 |
iMessageResourceId= R_BT_SAP_NO_SIM_NOTE; |
|
170 |
iSecondaryDisplayCommand=ECmdShowBtSapNoSimNote; |
|
171 |
break; |
|
172 |
case EBTDeviceBusy: |
|
173 |
iMessageResourceId=R_BT_BUSY_TEXT; |
|
174 |
iSecondaryDisplayCommand=ECmdShowBtBusyNote; |
|
175 |
break; |
|
176 |
case EIRNotSupported: |
|
177 |
iMessageResourceId=R_IR_NOT_SUPPORTED; |
|
178 |
iSecondaryDisplayCommand=ECmdShowIrNotSupportedNote; |
|
179 |
break; |
|
180 |
case ECmdShowBtBatteryLow: |
|
181 |
iMessageResourceId= R_BT_ACCESSORY_LOW; |
|
182 |
iSecondaryDisplayCommand= ECmdShowBtBatteryLowNote; |
|
183 |
break; |
|
184 |
case ECmdShowBtBatteryCritical: |
|
185 |
iMessageResourceId= R_BT_ACCESSORY_CRITICAL; |
|
186 |
iSecondaryDisplayCommand= ECmdShowBtBatteryCriticalNote; |
|
187 |
break; |
|
188 |
case EBTStayPowerOn: |
|
189 |
iMessageResourceId= R_BT_PERMANENTLY_ON; |
|
190 |
break; |
|
191 |
case EBTSwitchedOn: |
|
192 |
iMessageResourceId= R_BT_SWITCHED_ON; |
|
193 |
break; |
|
194 |
case EBTSwitchedOff: |
|
195 |
iMessageResourceId= R_BT_SWITCHED_OFF; |
|
196 |
break; |
|
197 |
default: |
|
198 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); |
|
199 |
User::Leave(KErrNotFound); |
|
200 |
} |
|
201 |
||
202 |
// if the logic string contains substitute indicator "%U", replace it with device name: |
|
203 |
HBufC* buf = StringLoader::LoadL( iMessageResourceId); |
|
204 |
iQueryMessage.Assign( buf ); |
|
205 |
||
206 |
TInt keyLen; |
|
207 |
TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( |
|
208 |
iQueryMessage, 0, keyLen ); |
|
209 |
if( pos > KErrNotFound) |
|
210 |
{ |
|
211 |
iBTAddr = TBTDevAddr( bPckg().iRemoteAddr ); |
|
212 |
if( !iDevice ) |
|
213 |
{ |
|
214 |
iDevice = CBTDevice::NewL(iBTAddr); |
|
215 |
} |
|
216 |
GetDeviceFromRegL( iBTAddr ); |
|
217 |
} |
|
218 |
else |
|
219 |
{ |
|
220 |
ShowNoteAndCompleteL(aSyncCall); |
|
221 |
} |
|
222 |
} |
|
223 |
||
224 |
// ---------------------------------------------------------- |
|
225 |
// CBTGenericInfoNotifier::ShowNoteAndCompleteL |
|
226 |
// Shows the notifier in backround |
|
227 |
// ---------------------------------------------------------- |
|
228 |
// |
|
229 |
void CBTGenericInfoNotifier::ShowNoteAndCompleteL(TBool aSyncCall) |
|
230 |
{ |
|
231 |
iNotifUiUtil->ShowInfoNoteL( iQueryMessage, iSecondaryDisplayCommand ); |
|
232 |
if (!aSyncCall) |
|
233 |
{ |
|
234 |
CompleteMessage(KErrNone); |
|
235 |
} |
|
236 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete")); |
|
237 |
} |
|
238 |
||
239 |
void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) |
|
240 |
{ |
|
241 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()")); |
|
242 |
||
243 |
TBTDeviceName name; |
|
244 |
BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); |
|
245 |
iQueryMessage.Zero(); |
|
246 |
BluetoothUiUtil::LoadResourceAndSubstringL( |
|
247 |
iQueryMessage, iMessageResourceId, name, 0); |
|
248 |
||
249 |
ShowNoteAndCompleteL(EFalse); |
|
250 |
||
251 |
FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete")); |
|
252 |
} |
|
253 |
||
254 |
// End of File |