uiacceltk/hitchcock/ServerCore/Src/alfwindowmanager.cpp
changeset 0 15bf7259bb7c
child 6 10534483575f
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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <fbs.h>
       
    21 
       
    22 #include "alfwindowmanager.h"
       
    23 #include "alfhierarchymodel.h"
       
    24 #include "alfstreamerserver.h"
       
    25 #include "alfstreamerbridge.h"
       
    26 #include "alfwindow.h"
       
    27 #include "alfwindowfxplugin.h"
       
    28 #include "alfwindowbuffer.h"
       
    29 #include "alfstreamerconsts.h"
       
    30 #include "alflogger.h"
       
    31 #include "alfwindowdata.h"
       
    32 
       
    33 #include <ecom.h>
       
    34 
       
    35 
       
    36 struct TPluginInfo
       
    37     {
       
    38     TPluginInfo():iPlugin(0),iDtor(TUid::Uid(0)), iPluginUid(TUid::Uid(0)), iNotifyEnabled(EFalse), iWindowDestroyNotifyEnabled(EFalse)
       
    39         {}
       
    40         
       
    41     CAlfWindowFxPlugin* iPlugin;
       
    42     TUid iDtor;
       
    43     TUid iPluginUid;
       
    44     TBool iNotifyEnabled; // flags would be more sophisticated way..
       
    45     TBool iWindowDestroyNotifyEnabled; 
       
    46     
       
    47     void EnableNotifications(TBool aEnable)
       
    48         {
       
    49         iNotifyEnabled = aEnable;
       
    50         }
       
    51     
       
    52     void NotifyNewWindow(const TWindowIdentifier& aId)
       
    53         {
       
    54         if (iNotifyEnabled)
       
    55             iPlugin->NewWindow(aId);
       
    56         }
       
    57     void EnableWindowDestroyNotifications(TBool aEnable)
       
    58         {
       
    59         iWindowDestroyNotifyEnabled = aEnable;
       
    60         }
       
    61             
       
    62     void NotifyDestroyWindow(const TWindowIdentifier& aId)
       
    63         {
       
    64         if (iWindowDestroyNotifyEnabled)
       
    65             iPlugin->DestroyWindow(aId);
       
    66         }    
       
    67     };
       
    68 
       
    69 class CAlfWindowManager::TAlfWindowMgrData
       
    70     {
       
    71     public:
       
    72     TInt iScreenId;
       
    73     
       
    74     RPointerArray<CAlfWindow> iWindows;
       
    75     RArray<TPluginInfo> iPlugins;
       
    76     CAlfHierarchyModel* iTree;
       
    77     
       
    78     RPointerArray<CAlfWindow> iChangedWindows;    
       
    79     };
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // FindPlugin
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CAlfWindowFxPlugin* CAlfWindowManager::FindPlugin(const TUid& aPluginUid)
       
    86     {
       
    87     for (TInt i = 0; i <= iData->iPlugins.Count()-1; i++)
       
    88         {
       
    89         if (iData->iPlugins[i].iPluginUid == aPluginUid )
       
    90             {
       
    91             return iData->iPlugins[i].iPlugin;
       
    92             }
       
    93         }
       
    94     return 0;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // NewL
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CAlfWindowManager* CAlfWindowManager::NewL(CAlfHierarchyModel* aAlfHierarchy)
       
   102     {
       
   103     CAlfWindowManager* self = new (ELeave) CAlfWindowManager;
       
   104     CleanupStack::PushL(self);
       
   105     self->ConstructL(aAlfHierarchy);
       
   106     CleanupStack::Pop();
       
   107     return self;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // destructor
       
   112 // ---------------------------------------------------------------------------
       
   113 //   
       
   114 CAlfWindowManager::~CAlfWindowManager()
       
   115     {
       
   116     if (iData)
       
   117         {
       
   118         iData->iWindows.ResetAndDestroy();
       
   119         delete iData;
       
   120         }
       
   121     REComSession::FinalClose();
       
   122     RFbsSession::Disconnect();
       
   123     }
       
   124 
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CreateNewWindowL
       
   128 // For Fx plugins   
       
   129 // ---------------------------------------------------------------------------
       
   130 //   
       
   131 EXPORT_C CAlfWindow* CAlfWindowManager::CreateNewWindowL(TUint aIndex, const TSize& aSizeInPixels )
       
   132     {
       
   133     if(!RFbsSession::GetSession())  
       
   134         {
       
   135         User::LeaveIfError(RFbsSession::Connect());
       
   136         }
       
   137 
       
   138     CAlfWindow* window = CAlfWindow::NewL(aIndex,*this, aSizeInPixels);
       
   139     CleanupStack::PushL(window);
       
   140     iData->iWindows.AppendL(window);
       
   141     CleanupStack::Pop();
       
   142       
       
   143     TAlfWServInfo wservInfo = window->WsInfo();
       
   144 
       
   145     TInt offset;
       
   146     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes( offset );
       
   147     if (windowAttributes)
       
   148         {
       
   149         windowAttributes->iSize = aSizeInPixels; 
       
   150         windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   151         windowAttributes->iParentNodeId = wservInfo.iParentRefId.iWindowIdentifer;
       
   152         
       
   153         TAlfBridgerData data;
       
   154         data.Set(EAlfDSNewWindow, 
       
   155             wservInfo.iRefId.iWindowGroupId, 
       
   156             wservInfo.iRefId.iWindowIdentifer, 
       
   157             (TAny*)offset); 
       
   158         
       
   159         User::LeaveIfError(PostIt(data));            
       
   160         }
       
   161     
       
   162     return window;
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // BindWindowToHitch
       
   167 // 
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 void CAlfWindowManager::BindWindowToHitchL(CAlfWindow* aWindow, CAlfWindowManager* aMgr)
       
   171 	{
       
   172     TAlfWServInfo wservInfo = aWindow->WsInfo();
       
   173 
       
   174     TInt offset;
       
   175     TAlfWindowAttributes* windowAttributes = CreateWindowAttributes( offset );
       
   176     if ( !windowAttributes )
       
   177         {
       
   178         return;
       
   179         }
       
   180     windowAttributes->iSize = aWindow->Size(); 
       
   181     windowAttributes->iPosition = aWindow->Position();
       
   182     windowAttributes->iWindowNodeType = wservInfo.iNodeType; 
       
   183     windowAttributes->iScreenNumber = wservInfo.iScreenNumber;
       
   184     windowAttributes->iParentNodeId = wservInfo.iParentRefId.iWindowIdentifer;
       
   185     windowAttributes->iClientHandle = wservInfo.iClientSideId.iWindowIdentifer;
       
   186     windowAttributes->iClientGroupHandle = wservInfo.iClientSideId.iWindowGroupId;
       
   187     
       
   188 #ifdef ALF_DEBUG_TRACK_DRAWING
       
   189     windowAttributes->iTrackWindow = wservInfo.iTrackWindow;
       
   190 #endif
       
   191 	TAlfBridgerData data;
       
   192     data.Set(EAlfDSNewWindow, 
       
   193         wservInfo.iRefId.iWindowGroupId, 
       
   194         wservInfo.iRefId.iWindowIdentifer, 
       
   195         (TAny*)offset); 
       
   196 
       
   197 	User::LeaveIfError(aMgr->PostIt(data));
       
   198 
       
   199 	aWindow->InsertedToScene(ETrue);
       
   200 	aWindow->SetPos(aWindow->Position());
       
   201 	if (aWindow->Rotation())
       
   202 	    {
       
   203 	    aWindow->SetRotation(aWindow->Rotation());
       
   204 	    }
       
   205 
       
   206     if ( aWindow->Opacity() != 1.0f) // different from default
       
   207         {
       
   208         aWindow->SetOpacity(aWindow->Opacity());
       
   209         }
       
   210 	aWindow->SetSurfaceExtent(aWindow->SurfaceExtent());
       
   211         
       
   212 	aWindow->SetActive(aWindow->IsActive());
       
   213 	}
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // CreateNewWindowL
       
   217 // for hierarchy model
       
   218 // ---------------------------------------------------------------------------
       
   219 //   
       
   220 CAlfWindow* CAlfWindowManager::CreateNewWindowL(TUint aIndex, const TAlfWServInfo& aInfo)
       
   221     {
       
   222     if(!RFbsSession::GetSession())
       
   223          {
       
   224          User::LeaveIfError(RFbsSession::Connect());
       
   225          }
       
   226 
       
   227      CAlfWindow* window = CAlfWindow::NewL(aIndex,*this, aInfo.iSize );
       
   228      CleanupStack::PushL(window);
       
   229      iData->iWindows.AppendL(window);
       
   230      CleanupStack::Pop();
       
   231 
       
   232      window->SetWsInfo(aInfo);
       
   233 
       
   234     // provide notification for plugins that have enabled it
       
   235     for (TInt i = 0; i <= iData->iPlugins.Count()-1; i++)
       
   236         {
       
   237         iData->iPlugins[i].NotifyNewWindow(aInfo.iClientSideId);
       
   238         }
       
   239 
       
   240     return window;
       
   241     }
       
   242     
       
   243 // ---------------------------------------------------------------------------
       
   244 // DestroyWindow
       
   245 // ---------------------------------------------------------------------------
       
   246 //   
       
   247 EXPORT_C void CAlfWindowManager::DestroyWindow(CAlfWindow& aWindow)
       
   248     {
       
   249     TInt i = iData->iWindows.Find(&aWindow);
       
   250     if (i >= 0)
       
   251         {
       
   252         TAlfWServInfo wservInfo = aWindow.WsInfo();
       
   253 
       
   254         TInt offset;
       
   255         TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   256         windowAttributes->iWindowNodeType = wservInfo.iNodeType; 
       
   257         windowAttributes->iScreenNumber = wservInfo.iScreenNumber; 
       
   258 
       
   259     	TAlfBridgerData data;
       
   260         data.Set(EAlfDSDestroyWindow, 
       
   261             wservInfo.iRefId.iWindowGroupId, 
       
   262             wservInfo.iRefId.iWindowIdentifer, 
       
   263             (TAny*)offset); 
       
   264 
       
   265         PostIt(data);
       
   266 
       
   267         iData->iWindows.Remove(i);
       
   268         delete &aWindow;
       
   269         
       
   270          // provide notification for plugins that have enabled it
       
   271     	for (TInt i = 0; i <= iData->iPlugins.Count()-1; i++)
       
   272         {
       
   273         iData->iPlugins[i].NotifyDestroyWindow(wservInfo.iClientSideId);
       
   274         }
       
   275         
       
   276        }
       
   277     }
       
   278     
       
   279 // ---------------------------------------------------------------------------
       
   280 // EnableNewWindowNotificationsL
       
   281 // ---------------------------------------------------------------------------
       
   282 //   
       
   283 EXPORT_C void CAlfWindowManager::EnableNewWindowNotificationsL(CAlfWindowFxPlugin& aPlugin, 
       
   284                                                 TBool aEnable)
       
   285     {
       
   286     // Assuming the amount of plugins to remain very limited
       
   287     for (TInt i = 0; i <= iData->iPlugins.Count()-1; i++)
       
   288         {
       
   289         if (iData->iPlugins[i].iPluginUid == *aPlugin.Identifier() )
       
   290             {
       
   291             iData->iPlugins[i].EnableNotifications(aEnable);
       
   292             }
       
   293         }
       
   294     }
       
   295     
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // EnableDestroyWindowNotificationsL
       
   299 // ---------------------------------------------------------------------------
       
   300 //   
       
   301 EXPORT_C void CAlfWindowManager::EnableDestroyWindowNotificationsL(CAlfWindowFxPlugin& aPlugin, 
       
   302                                                 TBool aEnable )
       
   303 	{
       
   304 	 // Assuming the amount of plugins to remain very limited
       
   305     for (TInt i = 0; i <= iData->iPlugins.Count()-1; i++)
       
   306         {
       
   307         if (iData->iPlugins[i].iPluginUid == *aPlugin.Identifier() )
       
   308             {
       
   309             iData->iPlugins[i].EnableWindowDestroyNotifications(aEnable);
       
   310             }
       
   311         }
       
   312 	}
       
   313 
       
   314 // ---------------------------------------------------------------------------
       
   315 // ReserveL
       
   316 // Decaprecated
       
   317 // ---------------------------------------------------------------------------
       
   318 //   
       
   319 EXPORT_C CAlfWindow* CAlfWindowManager::ReserveL( const TWindowIdentifier& /*aId*/, TBool aReserveBuffer /*= ETrue*/ )
       
   320     {
       
   321     return 0; // we never get here 
       
   322     }
       
   323     
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // Release
       
   327 // ---------------------------------------------------------------------------
       
   328 //   
       
   329 EXPORT_C void CAlfWindowManager::Release( CAlfWindow& /*aWindow*/, TBool /*aReserveBuffer = ETrue*/ )
       
   330     {
       
   331     /*TInt i = iData->iWindows.Find(&aWindow);
       
   332     if (i >= 0)
       
   333         {
       
   334         CAlfWindow* window = iData->iWindows[i]; 
       
   335         window->SetReserved( EFalse, aReserveBuffer );
       
   336         if (!window->WsInfo().ExistsInWServ())
       
   337             {
       
   338             __ALFFXLOGSTRING1("CAlfWindowManager::Released, 0x%x", window->Identifier());
       
   339             DestroyWindow( *window, EFalse );
       
   340             }
       
   341         }*/
       
   342     }
       
   343 
       
   344 // ---------------------------------------------------------------------------
       
   345 // ScreenId
       
   346 // ---------------------------------------------------------------------------
       
   347 //   
       
   348 EXPORT_C TInt CAlfWindowManager::ScreenId() const
       
   349     {
       
   350     if (iData)
       
   351         {
       
   352         return iData->iScreenId;          
       
   353         }
       
   354     return 0;
       
   355     }
       
   356 
       
   357 
       
   358 #ifdef RND_FXPLUGIN_FIX
       
   359 // ---------------------------------------------------------------------------
       
   360 // GetWinIdListL
       
   361 // ---------------------------------------------------------------------------
       
   362 //   
       
   363 EXPORT_C void CAlfWindowManager::GetWinIdListL(RArray<TWindowIdentifier>& aWinIdList)
       
   364     {
       
   365     // Create list 
       
   366     aWinIdList.Reset();
       
   367     for (TInt i=0; i < iData->iWindows.Count(); i++)
       
   368     	{
       
   369    		if (iData->iWindows[i]->IsActive() && iData->iWindows[i]->IsReserved() == EFalse )
       
   370 	    	{
       
   371 	    	aWinIdList.AppendL( iData->iWindows[i]->WsInfo().iClientSideId ); //\todo shoud this be ordered list?	
       
   372 	    	}
       
   373     	}
       
   374     }
       
   375 #endif    
       
   376 
       
   377 // ---------------------------------------------------------------------------
       
   378 // GetWinIdListL
       
   379 // ---------------------------------------------------------------------------
       
   380 //   
       
   381 EXPORT_C void CAlfWindowManager::GetWinIdListL( TInt aWsGroupId, RArray<TWindowIdentifier>& aWinIdList)
       
   382     {
       
   383     // Get list of windows which belong to the window server group specified
       
   384     aWinIdList.Reset();
       
   385     for ( TInt i=0; i < iData->iWindows.Count(); i++ )
       
   386     	{
       
   387    	    if ( iData->iWindows[i]->WsInfo().iClientSideId.iWindowGroupId == aWsGroupId )
       
   388    	        {
       
   389         	aWinIdList.AppendL( iData->iWindows[i]->WsInfo().iClientSideId );
       
   390         	}
       
   391     	}
       
   392     }
       
   393     
       
   394 // ---------------------------------------------------------------------------
       
   395 // 
       
   396 // ---------------------------------------------------------------------------
       
   397 //   
       
   398 EXPORT_C void CAlfWindowManager::GetWinInfoListL( TInt aWsGroupId, TInt aClientWindowHandle, RArray<TAlfWServInfo>& aWinInfoList )
       
   399     {
       
   400     aWinInfoList.Reset();
       
   401     for ( TInt i = 0; i < iData->iWindows.Count(); i++ )
       
   402         {
       
   403    	    if ( iData->iWindows[i]->WsInfo().iClientSideId.iWindowGroupId == aWsGroupId )
       
   404    	        {
       
   405             if ( aClientWindowHandle == KErrNotFound ||
       
   406                 iData->iWindows[i]->WsInfo().iClientSideId.iWindowIdentifer == aClientWindowHandle )
       
   407                 {
       
   408                 aWinInfoList.AppendL( iData->iWindows[i]->WsInfo() );
       
   409                 }
       
   410    	        }
       
   411         }
       
   412     }
       
   413     
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // MoveWindow
       
   417 // ---------------------------------------------------------------------------
       
   418 //   
       
   419 void CAlfWindowManager::MoveWindow(CAlfWindow& aWindow, TInt aIndex)
       
   420     {
       
   421     aWindow.Move(aIndex);    
       
   422     }
       
   423     
       
   424 
       
   425 // ---------------------------------------------------------------------------
       
   426 // SetWindowVisibility
       
   427 // ---------------------------------------------------------------------------
       
   428 //   
       
   429 void CAlfWindowManager::SetWindowVisibility(CAlfWindow& /*aWindow*/, TBool /*aVisible*/)
       
   430     {
       
   431         
       
   432     }
       
   433     
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // ContentReady
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 void CAlfWindowManager::ContentReady(CAlfWindow& aWindow, CAlfWindowBuffer* aOutBuffer)
       
   440     {
       
   441     //ASSERT(iData->iChangedWindows.Find(&aWindow) == KErrNotFound); // no plugin should produce more frames
       
   442                                                             // than actually bound to scene
       
   443     iData->iChangedWindows.Append(&aWindow);
       
   444 
       
   445     if(!aWindow.IsInsertedToScene())
       
   446     	{
       
   447     	TRAPD( err, BindWindowToHitchL(&aWindow, this) );
       
   448     	if (err)
       
   449     	    {
       
   450     	    __ALFLOGSTRING1( "CAlfWindowManager::ContentReady() ignore error: %d", err )
       
   451     	    }
       
   452     	}
       
   453     else
       
   454     	{
       
   455         TAlfWServInfo wservInfo = aWindow.WsInfo();
       
   456 
       
   457         TInt offset;
       
   458         TAlfWindowAttributes* windowAttributes = CreateWindowAttributes(offset);
       
   459 
       
   460         if (windowAttributes)
       
   461             {
       
   462             windowAttributes->iBitmapHandle = aOutBuffer->Handle();
       
   463             TAlfBridgerData d;
       
   464             d.Set(EAlfDSSetCoveringBitmap, 
       
   465                 wservInfo.iRefId.iWindowGroupId, 
       
   466                 wservInfo.iRefId.iWindowIdentifer, 
       
   467                 (TAny*)offset); 
       
   468 
       
   469             PostIt(d);
       
   470             }
       
   471     	}
       
   472     }
       
   473     
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 // constructor
       
   477 // ---------------------------------------------------------------------------
       
   478 //   
       
   479 CAlfWindowManager::CAlfWindowManager()
       
   480     {
       
   481         
       
   482     }
       
   483     
       
   484 
       
   485 // ---------------------------------------------------------------------------
       
   486 // ConstructL
       
   487 // ---------------------------------------------------------------------------
       
   488 //   
       
   489 void CAlfWindowManager::ConstructL(CAlfHierarchyModel* aAlfHierarchy)
       
   490     {
       
   491     iData = new (ELeave) TAlfWindowMgrData;
       
   492     iData->iTree = aAlfHierarchy;
       
   493     }
       
   494         
       
   495 
       
   496 // ---------------------------------------------------------------------------
       
   497 // LoadPluginL
       
   498 // ---------------------------------------------------------------------------
       
   499 //   
       
   500 void CAlfWindowManager::LoadPluginL(const TUid& aPluginUid)
       
   501     {
       
   502     ASSERT(iData);
       
   503     if ( FindPlugin(aPluginUid) )
       
   504         {
       
   505         User::Leave(KErrAlreadyExists);
       
   506         }
       
   507         
       
   508     TUid dtoridkey;
       
   509     CAlfWindowFxPlugin* fxplugin = (CAlfWindowFxPlugin*)REComSession::CreateImplementationL(aPluginUid, dtoridkey);    
       
   510     CleanupStack::PushL(fxplugin);
       
   511     fxplugin->ConstructL(*this, EColor16MAP); // TODO: decide buffer format
       
   512     TUid* pluginUid = fxplugin->Identifier();
       
   513     
       
   514     ASSERT(pluginUid); // construction was not complete i.e. basecall missing in plugin implementation
       
   515     
       
   516     *pluginUid = aPluginUid;
       
   517     
       
   518     TPluginInfo info;
       
   519     info.iPlugin = fxplugin;
       
   520     info.iDtor = dtoridkey;
       
   521     info.iPluginUid = aPluginUid;
       
   522     iData->iPlugins.AppendL(info);
       
   523     CleanupStack::Pop();
       
   524     }
       
   525 
       
   526 
       
   527 // ---------------------------------------------------------------------------
       
   528 // DestroyPlugin
       
   529 // ---------------------------------------------------------------------------
       
   530 //   
       
   531 void CAlfWindowManager::DestroyPlugin(const TUid& aPluginUid)
       
   532     {
       
   533     ASSERT(iData);
       
   534     TPluginInfo info;
       
   535     TInt pluginCount = iData->iPlugins.Count();
       
   536     for (int index = 0; index < pluginCount; index++)
       
   537         {
       
   538         info = iData->iPlugins[index];
       
   539         if (info.iPluginUid == aPluginUid)
       
   540             {
       
   541             delete info.iPlugin;
       
   542             REComSession::DestroyedImplementation(info.iDtor);
       
   543             iData->iPlugins.Remove(index);
       
   544             break;    
       
   545             }
       
   546         }
       
   547     }
       
   548 
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // HandlePluginMsgL
       
   552 // ---------------------------------------------------------------------------
       
   553 //   
       
   554 void CAlfWindowManager::HandlePluginMsgL(const RMessage2& aMessage)
       
   555     {
       
   556     ASSERT(iData);
       
   557     CAlfWindowFxPlugin* fxplugin = FindPlugin(TUid::Uid(aMessage.Int0()));
       
   558     if (fxplugin)
       
   559         {
       
   560         TInt lenght1 = aMessage.GetDesLength(1);
       
   561         TInt lenght2 = aMessage.GetDesMaxLength(2);
       
   562      
       
   563         HBufC8* inHBuf = HBufC8::NewLC(lenght1);
       
   564         TPtr8 inBuf = inHBuf->Des();
       
   565         aMessage.ReadL(1,inBuf); 
       
   566         
       
   567         if ( aMessage.Function() == EAlfDecodSSendSynch )
       
   568             {
       
   569             HBufC8* outBuf = HBufC8::NewLC(lenght2);
       
   570             TPtr8 outptr = outBuf->Des();
       
   571             fxplugin->HandleMessageL(inBuf, outptr);
       
   572             
       
   573             if(!aMessage.IsNull())
       
   574                 {
       
   575                 aMessage.WriteL(2,*outBuf);
       
   576                 aMessage.Complete(KErrNone);
       
   577                 }   
       
   578             
       
   579             CleanupStack::PopAndDestroy();
       
   580             }
       
   581         else
       
   582             {
       
   583             fxplugin->HandleMessageL(inBuf, aMessage);
       
   584             }
       
   585     
       
   586         CleanupStack::PopAndDestroy();
       
   587         }
       
   588     else
       
   589         {
       
   590         aMessage.Complete(KErrNotFound);
       
   591         }
       
   592     }
       
   593 
       
   594 
       
   595 // ---------------------------------------------------------------------------
       
   596 // CancelPluginMsg
       
   597 // ---------------------------------------------------------------------------
       
   598 //   
       
   599 void CAlfWindowManager::CancelPluginMsg(const TUid& aPluginUid, TInt aMessageId)
       
   600     {
       
   601     if (!iData)
       
   602         {
       
   603         return;
       
   604         }
       
   605         
       
   606     if (aPluginUid == KNullUid)
       
   607         {
       
   608         for (TInt i = iData->iPlugins.Count()-1; i >= 0 ; i--)
       
   609             {
       
   610             iData->iPlugins[i].iPlugin->CancelMessage(aMessageId);
       
   611             }
       
   612         }
       
   613     else
       
   614         {
       
   615         CAlfWindowFxPlugin* fxplugin = FindPlugin(aPluginUid);
       
   616         if (fxplugin)
       
   617             {
       
   618             fxplugin->CancelMessage(aMessageId);
       
   619             }
       
   620         }    
       
   621     }
       
   622 
       
   623 
       
   624 // ---------------------------------------------------------------------------
       
   625 // PostIt
       
   626 // ---------------------------------------------------------------------------
       
   627 //   
       
   628 EXPORT_C TInt CAlfWindowManager::PostIt(const TAlfBridgerData& aData)
       
   629     {
       
   630 //    RDebug::Print(_L("CAlfWindowManager::PostIt") );
       
   631     return iData->iTree->Server().Bridge()->AddData(aData.iOp, aData.iInt1, aData.iInt2, aData.iPtr);
       
   632     }
       
   633 
       
   634 // ---------------------------------------------------------------------------
       
   635 // Bridge
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 EXPORT_C CAlfStreamerBridge* CAlfWindowManager::Bridge()
       
   639     {
       
   640     return iData->iTree->Server().Bridge();
       
   641     }
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // PrepareNewFrame
       
   645 // ---------------------------------------------------------------------------
       
   646 //   
       
   647 void CAlfWindowManager::PrepareNewFrame(TUint aEstimatedInterval)
       
   648     {
       
   649     iData->iChangedWindows.Reset();
       
   650     for (TInt i = iData->iPlugins.Count()-1; i >= 0 ; i--)
       
   651         {
       
   652         TRAP_IGNORE(iData->iPlugins[i].iPlugin->PrepareFrameL(aEstimatedInterval));
       
   653         // for now, just ignore error. When collecting complete frames, we could use this info though
       
   654         }    
       
   655     }
       
   656 
       
   657 // ---------------------------------------------------------------------------
       
   658 // 
       
   659 // ---------------------------------------------------------------------------
       
   660 //
       
   661 TAlfWindowAttributes* CAlfWindowManager::CreateWindowAttributes(TInt& aIndex)
       
   662     {
       
   663     TAlfWindowAttributes empty;
       
   664     TAlfWindowAttributes* attributes = NULL;
       
   665     TRAP_IGNORE(attributes = (TAlfWindowAttributes*)Bridge()->AppendVarDataL( sizeof(TAlfWindowAttributes), aIndex ))
       
   666     *attributes = empty;
       
   667     return attributes;
       
   668     }
       
   669 
       
   670 // ---------------------------------------------------------------------------
       
   671 // 
       
   672 // ---------------------------------------------------------------------------
       
   673 //
       
   674 TAlfWindowCommandBufferAttributes* CAlfWindowManager::CreateWindowCommandBufferAttributes(TInt& aIndex)
       
   675     {
       
   676     TAlfWindowCommandBufferAttributes empty;    
       
   677     TAlfWindowCommandBufferAttributes* windowCommandBuffer = NULL;    
       
   678     TRAP_IGNORE(windowCommandBuffer = (TAlfWindowCommandBufferAttributes*)Bridge()->AppendVarDataL( sizeof(TAlfWindowCommandBufferAttributes), aIndex ))    
       
   679     *windowCommandBuffer = empty;
       
   680     return windowCommandBuffer;
       
   681     }