sipvoipprovider/svphold/src/svpholdattributehandler.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Handles SDP direction attribute related issues.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <badesca.h>
       
    20 #include    "svpholdattributehandler.h"
       
    21 #include    "svpholdcontext.h"
       
    22 #include    "svplogger.h"
       
    23 
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CSVPHoldAttributeHandler::CSVPHoldAttributeHandler
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CSVPHoldAttributeHandler::CSVPHoldAttributeHandler() :
       
    30     iAttributeArray( NULL )
       
    31     {
       
    32     
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CSVPHoldAttributeHandler::ConstructL
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CSVPHoldAttributeHandler::ConstructL()
       
    40     {
       
    41     // Create attribute array
       
    42     iAttributeArray =
       
    43         new ( ELeave ) CDesC8ArrayFlat( KSVPHoldDirectionAttributeCount );
       
    44         
       
    45     iAttributeArray->InsertL( KSVPHoldSendrecvIndex,
       
    46                               KSVPHoldAttributeSendrecv );
       
    47     iAttributeArray->InsertL( KSVPHoldSendonlyIndex,
       
    48                               KSVPHoldAttributeSendonly );
       
    49     iAttributeArray->InsertL( KSVPHoldRecvonlyIndex,
       
    50                               KSVPHoldAttributeRecvonly );
       
    51     iAttributeArray->InsertL( KSVPHoldInactiveIndex,
       
    52                               KSVPHoldAttributeInactive );
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CSVPHoldAttributeHandler::NewL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CSVPHoldAttributeHandler* CSVPHoldAttributeHandler::NewL()
       
    60     {
       
    61     CSVPHoldAttributeHandler* self = new ( ELeave ) CSVPHoldAttributeHandler;
       
    62     CleanupStack::PushL( self );
       
    63     
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66 
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CSVPHoldAttributeHandler::~CSVPHoldAttributeHandler
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 CSVPHoldAttributeHandler::~CSVPHoldAttributeHandler()
       
    75     {
       
    76     if ( iAttributeArray )
       
    77         {
       
    78         iAttributeArray->Reset();
       
    79         }
       
    80         
       
    81     delete iAttributeArray;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CSVPHoldAttributeHandler::FindDirectionAttribute
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 TInt CSVPHoldAttributeHandler::FindDirectionAttribute(
       
    89     MDesC8Array* aAttributeLines )
       
    90     {
       
    91     if ( !aAttributeLines )
       
    92         {
       
    93         SVPDEBUG1( "CSVPHoldAttributeHandler::FindDirectionAttribute - NULL" )
       
    94         
       
    95         return KErrNotFound;
       
    96         }
       
    97         
       
    98     SVPDEBUG2( "CSVPHoldAttributeHandler::FindDirectionAttribute - Attribute count is %i",
       
    99         aAttributeLines->MdcaCount() )
       
   100     
       
   101     for ( TInt j = 0; j < aAttributeLines->MdcaCount(); j++ )
       
   102         {
       
   103         SVPDEBUG1( "CSVPHoldAttributeHandler::FindDirectionAttribute - Searching" )
       
   104         
       
   105         const TPtrC8 attr = aAttributeLines->MdcaPoint( j );
       
   106         TInt pos = 0;
       
   107         TInt res = iAttributeArray->Find(
       
   108             attr.Left( KSVPMaxDirectionAttributeLength ), pos );
       
   109         
       
   110         SVPDEBUG2( "CSVPHoldAttributeHandler::FindDirectionAttribute res: %d",
       
   111             res )
       
   112         SVPDEBUG2( "CSVPHoldAttributeHandler::FindDirectionAttribute pos: %d",
       
   113             pos )
       
   114                 
       
   115         if( 0 == res )
       
   116             {
       
   117             // Found right direction attribute
       
   118             return pos;
       
   119             }
       
   120         }
       
   121     
       
   122     SVPDEBUG1( "CSVPHoldAttributeHandler::FindDirectionAttribute - Not found" )
       
   123     
       
   124     return KErrNotFound;
       
   125     }
       
   126 
       
   127