meetingui/attendeeview/UiSrc/CAttendeeCaller.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2004-2006 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:  Provides wrapper class CCallUi methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cattendeecaller.h"
       
    22 #include "attendeeview.hrh"
       
    23 #include <attendeeview_res.rsg>
       
    24 
       
    25 // Phonebook 
       
    26 #include <cpbkphonenumberselect.h>
       
    27 #include <cpbkcontactitem.h>
       
    28 #include <cpbkfieldinfo.h>
       
    29 
       
    30 // TODO Migration to Phonebook2
       
    31 // Phonebook2
       
    32 // Virtual Phonebook
       
    33 
       
    34 // System includes
       
    35 #include <aiwcommon.hrh>
       
    36 #include <aiwdialdataext.h>
       
    37 #include <eikmenub.h>
       
    38 
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CAttendeeCaller::CAttendeeCaller
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CAttendeeCaller::CAttendeeCaller()
       
    49     {
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------
       
    53 // CAttendeeCaller::ConstructL
       
    54 // ----------------------------------------------------
       
    55 //
       
    56 void CAttendeeCaller::ConstructL()
       
    57     {
       
    58 	//Crete service handler
       
    59 	iServiceHandler = CAiwServiceHandler::NewL();
       
    60 
       
    61 	//Atttach menu
       
    62 	iServiceHandler->AttachMenuL( R_ATTENDEEVIEW_CALL_MENU,
       
    63 							      R_ATTENDEEVIEW_CALL_AIW_INTEREST );
       
    64 
       
    65     // Attach also base interest
       
    66     iServiceHandler->AttachL( R_ATTENDEEVIEW_CALL_AIW_INTEREST );       
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CAttendeeCaller::NewL
       
    71 // Two-phased constructor.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CAttendeeCaller* CAttendeeCaller::NewL()
       
    75     {
       
    76     CAttendeeCaller* self = new(ELeave)CAttendeeCaller;
       
    77     CleanupStack::PushL( self );
       
    78     self->ConstructL();
       
    79     CleanupStack::Pop(self);
       
    80     return self;
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------
       
    84 // CAttendeeCaller::~CAttendeeCaller
       
    85 // ----------------------------------------------------
       
    86 //
       
    87 CAttendeeCaller::~CAttendeeCaller()
       
    88     {
       
    89     delete iServiceHandler;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CAttendeeCaller::InitializeServiceHandlerL
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 void CAttendeeCaller::InitializeServiceHandlerL( CEikMenuPane& aMenuPane,
       
    97                                                  TBool aVisible ) const
       
    98     {
       
    99     if ( aVisible )
       
   100         {
       
   101 
       
   102         iServiceHandler->InitializeMenuPaneL(
       
   103                     aMenuPane,
       
   104                     R_ATTENDEEVIEW_CALL_MENU,
       
   105                     KAiwCmdCall,
       
   106                     iServiceHandler->InParamListL() );
       
   107                     
       
   108         }
       
   109     else
       
   110         {
       
   111         aMenuPane.SetItemDimmed( KAiwCmdCall, ETrue );
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------
       
   116 // CAttendeeCaller::CallCmdL
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CAttendeeCaller::CallCmdL( TInt aCommandId, CPbkContactItem& aPbkItem )
       
   120     {
       
   121     
       
   122     if ( iServiceHandler->ServiceCmdByMenuCmd( aCommandId ) == KAiwCmdNone &&
       
   123            aCommandId != EAttCallCmd )
       
   124         {
       
   125         return;
       
   126         }
       
   127 
       
   128     // Setup dial data
       
   129     CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC();
       
   130     dialData->SetWindowGroup( CCoeEnv::Static()->RootWin().Identifier() );
       
   131 
       
   132     // TODO Create and set a contact link when using VirtualPhonebook
       
   133     //dialData.SetContactId( aPbkItem.Id() );
       
   134 
       
   135     const TPbkContactItemField* field = SelectPhoneNumberL( aPbkItem );
       
   136     if ( !field )
       
   137         {
       
   138         return;
       
   139         }
       
   140 
       
   141     const TDesC& phoneNumber(
       
   142             field->Text().Left( AIWDialDataExt::KMaximumPhoneNumberLength ) );
       
   143 
       
   144     dialData->SetPhoneNumberL( phoneNumber );
       
   145 
       
   146 
       
   147     // If the command was not launched via menu but the send key
       
   148     // (which is the case when iCommandId is EAttCallCmd), we
       
   149     // need to deduct whether to launch voice or video call
       
   150     if ( aCommandId == EAttCallCmd )
       
   151         {
       
   152         // Default to voice call
       
   153         dialData->SetCallType( CAiwDialData::EAIWVoice );
       
   154         
       
   155         // CASE A:
       
   156         // If there is a no default phone number field, but there
       
   157         // is a default video number field, launch video call
       
   158         if ( !aPbkItem.DefaultPhoneNumberField() &&
       
   159               aPbkItem.DefaultVideoNumberField() )
       
   160             {
       
   161             dialData->SetCallType( CAiwDialData::EAIWForcedVideo );
       
   162             }
       
   163 
       
   164         // CASE B:
       
   165         // No default fields at all. This means that the user
       
   166         // was shown a number selection list, or there was just
       
   167         // one number
       
   168         else if ( !aPbkItem.DefaultPhoneNumberField() &&
       
   169                   !aPbkItem.DefaultVideoNumberField() )
       
   170             {
       
   171             // If the selected field was a video field, launch video call
       
   172             if ( field->FieldInfo().FieldId() == EPbkFieldIdPhoneNumberVideo )
       
   173                 {
       
   174                 dialData->SetCallType( CAiwDialData::EAIWForcedVideo );
       
   175                 }
       
   176             }         
       
   177         }
       
   178 
       
   179     CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   180     dialData->FillInParamListL( paramList );    
       
   181 
       
   182     if ( aCommandId == EAttCallCmd )
       
   183        {
       
   184        iServiceHandler->ExecuteServiceCmdL( KAiwCmdCall,
       
   185                                     paramList,
       
   186                                     iServiceHandler->OutParamListL(), 
       
   187                                     0,
       
   188                                     NULL );
       
   189        }
       
   190     else
       
   191         {
       
   192         iServiceHandler->ExecuteMenuCmdL( aCommandId,
       
   193                                       paramList,
       
   194                                       iServiceHandler->OutParamListL(),
       
   195                                       0,
       
   196                                       NULL );   
       
   197         }
       
   198 
       
   199     CleanupStack::PopAndDestroy( dialData ); // dialData
       
   200 
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------
       
   204 // CAttendeeCaller::HandleSubmenuL
       
   205 // ---------------------------------------------------------
       
   206 //
       
   207 TBool CAttendeeCaller::HandleSubmenuL( CEikMenuPane& aPane )
       
   208     {
       
   209     return iServiceHandler->HandleSubmenuL( aPane );
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // CAttendeeCaller::SelectPhoneNumberL
       
   214 // ---------------------------------------------------------
       
   215 //
       
   216 const TPbkContactItemField* CAttendeeCaller::SelectPhoneNumberL( 
       
   217                                   CPbkContactItem& aContactItem )
       
   218     {    
       
   219     CPbkPhoneNumberSelect::TParams params( aContactItem );    
       
   220 	    
       
   221     CPbkPhoneNumberSelect* dlg = new(ELeave)CPbkPhoneNumberSelect;
       
   222     dlg->ExecuteLD( params );
       
   223     
       
   224     return params.SelectedField();       
       
   225     }
       
   226     
       
   227 //  End of File