mobilemessaging/smsui/viewersrc/MsgSmsViewerCDMAAppUi.cpp
branchRCL_3
changeset 27 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2004 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 *     Sms CDMA Viewer Application UI
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // UIKON/AVKON
       
    21 #include <akntitle.h>                   // CAknTitlePane
       
    22 #include <txtrich.h>                    // Rich text ed
       
    23 // messaging editors
       
    24 #include <msgbodycontrol.h>             // CMsgBodyControl
       
    25 #include <eikrted.h>                    // CEikRichTextEditor
       
    26 #include <msgeditorview.h>              // CMsgEditorView
       
    27 #include <msgaddresscontrol.h>          // CMsgAddressControl
       
    28 #include <msgbiobodycontrol.h>          // CMsgBioBodyControl
       
    29 // messaging
       
    30 #include <smuthdr.h>
       
    31 #include <SmsMessageWrappers.h> 
       
    32 #include <MuiuMsvUiServiceUtilities.h>  // DiskSpaceBelowCriticalLevelL
       
    33 #include <MuiuMsvUiServiceUtilitiesInternal.h>
       
    34 #include <AknInputBlock.h>				// CAknInputBlock
       
    35 // phone
       
    36 #include <CommonPhoneParser.h>          // Common phone number validity checker
       
    37 // resources
       
    38 #include <smsviewer.rsg>                // resouce identifiers
       
    39 #include <MsgEditor.mbg>                // bitmaps
       
    40 // local
       
    41 #include "msgsmsviewer.hrh"             // application specific commands
       
    42 #include "msgsmsviewerdoc.h"            // CMsgSmsViewerDocument
       
    43 #include "msgsmsviewerappui.h"          // CMsgSmsViewerAppUi
       
    44 // Find item
       
    45 #include <finditemmenu.rsg>             // find item resources
       
    46 #include <finditemmenu.h>               // CFindItemMenu
       
    47 #include <finditem.hrh>
       
    48 //#include <finditemdialog.h>             // CFindItemDialog
       
    49 // phonebook
       
    50 #include <CPbkContactEngine.h>          // Phonebook Engine
       
    51 #include <RPbkViewResourceFile.h>
       
    52 #include <CPbkFieldsInfo.h>             // Phonebook field types
       
    53 #include <CPbkDataSaveAppUi.h>          // CreateContact menu
       
    54 // general
       
    55 #include <StringLoader.h>               // StringLoader
       
    56 #include <FeatMgr.h>                    // FeatureManager
       
    57 #include <data_caging_path_literals.hrh>	// Data Caging For Platform Security
       
    58 #include <akniconutils.h>				// Icon utility
       
    59 #include <MsgVoIPExtension.h>
       
    60 
       
    61 // variant
       
    62 #include <bldvariant.hrh>
       
    63 // local
       
    64 #include "msgsmsviewerdoc.h"            // CMsgSmsViewerDocument
       
    65 #include "msgsmsviewerappui.h"          // CMsgSmsViewerCDMAAppUi
       
    66 #include "msgsmsviewercdmaappui.h"          // CMsgSmsViewerCDMAAppUi
       
    67 
       
    68 #include <Sendui.h>
       
    69 #include <CMessageData.h>               // for SendUi
       
    70 
       
    71 // Mbm-file location
       
    72 _LIT( KMsgEditorMbm, "MsgEditor.mbm" );
       
    73 
       
    74 // C++ default constructor can NOT contain any code, that
       
    75 // might leave.
       
    76 CMsgSmsViewerCDMAAppUi::CMsgSmsViewerCDMAAppUi()
       
    77     : iCallbackNumber( KNullDesC )
       
    78     {
       
    79     }
       
    80 
       
    81 // Symbian OS default constructor can leave.
       
    82 void CMsgSmsViewerCDMAAppUi::ConstructL()
       
    83     {
       
    84     CMsgEditorAppUi::ConstructL();
       
    85 
       
    86     // Prepare FeatureManager, read values to members
       
    87     FeatureManager::InitializeLibL();
       
    88     iHelpFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdHelp );
       
    89     iEmailFeatureSupported =  FeatureManager::FeatureSupported(KFeatureIdEmailOverSms);
       
    90     
       
    91     // Prepare iSmsHeader
       
    92     CPlainText* nullString = CPlainText::NewL();
       
    93     CleanupStack::PushL( nullString );
       
    94     iSmsHeader = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *nullString );
       
    95     CleanupStack::PopAndDestroy(nullString);
       
    96 
       
    97     iSendUi = CSendUi::NewL();
       
    98     
       
    99     if( !iEikonEnv->StartedAsServerApp( ) )
       
   100         { // If the app was not started as server app, we can call PrepareLaunchL
       
   101         Document()->PrepareToLaunchL( this );
       
   102         }
       
   103     iMsgVoIPExtension = CMsgVoIPExtension::NewL();
       
   104     
       
   105     // Use CDMA Menubar
       
   106     MenuBar()->SetMenuTitleResourceId(R_SMSV_OPTIONSMENUBAR_CDMA);
       
   107     MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
   108     }   
       
   109 
       
   110 // Destructor
       
   111 CMsgSmsViewerCDMAAppUi::~CMsgSmsViewerCDMAAppUi()
       
   112     {
       
   113     FeatureManager::UnInitializeLib();
       
   114     delete iMsgVoIPExtension;
       
   115     }
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CMsgSmsViewerCDMAAppUi::LaunchViewL
       
   120 // (other items were commented in a header).
       
   121 // ---------------------------------------------------------
       
   122 void CMsgSmsViewerCDMAAppUi::LaunchViewL()
       
   123     {
       
   124     CAknInputBlock::NewLC();
       
   125 
       
   126     // Creating view (exits app immediately if fails)
       
   127     iView = CMsgEditorView::NewL( *this, CMsgEditorView::EMsgReadOnly );
       
   128     // get hands on entry
       
   129     const CMsgSmsViewerDocument* doc = Document();
       
   130     TMsvEntry msvEntry = doc->Entry();
       
   131     // Getting sender/receiver to From/To-field
       
   132     // (just copies the content of iDetails to To/From-field,
       
   133     // should work also with IR-messages...)
       
   134     iRecipientstring = msvEntry.iDetails;  
       
   135 
       
   136     __ASSERT_DEBUG(msvEntry.Id() != 
       
   137          KMsvNullIndexEntryId, Panic( EMsgSmsNoMessage ));
       
   138 
       
   139 
       
   140     // Instead of using Sms Mtm load the entry's values
       
   141     // using store. This is because Sms Viewer is also used
       
   142     // by bio messages and then sms mtm can't be used...
       
   143 
       
   144     CMsvStore* store = doc->CurrentEntry().ReadStoreL();
       
   145     CleanupStack::PushL(store);
       
   146   
       
   147     // This TRAPping is needed to find out if the entry's store has
       
   148     // KUidMsvSMSHeaderStream. If it hasn't, we're most propably dealing
       
   149     // with non sms message and we can assume it is received message.
       
   150     TRAPD( err, iSmsHeader->RestoreL( *store ));
       
   151     if (err == KErrNone)
       
   152         {// Yes, it is sms based message
       
   153         iIrBt = EFalse;
       
   154         
       
   155         // Original longish LaunchViewL-function is splitted to 3 parts;
       
   156         // LaunchViewL, SmsBasedMsgHandlingL & LaunchBioViewL
       
   157         SmsBasedMsgHandlingL( msvEntry.iBioType, store );
       
   158         }
       
   159     else
       
   160         {// No, this is not a sms and sms pdu can't be checked. However
       
   161         // this is most propably _received_ IR or BT message.
       
   162         iIrBt = ETrue;
       
   163         iControlId = EMsgComponentIdFrom;
       
   164         iView->AddControlFromResourceL( 
       
   165             R_SMSV_FROM, 
       
   166             EMsgAddressControl, 
       
   167             EMsgAppendControl, 
       
   168             EMsgHeader);
       
   169         }
       
   170     CleanupStack::PopAndDestroy( store ); //store
       
   171 
       
   172     // Tests if Bio message
       
   173     if ( msvEntry.iBioType ) 
       
   174         {
       
   175         // Original longish LaunchViewL-function is split into 3 parts;
       
   176         // LaunchViewL, SmsBasedMsgHandlingL & LaunchBioViewL
       
   177         iFindItemMenu = CFindItemMenu::NewL( ESmsViewerFindItem );
       
   178         LaunchBioViewL( msvEntry );
       
   179         }
       
   180 
       
   181     if ( iIsFromEmail )
       
   182         { // Email over SMS. Use email address
       
   183         if (KErrNotFound != iEmailAddress.Match( iRecipientstring ))
       
   184             {
       
   185             iRecipientstring = KNullDesC;
       
   186             }
       
   187         }
       
   188     else // General SMS. Use sender number
       
   189         {
       
   190         if (KErrNotFound != iNumber.Match( iRecipientstring ))
       
   191             {
       
   192             iRecipientstring = KNullDesC;
       
   193             }
       
   194         }
       
   195     CMsgBaseControl* addressBase = iView->ControlById( iControlId );
       
   196     CMsgAddressControl* addressControl = static_cast<CMsgAddressControl*>( addressBase );
       
   197     if ( iIsFromEmail )
       
   198         { // Email over SMS. Use email address          
       
   199         addressControl->AddRecipientL( iRecipientstring, iEmailAddress, KNullContactId, ETrue );
       
   200         }
       
   201     else
       
   202         { // General SMS. Use sender number
       
   203         addressControl->AddRecipientL( iRecipientstring, iNumber, KNullContactId, ETrue );
       
   204         }
       
   205 
       
   206     if ( !iBioMsg )
       
   207         {
       
   208         // Read the value of automatic highlight sd-key
       
   209         ReadAutoHlSharedDataValueAndSetNotifyL();
       
   210         // Set the state of automatic highlighting for sms
       
   211         SetAutomaticHighlightL( iAutomaticHlValue );
       
   212         }
       
   213 
       
   214     // Parse the filename
       
   215     TParse tp;
       
   216     tp.Set( KMsgEditorMbm, &KDC_APP_BITMAP_DIR, NULL );
       
   217     // Load the bitmaps
       
   218     CFbsBitmap *bitmap;
       
   219     CFbsBitmap *bitmapMask;
       
   220     AknIconUtils::CreateIconLC(
       
   221         bitmap, bitmapMask, tp.FullName(), 
       
   222         EMbmMsgeditorQgn_prop_folder_sms_tab1, 
       
   223         EMbmMsgeditorQgn_prop_folder_sms_tab1_mask);
       
   224 
       
   225     // navipane tabgroup takes ownership of the bitmaps.
       
   226     UpdateNaviPaneL( bitmap, bitmapMask );
       
   227     CleanupStack::Pop(2); // bitmap, bitmapMask
       
   228 
       
   229     // set focus
       
   230     iView->ExecuteL( ClientRect(), iControlId );
       
   231 
       
   232     CleanupStack::PopAndDestroy();// CAknInputBlock
       
   233     }
       
   234 
       
   235 
       
   236 // ---------------------------------------------------------
       
   237 // CMsgSmsViewerAppUi::SmsBasedMsgHandlingL
       
   238 // (other items were commented in a header).
       
   239 // ---------------------------------------------------------
       
   240 void CMsgSmsViewerCDMAAppUi::SmsBasedMsgHandlingL( 
       
   241     TInt32 aBioType, CMsvStore* aStore )
       
   242     {
       
   243     // Initialize the richtext object...
       
   244     CParaFormatLayer* paraFormat = iEikonEnv->SystemParaFormatLayerL(); // <- pointer only
       
   245     CCharFormatLayer* charFormat = iEikonEnv->SystemCharFormatLayerL(); // <- pointer only
       
   246     CRichText* textBody = CRichText::NewL( paraFormat, charFormat );
       
   247     CleanupStack::PushL( textBody );
       
   248     // ...and read bodytext
       
   249     if ( aStore != NULL )
       
   250         {
       
   251         aStore->RestoreBodyTextL( *textBody );
       
   252         }
       
   253     if ( !aBioType )
       
   254         {
       
   255         // message is ordinary sms message or Picture Message
       
   256         // so, let's get message body to viewer. 
       
   257         CMsgBaseControl* baseControl = iView->ControlById( 
       
   258             EMsgComponentIdBody );
       
   259         CMsgBodyControl* bodyControl = static_cast<CMsgBodyControl*>(baseControl);
       
   260         
       
   261         iFindItemMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
       
   262             //the Title-pane text
       
   263             HBufC* text = StringLoader::LoadLC( R_QTN_TITLE_SMS, iCoeEnv );
       
   264             CAknTitlePane* title = static_cast<CAknTitlePane*> 
       
   265                 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
   266 
       
   267             title->SetTextL( *text );
       
   268             CleanupStack::PopAndDestroy(); // text
       
   269 
       
   270             // body text
       
   271             bodyControl->SetTextContentL( *textBody );
       
   272             if ( iView->ItemFinder() )
       
   273                 {
       
   274                 iView->ItemFinder()->SetFindModeL( 
       
   275                     CItemFinder::EPhoneNumber |
       
   276                     CItemFinder::EUrlAddress |
       
   277                     CItemFinder::EEmailAddress );
       
   278                 }
       
   279             bodyControl->SetPlainTextMode( ETrue );
       
   280         }
       
   281     CleanupStack::PopAndDestroy(); //textBody
       
   282     
       
   283     // Deciding between To/From text in address control
       
   284 
       
   285     const CSmsPDU::TSmsPDUType pduType = iSmsHeader->Type();
       
   286 
       
   287     switch ( pduType )
       
   288         {
       
   289 
       
   290         case CSmsPDU::ESmsDeliver:
       
   291            
       
   292             // Setting from-control
       
   293             iControlId = EMsgComponentIdFrom;
       
   294             iView->AddControlFromResourceL( 
       
   295                     R_SMSV_FROM, 
       
   296                     EMsgAddressControl, 
       
   297                     EMsgAppendControl, 
       
   298                     EMsgHeader );
       
   299             ExtractCallingInfoL();
       
   300             
       
   301             break;
       
   302 
       
   303         case CSmsPDU::ESmsSubmit:
       
   304             // Setting To-control
       
   305             iControlId = EMsgComponentIdTo;
       
   306             iView->AddControlFromResourceL( 
       
   307                 R_SMSV_TO, 
       
   308                 EMsgAddressControl, 
       
   309                 EMsgAppendControl, 
       
   310                 EMsgHeader );
       
   311             // take the number
       
   312             iNumber = iSmsHeader->FromAddress();
       
   313 
       
   314             break;
       
   315 
       
   316         default:
       
   317             Panic( EMsgSmsViewerUnknownSmsPduType );
       
   318             break;
       
   319         }
       
   320     }
       
   321 
       
   322 
       
   323 // ---------------------------------------------------------
       
   324 // CMsgSmsViewerCDMAAppUi::DynInitNonBioOptionsMenuL
       
   325 // (other items were commented in a header).
       
   326 // ---------------------------------------------------------
       
   327 void CMsgSmsViewerCDMAAppUi::DynInitNonBioOptionsMenuL( CEikMenuPane* aMenuPane )
       
   328     {
       
   329     if ( aMenuPane != NULL ) 
       
   330         {
       
   331         TPtrC senderNumber = KNullDesC();
       
   332 
       
   333         if ( iIsFromEmail ) // case of Email over SMS 
       
   334             {  
       
   335             senderNumber.Set( iEmailAddress );
       
   336             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
   337             if ( iValidCallbackNumber )
       
   338                 {
       
   339                 iFindItemMenu->SetCallbackNumber ( iCallbackNumber);
       
   340                 }
       
   341             }
       
   342         else 
       
   343             {
       
   344             if ( iValidSenderNumber ) // if sender's number is valid, choose it first
       
   345                 {
       
   346                 senderNumber.Set( iNumber );
       
   347                 }
       
   348             if ( iValidCallbackNumber && ( ComparePhoneNumberL( iCallbackNumber, iNumber ) != 0 ) )
       
   349                 {
       
   350                 iFindItemMenu->SetCallbackNumber ( iCallbackNumber);
       
   351                 }
       
   352             }
       
   353 
       
   354         iFindItemMenu->AddItemFinderMenuL( 
       
   355                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
   356                 aMenuPane, EFindItemMenuPlaceHolder,
       
   357                 senderNumber, 
       
   358                 ( iRecipientstring.Length() != 0 ));
       
   359         // Remove "Call back to sender" and "create cc" from menu
       
   360         // Find UI can handle it now.
       
   361         aMenuPane->SetItemDimmed( ESmsViewerCallBack, ETrue );
       
   362         aMenuPane->SetItemDimmed( ESmsViewerCreateCC, ETrue );
       
   363 
       
   364         // Remove "reply"  from menu, 
       
   365         // if this is a sent message
       
   366         if ( iControlId == EMsgComponentIdTo )
       
   367             {
       
   368             aMenuPane->SetItemDimmed( ESmsViewerReply, ETrue );
       
   369             }
       
   370 
       
   371         // Help handling
       
   372         aMenuPane->SetItemDimmed( EAknCmdHelp, !iHelpFeatureSupported );
       
   373         }
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------
       
   377 // CMsgSmsViewerCDMAAppUi::HandleCommandL
       
   378 // (other items were commented in a header).
       
   379 // ---------------------------------------------------------
       
   380 void CMsgSmsViewerCDMAAppUi::HandleCommandL(TInt aCommand )
       
   381     {
       
   382     // is it find item command
       
   383     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) && !iGms && !iBioMsg )
       
   384         {
       
   385         iFindItemMenu->HandleItemFinderCommandL( aCommand );
       
   386         return;
       
   387         }
       
   388     
       
   389     // Are we dealing with bio-message?
       
   390     if ( iBioMsg ) 
       
   391         {
       
   392         // let the biocontrol handle the command and check
       
   393         // whether it was handled.
       
   394         if ( aCommand==EAknCmdHelp )
       
   395             {
       
   396             LaunchHelpL();
       
   397             return;
       
   398             }
       
   399 
       
   400         if ( BioBody().HandleBioCommandL( aCommand ))
       
   401             {
       
   402             return;// Bio control has handled the command.
       
   403             }
       
   404         }
       
   405     
       
   406     // find item
       
   407     if ( iFindItemMenu && iFindItemMenu->CommandIsValidL( aCommand ) && ( iGms || iBioMsg ))
       
   408         {
       
   409         DoSearchL( aCommand );
       
   410         }
       
   411     
       
   412     switch ( aCommand )
       
   413         {
       
   414         case ESmsViewerReply:
       
   415             CheckDiskAndReplyForwardL( EFalse );
       
   416             Exit( EAknSoftkeyClose );
       
   417             break;
       
   418         case ESmsViewerForward:
       
   419             CheckDiskAndReplyForwardL( ETrue );
       
   420             Exit( EAknSoftkeyClose );
       
   421             break;
       
   422         case ESmsViewerDelete:
       
   423             DoFileDeleteL();
       
   424             break;
       
   425         case ESmsViewerMove:
       
   426             DoMoveEntryL();
       
   427             break;
       
   428         case ESmsViewerCallBack:
       
   429             DoCallBackToSenderL();
       
   430             break;
       
   431         case ESmsViewerCreateCCNew:
       
   432             // FALLTHROUGH
       
   433         case ESmsViewerCreateCCExisting:
       
   434             DoCreateContactCardL( aCommand );
       
   435             break;
       
   436         case ESmsViewerMessInfo:
       
   437             DoMessageInfoL();
       
   438             break;
       
   439         case EAknSoftkeyBack:
       
   440             Exit( EAknSoftkeyClose );
       
   441             break;
       
   442         case EEikCmdExit:
       
   443             // system exit
       
   444             DoMsgSaveExitL();
       
   445             break;
       
   446         case EAknCmdHelp:
       
   447             LaunchHelpL();
       
   448             break;
       
   449         default:
       
   450             break;
       
   451         }
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------
       
   455 // CMsgSmsViewerCDMAAppUi::DynInitMenuPaneL
       
   456 // (other items were commented in a header).
       
   457 // ---------------------------------------------------------
       
   458 void CMsgSmsViewerCDMAAppUi::DynInitMenuPaneL(
       
   459     TInt aMenuId, 
       
   460     CEikMenuPane* aMenuPane )
       
   461     {
       
   462     // Confirm app is running properly
       
   463     if ( !Document()->IsLaunched())
       
   464         {
       
   465         // If not, hide everything and return
       
   466         TInt amountOfItems = aMenuPane->NumberOfItemsInPane();
       
   467         if ( amountOfItems )
       
   468             {
       
   469             aMenuPane->DeleteBetweenMenuItems( 0, amountOfItems-1 );
       
   470             return;
       
   471             }
       
   472         }
       
   473 
       
   474     // ...then construct the menu itself. There is two menu-resources,
       
   475     // one for contextmenu and one for normal optionsmenu. 
       
   476     switch ( aMenuId )
       
   477         {
       
   478         case R_SMSV_OPTIONSMENUPANE_CDMA: 
       
   479             {
       
   480             if ( !iBioMsg )
       
   481                 { // Normal sms or picture msg
       
   482                 DynInitNonBioOptionsMenuL( aMenuPane );
       
   483                 }
       
   484             else
       
   485                 { // Smart (BIO) msg
       
   486                 DynInitBioOptionsMenuL( aMenuId, aMenuPane );
       
   487                 }
       
   488             }
       
   489             break;
       
   490         case R_SMSV_CONTEXTMENUPANE_CDMA:
       
   491             {
       
   492             if ( !iBioMsg )
       
   493                 { // Normal sms or picture msg
       
   494                 DynInitNonBioContextMenuL( aMenuPane );
       
   495                 }
       
   496             else
       
   497                 { // Smart (BIO) msg
       
   498                 DynInitBioContextMenuL( aMenuPane );
       
   499                 }
       
   500             }                
       
   501             break;
       
   502         case R_FINDITEMMENU_MENU:
       
   503             {
       
   504             iFindItemMenu->DisplayFindItemCascadeMenuL( *aMenuPane );
       
   505             }
       
   506             break;
       
   507         default:
       
   508             if ( iBioMsg || iGms )
       
   509                 {// for BIO & GMS; create contact card menu
       
   510                 // If it's AIW sub-menu, let AIW initialize it
       
   511                 InitAiwContactCardSubMenuL( aMenuPane );
       
   512                 }
       
   513             else
       
   514                 {// for normal SMS; update the finder menu
       
   515                 if( iVoIPNumber && iMsgVoIPExtension->IsVoIPSupported() )
       
   516                     {
       
   517                     iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
   518                     }
       
   519                 iFindItemMenu->UpdateItemFinderMenuL( aMenuId, aMenuPane );
       
   520                 }
       
   521             break;
       
   522         }
       
   523     }
       
   524 
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CMsgSmsViewerCDMAAppUi::DynInitNonBioContextMenuL
       
   528 // (other items were commented in a header).
       
   529 // ---------------------------------------------------------
       
   530 void CMsgSmsViewerCDMAAppUi::DynInitNonBioContextMenuL( CEikMenuPane* aMenuPane )
       
   531     {
       
   532     if ( aMenuPane != NULL )
       
   533         {
       
   534 
       
   535         TPtrC senderNumber = KNullDesC();
       
   536         if ( iIsFromEmail ) // SMS originating address is email address 
       
   537             {  
       
   538             senderNumber.Set( iEmailAddress );
       
   539             iFindItemMenu->SetSenderDescriptorType( CItemFinder::EEmailAddress );
       
   540             if ( iValidCallbackNumber )
       
   541                 {// set callback number when it is attached on the email over SMS
       
   542                 iFindItemMenu->SetCallbackNumber ( iCallbackNumber);
       
   543                 }
       
   544             }            
       
   545         else 
       
   546             {// SMS originating adddress is Phone number
       
   547             if ( iValidSenderNumber ) // if sender's number is valid, choose it first
       
   548                 {
       
   549                 senderNumber.Set( iNumber );
       
   550                 }
       
   551             if ( iValidCallbackNumber && ( ComparePhoneNumberL( iCallbackNumber, iNumber ) != 0 ) )
       
   552                 {// set callback number when it is valid and different from SMS originating address.
       
   553                 iFindItemMenu->SetCallbackNumber ( iCallbackNumber);
       
   554                 }
       
   555             }
       
   556 
       
   557         iFindItemMenu->AddItemFinderMenuL( 
       
   558                 IsBodyFocused() ? iView->ItemFinder() : 0,
       
   559                 aMenuPane, EFindItemContextMenuPlaceHolder,
       
   560                 senderNumber, 
       
   561                 ETrue, ETrue );
       
   562 
       
   563         }
       
   564     }
       
   565 
       
   566 // ---------------------------------------------------------
       
   567 // CMsgSmsViewerCDMAAppUi::HandleKeyEventL
       
   568 // (other items were commented in a header).
       
   569 // ---------------------------------------------------------
       
   570 TKeyResponse CMsgSmsViewerCDMAAppUi::HandleKeyEventL(
       
   571     const TKeyEvent& aKeyEvent, 
       
   572     TEventCode aType )
       
   573     {
       
   574     TKeyResponse aResponse = EKeyWasNotConsumed;
       
   575    
       
   576     // Confirm app is running properly
       
   577     if ( iView && ( aType == EEventKey ) && Document()->IsLaunched())
       
   578         { 
       
   579         // react with all sms classes
       
   580         switch ( aKeyEvent.iCode )
       
   581             {
       
   582             case EKeyUpArrow:
       
   583             case EKeyDownArrow:
       
   584                 {
       
   585                 // Base-editor handles scrolling
       
   586                 iView->OfferKeyEventL( aKeyEvent, aType );
       
   587                 aResponse = EKeyWasConsumed;
       
   588                 }
       
   589                 break;
       
   590             case EKeyDevice3:
       
   591                 {// Selection-key checking (Context sensitive menu)
       
   592                 // (with Class 0 just show the menu)
       
   593                 MenuBar()->SetMenuTitleResourceId( R_SMSV_CONTEXTMENUBAR_CDMA);
       
   594                 MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
   595                 MenuBar()->TryDisplayMenuBarL();
       
   596                 MenuBar()->SetMenuTitleResourceId( R_SMSV_OPTIONSMENUBAR_CDMA );
       
   597                 MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
   598                 aResponse = EKeyWasConsumed;
       
   599                 }
       
   600                 break;
       
   601             case EKeyYes:
       
   602                 {// Send-key checking. Either valid sender's phone number or callback number is valid. 
       
   603                 if ( !iIrBt && !iBioMsg )
       
   604                     { // normal sms
       
   605                     DoHandleSendKeyL();
       
   606                     }
       
   607                 else if ( iValidSenderNumber && !iIrBt )
       
   608                     { // smart message
       
   609                     TBool okToQuery( ETrue );
       
   610                     // Is it biocontrol?
       
   611                     TUint32 permBio = OptionsMenuPermissionsBioL();
       
   612                     okToQuery = ( permBio & EMsgBioCallBack ) ? ETrue : EFalse ;
       
   613                         
       
   614                     
       
   615                   // Launch confirmation query and start calling
       
   616                     if ( okToQuery )
       
   617                         {
       
   618                         if ( iMsgVoIPExtension->IsPreferredTelephonyVoIP() &&
       
   619                              iMsgVoIPExtension->VoIPProfilesExistL() )
       
   620                             {
       
   621                             MsvUiServiceUtilitiesInternal::InternetCallToSenderQueryL( iNumber, iRecipientstring, ETrue );  
       
   622                             }
       
   623                         else
       
   624                             {
       
   625                             MsvUiServiceUtilitiesInternal::CallToSenderQueryL( iNumber, iRecipientstring, ETrue );
       
   626                             }
       
   627                         }
       
   628                     }
       
   629                 else
       
   630                     {
       
   631                     //do nothing
       
   632                     }
       
   633                 aResponse = EKeyWasConsumed;
       
   634                 }
       
   635                 break;
       
   636             default:
       
   637                 break;
       
   638             }
       
   639         
       
   640             switch ( aKeyEvent.iCode )
       
   641                 {
       
   642                 case EKeyRightArrow:
       
   643                     {// Show next message if possible
       
   644                     if ( IsNextMessageAvailableL( ETrue ))
       
   645                         {
       
   646                         NextMessageL( ETrue );
       
   647                         aResponse = EKeyWasConsumed;
       
   648                         }
       
   649                     }
       
   650                     break;
       
   651                 case EKeyLeftArrow:
       
   652                     { // Show prev message if possible
       
   653                     if ( IsNextMessageAvailableL( EFalse ))
       
   654                         {
       
   655                         NextMessageL( EFalse );
       
   656                         aResponse = EKeyWasConsumed;
       
   657                         }
       
   658                     }
       
   659                     break;
       
   660                 case EKeyBackspace:
       
   661                     {
       
   662                     DoFileDeleteL();
       
   663                     aResponse = EKeyWasConsumed;
       
   664                     }
       
   665                     break;
       
   666                 default:
       
   667                     break;
       
   668                 }
       
   669         }
       
   670     else // App is not running properly yet
       
   671         {
       
   672         aResponse = EKeyWasConsumed;
       
   673 
       
   674         }
       
   675     
       
   676     return aResponse; 
       
   677     }
       
   678 
       
   679 
       
   680 // ----------------------------------------------------
       
   681 // CMsgSmsViewerCDMAAppUi::DoHandleSendKeyL
       
   682 // 
       
   683 // ----------------------------------------------------
       
   684 
       
   685 void CMsgSmsViewerCDMAAppUi::DoHandleSendKeyL()
       
   686     {
       
   687     if ( !iMsgVoIPExtension )
       
   688         {
       
   689         return;
       
   690         }
       
   691 
       
   692     TPtrC senderNumber = KNullDesC();
       
   693     TPtrC alias = KNullDesC();
       
   694     TPtrC focusedNumber = KNullDesC();
       
   695         
       
   696     if ( iIsFromEmail ) // case of Email over SMS 
       
   697         {  
       
   698         senderNumber.Set( iEmailAddress );
       
   699         }
       
   700     else // SMS originating address is phone number
       
   701         {
       
   702         if ( iValidSenderNumber ) // if sender's number is valid, choose it first
       
   703             {
       
   704             senderNumber.Set( iNumber );
       
   705             }
       
   706         if ( iRecipientstring.Length() )
       
   707             {
       
   708             alias.Set( *&iRecipientstring );
       
   709             }
       
   710         }
       
   711 
       
   712     if ( IsBodyFocused() && iView->ItemFinder( ) )
       
   713         {
       
   714         const CItemFinder::CFindItemExt& item =
       
   715             iView->ItemFinder( )->CurrentItemExt( );
       
   716         if (    item.iItemDescriptor
       
   717             &&  (   item.iItemType == CItemFinder::EPhoneNumber
       
   718                 ||  item.iItemType == CItemFinder::EEmailAddress ) )
       
   719             {
       
   720             focusedNumber.Set( *(item.iItemDescriptor) );
       
   721             }
       
   722         }
       
   723 
       
   724     MsvUiServiceUtilitiesInternal::InternetOrVoiceCallServiceL( 
       
   725             *iMsgVoIPExtension,
       
   726             senderNumber,
       
   727             alias,
       
   728             focusedNumber,
       
   729             ETrue,
       
   730             iEikonEnv );    
       
   731     }
       
   732 
       
   733 
       
   734 // ----------------------------------------------------
       
   735 // CMsgSmsViewerCDMAAppUi::SetAutomaticHighlightL
       
   736 // 
       
   737 // ----------------------------------------------------
       
   738 void CMsgSmsViewerCDMAAppUi::SetAutomaticHighlightL( const TBool aSwitchON )
       
   739     {
       
   740     __ASSERT_DEBUG( !iGms, Panic( EMsgSmsNotForGms ) );
       
   741     __ASSERT_DEBUG( !iBioMsg, Panic( EMsgSmsNotAllowedForBio ) );
       
   742     if ( iView->ItemFinder() )
       
   743         {
       
   744         // content highlight
       
   745         if ( aSwitchON )
       
   746             { // switch ON
       
   747             iView->ItemFinder()->SetFindModeL( 
       
   748                 CItemFinder::EPhoneNumber |
       
   749                 CItemFinder::EUrlAddress |
       
   750                 CItemFinder::EEmailAddress );
       
   751             }
       
   752         else
       
   753             { // switch OFF
       
   754             iView->ItemFinder()->SetFindModeL( 
       
   755                 CItemFinder::ENoneSelected );
       
   756             }
       
   757         // header highlight     
       
   758         if ( iControlId != EMsgComponentIdTo && ( iValidSenderNumber || iValidEmailAddress) )
       
   759             {
       
   760              static_cast<CMsgAddressControl*>
       
   761                  (iView->ControlById( iControlId ))->SetAddressFieldAutoHighlight( aSwitchON );
       
   762 
       
   763             }
       
   764         }
       
   765     }
       
   766 
       
   767 // ----------------------------------------------------
       
   768 // CMsgSmsViewerCDMAAppUi::ExtractCallingInfoL
       
   769 // 
       
   770 // ----------------------------------------------------
       
   771 void CMsgSmsViewerCDMAAppUi::ExtractCallingInfoL()
       
   772 {
       
   773 
       
   774 
       
   775 	HBufC* callback = NULL;	
       
   776 
       
   777 	callback = iSmsHeader->CdmaMessage().GetCallbackNumberL();
       
   778 	if (callback != NULL)
       
   779 	  {
       
   780 		CleanupStack::PushL(callback);
       
   781 		iCallbackNumber = callback->Des();
       
   782 	    iValidCallbackNumber = CommonPhoneParser::IsValidPhoneNumber( 
       
   783             iCallbackNumber, CommonPhoneParser::EPhoneClientNumber );
       
   784 		CleanupStack::PopAndDestroy(callback);
       
   785 		
       
   786 	  }
       
   787 	// Currently only consider general SMS situation.
       
   788 
       
   789     if ( MsvUiServiceUtilities::IsValidEmailAddressL(iSmsHeader->FromAddress()) 
       
   790     				&& iEmailFeatureSupported )
       
   791       { 
       
   792 	  iIsFromEmail = ETrue;
       
   793 	  iValidEmailAddress = ETrue;
       
   794 	  iVoIPNumber = ETrue;
       
   795 	  iEmailAddress = iSmsHeader->FromAddress();
       
   796       }
       
   797     else
       
   798       {
       
   799       iNumber = iSmsHeader->FromAddress();
       
   800       iValidSenderNumber = CommonPhoneParser::IsValidPhoneNumber( iNumber, 
       
   801             CommonPhoneParser::ESMSNumber );		
       
   802       }
       
   803 	
       
   804 }
       
   805