22 #include <BTNotif.rsg> // Own resources |
22 #include <BTNotif.rsg> // Own resources |
23 #include "BTNGenericInfoNotifier.h" // Own class definition |
23 #include "BTNGenericInfoNotifier.h" // Own class definition |
24 #include "btNotifDebug.h" // Debugging macros |
24 #include "btNotifDebug.h" // Debugging macros |
25 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h> |
25 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h> |
26 #include <e32cmn.h> |
26 #include <e32cmn.h> |
|
27 #include <bluetoothuiutil.h> |
27 #include "btnotifnameutils.h" |
28 #include "btnotifnameutils.h" |
28 |
29 |
29 // ================= MEMBER FUNCTIONS ======================= |
30 // ================= MEMBER FUNCTIONS ======================= |
30 |
31 |
31 // ---------------------------------------------------------- |
32 // ---------------------------------------------------------- |
82 // ---------------------------------------------------------- |
83 // ---------------------------------------------------------- |
83 // |
84 // |
84 TPtrC8 CBTGenericInfoNotifier::StartL( const TDesC8& aBuffer ) |
85 TPtrC8 CBTGenericInfoNotifier::StartL( const TDesC8& aBuffer ) |
85 { |
86 { |
86 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL()")); |
87 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL()")); |
87 ProcessParamBufferL(aBuffer); |
88 if( !iNotifUiUtil ) |
88 |
89 { |
89 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); |
90 iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); |
90 |
91 } |
|
92 ProcessParamBufferL(aBuffer, ETrue); |
|
93 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); |
|
94 |
91 TPtrC8 ret(KNullDesC8); |
95 TPtrC8 ret(KNullDesC8); |
92 return (ret); |
96 return (ret); |
93 } |
97 } |
94 |
98 |
95 // ---------------------------------------------------------- |
99 // ---------------------------------------------------------- |
106 { |
110 { |
107 aMessage.Complete(KErrInUse); |
111 aMessage.Complete(KErrInUse); |
108 return; |
112 return; |
109 } |
113 } |
110 iMessage = aMessage; |
114 iMessage = aMessage; |
111 ProcessParamBufferL(aBuffer); |
115 ProcessParamBufferL(aBuffer, EFalse); |
112 } |
116 } |
113 |
117 |
114 // ---------------------------------------------------------- |
118 // ---------------------------------------------------------- |
115 // CBTGenericInfoNotifier::ProcessParamBufferL |
119 // CBTGenericInfoNotifier::ProcessParamBufferL |
116 // Parse the data out of the message that is sent by the |
120 // Parse the data out of the message that is sent by the |
117 // client of the notifier. |
121 // client of the notifier. |
118 // ---------------------------------------------------------- |
122 // ---------------------------------------------------------- |
119 void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer) |
123 void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer, TBool aSyncCall) |
120 { |
124 { |
121 TBTGenericInfoNotifierParams bParams; |
125 TBTGenericInfoNotifierParams bParams; |
122 TPckgC<TBTGenericInfoNotifierParams> bPckg(bParams); |
126 TPckgC<TBTGenericInfoNotifierParams> bPckg(bParams); |
123 |
127 |
124 bPckg.Set( aBuffer ); |
128 bPckg.Set( aBuffer ); |
125 iSecondaryDisplayCommand = ECmdBTnotifUnavailable; |
129 iSecondaryDisplayCommand = ECmdBTnotifUnavailable; |
126 switch (bPckg().iMessageType) |
130 switch (bPckg().iMessageType) |
127 { |
131 { |
201 default: |
205 default: |
202 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); |
206 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); |
203 User::Leave(KErrNotFound); |
207 User::Leave(KErrNotFound); |
204 } |
208 } |
205 |
209 |
206 // if the logic string contains substitute indicator "%U", replace it with device name: |
210 // if the logic string contains substitute indicator "%U", replace it with device name: |
207 iQueryMessage = StringLoader::LoadL( iMessageResourceId); |
211 HBufC* buf = StringLoader::LoadL( iMessageResourceId); |
208 _LIT(PU,"%U"); |
212 iQueryMessage.Assign( buf ); |
209 if( iQueryMessage->Find(PU) != KErrNotFound) |
213 |
|
214 TInt keyLen; |
|
215 TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( |
|
216 iQueryMessage, 0, keyLen ); |
|
217 if( pos > KErrNotFound) |
210 { |
218 { |
211 iBTAddr = TBTDevAddr( bPckg().iRemoteAddr ); |
219 iBTAddr = TBTDevAddr( bPckg().iRemoteAddr ); |
212 iDevice = CBTDevice::NewL(iBTAddr); |
220 if( !iDevice ) |
|
221 { |
|
222 iDevice = CBTDevice::NewL(iBTAddr); |
|
223 } |
213 GetDeviceFromRegL( iBTAddr ); |
224 GetDeviceFromRegL( iBTAddr ); |
214 } |
225 } |
215 else |
226 else |
216 { |
227 { |
217 ShowNoteAndCompleteL(); |
228 ShowNoteAndCompleteL(aSyncCall); |
218 } |
229 } |
219 } |
230 } |
220 |
231 |
221 // ---------------------------------------------------------- |
232 // ---------------------------------------------------------- |
222 // CBTGenericInfoNotifier::ShowNoteAndCompleteL |
233 // CBTGenericInfoNotifier::ShowNoteAndCompleteL |
223 // Shows the notifier in backround |
234 // Shows the notifier in backround |
224 // ---------------------------------------------------------- |
235 // ---------------------------------------------------------- |
225 // |
236 // |
226 void CBTGenericInfoNotifier::ShowNoteAndCompleteL() |
237 void CBTGenericInfoNotifier::ShowNoteAndCompleteL(TBool aSyncCall) |
227 { |
238 { |
228 iNotifUiUtil->ShowInfoNoteL( *iQueryMessage, iSecondaryDisplayCommand ); |
239 iNotifUiUtil->ShowInfoNoteL( iQueryMessage, iSecondaryDisplayCommand ); |
229 CompleteMessage(KErrNone); |
240 if (!aSyncCall) |
|
241 { |
|
242 CompleteMessage(KErrNone); |
|
243 } |
230 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete")); |
244 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete")); |
231 } |
245 } |
232 |
246 |
233 void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) |
247 void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) |
234 { |
248 { |
235 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()")); |
249 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()")); |
236 |
|
237 delete iQueryMessage; |
|
238 iQueryMessage=NULL; |
|
239 |
250 |
240 TBTDeviceName name; |
251 TBTDeviceName name; |
241 BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); |
252 BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); |
242 iQueryMessage = StringLoader::LoadL( iMessageResourceId, name); |
253 iQueryMessage.Zero(); |
|
254 BluetoothUiUtil::LoadResourceAndSubstringL( |
|
255 iQueryMessage, iMessageResourceId, name, 0); |
243 |
256 |
244 ShowNoteAndCompleteL(); |
257 ShowNoteAndCompleteL(EFalse); |
245 |
258 |
246 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete")); |
259 FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete")); |
247 } |
260 } |
248 |
261 |
249 // End of File |
262 // End of File |