uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp
branchRCL_3
changeset 51 e5af45d51884
parent 50 1801340c26a2
child 52 31fccae4f8a7
--- a/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Thu Aug 19 10:48:02 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Tue Aug 31 16:07:35 2010 +0300
@@ -33,11 +33,6 @@
 #else
     #include "alflogger.h"
 #endif
-
-#ifdef ALF_MEMORYLOGGING
-#include <hal.h>
-#endif
-
 // ---------------------------------------------------------------------------
 // Constructor
 // ---------------------------------------------------------------------------
@@ -47,30 +42,6 @@
     {
     }
 
-
-void CAlfNode::ReportOOM()
-    {
-#ifdef ALF_MEMORYLOGGING
-    RDebug::Printf("CAlfNode::ReportOOM");
-
-    TInt totalSpaceAllocated = 0;
-    TInt cellsAllocatedInHeap = User::AllocSize(totalSpaceAllocated);
-    TInt largestFreeBlock = 0;
-    TInt totalFreeSpaceInHeap = User::Available(largestFreeBlock);
-    TInt freeRAM = 0;
-    if ( HAL::Get( HALData::EMemoryRAMFree, freeRAM ) != KErrNone )
-        {
-        freeRAM = -1;
-        }
-        
-    RDebug::Printf("CAlfNode::ReportOOM - Allocated space: %d, Amount of allocated cells: %d, Largest free block: %d, Free space in heap: %d",
-            totalSpaceAllocated,
-            cellsAllocatedInHeap,
-            largestFreeBlock,
-            totalFreeSpaceInHeap);
-    RDebug::Printf("CAlfNode::ReportOOM - Free RAM in system: %d", freeRAM);
-#endif
-    }
 // ---------------------------------------------------------------------------
 // ConstructL
 // ---------------------------------------------------------------------------
@@ -394,60 +365,61 @@
 // ---------------------------------------------------------------------------
 //
 
+// ---------------------------------------------------------------------------
+// CAlfNode::TraverseNodeTree
+// Traverse through node tree and fill node array 
+// ---------------------------------------------------------------------------
+//
+
 void CAlfNode::TraverseNodeTree( CAlfNode* node,  RPointerArray<CAlfNode>& nodes, TBool aTraverseOnlySiblings, TBool aAddMe)
     {
     // Exit if we've already finished walking the tree.
     if ( node == NULL) 
         { 
-        __ALFLOGSTRING("TraverseNodeTree returning - NULL");                                  
+        __ALFLOGSTRING(" returning NULL");                                  
         return;
         }
-    
-    while ( node )
+    if (!aTraverseOnlySiblings)
         {
-        if (!aTraverseOnlySiblings)
-            {   
-            if ( node->iSpriteChild ) 
-                {
-                CAlfNode* spritenode = node->iSpriteChild ;
-                while ( spritenode )
-                    {
-                    nodes.Append( spritenode );                
-                    spritenode = spritenode->iSibling;
-                    }
-                }
-    
-            if( node->iTextCursor )
-                {
-                nodes.Append(node->iTextCursor );            
-                }
-    
-            if( node->iAnimChild )
+        if ( node->iSpriteChild ) 
+            {
+        CAlfNode* spritenode = node->iSpriteChild ;
+            while ( spritenode )
                 {
-                CAlfNode* animnode = node->iAnimChild ;
-                while ( animnode )
-                    {
-                    nodes.Append( animnode );                
-                    animnode = animnode->iSibling;
-                    }
-                }
-        
-            if ( node->iChild)
-                {                
-                TraverseNodeTree(node->iChild , nodes, EFalse, ETrue);            
+                nodes.Append( spritenode );                
+                spritenode = spritenode->iSibling;
                 }
-            } 
-
-        if (aAddMe)
+            }
+    
+        if( node->iTextCursor )
             {
-            nodes.Append( node );
+            nodes.Append(node->iTextCursor );            
+            }
+    
+        if( node->iAnimChild )
+            {
+            CAlfNode* animnode = node->iAnimChild ;
+            while ( animnode )
+                {
+                nodes.Append( animnode );                
+                animnode = animnode->iSibling;
+                }
             }
+        
+        if ( node->iChild)
+            {                
+            TraverseNodeTree(node->iChild , nodes, EFalse, ETrue);            
+            }
+        } 
 
-        // Without recursion, continue with the following:
-        // TraverseNodeTree(node->iSibling, nodes, ETrue, ETrue);
-        node = node->iSibling;
-        aTraverseOnlySiblings = ETrue;
-        aAddMe = ETrue;
+    if (aAddMe)
+        {
+        nodes.Append( node );
+        }
+
+    if ( node->iSibling )
+        {                
+        TraverseNodeTree(node->iSibling, nodes, ETrue, ETrue);               
         }
     }
 
