multimediacommsengine/tsrc/MCETestUI/src/CMCETestUIMainViewModel.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 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "CMCETestUIMainViewModel.h"
       
    22 #include "CMCETestUIEngine.h"
       
    23 #include "CMCETestUIEngineProfile.h"
       
    24 #include "CMCETestUIEngineOutSession.h"
       
    25 #include "CMceTestUIEngineOutEvent.h"
       
    26 #include "CMceTestUIEngineInEvent.h"
       
    27 #include "CMceTestUIEngineOutRefer.h"
       
    28 #include "CMceTestUIEngineInRefer.h"
       
    29 #include "CMceTestUIEngineInSession.h"
       
    30 #include <mcesession.h>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // ================= MEMBER FUNCTIONS ==========================================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CMCETestUIMainViewModel::NewL
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CMCETestUIMainViewModel* CMCETestUIMainViewModel::NewL(
       
    41         CMCETestUIEngine& aEngine )
       
    42     {
       
    43 	CMCETestUIMainViewModel* self = 
       
    44 	    new(ELeave) CMCETestUIMainViewModel( aEngine );
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop(self);
       
    48 	return self;    
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CMCETestUIMainViewModel::CMCETestUIMainViewModel
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CMCETestUIMainViewModel::CMCETestUIMainViewModel( CMCETestUIEngine& aEngine )
       
    56     :iEngine( aEngine ),
       
    57     managerSuppressed( EFalse ),
       
    58     profilesSuppressed( EFalse )
       
    59     {
       
    60     }
       
    61     
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMCETestUIMainViewModel::ConstructL()
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void CMCETestUIMainViewModel::ConstructL()
       
    67     {
       
    68     iArray = new (ELeave) CDesCArrayFlat( 1 );
       
    69 
       
    70     PopulateMainViewManagerL();
       
    71 	PopulateMainViewProfilesL();
       
    72     PopulateMainViewOutSessionsL();
       
    73     PopulateMainViewInSessionsL();
       
    74     PopulateMainViewOutEventsL();
       
    75     PopulateMainViewInEventsL();
       
    76     PopulateMainViewOutRefersL();
       
    77     PopulateMainViewInRefersL();
       
    78     
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CMCETestUIMainViewModel::~CMCETestUIMainViewModel()
       
    83 // Destructor
       
    84 // Frees reserved resources
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CMCETestUIMainViewModel::~CMCETestUIMainViewModel()
       
    88     {
       
    89     delete iArray;
       
    90     }
       
    91     
       
    92 // -----------------------------------------------------------------------------
       
    93 // CMCETestUIMainViewModel::MdcaCount() const
       
    94 // 
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TInt CMCETestUIMainViewModel::MdcaCount() const
       
    98     {
       
    99     return iArray->MdcaCount();
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CMCETestUIMainViewModel::MdcaPoint() const
       
   104 // 
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 TPtrC CMCETestUIMainViewModel::MdcaPoint( TInt aIndex ) const
       
   108     {
       
   109     return iArray->MdcaPoint( aIndex );
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CMCETestUIMainViewModel::IsManagerSelected() const
       
   114 // 
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 TBool CMCETestUIMainViewModel::IsManagerSelected( TInt aIndex ) const
       
   118     {
       
   119     if ( aIndex == 0 && !managerSuppressed )
       
   120         {
       
   121         return ETrue;
       
   122         }
       
   123     
       
   124     return EFalse;    
       
   125     }
       
   126     
       
   127 // -----------------------------------------------------------------------------
       
   128 // CMCETestUIMainViewModel::SelectedProfileIndex() const
       
   129 // 
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TInt CMCETestUIMainViewModel::SelectedProfileIndex( TInt aIndex ) const
       
   133     {
       
   134 
       
   135     if ( managerSuppressed )
       
   136         {
       
   137         ++aIndex;
       
   138         }
       
   139 
       
   140     if ( aIndex == 0 )
       
   141         {
       
   142         return KErrNotFound;
       
   143         }
       
   144 
       
   145     aIndex -= 1; // Selected is not the manager
       
   146 
       
   147     const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   148                 iEngine.UsedProfiles();
       
   149 
       
   150     if ( profilesSuppressed )
       
   151         {
       
   152         aIndex += profiles.Count();
       
   153         }
       
   154 
       
   155     if ( aIndex < profiles.Count() )
       
   156         {
       
   157         return aIndex;
       
   158         }
       
   159     
       
   160     return KErrNotFound;    
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CMCETestUIMainViewModel::SelectedSessionIndex() const
       
   165 // 
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 TInt CMCETestUIMainViewModel::SelectedSessionIndex( TInt aIndex ) const
       
   169     {
       
   170 
       
   171     const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   172                 iEngine.UsedProfiles();
       
   173 
       
   174     const RPointerArray<CMCETestUIEngineOutSession>& outSessions = 
       
   175                 iEngine.OutSessions();               
       
   176                 
       
   177     const RPointerArray<CMCETestUIEngineInSession>& inSessions = 
       
   178                 iEngine.InSessions(); 
       
   179 
       
   180 
       
   181     // Next does not work correctly
       
   182                     
       
   183     if ( managerSuppressed )
       
   184         {
       
   185         ++aIndex;
       
   186         }
       
   187 
       
   188     if ( aIndex == 0)
       
   189         {
       
   190         return KErrNotFound;
       
   191         }
       
   192 
       
   193     aIndex -= 1; // Selected is not the manager
       
   194     
       
   195     if ( profilesSuppressed )
       
   196         {
       
   197         aIndex += profiles.Count();
       
   198         }
       
   199 
       
   200     if ( aIndex < profiles.Count() )
       
   201         {
       
   202         return KErrNotFound;
       
   203         }
       
   204     
       
   205     aIndex -= profiles.Count(); // Selected is not a profile
       
   206     
       
   207     if ( aIndex < outSessions.Count() + inSessions.Count() )
       
   208         {
       
   209         return aIndex;
       
   210         }
       
   211         
       
   212     return KErrNotFound;   // default      
       
   213     }
       
   214     
       
   215 // -----------------------------------------------------------------------------
       
   216 // CMCETestUIMainViewModel::SelectedEventIndex() const
       
   217 // 
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 TInt CMCETestUIMainViewModel::SelectedEventIndex( TInt aIndex ) const
       
   221     {
       
   222 
       
   223     const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   224                 iEngine.UsedProfiles();
       
   225 
       
   226     const RPointerArray<CMCETestUIEngineOutSession>& outSessions = 
       
   227                 iEngine.OutSessions();               
       
   228                 
       
   229     const RPointerArray<CMCETestUIEngineInSession>& inSessions = 
       
   230                 iEngine.InSessions(); 
       
   231                 
       
   232     const RPointerArray<CMCETestUIEngineOutEvent>& outEvents = 
       
   233                 iEngine.OutEvents();               
       
   234                 
       
   235     const RPointerArray<CMCETestUIEngineInEvent>& inEvents = 
       
   236                 iEngine.InEvents(); 
       
   237             
       
   238 
       
   239 
       
   240     // Next does not work correctly
       
   241                     
       
   242     if ( managerSuppressed )
       
   243         {
       
   244         ++aIndex;
       
   245         }
       
   246 
       
   247     if ( aIndex == 0)
       
   248         {
       
   249         return KErrNotFound;
       
   250         }
       
   251 
       
   252     aIndex -= 1; // Selected is not the manager
       
   253     
       
   254     if ( profilesSuppressed )
       
   255         {
       
   256         aIndex += profiles.Count();
       
   257         }
       
   258 
       
   259     if ( aIndex < profiles.Count() )
       
   260         {
       
   261         return KErrNotFound;
       
   262         }
       
   263     
       
   264     aIndex -= profiles.Count(); // Selected is not a profile
       
   265     
       
   266     if ( aIndex < outSessions.Count() + inSessions.Count() )
       
   267         {
       
   268         return aIndex;
       
   269         }
       
   270         
       
   271     aIndex -= (outSessions.Count() + inSessions.Count() ); // Selected is not session
       
   272     
       
   273     if ( aIndex < outEvents.Count() + inEvents.Count() )
       
   274         {
       
   275         return aIndex;
       
   276         }    
       
   277         
       
   278     return KErrNotFound;   // default      
       
   279     }
       
   280     
       
   281 // -----------------------------------------------------------------------------
       
   282 // CMCETestUIMainViewModel::SelectedReferIndex() const
       
   283 // 
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TInt CMCETestUIMainViewModel::SelectedReferIndex( TInt aIndex ) const
       
   287     {
       
   288 
       
   289     const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   290                 iEngine.UsedProfiles();
       
   291 
       
   292     const RPointerArray<CMCETestUIEngineOutSession>& outSessions = 
       
   293                 iEngine.OutSessions();               
       
   294                 
       
   295     const RPointerArray<CMCETestUIEngineInSession>& inSessions = 
       
   296                 iEngine.InSessions(); 
       
   297                 
       
   298     const RPointerArray<CMCETestUIEngineOutEvent>& outEvents = 
       
   299                 iEngine.OutEvents();               
       
   300                 
       
   301     const RPointerArray<CMCETestUIEngineInEvent>& inEvents = 
       
   302                 iEngine.InEvents(); 
       
   303             
       
   304 	const RPointerArray<CMCETestUIEngineOutRefer>& outRefers = 
       
   305                 iEngine.OutRefers();               
       
   306                 
       
   307     const RPointerArray<CMCETestUIEngineInRefer>& inRefers = 
       
   308                 iEngine.InRefers();
       
   309 
       
   310     // Next does not work correctly
       
   311                     
       
   312     if ( managerSuppressed )
       
   313         {
       
   314         ++aIndex;
       
   315         }
       
   316 
       
   317     if ( aIndex == 0)
       
   318         {
       
   319         return KErrNotFound;
       
   320         }
       
   321 
       
   322     aIndex -= 1; // Selected is not the manager
       
   323     
       
   324     if ( profilesSuppressed )
       
   325         {
       
   326         aIndex += profiles.Count();
       
   327         }
       
   328 
       
   329     if ( aIndex < profiles.Count() )
       
   330         {
       
   331         return KErrNotFound;
       
   332         }
       
   333     
       
   334     aIndex -= profiles.Count(); // Selected is not a profile
       
   335     
       
   336     if ( aIndex < outSessions.Count() + inSessions.Count() )
       
   337         {
       
   338         return aIndex;
       
   339         }
       
   340         
       
   341     aIndex -= (outSessions.Count() + inSessions.Count() ); // Selected is not session
       
   342     
       
   343     if ( aIndex < outEvents.Count() + inEvents.Count() )
       
   344         {
       
   345         return aIndex;
       
   346         }    
       
   347    	
       
   348    	aIndex -= (outEvents.Count() + inEvents.Count() ); // Selected is not event
       
   349     
       
   350     if ( aIndex < outRefers.Count() + inRefers.Count() )
       
   351         {
       
   352         return aIndex;
       
   353         }    
       
   354     
       
   355     return KErrNotFound;   // default      
       
   356     }
       
   357 // -----------------------------------------------------------------------------
       
   358 // CMCETestUIMainViewModel::CmdProvider()
       
   359 // 
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 MMCETestUIEngineCmdProvider& CMCETestUIMainViewModel::CmdProvider( TInt aIndex )
       
   363     {
       
   364     
       
   365     const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   366                 iEngine.UsedProfiles();
       
   367 
       
   368     const RPointerArray<CMCETestUIEngineOutSession>& outSessions = 
       
   369                 iEngine.OutSessions();               
       
   370                 
       
   371     const RPointerArray<CMCETestUIEngineInSession>& inSessions = 
       
   372                 iEngine.InSessions(); 
       
   373 
       
   374 	const RPointerArray<CMCETestUIEngineOutEvent>& outEvents = 
       
   375                 iEngine.OutEvents();               
       
   376                 
       
   377     const RPointerArray<CMCETestUIEngineInEvent>& inEvents = 
       
   378                 iEngine.InEvents();
       
   379 
       
   380 	const RPointerArray<CMCETestUIEngineOutRefer>& outRefers = 
       
   381                 iEngine.OutRefers();               
       
   382                 
       
   383     const RPointerArray<CMCETestUIEngineInRefer>& inRefers = 
       
   384                 iEngine.InRefers();
       
   385 
       
   386     // Next does not work correctly
       
   387                     
       
   388     if ( managerSuppressed )
       
   389         {
       
   390         ++aIndex;
       
   391         }
       
   392 
       
   393     if ( aIndex == 0)
       
   394         {
       
   395         return iEngine;
       
   396         }
       
   397 
       
   398     aIndex -= 1; // Selected is not the manager
       
   399     
       
   400     if ( profilesSuppressed )
       
   401         {
       
   402         aIndex += profiles.Count();
       
   403         }
       
   404 
       
   405     if ( aIndex < profiles.Count() )
       
   406         {
       
   407         return *(profiles[aIndex]);
       
   408         }
       
   409     
       
   410     aIndex -= profiles.Count(); // Selected is not a profile
       
   411     
       
   412     if ( aIndex < outSessions.Count() )
       
   413         {
       
   414         return *(outSessions[aIndex]);
       
   415         }
       
   416     
       
   417     aIndex -= outSessions.Count(); // Selected is not an outsession
       
   418     
       
   419     if ( aIndex < inSessions.Count() )
       
   420         {
       
   421         return *(inSessions[aIndex]);
       
   422         }
       
   423     
       
   424     aIndex -= inSessions.Count(); // Selected is not a session
       
   425     
       
   426     if ( aIndex < outEvents.Count() )
       
   427         {
       
   428         return *(outEvents[aIndex]);
       
   429         }
       
   430     
       
   431     aIndex -= outEvents.Count(); // Selected is not an outEvent
       
   432     
       
   433     if ( aIndex < inEvents.Count() )
       
   434         {
       
   435         return *(inEvents[aIndex]);
       
   436         }
       
   437     
       
   438    aIndex -= inEvents.Count(); // Selected is not an event
       
   439     
       
   440     if ( aIndex < outRefers.Count() )
       
   441         {
       
   442         return *(outRefers[aIndex]);
       
   443         }
       
   444     
       
   445     aIndex -= outRefers.Count(); // Selected is not an outrefer
       
   446     
       
   447     if ( aIndex < inRefers.Count() )
       
   448         {
       
   449         return *(inRefers[aIndex]);
       
   450         }
       
   451         
       
   452     return iEngine;   // default      
       
   453     
       
   454         
       
   455     }
       
   456 
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CMCETestUIMainViewModel::PopulateMainViewManagerL
       
   460 // Populate main view manager
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 void CMCETestUIMainViewModel::PopulateMainViewManagerL()
       
   464     {
       
   465     if ( !managerSuppressed )
       
   466         {
       
   467         TInt sessionCount = iEngine.OutSessions().Count() +
       
   468                             iEngine.InSessions().Count();
       
   469                             
       
   470         TInt eventCount =  iEngine.OutEvents().Count() +
       
   471                             iEngine.InEvents().Count(); 
       
   472                             
       
   473         TInt referCount =  iEngine.OutRefers().Count() +
       
   474                             iEngine.InRefers().Count();                    
       
   475                             
       
   476         TInt itemLength = KMCEManager().Length() + KSessionCount().Length() + 
       
   477         				  KEventCount().Length() + KReferCount().Length() + KTab().Length() * 4 + KSpace().Length() + 10;
       
   478                           
       
   479         HBufC* item =  HBufC::NewLC( itemLength );
       
   480         TPtr itemPtr = item->Des();
       
   481         itemPtr.Append( KTab );
       
   482         itemPtr.Append( KMCEManager );
       
   483         itemPtr.Append( KTab );
       
   484         itemPtr.Append( KSessionCount );
       
   485         itemPtr.AppendNum( sessionCount );
       
   486      //   itemPtr.Append( KSpace );
       
   487         itemPtr.Append( KEventCount );
       
   488         itemPtr.AppendNum( eventCount );
       
   489      //   itemPtr.Append( KSpace );
       
   490         itemPtr.Append( KReferCount );
       
   491         itemPtr.AppendNum( referCount );
       
   492                
       
   493         iArray->AppendL( *item );
       
   494         
       
   495         CleanupStack::PopAndDestroy( item );
       
   496         item = NULL;
       
   497         }
       
   498     }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CMCETestUIMainViewModel::PopulateMainViewProfilesL
       
   502 // Populate main view profiles
       
   503 // -----------------------------------------------------------------------------
       
   504 //
       
   505 void CMCETestUIMainViewModel::PopulateMainViewProfilesL()
       
   506     {   
       
   507     if ( !profilesSuppressed )
       
   508         {
       
   509         const RPointerArray<CMCETestUIEngineProfile>& profiles = 
       
   510             iEngine.UsedProfiles();
       
   511             
       
   512         for ( TInt i = 0; i < profiles.Count(); ++i )
       
   513             {
       
   514             const TDesC8& providerName = profiles[i]->ProviderName();
       
   515             HBufC* providerName16 = HBufC16::NewLC( providerName.Length() );
       
   516             TPtr providerNamePtr = providerName16->Des();
       
   517             providerNamePtr.Copy( providerName );
       
   518             
       
   519             const TDesC8& aor = profiles[i]->Aor();
       
   520             HBufC* aor16 = HBufC16::NewLC( aor.Length() );
       
   521             TPtr aorPtr = aor16->Des();
       
   522             aorPtr.Copy( aor );
       
   523             
       
   524             TPtrC registerStatus;
       
   525             if ( profiles[i]->IsRegistered() )
       
   526                 {
       
   527                 registerStatus.Set( KRegistered );
       
   528                 }
       
   529             else
       
   530                 {
       
   531                 registerStatus.Set( KNotRegistered );
       
   532                 }
       
   533             TInt itemLength = providerName.Length() + registerStatus.Length() + 
       
   534                               KProfile().Length() + aor.Length() +
       
   535                               KSpace().Length() +KTab().Length()*4;
       
   536                             
       
   537             HBufC* item =  HBufC::NewLC( itemLength );
       
   538             TPtr itemPtr = item->Des();
       
   539             itemPtr.Append( KTab );
       
   540             itemPtr.Append( KProfile );
       
   541             itemPtr.Append( *providerName16 );
       
   542             itemPtr.Append( KSpace );
       
   543             itemPtr.Append( registerStatus );
       
   544             itemPtr.Append( KTab );
       
   545             //itemPtr.Append(KSpace);
       
   546             itemPtr.Append( *aor16 );
       
   547             itemPtr.Append( KTab );
       
   548             iArray->AppendL( *item );
       
   549 
       
   550             CleanupStack::PopAndDestroy( item );
       
   551             item = NULL;
       
   552             CleanupStack::PopAndDestroy( aor16 );
       
   553             aor16 = NULL;
       
   554             CleanupStack::PopAndDestroy( providerName16 );
       
   555             providerName16 = NULL;
       
   556           
       
   557             
       
   558             }
       
   559         }
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // CMCETestUIMainViewModel::PopulateMainViewOutSessionsL
       
   564 // Populate main view outgoing sessions
       
   565 // -----------------------------------------------------------------------------
       
   566 //
       
   567 void CMCETestUIMainViewModel::PopulateMainViewOutSessionsL()
       
   568     {
       
   569     const RPointerArray<CMCETestUIEngineOutSession>& outSessions = 
       
   570             iEngine.OutSessions();
       
   571 
       
   572 	if( outSessions.Count() == 0) return;
       
   573 	
       
   574     for ( TInt i = 0; i < outSessions.Count(); ++i )
       
   575         {
       
   576         TInt itemLength = KOutSession().Length() + 
       
   577                           KLeftParenthesis().Length() + 
       
   578                           KProfileId().Length() + 2 +KSpace().Length()+
       
   579                           outSessions[i]->TextualDirection().Length() +
       
   580                           KRightParenthesis().Length() +
       
   581                           outSessions[i]->State().Length() +
       
   582                           KTab().Length() * 4 + 5 ;  
       
   583         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   584         TPtr itemPtr = item->Des();
       
   585         itemPtr.Append( KTab );        
       
   586         itemPtr.Append( KOutSession );
       
   587         itemPtr.AppendNum( outSessions[i]->Id() );
       
   588         itemPtr.Append( KLeftParenthesis );
       
   589         itemPtr.Append( KProfileId);
       
   590         itemPtr.AppendNum( outSessions[i]->ProfileId());
       
   591         itemPtr.Append( KSpace);
       
   592         itemPtr.Append( outSessions[i]->TextualDirection() );
       
   593         itemPtr.Append( KRightParenthesis );
       
   594         itemPtr.Append( KTab );
       
   595         itemPtr.Append( outSessions[i]->State() );
       
   596     	iArray->AppendL( *item );
       
   597         CleanupStack::PopAndDestroy( item );
       
   598         item = NULL;     
       
   599         }
       
   600     }
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 // CMCETestUIMainViewModel::PopulateMainViewInSessionsL
       
   604 // Populate main view incoming sessions
       
   605 // -----------------------------------------------------------------------------
       
   606 //
       
   607 void CMCETestUIMainViewModel::PopulateMainViewInSessionsL()
       
   608     {
       
   609     const RPointerArray<CMCETestUIEngineInSession>& inSessions = 
       
   610             iEngine.InSessions();
       
   611 	if( inSessions.Count() == 0) return;
       
   612 
       
   613     for ( TInt i = 0; i < inSessions.Count(); ++i )
       
   614         {
       
   615         TInt itemLength = KInSession().Length() + 
       
   616                           KLeftParenthesis().Length() + 
       
   617                           KProfileId().Length() + 2 +KSpace().Length()+
       
   618                           inSessions[i]->TextualDirection().Length() +
       
   619                           KRightParenthesis().Length() + 
       
   620                           inSessions[i]->State().Length() +
       
   621                           KTab().Length() * 4 + 5 ;  
       
   622         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   623         TPtr itemPtr = item->Des();
       
   624         itemPtr.Append( KTab );        
       
   625         itemPtr.Append( KInSession );
       
   626         itemPtr.AppendNum( inSessions[i]->Id() );
       
   627         itemPtr.Append( KLeftParenthesis );
       
   628         itemPtr.Append( KProfileId);
       
   629         itemPtr.AppendNum( inSessions[i]->ProfileId());
       
   630         itemPtr.Append( KSpace);
       
   631         itemPtr.Append( inSessions[i]->TextualDirection() );
       
   632         itemPtr.Append( KRightParenthesis );
       
   633         itemPtr.Append( KTab );
       
   634         itemPtr.Append( inSessions[i]->State() );
       
   635         iArray->AppendL( *item );
       
   636         CleanupStack::PopAndDestroy( item );
       
   637         item = NULL;     
       
   638         }
       
   639     }
       
   640 // -----------------------------------------------------------------------------
       
   641 // CMCETestUIMainViewModel::PopulateMainViewOutSessionsL
       
   642 // Populate main view outgoing sessions
       
   643 // -----------------------------------------------------------------------------
       
   644 //
       
   645 void CMCETestUIMainViewModel::PopulateMainViewOutEventsL()
       
   646     {
       
   647     const RPointerArray<CMCETestUIEngineOutEvent>& outEvents = 
       
   648             iEngine.OutEvents();
       
   649     if( outEvents.Count() == 0) return;
       
   650 
       
   651     for ( TInt i = 0; i < outEvents.Count(); ++i )
       
   652         {
       
   653         TInt itemLength = KOutEvent().Length() + 
       
   654                           outEvents[i]->State().Length() +
       
   655                           KTab().Length() * 3 + 5 ;  
       
   656         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   657         TPtr itemPtr = item->Des();
       
   658         itemPtr.Append( KTab );        
       
   659         itemPtr.Append( KOutEvent);
       
   660         itemPtr.AppendNum( outEvents[i]->Id() );
       
   661         itemPtr.Append( KTab );
       
   662         itemPtr.Append( outEvents[i]->State() );
       
   663    	    iArray->AppendL( *item );
       
   664         CleanupStack::PopAndDestroy( item );
       
   665         item = NULL;     
       
   666         }
       
   667     }
       
   668 
       
   669 // -----------------------------------------------------------------------------
       
   670 // CMCETestUIMainViewModel::PopulateMainViewInEventsL
       
   671 // Populate main view incoming sessions
       
   672 // -----------------------------------------------------------------------------
       
   673 //
       
   674 void CMCETestUIMainViewModel::PopulateMainViewInEventsL()
       
   675     {
       
   676     const RPointerArray<CMCETestUIEngineInEvent>& inEvents = 
       
   677             iEngine.InEvents();
       
   678 	if( inEvents.Count() == 0) return;
       
   679 
       
   680     for ( TInt i = 0; i < inEvents.Count(); ++i )
       
   681         {
       
   682         TInt itemLength = KInEvent().Length() + 
       
   683                           inEvents[i]->State().Length() +
       
   684                           KTab().Length() * 3 + 5 ;  
       
   685         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   686         TPtr itemPtr = item->Des();
       
   687         itemPtr.Append( KTab );        
       
   688         itemPtr.Append( KInEvent );
       
   689         itemPtr.AppendNum( inEvents[i]->Id() );
       
   690         itemPtr.Append( KTab);
       
   691         itemPtr.Append( inEvents[i]->State() );
       
   692         iArray->AppendL( *item );
       
   693         CleanupStack::PopAndDestroy( item );
       
   694         item = NULL;     
       
   695         }
       
   696     }
       
   697 
       
   698 // -----------------------------------------------------------------------------
       
   699 // CMCETestUIMainViewModel::PopulateMainViewOutRefersL
       
   700 // Populate main view outgoing sessions
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 void CMCETestUIMainViewModel::PopulateMainViewOutRefersL()
       
   704     {
       
   705     const RPointerArray<CMCETestUIEngineOutRefer>& outRefers = 
       
   706             iEngine.OutRefers();
       
   707     if( outRefers.Count() == 0) return;
       
   708 
       
   709     for ( TInt i = 0; i < outRefers.Count(); ++i )
       
   710         {
       
   711         TInt itemLength = KOutRefer().Length() + 
       
   712                           outRefers[i]->State().Length() +
       
   713                           KTab().Length() * 3 + 5 ;  
       
   714         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   715         TPtr itemPtr = item->Des();
       
   716         itemPtr.Append( KTab );        
       
   717         itemPtr.Append( KOutRefer);
       
   718         itemPtr.AppendNum( outRefers[i]->Id() );
       
   719         itemPtr.Append( KTab );
       
   720         itemPtr.Append( outRefers[i]->State() );
       
   721    	    iArray->AppendL( *item );
       
   722         CleanupStack::PopAndDestroy( item );
       
   723         item = NULL;     
       
   724         }
       
   725     }
       
   726 
       
   727 // -----------------------------------------------------------------------------
       
   728 // CMCETestUIMainViewModel::PopulateMainViewInRefersL
       
   729 // Populate main view incoming sessions
       
   730 // -----------------------------------------------------------------------------
       
   731 //
       
   732 void CMCETestUIMainViewModel::PopulateMainViewInRefersL()
       
   733     {
       
   734     const RPointerArray<CMCETestUIEngineInRefer>& inRefers = 
       
   735             iEngine.InRefers();
       
   736 	if( inRefers.Count() == 0) return;
       
   737 
       
   738     for ( TInt i = 0; i < inRefers.Count(); ++i )
       
   739         {
       
   740         TInt itemLength = KInRefer().Length() + 
       
   741                           inRefers[i]->State().Length() +
       
   742                           KTab().Length() * 3 + 5 ;  
       
   743         HBufC* item =  HBufC::NewLC( itemLength ); 
       
   744         TPtr itemPtr = item->Des();
       
   745         itemPtr.Append( KTab );        
       
   746         itemPtr.Append( KInRefer );
       
   747         itemPtr.AppendNum( inRefers[i]->Id() );
       
   748         itemPtr.Append( KTab);
       
   749         itemPtr.Append( inRefers[i]->State() );
       
   750         iArray->AppendL( *item );
       
   751         CleanupStack::PopAndDestroy( item );
       
   752         item = NULL;     
       
   753         }
       
   754     }
       
   755 
       
   756 // End of File