bluetoothengine/bteng/btengdiscovery/src/btengdevicesearch.cpp
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
    70 // Destructor
    70 // Destructor
    71 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    72 //
    72 //
    73 CBTEngDeviceSearch::~CBTEngDeviceSearch()
    73 CBTEngDeviceSearch::~CBTEngDeviceSearch()
    74     {
    74     {
       
    75     if( iNotifier.Handle()&& iActive->IsActive())
       
    76        {
       
    77        iNotifier.CancelNotifier( KDeviceSelectionNotifierUid );
       
    78        iActive->CancelRequest();
       
    79        }
    75     delete iActive;
    80     delete iActive;
    76     iNotifier.Close();
    81     iNotifier.Close();
    77     iHostResolver.Close();
    82     iHostResolver.Close();
    78     iSocketServer.Close();
    83     iSocketServer.Close();
    79     }
    84     }
   125 void CBTEngDeviceSearch::CancelSearch()
   130 void CBTEngDeviceSearch::CancelSearch()
   126     {
   131     {
   127     TRACE_FUNC_ENTRY
   132     TRACE_FUNC_ENTRY
   128     if( iActive->IsActive() && iClientReq == EDeviceSearch)
   133     if( iActive->IsActive() && iClientReq == EDeviceSearch)
   129         {
   134         {
   130         iActive->Cancel();
       
   131         if (iActive->RequestId() == KDevSearchAoReqId)
   135         if (iActive->RequestId() == KDevSearchAoReqId)
   132             {
   136             {
       
   137             iNotifier.CancelNotifier( KDeviceSelectionNotifierUid );
       
   138             iActive->CancelRequest();
   133             iNotifier.Close();
   139             iNotifier.Close();
   134             NotifyClient(KErrAbort);
   140             NotifyClient(KErrAbort);
   135             }
   141             }
   136         else if (iActive->RequestId() == KDevEirServiceListAoReqId)
   142         else if (iActive->RequestId() == KDevEirServiceListAoReqId)
   137             {
   143             {
       
   144             iHostResolver.Cancel();
   138             iHostResolver.Close();
   145             iHostResolver.Close();
   139             }
   146             }
   140         }
   147         }
       
   148     
   141     TRACE_FUNC_EXIT
   149     TRACE_FUNC_EXIT
   142     }
   150     }
   143 
   151 
   144 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
   145 // Get cached EIR data from host resolver and extract service uuids
   153 // Get cached EIR data from host resolver and extract service uuids
   172 void CBTEngDeviceSearch::CancelGetEirServiceUUIDs()
   180 void CBTEngDeviceSearch::CancelGetEirServiceUUIDs()
   173     {
   181     {
   174     TRACE_FUNC_ENTRY
   182     TRACE_FUNC_ENTRY
   175     if( iActive->IsActive() && iClientReq == EGetDeviceEir)
   183     if( iActive->IsActive() && iClientReq == EGetDeviceEir)
   176         {
   184         {
   177         iActive->Cancel();
   185         iHostResolver.Cancel();
   178         iHostResolver.Close();
   186         iHostResolver.Close();
   179         }
   187         }
   180     TRACE_FUNC_EXIT
   188     TRACE_FUNC_EXIT
   181     }
   189     }
   182 
   190 
   183 // ---------------------------------------------------------------------------
   191 // ---------------------------------------------------------------------------
   184 // From class MBTEngActiveObserver.
   192 // From class MBTEngActiveObserver.
   185 // Callback to notify that an outstanding request has completed.
   193 // Callback to notify that an outstanding request has completed.
   186 // ---------------------------------------------------------------------------
   194 // ---------------------------------------------------------------------------
   187 //
   195 //
   188 void CBTEngDeviceSearch::RequestCompletedL( CBTEngActive* aActive, 
   196 void CBTEngDeviceSearch::RequestCompletedL( CBTEngActive* aActive, TInt aId, 
   189     TInt aStatus )
   197     TInt aStatus )
   190     {
   198     {
   191     TRACE_FUNC_ARG( ( _L( "status: %d") , aStatus ) )
   199     TRACE_FUNC_ARG( ( _L( "status: %d") , aStatus ) )
   192     (void) aActive;
   200     (void) aActive;
   193     if ( aActive->RequestId() == KDevSearchAoReqId )
   201     if ( aId == KDevSearchAoReqId )
   194         {
   202         {
   195         HandleDeviceSelectionResultL(aStatus);
   203         HandleDeviceSelectionResultL(aStatus);
   196         }
   204         }
   197     else if ( aActive->RequestId() == KDevEirServiceListAoReqId )
   205     else if (aId == KDevEirServiceListAoReqId)
   198         {
   206         {
   199         HandleDeviceEirDataResult( aStatus );
   207         HandleDeviceEirDataResult( aStatus );
   200         }
   208         }
   201     TRACE_FUNC_EXIT
   209     TRACE_FUNC_EXIT
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // From class MBTEngActiveObserver.
       
   206 // Handles cancelation of an outstanding request
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 void CBTEngDeviceSearch::CancelRequest( TInt aRequestId )
       
   210     {
       
   211     TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) )
       
   212     if ( aRequestId == KDevSearchAoReqId )
       
   213         {
       
   214         iNotifier.CancelNotifier( KDeviceSelectionNotifierUid );
       
   215         }
       
   216     else if ( aRequestId == KDevEirServiceListAoReqId )
       
   217         {
       
   218         iHostResolver.Cancel();
       
   219         }
       
   220     TRACE_FUNC_EXIT 
       
   221     }
   210     }
   222 
   211 
   223 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   224 // From class MBTEngActiveObserver.
   213 // From class MBTEngActiveObserver.
   225 // Callback to notify that an error has occurred in RunL.
   214 // Callback to notify that an error has occurred in RunL.
   226 // ---------------------------------------------------------------------------
   215 // ---------------------------------------------------------------------------
   227 //
   216 //
   228 void CBTEngDeviceSearch::HandleError( CBTEngActive* aActive, 
   217 void CBTEngDeviceSearch::HandleError( CBTEngActive* aActive, TInt aId, 
   229     TInt aError )
   218     TInt aError )
   230     {
   219     {
   231     TRACE_FUNC_ARG( ( _L( "error: %d") , aError ) )
   220     TRACE_FUNC_ARG( ( _L( "error: %d") , aError ) )
   232     (void) aActive;
   221     (void) aActive;
       
   222     (void) aId;
   233     iNotifier.Close();
   223     iNotifier.Close();
   234     iHostResolver.Close();
   224     iHostResolver.Close();
   235     NotifyClient(aError);
   225     NotifyClient(aError);
   236     }
   226     }
   237 
   227