mmshplugins/mmshaoplugin/src/muscallmonitorbase.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 21 33a5d2bbf6fc
child 23 bc78a40cd63c
equal deleted inserted replaced
21:33a5d2bbf6fc 22:73a1feb507fb
    17 
    17 
    18 
    18 
    19 #include "mussesseioninformationapi.h"
    19 #include "mussesseioninformationapi.h"
    20 #include "muscallmonitorbase.h"
    20 #include "muscallmonitorbase.h"
    21 #include "muslogger.h"
    21 #include "muslogger.h"
    22 #include "mussettings.h"
       
    23 
    22 
    24 #include <etel.h>
    23 #include <etel.h>
    25 #include <etelmm.h>
    24 #include <etelmm.h>
    26 #include <e32svr.h>
    25 #include <e32svr.h>
    27 #include <mmtsy_names.h>
    26 #include <mmtsy_names.h>
    28 #include <e32property.h>
    27 #include <e32property.h>
    29 
    28 
    30 _LIT( KDoNotSendOwnNumber, "#31#" );
       
    31 _LIT( KDoSendOwnNumber, "*31#" );
       
    32 
       
    33 
    29 
    34 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    35 // C++ destructor.
    31 // C++ destructor.
    36 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    37 //
    33 //
    43 
    39 
    44 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    45 // C++ constructor.
    41 // C++ constructor.
    46 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    47 //
    43 //
    48 CMusCallMonitorBase::CMusCallMonitorBase(const RMobileCall& aCall, MMusTsyPropertyObserver& aObserver ) 
    44 CMusCallMonitorBase::CMusCallMonitorBase(const RMobileCall& aCall, 
    49         : CActive( EPriorityNormal ),iCall(aCall),iTsyObserver( aObserver )
    45         MMusTsyPropertyObserver& aObserver, 
       
    46         MMusCallStateObserver& aCallStateObserver ) 
       
    47         : CActive( EPriorityNormal ),iCall(aCall),iTsyObserver( aObserver ), 
       
    48         iCallStateObserver( aCallStateObserver )
       
    49         
    50         
    50         
    51     {   
    51     {   
    52 	// Intialize the remote call event state to Resume , means connected.
    52 	// Intialize the remote call event state to Resume , means connected.
    53     iRemoteCallEvent = RMobileCall::ERemoteResume;
    53     iRemoteCallEvent = RMobileCall::ERemoteResume;
    54     // Intialize the local call event state to Resume , means connected.
    54     // Intialize the local call event state to Resume , means connected.
    65     MUS_LOG1( "mus: [MUSAO]  -> CMusCallMonitorBase::SetStateL, aVal %d", aVal )
    65     MUS_LOG1( "mus: [MUSAO]  -> CMusCallMonitorBase::SetStateL, aVal %d", aVal )
    66     TInt callCount = 0;
    66     TInt callCount = 0;
    67     User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
    67     User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
    68                             NMusSessionInformationApi::KMusCallCount,callCount));
    68                             NMusSessionInformationApi::KMusCallCount,callCount));
    69     MUS_LOG1( "mus: [MUSAO]  - CallCount = %d",callCount )
    69     MUS_LOG1( "mus: [MUSAO]  - CallCount = %d",callCount )
       
    70     
       
    71     RMobileCall::TMobileCallInfoV3 callInfo;
       
    72     RMobileCall::TMobileCallInfoV3Pckg pckg( callInfo );
       
    73     iCall.GetMobileCallInfo( pckg );
       
    74     if( callInfo.iEmergency )
       
    75     	{
       
    76     	User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
    77     				 NMusSessionInformationApi::KMusCallEvent,
       
    78     				 ( TInt ) NMusSessionInformationApi::ENoCall ));
       
    79     	}
    70     /*
    80     /*
    71     * CountOfCallMonitors is number of CallMonitor Objects.Static Reference Count.
    81     * CountOfCallMonitors is number of CallMonitor Objects.Static Reference Count.
    72     * = No of active calls . 
    82     * = No of active calls . 
    73     * React one and only if one call is present -> Mush Call criteria.
    83     * React one and only if one call is present -> Mush Call criteria.
    74     * if call count is more than one , should be taken care by conference call or
    84     * if call count is more than one , should be taken care by conference call or
    75     * multicall criteria.
    85     * multicall criteria.
    76     */
    86     */
    77      if( callCount == 1) 
    87     else if( callCount == 1 ) 
    78         {
    88         {
    79         TInt currentVal;
    89         TInt currentVal;
    80         User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
    90         User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
    81                             NMusSessionInformationApi::KMusCallEvent,currentVal));
    91                             NMusSessionInformationApi::KMusCallEvent,currentVal));
    82         MUS_LOG1( "mus: [MUSAO]  - Remote State = %d",iRemoteCallEvent )
    92         MUS_LOG1( "mus: [MUSAO]  - Remote State = %d",iRemoteCallEvent )
    83         
       
    84         
       
    85         /*
       
    86          If Call is Connected then set the Call info.
       
    87          */
       
    88         if( aVal==NMusSessionInformationApi::ECallConnected ) 
       
    89             {
       
    90             SetCallInfoL();
       
    91             }
       
    92         
       
    93         /* If current event is callconnected and remote is not in hold set the
    93         /* If current event is callconnected and remote is not in hold set the
    94            property value to CallConnected.Else set it to CallHold.
    94            property value to CallConnected.Else set it to CallHold.
    95            Note : We can be sure about Local is connected when it goes to
    95            Note : We can be sure about Local is connected when it goes to
    96                   CallConnected State. But remote call events are just notified
    96                   CallConnected State. But remote call events are just notified
    97                   in call event monitor. So this stores the last remotecall event
    97                   in call event monitor. So this stores the last remotecall event
   107                 {
   107                 {
   108                 User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   108                 User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   109                                                  NMusSessionInformationApi::KMusCallEvent,
   109                                                  NMusSessionInformationApi::KMusCallEvent,
   110                                                  aVal ));    
   110                                                  aVal ));    
   111                 }
   111                 }
   112             }
   112             } 
   113     	else if( aVal==NMusSessionInformationApi::EConferenceCall)
       
   114     			{
       
   115                 User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   116                                                    NMusSessionInformationApi::KMusCallEvent,
       
   117                                                    NMusSessionInformationApi::EConferenceCall   ));  
       
   118     			}
       
   119         else if( aVal==NMusSessionInformationApi::ECallHold || iRemoteCallEvent==RMobileCall::ERemoteHold )
   113         else if( aVal==NMusSessionInformationApi::ECallHold || iRemoteCallEvent==RMobileCall::ERemoteHold )
   120             {            
   114             {            
   121             User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   115             User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
   122                                                NMusSessionInformationApi::KMusCallEvent,
   116                                                NMusSessionInformationApi::KMusCallEvent,
   123                                                NMusSessionInformationApi::ECallHold   ));  
   117                                                NMusSessionInformationApi::ECallHold   ));  
   124             }          
   118             }          
   125         if( aVal != NMusSessionInformationApi::ENoCall)
   119          else if( aVal==NMusSessionInformationApi::ENoCall )
       
   120             {            
       
   121             User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   122                                                NMusSessionInformationApi::KMusCallEvent,
       
   123                                                NMusSessionInformationApi::ENoCall ));  
       
   124             }  
       
   125           else if( aVal==NMusSessionInformationApi::EConferenceCall )
       
   126             {            
       
   127             User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   128                                                NMusSessionInformationApi::KMusCallEvent,
       
   129                                                NMusSessionInformationApi::EConferenceCall ));  
       
   130             }  
       
   131          	  
       
   132         /*
       
   133          If Call is Connected then set the Call info.
       
   134          */
       
   135         if( aVal==NMusSessionInformationApi::ECallConnected ) 
   126             {
   136             {
   127             RMobileCall::TMobileCallInfoV3 callInfo;
   137             SetCallInfoL();
   128             RMobileCall::TMobileCallInfoV3Pckg pckg( callInfo );
       
   129     
       
   130             User::LeaveIfError(iCall.GetMobileCallInfo( pckg ));  
       
   131             if( callInfo.iEmergency )
       
   132                     {
       
   133                     User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   134                                              NMusSessionInformationApi::KMusCallEvent,
       
   135                                              ( TInt ) NMusSessionInformationApi::ENoCall ));
       
   136                     }
       
   137             }
   138             }
   138 
   139 
       
   140         // All P/S Keys are Set
       
   141         //Check if preconditions are met to start or stop the MushClient.
       
   142         iCallStateObserver.MusCallStateChanged();
   139         }   
   143         }   
   140  
   144  
   141     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::SetStateL" )    
   145     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::SetStateL" )    
   142     }
   146     }
   143 
   147 
   153     User::LeaveIfError(iCall.GetMobileCallInfo( callInfoPckg ));    
   157     User::LeaveIfError(iCall.GetMobileCallInfo( callInfoPckg ));    
   154     RMobilePhone::TMobileAddress remoteNumber = 
   158     RMobilePhone::TMobileAddress remoteNumber = 
   155                                            callInfo.iRemoteParty.iRemoteNumber;
   159                                            callInfo.iRemoteParty.iRemoteNumber;
   156      // Set telephone number
   160      // Set telephone number
   157     HBufC* telNo( NULL );
   161     HBufC* telNo( NULL );
   158     HBufC* cleanTelNo( NULL );
       
   159     if( remoteNumber.iTelNumber.Length() > 0 )
   162     if( remoteNumber.iTelNumber.Length() > 0 )
   160         {
   163         {
   161         MUS_LOG( "mus: [MUSAO]     remoteNumber.iTelNumber.Lenght > 0" )
   164         MUS_LOG( "mus: [MUSAO]     remoteNumber.iTelNumber.Lenght > 0" )
   162         telNo = remoteNumber.iTelNumber.AllocLC();
   165         telNo = remoteNumber.iTelNumber.AllocLC();
   163         }
   166         }
   164     else
   167     else
   165         {
   168         {
   166         MUS_LOG( "mus: [MUSAO]     remoteNumber.iTelNumber.Lenght =< 0" )
   169         MUS_LOG( "mus: [CALLMN]     remoteNumber.iTelNumber.Lenght =< 0" )
   167         RMobilePhone::TMobileAddress dialledParty = callInfo.iDialledParty;
   170         RMobilePhone::TMobileAddress dialledParty = callInfo.iDialledParty;
   168         telNo = dialledParty.iTelNumber.AllocLC();
   171         telNo = dialledParty.iTelNumber.AllocLC();
   169         
   172         }
   170         }
       
   171     if ( MultimediaSharingSettings::PrivacySetting() )
       
   172         {
       
   173         SetClirSetting( *telNo );
       
   174         }
       
   175     cleanTelNo = RemovePrefix( *telNo );
       
   176     CleanupStack::PushL( cleanTelNo );  
       
   177     
       
   178     User::LeaveIfError(RProperty::Set( 
   173     User::LeaveIfError(RProperty::Set( 
   179                                       NMusSessionInformationApi::KCategoryUid,
   174                                       NMusSessionInformationApi::KCategoryUid,
   180                                       NMusSessionInformationApi::KMusTelNumber,
   175                                       NMusSessionInformationApi::KMusTelNumber,
   181                                       *cleanTelNo ));  
   176                                       *telNo ));  
   182     MUS_LOG_TDESC("mus: [MUSAO]     telNo = ", (*cleanTelNo))
   177     MUS_LOG_TDESC("mus: [MUSAO]     telNo = ", (*telNo))
   183     CleanupStack::PopAndDestroy(cleanTelNo);
       
   184     CleanupStack::PopAndDestroy(telNo);
   178     CleanupStack::PopAndDestroy(telNo);
   185     
   179     
   186     // Set call direction.
   180     // Set call direction.     
   187     RMobileCall::TMobileCallDirection direction =
   181     RMobileCall::TMobileCallDirection direction =
   188                                             callInfo.iRemoteParty.iDirection;
   182                                             callInfo.iRemoteParty.iDirection;
   189     MUS_LOG1( "mus: [MUSAO]  Call Direction = %d",direction )
   183     MUS_LOG1( "mus: [MUSAO]  Call Direction = %d",direction )
   190     if( direction == RMobileCall::EMobileOriginated )
   184     if( direction == RMobileCall::EMobileOriginated )
   191         {
   185         {
   194                         NMusSessionInformationApi::KMusCallDirection,
   188                         NMusSessionInformationApi::KMusCallDirection,
   195                         ( TInt ) NMusSessionInformationApi::ECallOrginated ));
   189                         ( TInt ) NMusSessionInformationApi::ECallOrginated ));
   196         }
   190         }
   197     else if ( direction  == RMobileCall::EMobileTerminated )
   191     else if ( direction  == RMobileCall::EMobileTerminated )
   198         {
   192         {
   199         SetTerminatingPrivacy( iCall );
       
   200         User::LeaveIfError(RProperty::Set( 
   193         User::LeaveIfError(RProperty::Set( 
   201                         NMusSessionInformationApi::KCategoryUid,
   194                         NMusSessionInformationApi::KCategoryUid,
   202                         NMusSessionInformationApi::KMusCallDirection,
   195                         NMusSessionInformationApi::KMusCallDirection,
   203                         ( TInt ) NMusSessionInformationApi::ECallTerminated ));
   196                         ( TInt ) NMusSessionInformationApi::ECallTerminated ));
   204         }
   197         }
   206         {
   199         {
   207         User::LeaveIfError(RProperty::Set( 
   200         User::LeaveIfError(RProperty::Set( 
   208                         NMusSessionInformationApi::KCategoryUid,
   201                         NMusSessionInformationApi::KCategoryUid,
   209                         NMusSessionInformationApi::KMusCallDirection,
   202                         NMusSessionInformationApi::KMusCallDirection,
   210                         ( TInt ) NMusSessionInformationApi::ENoDirection ));
   203                         ( TInt ) NMusSessionInformationApi::ENoDirection ));
   211         }
   204         } 
   212     
   205     
       
   206     
       
   207     /* Set the call provider information to some dummy Value */
       
   208     User::LeaveIfError(RProperty::Set( 
       
   209                             NMusSessionInformationApi::KCategoryUid,
       
   210                             NMusSessionInformationApi::KMUSCallProvider,
       
   211                             KNullDesC));
   213     
   212     
   214     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::SetCallInfoL" )  
   213     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::SetCallInfoL" )  
   215     }
   214     }
   216 
   215 
   217 // -----------------------------------------------------------------------------
   216 // -----------------------------------------------------------------------------
   240     RCall::TCallInfo callInfo;
   239     RCall::TCallInfo callInfo;
   241     iCall.GetInfo(callInfo);
   240     iCall.GetInfo(callInfo);
   242     iTsyObserver.NotifyCallStateChanged( aVal, callInfo.iCallName );
   241     iTsyObserver.NotifyCallStateChanged( aVal, callInfo.iCallName );
   243     }
   242     }
   244 
   243 
   245 // --------------------------------------------------------------------------
   244 
   246 // void CMusCallMonitorBase::SetClirSetting()
   245 // --------------------------------------------------------------------------------
   247 // Determine CLIR setting from dialled digits
   246 // CMusCallConferenceMonitor::IsDataReadyL()
   248 // --------------------------------------------------------------------------
   247 // Checks if Data is ready CS Call.
   249 //
   248 // --------------------------------------------------------------------------------
   250 void CMusCallMonitorBase::SetClirSetting( const TDesC& aDialledNumber ) const
   249 
   251     {
   250 TBool CMusCallMonitorBase::IsDataReadyL()
   252     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitorBase::SetClirSetting" );
   251     {
   253 
   252     // This function need to be updated when new 
   254     NMusSessionInformationApi::TMusClirSetting 
   253     // P/S key is published in Call monitor 
   255         sendNumber( NMusSessionInformationApi::ESendOwnNumber );
   254 
   256 
   255     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitorBase::IsDataReadyL" )
   257     TPtrC prefix = aDialledNumber.Left( KDoNotSendOwnNumber().Length() );
   256     
   258     if ( prefix == KDoNotSendOwnNumber() )
   257     // Ensure there is tel Number.
   259         {
   258     HBufC* telNumInfo = HBufC::NewLC( RProperty::KMaxPropertySize );
   260         sendNumber = NMusSessionInformationApi::EDoNotSendOwnNumber;
   259     TPtr ptelInfo = telNumInfo->Des();
   261         }
   260     TInt err  = KErrNone;
   262     RProperty::Set( NMusSessionInformationApi::KCategoryUid, 
   261        
   263                     NMusSessionInformationApi::KMusClirSetting, sendNumber );
   262     err = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
   264     MUS_LOG1( "mus: [MUSAO]  <- CMusCallMonitorBase::SetClirSetting send nbr=%d",
   263                             NMusSessionInformationApi::KMusTelNumber,
   265     sendNumber == NMusSessionInformationApi::ESendOwnNumber );
   264                             ptelInfo );
   266     }
   265 
   267 
   266     TBool telInfoExisit ( err == KErrNone && telNumInfo->Des().Length() > 0 );
   268 
   267     CleanupStack::PopAndDestroy( telNumInfo );
   269 // --------------------------------------------------------------------------
   268     
   270 // void CMusCallMonitorBase::RemovePrefix()
   269     // Ensure Call direction info is there
   271 // --------------------------------------------------------------------------
   270     TInt callDirection = NMusSessionInformationApi::ENoDirection;
   272 //
   271     err = RProperty::Get( 
   273 HBufC* CMusCallMonitorBase::RemovePrefix( const TDesC& aOriginator ) const
   272                     NMusSessionInformationApi::KCategoryUid,
   274     {
   273                     NMusSessionInformationApi::KMusCallDirection,
   275     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitorBase::removePrefix" );
   274                     callDirection );
   276 
   275     
   277     HBufC * withoutPrefix(NULL);
   276     TBool callInfoExisit ( err == KErrNone && callDirection != NMusSessionInformationApi::ENoDirection );
   278     
   277     
   279     TPtrC prefix = aOriginator.Left( KDoNotSendOwnNumber().Length() );
   278     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::IsDataReadyL" )
   280     if ( prefix == KDoNotSendOwnNumber()|| prefix == KDoSendOwnNumber() )
   279     return telInfoExisit && callInfoExisit;
   281         {
       
   282         MUS_LOG( "Number have a prefix" );
       
   283         withoutPrefix = aOriginator.AllocL();
       
   284         *withoutPrefix = aOriginator;
       
   285         TPtr ptr = withoutPrefix->Des();
       
   286         ptr.Delete(0,KDoNotSendOwnNumber().Length());
       
   287         }
       
   288     else
       
   289         {
       
   290         withoutPrefix = aOriginator.AllocL();
       
   291         }
       
   292     
       
   293     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::RemovePrefix" );
       
   294     return withoutPrefix;
       
   295     }
       
   296 
       
   297 
       
   298 // --------------------------------------------------------------------------
       
   299 // void CMusCallMonitorBase::SetTerminatingPrivacy()
       
   300 // --------------------------------------------------------------------------
       
   301 //
       
   302 void CMusCallMonitorBase::SetTerminatingPrivacy( const RMobileCall& aCall ) const
       
   303     {
       
   304     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitorBase::SetTerminatingPrivacy" )
       
   305     RMobileCall::TMobileCallInfoV3 callInfo;
       
   306     RMobileCall::TMobileCallInfoV3Pckg callInfoPckg( callInfo );
       
   307     if( aCall.GetMobileCallInfo( callInfoPckg ) != KErrNone )
       
   308         {
       
   309         return; // error cannot do
       
   310         }
       
   311     MUS_LOG( "mus: [MUSAO] Get remote status" )
       
   312     RMobileCall::TMobileCallRemoteIdentityStatus remoteStatus = 
       
   313                     callInfo.iRemoteParty.iRemoteIdStatus;
       
   314             
       
   315     if( remoteStatus == RMobileCall::ERemoteIdentitySuppressed )
       
   316         {
       
   317          RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   318                         NMusSessionInformationApi::KMUSPrivacy,
       
   319                         ( TInt ) NMusSessionInformationApi::EPrivacyOn );
       
   320         }
       
   321     else
       
   322         {
       
   323         RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   324                         NMusSessionInformationApi::KMUSPrivacy,
       
   325                         ( TInt ) NMusSessionInformationApi::EPrivacyOff );
       
   326         }
       
   327     MUS_LOG1( "mus: [MUSAO] Remote status = %d",remoteStatus )
       
   328     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitorBase::SetTerminatingPrivacy" )
       
   329     }
   280     }
   330 
   281 
   331 // End of file
   282 // End of file
   332 
   283