bluetoothengine/btnotif/btnotifsrv/src/btnotifgeninfonotifier.cpp
changeset 70 f5508c13dfe0
parent 57 5ebadcda06cb
equal deleted inserted replaced
67:16e4b9007960 70:f5508c13dfe0
    32 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    33 // C++ default constructor
    33 // C++ default constructor
    34 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    35 //
    35 //
    36 CBTNotifGenInfoNotifier::CBTNotifGenInfoNotifier( CBTNotifServer* aServer )
    36 CBTNotifGenInfoNotifier::CBTNotifGenInfoNotifier( CBTNotifServer* aServer )
    37 :   iServer( aServer )
    37 :   iServer( aServer ),iNotification(NULL),iEnterSAPNotification(NULL)
    38     {
    38     {
    39     }
    39     }
    40 
    40 
    41 
    41 
    42 // ---------------------------------------------------------------------------
    42 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   147 //
   147 //
   148 void CBTNotifGenInfoNotifier::ShowNotificationL(const RMessage2& aMessage )
   148 void CBTNotifGenInfoNotifier::ShowNotificationL(const RMessage2& aMessage )
   149     {
   149     {
   150     BOstraceFunctionEntry0( DUMMY_DEVLIST );
   150     BOstraceFunctionEntry0( DUMMY_DEVLIST );
   151     if(iNotification)
       
   152         {
       
   153         iNotification->RemoveObserver();
       
   154         iNotification = NULL;
       
   155         }
       
   156     iNotification = iServer->NotificationManager()->GetNotification();
       
   157     User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
       
   158     iNotification->SetObserver( this );
       
   159     iNotification->SetNotificationType( TBluetoothDialogParams::ENote, EGenericInfo );
       
   160     
       
   161     // read the message parameters
   151     // read the message parameters
   162     RBuf8 params;
   152     RBuf8 params;
   163     params.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
   153     params.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
   164     aMessage.ReadL( EBTNotifSrvParamSlot, params );
   154     aMessage.ReadL( EBTNotifSrvParamSlot, params );
   165     TBTGenericInfoNotifierParams notifparams;
   155     TBTGenericInfoNotifierParams notifparams;
   166     TPckgC<TBTGenericInfoNotifierParams> paramsPckg( notifparams );
   156     TPckgC<TBTGenericInfoNotifierParams> paramsPckg( notifparams );
   167     paramsPckg.Set( params );
   157     paramsPckg.Set( params );
   168     TInt notifType = paramsPckg().iMessageType;
   158     TInt notifType = paramsPckg().iMessageType;
       
   159 
       
   160     TInt err = KErrNone;
       
   161 
       
   162     if(iNotification)
       
   163         {
       
   164         iNotification->RemoveObserver();
       
   165         iNotification = NULL;
       
   166         }
       
   167     iNotification = iServer->NotificationManager()->GetNotification();
       
   168     User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
       
   169     iNotification->SetObserver( this );
   169     
   170     
   170     switch(notifType)
   171     switch(notifType)
   171         {
   172         {
   172         case EBTSwitchedOn:
   173         case EBTSwitchedOn:
   173         case EBTSwitchedOff:
   174         case EBTSwitchedOff:
   174             {
   175             {
   175             User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EAdditionalInt, notifType));
   176             User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EAdditionalInt, notifType));
       
   177             iNotification->SetNotificationType( TBluetoothDialogParams::ENote, EGenericInfo );
   176             }break;
   178             }break;
   177             
   179         case EBTEnterSap:
       
   180             // save the pointer in order to dismiss the dialog later on
       
   181             iEnterSAPNotification = iNotification;
       
   182             iNotification->SetNotificationType( TBluetoothDialogParams::bt_052_d_entering, EUnusedResource );
       
   183             break;
       
   184         case EBTSapNoSim:
       
   185             iNotification->SetNotificationType( TBluetoothDialogParams::bt_053_d_unable_to_use_no_sim, EUnusedResource );
       
   186             break;
       
   187         case EBTSapFailed:
       
   188             iNotification->SetNotificationType( TBluetoothDialogParams::bt_053_d_unable_to_use, EUnusedResource );
       
   189             break;
       
   190         case EBTSapOk:
       
   191             if(iEnterSAPNotification)
       
   192                 iEnterSAPNotification->Close();
       
   193             iNotification->SetNotificationType( TBluetoothDialogParams::bt_054_d_entered_popup, EGenericInfo );
       
   194             // Todo: handler err in a proper way
       
   195             err = iNotification->SetData( TBluetoothDeviceDialog::EAdditionalInt, notifType);
       
   196             break;
   178         default:
   197         default:
   179             {
   198             {
       
   199             iNotification->SetNotificationType( TBluetoothDialogParams::ENote, EGenericInfo );
   180             TBTDevAddr addr(paramsPckg().iRemoteAddr);
   200             TBTDevAddr addr(paramsPckg().iRemoteAddr);
   181 
   201 
   182             // Get the device name
   202             // Get the device name
   183             TInt err = KErrNone;
       
   184 
       
   185             const CBtDevExtension* dev = iServer->DevRepository().Device(addr);
   203             const CBtDevExtension* dev = iServer->DevRepository().Device(addr);
   186             if(dev)
   204             if(dev)
   187                 {
   205                 {
   188                 if(0 != dev->Device().FriendlyName().Length()&& dev->Device().IsValidFriendlyName())
   206                 if(0 != dev->Device().FriendlyName().Length()&& dev->Device().IsValidFriendlyName())
   189                     {
   207                     {