uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
child 13 8f67d927ea57
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <graphics/wsgraphicscontext.h>
       
    21 #include <graphics/wsgraphicdrawerinterface.h>
       
    22 #include <bitstd.h>
       
    23 #include <fbs.h>
       
    24 #include <gdi.h>
       
    25 #include <e32math.h>
       
    26 #include <e32hashtab.h>
       
    27 #include <uiacceltk/HuiUtil.h>
       
    28 
       
    29 #include "alfhierarchymodel.h"
       
    30 #include "alfstreamerconsts.h"
       
    31 #include "alfstreamerserver.h"
       
    32 #include "alfwindowmanager.h"
       
    33 #include "alfstreamerbridge.h"
       
    34 #include "alfwindow.h"
       
    35 #include "alflogger.h"
       
    36 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
    37 #include "alfcommanddebug.h"
       
    38 #endif
       
    39 #include "alfnodes.h"
       
    40 #include "huiwscanvascommands.h"
       
    41 
       
    42 #include "mwsgraphicscontexttobitgdimappings.h"
       
    43 
       
    44 const TInt KChunkCommitBatchSize = 10000;
       
    45 const TInt KChunkMaxSize = 500000;
       
    46 const TInt KFrameOffsetTemplate = 12345678;
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // NewL
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CAlfHierarchyModel* CAlfHierarchyModel::NewL(CAlfStreamerServer& aServer)
       
    53     {
       
    54     CAlfHierarchyModel* self = new(ELeave)CAlfHierarchyModel(aServer);
       
    55     CleanupStack::PushL(self);
       
    56     self->ConstructL();
       
    57     CleanupStack::Pop(self);
       
    58     return self;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // ConstructL
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CAlfHierarchyModel::ConstructL()
       
    66     {
       
    67     iWindowPos = TPoint(0, 0 );
       
    68     iSema.CreateLocal();
       
    69     if (iServer.Bridge())
       
    70         {
       
    71         iServer.Bridge()->SetBatchObserver(this);
       
    72         }                
       
    73 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
    74     iCommandDebugger = CAlfCommandDebug::NewL();
       
    75 #endif
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // AppendScreenL
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CAlfHierarchyModel::AppendScreen( TInt aScreenNumber )
       
    83     {
       
    84     __ALFLOGSTRING1("CAlfHierarchyModel::AppendScreenL( %d )", aScreenNumber );
       
    85     if ( aScreenNumber > 0 ) // first display comes with the package. only the following are created when requested
       
    86         {
       
    87         iServer.Bridge()->AddData( EAlfDSCreateNewDisplay, aScreenNumber, 0, NULL );
       
    88         }
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // RemoveScreenL
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CAlfHierarchyModel::RemoveScreen( TInt aScreenNumber )
       
    96     {
       
    97     if ( aScreenNumber < 1 ) 
       
    98 		{
       
    99 		// The main display cannot be removed.
       
   100 		return;
       
   101 		}
       
   102 	
       
   103     __ALFLOGSTRING1("CAlfHierarchyModel::RemoveDisplayL( %d )", aScreenNumber );
       
   104     // NOTE & TODO: This works fine, if we are removing the last added display. If we happen to remove display in the middle,
       
   105     // then referring to displays by their indeces would be a major problem
       
   106     // TODO: Who destroyes the nodes on this display? wserv?
       
   107     iServer.Bridge()->AddData( EAlfDSDestroyDisplay, aScreenNumber, 0, NULL );
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // destructor
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 CAlfHierarchyModel::~CAlfHierarchyModel()
       
   115     {
       
   116     // we do not complete pending messages 
       
   117 	iPendingAlfWindowDataMessages.Close(); 
       
   118 	iNodeHashArray.Close();
       
   119     if (iServer.Bridge())
       
   120         {
       
   121         iServer.Bridge()->SetBatchObserver(0);
       
   122         }
       
   123     delete iPeriodic;
       
   124     iSema.Close();
       
   125     if(iStream)
       
   126         {
       
   127         iStream->Close();
       
   128         delete iStream;
       
   129         iStream = NULL;
       
   130         }
       
   131     iChunk.Close();
       
   132 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
   133     delete iCommandDebugger;
       
   134 #endif
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // ReleaseSemaphor
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void ReleaseSemaphor(TAny* aAlfHierarchyModel)
       
   142     {
       
   143     CAlfHierarchyModel* me = (CAlfHierarchyModel*)aAlfHierarchyModel;
       
   144     me->DoReleaseSemaphor();
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // DoReleaseSemaphor
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CAlfHierarchyModel::DoReleaseSemaphor()
       
   152     {
       
   153     iSema.Signal();
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // RequestPacketEndCallback
       
   158 // 
       
   159 // This is used to notify when certain offset in the chunk is freed. To avoid 
       
   160 // excessive notifications (and callbacks), skip some of the notifications.
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CAlfHierarchyModel::RequestPacketEndCallback( TInt aOffset )
       
   164     {
       
   165     if ( aOffset > iPreviousCallbackOffset + KChunkCommitBatchSize || aOffset < iPreviousCallbackOffset )
       
   166         {
       
   167         iPreviousCallbackOffset = aOffset;
       
   168         iServer.Bridge()->RequestCommandReadNotification( aOffset );
       
   169         }
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // RequestFrameEndCallback
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void CAlfHierarchyModel::RequestFrameEndCallback( )
       
   177     {
       
   178     __ALFLOGSTRING( "CAlfHierarchyModel::RequestFrameEndCallback" );
       
   179     iServer.Bridge()->StartNewBlock();
       
   180     }
       
   181 // ---------------------------------------------------------------------------
       
   182 // HandleMessageL
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void CAlfHierarchyModel::HandleMessageL( const RMessage2& aMessage )
       
   186     {
       
   187     iSema.Wait();
       
   188     CleanupStack::PushL(TCleanupItem(ReleaseSemaphor, this));
       
   189     TBool doComplete= EFalse;
       
   190     // __ALFLOGSTRING1( "CAlfHierarchyModel::HandleMessageL %d", aMessage.Function() );
       
   191     switch (aMessage.Function())
       
   192         {
       
   193         case EAlfBridgerRequestDataBlock:
       
   194             {
       
   195             ShareChunkL( aMessage );
       
   196             return;
       
   197             }
       
   198         case EDsNotifyNativeWindowData:
       
   199             {
       
   200             User::Leave(KErrNotSupported);
       
   201             return;
       
   202             }
       
   203         case EAlfBridgerAsyncronousData:
       
   204             {
       
   205             if ( iChunk.Handle() )
       
   206                 {
       
   207                 ExecuteCommandsL();
       
   208                 if ( iBatchAlreadyCommited )
       
   209                     {
       
   210                     // This may happen, if alfstreamerbridge happens to process the commands (containing the EAlfCommitBatch) 
       
   211                     //  before this asyncronous request is received.
       
   212                     __ALFLOGSTRING("Batch already completed. Complete immediately");
       
   213                     aMessage.Complete( EAlfBridgerAsyncronousData );
       
   214                     iBatchAlreadyCommited = EFalse;
       
   215                     }
       
   216                 else
       
   217                     {
       
   218                     SetSynchMessage(&aMessage);
       
   219                     }
       
   220                 }
       
   221             break;
       
   222             }
       
   223         case EAlfBridgerBlindSend:
       
   224             {
       
   225             ExecuteCommandsL();
       
   226             CleanupStack::PopAndDestroy(); // releases iSema
       
   227             aMessage.Complete( EAlfBridgerBlindSend );
       
   228             return;
       
   229             }
       
   230         case EAlfBridgerSendChunk:
       
   231             {
       
   232             OpenChunkL( aMessage );
       
   233 			aMessage.Complete( EAlfBridgerSendChunk );
       
   234             return;
       
   235             }
       
   236         default:
       
   237             {
       
   238             doComplete= ETrue;
       
   239             __ALFLOGSTRING("CAlfHierarchyModel::HandleMessageL, default case reached.");
       
   240             break;
       
   241             }
       
   242         }
       
   243     if (doComplete && !aMessage.IsNull())
       
   244         {
       
   245         aMessage.Complete(KErrNotSupported);
       
   246         }
       
   247            
       
   248     CleanupStack::PopAndDestroy(); // releases iSema
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // ShareChunkL
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 void CAlfHierarchyModel::ShareChunkL( const RMessage2& aMessage )
       
   256     {
       
   257     if ( !iChunk.Handle() )
       
   258         {
       
   259         // For security reasons, alfserver owns the chunk. Because it is nameless, it cannot be accessed
       
   260         // unless a handle to the chunk is given by alfserver
       
   261         //
       
   262         // TODO:CHECK what if somebody else wants to send EAlfBridgerRequestDataBlock. Currently we are giving the chunk
       
   263         // to anybody who connects to the server.
       
   264         iChunk.CreateDisconnectedGlobal( KNullDesC, 0, KChunkMaxSize, KChunkMaxSize ); //CreateDisconnectedGlobal
       
   265         iChunkHeader  = reinterpret_cast<TChunkHeader*>(iChunk.Base());
       
   266         memset( iChunkHeader, 0, sizeof( TChunkHeader ) );
       
   267         }
       
   268     TInt screenNumber = aMessage.Int1();
       
   269     TPckg<TInt> pkgLength( KChunkMaxSize );
       
   270     AppendScreen( screenNumber );
       
   271     aMessage.WriteL(0, pkgLength );
       
   272     aMessage.Complete( iChunk );
       
   273     if ( iStream )
       
   274         {
       
   275         iStream->Close();
       
   276         }
       
   277     else
       
   278         {
       
   279         iStream = new(ELeave)RMemReadStream;
       
   280         }
       
   281     iStream->Open( iChunk.Base() + sizeof( TChunkHeader), KChunkMaxSize );
       
   282     
       
   283     CleanupStack::PopAndDestroy(); // releases iSema
       
   284 }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 // ShareChunkL
       
   288 // ---------------------------------------------------------------------------
       
   289 //
       
   290 void CAlfHierarchyModel::OpenChunkL( const RMessage2& aMessage )
       
   291     {
       
   292     TInt size = aMessage.Int0();
       
   293     TInt32 handle = aMessage.Int1();
       
   294     TBool openForReading = aMessage.Int2();
       
   295     
       
   296     iCacheChunks.Insert( handle, RChunk() );
       
   297     iCacheChunks.Find( handle )->SetHandle( aMessage.Int1() );
       
   298     iCacheChunks.Find( handle )->Open( aMessage, 1, EFalse, EOwnerProcess );
       
   299     
       
   300     if ( openForReading ) 
       
   301         {
       
   302         if (iStream)
       
   303             {
       
   304             iStream->Close();
       
   305             }
       
   306         else
       
   307             {
       
   308             iStream = new(ELeave)RMemReadStream;
       
   309             }
       
   310         
       
   311         TUint8*  base = iCacheChunks.Find( handle )->Base();
       
   312         iStream->Open( base + sizeof( TChunkHeader), size );
       
   313 
       
   314         __ALFLOGSTRING1("Chunk in use %d", iChunkInUse );
       
   315         iChunkInUse = handle;    
       
   316         iChunkHeader  = reinterpret_cast<TChunkHeader*>(base);
       
   317         }
       
   318     CleanupStack::PopAndDestroy(); // releases iSema
       
   319   
       
   320 }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // CloseChunkL
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CAlfHierarchyModel::CloseChunk( TInt32 aChunkHandle )
       
   327     {
       
   328     __ALFLOGSTRING1("CAlfHierarchyModel::CloseChunkL: closing %d", aChunkHandle );
       
   329     RChunk* chunk = iCacheChunks.Find( aChunkHandle );
       
   330     iCacheChunks.Remove( aChunkHandle );
       
   331     if ( chunk )
       
   332         {
       
   333         chunk->Close();
       
   334         }
       
   335     else
       
   336         {
       
   337         __ALFLOGSTRING1( "CAlfHierarchyModel::CloseChunkL - Warning: chunk %d not found!", aChunkHandle );
       
   338         }
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // ReadEndMarkerL
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 void CAlfHierarchyModel::ReadEndMarkerL()
       
   346     {
       
   347     TUint8 marker = iStream->ReadInt8L();
       
   348     ASSERT( marker == EAlfCommandEndMarker ) ; // endmarker
       
   349     }
       
   350     
       
   351 // ---------------------------------------------------------------------------
       
   352 // ReadRectL
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CAlfHierarchyModel::ReadRectL( TRect& aRect, RMemReadStream* aStream )
       
   356     {
       
   357     aStream->ReadL( (TUint8*)&(aRect.iTl.iX), sizeof( TRect) );
       
   358     }
       
   359 
       
   360 // ---------------------------------------------------------------------------
       
   361 // ReadRegionL
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 void CAlfHierarchyModel::ReadRegionL( RMemReadStream* aStream, RRegion& aRegion, TPoint aWindowPos )
       
   365     {
       
   366     aRegion.Clear();
       
   367     TRect rect;
       
   368     TInt count = aStream->ReadInt32L();
       
   369     for (TInt i = 0 ; i < count ; i++ )
       
   370         {
       
   371         ReadRectL( rect, aStream );
       
   372         rect.Move(-aWindowPos);
       
   373         aRegion.AddRect( rect );
       
   374         }
       
   375     }
       
   376 	
       
   377 
       
   378 // ---------------------------------------------------------------------------
       
   379 // ExecuteCommandsL
       
   380 // ---------------------------------------------------------------------------
       
   381 //
       
   382 void CAlfHierarchyModel::ExecuteCommandsL(  )
       
   383     {
       
   384     if ( !iStream )
       
   385         {
       
   386         return;
       
   387         }
       
   388     TInt offset = iStream->Source()->TellL( MStreamBuf::ERead ).Offset();
       
   389 
       
   390 
       
   391 #ifdef _ALF_LOGGING
       
   392     TInt commandCount(0);
       
   393     TSgcCanvasCommands previousCommand;
       
   394 #endif
       
   395     TSgcCanvasCommands command = EAlfCommandNotInitialized;
       
   396     TTime beginTime;
       
   397     beginTime.HomeTime();
       
   398     
       
   399     __ALFLOGSTRING1( "CAlfHierarchyModel::ExecuteCommandsL - Committed write offset: %d", iChunkHeader->iCommittedWriteOffset );
       
   400     while( iChunkHeader->iCommittedWriteOffset != offset )
       
   401         {
       
   402 #ifdef _ALF_LOGGING
       
   403         previousCommand = command;
       
   404 #endif
       
   405         TRAPD( err,
       
   406                 command = (TSgcCanvasCommands)iStream->ReadUint8L();
       
   407                 iScreenNumber = iStream->ReadUint8L();
       
   408             );
       
   409         if ( err != KErrNone )
       
   410 	          {
       
   411 #ifdef _ALF_LOGGING
       
   412 	          __ALFLOGSTRING3("CAlfHierarchyModel::ExecuteCommandsL - Cmd: %d, Previous Cmd: %d, Count: %d..", command, previousCommand, commandCount );
       
   413 #endif	          
       
   414 	          __ALFLOGSTRING2("..CAlfHierarchyModel::ExecuteCommandsL - Offset: %d, LEAVE WITH ERROR: %d", offset, err  );
       
   415               }
       
   416         
       
   417 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
   418         commandCount++;
       
   419         iUsedCommands[command]++;
       
   420 
       
   421         iCommandDebugger->SetDescription( command );
       
   422         __ALFLOGSTRING3("CAlfHierarchyModel::ExecuteCommandsL (%d) %S offset: %d,", command, &iCommandDebugger->Text(), offset );
       
   423 #endif        
       
   424         switch ( command )
       
   425             {
       
   426         	case EAlfSetWindowId:
       
   427                 {
       
   428                 TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   429                 CAlfNodeVisual* node = (CAlfNodeVisual*)FindNode( nodeId );
       
   430 
       
   431                 if ( node )
       
   432                     {
       
   433 #ifdef ALF_DEBUG_TRACK_DRAWING					
       
   434                     if (node->iId == iSearchNode || node->Tracking() )
       
   435                         {
       
   436                         RDebug::Print( _L( "CAlfHierarchyModel::ExecuteCommandsL - Tracking"));
       
   437                         }
       
   438 #endif						
       
   439 #ifdef ALF_DEBUG_PRINT_NODE_INFO
       
   440                     _LIT( KText, "Drawing");
       
   441                     // node->PrintInfo(0, node, TPtrC(KText) , iSearchNode);
       
   442 #endif
       
   443 
       
   444                     node->DrawWindowFrameL( *iStream );
       
   445                     }
       
   446                 else
       
   447                     {
       
   448                     ProcessUnknownNodeDrawingL( *iStream );
       
   449                     }
       
   450                 break;
       
   451                 }
       
   452             case EAlfNodeCreated:
       
   453                 {
       
   454                 DoNodeCreatedL();
       
   455                 break;
       
   456                 }
       
   457             case EAlfNodeReleased:
       
   458                 {
       
   459                 DoNodeReleasedL();
       
   460                 break;
       
   461                 }
       
   462             case EAlfNodeActivated:
       
   463                 {
       
   464                 DoNodeActivatedL();
       
   465                 break;
       
   466                 }
       
   467             case EAlfNodeExtentChanged:
       
   468                 {
       
   469                 DoNodeExtentChangedL();
       
   470                 break;
       
   471                 }
       
   472             case EAlfNodeSiblingOrderChanged:
       
   473                 {
       
   474                 DoNodeSiblingOrderChangedL();
       
   475                 break;
       
   476                 }
       
   477             case EAlfNodeFlagChanged:
       
   478                 {
       
   479                 DoNodeFlagChangedL();
       
   480                 break;
       
   481                 }
       
   482             case EAlfNodeFadeCountChanged:
       
   483                 {
       
   484                 DoNodeFadeCountChangedL();
       
   485                 break;
       
   486                 }                
       
   487             case EAlfNodeFadeAllChildren:
       
   488                 {
       
   489                 DoNodeFadeAllChildrenL();
       
   490                 break;
       
   491                 }                
       
   492             case EAlfNodeTransparentRegionChanged:
       
   493                 {
       
   494                 DoNodeTransparentRegionChangedL();
       
   495                 break;
       
   496                 }
       
   497             case EAlfNodeLayerAdded:
       
   498                 {
       
   499                 DoNodeLayerAddedL();
       
   500                 break;
       
   501                 }
       
   502             case EAlfNodeLayerExtentChanged:
       
   503                  {
       
   504                  DoNodeLayerExtentChangedL();
       
   505                  break;
       
   506                  }               
       
   507             case EAlfNodeLayerUsesAlphaFlagChanged:
       
   508                  {
       
   509                  DoNodeLayerUsesAlphaFlagChangedL();
       
   510                  break;
       
   511                  }               
       
   512             case EAlfNodeMovedToWindowGroup:
       
   513                 {
       
   514                 DoNodeMovedToWindowGroupL();
       
   515                 break;
       
   516                 }
       
   517             case EAlfNodeWindowGroupChained:
       
   518                 {
       
   519                 DoNodeWindowGroupChainedL();
       
   520                 break;
       
   521                 }
       
   522             case EAlfNodeWindowGroupChainBrokenAfter:
       
   523                 {
       
   524                 DoNodeWindowGroupChainBrokenAfterL();
       
   525                 break;
       
   526                 }
       
   527             case EAlfWrap:
       
   528                 {
       
   529                 ReadEndMarkerL(); // futile, but just in case somet
       
   530                 iStream->Source()->SeekL( MStreamBuf::ERead, TStreamPos(0));
       
   531                 iChunkHeader->iReadOffset = 0;
       
   532                 break;
       
   533                 }
       
   534             case EAlfNodeAttributeChanged: // currently only textcursor may receive these events
       
   535                 {
       
   536                 DoNodeAttributeChangedL();
       
   537                 break;
       
   538                 }
       
   539             case EAlfCommitBatch:
       
   540                 {
       
   541                 RequestFrameEndCallback();
       
   542                 break;
       
   543                 }
       
   544 #ifdef ALF_DEBUG_TRACK_DRAWING              
       
   545             case EAlfDebugTrackNode:
       
   546                 {
       
   547                 DoNodeDebugTrackL();
       
   548                 break;
       
   549                 }
       
   550 #endif                
       
   551             case EAlfDestroyChunk:
       
   552                 { 
       
   553                 TInt chunkId = iStream->ReadInt32L();
       
   554                 iServer.Bridge()->AddData( EAlfReleaseTemporaryChunk, chunkId );
       
   555                 break;
       
   556                 }
       
   557             case EAlfJumpToAnotherChunk:
       
   558                 {
       
   559                 RequestPacketEndCallback( offset );
       
   560                 TInt32 readChunkId = iStream->ReadInt32L();
       
   561                 TInt size = iStream->ReadInt32L();
       
   562                 ReadEndMarkerL();
       
   563                 // __ALFLOGSTRING1("Next chunk: %d, size: %d, previous chunk: %d"), readChunkId, size, iChunkInUse );
       
   564        
       
   565                 if ( readChunkId == 0 )
       
   566                     {
       
   567                     iChunkHeader  = reinterpret_cast<TChunkHeader*>(iChunk.Base());
       
   568                     iStream->Close();
       
   569                     iStream->Open( iChunk.Base() + sizeof( TChunkHeader), KChunkMaxSize );
       
   570                     iStream->Source()->SeekL( MStreamBuf::ERead, TStreamPos(0)); 
       
   571                     }
       
   572                 else
       
   573                     {
       
   574                     iStream->Close();
       
   575                     iStream->Open( iCacheChunks.Find( readChunkId )->Base() + sizeof( TChunkHeader), size );
       
   576                     iChunkHeader  = reinterpret_cast<TChunkHeader*>(iCacheChunks.Find( readChunkId )->Base());
       
   577                     }
       
   578                 iChunkInUse = readChunkId;
       
   579                 
       
   580                 break;
       
   581                 }
       
   582             default:
       
   583                 {
       
   584                 __ALFLOGSTRING("CAlfHierarchyModel::ExecuteCommandsL, off track");
       
   585 #ifdef _ALF_LOGGING
       
   586                 __ALFLOGSTRING3("CAlfHierarchyModel::ExecuteCommandsL, off track - Cmd: %d, Previous Cmd: %d, Count: %d..", command, previousCommand, commandCount );
       
   587 #endif                
       
   588                 __ALFLOGSTRING1("..CAlfHierarchyModel::ExecuteCommandsL, unrecoverable error : HALTING at offset: %d", offset );
       
   589                 USER_INVARIANT();  
       
   590                 break;
       
   591                 }
       
   592             }
       
   593         ReadEndMarkerL();
       
   594         offset = iStream->Source()->TellL( MStreamBuf::ERead ).Offset();
       
   595         RequestPacketEndCallback( offset );
       
   596         //__ALFLOGSTRING1("end offset %d  offset %d, command %d"), aEndOffset, offset, command );
       
   597         };
       
   598     iFrame++;
       
   599     }
       
   600 
       
   601 // ---------------------------------------------------------------------------
       
   602 // BridgerCallback
       
   603 // This is called by CAlfStreamBridge when EAlfCommitBatch is processed.
       
   604 //
       
   605 // Note: This call comes from another thread, Alf server thread. Beware that
       
   606 //       Alf streamer/decoder server thread might access the class data
       
   607 //       concurrently!
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 void CAlfHierarchyModel::BridgerCallback( TInt aOp, TInt aInt )
       
   611     {
       
   612     // hackish, just do the panic release for window server
       
   613     // Trying to mimize changes on existing logic
       
   614     if (aOp == KRELEASEWINDOWSERVER)
       
   615         {
       
   616         __ALFLOGSTRING1("CAlfHierarchyModel::BridgerCallback, iMessage is null: %d", iMessage.IsNull());
       
   617 
       
   618         if (!iMessage.IsNull()) 
       
   619             {
       
   620             __ALFLOGSTRING("CAlfHierarchyModel::BridgerCallback, emergency releasing of window server");
       
   621             iMessage.Complete(EAlfBridgerAsyncronousData);
       
   622             iDidForcedComplete = ETrue;
       
   623             }
       
   624         else if (aInt == KRELEASEDBEFOREQUEUE)
       
   625             {
       
   626             iBatchAlreadyCommited = ETrue;   
       
   627             }    
       
   628                   
       
   629         return;
       
   630         }        
       
   631         
       
   632     switch( aOp )
       
   633         {
       
   634         case EAlfDSGetAlfNativeWindowData:
       
   635             {                        
       
   636     		iSema.Wait();
       
   637     		// Complete the pending message
       
   638             RMessage2* rsMessage = (RMessage2*)aInt;
       
   639     		for (TInt i = 0; i < iPendingAlfWindowDataMessages.Count(); i++)
       
   640     			{
       
   641     			if (&(iPendingAlfWindowDataMessages[i]) == rsMessage)
       
   642     				{
       
   643     				// Complete the message to RS
       
   644     				rsMessage->Complete(KErrNone);
       
   645     				iPendingAlfWindowDataMessages.Remove(i);
       
   646     				break;
       
   647     				}
       
   648     			}
       
   649 		    iSema.Signal();
       
   650             break;
       
   651             }    
       
   652 
       
   653         case EAlfRequestCommandReadNotification:
       
   654             {
       
   655     		if (iChunkHeader)
       
   656     			{
       
   657     			iChunkHeader->iReadOffset = aInt; // last read offset
       
   658     			}
       
   659                     
       
   660             // TODO: If you can absolute guaranteen to count the available space correctly, then this can also complete iSpaceNotificationMessage
       
   661             break;
       
   662             }
       
   663         case EAlfRequestCommitBatch:
       
   664             {
       
   665             __ALFLOGSTRING1("CAlfHierarchyModel::BridgerCallback, iMessage.IsNull %d", iMessage.IsNull());
       
   666             if ( iMessage.IsNull())
       
   667                 {
       
   668                 if (!iDidForcedComplete)
       
   669                     {
       
   670                     __ALFLOGSTRING("request for this message has not arrived. complete on arrival");
       
   671                     iBatchAlreadyCommited = ETrue;
       
   672                     }
       
   673                 }
       
   674             else
       
   675                 {
       
   676                 iBatchAlreadyCommited = EFalse;
       
   677                 iMessage.Complete(EAlfBridgerAsyncronousData);
       
   678                 }
       
   679             iDidForcedComplete = EFalse;
       
   680             break;
       
   681             }
       
   682         case EAlfReleaseTemporaryChunk:
       
   683             {
       
   684             CloseChunk( aInt );
       
   685             break;
       
   686             }
       
   687         default:
       
   688             {
       
   689             USER_INVARIANT();                
       
   690             }    
       
   691         }
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------------------------
       
   695 // DoNodeCreatedL
       
   696 // ---------------------------------------------------------------------------
       
   697 //
       
   698 void CAlfHierarchyModel::DoNodeCreatedL()
       
   699     {
       
   700 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
   701     TBool trackThisNode(EFalse);
       
   702 #endif
       
   703     CAlfNode* node = NULL;    
       
   704     // Nodes add themself to iNodeStructArray, which "owns" the nodes. Nodes are created and destroyed only if requested by the Wserv
       
   705     MWsWindowTreeNode::TType nodeType = (MWsWindowTreeNode::TType)iStream->ReadInt32L();
       
   706     switch (nodeType)
       
   707         {
       
   708         case MWsWindowTreeNode::EWinTreeNodeClient:
       
   709             {
       
   710             node = CAlfNodeWindow::NewL( this, iStream, iScreenNumber );
       
   711             break;
       
   712             }
       
   713         case MWsWindowTreeNode::EWinTreeNodeRoot:
       
   714             {
       
   715             node = CAlfNodeRoot::NewL( this ,iStream, iScreenNumber );
       
   716             iRootNode = (CAlfNodeRoot*)node;
       
   717             break;
       
   718             }
       
   719         case MWsWindowTreeNode::EWinTreeNodeGroup:
       
   720             {
       
   721             node = CAlfNodeGroup::NewL( this, iStream, iScreenNumber );
       
   722             break;
       
   723             }
       
   724         case MWsWindowTreeNode::EWinTreeNodeAnim:
       
   725             {
       
   726             node = CAlfNodeAnim::NewL(this, iStream, iScreenNumber );
       
   727             break;
       
   728             }
       
   729         case MWsWindowTreeNode::EWinTreeNodeSprite:
       
   730             {
       
   731             node = CAlfNodeSprite::NewL( this, iStream, iScreenNumber );
       
   732             break;
       
   733             }
       
   734         case MWsWindowTreeNode::EWinTreeNodeStandardTextCursor:
       
   735             {
       
   736             node = CAlfNodeTextCursor::NewL( this, iStream, iScreenNumber );
       
   737             break;
       
   738             }
       
   739         default:
       
   740             {
       
   741             __ALFLOGSTRING1("CAlfHierarchyModel::DoNodeCreatedL, unknown node type: %i", nodeType);
       
   742             break;
       
   743             }
       
   744         }
       
   745     // Note to Debuggers
       
   746     // You can track certain type of nodes and their draw buffers by changing the trackThisNode value to 1. 
       
   747     // Then enable breakpoints in 
       
   748     // some places marked in code using the ALF_DEBUG_TRACK_DRAWING and HUI_DEBUG_TRACK_DRAWING . The macro 
       
   749     // must be enabled in 
       
   750     //   alfappservercore.mmp 
       
   751     //   coretoolkit.mmp and
       
   752     //   alfrenderstageplugin.mmp
       
   753     
       
   754 #ifdef ALF_DEBUG_TRACK_DRAWING 
       
   755     if ( trackThisNode )
       
   756         {
       
   757         node->SetTracking( trackThisNode );
       
   758         }
       
   759 #endif
       
   760     
       
   761 #ifdef ALF_DEBUG_PRINT_NODE_INFO    
       
   762     if ( node )
       
   763         {
       
   764         RDebug::Print(_L("DoNodeCreatedL"));
       
   765         iRootNode->iLogging = 1;
       
   766         CAlfNode::PrintNodeTree(iRootNode, node->iId);
       
   767         iRootNode->iLogging = 0;
       
   768         //CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText) , iSearchNode);
       
   769         }
       
   770 #endif
       
   771     }
       
   772 
       
   773 // ---------------------------------------------------------------------------
       
   774 // DoNodeReleasedL
       
   775 // ---------------------------------------------------------------------------
       
   776 //
       
   777 void CAlfHierarchyModel::DoNodeReleasedL()
       
   778     {
       
   779     MWsWindowTreeNode::TType nodeType = (MWsWindowTreeNode::TType)iStream->ReadInt32L();
       
   780     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   781     CAlfNode* node = FindNode( nodeId );
       
   782 
       
   783 #ifdef ALF_DEBUG_PRINT_NODE_INFO    
       
   784     if ( node )
       
   785         {
       
   786         //_LIT(KText,"DoNodeReleasedL");
       
   787         CAlfNode::PrintNodeTree(iRootNode, node->iId);
       
   788                 
       
   789 //        CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText) , iSearchNode);
       
   790         }
       
   791 #endif    
       
   792     if ( node )
       
   793         {
       
   794         delete node;
       
   795         }
       
   796     else
       
   797         {
       
   798         USER_INVARIANT();
       
   799         }
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------------------------
       
   803 // DoNodeActivatedL
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 void CAlfHierarchyModel::DoNodeActivatedL()
       
   807     {
       
   808     TInt nodeType = iStream->ReadInt32L();
       
   809     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   810     CAlfNode* node = FindNode( nodeId );
       
   811     if ( node )
       
   812         {
       
   813         node->ActivateNode();
       
   814         }
       
   815     else
       
   816         {
       
   817         USER_INVARIANT();
       
   818         }
       
   819     }
       
   820 
       
   821 // ---------------------------------------------------------------------------
       
   822 // DoNodeExtentChangedL
       
   823 // ---------------------------------------------------------------------------
       
   824 //
       
   825 void CAlfHierarchyModel::DoNodeExtentChangedL()
       
   826     {
       
   827     TRect rect;
       
   828     ReadRectL( rect, iStream);
       
   829     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   830 
       
   831     CAlfNodeVisual* node = (CAlfNodeVisual*)FindNode( nodeId );
       
   832     if ( node )
       
   833        {
       
   834        node->SetExtent( rect );
       
   835        }
       
   836     else
       
   837         {
       
   838         USER_INVARIANT();
       
   839         }
       
   840 #ifdef ALF_DEBUG_PRINT_NODE_INFO    
       
   841     if ( node )
       
   842         {
       
   843         RDebug::Print(_L("Extent changed"));
       
   844         CAlfNode::PrintNodeTree(iRootNode, node->iId);
       
   845         //CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText), iSearchNode);
       
   846         }
       
   847 #endif
       
   848 
       
   849     }
       
   850 
       
   851 // ---------------------------------------------------------------------------
       
   852 // DoNodeSiblingOrderChangedL
       
   853 // ---------------------------------------------------------------------------
       
   854 //
       
   855 void CAlfHierarchyModel::DoNodeSiblingOrderChangedL()
       
   856     {
       
   857     TInt newPos = iStream->ReadInt32L();
       
   858     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   859 
       
   860     CAlfNode* node = FindNode( nodeId );
       
   861     if ( node )
       
   862         {
       
   863         node->SiblingOrderChanged( newPos );
       
   864         }
       
   865     else
       
   866         {
       
   867 #ifdef _DEBUG
       
   868         RDebug::Print( _L("Missing a node %d"), nodeId );
       
   869 #endif
       
   870         // USER_INVARIANT();
       
   871         }
       
   872     
       
   873 #ifdef ALF_DEBUG_PRINT_NODE_INFO    
       
   874     if ( node )
       
   875         {
       
   876         RDebug::Print(_L("Sibling order changed"));
       
   877         CAlfNode::PrintNodeTree(iRootNode, node->iId);
       
   878                 
       
   879         // CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText), iSearchNode );
       
   880         }
       
   881 #endif
       
   882     }
       
   883 
       
   884 // ---------------------------------------------------------------------------
       
   885 // DoNodeFlagChangedL
       
   886 // ---------------------------------------------------------------------------
       
   887 //
       
   888 void CAlfHierarchyModel::DoNodeFlagChangedL()
       
   889     {
       
   890     MWsWindowTreeObserver::TFlags flag = (MWsWindowTreeObserver::TFlags)iStream->ReadUint32L();
       
   891     TBool newValue = (TBool)iStream->ReadInt32L();
       
   892     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   893 
       
   894     CAlfNode* node = FindNode( nodeId );
       
   895     if ( node )
       
   896         {
       
   897         node->FlagChanged( flag, newValue );
       
   898         
       
   899         }
       
   900     else
       
   901         {
       
   902         USER_INVARIANT();
       
   903         }
       
   904     }
       
   905 
       
   906 // ---------------------------------------------------------------------------
       
   907 // DoNodeFadeAllChildrenL
       
   908 // ---------------------------------------------------------------------------
       
   909 //
       
   910 void CAlfHierarchyModel::DoNodeFadeAllChildrenL()
       
   911     {
       
   912     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   913     TBool faded = (TBool)iStream->ReadInt32L();    
       
   914 
       
   915     CAlfNode* node = FindNode( nodeId );
       
   916     if ( node )
       
   917         {
       
   918         node->FadeAllChildren( faded );
       
   919         }
       
   920     else
       
   921         {
       
   922         USER_INVARIANT();
       
   923         }
       
   924     }
       
   925 
       
   926 // ---------------------------------------------------------------------------
       
   927 // DoNodeFadeCountChangedL
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 void CAlfHierarchyModel::DoNodeFadeCountChangedL()
       
   931     {
       
   932     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   933     TInt fadeCount = (TInt)iStream->ReadUint32L();
       
   934 
       
   935     CAlfNode* node = FindNode( nodeId );
       
   936     if ( node )
       
   937         {
       
   938         node->FadeCountChanged( fadeCount );
       
   939         }
       
   940     else
       
   941         {
       
   942         USER_INVARIANT();
       
   943         }
       
   944     }
       
   945 
       
   946 // ---------------------------------------------------------------------------
       
   947 // DoNodeTransparentRegionChangedL
       
   948 // ---------------------------------------------------------------------------
       
   949 //
       
   950 void CAlfHierarchyModel::DoNodeTransparentRegionChangedL()
       
   951     {
       
   952     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   953     iStream->ReadInt8L();
       
   954     RRegion newTransparentRegion;
       
   955     RRegion newOpaqueRegion;
       
   956     ReadRegionL( iStream, newTransparentRegion );
       
   957     iStream->ReadInt8L();
       
   958     ReadRegionL( iStream, newOpaqueRegion );
       
   959     // TODO: Implement actions
       
   960     }
       
   961 
       
   962 // ---------------------------------------------------------------------------
       
   963 // DoNodeLayerAddedL
       
   964 // ---------------------------------------------------------------------------
       
   965 //
       
   966 void CAlfHierarchyModel::DoNodeLayerAddedL()
       
   967     {
       
   968     DoNodeLayerExtentChangedL();
       
   969     }
       
   970 
       
   971 // ---------------------------------------------------------------------------
       
   972 // DoNodeLayerExtentChangedL
       
   973 // ---------------------------------------------------------------------------
       
   974 //
       
   975 void CAlfHierarchyModel::DoNodeLayerExtentChangedL()
       
   976     {   
       
   977     // Set composition surface extent 
       
   978     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
   979     TRect extent = TRect(0,0,0,0);
       
   980     ReadRectL(extent, iStream); 
       
   981     CAlfNodeVisual* node = (CAlfNodeVisual*)FindNode( nodeId );
       
   982     if ( node && node->Window() )
       
   983         {
       
   984         // SetSurfaceExtent is not supported for image visual
       
   985         node->Window()->SetSurfaceExtent( extent );
       
   986         }
       
   987     else if( node ) // this would mean that node has being orphaneded but not yet deleted
       
   988         {
       
   989         __ALFLOGSTRING1("CAlfHierarchyModel::DoNodeLayerExtentChangedL node found but window %d was destroyed", nodeId);
       
   990         }
       
   991     }
       
   992 
       
   993 // ---------------------------------------------------------------------------
       
   994 // DoNodeLayerUsesAlphaFlagChangedL
       
   995 // ---------------------------------------------------------------------------
       
   996 //
       
   997 void CAlfHierarchyModel::DoNodeLayerUsesAlphaFlagChangedL()
       
   998     {   
       
   999     // Set composition surface extent 
       
  1000     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
  1001     TBool enabled = (TBool)iStream->ReadInt32L();
       
  1002     CAlfNodeVisual* node = (CAlfNodeVisual*)FindNode( nodeId );
       
  1003     if ( node && node->Window() )
       
  1004         {
       
  1005         // SetLayerUsesAplhaFlag is not supported for image visual
       
  1006         node->Window()->SetLayerUsesAplhaFlag( enabled );
       
  1007         }
       
  1008     else if( node ) // this would mean that node has being orphaneded but not yet deleted
       
  1009         {
       
  1010         __ALFLOGSTRING1("CAlfHierarchyModel::DoNodeLayerUsesAlphaFlagChangedL node found but window %d was destroyed", nodeId);
       
  1011         }
       
  1012     }
       
  1013 
       
  1014 
       
  1015 // ---------------------------------------------------------------------------
       
  1016 // DoNodeMovedToWindowGroupL
       
  1017 // ---------------------------------------------------------------------------
       
  1018 //
       
  1019 void CAlfHierarchyModel::DoNodeMovedToWindowGroupL()
       
  1020     {
       
  1021     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
  1022     TUint32 newWindowgroupNode = (TUint32)iStream->ReadUint32L();
       
  1023     CAlfNodeWindow* node = (CAlfNodeWindow*)FindNode( nodeId );
       
  1024     if ( node )
       
  1025         {
       
  1026         node->MoveToWindowGroup( newWindowgroupNode );
       
  1027 		} 
       
  1028     }
       
  1029 
       
  1030 // ---------------------------------------------------------------------------
       
  1031 // DoNodeWindowGroupChainedL
       
  1032 // ---------------------------------------------------------------------------
       
  1033 //
       
  1034 void CAlfHierarchyModel::DoNodeWindowGroupChainedL()
       
  1035     {
       
  1036     TUint32 parentNode = (TUint32)iStream->ReadUint32L();
       
  1037     TUint32 childNode = (TUint32)iStream->ReadUint32L();
       
  1038     CAlfNodeGroup* node = (CAlfNodeGroup*)FindNode( parentNode );
       
  1039     if ( node )
       
  1040     	{
       
  1041     	node->WindowGroupChained( childNode );
       
  1042     	}
       
  1043     }
       
  1044 
       
  1045 // ---------------------------------------------------------------------------
       
  1046 // DoNodeWindowGroupChainBrokenAfterL
       
  1047 // ---------------------------------------------------------------------------
       
  1048 //
       
  1049 void CAlfHierarchyModel::DoNodeWindowGroupChainBrokenAfterL()
       
  1050     {
       
  1051     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
  1052     CAlfNodeGroup* node = (CAlfNodeGroup*)FindNode( nodeId );
       
  1053     if ( node )
       
  1054     	{
       
  1055     	node->GroupChainBrokenAfter();
       
  1056     	}
       
  1057     }
       
  1058 
       
  1059 // ---------------------------------------------------------------------------
       
  1060 // DoNodeAttributeChangedL
       
  1061 // ---------------------------------------------------------------------------
       
  1062 //
       
  1063 void CAlfHierarchyModel::DoNodeAttributeChangedL()
       
  1064     {
       
  1065     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
  1066     CAlfNodeTextCursor* node = (CAlfNodeTextCursor*)FindNode( nodeId);
       
  1067     if ( node && node->Type() == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor )
       
  1068         {
       
  1069         node->AttributeChangedL( iStream );
       
  1070 
       
  1071 #ifdef ALF_DEBUG_PRINT_NODE_INFO    
       
  1072     if ( node )
       
  1073         {
       
  1074         //_LIT(KText,"Attribute changed");
       
  1075         //CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText) , iSearchNode);
       
  1076         //CAlfNode::PrintNodeTree(iRootNode, KText, node->iId);
       
  1077                 
       
  1078         }
       
  1079 #endif  
       
  1080         }
       
  1081     else
       
  1082         {
       
  1083         USER_INVARIANT(); // attribute change for unexpected node type. new code needed!
       
  1084         }
       
  1085     }
       
  1086 // ---------------------------------------------------------------------------
       
  1087 // DoNodeWindowGroupChainBrokenAfterL
       
  1088 // ---------------------------------------------------------------------------
       
  1089 //
       
  1090 #ifdef ALF_DEBUG_TRACK_DRAWING
       
  1091 void CAlfHierarchyModel::DoNodeDebugTrackL()
       
  1092     {
       
  1093     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
       
  1094     TBool trackingValue = iStream->ReadUint32L();
       
  1095     CAlfNodeGroup* node = (CAlfNodeGroup*)FindNode( nodeId );
       
  1096     if ( node )
       
  1097         {
       
  1098         node->SetTracking( trackingValue );
       
  1099         }
       
  1100     }
       
  1101 #endif
       
  1102 // ---------------------------------------------------------------------------
       
  1103 // FindNode
       
  1104 // ---------------------------------------------------------------------------
       
  1105 //
       
  1106 CAlfNode* CAlfHierarchyModel::FindNode( TUint32 aWindowId )
       
  1107     {
       
  1108     if ( iPreviouslySearchedNode && iPreviouslySearchedNode->iId == aWindowId )
       
  1109         {
       
  1110         return iPreviouslySearchedNode;
       
  1111         }
       
  1112     CNodeHashStruct* nodeHashStruct = iNodeHashArray.Find( aWindowId );
       
  1113     if (nodeHashStruct)
       
  1114         {
       
  1115         iPreviouslySearchedNode = nodeHashStruct->iNode;
       
  1116         return iPreviouslySearchedNode;
       
  1117         }
       
  1118     return NULL;
       
  1119     }
       
  1120 
       
  1121 // ---------------------------------------------------------------------------
       
  1122 // InsertNode
       
  1123 // ---------------------------------------------------------------------------
       
  1124 //
       
  1125 TInt CAlfHierarchyModel::InsertNode( TUint32 aWindowId, CAlfNode* aNode  )
       
  1126     {
       
  1127     return iNodeHashArray.Insert( aWindowId, CNodeHashStruct( aNode ));
       
  1128     }
       
  1129 
       
  1130 // ---------------------------------------------------------------------------
       
  1131 // RemoveNode
       
  1132 // ---------------------------------------------------------------------------
       
  1133 //
       
  1134 TBool CAlfHierarchyModel::RemoveNode( TUint32 aWindowId )
       
  1135 	{
       
  1136 	iPreviouslySearchedNode = NULL;
       
  1137 	return iNodeHashArray.Remove( aWindowId );
       
  1138 	}
       
  1139 
       
  1140 // ---------------------------------------------------------------------------
       
  1141 // RemoveAllNodes
       
  1142 // ---------------------------------------------------------------------------
       
  1143 //
       
  1144 void CAlfHierarchyModel::RemoveAllNodes( )
       
  1145     {
       
  1146     // TODO: Is this useless? wserv will remove its nodes anyway, if screen is destroyed
       
  1147     }
       
  1148 
       
  1149 // ---------------------------------------------------------------------------
       
  1150 // ProcessUnknownNodeDrawingL
       
  1151 // ---------------------------------------------------------------------------
       
  1152 //
       
  1153 void CAlfHierarchyModel::ProcessUnknownNodeDrawingL( RMemReadStream& aStream )
       
  1154     {
       
  1155     TInt32 chunkInUse = aStream.ReadInt32L();
       
  1156     TInt nextFramePos = aStream.ReadInt32L();
       
  1157        
       
  1158     // jump to the next frame
       
  1159     if ( nextFramePos == KFrameOffsetTemplate )
       
  1160         {
       
  1161         __ALFLOGSTRING("CAlfHierarchyModel::PostBufferL, Address of the frame has not been initialized!");
       
  1162         } 
       
  1163     TUint8 padding = aStream.ReadInt8L();
       
  1164     aStream.ReadInt8L();
       
  1165     while( padding--)
       
  1166         {
       
  1167         aStream.ReadInt8L();
       
  1168         }
       
  1169     TInt currentPos = aStream.Source()->TellL( MStreamBuf::ERead ).Offset();
       
  1170     aStream.Source()->SeekL( MStreamBuf::ERead, TStreamPos(nextFramePos));
       
  1171     TSgcCanvasCommands packetState = (TSgcCanvasCommands)aStream.ReadInt8L();
       
  1172     switch( packetState )
       
  1173         {
       
  1174         case EAlfPacketReady: // fall through
       
  1175         case EAlfPacketNotReady:
       
  1176         default:
       
  1177             {
       
  1178             __ALFLOGSTRING1("CAlfHierarchyModel::PostBufferL endMarker: %d ", packetState);
       
  1179             break;
       
  1180             }
       
  1181         }
       
  1182     }
       
  1183     
       
  1184