multimediacommsengine/tsrc/MCETestUI/src/CMCETestUIEventViewModel.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "CMCETestUIEventViewModel.h"
       
    21 #include "CMCETestUIEngine.h"
       
    22 #include "MMCETestUIEngineCmdProvider.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 _LIT( KTab, "\t" );
       
    27 _LIT( KLeftParenthesis, "( " );
       
    28 _LIT( KRightParenthesis, " )" );
       
    29 
       
    30 // ================= MEMBER FUNCTIONS ==========================================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CMCETestUIEventViewModel::NewL
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CMCETestUIEventViewModel* CMCETestUIEventViewModel::NewL(
       
    37         CMCETestUIEngine& aEngine,
       
    38         CMCETestUIEngineEvent& aEvent )
       
    39     {
       
    40 	CMCETestUIEventViewModel* self = 
       
    41 	    new(ELeave) CMCETestUIEventViewModel( aEngine, aEvent );
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL();
       
    44 	CleanupStack::Pop(self);
       
    45 	return self;    
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CMCETestUIEventViewModel::CMCETestUIEventViewModel
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CMCETestUIEventViewModel::CMCETestUIEventViewModel(
       
    53         CMCETestUIEngine& aEngine,
       
    54         CMCETestUIEngineEvent& aEvent )
       
    55     :iEngine( aEngine ),
       
    56      iEvent( aEvent )
       
    57     {
       
    58     }
       
    59     
       
    60 // -----------------------------------------------------------------------------
       
    61 // CMCETestUIEventViewModel::ConstructL()
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CMCETestUIEventViewModel::ConstructL()
       
    65     {
       
    66     iArray = new (ELeave) CDesCArrayFlat( 1 );
       
    67 
       
    68    // PopulateStreamsL();
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMCETestUISessionViewModel::~CMCETestUISessionViewModel()
       
    73 // Destructor
       
    74 // Frees reserved resources
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CMCETestUIEventViewModel::~CMCETestUIEventViewModel()
       
    78     {
       
    79     delete iArray;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CMCETestUIEventViewModel::MdcaCount() const
       
    84 // 
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TInt CMCETestUIEventViewModel::MdcaCount() const
       
    88     {
       
    89     return iArray->MdcaCount();
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CMCETestUIEventViewModel::MdcaPoint() const
       
    94 // 
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TPtrC CMCETestUIEventViewModel::MdcaPoint( TInt aIndex ) const
       
    98     {
       
    99     return iArray->MdcaPoint( aIndex );
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CMCETestUIEventViewModel::CmdProvider()
       
   104 // 
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 MMCETestUIEngineCmdProvider& CMCETestUIEventViewModel::CmdProvider( 
       
   108         TInt aIndex )
       
   109     {
       
   110     return iEngine;   // default         
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CMCETestUISessionViewModel::PopulateStreamsL
       
   116 // Populate streams of a session
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CMCETestUISessionViewModel::PopulateStreamsL()
       
   120     {
       
   121     const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = 
       
   122             iSession.AudioStreamsL();
       
   123 
       
   124     for ( TInt i = 0; i < audioStreams.Count(); ++i )
       
   125         {
       
   126                               
       
   127         TInt itemLength = KAudioStream().Length() + 
       
   128                           KLeftParenthesis().Length() +
       
   129                           audioStreams[i]->TextualDirection().Length() +
       
   130                           KRightParenthesis().Length() +
       
   131                           audioStreams[i]->State().Length() +
       
   132                           KTab().Length() * 3;
       
   133                       
       
   134         HBufC16* item = HBufC16::NewLC( itemLength );
       
   135         TPtr16 itemPtr = item->Des();
       
   136         itemPtr.Append( KTab );
       
   137         itemPtr.Append( KAudioStream );
       
   138         itemPtr.Append( KLeftParenthesis() );
       
   139         itemPtr.Append( audioStreams[i]->TextualDirection() );
       
   140         itemPtr.Append( KRightParenthesis() );
       
   141         itemPtr.Append( KTab );
       
   142         itemPtr.Append( audioStreams[i]->State() );
       
   143         itemPtr.Append( KTab );
       
   144     
       
   145         iArray->AppendL( *item );
       
   146         
       
   147         CleanupStack::PopAndDestroy( item );
       
   148         item = NULL;
       
   149         }
       
   150     }
       
   151 
       
   152 // End of File