convergedcallengine/csplugin/src/cspcall.cpp
changeset 0 ff3b6d0fd310
child 15 13725ba12484
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  Implements class CSPCall which provides call functionality
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <etelmm.h>
       
    20 #include <etel.h>
       
    21 #include <centralrepository.h>
       
    22 #include <settingsinternalcrkeys.h>
       
    23 #include <ccpdefs.h>
       
    24 #include <gsmerror.h>
       
    25 #include <etelsat.h>
       
    26 #include <cccpcallparameters.h>
       
    27 
       
    28 #include "cspcall.h"
       
    29 #include "cspetelcallrequester.h"
       
    30 #include "cspetelcalleventmonitor.h"
       
    31 #include "cspcallinfomonitor.h"
       
    32 #include "cspetelcallstatusmonitor.h"
       
    33 #include "cspetelcallcapsmonitor.h"
       
    34 #include "csptransferprovider.h"
       
    35 #include "cspforwardprovider.h"
       
    36 #include "csplogger.h"
       
    37 #include "csppanic.pan"
       
    38 #include "cspconsts.h"
       
    39 #include "cspaudiohandler.h"
       
    40 #include "mcspcommoninfo.h"
       
    41 #include "mcspsecuritysettingobserver.h"
       
    42 #include "tcspskypeidparser.h"
       
    43 #include "cspuuimonitor.h"
       
    44 #include "cspuuimessagesender.h"
       
    45 
       
    46 const TInt KTimesToSplitValue = 16;
       
    47 
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CSPCall::~CSPCall
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CSPCall::~CSPCall()
       
    54     {
       
    55     CSPLOGSTRING(CSPOBJECT, "CSPCall::~CSPCall <");
       
    56 
       
    57     delete iParams;
       
    58     iCommonInfo.IndicateHangupComplete( *this );
       
    59     
       
    60     if ( iAudioHandler 
       
    61          && iAudioStatus == ECSPCallAudioStatusActive )
       
    62         {
       
    63         iAudioStatus = ECSPCallAudioStatusInactive;
       
    64         iAudioHandler->Stop();
       
    65         }
       
    66     
       
    67     delete iUserToUserInformation;    
       
    68     delete iRequester;    
       
    69     delete iCallEventMonitor;
       
    70     delete iCallStatusMonitor;
       
    71     delete iCallCapsMonitor; 
       
    72     delete iCallInfoMonitor;
       
    73     delete iForwardProvider;
       
    74     delete iTransferProvider;
       
    75     delete iUUIMonitor;
       
    76     delete iUUIMessageSender;
       
    77     delete iSkypeId;
       
    78 
       
    79     iObservers.Close();        
       
    80     if ( iCall.SubSessionHandle() )
       
    81         {
       
    82         iCall.Close();
       
    83         }
       
    84     
       
    85     CSPLOGSTRING(CSPOBJECT, "CSPCall::~CSPCall >");
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSPCall::SetAudioHandler
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CSPCall::SetAudioHandler( CSPAudioHandler* aHandler )
       
    93     {
       
    94     CSPLOGSTRING2(CSPINT, "CSPCall::SetAudioHandler handler: %x", aHandler);
       
    95     iAudioHandler = aHandler;
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CSPCall::SecuritySettingChanged
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CSPCall::SecuritySettingChanged( TInt aValue )
       
   103     {
       
   104     switch ( aValue )
       
   105         {
       
   106         case MCSPSecuritySettingObserver::ESecureCall:         
       
   107             {
       
   108             CSPLOGSTRING(CSPINT, 
       
   109                     "CSPCall::SecuritySettingChanged Sending 'secure call' event");
       
   110             NotifyCallEventOccurred( MCCPCallObserver::ECCPSecureCall );
       
   111             break; 
       
   112             }            
       
   113         case MCSPSecuritySettingObserver::ENotSecureCall:                     
       
   114             {
       
   115             CSPLOGSTRING(CSPINT, 
       
   116                     "CSPCall::SecuritySettingChanged Sending 'not secure call' event");
       
   117             NotifyCallEventOccurred( MCCPCallObserver::ECCPNotSecureCall );
       
   118             break;  
       
   119             }
       
   120         case MCSPSecuritySettingObserver::ESecureNotSpecified:                     
       
   121             {
       
   122             CSPLOGSTRING(CSPINT, 
       
   123                     "CSPCall::SecuritySettingChanged Sending SecureNotSpecified");
       
   124             NotifyCallEventOccurred( MCCPCallObserver::ECCPSecureNotSpecified );
       
   125             break;  
       
   126             }
       
   127 
       
   128         default: 
       
   129             {
       
   130             CSPLOGSTRING(CSPERROR, "CSPCall::SecuritySettingChanged, \
       
   131                 unknown event");            
       
   132             break;  
       
   133             }
       
   134         }
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CSPCall::RemoteAlertingToneStatusChanged
       
   139 // Sends EarlyMediaStarted event to observer if network has started to 
       
   140 // play remote alerting tone. There is only one known use case: Network
       
   141 // starts playing alerting tone during connecting state. 
       
   142 //
       
   143 // This RemoteAlertingToneStatusChanged is called for every call, 
       
   144 // so it is calls responsibility to determine if the 
       
   145 // observer should be notified.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CSPCall::RemoteAlertingToneStatusChanged(
       
   149     RMmCustomAPI::TRemoteAlertingToneStatus aNewStatus )
       
   150     {
       
   151     CSPLOGSTRING2(CSPINT, 
       
   152         "CSPCall::RemoteAlertingToneStatusChanged new status: %d", aNewStatus );
       
   153     
       
   154     if ( aNewStatus == RMmCustomAPI::EUiStopTone ||
       
   155          aNewStatus == RMmCustomAPI::EUiNoTone ) // NW tells us to stop playing 
       
   156         {
       
   157         // Connecting is only state where network starts playing the tone.
       
   158         if ( iCallState == MCCPCallObserver::ECCPStateConnecting )
       
   159             {
       
   160             NotifyCallEventOccurred( 
       
   161                 MCCPCallObserver::ECCCSPEarlyMediaStarted );
       
   162             }
       
   163         }
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // CSPCall::NotifyCallStateChangedETel
       
   168 // Notifies observers about state changes
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CSPCall::NotifyCallStateChangedETel( RMobileCall::TMobileCallStatus aState ) 
       
   172     {
       
   173     CSPLOGSTRING3(CSPINT, 
       
   174                   "CSPCall::NotifyCallStateChangedETel < state: %d this: %x", 
       
   175                   aState, this );
       
   176     switch ( aState )
       
   177         {
       
   178         /*
       
   179         Cannot receive any mapping call statuses from ETel to following
       
   180         optional states:
       
   181         
       
   182         ECCPStateForwarding   MO call is being forwarded at receiver end
       
   183         ECCPStateQueued       Call is queued locally.
       
   184         
       
   185         The commented observer calls are for CS specific call states.
       
   186         */
       
   187         
       
   188         // Indicates that the call is idle or unknown.
       
   189         case RMobileCall::EStatusIdle:
       
   190         case RMobileCall::EStatusUnknown:
       
   191             {
       
   192             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Idle");
       
   193 
       
   194             // If audio still active
       
   195             if ( iAudioStatus == ECSPCallAudioStatusActive 
       
   196                  && iAudioHandler
       
   197                  && iParams->CallType() == CCPCall::ECallTypeCSVoice )
       
   198                 {
       
   199                 iAudioStatus = ECSPCallAudioStatusInactive;
       
   200                 iAudioHandler->Stop();
       
   201                 }
       
   202                 
       
   203             // Notify error in case not going through disconnecting
       
   204             if ( iCallState != MCCPCallObserver::ECCPStateDisconnecting 
       
   205                      && !iTerminationErrorNotified )
       
   206                 {
       
   207                 CheckAndNotifyTerminationError();
       
   208                 }
       
   209             
       
   210             NotifyCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   211             iCommonInfo.IndicateHangupComplete( *this );
       
   212             break;
       
   213             }
       
   214         // The call is dialling.
       
   215         case RMobileCall::EStatusDialling:
       
   216             CSPLOGSTRING(CSPINT, "CSPCall callstate Dialling");
       
   217             {
       
   218             if ( iAudioHandler && iParams->CallType() == CCPCall:: ECallTypeCSVoice )
       
   219                 {
       
   220                 iAudioStatus = ECSPCallAudioStatusActive;
       
   221                 iAudioHandler->Start();
       
   222                 }
       
   223                 
       
   224             iDontReportTerm = EFalse;
       
   225             NotifyCallStateChanged( MCCPCallObserver::ECCPStateDialling );
       
   226             break;
       
   227             }            
       
   228         //Indicates that the MT call is ringing but not answered yet by 
       
   229         // the local user
       
   230         case RMobileCall::EStatusRinging:
       
   231             {
       
   232             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Ringing");
       
   233             NotifyCallStateChanged( MCCPCallObserver::ECCPStateRinging );
       
   234             break;
       
   235             }
       
   236         // Indicates that the local user has answered the MT call but
       
   237         // the network has not acknowledged the call connection yet. 
       
   238         case RMobileCall::EStatusAnswering:
       
   239             {
       
   240             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Answering");
       
   241 
       
   242             if ( !iMobileOriginated
       
   243                 && iAudioHandler 
       
   244                 && iAudioStatus == ECSPCallAudioStatusInactive
       
   245                 && iParams->CallType() == CCPCall::ECallTypeCSVoice )
       
   246                 {
       
   247                 iAudioStatus = ECSPCallAudioStatusActive;
       
   248                 iAudioHandler->Start();
       
   249                 }
       
   250 
       
   251             NotifyCallStateChanged( MCCPCallObserver::ECCPStateAnswering );
       
   252             break;
       
   253             }
       
   254         // MO Call: the network notifies to the MS that the remote party
       
   255         // is now ringing. 
       
   256         case RMobileCall::EStatusConnecting:
       
   257             {
       
   258             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETelConnecting");
       
   259             RMmCustomAPI::TRemoteAlertingToneStatus tone = 
       
   260                 iCommonInfo.GetRemoteAlertingToneStatus();
       
   261             if ( tone == RMmCustomAPI::EUiNoTone ||
       
   262                  tone == RMmCustomAPI::EUiStopTone )
       
   263                 {
       
   264                 NotifyCallStateChangedWithInband( MCCPCallObserver::ECCPStateConnecting );
       
   265                 }
       
   266             else
       
   267                 {
       
   268                 NotifyCallStateChanged( MCCPCallObserver::ECCPStateConnecting );
       
   269                 }
       
   270             break;
       
   271             }
       
   272         // Indicates that call is connected and active.
       
   273         case RMobileCall::EStatusConnected:
       
   274             {
       
   275             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Connected");
       
   276 
       
   277             iDontReportTerm = ETrue;
       
   278             NotifyCallStateChanged( MCCPCallObserver::ECCPStateConnected );
       
   279             
       
   280             // Agreement with TSY is that the
       
   281             // COLP number is available in connected state.
       
   282             NotifyRemotePartyNumberChanged();            
       
   283             break;
       
   284             }
       
   285         // Indicates that call is disconnecting. (Same as RCall::HangingUp)
       
   286         case RMobileCall::EStatusDisconnecting:
       
   287             {
       
   288             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Disconnecting");
       
   289 
       
   290             if ( !iTerminationErrorNotified )
       
   291                 {
       
   292                 CheckAndNotifyTerminationError();
       
   293                 }
       
   294             
       
   295             NotifyCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );                
       
   296             break;
       
   297             }
       
   298         // Indicates that the call is disconnecting with inband data
       
   299         // (to enable the network to send an audio tone), signifying
       
   300         // that the call is not to be released until user terminates call
       
   301         case RMobileCall::EStatusDisconnectingWithInband:
       
   302             {
       
   303             CSPLOGSTRING(CSPINT, 
       
   304                 "CSPCall::NotifyCallStateChangedETel DisconnectingWithInband");
       
   305 
       
   306             if ( !iTerminationErrorNotified )
       
   307                 {
       
   308                 CheckAndNotifyTerminationError();
       
   309                 }
       
   310             
       
   311             NotifyCallStateChangedWithInband( 
       
   312                                 MCCPCallObserver::ECCPStateDisconnecting );
       
   313             break;
       
   314             }
       
   315         // Indicates that the call is connected but on hold.  
       
   316         case RMobileCall::EStatusHold:
       
   317             {
       
   318             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Hold");
       
   319             NotifyCallStateChanged( MCCPCallObserver::ECCPStateHold );
       
   320             break;
       
   321             }
       
   322         case RMobileCall::EStatusTransferring:
       
   323             {
       
   324             CSPLOGSTRING(CSPINT, "CSPCall::NotifyCallStateChangedETel Transferring");
       
   325             NotifyCallStateChanged( MCCPCallObserver::ECCPStateTransferring );
       
   326             break;
       
   327             }
       
   328             
       
   329         // Indicates that call is undergoing temporary channel loss
       
   330         // and it may or may not be reconnected.  
       
   331         case RMobileCall::EStatusReconnectPending: // fall through 
       
   332         //Indicates that the call is the non-active half of an alternating
       
   333         // call. This call is waiting for its active half or the remote
       
   334         // end to switch alternating call mode.
       
   335         case RMobileCall::EStatusWaitingAlternatingCallSwitch: // fall through
       
   336         case RMobileCall::EStatusTransferAlerting:
       
   337             {
       
   338             CSPLOGSTRING2(CSPINT, 
       
   339                     "CSPCall::NotifyCallStateChangedETel no special handling for state %d",
       
   340                     aState);            
       
   341             break;
       
   342             }
       
   343 
       
   344         default:
       
   345             {
       
   346             CSPLOGSTRING(CSPERROR, 
       
   347                     "CSPCall::NotifyCallStateChangedETel callstate UNKNOWN");
       
   348             break;
       
   349             }
       
   350         }
       
   351     CSPLOGSTRING(CSPREQIN, "CSPCall::NotifyCallStateChangedETel >");
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------------------------
       
   355 // CSPCall::NotifyCallEventOccurred
       
   356 // Notifies observers about call events
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 void CSPCall::NotifyCallEventOccurred( 
       
   360     MCCPCallObserver::TCCPCallEvent aEvent )
       
   361     {
       
   362     CSPLOGSTRING2(CSPINT, 
       
   363             "CSPCall::NotifyCallEventOccurred < event: %d", aEvent);
       
   364     
       
   365     TInt obsCount = iObservers.Count();
       
   366     for ( TInt i = 0; i < obsCount; i++ )
       
   367         {
       
   368         CSPLOGSTRING2(CSPINT, "CSPCall::NotifyCallEventOccurred obs=%d",i);
       
   369         MCCPCallObserver *obs = iObservers[i];
       
   370         if ( obs )
       
   371             {
       
   372             obs->CallEventOccurred( aEvent, this );
       
   373             }
       
   374             
       
   375         CSPLOGSTRING2(CSPINT, "CSPCall::NotifyCallEventOccurred ok obs=%d",i);
       
   376         }
       
   377         
       
   378     CSPLOGSTRING2(CSPINT, "CSPCall::NotifyCallEventOccurred > event: %d", aEvent);
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // CSPCall::NotifyTransferCallEventOccurred
       
   383 // Forward notification of transfer event to it's provider
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CSPCall::NotifyTransferCallEventOccurred( 
       
   387     MCCPTransferObserver::TCCPTransferEvent aEvent ) 
       
   388     {
       
   389     CSPLOGSTRING2(CSPINT, "CSPCall::NotifyTransferCallEventOccurred %d", aEvent);
       
   390     // forward the method call to CSPTransferProvider object
       
   391     iTransferProvider->TransferEventOccurred( aEvent );
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // CSPCall::NotifyForwardEventOccurred
       
   396 // Notifies observers about call events
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 void CSPCall::NotifyForwardEventOccurred( 
       
   400     MCCPForwardObserver::TCCPForwardEvent aEvent )
       
   401     {
       
   402     CSPLOGSTRING2(CSPINT, "CSPCall::NotifyForwardEventOccurred %d", aEvent);
       
   403     iForwardProvider->NotifyForwardEventOccurred( aEvent );    
       
   404     }
       
   405 
       
   406 // ---------------------------------------------------------------------------
       
   407 // CSPCall::CallName
       
   408 // Get call name
       
   409 // ---------------------------------------------------------------------------
       
   410 //
       
   411 void CSPCall::CallName( TName& aCallName )
       
   412     {
       
   413     CSPLOGSTRING(CSPINT, "CSPCall::CallName");
       
   414     aCallName.Zero();
       
   415     aCallName.Append( iCallName );
       
   416     }
       
   417 
       
   418 // ---------------------------------------------------------------------------
       
   419 // CSPCall::DialRequestFailed
       
   420 // Handles situations when dial fails
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CSPCall::DialRequestFailed( TInt aErrorCode )
       
   424     {
       
   425     CSPLOGSTRING(CSPERROR, "CSPCall::DialRequestFailed");
       
   426     iDialCompletionCode = aErrorCode;
       
   427     
       
   428     // If state has not changed 
       
   429     // ( e.g. in case of dial could not be initiated by network problem)
       
   430     if ( iCallStatusMonitor->State() == 
       
   431                    RMobileCall::RMobileCall::EStatusUnknown )
       
   432         {
       
   433 	    NotifyErrorOccurred( iRequester->MapError( aErrorCode ) );	        	
       
   434         
       
   435         // Force release since otherwise call remains unreleased
       
   436         CSPLOGSTRING(CSPERROR, "CSPCall::DialRequestFailed() Force Idle");
       
   437         NotifyCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   438         }
       
   439     
       
   440     // If dial request has completed after notifying disconnecting state
       
   441     else if ( iCallState == MCCPCallObserver::ECCPStateDisconnecting
       
   442              && !iTerminationErrorNotified )
       
   443         {
       
   444         CheckAndNotifyTerminationError();
       
   445         }
       
   446     }
       
   447 
       
   448 // ---------------------------------------------------------------------------
       
   449 // CSPCall::EmergencyDialRequestFailed
       
   450 // Handles situations when emergency dial fails
       
   451 // ---------------------------------------------------------------------------
       
   452 //
       
   453 void CSPCall::EmergencyDialRequestFailed( TInt /*aErrorCode*/ )
       
   454     {
       
   455     CSPLOGSTRING(CSPERROR, "CSPCall::EmergencyDialRequestFailed");
       
   456     
       
   457     // Always same error code for CCE
       
   458     NotifyErrorOccurred( ECCPEmergencyFailed );
       
   459     
       
   460     // Mark that exit code will not be used
       
   461     iTerminationErrorNotified = ETrue;
       
   462     }
       
   463     
       
   464 // ---------------------------------------------------------------------------
       
   465 // CSPCall::NotifyErrorOccurred
       
   466 // Notifies observers about errors
       
   467 // ---------------------------------------------------------------------------
       
   468 //
       
   469 void CSPCall::NotifyErrorOccurred( TCCPError aError )
       
   470     {
       
   471     CSPLOGSTRING2(CSPERROR, "CSPCall::NotifyErrorOccurred err %d", aError );
       
   472 
       
   473     TInt obsCount = iObservers.Count();
       
   474     for ( TInt i = 0; i < obsCount; i++ )
       
   475         {
       
   476         MCCPCallObserver *obs = iObservers[i];
       
   477         if ( obs )
       
   478             {
       
   479             obs->ErrorOccurred( aError, this );
       
   480             }
       
   481         }
       
   482     }
       
   483     
       
   484 // ---------------------------------------------------------------------------
       
   485 // CSPCall::CallCapsChanged
       
   486 // Notifies observers about new capabilities.
       
   487 // ---------------------------------------------------------------------------
       
   488 //
       
   489 void CSPCall::CallCapsChanged( const TUint32 aCapsFlags )
       
   490     {
       
   491     CSPLOGSTRING2(CSPERROR, "CSPCall::CallCapsChanged %b", aCapsFlags );
       
   492     iCapsFlags = aCapsFlags;
       
   493     TInt obsCount = iObservers.Count();
       
   494     for ( TInt i = 0; i < obsCount; i++ )
       
   495         {
       
   496         MCCPCallObserver *obs = iObservers[i];
       
   497         if ( obs )
       
   498             {
       
   499             obs->CallCapsChanged( aCapsFlags, this );
       
   500             }
       
   501         }
       
   502     }
       
   503 
       
   504 // ---------------------------------------------------------------------------
       
   505 // From class MCCPCSCall
       
   506 // CSPCall::GetMobileCallInfo
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 TInt CSPCall::GetMobileCallInfo( TDes8& aCallInfo ) const
       
   510     {
       
   511     CSPLOGSTRING(CSPINT, "CSPCall::GetMobileCallInfo");
       
   512     return iCall.GetMobileCallInfo( aCallInfo );
       
   513     }
       
   514 
       
   515 // ---------------------------------------------------------------------------
       
   516 // From class MCCPCSCall
       
   517 // CSPCall::GetMobileDataCallCaps
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 TInt CSPCall::GetMobileDataCallCaps( TDes8& /*aCaps*/ ) const
       
   521     {
       
   522     CSPLOGSTRING(CSPERROR, 
       
   523             "CSPCall::GetMobileDataCallCaps ERROR, Not supported");
       
   524     return KErrNotSupported;
       
   525     }
       
   526 
       
   527 // ---------------------------------------------------------------------------
       
   528 // From class MCCPCall
       
   529 // CSPCall::Dial
       
   530 // ---------------------------------------------------------------------------
       
   531 //
       
   532 TInt CSPCall::Dial()
       
   533     {
       
   534     CSPLOGSTRING( CSPREQIN, "CSPCall::Dial" );
       
   535     // Parameters not given, must create empty descriptor.
       
   536     TBuf8<1> params;
       
   537     return Dial(params);
       
   538     }
       
   539 
       
   540 // ---------------------------------------------------------------------------
       
   541 // From class MCCPCall
       
   542 // CSPCall::RemoteParty
       
   543 // ---------------------------------------------------------------------------
       
   544 //
       
   545 const TDesC& CSPCall::RemoteParty() const
       
   546     {
       
   547     CSPLOGSTRING(CSPREQIN, "CSPCall::RemoteParty");
       
   548     return iRemotePartyNumber;
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // From class MCCPCall
       
   553 // CSPCall::RemotePartyName
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 const TDesC& CSPCall::RemotePartyName()
       
   557     {
       
   558     CSPLOGSTRING(CSPREQIN, "CSPCall::RemotePartyName");
       
   559     return iRemotePartyName;
       
   560     }
       
   561   
       
   562 // ---------------------------------------------------------------------------
       
   563 // From class MCCPCall
       
   564 // CSPCall::DialledParty
       
   565 // ---------------------------------------------------------------------------
       
   566 //  
       
   567 const TDesC& CSPCall::DialledParty() const 
       
   568     {
       
   569     CSPLOGSTRING2(CSPREQIN, "CSPCall::DialledParty %S", &iRemotePartyNumber);
       
   570     return iRemotePartyNumber;
       
   571     }
       
   572     
       
   573 // ---------------------------------------------------------------------------
       
   574 // From class MCCPCall
       
   575 // CSPCall::Answer
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 TInt CSPCall::Answer()
       
   579     {
       
   580     CSPLOGSTRING(CSPREQIN, "CSPCall::Answer <");
       
   581     TInt ret( KErrNone );
       
   582     
       
   583     if ( iCallState == MCCPCallObserver::ECCPStateRinging 
       
   584          || iCallState == MCCPCallObserver::ECCPStateQueued )
       
   585         {    
       
   586         if( iMobileOriginated )
       
   587             {
       
   588             ret = KErrGeneral;
       
   589             }
       
   590         else if( iCallState != MCCPCallObserver::ECCPStateRinging && 
       
   591             iCallState != MCCPCallObserver::ECCPStateQueued )
       
   592             {
       
   593             ret = KErrAccessDenied;
       
   594             }
       
   595         else
       
   596             {
       
   597             ret = iCommonInfo.IndicateAnswerRequest( *this );
       
   598             }
       
   599         }
       
   600     else
       
   601         {
       
   602         // Not correct state for answer
       
   603         ret = KErrNotReady;
       
   604         }
       
   605     
       
   606     CSPLOGSTRING2(CSPREQIN, "CSPCall::Answer > ret %d", ret);
       
   607     return ret;
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 // From class MCCPCallCommandHandling
       
   612 // CSPCall::PerformAnswerRequest
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 TInt CSPCall::PerformAnswerRequest()
       
   616     {
       
   617     CSPLOGSTRING(CSPREQIN, "CSPCall::PerformAnswerRequest");
       
   618     
       
   619     TInt ret = iRequester->MakeRequest( CSPEtelCallRequester::ERequestTypeAnswer );
       
   620     CSPLOGSTRING3(CSPINT, 
       
   621             "CSPCall::Answer request performed, call state %d ret: %d", iCallState, ret);
       
   622 
       
   623     return ret;
       
   624     }
       
   625 
       
   626 // ---------------------------------------------------------------------------
       
   627 // From class MCCPCall
       
   628 // CSPCall::Reject
       
   629 // ---------------------------------------------------------------------------
       
   630 //
       
   631 TInt CSPCall::Reject()
       
   632     {
       
   633     CSPLOGSTRING(CSPREQIN, "CSPCall::Reject <");
       
   634     TInt ret;
       
   635     if ( iCallState == MCCPCallObserver::ECCPStateRinging
       
   636          || iCallState == MCCPCallObserver::ECCPStateQueued
       
   637          || iCallState == MCCPCallObserver::ECCPStateAnswering )
       
   638         {        
       
   639         CSPLOGSTRING( CSPREQIN, "CSPCall::Reject 2" );
       
   640         ret = HangUp();
       
   641         }
       
   642     else
       
   643         {
       
   644         ret = KErrNotReady;
       
   645         }
       
   646     CSPLOGSTRING2(CSPREQIN, "CSPCall::Reject > ret: %d", ret );
       
   647     return ret;
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // From class MCCPCall
       
   652 // CSPCall::Queue
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 TInt CSPCall::Queue()
       
   656     {
       
   657     CSPLOGSTRING(CSPREQIN, "CSPCall::Queue");
       
   658     TBool callWaitingState;
       
   659     iDontReportTerm = ETrue;
       
   660     
       
   661     TRAPD( res, iCommonInfo.GetCallWaitingL( *iParams, callWaitingState ) );
       
   662     if( res == KErrNone )
       
   663         {
       
   664         if ( callWaitingState )
       
   665             {
       
   666             CSPLOGSTRING(CSPREQIN, "CSPCall::Queue Call Waiting On");
       
   667             iCallState = MCCPCallObserver::ECCPStateQueued;
       
   668             
       
   669             // Notify Queued state
       
   670             TInt obsCount = iObservers.Count ( );
       
   671             for (TInt i = 0; i < obsCount; i++ )
       
   672                 {
       
   673                 MCCPCallObserver *obs = iObservers[i];
       
   674                 if ( obs )
       
   675                     {
       
   676                     obs->CallStateChanged ( iCallState, this );
       
   677                     }
       
   678                 }
       
   679             CSPLOGSTRING(CSPOBJECT, "CSPCall::Queue ok");
       
   680 
       
   681             return KErrNone;
       
   682             }
       
   683         else
       
   684             {
       
   685             CSPLOGSTRING(CSPREQIN, "CSPCall::Queue Call Waiting Off");
       
   686             }
       
   687         }
       
   688     else
       
   689         {
       
   690         CSPLOGSTRING2(CSPERROR, 
       
   691                       "CSPCall::Queue Error %d with CR. Call Waiting Off", 
       
   692                       res);
       
   693         }
       
   694     
       
   695     return KErrNotSupported;
       
   696     }
       
   697     
       
   698 // ---------------------------------------------------------------------------
       
   699 // From class MCCPCall
       
   700 // CSPCall::Ringing
       
   701 // ---------------------------------------------------------------------------
       
   702 //
       
   703 TInt CSPCall::Ringing()
       
   704     {
       
   705     CSPLOGSTRING(CSPREQIN, "CSPCall::Ringing");
       
   706     iDontReportTerm = ETrue;
       
   707     
       
   708     // Ringing state is accepted because MT-call goes to ringing
       
   709     // state in the beginning based on ETel state maching.
       
   710     if ( iCallState == MCCPCallObserver::ECCPStateIdle ||
       
   711          iCallState == MCCPCallObserver::ECCPStateRinging ) 
       
   712         {
       
   713         NotifyRingingState();
       
   714         return KErrNone;
       
   715         }
       
   716     else if ( iCallState == MCCPCallObserver::ECCPStateAnswering )
       
   717         {
       
   718         // Do nothing if already in Answering state (autoanswer).   
       
   719         return KErrNone; 
       
   720         }
       
   721         
       
   722     return KErrNotReady;
       
   723     }
       
   724     
       
   725 // ---------------------------------------------------------------------------
       
   726 // From class MCCPCall
       
   727 // CSPCall::HangUp
       
   728 // ---------------------------------------------------------------------------
       
   729 //
       
   730 TInt CSPCall::HangUp()
       
   731     {
       
   732     CSPLOGSTRING2(CSPREQIN, "CSPCall::HangUp this: %x", this);
       
   733     TInt ret( KErrNone );
       
   734     
       
   735     CSPEtelCallRequester::TRequestType req = iRequester->Request();
       
   736     if ( req == CSPEtelCallRequester::ERequestTypeDial || 
       
   737          ( req == CSPEtelCallRequester::ERequestTypeDialEmergency ) )
       
   738         {
       
   739         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp 1: Cancel ongoing dial");
       
   740         ret = iRequester->DialCancel();
       
   741         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp Canceled");
       
   742         }
       
   743     else if ( req == CSPEtelCallRequester::ERequestTypeHangup )
       
   744         {
       
   745         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp 2");
       
   746         ret = KErrAlreadyExists;
       
   747         }
       
   748     else if ( req == CSPEtelCallRequester::ERequestTypeNone 
       
   749               && iCallState != MCCPCallObserver::ECCPStateIdle )
       
   750         {
       
   751         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp 3");
       
   752         ret = iRequester->MakeRequest( CSPEtelCallRequester::ERequestTypeHangup );
       
   753         iCommonInfo.IndicateActiveHangup( *this );
       
   754         }
       
   755     else if ( req == CSPEtelCallRequester::ERequestTypeNone )
       
   756         {
       
   757         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp 4");
       
   758         ret = KErrAlreadyExists;
       
   759         }
       
   760     else
       
   761         {
       
   762         CSPLOGSTRING(CSPREQIN, "CSPCall::HangUp 5");
       
   763         // Request pending, must be canceled
       
   764         iRequester->Cancel();
       
   765         ret = iRequester->MakeRequest( CSPEtelCallRequester::ERequestTypeHangup );
       
   766         iCommonInfo.IndicateActiveHangup( *this );
       
   767         }
       
   768         
       
   769     return ret;
       
   770     }
       
   771 
       
   772 // ---------------------------------------------------------------------------
       
   773 // From class MCCPCall
       
   774 // CSPCall::Cancel
       
   775 // ---------------------------------------------------------------------------
       
   776 //
       
   777 TInt CSPCall::Cancel()
       
   778     {
       
   779     CSPLOGSTRING(CSPREQIN, "CSPCall::Cancel");
       
   780     return HangUp();
       
   781     }
       
   782         
       
   783 // ---------------------------------------------------------------------------
       
   784 // From class MCCPCall
       
   785 // CSPCall::Hold
       
   786 // ---------------------------------------------------------------------------
       
   787 //
       
   788 TInt CSPCall::Hold()
       
   789     {
       
   790     CSPLOGSTRING2(CSPREQIN, "CSPCall::Hold this: %x", this);
       
   791     TInt ret;
       
   792         
       
   793     if ( iCallState == MCCPCallObserver::ECCPStateConnected )
       
   794         {
       
   795         CSPLOGSTRING(CSPREQOUT, "CSPCall::Hold make request");
       
   796 
       
   797         // Set call on hold
       
   798         ret = iRequester->MakeRequest( 
       
   799                     CSPEtelCallRequester::ERequestTypeHold );
       
   800         if ( ret != KErrNone )
       
   801             {
       
   802             CSPLOGSTRING2(CSPERROR, 
       
   803                 "CSPCall::Hold ERROR: %d", ret);
       
   804             }
       
   805         }
       
   806     else if ( iCallState == MCCPCallObserver::ECCPStateHold )
       
   807         {
       
   808         CSPLOGSTRING(CSPERROR, "CSPCall::Hold : already held");
       
   809         ret = KErrAlreadyExists;
       
   810         }
       
   811     else
       
   812         {
       
   813         CSPLOGSTRING(CSPERROR, "CSPCall::Hold not allowed");
       
   814         ret = KErrNotReady;
       
   815         }
       
   816 
       
   817     return ret;
       
   818     } 
       
   819 
       
   820 // ---------------------------------------------------------------------------
       
   821 // From class MCCPCall
       
   822 // CSPCall::Resume
       
   823 // ---------------------------------------------------------------------------
       
   824 //
       
   825 TInt CSPCall::Resume()
       
   826     {
       
   827     CSPLOGSTRING2(CSPREQIN, "CSPCall::Resume this: %x", this);
       
   828     TInt ret;
       
   829         
       
   830     if ( iCallState == MCCPCallObserver::ECCPStateHold )
       
   831         {
       
   832         CSPLOGSTRING(CSPREQOUT, "CSPCall::Resume request");
       
   833         
       
   834         ret = iRequester->MakeRequest( 
       
   835             CSPEtelCallRequester::ERequestTypeResume );
       
   836         if ( KErrNone != ret )
       
   837             {
       
   838             CSPLOGSTRING2(CSPERROR, "CSPCall::Resume ERROR %d", ret);
       
   839             }
       
   840         }
       
   841     else if ( iCallState == MCCPCallObserver::ECCPStateConnected )
       
   842         {
       
   843         CSPLOGSTRING(CSPERROR, "CSPCall::Resume already connected" );
       
   844         ret = KErrAlreadyExists;
       
   845         }
       
   846     else
       
   847         {
       
   848         CSPLOGSTRING(CSPERROR, "CSPCall::Resume not held state" );
       
   849         ret = KErrNotReady;
       
   850         }
       
   851     
       
   852     return ret;
       
   853     }
       
   854 
       
   855 // ---------------------------------------------------------------------------
       
   856 // From class MCCPCall
       
   857 // CSPCall::Swap
       
   858 // ---------------------------------------------------------------------------
       
   859 //
       
   860 TInt CSPCall::Swap()
       
   861     {
       
   862     CSPLOGSTRING2(CSPREQIN, "CSPCall::Swap this: %x", this);
       
   863     TInt ret;
       
   864     if ( iCallState == MCCPCallObserver::ECCPStateConnected
       
   865          || iCallState == MCCPCallObserver::ECCPStateHold )
       
   866         {    
       
   867         ret = iRequester->MakeRequest( CSPEtelCallRequester::ERequestTypeSwap );
       
   868         if ( ret )
       
   869             {
       
   870             CSPLOGSTRING2( CSPERROR, "CSPCall::Swap Error %d", ret );
       
   871             }
       
   872         }
       
   873     else
       
   874         {
       
   875         ret = KErrNotReady;
       
   876         }
       
   877     return ret;
       
   878     }
       
   879 
       
   880 // ---------------------------------------------------------------------------
       
   881 // From class MCCPCall
       
   882 // CSPCall::IsMobileOriginated
       
   883 // ---------------------------------------------------------------------------
       
   884 //
       
   885 TBool CSPCall::IsMobileOriginated() const
       
   886     {
       
   887     CSPLOGSTRING(CSPREQIN, "CSPCall::IsMobileOriginated");
       
   888     return iMobileOriginated;
       
   889     }
       
   890 
       
   891 // ---------------------------------------------------------------------------
       
   892 // From class MCCPCall
       
   893 // CSPCall::State
       
   894 // ---------------------------------------------------------------------------
       
   895 //
       
   896 MCCPCallObserver::TCCPCallState CSPCall::State() const
       
   897     {
       
   898     CSPLOGSTRING2(CSPREQIN, "CSPCall::State %d", iCallState);
       
   899     return iCallState;
       
   900     }
       
   901 
       
   902 // ---------------------------------------------------------------------------
       
   903 // From class MCCPCall
       
   904 // CSPCall::Uid
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 TUid CSPCall::Uid() const
       
   908     {
       
   909     CSPLOGSTRING2(CSPREQIN, "CSPCall::Uid %d", KCSPImplementationUid);
       
   910     return KCSPImplementationUid;
       
   911     }
       
   912 
       
   913 // ---------------------------------------------------------------------------
       
   914 // From class MCCPCall
       
   915 // CSPCall::Caps
       
   916 // ---------------------------------------------------------------------------
       
   917 //
       
   918 MCCPCallObserver::TCCPCallControlCaps CSPCall::Caps( ) const
       
   919     {
       
   920     CSPLOGSTRING2(CSPREQIN, "CSPCall::Caps %b", iCapsFlags );
       
   921     return (MCCPCallObserver::TCCPCallControlCaps) iCapsFlags;
       
   922     }
       
   923  
       
   924 // ---------------------------------------------------------------------------
       
   925 // From class MCCPCall
       
   926 // CSPCall::SetParameters
       
   927 // ---------------------------------------------------------------------------
       
   928 //
       
   929 void CSPCall::SetParameters( const CCCPCallParameters& /*aNewParams*/ )
       
   930     {
       
   931     CSPLOGSTRING(CSPOBJECT, "CSPCall::SetParameters ERROR Can't set params");
       
   932     }
       
   933 
       
   934 // ---------------------------------------------------------------------------
       
   935 // From class MCCPCall
       
   936 // CSPCall::Parameters
       
   937 // ---------------------------------------------------------------------------
       
   938 //
       
   939 const CCCPCallParameters& CSPCall::Parameters() const
       
   940     {
       
   941     CSPLOGSTRING(CSPINT, "CSPCall::Parameters");
       
   942     return *iParams;
       
   943     }
       
   944 
       
   945 // ---------------------------------------------------------------------------
       
   946 // From class MCCPCall
       
   947 // CSPCall::TransferProvider
       
   948 // ---------------------------------------------------------------------------
       
   949 //
       
   950 MCCPTransferProvider* CSPCall::TransferProviderL(const MCCPTransferObserver& 
       
   951                                                             aObserver )
       
   952     {
       
   953     CSPLOGSTRING(CSPREQIN, "CSPCall::TransferProvider");
       
   954     iTransferProvider->AddObserverL( aObserver );
       
   955     return iTransferProvider;
       
   956     }
       
   957     
       
   958 // ---------------------------------------------------------------------------
       
   959 // From class MCCPCall
       
   960 // CSPCall::ForwardProvider
       
   961 // ---------------------------------------------------------------------------
       
   962 //
       
   963 MCCPForwardProvider* CSPCall::ForwardProviderL( 
       
   964         const MCCPForwardObserver& aObserver )
       
   965     {
       
   966     CSPLOGSTRING(CSPREQIN, "CSPCall::ForwardProvider");
       
   967     iForwardProvider->AddObserverL( aObserver );
       
   968     return iForwardProvider;
       
   969     }
       
   970 
       
   971 // ---------------------------------------------------------------------------
       
   972 // From class MCCPCall
       
   973 // CSPCall::AddObserverL
       
   974 // ---------------------------------------------------------------------------
       
   975 //
       
   976 void CSPCall::AddObserverL( const MCCPCallObserver& aObserver )
       
   977     {
       
   978     CSPLOGSTRING2(CSPREQIN, "CSPCall::AddObserverL %x", &aObserver);
       
   979     if ( iObservers.Find( &aObserver ) == KErrNotFound )
       
   980         {
       
   981         iObservers.AppendL( &aObserver );
       
   982         }
       
   983     }
       
   984 
       
   985 // ---------------------------------------------------------------------------
       
   986 // From class MCCPCall
       
   987 // Removes observer.
       
   988 // ---------------------------------------------------------------------------
       
   989 //
       
   990 TInt CSPCall::RemoveObserver( const MCCPCallObserver& aObserver )
       
   991     {
       
   992     CSPLOGSTRING2(CSPREQIN, "CSPCall::RemoveObserver %x", &aObserver);
       
   993     
       
   994     TInt found = iObservers.Find( &aObserver );
       
   995     if ( found != KErrNotFound )
       
   996         {
       
   997         iObservers.Remove( found );
       
   998         return KErrNone;
       
   999         }
       
  1000         
       
  1001     return found;
       
  1002     }
       
  1003 
       
  1004 // ---------------------------------------------------------------------------
       
  1005 // From class MCCPCall
       
  1006 // CSPCall::IsCallForwarded
       
  1007 // ---------------------------------------------------------------------------
       
  1008 //
       
  1009 TBool CSPCall::IsCallForwarded( ) const
       
  1010     {
       
  1011     CSPLOGSTRING(CSPREQIN, "CSPCall::IsCallForwarded <");
       
  1012     TBool ret( EFalse );
       
  1013     TInt err( KErrNone );
       
  1014     RMobileCall::TMobileCallInfoV3 callInfo;
       
  1015     RMobileCall::TMobileCallInfoV3Pckg pck( callInfo );
       
  1016     err = iCall.GetMobileCallInfo( pck );
       
  1017     if (err == KErrNone )
       
  1018         {
       
  1019         ret = callInfo.iForwarded;
       
  1020         }
       
  1021     
       
  1022     CSPLOGSTRING2(CSPREQIN, 
       
  1023             "CSPCall::IsCallForwarded > forwarder: %d", ret );
       
  1024     
       
  1025     return ret;
       
  1026     }
       
  1027 
       
  1028 // ---------------------------------------------------------------------------
       
  1029 // From class MCCPCall
       
  1030 // CSPCall::IsSecured
       
  1031 // ---------------------------------------------------------------------------
       
  1032 //
       
  1033 TBool CSPCall::IsSecured( ) const
       
  1034     {    
       
  1035     CSPLOGSTRING(CSPREQIN, "CSPCall::IsSecured");
       
  1036     return iCommonInfo.NetworkSecurityStatus();
       
  1037     }
       
  1038 
       
  1039 // ---------------------------------------------------------------------------
       
  1040 // From class MCCPCall
       
  1041 // CSPCall::SecureSpecified
       
  1042 // ---------------------------------------------------------------------------
       
  1043 //
       
  1044 TBool CSPCall::SecureSpecified( ) const
       
  1045     {    
       
  1046     CSPLOGSTRING(CSPREQIN, "CSPCall::SecureSpecified");
       
  1047     return iCommonInfo.SecureSpecified();
       
  1048     }
       
  1049 
       
  1050 // ---------------------------------------------------------------------------
       
  1051 // From class MCCPCall
       
  1052 // CSPCall::Tone
       
  1053 // ---------------------------------------------------------------------------
       
  1054 //
       
  1055 TCCPTone CSPCall::Tone() const
       
  1056     {
       
  1057     CSPLOGSTRING(CSPREQIN, "CSPCall::Tone <");
       
  1058     TCCPTone tone( ECCPNoSoundSequence );
       
  1059 
       
  1060     if ( iCallState == MCCPCallObserver::ECCPStateConnecting )
       
  1061         {
       
  1062         RMmCustomAPI::TRemoteAlertingToneStatus ts = iCommonInfo.GetRemoteAlertingToneStatus();
       
  1063         
       
  1064         if (ts == RMmCustomAPI::EUiRbtTone )
       
  1065             {
       
  1066             tone = ECCPRemoteAlerting;
       
  1067             }
       
  1068         else if ( ts == RMmCustomAPI::EUiStopTone )
       
  1069             {
       
  1070             tone = ECCPNoSoundSequence;
       
  1071             }
       
  1072         else            
       
  1073             {
       
  1074             // No tone
       
  1075             tone = ECCPNoSoundSequence;
       
  1076             }
       
  1077         }
       
  1078     else
       
  1079         {
       
  1080         // Handle disconnecting tones      
       
  1081         TInt callDisconnectingError = ExitCodeError();
       
  1082         CSPLOGSTRING2(CSPINT, "CSPCall::Tone exit code err: %d", callDisconnectingError);
       
  1083 
       
  1084         switch( callDisconnectingError )
       
  1085             {
       
  1086             case KErrNone:
       
  1087                 // GSM: DIAL TONE (optional) - not used in Nokia phones 
       
  1088                 CSPLOGSTRING(CSPERROR, "CSPCall::Tone: No sound");
       
  1089                 break;
       
  1090             case KErrGsmCCUserBusy:
       
  1091                 // GSM: SUBSCRIBER BUSY
       
  1092                 tone = ECCPToneUserBusy;
       
  1093                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Subscriber Busy");
       
  1094                 break;
       
  1095                 // Fall through
       
  1096             case KErrGsmCCNumberChanged:
       
  1097             case KErrGsmCCResponseToStatusEnquiry:
       
  1098             case KErrGsmCCNormalUnspecified:
       
  1099                 // GSM: NONE, Nokia phones: radio path not available
       
  1100                 tone = ECCPToneRadioPathNotAvailable;
       
  1101                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: RadioPathNotAvailable");
       
  1102                 break;      
       
  1103             case KErrGsmCCNoChannelAvailable:
       
  1104             case KErrGsmCCTemporaryFailure:
       
  1105             case KErrGsmCCSwitchingEquipmentCongestion:
       
  1106             case KErrGsmCCRequestedChannelNotAvailable:
       
  1107             case KErrGsmCCQualityOfServiceNotAvailable:
       
  1108             case KErrGsmCCBearerCapabilityNotCurrentlyAvailable:
       
  1109                 // GSM: CONGESTION
       
  1110                 tone = ECCPToneCongestion;
       
  1111                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Congestion");
       
  1112                 break;
       
  1113             case KErrGsmCCUnassignedNumber:
       
  1114             case KErrGsmCCNoRouteToDestination:
       
  1115             case KErrGsmCCChannelUnacceptable:
       
  1116             case KErrGsmCCOperatorDeterminedBarring:
       
  1117             case KErrGsmCCUserNotResponding:
       
  1118             case KErrGsmCCUserAlertingNoAnswer:
       
  1119             case KErrGsmCCCallRejected:
       
  1120             case KErrGsmCCNonSelectedUserClearing:
       
  1121             case KErrGsmCCDestinationOutOfOrder:
       
  1122             case KErrGsmCCInvalidNumberFormat:
       
  1123             case KErrGsmCCFacilityRejected:
       
  1124             case KErrGsmCCNetworkOutOfOrder:
       
  1125             case KErrGsmCCAccessInformationDiscarded:
       
  1126             case KErrGsmCCResourceNotAvailable:
       
  1127             case KErrGsmCCRequestedFacilityNotSubscribed:
       
  1128             case KErrGsmCCIncomingCallsBarredInCug:
       
  1129             case KErrGsmCCBearerCapabilityNotAuthorised:
       
  1130             case KErrGsmCCServiceNotAvailable:
       
  1131             case KErrGsmCCBearerServiceNotImplemented:
       
  1132             case KErrGsmCCChannelTypeNotImplemented:
       
  1133             case KErrGsmCCAcmGreaterThanAcmMax:
       
  1134             case KErrGsmCCRequestedFacilityNotImplemented:
       
  1135             case KErrGsmCCOnlyRestrictedDigitalInformationBCAvailable:
       
  1136             case KErrGsmCCServiceNotImplemented:
       
  1137             case KErrGsmCCInvalidCallReferenceValue:
       
  1138             case KErrGsmCCChannelDoesNotExist:
       
  1139             case KErrGsmCCSuspendedCallExistsButCallIdentityDoesNotWork:
       
  1140             case KErrGsmCCCallIdentityInUse:
       
  1141             case KErrGsmCCNoCallSuspended:
       
  1142             case KErrGsmCCRequestedCallIdentityAlreadyCleared:
       
  1143             case KErrGsmCCUserNotInCug:
       
  1144             case KErrGsmCCIncompatibleDestination:
       
  1145             case KErrGsmCCInvalidTransitNetworkSelection:
       
  1146             case KErrGsmCCIncompatibleSegmentedMessage:
       
  1147             case KErrGsmCCSemanticallyIncorrectMessage:
       
  1148             case KErrGsmCCInvalidMandatoryInformation:
       
  1149             case KErrGsmCCNonExistentMessageType:
       
  1150             case KErrGsmCCIncompatibleMessageInProtocolState:
       
  1151             case KErrGsmCCNonExistentInformationElement:
       
  1152             case KErrGsmCCConditionalIEError:
       
  1153             case KErrGsmCCIncompatibleMessageInCallState:
       
  1154             case KErrGsmCCRecoveryOnTimerExpiry:
       
  1155             case KErrGsmCCUnspecifiedProtocolError:
       
  1156             case KErrGsmCCUnspecifiedInterworkingError:
       
  1157                 // GSM: SPECIAL INFORMATION
       
  1158                 tone = ECCPToneSpecialInformation;
       
  1159                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Special Information");
       
  1160                 break;
       
  1161             default:
       
  1162                 CSPLOGSTRING(CSPERROR, "CSPCall::Tone: ERROR not found");
       
  1163                 break;
       
  1164             }
       
  1165          }
       
  1166     
       
  1167     CSPLOGSTRING2(CSPREQIN, "CSPCall::Tone > tone: %d", tone);
       
  1168     return tone;
       
  1169     }
       
  1170     
       
  1171 // ---------------------------------------------------------------------------
       
  1172 // From class MCCPCSCall
       
  1173 // CSPCall::NoFdnCheck
       
  1174 // ---------------------------------------------------------------------------
       
  1175 //
       
  1176 void CSPCall::NoFDNCheck( )
       
  1177     {
       
  1178     CSPLOGSTRING(CSPREQIN, "CSPCall::NoFDNCheck");
       
  1179     iFdnCheck = EFalse;
       
  1180     }
       
  1181     
       
  1182 // ---------------------------------------------------------------------------
       
  1183 // CSPCall::LogDialedNumber
       
  1184 // ---------------------------------------------------------------------------
       
  1185 //
       
  1186 TBool CSPCall::LogDialedNumber() const
       
  1187     {
       
  1188     CSPLOGSTRING(CSPREQIN, "CSPCall::LogDialedNumber true");
       
  1189     return ETrue;
       
  1190     }
       
  1191     
       
  1192 // ---------------------------------------------------------------------------
       
  1193 // From class MCCPCSCall
       
  1194 // CSPCall::Dial
       
  1195 // ---------------------------------------------------------------------------
       
  1196 //
       
  1197 TInt CSPCall::Dial( const TDesC8& /*aCallParams*/ )
       
  1198     {
       
  1199     CSPLOGSTRING(CSPREQIN, "CSPCall::Dial");
       
  1200     return iCommonInfo.IndicateDialRequest( *this );
       
  1201     }
       
  1202 
       
  1203 // ---------------------------------------------------------------------------
       
  1204 // From class MCCPCallCommandHandling
       
  1205 // CSPCall::PerformDialRequest
       
  1206 // ---------------------------------------------------------------------------
       
  1207 //
       
  1208 TInt CSPCall::PerformDialRequest()
       
  1209     {
       
  1210     CSPLOGSTRING(CSPREQIN, "CSPCall::PerformDialRequest");
       
  1211     iDialCompletionCode = KErrNone;
       
  1212     iTerminationErrorNotified = EFalse;
       
  1213     
       
  1214     // Send the User to User Information.
       
  1215     if( iUserToUserInformation->Length() )
       
  1216         {
       
  1217         iUUIMessageSender->SendUUIMessage( *iUserToUserInformation );
       
  1218         }
       
  1219     
       
  1220     return DialFdnCond( iFdnCheck );
       
  1221     }
       
  1222     
       
  1223 // ---------------------------------------------------------------------------
       
  1224 // CSPCall::CSPCall
       
  1225 // ---------------------------------------------------------------------------
       
  1226 //
       
  1227 CSPCall::CSPCall( RMobileLine& aLine, 
       
  1228                   TBool aMobileOriginated,
       
  1229                   const TDesC& aName,
       
  1230                   MCSPCommonInfo& aCommonInfo,
       
  1231                   TBool aIsEmergencyCall ) : 
       
  1232                     iLine( aLine ),
       
  1233                     iMobileOriginated( aMobileOriginated ),
       
  1234                     iName( aName ), 
       
  1235                     iCommonInfo( aCommonInfo ),
       
  1236                     iTerminationErrorNotified( EFalse ),
       
  1237                     iIsEmergencyCall( aIsEmergencyCall),
       
  1238                     iFdnCheck(ETrue),
       
  1239                     iAudioStatus( ECSPCallAudioStatusInactive ) 
       
  1240                     
       
  1241     {
       
  1242     CSPLOGSTRING(CSPOBJECT, "CSPCall::CSPCall");
       
  1243     }
       
  1244 
       
  1245 // ---------------------------------------------------------------------------
       
  1246 // CSPCall::ConstructL
       
  1247 // Constructing CSPCall in 2nd phase
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //    
       
  1250 void CSPCall::ConstructL( const CCCECallParameters& aParams )
       
  1251     {
       
  1252     CSPLOGSTRING(CSPOBJECT, "CSPCall::ConstructL <");
       
  1253 
       
  1254     // Create cloned copy of call parameters 
       
  1255     iParams = static_cast<CCCECallParameters*>( aParams.CloneL() );
       
  1256     
       
  1257     // Open call handle  
       
  1258     OpenCallHandleL(); 
       
  1259 
       
  1260     // Update call info 
       
  1261     UpdateCallInfo(); 
       
  1262     
       
  1263     // Update call state from ETel 
       
  1264     UpdateCallState(); 
       
  1265     
       
  1266     // Create call handlers for call related requests 
       
  1267     // and for monitoring call related events 
       
  1268     CreateCallHandlersL(); 
       
  1269         
       
  1270     CSPLOGSTRING(CSPOBJECT, "CSPCall::ConstructL >");
       
  1271     }
       
  1272 
       
  1273 // ---------------------------------------------------------------------------
       
  1274 // CSPCall::OpenCallHandleL
       
  1275 // Open call handle, calls either OpenNewCallL or OpenExistingCallL depending 
       
  1276 // of the call direction and if the call is a client call       
       
  1277 // ---------------------------------------------------------------------------
       
  1278 //    
       
  1279 void CSPCall::OpenCallHandleL()
       
  1280     {
       
  1281     CSPLOGSTRING(CSPINT, "CSPCall::OpenCallHandleL <");
       
  1282     
       
  1283     if ( iMobileOriginated )
       
  1284         {
       
  1285         // There is no existing call on line, open new call 
       
  1286         OpenNewCall();
       
  1287         }
       
  1288     else
       
  1289         {
       
  1290         // Mobile terminated call on line, open existing call 
       
  1291         OpenExistingCallL( iName ); 
       
  1292         }
       
  1293 
       
  1294     CSPLOGSTRING(CSPINT, "CSPCall::OpenCallHandleL >");
       
  1295     }
       
  1296 
       
  1297 // ---------------------------------------------------------------------------
       
  1298 // CSPCall::UpdateCallInfoL
       
  1299 // Update call info including remote party name and number data  
       
  1300 // ---------------------------------------------------------------------------
       
  1301 //    
       
  1302 void CSPCall::UpdateCallInfo()
       
  1303     {
       
  1304     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfo <");
       
  1305     RMobileCall::TMobileCallInfoV7 callInfo;
       
  1306     RMobileCall::TMobileCallInfoV7Pckg pck( callInfo );
       
  1307     TInt err = iCall.GetMobileCallInfo( pck );
       
  1308     
       
  1309     UpdateCallInfoImpl( callInfo );
       
  1310 
       
  1311     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfo >");
       
  1312     }
       
  1313 
       
  1314 // ---------------------------------------------------------------------------
       
  1315 // CSPCall::UpdateCallInfoImpl
       
  1316 // Implementation for UpdateCallInfo().
       
  1317 // ---------------------------------------------------------------------------
       
  1318 //    
       
  1319 void CSPCall::UpdateCallInfoImpl( RMobileCall::TMobileCallInfoV7 aCallInfo )
       
  1320     {
       
  1321     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfoImpl <");
       
  1322 
       
  1323     if ( iMobileOriginated )
       
  1324         {
       
  1325         // Call wasn't added by ETel monitor, update info accordingly
       
  1326         UpdateCallNameNumberInfo( aCallInfo, EFalse ); 
       
  1327         }
       
  1328     else
       
  1329         {
       
  1330         // Call was added by ETel monitor, update info accordingly
       
  1331         UpdateCallNameNumberInfo( aCallInfo, ETrue );
       
  1332         }
       
  1333     
       
  1334 
       
  1335     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfoImpl >");
       
  1336     }
       
  1337 
       
  1338 // ---------------------------------------------------------------------------
       
  1339 // CSPCall::UpdateCallOrigin
       
  1340 // Set call origin to CCCECallParameters.
       
  1341 // ---------------------------------------------------------------------------
       
  1342 //    
       
  1343 void CSPCall::UpdateCallOrigin( RMobileCall::TMobileCallInfoV7 aCallInfo )
       
  1344     {
       
  1345     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallOrigin <");
       
  1346    
       
  1347     if ( iMobileOriginated )
       
  1348         {
       
  1349         if ( RMobileCall::EOriginatorSIM == aCallInfo.iCallParamOrigin )
       
  1350             {
       
  1351             iParams->SetOrigin(CCCECallParameters::ECCECallOriginSAT);
       
  1352             }
       
  1353         }
       
  1354     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallOrigin >");
       
  1355     }
       
  1356 
       
  1357 
       
  1358 
       
  1359 // ---------------------------------------------------------------------------
       
  1360 // CSPCall::UpdateCallStateL
       
  1361 //   
       
  1362 // ---------------------------------------------------------------------------
       
  1363 //    
       
  1364 int CSPCall::UpdateCallState()
       
  1365     {
       
  1366     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallState <");
       
  1367     TInt err( KErrNone ); 
       
  1368     
       
  1369     // Update call state from ETel
       
  1370     RMobileCall::TMobileCallStatus etelState;
       
  1371     err = iCall.GetMobileCallStatus( etelState );
       
  1372     if ( KErrNone == err )
       
  1373         {
       
  1374         iCallState = CCPStateFromETelState( etelState );
       
  1375         }
       
  1376     CSPLOGSTRING2(CSPINT, "CSPCall::UpdateCallState > res %d", err);
       
  1377     
       
  1378     return err; 
       
  1379     }
       
  1380 
       
  1381 // ---------------------------------------------------------------------------
       
  1382 // CSPCall::NotifyRemotePartyNumberChanged
       
  1383 //   
       
  1384 // ---------------------------------------------------------------------------
       
  1385 //
       
  1386 void CSPCall::NotifyRemotePartyNumberChanged()
       
  1387     {
       
  1388     CSPLOGSTRING(CSPINT, "CSPCall::NotifyRemotePartyNumberChanged <");
       
  1389     
       
  1390     // If COLP number is different from original dialled number
       
  1391     // it is available in connected state of a MO call.
       
  1392     // TSY does not send notification so number must be fetched.
       
  1393     if ( IsMobileOriginated() )
       
  1394         {
       
  1395         RMobileCall::TMobileCallInfoV3 callInfo;
       
  1396         RMobileCall::TMobileCallInfoV3Pckg callInfoPckg( callInfo );
       
  1397     
       
  1398         GetMobileCallInfo( callInfoPckg );    
       
  1399         callInfo = callInfoPckg();
       
  1400     
       
  1401         
       
  1402         if ( callInfo.iRemoteParty.iRemoteNumber.iTelNumber.Length() )
       
  1403             {        
       
  1404             NotifyRemotePartyInfoChanged( KNullDesC(),
       
  1405                 callInfo.iRemoteParty.iRemoteNumber.iTelNumber);        
       
  1406             }
       
  1407         }
       
  1408     }
       
  1409 
       
  1410 
       
  1411 // ---------------------------------------------------------------------------
       
  1412 // CSPCall::CreateCallHandlersL
       
  1413 // Create call handlers for call related requests and call monitoring  
       
  1414 // ---------------------------------------------------------------------------
       
  1415 //    
       
  1416 void CSPCall::CreateCallHandlersL()
       
  1417     {
       
  1418     CSPLOGSTRING(CSPINT, "CSPCall::CreateCallHandlersL <");
       
  1419 
       
  1420     iRequester = CSPEtelCallRequester::NewL( *this, iCall );
       
  1421 
       
  1422     iCallEventMonitor = CSPEtelCallEventMonitor::NewL( *this, iCall );
       
  1423     iCallEventMonitor->StartMonitoring();
       
  1424     iCallStatusMonitor = CSPEtelCallStatusMonitor::NewL( *this, iCall );
       
  1425     iCallStatusMonitor->StartMonitoring();
       
  1426     
       
  1427     iCallCapsMonitor = CSPEtelCallCapsMonitor::NewL( *this, iCall );
       
  1428     iCallCapsMonitor->StartMonitoring();
       
  1429     iCapsFlags = iCallCapsMonitor->FetchCallControlCapsL();
       
  1430     
       
  1431     iCallInfoMonitor = CSPCallInfoMonitor::NewL( *this, iCall );
       
  1432     iCallInfoMonitor->StartMonitoring();
       
  1433     
       
  1434     // Start UUI monitor and create message sender 
       
  1435     iSkypeId = TCSPSkypeIdParser::CreateSkypeIdBufferL();
       
  1436     iUUIMonitor = CSPUUIMonitor::NewL( iCall,*this );
       
  1437     iUUIMonitor->StartMonitor();
       
  1438     iUUIMessageSender = CSPUUIMessageSender::NewL( iCall );
       
  1439     iUserToUserInformation = iParams->UUSId().AllocL();
       
  1440     
       
  1441     // Transfer provider
       
  1442     iTransferProvider = CSPTransferProvider::NewL( iCall, *this, iCommonInfo );
       
  1443 
       
  1444     // Forward provider
       
  1445     iForwardProvider = CSPForwardProvider::NewL();
       
  1446     
       
  1447     CSPLOGSTRING(CSPINT, "CSPCall::CreateCallHandlersL >");
       
  1448     }
       
  1449 
       
  1450 // ---------------------------------------------------------------------------
       
  1451 // CSPCall::NotifyRingingState
       
  1452 // Gets to ringing state
       
  1453 // ---------------------------------------------------------------------------
       
  1454 //     
       
  1455 void CSPCall::NotifyRingingState( )
       
  1456     {
       
  1457     CSPLOGSTRING(CSPREQIN, "CSPCall::NotifyRingingState");
       
  1458     iCallState = MCCPCallObserver::ECCPStateRinging;
       
  1459 
       
  1460     TInt obsCount = iObservers.Count ( );
       
  1461     for (TInt i = 0; i < obsCount; i++ )
       
  1462         {
       
  1463         MCCPCallObserver *obs = iObservers[i];
       
  1464         if ( obs )
       
  1465             {
       
  1466             obs->CallStateChanged ( iCallState, this );
       
  1467             }
       
  1468         }
       
  1469     }
       
  1470 
       
  1471 // ---------------------------------------------------------------------------
       
  1472 // CSPCall::CCPStateFromETelState
       
  1473 // Simple mapping between state enumerations.
       
  1474 // ---------------------------------------------------------------------------
       
  1475 //     
       
  1476 MCCPCallObserver::TCCPCallState CSPCall::CCPStateFromETelState( 
       
  1477     RMobileCall::TMobileCallStatus aEtelState ) 
       
  1478     {
       
  1479     MCCPCallObserver::TCCPCallState ret = MCCPCallObserver::ECCPStateIdle;
       
  1480     switch ( aEtelState )
       
  1481         {
       
  1482         case RMobileCall::EStatusUnknown:
       
  1483             {
       
  1484             CSPLOGSTRING( CSPREQIN, 
       
  1485                 "CSPCall::State > RMobileCall::Unknown" );
       
  1486             ret = MCCPCallObserver::ECCPStateIdle;
       
  1487             break;
       
  1488             }
       
  1489         case RMobileCall::EStatusIdle:
       
  1490             {
       
  1491             CSPLOGSTRING( CSPREQIN, 
       
  1492                 "CSPCall::State > RMobileCall::EStatusIdle" );
       
  1493             ret = MCCPCallObserver::ECCPStateIdle;
       
  1494             break;
       
  1495             }
       
  1496         case RMobileCall::EStatusRinging:
       
  1497             {
       
  1498             CSPLOGSTRING( CSPREQIN, 
       
  1499                 "CSPCall::State > RMobileCall::EStatusRinging" );
       
  1500             ret = MCCPCallObserver::ECCPStateRinging;
       
  1501             break;
       
  1502             }
       
  1503         // Map the following to connecting status
       
  1504         case RMobileCall::EStatusDialling:                
       
  1505             {
       
  1506             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1507                 RMobileCall::EStatusDialling" );
       
  1508             ret = MCCPCallObserver::ECCPStateDialling;
       
  1509             break;
       
  1510             }
       
  1511         case RMobileCall::EStatusConnecting:
       
  1512             {
       
  1513             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1514                 RMobileCall::Connecting" );
       
  1515             ret = MCCPCallObserver::ECCPStateConnecting;
       
  1516             break;
       
  1517             }
       
  1518         case RMobileCall::EStatusAnswering:
       
  1519             {
       
  1520             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1521                 RMobileCall::Answering" );
       
  1522             ret = MCCPCallObserver::ECCPStateAnswering;
       
  1523             break;                
       
  1524             }
       
  1525         // Call is connected and active.
       
  1526         case RMobileCall::EStatusConnected:
       
  1527             {
       
  1528             CSPLOGSTRING( CSPREQIN, 
       
  1529             "CSPCall::State > RMobileCall::EStatusConnected" );
       
  1530             ret = MCCPCallObserver::ECCPStateConnected;
       
  1531             break;
       
  1532             }
       
  1533         case RMobileCall::EStatusDisconnectingWithInband:
       
  1534         case RMobileCall::EStatusDisconnecting:
       
  1535             {
       
  1536             CSPLOGSTRING( CSPREQIN, 
       
  1537                  "CSPCall::State > RMobileCall::EStatusDisconnecting/Inband?");
       
  1538             ret = MCCPCallObserver::ECCPStateDisconnecting;
       
  1539             break;
       
  1540             }
       
  1541         case RMobileCall::EStatusReconnectPending:
       
  1542             {
       
  1543             CSPLOGSTRING( CSPREQIN, 
       
  1544             "CSPCall::State > RMobileCall::EStatusHangingUp" );
       
  1545             ret = MCCPCallObserver::ECCPStateDisconnecting;
       
  1546             break;
       
  1547             }
       
  1548         case RMobileCall::EStatusHold:
       
  1549             {
       
  1550             CSPLOGSTRING( CSPREQIN, 
       
  1551             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1552             ret = MCCPCallObserver::ECCPStateHold;
       
  1553             break;
       
  1554             }
       
  1555         case RMobileCall::EStatusWaitingAlternatingCallSwitch: 
       
  1556             {
       
  1557             // This state is not used in real life.
       
  1558             CSPLOGSTRING( CSPREQIN, 
       
  1559             "CSPCall::State > RMobileCall::EStatusWaitingAlternatingCallSwitch" );
       
  1560             ret = MCCPCallObserver::ECCPStateConnected;
       
  1561             break;
       
  1562             }
       
  1563         case RMobileCall::EStatusTransferring: 
       
  1564             {
       
  1565             CSPLOGSTRING( CSPREQIN, 
       
  1566             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1567             ret = MCCPCallObserver::ECCPStateTransferring;
       
  1568             break;
       
  1569             }
       
  1570         case RMobileCall::EStatusTransferAlerting: 
       
  1571             {
       
  1572             CSPLOGSTRING( CSPREQIN, 
       
  1573             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1574             ret = MCCPCallObserver::ECCPStateTransferring;
       
  1575             break;
       
  1576             }            
       
  1577         default:
       
  1578             {
       
  1579             CSPLOGSTRING( CSPREQIN, 
       
  1580                 "CSPCall::CCPStateFromETelState unhandled state ");
       
  1581             }
       
  1582         }
       
  1583 
       
  1584     CSPLOGSTRING3(CSPINT, 
       
  1585         "CSPCall::CCPStateFromETelState ETel: %d CCP: %d", aEtelState, ret);
       
  1586     return ret;
       
  1587     }
       
  1588 
       
  1589 // ---------------------------------------------------------------------------
       
  1590 // CSPCall::NotifyCallStateChanged
       
  1591 // Notifies observers about state changes
       
  1592 // ---------------------------------------------------------------------------
       
  1593 //
       
  1594 void CSPCall::NotifyCallStateChanged( MCCPCallObserver::TCCPCallState aState ) 
       
  1595     {
       
  1596     CSPLOGSTRING3(CSPINT, 
       
  1597             "CSPCall::NotifyCallStateChanged < state: %d this: %x", 
       
  1598             aState, this );
       
  1599                            
       
  1600     iCallState = aState;    
       
  1601     TBool notifyObservers( ETrue ); 
       
  1602 
       
  1603     if ( !iMobileOriginated && MCCPCallObserver::ECCPStateRinging == aState )
       
  1604         {
       
  1605         CSPLOGSTRING2(CSPINT, "CSPCall::No notify on ringing MT", aState);        
       
  1606         notifyObservers = EFalse; 
       
  1607         }
       
  1608     
       
  1609     if ( notifyObservers )
       
  1610         {
       
  1611         TInt obsCount = iObservers.Count();
       
  1612         for ( TInt i = 0; i < obsCount; i++ )
       
  1613             {
       
  1614             MCCPCallObserver *obs = iObservers[i];
       
  1615             if ( obs )
       
  1616                 {            
       
  1617                 obs->CallStateChanged( aState, this );
       
  1618                 }
       
  1619             }
       
  1620         }
       
  1621         
       
  1622     CSPLOGSTRING3(CSPINT, 
       
  1623             "CSPCall::NotifyCallStateChanged > state: %d this: %x", 
       
  1624             aState, this );
       
  1625     }
       
  1626 
       
  1627 // ---------------------------------------------------------------------------
       
  1628 // CSPCall::NotifyCallStateChangedWithInband
       
  1629 // Notifies observers about state changes
       
  1630 // ---------------------------------------------------------------------------
       
  1631 //
       
  1632 void CSPCall::NotifyCallStateChangedWithInband( 
       
  1633         MCCPCallObserver::TCCPCallState aState ) 
       
  1634     {
       
  1635     CSPLOGSTRING3(CSPINT, 
       
  1636         "CSPCall::NotifyCallStateChangedWithInBand < state: %d this: %x", 
       
  1637         aState, this );
       
  1638     
       
  1639     iCallState = aState;
       
  1640    
       
  1641     if ( !iMobileOriginated && MCCPCallObserver::ECCPStateRinging == aState )
       
  1642         {
       
  1643         CSPLOGSTRING2(CSPINT, "CSPCall::No notify on ringing MT", aState);
       
  1644         }
       
  1645     else
       
  1646         {        
       
  1647         TInt obsCount = iObservers.Count();
       
  1648         for ( TInt i = 0; i < obsCount; i++ )
       
  1649             {            
       
  1650             MCCPCallObserver *obs = iObservers[i];
       
  1651             if ( obs )
       
  1652                 {
       
  1653                 obs->CallStateChangedWithInband( aState, this );
       
  1654                 }
       
  1655             }
       
  1656         }
       
  1657     CSPLOGSTRING3(CSPINT, 
       
  1658             "CSPCall::NotifyCallStateChangedWithInband > state: %d this: %x", 
       
  1659             aState, this);
       
  1660     }
       
  1661 
       
  1662 // ---------------------------------------------------------------------------
       
  1663 // CSPCall::ReadRepositoryL
       
  1664 // Reads the given information from Central Repository.
       
  1665 // ---------------------------------------------------------------------------
       
  1666 //
       
  1667 void CSPCall::ReadRepositoryL( TUid aUid, TUint aKey, TInt& aVal)
       
  1668     {
       
  1669     CSPLOGSTRING(CSPINT, "CSPCall::ReadRepositoryL");
       
  1670     
       
  1671     CRepository* cr = CRepository::NewL( aUid );
       
  1672     TInt err = cr->Get( aKey, aVal );
       
  1673     delete cr;
       
  1674     User::LeaveIfError( err );
       
  1675     }
       
  1676 
       
  1677 // ---------------------------------------------------------------------------
       
  1678 // CSPCall::CheckAndNotifyTerminationError
       
  1679 // Reads error code from ETel.
       
  1680 // ---------------------------------------------------------------------------
       
  1681 //
       
  1682 void CSPCall::CheckAndNotifyTerminationError()
       
  1683     {
       
  1684     CSPLOGSTRING2(CSPINT, 
       
  1685         "CSPCall::CheckAndNotifyTerminationError dial completion code: %d", 
       
  1686         iDialCompletionCode);
       
  1687     
       
  1688     // Emergency error handling is separated into CSPEtelCallRequester
       
  1689     if ( !iIsEmergencyCall )
       
  1690         {
       
  1691         TInt termErr = ExitCodeError();
       
  1692         CSPLOGSTRING2(CSPINT, 
       
  1693                 "CSPCall::CheckAndNotifyTerminationError exit code error: %d", 
       
  1694                 termErr);
       
  1695         
       
  1696         if ( termErr == KErrNone )
       
  1697             {
       
  1698             // Handle KErrGsmCCUnassignedNumber correctly
       
  1699             // because the value is not stored in exit code.
       
  1700             termErr = iDialCompletionCode;
       
  1701             CSPLOGSTRING(CSPINT, 
       
  1702                     "CSPCall::CheckAndNotifyTerminationError use dial completion code");
       
  1703             }
       
  1704             
       
  1705         if ( termErr == KErrGsmRRPreEmptiveRelease )
       
  1706             {
       
  1707             // Error KErrGsmRRPreEmptiveRelease occurs when there is active call 
       
  1708             // and user make emergency call, can be ignored.
       
  1709             CSPLOGSTRING3( 
       
  1710                 CSPERROR, 
       
  1711                 "CSPCall::CheckAndNotifyTerminationError preemptive release, ignore: %d",
       
  1712                 termErr,
       
  1713                 this );
       
  1714             }
       
  1715         else if ( iDontReportTerm 
       
  1716                 && (  termErr == KErrGsmCCNormalUnspecified 
       
  1717                    || termErr == KErrGsmCCCallRejected ) )
       
  1718             {
       
  1719             // Not an error, since this happens on normal 
       
  1720             // call termination situation after connected call.
       
  1721             CSPLOGSTRING3(CSPERROR, 
       
  1722                     "CSPCall::CheckAndNotifyTerminationError DISCARD this: %x err: %d", 
       
  1723                     this, 
       
  1724                     termErr);    
       
  1725             }        
       
  1726         else if ( termErr )
       
  1727             {
       
  1728             TCCPError ccpErr(ECCPErrorNone);
       
  1729 
       
  1730             // Only a couple of error codes can have diagnostic information. 
       
  1731             // aDiagnostic ought to be undefined in other situatios,
       
  1732             // but at least in this way we can really guarantee it.
       
  1733             if ( termErr == KErrGsmCCFacilityRejected ||
       
  1734                  termErr == KErrGsmCCRequestedFacilityNotSubscribed ||
       
  1735                  termErr == KErrGsmCCIncomingCallsBarredInCug ||
       
  1736                  termErr == KErrGsmCCRequestedFacilityNotImplemented ||
       
  1737                  termErr == KErrGsmCCUserNotInCug )
       
  1738                 {
       
  1739                 TName name;
       
  1740                 CallName( name );        
       
  1741                 TInt diagErr = iCommonInfo.GetDiagnosticError( name );
       
  1742                 ccpErr = iRequester->MapError( diagErr );
       
  1743     
       
  1744                 // Finally use exit code if diagnostic did not contain
       
  1745                 // any useful information.
       
  1746                 if ( ccpErr == ECCPRequestFailure )
       
  1747                     {
       
  1748                     ccpErr = iRequester->MapError( termErr );
       
  1749                     }
       
  1750                 }
       
  1751             else
       
  1752                 {
       
  1753                 ccpErr = iRequester->MapError( termErr );
       
  1754                 }
       
  1755             
       
  1756             NotifyErrorOccurred( ccpErr );
       
  1757             iTerminationErrorNotified = ETrue;
       
  1758             }
       
  1759         }    
       
  1760     }
       
  1761 
       
  1762 // ---------------------------------------------------------------------------
       
  1763 // CSPCall::ExitCodeError
       
  1764 // Reads error code from ETel call info's iExitCode.
       
  1765 // ---------------------------------------------------------------------------
       
  1766 //
       
  1767 TInt CSPCall::ExitCodeError() const
       
  1768     {
       
  1769     CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError < this: %x", 
       
  1770                     this );
       
  1771     TInt callError;
       
  1772     RMobileCall::TMobileCallInfoV3 callInfo;
       
  1773     RMobileCall::TMobileCallInfoV3Pckg pck( callInfo );
       
  1774     TInt getErr = iCall.GetMobileCallInfo( pck );
       
  1775     // Is there value in higher 16 bits
       
  1776     if ( KErrNone == getErr && (callInfo.iExitCode & 0xFFFF0000) ) 
       
  1777         {
       
  1778         CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError callInfo.iExitCode %d", 
       
  1779             callInfo.iExitCode );
       
  1780         callError = ( callInfo.iExitCode >> KTimesToSplitValue ); 
       
  1781         
       
  1782         if ( callError > KErrEtelGsmBase ) 
       
  1783             // Not in valid exteded range
       
  1784             {
       
  1785             // Ignore invalid extented code
       
  1786             if ( ( callInfo.iExitCode & 0x0000FFFF ) == KErrNone ) 
       
  1787                 // core error is zero
       
  1788                 {
       
  1789                 callError = KErrNone;
       
  1790                 }
       
  1791             else
       
  1792                 {
       
  1793                 callError = ( ( callInfo.iExitCode & 0x0000FFFF ) 
       
  1794                     | 0xFFFF0000 ); 
       
  1795                 }
       
  1796             }
       
  1797         }
       
  1798     // Higher and lower 16 bits are zero
       
  1799     else if ( !( callInfo.iExitCode & 0xFFFFFFFF ) ) 
       
  1800         {
       
  1801         callError = KErrNone;
       
  1802         }
       
  1803     else 
       
  1804         {
       
  1805         // No extended error, expand value to full range
       
  1806         callError = ( callInfo.iExitCode | 0xFFFF0000 );
       
  1807         }
       
  1808         
       
  1809     CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError > err: %d", callError);
       
  1810         
       
  1811     return callError;
       
  1812     }
       
  1813 
       
  1814 // ---------------------------------------------------------------------------
       
  1815 // CSPCall::UUSMessageReceived
       
  1816 // ---------------------------------------------------------------------------
       
  1817 //
       
  1818  void CSPCall::UUSMessageReceived( TDesC& aMessage )
       
  1819     {      
       
  1820     CSPLOGSTRING(CSPREQIN, "CSPCall::UUSMessageReceived");
       
  1821     TCSPSkypeIdParser parser;
       
  1822            
       
  1823     TPtr ptr = iSkypeId->Des();
       
  1824     ptr.Zero();
       
  1825     const TInt error( parser.Parse( aMessage, ptr ) );
       
  1826     
       
  1827     if ( !error ) 
       
  1828         {
       
  1829         iRemotePartyName = ptr;
       
  1830         NotifyCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange );            
       
  1831         }
       
  1832     CSPLOGSTRING2(CSPINT, "CSPCall::UUSMessageReceived  err: %d",  error );        
       
  1833     }
       
  1834 
       
  1835 // ---------------------------------------------------------------------------
       
  1836 // CSPCall::NotifyRemotePartyInfoChanged
       
  1837 // ---------------------------------------------------------------------------
       
  1838 //
       
  1839 void CSPCall::NotifyRemotePartyInfoChanged( const TDesC& aRemotePartyName,
       
  1840                                             const TDesC& aRemotePartyNumber )
       
  1841     {
       
  1842     CSPLOGSTRING(CSPREQIN, "CSPCall::NotifyRemotePartyInfoChanged");
       
  1843     
       
  1844     if ( aRemotePartyName.Length() )    
       
  1845         {
       
  1846         iRemotePartyName = aRemotePartyName;
       
  1847         }
       
  1848     
       
  1849     if ( aRemotePartyNumber.Length() )    
       
  1850         {
       
  1851         iRemotePartyNumber = aRemotePartyNumber;
       
  1852         }
       
  1853     
       
  1854     NotifyCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange );
       
  1855     }
       
  1856 
       
  1857 // ---------------------------------------------------------------------------
       
  1858 // CSPCall::DontReportTerminationError
       
  1859 // ---------------------------------------------------------------------------
       
  1860 //
       
  1861 void CSPCall::DontReportTerminationError() 
       
  1862     {
       
  1863     CSPLOGSTRING(CSPREQIN, "CSPCall::DontReportTerminationError");
       
  1864     iDontReportTerm = ETrue;
       
  1865     }
       
  1866 
       
  1867 // ---------------------------------------------------------------------------
       
  1868 // CSPCall::UpdateCallNameNumberInfo
       
  1869 // Update call info including remote party name and number data  
       
  1870 // ---------------------------------------------------------------------------
       
  1871 //    
       
  1872 void CSPCall::UpdateCallNameNumberInfo(
       
  1873         RMobileCall::TMobileCallInfoV3& aCallInfo, 
       
  1874         TBool aCallAddedByMonitor )
       
  1875     {
       
  1876     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallNameNumberInfo <");
       
  1877 
       
  1878     iCallName.Zero();
       
  1879     iRemotePartyNumber.Zero();
       
  1880     iRemotePartyName.Zero();
       
  1881     
       
  1882     if ( aCallAddedByMonitor )        
       
  1883         {
       
  1884         CSPLOGSTRING(CSPINT, 
       
  1885                 "CSPCall::UpdateCallNameNumberInfo call added by monitor");
       
  1886 
       
  1887         // If call was created by ETel line status or incoming call monitor
       
  1888         // the call name is already known, only remote party info is fetched from 
       
  1889         // call info 
       
  1890         iCallName.Append( iName );
       
  1891         iRemotePartyName.Append( aCallInfo.iRemoteParty.iCallingName );
       
  1892         iRemotePartyNumber.Append( aCallInfo.iRemoteParty.iRemoteNumber.iTelNumber );
       
  1893         }
       
  1894     else 
       
  1895         {
       
  1896         CSPLOGSTRING(CSPINT, 
       
  1897                 "CSPCall::UpdateCallNameNumberInfo call added by plugin owner");
       
  1898         
       
  1899         // The call was not created by monitor and the remote number is already known, 
       
  1900         // fetch only call name from call info  
       
  1901         iCallName.Append( aCallInfo.iCallName );
       
  1902         iRemotePartyNumber.Append( iName ); 
       
  1903         }
       
  1904     
       
  1905     CSPLOGSTRING2(CSPINT, 
       
  1906             "CSPCall::UpdateCallNameNumberInfo iCallName: %S", &iCallName );
       
  1907     CSPLOGSTRING2(CSPINT, 
       
  1908             "CSPCall::UpdateCallNameNumberInfo iRemotePartyNumber: %S", &iRemotePartyNumber );
       
  1909     CSPLOGSTRING2(CSPINT, 
       
  1910             "CSPCall::UpdateCallNameNumberInfo iRemotePartyName: %S", &iRemotePartyName );
       
  1911 
       
  1912     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallNameNumberInfo >");
       
  1913     }
       
  1914 
       
  1915 // ---------------------------------------------------------------------------
       
  1916 // CSPCall::OpenNewCall
       
  1917 // Open new call 
       
  1918 // ---------------------------------------------------------------------------
       
  1919 //    
       
  1920 void CSPCall::OpenNewCall()
       
  1921     {
       
  1922     CSPLOGSTRING(CSPINT, "CSPCall::OpenNewCall <");
       
  1923 
       
  1924     // Open new call 
       
  1925     __ASSERT_ALWAYS( iCall.OpenNewCall( iLine ) == KErrNone, 
       
  1926             Panic( ECSPPanicNoEtel ) );
       
  1927 
       
  1928     CSPLOGSTRING(CSPINT, "CSPCall::OpenNewCall >");
       
  1929     }
       
  1930 
       
  1931 // ---------------------------------------------------------------------------
       
  1932 // CSPCall::OpenExistingCallL
       
  1933 // Open existing call  
       
  1934 // ---------------------------------------------------------------------------
       
  1935 //    
       
  1936 void CSPCall::OpenExistingCallL( const TDesC& aName )
       
  1937     {
       
  1938     CSPLOGSTRING2(CSPINT, 
       
  1939             "CSPCall::OpenExistingCallL < aName: %S", &aName);
       
  1940     
       
  1941     // Open existing call with given name from current line 
       
  1942     TInt err = iCall.OpenExistingCall( iLine, aName ); 
       
  1943     
       
  1944     if ( KErrNone != err  )
       
  1945         {
       
  1946         CSPLOGSTRING2(CSPERROR,
       
  1947             "CSPCall::OpenCallHandleL OpenExistingCall error: %d, leaving", err);    
       
  1948         User::Leave( err );
       
  1949         }
       
  1950 
       
  1951     CSPLOGSTRING(CSPINT, "CSPCall::OpenExistingCallL >");
       
  1952     }
       
  1953 
       
  1954 // End of File
       
  1955