bluetoothengine/btnotif/btnotifsrv/src/bluetoothnotification.cpp
changeset 42 b72428996822
parent 31 a0ea99b6fa53
child 57 5ebadcda06cb
equal deleted inserted replaced
32:19bd632b5100 42:b72428996822
   146 TInt CBluetoothNotification::Close()
   146 TInt CBluetoothNotification::Close()
   147     {
   147     {
   148     BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
   148     BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
   149     iDialog->Cancel();
   149     iDialog->Cancel();
   150     iManager->ReleaseNotification( this );
   150     iManager->ReleaseNotification( this );
   151 	BOstraceFunctionExit1( DUMMY_DEVLIST, this );
   151 	BOstraceFunctionExit0( DUMMY_DEVLIST );
   152     return KErrNone;
   152     return KErrNone;
   153     }
   153     }
   154 
   154 
   155 
   155 
   156 // ---------------------------------------------------------------------------
   156 // ---------------------------------------------------------------------------
   159 //
   159 //
   160 void CBluetoothNotification::SetDataL( TInt aType, const TDesC& aData )
   160 void CBluetoothNotification::SetDataL( TInt aType, const TDesC& aData )
   161     {
   161     {
   162     BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
   162     BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
   163     TBuf16<6> key;
   163     TBuf16<6> key;
   164     TInt err = 0;
       
   165     CHbSymbianVariant* value = NULL;
   164     CHbSymbianVariant* value = NULL;
   166     switch( aType )
   165     switch( aType )
   167         {
   166         {
   168         case TBluetoothDialogParams::EAddress:
   167         case TBluetoothDialogParams::EAddress:
   169         case TBluetoothDeviceDialog::EDeviceName:
   168         case TBluetoothDeviceDialog::EDeviceName:
   189                     }
   188                     }
   190                     TPtrC p(buf);
   189                     TPtrC p(buf);
   191                     TPtrC16 *ptr = (TPtrC16 *)value->Data();
   190                     TPtrC16 *ptr = (TPtrC16 *)value->Data();
   192                     BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
   191                     BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
   193                     );
   192                     );
   194             err = iNotificationData->Add( key, value );   // Takes ownership of value
   193             User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
   195             if ( err )
       
   196                 {
       
   197                 // Note: need a proper exception handling. 
       
   198                 // NOTIF_NOTHANDLED( err )
       
   199                 }
       
   200             break;
   194             break;
   201         case TBluetoothDialogParams::EResource:
   195         case TBluetoothDialogParams::EResource:
   202         case TBluetoothDeviceDialog::EDeviceClass:
   196         case TBluetoothDeviceDialog::EDeviceClass:
   203         case TBluetoothDeviceDialog::EAdditionalInt:
   197         case TBluetoothDeviceDialog::EAdditionalInt:
   204             PanicServer( EBTNotifPanicBadArgument );
   198             PanicServer( EBTNotifPanicBadArgument );
   218 //
   212 //
   219 void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
   213 void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
   220     {
   214     {
   221     BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
   215     BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
   222     TBuf<6> key;
   216     TBuf<6> key;
   223     TInt err = 0;
       
   224     CHbSymbianVariant* value = NULL;
   217     CHbSymbianVariant* value = NULL;
   225     switch( aType )
   218     switch( aType )
   226         {
   219         {
   227         case TBluetoothDialogParams::EDialogType:
   220         case TBluetoothDialogParams::EDialogType:
   228         case TBluetoothDialogParams::EResource:
   221         case TBluetoothDialogParams::EResource:
   249                     }
   242                     }
   250                     TPtrC p(buf);
   243                     TPtrC p(buf);
   251                     TInt *intPtr = (TInt *)value->Data();
   244                     TInt *intPtr = (TInt *)value->Data();
   252                     BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
   245                     BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
   253                     );
   246                     );
   254 			err = iNotificationData->Add( key, value );   // Takes ownership of value
   247 			User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
   255 	         if ( err )
       
   256 	             {
       
   257                  // need a proper exception handling.
       
   258                  //NOTIF_NOTHANDLED( !err )
       
   259 	             }
       
   260             
       
   261             break;
   248             break;
   262         case TBluetoothDialogParams::EAddress:
   249         case TBluetoothDialogParams::EAddress:
   263         case TBluetoothDeviceDialog::EDeviceName:
   250         case TBluetoothDeviceDialog::EDeviceName:
   264             PanicServer( EBTNotifPanicBadArgument );
   251             PanicServer( EBTNotifPanicBadArgument );
   265             break;
   252             break;
   295                 {
   282                 {
   296                 // todo: better exception handing than ignoring this failure?
   283                 // todo: better exception handing than ignoring this failure?
   297                 }
   284                 }
   298             }
   285             }
   299         }
   286         }
   300     iObserver->MBRDataReceived( aData );
   287     if( iObserver )
       
   288         {
       
   289     	iObserver->MBRDataReceived( aData );
       
   290         }
   301     BOstraceFunctionExit1( DUMMY_DEVLIST, this );
   291     BOstraceFunctionExit1( DUMMY_DEVLIST, this );
   302     }
   292     }
   303 
   293 
   304 #ifdef BLUETOOTHTRACE_ENABLED
   294 #ifdef BLUETOOTHTRACE_ENABLED
   305 
   295 
   398         iObserver->MBRNotificationClosed( aCompletionCode, resultPtr );
   388         iObserver->MBRNotificationClosed( aCompletionCode, resultPtr );
   399         }
   389         }
   400     resultBuf.Close();
   390     resultBuf.Close();
   401     iManager->ReleaseNotification( this );
   391     iManager->ReleaseNotification( this );
   402     // Note that we might get deleted after releasing ourselves.
   392     // Note that we might get deleted after releasing ourselves.
   403     BOstraceFunctionExit1( DUMMY_DEVLIST, this );
   393     BOstraceFunctionExit0( DUMMY_DEVLIST );
   404     }
   394     }
   405 
   395