@@ -1018,14 +990,7 @@
     {
     TAny* attributes = NULL;
     TRAP_IGNORE(attributes = (TAny*)iModel->Server().Bridge()->AppendVarDataL( aSize, aIndex ))
-    if (attributes)
-        {
-        Mem::FillZ( (TUint8*)attributes, aSize ); // Initialize the returned memory area to 0
-        }
-    else
-        {
-        CAlfNode::ReportOOM();
-        }
+    Mem::FillZ( (TUint8*)attributes, aSize ); // Initialize the returned memory area to 0
     return attributes;
     }
 
@@ -1342,21 +1307,14 @@
             // position must be updated, because it not necessary the first drawn.
             TInt offset;
             TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
-            if (windowAttributes)
-                {
-                windowAttributes->iOrdinalPosition = ordinal; 
-                windowAttributes->iWindowNodeType = iType;
-                windowAttributes->iScreenNumber = iScreenNumber;
-                // for updating window group ordinals
-                iModel->Server().Bridge()->AddData( EAlfDSReorder, 
-                        iGroupId, 
-                        iId, 
-                        (TAny*)offset );
-                }
-			else
-				{
-		        CAlfNode::ReportOOM();
-				}
+            windowAttributes->iOrdinalPosition = ordinal; 
+            windowAttributes->iWindowNodeType = iType;
+            windowAttributes->iScreenNumber = iScreenNumber;
+            // for updating window group ordinals
+            iModel->Server().Bridge()->AddData( EAlfDSReorder, 
+                    iGroupId, 
+                    iId, 
+                    (TAny*)offset );
             }
         }
     AMT_MAP_NODE_SET_ORDINAL_POSITION();
@@ -1426,10 +1384,8 @@
         {
         nodeFlags |= EAlfWinNodeFlagOpaque;         
         }
-    
-	// New drawing commands always replace all the previous drawing commands for text cursor and anim nodes.
-    if (   iType == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor 
-        || iType == MWsWindowTreeNode:: EWinTreeNodeAnim )
+        
+    if ( iType == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor )
         {
         emptyBuffer = ETrue;
         }
@@ -1554,13 +1510,6 @@
                 }
             break;
             }
-        case MWsWindowTreeObserver::EScreenDeviceValid:
-            {
-            iWindow->SetScreenDeviceValid(aNewValue);
-            break;
-            }
-        default:
-            break;
         }
     if ( aFlag == MWsWindowTreeObserver::ENonFading && HasChildren() )
         {
@@ -1953,24 +1902,17 @@
     
     TInt offset;
     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
-    if (windowAttributes)
-        {
-        windowAttributes->iWindowNodeType = iType; 
-        windowAttributes->iClientHandle = clientHandle;
-        windowAttributes->iScreenNumber = iScreenNumber;
-        windowAttributes->iSecureId = iSecureId;
-        windowAttributes->iParentNodeId = parentId;
-        
-        iModel->Server().Bridge()->AddData( EAlfDSNewWindow, 
-                iGroupId, 
-                iId, 
-                (TAny*)offset );
-        }
-    else
-        {
-        CAlfNode::ReportOOM();
-        }
-        
+    windowAttributes->iWindowNodeType = iType; 
+    windowAttributes->iClientHandle = clientHandle;
+    windowAttributes->iScreenNumber = iScreenNumber;
+    windowAttributes->iSecureId = iSecureId;
+    windowAttributes->iParentNodeId = parentId;
+	
+    iModel->Server().Bridge()->AddData( EAlfDSNewWindow, 
+            iGroupId, 
+            iId, 
+            (TAny*)offset );
+    
     AMT_MAP_STREAMER_NODE_GROUP_CONSTRUCT();
 	}
 
