realtimenetprots/sipfw/ClientResolver/Resolver/inc/CSIPFeatureSet.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2006-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:
       
    15 * Name          : CSIPFeatureSet.h
       
    16 * Part of       : SIP Client Resolver
       
    17 * Version       : 1.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 
       
    29 #ifndef CSIPFEATURESET_H
       
    30 #define CSIPFEATURESET_H
       
    31 
       
    32 //  INCLUDES
       
    33 #include <e32base.h>
       
    34 #include <stringpool.h>
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CSIPAcceptContactHeader;
       
    38 class CSIPFeatureTag;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 * Container for feature tags
       
    43 * @lib sipresolver.lib
       
    44 */
       
    45 class CSIPFeatureSet : public CBase
       
    46     {
       
    47     public:	// Constructors and destructor
       
    48 
       
    49 		/**
       
    50 		* Creates a new empty instance of CSIPFeatureSet
       
    51 		* @return a new instance of CSIPFeatureSet
       
    52 		*/
       
    53         static CSIPFeatureSet* NewL();
       
    54 
       
    55 		/**
       
    56 		* Creates a new empty instance of CSIPFeatureSet and 
       
    57 		* puts it to CleanupStack
       
    58 		* @return a new instance of CSIPFeatureSet
       
    59 		*/
       
    60         static CSIPFeatureSet* NewLC();
       
    61 
       
    62 		/**
       
    63 		* Creates a new instance of CSIPFeatureSet
       
    64 		* @param aAcceptContactHeader the header from which 
       
    65 		*        the feature set is extracted from.
       
    66 		* @return a new instance of CSIPFeatureSet
       
    67 		*/
       
    68         static CSIPFeatureSet* NewL(
       
    69 		    const CSIPAcceptContactHeader& aAcceptContactHeader);
       
    70 
       
    71 		/**
       
    72 		* Creates a new instance of CSIPFeatureSet and puts it to CleanupStack
       
    73 		* @param aAcceptContactHeader the header from which 
       
    74 		*        the feature set is extracted from.
       
    75 		* @return a new instance of CSIPFeatureSet
       
    76 		*/
       
    77         static CSIPFeatureSet* NewLC(
       
    78 		    const CSIPAcceptContactHeader& aAcceptContactHeader);
       
    79 
       
    80 		/**
       
    81 		* Destructor, deletes the resources of CSIPFeatureSet.
       
    82 		*/
       
    83         ~CSIPFeatureSet();
       
    84 
       
    85     public: // New functions
       
    86 
       
    87 		/**
       
    88 		* Adds new features from a Accept-Contact-header
       
    89 		* @param aAcceptContactHeader the header from which 
       
    90 		*        the feature set is extracted from.
       
    91 		*/
       
    92         void AddFeaturesL(const CSIPAcceptContactHeader& aAcceptContactHeader);
       
    93 
       
    94 		/**
       
    95 		* Checks whether "require"-tag is present.
       
    96 		* @return ETrue if present, otherwise EFalse.
       
    97 		*/
       
    98         TBool Require() const;
       
    99     
       
   100 		/**
       
   101 		* Calculates the matching score with another feature set.
       
   102 		* @param aFeatureSet the compared feature set.
       
   103 		* @return if zero the feature set does not match,
       
   104 		*         otherwise a non-negative matching score
       
   105 		*/
       
   106         TInt CalculateScore(const CSIPFeatureSet& aFeatureSet) const;
       
   107     
       
   108     private: // Constructors    
       
   109    
       
   110         CSIPFeatureSet();
       
   111 
       
   112         void ConstructL(const CSIPAcceptContactHeader& aAcceptContactHeader);
       
   113         
       
   114     private: // New functions
       
   115             
       
   116         void AddFeatureTagsL(
       
   117             RStringF aName,
       
   118             const TDesC8& aValue);
       
   119         
       
   120         void AddFeatureTagL(
       
   121             RStringF aName,
       
   122             const TDesC8& aValue);        
       
   123         
       
   124         void AddBooleanFeatureTagL(
       
   125             RStringF aName,
       
   126             TBool aNegation,
       
   127             TBool aValue);
       
   128             
       
   129         void RemoveQuotesL(
       
   130             const TDesC8& aValue,
       
   131             TPtrC8& aWithoutQuotes) const;
       
   132             
       
   133         TBool StartsAndEndsWithQuotes(const TDesC8& aValue) const;
       
   134             
       
   135         TBool IsFeatureParamName(RStringF aName) const;
       
   136                    
       
   137     private: // Data
       
   138     
       
   139         RPointerArray<CSIPFeatureTag> iFeatureTags;
       
   140         TBool iRequire;
       
   141         
       
   142     private: // For testing purposes
       
   143 #ifdef CPPUNIT_TEST    
       
   144         friend class CSIPFeatureSetTest;
       
   145 #endif
       
   146     };
       
   147 
       
   148 #endif // CSIPFEATURESET_H
       
   149 
       
   150 // End of File