emailservices/emailclientapi/src/emailmessagesearch.cpp
changeset 74 6c59112cfd31
parent 66 084b5b1f02a7
equal deleted inserted replaced
69:4e54af54a4a1 74:6c59112cfd31
    89 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    90 void CEmailMessageSearchAsync::Release()
    90 void CEmailMessageSearchAsync::Release()
    91     {
    91     {
    92     if (KErrNone != iGate.Wait(1))
    92     if (KErrNone != iGate.Wait(1))
    93         {
    93         {
    94         this->Cancel();
    94         this->CancelSearch();
    95         }
    95         }
    96     delete this;
    96     delete this;
    97     }
    97     }
    98 
    98 
    99 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   254 // Cancels search.
   254 // Cancels search.
   255 // -----------------------------------------------------------------------------
   255 // -----------------------------------------------------------------------------
   256 void CEmailMessageSearchAsync::Cancel()
   256 void CEmailMessageSearchAsync::Cancel()
   257     {
   257     {
   258     if (KErrNone != iGate.Wait(1))
   258     if (KErrNone != iGate.Wait(1))
   259         {
   259         {        
   260         
   260         CancelSearch();
   261         /**
   261         }
   262          * Cancels current search. Does nothing if there is not any search.
   262     
   263          * The search client will not be called back after this function is called.
   263     // Release gate
   264          *
   264     iGate.Signal();    
   265          */
       
   266         const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
       
   267         iPlugin->CancelSearch( fsMailboxId );
       
   268         }
       
   269     else
       
   270         {
       
   271         // Release gate
       
   272         iGate.Signal();
       
   273         }
       
   274     }
   265     }
   275 
   266 
   276 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   277 //  * @return search status:
   268 //  * @return search status:
   278 //  *     < 0 : Search has failed
   269 //  *     < 0 : Search has failed
   293     else
   284     else
   294         {
   285         {
   295         // Release gate
   286         // Release gate
   296         iGate.Signal();       
   287         iGate.Signal();       
   297         }
   288         }
   298 
   289     //if we really locked iGate here, we release it in else 
       
   290     //brach. If it was already locked, we must not release it here!
       
   291     // coverity[missing_unlock]
   299     return ret; 
   292     return ret; 
   300     }
   293     }
   301 
   294 
   302 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   303 // Resets all search attribures. Cancels search if ongoing. 
   296 // Resets all search attribures. Cancels search if ongoing. 
   304 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   305 void CEmailMessageSearchAsync::Reset()
   298 void CEmailMessageSearchAsync::Reset()
   306     {
   299     {
   307     if ( KErrNone != iGate.Wait( 1 ) )
   300     if ( KErrNone != iGate.Wait( 1 ) )
   308         {
   301         {
   309         this->Cancel();
   302         this->CancelSearch();
   310         }
   303         }
   311     
   304     
   312     iCriteria = TFSMailSortCriteria();
   305     iCriteria = TFSMailSortCriteria();
   313     iSearchStrings.Reset();
   306     iSearchStrings.Reset();
   314     
   307     
   358         // Leave now, search is going on
   351         // Leave now, search is going on
   359         User::Leave( KErrNotReady );
   352         User::Leave( KErrNotReady );
   360         }
   353         }
   361     }
   354     }
   362 
   355 
       
   356 // -----------------------------------------------------------------------------
       
   357 // Cancels search
       
   358 // -----------------------------------------------------------------------------
       
   359 void CEmailMessageSearchAsync::CancelSearch()
       
   360     {
       
   361     /**
       
   362      * Cancels current search. Does nothing if there is not any search.
       
   363      * The search client will not be called back after this function is called.
       
   364      *
       
   365      */
       
   366     const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
       
   367     iPlugin->CancelSearch( fsMailboxId );
       
   368     }
   363 // End of file
   369 // End of file