phoneplugins/csplugin/src/cspcall.cpp
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     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::TMobileCallInfoV7Pckg pck( iEtelCallInfo );
       
  1015     err = GetMobileCallInfo( pck );
       
  1016     if (err == KErrNone )
       
  1017         {
       
  1018         ret = iEtelCallInfo.iForwarded;
       
  1019         }
       
  1020     
       
  1021     CSPLOGSTRING2(CSPREQIN, 
       
  1022             "CSPCall::IsCallForwarded > forwarder: %d", ret );
       
  1023     
       
  1024     return ret;
       
  1025     }
       
  1026 
       
  1027 // ---------------------------------------------------------------------------
       
  1028 // From class MCCPCall
       
  1029 // CSPCall::IsSecured
       
  1030 // ---------------------------------------------------------------------------
       
  1031 //
       
  1032 TBool CSPCall::IsSecured( ) const
       
  1033     {    
       
  1034     CSPLOGSTRING(CSPREQIN, "CSPCall::IsSecured");
       
  1035     return iCommonInfo.NetworkSecurityStatus();
       
  1036     }
       
  1037 
       
  1038 // ---------------------------------------------------------------------------
       
  1039 // From class MCCPCall
       
  1040 // CSPCall::SecureSpecified
       
  1041 // ---------------------------------------------------------------------------
       
  1042 //
       
  1043 TBool CSPCall::SecureSpecified( ) const
       
  1044     {    
       
  1045     CSPLOGSTRING(CSPREQIN, "CSPCall::SecureSpecified");
       
  1046     return iCommonInfo.SecureSpecified();
       
  1047     }
       
  1048 
       
  1049 // ---------------------------------------------------------------------------
       
  1050 // From class MCCPCall
       
  1051 // CSPCall::Tone
       
  1052 // ---------------------------------------------------------------------------
       
  1053 //
       
  1054 TCCPTone CSPCall::Tone() const
       
  1055     {
       
  1056     CSPLOGSTRING(CSPREQIN, "CSPCall::Tone <");
       
  1057     TCCPTone tone( ECCPNoSoundSequence );
       
  1058 
       
  1059     if ( iCallState == MCCPCallObserver::ECCPStateConnecting )
       
  1060         {
       
  1061         RMmCustomAPI::TRemoteAlertingToneStatus ts = iCommonInfo.GetRemoteAlertingToneStatus();
       
  1062         
       
  1063         if (ts == RMmCustomAPI::EUiRbtTone )
       
  1064             {
       
  1065             tone = ECCPRemoteAlerting;
       
  1066             }
       
  1067         else if ( ts == RMmCustomAPI::EUiStopTone )
       
  1068             {
       
  1069             tone = ECCPNoSoundSequence;
       
  1070             }
       
  1071         else            
       
  1072             {
       
  1073             // No tone
       
  1074             tone = ECCPNoSoundSequence;
       
  1075             }
       
  1076         }
       
  1077     else
       
  1078         {
       
  1079         // Handle disconnecting tones      
       
  1080         TInt callDisconnectingError = ExitCodeError();
       
  1081         CSPLOGSTRING2(CSPINT, "CSPCall::Tone exit code err: %d", callDisconnectingError);
       
  1082 
       
  1083         switch( callDisconnectingError )
       
  1084             {
       
  1085             case KErrNone:
       
  1086                 // GSM: DIAL TONE (optional) - not used in Nokia phones 
       
  1087                 CSPLOGSTRING(CSPERROR, "CSPCall::Tone: No sound");
       
  1088                 break;
       
  1089             case KErrGsmCCUserBusy:
       
  1090                 // GSM: SUBSCRIBER BUSY
       
  1091                 tone = ECCPToneUserBusy;
       
  1092                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Subscriber Busy");
       
  1093                 break;
       
  1094                 // Fall through
       
  1095             case KErrGsmCCNumberChanged:
       
  1096             case KErrGsmCCResponseToStatusEnquiry:
       
  1097             case KErrGsmCCNormalUnspecified:
       
  1098                 // GSM: NONE, Nokia phones: radio path not available
       
  1099                 tone = ECCPToneRadioPathNotAvailable;
       
  1100                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: RadioPathNotAvailable");
       
  1101                 break;      
       
  1102             case KErrGsmCCNoChannelAvailable:
       
  1103             case KErrGsmCCTemporaryFailure:
       
  1104             case KErrGsmCCSwitchingEquipmentCongestion:
       
  1105             case KErrGsmCCRequestedChannelNotAvailable:
       
  1106             case KErrGsmCCQualityOfServiceNotAvailable:
       
  1107             case KErrGsmCCBearerCapabilityNotCurrentlyAvailable:
       
  1108                 // GSM: CONGESTION
       
  1109                 tone = ECCPToneCongestion;
       
  1110                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Congestion");
       
  1111                 break;
       
  1112             case KErrGsmCCUnassignedNumber:
       
  1113             case KErrGsmCCNoRouteToDestination:
       
  1114             case KErrGsmCCChannelUnacceptable:
       
  1115             case KErrGsmCCOperatorDeterminedBarring:
       
  1116             case KErrGsmCCUserNotResponding:
       
  1117             case KErrGsmCCUserAlertingNoAnswer:
       
  1118             case KErrGsmCCCallRejected:
       
  1119             case KErrGsmCCNonSelectedUserClearing:
       
  1120             case KErrGsmCCDestinationOutOfOrder:
       
  1121             case KErrGsmCCInvalidNumberFormat:
       
  1122             case KErrGsmCCFacilityRejected:
       
  1123             case KErrGsmCCNetworkOutOfOrder:
       
  1124             case KErrGsmCCAccessInformationDiscarded:
       
  1125             case KErrGsmCCResourceNotAvailable:
       
  1126             case KErrGsmCCRequestedFacilityNotSubscribed:
       
  1127             case KErrGsmCCIncomingCallsBarredInCug:
       
  1128             case KErrGsmCCBearerCapabilityNotAuthorised:
       
  1129             case KErrGsmCCServiceNotAvailable:
       
  1130             case KErrGsmCCBearerServiceNotImplemented:
       
  1131             case KErrGsmCCChannelTypeNotImplemented:
       
  1132             case KErrGsmCCAcmGreaterThanAcmMax:
       
  1133             case KErrGsmCCRequestedFacilityNotImplemented:
       
  1134             case KErrGsmCCOnlyRestrictedDigitalInformationBCAvailable:
       
  1135             case KErrGsmCCServiceNotImplemented:
       
  1136             case KErrGsmCCInvalidCallReferenceValue:
       
  1137             case KErrGsmCCChannelDoesNotExist:
       
  1138             case KErrGsmCCSuspendedCallExistsButCallIdentityDoesNotWork:
       
  1139             case KErrGsmCCCallIdentityInUse:
       
  1140             case KErrGsmCCNoCallSuspended:
       
  1141             case KErrGsmCCRequestedCallIdentityAlreadyCleared:
       
  1142             case KErrGsmCCUserNotInCug:
       
  1143             case KErrGsmCCIncompatibleDestination:
       
  1144             case KErrGsmCCInvalidTransitNetworkSelection:
       
  1145             case KErrGsmCCIncompatibleSegmentedMessage:
       
  1146             case KErrGsmCCSemanticallyIncorrectMessage:
       
  1147             case KErrGsmCCInvalidMandatoryInformation:
       
  1148             case KErrGsmCCNonExistentMessageType:
       
  1149             case KErrGsmCCIncompatibleMessageInProtocolState:
       
  1150             case KErrGsmCCNonExistentInformationElement:
       
  1151             case KErrGsmCCConditionalIEError:
       
  1152             case KErrGsmCCIncompatibleMessageInCallState:
       
  1153             case KErrGsmCCRecoveryOnTimerExpiry:
       
  1154             case KErrGsmCCUnspecifiedProtocolError:
       
  1155             case KErrGsmCCUnspecifiedInterworkingError:
       
  1156                 // GSM: SPECIAL INFORMATION
       
  1157                 tone = ECCPToneSpecialInformation;
       
  1158                 CSPLOGSTRING(CSPINT, "CSPCall::Tone: Special Information");
       
  1159                 break;
       
  1160             default:
       
  1161                 CSPLOGSTRING(CSPERROR, "CSPCall::Tone: ERROR not found");
       
  1162                 break;
       
  1163             }
       
  1164          }
       
  1165     
       
  1166     CSPLOGSTRING2(CSPREQIN, "CSPCall::Tone > tone: %d", tone);
       
  1167     return tone;
       
  1168     }
       
  1169     
       
  1170 // ---------------------------------------------------------------------------
       
  1171 // From class MCCPCSCall
       
  1172 // CSPCall::NoFdnCheck
       
  1173 // ---------------------------------------------------------------------------
       
  1174 //
       
  1175 void CSPCall::NoFDNCheck( )
       
  1176     {
       
  1177     CSPLOGSTRING(CSPREQIN, "CSPCall::NoFDNCheck");
       
  1178     iFdnCheck = EFalse;
       
  1179     }
       
  1180     
       
  1181 // ---------------------------------------------------------------------------
       
  1182 // CSPCall::LogDialedNumber
       
  1183 // ---------------------------------------------------------------------------
       
  1184 //
       
  1185 TBool CSPCall::LogDialedNumber() const
       
  1186     {
       
  1187     CSPLOGSTRING(CSPREQIN, "CSPCall::LogDialedNumber true");
       
  1188     return ETrue;
       
  1189     }
       
  1190     
       
  1191 // ---------------------------------------------------------------------------
       
  1192 // From class MCCPCSCall
       
  1193 // CSPCall::Dial
       
  1194 // ---------------------------------------------------------------------------
       
  1195 //
       
  1196 TInt CSPCall::Dial( const TDesC8& /*aCallParams*/ )
       
  1197     {
       
  1198     CSPLOGSTRING(CSPREQIN, "CSPCall::Dial");
       
  1199     return iCommonInfo.IndicateDialRequest( *this );
       
  1200     }
       
  1201 
       
  1202 // ---------------------------------------------------------------------------
       
  1203 // From class MCCPCallCommandHandling
       
  1204 // CSPCall::PerformDialRequest
       
  1205 // ---------------------------------------------------------------------------
       
  1206 //
       
  1207 TInt CSPCall::PerformDialRequest()
       
  1208     {
       
  1209     CSPLOGSTRING(CSPREQIN, "CSPCall::PerformDialRequest");
       
  1210     iDialCompletionCode = KErrNone;
       
  1211     iTerminationErrorNotified = EFalse;
       
  1212     
       
  1213     // Send the User to User Information.
       
  1214     if( iUserToUserInformation->Length() )
       
  1215         {
       
  1216         iUUIMessageSender->SendUUIMessage( *iUserToUserInformation );
       
  1217         }
       
  1218     
       
  1219     return DialFdnCond( iFdnCheck );
       
  1220     }
       
  1221     
       
  1222 // ---------------------------------------------------------------------------
       
  1223 // CSPCall::CSPCall
       
  1224 // ---------------------------------------------------------------------------
       
  1225 //
       
  1226 CSPCall::CSPCall( RMobileLine& aLine, 
       
  1227                   TBool aMobileOriginated,
       
  1228                   const TDesC& aName,
       
  1229                   MCSPCommonInfo& aCommonInfo,
       
  1230                   TBool aIsEmergencyCall ) : 
       
  1231                     iLine( aLine ),
       
  1232                     iMobileOriginated( aMobileOriginated ),
       
  1233                     iName( aName ), 
       
  1234                     iParams( NULL ),
       
  1235                     iCallState( MCCPCallObserver::ECCPStateIdle ),
       
  1236                     iCapsFlags( 0 ),
       
  1237                     iCallStatusMonitor( NULL ),
       
  1238                     iCallEventMonitor( NULL ),
       
  1239                     iCallInfoMonitor( NULL ),
       
  1240                     iRequester( NULL ),
       
  1241                     iDialCompletionCode( KErrNone ),
       
  1242                     iCommonInfo( aCommonInfo ),
       
  1243                     iTerminationErrorNotified( EFalse ),
       
  1244                     iIsEmergencyCall( aIsEmergencyCall),
       
  1245                     iTransferProvider( NULL ),
       
  1246                     iForwardProvider( NULL ),
       
  1247                     iAudioHandler( NULL ),
       
  1248                     iFdnCheck( ETrue ),
       
  1249                     iCallCapsMonitor( NULL ),
       
  1250                     iUUIMonitor( NULL ),
       
  1251                     iUUIMessageSender( NULL ),
       
  1252                     iSkypeId( NULL ),
       
  1253                     iAudioStatus( ECSPCallAudioStatusInactive ),
       
  1254                     iDontReportTerm( EFalse ),
       
  1255                     iUserToUserInformation( NULL )
       
  1256     {
       
  1257     CSPLOGSTRING(CSPOBJECT, "CSPCall::CSPCall");
       
  1258     }
       
  1259 
       
  1260 // ---------------------------------------------------------------------------
       
  1261 // CSPCall::ConstructL
       
  1262 // Constructing CSPCall in 2nd phase
       
  1263 // ---------------------------------------------------------------------------
       
  1264 //    
       
  1265 void CSPCall::ConstructL( const CCCECallParameters& aParams )
       
  1266     {
       
  1267     CSPLOGSTRING(CSPOBJECT, "CSPCall::ConstructL <");
       
  1268 
       
  1269     // Create cloned copy of call parameters 
       
  1270     iParams = static_cast<CCCECallParameters*>( aParams.CloneL() );
       
  1271     
       
  1272     // Open call handle  
       
  1273     OpenCallHandleL(); 
       
  1274 
       
  1275     // Update call info 
       
  1276     UpdateCallInfo(); 
       
  1277     
       
  1278     // Update call state from ETel 
       
  1279     UpdateCallState(); 
       
  1280     
       
  1281     // Create call handlers for call related requests 
       
  1282     // and for monitoring call related events 
       
  1283     CreateCallHandlersL(); 
       
  1284         
       
  1285     CSPLOGSTRING(CSPOBJECT, "CSPCall::ConstructL >");
       
  1286     }
       
  1287 
       
  1288 // ---------------------------------------------------------------------------
       
  1289 // CSPCall::OpenCallHandleL
       
  1290 // Open call handle, calls either OpenNewCallL or OpenExistingCallL depending 
       
  1291 // of the call direction and if the call is a client call       
       
  1292 // ---------------------------------------------------------------------------
       
  1293 //    
       
  1294 void CSPCall::OpenCallHandleL()
       
  1295     {
       
  1296     CSPLOGSTRING(CSPINT, "CSPCall::OpenCallHandleL <");
       
  1297     
       
  1298     if ( iMobileOriginated )
       
  1299         {
       
  1300         // There is no existing call on line, open new call 
       
  1301         OpenNewCall();
       
  1302         }
       
  1303     else
       
  1304         {
       
  1305         // Mobile terminated call on line, open existing call 
       
  1306         OpenExistingCallL( iName ); 
       
  1307         }
       
  1308 
       
  1309     CSPLOGSTRING(CSPINT, "CSPCall::OpenCallHandleL >");
       
  1310     }
       
  1311 
       
  1312 // ---------------------------------------------------------------------------
       
  1313 // CSPCall::UpdateCallInfoL
       
  1314 // Update call info including remote party name and number data  
       
  1315 // ---------------------------------------------------------------------------
       
  1316 //    
       
  1317 void CSPCall::UpdateCallInfo()
       
  1318     {
       
  1319     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfo <");
       
  1320     RMobileCall::TMobileCallInfoV7Pckg pck( iEtelCallInfo );
       
  1321     TInt err = GetMobileCallInfo( pck );
       
  1322     UpdateCallInfoImpl( iEtelCallInfo );
       
  1323 
       
  1324     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfo >");
       
  1325     }
       
  1326 
       
  1327 // ---------------------------------------------------------------------------
       
  1328 // CSPCall::UpdateCallInfoImpl
       
  1329 // Implementation for UpdateCallInfo().
       
  1330 // ---------------------------------------------------------------------------
       
  1331 //    
       
  1332 void CSPCall::UpdateCallInfoImpl( const RMobileCall::TMobileCallInfoV7& aCallInfo )
       
  1333     {
       
  1334     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfoImpl <");
       
  1335 
       
  1336     if ( iMobileOriginated )
       
  1337         {
       
  1338         // Call wasn't added by ETel monitor, update info accordingly
       
  1339         UpdateCallNameNumberInfo( aCallInfo, EFalse ); 
       
  1340         }
       
  1341     else
       
  1342         {
       
  1343         // Call was added by ETel monitor, update info accordingly
       
  1344         UpdateCallNameNumberInfo( aCallInfo, ETrue );
       
  1345         }
       
  1346     
       
  1347 
       
  1348     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallInfoImpl >");
       
  1349     }
       
  1350 
       
  1351 // ---------------------------------------------------------------------------
       
  1352 // CSPCall::UpdateCallOrigin
       
  1353 // Set call origin to CCCECallParameters.
       
  1354 // ---------------------------------------------------------------------------
       
  1355 //    
       
  1356 void CSPCall::UpdateCallOrigin( const RMobileCall::TMobileCallInfoV7& aCallInfo )
       
  1357     {
       
  1358     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallOrigin <");
       
  1359 
       
  1360     if ( RMobileCall::EOriginatorSIM == aCallInfo.iCallParamOrigin )
       
  1361         {
       
  1362         iParams->SetOrigin(CCCECallParameters::ECCECallOriginSAT);
       
  1363         iParams->SetAlphaId(aCallInfo.iAlphaId);
       
  1364         }
       
  1365 
       
  1366     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallOrigin >");
       
  1367     }
       
  1368 
       
  1369 
       
  1370 
       
  1371 // ---------------------------------------------------------------------------
       
  1372 // CSPCall::UpdateCallStateL
       
  1373 //   
       
  1374 // ---------------------------------------------------------------------------
       
  1375 //    
       
  1376 int CSPCall::UpdateCallState()
       
  1377     {
       
  1378     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallState <");
       
  1379     TInt err( KErrNone ); 
       
  1380     
       
  1381     // Update call state from ETel
       
  1382     RMobileCall::TMobileCallStatus etelState;
       
  1383     err = iCall.GetMobileCallStatus( etelState );
       
  1384     if ( KErrNone == err )
       
  1385         {
       
  1386         iCallState = CCPStateFromETelState( etelState );
       
  1387         }
       
  1388     CSPLOGSTRING2(CSPINT, "CSPCall::UpdateCallState > res %d", err);
       
  1389     
       
  1390     return err; 
       
  1391     }
       
  1392 
       
  1393 // ---------------------------------------------------------------------------
       
  1394 // CSPCall::NotifyRemotePartyNumberChanged
       
  1395 //   
       
  1396 // ---------------------------------------------------------------------------
       
  1397 //
       
  1398 void CSPCall::NotifyRemotePartyNumberChanged()
       
  1399     {
       
  1400     CSPLOGSTRING(CSPINT, "CSPCall::NotifyRemotePartyNumberChanged <");
       
  1401     // If COLP number is different from original dialled number
       
  1402     // it is available in connected state of a MO call.
       
  1403     // TSY does not send notification so number must be fetched.
       
  1404     if ( IsMobileOriginated() )
       
  1405         {
       
  1406         RMobileCall::TMobileCallInfoV7Pckg callInfoPckg( iEtelCallInfo );
       
  1407         GetMobileCallInfo( callInfoPckg );
       
  1408         if ( iEtelCallInfo.iRemoteParty.iRemoteNumber.iTelNumber.Length() )
       
  1409             {
       
  1410             NotifyRemotePartyInfoChanged( KNullDesC(),
       
  1411                 iEtelCallInfo.iRemoteParty.iRemoteNumber.iTelNumber);        
       
  1412             }
       
  1413         }
       
  1414 
       
  1415     }
       
  1416 
       
  1417 
       
  1418 // ---------------------------------------------------------------------------
       
  1419 // CSPCall::CreateCallHandlersL
       
  1420 // Create call handlers for call related requests and call monitoring  
       
  1421 // ---------------------------------------------------------------------------
       
  1422 //    
       
  1423 void CSPCall::CreateCallHandlersL()
       
  1424     {
       
  1425     CSPLOGSTRING(CSPINT, "CSPCall::CreateCallHandlersL <");
       
  1426 
       
  1427     iRequester = CSPEtelCallRequester::NewL( *this, iCall );
       
  1428 
       
  1429     iCallEventMonitor = CSPEtelCallEventMonitor::NewL( *this, iCall );
       
  1430     iCallEventMonitor->StartMonitoring();
       
  1431     iCallStatusMonitor = CSPEtelCallStatusMonitor::NewL( *this, iCall );
       
  1432     iCallStatusMonitor->StartMonitoring();
       
  1433     
       
  1434     iCallCapsMonitor = CSPEtelCallCapsMonitor::NewL( *this, iCall );
       
  1435     iCallCapsMonitor->StartMonitoring();
       
  1436     iCapsFlags = iCallCapsMonitor->FetchCallControlCapsL();
       
  1437     
       
  1438     iCallInfoMonitor = CSPCallInfoMonitor::NewL( *this, iCall );
       
  1439     iCallInfoMonitor->StartMonitoring();
       
  1440     
       
  1441     // Start UUI monitor and create message sender 
       
  1442     iSkypeId = TCSPSkypeIdParser::CreateSkypeIdBufferL();
       
  1443     iUUIMonitor = CSPUUIMonitor::NewL( iCall,*this );
       
  1444     iUUIMonitor->StartMonitor();
       
  1445     iUUIMessageSender = CSPUUIMessageSender::NewL( iCall );
       
  1446     iUserToUserInformation = iParams->UUSId().AllocL();
       
  1447     
       
  1448     // Transfer provider
       
  1449     iTransferProvider = CSPTransferProvider::NewL( iCall, *this, iCommonInfo );
       
  1450 
       
  1451     // Forward provider
       
  1452     iForwardProvider = CSPForwardProvider::NewL();
       
  1453     
       
  1454     CSPLOGSTRING(CSPINT, "CSPCall::CreateCallHandlersL >");
       
  1455     }
       
  1456 
       
  1457 // ---------------------------------------------------------------------------
       
  1458 // CSPCall::NotifyRingingState
       
  1459 // Gets to ringing state
       
  1460 // ---------------------------------------------------------------------------
       
  1461 //     
       
  1462 void CSPCall::NotifyRingingState( )
       
  1463     {
       
  1464     CSPLOGSTRING(CSPREQIN, "CSPCall::NotifyRingingState");
       
  1465     iCallState = MCCPCallObserver::ECCPStateRinging;
       
  1466 
       
  1467     TInt obsCount = iObservers.Count ( );
       
  1468     for (TInt i = 0; i < obsCount; i++ )
       
  1469         {
       
  1470         MCCPCallObserver *obs = iObservers[i];
       
  1471         if ( obs )
       
  1472             {
       
  1473             obs->CallStateChanged ( iCallState, this );
       
  1474             }
       
  1475         }
       
  1476     }
       
  1477 
       
  1478 // ---------------------------------------------------------------------------
       
  1479 // CSPCall::CCPStateFromETelState
       
  1480 // Simple mapping between state enumerations.
       
  1481 // ---------------------------------------------------------------------------
       
  1482 //     
       
  1483 MCCPCallObserver::TCCPCallState CSPCall::CCPStateFromETelState( 
       
  1484     RMobileCall::TMobileCallStatus aEtelState ) 
       
  1485     {
       
  1486     MCCPCallObserver::TCCPCallState ret = MCCPCallObserver::ECCPStateIdle;
       
  1487     switch ( aEtelState )
       
  1488         {
       
  1489         case RMobileCall::EStatusUnknown:
       
  1490             {
       
  1491             CSPLOGSTRING( CSPREQIN, 
       
  1492                 "CSPCall::State > RMobileCall::Unknown" );
       
  1493             ret = MCCPCallObserver::ECCPStateIdle;
       
  1494             break;
       
  1495             }
       
  1496         case RMobileCall::EStatusIdle:
       
  1497             {
       
  1498             CSPLOGSTRING( CSPREQIN, 
       
  1499                 "CSPCall::State > RMobileCall::EStatusIdle" );
       
  1500             ret = MCCPCallObserver::ECCPStateIdle;
       
  1501             break;
       
  1502             }
       
  1503         case RMobileCall::EStatusRinging:
       
  1504             {
       
  1505             CSPLOGSTRING( CSPREQIN, 
       
  1506                 "CSPCall::State > RMobileCall::EStatusRinging" );
       
  1507             ret = MCCPCallObserver::ECCPStateRinging;
       
  1508             break;
       
  1509             }
       
  1510         // Map the following to connecting status
       
  1511         case RMobileCall::EStatusDialling:                
       
  1512             {
       
  1513             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1514                 RMobileCall::EStatusDialling" );
       
  1515             ret = MCCPCallObserver::ECCPStateDialling;
       
  1516             break;
       
  1517             }
       
  1518         case RMobileCall::EStatusConnecting:
       
  1519             {
       
  1520             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1521                 RMobileCall::Connecting" );
       
  1522             ret = MCCPCallObserver::ECCPStateConnecting;
       
  1523             break;
       
  1524             }
       
  1525         case RMobileCall::EStatusAnswering:
       
  1526             {
       
  1527             CSPLOGSTRING( CSPREQIN, "CSPCall::State > \
       
  1528                 RMobileCall::Answering" );
       
  1529             ret = MCCPCallObserver::ECCPStateAnswering;
       
  1530             break;                
       
  1531             }
       
  1532         // Call is connected and active.
       
  1533         case RMobileCall::EStatusConnected:
       
  1534             {
       
  1535             CSPLOGSTRING( CSPREQIN, 
       
  1536             "CSPCall::State > RMobileCall::EStatusConnected" );
       
  1537             ret = MCCPCallObserver::ECCPStateConnected;
       
  1538             break;
       
  1539             }
       
  1540         case RMobileCall::EStatusDisconnectingWithInband:
       
  1541         case RMobileCall::EStatusDisconnecting:
       
  1542             {
       
  1543             CSPLOGSTRING( CSPREQIN, 
       
  1544                  "CSPCall::State > RMobileCall::EStatusDisconnecting/Inband?");
       
  1545             ret = MCCPCallObserver::ECCPStateDisconnecting;
       
  1546             break;
       
  1547             }
       
  1548         case RMobileCall::EStatusReconnectPending:
       
  1549             {
       
  1550             CSPLOGSTRING( CSPREQIN, 
       
  1551             "CSPCall::State > RMobileCall::EStatusHangingUp" );
       
  1552             ret = MCCPCallObserver::ECCPStateDisconnecting;
       
  1553             break;
       
  1554             }
       
  1555         case RMobileCall::EStatusHold:
       
  1556             {
       
  1557             CSPLOGSTRING( CSPREQIN, 
       
  1558             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1559             ret = MCCPCallObserver::ECCPStateHold;
       
  1560             break;
       
  1561             }
       
  1562         case RMobileCall::EStatusWaitingAlternatingCallSwitch: 
       
  1563             {
       
  1564             // This state is not used in real life.
       
  1565             CSPLOGSTRING( CSPREQIN, 
       
  1566             "CSPCall::State > RMobileCall::EStatusWaitingAlternatingCallSwitch" );
       
  1567             ret = MCCPCallObserver::ECCPStateConnected;
       
  1568             break;
       
  1569             }
       
  1570         case RMobileCall::EStatusTransferring: 
       
  1571             {
       
  1572             CSPLOGSTRING( CSPREQIN, 
       
  1573             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1574             ret = MCCPCallObserver::ECCPStateTransferring;
       
  1575             break;
       
  1576             }
       
  1577         case RMobileCall::EStatusTransferAlerting: 
       
  1578             {
       
  1579             CSPLOGSTRING( CSPREQIN, 
       
  1580             "CSPCall::State > RMobileCall::EStatusHold" );
       
  1581             ret = MCCPCallObserver::ECCPStateTransferring;
       
  1582             break;
       
  1583             }            
       
  1584         default:
       
  1585             {
       
  1586             CSPLOGSTRING( CSPREQIN, 
       
  1587                 "CSPCall::CCPStateFromETelState unhandled state ");
       
  1588             }
       
  1589         }
       
  1590 
       
  1591     CSPLOGSTRING3(CSPINT, 
       
  1592         "CSPCall::CCPStateFromETelState ETel: %d CCP: %d", aEtelState, ret);
       
  1593     return ret;
       
  1594     }
       
  1595 
       
  1596 // ---------------------------------------------------------------------------
       
  1597 // CSPCall::NotifyCallStateChanged
       
  1598 // Notifies observers about state changes
       
  1599 // ---------------------------------------------------------------------------
       
  1600 //
       
  1601 void CSPCall::NotifyCallStateChanged( MCCPCallObserver::TCCPCallState aState ) 
       
  1602     {
       
  1603     CSPLOGSTRING3(CSPINT, 
       
  1604             "CSPCall::NotifyCallStateChanged < state: %d this: %x", 
       
  1605             aState, this );
       
  1606                            
       
  1607     iCallState = aState;    
       
  1608     TBool notifyObservers( ETrue ); 
       
  1609 
       
  1610     if ( !iMobileOriginated && MCCPCallObserver::ECCPStateRinging == aState )
       
  1611         {
       
  1612         CSPLOGSTRING2(CSPINT, "CSPCall::No notify on ringing MT", aState);        
       
  1613         notifyObservers = EFalse; 
       
  1614         }
       
  1615     
       
  1616     if ( notifyObservers )
       
  1617         {
       
  1618         TInt obsCount = iObservers.Count();
       
  1619         for ( TInt i = 0; i < obsCount; i++ )
       
  1620             {
       
  1621             MCCPCallObserver *obs = iObservers[i];
       
  1622             if ( obs )
       
  1623                 {            
       
  1624                 obs->CallStateChanged( aState, this );
       
  1625                 }
       
  1626             }
       
  1627         }
       
  1628         
       
  1629     CSPLOGSTRING3(CSPINT, 
       
  1630             "CSPCall::NotifyCallStateChanged > state: %d this: %x", 
       
  1631             aState, this );
       
  1632     }
       
  1633 
       
  1634 // ---------------------------------------------------------------------------
       
  1635 // CSPCall::NotifyCallStateChangedWithInband
       
  1636 // Notifies observers about state changes
       
  1637 // ---------------------------------------------------------------------------
       
  1638 //
       
  1639 void CSPCall::NotifyCallStateChangedWithInband( 
       
  1640         MCCPCallObserver::TCCPCallState aState ) 
       
  1641     {
       
  1642     CSPLOGSTRING3(CSPINT, 
       
  1643         "CSPCall::NotifyCallStateChangedWithInBand < state: %d this: %x", 
       
  1644         aState, this );
       
  1645     
       
  1646     iCallState = aState;
       
  1647    
       
  1648     if ( !iMobileOriginated && MCCPCallObserver::ECCPStateRinging == aState )
       
  1649         {
       
  1650         CSPLOGSTRING2(CSPINT, "CSPCall::No notify on ringing MT", aState);
       
  1651         }
       
  1652     else
       
  1653         {        
       
  1654         TInt obsCount = iObservers.Count();
       
  1655         for ( TInt i = 0; i < obsCount; i++ )
       
  1656             {            
       
  1657             MCCPCallObserver *obs = iObservers[i];
       
  1658             if ( obs )
       
  1659                 {
       
  1660                 obs->CallStateChangedWithInband( aState, this );
       
  1661                 }
       
  1662             }
       
  1663         }
       
  1664     CSPLOGSTRING3(CSPINT, 
       
  1665             "CSPCall::NotifyCallStateChangedWithInband > state: %d this: %x", 
       
  1666             aState, this);
       
  1667     }
       
  1668 
       
  1669 // ---------------------------------------------------------------------------
       
  1670 // CSPCall::ReadRepositoryL
       
  1671 // Reads the given information from Central Repository.
       
  1672 // ---------------------------------------------------------------------------
       
  1673 //
       
  1674 void CSPCall::ReadRepositoryL( TUid aUid, TUint aKey, TInt& aVal)
       
  1675     {
       
  1676     CSPLOGSTRING(CSPINT, "CSPCall::ReadRepositoryL");
       
  1677     
       
  1678     CRepository* cr = CRepository::NewL( aUid );
       
  1679     TInt err = cr->Get( aKey, aVal );
       
  1680     delete cr;
       
  1681     User::LeaveIfError( err );
       
  1682     }
       
  1683 
       
  1684 // ---------------------------------------------------------------------------
       
  1685 // CSPCall::CheckAndNotifyTerminationError
       
  1686 // Reads error code from ETel.
       
  1687 // ---------------------------------------------------------------------------
       
  1688 //
       
  1689 void CSPCall::CheckAndNotifyTerminationError()
       
  1690     {
       
  1691     CSPLOGSTRING2(CSPINT, 
       
  1692         "CSPCall::CheckAndNotifyTerminationError dial completion code: %d", 
       
  1693         iDialCompletionCode);
       
  1694     
       
  1695     // Emergency error handling is separated into CSPEtelCallRequester
       
  1696     if ( !iIsEmergencyCall )
       
  1697         {
       
  1698         TInt termErr = ExitCodeError();
       
  1699         CSPLOGSTRING2(CSPINT, 
       
  1700                 "CSPCall::CheckAndNotifyTerminationError exit code error: %d", 
       
  1701                 termErr);
       
  1702         
       
  1703         if ( termErr == KErrNone )
       
  1704             {
       
  1705             // Handle KErrGsmCCUnassignedNumber correctly
       
  1706             // because the value is not stored in exit code.
       
  1707             termErr = iDialCompletionCode;
       
  1708             CSPLOGSTRING(CSPINT, 
       
  1709                     "CSPCall::CheckAndNotifyTerminationError use dial completion code");
       
  1710             }
       
  1711             
       
  1712         if ( termErr == KErrGsmRRPreEmptiveRelease )
       
  1713             {
       
  1714             // Error KErrGsmRRPreEmptiveRelease occurs when there is active call 
       
  1715             // and user make emergency call, can be ignored.
       
  1716             CSPLOGSTRING3( 
       
  1717                 CSPERROR, 
       
  1718                 "CSPCall::CheckAndNotifyTerminationError preemptive release, ignore: %d",
       
  1719                 termErr,
       
  1720                 this );
       
  1721             }
       
  1722         else if ( iDontReportTerm 
       
  1723                 && (  termErr == KErrGsmCCNormalUnspecified 
       
  1724                    || termErr == KErrGsmCCCallRejected ) )
       
  1725             {
       
  1726             // Not an error, since this happens on normal 
       
  1727             // call termination situation after connected call.
       
  1728             CSPLOGSTRING3(CSPERROR, 
       
  1729                     "CSPCall::CheckAndNotifyTerminationError DISCARD this: %x err: %d", 
       
  1730                     this, 
       
  1731                     termErr);    
       
  1732             }        
       
  1733         else if ( termErr )
       
  1734             {
       
  1735             TCCPError ccpErr(ECCPErrorNone);
       
  1736 
       
  1737             // Only a couple of error codes can have diagnostic information. 
       
  1738             // aDiagnostic ought to be undefined in other situatios,
       
  1739             // but at least in this way we can really guarantee it.
       
  1740             if ( termErr == KErrGsmCCFacilityRejected ||
       
  1741                  termErr == KErrGsmCCRequestedFacilityNotSubscribed ||
       
  1742                  termErr == KErrGsmCCIncomingCallsBarredInCug ||
       
  1743                  termErr == KErrGsmCCRequestedFacilityNotImplemented ||
       
  1744                  termErr == KErrGsmCCUserNotInCug )
       
  1745                 {
       
  1746                 TName name;
       
  1747                 CallName( name );        
       
  1748                 TInt diagErr = iCommonInfo.GetDiagnosticError( name );
       
  1749                 ccpErr = iRequester->MapError( diagErr );
       
  1750     
       
  1751                 // Finally use exit code if diagnostic did not contain
       
  1752                 // any useful information.
       
  1753                 if ( ccpErr == ECCPRequestFailure )
       
  1754                     {
       
  1755                     ccpErr = iRequester->MapError( termErr );
       
  1756                     }
       
  1757                 }
       
  1758             else
       
  1759                 {
       
  1760                 ccpErr = iRequester->MapError( termErr );
       
  1761                 }
       
  1762             
       
  1763             NotifyErrorOccurred( ccpErr );
       
  1764             iTerminationErrorNotified = ETrue;
       
  1765             }
       
  1766         }    
       
  1767     }
       
  1768 
       
  1769 // ---------------------------------------------------------------------------
       
  1770 // CSPCall::ExitCodeError
       
  1771 // Reads error code from ETel call info's iExitCode.
       
  1772 // ---------------------------------------------------------------------------
       
  1773 //
       
  1774 TInt CSPCall::ExitCodeError() const
       
  1775     {
       
  1776     CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError < this: %x", 
       
  1777                     this );
       
  1778     TInt callError;
       
  1779     RMobileCall::TMobileCallInfoV7Pckg pck( iEtelCallInfo );
       
  1780     TInt getErr = GetMobileCallInfo( pck );
       
  1781     // Is there value in higher 16 bits
       
  1782     if ( KErrNone == getErr && (iEtelCallInfo.iExitCode & 0xFFFF0000) ) 
       
  1783         {
       
  1784         CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError callInfo.iExitCode %d", 
       
  1785             iEtelCallInfo.iExitCode );
       
  1786         callError = ( iEtelCallInfo.iExitCode >> KTimesToSplitValue ); 
       
  1787         
       
  1788         if ( callError > KErrEtelGsmBase ) 
       
  1789             // Not in valid exteded range
       
  1790             {
       
  1791             // Ignore invalid extented code
       
  1792             if ( ( iEtelCallInfo.iExitCode & 0x0000FFFF ) == KErrNone ) 
       
  1793                 // core error is zero
       
  1794                 {
       
  1795                 callError = KErrNone;
       
  1796                 }
       
  1797             else
       
  1798                 {
       
  1799                 callError = ( ( iEtelCallInfo.iExitCode & 0x0000FFFF ) 
       
  1800                     | 0xFFFF0000 ); 
       
  1801                 }
       
  1802             }
       
  1803         }
       
  1804     // Higher and lower 16 bits are zero
       
  1805     else if ( !( iEtelCallInfo.iExitCode & 0xFFFFFFFF ) ) 
       
  1806         {
       
  1807         callError = KErrNone;
       
  1808         }
       
  1809     else 
       
  1810         {
       
  1811         // No extended error, expand value to full range
       
  1812         callError = ( iEtelCallInfo.iExitCode | 0xFFFF0000 );
       
  1813         }
       
  1814         
       
  1815     CSPLOGSTRING2(CSPINT, "CSPCall::ExitCodeError > err: %d", callError);
       
  1816         
       
  1817     return callError;
       
  1818     }
       
  1819 
       
  1820 // ---------------------------------------------------------------------------
       
  1821 // CSPCall::UUSMessageReceived
       
  1822 // ---------------------------------------------------------------------------
       
  1823 //
       
  1824  void CSPCall::UUSMessageReceived( const TDesC& aMessage )
       
  1825     {      
       
  1826     CSPLOGSTRING(CSPREQIN, "CSPCall::UUSMessageReceived");
       
  1827     TCSPSkypeIdParser parser;
       
  1828            
       
  1829     TPtr ptr = iSkypeId->Des();
       
  1830     ptr.Zero();
       
  1831     const TInt error( parser.Parse( aMessage, ptr ) );
       
  1832     
       
  1833     if ( !error ) 
       
  1834         {
       
  1835         iRemotePartyName = ptr;
       
  1836         NotifyCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange );            
       
  1837         }
       
  1838     CSPLOGSTRING2(CSPINT, "CSPCall::UUSMessageReceived  err: %d",  error );        
       
  1839     }
       
  1840 
       
  1841 // ---------------------------------------------------------------------------
       
  1842 // CSPCall::NotifyRemotePartyInfoChanged
       
  1843 // ---------------------------------------------------------------------------
       
  1844 //
       
  1845 void CSPCall::NotifyRemotePartyInfoChanged( const TDesC& aRemotePartyName,
       
  1846                                             const TDesC& aRemotePartyNumber )
       
  1847     {
       
  1848     CSPLOGSTRING(CSPREQIN, "CSPCall::NotifyRemotePartyInfoChanged");
       
  1849     if ( aRemotePartyName.Length() )    
       
  1850         {
       
  1851         iRemotePartyName = aRemotePartyName;
       
  1852         }
       
  1853     
       
  1854     if ( aRemotePartyNumber.Length() )    
       
  1855         {
       
  1856         iRemotePartyNumber = aRemotePartyNumber;
       
  1857         }
       
  1858     
       
  1859     NotifyCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange );
       
  1860     }
       
  1861 
       
  1862 // ---------------------------------------------------------------------------
       
  1863 // CSPCall::DontReportTerminationError
       
  1864 // ---------------------------------------------------------------------------
       
  1865 //
       
  1866 void CSPCall::DontReportTerminationError() 
       
  1867     {
       
  1868     CSPLOGSTRING(CSPREQIN, "CSPCall::DontReportTerminationError");
       
  1869     iDontReportTerm = ETrue;
       
  1870     }
       
  1871 
       
  1872 // ---------------------------------------------------------------------------
       
  1873 // CSPCall::UpdateCallNameNumberInfo
       
  1874 // Update call info including remote party name and number data  
       
  1875 // ---------------------------------------------------------------------------
       
  1876 //    
       
  1877 void CSPCall::UpdateCallNameNumberInfo(
       
  1878         const RMobileCall::TMobileCallInfoV3& aCallInfo, 
       
  1879         TBool aCallAddedByMonitor )
       
  1880     {
       
  1881     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallNameNumberInfo <");
       
  1882 
       
  1883     iCallName.Zero();
       
  1884     iRemotePartyNumber.Zero();
       
  1885     iRemotePartyName.Zero();
       
  1886     
       
  1887     if ( aCallAddedByMonitor )        
       
  1888         {
       
  1889         CSPLOGSTRING(CSPINT, 
       
  1890                 "CSPCall::UpdateCallNameNumberInfo call added by monitor");
       
  1891 
       
  1892         // If call was created by ETel line status or incoming call monitor
       
  1893         // the call name is already known, only remote party info is fetched from 
       
  1894         // call info 
       
  1895         iCallName.Append( iName );
       
  1896         iRemotePartyName.Append( aCallInfo.iRemoteParty.iCallingName );
       
  1897         iRemotePartyNumber.Append( aCallInfo.iRemoteParty.iRemoteNumber.iTelNumber );
       
  1898         }
       
  1899     else 
       
  1900         {
       
  1901         CSPLOGSTRING(CSPINT, 
       
  1902                 "CSPCall::UpdateCallNameNumberInfo call added by plugin owner");
       
  1903         
       
  1904         // The call was not created by monitor and the remote number is already known, 
       
  1905         // fetch only call name from call info  
       
  1906         iCallName.Append( aCallInfo.iCallName );
       
  1907         iRemotePartyNumber.Append( iName ); 
       
  1908         }
       
  1909     
       
  1910     CSPLOGSTRING2(CSPINT, 
       
  1911             "CSPCall::UpdateCallNameNumberInfo iCallName: %S", &iCallName );
       
  1912     CSPLOGSTRING2(CSPINT, 
       
  1913             "CSPCall::UpdateCallNameNumberInfo iRemotePartyNumber: %S", &iRemotePartyNumber );
       
  1914     CSPLOGSTRING2(CSPINT, 
       
  1915             "CSPCall::UpdateCallNameNumberInfo iRemotePartyName: %S", &iRemotePartyName );
       
  1916 
       
  1917     CSPLOGSTRING(CSPINT, "CSPCall::UpdateCallNameNumberInfo >");
       
  1918     }
       
  1919 
       
  1920 // ---------------------------------------------------------------------------
       
  1921 // CSPCall::OpenNewCall
       
  1922 // Open new call 
       
  1923 // ---------------------------------------------------------------------------
       
  1924 //    
       
  1925 void CSPCall::OpenNewCall()
       
  1926     {
       
  1927     CSPLOGSTRING(CSPINT, "CSPCall::OpenNewCall <");
       
  1928 
       
  1929     // Open new call 
       
  1930     __ASSERT_ALWAYS( iCall.OpenNewCall( iLine ) == KErrNone, 
       
  1931             Panic( ECSPPanicNoEtel ) );
       
  1932 
       
  1933     CSPLOGSTRING(CSPINT, "CSPCall::OpenNewCall >");
       
  1934     }
       
  1935 
       
  1936 // ---------------------------------------------------------------------------
       
  1937 // CSPCall::OpenExistingCallL
       
  1938 // Open existing call  
       
  1939 // ---------------------------------------------------------------------------
       
  1940 //    
       
  1941 void CSPCall::OpenExistingCallL( const TDesC& aName )
       
  1942     {
       
  1943     CSPLOGSTRING2(CSPINT, 
       
  1944             "CSPCall::OpenExistingCallL < aName: %S", &aName);
       
  1945     
       
  1946     // Open existing call with given name from current line 
       
  1947     TInt err = iCall.OpenExistingCall( iLine, aName ); 
       
  1948     
       
  1949     if ( KErrNone != err  )
       
  1950         {
       
  1951         CSPLOGSTRING2(CSPERROR,
       
  1952             "CSPCall::OpenCallHandleL OpenExistingCall error: %d, leaving", err);    
       
  1953         User::Leave( err );
       
  1954         }
       
  1955 
       
  1956     CSPLOGSTRING(CSPINT, "CSPCall::OpenExistingCallL >");
       
  1957     }
       
  1958 
       
  1959 // End of File
       
  1960