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