phonebookengines_old/contactsmodel/tsrc/cntfindplugin/src/cntfindplugin.cpp
branchRCL_3
changeset 19 5b6f26637ad3
equal deleted inserted replaced
18:d4f567ce2e7c 19:5b6f26637ad3
       
     1 // Copyright (c) 2002-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 // A simple find implementation of the interface CFindUtilInterface
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <cntviewfindconfig.h>
       
    19 #include <ecom/implementationproxy.h>
       
    20 
       
    21 // Static DLL functions
       
    22 
       
    23 // ____________________________________________________________________________
       
    24 // 
       
    25 /**
       
    26 	@class CFindUtilBase
       
    27 	Intended usage: This class implements the functionality promised by 
       
    28 	the CFindUtilInterface defintion class. It does little apart from 
       
    29 	implementing a simple find,as a demonsration of using ECOM to load a test
       
    30 	plugin.
       
    31  */
       
    32 class CFindUtilBase : public CContactViewFindConfigInterface
       
    33 {
       
    34 // Methods
       
    35 public:
       
    36 /**
       
    37 	@fn				NewL(TAny* aInitParams)
       
    38 	Intended Usage	: Standardised safe construction which leaves nothing the cleanup stack.
       
    39 	Error Condition	: Leaves with error code.
       
    40 	@leave KErrNoMemory.
       
    41 	@since			7.0
       
    42 	@param			None
       
    43 	@return			CFindUtilBase* The class instance.
       
    44 	@pre 			None
       
    45 	@post			CFindUtilBase has been constructed,
       
    46 					and initialised.
       
    47  */
       
    48 	static CFindUtilBase* NewL();
       
    49 
       
    50 /**
       
    51 	@fn				~CFindUtilBase()
       
    52 	Intended Usage	: Default Destructor	
       
    53 	Error Condition	: None	
       
    54 	@since			7.0
       
    55 	@pre 			CFindUtilBase has been constructed
       
    56 	@post			CFindUtilBase has been completely destroyed.
       
    57  */
       
    58 	virtual ~CFindUtilBase();
       
    59 
       
    60 public:
       
    61 	//Methods that implement the pure virtual functions defined as part of the interface.
       
    62 	virtual void OpenL() ;
       
    63 	virtual void Close() ;
       
    64 	virtual TBool Match(const TDesC& aContactsField, const TDesC& aWord);	
       
    65 	virtual TBool IsWordValidForMatching(const TDesC& aWord);
       
    66 	virtual TBool MatchRefineL( const TDesC& aItemString, const TDesC &aSearchText);
       
    67 
       
    68 private:
       
    69 /**
       
    70 	@fn				CFindUtilBase()
       
    71 	Intended Usage	: Default Constructor : usable only by derived classes	
       
    72 	Error Condition	: None	
       
    73 	@since			7.0
       
    74 	@pre 			None
       
    75 	@post			CFindUtilBase has been constructed
       
    76  */
       
    77 	CFindUtilBase();
       
    78 
       
    79 };  // End of CFindUtilBase definition
       
    80 
       
    81 // __________________________________________________________________________
       
    82 // Implementation
       
    83 
       
    84 CFindUtilBase* CFindUtilBase::NewL()
       
    85 // Intended Usage	: Safe construction which leaves nothing upon the cleanup stack	
       
    86 // Error Condition	: Will leave with an appropriate error code	
       
    87 // Dependencies	: CBase
       
    88 // @param			" "
       
    89 // @return			CFindUtilBase* a pointer to the fully instantiated CFindUtilBase object
       
    90 // @pre 			None
       
    91 // @post			The object has been fully instantiated
       
    92 // Static member
       
    93 	{
       
    94 	CFindUtilBase* self=new(ELeave) CFindUtilBase();  // calls c'tor
       
    95 	return self;
       
    96 	}
       
    97 
       
    98 CFindUtilBase::~CFindUtilBase()
       
    99 // Default virtual d'tor
       
   100 	{
       
   101 	}
       
   102 
       
   103 CFindUtilBase::CFindUtilBase()
       
   104 // Default c'tor for use by derived and 
       
   105 // static construction methods only
       
   106 : CContactViewFindConfigInterface()
       
   107 	{
       
   108 	}
       
   109 
       
   110 void CFindUtilBase::OpenL()
       
   111 	{
       
   112 	}
       
   113 
       
   114 void CFindUtilBase::Close()
       
   115 	{
       
   116 	}
       
   117 
       
   118 TBool CFindUtilBase::Match(const TDesC& aContactsField, const TDesC& aWord)
       
   119 	{
       
   120 	TInt srchLen = aWord.Length();
       
   121 	if (!aContactsField.Length() || (srchLen > aContactsField.Length()))
       
   122 		{
       
   123 		return EFalse;
       
   124 		}
       
   125 	TPtrC matchStr(aContactsField.Left(srchLen));
       
   126 	return (matchStr.MatchC(aWord) != KErrNotFound);
       
   127 	}
       
   128 
       
   129 TBool CFindUtilBase::IsWordValidForMatching(const TDesC& aWord)
       
   130 	{
       
   131 		if(aWord == aWord)
       
   132 			return ETrue;
       
   133 		return EFalse;
       
   134 	}
       
   135 
       
   136 
       
   137 TBool CFindUtilBase::MatchRefineL( const TDesC& aItemString, const TDesC &aSearchText)
       
   138 	{
       
   139 	if(aItemString.MatchC(aSearchText))
       
   140 		{
       
   141 		return ETrue;
       
   142 		}
       
   143 	return EFalse;
       
   144 	}
       
   145 
       
   146 // __________________________________________________________________________
       
   147 // Exported proxy for instantiation method resolution
       
   148 // Define the interface UIDs
       
   149 const TImplementationProxy ImplementationTable[] = 
       
   150 	{
       
   151 		IMPLEMENTATION_PROXY_ENTRY(0x101F8012,	CFindUtilBase::NewL),
       
   152 	};
       
   153 
       
   154 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   155 	{
       
   156 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   157 
       
   158 	return ImplementationTable;
       
   159 	}
       
   160