mmserv/radioutility/radio_utility/src/RadioMonitorBody.cpp
changeset 16 43d09473c595
parent 0 71ca22bcf22a
child 46 0ac9a5310753
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
    17 
    17 
    18 
    18 
    19 #include <RadioMonitor.h>
    19 #include <RadioMonitor.h>
    20 #include "RadioMonitorBody.h"
    20 #include "RadioMonitorBody.h"
    21 #include "RadioServerData.h"
    21 #include "RadioServerData.h"
       
    22 #include "trace.h"
       
    23 
       
    24 // This has to be the last include. 
       
    25 #ifdef STUB_CONSTELLATION
       
    26 #   include "RadioStubManager.h"
       
    27 #   define KRadioServerPropertyCategory KStub_KRadioServerPropertyCategory
       
    28 #endif //STUB_CONSTELLATION
    22 
    29 
    23 // ======== MEMBER FUNCTIONS ========
    30 // ======== MEMBER FUNCTIONS ========
    24 
    31 
    25 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    26 // CRadioMonitor::CBody::NewL
    33 // CRadioMonitor::CBody::NewL
    28 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    29 //
    36 //
    30 CRadioMonitor::CBody* CRadioMonitor::CBody::NewL(
    37 CRadioMonitor::CBody* CRadioMonitor::CBody::NewL(
    31     MRadioMonitorObserver& aObserver )
    38     MRadioMonitorObserver& aObserver )
    32     {
    39     {
    33     CRadioMonitor::CBody* s = new(ELeave) CRadioMonitor::CBody();
    40     FUNC_LOG;
    34     s->iRadioMonitorClient = &aObserver;
    41     CRadioMonitor::CBody* s = new(ELeave) CRadioMonitor::CBody( aObserver );
    35     CleanupStack::PushL(s);
    42     CleanupStack::PushL(s);
    36     s->ConstructL();
    43     s->ConstructL();
    37     CleanupStack::Pop();
    44     CleanupStack::Pop();
    38     return s;
    45     return s;
    39     }
    46     }
    42 // Destructor.
    49 // Destructor.
    43 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    44 //
    51 //
    45 CRadioMonitor::CBody::~CBody()
    52 CRadioMonitor::CBody::~CBody()
    46     {
    53     {
       
    54     FUNC_LOG;
    47     Cancel();
    55     Cancel();
    48     iProperty.Close();
    56     iProperty.Close();
    49     }
    57     }
    50 
    58 
    51 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    52 // CRadioMonitor::CBody::CBody
    60 // CRadioMonitor::CBody::CBody
    53 // Two-phased constructor.
    61 // Two-phased constructor.
    54 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    55 //
    63 //
    56 CRadioMonitor::CBody::CBody() :
    64 CRadioMonitor::CBody::CBody( MRadioMonitorObserver& aObserver ) :
    57     CActive(EPriorityStandard)
    65     CActive(EPriorityStandard),
       
    66     iRadioMonitorClient(aObserver)
    58     {
    67     {
       
    68     FUNC_LOG;
    59     }
    69     }
    60 
    70 
    61 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    62 // CRadioMonitor::ConstructL
    72 // CRadioMonitor::ConstructL
    63 // Two-phased constructor.
    73 // Two-phased constructor.
    64 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    65 //
    75 //
    66 void CRadioMonitor::CBody::ConstructL()
    76 void CRadioMonitor::CBody::ConstructL()
    67     {
    77     {
       
    78     FUNC_LOG;
    68     CActiveScheduler::Add(this);
    79     CActiveScheduler::Add(this);
    69 
    80 
    70     // Attach property
    81     // Attach property
    71     User::LeaveIfError(iProperty.Attach(KRadioServerPropertyCategory,
    82     User::LeaveIfError(iProperty.Attach(KRadioServerPropertyCategory,
    72                                         KRadioServPsMonitorState));
    83                                         KRadioServPsMonitorState));
    80 // (other items were commented in a header).
    91 // (other items were commented in a header).
    81 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
    82 //
    93 //
    83 TBool CRadioMonitor::CBody::IsRadioOn() const
    94 TBool CRadioMonitor::CBody::IsRadioOn() const
    84     {
    95     {
       
    96     FUNC_LOG;
    85     TBool radioState = ERadioStateOff;
    97     TBool radioState = ERadioStateOff;
    86     RProperty::Get(KRadioServerPropertyCategory,
    98     RProperty::Get(KRadioServerPropertyCategory,
    87                    KRadioServPsMonitorState,
    99                    KRadioServPsMonitorState,
    88                    radioState);
   100                    radioState);
    89 
   101 
    95 // Called when property value changes
   107 // Called when property value changes
    96 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
    97 //
   109 //
    98 void CRadioMonitor::CBody::RunL()
   110 void CRadioMonitor::CBody::RunL()
    99     {
   111     {
       
   112     FUNC_LOG;
   100     TBool radioState = ERadioStateOff;
   113     TBool radioState = ERadioStateOff;
   101 
   114 
   102     // Resubscribe before processing new value to prevent missing updates
   115     // Resubscribe before processing new value to prevent missing updates
   103     iProperty.Subscribe(iStatus);
   116     iProperty.Subscribe(iStatus);
   104     SetActive();
   117     SetActive();
   105 
   118 
   106     TInt error = iProperty.Get(radioState);
   119     TInt error = iProperty.Get(radioState);
   107     if ( error == KErrNone )
   120     if ( error == KErrNone )
   108         {
   121         {
   109         iRadioMonitorClient->MrmEvent((TRadioMonitorEvent)radioState);
   122         iRadioMonitorClient.MrmEvent((TRadioMonitorEvent)radioState);
   110         }
   123         }
   111     else if ( error == KErrNotFound )
   124     else if ( error == KErrNotFound )
   112         {
   125         {
   113         iRadioMonitorClient->MrmEvent(ERadioStateOff);
   126         iRadioMonitorClient.MrmEvent(ERadioStateOff);
   114         }
   127         }
   115     else
   128     else
   116         {
   129         {
   117         // pass
   130         // pass
   118         }
   131         }
   123 // Cancels event listening
   136 // Cancels event listening
   124 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   125 //
   138 //
   126 void CRadioMonitor::CBody::DoCancel()
   139 void CRadioMonitor::CBody::DoCancel()
   127     {
   140     {
       
   141     FUNC_LOG;
   128     iProperty.Cancel();
   142     iProperty.Cancel();
   129     }
   143     }
   130 
   144 
   131 // End of File
   145 // End of File