epoc32/include/cntfilt.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 cntfilt.h
     1 // Copyright (c) 1997-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CNTFILT_H__
       
    17 #define __CNTFILT_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
       
    22 #include <d32dbms.h>
       
    23 #endif
       
    24 
       
    25 #include <cntdb.h>
       
    26 
       
    27 class CCntFilter : public CBase
       
    28 /** A contact database filter.
       
    29 
       
    30 This is used to get a subset of the items in a contact database. 
       
    31 There are three criteria used when filtering a database:
       
    32 
       
    33 - the contact item's state
       
    34 
       
    35 - the date/time the contact item was created/last modified/deleted
       
    36 
       
    37 - the contact item's type
       
    38 
       
    39 The state can be one of: deleted, modified or created (since 
       
    40 a specified date/time). The filter can be set to include contact items of 
       
    41 only one state, or it can be set to include contact items of all states, using 
       
    42 the TInclude enumeration. 
       
    43 
       
    44 The date/time value is used in combination with the contact item's state.
       
    45 
       
    46 The contact item's type is one of contact card, contact card group, contact 
       
    47 card template, or own card. Any combination of contact types may be specified 
       
    48 in the filter, in addition to the contact item's state.
       
    49 
       
    50 After the filter has been set up, it should be passed to the function 
       
    51 CContactDatabase::FilterDatabaseL(). 
       
    52 @publishedAll
       
    53 @released
       
    54 */
       
    55 	{
       
    56 	friend class CPackagerTests; //Comparison test
       
    57 public:	
       
    58 	/** Flags to identify which contact items should be included in the filter.
       
    59 
       
    60 	Only one of the following values can be set in the filter at a time. However 
       
    61 	the client may select to filter contacts in all states using EIncludeAllContacts. */
       
    62 	enum TInclude 
       
    63 		{ 
       
    64 		/** Contact items in all states should be included. */
       
    65 		EIncludeAllContacts,
       
    66 		/** Only contact items which have been added since the date/time should be included. */
       
    67 		EIncludeNewContacts,
       
    68 		/** Only contact items which have been modified since the date/time should be included. */
       
    69 		EIncludeModifiedContacts,
       
    70 		/** Only contact items which have been deleted since the date/time should be included. */
       
    71 		EIncludeDeletedContacts	
       
    72 		};
       
    73 	/** Contact item types.*/
       
    74 	enum TContactType
       
    75 		{
       
    76 		/** All contact item types should be included. */
       
    77 		EIncludeAllTypes = 0x01,
       
    78 		/** Contact cards should be included in the filter. */
       
    79 		EContactCards = 0x02,
       
    80 		/** Contact card groups should be included in the filter. */
       
    81 		EContactGroups = 0x04, 
       
    82 		/** Contact card templates should be included in the filter. */
       
    83 		EContactTemplates = 0x08,
       
    84 		/** Own cards should be included in the filter. */
       
    85 		EContactOwnCard = 0x10 
       
    86 		};
       
    87 
       
    88 	IMPORT_C static CCntFilter* NewL();
       
    89 	IMPORT_C static CCntFilter* NewLC();
       
    90 	IMPORT_C static CCntFilter* NewL(const CCntFilter* aFilter);
       
    91 	IMPORT_C static CCntFilter* NewLC(const CCntFilter* aFilter);
       
    92 	static CCntFilter* NewLC(RReadStream& aStream);
       
    93 	IMPORT_C ~CCntFilter();
       
    94 public:
       
    95 	/** A pointer to an array which stores the filtered list of contact IDs. */
       
    96 	CContactIdArray* iIds;
       
    97 //
       
    98 	IMPORT_C void SetIncludeModifiedContacts(TBool aIncludeModified); 
       
    99 	IMPORT_C void SetIncludeNewContacts(TBool aIncludeNew); 
       
   100 	IMPORT_C void SetIncludeDeletedContacts(TBool aIncludeDeleted);
       
   101 //
       
   102 	IMPORT_C TBool TestContactFilterType(TUid aTypeUid);
       
   103 	IMPORT_C void SetContactFilterTypeALL(TBool aFilterAllContacts);
       
   104 	IMPORT_C void SetContactFilterTypeCard(TBool aFilterCards);
       
   105 	IMPORT_C void SetContactFilterTypeGroup(TBool aFilterGroups);
       
   106 	IMPORT_C void SetContactFilterTypeTemplate(TBool aFilterTemplates);
       
   107 	IMPORT_C void SetContactFilterTypeOwnCard(TBool aFilterOwnCard);
       
   108 	void ExternalizeL(RWriteStream& aStream) const;
       
   109 	void InternalizeL(RReadStream& aStream);	
       
   110 //
       
   111 	inline TBool ContactFilterTypeALL() const;
       
   112 	inline TBool ContactFilterTypeCard() const;
       
   113 	inline TBool ContactFilterTypeGroup() const;
       
   114 	inline TBool ContactFilterTypeOwnCard() const;
       
   115 	inline TBool ContactFilterTypeTemplate() const;
       
   116 //
       
   117 	inline TBool IncludeModifiedContacts();
       
   118 	inline TBool IncludeNewContacts();
       
   119 	inline TBool IncludeDeletedContacts();
       
   120 //
       
   121 	inline TTime GetFilterDateTime();
       
   122 	inline void SetFilterDateTime(TTime aTime);
       
   123 //
       
   124 	IMPORT_C void Reset();
       
   125 //
       
   126 /**	
       
   127     Intended usage: Reserved to preserve future BC  */ 
       
   128 	IMPORT_C void Reserved1();
       
   129 /**	
       
   130     Intended usage: Reserved to preserve future BC  */
       
   131   	IMPORT_C void Reserved2();
       
   132 
       
   133 private:
       
   134 	TTime            iSinceDateTime;
       
   135 	TInclude		 iInclude;
       
   136 	TInt32			 iContactType;
       
   137 	TAny*	         iReserved1;
       
   138 	TAny*			 iReserved2;
       
   139 	CCntFilter();
       
   140 	CCntFilter(const CCntFilter* aFilter);
       
   141 	};
       
   142 
       
   143 
       
   144 inline TBool CCntFilter::IncludeModifiedContacts()
       
   145 /** Tests whether the filter includes only contacts modified since the filter's 
       
   146 date/time.
       
   147 
       
   148 @return ETrue if the filter only includes modified contacts. EFalse if not. */
       
   149 	{return iInclude == EIncludeModifiedContacts;};
       
   150 
       
   151 inline TBool CCntFilter::IncludeNewContacts()
       
   152 /** Tests whether the filter includes only contacts created since the filter's 
       
   153 date/time.
       
   154 
       
   155 @return ETrue if the filter only includes new contacts. EFalse if not. */
       
   156 	{return iInclude == EIncludeNewContacts;};
       
   157 
       
   158 inline TBool CCntFilter::IncludeDeletedContacts()
       
   159 /** Tests whether the filter includes only contacts deleted since the filter's 
       
   160 date/time.
       
   161 
       
   162 @return ETrue if the filter only includes deleted contacts. EFalse if not. */
       
   163 	{return iInclude == EIncludeDeletedContacts;};
       
   164 
       
   165 inline TTime CCntFilter::GetFilterDateTime()
       
   166 /** Gets the date and time used by the filter, as set by SetFilterDateTime().
       
   167 
       
   168 @return The filter's date and time value. */
       
   169 	{return iSinceDateTime;};
       
   170 
       
   171 inline void CCntFilter::SetFilterDateTime(TTime aTime)
       
   172 /** Sets the date and time used by the filter in combination with the TInclude 
       
   173 value to test contact items against.
       
   174 
       
   175 @param aTime The new date and time value. */
       
   176 	{iSinceDateTime = aTime;};
       
   177 
       
   178 // CONTACT TYPE
       
   179 inline TBool CCntFilter::ContactFilterTypeALL() const
       
   180 /** Tests whether all contact item types are included in the filter, as set by 
       
   181 SetContactFilterTypeALL().
       
   182 
       
   183 @return ETrue if all contact item types are included in the filter, EFalse 
       
   184 if not. */
       
   185 	{return iContactType & EIncludeAllTypes;}
       
   186 
       
   187 inline TBool CCntFilter::ContactFilterTypeCard() const
       
   188 /** Tests whether contact cards are included in the filter, as set by SetContactFilterTypeCard().
       
   189 
       
   190 @return ETrue if contact cards are included in the filter, EFalse if not. */
       
   191 	{return iContactType & EContactCards;}
       
   192 
       
   193 inline TBool CCntFilter::ContactFilterTypeGroup() const
       
   194 /** Tests whether contact card groups are included in the filter, as set by SetContactFilterTypeGroup().
       
   195 
       
   196 @return ETrue if contact card groups are included in the filter, EFalse if 
       
   197 not. */
       
   198 	{return iContactType & EContactGroups;}
       
   199 
       
   200 inline TBool CCntFilter::ContactFilterTypeOwnCard() const
       
   201 /** Tests whether own cards are included in the filter, as set by SetContactFilterTypeOwnCard().
       
   202 
       
   203 @return ETrue if own cards are included in the filter, EFalse if not. */
       
   204 	{return iContactType & EContactOwnCard;}
       
   205 
       
   206 inline TBool CCntFilter::ContactFilterTypeTemplate() const
       
   207 /** Tests whether contact card templates are included in the filter, as set by 
       
   208 SetContactFilterTypeTemplate().
       
   209 
       
   210 @return ETrue if contact card templates are included in the filter, EFalse 
       
   211 if not. */
       
   212 	{return iContactType & EContactTemplates;}
       
   213 
       
   214 #endif