mmshplugins/mmshaoplugin/src/muspropertymonitor.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "muspropertymonitor.h"
    19 #include "muspropertymonitor.h"
       
    20 #include "musmanager.h"
    20 #include "mussesseioninformationapi.h"
    21 #include "mussesseioninformationapi.h"
    21 #include "muslogger.h"
    22 #include "muslogger.h"
    22 
    23 
    23 
    24 
    24 // -----------------------------------------------------------------------------
    25 // -----------------------------------------------------------------------------
    25 // Symbian two-phase constructor.
    26 // Symbian two-phase constructor.
    26 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
    27 //
    28 //
    28 CMusPropertyMonitor* CMusPropertyMonitor::NewL( MMusCallStateObserver& aCallStateObserver )  
    29 CMusPropertyMonitor* CMusPropertyMonitor::NewL()
    29     {
    30     {
    30     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::NewL" )
    31     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::NewL" )
    31     CMusPropertyMonitor* self = new (ELeave) CMusPropertyMonitor( aCallStateObserver );
    32     CMusPropertyMonitor* self = new (ELeave) CMusPropertyMonitor();
    32     CleanupStack::PushL( self );
    33     CleanupStack::PushL( self );
    33     self->ConstructL();
    34     self->ConstructL();
    34     CleanupStack::Pop( self );
    35     CleanupStack::Pop( self );
    35     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::NewL" )
    36     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::NewL" )
    36     return self;
    37     return self;
    38 
    39 
    39 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    40 // C++ constructor.
    41 // C++ constructor.
    41 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    42 //
    43 //
    43 CMusPropertyMonitor::CMusPropertyMonitor( MMusCallStateObserver& aCallStateObserver )
    44 CMusPropertyMonitor::CMusPropertyMonitor()
    44     :CActive( EPriorityNormal ), iCallStateObserver ( aCallStateObserver )
    45     :CActive( EPriorityNormal )
    45     {
    46     {
    46     }
    47     }
    47 
    48 
    48 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    49 // Symbian second-phase constructor.
    50 // Symbian second-phase constructor.
    70 CMusPropertyMonitor::~CMusPropertyMonitor()
    71 CMusPropertyMonitor::~CMusPropertyMonitor()
    71     {
    72     {
    72     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::~CMusPropertyMonitor" )
    73     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::~CMusPropertyMonitor" )
    73     Cancel();
    74     Cancel();
    74     iPropertyEvent.Close(); 
    75     iPropertyEvent.Close(); 
       
    76     delete iManager;        
    75     MUS_LOG( "mus: [MUSAO]  -> <- CMusPropertyMonitor::~CMusPropertyMonitor" )
    77     MUS_LOG( "mus: [MUSAO]  -> <- CMusPropertyMonitor::~CMusPropertyMonitor" )
    76     }
    78     }
    77 
    79 
    78 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    79 // CMusPropertyMonitor::RunL()
    81 // CMusPropertyMonitor::RunL()
    82 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    83 //
    85 //
    84 void CMusPropertyMonitor::RunL()
    86 void CMusPropertyMonitor::RunL()
    85     {
    87     {
    86     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::RunL" )
    88     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::RunL" )
    87 
       
    88     // resubscribe before processing new value to prevent missing updates
    89     // resubscribe before processing new value to prevent missing updates
    89     iPropertyEvent.Subscribe( iStatus );
    90     iPropertyEvent.Subscribe( iStatus );
    90     SetActive();    
    91     SetActive();    
    91 
    92     TInt value = NMusSessionInformationApi::ENoCall;
    92     //Check if preconditions are met to start or stop the MushClient.
    93     User::LeaveIfError(iPropertyEvent.Get( value ));     
    93     iCallStateObserver.MusCallStateChanged();
    94     switch(value)
    94 
    95         {      
       
    96         /* CallHold and ConferenceCall are Error Cases.Will be handled by
       
    97            Availability Plugin and Inform to AIW.
       
    98          */           
       
    99         case NMusSessionInformationApi::ECallHold:
       
   100              MUS_LOG( "mus: [MUSAO]  CallEvent  = ECallHold" )                 
       
   101              break;
       
   102         case NMusSessionInformationApi::EConferenceCall:
       
   103              MUS_LOG( "mus: [MUSAO]  CallEvent  = EConferenceCall" )                 
       
   104              break;
       
   105         /* When Call is connected , start the MusClient */
       
   106         case NMusSessionInformationApi::ECallConnected:
       
   107              MUS_LOG( "mus: [MUSAO]  CallEvent  = ECallConnected" )
       
   108              StartMusClientL();
       
   109              break;
       
   110         /* When Call is disconnected , stop the MusClient */
       
   111         case NMusSessionInformationApi::ENoCall:
       
   112              MUS_LOG( "mus: [MUSAO]  CallEvent  = ENoCall" )
       
   113              StopMusClient();
       
   114              break;     
       
   115         case NMusSessionInformationApi::EConferenceTerminated:
       
   116              MUS_LOG( "mus: [MUSAO]  CallEvent  = EConferenceTerminated" ) 
       
   117              break;
       
   118         
       
   119         default:
       
   120              MUS_LOG( "mus: [MUSAO]  CallEvent  = default. Treated ENoCall" )
       
   121              StopMusClient();
       
   122         }
    95     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunL" )
   123     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunL" )
    96     }
   124     }
    97 
   125 
    98 
   126 
    99 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   107     iPropertyEvent.Cancel();
   135     iPropertyEvent.Cancel();
   108     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::DoCancel" )
   136     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::DoCancel" )
   109     }
   137     }
   110 
   138 
   111 // -----------------------------------------------------------------------------
   139 // -----------------------------------------------------------------------------
       
   140 // CMusPropertyMonitor::StartMusClient()
       
   141 // This will start the MusManager Client which inturn should start
       
   142 // MusManager Server and Availability Plugin.
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CMusPropertyMonitor::StartMusClientL()
       
   146     {
       
   147     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::StartMusClient" )
       
   148     if( !iManager )
       
   149         {
       
   150         iManager = CMusManager::NewL();
       
   151         }
       
   152     iManager->ExamineAvailabilityL();   
       
   153     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::StartMusClient" ) 
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CMusPropertyMonitor::StopMusClient()
       
   158 // This will stop the MusManager Client which inturn should stop
       
   159 // MusManager Server and Availability Plugin.
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CMusPropertyMonitor::StopMusClient()
       
   163     {
       
   164     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::StopMusClient" )
       
   165     if( iManager )
       
   166         {
       
   167         delete iManager;
       
   168         iManager = NULL;
       
   169         }
       
   170     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::StopMusClient" )
       
   171     
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
   112 // CMusPropertyMonitor::RunError()
   175 // CMusPropertyMonitor::RunError()
   113 // Implemented for CActive.It will be called automatically
   176 // Implemented for CActive.It will be called automatically
   114 // when a leave occurs in RunL()
   177 // when a leave occurs in RunL()
   115 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   116 //
   179 //
   117 TInt CMusPropertyMonitor::RunError(TInt aError)
   180 TInt CMusPropertyMonitor::RunError(TInt aError)
   118     {
   181     {
   119     MUS_LOG1( "mus: [MUSAO]  -> CMusPropertyMonitor::RunError = %d",aError )
   182     MUS_LOG1( "mus: [MUSAO]  -> CMusPropertyMonitor::RunError = %d",aError )
   120     
   183     if( iManager )
   121     // Monitoring Error Occurred, Terminate the MushSession.
   184         {
   122     TInt err = RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   185         delete iManager;
   123                           NMusSessionInformationApi::KMusCallEvent,
   186         iManager = NULL;
   124                           NMusSessionInformationApi::ENoCall);
   187         }    
   125 
       
   126     iCallStateObserver.MusCallStateChanged();
       
   127 
       
   128     aError = KErrNone; // We handled this error already. So return KErrNone.
   188     aError = KErrNone; // We handled this error already. So return KErrNone.
   129     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunError " )    
   189     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunError " )    
   130     return aError;
   190     return aError;
   131     }
   191     }
   132 
   192 
   133 // -----------------------------------------------------------------------------
       
   134 // CMusPropertyMonitor::IsCallConnected()
       
   135 // Checks if the call is connected: 
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TBool CMusPropertyMonitor::IsCallConnected()
       
   139     {
       
   140     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::IsCallConnected" )
       
   141     TInt callState = ( TInt ) NMusSessionInformationApi::ENoCall;
       
   142     TInt err = KErrNone;
       
   143     
       
   144     err = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   145                           NMusSessionInformationApi::KMusCallEvent,
       
   146                           callState );
       
   147     
       
   148     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::IsCallConnected" )
       
   149     
       
   150     return ( err == KErrNone && callState != NMusSessionInformationApi::ENoCall );
       
   151     }
       
   152 
       
   153 // End of file
   193 // End of file