uiacceltk/hitchcock/Client/src/alfenv.cpp
changeset 64 9f8c0686fb49
equal deleted inserted replaced
-1:000000000000 64:9f8c0686fb49
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Environment
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <coemain.h>
       
    21 #include <AknsConstants.h>
       
    22 #include <AknTaskList.h>
       
    23 #include <alf/ftokenclient.h>
       
    24 #include <aknappui.h>
       
    25 #include "alf/alfenv.h"
       
    26 #include "alfclient.h"
       
    27 #include "alf/alfdisplay.h"
       
    28 #include "alf/alfroster.h"
       
    29 #include "alf/alfcontrolgroup.h"
       
    30 #include "alf/alfevent.h"
       
    31 #include "alf/alftexturemanager.h"
       
    32 #include "alf/alftextstylemanager.h"
       
    33 #include "alfcommandscheduler.h"
       
    34 #include "alf/alfstatic.h"
       
    35 #include "alf/alflayoutmetrics.h"
       
    36 #include "alf/alfconstants.h"
       
    37 #include "alf/alfevent.h"
       
    38 #include "alf/alfcontrol.h"
       
    39 #include "alf/alfbatchbuffer.h"
       
    40 #include "alf/alfenvobject.h"
       
    41 #include "alfuids.h"
       
    42 #include "alfpanic.h"
       
    43 
       
    44 #include "uiacceltk/HuiUtil.h"
       
    45 #include "alflogger.h"
       
    46 // Literals and constants
       
    47 // This string is used with multiple ALF clients -panic. The panic conserns 
       
    48 // only ALF clients, NOT the server!
       
    49 _LIT( KUIAcceltkClientPanic, "UIAcceltkClient" );
       
    50 
       
    51 struct TSharedTextureManagerEntry 
       
    52     {
       
    53     public:
       
    54     	~TSharedTextureManagerEntry()
       
    55         {
       
    56         }
       
    57     	TSharedTextureManagerEntry()                      
       
    58                       : iRefCount(0), iTextureManager(NULL)
       
    59         {                            
       
    60         }
       
    61     	
       
    62     	TSharedTextureManagerEntry(CAlfTextureManager* aTextureManager)                      
       
    63                       : iRefCount(1), iTextureManager(aTextureManager)
       
    64         {
       
    65         }
       
    66 
       
    67     /** The texturemanager reference count */
       
    68     TInt iRefCount;
       
    69 
       
    70     /** The shared texture manager entry. */
       
    71     CAlfTextureManager* iTextureManager;
       
    72     };
       
    73 
       
    74 
       
    75 // Used flags.
       
    76 enum TAlfEnvFlags
       
    77     {
       
    78     EOwnClient =            0x01,
       
    79     ETokenClientConnected = 0x02 
       
    80     // ...add other flags...
       
    81     };
       
    82 
       
    83 
       
    84 // Deault max framerate
       
    85 const TInt KAlfDefaultMaxFrameRate = 33;
       
    86     
       
    87 // Default flags
       
    88 const TUint KAlfEnvDefaultFlags = 0x00;
       
    89 
       
    90 // Size of buffer towards client side.
       
    91 const TInt KAlfTextureInfoMonitorBufferSize = 128;
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // Returns connected control with ID 
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CAlfControl* FindConnectedControl(CAlfControl& aControl, TInt aId, TBool aUserId)
       
    98     {
       
    99     CAlfControl* result = NULL;
       
   100     for ( TInt connectionIndex = 0 ; connectionIndex < aControl.ConnectionCount() && !result ; connectionIndex++ )
       
   101         {
       
   102         CAlfControl& connection = aControl.Connection( connectionIndex );
       
   103         if( (aUserId?
       
   104             connection.Id():
       
   105             connection.Identifier()) 
       
   106                 == aId)
       
   107             {
       
   108             result = &connection;
       
   109             }
       
   110         else
       
   111             {
       
   112             result = FindConnectedControl( connection, aId, aUserId );
       
   113             }
       
   114         }
       
   115     
       
   116     return result;
       
   117     }
       
   118 
       
   119 /**
       
   120  * Gets the pointer evetns from the server
       
   121  */
       
   122 NONSHARABLE_CLASS(CAlfPtrEventFetcher):public CActive
       
   123     {
       
   124     public:
       
   125     CAlfPtrEventFetcher(RAlfClient& aClient, CAlfEnv& aEnv)
       
   126         :CActive(CActive::EPriorityHigh),iClient(aClient),iEventAsDescriptor(iEvent),iEnv(aEnv)
       
   127         {
       
   128         CActiveScheduler::Add(this);
       
   129         }
       
   130 
       
   131     ~CAlfPtrEventFetcher()
       
   132         {
       
   133         Cancel();
       
   134         }
       
   135 
       
   136     void Start()
       
   137         {
       
   138         ASSERT(!IsActive());
       
   139         SetActive();
       
   140         iClient.RequestPointerEvents(iEventAsDescriptor, iStatus);
       
   141         }
       
   142 
       
   143     private:
       
   144     void DeliverPointerEventL();
       
   145     
       
   146     void RunL()
       
   147         {
       
   148         if(iStatus.Int() == KErrNone)    
       
   149         	{
       
   150         	DeliverPointerEventL();		
       
   151         	Start();
       
   152         	}
       
   153         else
       
   154         	{
       
   155         	__ALFLOGSTRING1( "~CAlfPtrEventFetcher::RunL error %d", iStatus.Int() )	
       
   156         	}
       
   157         
       
   158         }
       
   159         
       
   160     void DoCancel()
       
   161         {
       
   162         iClient.CancelPointerEvents();
       
   163         }
       
   164 
       
   165     TInt RunError(TInt /*aError*/)
       
   166         {
       
   167         //Nothing to worry, just restart
       
   168         Start();
       
   169         return KErrNone;
       
   170         }
       
   171 
       
   172     RAlfClient& iClient;
       
   173     TAlfTouchEvent iEvent;
       
   174     TPckg<TAlfTouchEvent> iEventAsDescriptor;
       
   175     CAlfEnv& iEnv;
       
   176     friend class CAlfEnv; // allow env to acces our event data
       
   177     };
       
   178 
       
   179 void CAlfPtrEventFetcher::DeliverPointerEventL()
       
   180     {
       
   181     TBool eventSent(EFalse);
       
   182     
       
   183     // search clients based on handles from server
       
   184     CAlfControl* ctrl = iEnv.FindControl(iEvent.iControls[0], EFalse);
       
   185     TInt visualIdentifier = iEvent.iVisuals[0];
       
   186     
       
   187     for(TInt ii = 1; ctrl ; ii++)
       
   188         {
       
   189         // Find the visual index
       
   190         CAlfVisual* visual = NULL;
       
   191         for ( TInt i = ctrl->VisualCount() - 1 ; i >= 0 && visualIdentifier ; i-- )
       
   192             {
       
   193             if ( ctrl->Visual( i ).Identifier() == visualIdentifier )
       
   194                 {
       
   195                 visual = &ctrl->Visual( i );
       
   196                 break;
       
   197                 }
       
   198             }
       
   199         
       
   200         // Todo: Do we allow ctrl to leave and still pass the event to other cntrls ??
       
   201         TBool consumed = EFalse;
       
   202         TAlfEvent event(*ctrl->Display(), iEvent.iEvent); 
       
   203         event.SetVisual( visual );
       
   204         eventSent = ETrue;
       
   205         /*TRAP_IGNORE(*/consumed = ctrl->OfferEventL(event)/*)*/;
       
   206         if (consumed)
       
   207             {
       
   208             break;
       
   209             }
       
   210             
       
   211         ctrl = iEnv.FindControl(iEvent.iControls[ii], EFalse);
       
   212         visualIdentifier = iEvent.iVisuals[ii];
       
   213         }
       
   214     
       
   215     if (!eventSent)
       
   216         {
       
   217         // ptr event hit visual having groupless control as an owner
       
   218         // we can't resolve destination in toolkit side, just post infromation about the event data to 
       
   219         // action observers and let the app implementation decide whether event is used or nor.
       
   220         iEnv.ReportAction(TAlfActionCommand(KAlfOrpheanPtrEventReceived));
       
   221         }
       
   222     }
       
   223 
       
   224 
       
   225 NONSHARABLE_CLASS(CAlfSystemEventFetcher):public CActive
       
   226     {
       
   227     public:
       
   228     CAlfSystemEventFetcher(RAlfClient& aClient, CAlfEnv& aEnv)
       
   229         :CActive(CActive::EPriorityHigh),iClient(aClient),iEventAsDescriptor(iEvent),iEnv(aEnv)
       
   230         {
       
   231         CActiveScheduler::Add(this);
       
   232         }
       
   233 
       
   234     ~CAlfSystemEventFetcher()
       
   235         {
       
   236         Cancel();
       
   237         }
       
   238 
       
   239     void Start()
       
   240         {
       
   241         ASSERT(!IsActive());
       
   242         SetActive();
       
   243         iClient.RequestSystemEvents(iEventAsDescriptor, iStatus);
       
   244         }
       
   245 
       
   246     private:
       
   247     void DeliverSystemEventL();
       
   248     
       
   249     void RunL()
       
   250         {
       
   251         if(iStatus.Int() != KErrNone)
       
   252             { // for now..
       
   253             USER_INVARIANT();
       
   254             }
       
   255             
       
   256         DeliverSystemEventL();
       
   257         Start();
       
   258         }
       
   259         
       
   260     void DoCancel()
       
   261         {
       
   262         iClient.CancelSystemEvents();
       
   263         }
       
   264 
       
   265     TInt RunError(TInt /*aError*/)
       
   266         {
       
   267         //Nothing to worry, just restart
       
   268         Start();
       
   269         return KErrNone;
       
   270         }
       
   271 
       
   272     RAlfClient& iClient;
       
   273     TInt iEvent;
       
   274     TPckg<TInt> iEventAsDescriptor;
       
   275     CAlfEnv& iEnv;
       
   276     };
       
   277 
       
   278 void CAlfSystemEventFetcher::DeliverSystemEventL()
       
   279     {
       
   280     if (iEvent == KAknsMessageSkinChange)
       
   281         {
       
   282         iEnv.SetSkinChangePending(ETrue);
       
   283         iEnv.ReportWsEventAsActionCommand(KAlfActionIdSkinChanged); 
       
   284         // Some action observer may have already called by themselves
       
   285         // NotifySkinChangedL, so check before we do it.
       
   286         if (iEnv.SkinChangePending())
       
   287             {
       
   288             iEnv.NotifySkinChangedL();            
       
   289             }        
       
   290         }
       
   291     }
       
   292        
       
   293 /**
       
   294  * Texture information monitor.
       
   295  */
       
   296 NONSHARABLE_CLASS( CAlfTextureInfoMonitor ) : public CActive
       
   297     {
       
   298 public:
       
   299     /**
       
   300      * Two-phased constructor.
       
   301      * @param aClient reference to client.
       
   302      */
       
   303     static CAlfTextureInfoMonitor* NewL( CAlfEnv& aEnv );
       
   304     
       
   305     /**
       
   306      * Destructor.
       
   307      */
       
   308     ~CAlfTextureInfoMonitor();
       
   309        
       
   310 private:
       
   311 
       
   312     /**
       
   313      * Constructor.
       
   314      * @param aClient reference to client.
       
   315      */
       
   316     CAlfTextureInfoMonitor( CAlfEnv& aEnv );
       
   317     
       
   318     /**
       
   319      * Symbian OS constructor.
       
   320      */
       
   321     void ConstructL();
       
   322 
       
   323     /**
       
   324      * Issues a request.
       
   325      */
       
   326     void IssueRequest();
       
   327     
       
   328     /**
       
   329      * Called by active object framework when request is completed.
       
   330      */
       
   331     virtual void RunL();
       
   332     
       
   333     /**
       
   334      * Cancels pending request.
       
   335      */
       
   336     virtual void DoCancel();
       
   337     
       
   338 private:
       
   339     
       
   340     /**
       
   341      * Reference to environment.
       
   342      */
       
   343     CAlfEnv& iEnv;    
       
   344     
       
   345     /**
       
   346      * Buffer containing texture info events.
       
   347      */
       
   348     TBuf8< KAlfTextureInfoMonitorBufferSize > iTextureEventBuffer;
       
   349     };
       
   350 
       
   351 CAlfTextureInfoMonitor* CAlfTextureInfoMonitor::NewL( CAlfEnv& aEnv )
       
   352     {
       
   353     CAlfTextureInfoMonitor* self = 
       
   354         new (ELeave) CAlfTextureInfoMonitor( aEnv );
       
   355 
       
   356     CleanupStack::PushL( self );
       
   357     self->ConstructL();
       
   358     CleanupStack::Pop( self );
       
   359     
       
   360     return self;    
       
   361     }
       
   362     
       
   363 CAlfTextureInfoMonitor::~CAlfTextureInfoMonitor()
       
   364     {
       
   365     Cancel();
       
   366     }
       
   367     
       
   368 CAlfTextureInfoMonitor::CAlfTextureInfoMonitor( CAlfEnv& aEnv )
       
   369     : CActive( CActive::EPriorityStandard ),
       
   370       iEnv( aEnv )
       
   371     {
       
   372     CActiveScheduler::Add( this );
       
   373     }
       
   374     
       
   375 void CAlfTextureInfoMonitor::ConstructL()
       
   376     {
       
   377     IssueRequest();
       
   378     }
       
   379 
       
   380 void CAlfTextureInfoMonitor::IssueRequest()
       
   381     {
       
   382     iEnv.Client().TextureNotifyInfo( iStatus, iTextureEventBuffer );
       
   383     SetActive();
       
   384     }
       
   385     
       
   386 void CAlfTextureInfoMonitor::RunL()
       
   387     {
       
   388     if ( iStatus.Int() == KErrNone )
       
   389         {
       
   390         iEnv.HandleTextureInfo( iTextureEventBuffer );
       
   391         IssueRequest();
       
   392         }
       
   393     }
       
   394     
       
   395 void CAlfTextureInfoMonitor::DoCancel()
       
   396     {
       
   397     iEnv.Client().TextureCancelNotifyInfo();
       
   398     }
       
   399 
       
   400 // Private data
       
   401 struct CAlfEnv::TPrivateData
       
   402     {
       
   403     // Structure used to hold owned objects in the extension array
       
   404     struct TObjectHolder
       
   405         {
       
   406         TInt iUid;
       
   407         MAlfEnvObject* iObject;
       
   408         };
       
   409     TPrivateData():iFlags(0),iClient(0),iSharedRoster(0),
       
   410                    iTextureManager(0),iTextStyleManager(0),iScheduler(0),
       
   411                    iMaxFrameRate(0),iRefreshMode(EAlfRefreshModeAutomatic),
       
   412                    iStatic(0),iLayoutMetricsUtility(0),iPointerEventAo(0),
       
   413                    iBatchBufferHandler(0){}
       
   414     TUint iFlags;                                   // Owned.
       
   415     RAlfClient* iClient;                            // Owned/not owned - see EOwnClient
       
   416     CAlfRoster* iSharedRoster;                      // Owned.
       
   417     RPointerArray<CAlfDisplay> iDisplays;           // Owned.
       
   418     RPointerArray<CAlfControlGroup> iLoadedGroups;  // Owned.
       
   419     CAlfTextureManager* iTextureManager;            // Owned.
       
   420     CAlfTextStyleManager* iTextStyleManager;        // Owned.
       
   421     RPointerArray<MAlfActionObserver> iActionObservers;   // Owned.
       
   422     RArray<TSharedTextureManagerEntry> iSharedTextureManagers; // Owned.
       
   423     CAlfCommandScheduler* iScheduler;               // Owned.
       
   424     TInt iMaxFrameRate;
       
   425     TAlfRefreshMode iRefreshMode;
       
   426     RFTokenClient   iTokenClient;                    // lazy bound, connected once first real request occurs
       
   427     CAlfStatic* iStatic;                              // Owned.
       
   428     CAlfLayoutMetricsUtility* iLayoutMetricsUtility;  // Owned.
       
   429     CAlfPtrEventFetcher* iPointerEventAo;             // Owned.
       
   430     CAlfSystemEventFetcher* iSystemEventAo;             // Owned.
       
   431     TVersion iApiVersion;
       
   432     CAlfBatchBuffer* iBatchBufferHandler;
       
   433         
       
   434     // Flags to avoid unnecessary skin & layout notify calls
       
   435     TBool iNotifySkinChangePending;  
       
   436     TBool iNotifyLayoutChangePending;  
       
   437     
       
   438     CAlfTextureInfoMonitor* iTextureInfoMonitor; // Owned.
       
   439     
       
   440     RArray<CAlfEnv::TPrivateData::TObjectHolder> iExtensionArray;
       
   441     };
       
   442 
       
   443 // ======== MEMBER FUNCTIONS ========
       
   444 
       
   445 // ---------------------------------------------------------------------------
       
   446 // Constructor
       
   447 // ---------------------------------------------------------------------------
       
   448 //
       
   449 CAlfEnv::CAlfEnv()
       
   450     {
       
   451     }
       
   452 
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 // ConstructL
       
   456 // ---------------------------------------------------------------------------
       
   457 //
       
   458 void CAlfEnv::ConstructL(TVersion aVersion)
       
   459     {
       
   460     /*  
       
   461     // AknEventMonitor can be used if we want to know the target control also
       
   462     // Otherwise CoeMonitor should be used for better compatibility between 
       
   463     // releases 
       
   464       
       
   465     CAknAppUi* appUi = iAvkonAppUi; // actually macro using coe static...
       
   466     if (appUi && appUi->EventMonitor())
       
   467         {
       
   468         appUi->EventMonitor()->AddObserverL(this);
       
   469         appUi->EventMonitor()->Enable();
       
   470         }
       
   471 */
       
   472 
       
   473     // Enforces single CAlfEnv policy. Panics ONLY the client, NOT the server!!
       
   474     __ASSERT_ALWAYS( !CAlfEnv::Static(), User::Panic( KUIAcceltkClientPanic, EAlfEnvPanicMultipleAlfEnvironments ) );
       
   475     
       
   476     CCoeEnv* coeStatic = CCoeEnv::Static();
       
   477     if ( coeStatic )
       
   478         {
       
   479         coeStatic->AddMessageMonitorObserverL(*this);
       
   480         }
       
   481 
       
   482     // Create private data
       
   483     iData = new (ELeave) TPrivateData;
       
   484 
       
   485     iData->iApiVersion = aVersion;
       
   486     
       
   487     // NULL member data before anything else may leave.
       
   488     iData->iClient = NULL;
       
   489     iData->iSharedRoster = NULL;
       
   490     iData->iTextureManager = NULL;
       
   491     iData->iTextStyleManager = NULL;
       
   492     iData->iScheduler = NULL;
       
   493     iData->iStatic = NULL;
       
   494     iData->iLayoutMetricsUtility = NULL;
       
   495     iData->iPointerEventAo = NULL;
       
   496     iData->iSystemEventAo = NULL;
       
   497     iData->iBatchBufferHandler = NULL;
       
   498     iData->iTextureInfoMonitor = NULL;
       
   499                 
       
   500     // Set flags
       
   501     iData->iFlags = KAlfEnvDefaultFlags;
       
   502     
       
   503     // Set client ( pekjokel: client can be passed from outside as well? )
       
   504     iData->iClient = new (ELeave) RAlfClient;
       
   505     iData->iFlags |= EOwnClient;
       
   506     iData->iClient->OpenL();
       
   507     
       
   508     if (coeStatic)
       
   509         {
       
   510         CAknTaskList* taskList = CAknTaskList::NewLC(coeStatic->WsSession());
       
   511         const RArray<RWsSession::TWindowGroupChainInfo>& chain = taskList->WgArray();
       
   512         const TInt chainCount = chain.Count();
       
   513 
       
   514         TInt parentId = 0;
       
   515 
       
   516         TInt wgId = coeStatic->RootWin().Identifier();
       
   517         for ( TInt ii = 0; ii < chainCount; ii++ )
       
   518             {
       
   519             const RWsSession::TWindowGroupChainInfo& info = chain[ ii ];
       
   520             if ( info.iId == wgId )
       
   521                 {
       
   522                 parentId = info.iParentId;
       
   523                 break;
       
   524                 }
       
   525             }
       
   526         
       
   527         if (parentId > 0)
       
   528             {
       
   529             iData->iClient->SetWgParent(parentId);
       
   530             }
       
   531   
       
   532         CleanupStack::PopAndDestroy();       
       
   533         }
       
   534         
       
   535      // Create a shared roster. This is used by all overlaid displays.
       
   536     iData->iSharedRoster = new (ELeave) CAlfRoster;
       
   537     iData->iSharedRoster->ConstructL(NULL);
       
   538     
       
   539     iData->iDisplays.Reset();
       
   540     iData->iLoadedGroups.Reset();
       
   541     
       
   542     iData->iMaxFrameRate = KAlfDefaultMaxFrameRate;
       
   543         
       
   544     // Create a texture manager.
       
   545     User::LeaveIfError( iData->iClient->TextureUpdateOwnerId() );
       
   546     iData->iTextureManager = CAlfTextureManager::NewL(*this, TUid::Uid(0));
       
   547     iData->iTextureManager->AddLoadObserverL(this);
       
   548     iData->iTextureManager->AddStateObserverL(this);
       
   549     iData->iSharedTextureManagers.Reset();
       
   550     
       
   551     // Create a text style manager.
       
   552     iData->iTextStyleManager = CAlfTextStyleManager::NewL(*this);
       
   553     
       
   554     // Command scheduler
       
   555     iData->iScheduler = CAlfCommandScheduler::NewL( *this ); 
       
   556     
       
   557     // Static data storage
       
   558     iData->iStatic = CAlfStatic::NewL(this);
       
   559         
       
   560     // Layout metrics utility
       
   561     iData->iLayoutMetricsUtility = CAlfLayoutMetricsUtility::NewL(*this);
       
   562     
       
   563     // Create one shared pointer event fetcher for all displays and start it
       
   564     // to listen to incoming pointer events.
       
   565     iData->iPointerEventAo = new (ELeave) CAlfPtrEventFetcher(Client(), *this); 
       
   566     iData->iPointerEventAo->Start();
       
   567 
       
   568     iData->iSystemEventAo = new (ELeave) CAlfSystemEventFetcher(Client(), *this); 
       
   569     iData->iSystemEventAo->Start();
       
   570     
       
   571     iData->iBatchBufferHandler = CAlfBatchBuffer::NewL( *this );
       
   572 
       
   573     iData->iNotifySkinChangePending = EFalse;
       
   574     iData->iNotifyLayoutChangePending = EFalse;
       
   575 
       
   576     iData->iTextureInfoMonitor = 
       
   577         CAlfTextureInfoMonitor::NewL( *this );
       
   578     
       
   579     }
       
   580 
       
   581 // ---------------------------------------------------------------------------
       
   582 // 2-phased contructor
       
   583 // ---------------------------------------------------------------------------
       
   584 //
       
   585 EXPORT_C CAlfEnv* CAlfEnv::NewL(TVersion aVersion)
       
   586     {
       
   587     CAlfEnv* self = CAlfEnv::NewLC(aVersion);
       
   588     CleanupStack::Pop( self );
       
   589     return self;
       
   590     }
       
   591 
       
   592 
       
   593 // ---------------------------------------------------------------------------
       
   594 // 2-phased contructor. Object stays on the stack.
       
   595 // ---------------------------------------------------------------------------
       
   596 //
       
   597 EXPORT_C CAlfEnv* CAlfEnv::NewLC(TVersion aVersion)
       
   598     {
       
   599     CAlfEnv* self = new( ELeave ) CAlfEnv;
       
   600     CleanupStack::PushL( self );    
       
   601     
       
   602     // Check client API compatibility. 
       
   603     if (aVersion.iMajor != self->Version().iMajor)
       
   604         {
       
   605         User::Leave(KErrNotSupported);    
       
   606         }
       
   607     
       
   608     self->ConstructL(aVersion);
       
   609     return self;
       
   610     }
       
   611 
       
   612 
       
   613 // ---------------------------------------------------------------------------
       
   614 // Destructor
       
   615 // ---------------------------------------------------------------------------
       
   616 //
       
   617 EXPORT_C CAlfEnv::~CAlfEnv()
       
   618     {
       
   619     // Delete struct items
       
   620     if ( iData )
       
   621         {
       
   622         delete iData->iBatchBufferHandler;
       
   623         iData->iBatchBufferHandler = NULL;
       
   624         
       
   625         // Destroy pointer event fetcher
       
   626         delete iData->iPointerEventAo;
       
   627         iData->iPointerEventAo = NULL;
       
   628 
       
   629         delete iData->iSystemEventAo;
       
   630         iData->iSystemEventAo = NULL;
       
   631                 
       
   632         iData->iLoadedGroups.ResetAndDestroy();
       
   633         iData->iDisplays.ResetAndDestroy();
       
   634         delete iData->iSharedRoster;
       
   635         iData->iSharedRoster = NULL;        
       
   636         
       
   637         delete iData->iScheduler;
       
   638         iData->iScheduler= NULL;
       
   639         
       
   640         // Delete extension objects in reverse order.
       
   641         // (Objects should be added with dependent objects after the object on which they depend)
       
   642         for (TInt extensionIndex = iData->iExtensionArray.Count()-1 ; 
       
   643             extensionIndex >= 0; 
       
   644             extensionIndex--)
       
   645             {
       
   646             MAlfEnvObject* obj =  iData->iExtensionArray[extensionIndex].iObject;
       
   647             if ( obj)
       
   648                 {
       
   649                 obj->Release();   
       
   650                 }
       
   651             }
       
   652         iData->iExtensionArray.Reset();
       
   653         iData->iExtensionArray.Close();
       
   654                 
       
   655         if (iData->iTextureManager)
       
   656             {
       
   657             iData->iTextureManager->RemoveLoadObserver(this);
       
   658             iData->iTextureManager->RemoveStateObserver(this);
       
   659             }
       
   660 
       
   661         delete iData->iTextureManager;
       
   662         iData->iTextureManager = NULL;
       
   663     
       
   664         delete iData->iTextStyleManager;
       
   665         iData->iTextStyleManager = NULL;
       
   666         
       
   667         // Remove shared texture managers if any exists
       
   668    	    RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
   669        	TInt count = iData->iSharedTextureManagers.Count();
       
   670         for(TInt i = 0; i < count; i++)
       
   671           	{
       
   672           	TSharedTextureManagerEntry entry = managers[i];
       
   673             entry.iTextureManager->RemoveLoadObserver(this);
       
   674             entry.iTextureManager->RemoveStateObserver(this);          	
       
   675           	delete entry.iTextureManager;
       
   676       		managers.Remove(i);
       
   677         	}  								                       
       
   678 
       
   679         iData->iSharedTextureManagers.Close();	    
       
   680 
       
   681         delete iData->iTextureInfoMonitor;
       
   682         iData->iTextureInfoMonitor = NULL;
       
   683 
       
   684         // ... close, release, delete other member data...
       
   685         iData->iActionObservers.Close();
       
   686         
       
   687         // Disconnect and delete client if owned
       
   688         if ( (iData->iFlags&EOwnClient) && iData->iClient )
       
   689             {
       
   690             iData->iClient->Disconnect();
       
   691             delete iData->iClient;
       
   692             }
       
   693         iData->iClient = NULL;
       
   694         iData->iFlags &= ~EOwnClient;
       
   695         
       
   696         delete iData->iLayoutMetricsUtility;
       
   697         
       
   698       
       
   699 
       
   700         delete iData->iStatic;
       
   701         }
       
   702     
       
   703     // Delete struct
       
   704     delete iData;
       
   705     iData = NULL;
       
   706 
       
   707 /*  
       
   708     // AknEventMonitor can be used if we want to know the target control also
       
   709     // Otherwise CoeMonitor should be used for better compatibility between 
       
   710     // releases 
       
   711   
       
   712     CAknAppUi* appUi = iAvkonAppUi; // actually macro using coe static...
       
   713     if (appUi && appUi->EventMonitor())
       
   714         {
       
   715         appUi->EventMonitor()->RemoveObserver(this);
       
   716         appUi->EventMonitor()->Enable(EFalse);
       
   717         }
       
   718 */
       
   719 
       
   720     CCoeEnv* coeStatic = CCoeEnv::Static();
       
   721     if ( coeStatic )
       
   722         {
       
   723         coeStatic->RemoveMessageMonitorObserver(*this);
       
   724         }
       
   725     }
       
   726 
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // Returns the client
       
   730 // ---------------------------------------------------------------------------
       
   731 //
       
   732 EXPORT_C RAlfClient& CAlfEnv::Client()
       
   733     {
       
   734     __ASSERT_ALWAYS( iData, USER_INVARIANT() );
       
   735     __ASSERT_ALWAYS( iData->iClient, USER_INVARIANT() );
       
   736     __ASSERT_ALWAYS( iData->iClient->Handle(), USER_INVARIANT() );
       
   737     
       
   738     iData->iClient->SetAlfEnv(*this);
       
   739     return *iData->iClient;
       
   740     }
       
   741 
       
   742 // ---------------------------------------------------------------------------
       
   743 // Creates new display
       
   744 // ---------------------------------------------------------------------------
       
   745 //    
       
   746 EXPORT_C CAlfDisplay& CAlfEnv::NewDisplayL(
       
   747     const TRect& aRect,
       
   748     TInt aFlags,
       
   749     TInt aDisplayType)
       
   750     {
       
   751     return NewDisplayL(aRect, aFlags, NULL, aDisplayType, KAlfUidBackBufferScreen0);    
       
   752     }  
       
   753     
       
   754 // ---------------------------------------------------------------------------
       
   755 // Creates new display
       
   756 // ---------------------------------------------------------------------------
       
   757 //    
       
   758 EXPORT_C CAlfDisplay& CAlfEnv::NewDisplayL( 
       
   759 	const TRect& aRect, 
       
   760 	TInt aFlags, 
       
   761 	CAlfDisplay* /*aRosterOwningDisplay*/, 
       
   762     TInt aDisplayType, 
       
   763     TUid aBackBufferUid )
       
   764     {
       
   765     CAlfRoster* roster = NULL;
       
   766     
       
   767     if(aFlags & ENewDisplayOverlaid)
       
   768         {
       
   769         roster = iData->iSharedRoster;
       
   770         }
       
   771     
       
   772     TBool asCoeControl = EFalse;
       
   773     if ( aFlags & ENewDisplayAsCoeControl )
       
   774         {
       
   775         asCoeControl = ETrue;
       
   776         }
       
   777            
       
   778     CAlfDisplay* display = new (ELeave) CAlfDisplay;
       
   779     CleanupStack::PushL(display);
       
   780     display->ConstructL(*this, asCoeControl,aRect, roster, aDisplayType, aBackBufferUid);
       
   781     CleanupStack::Pop(display);
       
   782     TInt err = iData->iDisplays.Append(display);
       
   783     if ( err != KErrNone )
       
   784         {
       
   785         delete display;
       
   786         User::Leave( err );
       
   787         }                
       
   788     return *display;
       
   789     }  
       
   790 // ---------------------------------------------------------------------------
       
   791 // Called when display is deleted.
       
   792 // ---------------------------------------------------------------------------
       
   793 // 
       
   794 void CAlfEnv::RemoveDisplay(CAlfDisplay& aDisplay)
       
   795     {
       
   796     // Actually this is "DestroyDisplay"
       
   797 
       
   798     /** @todo  Make a proper observer. */
       
   799     TInt index = iData->iDisplays.Find(&aDisplay);
       
   800     if(index >= 0)
       
   801         {
       
   802         iData->iDisplays.Remove(index);
       
   803         iData->iDisplays.Compress();
       
   804         }
       
   805     // @todo: remove from the server side
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 // Creates new control group
       
   810 // ---------------------------------------------------------------------------
       
   811 //
       
   812 EXPORT_C CAlfControlGroup& CAlfEnv::NewControlGroupL( TInt aId )
       
   813     {
       
   814     if ( FindControlGroup( aId ) )
       
   815         {
       
   816         User::Leave( KErrAlreadyExists );
       
   817         }
       
   818     
       
   819     CAlfControlGroup* group = new (ELeave) CAlfControlGroup;
       
   820     CleanupStack::PushL( group );
       
   821     group->ConstructL( aId, *this );
       
   822     CleanupStack::Pop( group );
       
   823     TInt err = iData->iLoadedGroups.Append( group );
       
   824     if ( err != KErrNone )
       
   825         {
       
   826         delete group;
       
   827         User::Leave( err );
       
   828         }
       
   829     
       
   830     return *group;
       
   831     }
       
   832  
       
   833 // ---------------------------------------------------------------------------
       
   834 // Deletes control group
       
   835 // ---------------------------------------------------------------------------
       
   836 //   
       
   837 EXPORT_C TInt CAlfEnv::DeleteControlGroup(TInt aId)
       
   838     {
       
   839     TInt i;
       
   840 
       
   841     for(i = 0; i < iData->iLoadedGroups.Count(); ++i)
       
   842         {
       
   843         if(iData->iLoadedGroups[i]->ResourceId() == aId)
       
   844             {
       
   845             CAlfControlGroup* group = iData->iLoadedGroups[i];
       
   846 
       
   847             CancelCommands(group);
       
   848 
       
   849             for (TInt ii = iData->iDisplays.Count()-1; ii>=0; ii--)
       
   850                 {
       
   851                 CAlfRoster& r = iData->iDisplays[ii]->Roster();
       
   852                 TInt index = r.Find(*group);
       
   853                 if (index != KErrNotFound)
       
   854                     {
       
   855                     r.Hide(*group); // update server
       
   856                     r.Remove(group); // update client 
       
   857                     }
       
   858                 }
       
   859 
       
   860             // This is control group to delete.
       
   861             iData->iLoadedGroups.Remove(i);
       
   862             delete group;
       
   863             return KErrNone;
       
   864             }
       
   865         }
       
   866 
       
   867     return KErrNotFound;
       
   868     }
       
   869     
       
   870 // ---------------------------------------------------------------------------
       
   871 // Returns control group with ID
       
   872 // ---------------------------------------------------------------------------
       
   873 //
       
   874 EXPORT_C CAlfControlGroup& CAlfEnv::ControlGroup(TInt aResourceId)
       
   875     {
       
   876     for(TInt i = 0; i < iData->iLoadedGroups.Count(); ++i)
       
   877         {
       
   878         if(iData->iLoadedGroups[i]->ResourceId() == aResourceId)
       
   879             {
       
   880             return *iData->iLoadedGroups[i];
       
   881             }
       
   882         }
       
   883 
       
   884     // Group hasn't been loaded yet
       
   885     /** @todo load automatically? */
       
   886     __ASSERT_DEBUG( EFalse, USER_INVARIANT() );
       
   887     return *iData->iLoadedGroups[0];
       
   888     }
       
   889    
       
   890 // ---------------------------------------------------------------------------
       
   891 // Returns control group with ID or NULL if not found
       
   892 // ---------------------------------------------------------------------------
       
   893 // 
       
   894 EXPORT_C CAlfControlGroup* CAlfEnv::FindControlGroup(TInt aResourceId) const
       
   895     {
       
   896     for(TInt i = 0; i < iData->iLoadedGroups.Count(); ++i)
       
   897         {
       
   898         if(iData->iLoadedGroups[i]->ResourceId() == aResourceId)
       
   899             {
       
   900             return iData->iLoadedGroups[i];
       
   901             }
       
   902         }
       
   903 
       
   904     return NULL;
       
   905     }
       
   906 
       
   907 // ---------------------------------------------------------------------------
       
   908 // Returns control with ID
       
   909 // ---------------------------------------------------------------------------
       
   910 //
       
   911 EXPORT_C CAlfControl* CAlfEnv::FindControl(TInt aId, TBool aUserId) const
       
   912     {
       
   913     for(TInt i = 0; i < iData->iLoadedGroups.Count(); ++i)
       
   914         {
       
   915         CAlfControl* control = iData->iLoadedGroups[i]->FindControl(aId, aUserId);
       
   916         if(control)
       
   917             {
       
   918             return control;
       
   919             }
       
   920         }
       
   921         
       
   922     // If we cannot found it from any of the groups, check the connections
       
   923     for(TInt groupIndex = 0; groupIndex < iData->iLoadedGroups.Count(); ++groupIndex)
       
   924         {
       
   925         CAlfControlGroup* controlGroup = iData->iLoadedGroups[groupIndex];
       
   926         
       
   927         for ( TInt controlIndex = 0 ; controlIndex < controlGroup->Count() ; controlIndex++ )
       
   928             {
       
   929             CAlfControl* foundControl = FindConnectedControl(controlGroup->Control(controlIndex), aId, aUserId);
       
   930             if ( foundControl )
       
   931                 {
       
   932                 return foundControl;
       
   933                 }
       
   934             }
       
   935         } 
       
   936         
       
   937     // The control does not exist.
       
   938     return NULL;
       
   939     }
       
   940 
       
   941 // ---------------------------------------------------------------------------
       
   942 // Returns display count
       
   943 // ---------------------------------------------------------------------------
       
   944 //
       
   945 EXPORT_C TInt CAlfEnv::DisplayCount() const
       
   946     {
       
   947     return iData->iDisplays.Count();
       
   948     }
       
   949  
       
   950 // ---------------------------------------------------------------------------
       
   951 // Set refresh mode.
       
   952 // ---------------------------------------------------------------------------
       
   953 //   
       
   954 EXPORT_C void CAlfEnv::SetRefreshMode( TAlfRefreshMode aMode )
       
   955     {
       
   956     if(aMode == EAlfRefreshModeAutomatic)
       
   957         {
       
   958         // syncronoushly rasterize all the changed text visuals
       
   959         iData->iTextStyleManager->RefreshAllVisuals();
       
   960         }
       
   961     Client().EnvSetRefreshMode( aMode );
       
   962     iData->iRefreshMode = TAlfRefreshMode(aMode);
       
   963     }
       
   964     
       
   965 // ---------------------------------------------------------------------------
       
   966 // Set max frame rate.
       
   967 // ---------------------------------------------------------------------------
       
   968 // 
       
   969 EXPORT_C void CAlfEnv::SetMaxFrameRate( TReal32 aFrameRate ) __SOFTFP
       
   970     {
       
   971     Client().EnvSetMaxFrameRate( aFrameRate );
       
   972     iData->iMaxFrameRate = (TInt)aFrameRate;
       
   973     }
       
   974 
       
   975 // ---------------------------------------------------------------------------
       
   976 // Continues refresh
       
   977 // ---------------------------------------------------------------------------
       
   978 //    
       
   979 EXPORT_C void CAlfEnv::ContinueRefresh()
       
   980     {
       
   981     Client().EnvContinueRefresh();
       
   982     }
       
   983 
       
   984 // ---------------------------------------------------------------------------
       
   985 // Pauses refresh
       
   986 // ---------------------------------------------------------------------------
       
   987 //    
       
   988 EXPORT_C void CAlfEnv::PauseRefresh()
       
   989     {
       
   990     Client().EnvPauseRefresh();
       
   991     }
       
   992   
       
   993 // ---------------------------------------------------------------------------
       
   994 // Called when a redraw is wanted
       
   995 // ---------------------------------------------------------------------------
       
   996 //    
       
   997 EXPORT_C TInt CAlfEnv::RefreshCallBack(TAny* aInstance)
       
   998     {
       
   999     CAlfEnv* self = static_cast<CAlfEnv*>( aInstance );
       
  1000     self->Client().EnvRefreshCallBack();
       
  1001     return KErrNone;
       
  1002     }
       
  1003     
       
  1004 // ---------------------------------------------------------------------------
       
  1005 // Returns the first display
       
  1006 // ---------------------------------------------------------------------------
       
  1007 //
       
  1008 EXPORT_C CAlfDisplay& CAlfEnv::PrimaryDisplay() const
       
  1009     {
       
  1010     return *iData->iDisplays[0];
       
  1011     }
       
  1012 
       
  1013 // ---------------------------------------------------------------------------
       
  1014 // 
       
  1015 // ---------------------------------------------------------------------------
       
  1016 //
       
  1017 EXPORT_C CAlfTextureManager& CAlfEnv::TextureManager() const
       
  1018     {
       
  1019     return *iData->iTextureManager;
       
  1020     }
       
  1021 
       
  1022 // ---------------------------------------------------------------------------
       
  1023 // 
       
  1024 // ---------------------------------------------------------------------------
       
  1025 //
       
  1026 EXPORT_C CAlfTextStyleManager& CAlfEnv::TextStyleManager() const
       
  1027     {
       
  1028     return *iData->iTextStyleManager;
       
  1029     }
       
  1030 
       
  1031 // ---------------------------------------------------------------------------
       
  1032 // From class MAknWsEventObserver
       
  1033 // Controls server based on raw ws events
       
  1034 // ---------------------------------------------------------------------------
       
  1035 //
       
  1036 void CAlfEnv::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* /*aDestination*/)
       
  1037     {
       
  1038     __ASSERT_ALWAYS(iData, USER_INVARIANT());
       
  1039 
       
  1040 	TInt eventType = aEvent.Type();
       
  1041 	// block these two here to avoid any extra execution beneath avkon level
       
  1042     if (eventType == KAknFullOrPartialForegroundLost ||
       
  1043         eventType == KAknFullOrPartialForegroundGained )
       
  1044         {        
       
  1045         const TBool foreground = (eventType == KAknFullOrPartialForegroundGained);      
       
  1046          
       
  1047         iData->iClient->ApplicationIsForeground(foreground);
       
  1048         iData->iScheduler->AppicationOnForeground(foreground);
       
  1049 
       
  1050         if (foreground)
       
  1051             {
       
  1052             ReportWsEventAsActionCommand(KAlfActionIdForegroundGained); 
       
  1053             }
       
  1054         else
       
  1055             {            
       
  1056             ReportWsEventAsActionCommand(KAlfActionIdForegroundLost);    
       
  1057             }                                    
       
  1058         } 
       
  1059     else if (eventType == EEventFocusGained)
       
  1060         {
       
  1061         ReportWsEventAsActionCommand(KAlfActionIdFocusGained);            
       
  1062         }        
       
  1063     else if (eventType == EEventFocusLost)
       
  1064         {
       
  1065         ReportWsEventAsActionCommand(KAlfActionIdFocusLost);                        
       
  1066         }        
       
  1067     else if (eventType == KEikInputLanguageChange)
       
  1068         {
       
  1069         ReportWsEventAsActionCommand(KAlfActionIdInputLanguageChanged);    
       
  1070         }
       
  1071     else if (eventType == EEventUser)
       
  1072         {
       
  1073         TApaSystemEvent* systemEvent = (TApaSystemEvent*) aEvent.EventData();
       
  1074         if (*systemEvent == EApaSystemEventSecureShutdown)
       
  1075             {
       
  1076             ReportWsEventAsActionCommand(KAlfActionIdExitRequested);        
       
  1077             }
       
  1078         else if (CEikonEnv::Static())
       
  1079             {                                         
       
  1080             if (*systemEvent == EApaSystemEventShutdown && 
       
  1081                 !CEikonEnv::Static()->IsSystem())
       
  1082                 {
       
  1083                 ReportWsEventAsActionCommand(KAlfActionIdExitRequested);    
       
  1084                 }
       
  1085             }
       
  1086         }        
       
  1087     else
       
  1088         {
       
  1089         // for PC lint
       
  1090         }
       
  1091 
       
  1092 
       
  1093     // - Skin change events are handled from CAlfSystemEventFetcher
       
  1094     // - Layout change events are handled from CAlfDisplay
       
  1095     }
       
  1096 
       
  1097 // ---------------------------------------------------------------------------
       
  1098 // 
       
  1099 // ---------------------------------------------------------------------------
       
  1100 //
       
  1101 EXPORT_C void CAlfEnv::AddActionObserverL(MAlfActionObserver* aObserver)
       
  1102     {
       
  1103     if (iData->iActionObservers.Find(aObserver) == KErrNotFound)
       
  1104         {
       
  1105         iData->iActionObservers.AppendL(aObserver);        
       
  1106         }
       
  1107     }
       
  1108     
       
  1109 // ---------------------------------------------------------------------------
       
  1110 // 
       
  1111 // ---------------------------------------------------------------------------
       
  1112 //
       
  1113 EXPORT_C void CAlfEnv::RemoveActionObserver(MAlfActionObserver* aObserver)
       
  1114     {
       
  1115     TInt index = iData->iActionObservers.Find(aObserver); 
       
  1116     if (index != KErrNotFound )
       
  1117         {
       
  1118         iData->iActionObservers.Remove(index);            
       
  1119         }
       
  1120     }
       
  1121     
       
  1122 // ---------------------------------------------------------------------------
       
  1123 // 
       
  1124 // ---------------------------------------------------------------------------
       
  1125 //
       
  1126 void CAlfEnv::HandleActionL(const TAlfActionCommand& aActionCommand)
       
  1127     { // handle in reverse order as action observer may remove it self during handling of command
       
  1128     for (TInt ii = iData->iActionObservers.Count()-1; ii >= 0; ii-- )
       
  1129         {
       
  1130         iData->iActionObservers[ii]->HandleActionL(aActionCommand);
       
  1131         }
       
  1132     }
       
  1133     
       
  1134     
       
  1135 // ---------------------------------------------------------------------------
       
  1136 // 
       
  1137 // ---------------------------------------------------------------------------
       
  1138 //
       
  1139 EXPORT_C TInt CAlfEnv::Send(const TAlfCommand& aCommand, TInt aDelayMilliSeconds )
       
  1140     {
       
  1141     TRAPD( err , iData->iScheduler->ScheduleCommandL( aCommand, aDelayMilliSeconds ) );
       
  1142     return err;
       
  1143     }
       
  1144     
       
  1145 // ---------------------------------------------------------------------------
       
  1146 // 
       
  1147 // ---------------------------------------------------------------------------
       
  1148 //
       
  1149 EXPORT_C void CAlfEnv::CancelCommands( TAny* aObject )
       
  1150     {
       
  1151     if (iData->iScheduler)
       
  1152         {
       
  1153         iData->iScheduler->CancelCommands( aObject );
       
  1154         }
       
  1155     }
       
  1156     
       
  1157 // ---------------------------------------------------------------------------
       
  1158 // 
       
  1159 // ---------------------------------------------------------------------------
       
  1160 //
       
  1161 EXPORT_C void CAlfEnv::CancelCustomCommands(MAlfEventHandler* aObject)
       
  1162     {
       
  1163     if (iData->iScheduler)
       
  1164         {
       
  1165         iData->iScheduler->CancelCommands( aObject );
       
  1166         }
       
  1167     }
       
  1168 
       
  1169 // ---------------------------------------------------------------------------
       
  1170 // 
       
  1171 // ---------------------------------------------------------------------------
       
  1172 //
       
  1173 EXPORT_C void CAlfEnv::CancelCommands(TAny* aObject, TAlfOp aCommandOperation)
       
  1174     {
       
  1175     if (iData->iScheduler)
       
  1176         {
       
  1177         iData->iScheduler->CancelCommands( aObject , aCommandOperation );
       
  1178         }
       
  1179     }
       
  1180 
       
  1181 // ---------------------------------------------------------------------------
       
  1182 // 
       
  1183 // ---------------------------------------------------------------------------
       
  1184 //
       
  1185 EXPORT_C void CAlfEnv::CancelCommands( TAny* aObject, TAlfCommandType aCommandType )
       
  1186     {
       
  1187     // use overloaded CancelCustomCommands instead for custom commands
       
  1188     __ASSERT_DEBUG( aCommandType != EAlfCommandTypeCustomEvent, USER_INVARIANT() );
       
  1189     
       
  1190     if (iData->iScheduler)
       
  1191         {
       
  1192         iData->iScheduler->CancelCommands( aObject, aCommandType, 0 );
       
  1193         }
       
  1194     }
       
  1195 
       
  1196 // ---------------------------------------------------------------------------
       
  1197 // 
       
  1198 // ---------------------------------------------------------------------------
       
  1199 //    
       
  1200 EXPORT_C void CAlfEnv::CancelCustomCommands(MAlfEventHandler* aObject, TInt aCustomParam )
       
  1201     {
       
  1202     if (iData->iScheduler)
       
  1203         {
       
  1204         iData->iScheduler->CancelCommands( aObject, EAlfCommandTypeCustomEvent, aCustomParam );
       
  1205         }
       
  1206     }
       
  1207 // ---------------------------------------------------------------------------
       
  1208 // 
       
  1209 // ---------------------------------------------------------------------------
       
  1210 //
       
  1211 EXPORT_C TInt CAlfEnv::MilliSecondsUntilCommand( TAny* aObject )
       
  1212     {
       
  1213     return iData->iScheduler->MilliSecondsUntilCommand( aObject ); 
       
  1214     }
       
  1215     
       
  1216 // ---------------------------------------------------------------------------
       
  1217 // 
       
  1218 // ---------------------------------------------------------------------------
       
  1219 //
       
  1220 EXPORT_C TInt CAlfEnv::MilliSecondsUntilCustomCommand(MAlfEventHandler* aObject)
       
  1221     {
       
  1222     return iData->iScheduler->MilliSecondsUntilCommand( aObject ); 
       
  1223     }
       
  1224 
       
  1225 // ---------------------------------------------------------------------------
       
  1226 // 
       
  1227 // ---------------------------------------------------------------------------
       
  1228 //
       
  1229 EXPORT_C TInt CAlfEnv::MilliSecondsUntilCommand(TAny* aObject, TAlfOp aCommandOperation)
       
  1230     {
       
  1231     return iData->iScheduler->MilliSecondsUntilCommand( aObject , aCommandOperation ); 
       
  1232     }
       
  1233 
       
  1234 // ---------------------------------------------------------------------------
       
  1235 // 
       
  1236 // ---------------------------------------------------------------------------
       
  1237 //
       
  1238 EXPORT_C TInt CAlfEnv::MilliSecondsUntilCommand( TAny* aObject, TAlfCommandType aCommandType )
       
  1239     {
       
  1240     // use overloaded CancelCustomCommands instead for custom commands
       
  1241     __ASSERT_DEBUG( aCommandType != EAlfCommandTypeCustomEvent, USER_INVARIANT() );
       
  1242     
       
  1243     return iData->iScheduler->MilliSecondsUntilCommand( aObject, aCommandType, 0 ); 
       
  1244     }
       
  1245 
       
  1246 // ---------------------------------------------------------------------------
       
  1247 // 
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //    
       
  1250 EXPORT_C TInt CAlfEnv::MilliSecondsUntilCustomCommand(MAlfEventHandler* aObject, TInt aCustomParam )
       
  1251     {
       
  1252     return iData->iScheduler->MilliSecondsUntilCommand( aObject, EAlfCommandTypeCustomEvent, aCustomParam ); 
       
  1253     }
       
  1254     
       
  1255 // ---------------------------------------------------------------------------
       
  1256 // 
       
  1257 // ---------------------------------------------------------------------------
       
  1258 //
       
  1259 EXPORT_C TKeyResponse CAlfEnv::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType,
       
  1260                                         CAlfDisplay* aAssocDisplay)
       
  1261     {
       
  1262     if(aAssocDisplay)
       
  1263         {
       
  1264         TAlfEvent event(*aAssocDisplay, aKeyEvent, aType);
       
  1265 
       
  1266         if(aAssocDisplay->Roster().HandleEventL(event))
       
  1267             {
       
  1268             return EKeyWasConsumed;
       
  1269             }
       
  1270         return EKeyWasNotConsumed;
       
  1271         }
       
  1272 
       
  1273     return EKeyWasNotConsumed;
       
  1274     }
       
  1275     
       
  1276 // ---------------------------------------------------------------------------
       
  1277 // 
       
  1278 // ---------------------------------------------------------------------------
       
  1279 //
       
  1280 void CAlfEnv::BroadcastEventL(const TAlfEvent& aEvent)
       
  1281     {
       
  1282     for(TInt i = 0; i < iData->iDisplays.Count(); ++i)
       
  1283         {
       
  1284         TAlfEvent event = aEvent;
       
  1285         event.SetDisplay( iData->iDisplays[i] );
       
  1286         /** @todo  Musn't access the roster directly. */
       
  1287         iData->iDisplays[i]->Roster().HandleEventL(event);
       
  1288         }
       
  1289     }
       
  1290 
       
  1291 // ---------------------------------------------------------------------------
       
  1292 // 
       
  1293 // ---------------------------------------------------------------------------
       
  1294 //
       
  1295 TInt CAlfEnv::ReportAction(const TAlfActionCommand& aCommand)
       
  1296     {
       
  1297     TInt resultError = KErrNone;
       
  1298 
       
  1299     for(TInt i = 0; i < iData->iActionObservers.Count(); ++i)
       
  1300         {
       
  1301         TRAPD(err, iData->iActionObservers[i]->HandleActionL(aCommand));
       
  1302         if(err != KErrNone && resultError == KErrNone)
       
  1303             {
       
  1304             // The first error code is returned.
       
  1305             resultError = err;
       
  1306             }
       
  1307         }
       
  1308     return resultError;
       
  1309     }
       
  1310 
       
  1311 // ---------------------------------------------------------------------------
       
  1312 // 
       
  1313 // ---------------------------------------------------------------------------
       
  1314 //
       
  1315 EXPORT_C CAlfTextureManager* CAlfEnv::CreateSharedTextureManagerL(TUid aUid)
       
  1316     {
       
  1317     CAlfTextureManager* retVal = NULL;
       
  1318     RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1319     TInt count = managers.Count();
       
  1320     for(TInt i = 0; i < count; i++)
       
  1321       	{
       
  1322     	if (managers[i].iTextureManager->ManagerUid() == aUid)
       
  1323     		{
       
  1324     		managers[i].iRefCount++;    			
       
  1325     		retVal = managers[i].iTextureManager;
       
  1326     		}
       
  1327     	}
       
  1328     	
       
  1329     // Does not yet exist, create new one	
       
  1330     if (!retVal)
       
  1331         {
       
  1332        	CAlfTextureManager* manager = CAlfTextureManager::NewL(*this, aUid);	  								                       
       
  1333         TSharedTextureManagerEntry entry(manager);
       
  1334         managers.Append(entry);
       
  1335         retVal = manager;    	          
       
  1336         retVal->AddLoadObserverL(this);
       
  1337         retVal->AddStateObserverL(this);        
       
  1338         }                
       
  1339 
       
  1340     return retVal;    
       
  1341     }
       
  1342 
       
  1343 // ---------------------------------------------------------------------------
       
  1344 // 
       
  1345 // ---------------------------------------------------------------------------
       
  1346 //
       
  1347 EXPORT_C void CAlfEnv::DeleteSharedTextureManager(TUid aUid)
       
  1348     {
       
  1349     RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1350     TInt count = managers.Count();
       
  1351     for(TInt i = 0; i < count; i++)
       
  1352       	{
       
  1353     	if (managers[i].iTextureManager->ManagerUid() == aUid)
       
  1354     		{
       
  1355     		if (managers[i].iRefCount <= 1)
       
  1356     		    {
       
  1357                 managers[i].iTextureManager->RemoveLoadObserver(this);
       
  1358                 managers[i].iTextureManager->RemoveStateObserver(this);
       
  1359     		    delete managers[i].iTextureManager;
       
  1360        			managers.Remove(i);
       
  1361        			managers.Compress();    			        
       
  1362     		    }
       
  1363     		else
       
  1364     		    {
       
  1365     		    managers[i].iRefCount--;        
       
  1366     		    }    			    
       
  1367     		break;
       
  1368     		}  								                       
       
  1369         }                
       
  1370     }
       
  1371 
       
  1372 // ---------------------------------------------------------------------------
       
  1373 // 
       
  1374 // ---------------------------------------------------------------------------
       
  1375 //
       
  1376 EXPORT_C CAlfTextureManager* CAlfEnv::SharedTextureManager(TUid aUid) const
       
  1377     {
       
  1378     CAlfTextureManager* retVal = NULL;
       
  1379 
       
  1380     RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1381     TInt count = managers.Count();
       
  1382     for(TInt i = 0; i < count; i++)
       
  1383       	{
       
  1384     	if (managers[i].iTextureManager->ManagerUid() == aUid)
       
  1385     		{
       
  1386             retVal = managers[i].iTextureManager;
       
  1387          	break;
       
  1388     		}  								                       
       
  1389         }                
       
  1390         
       
  1391     return retVal;    
       
  1392     }
       
  1393 
       
  1394 // ---------------------------------------------------------------------------
       
  1395 // 
       
  1396 // ---------------------------------------------------------------------------
       
  1397 //
       
  1398 void CAlfEnv::TextureLoadingCompleted(CAlfTexture& /*aTexture*/,
       
  1399                                          TInt /*aTextureId*/,
       
  1400                                          TInt /*aErrorCode*/)
       
  1401     {
       
  1402     // This is not used at the moment, but in the future may be needed.            
       
  1403     }
       
  1404 
       
  1405 
       
  1406 // ---------------------------------------------------------------------------
       
  1407 // 
       
  1408 // ---------------------------------------------------------------------------
       
  1409 //
       
  1410 void CAlfEnv::TextureManagerStateChanged(const CAlfTextureManager& /*aManager*/)
       
  1411     {
       
  1412     // When texture manager is loading, reduce framerate little.
       
  1413 /*
       
  1414     if (aManager.State() == CAlfTextureManager::EIdle)
       
  1415         {
       
  1416         Client().EnvSetMaxFrameRate( iData->iMaxFrameRate );
       
  1417         }
       
  1418     else
       
  1419         {        
       
  1420         Client().EnvSetMaxFrameRate( iData->iMaxFrameRate/2 );            
       
  1421         }            
       
  1422 */
       
  1423     }
       
  1424 
       
  1425 // ---------------------------------------------------------------------------
       
  1426 // 
       
  1427 // ---------------------------------------------------------------------------
       
  1428 //
       
  1429 EXPORT_C TAlfRefreshMode CAlfEnv::RefreshMode()
       
  1430     {
       
  1431     return iData->iRefreshMode;    
       
  1432     }
       
  1433 
       
  1434 // ---------------------------------------------------------------------------
       
  1435 // 
       
  1436 // ---------------------------------------------------------------------------
       
  1437 //
       
  1438 EXPORT_C TAlfRenderer CAlfEnv::Renderer() const
       
  1439     {
       
  1440     return TAlfRenderer(iData->iClient->EnvRenderer());            
       
  1441     }
       
  1442 
       
  1443 // ---------------------------------------------------------------------------
       
  1444 // 
       
  1445 // ---------------------------------------------------------------------------
       
  1446 //
       
  1447 EXPORT_C void CAlfEnv::SetIdleThreshold(TInt aMilliSeconds)
       
  1448     {
       
  1449     Client().EnvSetIdleThreshold(aMilliSeconds);    
       
  1450     }
       
  1451     
       
  1452 // ---------------------------------------------------------------------------
       
  1453 // 
       
  1454 // ---------------------------------------------------------------------------
       
  1455 //
       
  1456 EXPORT_C void CAlfEnv::Release(TBool aReleaseSharedTextures)
       
  1457     {
       
  1458     iData->iTextStyleManager->ReleaseAllVisuals();
       
  1459     
       
  1460     iData->iTextureManager->Release();
       
  1461     if (aReleaseSharedTextures)
       
  1462         {
       
  1463         RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1464         TInt count = managers.Count();
       
  1465         for(TInt i = 0; i < count; i++)
       
  1466           	{
       
  1467         	managers[i].iTextureManager->Release();    	  								                       
       
  1468             }                            
       
  1469         }        
       
  1470 
       
  1471     }
       
  1472    
       
  1473 // ---------------------------------------------------------------------------
       
  1474 // 
       
  1475 // ---------------------------------------------------------------------------
       
  1476 //
       
  1477 EXPORT_C void CAlfEnv::RestoreL()
       
  1478     {
       
  1479     iData->iTextureManager->RestoreL();
       
  1480     RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1481     TInt count = managers.Count();
       
  1482     for(TInt i = 0; i < count; i++)
       
  1483       	{
       
  1484     	managers[i].iTextureManager->RestoreL();    	  								                       
       
  1485         }                            
       
  1486     iData->iTextStyleManager->RefreshAllVisuals();
       
  1487     }
       
  1488     
       
  1489 // ---------------------------------------------------------------------------
       
  1490 // 
       
  1491 // ---------------------------------------------------------------------------
       
  1492 //
       
  1493 EXPORT_C void CAlfEnv::SetFullScreenDrawing(TBool aEnable)
       
  1494     {
       
  1495     Client().SetFullScreenDrawing(aEnable);
       
  1496     }
       
  1497     
       
  1498 // ---------------------------------------------------------------------------
       
  1499 // 
       
  1500 // ---------------------------------------------------------------------------
       
  1501 //
       
  1502 EXPORT_C void CAlfEnv::NotifySkinChangedL()
       
  1503     {
       
  1504     SetSkinChangePending(EFalse);       
       
  1505     iData->iTextureManager->NotifySkinChangedL();
       
  1506     RArray<TSharedTextureManagerEntry>& managers = (iData->iSharedTextureManagers);
       
  1507     TInt count = managers.Count();
       
  1508     for(TInt i = 0; i < count; i++)
       
  1509       	{
       
  1510     	managers[i].iTextureManager->NotifySkinChangedL();    	  								                       
       
  1511         }                            
       
  1512     }
       
  1513 
       
  1514 // ---------------------------------------------------------------------------
       
  1515 // 
       
  1516 // ---------------------------------------------------------------------------
       
  1517 //
       
  1518 EXPORT_C void CAlfEnv::NotifyLayoutChangedL()
       
  1519     {
       
  1520     SetLayoutChangePending(EFalse); 
       
  1521     for(TInt i = 0; i < iData->iDisplays.Count(); ++i)
       
  1522         {
       
  1523         iData->iDisplays[i]->NotifyLayoutChangedL();
       
  1524         }        
       
  1525     }
       
  1526 
       
  1527 
       
  1528 // ---------------------------------------------------------------------------
       
  1529 // 
       
  1530 // ---------------------------------------------------------------------------
       
  1531 //
       
  1532 EXPORT_C RFTokenClient* CAlfEnv::TokenClient()
       
  1533     {
       
  1534     ASSERT(iData);
       
  1535     if (!(iData->iFlags&ETokenClientConnected))
       
  1536         {
       
  1537         TInt err = iData->iTokenClient.Connect();
       
  1538         if (!err)
       
  1539             {
       
  1540             iData->iFlags |= ETokenClientConnected;
       
  1541             }
       
  1542         }
       
  1543     
       
  1544     if (iData->iFlags&ETokenClientConnected)
       
  1545         {
       
  1546         return &iData->iTokenClient;
       
  1547         }
       
  1548     else 
       
  1549         {
       
  1550         return NULL;
       
  1551         }
       
  1552     }
       
  1553 
       
  1554 // ---------------------------------------------------------------------------
       
  1555 // for better compatibility with different S60 releases
       
  1556 // ---------------------------------------------------------------------------
       
  1557 //
       
  1558 void CAlfEnv::MonitorWsMessage(const TWsEvent& aEvent)
       
  1559     {
       
  1560     TRAP_IGNORE(CAlfEnv::HandleWsEventL(aEvent, 0))
       
  1561     }
       
  1562 
       
  1563 
       
  1564 // ---------------------------------------------------------------------------
       
  1565 // 
       
  1566 // ---------------------------------------------------------------------------
       
  1567 //
       
  1568 EXPORT_C CAlfLayoutMetricsUtility* CAlfEnv::LayoutMetricsUtility()
       
  1569     {
       
  1570     return iData->iLayoutMetricsUtility;    
       
  1571     }
       
  1572 
       
  1573 // ---------------------------------------------------------------------------
       
  1574 // DEPRECATED: Widget code removed!
       
  1575 // ---------------------------------------------------------------------------
       
  1576 //
       
  1577 EXPORT_C IAlfWidgetFactory& CAlfEnv::WidgetFactory()const
       
  1578     {
       
  1579     IAlfWidgetFactory* ret(NULL); 
       
  1580     return *ret;    
       
  1581     }
       
  1582 
       
  1583 // ---------------------------------------------------------------------------
       
  1584 // DEPRECATED: Widget code removed!
       
  1585 // ---------------------------------------------------------------------------
       
  1586 //
       
  1587 EXPORT_C void CAlfEnv::AppendWidgetL(IAlfWidget* /*aAlfWidget*/)
       
  1588     {
       
  1589     }
       
  1590 
       
  1591 // ---------------------------------------------------------------------------
       
  1592 // DEPRECATED: Widget code removed!
       
  1593 // ---------------------------------------------------------------------------
       
  1594 //
       
  1595 EXPORT_C TInt CAlfEnv::DestroyWidget(IAlfWidget* /*aAlfWidget*/)
       
  1596     {
       
  1597     return 0;    
       
  1598     }
       
  1599 
       
  1600 // ---------------------------------------------------------------------------
       
  1601 // DEPRECATED: Widget code removed!
       
  1602 // ---------------------------------------------------------------------------
       
  1603 //
       
  1604 EXPORT_C IAlfWidget* CAlfEnv::FindWidget(const char* /*aWidgetName*/) const
       
  1605     {
       
  1606     IAlfWidget* ret(NULL);
       
  1607     return ret;
       
  1608     }
       
  1609 
       
  1610 // ---------------------------------------------------------------------------
       
  1611 // Uses CAlfStatic directly. friend is needed to access dll static 
       
  1612 // ---------------------------------------------------------------------------
       
  1613 //
       
  1614 EXPORT_C CAlfEnv* CAlfEnv::Static()
       
  1615     {
       
  1616     if ( CAlfStatic::Data() )
       
  1617         {
       
  1618         return &CAlfStatic::Env();
       
  1619         }
       
  1620         
       
  1621     return 0;
       
  1622     }
       
  1623 
       
  1624 // ---------------------------------------------------------------------------
       
  1625 // Support for extreme usecases where there are several controls but they don't
       
  1626 // belong to ctrl groups (so env cannot deliver the event by it self, but 
       
  1627 // application needs to fetch events based on notifications from environment) 
       
  1628 // ---------------------------------------------------------------------------
       
  1629 //
       
  1630 EXPORT_C TPointerEvent* CAlfEnv::LastReceivedPtrEvent()
       
  1631     {
       
  1632     if (iData && iData->iPointerEventAo)
       
  1633         {
       
  1634         return &iData->iPointerEventAo->iEvent.iEvent;
       
  1635         }
       
  1636     return 0;
       
  1637     }
       
  1638 
       
  1639 // ---------------------------------------------------------------------------
       
  1640 // 
       
  1641 // ---------------------------------------------------------------------------
       
  1642 //
       
  1643 EXPORT_C TVersion CAlfEnv::Version() const
       
  1644     {
       
  1645     return TVersion(ALF_VERSION_MAJOR, ALF_VERSION_MINOR, ALF_VERSION_BUILD);    
       
  1646     }
       
  1647 
       
  1648 
       
  1649 // ---------------------------------------------------------------------------
       
  1650 // 
       
  1651 // ---------------------------------------------------------------------------
       
  1652 //
       
  1653 TVersion CAlfEnv::ApiVersion() const
       
  1654     {
       
  1655     return iData->iApiVersion;    
       
  1656     }
       
  1657     
       
  1658 // ---------------------------------------------------------------------------
       
  1659 // 
       
  1660 // ---------------------------------------------------------------------------
       
  1661 //
       
  1662 EXPORT_C CAlfBatchBuffer& CAlfEnv::BatchBufferHandler() const
       
  1663     {
       
  1664     return *iData->iBatchBufferHandler;
       
  1665     }
       
  1666 
       
  1667 void CAlfEnv::ReportWsEventAsActionCommand(TInt aActionCommandId)
       
  1668     {
       
  1669     if (aActionCommandId == KAlfActionIdDeviceLayoutChanged) 
       
  1670         {            
       
  1671         SetLayoutChangePending(ETrue); 
       
  1672         ReportAction(TAlfActionCommand(aActionCommandId));      
       
  1673         // If action obeserver did not call NotifyLayoutChangedL, we do it.
       
  1674         if (LayoutChangePending())
       
  1675             {
       
  1676             TRAP_IGNORE(NotifyLayoutChangedL());    
       
  1677             }
       
  1678         }
       
  1679     else
       
  1680         {
       
  1681         ReportAction(TAlfActionCommand(aActionCommandId));      
       
  1682         }            
       
  1683     }
       
  1684 
       
  1685 // ---------------------------------------------------------------------------
       
  1686 // 
       
  1687 // ---------------------------------------------------------------------------
       
  1688 //
       
  1689 TBool CAlfEnv::SkinChangePending() const
       
  1690     {
       
  1691     return iData->iNotifySkinChangePending;    
       
  1692     }
       
  1693 
       
  1694 // ---------------------------------------------------------------------------
       
  1695 // 
       
  1696 // ---------------------------------------------------------------------------
       
  1697 //
       
  1698 void CAlfEnv::SetSkinChangePending(TBool aPending)
       
  1699     {
       
  1700     iData->iNotifySkinChangePending = aPending;        
       
  1701     }
       
  1702 
       
  1703 // ---------------------------------------------------------------------------
       
  1704 // 
       
  1705 // ---------------------------------------------------------------------------
       
  1706 //
       
  1707 TBool CAlfEnv::LayoutChangePending() const
       
  1708     {
       
  1709     return iData->iNotifyLayoutChangePending;   
       
  1710     }
       
  1711 
       
  1712 // ---------------------------------------------------------------------------
       
  1713 // 
       
  1714 // ---------------------------------------------------------------------------
       
  1715 //
       
  1716 void CAlfEnv::SetLayoutChangePending(TBool aPending)
       
  1717     {
       
  1718     iData->iNotifyLayoutChangePending = aPending;    
       
  1719     }
       
  1720 
       
  1721 
       
  1722 // ---------------------------------------------------------------------------
       
  1723 // 
       
  1724 // ---------------------------------------------------------------------------
       
  1725 //
       
  1726 void CAlfEnv::HandleTextureInfo( const TDesC8& aEventData )
       
  1727     {
       
  1728     // Notify texture manager with new information.
       
  1729 
       
  1730     TAlfTextureInfoEvent eventData;
       
  1731     TPckg< TAlfTextureInfoEvent > eventBuf( eventData );
       
  1732     const TInt eventBufMaxLength = eventBuf.MaxLength();
       
  1733     TPtrC8 remainder( aEventData );
       
  1734     
       
  1735     while ( eventBufMaxLength <= remainder.Length() )
       
  1736         {
       
  1737         // Get event data - note that as data is copied to local buffer,
       
  1738         // there is no need to worry about padding issues.
       
  1739         eventBuf.Copy( remainder.Left( eventBufMaxLength ) );
       
  1740         remainder.Set( remainder.Mid( eventBufMaxLength ) );
       
  1741         
       
  1742         // Inform texture manager.
       
  1743         TRAP_IGNORE(iData->iTextureManager->ReportTextureInfoL( 
       
  1744             eventData.iTextureId, 
       
  1745             eventData.iTextureSize ));      
       
  1746         }
       
  1747             
       
  1748     // Note: texture information events are not delivered to shared texture
       
  1749     // managers (iData->iSharedTextureManagers) as this feature is not supported
       
  1750     // for those.    
       
  1751     }
       
  1752 
       
  1753 
       
  1754 
       
  1755 EXPORT_C MAlfEnvObject* CAlfEnv::Extension( TInt aUid) const
       
  1756     {
       
  1757     TPrivateData::TObjectHolder holder;
       
  1758     holder.iUid = aUid;
       
  1759     TInt index = iData->iExtensionArray.Find(holder);
       
  1760     if (index!=KErrNotFound)
       
  1761         {
       
  1762         return iData->iExtensionArray[index].iObject;
       
  1763         }
       
  1764     else
       
  1765         {
       
  1766         return NULL;
       
  1767         } 
       
  1768     }
       
  1769 
       
  1770 EXPORT_C TInt CAlfEnv::AddExtension( TInt aUid, MAlfEnvObject* aNewExtension)
       
  1771     {
       
  1772     TPrivateData::TObjectHolder holder;
       
  1773     holder.iUid = aUid;
       
  1774     holder.iObject = aNewExtension;
       
  1775     return iData->iExtensionArray.Append(holder);
       
  1776     }
       
  1777 
       
  1778 EXPORT_C void CAlfEnv::HandlePointerEventL(const TPointerEvent& aPointerEvent, 
       
  1779                                    CAlfDisplay& aAssocDisplay)
       
  1780     {
       
  1781     aAssocDisplay.HandlePointerEventL(aPointerEvent);
       
  1782     }
       
  1783 
       
  1784 // ---------------------------------------------------------------------------
       
  1785 // Returns index of the display
       
  1786 // ---------------------------------------------------------------------------
       
  1787 //
       
  1788 EXPORT_C TInt CAlfEnv::FindDisplayIndex(const CAlfDisplay& aDisplay) const
       
  1789     {
       
  1790     TInt index = iData->iDisplays.Find(&aDisplay);
       
  1791     return index;
       
  1792     }
       
  1793     
       
  1794 // ---------------------------------------------------------------------------
       
  1795 // Returns indexed display
       
  1796 // ---------------------------------------------------------------------------
       
  1797 //    
       
  1798 EXPORT_C CAlfDisplay& CAlfEnv::Display( TInt aIndex) const
       
  1799     {
       
  1800     return *iData->iDisplays[aIndex];
       
  1801     }
       
  1802