tstaskmonitor/server/src/tsfswmonitor.cpp
changeset 83 156f692b1687
parent 80 397d00875918
equal deleted inserted replaced
80:397d00875918 83:156f692b1687
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     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:  ws monitor implementation
       
    15  *
     8  *
    16 */
     9  * Initial Contributors:
    17 
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  ws monitor implementation
       
    15  *
       
    16  */
    18 
    17 
    19 #include "tsfswmonitor.h"
    18 #include "tsfswmonitor.h"
    20 #include "tsfswobservers.h"
    19 #include "tsdataobserver.h"
    21 
    20 
    22 // --------------------------------------------------------------------------
    21 // --------------------------------------------------------------------------
    23 // CTsFswMonitor::~CTsFswMonitor
    22 // CTsFswMonitor::~CTsFswMonitor
    24 // --------------------------------------------------------------------------
    23 // --------------------------------------------------------------------------
    25 //
    24 //
    26 CTsFswMonitor::~CTsFswMonitor()
    25 CTsFswMonitor::~CTsFswMonitor()
    27     {
    26 {
    28     Cancel();
    27     Cancel();
    29     iWg.Close();
    28     mWg.Close();
    30     iWsSession.Close();
    29     mWsSession.Close();
    31     }
    30 }
    32 
    31 
    33 // --------------------------------------------------------------------------
    32 // --------------------------------------------------------------------------
    34 // CTsFswMonitor::CTsFswMonitor
    33 // CTsFswMonitor::CTsFswMonitor
    35 // --------------------------------------------------------------------------
    34 // --------------------------------------------------------------------------
    36 //
    35 //
    37 CTsFswMonitor::CTsFswMonitor(MTsFswTaskListObserver& aTaskListObserver) : CActive( EPriorityStandard ),
    36 CTsFswMonitor::CTsFswMonitor(MHsDataObserver& taskListObserver) :
    38     iTaskListObserver(&aTaskListObserver)
    37     CActive(EPriorityStandard), mTaskListObserver(&taskListObserver)
    39     {
    38 {
    40     }
    39 }
    41 
    40 
    42 // --------------------------------------------------------------------------
    41 // --------------------------------------------------------------------------
    43 // CTsFswMonitor::NewL
    42 // CTsFswMonitor::NewL
    44 // --------------------------------------------------------------------------
    43 // --------------------------------------------------------------------------
    45 //        
    44 //        
    46 CTsFswMonitor* CTsFswMonitor::NewL(MTsFswTaskListObserver& aTaskListObserver)
    45 CTsFswMonitor* CTsFswMonitor::NewL(MHsDataObserver& taskListObserver)
    47     {
    46 {
    48     CTsFswMonitor* self = NewLC(aTaskListObserver);
    47     CTsFswMonitor* self = NewLC(taskListObserver);
    49     CleanupStack::Pop( self );
    48     CleanupStack::Pop(self);
    50     return self;
    49     return self;
    51     }
    50 }
    52 
    51 
    53 // --------------------------------------------------------------------------
    52 // --------------------------------------------------------------------------
    54 // CTsFswMonitor::NewLC
    53 // CTsFswMonitor::NewLC
    55 // --------------------------------------------------------------------------
    54 // --------------------------------------------------------------------------
    56 //
    55 //
    57 CTsFswMonitor* CTsFswMonitor::NewLC(MTsFswTaskListObserver& aTaskListObserver)
    56 CTsFswMonitor* CTsFswMonitor::NewLC(MHsDataObserver& taskListObserver)
    58     {
    57 {
    59     CTsFswMonitor* self = new ( ELeave ) CTsFswMonitor(aTaskListObserver);
    58     CTsFswMonitor* self = new (ELeave) CTsFswMonitor(taskListObserver);
    60     CleanupStack::PushL( self );
    59     CleanupStack::PushL(self);
    61     self->ConstructL();
    60     self->ConstructL();
    62     return self;
    61     return self;
    63     }
    62 }
    64     
    63 
    65 // --------------------------------------------------------------------------
    64 // --------------------------------------------------------------------------
    66 // CTsFswMonitor::ConstructL
    65 // CTsFswMonitor::ConstructL
    67 // --------------------------------------------------------------------------
    66 // --------------------------------------------------------------------------
    68 //
    67 //
    69 void CTsFswMonitor::ConstructL()
    68 void CTsFswMonitor::ConstructL()
    70     {
    69 {
    71     CActiveScheduler::Add( this );
    70     CActiveScheduler::Add(this);
    72     //Create window server observer
    71     //Create window server observer
    73     ConstractObserverL();
    72     ConstractObserverL();
    74     Subscribe();
    73     Subscribe();
    75     }
    74 }
    76 
       
    77 
    75 
    78 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    79 // Subscribe
    77 // Subscribe
    80 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    81 //
    79 //
    82 void CTsFswMonitor::Subscribe()
    80 void CTsFswMonitor::Subscribe()
    83     {
    81 {
    84     if( !IsActive() )
    82     if (!IsActive()) {
    85         {
    83         mWsSession.EventReady(&iStatus);
    86         iWsSession.EventReady( &iStatus );
       
    87         SetActive();
    84         SetActive();
    88         }
       
    89     }
    85     }
       
    86 }
    90 
    87 
    91 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    92 // ConstractObserverL
    89 // ConstractObserverL
    93 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    94 //
    91 //
    95 void CTsFswMonitor::ConstractObserverL()
    92 void CTsFswMonitor::ConstractObserverL()
    96 {
    93 {
    97     User::LeaveIfError( iWsSession.Connect() );
    94     User::LeaveIfError(mWsSession.Connect());
    98     iWg = RWindowGroup( iWsSession );
    95     mWg = RWindowGroup(mWsSession);
    99     User::LeaveIfError( iWg.Construct( 
    96     User::LeaveIfError(mWg.Construct(reinterpret_cast<TUint32> (&mWg)));
   100                         reinterpret_cast<TUint32>( &iWg ) ) );
    97     mWg.DisableFocusChangeEvents();
   101     iWg.DisableFocusChangeEvents();
    98     mWg.DisableModifierChangedEvents();
   102     iWg.DisableModifierChangedEvents();
    99     mWg.DisableOnEvents();
   103     iWg.DisableOnEvents();
   100     mWg.DisableScreenChangeEvents();
   104     iWg.DisableScreenChangeEvents();
       
   105 
   101 
   106     //enable notifications about group lists
   102     //enable notifications about group lists
   107     User::LeaveIfError( iWg.EnableGroupListChangeEvents() );
   103     User::LeaveIfError(mWg.EnableGroupListChangeEvents());
   108 }
   104 }
   109 
   105 
   110 void CTsFswMonitor::RunL()
   106 void CTsFswMonitor::RunL()
   111 {
   107 {
   112     User::LeaveIfError( iStatus.Int() );
   108     User::LeaveIfError(iStatus.Int());
   113     TWsEvent event;
   109     TWsEvent event;
   114     iWsSession.GetEvent( event );
   110     mWsSession.GetEvent(event);
   115     Subscribe();//new subscribtion has to be called after picking event
   111     Subscribe();//new subscribtion has to be called after picking event
   116     if( EEventWindowGroupListChanged == event.Type() /*|| EEventFocusGroupChanged == event.Type()*/ )
   112     if (EEventWindowGroupListChanged == event.Type() /*|| EEventFocusGroupChanged == event.Type()*/) {
   117         {
   113         if (mTaskListObserver) {
   118         if ( iTaskListObserver )
   114             mTaskListObserver->DataChanged();
   119             {
       
   120             iTaskListObserver->UpdateTaskList(); 
       
   121             }
       
   122         }
   115         }
       
   116     }
   123 }
   117 }
   124 
   118 
   125 TInt CTsFswMonitor::RunError( TInt /*aError*/ )
   119 TInt CTsFswMonitor::RunError(TInt /*aError*/)
   126 {
   120 {
   127     Subscribe();
   121     Subscribe();
   128     return KErrNone;
   122     return KErrNone;
   129 }
   123 }
   130 
   124 
   131 void CTsFswMonitor::DoCancel()
   125 void CTsFswMonitor::DoCancel()
   132 {
   126 {
   133     if( IsActive() )
   127     if (IsActive()) {
   134         {
   128         mWsSession.EventReadyCancel();
   135         iWsSession.EventReadyCancel();
   129     }
   136         }
       
   137 }
   130 }
   138 
   131 
   139 // end of file
   132 // end of file