@@ -2007,8 +1949,8 @@
     if (iModel)
         {
         iModel->Server().Bridge()->AddData( EAlfDSGroupChained, 
-                iGroupId, 
-                iChainedTo->iGroupId, 
+                iId, 
+                aChainedGroup, 
                 (TAny*)iScreenNumber
                 );                
         }
@@ -2020,18 +1962,16 @@
 //
 void CAlfNodeGroup::GroupChainBrokenAfter(  )
 	{
-    TUint32 oldChainedTo = 0; 
 	if ( iChainedTo )
 		{
 		iChainedTo->iChainedFrom = NULL;
-		oldChainedTo = iChainedTo->iId;
 		iChainedTo = NULL;
 		}
 	if (iModel)
 		{
 		iModel->Server().Bridge()->AddData( EAlfDSGroupChainBroken, 
-		        oldChainedTo, 
 				iId, 
+				0, 
 				(TAny*)iScreenNumber );                
 		}
 
@@ -2050,33 +1990,20 @@
     	}
     if ( iChainedFrom )
     	{
-        if (iModel)
-            {
-            iModel->Server().Bridge()->AddData( EAlfDSGroupChainBroken, 
-                    iChainedFrom->iId, 
-                    iId, 
-                    (TAny*)iScreenNumber );                
-            }
+    	iChainedFrom->iChainedTo = NULL;
     	}
     
     if (iModel)
         {
         TInt offset;
         TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes));
-        if (windowAttributes)
-            {
-            windowAttributes->iWindowNodeType = iType; 
-            windowAttributes->iScreenNumber = iScreenNumber; 
-    
-            iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
-                    iGroupId, 
-                    iId, 
-                    (TAny*)offset );
-            }
-		else
-			{
-			CAlfNode::ReportOOM();
-			}
+        windowAttributes->iWindowNodeType = iType; 
+        windowAttributes->iScreenNumber = iScreenNumber; 
+
+        iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
+                iGroupId, 
+                iId, 
+                (TAny*)offset );
         iWindow = 0; // just in case
         }
     RemoveDependencies( iParent->iChild );
@@ -2209,26 +2136,19 @@
     TInt offset;
     // pass rest of the cursor data
     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
-    if (attributes)
-        {
-        attributes->iColor = iColor;
-        attributes->iFlags = iFlags;
-        attributes->iFlashInterval = iFlashInterval;
-        attributes->iScreenNumber = iScreenNumber;
-        
-        aModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
-                iGroupId, 
-                iId, 
-                (TAny*)offset );
-        
-        UpdateOrdinalPosition();
-        
-        AMT_MAP_STREAMER_TEXT_CURSOR_CONSTRUCT();
-        }
-	else
-		{
-		CAlfNode::ReportOOM();
-		}
+    attributes->iColor = iColor;
+    attributes->iFlags = iFlags;
+    attributes->iFlashInterval = iFlashInterval;
+    attributes->iScreenNumber = iScreenNumber;
+    
+    aModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
+            iGroupId, 
+            iId, 
+            (TAny*)offset );
+    
+    UpdateOrdinalPosition();
+    
+    AMT_MAP_STREAMER_TEXT_CURSOR_CONSTRUCT();
     }
 
 // ---------------------------------------------------------------------------
@@ -2278,23 +2198,17 @@
         }
     TInt offset;
     TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes));
-    if (attributes)
-        {
-        attributes->iColor = iColor;
-        attributes->iFlags = iFlags;
-        attributes->iFlashInterval = iFlashInterval;
-        attributes->iScreenNumber = iScreenNumber;
-        __ALFLOGSTRING("Forwarding cursor data");
-        iModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
+       attributes->iColor = iColor;
+       attributes->iFlags = iFlags;
+       attributes->iFlashInterval = iFlashInterval;
+       attributes->iScreenNumber = iScreenNumber;
+       __ALFLOGSTRING("Forwarding cursor data");
+       iModel->Server().Bridge()->AddData( EAlfDSSetCursorData, 
                iGroupId, 
                iId, 
                (TAny*)offset );
-        AMT_MAP_STREAMER_TEXT_CURSOR_CHANGE();
-        }
-	else
-		{
-		CAlfNode::ReportOOM();
-		}		
+       
+   AMT_MAP_STREAMER_TEXT_CURSOR_CHANGE();
     }
 CAlfNodeTextCursor::~CAlfNodeTextCursor( )
     {