messagingfw/msgsrvnstore/server/src/msvsearchsortcacheentry.cpp
changeset 0 8e480a14352b
child 36 e7635922c074
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2008-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 #include <e32math.h>
       
    17 #include "msvsearchsortcacheentry.h"
       
    18 #include "msvsearchsortcachemanager.h"
       
    19 
       
    20 /******************************
       
    21  * CreateQueryEntryL()
       
    22  * @param const TMsvSearchSortQuery& : a Client request Query , const TBool :Mark the Query 
       
    23  * @return :CMsvSearchSortCacheEntry* : a handle to a new search sort cache entry. 
       
    24  ******************************/ 
       
    25  CMsvSearchSortCacheEntry* CMsvSearchSortCacheEntry::CreateQueryEntryL(const CMsvSearchSortQuery* aQuery, const TBool aMarkQuery,TInt aiteratorCount)
       
    26 	{
       
    27 	CMsvSearchSortCacheEntry* self = new(ELeave) CMsvSearchSortCacheEntry(aQuery,aMarkQuery,aiteratorCount);
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructQueryNodeL(aQuery);
       
    30 	CleanupStack::Pop(self);
       
    31 	return self;
       
    32 	}
       
    33  
       
    34 /********************************
       
    35  * Default Constructor :CMsvSearchSortCacheEntry()
       
    36  * @param None.
       
    37  * @return None.
       
    38  ********************************/
       
    39 /*CMsvSearchSortCacheEntry::CMsvSearchSortCacheEntry()
       
    40 	{
       
    41 	}*/
       
    42 
       
    43 /********************************
       
    44  * Default Constructor :CMsvSearchSortCacheEntry()
       
    45  * @param None.
       
    46  * @return None.
       
    47  ********************************/
       
    48 CMsvSearchSortCacheEntry::CMsvSearchSortCacheEntry(const CMsvSearchSortQuery* aQuery,const TBool aMarkQuery, TInt aiteratorCount)
       
    49 	{
       
    50 	iQueryLevel	= aQuery->iQueryCount;
       
    51 	iSubFolderOption = aQuery->iSubFolderSearch;
       
    52 	iteratorCount = aiteratorCount;
       
    53 	iSortOnHeader = EFalse;
       
    54 	iParentId = aQuery->iParentId;
       
    55 	iResultType = aQuery->iSearchSortResultType; //Setting the Result Type
       
    56 	iMarkQuery = aMarkQuery;  //Mark the Query.
       
    57 	iQueryID = 0;
       
    58 	iQueryOptions = 0;
       
    59 	iMsgQuery.Reset();
       
    60 	}
       
    61 
       
    62 /*******************************
       
    63  * Destructor : ~CMsvCacheEntry()
       
    64  * @param None.
       
    65  * @return None.
       
    66  * ******************************/
       
    67 CMsvSearchSortCacheEntry::~CMsvSearchSortCacheEntry()
       
    68 	{
       
    69 	iMsgQuery.Close();
       
    70 	}
       
    71 	
       
    72 /*******************************
       
    73  * ConstructQueryNodeL() : Create a Search Sort Cache Entry.
       
    74  * @param const TMsvSearchSortQuery& : a Client request Query , const TBool :Mark the Query 
       
    75  * @return None
       
    76  ********************************/
       
    77 void CMsvSearchSortCacheEntry::ConstructQueryNodeL(const CMsvSearchSortQuery* aQuery)
       
    78 	{
       
    79 	iMsgQuery.Reset();
       
    80 	if(!aQuery->iIsSearchQuery)
       
    81 		{
       
    82 		DoSortQuery();//Set Search or Sort Query .
       
    83 		iMsgExplicitSortPart = aQuery->iSortOnMessagePart;
       
    84 		}
       
    85 	if(aQuery->iCaseSensitive)
       
    86 		{
       
    87 		DoCaseSensetive();//Case Sensitive  bit is set.
       
    88 		}
       
    89 	if(aQuery->iWholeWord)
       
    90 		{
       
    91 		DoWholeWord();//Whole Word bit is set.
       
    92 		}
       
    93 	if(aQuery->iWildCardCharacter)
       
    94 		{
       
    95 		DoWildCharacter();//set Wild Character option.
       
    96 		}
       
    97 	if(aQuery->iIsSearchQuery)
       
    98 		{
       
    99 		//SearchQuery And Explicit Sort is required.
       
   100 		//Explicit sort leds thier will be no  default sort based on date and time.
       
   101 		if(aQuery->iExplicitSort)
       
   102 			{
       
   103 			DoExplicitSortReq(); // Set the flag for Explicit sorting .
       
   104 			iMsgExplicitSortPart = aQuery->iSortOnMessagePart;
       
   105 			}
       
   106 		else 
       
   107 			{
       
   108 			iMsgExplicitSortPart = aQuery->iSortOnMessagePart;
       
   109 			}
       
   110 		}
       
   111 	if(aQuery->iSortOrder == EMsvSortAscending)
       
   112 		{
       
   113 		DoAscendingSort();//Ascending or Descending Sort option bit is set. 
       
   114 		}
       
   115 	//Query data Appening to a RArray. 
       
   116 	for (TInt qCount = 0; qCount < aQuery->iQueryCount; qCount++)
       
   117 		{
       
   118 		iQueryData.iMessagePart = aQuery->iQueryTable[qCount].iMessagePart;
       
   119 		iQueryData.iRelationOp = aQuery->iQueryTable[qCount].iRelationOp;
       
   120 		iQueryData.iQueryString.Copy(aQuery->iQueryTable[qCount].iQueryString);
       
   121 		iMsgQuery.Append(iQueryData);	 
       
   122 		}
       
   123 	
       
   124 		CMSvSearchSortCacheManager::Instance()->GenerateQueryId(*this);
       
   125 	}
       
   126