metadataengine/server/inc/mdsnotifycomparator.h
changeset 0 c53acadfccc6
child 15 3cebc1a84278
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  Comparator algorithms for notifier*
       
    15 */
       
    16 
       
    17 #ifndef __MDSNOTIFYCOMPARATOR_H__
       
    18 #define __MDSNOTIFYCOMPARATOR_H__
       
    19 
       
    20 #include <e32base.h>
       
    21 
       
    22 #include "mdccommon.h"
       
    23 
       
    24 class CMdCSerializationBuffer;
       
    25 class TMdCRelation;
       
    26 class TMdCRelationCondition;
       
    27 
       
    28 /**
       
    29 * A collection of algorithms for comparing events against
       
    30 * criteria profile of notifier. The event either does not
       
    31 * or does match the profile set by the given criteria.
       
    32 */
       
    33 class CMdSNotifyComparator : public CBase
       
    34     {
       
    35     public: // public construction
       
    36 
       
    37         /** static construction */
       
    38         static CMdSNotifyComparator* NewL();
       
    39         static CMdSNotifyComparator* NewLC();
       
    40 
       
    41         /** destructor */
       
    42         virtual ~CMdSNotifyComparator();
       
    43 
       
    44     private: // private construction
       
    45 
       
    46         /** constructor */        
       
    47         CMdSNotifyComparator();
       
    48 
       
    49         /** 2nd phase constructor */
       
    50         void ConstructL();
       
    51 
       
    52     public: // methods
       
    53 
       
    54         /**
       
    55         * Matches items against the given condition
       
    56         * 
       
    57         * @param aType listener's type
       
    58         * @param aSerializedCondition serialized condition to be matched 
       
    59         *                             against
       
    60         * @param aSerializedItems the items to compare
       
    61         * @param aSerializedItemIds the item IDs (successful and failed IDs)
       
    62         * @param aMatchingItemIdArray matching object IDs
       
    63         * 
       
    64         * @return If true at least some item matches.
       
    65         */
       
    66         TBool MatchL(TDefId aNamespaceId, TUint32 aType,
       
    67         		CMdCSerializationBuffer& aSerializedCondition,
       
    68         		CMdCSerializationBuffer& aSerializedItems,
       
    69 		    	CMdCSerializationBuffer& aSerializedItemIds,
       
    70 		    	RArray<TItemId>& aMatchingItemIdArray, 
       
    71 		    	TBool aAllowConfidential);
       
    72 
       
    73 		/**
       
    74         * Matches object against the given condition. This variant matches only
       
    75         * object conditions.
       
    76         * 
       
    77         * @param aSerializedCondition serialized condition to be matched 
       
    78         *                             against
       
    79         * @param aSerializedItem the object to compare (buffer's position is 
       
    80         *                        in the begin of object)
       
    81         * @param aObjectId object ID
       
    82         * @param aAllowConfidential allow confidential objects
       
    83         * 
       
    84         * @return Does object match with condition.
       
    85 		*/
       
    86 		TBool MatchObjectL(CMdCSerializationBuffer& aSerializedCondition,
       
    87 		    	CMdCSerializationBuffer& aSerializedItem,
       
    88 		    	TItemId aObjectId, TBool aAllowConfidential);
       
    89 
       
    90 		/**
       
    91         * Matches event against the given condition. This variant matches only
       
    92         * event conditions.
       
    93         * 
       
    94         * @param aSerializedCondition serialized condition to be matched 
       
    95         *                             against
       
    96         * @param aSerializedItem the event to compare (buffer's position is in 
       
    97         *                        the begin of event)
       
    98         * @param aEventId event ID
       
    99         * 
       
   100         * @return Does event match with condition.
       
   101 		*/
       
   102 		TBool MatchEventL(CMdCSerializationBuffer& aSerializedCondition,
       
   103 		    	CMdCSerializationBuffer& aSerializedItem, TItemId aEventId);
       
   104 
       
   105 		/**
       
   106         * Matches relation against the given condition. This variant matches 
       
   107         * only relation conditions.
       
   108         * 
       
   109         * @param aSerializedCondition serialized condition to be matched 
       
   110         *                             against
       
   111         * @param aSerializedItem the relation to compare (buffer's position is 
       
   112         *                        in the begin of relation)
       
   113         * @param aRelationId relation ID
       
   114         * 
       
   115         * @return Does relation match with condition.
       
   116 		*/
       
   117 		TBool MatchRelationL(CMdCSerializationBuffer& aSerializedCondition,
       
   118 		    	CMdCSerializationBuffer& aSerializedItem, TItemId aRelationId);
       
   119 
       
   120         /**
       
   121         * Matches object IDs against the given condition. This variant matches 
       
   122         * only object ID conditions.
       
   123         * 
       
   124         * @param aSerializedCondition serialized condition to be matched 
       
   125         *                             against
       
   126         * @param aItemIdArray the object IDs to compare
       
   127         * @param aMatchingItemIdArray matching object IDs
       
   128         * 
       
   129         * @return If true all objects matches and result is same as 
       
   130         *         aItemIdArray, so aMatchingItemIdArray might not contain any 
       
   131         *         IDs in that case.
       
   132         */
       
   133 		TBool MatchObjectIdsL(CMdCSerializationBuffer& aSerializedCondition,
       
   134 		    	const RArray<TItemId>& aItemIdArray,
       
   135 		    	RArray<TItemId>& aMatchingItemIdArray);
       
   136 
       
   137 		/**
       
   138 	     * Matches relation items against the given condition.
       
   139 	     * This variant matches only relation conditions.
       
   140 	     * 
       
   141 	     * @param aSerializedCondition serialized condition to be matched 
       
   142 	     *                             against
       
   143 	     * @param aSerializedItems the relation to compare (buffer's position 
       
   144 	     *                         is in the begin of relation)
       
   145 	     * @param aMatchingItemIdArray relation ID array
       
   146 	     * 
       
   147 	     * @return Does relation match with condition.
       
   148 		 */
       
   149 		TBool MatchRelationItemsL(CMdCSerializationBuffer& aSerializedCondition,
       
   150 				CMdCSerializationBuffer& aSerializedItems,
       
   151 			    RArray<TItemId>& aMatchingItemIdArray);
       
   152 
       
   153 		/**
       
   154 	     * Matches relation items against the given condition.
       
   155 	     * This variant matches only relation conditions.
       
   156 	     * 
       
   157 	     * @param aSerializedCondition serialized condition to be matched 
       
   158 	     *                             against
       
   159 	     * @param aRelation relation
       
   160 	     * 
       
   161 	     * @return Does relation match with condition.
       
   162 		 */
       
   163 		TBool MatchRelationItemL(CMdCSerializationBuffer& aSerializedCondition,
       
   164 				const TMdCRelation& aRelation);
       
   165 
       
   166     private:
       
   167         /**
       
   168         * Compare string begins against the given string
       
   169         * @param aDes contains reference to the string  
       
   170         * @param aCompareDes reference to the compared string
       
   171         * @return compare result
       
   172         */
       
   173 	    TBool CompareDesBeginsWith( TDesC16& aDes, TDesC16& aCompareDes );
       
   174 
       
   175         /**
       
   176         * Compare string ends with the given string
       
   177         * @param aDes contains reference to the string  
       
   178         * @param aCompareDes reference to the compared string
       
   179         * @return compare result
       
   180         */
       
   181         TBool CompareDesEndsWith( TDesC16& aDes, TDesC16& aCompareDes );
       
   182 
       
   183         /**
       
   184         * Finds string with the given string
       
   185         * @param aDes contains reference to the string  
       
   186         * @param aCompareDes reference to the searched string
       
   187         * @return compare result
       
   188         */
       
   189  		TBool FindDes( TDesC16& aDes, TDesC16& aFindDes );
       
   190 
       
   191 		/**
       
   192          * Matches object ID against the given logic condition which contains 
       
   193          * object ID conditions. Caller must set condition buffer to begin of 
       
   194          * the logic condition.
       
   195          * 
       
   196          * @param aSerializedCondition serialized logic condition to be 
       
   197          *                             matched against
       
   198          * @param aObjectId object ID
       
   199          * 
       
   200          * @return Does relation match with condition.
       
   201 		 */
       
   202 		TBool MatchObjectIdToObjectIdConditionsL(
       
   203 				CMdCSerializationBuffer& aSerializedCondition, 
       
   204 				TItemId aObjectId);
       
   205 
       
   206 		/**
       
   207          * Matches object ID against the given logic condition which contains 
       
   208          * object ID conditions. Caller must set condition buffer to begin of 
       
   209          * the logic condition.
       
   210          * 
       
   211          * @param aSerializedCondition serialized logic condition to be 
       
   212          *                             matched against
       
   213          * @param aSerializedItem serializad object
       
   214          * @param aAllowConfidential is confidential objects allowed
       
   215          * 
       
   216          * @return Does object match with condition.
       
   217 		 */
       
   218         TBool CheckObjectL( CMdCSerializationBuffer& aSerializedCondition, 
       
   219         		CMdCSerializationBuffer& aSerializedItem,
       
   220         		TBool aAllowConfidential );
       
   221 		/**
       
   222          * Matches object's property against the given logic condition which 
       
   223          * contains object ID conditions.
       
   224          * 
       
   225          * @param aSerializedCondition serialized logic condition to be 
       
   226          *                             matched against
       
   227          * @param aSerializedItem serializad object
       
   228          * 
       
   229          * @return Does object's propertys match with condition.
       
   230 		 */
       
   231         TBool CheckPropertyL( CMdCSerializationBuffer& aSerializedCondition,
       
   232     			CMdCSerializationBuffer& aSerializedItem );
       
   233 
       
   234         /**
       
   235          * Matches relation IDs in given condition against given one.
       
   236          * 
       
   237          * @param aRelationCondition relation condition
       
   238          * @param aSerializedCondition serialized ids to be matched against
       
   239          * @param aRelationId the relation IDs to compare
       
   240          * 
       
   241          * @return ETrue if relation match
       
   242          */
       
   243         TBool MatchRelationIdsL(
       
   244         		const TMdCRelationCondition& aRelationCondition, 
       
   245         		CMdCSerializationBuffer& aSerializedCondition,
       
   246         		TItemId aRelationId);
       
   247 
       
   248         inline TBool BoolEqual( TBool aLeft, TBool aRight )
       
   249         	{
       
   250         	return (aLeft && aRight || !aLeft && !aRight);
       
   251         	}
       
   252     };
       
   253 
       
   254 #endif	// __MDSNOTIFYCOMPARATOR_H__