mmsharing/mmshavailability/src/musavacalleventmonitor.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
   115         direction )
   115         direction )
   116     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  <- CMusAvaCallEventMonitor::\
   116     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  <- CMusAvaCallEventMonitor::\
   117         CallDirectionL" )
   117         CallDirectionL" )
   118     return direction;
   118     return direction;
   119     }
   119     }
   120 
   120     
   121 // --------------------------------------------------------------------------
   121 // --------------------------------------------------------------------------
   122 // aTelNumber will be filled with telephone number or SIP URI of current
   122 // Returns the direction of connected call.
   123 // connected call
   123 // --------------------------------------------------------------------------
   124 // --------------------------------------------------------------------------
   124 //
   125 //
   125 TInt CMusAvaCallEventMonitor::CallPrivacyL()
   126 void
   126     {
   127 CMusAvaCallEventMonitor::GetTelNumberL( TDes& aTelNumber, TBool& aIsSipUri )
   127     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  -> CMusAvaCallEventMonitor::\
   128 
   128             CallPrivacyL" )
       
   129     // retrieve call count
       
   130     TInt privacy( 0 );
       
   131     User::LeaveIfError( RProperty::Get(
       
   132         NMusSessionInformationApi::KCategoryUid,
       
   133         NMusSessionInformationApi::KMUSPrivacy,
       
   134         privacy ) );
       
   135 
       
   136     MUS_LOG1( "mus: [CMusAvaCallEventMonitor]     Call privacy = %d ", 
       
   137             privacy )
       
   138     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  <- CMusAvaCallEventMonitor::\
       
   139         CallPrivacyL" )
       
   140     return privacy;
       
   141     }
       
   142 	
       
   143 // --------------------------------------------------------------------------
       
   144 // aTelNumber will be filled with telephone number of current connected call
       
   145 // --------------------------------------------------------------------------
       
   146 //
       
   147 void CMusAvaCallEventMonitor::GetTelNumberL( TDes& aTelNumber )
   129     {
   148     {
   130     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  -> CMusAvaCallEventMonitor::\
   149     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  -> CMusAvaCallEventMonitor::\
   131         GetTelNumberL" )
   150         GetTelNumberL" )
   132 
   151     TBuf<KMusTelNumberMaxLength> telNumber;
   133     TInt error = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
   152 
   134                                  NMusSessionInformationApi::KMusTelNumber,
   153     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   135                                  aTelNumber );
   154         GetTelNumberL - a" )
       
   155     TInt error = RProperty::Get(
       
   156         NMusSessionInformationApi::KCategoryUid,
       
   157         NMusSessionInformationApi::KMusTelNumber,
       
   158         telNumber );
   136 
   159 
   137     MUS_LOG1( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   160     MUS_LOG1( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   138         GetTelNumberL (%d)", error )
   161         GetTelNumberL (%d)", error )
   139 
   162 
   140     if ( error == KErrOverflow )
   163     if ( error != KErrOverflow )
   141         {
   164         {
   142         MUS_LOG1( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   165         User::LeaveIfError( error );
   143             GetTelNumberL - Buffer too small (%d), leave", 
   166         }
   144             aTelNumber.MaxLength() )
   167 
   145         User::Leave( error );
   168     TInt length = telNumber.Length();
   146         }
   169     TInt maxLength = aTelNumber.MaxLength();
   147     User::LeaveIfError( error );
   170     if ( maxLength < length )
   148     
   171         {
   149     aIsSipUri = IsSipUri( aTelNumber );
   172         // buffer is too small for returned tel number.
   150     MUS_LOG1( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   173         MUS_LOG2( "mus: [CMusAvaCallEventMonitor]  CMusAvaCallEventMonitor::\
   151           GetTelNumberL (is SIP URI=%d)", aIsSipUri )
   174             GetTelNumberL - Buffer too small (%d, %d), leave", 
   152     
   175             maxLength, length )
       
   176         User::Leave( KErrOverflow );
       
   177         }
       
   178 
       
   179     aTelNumber.Copy( telNumber );
   153     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  <- CMusAvaCallEventMonitor::\
   180     MUS_LOG( "mus: [CMusAvaCallEventMonitor]  <- CMusAvaCallEventMonitor::\
   154         GetTelNumberL" )
   181         GetTelNumberL" )
   155     }
   182     }
   156 
   183 
   157 
   184 
   219                 break;
   246                 break;
   220                 }
   247                 }
   221 
   248 
   222             case NMusSessionInformationApi::ECallConnected:
   249             case NMusSessionInformationApi::ECallConnected:
   223                 {
   250                 {
       
   251                 // retrieve telnumber
       
   252                 TInt error;
   224                 TBuf<KMusTelNumberMaxLength> telNumber;
   253                 TBuf<KMusTelNumberMaxLength> telNumber;
   225                 TBool isSipUri( EFalse );
   254                 error = RProperty::Get(
   226                 GetTelNumberL( telNumber, isSipUri );
   255                     NMusSessionInformationApi::KCategoryUid,
   227                 iObserver.CallConnectedL( telNumber, isSipUri );
   256                     NMusSessionInformationApi::KMusTelNumber,
       
   257                     telNumber );
       
   258 
       
   259                 if ( error != KErrOverflow )
       
   260                     {
       
   261                     User::LeaveIfError( error );
       
   262                     }
       
   263 
       
   264                 iObserver.CallConnectedL( telNumber );
   228                 break;
   265                 break;
   229                 }
   266                 }
   230 
   267 
   231             case NMusSessionInformationApi::ECallHold:
   268             case NMusSessionInformationApi::ECallHold:
   232                 {
   269                 {
       
   270                  // retrieve telnumber
       
   271                 TInt error;
   233                 TBuf<KMusTelNumberMaxLength> telNumber;
   272                 TBuf<KMusTelNumberMaxLength> telNumber;
   234                 TBool isSipUri( EFalse );
   273                 error = RProperty::Get(
   235                 GetTelNumberL( telNumber, isSipUri );
   274                     NMusSessionInformationApi::KCategoryUid,
   236                 iObserver.CallHoldL( telNumber, isSipUri );
   275                     NMusSessionInformationApi::KMusTelNumber,
       
   276                     telNumber );
       
   277 
       
   278                 if ( error != KErrOverflow )
       
   279                     {
       
   280                     User::LeaveIfError( error );
       
   281                     }
       
   282                 iObserver.CallHoldL( telNumber );
   237                 break;
   283                 break;
   238                 }
   284                 }
   239 
   285 
   240             case NMusSessionInformationApi::EConferenceCall:
   286             case NMusSessionInformationApi::EConferenceCall:
   241                 {
   287                 {
   242                 iObserver.ConferenceCallL();
   288                 iObserver.ConferenceCallL();
   243                 break;
   289                 break;
   244                 }
   290                 }
       
   291             case NMusSessionInformationApi::EConferenceTerminated:
       
   292             	{
       
   293             	iObserver.ConferenceCallLTerminated();
       
   294             	break;
       
   295             	}
   245 
   296 
   246             default:
   297             default:
   247                 {
   298                 {
   248                 iObserver.NoActiveCallL();
   299                 iObserver.NoActiveCallL();
   249                 break;
   300                 break;
   269     aError = KErrNone;
   320     aError = KErrNone;
   270 
   321 
   271     MUS_LOG( "mus: [MUSAOP]  <- CMusAvaCallEventMonitor::RunError" )
   322     MUS_LOG( "mus: [MUSAOP]  <- CMusAvaCallEventMonitor::RunError" )
   272     return aError;
   323     return aError;
   273     }
   324     }
   274 
       
   275 
       
   276 // --------------------------------------------------------------------------
       
   277 // CMusAvaCallEventMonitor::IsSipUri()
       
   278 // --------------------------------------------------------------------------
       
   279 //
       
   280 TBool CMusAvaCallEventMonitor::IsSipUri( const TDesC& aTelNumber ) const
       
   281     {
       
   282     _LIT( KSipPrefix, "sip:" );
       
   283      TPtrC prefix = aTelNumber.Left( KSipPrefix().Length() );
       
   284      return prefix.Compare( KSipPrefix ) == 0;
       
   285      }