srsf/vcommandmanager/src/vcmanagercontactselecthandler_aiw.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "vcmanagercontactselecthandler_aiw.h"
       
    21 #include "vcmanagerdialer_aiw.h"
       
    22 
       
    23 #include <CPbkFieldInfo.h>
       
    24 
       
    25 #include <vascvpbkhandler.h>
       
    26 
       
    27 #include <cntdef.h>
       
    28 #include <eikenv.h>
       
    29 
       
    30 #include <featmgr.h> // FeatureManager.
       
    31 
       
    32 #ifdef __SIND_EXTENSIONS
       
    33 #include <sendui.h>
       
    34 #include <SendUiConsts.h>
       
    35 #include <CMessageData.h>
       
    36 #endif // __SIND_EXTENSIONS
       
    37 
       
    38 #include "rubydebug.h"
       
    39 
       
    40 #ifdef __WINS__
       
    41 // Text to show in emulator when dialing
       
    42 _LIT( KDialingNoteWins, "Dialing" );
       
    43 #endif
       
    44 
       
    45 // CONSTANTS
       
    46 
       
    47 // ================= MEMBER FUNCTIONS =======================
       
    48 
       
    49 // ---------------------------------------------------------
       
    50 // CVcManagerContactSelectHandler::CVcManagerContactSelectHandler
       
    51 // C++ default constructor can NOT contain any code, that
       
    52 // might leave.
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CVcManagerContactSelectHandler::CVcManagerContactSelectHandler()
       
    56  : iVideoTelephonySupported( EFalse ), iVoIPFeatureSupported( EFalse )     
       
    57     {
       
    58     // Nothing
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------
       
    62 // CVcManagerContactSelectHandler::NewL
       
    63 // Two-phased constructor.
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 CVcManagerContactSelectHandler* CVcManagerContactSelectHandler::NewL(
       
    67                                        MNssContextMgr* aContextManager,
       
    68                                        MNssTagSelectNotification* aTagSelectNotification )
       
    69     {
       
    70     CVcManagerContactSelectHandler* self = new (ELeave) CVcManagerContactSelectHandler;
       
    71     
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL( aContextManager, aTagSelectNotification );
       
    74     CleanupStack::Pop( self );
       
    75 
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler
       
    81 // Destructor
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler()
       
    85     {
       
    86     RUBY_DEBUG0( "CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler" );
       
    87 
       
    88     delete iPbkHandler;
       
    89 
       
    90     if ( iTagSelectNotification )
       
    91         {
       
    92         iTagSelectNotification->Deregister( iContext, this );
       
    93         }
       
    94 
       
    95     delete iContext;
       
    96 
       
    97 #ifdef __SIND_EXTENSIONS
       
    98     delete iSendUi;
       
    99 #endif // __SIND_EXTENSIONS
       
   100 
       
   101     delete iGlobalDialer;
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CVcManagerContactSelectHandler::HandleTagSelect
       
   106 // EPOC default constructor can leave.
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 void CVcManagerContactSelectHandler::ConstructL( MNssContextMgr* aContextManager,
       
   110                                                  MNssTagSelectNotification* aTagSelectNotification )
       
   111     {
       
   112     RUBY_DEBUG_BLOCK( "CVcManagerContactSelectHandler::ConstructL" );
       
   113     
       
   114     iTagSelectNotification = aTagSelectNotification;
       
   115     
       
   116     iContext = aContextManager->CreateContextL();
       
   117     iContext->SetNameL( KNssGCHNameDialContext );
       
   118     iContext->SetGlobal( ETrue );
       
   119     iTagSelectNotification->RegisterL( iContext, this );
       
   120 
       
   121     RUBY_DEBUG0( "CVcManagerContactSelectHandler::ConstructL creating instance of CVasVPbkHandler" );
       
   122     iPbkHandler = CVasVPbkHandler::NewL();
       
   123     iPbkHandler->InitializeL();
       
   124     
       
   125     FeatureManager::InitializeLibL();
       
   126     iVideoTelephonySupported = FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony );
       
   127     
       
   128     iVoIPFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
       
   129 
       
   130     // Frees the TLS. Must be done after FeatureManager is used.
       
   131     FeatureManager::UnInitializeLib();
       
   132     
       
   133     // Take Eikon environment
       
   134     iEikonEnvironment = CEikonEnv::Static();
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CVcManagerContactSelectHandler::HandleTagSelect
       
   139 // Dials number
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CVcManagerContactSelectHandler::HandleTagSelect( MNssTag* aTag )
       
   143     {
       
   144     RUBY_DEBUG2( "CVcManagerContactSelectHandler::HandleTagSelect VOIP %i video %i", iVoIPFeatureSupported, iVideoTelephonySupported );
       
   145 
       
   146     TRAP_IGNORE( DoHandleTagSelectL( aTag ) );
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CVcManagerContactSelectHandler::DoHandleTagSelect
       
   151 // Dials number or create message
       
   152 // ---------------------------------------------------------
       
   153 //
       
   154 void CVcManagerContactSelectHandler::DoHandleTagSelectL( MNssTag* aTag )
       
   155     {
       
   156     RUBY_DEBUG_BLOCK( "CVcManagerContactSelectHandler::DoHandleTagSelectL" );
       
   157    
       
   158     CleanupDeletePushL( aTag );
       
   159    
       
   160     HBufC* name = aTag->SpeechItem()->PartialTextL( KNameTrainingIndex );        
       
   161     CleanupStack::PushL( name ); 
       
   162    
       
   163     iContactId = aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation );
       
   164   
       
   165     iPbkHandler->FindContactFieldL( aTag );
       
   166        
       
   167     TVasExtensionAction action =
       
   168          (TVasExtensionAction)aTag->RRD()->IntArray()->At( KVasExtensionRrdLocation );
       
   169     TVasExtensionCommand command =
       
   170          (TVasExtensionCommand)aTag->RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
       
   171 
       
   172     if ( action == EDial )
       
   173         {
       
   174         DialL( *name, iPbkHandler->TextL(), iPbkHandler->FieldTypeL(), command ); 
       
   175         }
       
   176 #ifdef __SIND_EXTENSIONS  
       
   177     else
       
   178         {
       
   179         CMessageData* messageData = CMessageData::NewL();
       
   180         CleanupStack::PushL( messageData );
       
   181                    
       
   182         // created when needed first time
       
   183         if ( !iSendUi )
       
   184             {
       
   185             iSendUi = CSendUi::NewL();
       
   186             }
       
   187          
       
   188         TUid sendUid( KSenduiMtmSmsUid );
       
   189         switch ( action )
       
   190             {
       
   191             case ENewMessage:
       
   192                 // @todo Check that KSenduiMtmUniMessageUid is ok to use
       
   193                 // instead of SenduiMtmMmsUid or KSenduiMtmSmsUid
       
   194                 sendUid = KSenduiMtmUniMessageUid;
       
   195                 messageData->AppendToAddressL( iPbkHandler->TextL(), *name );  
       
   196                 break;
       
   197                    
       
   198             case ENewEmail:
       
   199                 sendUid = KSenduiMtmSmtpUid;
       
   200                 messageData->AppendToAddressL( iPbkHandler->TextL(), *name );
       
   201                 break;
       
   202                    
       
   203             default:
       
   204                 RUBY_ERROR0( "CVcManagerContactSelectHandler::DoHandleTagSelectL wrong action id" );
       
   205             }
       
   206               
       
   207         RUBY_DEBUG1( "CVcManagerContactSelectHandler::DoHandleTagSelectL action %i",
       
   208                       action );               
       
   209         // launch editor as a stand-alone application so that 
       
   210         // it can/will be restored if put to background
       
   211         iSendUi->CreateAndSendMessageL( sendUid, messageData, KNullUid, EFalse );
       
   212         
       
   213         CleanupStack::PopAndDestroy( messageData );
       
   214         } 
       
   215 #endif // __SIND_EXTENSIONS        
       
   216 
       
   217     CleanupStack::PopAndDestroy( name );
       
   218     CleanupStack::Pop( aTag );
       
   219     }
       
   220 
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // CVcManagerContactSelectHandler::DialL
       
   224 // Dials contact
       
   225 // ---------------------------------------------------------
       
   226 //
       
   227 #ifndef __WINS__
       
   228 void CVcManagerContactSelectHandler::DialL( const TDesC& aName,
       
   229                                             const TDesC& aPhoneNumber,
       
   230                                             TFieldType aFieldType,
       
   231                                             TVasExtensionCommand aCommandId )
       
   232 #else
       
   233 void CVcManagerContactSelectHandler::DialL( const TDesC& /*aName*/,
       
   234                                             const TDesC& aPhoneNumber,
       
   235                                             TFieldType aFieldType,
       
   236                                             TVasExtensionCommand aCommandId )
       
   237 #endif // __WINS__                                            
       
   238     {
       
   239     RUBY_DEBUG2( "CVcManagerContactSelectHandler::DialL fieldtype %i commandId %i", aFieldType, aCommandId );
       
   240 
       
   241     // select call type
       
   242     TCallType callType( EVoice );
       
   243 
       
   244     if ( ( aCommandId == EVoipCommand || ( aCommandId == EDefaultCommand &&
       
   245            aFieldType == KUidContactFieldVCardMapVOIP ) ) && iVoIPFeatureSupported )
       
   246         {
       
   247         RUBY_DEBUG0( "CVcManagerContactSelectHandler::SetupDialData VOIP" );
       
   248 
       
   249         callType = EVoIP;
       
   250         }
       
   251     
       
   252     if ( ( aCommandId == EVideoCommand || ( aCommandId == EDefaultCommand &&
       
   253            aFieldType == KUidContactFieldVCardMapVIDEO ) ) && iVideoTelephonySupported )
       
   254         {
       
   255         RUBY_DEBUG0( "CVcManagerContactSelectHandler::SetupDialData video" );
       
   256 
       
   257         callType = EVideo;
       
   258         }
       
   259 
       
   260 #ifndef __WINS__
       
   261     if ( !iGlobalDialer )
       
   262         {
       
   263         iGlobalDialer = CVcManagerDialer::NewL();
       
   264         }
       
   265     iGlobalDialer->ExecuteL( aName, aPhoneNumber, callType );
       
   266 #else
       
   267     iEikonEnvironment->AlertWin( KDialingNoteWins, aPhoneNumber );
       
   268 #endif // __WINS__
       
   269 
       
   270     RUBY_DEBUG0( "CVcManagerContactSelectHandler::DialL done" );
       
   271     }
       
   272 
       
   273 // End of file