mmshplugins/mmshaoplugin/src/muspropertymonitor.cpp
changeset 0 f0cf47e981f9
child 31 33a5d2bbf6fc
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     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:  class to watch call monitor event properties
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "muspropertymonitor.h"
       
    20 #include "musmanager.h"
       
    21 #include "mussesseioninformationapi.h"
       
    22 #include "muslogger.h"
       
    23 
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // Symbian two-phase constructor.
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CMusPropertyMonitor* CMusPropertyMonitor::NewL()
       
    30     {
       
    31     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::NewL" )
       
    32     CMusPropertyMonitor* self = new (ELeave) CMusPropertyMonitor();
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop( self );
       
    36     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::NewL" )
       
    37     return self;
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // C++ constructor.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CMusPropertyMonitor::CMusPropertyMonitor()
       
    45     :CActive( EPriorityNormal )
       
    46     {
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // Symbian second-phase constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CMusPropertyMonitor::ConstructL()
       
    54     {
       
    55     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::ConstructL" )
       
    56     CActiveScheduler::Add(this);
       
    57     User::LeaveIfError( 
       
    58             iPropertyEvent.Attach(
       
    59                                 NMusSessionInformationApi::KCategoryUid,
       
    60                                 NMusSessionInformationApi::KMusCallEvent ) );
       
    61     MUS_LOG( "mus: [MUSAO] Property attached to KMusCallEvent" )    
       
    62     iPropertyEvent.Subscribe( iStatus );
       
    63     SetActive();
       
    64     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::ConstructL" )
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // C++ destructor.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CMusPropertyMonitor::~CMusPropertyMonitor()
       
    72     {
       
    73     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::~CMusPropertyMonitor" )
       
    74     Cancel();
       
    75     iPropertyEvent.Close(); 
       
    76     delete iManager;        
       
    77     MUS_LOG( "mus: [MUSAO]  -> <- CMusPropertyMonitor::~CMusPropertyMonitor" )
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CMusPropertyMonitor::RunL()
       
    82 // Implemented for CActive.It will be called automatically
       
    83 // when new property event occurs
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CMusPropertyMonitor::RunL()
       
    87     {
       
    88     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::RunL" )
       
    89     // resubscribe before processing new value to prevent missing updates
       
    90     iPropertyEvent.Subscribe( iStatus );
       
    91     SetActive();    
       
    92     TInt value = NMusSessionInformationApi::ENoCall;
       
    93     User::LeaveIfError(iPropertyEvent.Get( value ));     
       
    94     switch(value)
       
    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         default:
       
   116              MUS_LOG( "mus: [MUSAO]  CallEvent  = default. Treated ENoCall" )
       
   117              StopMusClient();
       
   118         }
       
   119     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunL" )
       
   120     }
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CMusPropertyMonitor::DoCancel()
       
   125 // Implemented for CActive.Will be called when Cancel() method called.
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CMusPropertyMonitor::DoCancel()
       
   129     {
       
   130     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::DoCancel" )
       
   131     iPropertyEvent.Cancel();
       
   132     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::DoCancel" )
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMusPropertyMonitor::StartMusClient()
       
   137 // This will start the MusManager Client which inturn should start
       
   138 // MusManager Server and Availability Plugin.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CMusPropertyMonitor::StartMusClientL()
       
   142     {
       
   143     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::StartMusClient" )
       
   144     if( !iManager )
       
   145         {
       
   146         iManager = CMusManager::NewL();
       
   147         }
       
   148     iManager->ExamineAvailabilityL();   
       
   149     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::StartMusClient" ) 
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CMusPropertyMonitor::StopMusClient()
       
   154 // This will stop the MusManager Client which inturn should stop
       
   155 // MusManager Server and Availability Plugin.
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 void CMusPropertyMonitor::StopMusClient()
       
   159     {
       
   160     MUS_LOG( "mus: [MUSAO]  -> CMusPropertyMonitor::StopMusClient" )
       
   161     if( iManager )
       
   162         {
       
   163         delete iManager;
       
   164         iManager = NULL;
       
   165         }
       
   166     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::StopMusClient" )
       
   167     
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMusPropertyMonitor::RunError()
       
   172 // Implemented for CActive.It will be called automatically
       
   173 // when a leave occurs in RunL()
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 TInt CMusPropertyMonitor::RunError(TInt aError)
       
   177     {
       
   178     MUS_LOG1( "mus: [MUSAO]  -> CMusPropertyMonitor::RunError = %d",aError )
       
   179     if( iManager )
       
   180         {
       
   181         delete iManager;
       
   182         iManager = NULL;
       
   183         }    
       
   184     aError = KErrNone; // We handled this error already. So return KErrNone.
       
   185     MUS_LOG( "mus: [MUSAO]  <- CMusPropertyMonitor::RunError " )    
       
   186     return aError;
       
   187     }
       
   188 
       
   189 // End of file