emailservices/emailclientapi/inc/emailmessagesearch.h
changeset 54 997a02608b3a
child 62 a8c646b56683
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Definition of Email message search API.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef EMAILMESSAGESEARCHASYNCIMPL_H_
       
    19 #define EMAILMESSAGESEARCHASYNCIMPL_H_
       
    20 
       
    21 #include <memailmessage.h>
       
    22 #include <memailmessagesearch.h>
       
    23 #include <emailsorting.h>
       
    24 
       
    25 #include "cfsmailclient.h"
       
    26 #include "mfsmailboxsearchobserver.h"
       
    27 #include "emailapiutils.h"
       
    28 
       
    29 using namespace EmailInterface;
       
    30 
       
    31 
       
    32 NONSHARABLE_CLASS( CEmailMessageSearchAsync) : 
       
    33     public CBase, 
       
    34     public MEmailMessageSearchAsync, 
       
    35     public MFSMailBoxSearchObserver
       
    36 
       
    37 {
       
    38 public:
       
    39     /**
       
    40     * Constructor
       
    41     * @return
       
    42     */
       
    43     static CEmailMessageSearchAsync* NewL(
       
    44         CPluginData& aPluginData,
       
    45         const TMailboxId& aMailboxId );
       
    46     
       
    47     /**
       
    48      * Destructor
       
    49      */
       
    50     ~CEmailMessageSearchAsync();
       
    51     
       
    52 public: // from MEmailInterface
       
    53     TEmailTypeId InterfaceId() const;
       
    54     
       
    55     void Release();
       
    56     
       
    57 
       
    58 public: // from MEmailMessageSearchAsync
       
    59     /**
       
    60     * Sets sort order for search results.
       
    61     * Leaves KErrNotReady if search is ongoing.
       
    62     */
       
    63     void SetSortCriteriaL( const TEmailSortCriteria& aCriteria );
       
    64     
       
    65     /**
       
    66     * Adds a search key. Leaves KErrNotReady if search is ongoing.
       
    67     */
       
    68     void AddSearchKeyL( const TDesC& aSearchKey );
       
    69                                                                   
       
    70     /**
       
    71     * Enables/disables search from remote email server.
       
    72     * Leaves KErrNotReady if search is ongoing.
       
    73     */
       
    74     void SetRemoteSearchL( TBool aRemote );                                                               
       
    75     
       
    76     /**
       
    77     * Indicates whether remote search is enabled.
       
    78     */
       
    79     TBool IsRemoteSearch() const;
       
    80     
       
    81     /**
       
    82      * Starts search, all methods affecting search attribures leave
       
    83      * KErrNotReady while search is ongoing.
       
    84      * @param aObserver called when results are available.
       
    85      */     
       
    86     void StartSearchL( MEmailSearchObserver& aObserver );
       
    87 
       
    88     /**
       
    89      * Cancels search.
       
    90      */
       
    91     void Cancel();
       
    92                                              
       
    93     /** returns search status 
       
    94       * @return search status:
       
    95       *     < 0 : Search has failed
       
    96       *     KRequestPending : search is ongoing. note that status may be
       
    97       *         KRequestPending after HandleResultL callback because results 
       
    98       *         may be given in chunks of results. Size of chunk depends on
       
    99       *         implementation and may vary.
       
   100       *     KErrNone : initial state, or search has finished
       
   101       */
       
   102     TInt Status() const;
       
   103     
       
   104     /**
       
   105      * Resets all search attribures. Cancels search if ongoing. 
       
   106      */
       
   107     void Reset();
       
   108     
       
   109 public:  // From MFSMailBoxSearchObserver
       
   110     /** 
       
   111      * Notifies the email search API client that a match has been found
       
   112      * 
       
   113      * @param aMatchMessage contains a pointer to the matched message.
       
   114      *         Ownership is transfered to the observer.
       
   115      *
       
   116      */
       
   117      void MatchFoundL( CFSMailMessage* aMatchMessage );
       
   118 
       
   119     /**
       
   120      * Notifies the email search API client that the search has completed
       
   121      *
       
   122      */
       
   123      void SearchCompletedL();
       
   124 
       
   125 //
       
   126     /**
       
   127     * Asks client if search engine should change search priority 
       
   128   	*/
       
   129     void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority); 
       
   130 //
       
   131 
       
   132     
       
   133 private:
       
   134     /**
       
   135      * Constructor
       
   136      */
       
   137     CEmailMessageSearchAsync(
       
   138         CPluginData& aPluginData,
       
   139         const TMailboxId& aMailboxId );
       
   140 
       
   141     void ConstructL();
       
   142     
       
   143     /**
       
   144      * Function leaves if search is going on. Otherwise it doesn't do anything.
       
   145      */
       
   146     inline void IsSearchGoingOnL() const; 
       
   147 
       
   148 private:
       
   149     
       
   150     CPluginData&    iPluginData;
       
   151     
       
   152     CFSMailPlugin*  iPlugin;
       
   153 
       
   154     TMailboxId      iMailboxId;
       
   155     
       
   156     TFSMailSortCriteria iCriteria;
       
   157         
       
   158     RPointerArray<TDesC> iSearchStrings;    
       
   159 
       
   160     MEmailSearchObserver* iObserver;
       
   161     
       
   162     mutable RSemaphore iGate;
       
   163 
       
   164     TBool iRemote;
       
   165 };
       
   166 
       
   167 #endif // EMAILMESSAGESEARCHASYNCIMPL_H_
       
   168 
       
   169 // End of file
       
   170