207 HBufC* defaultText = NULL; |
209 HBufC* defaultText = NULL; |
208 TBool showNote = EFalse; |
210 TBool showNote = EFalse; |
209 |
211 |
210 if ( aBuffer.Length() ) |
212 if ( aBuffer.Length() ) |
211 { |
213 { |
212 //Do nothing as accessory is rightly detected by accessory server and adaptation. |
214 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Default accessory selection or headphones information" ); |
|
215 |
|
216 TInt value( 0 ); |
|
217 TPckg<TInt> pckg( value ); |
|
218 pckg.Copy( aBuffer ); |
|
219 |
|
220 //get "default enhancement" string resource |
|
221 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Read default enhancement string" ); |
|
222 defaultText = iCoeEnv->AllocReadResourceLC( R_TEXT_DEFAULT_ENHANC ); |
|
223 |
|
224 TPtrC enhancement; |
|
225 TBool enhancementOk( ETrue ); |
|
226 |
|
227 if ( value != 0 ) |
|
228 { |
|
229 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Default selection" ); |
|
230 |
|
231 enhancementOk = EFalse; |
|
232 HBufC8* literals = iCoeEnv->AllocReadResourceAsDes8L( R_SELECTION_DIALOG_LITERALS ); |
|
233 TResourceReader reader; |
|
234 reader.SetBuffer( literals ); |
|
235 |
|
236 TInt count( reader.ReadInt16() ); |
|
237 API_TRACE_1( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Read literals, count %d", count ); |
|
238 |
|
239 // Find correct accessory literal |
|
240 for ( TInt i = 0; i < count; i++ ) |
|
241 { |
|
242 //read from resource |
|
243 TUint32 index( reader.ReadUint32() ); |
|
244 API_TRACE_1( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Read literal, index %d", index ); |
|
245 |
|
246 if ( index == value ) |
|
247 { |
|
248 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Literal found!" ); |
|
249 // Literal found |
|
250 enhancement.Set( reader.ReadTPtrC() ); |
|
251 enhancementOk = ETrue; |
|
252 break; |
|
253 } |
|
254 else |
|
255 { |
|
256 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Not found!" ); |
|
257 reader.ReadTPtrC(); |
|
258 } |
|
259 } |
|
260 |
|
261 delete literals; |
|
262 } |
|
263 |
|
264 if ( enhancementOk ) |
|
265 { |
|
266 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Enhancement OK!" ); |
|
267 HBufC* noteStr = NULL; |
|
268 |
|
269 // Headphones... |
|
270 if ( value == 0x08 || value == 0x40 || value == 0 ) |
|
271 { |
|
272 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Show headphones information!" ); |
|
273 |
|
274 // Default enhancement string if needed |
|
275 if ( value != 0 ) |
|
276 { |
|
277 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Show also default information!" ); |
|
278 noteStr = HBufC::NewL( defaultText->Length() + enhancement.Length() + 3 ); |
|
279 |
|
280 TPtr ptr( noteStr->Des() ); |
|
281 ptr.Append( defaultText->Des() ); |
|
282 ptr.Append( ' ' ); |
|
283 ptr.Append( enhancement ); |
|
284 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Default string ready!" ); |
|
285 } |
|
286 |
|
287 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Read use phone mic string!" ); |
|
288 // Read resource use phone mic and default enhancement text... |
|
289 HBufC* usePhoneMicTextHolder = iCoeEnv->AllocReadResourceLC( R_TEXT_HEADPHONES_MIC ); |
|
290 |
|
291 TBool chekcNoteStr( EFalse ); |
|
292 if ( noteStr ) |
|
293 { |
|
294 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Add phone mic string to default accessory string!" ); |
|
295 CleanupStack::PushL( noteStr ); |
|
296 HBufC* temp = noteStr->ReAllocL( noteStr->Length() + 2 + usePhoneMicTextHolder->Length() + 1 ); |
|
297 CleanupStack::Pop( noteStr ); |
|
298 noteStr = temp; |
|
299 chekcNoteStr = ETrue; |
|
300 } |
|
301 else |
|
302 { |
|
303 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Only use phone mic string!" ); |
|
304 noteStr = HBufC::NewL( usePhoneMicTextHolder->Length() + 1 ); |
|
305 } |
|
306 |
|
307 TPtr ptr( noteStr->Des() ); |
|
308 |
|
309 |
|
310 if( chekcNoteStr ) |
|
311 { |
|
312 ptr.Append( _L( ". " ) ); |
|
313 ptr.Append( usePhoneMicTextHolder->Des() ); |
|
314 } |
|
315 else |
|
316 { |
|
317 ptr.Append( usePhoneMicTextHolder->Des() ); |
|
318 } |
|
319 // Cleanup |
|
320 CleanupStack::PopAndDestroy( usePhoneMicTextHolder ); |
|
321 |
|
322 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - String ready!" ); |
|
323 } |
|
324 else |
|
325 { |
|
326 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Create default accessory text!" ); |
|
327 //only default accessory text |
|
328 noteStr = HBufC::NewL( defaultText->Length() + enhancement.Length() + 1 ); |
|
329 TPtr ptr( noteStr->Des() ); |
|
330 |
|
331 ptr.Append( defaultText->Des() ); |
|
332 ptr.Append( ' ' ); |
|
333 ptr.Append( enhancement ); |
|
334 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - Default accessory text ready!" ); |
|
335 } |
|
336 |
|
337 // Pass string to member string and free local copies |
|
338 CleanupStack::PopAndDestroy( defaultText ); |
|
339 CleanupStack::PushL( noteStr ); |
|
340 iNoteText = HBufC::NewL( noteStr->Length() ); |
|
341 TPtr ptr( iNoteText->Des() ); |
|
342 ptr.Append( noteStr->Des() ); |
|
343 CleanupStack::PopAndDestroy( noteStr ); |
|
344 showNote = ETrue; |
|
345 } |
|
346 else |
|
347 { |
|
348 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - No note" ); |
|
349 // No need to check this one, always set into cleanup stack |
|
350 CleanupStack::PopAndDestroy( defaultText ); |
|
351 } |
213 } |
352 } |
214 else |
353 else |
215 { |
354 { |
216 // Read resource string and adds heap buffer into cleanup stack. |
355 // Read resource string and adds heap buffer into cleanup stack. |
217 // This needs to be before creating 'note' for correct cleanup handling |
356 // This needs to be before creating 'note' for correct cleanup handling |
251 if ( iIsCancelled ) |
396 if ( iIsCancelled ) |
252 { |
397 { |
253 return; |
398 return; |
254 } |
399 } |
255 |
400 |
256 CHbDeviceMessageBoxSymbian *messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation); |
401 // Create note |
257 CleanupStack::PushL(messageBox); |
402 iNote = new ( ELeave ) CAknNoteDialog( |
258 messageBox->SetTextL(*iNoteText); |
403 CAknNoteDialog::ENoTone, |
259 messageBox->ShowL(); |
404 CAknNoteDialog::ELongTimeout ); |
260 CleanupStack::PopAndDestroy(messageBox); // messageBox |
405 |
261 delete iNoteText; |
406 iNote->PrepareLC( R_ACCFWUINOTIFIER_INFORMATION_NOTE ); // Adds to CleanupStack |
262 iNoteText = NULL; |
407 |
|
408 if ( iPublishNote ) |
|
409 { |
|
410 iNote->PublishDialogL( ECmdShowAccessoryNotSupportedNote, KCatAccFw ); |
|
411 iPublishNote = EFalse; |
|
412 } |
|
413 |
|
414 iNote->SetTextL( *iNoteText ); |
|
415 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::StartL() - iNote->RunLD()!" ); |
|
416 iNote->RunLD(); |
|
417 iNote = NULL; |
|
418 delete iNoteText; |
|
419 iNoteText = NULL; |
263 |
420 |
264 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::RunL() - Complete message" ); |
421 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::RunL() - Complete message" ); |
265 iMessage.Complete( KErrNone ); |
422 iMessage.Complete( KErrNone ); |
266 |
423 |
267 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::RunL() - return" ); |
424 API_TRACE_( "[AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::RunL() - return" ); |