epoc32/include/SyncMLDataFilter.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002-2004 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: For adding content to be synchronized.
    15 *
    16 */
    17 
    18 
    19 #ifndef __SYNCMLDATAFILTER_H__
    20 #define __SYNCMLDATAFILTER_H__
    21 
    22 //-------------------------------------------------------------------------------------------------
    23 // Includes
    24 //-------------------------------------------------------------------------------------------------
    25 #include <e32base.h>
    26 #include <s32strm.h>
    27 #include <barsread.h>
    28 
    29 //-------------------------------------------------------------------------------------------------
    30 // Enumerations
    31 //-------------------------------------------------------------------------------------------------
    32 
    33 //  Filter type (inclusive/exclusive)
    34 enum TSyncMLFilterType
    35 	{
    36 	ESyncMLTypeInclusive,
    37 	ESyncMLTypeExclusive
    38 	};
    39 
    40 // Logical operator of CGI script
    41 enum TSyncMLFilterMatchType
    42 	{
    43 	ESyncMLMatchDisabled,		// Value cannot be changed
    44 	ESyncMLMatchNotSelected,	// Value is not set yet
    45 	ESyncMLMatchAND,
    46 	ESyncMLMatchOR
    47 	};
    48 
    49 // Data type of filter property
    50 enum TSyncMLFilterPropertyDataType
    51 	{
    52 	ESyncMLDataTypeNull,
    53 	ESyncMLDataTypeBool,
    54 	ESyncMLDataTypeNumber,
    55 	ESyncMLDataTypeDate,
    56 	ESyncMLDataTypeTime,
    57 	ESyncMLDataTypeText8,
    58 	ESyncMLDataTypeText16
    59 	};
    60 	
    61 // This is used when DataProvider makes some changes to dynamic filters
    62 // or removes/adds filter based on store format of remote server
    63 enum TSyncMLFilterChangeInfo
    64 	{							
    65 	ESyncMLDefault,
    66 	ESyncMLNoChanges,
    67 	ESyncMLDynamicFiltersUpdated,
    68 	ESyncMLFiltersMoreFiltersSupportedByServer,
    69 	ESyncMLFiltersLessFiltersSupportedByServer,
    70 	ESyncMLFiltersUpdated		// General if many changes
    71 	};
    72 
    73 
    74 /**
    75 * Filter Property Class.
    76 *
    77 * @lib syncmldatafilter.lib
    78 */
    79 class CSyncMLFilterProperty : public CBase
    80 	{
    81 	public:
    82 		/**
    83     	* Symbian two-phased constructor.
    84     	*/
    85 		IMPORT_C static CSyncMLFilterProperty* NewLC();
    86 		
    87 		/**
    88     	* Symbian two-phased constructor.
    89     	* @param aReader TResourceReader for recource file that includes needed information to initialize filter property.
    90     	*/
    91 		IMPORT_C static CSyncMLFilterProperty* NewLC( TResourceReader& aReader );
    92 		
    93 		/**
    94     	* Symbian two-phased constructor.
    95     	* @param aStream RReadStream for stream that includes needed information to initialize filter property.
    96     	*/
    97 		IMPORT_C static CSyncMLFilterProperty* NewLC( RReadStream& aStream );
    98 		
    99 		/**
   100 		* Destructor.
   101 		*/
   102 		IMPORT_C ~CSyncMLFilterProperty();
   103 
   104 		/**
   105 	    * Externalizes filter property.
   106 	    * @param aStream Specifies stream where filter property is externalized.
   107 	    */
   108 		IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
   109 
   110 		/**
   111 	    * Name of filter property.
   112 	    * @return TDesC Name of the filter property.
   113 	    */
   114 		IMPORT_C const TDesC& DisplayName() const;
   115 		
   116 		/**
   117 	    * Data type of default values for filter property.
   118 	    * @return TSyncMLFilterPropertyDataType Data type.
   119 	    */
   120 		IMPORT_C TSyncMLFilterPropertyDataType DefaultValueDataType() const;
   121 		
   122 		/**
   123 	    * Data type of query value for filter property.
   124 	    * @return TSyncMLFilterPropertyDataType Data type.
   125 	    */
   126 		IMPORT_C TSyncMLFilterPropertyDataType QueryValueDataType() const;
   127 		
   128 		/**
   129 	    * Maximum text length of filter property. This is useful only if data type is text16 or text8.
   130 	    * @return TUint Maximum text length of the filter property.
   131 	    */
   132 		IMPORT_C TUint MaxTextLength() const;
   133 		
   134 		/**
   135 	    * Number of default values.
   136 	    * @return TInt Number of default values of the filter property.
   137 	    */
   138 		IMPORT_C TInt DefaultValueCount() const;
   139 		
   140 		/**
   141 	    * Default value from given index for text16 property. This is useful only if data type is text16.
   142 	    * @param aIndex Specifies index where default value is returned.
   143 	    * @return TDesC16 Default value from given index.
   144 	    */
   145 		IMPORT_C const TDesC16& DefaultValueText16L( TInt aIndex ) const;
   146 		
   147 		/**
   148 	    * Default value from given index for text8 property. This is useful only if data type is text8.
   149 	    * @param aIndex Specifies index where default value is returned.
   150 	    * @return TDesC8 Default value from given index.
   151 	    */
   152 		IMPORT_C const TDesC8& DefaultValueText8L( TInt aIndex ) const;
   153 		
   154 		/**
   155 	    * Default value from given index for number property. This is useful only if data type is number.
   156 	    * @param aIndex Specifies index where default value is returned.
   157 	    * @return TInt Default value from given index.
   158 	    */
   159 		IMPORT_C TInt DefaultValueIntL( TInt aIndex ) const;
   160 		
   161 		/**
   162 	    * Default value from given index for boolean property. This is useful only if data type is boolean.
   163 	    * @param aIndex Specifies index where default value is returned.
   164 	    * @return TBool Default value from given index.
   165 	    */
   166 		IMPORT_C TBool DefaultValueBoolL( TInt aIndex ) const;
   167 		
   168 		/**
   169 	    * Default value from given index for date property. This is useful only if data type is date.
   170 	    * @param aIndex Specifies index where default value is returned.
   171 	    * @return TTime Default value from given index.
   172 	    */
   173 		IMPORT_C const TTime& DefaultValueDateL( TInt aIndex ) const;
   174 		
   175 		/**
   176 	    * Default value from given index for time property. This is useful only if data type is time.
   177 	    * @param aIndex Specifies index where default value is returned.
   178 	    * @return TTime Default value from given index.
   179 	    */
   180 		IMPORT_C const TTime& DefaultValueTimeL( TInt aIndex ) const;
   181 		
   182 		/**
   183 	    * Clears all default values and value selections.
   184 	    */
   185 		IMPORT_C void ClearDefaultValuesL();
   186 		
   187 		/**
   188 	    * Adds default value for text16 property. This is useful only if data type is text16.
   189 	    * @param aNewDefaultValue Value of added default value.
   190 	    * @param aSelected Specifies if value is selected or not.
   191 	    */
   192 		IMPORT_C void AddDefaultValueText16L( TDesC16& aNewDefaultValue, const TBool aSelected );
   193 		
   194 		/**
   195 	    * Adds default value for text8 property. This is useful only if data type is text8.
   196 	    * @param aNewDefaultValue Value of added default value.
   197 	    * @param aSelected Specifies if value is selected or not.
   198 	    */
   199 		IMPORT_C void AddDefaultValueText8L( TDesC8& aNewDefaultValue, const TBool aSelected );
   200 		
   201 		/**
   202 	    * Adds default value for number property. This is useful only if data type is number.
   203 	    * @param aNewDefaultValue Value of added default value.
   204 	    * @param aSelected Specifies if value is selected or not.
   205 	    */
   206 		IMPORT_C void AddDefaultValueIntL( const TInt aNewDefaultValue, const TBool aSelected );
   207 		
   208 		/**
   209 	    * Adds default value for boolean property. This is useful only if data type is boolean.
   210 	    * @param aNewDefaultValue Value of added default value.
   211 	    * @param aSelected Specifies if value is selected or not.
   212 	    */
   213 		IMPORT_C void AddDefaultValueBoolL( const TBool aNewDefaultValue, const TBool aSelected );
   214 		
   215 		/**
   216 	    * Adds default value for date property. This is useful only if data type is date.
   217 	    * @param aNewDefaultValue Value of added default value.
   218 	    * @param aSelected Specifies if value is selected or not.
   219 	    */
   220 		IMPORT_C void AddDefaultValueDateL( const TTime& aNewDefaultValue, const TBool aSelected );
   221 		
   222 		/**
   223 	    * Adds default value for time property. This is useful only if data type is time.
   224 	    * @param aNewDefaultValue Value of added default value.
   225 	    * @param aSelected Specifies if value is selected or not.
   226 	    */
   227 		IMPORT_C void AddDefaultValueTimeL( const TTime& aNewDefaultValue, const TBool aSelected );
   228 		
   229 		/**
   230 	    * Can use query value with default values or not.
   231 	    * @return TBool Returns ETrue if query can be used. Otherwise EFalse is returned.
   232 	    */
   233 		IMPORT_C TBool CanUseQueryValue() const;
   234 		
   235 		/**
   236 	    * Does filter property support multiple selection.
   237 	    * @return TBool Returns ETrue if multiple values can be selected. Otherwise EFalse is returned.
   238 	    */
   239 		IMPORT_C TBool SupportsMultipleSelection() const;
   240 		
   241 		/**
   242 	    * Does filter property support empty selection.
   243 	    * @return TBool Returns ETrue if none of values can be selected. Otherwise EFalse is returned.
   244 	    */
   245 		IMPORT_C TBool SupportsEmptySelection() const;
   246 		
   247 		/**
   248 	    * Returns information about which default values are selected.
   249 	    * @param aIndex Specifies index where selection information is returned.
   250 	    * @return TBool Returns ETrue if default value in given index is selected. Otherwise EFalse is returned.
   251 	    */
   252 		IMPORT_C TBool IsDefaultValueSelected( TInt aIndex ) const;
   253 		
   254 		/**
   255 	    * Returns information about query value selection. This is useful only if query value can be used.
   256 	    * @return TBool Returns ETrue if query value is selected. Otherwise EFalse is returned.
   257 	    */
   258 		IMPORT_C TBool IsQueryValueSelected() const;
   259 		
   260 		/**
   261 	    * Selects default value from given index.
   262 	    * @param aIndex Specifies index which is selected.
   263 	    */
   264 		IMPORT_C void SelectDefaultValueL( TInt aIndex );
   265 		
   266 		/**
   267 	    * Unselects default value from given index.
   268 	    * @param aIndex Specifies index which is unselected.
   269 	    */
   270 		IMPORT_C void UnselectDefaultValueL( TInt aIndex );
   271 				
   272 		/**
   273 	    * Returns query value for text16 property. This is useful only if data type is text16 and if query value can be used.
   274 	    * @return TDesC16 Query value.
   275 	    */
   276 		IMPORT_C const TDesC16& QueryValueText16L() const;
   277 		
   278 		/**
   279 	    * Returns query value for text8 property. This is useful only if data type is text8 and if query value can be used.
   280 	    * @return TDesC8 Query value.
   281 	    */
   282 		IMPORT_C const TDesC8& QueryValueText8L() const;
   283 		
   284 		/**
   285 	    * Returns query value for number property. This is useful only if data type is number and if query value can be used.
   286 	    * @return TInt Query value.
   287 	    */
   288 		IMPORT_C TInt QueryValueIntL() const;
   289 		
   290 		/**
   291 	    * Returns query value for boolean property. This is useful only if data type is boolean and if query value can be used.
   292 	    * @return TBool Query value.
   293 	    */
   294 		IMPORT_C TBool QueryValueBoolL() const;
   295 		
   296 		/**
   297 	    * Returns query value for date property. This is useful only if data type is date and if query value can be used.
   298 	    * @return TTime Query value.
   299 	    */
   300 		IMPORT_C const TTime& QueryValueDateL() const;
   301 
   302 		/**
   303 	    * Returns query value for time property. This is useful only if data type is time and if query value can be used.
   304 	    * @return TTime Query value.
   305 	    */
   306 		IMPORT_C const TTime& QueryValueTimeL() const;
   307 		
   308 		/**
   309 	    * Unselects query value. This is useful only if query value can be used.
   310 	    * This method still keeps the value
   311 	    */
   312 		IMPORT_C void UnselectQueryValueL();
   313 		
   314 		/**
   315 	    * Sets query value for text16 property. This is useful only if data type is text16 and if query value can be used.
   316 	    * This method also selects query value.
   317 	    * @param aValue Specifies new value for query value.
   318 	    */
   319 		IMPORT_C void SetQueryValueText16L( const TDesC16& aValue );
   320 		
   321 		/**
   322 	    * Sets query value for text8 property. This is useful only if data type is text8 and if query value can be used.
   323 	    * This method also selects query value.
   324 	    * @param aValue Specifies new value for query value.
   325 	    */
   326 		IMPORT_C void SetQueryValueText8L( const TDesC8& aValue );
   327 		
   328 		/**
   329 	    * Sets query value for number property. This is useful only if data type is number and if query value can be used.
   330 	    * This method also selects query value.
   331 	    * @param aValue Specifies new value for query value.
   332 	    */
   333 		IMPORT_C void SetQueryValueIntL( TInt aValue );
   334 		
   335 		/**
   336 	    * Sets query value for boolean property. This is useful only if data type is boolean and if query value can be used.
   337 	    * This method also selects query value.
   338 	    * @param aValue Specifies new value for query value.
   339 	    */
   340 		IMPORT_C void SetQueryValueBoolL( TBool aValue );
   341 		
   342 		/**
   343 	    * Sets query value for date property. This is useful only if data type is date and if query value can be used.
   344 	    * This method also selects query value.
   345 	    * @param aValue Specifies new value for query value.
   346 	    */
   347 		IMPORT_C void SetQueryValueDateL( const TTime& aValue );
   348 		
   349 		/**
   350 	    * Sets query value for time property. This is useful only if data type is time and if query value can be used.
   351 	    * This method also selects query value.
   352 	    * @param aValue Specifies new value for query value.
   353 	    */
   354 		IMPORT_C void SetQueryValueTimeL( const TTime& aValue );
   355 		
   356 		/**
   357 	    * Size of data
   358 	    * @return Size of internal data
   359 	    */
   360 		IMPORT_C TInt DataSize();
   361 			
   362 	private:
   363 		/**
   364 	    * Basic constructor.
   365 	    */
   366 		CSyncMLFilterProperty();
   367 		
   368 
   369 	private:
   370 		HBufC* 							iDisplayName;
   371 		TSyncMLFilterPropertyDataType 	iDataTypeForDefaultValues;
   372 		TSyncMLFilterPropertyDataType 	iDataTypeForQueryValue;
   373 		TUint 							iMaxTextLength;
   374 		
   375 		RPointerArray<HBufC16>		 	iDefaultValueText16List;
   376 		RPointerArray<HBufC8> 			iDefaultValueText8List;
   377 		RArray<TInt>					iDefaultValueIntOrBoolList;
   378 		RPointerArray<TTime> 			iDefaultValueDateOrTimeList;
   379 		
   380 		TBool 							iCanUseQueryValue;
   381 		TBool 							iSupportsMultpleSelection;
   382 		TBool							iSupportsEmptySelection;
   383 		
   384 		RArray<TBool>					iDefaultValueSelected;
   385 		TBool							iQueryValueSelected;
   386 		
   387 		HBufC16*						iQueryValueText16;
   388 		HBufC8*							iQueryValueText8;
   389   		TInt 							iQueryValueIntOrBool;
   390 	  	TTime 							iQueryValueDateOrTime;
   391 
   392 	};
   393 	
   394 	
   395 /**
   396 * Filter Class.
   397 *
   398 * @lib syncmldatafilter.lib
   399 */
   400 class CSyncMLFilter : public CBase
   401 	{
   402 	public:
   403 		/**
   404     	* Symbian two-phased constructor.
   405     	*/
   406 		IMPORT_C static CSyncMLFilter* NewLC();
   407 		
   408 		/**
   409     	* Symbian two-phased constructor.
   410     	* @param aReader TResourceReader for recource file that includes needed information to initialize filter.
   411     	*/
   412 		IMPORT_C static CSyncMLFilter* NewLC( TResourceReader& aReader );
   413 		
   414 		/**
   415     	* Symbian two-phased constructor.
   416     	* @param aStream RReadStream for stream that includes needed information to initialize filter.
   417     	*/
   418 		IMPORT_C static CSyncMLFilter* NewLC( RReadStream& aStream );
   419 		
   420 		/**
   421 		* Destructor.
   422 		*/		
   423 		IMPORT_C ~CSyncMLFilter();
   424 
   425 		/**
   426 	    * Externalizes filter.
   427 	    * @param aStream Specifies stream where filter is externalized.
   428 	    */
   429 		IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
   430 		
   431 		/**
   432 	    * ID of filter.
   433 	    * @return TUint ID of the filter.
   434 	    */
   435 		IMPORT_C TUint FilterId() const;
   436 		
   437 		/**
   438 	    * Name of filter.
   439 	    * @return TDesC Name of the filter.
   440 	    */
   441 		IMPORT_C const TDesC& DisplayName() const
   442 		;
   443 		/**
   444 	    * Description of filter.
   445 	    * @return TDesC Description of the filter.
   446 	    */
   447 		IMPORT_C const TDesC& DisplayDescription() const;
   448 		
   449 		/**
   450 	    * Filter enable/disable information.
   451 	    * @return TBool ETrue if filter is enabled. Otherwise EFalse is returned.
   452 	    */
   453 		IMPORT_C TBool Enabled() const;
   454 		
   455 		/**
   456 	    * Set filter enable/disable information.
   457 	    * @param aEnabled ETrue if filter enabled and EFalse is filter is disabled
   458 	    */
   459 		IMPORT_C void SetEnabledL( const TBool aEnabled );
   460 		
   461 		/**
   462 	    * Information about server capabilities to support this filter.
   463 	    * @return TBool ETrue if filter is supported by server. Otherwise EFalse is returned.
   464 	    */
   465 		IMPORT_C TBool SupportedByServer() const;
   466 		
   467 		/**
   468 	    * Set information about server capabilities to support this filter.
   469 	    * @param aSupported ETrue if filter is supported by server and EFalse if it is not supported.
   470 	    */
   471 		IMPORT_C void SetSupportedByServerL( const TBool aSupported );
   472 		
   473 		/**
   474 	    * Information about match type effect to filter.
   475 	    * @return TBool ETrue if match type affect to filter. Otherwise EFalse is returned.
   476 	    */
   477 		IMPORT_C TBool MatchTypeSupported() const;
   478 		
   479 		/**
   480 	    * Set information about match type effect to filter.
   481 	    * @param aSupported ETrue if match type affect to filter and EFalse if it does not affect.
   482 	    */
   483 		IMPORT_C void SetMatchTypeSupported( const TBool aSupported );
   484 		
   485 		/**
   486 	    * Properties of filter.
   487 	    * @return RPointerArray Properties of filter.
   488 	    */
   489 		IMPORT_C RPointerArray<CSyncMLFilterProperty>& FilterProperties();
   490 		
   491 		/**
   492 	    * Size of data
   493 	    * @return Size of internal data
   494 	    */
   495 		IMPORT_C TInt DataSize();
   496 		
   497 	private:
   498 		/**
   499 	    * Basic constructor.
   500 	    */
   501 		CSyncMLFilter();
   502 	
   503 
   504 	private:
   505 		TUint 									iFilterId;
   506   		HBufC* 									iDisplayName;
   507   		HBufC* 									iDisplayDescription;
   508   		TBool 									iEnabled;
   509   		TBool 									iSupportedByServer;
   510   		TBool 									iMatchTypeSupported;
   511   		RPointerArray<CSyncMLFilterProperty>	iProperties;
   512 	
   513 	};
   514 
   515 #endif
   516 
   517 // End of file