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