mmsharing/mmshavailability/inc/musavacapabilitybase.h
changeset 22 496ad160a278
parent 0 f0cf47e981f9
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Capability
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMUSAVACAPABILITYBASE_H
       
    20 #define CMUSAVACAPABILITYBASE_H
       
    21 
       
    22 
       
    23 #include <e32base.h>    // CBase
       
    24 #include <sdpcodecstringconstants.h>
       
    25 #include <sdpcodecstringpool.h>
       
    26 #include "musunittesting.h"
       
    27 
       
    28 
       
    29 class CMusAvaCapabilityExchange;
       
    30 class CSIPServerTransaction;
       
    31 class CSIPHeaderBase;
       
    32 class CSdpDocument;
       
    33 class CSIPAcceptContactHeader;
       
    34 class CSdpFmtAttributeField;
       
    35 class CSdpAttributeField;
       
    36 class CSdpOriginField;
       
    37 class CSdpMediaField;
       
    38 class RStringF;
       
    39 
       
    40 #define CAPABILITY_CONTAINS( tagSet, tag ) tagSet.Find( tag ) >= KErrNone
       
    41 
       
    42 /**
       
    43  * Capability
       
    44  *
       
    45  * @lib musavailabilityplugin.dll
       
    46  */
       
    47 class CMusAvaCapabilityBase : public CBase
       
    48     {
       
    49 
       
    50 public: // constructors and destructor
       
    51 
       
    52     virtual ~CMusAvaCapabilityBase();
       
    53 
       
    54 
       
    55 protected: // constructors
       
    56 
       
    57     CMusAvaCapabilityBase( CMusAvaCapabilityExchange& aExchange );
       
    58 
       
    59     void ConstructL( const TDesC8& aFeature );
       
    60 
       
    61 public: // new functions
       
    62 
       
    63     /**
       
    64     * Returns exchance
       
    65     *
       
    66     * @return exchance
       
    67     */
       
    68     CMusAvaCapabilityExchange& Exchange() const;
       
    69 
       
    70     /**
       
    71     * Returns feature this capability represents
       
    72     *
       
    73     * @return feature this capability represents
       
    74     */
       
    75     const RStringF& Feature() const;
       
    76 
       
    77     /**
       
    78     * Checks if capability supports feature, found
       
    79     * in Accept-Contact header
       
    80     *
       
    81     * @param acceptContact accept contact
       
    82     * @return ETrue, if there is a match
       
    83     */
       
    84     virtual TBool Supports( const CSIPAcceptContactHeader& acceptContact );
       
    85 
       
    86     /**
       
    87     * Uses for conrolling capability 
       
    88     *
       
    89     * @return ETrue, if capability is enabled
       
    90     */
       
    91     TBool& Enabled();
       
    92 
       
    93     /**
       
    94     * Populates response to query
       
    95     *
       
    96     * @param aQuery query as SIP server transaction
       
    97     * @param aResponseHeaders SIP headers container for response
       
    98     * @param aResponseContent SDP document container for response
       
    99     */
       
   100     virtual void PopulateResponseL( 
       
   101             CSIPServerTransaction& aQuery,
       
   102             RPointerArray<CSIPHeaderBase>& aResponseHeaders,
       
   103             CSdpDocument& aResponseContent );
       
   104             
       
   105 
       
   106 protected: //abstract methods
       
   107 
       
   108     /**
       
   109     * Populates response to query
       
   110     *
       
   111     * @param aQuery query as SIP server transaction
       
   112     * @param aResponseHeaders SIP headers container for response
       
   113     * @param aResponseContent SDP document container for response
       
   114     */
       
   115     virtual void DoPopulateResponseL( 
       
   116             CSIPServerTransaction& aQuery,
       
   117             RPointerArray<CSIPHeaderBase>& aResponseHeaders,
       
   118             CSdpDocument& aResponseContent ) = 0;
       
   119 
       
   120 
       
   121 
       
   122 public: //static API
       
   123 
       
   124                        
       
   125     /**
       
   126      * Creates SDP document
       
   127      *
       
   128      * @param aQuery received query
       
   129      * @return SDP document
       
   130      */
       
   131     static CSdpDocument* ResponseContentLC( 
       
   132                                      const CSIPServerTransaction& aQuery );
       
   133 
       
   134     /**
       
   135      * Finds codec from SDP document
       
   136      *
       
   137      * @param aMedia name of the media
       
   138      * @param aCodec name of codec
       
   139      * @param aSDP SDP document
       
   140      * @return the media line
       
   141      */
       
   142     static const CSdpFmtAttributeField* CodecL( const RStringF& aMedia,
       
   143                                         const TDesC8& aCodec,
       
   144                                         CSdpDocument& aSDP );
       
   145 
       
   146     /**
       
   147      * Finds attribute field from SDP document
       
   148      *
       
   149      * @param aAttribute atrbute name
       
   150      * @param aSDP SDP document
       
   151      * @return the attribute
       
   152      */
       
   153     static const CSdpAttributeField* Attribute( const RStringF& aAttribute,
       
   154                                                    CSdpDocument& aSDP );
       
   155 
       
   156 protected://new functions
       
   157 
       
   158     /**
       
   159     * Adds contact header to response of query
       
   160     *
       
   161     * @param aQuery query as SIP server transaction
       
   162     * @param aResponseHeaders SIP headers container for response
       
   163     */
       
   164     virtual void AddContactHeaderL(
       
   165             CSIPServerTransaction& aQuery,
       
   166             RPointerArray<CSIPHeaderBase>& aResponseHeaders );
       
   167             
       
   168     /**
       
   169      * Creates origin field for sdp
       
   170      *
       
   171      * @param aNetType net type
       
   172      * @param aLocalHost local host
       
   173      * @param aHostType host type
       
   174      * @return origin field 
       
   175      */
       
   176     static CSdpOriginField* OriginFieldL( const RStringF& aNetType,
       
   177                                           const TDesC8& aLocalHost,
       
   178                                           const RStringF& aHostType );
       
   179                                           
       
   180     /**
       
   181      * Creates media line 
       
   182      *
       
   183      * @param aMedia name of the media
       
   184      * @param aFormatList format list
       
   185      * @return media line
       
   186      */
       
   187     CSdpMediaField* MediaLineLC( const RStringF& aMedia, 
       
   188                                  const TDesC8& aFormatList ) const;
       
   189     
       
   190     
       
   191     /**
       
   192      * Creates rtpmap line
       
   193      *
       
   194      * @param aCodec name of coded
       
   195      * @param aPayloadType payload type
       
   196      * @param aClockRate clockrate
       
   197      * @param aParams optional params
       
   198      * @return rtpmap line
       
   199      */
       
   200     CSdpFmtAttributeField* RtpMapLineLC( const TDesC8& aCodec,
       
   201                                  const TUint aPayloadType,
       
   202                                  const TUint aClockRate,
       
   203                                  const TDesC8& aParams = KNullDesC8 ) const;
       
   204     
       
   205                                    
       
   206 private:
       
   207 
       
   208     CMusAvaCapabilityExchange& iExchange;
       
   209     RStringF iFeature;
       
   210     TBool iIsEnabled;
       
   211 
       
   212     //for unit testing
       
   213     //MUS_UNITTEST ( UT_ )
       
   214 
       
   215     };
       
   216 
       
   217 #endif // CMUSAVACAPABILITYBASE_H