natplugins/natpnatfwsdpprovider/inc/nsputil.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:  Utility class description
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef NSPUTIL_H
       
    19 #define NSPUTIL_H
       
    20 
       
    21 #include "nsppluginreturndef.h"
       
    22 #include <e32des8.h>
       
    23 #include <e32cmn.h>
       
    24 #include "nsputdefinitions.h"
       
    25 
       
    26 class CSdpDocument;
       
    27 class CSdpConnectionField;
       
    28 class CSdpOriginField;
       
    29 class CSdpMediaField;
       
    30 class CNATFWCandidate;
       
    31 class CNSPMediaStream;
       
    32 
       
    33 /**
       
    34  *  Static utility class, that contains common sdp processing methods.
       
    35  *
       
    36  *  This class has static methods that are needed by multiple states in
       
    37  *  state machine. To avoid duplicate code, static methods are preferred.
       
    38  *
       
    39  *  @lib natfwsdpprovider.dll
       
    40  *  @since S60 3.2
       
    41  */
       
    42 class NSPUtil
       
    43     {
       
    44 public: // New functions
       
    45 
       
    46     /**
       
    47      * This method is used to map a single Sdp media field to correct
       
    48      * media stream. Mapping is done by comparing Media() - return values.
       
    49      *
       
    50      * @since       S60 3.2
       
    51      * @param       aMediaField         Sdp media field object.
       
    52      * @param       aMediaStreams       Array containing media streams.
       
    53      * @return      Pointer to media stream object, ownership is not changed.
       
    54      *              NULL returned if not found.
       
    55      */
       
    56     static CNSPMediaStream* FindMediaStream( const CSdpMediaField& aMediaField,
       
    57             RPointerArray<CNSPMediaStream>& aMediaStreams );
       
    58     
       
    59     /**
       
    60      * This method is used to map a single Sdp media field to correct
       
    61      * media stream. Mapping is done by comparing Media() - return values.
       
    62      *
       
    63      * @since       S60 3.2
       
    64      * @param       aMediaStream        media stream object.
       
    65      * @param       aMediaStreams       Array containing media streams.
       
    66      * @return      Pointer to media stream object, ownership is not changed.
       
    67      *              NULL returned if not found.
       
    68      */
       
    69     static CNSPMediaStream* FindMediaStream( const CNSPMediaStream& aMediaStream,
       
    70             RPointerArray<CNSPMediaStream>& aMediaStreams );
       
    71     
       
    72     /**
       
    73      * This method is used to map a single Sdp media stream to correct
       
    74      * media field. Mapping is done by comparing Media() - return values.
       
    75      *
       
    76      * @since       S60 3.2
       
    77      * @param       aMediaStream        media stream object.
       
    78      * @param       aMediaFields        Array containing Sdp media field
       
    79      *                                  objects.
       
    80      * @return      Pointer to media field object, ownership is not changed.
       
    81      *              NULL returned if not found.
       
    82      */
       
    83     static CSdpMediaField* FindMediaField( const CNSPMediaStream& aMediaStream,
       
    84             RPointerArray<CSdpMediaField>& aMediaFields );
       
    85     
       
    86     /**
       
    87      * This method is used to map a single Sdp media field to another
       
    88      * media field. Mapping is done by comparing Media() - return values.
       
    89      *
       
    90      * @since       S60 3.2
       
    91      * @param       aMediaField         Sdp media field object.
       
    92      * @param       aMediaFields        Array containing Sdp media field
       
    93      *                                  objects.
       
    94      * @return      Pointer to media field object, ownership is not changed.
       
    95      *              NULL returned if not found.
       
    96      */
       
    97     static CSdpMediaField* FindMediaField( const CSdpMediaField& aMediaField,
       
    98             RPointerArray<CSdpMediaField>& aMediaFields );
       
    99     
       
   100     /**
       
   101      * This method is used to update transport address to connection field.
       
   102      * 
       
   103      * @since       S60 3.2
       
   104      * @param       aField              Sdp connection field object.
       
   105      * @param       aAddress            address as string.
       
   106      */
       
   107     static void UpdateConnectionFieldL( CSdpConnectionField& aField,
       
   108             const TDesC8& aAddress );
       
   109     
       
   110     /**
       
   111      * This method is used to update transport address to origin field.
       
   112      * 
       
   113      * @since       S60 3.2
       
   114      * @param       aField              Sdp origin field object.
       
   115      * @param       aAddress            address as string.
       
   116      */
       
   117     static void UpdateOriginFieldL( CSdpOriginField& aField,
       
   118             const TDesC8& aAddress );
       
   119     
       
   120     /**
       
   121      * This method is used to insert media field rejection info to media field.
       
   122      *
       
   123      * @since       S60 3.2
       
   124      * @param       aField              Sdp media field object.
       
   125      */
       
   126     static void RejectL( CSdpMediaField& aField );
       
   127     
       
   128     /**
       
   129      * This method is used to check if the given media field is rejected,
       
   130      * i.e. reject port.
       
   131      * 
       
   132      * @since       S60 3.2
       
   133      * @param       aField              Sdp media field object.
       
   134      * @return      ETrue if media field is rejected, EFalse otherwise.
       
   135      */
       
   136     static TBool IsReject( const CSdpMediaField& aField );
       
   137     
       
   138     /**
       
   139      * This method is used to check if given candidate object is duplicate for some
       
   140      * other object in the given array.
       
   141      *
       
   142      * @since       S60 3.2
       
   143      * @param       aCand               Candidate object
       
   144      * @param       aCandidates         Candidates array.
       
   145      * @return      ETrue if candidate is a duplicate, EFalse otherwise.
       
   146      */
       
   147     static TBool IsDuplicate( const CNATFWCandidate& aCand,
       
   148             const RPointerArray<CNATFWCandidate>& aCandidates );
       
   149     
       
   150     /**
       
   151      * This method is used to check if given address is 'Unspeficied', i.e.
       
   152      * either 0.0.0.0(IPv4) or ::(IPv6).
       
   153      * Leave will occur if heap runs out.
       
   154      * 
       
   155      * @since		S60 3.2
       
   156      * @param		aAddress			Address as descriptor.
       
   157      * @param		aPort				Port as TUint.
       
   158      * @return		ETrue if given address is unspecified, EFalse otherwise.
       
   159      */
       
   160     static TBool IsUnspecifiedL( const TDesC8& aAddress, TUint aPort );
       
   161     
       
   162     /**
       
   163      * This method is used to sort objects as priority order.
       
   164      *
       
   165      * @since       S60 3.2
       
   166      * @param       aLocalCandidates    Array containing NAT FW candidate objects.
       
   167      */
       
   168     static void SortCandidatesL( RPointerArray<CNATFWCandidate>& aLocalCandidates );
       
   169     
       
   170     /**
       
   171      * This method is used jointly with TCleanupItem - class to clear objects from 
       
   172      * RPointerArray if leave occurs.
       
   173      *
       
   174      * @since       S60 3.2
       
   175      * @param       anArray             Array containing objects.
       
   176      */
       
   177     static void CleanupArrayItem( TAny* anArray );
       
   178 
       
   179 
       
   180 private: // data
       
   181         
       
   182     NSP_UT_DEFINITIONS
       
   183     
       
   184     };
       
   185 
       
   186 #endif // NSPUTILITY_H
       
   187 
       
   188 // end of file