phonebookui/Speeddial/src/SpdiaView.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-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:     Declares view for application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <bldvariant.hrh>
       
    25 #include <aknViewAppUi.h>
       
    26 #include <avkon.hrh>
       
    27 #include <akntitle.h>
       
    28 #include <aknlists.h>
       
    29 #include <eikmenub.h>
       
    30 
       
    31 #include <SpeedDial.rsg>
       
    32 #include <featmgr.h>
       
    33 #include <AiwCommon.hrh>    //KAiwCmdCall
       
    34 #include <aiwdialdataext.h>
       
    35 #include <StringLoader.h>
       
    36 #include <aknnotedialog.h>
       
    37 #include  "speeddial.hrh"
       
    38 #include "SpdiaControl.hrh"
       
    39 #include  "speeddialprivate.h"
       
    40 
       
    41 #include  "SpdiaView.h"
       
    42 #include  "SpdiaContainer.h"
       
    43 #include "SpdiaAppUi.h"
       
    44 #include <aknlayoutscalable_apps.cdl.h>
       
    45 #include <layoutmetadata.cdl.h>
       
    46 #include <vmnumber.h>
       
    47 #include <voicemailboxdomaincrkeys.h>
       
    48 #include <MVPbkContactLink.h>
       
    49 #include <telvmbxsettingscrkeys.h>
       
    50 
       
    51 #include <SettingsInternalCRKeys.h>
       
    52 #include <SpeeddialPrivateCRKeys.h>
       
    53 #include "Spdctrl.rsg"
       
    54 
       
    55 
       
    56 #include <CMessageData.h>
       
    57 #include <txtrich.h>
       
    58 #include <SendUiConsts.h>
       
    59 #include <sendnorm.rsg>
       
    60 #include <MVPbkContactFieldTextData.h>
       
    61 
       
    62 // ================= MEMBER FUNCTIONS =======================
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CSpdiaView::NewLC
       
    66 //
       
    67 // ---------------------------------------------------------
       
    68 CSpdiaView* CSpdiaView::NewLC(CSpeedDialPrivate* aSpeedPrivate)
       
    69     {
       
    70     CSpdiaView* self = new( ELeave ) CSpdiaView;
       
    71     CleanupStack::PushL( self );
       
    72     self->ConstructL(aSpeedPrivate);
       
    73     return self;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CSpdiaView::ConstructL
       
    78 // Symbian two-phased constructor
       
    79 // ---------------------------------------------------------
       
    80 void CSpdiaView::ConstructL(CSpeedDialPrivate* aSpeedPrivate)
       
    81     {
       
    82     BaseConstructL( R_SPDIA_VIEW );
       
    83     CSpdiaBaseView::ConstructL();
       
    84     
       
    85 		iSpeedPrivate = aSpeedPrivate;
       
    86 	
       
    87     iCbaID = R_SPDIA_MENUBAR_VIEW_VOICE;
       
    88 
       
    89     // Attach the AIW CallUI menus with to speeddial menus.
       
    90     // This is used for CallUI menus that we want attach
       
    91     // into our owm menus.
       
    92 
       
    93     iServiceHandler = CAiwServiceHandler::NewL();
       
    94     iServiceHandler->AttachMenuL( R_SPDIA_VIEW_MENU, R_SPDIAL_APP_INTEREST );
       
    95     iServiceHandler->AttachMenuL( R_SPDIA_VIEW_MENU_OK_CALL, R_SPDIAL_APP_INTEREST );
       
    96     iServiceHandler->AttachMenuL( R_SPDIA_VIEW_MENU_OK_CALL_VIDEO, R_SPDIAL_APP_INTEREST );
       
    97 
       
    98     // Attach the AIW CallUI query menus to speeddial .
       
    99     // This is used for CallUI list query menu (i.e menu that
       
   100     // is not attached to any of speeddial own menus).
       
   101 
       
   102     iServiceHandler->AttachL( R_SPDIAL_APP_INTEREST );
       
   103     iReleasenumberFlag = EFalse;
       
   104     iClientRectChanged = EFalse;
       
   105     //CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
   106 
       
   107     iSendUi = CSendUi::NewL();
       
   108     iAIWRunFlag = EFalse;
       
   109     iAssignCompletedFlag = ETrue;
       
   110     iIsShowVmbxDlg = EFalse;
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CSpdiaView::~CSpdiaView
       
   115 // ?implementation_description
       
   116 // ---------------------------------------------------------
       
   117 CSpdiaView::~CSpdiaView()
       
   118     {
       
   119     delete iContainer;
       
   120     delete iServiceHandler;
       
   121     delete iSendUi;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------
       
   125 // CSpdiaView::LoadCbaL
       
   126 // Loads relevant CBA key
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 void CSpdiaView::LoadCba(TInt aResourceID)
       
   130     {
       
   131     if ( iCbaID != aResourceID )
       
   132         {
       
   133         MenuBar()->SetMenuTitleResourceId( aResourceID );
       
   134         iCbaID = aResourceID;
       
   135         }
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // CSpdiaView::Id
       
   140 // ---------------------------------------------------------
       
   141 TUid CSpdiaView::Id() const
       
   142     {
       
   143     return KViewId;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CSpdiaView::NumberCallL
       
   148 // Call Phone client
       
   149 // Function used when send key is pressed.
       
   150 // ---------------------------------------------------------------------------
       
   151 void CSpdiaView::NumberCallL( const TDesC& aNumber,
       
   152         TInt& aNumberType, TBool aVmbx )          
       
   153     {
       
   154     // Set type to EAIWForcedCS if calltype is Vmbx.
       
   155     CAiwDialData::TCallType callType 
       
   156         = aVmbx ? CAiwDialData::EAIWForcedCS : CAiwDialData::EAIWVoice;                      
       
   157 	
       
   158 	
       
   159     switch( aNumberType )
       
   160         {
       
   161 		    case ESpDialPbkFieldIdPhoneNumberVideo:
       
   162 				    callType = CAiwDialData::EAIWForcedVideo;	
       
   163 				    break;   			
       
   164 
       
   165 		    case ESpDialPbkFieldIdVOIP:
       
   166 		    	if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   167 		    		{
       
   168 				    callType = CAiwDialData::EAIWVoiP;	
       
   169 		    		}
       
   170         		break;
       
   171         default:
       
   172 				    break;
       
   173 		
       
   174         }
       
   175     CmdNumberCallL( KAiwCmdCall, ETrue, aNumber, callType );
       
   176 
       
   177  	
       
   178 #ifdef COMMENTED //Start of Comment -Existing Code
       
   179 	
       
   180     if ( aNumberType == ESpDialPbkFieldIdPhoneNumberVideo ) // change
       
   181         {
       
   182         callType = EAiwForcedVideo;
       
   183         CmdNumberCallL( KAiwCmdCall, ETrue, aNumber, callType );
       
   184         }
       
   185     // If field Id is ESpDialPbkFieldIdVOIP, set call type to VoIP.
       
   186     else if ( aNumberType == ESpDialPbkFieldIdVOIP )
       
   187     	&& FeatureManager::FeatureSupported(KFeatureIdCommonVoip))
       
   188         {
       
   189         callType = EAiwVoIPCall;
       
   190         CmdNumberCallL(KAiwCmdCall, ETrue, aNumber, callType );
       
   191         }
       
   192     else
       
   193         {
       
   194         CmdNumberCallL( KAiwCmdCall, ETrue, aNumber, callType );
       
   195         }
       
   196  #endif //End of Comment - Existing code
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------
       
   200 // CSpdiaView::HandleCommandL
       
   201 // ?implementation_description
       
   202 // ---------------------------------------------------------
       
   203 void CSpdiaView::HandleCommandL(TInt aCommand)
       
   204     {
       
   205     if(iSpeedPrivate->GetWait()->IsStarted())
       
   206     return;
       
   207     
       
   208     if ( !iAssignCompletedFlag )
       
   209         {
       
   210         return;
       
   211         }
       
   212     
       
   213     switch ( aCommand )
       
   214         {
       
   215         case ESpdiaCmdNumberCall:
       
   216             {
       
   217             CmdNumberCallL(KAiwCmdCall, ETrue );  //KAiwCmdCall: CallUI shows list query if necessary
       
   218             break;
       
   219             }
       
   220         case EAknSoftkeyExit:
       
   221             {
       
   222             AppUi()->Exit();
       
   223             break;
       
   224             }
       
   225         case EAknCmdExit:
       
   226             {
       
   227             AppUi()->ProcessCommandL( EAknCmdExit );
       
   228             break;
       
   229             }
       
   230         case ESpdiaCmdChange:
       
   231         case ESpdiaCmdAssign:
       
   232             {
       
   233             CmdAssignNumberL();
       
   234             break;
       
   235             }
       
   236         case ESpdiaCmdClear:
       
   237             {
       
   238             CmdReleaseNumberL();
       
   239             break;
       
   240             }
       
   241         case ESpdiaCmdView:
       
   242             {
       
   243             CmdViewNumberL();
       
   244             break;
       
   245             }
       
   246 
       
   247         case ESpdiaCmdMessage:
       
   248         	{
       
   249     		CmdSendMessageL();    	
       
   250     		break;
       
   251 	       	}
       
   252 
       
   253         //for help     
       
   254         case EAknCmdHelp:
       
   255             {
       
   256             AppUi()->HandleCommandL(aCommand);
       
   257             break;
       
   258             }
       
   259         case EAknCmdTaskSwapper:
       
   260             {
       
   261             //do nothing
       
   262             break;
       
   263             } 
       
   264         default:        
       
   265             {
       
   266             CmdNumberCallL( aCommand, EFalse );
       
   267             break;
       
   268             }
       
   269         }
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // CSpdiaView::HandleClientRectChange
       
   274 //
       
   275 // ---------------------------------------------------------
       
   276 void CSpdiaView::HandleClientRectChange()
       
   277     {
       
   278     if ( iContainer && !iClientRectChanged )
       
   279         {
       
   280         iClientRectChanged = ETrue;
       
   281         iContainer->SetRect( ClientRect() );
       
   282         iClientRectChanged = EFalse;
       
   283         }
       
   284     }
       
   285     
       
   286 // ---------------------------------------------------------
       
   287 // CSpdiaView::HandleStatusPaneSizeChange
       
   288 //
       
   289 // ---------------------------------------------------------
       
   290 void CSpdiaView::HandleStatusPaneSizeChange()
       
   291     {
       
   292     HandleClientRectChange();
       
   293     }
       
   294 
       
   295 // ---------------------------------------------------------
       
   296 // CSpdiaView::CmdAssignNumberL
       
   297 // Command handle : Assign
       
   298 // ---------------------------------------------------------
       
   299 TBool CSpdiaView::CmdAssignNumberL()
       
   300     {
       
   301     if ( ( iContainer->IsVoiceMailBox() ) || ( iContainer->IsVdoMailBox() ) )
       
   302         {
       
   303         return EFalse;
       
   304         }
       
   305     // Return EFalse if speeddial does not finish assigning.
       
   306     if ( CSpeedDialPrivate::STATE_IDLE != iSpeedPrivate->State() )
       
   307         {
       
   308         return EFalse;
       
   309         }
       
   310     TInt error( KErrNone );
       
   311     TInt result( KErrNone );
       
   312     CSpeedDialPrivate& control = iContainer->Control();
       
   313     
       
   314     // A display state will be restored supposing it is an error.
       
   315     TInt index( iContainer->CurGridPosition() );
       
   316    	result = control.CheckingIfPopUpNeededL();
       
   317     control.MakeVisible( EFalse );
       
   318     
       
   319     if ( result )
       
   320         {
       
   321         result = PopUpEnableSpDiaDlgL();
       
   322         if ( result != ESpdCmdEnableYes && 
       
   323             result != ESpdCmdEnableNo && 
       
   324             result != EEikBidOk )
       
   325             {
       
   326             return EFalse;
       
   327             }			
       
   328         }
       
   329     
       
   330     MVPbkContactLink *assignContact = NULL;
       
   331     
       
   332     // set the update flag
       
   333     iAssignNumberFlag = EFalse;
       
   334     index = index + 1;
       
   335     
       
   336     // launches the ContactFetchView of the Phonebook
       
   337     iAssignCompletedFlag = EFalse;
       
   338     result = control.ShowAssign( index, assignContact );
       
   339    	iAssignCompletedFlag = ETrue;
       
   340    	index = index - 1; 
       
   341     delete assignContact;
       
   342   	
       
   343     if ( result == KErrNone )
       
   344         {	
       
   345         // If contact is selected sucessfully
       
   346         iAssignNumberFlag = EFalse;
       
   347         }
       
   348     else
       
   349         {	
       
   350         // If ConatactFetchView is canceled
       
   351         iAssignNumberFlag = ETrue;
       
   352         }
       
   353     
       
   354     control.MakeVisible( ETrue );
       
   355     UndoLayoutAndLeaveL( error );
       
   356     // Control pane is not updated quickly after canceling "Change" from options menu
       
   357     iContainer->MiddleSoftKeyL();
       
   358     
       
   359     TRect mainPaneRect ;
       
   360     TRect statusPaneRect;
       
   361     TPoint oldPosition;
       
   362     oldPosition.iX = 0;
       
   363     oldPosition.iY = 0;
       
   364     
       
   365     // Set the layout after assingning the contact
       
   366     iContainer->SetStatusPaneL();
       
   367 
       
   368     // Update the whole grid 
       
   369     TRAP( error, iContainer->UpdatePhoneNumberL( -1 ) );
       
   370 
       
   371     UndoLayoutAndLeaveL( error );
       
   372    
       
   373     // After assigning the contact,set the state as STATE_IDLE 
       
   374     iSpeedPrivate->SetState( CSpeedDialPrivate::STATE_IDLE );
       
   375    
       
   376     // Handle Msk
       
   377     iContainer->MiddleSoftKeyL();
       
   378    
       
   379     // To exit from FSW 
       
   380     if ( result == KLeaveExit )
       
   381         {
       
   382         AppUi()->Exit();
       
   383         }
       
   384    
       
   385     // return ETrue if assignment operation success, else return EFalse.
       
   386     if ( KErrNone == result )
       
   387         {
       
   388         return ETrue;
       
   389         }
       
   390     return EFalse;
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------
       
   394 // CSpdiaView::DoActivateL
       
   395 // ?implementation_description
       
   396 // ---------------------------------------------------------
       
   397 void CSpdiaView::DoActivateL(
       
   398         const TVwsViewId& /*aPrevViewId*/,
       
   399 		TUid /*aCustomMessageId*/,
       
   400         const TDesC8& /*aCustomMessage*/)
       
   401     {
       
   402     if ( !iContainer )
       
   403         {
       
   404         iContainer = new(ELeave) CSpdiaContainer( iSpeedPrivate );
       
   405         iContainer->SetMopParent( this );
       
   406         iContainer->ConstructL( this );
       
   407         }
       
   408     else
       
   409         {
       
   410         iContainer->ActivateL();
       
   411         }
       
   412     AppUi()->AddToStackL( *this, iContainer );
       
   413     iContainer->MiddleSoftKeyL();
       
   414   }
       
   415 
       
   416 // ---------------------------------------------------------
       
   417 // CSpdiaView::DoDeactivate
       
   418 // ?implementation_description
       
   419 // ---------------------------------------------------------
       
   420 void CSpdiaView::DoDeactivate()
       
   421     {
       
   422     if ( iContainer )
       
   423         {
       
   424         AppUi()->RemoveFromStack( iContainer );
       
   425         delete iContainer;
       
   426         iContainer=NULL;
       
   427         }
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------
       
   431 // CSpdiaView::HandleForegroundEventL(...)
       
   432 // Foreground and background events.
       
   433 // @param aForeGround  ETrue : come to the foreground
       
   434 //                     EFalse: removed to the foreground
       
   435 // ---------------------------------------------------------
       
   436 void CSpdiaView::HandleForegroundEventL(TBool aForeground)
       
   437     {
       
   438     if ( iSpeedPrivate == NULL )
       
   439         {
       
   440         return;
       
   441         }
       
   442 
       
   443     if ( aForeground )
       
   444         {
       
   445         // We had gone to idle mode using active application..
       
   446         // We are coming back..Restore the GridStatus..
       
   447         if ( iSpeedPrivate->State() == CSpeedDialPrivate::STATE_IDLE && 
       
   448             iSpeedPrivate->GridStatus() == CSpeedDialPrivate::EGridNoUse )
       
   449             {
       
   450             iSpeedPrivate->SetGridStatus( CSpeedDialPrivate::EGridUse );
       
   451             }
       
   452 
       
   453         // The cba resource should be updated when go back to speeddial.
       
   454         iContainer->MiddleSoftKeyL();
       
   455         LoadCba( iContainer->MenuResourceID() );        
       
   456         
       
   457         iAIWRunFlag = EFalse;	 
       
   458         }
       
   459     else
       
   460         {
       
   461         // We are going out of use by active application..
       
   462         // We are no longer using the Grid..Update GridStatus..
       
   463         if ( iSpeedPrivate->State() == CSpeedDialPrivate::STATE_IDLE && 
       
   464             iSpeedPrivate->GridStatus() == CSpeedDialPrivate::EGridUse )
       
   465             {
       
   466             iSpeedPrivate->SetGridStatus( CSpeedDialPrivate::EGridNoUse );
       
   467             }
       
   468         }
       
   469 
       
   470     // For updation of the grid view while coming from the Phonebook view
       
   471     if ( iReleasenumberFlag || iAssignNumberFlag )
       
   472         {
       
   473         // Refresh and draw the grid
       
   474         iAssignNumberFlag = EFalse;
       
   475         }	
       
   476 
       
   477     // On skin change create the speeddial grid and draw the new icons.
       
   478     if ( ( aForeground && ( STATIC_CAST( CSpdiaAppUi*, AppUi() )->IsSkinChanged() ) ) )
       
   479         {			
       
   480         iContainer->HandleResourceChange( KAknsMessageSkinChange );		
       
   481         iContainer->DrawNow();
       
   482         }	
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------
       
   486 // CSpdiaView::CmdNumberCallL
       
   487 // Command handle : Call
       
   488 // ---------------------------------------------------------
       
   489 void CSpdiaView::CmdNumberCallL ( TInt aCommand,
       
   490                                   TBool aShowQuery  //True: Let CallUI to show query to user
       
   491                                                     //False:Speed Dial menu already shown to user
       
   492                                 )
       
   493     {
       
   494     CSpeedDialPrivate& control = iContainer->Control();/////////////////need 2 change
       
   495     TPhCltTelephoneNumber number;
       
   496     TBool call( EFalse );
       
   497     TInt index( iContainer->CurGridPosition() );
       
   498 
       
   499     number = control.PhoneNumber( index );
       
   500     int type = control.NumberType( index );
       
   501     if ( ( iContainer->IsVoiceMailBox()) || ( iContainer->IsVdoMailBox() ) ) 
       
   502         {
       
   503         TInt numberType( ESpDialPbkFieldIdNone );
       
   504         CRepository*  vmbxkey2 = CRepository::NewL( KCRUidTelVideoMailbox );
       
   505         vmbxkey2->Get( KTelVideoMbxKey, vmbxsupported );
       
   506         delete vmbxkey2;
       
   507         vmbxkey2 = NULL;
       
   508         iAIWRunFlag = ETrue;
       
   509         if ( vmbxsupported == 2 )
       
   510             {
       
   511             if ( iContainer->IsVoiceMailBox() )
       
   512                 {
       
   513                 call = control.ExVoiceMailL( number );
       
   514                 }
       
   515             else if ( iContainer->IsVdoMailBox() )
       
   516                 {
       
   517                 call = control.ExVideoMailL( number );
       
   518                 }
       
   519             }
       
   520         else
       
   521             {
       
   522             iStatusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
   523             iStatusPane->MakeVisible( ETrue );
       
   524             iStatusPane->DrawNow(); 
       
   525             // When Vmbx dialog need to showing, set the flag to ETrue.
       
   526             iIsShowVmbxDlg = ETrue;
       
   527             if ( iContainer->IsVoiceMailBox() || iContainer->IsVdoMailBox() )
       
   528                 {
       
   529                 call = control.VoiceMailL( number );
       
   530                 }
       
   531             iIsShowVmbxDlg = EFalse;
       
   532             iContainer->VoiceMailDialogLaunched( EFalse );
       
   533             iContainer->SetStatusPaneL();
       
   534             }
       
   535         iAIWRunFlag = EFalse;
       
   536         if ( call )
       
   537             {
       
   538             TInt vmbxType = control.VoiceMailType();
       
   539             if( vmbxType == EVmbxIP )
       
   540                 {
       
   541                 numberType = ESpDialPbkFieldIdVOIP;
       
   542                 }
       
   543             else if( vmbxType == EVmbxVideo )
       
   544                 {
       
   545                 numberType = ESpDialPbkFieldIdPhoneNumberVideo;
       
   546                 }				        
       
   547             // Vmbx call, set ETrue to set EAIWForcedCS type.
       
   548             NumberCallL( number, numberType, ETrue );
       
   549             }
       
   550         }
       
   551     else if ( control.Contact(index ) != NULL )
       
   552         {
       
   553         //Set default call type (however this may be changed by CallUI).If event or
       
   554         //call type is video number type, we provie video call option as default
       
   555         CAiwDialData::TCallType callType = CAiwDialData::EAIWVoice;
       
   556 				
       
   557         if ( type == ESpDialPbkFieldIdPhoneNumberVideo )
       
   558             {
       
   559             callType = 	CAiwDialData::EAIWForcedVideo;
       
   560             }
       
   561         // If field Id is ESpDialPbkFieldIdVOIP, set call type to VoIP.
       
   562         else if ( type == ESpDialPbkFieldIdVOIP && FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   563             {
       
   564             callType = 	CAiwDialData::EAIWVoiP;   
       
   565             }
       
   566         CmdNumberCallL( aCommand, aShowQuery, number, callType );
       
   567         }
       
   568     }
       
   569 
       
   570 
       
   571 // ---------------------------------------------------------
       
   572 // CSpdiaView::CmdNumberCallL
       
   573 // Command handle : Call
       
   574 // ---------------------------------------------------------
       
   575 
       
   576 void CSpdiaView::CmdNumberCallL ( 	TInt aCommandId, 
       
   577                               		TBool aShowQuery, 
       
   578                               		TPtrC aNumber, 
       
   579 							  		CAiwDialData::TCallType aCallType )		
       
   580     {
       
   581     if( !aNumber.Length() )
       
   582         {
       
   583         return;
       
   584         }
       
   585    
       
   586     // We have phone number, so let's set the dial data
       
   587     CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC();
       
   588     dialData->SetCallType( aCallType );
       
   589 
       
   590     MVPbkStoreContact* contact = iSpeedPrivate->Contact( iContainer->CurGridPosition() );
       
   591     if ( contact )
       
   592         {
       
   593         HBufC* nameBuffer( NULL );
       
   594         nameBuffer = iSpeedPrivate->ContactTitleL( contact, ETrue );
       
   595         CleanupStack::PushL( nameBuffer );
       
   596         if ( nameBuffer->Length() > AIWDialDataExt::KMaximumNameLength )
       
   597             {
       
   598             TPtrC namePtr = nameBuffer->Left( AIWDialDataExt::KMaximumNameLength );
       
   599             dialData->SetNameL( namePtr );
       
   600             }
       
   601         else
       
   602             {
       
   603             dialData->SetNameL( *nameBuffer );
       
   604             }
       
   605         CleanupStack::PopAndDestroy( nameBuffer );
       
   606         }
       
   607         
       
   608     dialData->SetPhoneNumberL( aNumber );
       
   609     dialData->SetWindowGroup( AIWDialData::KAiwGoToIdle );
       
   610     CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   611     dialData->FillInParamListL( paramList );
       
   612     CleanupStack::PopAndDestroy( dialData );
       
   613 
       
   614     // Set the flag to ETrue, it means the aiw will be called in a fast time.
       
   615     iAIWRunFlag = ETrue;
       
   616     if ( aShowQuery )
       
   617         {
       
   618         // Execute direct command (we use CallUI's list query)
       
   619         iServiceHandler->ExecuteServiceCmdL( aCommandId,
       
   620                             paramList,
       
   621                             iServiceHandler->OutParamListL(),
       
   622                             0,
       
   623                             this ); //Callback is NULL as no dial results wanted.
       
   624         }
       
   625     else
       
   626         {
       
   627         // Execute Menu based command (we have already shown speeddial-AIW menu to user)
       
   628         iServiceHandler->ExecuteMenuCmdL( aCommandId,
       
   629                             paramList,
       
   630                             iServiceHandler->OutParamListL(),
       
   631                             0,
       
   632                             this ); //Callback is NULL as no dial results wanted.
       
   633         }
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------
       
   637 // CSpdiaView::CmdReleaseNumberL
       
   638 // Command handle: Release
       
   639 // ---------------------------------------------------------
       
   640 void CSpdiaView::CmdReleaseNumberL()
       
   641     {
       
   642     TInt index(iContainer->CurGridPosition());
       
   643     
       
   644     iReleasenumberFlag = ETrue;
       
   645     if ( iContainer->Control().ShowRemove( index ) )
       
   646         {
       
   647         iContainer->UpdatePhoneNumberL( index );
       
   648         iContainer->Grid()->DrawDeferred();
       
   649         }
       
   650     iReleasenumberFlag = EFalse;
       
   651     iContainer->MiddleSoftKeyL();
       
   652      
       
   653     iSpeedPrivate->SetState(CSpeedDialPrivate::STATE_IDLE);
       
   654     }
       
   655 
       
   656 // ---------------------------------------------------------
       
   657 // CSpdiaView::CmdViewNumberL
       
   658 // Command handle: ViewNumber
       
   659 // ---------------------------------------------------------
       
   660 void CSpdiaView::CmdViewNumberL()
       
   661     {
       
   662     iContainer->ShowViewNumberL();
       
   663     }
       
   664 
       
   665 // ---------------------------------------------------------
       
   666 // CSpdiaView::UndoLayoutAndLeaveL
       
   667 // ?implementation_description
       
   668 // ---------------------------------------------------------
       
   669 void CSpdiaView::UndoLayoutAndLeaveL(TInt aError, TBool aUpdateSp)
       
   670     {
       
   671     if ( aError != KErrNone )
       
   672         {
       
   673         iContainer->MakeVisible( ETrue );
       
   674         if (aUpdateSp)
       
   675             {
       
   676             iStatusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
   677             }
       
   678         User::Leave( aError );
       
   679         }
       
   680     }
       
   681 
       
   682 // ---------------------------------------------------------
       
   683 // CSpdiaView::MakeInvisibleCallBack
       
   684 // ---------------------------------------------------------
       
   685 TInt CSpdiaView::MakeInvisibleCallBack(TAny* aContainer)
       
   686     {
       
   687     STATIC_CAST( CSpdiaContainer*, aContainer )->MakeVisible( EFalse );
       
   688     return FALSE;
       
   689     }
       
   690 
       
   691 // ---------------------------------------------------------
       
   692 // CSpdiaView::DynInitMenuPaneL
       
   693 // Remove menu item for help application
       
   694 // when feature is not supported.
       
   695 // ---------------------------------------------------------
       
   696 void CSpdiaView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   697     {
       
   698 
       
   699     //AIW knows its own submenu hooks, so we can return from here if AIW handled this.
       
   700     if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) )
       
   701         {
       
   702         return;
       
   703         }
       
   704 
       
   705     TInt index;
       
   706 
       
   707     switch( aResourceId )
       
   708         {
       
   709         case R_SENDUI_MENU:
       
   710             index = 2;
       
   711             iSendUi->AddSendMenuItemL( *aMenuPane, index, ESpdiaCmdMessage, KCapabilitiesForAllServices );
       
   712             break;
       
   713 
       
   714         case R_SPDIA_VIEW_MENU:
       
   715         case R_SPDIA_VIEW_MENU_VOICE:
       
   716         case R_SPDIA_VIEW_MENU_ASSIGN:
       
   717         case R_SPDIA_VIEW_MENU_OK_CALL:
       
   718         case R_SPDIA_VIEW_MENU_OK_CALL_VIDEO:
       
   719             {
       
   720             // Check if help feature is available
       
   721             if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   722                 {
       
   723                 if ( ( aResourceId != R_SPDIA_VIEW_MENU_OK_CALL ) &&
       
   724                 	   ( aResourceId != R_SPDIA_VIEW_MENU_OK_CALL_VIDEO ) )
       
   725                     {
       
   726                 		aMenuPane->DeleteMenuItem( EAknCmdHelp );	
       
   727                     }
       
   728                 }
       
   729             DynInitAiwMenuPaneL( aResourceId, aMenuPane, ETrue ); 	
       
   730             break;
       
   731             }
       
   732         default:
       
   733             {
       
   734             break;
       
   735             }
       
   736         }
       
   737     }
       
   738 
       
   739 void CSpdiaView::DynInitAiwMenuPaneL( TInt aResourceId,
       
   740                                       CEikMenuPane* aMenuPane,
       
   741                                       TBool aVideo )
       
   742     {
       
   743     CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   744 
       
   745     // Get number type for commands.
       
   746     TInt numberType = 0;
       
   747     
       
   748     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   749     	{
       
   750     	numberType = iContainer->Control().NumberType( iContainer->CurGridPosition() );//////need2 change
       
   751         if ( numberType == ESpDialPbkFieldIdVOIP )
       
   752             {
       
   753             TAiwVariant variant;
       
   754             TAiwGenericParam param( EGenericParamSIPAddress, variant );
       
   755             paramList.AppendL( param );
       
   756             }
       
   757         }
       
   758     else if ( !aVideo )
       
   759         {
       
   760         TAiwVariant variant;
       
   761         TAiwGenericParam param( EGenericParamPhoneNumber, variant );
       
   762         paramList.AppendL( param );
       
   763         }
       
   764     	
       
   765     iServiceHandler->InitializeMenuPaneL( *aMenuPane,
       
   766                                           aResourceId,
       
   767                                           ESpdiaCmdLast,
       
   768                                           paramList );
       
   769     if ( aMenuPane->NumberOfItemsInPane() == KErrNone )
       
   770         {
       
   771         User::Leave( KErrNotFound );
       
   772         }
       
   773     }
       
   774 
       
   775 
       
   776 // ---------------------------------------------------------
       
   777 // CSpdiaView::SetCba
       
   778 // Only in 5.0, used for changing cba buttons dynamically
       
   779 // ---------------------------------------------------------
       
   780 void CSpdiaView::SetCba( TInt aResourceId ) 
       
   781     {
       
   782     if ( Cba() )
       
   783         {
       
   784         TRAP_IGNORE(Cba()->SetCommandSetL(aResourceId));
       
   785         }
       
   786     Cba()->DrawDeferred(); 
       
   787     }
       
   788 
       
   789 // ---------------------------------------------------------
       
   790 // CSpdiaView::CmdSendMessageL
       
   791 // Command handle: Send Message
       
   792 // ---------------------------------------------------------
       
   793 void CSpdiaView::CmdSendMessageL()
       
   794     { 
       
   795     CArrayFixFlat<TUid>* servicesToDim = new(ELeave) CArrayFixFlat<TUid>(1);
       
   796     CleanupStack::PushL( servicesToDim );
       
   797     
       
   798     servicesToDim->AppendL( KSenduiMtmBtUid );
       
   799     servicesToDim->AppendL( KSenduiMtmIrUid );
       
   800     servicesToDim->AppendL( KSenduiMtmPostcardUid );
       
   801 
       
   802  
       
   803     TUid serviceUid = iSendUi->ShowTypedQueryL(CSendUi::EWriteMenu,NULL ,KCapabilitiesForAllServices,servicesToDim,KNullDesC);
       
   804     CleanupStack::PopAndDestroy(); //servicesToDim 
       
   805 
       
   806     if ( serviceUid.iUid == 0 )
       
   807         return;
       
   808     
       
   809     TSendingCapabilities capabilities;
       
   810     iSendUi->ServiceCapabilitiesL( serviceUid, capabilities );
       
   811     
       
   812     CMessageData *messageData = CMessageData::NewL();
       
   813     CleanupStack::PushL( messageData );
       
   814 
       
   815     // Gets current tile pane and saves it to operatorName
       
   816     TBuf<20> operatorName;
       
   817     CAknTitlePane* title = NULL;
       
   818     CEikStatusPane *sp = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
   819     title = STATIC_CAST( CAknTitlePane*, 
       
   820         sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   821     operatorName.Copy( *title->Text() );
       
   822 
       
   823     // send as body
       
   824     CRichText* text = CRichText::NewL(
       
   825                             iEikonEnv->SystemParaFormatLayerL(), 
       
   826                             iEikonEnv->SystemCharFormatLayerL(), CEditableText::EFlatStorage);
       
   827     CleanupStack::PushL( text );
       
   828     text->InsertL( 0, KNullDesC );
       
   829     messageData->SetBodyTextL( text );
       
   830    
       
   831     MVPbkStoreContact* contact( iSpeedPrivate->Contact(iContainer->CurGridPosition()) );
       
   832     if ( NULL == contact )
       
   833         {
       
   834         return;
       
   835         }
       
   836 
       
   837     // get the phone number
       
   838     const TDesC& phoneNumber = iSpeedPrivate->PhoneNumber( iContainer->CurGridPosition() );
       
   839     TBool unnamedContact( EFalse );
       
   840     // get the contact title
       
   841     HBufC* nameBuffer = iSpeedPrivate->ContactTitleL( contact, EFalse );
       
   842     if ( nameBuffer == NULL )
       
   843         {
       
   844         // For unnamed contact, use phonenumber
       
   845         unnamedContact = ETrue;
       
   846         nameBuffer = HBufC::NewL( phoneNumber.Length() );
       
   847         nameBuffer->Des() = phoneNumber;
       
   848         }
       
   849     CleanupStack::PushL( nameBuffer );  
       
   850     
       
   851     TUid techTypeUid = iSendUi->TechnologyType( serviceUid );
       
   852         
       
   853     if ( KSenduiMtmSmtpUid == serviceUid || KSenduiTechnologyMailUid == techTypeUid )
       
   854         {
       
   855         HBufC* email = NULL;
       
   856         email = iSpeedPrivate->EMail( contact );
       
   857         CleanupStack::PushL( email );   
       
   858          	
       
   859         if ( NULL == email )
       
   860             {
       
   861             CleanupStack::PopAndDestroy( email );  //email
       
   862             CleanupStack::PopAndDestroy( nameBuffer );      // nameBuffer
       
   863             CleanupStack::PopAndDestroy( 2 );               // text and messageData
       
   864             return; 
       
   865             }
       
   866             		
       
   867         // append the to address
       
   868         if ( !unnamedContact )
       
   869             {
       
   870             // not unnamed contact, use name
       
   871             messageData->AppendToAddressL( email->Des(), *nameBuffer );
       
   872             }
       
   873         else
       
   874             {
       
   875             // unnamed contact, use email
       
   876             messageData->AppendToAddressL( email->Des(), *email );
       
   877             }
       
   878 	    
       
   879         // Create and Send Message
       
   880         iSendUi->CreateAndSendMessageL( serviceUid /*KSenduiMtmUniMessageUid*/, messageData );
       
   881         CleanupStack::PopAndDestroy( email ); //email
       
   882         }
       
   883     else
       
   884         {
       
   885         // append the to address
       
   886         messageData->AppendToAddressL( phoneNumber, *nameBuffer );
       
   887 
       
   888         // Create and Send Message
       
   889         iIsShowMsgDlg = ETrue;
       
   890         iSendUi->CreateAndSendMessageL(serviceUid /*KSenduiMtmUniMessageUid*/, messageData );
       
   891         iIsShowMsgDlg = EFalse;
       
   892         }
       
   893 
       
   894     title->SetTextL( operatorName ); //Sets title pane for operatorName which was save  
       
   895     CleanupStack::PopAndDestroy( nameBuffer ); //nameBuffer
       
   896     CleanupStack::PopAndDestroy( text ); //text
       
   897     CleanupStack::PopAndDestroy( messageData ); //messageData
       
   898     iContainer->SetStatusPaneL();		
       
   899     }
       
   900 
       
   901 
       
   902 // ---------------------------------------------------------
       
   903 // CSpdiaView::IsSettingType
       
   904 // ---------------------------------------------------------
       
   905 TBool CSpdiaView::IsSettingType( )
       
   906     {
       
   907     return ( ( CSpdiaAppUi* )AppUi() )->IsSettingType();
       
   908     }
       
   909     
       
   910 // ---------------------------------------------------------
       
   911 // CSpdiaView::SetSpeedPrivate
       
   912 // Only invoked by CSpdiaAppUi::~CSpdiaAppUi()
       
   913 // ---------------------------------------------------------
       
   914 void CSpdiaView::SetSpeedPrivate( CSpeedDialPrivate* aSpeedPrivate )
       
   915     {
       
   916     iSpeedPrivate = aSpeedPrivate;
       
   917     }
       
   918 
       
   919 // ---------------------------------------------------------
       
   920 // CSpdiaView::PopUpEnableSpDiaDlgL()
       
   921 // ---------------------------------------------------------
       
   922 TInt CSpdiaView::PopUpEnableSpDiaDlgL()
       
   923     {
       
   924     TInt result( EKeyPhoneEnd );
       
   925     CRepository* repository = CRepository::NewL( KCRUidTelephonySettings );
       
   926 
       
   927     result = ESpdCmdEnableYes;
       
   928     if ( result == ESpdCmdEnableYes || result == EEikBidOk )
       
   929         {
       
   930         repository->Set( KSettingsOneKeyDialling, 1 );
       
   931         }
       
   932 
       
   933     delete repository;
       
   934     return result;
       
   935     }
       
   936 
       
   937 // ---------------------------------------------------------
       
   938 // CSpdiaView::IsShowMsgDlg
       
   939 // if msg dialog is showng.
       
   940 // ---------------------------------------------------------
       
   941 TBool CSpdiaView::IsShowMsgDlg()
       
   942     {
       
   943     return iIsShowMsgDlg; 
       
   944     }    
       
   945 
       
   946 // ---------------------------------------------------------
       
   947 // CSpdiaView::IsShowVmbxDlg
       
   948 // if voice mail box dialog is showng.
       
   949 // ---------------------------------------------------------
       
   950 TBool CSpdiaView::IsShowVmbxDlg()
       
   951     {
       
   952     return iIsShowVmbxDlg;
       
   953     }
       
   954    
       
   955 // ---------------------------------------------------------
       
   956 // CSpdiaView::ProcessCommandL
       
   957 // from CAknView::ProcessCommandL .
       
   958 // ---------------------------------------------------------
       
   959 void CSpdiaView::ProcessCommandL(TInt aCommand)
       
   960 	  {
       
   961 	  if ( !iAssignCompletedFlag )
       
   962 	      {
       
   963 	      return;
       
   964 	  	  }
       
   965 	  switch( aCommand )
       
   966 		    {
       
   967         case EAknSoftkeyOptions:
       
   968             {
       
   969             if ( iAIWRunFlag || iSpeedPrivate->State() != CSpeedDialPrivate::STATE_IDLE )
       
   970                 {
       
   971                 }
       
   972             else
       
   973                 {
       
   974                 CAknView::ProcessCommandL(aCommand);
       
   975                 }
       
   976             break;
       
   977             }
       
   978   	    default:
       
   979   	        {
       
   980             CAknView::ProcessCommandL(aCommand);
       
   981   	    	  }
       
   982 		    }
       
   983 	  }
       
   984 
       
   985 // ---------------------------------------------------------
       
   986 // CSpdiaView::HandleNotifyL
       
   987 // call back funtion of aiw.
       
   988 // ---------------------------------------------------------
       
   989 TInt CSpdiaView::HandleNotifyL(
       
   990         TInt /*aCmdId*/,
       
   991         TInt aEventId,
       
   992         CAiwGenericParamList& /*aEventParamList*/,
       
   993         const CAiwGenericParamList& /*aInParamList*/)
       
   994     {
       
   995     TInt result = 0;
       
   996     // when the aiw is started, it means the service has been used at this moment.
       
   997     if ( aEventId == KAiwEventStarted )
       
   998         {
       
   999         iAIWRunFlag = EFalse;
       
  1000         }
       
  1001     return result;
       
  1002     }
       
  1003 
       
  1004 // ---------------------------------------------------------
       
  1005 // CSpdiaView::IsAssignCompleted
       
  1006 // return the iAssignCompletedFlag.
       
  1007 // ---------------------------------------------------------    
       
  1008 TBool CSpdiaView::IsAssignCompleted()
       
  1009     {
       
  1010     return iAssignCompletedFlag;
       
  1011     }
       
  1012 
       
  1013 // ---------------------------------------------------------
       
  1014 // Check whether there has been a focus when clicking MSK 
       
  1015 // @return ETrue for focus exists, or EFalse 
       
  1016 // ---------------------------------------------------------
       
  1017 TBool CSpdiaView::IsFocused()
       
  1018 	{
       
  1019 	return MenuBar()->ItemSpecificCommandsEnabled();
       
  1020 	}
       
  1021 // End of File