messagingfw/msgsrvnstore/server/inc/MSVFIND.H
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__MSVFIND_H__)
       
    17 #define __MSVFIND_H__
       
    18 
       
    19 #if !defined(__MSVAPI_H__)
       
    20 #include <msvapi.h>
       
    21 #endif
       
    22 
       
    23 #if !defined __MTCLBASE_H__
       
    24 #include <mtclbase.h>
       
    25 #endif
       
    26 
       
    27 #if !defined(__MTMDEF_H__)
       
    28 #include <mtmdef.h>
       
    29 #endif
       
    30 
       
    31 //**********************************
       
    32 // TMsvFindResult
       
    33 //**********************************
       
    34 //
       
    35 // Contains the result of a find operation for a particular entry
       
    36 //
       
    37 
       
    38 class TMsvFindResult
       
    39 /** A single result from a text search operation. The class encapsulates information 
       
    40 which:
       
    41 
       
    42 1. identifies the message in which the search text is found
       
    43 
       
    44 2. identifies the parts of the message that contain the search text. 
       
    45 @publishedAll
       
    46 @released
       
    47 */
       
    48 	{
       
    49 public:
       
    50 	IMPORT_C TMsvFindResult();
       
    51 	IMPORT_C TMsvFindResult(TMsvPartList aPartList, TMsvId aId);
       
    52 	//
       
    53 public:
       
    54 	/** The parts of the message that contain the search text. */
       
    55 	TMsvPartList iPartList;
       
    56 	/** The entry Id of the message that contains the search text. */
       
    57 	TMsvId iId;
       
    58 	};
       
    59 
       
    60 //**********************************
       
    61 // CMsvFindResultSelection
       
    62 //**********************************
       
    63 //
       
    64 // A list of find operation results with an accessor to find  
       
    65 // the position for a particular entry
       
    66 //
       
    67 
       
    68 class CMsvFindResultSelection : public CArrayFixFlat<TMsvFindResult>
       
    69 /** Collection of results from a text search operation. The collection is organized 
       
    70 as an array. 
       
    71 @publishedAll
       
    72 @released
       
    73 */
       
    74 	{
       
    75 public:
       
    76 	IMPORT_C CMsvFindResultSelection();
       
    77 	//
       
    78 public:
       
    79 	IMPORT_C CMsvFindResultSelection* CopyL()  const;
       
    80 	IMPORT_C CMsvFindResultSelection* CopyLC() const;
       
    81 	IMPORT_C TInt Find(TMsvId aId) const;
       
    82 	};
       
    83 
       
    84 //**********************************
       
    85 // TMsvFindOperationProgress
       
    86 //**********************************
       
    87 //
       
    88 // Find operation progress
       
    89 //
       
    90 
       
    91 class TMsvFindOperationProgress
       
    92 /** Encapsulates progress information for a text search operation. The class has 
       
    93 public data members. 
       
    94 @publishedAll
       
    95 @released
       
    96 */
       
    97 	{
       
    98 public:
       
    99 	IMPORT_C TMsvFindOperationProgress();
       
   100 	//
       
   101 public:
       
   102 	/** KErrNone if the search operation completed successfully otherwise one of the 
       
   103 	system-wide error codes.
       
   104 	
       
   105 	This has no meaning while the search operation is in progress. */
       
   106 	TInt iError;
       
   107 	/** The number of messages already searched. */
       
   108 	TInt iCompleted;
       
   109 	/** The number of messages remaining to be searched.
       
   110 	
       
   111 	If the search operation is for text within a specified root, folder or service, 
       
   112 	then this value is zero until the total number of messages has been determined. */
       
   113 	TInt iRemaining;
       
   114 	/** The entry Id identifying the message currently being searched */
       
   115 	TMsvId iCurrentId;
       
   116 	};
       
   117 
       
   118 class CClientMtmRegistry;
       
   119 class CMsvChildMessages;
       
   120 
       
   121 //**********************************
       
   122 // CMsvFindOperation
       
   123 //**********************************
       
   124 //
       
   125 // The find operation. Created by calling the relevant static function
       
   126 // The results for all of these are added to the CMsvFindResultSelection which
       
   127 // can be accessed via the accessor function GetFindResult
       
   128 //
       
   129 
       
   130 class CMsvFindOperation : public CMsvOperation
       
   131 /** Encapsulates a text search operation.
       
   132 
       
   133 The class offers an interface for locating messages which contain specified 
       
   134 text. Messages may contain data created for, or received from, any of the 
       
   135 transport protocols that are supported by the Messaging Architecture (e.g. 
       
   136 Email, FAX and SMS).
       
   137 
       
   138 Clients create a new instance for each search operation to be performed. They 
       
   139 are also responsible for destroying the instance once a search operation is 
       
   140 complete.
       
   141 
       
   142 Clients can derive from this class, typically to implement their own version 
       
   143 of the function IsValid(). 
       
   144 @publishedAll
       
   145 @released
       
   146 */
       
   147 	{
       
   148 public:
       
   149 	IMPORT_C static CMsvFindOperation* FindInChildrenL(CMsvSession& aSession, const TDesC& aTextToFind, TMsvId aParentId, TMsvPartList aPartList, TRequestStatus& aObserverRequestStatus);
       
   150 	IMPORT_C static CMsvFindOperation* FindInSelectionL(CMsvSession& aSession, const TDesC& aTextToFind, const CMsvEntrySelection& aSelection, TMsvPartList aPartList, TRequestStatus& aObserverRequestStatus);
       
   151 	IMPORT_C ~CMsvFindOperation();
       
   152 	//
       
   153 	IMPORT_C const TDesC8& ProgressL();
       
   154 	IMPORT_C const TDesC8& FinalProgress();
       
   155 	//
       
   156 	inline const CMsvFindResultSelection& GetFindResult() const;
       
   157 	//
       
   158 protected:
       
   159 	IMPORT_C CMsvFindOperation(CMsvSession& aSession, const TDesC& aTextToFind, TMsvPartList aPartList, TRequestStatus& aObserverRequestStatus);
       
   160 	IMPORT_C void ConstructFindInChildrenL(TMsvId aId);
       
   161 	IMPORT_C void ConstructFindInSelectionL(const CMsvEntrySelection& aSelection);
       
   162 	//
       
   163 private:
       
   164 	void ConstructL();
       
   165 	//
       
   166 	IMPORT_C void DoCancel();
       
   167 	IMPORT_C void RunL();
       
   168 	//
       
   169 	void DoRunL();
       
   170 	void FindL();
       
   171 	void Complete(TInt aStatus);
       
   172 	void StartL();
       
   173 	//
       
   174 	virtual TBool IsValid(const TMsvEntry& aEntry) const;
       
   175 	//
       
   176 private:
       
   177 	enum { EMsvFindingText, EMsvExpandingFolders } iState;
       
   178 	TBuf<KMsvMaxFindTextLength> iTextToFind;
       
   179 	TMsvPartList iPartList;
       
   180 	CMsvFindResultSelection* iFindResultSel;
       
   181 	TPckgBuf<TMsvFindOperationProgress> iProgress;
       
   182 	CMsvEntrySelection* iSelection;
       
   183 	CClientMtmRegistry* iClientRegistry;
       
   184 	CArrayPtrFlat<CBaseMtm>* iMtmArray;
       
   185 	CMsvChildMessages* iChildMessages;
       
   186 	TMsvId iCurrentId;
       
   187 	TMsvEntry iEntry;
       
   188 	};
       
   189 
       
   190 #include <msvfind.inl>
       
   191 
       
   192 #endif
       
   193