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