mmshplugins/mmshaoplugin/src/muspropertymonitor.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 21 33a5d2bbf6fc
child 23 bc78a40cd63c
equal deleted inserted replaced
21:33a5d2bbf6fc 22:73a1feb507fb
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "muspropertymonitor.h"
    19 #include "muspropertymonitor.h"
    20 #include "musmanager.h"
       
    21 #include "mussesseioninformationapi.h"
    20 #include "mussesseioninformationapi.h"
    22 #include "muslogger.h"
    21 #include "muslogger.h"
    23 
    22 
    24 
    23 
    25 // -----------------------------------------------------------------------------
    24 // -----------------------------------------------------------------------------
    26 // Symbian two-phase constructor.
    25 // Symbian two-phase constructor.
    27 // -----------------------------------------------------------------------------
    26 // -----------------------------------------------------------------------------
    28 //
    27 //
    29 CMusPropertyMonitor* CMusPropertyMonitor::NewL()
    28 CMusPropertyMonitor* CMusPropertyMonitor::NewL( MMusCallStateObserver& aCallStateObserver )  
    30     {
    29     {
    31     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::NewL" )
    30     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::NewL" )
    32     CMusPropertyMonitor* self = new (ELeave) CMusPropertyMonitor();
    31     CMusPropertyMonitor* self = new (ELeave) CMusPropertyMonitor( aCallStateObserver );
    33     CleanupStack::PushL( self );
    32     CleanupStack::PushL( self );
    34     self->ConstructL();
    33     self->ConstructL();
    35     CleanupStack::Pop( self );
    34     CleanupStack::Pop( self );
    36     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::NewL" )
    35     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::NewL" )
    37     return self;
    36     return self;
    39 
    38 
    40 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    41 // C++ constructor.
    40 // C++ constructor.
    42 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    43 //
    42 //
    44 CMusPropertyMonitor::CMusPropertyMonitor()
    43 CMusPropertyMonitor::CMusPropertyMonitor( MMusCallStateObserver& aCallStateObserver )
    45     :CActive( EPriorityNormal )
    44     :CActive( EPriorityNormal ), iCallStateObserver ( aCallStateObserver )
    46     {
    45     {
    47     }
    46     }
    48 
    47 
    49 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    50 // Symbian second-phase constructor.
    49 // Symbian second-phase constructor.
    71 CMusPropertyMonitor::~CMusPropertyMonitor()
    70 CMusPropertyMonitor::~CMusPropertyMonitor()
    72     {
    71     {
    73     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::~CMusPropertyMonitor" )
    72     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::~CMusPropertyMonitor" )
    74     Cancel();
    73     Cancel();
    75     iPropertyEvent.Close(); 
    74     iPropertyEvent.Close(); 
    76     delete iManager;        
       
    77     MUS_LOG( "mus: [MUSAO]  -> <- CMusPropertyMonitor::~CMusPropertyMonitor" )
    75     MUS_LOG( "mus: [MUSAO]  -> <- CMusPropertyMonitor::~CMusPropertyMonitor" )
    78     }
    76     }
    79 
    77 
    80 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    81 // CMusPropertyMonitor::RunL()
    79 // CMusPropertyMonitor::RunL()
    84 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    85 //
    83 //
    86 void CMusPropertyMonitor::RunL()
    84 void CMusPropertyMonitor::RunL()
    87     {
    85     {
    88     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::RunL" )
    86     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::RunL" )
       
    87 
    89     // resubscribe before processing new value to prevent missing updates
    88     // resubscribe before processing new value to prevent missing updates
    90     iPropertyEvent.Subscribe( iStatus );
    89     iPropertyEvent.Subscribe( iStatus );
    91     SetActive();    
    90     SetActive();    
    92     TInt value = NMusSessionInformationApi::ENoCall;
    91 
    93     User::LeaveIfError(iPropertyEvent.Get( value ));     
    92     //Check if preconditions are met to start or stop the MushClient.
    94     switch(value)
    93     iCallStateObserver.MusCallStateChanged();
    95         {      
    94 
    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         }
       
   123     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunL" )
    95     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunL" )
   124     }
    96     }
   125 
    97 
   126 
    98 
   127 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   135     iPropertyEvent.Cancel();
   107     iPropertyEvent.Cancel();
   136     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::DoCancel" )
   108     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::DoCancel" )
   137     }
   109     }
   138 
   110 
   139 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   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 // -----------------------------------------------------------------------------
       
   175 // CMusPropertyMonitor::RunError()
   112 // CMusPropertyMonitor::RunError()
   176 // Implemented for CActive.It will be called automatically
   113 // Implemented for CActive.It will be called automatically
   177 // when a leave occurs in RunL()
   114 // when a leave occurs in RunL()
   178 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   179 //
   116 //
   180 TInt CMusPropertyMonitor::RunError(TInt aError)
   117 TInt CMusPropertyMonitor::RunError(TInt aError)
   181     {
   118     {
   182     MUS_LOG1( "mus: [MUSAO]  -> CMusPropertyMonitor::RunError = %d",aError )
   119     MUS_LOG1( "mus: [MUSAO]  -> CMusPropertyMonitor::RunError = %d",aError )
   183     if( iManager )
   120     
   184         {
   121     // Monitoring Error Occurred, Terminate the MushSession.
   185         delete iManager;
   122     TInt err = RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   186         iManager = NULL;
   123                           NMusSessionInformationApi::KMusCallEvent,
   187         }    
   124                           NMusSessionInformationApi::ENoCall);
       
   125 
       
   126     iCallStateObserver.MusCallStateChanged();
       
   127 
   188     aError = KErrNone; // We handled this error already. So return KErrNone.
   128     aError = KErrNone; // We handled this error already. So return KErrNone.
   189     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunError " )    
   129     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunError " )    
   190     return aError;
   130     return aError;
   191     }
   131     }
   192 
   132 
       
   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 
   193 // End of file
   153 // End of file