phoneengine/phonemodel/src/cpephonemodel.cpp
changeset 0 5f000ab63145
child 1 838b0a10d15b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:  This module contains the implementation of CPEPhoneModel class 
       
    15                  member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDE FILES
       
    21 #include "cpeactivestarter.h"
       
    22 #include "cpeexternaldatahandler.h"
       
    23 #include "cpeidlestatusmonitor.h"
       
    24 #include "cpemessagehandler.h"
       
    25 #include "cpephonemodel.h"
       
    26 #include "cpeservicehandling.h"
       
    27 #include "cpesimstatemonitor.h"
       
    28 #include "pepanic.pan"
       
    29 #include "cperemotepartyinfomediator.h"
       
    30 
       
    31 #include <ccce.h>
       
    32 #include <cpeaudiodata.h>
       
    33 #include <cpecallhandling.h>                   
       
    34 #include <cpecontacthandlingproxy.h>
       
    35 #include <cpeengineinfo.h>
       
    36 #include <cpegsmaudiodata.h>
       
    37 #include <cpeloghandlingproxy.h>
       
    38 #include <featmgr.h>
       
    39 #include <mccedtmfinterface.h>
       
    40 #include <mpecontacthandling.h>
       
    41 #include <mpeloghandling.h>
       
    42 
       
    43 // CONSTANTS
       
    44 const TInt KDriveProfile ( 6 );
       
    45 const TInt KPECallTimerOff = 0;
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS ====================
       
    48 
       
    49 // ================= MEMBER FUNCTIONS =======================
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CPEPhoneModel::CPEPhoneModel
       
    53 // C++ default constructor can NOT contain any code, that
       
    54 // might leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CPEPhoneModel::CPEPhoneModel(
       
    58         MEngineMonitor& aEngineMonitor      // The reference parameter for phone application communication
       
    59         ) : CPEPhoneModelIF(),
       
    60             iEngineMonitor( aEngineMonitor ),
       
    61             iStep( 0 )
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CPEPhoneModel::CPEPhoneModel
       
    67 // C++ default constructor can NOT contain any code, that
       
    68 // might leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CPEPhoneModel::CPEPhoneModel(
       
    72         MEngineMonitor& aEngineMonitor ,     // The reference parameter for phone application communication
       
    73         CPEAudioFactory& aAudioFactory
       
    74         ) : CPEPhoneModelIF(),
       
    75             iEngineMonitor( aEngineMonitor ),
       
    76             iStep( 0 ),
       
    77             iAudioFactory( &aAudioFactory )
       
    78     {
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CPEPhoneModel::ConstructL
       
    83 // EPOC default constructor can leave.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CPEPhoneModel::ConstructL()
       
    87     {
       
    88     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 1" );
       
    89     iEngineInfo = CPEEngineInfo::NewL();
       
    90     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 2" );
       
    91     User::LeaveIfError( iFsSession.Connect() );
       
    92     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 3" );
       
    93     FeatureManager::InitializeLibL();
       
    94     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 4" );
       
    95     iActiveStarter = CPEActiveStarter::NewL( this );
       
    96     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 5" );
       
    97     iActiveStarter->StartUp();
       
    98     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ConstructL: 6" );
       
    99     }// ConstructL
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CPEPhoneModel::NewL
       
   103 // Two-phased constructor.
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 CPEPhoneModel* CPEPhoneModel::NewL(
       
   107         MEngineMonitor& aEngineMonitor   //for phone application communication
       
   108         )
       
   109     {
       
   110     CPEPhoneModel* self = new ( ELeave ) CPEPhoneModel( aEngineMonitor );
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL();
       
   113     CleanupStack::Pop( self );
       
   114     return self;
       
   115     }// NewL
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CPEPhoneModel::NewL
       
   119 // Two-phased constructor for module testing.
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 CPEPhoneModel* CPEPhoneModel::NewL( 
       
   123     MEngineMonitor& aEngineMonitor,
       
   124     CPEAudioFactory& aAudioFactory )
       
   125     {
       
   126     CPEPhoneModel* self = 
       
   127         new ( ELeave ) CPEPhoneModel( aEngineMonitor, aAudioFactory );
       
   128     CleanupStack::PushL( self );
       
   129     self->ConstructL();
       
   130     CleanupStack::Pop( self );
       
   131     return self;
       
   132     }
       
   133 
       
   134 // Destructor
       
   135 CPEPhoneModel::~CPEPhoneModel()
       
   136     {   
       
   137     delete iMediatorCommunicationHandler;
       
   138     delete iSimChangedMonitor;
       
   139     delete iMessageHandler;
       
   140     delete iServiceHandling;
       
   141     delete iSimStatusMonitor;
       
   142     delete iContactHandling;
       
   143     delete iLogHandling;
       
   144     delete iAudioData;
       
   145     delete iCallHandling;
       
   146     delete iExternalDataHandler;
       
   147     delete iCallStackCutter;
       
   148 
       
   149     if ( iActiveStarter )
       
   150         {
       
   151         delete iActiveStarter;
       
   152         }
       
   153 
       
   154     FeatureManager::UnInitializeLib();
       
   155     iFsSession.Close();
       
   156     delete iEngineInfo;
       
   157     delete iConvergedCallEngine;
       
   158     if ( iIdleStatusMonitor )
       
   159         {
       
   160         delete iIdleStatusMonitor;
       
   161         } 
       
   162     }// ~CPEPhoneModel
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CPEPhoneModel::EngineInfo
       
   166 // Returns the pointer of the CPEEngineInfo object.
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 MPEEngineInfo* CPEPhoneModel::EngineInfo()
       
   170     {
       
   171     return iEngineInfo;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // Returns the pointer of the CPEEngineInfo object.
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 MPEDataStore* CPEPhoneModel::DataStore()
       
   179     {
       
   180     return iEngineInfo;
       
   181     }    
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CPEPhoneModel::DataStoreExt
       
   185 // Returns the pointer to CPEExternalDataHandler object
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 MPEExternalDataHandler* CPEPhoneModel::DataStoreExt()
       
   189     {
       
   190     return iExternalDataHandler;
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CPEPhoneModel::MediatorCommandHandler
       
   195 // Returns the pointer to CPERemotePartyInfoMediator object
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 CPERemotePartyInfoMediator* CPEPhoneModel::MediatorCommunicationHandler()
       
   199     {
       
   200     return iMediatorCommunicationHandler;
       
   201     }
       
   202 
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CPEPhoneModel::NameByMessageToPhoneEngine
       
   207 // Return message name, given the id of message.
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 #ifdef TEF_LOGGING_ENABLED
       
   211 TPtrC CPEPhoneModel::NameByMessageToPhoneEngine(
       
   212         const MPEPhoneModel::TPEMessagesToPhoneEngine aMessage
       
   213         ) const
       
   214     {
       
   215     switch ( aMessage )
       
   216         {
       
   217         // Audio messages                     1000 - 1999
       
   218         case MPEPhoneModel::EPEMessageSetAudioMute:
       
   219             return MESSAGE("EPEMessageSetAudioMute");
       
   220         case MPEPhoneModel::EPEMessageSetAudioVolume:
       
   221             return MESSAGE("EPEMessageSetAudioVolume");
       
   222         case MPEPhoneModel::EPEMessageSetAudioOutput:
       
   223             return MESSAGE("EPEMessageSetAudioOutput");
       
   224 
       
   225         // Call messages                      2000 - 2999
       
   226         case MPEPhoneModel::EPEMessageAnswer:
       
   227             return MESSAGE("EPEMessageAnswer");
       
   228         case MPEPhoneModel::EPEMessageClientDial:
       
   229             return MESSAGE("EPEMessageClientDial");
       
   230         case MPEPhoneModel::EPEMessageClientDialEmergency:
       
   231             return MESSAGE("EPEMessageClientDialEmergency");
       
   232         case MPEPhoneModel::EPEMessageContinueEmergencyCallInitialization:
       
   233             return MESSAGE("EPEMessageContinueEmergencyCallInitialization");
       
   234         case MPEPhoneModel::EPEMessageContinueDTMFSending:
       
   235             return MESSAGE("EPEMessageContinueDTMFSending");
       
   236         case MPEPhoneModel::EPEMessageDial:
       
   237             return MESSAGE("EPEMessageDial");
       
   238         case MPEPhoneModel::EPEMessagePlayDTMF:
       
   239             return MESSAGE("EPEMessagePlayDTMF");
       
   240         case MPEPhoneModel::EPEMessageEndDTMF:
       
   241             return MESSAGE("EPEMessageEndDTMF");
       
   242         case MPEPhoneModel::EPEMessagePhoneNumberEdited:
       
   243             return MESSAGE("EPEMessagePhoneNumberEdited");
       
   244         case MPEPhoneModel::EPEMessageRelease:
       
   245             return MESSAGE("EPEMessageRelease");
       
   246         case MPEPhoneModel::EPEMessageReleaseAll:
       
   247             return MESSAGE("EPEMessageReleaseAll");
       
   248         case MPEPhoneModel::EPEMessageReject:
       
   249             return MESSAGE("EPEMessageReject");
       
   250         case MPEPhoneModel::EPEMessageSendDTMF:
       
   251             return MESSAGE("EPEMessageSendDTMF");
       
   252         case MPEPhoneModel::EPEMessageStopDTMFSending:
       
   253             return MESSAGE("EPEMessageStopDTMFSending");
       
   254         case MPEPhoneModel::EPEMessageStopTonePlay:
       
   255             return MESSAGE("EPEMessageStopTonePlay");
       
   256         case MPEPhoneModel::EPEMessageAutomaticAnswerOff:
       
   257             return MESSAGE("EPEMessageAutomaticAnswerOff");
       
   258         case MPEPhoneModel::EPEMessageTerminateAllConnections:
       
   259             return MESSAGE("EPEMessageTerminateAllConnections");
       
   260         case MPEPhoneModel::EPEMessageSatCallRequestCompleted:
       
   261             return MESSAGE("EPEMessageSatCallRequestCompleted");
       
   262             
       
   263         case MPEPhoneModel::EPEMessageAcceptUnattendedTransfer:
       
   264             return MESSAGE("EPEMessageAcceptUnattendedTransfer");
       
   265         case MPEPhoneModel::EPEMessageRejectUnattendedTransfer:
       
   266             return MESSAGE("EPEMessageRejectUnattendedTransfer");
       
   267 
       
   268         case MPEPhoneModel::EPEMessageDoUnattendedTransfer:
       
   269             return MESSAGE("EPEMessageDoUnattendedTransfer");
       
   270         case MPEPhoneModel::EPEMessageForwardCallToAddress:
       
   271             return MESSAGE("EPEMessageForwardCallToAddress");
       
   272 
       
   273         // Contact messages                   3000 - 3999
       
   274 
       
   275         // Error messages                     4000 - 4999
       
   276 
       
   277         // Network messages                   5000 - 5999
       
   278 
       
   279         // Parser messages                    6000 - 6999
       
   280 
       
   281         // Security messages                  7000 - 7999
       
   282 
       
   283         // Settings and Shared Data messages  8000 - 8999
       
   284 
       
   285         // Service messages                   8000 - 8999
       
   286         case MPEPhoneModel::EPEMessageDisableService:
       
   287             return MESSAGE("EPEMessageDisableService");
       
   288         // Startup messages                   9000 - 9999
       
   289         case MPEPhoneModel::EPEMessagePEConstructionReady:
       
   290             return MESSAGE("EPEMessagePEConstructionReady");
       
   291 
       
   292         // Miscellaneous messages             10000 - 10999
       
   293         case MPEPhoneModel::EPEMessageCheckEmergencyNumber:
       
   294             return MESSAGE("EPEMessageCheckEmergencyNumber");
       
   295             
       
   296         // Variant messages                   11000 - 12999
       
   297         
       
   298         // Audio messages                         11000 - 11199
       
   299 
       
   300         // Call messages                          11200 - 11399
       
   301         case CPEPhoneModelIF::EPEMessageAddConferenceMember:
       
   302             return MESSAGE("EPEMessageAddConferenceMember");
       
   303         case CPEPhoneModelIF::EPEMessageCreateConference:
       
   304             return MESSAGE("EPEMessageCreateConference");
       
   305         case CPEPhoneModelIF::EPEMessageDropConferenceMember:
       
   306             return MESSAGE("EPEMessageDropConferenceMember");
       
   307         case CPEPhoneModelIF::EPEMessageGoOneToOne:
       
   308             return MESSAGE("EPEMessageGoOneToOne");
       
   309         case CPEPhoneModelIF::EPEMessageHangUpConference:
       
   310             return MESSAGE("EPEMessageHangUpConference");
       
   311         case CPEPhoneModelIF::EPEMessageHold:
       
   312             return MESSAGE("EPEMessageHold");
       
   313         case CPEPhoneModelIF::EPEMessageHoldConference:
       
   314             return MESSAGE("EPEMessageHoldConference");
       
   315         case CPEPhoneModelIF::EPEMessageResume:
       
   316             return MESSAGE("EPEMessageResume");
       
   317         case CPEPhoneModelIF::EPEMessageResumeConference:
       
   318             return MESSAGE("EPEMessageResumeConference");
       
   319         case CPEPhoneModelIF::EPEMessageSwap:
       
   320             return MESSAGE("EPEMessageSwap");
       
   321         case CPEPhoneModelIF::EPEMessageSwapConference:
       
   322             return MESSAGE("EPEMessageSwapConference");
       
   323         case CPEPhoneModelIF::EPEMessageTransfer:
       
   324             return MESSAGE("EPEMessageTransfer");
       
   325         case CPEPhoneModelIF::EPEMessageSwitchToVideoOrVoice:
       
   326             return MESSAGE("EPEMessageSwitchToVideoOrVoice");   
       
   327 
       
   328         // Contact messages                       11400 - 11599
       
   329 
       
   330         // Error messages                         11600 - 11799
       
   331 
       
   332         // Network messages                       11800 - 12999
       
   333 
       
   334         // Parser messages                        12000 - 12199
       
   335         case CPEPhoneModelIF::EPEMessageCancelSSstringCommand:
       
   336             return MESSAGE("EPEMessageCancelSSstringCommand");
       
   337 
       
   338         // Security messages                      12200 - 12399
       
   339 
       
   340         // Settings and Shared Data messages      12400 - 12599
       
   341 
       
   342         // Miscellaneous messages                 12600 - 12799
       
   343         
       
   344         default:
       
   345             TEFLOGSTRING2( KTAINT, "pe:cpephonemodel::namebymessagetophoneengine, unknown message = %d", static_cast<TInt>(aMessage));
       
   346             return MESSAGE("Unknown message");
       
   347         } 
       
   348     }
       
   349 #else
       
   350 TPtrC CPEPhoneModel::NameByMessageToPhoneEngine(
       
   351         const TInt /*aMessage*/ ) const
       
   352     {
       
   353     return MESSAGE("Not available");
       
   354     }
       
   355 #endif // TEF_LOGGING_ENABLED
       
   356 
       
   357 // -----------------------------------------------------------------------------
       
   358 // CPEPhoneModel::NameByMessageFromPhoneEngine
       
   359 // Return message name, given the id of message.
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 #ifdef TEF_LOGGING_ENABLED
       
   363 TPtrC CPEPhoneModel::NameByMessageFromPhoneEngine(
       
   364         const TInt aMessage ) const
       
   365     {
       
   366     switch ( aMessage )
       
   367         {
       
   368         // Audio messages                     1000 - 1999
       
   369         case MEngineMonitor::EPEMessageAudioDtmfEvent:
       
   370             return MESSAGE("EPEMessageAudioDtmfEvent");
       
   371         case MEngineMonitor::EPEMessageAudioDTMFPlayComplete:
       
   372             return MESSAGE("EPEMessageAudioDTMFPlayComplete");
       
   373         case MEngineMonitor::EPEMessageAudioOutputPreferenceChanged:
       
   374             return MESSAGE("EPEMessageAudioOutputPreferenceChanged");
       
   375         case MEngineMonitor::EPEMessageAudioMuteChanged:
       
   376             return MESSAGE("EPEMessageAudioMuteChanged");
       
   377         case MEngineMonitor::EPEMessageAudioOutputChanged:
       
   378             return MESSAGE("EPEMessageAudioOutputChanged");
       
   379         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
       
   380             return MESSAGE("EPEMessageAvailableAudioOutputsChanged");
       
   381         case MEngineMonitor::EPEMessageAudioPlayStopped:
       
   382             return MESSAGE("EPEMessageAudioPlayStopped");
       
   383         case MEngineMonitor::EPEMessageAudioVolumeChanged:
       
   384             return MESSAGE("EPEMessageAudioVolumeChanged");
       
   385 
       
   386         // Call messages                      2000 - 2999
       
   387         case MEngineMonitor::EPEMessageAnswer:
       
   388             return MESSAGE("EPEMessageAnswer");
       
   389         case MEngineMonitor::EPEMessageAnswering:
       
   390             return MESSAGE("EPEMessageAnswering");
       
   391         case MEngineMonitor::EPEMessageCallControlCapsChanged:
       
   392             return MESSAGE("EPEMessageCallControlCapsChanged");
       
   393         case MEngineMonitor::EPEMessageCallWaiting:
       
   394             return MESSAGE("EPEMessageCallWaiting");
       
   395         case MEngineMonitor::EPEMessageCallWaitingAnswered:
       
   396             return MESSAGE("EPEMessageCallWaitingAnswered");
       
   397         case MEngineMonitor::EPEMessageChangedCallDuration:
       
   398             return MESSAGE("EPEMessageChangedCallDuration");
       
   399         case MEngineMonitor::EPEMessageConferenceIdle:
       
   400             return MESSAGE("EPEMessageConferenceIdle");
       
   401         case MEngineMonitor::EPEMessageConferenceCapsChange:
       
   402             return MESSAGE("EPEMessageConferenceCapsChange");
       
   403         case MEngineMonitor::EPEMessageConnected:
       
   404             return MESSAGE("EPEMessageConnected");
       
   405         case MEngineMonitor::EPEMessageConnectedConference:
       
   406             return MESSAGE("EPEMessageConnectedConference");
       
   407         case MEngineMonitor::EPEMessageConnecting:
       
   408             return MESSAGE("EPEMessageConnecting");
       
   409         case MEngineMonitor::EPEMessageDialing:
       
   410             return MESSAGE("EPEMessageDialing");
       
   411         case MEngineMonitor::EPEMessageDialingError:
       
   412             return MESSAGE("EPEMessageDialingError");
       
   413         case MEngineMonitor::EPEMessageDisconnecting:
       
   414             return MESSAGE("EPEMessageDisconnecting");
       
   415         case MEngineMonitor::EPEMessageDisconnectingConference:
       
   416             return MESSAGE("EPEMessageDisconnectingConference");
       
   417         case MEngineMonitor::EPEMessageDTMFSendingAborted:
       
   418             return MESSAGE("EPEMessageDTMFSendingAborted");
       
   419         case MEngineMonitor::EPEMessageHeld:
       
   420             return MESSAGE("EPEMessageHeld");
       
   421         case MEngineMonitor::EPEMessageHeldConference:
       
   422             return MESSAGE("EPEMessageHeldConference");
       
   423         case MEngineMonitor::EPEMessageIdle:
       
   424             return MESSAGE("EPEMessageIdle");
       
   425         case MEngineMonitor::EPEMessageIncoming:
       
   426             return MESSAGE("EPEMessageIncoming");
       
   427         case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
       
   428             return MESSAGE("EPEMessageInitiatedEmergencyCall");
       
   429         case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
       
   430             return MESSAGE("EPEMessageInitiatedEmergencyWhileActiveVideo");
       
   431         case MEngineMonitor::EPEMessagePacketNetworkDetached:
       
   432             return MESSAGE("EPEMessagePacketNetworkDetached");
       
   433         case MEngineMonitor::EPEMessageRemoteBusy:
       
   434             return MESSAGE("EPEMessageRemoteBusy");            
       
   435         case MEngineMonitor::EPEMessageSendingDTMF:
       
   436             return MESSAGE("EPEMessageSendingDTMF");
       
   437         case MEngineMonitor::EPEMessageSentDTMF:
       
   438             return MESSAGE("EPEMessageSentDTMF");
       
   439         case MEngineMonitor::EPEMessageSentSSString:
       
   440             return MESSAGE("EPEMessageSentSSString");
       
   441         case MEngineMonitor::EPEMessageStoppedDTMF:
       
   442             return MESSAGE("EPEMessageStoppedDTMF");
       
   443         case MEngineMonitor::EPEMessageSwapped:
       
   444             return MESSAGE("EPEMessageSwapped");
       
   445         case MEngineMonitor::EPEMessageTransferDone:
       
   446             return MESSAGE("EPEMessageTransferDone");
       
   447         case MEngineMonitor::EPEMessageWentOneToOne:
       
   448             return MESSAGE("EPEMessageWentOneToOne");
       
   449         case MEngineMonitor::EPEMessageDisconnectingWithInband:
       
   450             return MESSAGE("EPEMessageDisconnectingWithInband");
       
   451         case MEngineMonitor::EPEMessageContinuingDTMFSending:
       
   452             return MESSAGE("EPEMessageContinuingDTMFSending");
       
   453         case MEngineMonitor::EPEMessageCallAdded:
       
   454             return MESSAGE("EPEMessageCallAdded");
       
   455         case MEngineMonitor::EPEMessageRemoteTerminated:
       
   456             return MESSAGE("EPEMessageRemoteTerminated");
       
   457         case MEngineMonitor::EPEMessageShowIMEI:
       
   458             return MESSAGE("EPEMessageShowIMEI");
       
   459         case MEngineMonitor::EPEMessageUnknown:
       
   460             return MESSAGE("EPEMessageUnknown");
       
   461         case MEngineMonitor::EPEMessagePromptSpeedDial:
       
   462             return MESSAGE("EPEMessagePromptSpeedDial");
       
   463         case MEngineMonitor::EPEMessageSpeedDialNotAssigned:
       
   464             return MESSAGE("EPEMessageSpeedDialNotAssigned");
       
   465         case MEngineMonitor::EPEMessageInvalidSpeedDial:
       
   466             return MESSAGE("EPEMessageInvalidSpeedDial"); 
       
   467         case MEngineMonitor::EPEMessageDataPortLoaned:
       
   468             return MESSAGE("EPEMessageDataPortLoaned");
       
   469             
       
   470         case MEngineMonitor::EPEMessageUnattendedTransferRequest:
       
   471             return MESSAGE("EPEMessageUnattendedTransferRequest");
       
   472         case MEngineMonitor::EPEMessageRemoteForwarding:
       
   473             return MESSAGE("EPEMessageRemoteForwarding");
       
   474         case MEngineMonitor::EPEMessageMovedPermanently:
       
   475             return MESSAGE("EPEMessageMovedPermanently");
       
   476         case MEngineMonitor::EPEMessageMultipleChoices:
       
   477             return MESSAGE("EPEMessageMultipleChoices");
       
   478         case MEngineMonitor::EPEMessageRemotePartyInfoChanged:
       
   479             return MESSAGE("EPEMessageRemotePartyInfoChanged");
       
   480         case MEngineMonitor::EPEMessageConnectingWithInband:
       
   481             return MESSAGE("EPEMessageConnectingWithInband");
       
   482 
       
   483         // Contact messages                   3000 - 3999
       
   484         case MEngineMonitor::EPEMessageThumbnailLoadingCompleted:
       
   485             return MESSAGE("EPEMessageThumbnailLoadingCompleted");
       
   486 
       
   487         // Error messages                     4000 - 4999
       
   488         case MEngineMonitor::EPEMessageError:
       
   489             return MESSAGE("EPEMessageError");
       
   490         case MEngineMonitor::EPEMessageAudioHandlingError:
       
   491             return MESSAGE("EPEMessageAudioHandlingError");
       
   492         case MEngineMonitor::EPEMessageCallHandlingError:
       
   493             return MESSAGE("EPEMessageCallHandlingError");
       
   494         case MEngineMonitor::EPEMessageContactHandlingError:
       
   495             return MESSAGE("EPEMessageContactHandlingError");
       
   496         case MEngineMonitor::EPEMessageLogHandlingError:
       
   497             return MESSAGE("EPEMessageLogHandlingError");
       
   498 
       
   499         case MEngineMonitor::EPEMessageServiceHandlingError:
       
   500             return MESSAGE("EPEMessageServiceHandlingError");
       
   501         // Network messages                   5000 - 5999
       
   502         case MEngineMonitor::EPEMessageCallSecureStatusChanged:
       
   503             return MESSAGE("EPEMessageCallSecureStatusChanged");
       
   504         case MEngineMonitor::EPEMessageNetworkRegistrationStatusChange:
       
   505             return MESSAGE("EPEMessageNetworkRegistrationStatusChange");
       
   506 
       
   507         // Parser messages                    6000 - 6999
       
   508         case MEngineMonitor::EPEMessageSSRequestFailed:
       
   509             return MESSAGE("EPEMessageSSRequestFailed");
       
   510 
       
   511         // Security messages                  7000 - 7999
       
   512         case MEngineMonitor::EPEMessageBadBarringPasswordChange:
       
   513             return MESSAGE("EPEMessageBadBarringPasswordChange");
       
   514         case MEngineMonitor::EPEMessageBadPin1Change:
       
   515             return MESSAGE("EPEMessageBadPin1Change");
       
   516         case MEngineMonitor::EPEMessageBadPin2Change:
       
   517             return MESSAGE("EPEMessageBadPin2Change");
       
   518         case MEngineMonitor::EPEMessageBadPin1Unblock:
       
   519             return MESSAGE("EPEMessageBadPin1Unblock");
       
   520         case MEngineMonitor::EPEMessageBadPin2Unblock:
       
   521             return MESSAGE("EPEMessageBadPin2Unblock");
       
   522         case MEngineMonitor::EPEMessageBarringPasswordChanged:
       
   523             return MESSAGE("EPEMessageBarringPasswordChanged");
       
   524         case MEngineMonitor::EPEMessageChangedSimLock:
       
   525             return MESSAGE("EPEMessageChangedSimLock");
       
   526         case MEngineMonitor::EPEMessageFailedChangeSimLock:
       
   527             return MESSAGE("EPEMessageFailedChangeSimLock");
       
   528         case MEngineMonitor::EPEMessageFailedNewPin1AndPin2NotEqual:
       
   529             return MESSAGE("EPEMessageFailedNewPin1AndPin2NotEqual");
       
   530         case MEngineMonitor::EPEMessageFailedSecurityCommandAlreadyActive:
       
   531             return MESSAGE("EPEMessageFailedSecurityCommandAlreadyActive");
       
   532         case MEngineMonitor::EPEMessagePin1Changed:
       
   533             return MESSAGE("EPEMessagePin1Changed");
       
   534         case MEngineMonitor::EPEMessagePin2Changed:
       
   535             return MESSAGE("EPEMessagePin2Changed");
       
   536         case MEngineMonitor::EPEMessagePin1Unblocked:
       
   537             return MESSAGE("EPEMessagePin1Unblocked");
       
   538         case MEngineMonitor::EPEMessagePin2Unblocked:
       
   539             return MESSAGE("EPEMessagePin2Unblocked");
       
   540 
       
   541         // Settings and Shared Data messages  8000 - 8999
       
   542         case MEngineMonitor::EPEMessageProfileChanged:
       
   543             return MESSAGE("EPEMessageProfileChanged");
       
   544 
       
   545         // Startup messages                   9000 - 9999
       
   546         case MEngineMonitor::EPEMessagePEConstructionReady:
       
   547             return MESSAGE("EPEMessagePEConstructionReady");
       
   548         case MEngineMonitor::EPEMessagePEConstructionFailed:
       
   549             return MESSAGE("EPEMessagePEConstructionFailed");
       
   550         case MEngineMonitor::EPEMessagePEConstructionTwoPhaseReady:
       
   551             return MESSAGE("EPEMessagePEConstructionTwoPhaseReady");     
       
   552 
       
   553         // Miscellaneous messages             10000 - 10999
       
   554         case MEngineMonitor::EPEMessageInValidEmergencyNumber:
       
   555             return MESSAGE("EPEMessageInValidEmergencyNumber");
       
   556         case MEngineMonitor::EPEMessageValidEmergencyNumber:
       
   557             return MESSAGE("EPEMessageValidEmergencyNumber");
       
   558         case MEngineMonitor::EPEMessagePhoneIdentityReady:
       
   559             return MESSAGE("EPEMessagePhoneIdentityReady");
       
   560         case MEngineMonitor::EPEMessageStartATDialing:
       
   561             return MESSAGE("EPEMessageStartATDialing");
       
   562         case MEngineMonitor::EPEMessageLogEventSaved:
       
   563             return MESSAGE("EPEMessageLogEventSaved");
       
   564         case MEngineMonitor::EPEMessageDoNotSendMe:
       
   565             return MESSAGE("EPEMessageDoNotSendMe");
       
   566             
       
   567         // Variant messages                   11000 - 12999
       
   568         
       
   569         // Audio messages                         11000 - 11199
       
   570 
       
   571         // Call messages                          11200 - 11399
       
   572         case MEngineMonitor::EPEMessageActiveBarring:
       
   573             return MESSAGE("EPEMessageActiveBarring");
       
   574         case MEngineMonitor::EPEMessageActiveCallForwarding:
       
   575             return MESSAGE("EPEMessageActiveCallForwarding");
       
   576         case MEngineMonitor::EPEMessageAddedConferenceMember:
       
   577             return MESSAGE("EPEMessageAddedConferenceMember");
       
   578         case MEngineMonitor::EPEMessageALSLineChanged:
       
   579             return MESSAGE("EPEMessageALSLineChanged");
       
   580         case MEngineMonitor::EPEMessageCallBarred:
       
   581             return MESSAGE("EPEMessageCallBarred");
       
   582         case MEngineMonitor::EPEMessageIncCallIsForw:
       
   583         	return MESSAGE("EPEMessageIncCallIsForw");
       
   584         case MEngineMonitor::EPEMessageIncCallForwToC:
       
   585         	return MESSAGE("EPEMessageIncCallForwToC");
       
   586         case MEngineMonitor::EPEMessageOutCallForwToC:
       
   587         	return MESSAGE("EPEMessageOutCallForwToC");
       
   588         case MEngineMonitor::EPEMessageForwardUnconditionalModeActive:
       
   589         	return MESSAGE( "EPEMessageForwardUnconditionalModeActive" );
       
   590         case MEngineMonitor::EPEMessageForwardConditionallyModeActive:
       
   591         	return MESSAGE( "EPEMessageForwardConditionallyModeActive" );
       
   592         case MEngineMonitor::EPEMessageDroppedConferenceMember:
       
   593             return MESSAGE("EPEMessageDroppedConferenceMember");
       
   594         case MEngineMonitor::EPEMessageGoingOneToOne:
       
   595             return MESSAGE("EPEMessageGoingOneToOne");
       
   596         case MEngineMonitor::EPEMessageIssuedUSSDRequest:
       
   597             return MESSAGE("EPEMessageIssuedUSSDRequest");
       
   598         case MEngineMonitor::EPEMessageRemoteCreatedConference:
       
   599             return MESSAGE("EPEMessageRemoteCreatedConference");
       
   600         case MEngineMonitor::EPEMessageRemoteHeld:
       
   601             return MESSAGE("EPEMessageRemoteHeld");
       
   602         case MEngineMonitor::EPEMessageRemoteResumed:
       
   603             return MESSAGE("EPEMessageRemoteResumed");
       
   604         case MEngineMonitor::EPEMessageShowVersion:
       
   605             return MESSAGE("EPEMessageShowVersion");
       
   606         case MEngineMonitor::EPEMessageTempClirSuppressUnsuccessful:
       
   607             return MESSAGE("EPEMessageTempClirSuppressUnsuccessful");
       
   608         case MEngineMonitor::EPEMessageTempClirActivationUnsuccessful:
       
   609             return MESSAGE("EPEMessageTempClirActivationUnsuccessful");
       
   610 
       
   611         // Contact messages                       11400 - 11599
       
   612 
       
   613         // Error messages                         11600 - 11799
       
   614 
       
   615         // Network messages                       11800 - 12999
       
   616         case MEngineMonitor::EPEMessageServiceEnabled:
       
   617             return MESSAGE("EPEMessageServiceEnabled");
       
   618         case MEngineMonitor::EPEMessageServiceEnabling:
       
   619             return MESSAGE("EPEMessageServiceEnabling");    
       
   620         case MEngineMonitor::EPEMessageNoService:
       
   621             return MESSAGE("EPEMessageNoService");  
       
   622         case MEngineMonitor::EPEMessageServiceDisabled:
       
   623             return MESSAGE("EPEMessageServiceDisabled");  
       
   624 
       
   625         // Parser messages                        12000 - 12199
       
   626         case MEngineMonitor::EPEMessageActivateRfsDeep:
       
   627             return MESSAGE("EPEMessageActivateRfsDeep");
       
   628         case MEngineMonitor::EPEMessageActivateRfsNormal:
       
   629             return MESSAGE("EPEMessageActivateRfsNormal");
       
   630         case MEngineMonitor::EPEMessageActivateWarrantyMode:
       
   631             return MESSAGE("EPEMessageActivateWarrantyMode");
       
   632         case MEngineMonitor::EPEMessageIssuedSSRequest:
       
   633             return MESSAGE("EPEMessageIssuedSSRequest");
       
   634         case MEngineMonitor::EPEMessageIssuingSSRequest:
       
   635             return MESSAGE("EPEMessageIssuingSSRequest");
       
   636 
       
   637         // Security messages                      12200 - 12399
       
   638 
       
   639         // Settings messages                      12400 - 12599
       
   640         case MEngineMonitor::EPEMessageBarringNotification:
       
   641             return MESSAGE("EPEMessageBarringNotification");
       
   642         case MEngineMonitor::EPEMessageClipStatusNotification:
       
   643             return MESSAGE("EPEMessageClipStatusNotification");
       
   644         case MEngineMonitor::EPEMessageClirStatusNotification:
       
   645             return MESSAGE("EPEMessageClirStatusNotification");
       
   646         case MEngineMonitor::EPEMessageCnapStatusNotification:
       
   647             return MESSAGE("EPEMessageCnapStatusNotification");
       
   648         case MEngineMonitor::EPEMessageColpStatusNotification:
       
   649             return MESSAGE("EPEMessageColpStatusNotification");
       
   650         case MEngineMonitor::EPEMessageColrStatusNotification:
       
   651             return MESSAGE("EPEMessageColrStatusNotification");
       
   652         case MEngineMonitor::EPEMessageForwardingNotification:
       
   653             return MESSAGE("EPEMessageForwardingNotification");
       
   654         case MEngineMonitor::EPEMessageVmbxNumberLine1Changed:
       
   655             return MESSAGE("EPEMessageVmbxNumberLine1Changed");
       
   656         case MEngineMonitor::EPEMessageVmbxNumberLine2Changed:
       
   657             return MESSAGE("EPEMessageVmbxNumberLine2Changed");
       
   658         case MEngineMonitor::EPEMessageWaitingNotification:
       
   659             return MESSAGE("EPEMessageWaitingNotification");
       
   660         case MEngineMonitor::EPEMessageAlsStatusChanged:
       
   661             return MESSAGE("EPEMessageAlsStatusChanged");
       
   662 
       
   663         // Miscellaneous messages                 12600 - 12799
       
   664         case MEngineMonitor::EPEMessageSIMChanged:
       
   665             return MESSAGE("EPEMessageSIMChanged");
       
   666         case MEngineMonitor::EPEMessageSIMStateChanged:
       
   667             return MESSAGE("EPEMessageSIMStateChanged");
       
   668         default:
       
   669             TEFLOGSTRING2( KTAINT, "pe: cpephonemodel::namebymessagefromphoneengine, unknown message = %d", static_cast<TInt>(aMessage));
       
   670             return MESSAGE("Unknown message");
       
   671         } 
       
   672     }
       
   673 #else
       
   674 TPtrC CPEPhoneModel::NameByMessageFromPhoneEngine(
       
   675         const TInt /*aMessage*/ ) const
       
   676     { 
       
   677     return MESSAGE("Not available");
       
   678     }
       
   679 #endif // TEF_LOGGING_ENABLED
       
   680 
       
   681 // -----------------------------------------------------------------------------
       
   682 // CPEPhoneModel::HandleMessage
       
   683 // Handles messages from phone application.
       
   684 // -----------------------------------------------------------------------------
       
   685 //
       
   686 void CPEPhoneModel::HandleMessage(
       
   687         const TInt aMessage ) 
       
   688     {
       
   689     TInt errorCode( ECCPErrorNone );
       
   690     #ifdef TEF_LOGGING_ENABLED
       
   691     TInt callId;
       
   692     callId = iEngineInfo->CallId(); // Get CallId
       
   693     TPtrC messageName = NameByMessageToPhoneEngine( aMessage );
       
   694     TEFLOGSTRING3( KTAINT, 
       
   695         "PE cpephonemodel::handlemessage, messageName=%s, callId=%d", 
       
   696         messageName.Ptr( ), 
       
   697         callId );
       
   698     #endif
       
   699     
       
   700     if ( !iMessageHandler )
       
   701         {
       
   702         TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::HandleMessage: Not ready" );
       
   703         return;
       
   704         }
       
   705 
       
   706     switch ( aMessage )
       
   707         {
       
   708         case MPEPhoneModel::EPEMessageTerminateAllConnections:
       
   709             errorCode = iMessageHandler->HandleTerminateAllConnections( );
       
   710             break;
       
   711         case MPEPhoneModel::EPEMessageDial:
       
   712         	//Make a dial request
       
   713             errorCode = iMessageHandler->HandleDialCall( EFalse );
       
   714             break;
       
   715         case MPEPhoneModel::EPEMessageReleaseAll: //Make HangUp requests to all calls
       
   716             errorCode = iMessageHandler->HandleReleaseAll( );            
       
   717             break;
       
   718         case MPEPhoneModel::EPEMessageRelease:     //Make HangUp request
       
   719         case CPEPhoneModelIF::EPEMessageHangUpConference:
       
   720             errorCode = iMessageHandler->HandleReleaseCall( );            
       
   721             break;
       
   722         case MPEPhoneModel::EPEMessageAnswer:                        //Make Answer request
       
   723             errorCode = iMessageHandler->HandleAnswerCall( EFalse );
       
   724             break;
       
   725         case MPEPhoneModel::EPEMessageReject:                        //Make Reject request
       
   726             errorCode = iMessageHandler->HandleRejectCall( );
       
   727             break;
       
   728         case MPEPhoneModel::EPEMessageSetAudioMute:                  //Make Mute microphone request
       
   729             iMessageHandler->HandleSetAudioMute( );
       
   730             break;
       
   731         case MPEPhoneModel::EPEMessageSetAudioOutput:
       
   732             errorCode = iMessageHandler->HandleSetAudioOutput();
       
   733             break;
       
   734         case MPEPhoneModel::EPEMessageSetAudioVolume:              //Sets audio volume.
       
   735             iMessageHandler->HandleSetAudioVolume( );
       
   736             break;
       
   737         case CPEPhoneModelIF::EPEMessageHold:                        //Make Hold request
       
   738         case CPEPhoneModelIF::EPEMessageHoldConference:
       
   739             errorCode = iMessageHandler->HandleHoldCall( );
       
   740             break;
       
   741         case CPEPhoneModelIF::EPEMessageSwap:                        //Make Swap request
       
   742         case CPEPhoneModelIF::EPEMessageSwapConference:
       
   743             errorCode = iMessageHandler->HandleSwapCalls( );
       
   744             break;
       
   745         case CPEPhoneModelIF::EPEMessageResume:         //Make Resume request
       
   746         case CPEPhoneModelIF::EPEMessageResumeConference:
       
   747             errorCode = iMessageHandler->HandleResumeCall( );
       
   748             break;
       
   749         case CPEPhoneModelIF::EPEMessageDropConferenceMember:        // Drop conference member.
       
   750             errorCode = iMessageHandler->HandleDropConferenceMember( );
       
   751             break;
       
   752         case CPEPhoneModelIF::EPEMessageTransfer:                    //Make Transfer request
       
   753             errorCode = iMessageHandler->HandleTransferCalls( );
       
   754             break;
       
   755         case CPEPhoneModelIF::EPEMessageCreateConference:            // Build conference call.
       
   756             errorCode = iMessageHandler->HandleBuildConferenceCall( );
       
   757             break;
       
   758         case CPEPhoneModelIF::EPEMessageGoOneToOne:          // Go one to one. 
       
   759             errorCode = iMessageHandler->HandleGoOneToOne( );
       
   760             break;
       
   761         case CPEPhoneModelIF::EPEMessageAddConferenceMember:            //Add call to conference request
       
   762             errorCode = iMessageHandler->HandleAddConferenceMember();
       
   763             break;
       
   764         case MPEPhoneModel::EPEMessageSendDTMF:                    //Send dtmf string
       
   765             errorCode = iMessageHandler->HandleSendDtmf( );
       
   766             break;
       
   767         case MPEPhoneModel::EPEMessagePlayDTMF:                        //Play DTMF
       
   768             TRAP( errorCode, iMessageHandler->HandlePlayDTMFL() );
       
   769             break;
       
   770         case MPEPhoneModel::EPEMessageEndDTMF:                        //End DTMF playing
       
   771             errorCode = iMessageHandler->HandleEndDTMF();
       
   772             break;
       
   773         case MPEPhoneModel::EPEMessageStopTonePlay:    //Stop InBand tone playing.
       
   774             iMessageHandler->HandleStopInbandTonePlay( );
       
   775             break;
       
   776         case MPEPhoneModel::EPEMessageClientDial:  //Make Dial request(Client originated)
       
   777             errorCode = iMessageHandler->HandleDialCall( ETrue );
       
   778             break;
       
   779         case MPEPhoneModel::EPEMessageClientDialEmergency:  
       
   780             //Make emergency dial request(Client originated)
       
   781             errorCode = iMessageHandler->HandleDialEmergencyCall( ETrue );
       
   782             break;
       
   783         case MPEPhoneModel::EPEMessageContinueEmergencyCallInitialization:
       
   784             //Make emergency dial request
       
   785             iMessageHandler->ContinueDialEmergency();
       
   786             break;
       
   787         case MPEPhoneModel::EPEMessageContinueDTMFSending:     //Continue DTMF sending.
       
   788             iMessageHandler->HandleContinueDtmfSending( ETrue );
       
   789             break;
       
   790         case MPEPhoneModel::EPEMessageStopDTMFSending: //Stop DTMF sending.
       
   791             iMessageHandler->HandleContinueDtmfSending( EFalse );
       
   792             break;
       
   793         case CPEPhoneModelIF::EPEMessageCancelSSstringCommand:
       
   794             errorCode = iMessageHandler->HandleCancelSSstringCommand( );
       
   795             break;
       
   796         case MPEPhoneModel::EPEMessagePhoneNumberEdited:
       
   797             TRAP( errorCode, iMessageHandler->HandlePhoneNumberEditedL( ) );
       
   798             break;
       
   799         case MPEPhoneModel::EPEMessageCheckEmergencyNumber:
       
   800             errorCode = iMessageHandler->HandleEmergencyCheck( );
       
   801             break;
       
   802         case MPEPhoneModel::EPEMessageAutomaticAnswerOff:
       
   803             iMessageHandler->HandleAutomaticAnswerOff( );
       
   804             break;
       
   805         case CPEPhoneModelIF::EPEMessageSetALSLine:
       
   806             iCallHandling->SetActiveLine();
       
   807             break;     
       
   808         case CPEPhoneModelIF::EPEMessageSwitchToVideoOrVoice:
       
   809             iEngineInfo->SetIsSwitchToOperationOngoing( ETrue );
       
   810             errorCode = iMessageHandler->HandleSwitchToVideoOrVoice( iEngineInfo->CallId() );
       
   811             break; 
       
   812         case MPEPhoneModel::EPEMessageSatCallRequestCompleted: 
       
   813             iMessageHandler->HandleSatCallRequestCompleted();
       
   814             break;
       
   815         case MPEPhoneModel::EPEMessageReplaceActive:
       
   816             errorCode = iMessageHandler->HandleReplaceActive();
       
   817             break;
       
   818         case MPEPhoneModel::EPEMessageAcceptUnattendedTransfer:
       
   819             errorCode = iMessageHandler->
       
   820                 HandleUnattendedTransferRequestResponse( ETrue );
       
   821             break;
       
   822         case MPEPhoneModel::EPEMessageRejectUnattendedTransfer:
       
   823             errorCode = iMessageHandler->
       
   824                 HandleUnattendedTransferRequestResponse( EFalse );
       
   825             break;
       
   826 
       
   827         case MPEPhoneModel::EPEMessageDoUnattendedTransfer:
       
   828             errorCode = iMessageHandler->HandleUnattendedTransfer();
       
   829             break;
       
   830         case MPEPhoneModel::EPEMessageForwardCallToAddress:
       
   831             errorCode = iMessageHandler->ForwardCallToAddress();
       
   832             break;
       
   833         case MPEPhoneModel::EPEMessageDisableService:
       
   834             iMessageHandler->HandleDisableService();
       
   835             break;
       
   836 
       
   837         default:
       
   838             errorCode = ECCPErrorNotFound;
       
   839             break;
       
   840         } 
       
   841 
       
   842     if( errorCode )
       
   843 	    {
       
   844 	    TPEErrorInfo errorInfo;
       
   845 	    errorInfo.iErrorCode = errorCode;
       
   846 	    errorInfo.iCallId = KPECallIdNotUsed;
       
   847 	    errorInfo.iErrorType = EPECcp;
       
   848  	    iEngineMonitor.HandleError( errorInfo );
       
   849 	    }
       
   850     }// HandleMessage
       
   851 
       
   852 // -----------------------------------------------------------------------------
       
   853 // CPEPhoneModel::SendMessage
       
   854 // Reroutes messages to the over loaded SendMessage( TInt aMessage, TInt aCallId ) method.
       
   855 // Method creates new callid and calls overloaded method.
       
   856 // -----------------------------------------------------------------------------
       
   857 //
       
   858 void CPEPhoneModel::SendMessage(
       
   859        const MEngineMonitor::TPEMessagesFromPhoneEngine aMessage )
       
   860     {    
       
   861     SendMessage( aMessage, KPECallIdNotUsed );
       
   862     }// SendMessage( 1 param )
       
   863 
       
   864 // -----------------------------------------------------------------------------
       
   865 // CPEPhoneModel::SendMessage
       
   866 // Sends messages to the phone application
       
   867 // Method sets call parameters to the CPEEngineInfo object and
       
   868 // Method reroutes messages to the phone application.
       
   869 // -----------------------------------------------------------------------------
       
   870 //
       
   871 void CPEPhoneModel::SendMessage( 
       
   872         const MEngineMonitor::TPEMessagesFromPhoneEngine aMessage, 
       
   873         const TInt aCallId )
       
   874     {
       
   875     TInt errorCode( ECCPErrorNone );
       
   876     TPEState callState;      
       
   877     //Save message to local variable so that it can be modified
       
   878     TInt message( aMessage );
       
   879 
       
   880     #ifdef TEF_LOGGING_ENABLED
       
   881     TPtrC messageName = NameByMessageFromPhoneEngine( 
       
   882         static_cast<MEngineMonitor::TPEMessagesFromPhoneEngine>( aMessage ) );
       
   883     TEFLOGSTRING3( KTAINT, 
       
   884         "PE cpephonemodel::sendmessage, messageName=%s, callId=%d"
       
   885         , messageName.Ptr( )
       
   886         , aCallId );
       
   887     #endif
       
   888     
       
   889     if ( iMessageHandler )
       
   890         {
       
   891         errorCode = ProcessMessage( aMessage, aCallId );          
       
   892         }    
       
   893         
       
   894     if ( DelayMessageSending( aMessage, aCallId ) )
       
   895         {
       
   896         message = KPEDontSendMessage;
       
   897         }    
       
   898     
       
   899     // Set Call State to the EngineInfo
       
   900     if ( CallIdCheck::IsConference( aCallId ))
       
   901         {
       
   902         callState = iCallHandling->GetCallState( aCallId );
       
   903         if ( callState > EPEStateUnknown && callState < EPEStateMaximumState )
       
   904             {   
       
   905             iEngineInfo->SetConferenceCallState( static_cast<TPEState>( callState ) );
       
   906             }
       
   907         else
       
   908             {
       
   909             iEngineInfo->SetConferenceCallState( EPEStateUnknown );
       
   910             }
       
   911         }
       
   912     if ( CallIdCheck::IsValid( aCallId ))
       
   913         {
       
   914         callState = iCallHandling->GetCallState( aCallId );
       
   915         if ( callState > EPEStateUnknown && callState < EPEStateMaximumState )
       
   916             {   
       
   917             iEngineInfo->SetCallState( static_cast<TPEState>( callState ), aCallId );
       
   918             }
       
   919         else
       
   920             {
       
   921             iEngineInfo->SetCallState( EPEStateUnknown, aCallId );
       
   922             }
       
   923         }
       
   924 
       
   925     if ( ( message == MEngineMonitor::EPEMessageIncoming ) )
       
   926         {
       
   927         if ( FeatureManager::FeatureSupported( KFeatureIdDriveMode ) )
       
   928             {
       
   929             //Check for Drive mode
       
   930             if ( iEngineInfo->ProfileId() == KDriveProfile )
       
   931                 {
       
   932                 //Drive mode is enabled, do not forward message
       
   933                 message = KPEDontSendMessage;
       
   934                 }
       
   935             }
       
   936         }
       
   937 
       
   938     if ( message == MEngineMonitor::EPEMessageChangedCallDuration )    
       
   939 	    {   
       
   940 	    TInt callTimerSetting( EFalse );
       
   941         // safe to ignore error code here, duration display equals to zero == off if it fails
       
   942         iExternalDataHandler->Get( EPECallDurationDisplaySetting, callTimerSetting );
       
   943         // Message EPEMessageChangedCallDuration send supressed, if duration display is OFF
       
   944         if ( callTimerSetting == KPECallTimerOff )
       
   945             {
       
   946             message = KPEDontSendMessage;
       
   947             }
       
   948 	    }
       
   949 
       
   950     //MessageHandler may return error code
       
   951     if ( errorCode != ECCPErrorNone && errorCode != KPEDontSendMessage )
       
   952         {
       
   953         #ifdef TEF_LOGGING_ENABLED
       
   954         TPtrC messageName2 = 
       
   955             NameByMessageFromPhoneEngine( 
       
   956             static_cast<MEngineMonitor::TPEMessagesFromPhoneEngine>( message ) );
       
   957         TEFLOGSTRING3( 
       
   958             KTAERROR,
       
   959             "PE cpephonemodel::sendmessage > iEngineMonitor.HandleError: messageName=%s, CallId=%d",
       
   960         messageName2.Ptr( ), aCallId );
       
   961         #endif
       
   962         TPEErrorInfo errorInfo;
       
   963     	errorInfo.iErrorCode = errorCode;
       
   964     	errorInfo.iCallId = aCallId;
       
   965         errorInfo.iErrorType = EPECcp;
       
   966         iEngineMonitor.HandleError( errorInfo );
       
   967         }
       
   968     else if ( message == MEngineMonitor::EPEMessageCallHandlingError )
       
   969 	    {
       
   970         TEFLOGSTRING2( 
       
   971             KTAERROR, 
       
   972             "PE cpephonemodel::sendmessage > iEngineMonitor.HandleError: messageName=EPEMessageCallHandlingError, CallId=%d"
       
   973         , aCallId );
       
   974 	    TPEErrorInfo errorInfo = iEngineInfo->ErrorInfo();
       
   975     	errorInfo.iCallId = aCallId;
       
   976     	errorInfo.iErrorType = EPECcp;
       
   977         iEngineMonitor.HandleError( errorInfo );
       
   978 	    }
       
   979     else if ( message == MEngineMonitor::EPEMessageServiceHandlingError )
       
   980         {
       
   981         TEFLOGSTRING( 
       
   982             KTAERROR, 
       
   983             "PE cpephonemodel::sendmessage > iEngineMonitor.HandleError: messageName=EPEMessageServiceHandlingError" );
       
   984         TPEErrorInfo errorInfo = iEngineInfo->ErrorInfo();
       
   985         errorInfo.iCallId = aCallId;
       
   986         errorInfo.iErrorType = EPECch;
       
   987         iEngineMonitor.HandleError( errorInfo );
       
   988 	    }
       
   989     else if ( message != KPEDontSendMessage && errorCode != KPEDontSendMessage )
       
   990         {
       
   991         // Map message for PhoneApplication, since it doesn't use 
       
   992         // EPEMessageDisconnectingWithInband message
       
   993         if( message == MEngineMonitor::EPEMessageDisconnectingWithInband )
       
   994             {
       
   995             message = MEngineMonitor::EPEMessageDisconnecting;
       
   996             }
       
   997         else if ( message == MEngineMonitor::EPEMessageConnectingWithInband )
       
   998             {
       
   999             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1000             message = MEngineMonitor::EPEMessageConnecting;
       
  1001             }
       
  1002         #ifdef TEF_LOGGING_ENABLED
       
  1003         TPtrC messageName2 = NameByMessageFromPhoneEngine
       
  1004             ( static_cast<MEngineMonitor::TPEMessagesFromPhoneEngine>( message ) );
       
  1005         TEFLOGSTRING3( 
       
  1006             KTAINT, 
       
  1007             "PE cpephonemodel::sendmessage > iEngineMonitor HandleMessage: messageName=%s, CallId=%d"
       
  1008         , messageName2.Ptr( ), aCallId );
       
  1009         #endif
       
  1010         
       
  1011         __ASSERT_DEBUG( 
       
  1012             ( KPEDontSendMessage <= message < KPEMessagesFromPhoneEngineGsmLast ),
       
  1013             Panic( EPEPanicIllegalCommand ) );
       
  1014         iEngineMonitor.HandleMessage( 
       
  1015             static_cast<MEngineMonitor::TPEMessagesFromPhoneEngine>( message ), 
       
  1016             aCallId );
       
  1017         }
       
  1018     }// SendMessage( 2 params )
       
  1019 
       
  1020 // -----------------------------------------------------------------------------
       
  1021 // CPEPhoneModel::ProcessMessage
       
  1022 // Process messages from the subsystems by passing them to message handlder.
       
  1023 // -----------------------------------------------------------------------------
       
  1024 TInt CPEPhoneModel::ProcessMessage( 
       
  1025         const MEngineMonitor::TPEMessagesFromPhoneEngine aMessage, 
       
  1026         const TInt aCallId )
       
  1027     {
       
  1028     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::ProcessMessage" );
       
  1029     TInt errorCode( ECCPErrorNone );
       
  1030     
       
  1031     //Get Message
       
  1032     switch ( aMessage )
       
  1033         {
       
  1034         case MEngineMonitor::EPEMessageDialing:
       
  1035             TRAP( errorCode, iMessageHandler->HandleDialingStateL( aCallId ) );
       
  1036             break;
       
  1037 
       
  1038         case MEngineMonitor::EPEMessageIncoming:
       
  1039             TRAP( errorCode, iMessageHandler->HandleIncomingCallL( aCallId ) );
       
  1040             // Since it is possible that incoming call interrupts switch to operation
       
  1041             // we need to reset this value.
       
  1042             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1043             break;
       
  1044 
       
  1045         case MEngineMonitor::EPEMessageAnswering:
       
  1046             if ( CallIdCheck::IsVideo( aCallId )  )
       
  1047                 {
       
  1048                 // Answering video calls
       
  1049                 iMessageHandler->HandleStopInbandTonePlay( );
       
  1050                 iMessageHandler->HandleAudioRouting( ETrue, aCallId  );
       
  1051                 }
       
  1052             else if ( iEngineInfo->CallType( aCallId ) == EPECallTypeCSVoice || 
       
  1053                     iEngineInfo->CallType( aCallId ) == EPECallTypeVoIP )
       
  1054                 {
       
  1055                 iMessageHandler->HandleAudioRouting( EFalse, aCallId);
       
  1056                 }
       
  1057                 
       
  1058             break;
       
  1059 
       
  1060         case MEngineMonitor::EPEMessageConnected:
       
  1061             // Switch to status needs to be set false here because some networks
       
  1062             // do not use connecting state.
       
  1063             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1064             iEngineInfo->SetResumeHeldCall( ETrue, aCallId );
       
  1065             if ( CallIdCheck::IsVoice( aCallId ))
       
  1066                 {
       
  1067                 errorCode = iMessageHandler->HandleConnectedState( aCallId );
       
  1068                 }
       
  1069             else if ( CallIdCheck::IsVideo( aCallId )) 
       
  1070                 {
       
  1071                 // Video call : for video call logging and duration
       
  1072                 errorCode = iMessageHandler->HandleVideoCallConnected( aCallId );
       
  1073                     
       
  1074                 }
       
  1075             // VoIP call audio routing happens when 'connected' message is
       
  1076             // received because of differences in VoIP and CS call audio
       
  1077             // activation.
       
  1078             if ( EPECallTypeVoIP == iEngineInfo->CallType( aCallId ) )
       
  1079                 {
       
  1080                 iMessageHandler->HandleAudioRouting( EFalse, aCallId );
       
  1081                 }
       
  1082                 
       
  1083             break;                        
       
  1084 
       
  1085         case MEngineMonitor::EPEMessageIdle:
       
  1086             if ( CallIdCheck::IsVoice( aCallId ))
       
  1087                 {
       
  1088                 errorCode = iMessageHandler->HandleVoiceCallIdleState( aCallId );
       
  1089                 }
       
  1090             else if ( CallIdCheck::IsVideo( aCallId )) 
       
  1091                 {
       
  1092                 // Video call : for video call logging and duration
       
  1093                 errorCode = iMessageHandler->HandleVideoCallIdle( aCallId );
       
  1094                 }
       
  1095             if ( errorCode == ECCPErrorNone && iEngineInfo->IsSwitchToOperationOngoing() )
       
  1096                 {
       
  1097                 errorCode = iMessageHandler->ContinueSwitchToCall( aCallId );
       
  1098                 }
       
  1099             break;
       
  1100 
       
  1101         case MEngineMonitor::EPEMessageRemoteBusy:
       
  1102             if ( CallIdCheck::IsVoice( aCallId ))
       
  1103                 {                
       
  1104                 // Set video/voice boolean to false because error occured.
       
  1105                 iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1106                 iMessageHandler->HandleCallHandlingError( aCallId, ETrue );                
       
  1107                 }
       
  1108             break;
       
  1109 
       
  1110         case MEngineMonitor::EPEMessageCallHandlingError:
       
  1111             // Set video/voice boolean to false because error occured.
       
  1112             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1113             iMessageHandler->HandleCallHandlingError( aCallId, EFalse );            
       
  1114             break;
       
  1115                 
       
  1116         case MEngineMonitor::EPEMessageAudioOutputPreferenceChanged:
       
  1117             errorCode = iMessageHandler->HandleRoutePreferenceChanged();
       
  1118             break;
       
  1119                     
       
  1120         case MEngineMonitor::EPEMessageConferenceIdle:
       
  1121             if ( CallIdCheck::IsConference( aCallId ) )
       
  1122                 {
       
  1123                 errorCode = iMessageHandler->HandleConferenceIdleState( aCallId );
       
  1124                 }
       
  1125             break;
       
  1126             
       
  1127         case MEngineMonitor::EPEMessageAnswer: // Automatic answer complete
       
  1128             errorCode = iMessageHandler->HandleAnswerCall( ETrue );
       
  1129             break;
       
  1130 
       
  1131         case MEngineMonitor::EPEMessageAlsStatusChanged:
       
  1132         case MEngineMonitor::EPEMessageSIMStateChanged:
       
  1133             iMessageHandler->HandleSimStateChanged( );
       
  1134             break;
       
  1135 
       
  1136         case MEngineMonitor::EPEMessagePEConstructionReady:
       
  1137             iMessageHandler->HandleStartUp( );
       
  1138             break;
       
  1139 
       
  1140         case MEngineMonitor::EPEMessageDisconnecting:
       
  1141             errorCode = iMessageHandler->HandleDisconnecting( aCallId );
       
  1142             break;
       
  1143 
       
  1144         case MEngineMonitor::EPEMessageDisconnectingWithInband:
       
  1145             errorCode = iMessageHandler->HandleDisconnectingWithInband( aCallId );
       
  1146             break;
       
  1147 
       
  1148         case MEngineMonitor::EPEMessageConnectedConference:
       
  1149             iEngineInfo->SetResumeHeldCall( ETrue, aCallId );
       
  1150             break;
       
  1151 
       
  1152         case MEngineMonitor::EPEMessageSentDTMF:
       
  1153             errorCode = iMessageHandler->HandleDtmfSent();
       
  1154             break;
       
  1155 
       
  1156         case MEngineMonitor::EPEMessageActivateWarrantyMode:
       
  1157             errorCode = iMessageHandler->HandleGetLifeTimerData( );
       
  1158             break;
       
  1159           
       
  1160         case MEngineMonitor::EPEMessageStartATDialing:
       
  1161             errorCode = iMessageHandler->HandleDialCall( EFalse );
       
  1162             iMessageHandler->HandleATDialingStarted( errorCode ? EFalse : ETrue );
       
  1163             break;
       
  1164 
       
  1165         // MO call connecting.
       
  1166         case MEngineMonitor::EPEMessageConnecting:
       
  1167             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1168             iEngineInfo->SetInbandTone( ECCPRemoteAlerting );
       
  1169             iAudioData->PlayInbandTone();
       
  1170             break;   
       
  1171         /*        
       
  1172         case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
       
  1173             iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1174             if ( iCallStackCutter )
       
  1175                 {
       
  1176                 delete iCallStackCutter;
       
  1177                 iCallStackCutter = NULL;
       
  1178                 }
       
  1179             TRAPD( err, iCallStackCutter = CIdle::NewL( CActive::EPriorityHigh ) );
       
  1180             if ( !err )
       
  1181                 {
       
  1182                 iCallBackMessage = aMessage; 
       
  1183                 iCallBackCallId  = aCallId;
       
  1184                 iCallStackCutter->Start( TCallBack( CallBackMessageSend , this ) );
       
  1185                 }
       
  1186             message = KPEDontSendMessage;
       
  1187             break;
       
  1188         */        
       
  1189         case MEngineMonitor::EPEMessageDroppedConferenceMember:
       
  1190             iMessageHandler->HandleDroppedConferenceMember();
       
  1191             break;
       
  1192                 
       
  1193         case MEngineMonitor::EPEMessageDTMFSendingAborted:
       
  1194             iEngineInfo->SetDtmfString( KNullDesC() );
       
  1195             break;
       
  1196 
       
  1197         case MEngineMonitor::EPEMessageServiceEnabled:
       
  1198             errorCode = iMessageHandler->HandleServiceEnabled();
       
  1199             break;
       
  1200             
       
  1201         case MEngineMonitor::EPEMessageRemotePartyInfoChanged:
       
  1202             iMessageHandler->HandleRemotePartyInfoChanged( );
       
  1203             break;    
       
  1204 
       
  1205         default:
       
  1206             break;
       
  1207             }    
       
  1208     
       
  1209     return errorCode;
       
  1210     }
       
  1211 
       
  1212 // -----------------------------------------------------------------------------
       
  1213 // CPEPhoneModel::DelayMessageSending
       
  1214 // Determines which messages needs to be delayed and delays sending them
       
  1215 // to Engine monitor.
       
  1216 // -----------------------------------------------------------------------------
       
  1217 TBool CPEPhoneModel::DelayMessageSending( 
       
  1218         const MEngineMonitor::TPEMessagesFromPhoneEngine aMessage,
       
  1219         const TInt aCallId )
       
  1220     {    
       
  1221     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::DelayMessageSending" );
       
  1222         
       
  1223     TBool sendingDelayed( EFalse );
       
  1224     
       
  1225     if ( MEngineMonitor::EPEMessageInitiatedEmergencyCall == aMessage )
       
  1226         {
       
  1227         iEngineInfo->SetIsSwitchToOperationOngoing( EFalse );
       
  1228         if ( iCallStackCutter )
       
  1229             {
       
  1230             delete iCallStackCutter;
       
  1231             iCallStackCutter = NULL;
       
  1232             }
       
  1233         TRAPD( err, iCallStackCutter = CIdle::NewL( CActive::EPriorityHigh ) );
       
  1234         if ( !err )
       
  1235             {
       
  1236             iCallBackMessage = aMessage; 
       
  1237             iCallBackCallId  = aCallId;
       
  1238             iCallStackCutter->Start( TCallBack( CallBackMessageSend , this ) );
       
  1239             }
       
  1240         sendingDelayed = ETrue;        
       
  1241         }
       
  1242     return sendingDelayed;
       
  1243     }
       
  1244 
       
  1245 // -----------------------------------------------------------------------------
       
  1246 // CPEPhoneModel::RecallSteps
       
  1247 // Method informs about failures in starting modules.
       
  1248 // -----------------------------------------------------------------------------
       
  1249 //
       
  1250 void CPEPhoneModel::RecallSteps()
       
  1251     {
       
  1252     SendMessage( MEngineMonitor::EPEMessagePEConstructionFailed );
       
  1253     iActiveStarter = NULL;
       
  1254     }
       
  1255 
       
  1256 // -----------------------------------------------------------------------------
       
  1257 // CPEPhoneModel::StepL
       
  1258 // Method starts and connects modules asynchronically.
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //
       
  1261 TBool CPEPhoneModel::StepL()
       
  1262     {
       
  1263     TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 1" );
       
  1264     TBool continueStepping = ETrue;
       
  1265 
       
  1266     switch ( iStep )
       
  1267         {
       
  1268         case CPEPhoneModel::EPEInitializeCceConnection:
       
  1269             {
       
  1270             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 2.1" );
       
  1271             iConvergedCallEngine = CCCE::NewL();
       
  1272             MCCEDtmfObserver* tempPointer( NULL );
       
  1273             MCCEDtmfInterface& tempReference = iConvergedCallEngine->DtmfInterfaceL( *tempPointer );
       
  1274             iDtmfInterface = &tempReference;
       
  1275             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 2.2" );
       
  1276             break;
       
  1277             }
       
  1278         case CPEPhoneModel::EPEExternalData:
       
  1279             {
       
  1280             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 3.1" );
       
  1281             iExternalDataHandler = CPEExternalDataHandler::NewL( *this );
       
  1282             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 3.2" );
       
  1283             break;
       
  1284             }
       
  1285         case CPEPhoneModel::EPECallHandling:
       
  1286             {
       
  1287             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 4.1" );
       
  1288             iCallHandling = CPECallHandling::NewL( *this, *iConvergedCallEngine, *iDtmfInterface  );
       
  1289             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 4.2" );
       
  1290             break;
       
  1291             }
       
  1292         case CPEPhoneModel::EPEAudioHandling:
       
  1293             {
       
  1294             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 5.1" );
       
  1295             if ( iAudioFactory )
       
  1296                 {
       
  1297                 iAudioData = CPEGsmAudioData::NewL( 
       
  1298                         *this, iFsSession, *iAudioFactory );
       
  1299                 }
       
  1300             else
       
  1301                 {
       
  1302                 iAudioData = CPEGsmAudioData::NewL( *this, iFsSession );
       
  1303                 }
       
  1304             iDtmfInterface->AddObserverL( *iAudioData );
       
  1305             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 5.2" );
       
  1306             break;
       
  1307             }
       
  1308         case CPEPhoneModel::EPELogHandlingPhaseOne:
       
  1309             {
       
  1310             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 6.1" );
       
  1311             // Create Log Handling proxy along with dummy implementation
       
  1312             iLogHandling = CPELogHandlingProxy::CreateFirstPhaseL();
       
  1313             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 6.2" );
       
  1314             break;
       
  1315             }
       
  1316         case CPEPhoneModel::EPEContactHandlingPhaseOne:
       
  1317             {
       
  1318             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 7.1" );
       
  1319             // Create Contact Handling proxy along with dummy implementation
       
  1320             iContactHandling = CPEContactHandlingProxy::CreateFirstPhaseL(); 
       
  1321             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 7.2" );
       
  1322             break;
       
  1323             }
       
  1324         case CPEPhoneModel::EPESimStateMonitor:
       
  1325             {
       
  1326             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 9.1" );
       
  1327             //started after message handler construction
       
  1328             iSimStatusMonitor = CPESimStateMonitor::NewL( 
       
  1329                 *this, 
       
  1330                 CPESimStateMonitor::EEventSimStatus );
       
  1331             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 9.2" );
       
  1332             break;
       
  1333             }
       
  1334         case CPEPhoneModel::EPEServiceHandling:
       
  1335             {
       
  1336             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 10.1" );
       
  1337             iServiceHandling = CPEServiceHandling::NewL( *this );
       
  1338             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 10.2" );
       
  1339             break;
       
  1340             }
       
  1341         case CPEPhoneModel::EPEMessageHandler:
       
  1342             {
       
  1343             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 11.1" );
       
  1344             iMessageHandler = CPEMessageHandler::NewL( *this, 
       
  1345                                                           *iCallHandling, 
       
  1346                                                           iEngineMonitor, 
       
  1347                                                           *iAudioData, 
       
  1348                                                           *iLogHandling, 
       
  1349                                                           *iContactHandling, 
       
  1350                                                           *iSimStatusMonitor,
       
  1351                                                           *iExternalDataHandler,
       
  1352                                                           *iServiceHandling,
       
  1353                                                           iFsSession );
       
  1354             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 11.2" );
       
  1355             break;
       
  1356             }
       
  1357         case CPEPhoneModel::EPESimChangedMonitor:
       
  1358             {
       
  1359             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 12.1" );
       
  1360             iSimChangedMonitor = CPESimStateMonitor::NewL( 
       
  1361                 *this, 
       
  1362                 CPESimStateMonitor::EEventSimChanged );
       
  1363             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 12.2" );
       
  1364             iSimChangedMonitor->Start();
       
  1365             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 12.3" );
       
  1366             break;
       
  1367             }
       
  1368         case CPEPhoneModel::EPESimStatusMonitorStart:
       
  1369             {
       
  1370             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 13.1" );
       
  1371             iSimStatusMonitor->Start();
       
  1372             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 13.2" );
       
  1373             break;
       
  1374             }
       
  1375         case CPEPhoneModel::EPELogHandlingPhaseTwo:
       
  1376             {
       
  1377             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 14.1" );
       
  1378             // Finalize Log Handling contruction
       
  1379             static_cast< CPELogHandlingProxy* > ( iLogHandling )->CreateSecondPhaseL( 
       
  1380                 *this, 
       
  1381                 iFsSession );
       
  1382             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 14.2" );
       
  1383             break;
       
  1384             }
       
  1385         case CPEPhoneModel::EPEContactHandlingPhaseTwo:
       
  1386             {
       
  1387             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 15.1" );
       
  1388             // Start Idle State monitor to finalize ContactHandling contruction
       
  1389             iIdleStatusMonitor = CPEIdleStatusMonitor::NewL (*this );     
       
  1390             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 15.2" );
       
  1391 
       
  1392             
       
  1393             break; 
       
  1394             }
       
  1395         case CPEPhoneModel::EPEMediatorCommandHandler:
       
  1396             {
       
  1397             TEFLOGSTRING( KTAOBJECT, "CPEPhoneModel::StepL: 16.1" );
       
  1398             // Start Mediator command listener
       
  1399             iMediatorCommunicationHandler = CPERemotePartyInfoMediator::NewL( *this );
       
  1400             
       
  1401             // This should be set after the last case
       
  1402             continueStepping = EFalse;
       
  1403             break; 
       
  1404             }
       
  1405         default:
       
  1406             {
       
  1407             Panic( EPEPanicIndexOutOfRange );
       
  1408             break;
       
  1409             }
       
  1410         }
       
  1411 
       
  1412     if ( !continueStepping )
       
  1413         {
       
  1414         // Note, if you add cases, you have to set 
       
  1415         // continueStepping = EFalse into the last case.
       
  1416         SendMessage( MEngineMonitor::EPEMessagePEConstructionReady );
       
  1417         iActiveStarter = NULL;
       
  1418         }
       
  1419     else
       
  1420         {
       
  1421         ++iStep;
       
  1422         }
       
  1423     return continueStepping;
       
  1424     }// StepL
       
  1425 
       
  1426 // -----------------------------------------------------------------------------
       
  1427 // Handle internal messages
       
  1428 // -----------------------------------------------------------------------------
       
  1429 //
       
  1430 void CPEPhoneModel::HandleInternalMessage( 
       
  1431     const TInt aMessage ) 
       
  1432     {
       
  1433     HandleMessage( aMessage );
       
  1434     }
       
  1435 
       
  1436 // -----------------------------------------------------------------------------
       
  1437 // ConstructContactHandlingPhaseTwoL
       
  1438 // -----------------------------------------------------------------------------
       
  1439 //
       
  1440 void CPEPhoneModel::ConstructContactHandlingPhaseTwoL()
       
  1441     {
       
  1442     TEFLOGSTRING( KTAOBJECT, 
       
  1443         "PE CPEPhoneModel::ConstructContactHandlingPhaseTwo, start" );
       
  1444     // Finalize Contact Handling contruction
       
  1445     static_cast< CPEContactHandlingProxy* >( iContactHandling )->
       
  1446         CreateSecondPhaseL( *this, iFsSession );
       
  1447     TEFLOGSTRING( KTAOBJECT, 
       
  1448         "PE CPEPhoneModel::ConstructContactHandlingPhaseTwo, complete" );
       
  1449     SendMessage( MEngineMonitor::EPEMessagePEConstructionTwoPhaseReady );   
       
  1450     // not need any more
       
  1451     delete iIdleStatusMonitor; 
       
  1452     iIdleStatusMonitor = NULL; 
       
  1453     }
       
  1454 
       
  1455 // -----------------------------------------------------------------------------
       
  1456 // CallBackSendMessage
       
  1457 // -----------------------------------------------------------------------------
       
  1458 //
       
  1459 TInt CPEPhoneModel::CallBackMessageSend( TAny* aSelf )
       
  1460     {
       
  1461     TEFLOGSTRING( KTAINT, 
       
  1462         "PE CPEPhoneModel::CallBackMessageSend, start" );
       
  1463       
       
  1464     CPEPhoneModel* self = static_cast<CPEPhoneModel*>( aSelf );
       
  1465   
       
  1466     self->iEngineMonitor.HandleMessage( self->iCallBackMessage, self->iCallBackCallId );
       
  1467    
       
  1468     return KErrNone;
       
  1469     }
       
  1470 
       
  1471 // End of File