convergedcallengine/csplugin/src/csprovider.cpp
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
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:  Main class of CS Call Plug-in
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // EXTERNAL INCLUDES
       
    20 #include <e32base.h>
       
    21 #include <mccpconferencecallobserver.h>
       
    22 #include <mmtsy_names.h>
       
    23 #include <mccpssobserver.h>
       
    24 #include <rmmcustomapi.h>
       
    25 #include <startupdomainpskeys.h>
       
    26 #include <mccecall.h>
       
    27 
       
    28 // USER INCLUDES
       
    29 #include "csprovider.h"
       
    30 #include "cspvoicecall.h"
       
    31 #include "cspvideocall.h"
       
    32 #include "cspetelincomingcallmonitor.h"
       
    33 #include "cspetelconferencestatusmonitor.h"
       
    34 #include "cspdtmfprovider.h"
       
    35 #include "cspconferencecall.h"
       
    36 #include "cspcallarray.h"
       
    37 #include "cspservicesettingshandler.h"
       
    38 #include "cspaudiohandler.h"
       
    39 #include "cspetelcallwaitingrequester.h"
       
    40 #include "cspsupplementaryservicesmonitor.h"
       
    41 #include "cspcipheringstatusmonitor.h"
       
    42 #include "cspsssettingshandler.h"
       
    43 #include "cspcalladdedhandler.h"
       
    44 #include "csppubsublistener.h"
       
    45 #include "cspcallcommandhandler.h"
       
    46 #include "cspremotealertingtonelistener.h"
       
    47 #include "csppanic.pan"
       
    48 #include "csplogger.h"
       
    49 #include "cspconsts.h"
       
    50 
       
    51 const TInt KCSServiceId = 1; 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CSProvider::CSProvider
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CSProvider::CSProvider(): iImplementationUid( KCSPImplementationUid )
       
    58     {
       
    59     CSPLOGSTRING(CSPOBJECT, "CSProvider::CSProvider");
       
    60     iInitialized = EFalse;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CSProvider::~CSProvider
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CSProvider::~CSProvider()
       
    68     {
       
    69     CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider <");
       
    70     delete iCallArray;
       
    71     
       
    72     if ( iInitialized )
       
    73         {
       
    74         delete iConferenceStatusMonitor; 
       
    75         delete iCallCommandHandler;
       
    76         delete iRemoteAlertingToneListener;
       
    77         delete iSimStatusListener;
       
    78         delete iSsSettingsHandler;
       
    79         delete iAudioHandler;        
       
    80         delete iSsMonitor;
       
    81         delete iCwRequester;
       
    82         delete iServiceHandler;
       
    83         delete iIncomingVoiceCallMonitor;
       
    84         delete iIncomingDataCallMonitor;
       
    85         delete iIncomingAuxCallMonitor;
       
    86         delete iCallAddedHandler;
       
    87         delete iCipheringStatusMonitor;
       
    88         delete iDTMFProvider;
       
    89 
       
    90         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider close lines");
       
    91         iLineContainer.Close();
       
    92         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider close customapi");
       
    93         iMmCustom.Close();
       
    94         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider close conference call");
       
    95         iMobileConferenceCall.Close();
       
    96         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider close phone");
       
    97         iMobilePhone.Close();
       
    98         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider unload phone");
       
    99         iServer.UnloadPhoneModule( KMmTsyModuleName );
       
   100         CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider close server session");
       
   101         iServer.Close();
       
   102         }
       
   103 
       
   104     CSPLOGSTRING(CSPOBJECT, "CSProvider::~CSProvider >");
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CSProvider::ConstructL
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CSProvider::ConstructL()
       
   112     {
       
   113     CSPLOGSTRING(CSPOBJECT, "CSProvider::ConstructL <");
       
   114     iCallArray = CSPCallArray::NewL();
       
   115     CSPLOGSTRING(CSPOBJECT, "CSProvider::ConstructL >");
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CSProvider::NewL
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CSProvider* CSProvider::NewL()
       
   123     {
       
   124     CSPLOGSTRING(CSPOBJECT, "CSProvider::NewL() <");
       
   125     CSProvider* self = new ( ELeave ) CSProvider();
       
   126     CleanupStack::PushL( self );
       
   127     self->ConstructL();
       
   128     CleanupStack::Pop( self );
       
   129     CSPLOGSTRING(CSPOBJECT, "CSProvider::NewL() >");
       
   130     return self;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CSProvider::NotifySsEvent
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CSProvider::NotifySsEvent( 
       
   138                     RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode,
       
   139                     RMmCustomAPI::TSsInfo& aSsInfo )
       
   140     {
       
   141     CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent <");
       
   142     TBuf<10> addr;
       
   143     
       
   144     switch( aSsTypeAndMode.iSsType )
       
   145         {
       
   146         case RMmCustomAPI::ESsAllSs:
       
   147             {
       
   148             CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent ESsAllSs");
       
   149             if( iSsSettingsHandler )
       
   150                 {
       
   151                 TInt cugIndex( aSsInfo.iCugIndex );
       
   152                                 
       
   153                 if ( iSsSettingsHandler->IsValueValidCugIndex( cugIndex ) ) 
       
   154                     {
       
   155                     CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent CallCugEventOccurred");
       
   156                     iSsObserver->CallCugEventOccurred(  
       
   157                             MCCPSsObserver::ECCPSsShowIncCallGroupIndex );
       
   158                     }  
       
   159                 else 
       
   160                     {
       
   161                     CSPLOGSTRING2(CSPERROR, 
       
   162                             "CSProvider::NotifySsEvent err invalid cug index %d", cugIndex );
       
   163                     }
       
   164                 }
       
   165             break; 
       
   166             }
       
   167         
       
   168         case RMmCustomAPI::ESsRegPassword:
       
   169         case RMmCustomAPI::ESsClip:
       
   170         case RMmCustomAPI::ESsClir:
       
   171         case RMmCustomAPI::ESsCnap:
       
   172         case RMmCustomAPI::ESsColp:
       
   173         case RMmCustomAPI::ESsColr:
       
   174             {
       
   175             CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent Discarding");
       
   176             break; 
       
   177             }
       
   178 
       
   179         case RMmCustomAPI::ESsCallWaiting:
       
   180             {
       
   181             CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent ESsCallWaiting");
       
   182             iSsObserver->CallForwardEventOccurred( 
       
   183                                 MCCPSsObserver::ESsCallWaiting,
       
   184                                 addr );
       
   185             break; 
       
   186             }        
       
   187             
       
   188         case RMmCustomAPI::ESsAllForwardings:
       
   189         case RMmCustomAPI::ESsForwUncond:
       
   190         case RMmCustomAPI::ESsForwBusy:
       
   191         case RMmCustomAPI::ESsForwNoReply:
       
   192         case RMmCustomAPI::ESsForwNoReach:
       
   193         case RMmCustomAPI::ESsAllCondForwardings:
       
   194             {
       
   195             switch( aSsInfo.iForwMode )
       
   196                 {
       
   197                 case RMmCustomAPI::ESsIncCallIsForw:
       
   198                     iSsObserver->CallForwardEventOccurred( 
       
   199                                         MCCPSsObserver::ECCPSsIncCallIsForw,
       
   200                                         addr );
       
   201                     break;
       
   202                 case RMmCustomAPI::ESsIncCallForwToC:
       
   203                     iSsObserver->CallForwardEventOccurred( 
       
   204                                         MCCPSsObserver::ECCPSsIncCallForwToC,
       
   205                                         addr );
       
   206                     break;
       
   207                 case RMmCustomAPI::ESsOutCallForwToC:
       
   208                     iSsObserver->CallForwardEventOccurred( 
       
   209                                         MCCPSsObserver::ECCPSsOutCallForwToC,
       
   210                                         addr );
       
   211                     break;
       
   212                 default:
       
   213                     {
       
   214                     HandleDivertOrBarring( addr, aSsTypeAndMode );
       
   215                     break; 
       
   216                     }
       
   217                 }
       
   218             break;
       
   219             }
       
   220 
       
   221         case RMmCustomAPI::ESsAllBarrings:  
       
   222         case RMmCustomAPI::ESsBarrAllOut:
       
   223         case RMmCustomAPI::ESsBarrOutInter:
       
   224         case RMmCustomAPI::ESsBarrOutInterExcHome:
       
   225         case RMmCustomAPI::ESsOutgoingBarrServ:
       
   226             {            
       
   227             iSsObserver->BarringEventOccurred( 
       
   228                                     MCCPSsObserver::ECCPSsOutgoingCallBarred );
       
   229             break;
       
   230             }
       
   231 
       
   232         case RMmCustomAPI::ESsBarrAllIn:
       
   233         case RMmCustomAPI::ESsBarrAllInRoam:
       
   234         case RMmCustomAPI::ESsIncomingBarrServ:
       
   235             {            
       
   236             iSsObserver->BarringEventOccurred( 
       
   237                                     MCCPSsObserver::ECCPSsIncomingCallBarred );
       
   238             break;
       
   239             }
       
   240 
       
   241         default:
       
   242             {
       
   243             CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent Unknown SS");
       
   244             break; 
       
   245             }
       
   246         }
       
   247         
       
   248     CSPLOGSTRING(CSPINT, "CSProvider::NotifySsEvent >");    
       
   249     }
       
   250 
       
   251 // From CConvergedCallProvider
       
   252 // ---------------------------------------------------------------------------
       
   253 // CSProvider::InitializeL
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 void CSProvider::InitializeL( const MCCPObserver& aObserver,
       
   257                               const MCCPSsObserver& aSsObserver )
       
   258     {
       
   259     CSPLOGSTRING(CSPOBJECT, "CSProvider::InitializeL <");
       
   260     if ( iInitialized )
       
   261         {
       
   262         CSPLOGSTRING(CSPOBJECT, 
       
   263                 "CSProvider::InitializeL() Error already initialized");
       
   264         User::Leave( KErrAlreadyExists );
       
   265         }
       
   266     iInitialized = ETrue;
       
   267     
       
   268     CreateEtelConnectionsL();
       
   269     
       
   270     iServiceHandler = CSPServiceSettingsHandler::NewL();
       
   271 
       
   272     TInt readErr = iServiceHandler->ReadCSServiceId( iServiceId );
       
   273     if ( readErr )
       
   274         {
       
   275         CSPLOGSTRING(CSPERROR, "CSProvider::InitializeL()\
       
   276                 ERROR COULD NOT READ SERVICE ID FOR CS-PLUGIN ");
       
   277         CSPLOGSTRING(CSPERROR, "CSProvider::InitializeL() \
       
   278                 Please ensure that SPSettings is initialized corretly! ");
       
   279         iServiceId = KCSServiceId; 
       
   280         }
       
   281     
       
   282     // Save CCP observer as pointer-type member 
       
   283     const MCCPCSObserver& obs = static_cast<const MCCPCSObserver&>(aObserver);
       
   284     iCCPObserver = const_cast<MCCPCSObserver*>(&obs);
       
   285     
       
   286     // Save CCP SS observer as pointer-type member 
       
   287     const MCCPSsObserver& ssObs = static_cast<const MCCPSsObserver&>(aSsObserver);
       
   288     iSsObserver = const_cast<MCCPSsObserver*>(&ssObs);
       
   289     
       
   290     RPhone::TLineInfo lineInfo;
       
   291     __ASSERT_ALWAYS( iMobilePhone.GetLineInfo( 0, lineInfo )
       
   292         == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   293     
       
   294     // Open Lines. At least voice line must be opened.
       
   295     __ASSERT_ALWAYS( iLineContainer.Open( iMobilePhone, iServiceId ) == KErrNone,
       
   296         Panic( ECSPPanicNoEtel ) );
       
   297 
       
   298     RMobileLine& voiceLine = iLineContainer.LineByType( 
       
   299                                 RCSPLineContainer::ECSPLineSpeech );
       
   300     
       
   301     // Create and start incoming voice call monitor for primary line
       
   302     iIncomingVoiceCallMonitor = CSPEtelIncomingCallMonitor::NewL( *this, 
       
   303                                       voiceLine,
       
   304                                       RCSPLineContainer::ECSPLineSpeech );
       
   305     iIncomingVoiceCallMonitor->StartMonitoring();
       
   306 
       
   307     // Create and start incoming data call monitor for data line    
       
   308     RMobileLine& dataLine = iLineContainer.LineByType( RCSPLineContainer::ECSPLineData );
       
   309     iIncomingDataCallMonitor = CSPEtelIncomingCallMonitor::NewL( *this, dataLine,
       
   310                                       RCSPLineContainer::ECSPLineData );
       
   311     iIncomingDataCallMonitor->StartMonitoring();
       
   312     
       
   313     // Create and start incoming call monitor for auxilary line    
       
   314     RMobileLine& auxLine = iLineContainer.LineByType( RCSPLineContainer::ECSPLineAuxSpeech );
       
   315     iIncomingAuxCallMonitor = CSPEtelIncomingCallMonitor::NewL( *this, auxLine,
       
   316                                       RCSPLineContainer::ECSPLineAuxSpeech );
       
   317     iIncomingAuxCallMonitor->StartMonitoring();
       
   318 
       
   319     iCwRequester = CSPEtelCallWaitingRequester::NewL( iMobilePhone );
       
   320     
       
   321     // Start conference call monitor for monitoring external conference creation  
       
   322     iConferenceStatusMonitor = CSPEtelConferenceStatusMonitor::NewL( *this, 
       
   323                                     iMobileConferenceCall );
       
   324     iConferenceStatusMonitor->StartMonitoring();
       
   325 
       
   326     CSPLOGSTRING(CSPOBJECT, "CSProvider::InitializeL create DTMF provider");
       
   327     iDTMFProvider = CSPDTMFProvider::NewL( iMobilePhone, iMmCustom );
       
   328     
       
   329     // Create and start ciphering status monitor    
       
   330     iCipheringStatusMonitor = CSPCipheringStatusMonitor::NewL( iMmCustom, *this );
       
   331     iCipheringStatusMonitor->StartMonitoring();
       
   332 
       
   333     // Create audio handler
       
   334     CSPLOGSTRING(CSPOBJECT, "CSProvider::InitializeL create audio handler");
       
   335     iAudioHandler = CSPAudioHandler::NewL();
       
   336     
       
   337     // Create call added handler for listening ext call creation
       
   338     iCallAddedHandler = CSPCallAddedHandler::NewL( 
       
   339         obs, 
       
   340         iLineContainer, 
       
   341         *iCallArray,
       
   342         *this,
       
   343         *iAudioHandler );
       
   344     
       
   345     iSimStatusListener = CSPPubSubListener::NewL( 
       
   346         KPSUidStartup, 
       
   347         KPSSimStatus, 
       
   348         this );
       
   349     
       
   350     HandleSIMStatusL();
       
   351     
       
   352     iRemoteAlertingToneListener = 
       
   353         CSPRemoteAlertingToneListener::NewL( iMmCustom, *this );
       
   354     iRemoteAlertingToneListener->StartListening();
       
   355 
       
   356     iCallCommandHandler = CSPCallCommandHandler::NewL();
       
   357     
       
   358     CSPLOGSTRING(CSPOBJECT, "CSProvider::InitializeL >");
       
   359     }
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // CSProvider::NewCallL creates MO call.
       
   363 // ---------------------------------------------------------------------------
       
   364 //
       
   365 MCCPCall* CSProvider::NewCallL( const CCCPCallParameters& aCallParameters,
       
   366                                 const TDesC& aRemoteParty, 
       
   367                                 const MCCPCallObserver& aObserver )
       
   368     {
       
   369     CSPLOGSTRING(CSPREQIN, "CSProvider::NewCallL <");
       
   370     
       
   371     const CCCECallParameters& parameters = 
       
   372         reinterpret_cast<const CCCECallParameters&> (aCallParameters);
       
   373     
       
   374     TUint32 serviceId = aCallParameters.ServiceId();
       
   375 
       
   376     if ( serviceId != iServiceId )
       
   377         {
       
   378         CSPLOGSTRING(CSPERROR, "CSProvider::NewCallL ERROR, service id not acceptable!");
       
   379         User::Leave( ECCPErrorInvalidPhoneNumber );
       
   380         }
       
   381     
       
   382     RCSPLineContainer::TCSPLineId lineId = 
       
   383         iLineContainer.ResolveLineIdL( parameters );
       
   384 
       
   385     RMobileLine& line = iLineContainer.LineByType( lineId );
       
   386     
       
   387     CSPCall* call = NULL;
       
   388     
       
   389     if ( RCSPLineContainer::ECSPLineSpeech == lineId ||
       
   390          RCSPLineContainer::ECSPLineAuxSpeech == lineId )
       
   391         {
       
   392         call = CSPVoiceCall::NewL( const_cast<TDesC16&>(aRemoteParty), 
       
   393                             line, 
       
   394                             ETrue,
       
   395                             parameters,
       
   396                             *this,
       
   397                             EFalse );
       
   398         CleanupStack::PushL( call );
       
   399         }
       
   400         
       
   401     // Create CSPDataCall object for data/video call
       
   402     else if ( RCSPLineContainer::ECSPLineData == lineId )
       
   403         {
       
   404         call = CSPVideoCall::NewL( 
       
   405                             const_cast<TDesC16&>(aRemoteParty),
       
   406                             line, ETrue, parameters,
       
   407                             *this );
       
   408         CleanupStack::PushL( call );
       
   409         }
       
   410     else if ( RCSPLineContainer::ECSPLineFax == lineId )
       
   411         {
       
   412         CSPLOGSTRING(CSPERROR, 
       
   413             "CSProvider::NewCallL ERROR FAX is unsupported call type");
       
   414         User::Leave( KErrNotSupported );
       
   415         }
       
   416     
       
   417     if ( aRemoteParty.Length() == 0 )
       
   418         {
       
   419         CSPLOGSTRING(CSPERROR, "CSProvider::NewCallL ERROR: aRemoteParty.Length ==0");
       
   420          
       
   421         User::Leave( ECCPErrorInvalidPhoneNumber );
       
   422         }
       
   423     
       
   424     call->AddObserverL( aObserver );        
       
   425     TInt err = iCallArray->Add( call );
       
   426     User::LeaveIfError( err );
       
   427 
       
   428     call->SetAudioHandler( iAudioHandler );
       
   429     
       
   430     CleanupStack::Pop( call );
       
   431     
       
   432     CSPLOGSTRING(CSPOBJECT, "CSProvider::NewCallL >");
       
   433     return call;
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // CSProvider::ReleaseCall
       
   438 // ---------------------------------------------------------------------------
       
   439 //
       
   440 TInt CSProvider::ReleaseCall( MCCPCall& aCall )
       
   441     {
       
   442     CSPLOGSTRING2(CSPREQIN, "CSProvider::ReleaseCall %d", &aCall);
       
   443     CSPCall* call = static_cast<CSPCall*>(&aCall);
       
   444     TInt err = iCallArray->Remove( call );
       
   445     if ( err == KErrNone )
       
   446         {
       
   447         delete call;
       
   448         }
       
   449     return err;
       
   450     }
       
   451 
       
   452 // ---------------------------------------------------------------------------
       
   453 // CSProvider::NewEmergencyCallL
       
   454 // ---------------------------------------------------------------------------
       
   455 //
       
   456 MCCPEmergencyCall* CSProvider::NewEmergencyCallL( const TUint32 aServiceId,
       
   457                                                   const TDesC& aAddress,
       
   458                                            const MCCPCallObserver& aObserver )
       
   459     {
       
   460     CSPLOGSTRING(CSPOBJECT, "CSProvider::NewEmergencyCallL <");
       
   461 
       
   462     RMobileLine& voiceLine = iLineContainer.LineByType( 
       
   463                                     RCSPLineContainer::ECSPLineSpeech );
       
   464     TBuf8<KCCEBearerMaxSize> emptyBearer;
       
   465     TBuf<KCCESubAddressMaxSize> emptySubAddress;
       
   466     
       
   467     CCCECallParameters* tmpParams = CCCECallParameters::NewL();
       
   468     CleanupStack::PushL( tmpParams );
       
   469     tmpParams->SetServiceId(aServiceId);
       
   470     CSPVoiceCall* call = CSPVoiceCall::NewL( aAddress,
       
   471                                              voiceLine,
       
   472                                              ETrue,
       
   473                                              *tmpParams,
       
   474                                              *this,
       
   475                                              ETrue);
       
   476         
       
   477     CleanupStack::PopAndDestroy( tmpParams );
       
   478     CleanupStack::PushL( call );
       
   479     
       
   480     call->AddObserverL( aObserver );
       
   481     TInt err = iCallArray->Add( call );
       
   482     User::LeaveIfError( err );
       
   483 
       
   484     call->SetAudioHandler( iAudioHandler );
       
   485     
       
   486     CleanupStack::Pop( call );    
       
   487     
       
   488     CSPLOGSTRING(CSPOBJECT, "CSProvider::NewEmergencyCallL >");
       
   489     return call;
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // CSProvider::ReleaseEmergencyCall
       
   494 // ---------------------------------------------------------------------------
       
   495 //
       
   496 TInt CSProvider::ReleaseEmergencyCall( MCCPEmergencyCall& aCall )
       
   497     {
       
   498     CSPLOGSTRING(CSPOBJECT, "CSProvider::ReleaseEmergencyCall");    
       
   499     CSPVoiceCall* call = static_cast<CSPVoiceCall*>(&aCall);
       
   500     iCallArray->Remove( call );
       
   501     delete call;
       
   502     return KErrNone;
       
   503     }
       
   504     
       
   505 // ---------------------------------------------------------------------------
       
   506 // CSProvider::NewConferenceL
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 MCCPConferenceCall* CSProvider::NewConferenceL( 
       
   510                         const TUint32 /*aServiceId*/,
       
   511                         const MCCPConferenceCallObserver& aObserver )
       
   512     {   
       
   513     CSPLOGSTRING(CSPREQIN, "CSProvider::NewConferenceL <");
       
   514     if ( !iConferenceCall )
       
   515         {
       
   516         iConferenceCall = CSPConferenceCall::NewL( 
       
   517                                     iMobilePhone, *iCallArray, iServiceId );    
       
   518         iConferenceCall->AddObserverL( aObserver );
       
   519         }
       
   520     else 
       
   521         {
       
   522         CSPLOGSTRING(CSPERROR, "CSProvider::NewConferenceL()\
       
   523                 Error conference already exists");
       
   524         User::Leave( KErrAlreadyExists ); 
       
   525         }
       
   526     CSPLOGSTRING(CSPREQOUT, "CSProvider::NewConferenceL >");
       
   527     return iConferenceCall;
       
   528     }
       
   529 
       
   530 // ---------------------------------------------------------------------------
       
   531 // CSProvider::ReleaseConferenceCall
       
   532 // ---------------------------------------------------------------------------
       
   533 //
       
   534 TInt CSProvider::ReleaseConferenceCall( MCCPConferenceCall& aCall )
       
   535     {
       
   536     CSPLOGSTRING(CSPREQIN, "CSProvider::ReleaseConferenceCall");
       
   537     TInt ret( KErrNone ); 
       
   538     if ( &aCall == iConferenceCall )
       
   539         {
       
   540         delete iConferenceCall;
       
   541         iConferenceCall = NULL;
       
   542         }
       
   543     else
       
   544         {
       
   545         CSPLOGSTRING(CSPERROR, 
       
   546                 "CSProvider::ReleaseConferenceCall Error call not found");
       
   547         ret = KErrNotFound; 
       
   548         }
       
   549     return ret;
       
   550     }
       
   551     
       
   552 // ---------------------------------------------------------------------------
       
   553 // CSProvider::Uid
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 const TUid& CSProvider::Uid() const
       
   557     {
       
   558     CSPLOGSTRING2(CSPREQIN, "CSProvider::Uid uid: %d", iImplementationUid);
       
   559     return iImplementationUid;
       
   560     }
       
   561 
       
   562 // ---------------------------------------------------------------------------
       
   563 // CSProvider::Caps
       
   564 // ---------------------------------------------------------------------------
       
   565 //
       
   566 TUint32 CSProvider::Caps( ) const
       
   567     {
       
   568     CSPLOGSTRING(CSPREQIN, "CSProvider::Caps");
       
   569     return NULL;
       
   570     }
       
   571 
       
   572 // ---------------------------------------------------------------------------
       
   573 // CSProvider::DTMFProvider
       
   574 // ---------------------------------------------------------------------------
       
   575 //
       
   576 MCCPDTMFProvider* CSProvider::DTMFProviderL( 
       
   577             const MCCPDTMFObserver& aObserver )
       
   578     {
       
   579     CSPLOGSTRING2(CSPREQIN, 
       
   580             "CSProvider::DTMFProvider observer: %x", &aObserver);
       
   581     iDTMFProvider->AddObserverL( aObserver );
       
   582     CSPLOGSTRING(CSPREQIN, "CSProvider::DTMFProvider observer added");
       
   583     return iDTMFProvider;
       
   584     }
       
   585 
       
   586 // ---------------------------------------------------------------------------
       
   587 // CSProvider::ExtensionProvider
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 MCCPExtensionProvider* CSProvider::ExtensionProviderL( 
       
   591                             const MCCPExtensionObserver& /*aObserver*/)
       
   592     {
       
   593     CSPLOGSTRING(CSPREQIN, "CSProvider::ExtensionProvider");
       
   594     return NULL;
       
   595     }
       
   596     
       
   597 // ---------------------------------------------------------------------------
       
   598 // CSProvider::GetLifeTime
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 TBool CSProvider::GetLifeTime( TDes8& aLifeTimeInfo )
       
   602     {
       
   603     CSPLOGSTRING(CSPREQIN, "CSProvider::GetLifeTime");
       
   604     TInt err = iMmCustom.GetLifeTime( aLifeTimeInfo );    
       
   605     if ( err ) 
       
   606     	{
       
   607     	return EFalse;
       
   608     	}
       
   609    	return ETrue;
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------------------------
       
   613 // CSProvider::GetCSInfo
       
   614 // ---------------------------------------------------------------------------
       
   615 //
       
   616 TBool CSProvider::GetCSInfo( CSInfo& aCSInfo )
       
   617     {
       
   618     CSPLOGSTRING(CSPREQIN, "CSProvider::GetCSInfo");
       
   619     if ( iInitialized )
       
   620         {
       
   621         RMobilePhone::TMobilePhoneIdentityV1 imei;
       
   622         TRequestStatus reqStatus( KErrNone );
       
   623         
       
   624         CSPLOGSTRING(CSPREQOUT, 
       
   625                 "CSProvider::GetCSInfo request get phone id");
       
   626         iMobilePhone.GetPhoneId( reqStatus, imei );
       
   627         User::WaitForRequest( reqStatus );
       
   628         CSPLOGSTRING(CSPREQOUT, 
       
   629                 "CSProvider::GetCSInfo completed get phone id");
       
   630         
       
   631         if ( reqStatus.Int() != KErrNone )
       
   632              {
       
   633              imei.iSerialNumber.Zero();
       
   634              } 
       
   635              
       
   636         aCSInfo.iSerialNumber =  imei.iSerialNumber; 
       
   637         return reqStatus.Int() == KErrNone;
       
   638         }
       
   639         
       
   640     return iInitialized;
       
   641     }
       
   642         
       
   643 // ---------------------------------------------------------------------------
       
   644 // From MCSPIncomingCallObserver
       
   645 // CSProvider::IncomingCallArrived
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 void CSProvider::IncomingCallArrived( RMobileLine& aLine, TName aCallName,
       
   649                                       RCSPLineContainer::TCSPLineId aLineId )
       
   650     {
       
   651     RMobileLine::TLineInfo lineInfo;
       
   652     aLine.GetInfo( lineInfo );
       
   653     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived < line id   %d", aLineId );
       
   654     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived call name %S", &aCallName );
       
   655 
       
   656     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived answ %S", &lineInfo.iNameOfCallForAnswering );
       
   657     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived last %S", &lineInfo.iNameOfLastCallAdded );
       
   658     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived status %d", lineInfo.iStatus );
       
   659     CSPLOGSTRING2(CSPINT, "CSProvider::IncomingCallArrived hook %d", lineInfo.iHookStatus );
       
   660     
       
   661     // Find call by name.
       
   662     // In case CallAddedHandler has opened it and added to array, 
       
   663     // it should not be re-opened.    
       
   664     if ( !iCallArray->FindCall( aCallName ) )
       
   665         {
       
   666         TInt err(KErrUnknown);
       
   667         TUint32 serviceId( 0 );
       
   668         CCPCall::TCallType callType;
       
   669         CCCECallParameters::TCCELineType lineType;
       
   670         err = iLineContainer.ResolveCallInfo( aLineId, serviceId, callType, lineType );
       
   671         
       
   672         if ( !err )
       
   673             {
       
   674             CSPCall* call = NULL;
       
   675             TBuf8<KCCEBearerMaxSize> emptyBearer;
       
   676             TBuf<KCCESubAddressMaxSize> emptySubAddress;
       
   677             CCCECallParameters* callParameters = NULL; 
       
   678             TRAP_IGNORE( callParameters = CCCECallParameters::NewL() );
       
   679             if ( callParameters )
       
   680                 {
       
   681                 callParameters->SetServiceId(serviceId);
       
   682                 callParameters->SetCallType(callType);
       
   683                 callParameters->SetLineType(lineType);
       
   684                 callParameters->SetOrigin(CCCECallParameters::ECCECallOriginPhone);
       
   685             
       
   686                 if ( callType == CCPCall::ECallTypeCSVoice )
       
   687                     {
       
   688                     TRAP( err, call = CSPVoiceCall::NewL( aCallName, 
       
   689                                                     aLine, 
       
   690                                                     EFalse, 
       
   691                                                     *callParameters,
       
   692                                                     *this, 
       
   693                                                     EFalse ) );
       
   694                     }
       
   695                 else if ( callType == CCPCall::ECallTypeVideo )
       
   696                     {
       
   697                     TRAP( err, call = CSPVideoCall::NewL( aCallName,
       
   698                                                     aLine, 
       
   699                                                     EFalse, 
       
   700                                                     *callParameters,
       
   701                                                     *this ) );
       
   702                     }
       
   703                 else
       
   704                      {
       
   705                     CSPLOGSTRING2(CSPERROR, 
       
   706                        "CSProvider::IncomingCallArrived() unknown call type %d", err );
       
   707                     err = KErrUnknown;
       
   708                     }
       
   709                 
       
   710                 delete callParameters;
       
   711                 }
       
   712             
       
   713             if ( call && err == KErrNone )
       
   714                 {                
       
   715                 TInt appendError = iCallArray->Add( call );
       
   716                 CSPLOGSTRING2(CSPERROR, 
       
   717                       "CSProvider::IncomingCallArrived Appending call res %d", 
       
   718                         appendError);
       
   719                 
       
   720                 // Set audio handler for DevSound.
       
   721                 call->SetAudioHandler( iAudioHandler );
       
   722 
       
   723                 // Indicate incoming call for observer. 
       
   724                 TInt err = IndicateIncomingCall( call );
       
   725                 
       
   726                 if ( KErrNone == err && 
       
   727                      call->State() == MCCPCallObserver::ECCPStateAnswering )
       
   728                     {
       
   729                     // If call has proceeded already to Answering state (autoanswer) 
       
   730                     // a change notification needs to be sent. 
       
   731                     call->NotifyCallStateChangedETel( RMobileCall::EStatusAnswering );
       
   732                     }
       
   733                 
       
   734                 if ( err ) 
       
   735                     {
       
   736                     iCallArray->Remove( call );
       
   737                     delete call;
       
   738                     }
       
   739 
       
   740                 CSPLOGSTRING( CSPINT, "CSProvider::IncomingCallArrived Inform CCE OK" );
       
   741                 }
       
   742             else if ( call && err != KErrNone )
       
   743                 {
       
   744                 // Delete call, call array removal not needed.   
       
   745                 delete call; 
       
   746                 }
       
   747             else
       
   748                 {
       
   749                 CSPLOGSTRING2(CSPERROR, 
       
   750                   "CSProvider::IncomingCallArrived Call could not be created %d", err);                
       
   751                 }            
       
   752             }
       
   753         else
       
   754             {
       
   755             CSPLOGSTRING2(CSPERROR, "CSProvider::IncomingCallArrived ERROR Resolve call info err=%d", 
       
   756                                    err);
       
   757             }
       
   758         }
       
   759     CSPLOGSTRING(CSPINT, "CSProvider::IncomingCallArrived >");
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // CSProvider::GetCallWaitingL
       
   764 // ---------------------------------------------------------------------------
       
   765 //
       
   766 void CSProvider::GetCallWaitingL( const CCCECallParameters& aParams,
       
   767                                   TBool& aCallWaitingStatus )
       
   768     {
       
   769     CSPLOGSTRING(CSPINT, "CSProvider::GetCallWaitingL <");
       
   770     
       
   771     // If there are already connected or held call: call waiting must be 
       
   772     // already ON.    
       
   773     TInt callCount = iCallArray->GetCallCount();
       
   774     TInt activeCallCount = 0;
       
   775     for (TInt i = 0; i < callCount; i++)
       
   776         {
       
   777         switch (iCallArray->Get(i)->State())
       
   778             {
       
   779             case MCCPCallObserver::ECCPStateConnected:
       
   780                 {
       
   781                 activeCallCount++;
       
   782                 break;
       
   783                 }
       
   784             case MCCPCallObserver::ECCPStateHold:
       
   785                 {
       
   786                 activeCallCount++;
       
   787                 break;
       
   788                 }
       
   789             case MCCPCallObserver::ECCPStateAnswering:
       
   790                 {
       
   791                 activeCallCount++;
       
   792                 break;
       
   793                 }
       
   794             }
       
   795         }
       
   796     if ( activeCallCount > 0 )
       
   797         {
       
   798         // CW status must be ON, so it is not reasonable to ask it from network 
       
   799         aCallWaitingStatus = ETrue;
       
   800         }
       
   801     else 
       
   802         {
       
   803         iCwRequester->GetCallWaitingL( aParams, aCallWaitingStatus );
       
   804         }
       
   805     
       
   806     CSPLOGSTRING(CSPINT, "CSProvider::GetCallWaitingL >");
       
   807     }
       
   808     
       
   809 // ---------------------------------------------------------------------------
       
   810 // CSProvider::GetDiagnosticError
       
   811 // ---------------------------------------------------------------------------
       
   812 //
       
   813 TInt CSProvider::GetDiagnosticError( TName& aCallName )
       
   814     {
       
   815     CSPLOGSTRING2(CSPINT, 
       
   816             "CSProvider::GetDiagnosticError call name %S", &aCallName );
       
   817     return iMmCustom.GetDiagnosticInfo( aCallName );
       
   818     }
       
   819 
       
   820 // ---------------------------------------------------------------------------
       
   821 // CSProvider::NetworkSecurityStatus
       
   822 // ---------------------------------------------------------------------------
       
   823 //
       
   824 TBool CSProvider::NetworkSecurityStatus() const
       
   825     {
       
   826     CSPLOGSTRING(CSPINT, "CSProvider::NetworkSecurityStatus");
       
   827     return iCipheringStatusMonitor->NetworkSecurityStatus();
       
   828     }
       
   829 
       
   830 // ---------------------------------------------------------------------------
       
   831 // CSProvider::SecureSpecified
       
   832 // ---------------------------------------------------------------------------
       
   833 //
       
   834 TBool CSProvider::SecureSpecified() const
       
   835     {
       
   836     CSPLOGSTRING(CSPINT, "CSProvider::SecureSpecified");
       
   837     return iCipheringStatusMonitor->SecureSpecified();
       
   838     }
       
   839 
       
   840 // ---------------------------------------------------------------------------
       
   841 // Remote alerting tone playing status. Error situation is handled as no tone.
       
   842 // ---------------------------------------------------------------------------
       
   843 //
       
   844 RMmCustomAPI::TRemoteAlertingToneStatus CSProvider::GetRemoteAlertingToneStatus()
       
   845     {
       
   846     RMmCustomAPI::TRemoteAlertingToneStatus status;
       
   847     TInt err = iMmCustom.GetRemoteAlertingToneStatus( status );
       
   848     if ( err )
       
   849         {
       
   850         status = RMmCustomAPI::EUiNoTone;
       
   851         }
       
   852     CSPLOGSTRING2(CSPINT, 
       
   853         "CSProvider::GetRemoteAlertingToneStatus status: %d", status );
       
   854     return status;
       
   855     }
       
   856 
       
   857 // ---------------------------------------------------------------------------
       
   858 // CSProvider::SecuritySettingChanged
       
   859 // ---------------------------------------------------------------------------
       
   860 //
       
   861 void CSProvider::SecuritySettingChanged( TInt aValue )
       
   862     {
       
   863     CSPLOGSTRING2(CSPINT, 
       
   864         "CSProvider::SecuritySettingChanged value: %d", aValue);
       
   865     
       
   866     TInt callCount = iCallArray->GetCallCount();
       
   867     for (TInt i = 0; i < callCount; i++)
       
   868         {
       
   869         iCallArray->Get(i)->SecuritySettingChanged( aValue );
       
   870         }
       
   871     }
       
   872 
       
   873 // ---------------------------------------------------------------------------
       
   874 // CSProvider::CreateEtelConnectionsL
       
   875 // ---------------------------------------------------------------------------
       
   876 //
       
   877 void CSProvider::CreateEtelConnectionsL()
       
   878     {
       
   879     CSPLOGSTRING(CSPINT, "CSProvider::CreateEtelConnectionsL <");
       
   880     
       
   881     TInt errorCode( KErrNone );
       
   882     TInt phoneCount( 0 );
       
   883     RTelServer::TPhoneInfo phoneInfo;    
       
   884 
       
   885     //This method connects the client to the ETel Server. 
       
   886     //It must be used before any of other functions during a telephony session.
       
   887     __ASSERT_ALWAYS( iServer.Connect( KNbrOfMessageSlots ) 
       
   888         == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   889 
       
   890     //This method loads an ETel TSY module. mmtsy
       
   891     errorCode = iServer.LoadPhoneModule( KMmTsyModuleName );
       
   892     __ASSERT_ALWAYS( 
       
   893         errorCode == KErrNone || errorCode == KErrAlreadyExists, 
       
   894         Panic( ECSPPanicNoEtel ) );
       
   895     
       
   896     errorCode = iServer.SetExtendedErrorGranularity( 
       
   897         RTelServer::EErrorExtended );
       
   898     __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   899     
       
   900     errorCode = iServer.SetPriorityClientV2();
       
   901     CSPLOGSTRING2(CSPINT, "CSProvider:: Priority client: %d", errorCode );
       
   902     if( KErrAlreadyExists == errorCode )
       
   903     	{
       
   904     	CSPLOGSTRING(CSPOBJECT, "CSProvider::CreateEtelConnectionsL() Already initialized");
       
   905     	User::Leave( KErrAlreadyExists );
       
   906     	}
       
   907     //This method retrieves the total number of phones supported by all 
       
   908     //the currently loaded ETel (TSY) modules.
       
   909     errorCode = iServer.EnumeratePhones( phoneCount );
       
   910     __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   911 
       
   912     //This method retrieves information associated with the specified phone
       
   913     while ( phoneCount-- ) 
       
   914         { 
       
   915         errorCode = iServer.GetPhoneInfo( phoneCount, phoneInfo ); 
       
   916         __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   917 
       
   918         if ( phoneInfo.iName == KMmTsyPhoneName )
       
   919             {
       
   920             phoneCount = 0;
       
   921             }
       
   922         } 
       
   923  
       
   924     //This method opens a phone subsession by name, 
       
   925     //and starts the modem initialisation process.
       
   926     errorCode = iMobilePhone.Open( iServer, phoneInfo.iName );
       
   927     __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   928     
       
   929     iMobilePhone.SetEmergencyClient(RPhone::EEmergencyCSVoiceCallRequest);
       
   930     
       
   931     errorCode = iMobileConferenceCall.Open( iMobilePhone ); 
       
   932     __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   933     
       
   934     errorCode = iMmCustom.Open( iMobilePhone );
       
   935     __ASSERT_ALWAYS( errorCode == KErrNone, Panic( ECSPPanicNoEtel ) );
       
   936     
       
   937     iSsMonitor = new (ELeave) 
       
   938             CSPSupplementaryServicesMonitor( *this, iMmCustom );
       
   939     iSsMonitor->StartMonitoring();
       
   940     
       
   941     CSPLOGSTRING(CSPINT, "CSProvider::CreateEtelConnectionsL >");
       
   942     }
       
   943 
       
   944 // ---------------------------------------------------------------------------
       
   945 // CSProvider::HandleDivertOrBarring
       
   946 // Helper method.
       
   947 // ---------------------------------------------------------------------------
       
   948 //
       
   949 void CSProvider::HandleDivertOrBarring(TDesC& addr, RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode)
       
   950     {
       
   951     CSPLOGSTRING(CSPINT, "CSProvider::HandleDivertOrBarring <");
       
   952     switch ( aSsTypeAndMode.iSsType )
       
   953         {
       
   954         // MO unconditional diverts
       
   955         case RMmCustomAPI::ESsAllForwardings:
       
   956         case RMmCustomAPI::ESsForwUncond:
       
   957             {
       
   958             if( aSsTypeAndMode.iSsMode == RMmCustomAPI::ESsModeActive )
       
   959                 {                
       
   960                 iSsObserver->CallForwardEventOccurred( 
       
   961                             MCCPSsObserver::ECCPSsForwardUnconditionalModeActive,
       
   962                             addr );
       
   963                  }
       
   964              else
       
   965                 {
       
   966                 iSsObserver->CallForwardEventOccurred( 
       
   967                             MCCPSsObserver::ECCPSsForwardUnconditionalModeNotActive,
       
   968                             addr );                                
       
   969                 }
       
   970             break;
       
   971             }
       
   972         
       
   973         // MO conditional diverts
       
   974         case RMmCustomAPI::ESsForwBusy:
       
   975         case RMmCustomAPI::ESsForwNoReply:
       
   976         case RMmCustomAPI::ESsForwNoReach:
       
   977         case RMmCustomAPI::ESsAllCondForwardings:
       
   978             {
       
   979             if( aSsTypeAndMode.iSsMode == RMmCustomAPI::ESsModeActive )
       
   980                 {
       
   981                 iSsObserver->CallForwardEventOccurred( 
       
   982                             MCCPSsObserver::ECCPSsForwardConditionallyModeActive,
       
   983                             addr );
       
   984                 }
       
   985              else
       
   986                 {
       
   987                 iSsObserver->CallForwardEventOccurred( 
       
   988                             MCCPSsObserver::ECCPSsForwardConditionallyModeNotActive,
       
   989                             addr );
       
   990                 }
       
   991              break;
       
   992              }
       
   993         default:
       
   994             {
       
   995             // No handling needed
       
   996             }    
       
   997         }
       
   998     CSPLOGSTRING(CSPINT, "CSProvider::HandleDivertOrBarring >");
       
   999     }
       
  1000 
       
  1001 // ---------------------------------------------------------------------------
       
  1002 // CSProvider::InitializeCallParameters
       
  1003 // Initialises call parameters from SSSettings
       
  1004 // ---------------------------------------------------------------------------
       
  1005 //
       
  1006 void CSProvider::InitializeCallParameters( RMobileCall::TMobileCallParamsV7& aParams )
       
  1007     {
       
  1008     CSPLOGSTRING(CSPINT, "CSProvider::InitializeCallParameters <");
       
  1009     TInt defaultCug(0);
       
  1010     TInt cug(0);
       
  1011     
       
  1012     if( iSsSettingsHandler )
       
  1013         {
       
  1014         TRAP_IGNORE(iSsSettingsHandler->GetClirL( aParams.iIdRestrict ));
       
  1015         TRAP_IGNORE(iSsSettingsHandler->GetDefaultCugL( defaultCug ));
       
  1016         TRAP_IGNORE(iSsSettingsHandler->GetCugL( cug ));
       
  1017         }
       
  1018     
       
  1019     // This is always set to false thus allowing calls outside groups.
       
  1020     aParams.iCug.iSuppressOA = EFalse;    
       
  1021   
       
  1022     if ( cug >= 0 && cug != defaultCug ) // set group
       
  1023         {
       
  1024         // Invoke cug.
       
  1025         aParams.iCug.iCugIndex = cug; 
       
  1026         aParams.iCug.iExplicitInvoke = ETrue;
       
  1027         aParams.iCug.iSuppressPrefCug = ETrue;
       
  1028         }
       
  1029     else if ( cug == -1 ) // -1 supress
       
  1030         {
       
  1031         aParams.iCug.iCugIndex = defaultCug; 
       
  1032         aParams.iCug.iExplicitInvoke = ETrue;
       
  1033         aParams.iCug.iSuppressPrefCug = ETrue;
       
  1034         }
       
  1035     else    // default cug
       
  1036         {
       
  1037         aParams.iCug.iCugIndex = defaultCug; 
       
  1038         aParams.iCug.iExplicitInvoke = EFalse;
       
  1039         aParams.iCug.iSuppressPrefCug = EFalse;
       
  1040         }
       
  1041     CSPLOGSTRING(CSPINT, "CSProvider::InitializeCallParameters >");
       
  1042     }
       
  1043 
       
  1044 // ---------------------------------------------------------------------------
       
  1045 // CSProvider::InitializeDataCallParameters
       
  1046 // Initialises call parameters from SSSettings
       
  1047 // ---------------------------------------------------------------------------
       
  1048 //
       
  1049 void CSProvider::InitializeDataCallParameters( RMobileCall::TMobileHscsdCallParamsV1& aParams )
       
  1050     {
       
  1051     CSPLOGSTRING(CSPINT, "CSProvider::InitializeDataCallParameters <");
       
  1052     TInt defaultCug(0);
       
  1053     TInt cug(0);
       
  1054     
       
  1055     if( iSsSettingsHandler )
       
  1056         {
       
  1057         TRAP_IGNORE(iSsSettingsHandler->GetClirL( aParams.iIdRestrict ));
       
  1058         TRAP_IGNORE(iSsSettingsHandler->GetDefaultCugL( defaultCug ));
       
  1059         TRAP_IGNORE(iSsSettingsHandler->GetCugL( cug ));
       
  1060         }
       
  1061         
       
  1062     // This is always set to false thus allowing calls outside groups.
       
  1063     aParams.iCug.iSuppressOA = EFalse;
       
  1064   
       
  1065     if ( cug >= 0 && cug != defaultCug ) // set group
       
  1066         {
       
  1067         // Invoke cug.
       
  1068         aParams.iCug.iCugIndex = cug; 
       
  1069         aParams.iCug.iExplicitInvoke = ETrue;
       
  1070         aParams.iCug.iSuppressPrefCug = ETrue;
       
  1071         }
       
  1072     else if ( cug == -1 ) // -1 supress
       
  1073         {
       
  1074         aParams.iCug.iCugIndex = defaultCug; 
       
  1075         aParams.iCug.iExplicitInvoke = ETrue;
       
  1076         aParams.iCug.iSuppressPrefCug = ETrue;
       
  1077         }
       
  1078     else    // default cug
       
  1079         {
       
  1080         aParams.iCug.iCugIndex = defaultCug; 
       
  1081         aParams.iCug.iExplicitInvoke = EFalse;
       
  1082         aParams.iCug.iSuppressPrefCug = EFalse;
       
  1083         }
       
  1084     
       
  1085     CSPLOGSTRING(CSPINT, "CSProvider::InitializeDataCallParameters >");
       
  1086     }
       
  1087 
       
  1088 // ---------------------------------------------------------------------------
       
  1089 // CSProvider::IndicateClientCall
       
  1090 // This fucntion delivers call pointer to be managed by CCE.
       
  1091 // ---------------------------------------------------------------------------
       
  1092 //
       
  1093 void CSProvider::IndicateClientCall( MCCPCSCall* aCall )
       
  1094     {
       
  1095     CSPLOGSTRING2(CSPINT, "CSProvider::IndicateClientCall call: %x", aCall); 
       
  1096     iCCPObserver->MoCallCreated( *aCall );
       
  1097     CSPLOGSTRING(CSPINT, "CSProvider::IndicateClientCall Inform CCE OK"); 
       
  1098     }
       
  1099 
       
  1100 // ---------------------------------------------------------------------------
       
  1101 // CSProvider::IndicateIncomingCall
       
  1102 // This fucntion delivers call pointer to be managed by CCE.
       
  1103 // ---------------------------------------------------------------------------
       
  1104 //    
       
  1105 TInt CSProvider::IndicateIncomingCall( MCCPCSCall* aCall )
       
  1106     {
       
  1107     CSPLOGSTRING2(CSPINT, 
       
  1108             "CSProvider::IncomingCallArrived call: %x, inform CCE", aCall);
       
  1109     iCCPObserver->IncomingCall( aCall );
       
  1110     return KErrNone;
       
  1111     }
       
  1112     
       
  1113 // ---------------------------------------------------------------------------
       
  1114 // CSProvider::NotifyDataPortName
       
  1115 // ---------------------------------------------------------------------------
       
  1116 //      
       
  1117 void CSProvider::NotifyDataPortName( TName& aDataPortName )
       
  1118     {
       
  1119     CSPLOGSTRING2(CSPINT, 
       
  1120             "CSProvider::NotifyDataPortName name: %S", &aDataPortName);
       
  1121     iCCPObserver->DataPortName( aDataPortName );
       
  1122     }
       
  1123 
       
  1124 // ---------------------------------------------------------------------------
       
  1125 // CSProvider::HandleNotifyPSL
       
  1126 // From MCSPPubSubObserver.
       
  1127 // ---------------------------------------------------------------------------
       
  1128 //  
       
  1129 void CSProvider::HandleNotifyPSL( const TUid /*aUid*/, const TInt& /*aKey*/, 
       
  1130             const TRequestStatus& /*aStatus*/ )
       
  1131     {
       
  1132     CSPLOGSTRING(CSPINT, "CSProvider::HandleNotifyPSL");
       
  1133     HandleSIMStatusL();
       
  1134     }
       
  1135 
       
  1136 // ---------------------------------------------------------------------------
       
  1137 // CSProvider::RemoteAlertingToneStatusChanged
       
  1138 // From MCSPRemoteAlertingToneObserver.
       
  1139 // Notify all calls about the change. Call is responsible for 
       
  1140 // notifying observer if the status change was for the call.
       
  1141 // ---------------------------------------------------------------------------
       
  1142 // 
       
  1143 void CSProvider::RemoteAlertingToneStatusChanged(
       
  1144     RMmCustomAPI::TRemoteAlertingToneStatus aNewStatus )
       
  1145     {
       
  1146     CSPLOGSTRING(CSPINT, "CSProvider::RemoteAlertingToneStatusChanged");
       
  1147     for ( TInt i = 0; i < iCallArray->GetCallCount(); i++ )
       
  1148         {
       
  1149         CSPCall* call = iCallArray->Get( i );
       
  1150         if ( call )
       
  1151             {
       
  1152             call->RemoteAlertingToneStatusChanged( aNewStatus );
       
  1153             }
       
  1154         }
       
  1155     }
       
  1156 
       
  1157 // ---------------------------------------------------------------------------
       
  1158 // CSProvider::HandleSIMStatusL
       
  1159 // ---------------------------------------------------------------------------
       
  1160 //  
       
  1161 void CSProvider::HandleSIMStatusL()
       
  1162     {
       
  1163     CSPLOGSTRING(CSPINT, "CSProvider::HandleSIMStatusL");
       
  1164     if ( !iSsSettingsHandler && iSimStatusListener )
       
  1165         {
       
  1166         TInt simState( ESimNotReady );
       
  1167         TInt err = iSimStatusListener->Get( simState );
       
  1168         if ( err == KErrNone && simState == ESimUsable )
       
  1169             {
       
  1170             iSsSettingsHandler = CSPSsSettingsHandler::NewL( *iSsObserver );
       
  1171             }
       
  1172         else
       
  1173             {
       
  1174             CSPLOGSTRING2( CSPERROR, "CSProvider::HandleSIMStatusL, err: %d", err );
       
  1175             }    
       
  1176         }
       
  1177     
       
  1178     if ( iSsSettingsHandler && iSimStatusListener )
       
  1179         {
       
  1180         delete iSimStatusListener;
       
  1181         iSimStatusListener = NULL;
       
  1182         }
       
  1183     }
       
  1184 
       
  1185 // ---------------------------------------------------------------------------
       
  1186 // CSProvider::IndicateActiveHangup
       
  1187 // ---------------------------------------------------------------------------
       
  1188 //  
       
  1189 TInt CSProvider::IndicateActiveHangup( MCCPCallCommandHandling& aCall )
       
  1190     {
       
  1191     CSPLOGSTRING(CSPINT, "CSProvider::IndicateActiveHangup");
       
  1192     return iCallCommandHandler->IndicateActiveHangup( aCall );
       
  1193     }
       
  1194 
       
  1195 // ---------------------------------------------------------------------------
       
  1196 // CSProvider::IndicateHangupComplete
       
  1197 // ---------------------------------------------------------------------------
       
  1198 //  
       
  1199 TInt CSProvider::IndicateHangupComplete( MCCPCallCommandHandling& aCall )
       
  1200     {
       
  1201     CSPLOGSTRING(CSPINT, "CSProvider::IndicateHangupComplete");
       
  1202     return iCallCommandHandler->IndicateHangupComplete( aCall );
       
  1203     }
       
  1204 
       
  1205 // ---------------------------------------------------------------------------
       
  1206 // CSProvider::IndicateDialRequest
       
  1207 // ---------------------------------------------------------------------------
       
  1208 //  
       
  1209 TInt CSProvider::IndicateDialRequest( MCCPCallCommandHandling& aCall )
       
  1210     {
       
  1211     CSPLOGSTRING(CSPINT, "CSProvider::IndicateDialRequest");
       
  1212     return iCallCommandHandler->IndicateDialRequest( aCall );
       
  1213     }
       
  1214 
       
  1215 // ---------------------------------------------------------------------------
       
  1216 // CSProvider::IndicateAnswerRequest
       
  1217 // ---------------------------------------------------------------------------
       
  1218 //  
       
  1219 TInt CSProvider::IndicateAnswerRequest( MCCPCallCommandHandling& aCall )
       
  1220     {
       
  1221     CSPLOGSTRING(CSPINT, "CSProvider::IndicateAnswerRequest");
       
  1222     return iCallCommandHandler->IndicateAnswerRequest( aCall );
       
  1223     }
       
  1224     
       
  1225 // ---------------------------------------------------------------------------
       
  1226 // CSProvider::DontReportTerminationError
       
  1227 // ---------------------------------------------------------------------------
       
  1228 //  
       
  1229 TInt CSProvider::DontReportTerminationError()
       
  1230     {
       
  1231     CSPLOGSTRING(CSPINT, "CSProvider::DontReportTerminationError");
       
  1232    
       
  1233     TInt callCount = iCallArray->GetCallCount();
       
  1234     for ( TInt i = 0; i < callCount; i++ )
       
  1235         {
       
  1236         if ( iCallArray->Get(i)->State() == MCCPCallObserver::ECCPStateConnecting )
       
  1237             {
       
  1238             iCallArray->Get(i)->DontReportTerminationError();
       
  1239             return KErrNone;
       
  1240             }
       
  1241         }
       
  1242     return KErrNotFound;
       
  1243     }
       
  1244 
       
  1245 // ---------------------------------------------------------------------------
       
  1246 // CSProvider::NotifyStateChange
       
  1247 // ---------------------------------------------------------------------------
       
  1248 //
       
  1249 void CSProvider::NotifyStateChange( 
       
  1250             MCSPConferenceStatusObserver::TCSPConferenceState aStatus )
       
  1251     {
       
  1252     CSPLOGSTRING(CSPINT, "CSProvider::NotifyStateChange");
       
  1253     
       
  1254     if ( !iConferenceCall && 
       
  1255          aStatus == MCSPConferenceStatusObserver::ECSPConferenceActive )
       
  1256         {
       
  1257         TRAPD( err, iConferenceCall = CSPConferenceCall::NewL( 
       
  1258                                         iMobilePhone, *iCallArray, iServiceId ) );    
       
  1259         if ( KErrNone == err )
       
  1260             {
       
  1261             CSPLOGSTRING( CSPINT, "CSProvider::NotifyStateChange ext conference created" );
       
  1262             iCCPObserver->ConferenceCallCreated( *iConferenceCall );
       
  1263             }
       
  1264         else 
       
  1265             {
       
  1266             CSPLOGSTRING2(CSPERROR, "CSProvider::NotifyStateChange \
       
  1267                     ext conference creation error %d", err);
       
  1268             }
       
  1269         }
       
  1270    }
       
  1271     
       
  1272 // End of File
       
  1273