bluetoothengine/btnotif/btnotifwrapper/src/btnotifwrapper.cpp
changeset 31 a0ea99b6fa53
parent 29 48ae3789ce00
equal deleted inserted replaced
30:df7a93ede42e 31:a0ea99b6fa53
   163 
   163 
   164     // We need to store the parameters locally, as aBuffer is destroyed after
   164     // We need to store the parameters locally, as aBuffer is destroyed after
   165     // returning from this call. We do it on the heap, so we do not permanently
   165     // returning from this call. We do it on the heap, so we do not permanently
   166     // consume memory for the buffer.
   166     // consume memory for the buffer.
   167 
   167 
   168     iParamsBuf = HBufC8::NewL( aBuffer.Size() );
   168     iParamsBuf.CreateL( aBuffer );
   169     *iParamsBuf = aBuffer;
       
   170 
       
   171     TInt len = aMessage.GetDesMaxLength( aReplySlot );
   169     TInt len = aMessage.GetDesMaxLength( aReplySlot );
   172     iResponseBuf = HBufC8::NewL( len );
   170     
   173     // Copy in the response, to get the right buffer size.
   171     iResponseBuf.CreateL( len );
   174     iResponsePtr.Set( iResponseBuf->Des() );
   172     aMessage.ReadL( aReplySlot, iResponseBuf );
   175     aMessage.ReadL( aReplySlot, iResponsePtr );
       
   176 
   173 
   177     iBTNotif.StartNotifierAndGetResponse( iActive->RequestStatus(),
   174     iBTNotif.StartNotifierAndGetResponse( iActive->RequestStatus(),
   178                 iUid, *iParamsBuf, iResponsePtr );
   175                 iUid, iParamsBuf, iResponseBuf );
   179     iActive->GoActive();
   176     iActive->GoActive();
   180     // record the request
   177     // record the request
   181     iReplySlot = aReplySlot;
   178     iReplySlot = aReplySlot;
   182     iMessage = aMessage;
   179     iMessage = aMessage;
   183     }
   180     }
   197     if( !iMessage.IsNull() )
   194     if( !iMessage.IsNull() )
   198         {
   195         {
   199         iMessage.Complete( KErrCancel );
   196         iMessage.Complete( KErrCancel );
   200         }
   197         }
   201     iReplySlot = 0;
   198     iReplySlot = 0;
   202     delete iParamsBuf;
   199     iParamsBuf.Close();
   203     iParamsBuf = NULL;
   200     iResponseBuf.Close();
   204     delete iResponseBuf;
       
   205     iResponseBuf = NULL;
       
   206     }
   201     }
   207 
   202 
   208 // ---------------------------------------------------------------------------
   203 // ---------------------------------------------------------------------------
   209 // From class MEikSrvNotifierBase2.
   204 // From class MEikSrvNotifierBase2.
   210 // Synchronous notifier update.
   205 // Synchronous notifier update.
   257     ASSERT( aActive->RequestId() == KWrapperActive );
   252     ASSERT( aActive->RequestId() == KWrapperActive );
   258     (void) aActive;
   253     (void) aActive;
   259     if( !iMessage.IsNull() )
   254     if( !iMessage.IsNull() )
   260         {
   255         {
   261         TInt err( aStatus );
   256         TInt err( aStatus );
   262         if( !aStatus )
   257         if( !err )
   263             {
   258             {
   264             // for testing:
   259             err = iMessage.Write( iReplySlot, iResponseBuf );
   265             //TPckgBuf<TBTDeviceResponseParams> response;
       
   266             //response.Copy( *iResponseBuf );
       
   267             //response().BDAddr();
       
   268             err = iMessage.Write( iReplySlot, *iResponseBuf );
       
   269             }
   260             }
   270         iMessage.Complete( err );
   261         iMessage.Complete( err );
   271         }
   262         }
   272     // Clean up after usage.
   263     // Clean up after usage.
   273     iBTNotif.Close();
   264     iBTNotif.Close();
   274     delete iParamsBuf;
       
   275     iParamsBuf = NULL;
       
   276     delete iResponseBuf;
       
   277     iResponseBuf = NULL;
       
   278     delete iActive;
   265     delete iActive;
   279     iActive = NULL;
   266     iActive = NULL;
   280     }
   267     }
   281 
   268 
   282 
   269