phoneclientserver/callui/src/cauiengine/cauiengine.cpp
changeset 51 12bc758d6a02
parent 48 78df25012fda
child 53 25b8d29b7c59
equal deleted inserted replaced
48:78df25012fda 51:12bc758d6a02
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  Implementation of CallUIEngine.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "cauiengine.h" 
       
    21 #include    "cauiquery.h" // CCaUiQuery. 
       
    22 #include    <mcauireconnectqueryobserver.h>  // MCaUiReconnectQueryObserver.
       
    23 #include    <callui.rsg> // Resources. 
       
    24 #include    <cphcltdialer.h> // CPhcltDialer. 
       
    25 #include    <cphonecntfactory.h>
       
    26 #include    <cphcntsingleitemfetch.h>
       
    27 #include    <aiwinternaldialdata.h>
       
    28 #include    <aiwservicehandler.h> 
       
    29 #include    <cphcltextphonedialdata.h> // CPhCltExtPhoneDialData 
       
    30 
       
    31 #include    "callui.loc"                // Localized strings.
       
    32 
       
    33 #include    <stringloader.h> // String Loader. 
       
    34 #include    <aknnotewrappers.h>         // CAknInformationNote.
       
    35 #include    <akngloballistquery.h> // CAknGloballistQuery. 
       
    36 #include    <featmgr.h>                 // FeatureManager.
       
    37 
       
    38 #include    <aknglobalconfirmationquery.h> // Confirmation query.
       
    39 
       
    40 #include    <phcltutils.h> // Character removal. 
       
    41 #include    <aiwcommon.h> // AIW dialdata. 
       
    42 
       
    43 #include    <networkhandlingdomainpskeys.h> 
       
    44 #include    <e32property.h>             // Pub&Sub functionality.
       
    45 
       
    46 #include    "cauivoipextension.h" // VoIP/SCCP profile store 
       
    47 
       
    48 #include    <centralrepository.h>
       
    49 #include    <settingsinternalcrkeys.h> 
       
    50 #include     "cauilogger.h" // Call Ui Logger 
       
    51 #include    <aknmessagequerydialog.h> 
       
    52 #include    <aknglobalnote.h>
       
    53 #include    <mphcntstoreloader.h>
       
    54 #include    <mvpbkcontactstore.h> 
       
    55 
       
    56 #include "cauidialogs.h" 
       
    57 
       
    58 // CONSTANTS
       
    59 
       
    60 // GSM Network.
       
    61 const TInt KCaUiEngGsmNetwork = ENWNetworkModeGsm;
       
    62 // WCDMA Network.
       
    63 const TInt KCaUiEngWcdmaNetwork = ENWNetworkModeWcdma;
       
    64 
       
    65 
       
    66 _LIT( KCallTypeUriParam, "call-type" );
       
    67 _LIT( KCallTypeVideo, "video" );
       
    68 _LIT( KSemiColon, ";" );
       
    69 
       
    70 // ============================ MEMBER FUNCTIONS ===============================
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CCaUiEngine::CCaUiEngine
       
    74 // 
       
    75 // C++ default constructor can NOT contain any code, that might leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CCaUiEngine::CCaUiEngine()
       
    79 :   iResourceLoader( *CCoeEnv::Static() )
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCaUiEngine::ConstructL
       
    86 // 
       
    87 // Symbian 2nd phase constructor can leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CCaUiEngine::ConstructL()
       
    91     {
       
    92     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::ConstructL() Begin");
       
    93     // Sets up TLS, must be done before FeatureManager is used.
       
    94     FeatureManager::InitializeLibL();
       
    95 
       
    96     if ( CCoeEnv::Static() )
       
    97         {
       
    98         // Open CallUI resource file.
       
    99         TFileName* name = new ( ELeave ) TFileName( KCallUIResFile );
       
   100         CleanupStack::PushL( name );
       
   101         User::LeaveIfError( iResourceLoader.Open( *name ) );
       
   102         CleanupStack::PopAndDestroy( name );
       
   103         }
       
   104 
       
   105     // Get info is VoIP supported
       
   106     iVoIPProfileHandler = CCaUiVoIPExtension::NewL();
       
   107     iLongPressSet = ECaUiLongPressKeyNotSet;
       
   108 
       
   109     iServiceSelector = CConvergedServiceSelector::NewL();
       
   110 
       
   111     iDialogs = CCaUiDialogs::NewL( *this );
       
   112     
       
   113     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::ConstructL() Complete");
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CCaUiEngine::NewL
       
   119 // 
       
   120 // Two-phased constructor.
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CCaUiEngine* CCaUiEngine::NewL()
       
   124     {
       
   125     CCaUiEngine* self = new( ELeave ) CCaUiEngine;
       
   126     
       
   127     CleanupStack::PushL( self );
       
   128     self->ConstructL();
       
   129     CleanupStack::Pop();
       
   130 
       
   131     return self;
       
   132     }
       
   133 
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CCaUiEngine::~CCaUEngine
       
   137 // 
       
   138 // Destructor.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 CCaUiEngine::~CCaUiEngine()
       
   142     {
       
   143     delete iServiceSelector;
       
   144     
       
   145     // Delete VoIP extension if VoIP is supported
       
   146     if ( iVoIPProfileHandler )
       
   147         {
       
   148         delete iVoIPProfileHandler;
       
   149         }
       
   150     
       
   151     delete iEmergencyCall;      
       
   152     delete iContactSelector;
       
   153     delete iFactory;
       
   154     delete iVTSettingQuery;
       
   155 
       
   156     // Clear dial components.
       
   157     ClearDialContents();
       
   158 
       
   159     if ( CCoeEnv::Static() )
       
   160         {
       
   161         // Close resource loader.
       
   162         iResourceLoader.Close();
       
   163         }
       
   164     // Delete the menubuffer.
       
   165     delete iBuf;
       
   166     iBuf = NULL;
       
   167   
       
   168     delete iVTString;
       
   169     iVTString = NULL;
       
   170 
       
   171     delete iContactStoreLoader;
       
   172     delete iDialogs;
       
   173     
       
   174     // Frees the TLS! Must be done after FeatureManager is used.
       
   175     FeatureManager::UnInitializeLib();
       
   176     }
       
   177 
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CCaUiEngine::DialL
       
   181 // 
       
   182 // 
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CCaUiEngine::DialL(
       
   186     MCaUiDialResultObserver& aObserver,
       
   187     const TDesC8& aDialData,
       
   188     const TCaUiCallType aCallType )
       
   189     {
       
   190     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::DialL() Begin");
       
   191     iDialogs->SetReconfQueryOngoing( EFalse );
       
   192     // If iPhCltDialer and iDialData exist, 
       
   193     // destroy them and create new ones. This clears the dial data.
       
   194     ClearDialContents();
       
   195     iPhCltDialer = CPhCltExtPhoneBase::NewL( this );
       
   196     iObserver = &aObserver;
       
   197     iDialData = CPhCltExtPhoneDialData::NewL();
       
   198    
       
   199     CAiwInternalDialData* aiwDialData = CAiwInternalDialData::NewLC( aDialData );
       
   200     
       
   201     TPhCltTelephoneNumber  aiwTelNumber( aiwDialData->PhoneNumber() );
       
   202     HBufC* uriParams = FindAndRipURIParametersL( aiwTelNumber );
       
   203     CleanupStack::PushL( uriParams );
       
   204     aiwDialData->SetPhoneNumberL( aiwTelNumber );
       
   205     
       
   206 
       
   207     // ConvertDialDataL overwrites, if given in aDialData
       
   208     SetDialDataCallType( aCallType );
       
   209     
       
   210     // Convert AIW dial data to PhoneClient format.
       
   211     ConvertDialDataL( *aiwDialData  );
       
   212     
       
   213     // Check if there has been a long press of Send key
       
   214     if ( iDialData->InitiateCall() )
       
   215         {
       
   216         HandleLongPressOfSendKeyL();
       
   217         }
       
   218     
       
   219     iDialData->SetSendKeyPressed( 
       
   220         IsSendKeyPressed( aCallType, aiwDialData->CallType() ) );
       
   221     
       
   222 
       
   223     // By default call is made, unless user cancels the procedure.
       
   224     TBool createCall = ETrue;
       
   225 
       
   226     TPhCltCallType callType = iDialData->CallType();
       
   227     
       
   228     if ( aCallType == ECaUiCallTypeVoice )
       
   229         {
       
   230         iDialData->SetCallType( EPhCltVoice );
       
   231         }
       
   232     // If not forced video call is wanted, ask user to confirm it.
       
   233     // ECaUiCallTypeUnknown indicates that the call is not made from options menu.
       
   234     else if ( iDialData->CallType() == EPhCltVideo 
       
   235                             && aCallType == ECaUiCallTypeUnknown )
       
   236         {
       
   237         // Get preferred call-type from URI params, it will be passed to
       
   238         // list query and selected by default
       
   239         callType = CallTypeFromUriParams( *uriParams );
       
   240         // If query is canceled, then call is not made.
       
   241         createCall = iDialogs->LaunchCreateListQueryL( callType );
       
   242         // Set the call type, video must be forced
       
   243         if ( EPhCltVideo == callType )
       
   244             {
       
   245             iDialData->SetCallType( EPhCltForcedVideo );
       
   246             }
       
   247         else
       
   248             {
       
   249             iDialData->SetCallType( callType );
       
   250             }
       
   251         }
       
   252     else if ( aCallType == ECaUiCallTypeInternet )
       
   253         {
       
   254         iDialData->SetCallType( EPhCltCallVoIP );
       
   255         }
       
   256     else if ( aCallType == ECaUiCallTypeVideo )
       
   257         {
       
   258         // (Forced) video call must be created.
       
   259         iDialData->SetCallType( EPhCltForcedVideo );
       
   260         }
       
   261         
       
   262     CleanupStack::PopAndDestroy( uriParams );
       
   263     
       
   264     
       
   265     
       
   266     // If user did not Cancel query or query was not shown, 
       
   267     // perform the dial operation.
       
   268     if ( createCall )
       
   269         {
       
   270         if ( iDialData->ContactLink() != KNullDesC8() 
       
   271             && !aiwDialData->PhoneNumber().Length() )
       
   272             {
       
   273 
       
   274             TBool storeLoaded 
       
   275                 = LaunchContactStoreLoadingL( iDialData->ContactLink() );
       
   276             if ( storeLoaded )
       
   277                 {
       
   278                 // Launch address select.
       
   279                 // aCallType describes which selector is used. ( VoIP/PhoneNumber )
       
   280                 LaunchAddressSelectL( iDialData->ContactLink(), aCallType );
       
   281                 }
       
   282             }
       
   283         else 
       
   284             {
       
   285             PhoneClientDialL( NULL );
       
   286             }
       
   287         }
       
   288     else
       
   289         {
       
   290         HandleDialL( KErrCancel );
       
   291         }
       
   292     
       
   293     CleanupStack::PopAndDestroy( aiwDialData );
       
   294     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::DialL() End");
       
   295     }
       
   296 
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CCaUiEngine::LaunchNoNetSupNoteL
       
   300 // 
       
   301 // 
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 void CCaUiEngine::LaunchNoNetSupNoteL()
       
   305     {
       
   306 
       
   307     iDialogs->LaunchNoNetSupNoteL();
       
   308 
       
   309     }
       
   310 
       
   311 
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // CCaUiEngine::LaunchReconConfQueryL
       
   315 // 
       
   316 // 
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 void CCaUiEngine::LaunchReconConfQueryL( 
       
   320     MCaUiReconnectQueryObserver& aObserver,
       
   321     CPhCntMatcher* aPhCntMatcher,
       
   322     const TPtrC aPhoneNumber,
       
   323     const TBool aIncludeVideoCallOption )
       
   324     {
       
   325     // Empty pointer.
       
   326     TPtrC ptrc;
       
   327 
       
   328     iDialogs->LaunchReconConfQueryL(
       
   329         aObserver,
       
   330         aPhCntMatcher,
       
   331         aPhoneNumber,
       
   332         aIncludeVideoCallOption,
       
   333         ptrc );
       
   334     }
       
   335 
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CCaUiEngine::CancelReconConfQuery
       
   339 // 
       
   340 // 
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void CCaUiEngine::CancelReconConfQuery()
       
   344     {
       
   345 
       
   346     iDialogs->CancelReconConfQuery();
       
   347 
       
   348     }
       
   349 
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CCaUiEngine::LaunchNoteAndReconConfQueryL
       
   353 // 
       
   354 // 
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 void CCaUiEngine::LaunchNoteAndReconConfQueryL( 
       
   358     MCaUiReconnectQueryObserver& aObserver,
       
   359     CPhCntMatcher* aPhCntMatcher,
       
   360     const TPtrC aPhoneNumber,
       
   361     const TBool aIncludeVideoCallOption,
       
   362     const TPtrC aNoteText )
       
   363     {
       
   364     // Empty pointer.
       
   365     const TPtrC ptrc;
       
   366 
       
   367     iDialogs->LaunchNoteAndReconConfQueryL( 
       
   368         aObserver,
       
   369         aPhCntMatcher,
       
   370         aPhoneNumber,
       
   371         aIncludeVideoCallOption,
       
   372         aNoteText,
       
   373         ptrc );
       
   374 
       
   375     }
       
   376 
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // CCaUiEngine::CancelNoteAndReconConfQuery
       
   380 // 
       
   381 // 
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 void CCaUiEngine::CancelNoteAndReconConfQuery()
       
   385     {
       
   386 
       
   387     iDialogs->CancelNoteAndReconConfQuery();
       
   388 
       
   389     }
       
   390 
       
   391 // -----------------------------------------------------------------------------
       
   392 // CCaUiEngine::LaunchAddressSelectL
       
   393 // 
       
   394 // 
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 TBool CCaUiEngine::LaunchAddressSelectL(
       
   398     TDes& aTelNum, 
       
   399     const TInt aContactId,
       
   400     const TBool aVoIPAddressSelect )
       
   401     {
       
   402     TBool addressSelected( EFalse );
       
   403     TCaUiCallType callType( ECaUiCallTypeVoice );
       
   404 
       
   405     if ( aVoIPAddressSelect )
       
   406         {
       
   407         callType = ECaUiCallTypeInternet;
       
   408         }
       
   409     
       
   410     addressSelected = LaunchAddressSelectL( aTelNum, aContactId, callType );
       
   411 
       
   412     return addressSelected;
       
   413     }
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // CCaUiEngine::CancelAddressSelect
       
   417 // 
       
   418 // 
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 void CCaUiEngine::CancelAddressSelect()
       
   422     {
       
   423     }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 // From MPhCntStoreLoaderObserver.
       
   427 // CCaUiEngine::ContactStoreLoadingCompleted
       
   428 // -----------------------------------------------------------------------------
       
   429 //
       
   430 void CCaUiEngine::ContactStoreLoadingCompleted( 
       
   431         MVPbkContactStore* /*aStore*/, TInt aErrorCode )
       
   432     {
       
   433     TInt result( aErrorCode );
       
   434     
       
   435     if ( KErrNone == result )
       
   436         {
       
   437         TCaUiCallType caUiCallType( ECaUiCallTypeUnknown );
       
   438         ConvertPhCltCallType( iDialData->CallType(), caUiCallType );
       
   439         
       
   440         TRAP( result, 
       
   441             LaunchAddressSelectL( iDialData->ContactLink(), caUiCallType ) );
       
   442         }
       
   443     
       
   444     if ( KErrNone != result )
       
   445         {
       
   446         TRAP_IGNORE( HandleDialL( aErrorCode ) );
       
   447         }
       
   448     }
       
   449 
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CCaUiEngine::HandleDialL
       
   453 // 
       
   454 // 
       
   455 // -----------------------------------------------------------------------------
       
   456 //
       
   457 void CCaUiEngine::HandleDialL( const TInt aStatus )
       
   458     {
       
   459     if ( iObserver )
       
   460         {
       
   461         iObserver->HandleDialResultL( aStatus );
       
   462         }
       
   463     if ( !iDialogs->IsReconfQueryOngoing() )
       
   464         {
       
   465         ClearDialContents();
       
   466         }
       
   467     }
       
   468 
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // CCaUiEngine::OptionSelected
       
   472 // 
       
   473 // 
       
   474 // -----------------------------------------------------------------------------
       
   475 //
       
   476 void CCaUiEngine::OptionSelected( TCaUiReconType aReconType )
       
   477     {
       
   478     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::OptionSelected() Begin");
       
   479     if ( aReconType == ECallUiReconTypeVoice ||
       
   480          aReconType == ECallUiReconTypeVideo )
       
   481         {
       
   482         // Call is wanted to be made. Do it only if Dial data exists.
       
   483         if ( iDialData )
       
   484             {
       
   485           
       
   486             iDialogs->SetReconfQueryOngoing( EFalse );
       
   487 
       
   488             if( aReconType == ECallUiReconTypeVoice )
       
   489                 {
       
   490                 // Make sure that call type is correct, i.e. voice call.
       
   491                 iDialData->SetCallType( EPhCltVoice );
       
   492                 }
       
   493             else
       
   494                 {
       
   495                 // Make sure that call type is correct, i.e. video call.
       
   496                 iDialData->SetCallType( EPhCltVideo );
       
   497                 }
       
   498 
       
   499             TRAPD( err, iPhCltDialer->DialL( *iDialData ) );
       
   500             if( err )
       
   501                 {
       
   502                 CAUILOGSTRING2("CALLUI: >>>CCaUiEngine DialL error = %d", err );
       
   503                 }
       
   504             }
       
   505         }
       
   506     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::OptionSelected() End");
       
   507     }
       
   508 
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CCaUiEngine::ConvertDialDataL
       
   512 // 
       
   513 // 
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 
       
   517 void CCaUiEngine::ConvertDialDataL(
       
   518     const CAiwInternalDialData& aAiwDialData )
       
   519     {
       
   520     // Telephony number.
       
   521     iDialData->SetTelephoneNumber( aAiwDialData.PhoneNumber().Left( 
       
   522         iDialData->TelephoneNumber().MaxLength() ) );
       
   523 
       
   524     // Call type.
       
   525     CAiwDialData::TCallType aiwCallType = aAiwDialData.CallType();
       
   526     TPhCltCallType phCltCallType = EPhCltVoice;
       
   527 
       
   528     // After this the call type should be correct one.
       
   529     if ( aiwCallType == CAiwDialData::EAIWVideo )
       
   530         {
       
   531         phCltCallType = EPhCltVideo;
       
   532         iDialData->SetCallType( phCltCallType );
       
   533         }
       
   534     else if ( aiwCallType == CAiwDialData::EAIWForcedVideo )
       
   535         {
       
   536         phCltCallType = EPhCltForcedVideo;
       
   537         iDialData->SetCallType( phCltCallType );
       
   538         }
       
   539     else if ( aiwCallType == CAiwDialData::EAIWVoiP )
       
   540         {
       
   541         phCltCallType = EPhCltCallVoIP;
       
   542         iDialData->SetCallType( phCltCallType );
       
   543         }
       
   544     else if ( aiwCallType == CAiwDialData::EAIWForcedCS )
       
   545         {
       
   546         phCltCallType = EPhCltVoice; 
       
   547         iDialData->SetCallType( phCltCallType );
       
   548         }
       
   549     
       
   550 
       
   551     // Name.
       
   552     iDialData->SetNameL( aAiwDialData.Name().Left( 
       
   553         iDialData->Name().MaxLength() ) );
       
   554 
       
   555     // Contact link.
       
   556     iDialData->SetContactLinkL( aAiwDialData.ContactLink() );
       
   557 
       
   558     // Window group.
       
   559     iDialData->SetWindowGroup( aAiwDialData.WindowGroup() );
       
   560 
       
   561     // Redial.
       
   562     iDialData->SetRedial( aAiwDialData.Redial() );
       
   563 
       
   564     // Redial maximum duration.
       
   565     iDialData->SetRedialMaximumDuration( aAiwDialData.RedialMaximumDuration() );
       
   566 
       
   567     // Show number.
       
   568     iDialData->SetShowNumber( aAiwDialData.ShowNumber() );
       
   569 
       
   570     // Match.
       
   571     iDialData->SetAllowMatch( aAiwDialData.AllowMatch() );
       
   572 
       
   573     // End other calls.
       
   574     iDialData->SetEndOtherCalls( aAiwDialData.EndOtherCalls() );
       
   575 
       
   576     // Subaddress.
       
   577     iDialData->SetSubAddressL( aAiwDialData.SubAddress().Left( 
       
   578         iDialData->SubAddress().MaxLength() ) );
       
   579 
       
   580     // SAT call.
       
   581     iDialData->SetSATCall( aAiwDialData.SATCall() );
       
   582 
       
   583     // Bearer.
       
   584     iDialData->SetBearerL( aAiwDialData.Bearer().Left( 
       
   585         iDialData->Bearer().MaxLength() ) );
       
   586     
       
   587     // Set Long keypress activity. ETrue if client wants to initate 
       
   588     // voice/video call.
       
   589     iDialData->SetInitiateCall( aAiwDialData.InitiateCall() );
       
   590 
       
   591     if ( aAiwDialData.ServiceId() )
       
   592         {
       
   593         iDialData->SetServiceId( aAiwDialData.ServiceId() );
       
   594         }
       
   595     // Remove invalid chars.
       
   596     if( iDialData->CallType() != EPhCltCallVoIP )
       
   597 
       
   598         {
       
   599         TPhCltTelephoneNumber telnum;
       
   600         telnum.Zero();
       
   601         telnum = iDialData->TelephoneNumber();
       
   602         PhCltUtils::RemoveInvalidChars( telnum );
       
   603 
       
   604         iDialData->SetTelephoneNumber( telnum );
       
   605         }
       
   606     iDialData->SetUUIL( aAiwDialData.UUI() );
       
   607     }
       
   608 
       
   609 // -----------------------------------------------------------------------------
       
   610 // CCaUiEngine::ClearDialContents
       
   611 // 
       
   612 // 
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 void CCaUiEngine::ClearDialContents()
       
   616     {
       
   617     if ( iPhCltDialer )
       
   618         {
       
   619         delete iPhCltDialer;
       
   620         iPhCltDialer = NULL;
       
   621         }
       
   622 
       
   623     if ( iDialData )
       
   624         {
       
   625         delete iDialData;
       
   626         iDialData = NULL;
       
   627         }
       
   628 
       
   629     // Not owned, so just set to NULL.
       
   630     iObserver = NULL;
       
   631     }
       
   632 
       
   633 
       
   634 // -----------------------------------------------------------------------------
       
   635 // CCaUiEngine::IsVoIPProfiles()
       
   636 // 
       
   637 // 
       
   638 // -----------------------------------------------------------------------------
       
   639 //
       
   640 TBool CCaUiEngine::IsVoIPProfiles()
       
   641     {
       
   642     TBool isProfiles = EFalse;
       
   643 
       
   644     TRAP_IGNORE( isProfiles = iVoIPProfileHandler->IsVoIPProfilesL() );
       
   645       
       
   646     return isProfiles; 
       
   647     }
       
   648 
       
   649 
       
   650 // -----------------------------------------------------------------------------
       
   651 // CCaUiEngine::GetVoIPServiceIdsL()
       
   652 // 
       
   653 // 
       
   654 // -----------------------------------------------------------------------------
       
   655 //
       
   656 void CCaUiEngine::GetVoIPServiceIdsL( RIdArray& aVoipServiceIds ) const
       
   657     {
       
   658     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   659         {
       
   660         iVoIPProfileHandler->GetVoIPServiceIdsL( aVoipServiceIds );
       
   661         }
       
   662     }
       
   663 
       
   664 
       
   665 // -----------------------------------------------------------------------------
       
   666 // CCaUiEngine::GetVoipServiceNameL()
       
   667 // 
       
   668 // 
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CCaUiEngine::GetVoipServiceNameL( TServiceId aServiceId, TDes& aServiceName ) const
       
   672     {
       
   673     iVoIPProfileHandler->GetVoipServiceNameL( aServiceId, aServiceName );
       
   674     }
       
   675 
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // CCaUiEngine::LaunchAddressSelectL
       
   679 // 
       
   680 // 
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CCaUiEngine::LaunchAddressSelectL( 
       
   684     const TDesC8& aContactLink,
       
   685     const TCaUiCallType aCallType )
       
   686     {
       
   687     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::LaunchAddressSelectL() start");
       
   688     if ( !iFactory )
       
   689         {
       
   690         iFactory = CreateCntFactoryL();
       
   691         }
       
   692     if ( !iContactSelector ) 
       
   693         {
       
   694         iContactSelector = iFactory->CreateContactDataSelectionL();
       
   695         }
       
   696     
       
   697     CPhCntContactDataSelection::TCallType callType;
       
   698    
       
   699     // if aCallType is ECaUiCallTypeUnknown call is not intitated from Call ui menu
       
   700     // so have to use iDialDataCallType 
       
   701     if ( aCallType != ECaUiCallTypeUnknown )  
       
   702         {
       
   703         ConvertCaUiCallType( aCallType, callType );
       
   704         }
       
   705     else
       
   706         {
       
   707         ConvertDialDataCallType( callType );
       
   708         }
       
   709         
       
   710     iContactSelector->Cancel();
       
   711     iContactSelector->SelectPhoneNumberForCallL( aContactLink, 
       
   712                                                  callType, *this );
       
   713  
       
   714     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::LaunchAddressSelectL() end");
       
   715     }
       
   716 
       
   717     
       
   718 //------------------------------------------------------------------------------
       
   719 // CCaUiEngine::FindAndRipURIParametersL()
       
   720 // 
       
   721 // 
       
   722 // -----------------------------------------------------------------------------
       
   723 //
       
   724 HBufC* CCaUiEngine::FindAndRipURIParametersL( TDes& aNumber ) const
       
   725     {
       
   726     HBufC* buf = NULL;    
       
   727     TInt offset = aNumber.Locate( TChar( KSemiColon()[0] ) );
       
   728     if( offset > 0 ) // Separator is no allowed to be a first char
       
   729         {
       
   730         __ASSERT_ALWAYS( offset <= aNumber.Length(), 
       
   731             User::Leave( KErrGeneral ) );
       
   732         buf = aNumber.Mid( offset ).AllocL();         
       
   733         aNumber.SetLength( offset );           
       
   734         }
       
   735     else
       
   736         {
       
   737         buf = HBufC::NewL( 0 );
       
   738         }
       
   739     return buf;    
       
   740     }
       
   741    
       
   742 //------------------------------------------------------------------------------
       
   743 // CBrowserTelService::CallTypeFromUriParams()
       
   744 // 
       
   745 // 
       
   746 // -----------------------------------------------------------------------------
       
   747 //  
       
   748 TPhCltCallType CCaUiEngine::CallTypeFromUriParams( 
       
   749                                            const TDesC& aUriParams ) const
       
   750     {
       
   751     TPhCltCallType type( EPhCltVoice ); // Default type is voice call
       
   752     
       
   753     TPtrC value( ParamValue( KCallTypeUriParam, aUriParams ) );
       
   754     if( value.CompareF( KCallTypeVideo ) == 0 ) // URIs are case-insensitive.
       
   755         {
       
   756         type = EPhCltVideo;
       
   757         }
       
   758     // Otherwise return default type
       
   759     return type;
       
   760     }
       
   761     
       
   762 //------------------------------------------------------------------------------
       
   763 // CBrowserTelService::ParamValue()
       
   764 // 
       
   765 // 
       
   766 // -----------------------------------------------------------------------------
       
   767 //     
       
   768 TPtrC CCaUiEngine::ParamValue( const TDesC& aName, const TDesC& aUri ) const
       
   769     {  
       
   770     TInt startIndex = 0;
       
   771     TInt offset = 0;
       
   772     TPtrC pairTmp( KNullDesC()  );
       
   773     TPtrC ret( KNullDesC() );
       
   774     TBool found = EFalse;
       
   775 
       
   776     if( aName.Length() > 0 )
       
   777         {
       
   778         while( startIndex < aUri.Length() && !found )
       
   779             {
       
   780             pairTmp.Set( FindNextParamValuePair( aUri, startIndex ) );
       
   781             offset = pairTmp.FindF( aName ); // URIs are case-insensitive.
       
   782             if( offset >= 0 && 
       
   783               ( offset + aName.Length() + 1 < pairTmp.Length() ) )
       
   784                 {
       
   785                 ret.Set( pairTmp.Mid( offset + aName.Length() + 1 ) );
       
   786                 found = ETrue;
       
   787                 }
       
   788             }
       
   789         }
       
   790         
       
   791     return ret;    
       
   792     }    
       
   793    
       
   794 //------------------------------------------------------------------------------
       
   795 // CCaUiEngine::FindNextParamValuePair()
       
   796 // 
       
   797 // 
       
   798 // -----------------------------------------------------------------------------
       
   799 //   
       
   800 TPtrC CCaUiEngine::FindNextParamValuePair( const TDesC& aUri, 
       
   801                                            TInt& aStartIndex ) const
       
   802     {  
       
   803     TInt offset = 0;
       
   804     TPtrC tmp( KNullDesC() );
       
   805     TPtrC ret( KNullDesC() );
       
   806 
       
   807     tmp.Set( aUri.Mid( aStartIndex ) );
       
   808     // Search start mark for new paramter.
       
   809     offset = tmp.Find( KSemiColon );
       
   810     if( offset >= 0 )
       
   811         {
       
   812         if( aStartIndex + offset + KSemiColon().Length() < aUri.Length() ) 
       
   813             {
       
   814             // Move start index
       
   815             aStartIndex += offset + KSemiColon().Length();
       
   816         
       
   817             // Store descriptor after start mark
       
   818             tmp.Set( aUri.Mid( aStartIndex ) );
       
   819             
       
   820             // Search end mark (semi-colon)
       
   821             offset = tmp.Find( KSemiColon );
       
   822             if ( offset >= 0 )
       
   823                 {
       
   824                 // If end mark was found store the param/value pair
       
   825                 ret.Set( tmp.Left( offset ) );
       
   826                 }
       
   827             else
       
   828                 { 
       
   829                 // If end mark is not found, 
       
   830                 // the rest of descriptor belong to this parameter
       
   831                 ret.Set( tmp );
       
   832                 }      
       
   833             }
       
   834         }
       
   835     
       
   836     // Move start offset based on findings    
       
   837     if( ret.Length() )
       
   838         {
       
   839         aStartIndex += ret.Length();
       
   840         }
       
   841     else
       
   842         {
       
   843         aStartIndex = aUri.Length();
       
   844         }        
       
   845 
       
   846     return ret;
       
   847     }    
       
   848 
       
   849 // ---------------------------------------------------------
       
   850 //  CCaUiEngine::HandleFirstLongPressOfSendKeyL()
       
   851 // ---------------------------------------------------------
       
   852 //
       
   853 TBool CCaUiEngine::HandleFirstLongPressOfSendKeyL()
       
   854     {
       
   855     TBool set( EFalse );    
       
   856     
       
   857     TInt result = iDialogs->QueryVideoCallDefaultActionL();
       
   858        
       
   859     // Check user decision and set return value accordingly     
       
   860     switch ( result )
       
   861         {
       
   862         case EAknSoftkeyYes: // from avkon.hrh
       
   863             set = ETrue;
       
   864             break;
       
   865         case EAknSoftkeyNo:            
       
   866             set = EFalse;
       
   867             break;                                                           
       
   868         default:        
       
   869             set = EFalse;
       
   870             break;
       
   871         }    
       
   872     return set;
       
   873     }
       
   874 
       
   875 // ---------------------------------------------------------
       
   876 //  CCaUiEngine::HandleLongPressOfSendKeyL()
       
   877 // ---------------------------------------------------------
       
   878 //    
       
   879 void CCaUiEngine::HandleLongPressOfSendKeyL()
       
   880     {
       
   881         
       
   882     // Check if the setting is already ON -> make a video call
       
   883     if ( iLongPressSet == ECaUiLongPressKeyInUse )
       
   884         {
       
   885         // ON -> initiate a video call 
       
   886         // (Forced) video call must be created
       
   887         iDialData->SetCallType( EPhCltForcedVideo );
       
   888         }
       
   889     // Check if the setting is already OFF -> make a voice call
       
   890     else if ( iLongPressSet == ECaUiLongPressKeyNotInUse )
       
   891         {
       
   892         // OFF -> initiate a voice call
       
   893         // Voice call must be created
       
   894         iDialData->SetCallType( EPhCltVoice );    
       
   895         }
       
   896     // If the setting has never been set, check what the user wants to do
       
   897     else if ( iLongPressSet == ECaUiLongPressKeyNotSet )
       
   898         {
       
   899            // Ask from the user how long press of Send key should be handled
       
   900         TBool set = HandleFirstLongPressOfSendKeyL();
       
   901     
       
   902         if ( set )
       
   903             {
       
   904             // User answered YES -> initiate a video call
       
   905             // (Forced) video call must be created
       
   906             iLongPressSet = ECaUiLongPressKeyInUse;
       
   907             iDialData->SetCallType( EPhCltForcedVideo );
       
   908             }
       
   909         else
       
   910             {
       
   911             // User answered NO -> initiate a voice call
       
   912             // Voice call must be created
       
   913             iLongPressSet = ECaUiLongPressKeyNotInUse; 
       
   914             iDialData->SetCallType( EPhCltVoice );
       
   915             }              
       
   916         }        
       
   917     }
       
   918 
       
   919 // ---------------------------------------------------------
       
   920 //  CCaUiEngine::SelectionDone()
       
   921 // ---------------------------------------------------------
       
   922 //     
       
   923 void CCaUiEngine::SelectionDone( CPhCntSelectedData* aContactData, 
       
   924                                   TInt aErrorCode )
       
   925     {
       
   926     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::SelectionDone() Start");
       
   927     CAUILOGSTRING2("CALLUI: >>>SelectionDone() ECode = %d", aErrorCode );
       
   928     if ( aErrorCode == KErrNone )
       
   929         {
       
   930         TPhCltTelephoneNumber phoneNumber;
       
   931         HBufC8* fieldLink = NULL;
       
   932         
       
   933         if ( iDialData->TelephoneNumber() == KNullDesC )
       
   934             {
       
   935             phoneNumber = aContactData->Data();
       
   936 
       
   937             // Do not remove illegal chars if call type is VOIP and
       
   938             // call is made to a voip number
       
   939             if ( !( EPhCltCallVoIP == iDialData->CallType() &&
       
   940                     aContactData->NumberType()==MPhCntMatch::EVoipNumber ) )
       
   941                 {                    
       
   942                 PhCltUtils::RemoveInvalidChars( phoneNumber );
       
   943                 }                                    
       
   944             iDialData->SetTelephoneNumber( phoneNumber );
       
   945             }
       
   946         if ( aContactData->FieldLink().Length() > 0 )
       
   947             {
       
   948             fieldLink = aContactData->FieldLink().Alloc();
       
   949             }
       
   950         
       
   951         TRAP( aErrorCode, PhoneClientDialL( fieldLink ) );
       
   952       
       
   953         delete fieldLink;
       
   954         fieldLink = NULL;
       
   955         }
       
   956         
       
   957     if ( aErrorCode != KErrNone )
       
   958         {
       
   959         TRAP_IGNORE( HandleDialL( aErrorCode ) );
       
   960         }            
       
   961     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::SelectionDone() End");
       
   962     }
       
   963 // ---------------------------------------------------------
       
   964 //  CCaUiEngine::PhoneClientDialL()
       
   965 // ---------------------------------------------------------
       
   966 // 
       
   967 void CCaUiEngine::PhoneClientDialL( const TDesC8* aFieldLink )
       
   968     {
       
   969     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::DialL()::PhoneClient dial Start");
       
   970     
       
   971     TBool createCall( ETrue );
       
   972     TInt error( KErrNone );
       
   973     
       
   974     if ( aFieldLink )
       
   975         {
       
   976         iDialData->SetContactLinkL( *aFieldLink );
       
   977         }
       
   978     
       
   979     // Check if number is emergency number and if it is 
       
   980     // then call emeregency call
       
   981     if ( !iEmergencyCall )
       
   982         {
       
   983         iEmergencyCall = CPhCltEmergencyCall::NewL( this );
       
   984         }
       
   985     if ( IsEmergencyNumber() )
       
   986         {
       
   987         createCall = EFalse;
       
   988         error = KErrNone;
       
   989         iEmergencyCall->DialEmergencyCallL( iDialData->TelephoneNumber() );
       
   990         }
       
   991     
       
   992     if ( createCall )
       
   993         {
       
   994         CConvergedServiceSelector::TSsResult results;
       
   995         
       
   996         error = iServiceSelector->GetCallingServiceByCallType( 
       
   997                         results,
       
   998                         ServiceSelectorCallType(),
       
   999                         iDialData->ServiceId(),
       
  1000                         iDialData->SendKeyPressed(),
       
  1001                         iDialData->TelephoneNumber() );
       
  1002             
       
  1003         if ( KErrNone == error )
       
  1004             {
       
  1005             SetSelectorResults( results );
       
  1006             }
       
  1007         else
       
  1008             {
       
  1009             createCall = EFalse;
       
  1010             }
       
  1011         }
       
  1012     
       
  1013     // Here note launch + query if this is video call and we
       
  1014     // are not in 3G network.
       
  1015    
       
  1016     if ( createCall )
       
  1017         {
       
  1018         if ( ( iDialData->CallType() == EPhCltVideo ) ||
       
  1019              ( iDialData->CallType() == EPhCltForcedVideo ) )
       
  1020             {
       
  1021             if ( !IsVideoCallAllowedL() )
       
  1022                 {
       
  1023                 createCall = EFalse;
       
  1024                 error = KErrCancel;
       
  1025                 }
       
  1026             }
       
  1027         }
       
  1028     if ( createCall )
       
  1029         {
       
  1030         CAUILOGSTRING("CALLUI: >>>CCaUiEngine::DialL(): Call PhoneClientdial");
       
  1031         iPhCltDialer->DialL( *iDialData );
       
  1032         }
       
  1033     else 
       
  1034         {        
       
  1035         //User cancelled. Need to inform client.
       
  1036         if ( error != KErrNone ) // Emergency call does not need to inform client. 
       
  1037             {
       
  1038             HandleDialL( error );
       
  1039             }
       
  1040          }
       
  1041     CAUILOGSTRING("CALLUI: >>>CCaUiEngine::DialL()::PhoneClient dial End");
       
  1042     }
       
  1043     
       
  1044 // ---------------------------------------------------------
       
  1045 //  CCaUiEngine::SetDialDataCallType()
       
  1046 // ---------------------------------------------------------
       
  1047 // 
       
  1048 void CCaUiEngine::SetDialDataCallType( const TCaUiCallType aCallType )
       
  1049     {
       
  1050     if ( aCallType == ECaUiCallTypeVoice )
       
  1051         {
       
  1052         // Voice call must be created.
       
  1053         iDialData->SetCallType( EPhCltVoice );
       
  1054         }
       
  1055     else if ( aCallType == ECaUiCallTypeVideo )
       
  1056         {
       
  1057         // (Forced) video call must be created.
       
  1058         iDialData->SetCallType( EPhCltForcedVideo );
       
  1059         }
       
  1060     else if ( aCallType == ECaUiCallTypeInternet )
       
  1061         {
       
  1062         // VoIP call must be created.
       
  1063         iDialData->SetCallType( EPhCltCallVoIP );
       
  1064         }
       
  1065     else
       
  1066         {
       
  1067         // else Voice call is ok.
       
  1068         iDialData->SetCallType( EPhCltVoice );
       
  1069         }
       
  1070     }
       
  1071     
       
  1072 // ---------------------------------------------------------
       
  1073 //  CCaUiEngine::IsEmergencyNumber()
       
  1074 // ---------------------------------------------------------
       
  1075 //
       
  1076 TBool CCaUiEngine::IsEmergencyNumber()
       
  1077     {
       
  1078     TBool isEmergencyNumber( EFalse );
       
  1079     
       
  1080     // get phonenumber from iDialData and heck number using phoneclient
       
  1081     // emergencycall api
       
  1082     TInt result = iEmergencyCall->IsEmergencyPhoneNumber(
       
  1083         iDialData->TelephoneNumber(), 
       
  1084         isEmergencyNumber );
       
  1085    
       
  1086     return isEmergencyNumber;
       
  1087     }
       
  1088 
       
  1089 // ---------------------------------------------------------
       
  1090 //  CCaUiEngine::IsVideoCallAllowedL()
       
  1091 // ---------------------------------------------------------
       
  1092 // 
       
  1093 TBool CCaUiEngine::IsVideoCallAllowedL()
       
  1094     {
       
  1095     TInt err = KErrNone;
       
  1096     TInt createCall( ETrue );
       
  1097     TInt networkMode = KCaUiEngGsmNetwork; // Default: GSM.               
       
  1098     err = RProperty::Get( KPSUidNetworkInfo, 
       
  1099                           KNWTelephonyNetworkMode, 
       
  1100                           networkMode );     
       
  1101    
       
  1102     if ( err )
       
  1103         {
       
  1104         // Information is not ok, so assume that
       
  1105         // we are in GSM network.
       
  1106         networkMode = KCaUiEngGsmNetwork;
       
  1107         }
       
  1108     // check network status
       
  1109     TInt nwStatus = ENWStatusRegistrationUnknown;
       
  1110     RProperty::Get( KPSUidNetworkInfo, KNWRegistrationStatus, nwStatus );
       
  1111 
       
  1112     // If we are not in WCDMA network, then it is not allowed 
       
  1113     // to create a video call.
       
  1114     if ( networkMode != KCaUiEngWcdmaNetwork )
       
  1115         {     
       
  1116         TInt automaticredial = 0;
       
  1117         
       
  1118         GetCenRepValueL( KCRUidTelephonySettings, KSettingsAutomaticRedial, automaticredial );        
       
  1119         
       
  1120         // if no network, fall back to voice call for proper error handling
       
  1121         if ( (FeatureManager::FeatureSupported( KFeatureIdAutoRedialForVideoCall ) && automaticredial)
       
  1122               || nwStatus == ENWStatusRegistrationUnknown
       
  1123               || nwStatus == ENWStatusNotRegisteredNoService
       
  1124               || nwStatus == ENWStatusNotRegisteredEmergencyOnly
       
  1125               || nwStatus == ENWStatusNotRegisteredSearching )
       
  1126             {
       
  1127             // fallback to voice when no network support to videocall
       
  1128             // handled in Phone.
       
  1129             }
       
  1130         else
       
  1131             {
       
  1132             createCall = EFalse;
       
  1133             // Video call can not be done.
       
  1134             // => Launch Note + Reconnect Query.
       
  1135 
       
  1136             // Empty pointer.
       
  1137             TPtrC ptrc;
       
  1138 
       
  1139             iDialogs->LaunchNoteAndReconConfQueryL( 
       
  1140                 *this,
       
  1141                 NULL,
       
  1142                 iDialData->TelephoneNumber(),
       
  1143                 EFalse,
       
  1144                 ptrc,
       
  1145                 iDialData->Name() );
       
  1146             }
       
  1147         }
       
  1148     return createCall;
       
  1149     }
       
  1150 // ---------------------------------------------------------
       
  1151 //  CCaUiEngine::HandleEmergencyDialL()
       
  1152 // ---------------------------------------------------------
       
  1153 //    
       
  1154 void CCaUiEngine::HandleEmergencyDialL( const TInt aStatus )
       
  1155     {
       
  1156     if ( iObserver )
       
  1157         {
       
  1158         iObserver->HandleDialResultL( aStatus );
       
  1159         }
       
  1160     }
       
  1161 // ---------------------------------------------------------
       
  1162 //  CCaUiEngine::GetCenRepValue()
       
  1163 // ---------------------------------------------------------
       
  1164 // 
       
  1165 void CCaUiEngine::GetCenRepValueL( 
       
  1166         const TUid& aUid, 
       
  1167         const TUint aId,
       
  1168         TInt& aValue ) const
       
  1169     {
       
  1170     CRepository* repository = CRepository::NewL( aUid );
       
  1171     TInt err = repository->Get( aId, aValue );
       
  1172      
       
  1173     delete repository;
       
  1174     repository = NULL;
       
  1175      
       
  1176     if ( err != KErrNotFound ) // KErrNotFound acceptable.
       
  1177         {
       
  1178         User::LeaveIfError( err );
       
  1179         }
       
  1180     }
       
  1181 
       
  1182 // ---------------------------------------------------------
       
  1183 //  CCaUiEngine::ConvertCaUiCallType( )
       
  1184 // ---------------------------------------------------------
       
  1185 //    
       
  1186 void CCaUiEngine::ConvertCaUiCallType( const TCaUiCallType aCallType,
       
  1187                     CPhCntContactDataSelection::TCallType& aResultCallType  )
       
  1188     {
       
  1189     switch ( aCallType )
       
  1190         {
       
  1191         case ECaUiCallTypeVoice:
       
  1192             {
       
  1193             aResultCallType = CPhCntContactDataSelection::ECallPhoneNumber;
       
  1194             break;
       
  1195             }
       
  1196         case ECaUiCallTypeVideo:
       
  1197             {
       
  1198             aResultCallType = CPhCntContactDataSelection::ECallVideoNumber;
       
  1199             break;
       
  1200             }
       
  1201         case ECaUiCallTypeInternet:
       
  1202             {
       
  1203             aResultCallType = CPhCntContactDataSelection::ECallVoip;
       
  1204             break;
       
  1205             }
       
  1206         default:
       
  1207             {
       
  1208             aResultCallType = CPhCntContactDataSelection::ECallPhoneNumber;
       
  1209             break;
       
  1210             }
       
  1211         }
       
  1212     }
       
  1213     
       
  1214 // ---------------------------------------------------------
       
  1215 //  CCaUiEngine::ConvertDialDataCallType()
       
  1216 // ---------------------------------------------------------
       
  1217 //    
       
  1218 void CCaUiEngine::ConvertDialDataCallType( CPhCntContactDataSelection::TCallType& aResultCallType )
       
  1219     {
       
  1220     switch ( iDialData->CallType() )
       
  1221         {
       
  1222         case EPhCltVoice:
       
  1223             {
       
  1224             aResultCallType = CPhCntContactDataSelection::ECallPhoneNumber;
       
  1225             break;
       
  1226             }
       
  1227         case EPhCltVideo:
       
  1228         case EPhCltForcedVideo:
       
  1229             {
       
  1230             aResultCallType = CPhCntContactDataSelection::ECallVideoNumber;
       
  1231             break;
       
  1232             }
       
  1233         case EPhCltCallVoIP:
       
  1234             {
       
  1235             aResultCallType = CPhCntContactDataSelection::ECallVoip;
       
  1236             break;
       
  1237             }
       
  1238         default:
       
  1239             {
       
  1240             aResultCallType = CPhCntContactDataSelection::ECallPhoneNumber;
       
  1241             break;
       
  1242             }
       
  1243         }
       
  1244     }
       
  1245 
       
  1246 
       
  1247 // ---------------------------------------------------------
       
  1248 //  CCaUiEngine::ConvertPhCltCallType
       
  1249 // ---------------------------------------------------------
       
  1250 //    
       
  1251 void CCaUiEngine::ConvertPhCltCallType( const TPhCltCallType aCallType,
       
  1252         TCaUiCallType& aResultCallType ) const
       
  1253     {
       
  1254     switch ( aCallType )
       
  1255         {
       
  1256         case EPhCltVoice:
       
  1257             {
       
  1258             aResultCallType = ECaUiCallTypeVoice;
       
  1259             break;
       
  1260             }
       
  1261         case EPhCltVideo:
       
  1262         case EPhCltForcedVideo:
       
  1263             {
       
  1264             aResultCallType = ECaUiCallTypeVideo;
       
  1265             break;
       
  1266             }
       
  1267         case EPhCltCallVoIP:
       
  1268             {
       
  1269             aResultCallType = ECaUiCallTypeInternet;
       
  1270             break;
       
  1271             }
       
  1272         default:
       
  1273             {
       
  1274             break;
       
  1275             }
       
  1276         }
       
  1277     }
       
  1278 
       
  1279 
       
  1280 // ---------------------------------------------------------
       
  1281 //  CCaUiEngine::ServiceSelectorCallType()
       
  1282 // ---------------------------------------------------------
       
  1283 //    
       
  1284 CConvergedServiceSelector::TSsCallType CCaUiEngine::ServiceSelectorCallType() const
       
  1285     {
       
  1286     CConvergedServiceSelector::TSsCallType ret;
       
  1287     
       
  1288     switch ( iDialData->CallType() )
       
  1289         {
       
  1290         case EPhCltVoice:
       
  1291             {
       
  1292             ret = CConvergedServiceSelector::ESsVoiceCall;
       
  1293             break;
       
  1294             }
       
  1295         case EPhCltVideo:
       
  1296         case EPhCltForcedVideo:
       
  1297             {
       
  1298             ret = CConvergedServiceSelector::ESsVideoCall;
       
  1299             break;
       
  1300             }
       
  1301         case EPhCltCallVoIP:
       
  1302             {
       
  1303             ret = CConvergedServiceSelector::ESsVoipCall;
       
  1304             break;
       
  1305             }
       
  1306         default:
       
  1307             {
       
  1308             ret = CConvergedServiceSelector::ESsVoiceCall;
       
  1309             break;
       
  1310             }
       
  1311         }
       
  1312     
       
  1313     return ret;
       
  1314     }
       
  1315 
       
  1316 // ---------------------------------------------------------
       
  1317 //  CCaUiEngine::SetSelectorResults()
       
  1318 // ---------------------------------------------------------
       
  1319 //    
       
  1320 void CCaUiEngine::SetSelectorResults( 
       
  1321         CConvergedServiceSelector::TSsResult& aResults )
       
  1322     {
       
  1323     switch ( aResults.iCallType )
       
  1324         {
       
  1325         case CConvergedServiceSelector::ESsVoipCall:
       
  1326             {
       
  1327             iDialData->SetCallType( EPhCltCallVoIP );
       
  1328             break;
       
  1329             }
       
  1330         case CConvergedServiceSelector::ESsVideoCall:
       
  1331             {
       
  1332             iDialData->SetCallType( EPhCltForcedVideo );
       
  1333             break;
       
  1334             }
       
  1335         case CConvergedServiceSelector::ESsVoiceCall:
       
  1336         default:
       
  1337             {
       
  1338             iDialData->SetCallType( EPhCltVoice );
       
  1339             break;
       
  1340             }
       
  1341         }
       
  1342     
       
  1343     iDialData->SetServiceId( aResults.iServiceId );
       
  1344     }
       
  1345 
       
  1346 
       
  1347 // ---------------------------------------------------------
       
  1348 //  CCaUiEngine::LaunchContactStoreLoadingL
       
  1349 // ---------------------------------------------------------
       
  1350 //  
       
  1351 TBool CCaUiEngine::LaunchContactStoreLoadingL( const TDesC8& aContactLink )
       
  1352     {
       
  1353     if ( !iFactory )
       
  1354         {
       
  1355         iFactory = CreateCntFactoryL();
       
  1356         }
       
  1357     
       
  1358     if ( !iContactStoreLoader )
       
  1359         {
       
  1360         iContactStoreLoader = iFactory->CreateContactStoreLoaderL();
       
  1361         }
       
  1362     
       
  1363     TBool isStoreLoaded( 
       
  1364         iContactStoreLoader->IsContactStoreLoaded( aContactLink ) );
       
  1365     if ( !isStoreLoaded )
       
  1366         {
       
  1367         iContactStoreLoader->LoadContactStoreL( aContactLink, *this );        
       
  1368         }
       
  1369     
       
  1370     return isStoreLoaded;
       
  1371     }
       
  1372 
       
  1373 // ---------------------------------------------------------
       
  1374 //  CCaUiEngine::IsSendKeyPressed
       
  1375 // ---------------------------------------------------------
       
  1376 //
       
  1377 TBool CCaUiEngine::IsSendKeyPressed( TCaUiCallType aCallType,
       
  1378         CAiwDialData::TCallType aAiwCallType ) const
       
  1379     {
       
  1380     TBool isSendKeyPressed( EFalse );
       
  1381     if ( CAiwDialData::EAIWForcedCS != aAiwCallType )
       
  1382         {
       
  1383         if ( ECaUiCallTypeUnknown == aCallType )
       
  1384             {
       
  1385             isSendKeyPressed = ETrue;
       
  1386             }
       
  1387         }
       
  1388     
       
  1389     return isSendKeyPressed;
       
  1390     }
       
  1391 
       
  1392 // End of file