bluetoothengine/btnotif/src/BTNotifier.cpp
branchRCL_3
changeset 72 4b59561a31c0
parent 61 269724087bed
equal deleted inserted replaced
64:1934667b0e2b 72:4b59561a31c0
    91     FeatureManager::UnInitializeLib(); 
    91     FeatureManager::UnInitializeLib(); 
    92 
    92 
    93     iBTEngSettings = CBTEngSettings::NewL();
    93     iBTEngSettings = CBTEngSettings::NewL();
    94     iDevMan = CBTEngDevMan::NewL( this );
    94     iDevMan = CBTEngDevMan::NewL( this );
    95     iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );
    95     iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );
    96     iAuthoriseDialog = CBTNotifUIUtil::NewL( iIsCoverUI );
       
    97 
       
    98     TCallBack processParamsCb(ProcessStartParamsCallBack, this);
       
    99     iProcessStartParamsCallBack = new (ELeave) CAsyncCallBack(processParamsCb, CActive::EPriorityHigh);
       
   100     }
    96     }
   101 
    97 
   102 // ----------------------------------------------------------
    98 // ----------------------------------------------------------
   103 // Destructor.
    99 // Destructor.
   104 // ----------------------------------------------------------
   100 // ----------------------------------------------------------
   105 //
   101 //
   106 CBTNotifierBase::~CBTNotifierBase()
   102 CBTNotifierBase::~CBTNotifierBase()
   107     {
   103     {
   108     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase()"));    
   104     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase()"));    
   109     Cancel();
   105     Cancel();
   110 
       
   111     delete iProcessStartParamsCallBack;
       
   112     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase() -- Done"));    
   106     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::~CBTNotifierBase() -- Done"));    
   113     }
   107     }
   114 
   108 
   115 // ----------------------------------------------------------
   109 // ----------------------------------------------------------
   116 // CBTNotifierBase::Release
   110 // CBTNotifierBase::Release
   149 // Asynchronic notifier launch.
   143 // Asynchronic notifier launch.
   150 // ----------------------------------------------------------
   144 // ----------------------------------------------------------
   151 //
   145 //
   152 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
   146 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
   153     {
   147     {
   154     if (!iMessage.IsNull())
       
   155         {
       
   156         // We're already active. The notifier server will complete the message if we leave.
       
   157         User::Leave(KErrInUse);
       
   158         }
       
   159 
       
   160     __ASSERT_DEBUG(!iParamBuffer, BTNOTIF_PANIC(EiParamBufferLeakedFromPreviousActivation));
       
   161 
       
   162     if( !iNotifUiUtil )
   148     if( !iNotifUiUtil )
   163         {
   149         {
   164         iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );    
   150         iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );    
   165         }
   151         }
   166     if( !iAuthoriseDialog )
   152     
   167         {
   153     TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage));
   168         iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI );    
   154     if (err)
   169         }
   155         {
   170 
   156         CompleteMessage(err);
   171     iParamBuffer    = aBuffer.AllocL(); // ProcessStartParamsCallBack responsible for deallocation
   157         }
   172     iMessage        = aMessage;
       
   173     iReplySlot      = aReplySlot;
       
   174 
       
   175     // Return from StartL as soon as possible - processing the parameters involves displaying
       
   176     // waiting dialogs which would block the notifier server thus preventing other notifiers
       
   177     // from running, were we to do it from here.
       
   178     iProcessStartParamsCallBack->CallBack();
       
   179     }
   158     }
   180 
   159 
   181 // ----------------------------------------------------------
   160 // ----------------------------------------------------------
   182 // CBTNotifierBase::Cancel
   161 // CBTNotifierBase::Cancel
   183 // Cancelling method.
   162 // Cancelling method.
   185 //
   164 //
   186 void CBTNotifierBase::Cancel()
   165 void CBTNotifierBase::Cancel()
   187     {
   166     {
   188     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::Cancel()"));    
   167     FLOG(_L("[BTNOTIF]\t CBTNotifierBase::Cancel()"));    
   189 
   168 
   190     // In case we are being called before ProcessStartParamsCallBack
       
   191     // had a chance to run:
       
   192     delete iParamBuffer;
       
   193     iParamBuffer = NULL;
       
   194 
       
   195     if (iProcessStartParamsCallBack)
       
   196         {
       
   197         iProcessStartParamsCallBack->Cancel();
       
   198         // - the callback object is deleted in the destructor.
       
   199         }
       
   200 
       
   201     delete iNotifUiUtil;
   169     delete iNotifUiUtil;
   202     iNotifUiUtil = NULL;
   170     iNotifUiUtil = NULL;
   203     
       
   204     delete iAuthoriseDialog;
       
   205     iAuthoriseDialog = NULL;
       
   206     
   171     
   207 	delete iBTEngSettings;
   172 	delete iBTEngSettings;
   208     iBTEngSettings = NULL;
   173     iBTEngSettings = NULL;
   209 
   174 
   210     delete iDevMan;
   175     delete iDevMan;
   230 //
   195 //
   231 TPtrC8 CBTNotifierBase::UpdateL(const TDesC8& /*aBuffer*/)
   196 TPtrC8 CBTNotifierBase::UpdateL(const TDesC8& /*aBuffer*/)
   232     {
   197     {
   233     TPtrC8 ret(KNullDesC8);
   198     TPtrC8 ret(KNullDesC8);
   234     return (ret);
   199     return (ret);
   235     }
       
   236 
       
   237 TInt CBTNotifierBase::ProcessStartParamsCallBack(TAny* aNotif)
       
   238     {
       
   239     CBTNotifierBase* notif = static_cast<CBTNotifierBase*>(aNotif);
       
   240 
       
   241     __ASSERT_DEBUG(notif->iParamBuffer, BTNOTIF_PANIC(EiParamBufferNullInProcessStartParams));
       
   242     __ASSERT_DEBUG(!notif->iMessage.IsNull(), BTNOTIF_PANIC(EiMessageNullInProcessStartParams));
       
   243 
       
   244     TRAPD(err, notif->ProcessStartParamsL());
       
   245     if (err)
       
   246         {
       
   247         notif->CompleteMessage(err);
       
   248         }
       
   249 
       
   250     delete notif->iParamBuffer;
       
   251     notif->iParamBuffer = NULL;
       
   252 
       
   253     return 0;
       
   254     }
   200     }
   255 
   201 
   256 
   202 
   257 // ----------------------------------------------------------
   203 // ----------------------------------------------------------
   258 // CBTNotifierBase::AutoLockOnL
   204 // CBTNotifierBase::AutoLockOnL