mobilemessaging/postcard/postcardsrc/PostcardAppUi.cpp
changeset 0 72b543305e3a
child 2 0bf1d54f37d9
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 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:  PostcardAppUi implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <w32std.h>
       
    24 
       
    25 #include <eikapp.h>                 // CEikApplication
       
    26 #include <eikdialg.h>               // CEikDialog
       
    27 #include <eikenv.h>                 // Eikon Enviroment
       
    28 #include <eikmenub.h>               // CEikMenuBar
       
    29 #include <eikmenup.h>               // CEikMenuPane
       
    30 #include <bamdesca.h>               // MDesCArray
       
    31 #include <bautils.h>                // NearestLanguageFile
       
    32 
       
    33 #include <bldvariant.hrh>
       
    34 #include <centralrepository.h>
       
    35 #include <data_caging_path_literals.hrh>
       
    36 #include <ErrorUI.h>
       
    37 #include <featmgr.h>
       
    38 #include <StringLoader.h>
       
    39 
       
    40 #include <aknenv.h>
       
    41 #include <aknconsts.h>
       
    42 #include <AknGlobalMsgQuery.h>      // Global Msg Query
       
    43 #include <AknIndicatorContainer.h>
       
    44 #include <akninputblock.h>          // CAknInputBlock
       
    45 #include <aknnavi.h>                // CAknNavigationControlContainer
       
    46 #include <aknnotewrappers.h>
       
    47 #include <akntitle.h>
       
    48 #include <AknWaitDialog.h>
       
    49 
       
    50 #include <avkon.hrh>
       
    51 #include <avkon.mbg>
       
    52 
       
    53 #include <AknsConstants.h>
       
    54 #include <AknsUtils.h>
       
    55 
       
    56 #include <fbs.h>
       
    57 #include <gulicon.h>
       
    58 #include <txtetext.h>
       
    59 
       
    60 #include <hlplch.h>                 // For HlpLauncher 
       
    61 #include <csxhelp/postcard.hlp.hrh>
       
    62 
       
    63 #include <cntfield.h>
       
    64 #include <cntfldst.h>
       
    65 #include <cntitem.h>				// for ContactItem
       
    66 
       
    67 #include <mtmdef.h>                 // TMsvPartList
       
    68 #include <mtmuibas.h>               // MTM UI
       
    69 #include <msvapi.h>
       
    70 #include <msvstd.hrh>               // KUidMsvMessageEntryValue
       
    71 
       
    72 #include <cmsvattachment.h>
       
    73 #include <mmsvattachmentmanager.h>
       
    74 #include <mmsvattachmentmanagersync.h>
       
    75 
       
    76 #include <msgoperationwait.h>           // for CMsgOperationWait
       
    77 #include <MtmExtendedCapabilities.hrh>  // for KMtmUiFunctionMessageInfo
       
    78 #include <MuiuMsvUiServiceUtilities.h>  // for Diskspace check
       
    79 #include <muiumsvuiserviceutilitiesinternal.h>  // for Offline mode check
       
    80 
       
    81 #include <MsgEditorAppUi.rsg>
       
    82 #include <MsgEditorAppUiExtension.h>// for iMsgEditorAppUiExtension (zoom)
       
    83 #include <MsgEditorCommon.h>
       
    84 
       
    85 
       
    86 #include <mmsclient.h>
       
    87 #include <mmsmsventry.h>
       
    88 
       
    89 #include <messaginginternalcrkeys.h>
       
    90 #include <messagingvariant.hrh>     // postcard feature (variation) bits
       
    91 #include <MsgMediaResolver.h>
       
    92 #include <MsgMedia.hrh>             // TMmsMediaType
       
    93 #include <MsgImageInfo.h>
       
    94 #include <MsgMimeTypes.h>
       
    95 
       
    96 #include <Postcard.rsg>             // resource identifiers
       
    97 #include <postcard.mbg>             // icons
       
    98 #include "Postcard.hrh"             // for EPostcardCmds
       
    99 #include "PostcardAddressForm.h"    // for editing recipient address
       
   100 #include "PostcardAppUi.h"          // class header
       
   101 #include "PostcardCenRep.h"
       
   102 #include "PostcardController.h"     // Controller class
       
   103 #include "PostcardLaf.h"
       
   104 #include "PostcardOperationInsertImage.h" // for inserting images
       
   105 #include "PostcardOperationOpen.h"	// for opening the application
       
   106 #include "PostcardOperationSave.h"	// for saving or sending the postcard
       
   107 #include "PostcardPointerObserver.h"// MPocaPointerEventObserver
       
   108 #include "PostcardPrivateCRKeys.h"  // cenrep keys
       
   109 #include "PostcardQueryWaiter.h"    // for PostcardQueryWaiter
       
   110 #include "PostcardTextDialog.h"		// for editing greeting text
       
   111 #include "PostcardUtils.h"
       
   112 
       
   113 // ========== EXTERNAL DATA STRUCTURES =====================
       
   114 
       
   115 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
   116 
       
   117 // ========== CONSTANTS ====================================
       
   118 
       
   119 const TInt KPostcardMaxSendConfirmationLength = 320;
       
   120 const TInt KPostcardMaxMiniatureCharsPerLine = 100;
       
   121 const TInt KPostcardLegacyWidth = 208; // the width of legacy display
       
   122 const TInt KPostcardQvgaWidth = 320; // the width of legacy display
       
   123 const TInt KPostcardMaxAddressFocusLines = 5; // max number of address focus lines
       
   124 
       
   125 // ========== MACROS =======================================
       
   126 
       
   127 // ========== LOCAL CONSTANTS AND MACROS ===================
       
   128 
       
   129 // ========== MODULE DATA STRUCTURES =======================
       
   130 
       
   131 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
   132 
       
   133 // ========== LOCAL FUNCTIONS ==============================
       
   134 
       
   135 // ========== MEMBER FUNCTIONS =============================
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CPostcardAppUi::CPostcardAppUi
       
   139 // ---------------------------------------------------------
       
   140 CPostcardAppUi::CPostcardAppUi()
       
   141     {
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CPostcardAppUi::ConstructL
       
   146 // ---------------------------------------------------------
       
   147 void CPostcardAppUi::ConstructL()
       
   148     {
       
   149     CMsgEditorAppUi::ConstructL();
       
   150     
       
   151     // We don't have any app ui if launched from idle
       
   152     if ( iEikonEnv->EikAppUi() )
       
   153         {
       
   154         iAbsorber = CAknInputBlock::NewLC();
       
   155         CleanupStack::Pop( iAbsorber );
       
   156         }
       
   157 
       
   158     // Create central repository interface
       
   159     iCenRep = CPostcardCenRep::NewL();
       
   160 
       
   161     // initialize feature manager to check supported features
       
   162     FeatureManager::InitializeLibL();
       
   163     if ( FeatureManager::FeatureSupported( KFeatureIdCamera ) )
       
   164         {
       
   165         iPocaFlags |= EPostcardCamcorder;
       
   166         }
       
   167     if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   168         {
       
   169         iPocaFlags |= EPostcardHelp;
       
   170         }
       
   171     if( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   172         {
       
   173         iPocaFlags |= EPostcardFeatureOffline;
       
   174         }
       
   175     FeatureManager::UnInitializeLib( );
       
   176 
       
   177     // In case the postcard application is installed somewhere else than "Z" drive
       
   178     // we find out the right drive for postcard resource file
       
   179     TParse parseDrive;
       
   180     parseDrive.Set( Application( )->AppFullName( ), NULL, NULL );
       
   181     TPtrC drive = parseDrive.Drive( );
       
   182 
       
   183     TParse parse;
       
   184     parse.Set( KPostcardResourceFile, &KDC_APP_RESOURCE_DIR, NULL );
       
   185     TFileName fileName( parse.FullName() );
       
   186     fileName.Insert( 0, drive );
       
   187     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   188     iResourceFile = iEikonEnv->AddResourceFileL( fileName );
       
   189     parse.Set( KMsgEditorAppUiResourceFile, &KDC_RESOURCE_FILES_DIR, NULL );
       
   190     fileName.Zero( );
       
   191     fileName.Append( parse.FullName() );
       
   192     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   193 	iBaseResourceFile = iEikonEnv->AddResourceFileL( fileName );
       
   194 	
       
   195     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   196         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   197     
       
   198     iTitlePane = static_cast<CAknTitlePane*>
       
   199         ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   200     
       
   201 	if( !iEikonEnv->StartedAsServerApp( ) )
       
   202 		{
       
   203 	    Document().PrepareToLaunchL( this );
       
   204 		}
       
   205 
       
   206     iIdle = CPeriodic::NewL( EPriorityNormal - 1 );
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // CPostcardAppUi::~CPostcardAppUi
       
   211 // ---------------------------------------------------------
       
   212 CPostcardAppUi::~CPostcardAppUi()
       
   213     {
       
   214     // remove resource file from CONE-maintained resource file list.
       
   215     if ( iResourceFile )
       
   216         {
       
   217         iEikonEnv->DeleteResourceFile( iResourceFile );
       
   218         }
       
   219     if ( iBaseResourceFile )
       
   220         {
       
   221         iEikonEnv->DeleteResourceFile( iBaseResourceFile );
       
   222         }
       
   223 
       
   224     delete iController;
       
   225 
       
   226 	delete iGreeting;
       
   227 	delete iContact;
       
   228 
       
   229 	delete iImageInfo;
       
   230 	
       
   231 	delete iIdle;
       
   232 
       
   233     delete iAppIcon;
       
   234     
       
   235 	if( iMessageQuery )
       
   236 		{
       
   237         iMessageQuery->CancelMsgQuery();
       
   238         delete iMessageQuery;
       
   239         iMessageQuery = NULL;		
       
   240 		}
       
   241 
       
   242     delete iSendText;
       
   243 
       
   244     delete iCenRep;
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------
       
   248 // LaunchViewL
       
   249 // ---------------------------------------------------------
       
   250 void CPostcardAppUi::LaunchViewL()
       
   251     {
       
   252     // First show wait note and start the launch process
       
   253     ShowWaitNoteL( R_POSTCARD_WAIT_OPENING, EFalse );
       
   254 
       
   255     const TMsvEntry& entry = Document( ).Entry( );
       
   256     if ( entry.iType.iUid != KUidMsvMessageEntryValue )
       
   257         {
       
   258         User::Leave( KErrGeneral );
       
   259         }
       
   260 
       
   261     TRAPD( error, Document( ).Mtm( ).LoadMessageL( ) );
       
   262     if ( error )
       
   263         {
       
   264         User::Leave( error );
       
   265         }
       
   266     Document( ).SetMessageType( );
       
   267 
       
   268   	if ( !entry.ReadOnly() ) // editor
       
   269     	{
       
   270    	   	// End key should not close application in editor
       
   271 	   	CMsgEditorAppUi::SetCloseWithEndKey( EFalse );
       
   272     	}
       
   273 
       
   274     if( entry.ReadOnly() && !iNaviDecorator )
       
   275         {
       
   276         CreateViewerNaviPaneL( Document().Entry().iDate, EMsgEditorMsgPriorityNormal, ETrue );    
       
   277         iNaviPane->PushL( *iNaviDecorator );  // <- This has nothing to do with cleanup-stack!    
       
   278         }
       
   279 
       
   280     delete iAbsorber;
       
   281     iAbsorber = NULL;
       
   282 
       
   283     iController = CPostcardController::NewL( Document()
       
   284 #ifdef RD_SCALABLE_UI_V2
       
   285         , *this
       
   286 #endif
       
   287         );
       
   288 
       
   289     CreateAndSetTitleIconL();
       
   290     
       
   291     RefreshFocusLinesL( );
       
   292 
       
   293     iOperation = CPostcardOperationOpen::NewL(
       
   294         *this,
       
   295         Document(),
       
   296         *this,
       
   297         FsSession() );
       
   298     iOperation->Start( EFalse );
       
   299     }
       
   300 
       
   301 
       
   302 // ---------------------------------------------------------
       
   303 // CanSaveMessageL
       
   304 // ---------------------------------------------------------
       
   305 TBool CPostcardAppUi::CanSaveMessageL( TInt aAmount )
       
   306     {
       
   307     return !( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( 
       
   308         Document().Session(), 
       
   309         aAmount ) );
       
   310     }
       
   311 
       
   312 // ---------------------------------------------------------
       
   313 // DoMsgSaveExitL - called from options menu
       
   314 // ---------------------------------------------------------
       
   315 void CPostcardAppUi::DoMsgSaveExitL()
       
   316     {
       
   317     if( iMsgType == EPostcardSent )
       
   318         { // Msg is a sent one so just close the application
       
   319         Exit();
       
   320         return;
       
   321         }
       
   322         
       
   323     if ( CAknEnv::AppWithShutterRunning() )
       
   324         {
       
   325         iPocaFlags |= EPostcardRunAppShutterAtExit;
       
   326         }
       
   327 
       
   328     if ( IsMessageEmpty() ) 
       
   329         {
       
   330         if ( Document().Mtm().Entry().Entry().Visible() )
       
   331             {
       
   332             ShowInformationNoteL( R_POSTCARD_MESSAGE_DELETED, ETrue );
       
   333             }
       
   334         DeleteCurrentEntryL();
       
   335         }
       
   336     else if ( Document( ).Modified( ) && CanSaveMessageL() )
       
   337         {
       
   338         if ( IsForeground() )
       
   339             {
       
   340             TInt resId = R_POSTCARD_SAVING_NEW;
       
   341             if( iMsgType == EPostcardDraft )
       
   342                 { // We are saving an old postcard
       
   343                 resId = R_POSTCARD_SAVING;
       
   344                 }
       
   345 
       
   346             iPocaFlags |= EPostcardClosing;
       
   347             DoSaveL();
       
   348             ShowWaitNoteL( resId, EFalse );
       
   349             }
       
   350         else
       
   351             {
       
   352             TRAP_IGNORE( DoSaveL() );
       
   353             }
       
   354         BeginActiveWait();
       
   355         if ( iPocaFlags & EPostcardRunAppShutterAtExit )
       
   356             {
       
   357             RunAppShutter();
       
   358             }
       
   359         }
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------
       
   363 // CompleteLaunchViewL
       
   364 // ---------------------------------------------------------
       
   365 void CPostcardAppUi::CompleteLaunchViewL( )
       
   366     {
       
   367     iController->ActivateL( );
       
   368 	RemoveWaitNote( );
       
   369 	
       
   370 	iMsgType = Document( ).MessageType( );
       
   371     if( iMsgType == EPostcardSent )
       
   372         {
       
   373 	    iController->SetFocused( EPostcardImage );
       
   374         }
       
   375     else
       
   376         {
       
   377 	    iController->SetFocused( EPostcardRecipient );
       
   378             
       
   379         // If postcard editor is opened then disable the dialer 
       
   380         iAvkonAppUi->SetKeyEventFlags( 
       
   381               CAknAppUiBase::EDisableSendKeyShort | 
       
   382               CAknAppUiBase::EDisableSendKeyLong );	
       
   383         }
       
   384     SetMiddleSoftkeyL(); // set msk for this view
       
   385     if( iMsgType == EPostcardSendAs )
       
   386         {
       
   387         CheckLengthsL(  );
       
   388         }
       
   389     else if( iMsgType == EPostcardForward )
       
   390         {
       
   391         DoEditAddressL( );
       
   392         }
       
   393     iController->DrawDeferred( );
       
   394     iPocaFlags |= EPostcardLaunchSuccessful;
       
   395     }
       
   396 
       
   397 // ---------------------------------------------------------
       
   398 // CPostcardAppUi::HandleKeyEventL
       
   399 // ---------------------------------------------------------
       
   400 TKeyResponse CPostcardAppUi::HandleKeyEventL(
       
   401     const TKeyEvent& aKeyEvent, TEventCode aType )
       
   402     {
       
   403     
       
   404     if ( !Document( ).IsLaunched( ) )
       
   405         { // still launching
       
   406         return EKeyWasConsumed;
       
   407         }
       
   408 
       
   409 	if( aType != EEventKey )
       
   410 		{
       
   411 		return EKeyWasNotConsumed;
       
   412 		}
       
   413 
       
   414     switch ( aKeyEvent.iCode )
       
   415         {
       
   416         case EKeyOK:
       
   417         case EKeyEnter:         //Enter Key
       
   418             {
       
   419             // Selection key: Show context menus
       
   420             DoSelectionKeyL();
       
   421             return EKeyWasConsumed;
       
   422             }
       
   423 
       
   424         case EKeyYes:
       
   425             {
       
   426             // In view mode there's no function in Yes key
       
   427             if( iMsgType != EPostcardSent )
       
   428                 {
       
   429                 if( !ContactHasData( *iContact ) )
       
   430                     { // If there's no contact data -> open edit address dialog
       
   431                     DoEditAddressL( );
       
   432                     }
       
   433                 else
       
   434                     { // Else start sending process
       
   435                     DoSendL( );                
       
   436                     }
       
   437                 }
       
   438             return EKeyWasConsumed;
       
   439             }
       
   440         case EKeyBackspace:
       
   441         case EKeyDelete:
       
   442             {
       
   443             // Either delete image or the whole postcard entry
       
   444             DoBackspaceL( );
       
   445             return EKeyWasConsumed;
       
   446             }
       
   447         default:
       
   448             break;
       
   449         }
       
   450     switch ( aKeyEvent.iScanCode )
       
   451         {
       
   452         case EStdKeyLeftArrow:  // FALLTHROUGH
       
   453         case EStdKeyRightArrow:
       
   454             if( iMsgType == EPostcardSent && iController->Focused( ) == EPostcardImage )
       
   455                 {
       
   456                 return NavigateBetweenMessagesL(
       
   457                     aKeyEvent.iScanCode == EStdKeyRightArrow ?
       
   458                     ETrue : EFalse );
       
   459                 }
       
   460 		    //lint -fallthrough
       
   461         case EStdKeyUpArrow:    // FALLTHROUGH
       
   462         case EStdKeyDownArrow:  // FALLTHROUGH
       
   463             {
       
   464             if( !( iPocaFlags & EPostcardGreetingActive ) && 
       
   465             	!( iPocaFlags & EPostcardRecipientActive ) )
       
   466             	{
       
   467 	            iController->Move( aKeyEvent.iScanCode );
       
   468 	            SetMiddleSoftkeyL(); // set msk for this view
       
   469 	            
       
   470                 if ( iMsgType == EPostcardSent )
       
   471                     {
       
   472                     // In viewer
       
   473                     if ( iController->Focused() != EPostcardImage )
       
   474                         {
       
   475                         // Viewer does not have navigation arrows in text side
       
   476                         iNaviPane->Pop( iNaviDecorator );
       
   477                         }
       
   478                     else
       
   479                         {
       
   480                         iNaviPane->PushL( *iNaviDecorator );
       
   481                         }
       
   482                     }
       
   483             	}
       
   484                 
       
   485             return EKeyWasConsumed;
       
   486             }
       
   487         default:
       
   488         	{
       
   489 	        if( iMsgType != EPostcardSent && iController->Focused( ) == EPostcardText )
       
   490 	            {
       
   491 	            if( !( iPocaFlags & EPostcardGreetingActive ) )
       
   492 	            	{
       
   493 	            	if( aKeyEvent.iCode >= 35 && aKeyEvent.iCode <= 255 )
       
   494 	            	    {
       
   495     		            DoEditGreetingL( aKeyEvent );            		            	    
       
   496 	            	    }
       
   497 	            	}
       
   498 	            }
       
   499 	        else if( iMsgType != EPostcardSent && iController->Focused( ) == EPostcardRecipient )
       
   500 	            {
       
   501 	            if( !( iPocaFlags & EPostcardRecipientActive ) )
       
   502 	            	{
       
   503 	            	if( aKeyEvent.iCode >= 35 && aKeyEvent.iCode <= 255 )
       
   504 	            	    {
       
   505     		            DoEditAddressL( aKeyEvent );
       
   506 	            	    }
       
   507 	            	}
       
   508 	            }
       
   509             break;
       
   510         	}
       
   511         }
       
   512     return EKeyWasNotConsumed;
       
   513     }
       
   514 
       
   515 // ---------------------------------------------------------
       
   516 // HandleCommandL
       
   517 // ---------------------------------------------------------
       
   518 void CPostcardAppUi::HandleCommandL( TInt aCommand )
       
   519     {
       
   520     if ( aCommand != EEikCmdExit &&
       
   521          !Document().IsLaunched() )
       
   522         {
       
   523         return;
       
   524         }
       
   525     switch (aCommand)
       
   526         {
       
   527         case EPostcardCmdSend:
       
   528             DoSendL( );
       
   529             break;
       
   530         case EPostcardCmdEditAddress:
       
   531             DoEditAddressL( );
       
   532             break;
       
   533         case EPostcardCmdEditGreeting:
       
   534             DoEditGreetingL( );
       
   535             break;
       
   536         case EPostcardCmdInsertFromGallery:
       
   537             DoInsertImageL( MsgAttachmentUtils::EImage );
       
   538             break;
       
   539         case EPostcardCmdInsertFromCamera:
       
   540             DoInsertImageL( MsgAttachmentUtils::ENewImage );
       
   541             break;
       
   542         case EPostcardCmdReplaceFromGallery:
       
   543             DoInsertImageL( MsgAttachmentUtils::EImage );
       
   544             break;
       
   545         case EPostcardCmdReplaceFromCamera:
       
   546             DoInsertImageL( MsgAttachmentUtils::ENewImage );
       
   547             break;
       
   548         case EPostcardCmdDelete:
       
   549             DoBackspaceL( );
       
   550             break;
       
   551         case EPostcardCmdMessageInfo:
       
   552             DoUpdateEntryAndShowMessageInfoL( );
       
   553             break;
       
   554         case EPostcardCmdForward:
       
   555             DoForwardMessageL( );
       
   556             break;
       
   557         case EAknSoftkeyClose:
       
   558         	DoBackSaveL( );
       
   559         	break;
       
   560         case EAknSoftkeyEdit: // falltrough
       
   561         case EAknSoftkeyOpen:
       
   562         	DoSelectionKeyL( );
       
   563         	break;
       
   564         case EAknCmdHelp:
       
   565             {            
       
   566             if( iMsgType == EPostcardSent )
       
   567                 {
       
   568                 LaunchHelpL( KMMS_POSTCARD_HLP_MAIN_VIEW() );
       
   569                 }
       
   570             else
       
   571                 {
       
   572                 LaunchHelpL( KMMS_POSTCARD_HLP_MAIN_EDIT() );                
       
   573                 }
       
   574             break;
       
   575             }
       
   576         case EAknCmdExit:
       
   577         case EEikCmdExit:
       
   578             RemoveWaitNote();
       
   579             ExitAndSaveL();
       
   580             break;
       
   581         default:
       
   582             break;
       
   583         }
       
   584     return;
       
   585     }
       
   586 
       
   587 // ---------------------------------------------------------
       
   588 // DynInitMenuPaneL
       
   589 // ---------------------------------------------------------
       
   590 void CPostcardAppUi::DynInitMenuPaneL( TInt aMenuId, CEikMenuPane* aMenuPane )
       
   591     {
       
   592     switch ( aMenuId )
       
   593         {
       
   594         case R_POSTCARD_MAIN_OPTIONS:
       
   595             DynInitMainMenuL( aMenuPane );
       
   596             break;
       
   597 
       
   598         case R_POSTCARD_INSERT_SUBMENU:
       
   599         case R_POSTCARD_REPLACE_SUBMENU:
       
   600             DynInitInsertSubMenuL( aMenuPane );
       
   601             break;
       
   602 
       
   603         case R_POSTCARD_CONTEXT_OPTIONS:
       
   604             DynInitContextMenuL( aMenuPane );
       
   605             break;
       
   606         
       
   607         default:
       
   608             break;
       
   609         }
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------
       
   613 // DynInitMainMenuL
       
   614 // ---------------------------------------------------------
       
   615 void CPostcardAppUi::DynInitMainMenuL( CEikMenuPane* aMenuPane )
       
   616     {
       
   617     aMenuPane->SetItemDimmed( EPostcardCmdSend, 
       
   618         IsMainMenuOptionInvisible( EPostcardCmdSend ));
       
   619     aMenuPane->SetItemDimmed( EPostcardCmdEditAddress, 
       
   620         IsMainMenuOptionInvisible( EPostcardCmdEditAddress ));
       
   621     aMenuPane->SetItemDimmed( EPostcardCmdEditGreeting, 
       
   622         IsMainMenuOptionInvisible( EPostcardCmdEditGreeting ));
       
   623     aMenuPane->SetItemDimmed( EPostcardCmdInsertSubmenu, 
       
   624         IsMainMenuOptionInvisible( EPostcardCmdInsertSubmenu ));
       
   625     aMenuPane->SetItemDimmed( EPostcardCmdReplaceSubmenu, 
       
   626         IsMainMenuOptionInvisible( EPostcardCmdReplaceSubmenu ));
       
   627     aMenuPane->SetItemDimmed( EPostcardCmdInsertFromGallery, 
       
   628         IsMainMenuOptionInvisible( EPostcardCmdInsertFromGallery ));
       
   629     aMenuPane->SetItemDimmed( EPostcardCmdReplaceFromGallery, 
       
   630         IsMainMenuOptionInvisible( EPostcardCmdReplaceFromGallery ));
       
   631     aMenuPane->SetItemDimmed( EPostcardCmdForward, 
       
   632         IsMainMenuOptionInvisible( EPostcardCmdForward ));
       
   633     aMenuPane->SetItemDimmed( EPostcardCmdDelete, 
       
   634         IsMainMenuOptionInvisible( EPostcardCmdDelete ));
       
   635     aMenuPane->SetItemDimmed( EPostcardCmdMessageInfo, 
       
   636         IsMainMenuOptionInvisible( EPostcardCmdMessageInfo ));
       
   637     aMenuPane->SetItemDimmed( EAknCmdHelp, 
       
   638         IsMainMenuOptionInvisible( EAknCmdHelp ));
       
   639     aMenuPane->SetItemDimmed( EAknCmdExit, 
       
   640         IsMainMenuOptionInvisible( EAknCmdExit ));
       
   641     }
       
   642 
       
   643 // ---------------------------------------------------------
       
   644 // DynInitInsertSubMenuL
       
   645 // ---------------------------------------------------------
       
   646 void CPostcardAppUi::DynInitInsertSubMenuL( CEikMenuPane* aMenuPane )
       
   647     {
       
   648     // If insert/replace submenu is visible -> from Gallery is always visible!
       
   649     if ( !iImage )
       
   650         {
       
   651         aMenuPane->SetItemDimmed( EPostcardCmdInsertFromCamera, 
       
   652                 IsMainMenuOptionInvisible( EPostcardCmdInsertFromCamera ));
       
   653         }
       
   654     else
       
   655         {
       
   656         aMenuPane->SetItemDimmed( EPostcardCmdReplaceFromCamera, 
       
   657                 IsMainMenuOptionInvisible( EPostcardCmdReplaceFromCamera ));
       
   658         }
       
   659     
       
   660     }
       
   661 
       
   662 // ---------------------------------------------------------
       
   663 // DynInitContextMenuL
       
   664 // ---------------------------------------------------------
       
   665 void CPostcardAppUi::DynInitContextMenuL( CEikMenuPane* aMenuPane )
       
   666     {
       
   667     aMenuPane->SetItemDimmed( EPostcardCmdInsertSubmenu, 
       
   668         IsMainMenuOptionInvisible( EPostcardCmdInsertSubmenu ));
       
   669     aMenuPane->SetItemDimmed( EPostcardCmdReplaceSubmenu, 
       
   670         IsMainMenuOptionInvisible( EPostcardCmdReplaceSubmenu ));
       
   671     aMenuPane->SetItemDimmed( EPostcardCmdInsertFromGallery, 
       
   672         IsMainMenuOptionInvisible( EPostcardCmdInsertFromGallery ));
       
   673     aMenuPane->SetItemDimmed( EPostcardCmdReplaceFromGallery, 
       
   674         IsMainMenuOptionInvisible( EPostcardCmdReplaceFromGallery ));
       
   675     }
       
   676 
       
   677 // ---------------------------------------------------------
       
   678 // IsMainMenuOptionInvisible
       
   679 // ---------------------------------------------------------
       
   680 TBool CPostcardAppUi::IsMainMenuOptionInvisible( TInt aMenuItem )
       
   681     {
       
   682     TBool retVal( ETrue ); // Everything first invisible
       
   683     TPostcardPart focused = iController->Focused( );
       
   684 
       
   685     switch ( aMenuItem )
       
   686         {
       
   687         case EPostcardCmdSend:
       
   688             if( iMsgType != EPostcardSent )
       
   689                 {
       
   690                 if( ContactHasData( *iContact ) )
       
   691                     {
       
   692                     // If there's contact data -> show "Send"
       
   693                     retVal = EFalse;                
       
   694                     }
       
   695                 }
       
   696             break;
       
   697         case EPostcardCmdEditAddress:
       
   698             if( iMsgType != EPostcardSent && focused != EPostcardImage )
       
   699                 {
       
   700                 retVal = EFalse;
       
   701                 }
       
   702             break;
       
   703         case EPostcardCmdEditGreeting:
       
   704             if( iMsgType != EPostcardSent && focused != EPostcardImage )
       
   705                 {
       
   706                 retVal = EFalse;
       
   707                 }
       
   708             break;
       
   709         case EPostcardCmdInsertSubmenu:
       
   710             if( iMsgType != EPostcardSent && !iImage )
       
   711                 {
       
   712                 if( iPocaFlags & EPostcardCamcorder )
       
   713                 	{
       
   714 	                retVal = EFalse;            		
       
   715                 	}
       
   716                 }
       
   717             break;
       
   718         case EPostcardCmdReplaceSubmenu:
       
   719             if( iMsgType != EPostcardSent && iImage )
       
   720                 {
       
   721                 if( iPocaFlags & EPostcardCamcorder )
       
   722                 	{
       
   723 	                retVal = EFalse;            		
       
   724                 	}
       
   725                 }
       
   726             break;
       
   727         case EPostcardCmdInsertFromGallery:
       
   728             if( iMsgType != EPostcardSent && !iImage )
       
   729                 {
       
   730                 if( !(iPocaFlags & EPostcardCamcorder ) )
       
   731                 	{
       
   732 	                retVal = EFalse;            		
       
   733                 	}
       
   734                 }
       
   735             break;
       
   736         case EPostcardCmdReplaceFromGallery:
       
   737             if( iMsgType != EPostcardSent && iImage )
       
   738                 {
       
   739                 if( !(iPocaFlags & EPostcardCamcorder ) )
       
   740                 	{
       
   741 	                retVal = EFalse;            		
       
   742                 	}
       
   743                 }
       
   744             break;
       
   745         case EPostcardCmdInsertFromCamera:
       
   746             if( iMsgType != EPostcardSent )
       
   747                 {
       
   748                 if( iPocaFlags & EPostcardCamcorder )
       
   749                 	{
       
   750 	                retVal = EFalse;            		
       
   751                 	}
       
   752                 }
       
   753             break;
       
   754         case EPostcardCmdReplaceFromCamera:
       
   755             if( iMsgType != EPostcardSent && iImage )
       
   756                 {
       
   757                 if( iPocaFlags & EPostcardCamcorder )
       
   758                     {
       
   759                     retVal = EFalse;                    
       
   760                     }
       
   761                 }
       
   762             break;
       
   763         case EPostcardCmdForward:
       
   764             if( iMsgType == EPostcardSent )
       
   765                 {
       
   766                 retVal = EFalse;
       
   767                 }
       
   768             break;
       
   769         case EPostcardCmdDelete:
       
   770             if( iMsgType == EPostcardSent )
       
   771                 {
       
   772                 retVal = EFalse;
       
   773                 }
       
   774             break;
       
   775         case EPostcardCmdMessageInfo:
       
   776             retVal = EFalse;
       
   777             break;
       
   778         case EAknCmdHelp:
       
   779 			if( iPocaFlags & EPostcardHelp )
       
   780 				{
       
   781 				retVal = EFalse;				
       
   782 				}
       
   783 			break;
       
   784         case EAknCmdExit:
       
   785             retVal = EFalse;
       
   786             break;
       
   787         default:
       
   788             ;
       
   789         }
       
   790     return retVal;
       
   791     }
       
   792 
       
   793 // ---------------------------------------------------------
       
   794 // DoSendL
       
   795 // ---------------------------------------------------------
       
   796 void CPostcardAppUi::DoSendL()
       
   797     {
       
   798 	// Let's first check all the fields are present
       
   799 	if( !iImage )
       
   800 		{
       
   801 		ShowInformationNoteL( R_POSTCARD_SEND_INSERT_IMAGE, EFalse );
       
   802 	    iController->SetFocused( EPostcardImage );
       
   803 	    SetMiddleSoftkeyL();
       
   804 	    iController->DrawDeferred( );    
       
   805 		return;
       
   806 		}
       
   807 
       
   808     // Check that mandatory address fields are present
       
   809     TInt mandatories = MandatoryAddressFields();
       
   810     CContactItemFieldSet& fields = iContact->CardFields();
       
   811     TBool allFilled = ETrue;
       
   812     TInt i = EPostcardAddressName;
       
   813     for( ; mandatories && allFilled ; i++, mandatories >>= 1 )
       
   814         {
       
   815         if( mandatories & 1 )
       
   816             {
       
   817             const CContactItemField* field = TPostcardUtils::FieldOrNull( fields,
       
   818                 TPostcardUtils::ContactItemNameFromId( i ) );
       
   819             allFilled = ( field && field->TextStorage()->IsFull() );
       
   820             }
       
   821         }
       
   822     // If not all filled, open the edit address dialog with the right field
       
   823     if( !allFilled )
       
   824         {
       
   825         DoEditAddressL( TKeyEvent(), i - 1 );
       
   826 		return;
       
   827         }
       
   828 
       
   829     // Address is ok, let's still check the lengths..
       
   830 	if( !CheckLengthsL( ) )
       
   831 		{
       
   832 		return;
       
   833 		}
       
   834 	
       
   835 	// Here we are ready to send -> now let's ask the confirmation
       
   836     if( iMessageQuery )
       
   837         {
       
   838         iMessageQuery->CancelMsgQuery();
       
   839         delete iMessageQuery;
       
   840         iMessageQuery = NULL;
       
   841         }
       
   842 
       
   843    
       
   844     iMessageQuery = CAknGlobalMsgQuery::NewL();
       
   845 
       
   846     HBufC* addressString = CreateAddressStringForSendConfirmLC();
       
   847 
       
   848     delete iSendText; iSendText = NULL;
       
   849     iSendText = StringLoader::LoadL( R_POSTCARD_RECIPIENT_PROMPT_TEXT,
       
   850         *addressString );
       
   851     CleanupStack::PopAndDestroy( addressString ); // addressString
       
   852 
       
   853     CPostcardQueryWaiter* queryWaiter = new (ELeave) CPostcardQueryWaiter( this );
       
   854     CleanupStack::PushL( queryWaiter );
       
   855 
       
   856     iMessageQuery->ShowMsgQueryL( 
       
   857             queryWaiter->iStatus,
       
   858             *iSendText,
       
   859             R_AVKON_SOFTKEYS_SEND_CANCEL__SEND,
       
   860             KNullDesC(),
       
   861             KAvkonBitmapFile,
       
   862             EMbmAvkonQgn_note_query,
       
   863             EMbmAvkonQgn_note_query_mask );
       
   864 
       
   865     queryWaiter->SetActiveD(); // Will be deleted when the query is dismissed.
       
   866     CleanupStack::Pop( queryWaiter ); // queryWaiter
       
   867 
       
   868     // The rest of the sending process is done in QueryWaiterCallback !!
       
   869     }
       
   870 
       
   871 // ---------------------------------------------------------
       
   872 // DoSaveL
       
   873 // ---------------------------------------------------------
       
   874 void CPostcardAppUi::DoSaveL( )
       
   875     {
       
   876     if ( iOperation && iOperation->IsActive() )
       
   877         {
       
   878         // Save operation already in progress, don't start another
       
   879         return;
       
   880         }
       
   881     
       
   882     delete iOperation;
       
   883     iOperation = NULL;
       
   884     
       
   885     iOperation = CPostcardOperationSave::NewL(
       
   886         *this,
       
   887         Document(),
       
   888         *this,
       
   889         FsSession( ),
       
   890         *iContact,
       
   891         *iGreeting
       
   892         );
       
   893         
       
   894     iOperation->Start( EFalse );    // EFalse means no sending
       
   895     
       
   896     iAbsorber = CAknInputBlock::NewLC();
       
   897     CleanupStack::Pop( iAbsorber );
       
   898     }
       
   899 
       
   900 // ---------------------------------------------------------
       
   901 // DoBackSaveL
       
   902 // ---------------------------------------------------------
       
   903 void CPostcardAppUi::DoBackSaveL()
       
   904     {
       
   905     if( iMsgType == EPostcardSent )
       
   906         {
       
   907         // Msg is a sent one so just close the application
       
   908         Exit( EAknSoftkeyClose );
       
   909         return;
       
   910         }
       
   911         
       
   912     if ( IsMessageEmpty() ) 
       
   913         {
       
   914         if ( Document().Mtm().Entry().Entry().Visible() )
       
   915             {
       
   916             ShowInformationNoteL( R_POSTCARD_MESSAGE_DELETED, ETrue );
       
   917             }
       
   918         DeleteAndExitL();
       
   919         }
       
   920     else
       
   921         {
       
   922         TInt closeVal = ShowCloseQueryL( );
       
   923         if ( closeVal == EPostcardCloseCancel )
       
   924             {
       
   925             // User cancels the query
       
   926             return;
       
   927             }
       
   928         else if ( closeVal == EPostcardCloseDelete )
       
   929             {
       
   930             DeleteAndExitL();
       
   931             }
       
   932         else
       
   933             {
       
   934             // Save message
       
   935             if ( Document( ).Modified( ) )
       
   936                 {
       
   937                 if ( CanSaveMessageL() ) 
       
   938                     {
       
   939                     TInt resId = R_POSTCARD_SAVING_NEW;
       
   940                     if( iMsgType == EPostcardDraft )
       
   941                         {
       
   942                         // We are saving an old postcard
       
   943                         resId = R_POSTCARD_SAVING;
       
   944                         }
       
   945                         
       
   946                     iPocaFlags |= EPostcardClosing;
       
   947                     DoSaveL( );
       
   948                     ShowWaitNoteL( resId, ETrue );
       
   949                     BeginActiveWait();
       
   950                     }
       
   951                 else
       
   952                     {
       
   953                     if ( ShowConfirmationQueryL( R_POSTCARD_NO_SPACE_TO_SAVE ) )
       
   954                         {
       
   955                         // Exit without saving.
       
   956                         Exit( EAknSoftkeyClose );
       
   957                         }
       
   958                     //else nothing.
       
   959                     }
       
   960                 }
       
   961             else
       
   962                 {
       
   963                 // No changes -> just close.
       
   964                 Exit( EAknSoftkeyClose );
       
   965                 }
       
   966             }
       
   967         }        
       
   968     }
       
   969 
       
   970 // ---------------------------------------------------------
       
   971 // IsMessageEmpty
       
   972 // ---------------------------------------------------------
       
   973 TBool CPostcardAppUi::IsMessageEmpty( )
       
   974     {
       
   975     if( !iImage && iGreetingLength == 0 &&
       
   976         ( !iContact || !ContactHasData( *iContact ) ) )
       
   977         {
       
   978         return ETrue;
       
   979         }
       
   980     return EFalse;
       
   981     }
       
   982 
       
   983 // ---------------------------------------------------------
       
   984 // DoUpdateEntryAndShowMessageInfoL
       
   985 // ---------------------------------------------------------
       
   986 void CPostcardAppUi::DoUpdateEntryAndShowMessageInfoL( )
       
   987     {
       
   988     // First update the TMsvEntry
       
   989     if( iMsgType != EPostcardSent )
       
   990         { 
       
   991         // We are dealing with unsent message -> save recipient/text for now
       
   992         TMmsMsvEntry tEntry = static_cast<TMmsMsvEntry>( Document().Entry() );
       
   993 
       
   994         tEntry.iDate.UniversalTime();
       
   995 
       
   996         // Let's find name field
       
   997         _LIT( KEmptyName, "");
       
   998         TPtrC namePtr( KEmptyName );
       
   999         CContactItemFieldSet& fieldSet =  iContact->CardFields();
       
  1000         for( TInt i = 0; i<fieldSet.Count(); i++ )
       
  1001             {
       
  1002             if( !fieldSet[i].Label().Compare( TPostcardUtils::ContactItemNameFromId( EPostcardAddressName ) ) )
       
  1003                 {
       
  1004                 namePtr.Set( fieldSet[i].TextStorage()->Text() );
       
  1005                 break;
       
  1006                 }
       
  1007             }
       
  1008         tEntry.iDetails.Set( namePtr ) ;
       
  1009         // Let's set the subject
       
  1010         tEntry.iDescription.Set(
       
  1011             iGreeting->Read( 0, Min( iGreetingLength, 20 ) ) );
       
  1012         
       
  1013     	tEntry.iBioType = KUidMsgSubTypeMmsPostcard.iUid;
       
  1014         
       
  1015         Document().CurrentEntry().ChangeL( tEntry );
       
  1016         }
       
  1017     // And now call message info
       
  1018     DoShowMessageInfoL();
       
  1019     }
       
  1020 
       
  1021 // ---------------------------------------------------------
       
  1022 // DoShowMessageInfoL
       
  1023 // ---------------------------------------------------------
       
  1024 void CPostcardAppUi::DoShowMessageInfoL()
       
  1025     {
       
  1026     // Selection is not really used, just given as a parameter
       
  1027     CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
       
  1028     CleanupStack::PushL( selection );
       
  1029     TBuf8<1> param;
       
  1030     param.Zero();
       
  1031 
       
  1032     CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( Document() );
       
  1033     
       
  1034     CMsvOperation* op = Document().MtmUi().InvokeAsyncFunctionL(
       
  1035         KMtmUiFunctionMessageInfo,
       
  1036         *selection,
       
  1037         watch->iStatus,
       
  1038         param );
       
  1039     CleanupStack::Pop( watch ); // watch
       
  1040     Document().AddSingleOperationL( op, watch );
       
  1041 
       
  1042     CleanupStack::PopAndDestroy( selection ); // selection
       
  1043     }
       
  1044 
       
  1045 // ---------------------------------------------------------
       
  1046 // DoBackspaceL
       
  1047 // ---------------------------------------------------------
       
  1048 void CPostcardAppUi::DoBackspaceL( )
       
  1049     {
       
  1050     if( iMsgType == EPostcardSent )
       
  1051         {
       
  1052         if( ShowConfirmationQueryL( R_POSTCARD_DELETE_MESSAGE ) )
       
  1053             {
       
  1054             DeleteAndExitL( );
       
  1055             }
       
  1056         }
       
  1057     else 
       
  1058         {
       
  1059         if( iController->Focused( ) == EPostcardImage && iImage )
       
  1060             {
       
  1061             if( ShowConfirmationQueryL( R_POSTCARD_REMOVE_IMAGE ) )
       
  1062             	{
       
  1063 				// Lets go thru the attas to find the right atta
       
  1064         		CMsvStore* editStore = Document( ).Mtm( ).Entry( ).EditStoreL( );
       
  1065 				MMsvAttachmentManager* manager = &( editStore->AttachmentManagerL( ) );
       
  1066 			    TInt count = manager->AttachmentCount( );
       
  1067     			CMsvAttachment* atta = NULL;
       
  1068     			TInt a = 0;
       
  1069 			    for( ; a < count; a++)
       
  1070         			{
       
  1071 			        atta = manager->GetAttachmentInfoL( a );
       
  1072         			CleanupStack::PushL( atta );
       
  1073         			if( Document( ).IsImage( atta->MimeType( ) ) )
       
  1074         				{
       
  1075 						CleanupStack::PopAndDestroy( atta );
       
  1076         				break;
       
  1077         				}
       
  1078 					CleanupStack::PopAndDestroy( atta );
       
  1079         			}
       
  1080         		if( a > -1 && a < count )
       
  1081         			{
       
  1082         			// and delete atta if found
       
  1083 					editStore->AttachmentManagerExtensionsL( ).RemoveAttachmentL( a );    				
       
  1084         			}
       
  1085 		    	editStore->CommitL( );
       
  1086 			    delete editStore;
       
  1087                 // Lets nullify the icon in Controller
       
  1088     	        iController->SetBitmap( EPostcardImage, NULL );
       
  1089 	            iImage = NULL;
       
  1090 	            // And draw the UI again
       
  1091         		iController->DrawDeferred( );
       
  1092             	}
       
  1093             }
       
  1094         }
       
  1095     }
       
  1096 
       
  1097 // ---------------------------------------------------------
       
  1098 // DoForwardMessageL
       
  1099 // ---------------------------------------------------------
       
  1100 void CPostcardAppUi::DoForwardMessageL( )
       
  1101     {
       
  1102     TMsvPartList parts =
       
  1103         KMsvMessagePartBody |
       
  1104         KMsvMessagePartDescription |
       
  1105         KMsvMessagePartAttachments;
       
  1106 
       
  1107     CBaseMtmUi& mtmUi = Document().MtmUi();
       
  1108 
       
  1109     CMsgOperationWait* wait =
       
  1110         CMsgOperationWait::NewLC( EActivePriorityWsEvents + 10 );
       
  1111 
       
  1112     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
       
  1113     CMsvOperation* oper = mtmUi.ForwardL( KMsvDraftEntryIdValue, parts, wait->iStatus );
       
  1114     CleanupStack::PushL( oper );
       
  1115 
       
  1116     wait->Start();
       
  1117 
       
  1118     CleanupStack::PopAndDestroy( 2 );  // wait, oper
       
  1119     }
       
  1120 
       
  1121 // ---------------------------------------------------------
       
  1122 // DoEditAddressL
       
  1123 // ---------------------------------------------------------
       
  1124 void CPostcardAppUi::DoEditAddressL( TKeyEvent aKeyEvent /*=TKeyEvent()*/,
       
  1125                                				TInt aFirstFocused /*=-1*/)
       
  1126     { 
       
  1127 	CPostcardAddressForm* form = NULL;
       
  1128 	TInt ret = 0;
       
  1129     iController->SetFocused( EPostcardRecipient );
       
  1130     form = CPostcardAddressForm::NewL( *this, Document(), *iContact, ret,
       
  1131         aFirstFocused, aKeyEvent );
       
  1132     form->SetMopParent( iController );
       
  1133     iPocaFlags |= EPostcardRecipientActive;
       
  1134 
       
  1135     // Form might leave with KLeaveExit from CPostcardContact, 
       
  1136     // so we need to trap it and take proper actions. If it leaves,
       
  1137     // it means that Messaging is closed from FSW and there has been
       
  1138     // an active AIW to phonebook.
       
  1139     TRAPD( err, form->ExecLD() );
       
  1140 
       
  1141 	iPocaFlags &= ~EPostcardRecipientActive;
       
  1142     if ( err )
       
  1143         {
       
  1144         // form must be deleted here, since for some reason its destructor is
       
  1145         // not called, if leave oocurs in ExecLD.
       
  1146         delete form;
       
  1147         form = NULL;
       
  1148         User::Leave( err );
       
  1149         }
       
  1150 
       
  1151     if( ret == EPostcardDialogExit )
       
  1152         {
       
  1153         // If exit -> we need to save if possible
       
  1154         iPocaFlags |= EPostcardExitCalledFromDialog;
       
  1155         if ( Document( ).Modified( ) )
       
  1156             {
       
  1157             if ( CanSaveMessageL() )
       
  1158                 {
       
  1159                 TInt resId = R_POSTCARD_SAVING;
       
  1160                 ShowWaitNoteL( resId, ETrue );
       
  1161                 DoSaveL( );
       
  1162                 }
       
  1163             else
       
  1164                 {
       
  1165                 // No space -> exit without saving.
       
  1166                 Exit( EEikCmdExit );
       
  1167                 }
       
  1168             }
       
  1169         else
       
  1170             {
       
  1171             Exit( EEikCmdExit );         
       
  1172             }
       
  1173         }
       
  1174     else if( iMsgType == EPostcardSent )
       
  1175         {
       
  1176         if( ret == EPostcardDialogForward )
       
  1177             {
       
  1178             DoForwardMessageL( );
       
  1179             return;
       
  1180             }           
       
  1181         iController->DrawDeferred( );
       
  1182         }
       
  1183 	else
       
  1184 		{
       
  1185 		Document( ).SetChanged( EPostcardRecipient );
       
  1186         iController->DrawDeferred( );
       
  1187 		if( ret == EPostcardDialogSend )
       
  1188 		    {
       
  1189             DoSendL( );		    
       
  1190 		    }
       
  1191 		}
       
  1192     }
       
  1193 
       
  1194 // ---------------------------------------------------------
       
  1195 // DoEditGreetingL
       
  1196 // ---------------------------------------------------------
       
  1197 void CPostcardAppUi::DoEditGreetingL( TKeyEvent aKeyEvent )
       
  1198     { 
       
  1199     CPostcardTextDialog* dialog = NULL;
       
  1200     TInt ret = 0;
       
  1201     iController->SetFocused( EPostcardText );
       
  1202     dialog = CPostcardTextDialog::NewL(*this, Document(), *iGreeting, 
       
  1203         ret, aKeyEvent );
       
  1204     dialog->SetMopParent( iController );
       
  1205     iPocaFlags |= EPostcardGreetingActive;
       
  1206     TRAP_IGNORE( dialog->ExecLD() );
       
  1207 
       
  1208 	iPocaFlags &= ~EPostcardGreetingActive;
       
  1209 
       
  1210     if( ret == EPostcardDialogExit )
       
  1211         {
       
  1212         // If exit -> we need to save if possible
       
  1213         iPocaFlags |= EPostcardExitCalledFromDialog;
       
  1214         if ( Document( ).Modified( ) )
       
  1215             {
       
  1216             if ( CanSaveMessageL() )
       
  1217                 {
       
  1218                 TInt resId = R_POSTCARD_SAVING;
       
  1219                 ShowWaitNoteL( resId, ETrue );
       
  1220                 DoSaveL( );
       
  1221                 }
       
  1222             else
       
  1223                 {
       
  1224                 // No space -> exit without saving.
       
  1225                 Exit( EEikCmdExit );                
       
  1226                 }
       
  1227             }
       
  1228         else
       
  1229             {
       
  1230             Exit( EEikCmdExit );         
       
  1231             }
       
  1232         }
       
  1233     else if( iMsgType == EPostcardSent )
       
  1234         {
       
  1235         if( ret == EPostcardDialogForward )
       
  1236             {
       
  1237             DoForwardMessageL( );
       
  1238             return;
       
  1239             }           
       
  1240         iController->DrawDeferred( );
       
  1241         }
       
  1242 	else
       
  1243 		{
       
  1244 		Document( ).SetChanged( EPostcardText );
       
  1245         iController->DrawDeferred( );
       
  1246 		if( ret == EPostcardDialogSend )
       
  1247 		    {
       
  1248 		    // Send chosen in greeting dialog
       
  1249             if( ContactHasData( *iContact ) )
       
  1250                 {
       
  1251                 // If there's contact data -> start sending
       
  1252                 DoSendL( );
       
  1253                 }
       
  1254             else
       
  1255                 {
       
  1256                 // If no contact data -> open address dialog
       
  1257                 DoEditAddressL( );                
       
  1258                 }
       
  1259 		    }
       
  1260 		}
       
  1261     }
       
  1262 
       
  1263 // ---------------------------------------------------------
       
  1264 // DoInsertImageL
       
  1265 // ---------------------------------------------------------
       
  1266 void CPostcardAppUi::DoInsertImageL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType )
       
  1267     {
       
  1268     iController->SetFocused( EPostcardImage );
       
  1269     SetMiddleSoftkeyL(); // set msk for the view
       
  1270     if ( FetchFileL( aFetchType ) )
       
  1271         {
       
  1272         // The file is selected and iImageInfo created
       
  1273 
       
  1274 	    ShowWaitNoteL( R_POSTCARD_WAIT_INSERTING, EFalse );
       
  1275 
       
  1276         iOperation = CPostcardOperationInsertImage::NewL(
       
  1277             *this,
       
  1278             Document(),
       
  1279             *this,
       
  1280             iImageInfo,
       
  1281             FsSession() );
       
  1282         iImageInfo = NULL; // ownership moves
       
  1283         iOperation->Start( EFalse );
       
  1284         
       
  1285         iAbsorber = CAknInputBlock::NewLC();
       
  1286         CleanupStack::Pop( iAbsorber );
       
  1287         }
       
  1288 
       
  1289     iController->DrawDeferred( );
       
  1290     }
       
  1291 
       
  1292 // ---------------------------------------------------------
       
  1293 // FetchFileL
       
  1294 // ---------------------------------------------------------
       
  1295 TBool CPostcardAppUi::FetchFileL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType )
       
  1296     {
       
  1297     CDesCArrayFlat* dummy = new ( ELeave ) CDesCArrayFlat( 1 );
       
  1298     CleanupStack::PushL( dummy );
       
  1299     TFileName fileName;
       
  1300     TBool fetchOK = MsgAttachmentUtils::FetchFileL(
       
  1301         aFetchType,
       
  1302         fileName,
       
  1303         *dummy,
       
  1304         ETrue,
       
  1305         EFalse,
       
  1306         this );
       
  1307 
       
  1308     CleanupStack::PopAndDestroy( dummy );
       
  1309 
       
  1310     switch ( aFetchType )
       
  1311         {
       
  1312         case MsgAttachmentUtils::ENewImage:
       
  1313         case MsgAttachmentUtils::ENewAudio:
       
  1314         case MsgAttachmentUtils::ENewVideo:            
       
  1315             {
       
  1316             if ( fetchOK )
       
  1317                 {
       
  1318                 // Something was fetched
       
  1319                 fetchOK = CreateMediaInfoForInsertL( fileName )
       
  1320                     ? ETrue
       
  1321                     : EFalse;
       
  1322                 }
       
  1323             }
       
  1324             break;
       
  1325         case MsgAttachmentUtils::EImage:
       
  1326         case MsgAttachmentUtils::EAudio:
       
  1327         case MsgAttachmentUtils::EVideo:
       
  1328         default:
       
  1329             // CreateMediaInfoForInsertL is called in VeritySelectionL
       
  1330             break;
       
  1331         }
       
  1332     return fetchOK;
       
  1333     }
       
  1334 
       
  1335 
       
  1336 // ---------------------------------------------------------
       
  1337 // VerifySelectionL
       
  1338 // ---------------------------------------------------------
       
  1339 TBool CPostcardAppUi::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
  1340     {
       
  1341     CAknInputBlock* blocker = CAknInputBlock::NewLC();
       
  1342 
       
  1343     TBool ret = EFalse;
       
  1344     if ( aSelectedFiles->MdcaCount() == 1 )
       
  1345         {
       
  1346         TPtrC ptr = aSelectedFiles->MdcaPoint( 0 );
       
  1347         if ( CreateMediaInfoForInsertL( ptr ) )
       
  1348             {
       
  1349             ret = ETrue;
       
  1350             }
       
  1351         }
       
  1352         
       
  1353     CleanupStack::PopAndDestroy( blocker );  // Input blocker
       
  1354     return ret;
       
  1355     }
       
  1356 
       
  1357 // ---------------------------------------------------------
       
  1358 // CreateMediaInfoForInsertL
       
  1359 // ---------------------------------------------------------
       
  1360 TBool CPostcardAppUi::CreateMediaInfoForInsertL( const TDesC& aFileName )
       
  1361     {
       
  1362     if( iImageInfo )
       
  1363     	{
       
  1364     	delete iImageInfo;
       
  1365     	iImageInfo = NULL;
       
  1366     	}
       
  1367 
       
  1368     RFile fileHandle = Document().MediaResolver()->FileHandleL( aFileName );
       
  1369     CleanupClosePushL( fileHandle );
       
  1370 	iImageInfo = static_cast<CMsgImageInfo*>( Document().MediaResolver()->CreateMediaInfoL( fileHandle ) );
       
  1371 	Document().MediaResolver()->ParseInfoDetailsL( iImageInfo, fileHandle );
       
  1372 	CleanupStack::PopAndDestroy( &fileHandle );
       
  1373 
       
  1374     TInt errResId = 0;
       
  1375 
       
  1376     if ( !CanSaveMessageL( iImageInfo->FileSize() ) )
       
  1377         {
       
  1378         User::Leave( KErrDiskFull );
       
  1379         }
       
  1380 
       
  1381     // Supported type check
       
  1382     if( iImageInfo->Protection( ) )
       
  1383         {
       
  1384         errResId = R_POSTCARD_CANNOT_SEND_PROTECTED;        
       
  1385         }
       
  1386     else if ( iImageInfo->Corrupt() )
       
  1387         {
       
  1388         // Corrupt is set to only supported media types
       
  1389         errResId = R_POSTCARD_OBJECT_CORRUPTED;
       
  1390         }
       
  1391     else if( !Document( ).IsImage( iImageInfo->MimeType( ) ) )
       
  1392     	{
       
  1393         errResId = R_POSTCARD_FORMAT_NOT_SUPPORTED;    		
       
  1394     	}
       
  1395     // DRM check
       
  1396     else if ( iImageInfo->MediaType() != EMsgMediaImage )
       
  1397         {
       
  1398         // Keep this after DRM check!
       
  1399         errResId = R_POSTCARD_FORMAT_NOT_SUPPORTED;
       
  1400         }
       
  1401     else if ( iImageInfo->IsAnimation( ) )
       
  1402         {
       
  1403         errResId = R_POSTCARD_FORMAT_NOT_SUPPORTED;
       
  1404         }
       
  1405 
       
  1406     if ( errResId != 0 )
       
  1407         {
       
  1408         delete iImageInfo;
       
  1409         iImageInfo = NULL;
       
  1410         ShowInformationNoteL( errResId, EFalse );
       
  1411         return EFalse;
       
  1412         }
       
  1413     return ETrue;
       
  1414 
       
  1415     }
       
  1416 
       
  1417 // ---------------------------------------------------------
       
  1418 // DoSelectionKeyL
       
  1419 // ---------------------------------------------------------
       
  1420 void CPostcardAppUi::DoSelectionKeyL()
       
  1421     {
       
  1422 	if( iMsgType != EPostcardSent )
       
  1423 		{
       
  1424 		// We are in editor mode
       
  1425 		TPostcardPart focused = iController->Focused( );
       
  1426 		switch ( focused )
       
  1427         	{
       
  1428         	case EPostcardImage:
       
  1429         		{
       
  1430 		        MenuBar( )->SetMenuTitleResourceId( R_POSTCARD_CONTEXT_MENUBAR );
       
  1431 		        MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1432 		        // if display fails set old menu back
       
  1433 		        TRAPD( err, MenuBar( )->TryDisplayMenuBarL( ) ); 
       
  1434 		        MenuBar( )->SetMenuTitleResourceId( R_POSTCARD_MAIN_MENUBAR );
       
  1435 		        MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1436 		        User::LeaveIfError( err );
       
  1437         		break;
       
  1438         		}
       
  1439     		case EPostcardRecipient:
       
  1440     			{
       
  1441     			DoEditAddressL( );
       
  1442     			break;
       
  1443     			}
       
  1444     		case EPostcardText:
       
  1445     			{
       
  1446     			DoEditGreetingL( );
       
  1447     			break;
       
  1448     			}
       
  1449     		default:
       
  1450     			break;
       
  1451 	        }
       
  1452 		}
       
  1453 	else
       
  1454 		{
       
  1455 		// We are in viewer mode
       
  1456 		TPostcardPart focused = iController->Focused( );
       
  1457 		switch ( focused )
       
  1458         	{
       
  1459         	case EPostcardImage:
       
  1460         		{
       
  1461         		break;
       
  1462         		}
       
  1463     		case EPostcardRecipient:
       
  1464     			{
       
  1465     			DoEditAddressL( );
       
  1466     			break;
       
  1467     			}
       
  1468     		case EPostcardText:
       
  1469     			{
       
  1470     			DoEditGreetingL( );
       
  1471     			break;
       
  1472     			}
       
  1473     		default:
       
  1474     			break;
       
  1475 	        }			
       
  1476 		}
       
  1477     return;
       
  1478     }
       
  1479     
       
  1480 // ---------------------------------------------------------
       
  1481 // LaunchHelpL
       
  1482 // ---------------------------------------------------------
       
  1483 void CPostcardAppUi::LaunchHelpL( const TDesC& aContext )
       
  1484     {
       
  1485     CArrayFix<TCoeHelpContext>* 
       
  1486         helpContext = new(ELeave) CArrayFixFlat<TCoeHelpContext>( 1 );
       
  1487     TCoeHelpContext context( TUid::Uid(0x10207247), aContext );
       
  1488     helpContext->AppendL( context );
       
  1489     HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession( ), helpContext );    
       
  1490     }
       
  1491 
       
  1492 // ---------------------------------------------------------
       
  1493 // FsSession
       
  1494 // ---------------------------------------------------------
       
  1495 RFs& CPostcardAppUi::FsSession() const
       
  1496     {
       
  1497     return ( iCoeEnv->FsSession() );
       
  1498     }
       
  1499 
       
  1500 #ifdef RD_SCALABLE_UI_V2
       
  1501 // ---------------------------------------------------------
       
  1502 // CPostcardAppUi::PocaPointerEvent
       
  1503 // ---------------------------------------------------------
       
  1504 void CPostcardAppUi::PocaPointerEventL( TPocaPointerEvent aEvent,
       
  1505     TPocaPointerEventType aEventType )
       
  1506     {
       
  1507     if ( AknLayoutUtils::PenEnabled() )
       
  1508         {
       
  1509         // Handle pointer (pen) events to areas in main pane
       
  1510         switch( aEvent )
       
  1511             {
       
  1512             case EPocaPointerEventUpIcon:
       
  1513             case EPocaPointerEventDownIcon:
       
  1514                 iController->MoveVertically( aEvent == EPocaPointerEventUpIcon ? ETrue : EFalse );
       
  1515                 
       
  1516                 if ( iMsgType == EPostcardSent )
       
  1517                     {
       
  1518                     // In viewer
       
  1519                     if ( iController->Focused() != EPostcardImage )
       
  1520                         {
       
  1521                         // Viewer does not have navigation arrows in text side
       
  1522                         iNaviPane->Pop( iNaviDecorator );
       
  1523                         }
       
  1524                     else
       
  1525                         {
       
  1526                         iNaviPane->PushL( *iNaviDecorator );
       
  1527                         }
       
  1528                     }
       
  1529                 break;
       
  1530                 
       
  1531             case EPocaPointerEventGreeting:
       
  1532                 if( iController->Focused() == EPostcardText )
       
  1533                     {
       
  1534                     DoSelectionKeyL();
       
  1535                     }
       
  1536                 else
       
  1537                     {
       
  1538                     iController->MoveHorizontally(
       
  1539                         aEvent == EPocaPointerEventAddress ? ETrue : EFalse );
       
  1540                     }
       
  1541                 break;
       
  1542             case EPocaPointerEventAddress:
       
  1543                 if( iController->Focused() == EPostcardRecipient )
       
  1544                     {
       
  1545                     DoSelectionKeyL();
       
  1546                     }
       
  1547                 else
       
  1548                     {
       
  1549                     iController->MoveHorizontally(
       
  1550                         aEvent == EPocaPointerEventAddress ? ETrue : EFalse );
       
  1551                     }
       
  1552                break;
       
  1553             case EPocaPointerEventFrontBg: // front picture area
       
  1554                 DoSelectionKeyL();
       
  1555                 break;
       
  1556             default:
       
  1557                 ;
       
  1558             }
       
  1559         SetMiddleSoftkeyL(); // set msk for the view
       
  1560         }
       
  1561     else
       
  1562         {
       
  1563         // Suppress warnings
       
  1564         aEvent = aEvent;
       
  1565         aEventType = aEventType;
       
  1566         }
       
  1567     }
       
  1568 
       
  1569 #endif // RD_SCALABLE_UI_V2
       
  1570 
       
  1571 // ---------------------------------------------------------
       
  1572 // CPostcardAppUi::MenuBar
       
  1573 // Returns application menubar.
       
  1574 // ---------------------------------------------------------
       
  1575 CEikMenuBar* CPostcardAppUi::MenuBar() const
       
  1576     {
       
  1577     return iEikonEnv->AppUiFactory()->MenuBar();
       
  1578     }
       
  1579 
       
  1580 // ---------------------------------------------------------
       
  1581 // CPostcardAppUi::HandleResourceChangeL
       
  1582 // ---------------------------------------------------------
       
  1583 void CPostcardAppUi::HandleResourceChangeL(TInt aType)
       
  1584     {
       
  1585     CMsgEditorAppUi::HandleResourceChangeL(aType);
       
  1586 	if ( aType == KEikDynamicLayoutVariantSwitch )
       
  1587         {
       
  1588         // The layout is changing -> reread coordinates
       
  1589         if ( iController )
       
  1590     	   	{
       
  1591         	iController->RefreshCoordinates( );
       
  1592         	}
       
  1593     	if ( iGreetingLength )
       
  1594     		{
       
  1595     		CreateGreetingBitmapL( );
       
  1596     		}
       
  1597         if ( ContactHasData( ) )
       
  1598             {
       
  1599             RefreshRecipientBitmapL( );
       
  1600             }
       
  1601         RefreshFocusLinesL( );
       
  1602         if ( iController )
       
  1603             {
       
  1604             iController->DrawDeferred( );
       
  1605             }
       
  1606         
       
  1607         SetTitleIconL();
       
  1608         }
       
  1609     else if ( aType == KAknsMessageSkinChange )
       
  1610         {
       
  1611         CreateAndSetTitleIconL();
       
  1612         // The skin is changing -> recreate icons and refresh coordinates
       
  1613         if( iController )
       
  1614             {
       
  1615             iController->ReLoadIconsL( );
       
  1616             }
       
  1617         }
       
  1618     }
       
  1619 
       
  1620 // ---------------------------------------------------------
       
  1621 // CPostcardAppUi::ShowCloseQueryL
       
  1622 // ---------------------------------------------------------
       
  1623 TInt CPostcardAppUi::ShowCloseQueryL()
       
  1624     {
       
  1625     TInt selectedIndex( 0 );
       
  1626     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
       
  1627     dlg->PrepareLC( R_POSTCARD_CLOSE_QUERY );
       
  1628     if ( dlg->RunLD() )
       
  1629         {
       
  1630         return ( selectedIndex == 0 )
       
  1631             ? EPostcardCloseSave
       
  1632             : EPostcardCloseDelete;
       
  1633         }
       
  1634     else
       
  1635         {
       
  1636         return EPostcardCloseCancel;
       
  1637         }
       
  1638     }
       
  1639 
       
  1640 // ---------------------------------------------------------
       
  1641 // CPostcardAppUi::ExitAndSaveL
       
  1642 // ---------------------------------------------------------
       
  1643 void CPostcardAppUi::ExitAndSaveL()
       
  1644     {
       
  1645     if ( iPocaFlags & EPostcardClosing )
       
  1646         {
       
  1647         Exit( EAknSoftkeyClose );
       
  1648         return;
       
  1649         }
       
  1650     
       
  1651     if ( CAknEnv::AppWithShutterRunning() )
       
  1652         {
       
  1653         iPocaFlags |= EPostcardRunAppShutterAtExit;
       
  1654         }
       
  1655 
       
  1656     if ( iPocaFlags & EPostcardLaunchSuccessful &&
       
  1657          Document().MediaAvailable() )
       
  1658         {
       
  1659         DoMsgSaveExitL();
       
  1660         }
       
  1661     
       
  1662     Exit();
       
  1663     }
       
  1664 
       
  1665 // ---------------------------------------------------------
       
  1666 // CPostcardAppUi::PostcardOperationEvent
       
  1667 // ---------------------------------------------------------
       
  1668 void CPostcardAppUi::PostcardOperationEvent(
       
  1669             TPostcardOperationType aOperation,
       
  1670             TPostcardOperationEvent aEvent )
       
  1671     {
       
  1672     // If a large image is inserted, it may take enough time for a screen
       
  1673     // backlight to go off. It wouldn't reactivate unless inactivity timer
       
  1674     // is reseted (or user presses a key).
       
  1675     User::ResetInactivityTime();
       
  1676 
       
  1677     delete iAbsorber;
       
  1678     iAbsorber = NULL;
       
  1679 
       
  1680     if( aOperation == EPostcardOperationOpen )
       
  1681         { 
       
  1682         if( aEvent == EPostcardOperationError )
       
  1683             {
       
  1684             RemoveWaitNote( );
       
  1685             TInt error = iOperation->GetError( );
       
  1686             if( error == R_POSTCARD_FORMAT_NOT_SUPPORTED ||
       
  1687                 error == R_POSTCARD_MULTIPLE_FILES ||
       
  1688                 error == R_POSTCARD_CANNOT_SEND_PROTECTED ||
       
  1689                 error == R_POSTCARD_PROCESS_NOT_SUCCESSFUL ||
       
  1690                 error == R_POSTCARD_OBJECT_CORRUPTED )
       
  1691                 {
       
  1692                 TRAP_IGNORE( ShowInformationNoteL( error, EFalse ) );
       
  1693                 }
       
  1694             iOperation->Cancel( );
       
  1695             delete iOperation;
       
  1696             iOperation = NULL;
       
  1697             TRAP_IGNORE( iController->ActivateL( ) ); // This is called to give infonote more time
       
  1698             DoDelayedExit( 0 );
       
  1699             }
       
  1700         else
       
  1701             {
       
  1702             // Delete opening operation. CompleteLaunchViewL() may start
       
  1703             // a save operation.
       
  1704             delete iOperation;
       
  1705             iOperation = NULL;
       
  1706             // Change state only if opening an existing message. State for a changed
       
  1707             // item is changed when it is really edited. This prevents saving of empty
       
  1708             // messages to drafts.
       
  1709             if ( Document().MessageType() != EPostcardNew &&
       
  1710                  Document().MessageType() != EPostcardSent )
       
  1711                 {
       
  1712                 if ( iImage )
       
  1713                     {
       
  1714                     Document().SetChanged( EPostcardImage );
       
  1715                     }
       
  1716                 if ( iGreeting )
       
  1717                     {
       
  1718                     Document().SetChanged( EPostcardText );                
       
  1719                     }
       
  1720                 if ( iContact )
       
  1721                     {
       
  1722                     Document().SetChanged( EPostcardRecipient );
       
  1723                     }
       
  1724                 }
       
  1725 
       
  1726             TRAP_IGNORE( CompleteLaunchViewL( ) );
       
  1727             }        
       
  1728         }
       
  1729     else if( aOperation == EPostcardOperationSave )
       
  1730         {
       
  1731         if( iOperation->GetError( ) )
       
  1732         	{
       
  1733         	TRAP_IGNORE( ShowGlobalInformationNoteL( iOperation->GetError( ), EFalse ) );
       
  1734         	}
       
  1735         delete iOperation;
       
  1736         iOperation = NULL;
       
  1737 
       
  1738         RemoveWaitNote();
       
  1739         if( aEvent == EPostcardOperationError )
       
  1740             {
       
  1741             Exit( EAknSoftkeyClose );
       
  1742             }
       
  1743         else
       
  1744             {
       
  1745             DoDelayedExit( 0 );
       
  1746             }
       
  1747         EndActiveWait();
       
  1748         }
       
  1749     else
       
  1750     	{
       
  1751     	// Insert image operation
       
  1752     	TInt error = iOperation->GetError( );
       
  1753         if( error )
       
  1754         	{
       
  1755         	if( error == R_POSTCARD_FORMAT_NOT_SUPPORTED ||
       
  1756                 error == R_POSTCARD_PROCESS_NOT_SUCCESSFUL )
       
  1757         		{
       
  1758 	        	TRAP_IGNORE( ShowInformationNoteL( error, EFalse ) );
       
  1759         		}
       
  1760         	}
       
  1761     	delete iOperation;
       
  1762     	iOperation = NULL;
       
  1763     	delete iImageInfo;
       
  1764     	iImageInfo = NULL;
       
  1765     	RemoveWaitNote( );
       
  1766 	    iController->DrawDeferred( );	
       
  1767 	    Document( ).SetChanged( EPostcardImage );
       
  1768     	}
       
  1769     }
       
  1770 
       
  1771 // ---------------------------------------------------------
       
  1772 // DoDelayedExit
       
  1773 // ---------------------------------------------------------
       
  1774 void CPostcardAppUi::DoDelayedExit( TInt aDelayTime )
       
  1775     {
       
  1776     if ( !iIdle )
       
  1777         {
       
  1778         
       
  1779         }
       
  1780     iIdle->Cancel();
       
  1781     iIdle->Start( aDelayTime,
       
  1782                   aDelayTime, 
       
  1783                   TCallBack( DelayedExit, this ));
       
  1784     }
       
  1785 
       
  1786 // ---------------------------------------------------------
       
  1787 // DelayedExit
       
  1788 // ---------------------------------------------------------
       
  1789 TInt CPostcardAppUi::DelayedExit( TAny* aThis )
       
  1790     {
       
  1791     CPostcardAppUi* editor = static_cast<CPostcardAppUi*>( aThis );
       
  1792     editor->DoExternalExit();
       
  1793 	CAknEnv::RunAppShutter( );
       
  1794     return KErrNone;
       
  1795     }
       
  1796 
       
  1797 // ---------------------------------------------------------
       
  1798 // DoExternalExit
       
  1799 // ---------------------------------------------------------
       
  1800 void CPostcardAppUi::DoExternalExit()
       
  1801     {
       
  1802     RemoveWaitNote( );
       
  1803     if( iOperation )
       
  1804         {
       
  1805         delete iOperation;
       
  1806         iOperation = NULL;
       
  1807         }
       
  1808     
       
  1809     if( iPocaFlags & EPostcardExitCalledFromDialog )
       
  1810         {
       
  1811         Exit( EAknCmdExit );
       
  1812         }
       
  1813     else
       
  1814         {
       
  1815         Exit( EAknSoftkeyClose );
       
  1816         }
       
  1817     }
       
  1818 
       
  1819 // ---------------------------------------------------------
       
  1820 // CPostcardAppUi::SetImageL
       
  1821 // ---------------------------------------------------------
       
  1822 void CPostcardAppUi::SetImage( CGulIcon* aIcon )
       
  1823     {
       
  1824     iImage = aIcon;
       
  1825     iController->SetBitmap( EPostcardImage, aIcon );
       
  1826     }
       
  1827 
       
  1828 // ---------------------------------------------------------
       
  1829 // CPostcardAppUi::SetTextL
       
  1830 // ---------------------------------------------------------
       
  1831 void CPostcardAppUi::SetTextL( CPlainText& aPlainText )
       
  1832     {
       
  1833 	delete iGreeting;
       
  1834 	iGreeting = &aPlainText;
       
  1835 	iGreetingLength = iGreeting->DocumentLength();
       
  1836 	if( iGreetingLength )
       
  1837 		{
       
  1838 		CreateGreetingBitmapL( );
       
  1839 		}
       
  1840 	else
       
  1841 		{
       
  1842 		iController->RemoveBitmap( EPostcardText );		
       
  1843 		}
       
  1844     }
       
  1845 
       
  1846 // ---------------------------------------------------------
       
  1847 // CPostcardAppUi::MaxTextLength
       
  1848 // ---------------------------------------------------------
       
  1849 TInt CPostcardAppUi::MaxTextLength( TInt aControlId )
       
  1850     {
       
  1851     const TInt KFirstControlId = EPostcardTextEditor;
       
  1852     __ASSERT_DEBUG( aControlId >= KFirstControlId &&
       
  1853         aControlId <= EPostcardAddressCountry, Panic( EPostcardPanicCoding ) );
       
  1854 
       
  1855     // Keys has to be in the same order in the table as control IDs in
       
  1856     // TPostcardControls
       
  1857     static const TUint32 keys[ENumPostcardControls] = 
       
  1858         {
       
  1859         KPocaKeyMaxGreetingLength, KPocaKeyMaxNameLength,
       
  1860         KPocaKeyMaxInfoLength, KPocaKeyMaxStreetLength,
       
  1861         KPocaKeyMaxZipLength, KPocaKeyMaxCityLength,
       
  1862         KPocaKeyMaxStateLength, KPocaKeyMaxCountryLength
       
  1863         };
       
  1864     return iCenRep->Get( keys[ aControlId - KFirstControlId ] );
       
  1865     }
       
  1866 
       
  1867 // ---------------------------------------------------------
       
  1868 // CPostcardAppUi::CenRep
       
  1869 // ---------------------------------------------------------
       
  1870 const CPostcardCenRep& CPostcardAppUi::CenRep()
       
  1871     {
       
  1872     return *iCenRep;
       
  1873     }
       
  1874 
       
  1875 // ---------------------------------------------------------
       
  1876 // CPostcardAppUi::SetRecipientL
       
  1877 // ---------------------------------------------------------
       
  1878 void CPostcardAppUi::SetRecipientL( CContactCard& aRecipient )
       
  1879     {
       
  1880     delete iContact;
       
  1881     iContact = &aRecipient;
       
  1882 
       
  1883     if( !ContactHasData( aRecipient ) )
       
  1884         {
       
  1885         iController->RemoveBitmap( EPostcardRecipient );
       
  1886         return;			
       
  1887         }
       
  1888 
       
  1889     RefreshRecipientBitmapL( );
       
  1890     }
       
  1891 
       
  1892 // ---------------------------------------------------------
       
  1893 // CPostcardAppUi::RefreshRecipientBitmapL
       
  1894 // ---------------------------------------------------------
       
  1895 void CPostcardAppUi::RefreshRecipientBitmapL( )
       
  1896     {
       
  1897     // Get the contact set
       
  1898     CContactItemFieldSet& set = iContact->CardFields( );
       
  1899 	
       
  1900     CDesCArrayFlat* strings = new (ELeave) CDesCArrayFlat( CPostcardAddressForm::ENumAddrFields );
       
  1901     CleanupStack::PushL( strings );
       
  1902 
       
  1903     CArrayFixFlat<TInt>* indexes =
       
  1904         new ( ELeave ) CArrayFixFlat<TInt>(CPostcardAddressForm::ENumAddrFields);
       
  1905     CleanupStack::PushL( indexes );
       
  1906     for( TInt a=0; a<CPostcardAddressForm::ENumAddrFields; a++ )
       
  1907         {
       
  1908         indexes->AppendL(-1);
       
  1909         }
       
  1910 
       
  1911     // Lets first find the indexes of different fields from the ContactItemFieldSet
       
  1912 	for( TInt i = 0; i<set.Count( ); i++ )
       
  1913 		{
       
  1914 		CContactItemField& field = set[i];
       
  1915     	for( TInt a = EPostcardAddressName; a <= EPostcardAddressCountry; a++ )
       
  1916     		{
       
  1917     		if( !field.Label( ).Compare( TPostcardUtils::ContactItemNameFromId( a ) ) )
       
  1918     		    { // Label found so store the index of ContactItemField
       
  1919     	        indexes->Delete( a-EPostcardAddressName ); // remove -1
       
  1920     	        indexes->InsertL( a-EPostcardAddressName, i ); // add right one
       
  1921     			continue;
       
  1922     		    }
       
  1923     		}
       
  1924 		}			
       
  1925 	// Lets put them into right order
       
  1926 	for( TInt a = EPostcardAddressName; a<=EPostcardAddressCountry; a++ )
       
  1927 		{
       
  1928 		TInt id = indexes->At( a - EPostcardAddressName );
       
  1929 		if( id != -1 )
       
  1930 			{
       
  1931 			CContactItemField& field = set[ id ];
       
  1932     		if( field.TextStorage( )->Text( ).Length( ) > 0 )
       
  1933 	    		{
       
  1934             	strings->AppendL( field.TextStorage()->Text() );
       
  1935 	    		}
       
  1936 			}
       
  1937 		}
       
  1938     CleanupStack::PopAndDestroy( indexes );
       
  1939     // And create a transparent bitmap of the address strings
       
  1940 	CGulIcon* icon = CreateTransparentIconL( *strings );
       
  1941 	iController->SetBitmap( EPostcardRecipient, icon );
       
  1942 
       
  1943 	CleanupStack::PopAndDestroy( strings );
       
  1944     }
       
  1945 
       
  1946 // ---------------------------------------------------------
       
  1947 // CreateGreetingBitmapL
       
  1948 // ---------------------------------------------------------
       
  1949 void CPostcardAppUi::CreateGreetingBitmapL( )
       
  1950 	{
       
  1951     TPtrC16 text( iGreeting->Read( 0, iGreetingLength ) );
       
  1952     
       
  1953     CGulIcon* icon = CreateTransparentIconL( text );
       
  1954    	iController->SetBitmap( EPostcardText, icon );
       
  1955 	}
       
  1956 
       
  1957 // ---------------------------------------------------------
       
  1958 // CreateTransparentIconL
       
  1959 // ---------------------------------------------------------
       
  1960 CGulIcon* CPostcardAppUi::CreateTransparentIconL( const TDesC& aText )	
       
  1961 	{
       
  1962 	TSize iconSize = PostcardLaf::GreetingText( ).Size( );
       
  1963 
       
  1964 	// The bitmap
       
  1965 	CFbsBitmap* bitmap = CreateEmptyBitmapLC( iconSize ); // pushes to stack
       
  1966 
       
  1967 	// The mask bitmap
       
  1968 	CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap( );
       
  1969 	CleanupStack::PushL( bitmapMask );
       
  1970 	bitmapMask->Create( iconSize, EGray2 );
       
  1971 	
       
  1972 	CFbsBitmapDevice* deviceMask = CFbsBitmapDevice::NewL( bitmapMask );
       
  1973 	CleanupStack::PushL( deviceMask );
       
  1974 	
       
  1975 	CBitmapContext* contextMask = NULL;
       
  1976 	deviceMask->CreateBitmapContext( contextMask );	
       
  1977 	CleanupStack::PushL( contextMask );
       
  1978 
       
  1979     contextMask->SetPenStyle(CGraphicsContext::ENullPen);
       
  1980     contextMask->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1981     contextMask->SetBrushColor( KRgbBlack );
       
  1982     contextMask->DrawRect(TRect(TPoint(0,0), iconSize));
       
  1983 
       
  1984     contextMask->SetPenStyle(CGraphicsContext::ESolidPen);
       
  1985     contextMask->SetBrushStyle(CGraphicsContext::ENullBrush);
       
  1986     contextMask->SetPenColor(KRgbWhite);
       
  1987 
       
  1988 	CFont* font = NULL;
       
  1989     CParaFormat paraFormat;
       
  1990     TParaFormatMask paraFormatMask;
       
  1991 	TCharFormat charFormat;
       
  1992 	TCharFormatMask charFormatMask;
       
  1993 
       
  1994 	PostcardLaf::MiniatureFont( charFormat, charFormatMask, paraFormat, paraFormatMask  );
       
  1995 
       
  1996 	deviceMask->GetNearestFontToDesignHeightInTwips( font, charFormat.iFontSpec );
       
  1997 	
       
  1998 	contextMask->UseFont( font );
       
  1999 
       
  2000    	TInt top = PostcardLaf::BaselineTop( );
       
  2001    	TInt delta = PostcardLaf::BaselineDelta( );
       
  2002     TInt leftMargin = PostcardLaf::LeftMargin( );
       
  2003     HBufC* buf = HBufC::NewLC( KPostcardMaxMiniatureCharsPerLine );
       
  2004     TPtr strPtr = buf->Des( );
       
  2005 
       
  2006 	TBool linesLeft = ETrue;
       
  2007 	TInt lineIndex = 0;
       
  2008 	TInt charTotalIndex = 0;
       
  2009     TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
  2010     TInt lineWidth = iconSize.iWidth - leftMargin; // We use the same margin on right side, too
       
  2011     const TInt greetingLineCount = PostcardLaf::GreetingFocusLineCount();
       
  2012 
       
  2013     // Insert lines until there is something to add or
       
  2014     // maximum amount of greeting focus lines is reached.
       
  2015     // This prevents drawing of text without a focus line,
       
  2016     // which can happen for the last row of the greeting text.
       
  2017 	while( linesLeft && lineIndex < greetingLineCount )
       
  2018 		{
       
  2019 		strPtr.Zero( );
       
  2020     	TPtrC origPtr = aText.Mid( charTotalIndex ); 
       
  2021     	TInt index = 0;
       
  2022     	while( index < origPtr.Length( ) 
       
  2023     	    && font->TextWidthInPixels( origPtr.Mid( 0, index ) ) + leftMargin < lineWidth )
       
  2024     		{
       
  2025     		index++;
       
  2026     		charTotalIndex++;
       
  2027             TChar ch = origPtr[index-1];
       
  2028             if( ch == 0x2029 ) // If enter, break from the while
       
  2029                 {
       
  2030                 charTotalIndex++; // increase now as it will be decreased next
       
  2031                 break;
       
  2032                 }
       
  2033     		}
       
  2034     	if( index < origPtr.Length( ) - 1 )
       
  2035     	    { // This is the last character in the text so lets still include that
       
  2036     	    index--;
       
  2037     	    charTotalIndex--;
       
  2038     	    }
       
  2039     	if( index > 0 )
       
  2040     		{ // There's actually something to draw on this line
       
  2041     		strPtr.Append( origPtr.Mid( 0, index ) );
       
  2042     		if( strPtr[index-1] == 0x2029 )
       
  2043     		    { // Remove the last character if it's CR
       
  2044                 strPtr.Delete( index-1, 1 );
       
  2045                 index--;
       
  2046                 charTotalIndex--;
       
  2047     		    }
       
  2048 
       
  2049             if( index == 0 )
       
  2050                 { // There are probably many empty lines so thats why we got here.. just increase line
       
  2051 			    lineIndex++;
       
  2052     		    }
       
  2053     		else
       
  2054     		    { // Now we can draw it
       
  2055         		TInt deltaX = leftMargin;
       
  2056         		if( mirrored )
       
  2057         		    {
       
  2058         		    deltaX = iconSize.iWidth - leftMargin - font->TextWidthInPixels( strPtr );
       
  2059         		    }
       
  2060         		TPoint point = TPoint( deltaX, top + ( lineIndex * delta ) );
       
  2061         		lineIndex++; // lets change the line
       
  2062         		if( mirrored )
       
  2063         		    {
       
  2064         		    CGraphicsContext::TDrawTextExtendedParam params;
       
  2065         		    params.iParRightToLeft = ETrue; // change the direction of text
       
  2066             		contextMask->DrawTextExtended( strPtr, point, params );
       
  2067         		    }
       
  2068         		else
       
  2069         		    {
       
  2070             		contextMask->DrawText( strPtr, point );
       
  2071         		    }
       
  2072     		    }    
       
  2073     		if( index >= origPtr.Length( ) )
       
  2074     			{
       
  2075     			linesLeft = EFalse;
       
  2076     			}
       
  2077     		}
       
  2078 		else  // Nothing left -> return
       
  2079 			{
       
  2080 			if( origPtr.Length( ) == 0)
       
  2081 			    { // Nothing left -> return
       
  2082     			linesLeft = EFalse;	
       
  2083 			    }
       
  2084 			else
       
  2085 			    { // Just an empty line -> increase line counter
       
  2086 			    lineIndex++;
       
  2087 			    }
       
  2088 			}
       
  2089 		}
       
  2090 
       
  2091 	CleanupStack::PopAndDestroy( 3, deviceMask );   // deviceMask, contextMask, buf
       
  2092 	
       
  2093     CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
       
  2094 
       
  2095     // Ownership moves, so just pop.
       
  2096     CleanupStack::Pop( 2, bitmap ); // bitmapMask and bitmap
       
  2097 
       
  2098 	return icon;
       
  2099 	}
       
  2100 
       
  2101 // ---------------------------------------------------------
       
  2102 // CreateTransparentIconL
       
  2103 // ---------------------------------------------------------
       
  2104 CGulIcon* CPostcardAppUi::CreateTransparentIconL( const MDesCArray& aStrings )
       
  2105 	{
       
  2106 	TSize iconSize = PostcardLaf::Address( ).Size( );
       
  2107 
       
  2108 	CFbsBitmap* bitmap = CreateEmptyBitmapLC( iconSize ); // pushes to stack
       
  2109 	
       
  2110 	CFbsBitmap* bitmapMask = new (ELeave) CFbsBitmap( );
       
  2111 	CleanupStack::PushL( bitmapMask );
       
  2112 	bitmapMask->Create( iconSize, EGray2 );
       
  2113 	
       
  2114 	CFbsBitmapDevice* deviceMask = CFbsBitmapDevice::NewL( bitmapMask );
       
  2115 	CleanupStack::PushL( deviceMask );
       
  2116 	
       
  2117 	CBitmapContext* contextMask = NULL;
       
  2118 	deviceMask->CreateBitmapContext( contextMask );	
       
  2119 	CleanupStack::PushL( contextMask );
       
  2120 
       
  2121     contextMask->SetPenStyle(CGraphicsContext::ENullPen);
       
  2122     contextMask->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2123     contextMask->SetBrushColor( KRgbBlack );
       
  2124     contextMask->DrawRect(TRect(TPoint(0,0), iconSize));
       
  2125 
       
  2126     contextMask->SetPenStyle(CGraphicsContext::ESolidPen);
       
  2127     contextMask->SetBrushStyle(CGraphicsContext::ENullBrush);
       
  2128     contextMask->SetPenColor(KRgbWhite);
       
  2129 
       
  2130 	CFont* font = NULL;
       
  2131     CParaFormat paraFormat;
       
  2132     TParaFormatMask paraFormatMask;
       
  2133 	TCharFormat charFormat;
       
  2134 	TCharFormatMask charFormatMask;
       
  2135 
       
  2136 	PostcardLaf::MiniatureFont( charFormat, charFormatMask, paraFormat, paraFormatMask  );
       
  2137 
       
  2138 	deviceMask->GetNearestFontToDesignHeightInTwips( font, charFormat.iFontSpec );
       
  2139 	
       
  2140 	contextMask->UseFont( font );
       
  2141 
       
  2142    	TInt top = PostcardLaf::BaselineTop( );
       
  2143    	TInt delta = PostcardLaf::BaselineDelta( );
       
  2144     TInt leftMargin = PostcardLaf::LeftMargin( );
       
  2145     HBufC* buf = HBufC::NewLC( KPostcardMaxMiniatureCharsPerLine );
       
  2146     TPtr strPtr = buf->Des( );
       
  2147     TBool mirrored = AknLayoutUtils::LayoutMirrored();
       
  2148     TInt ellipsisWidth = font->CharWidthInPixels( CEditableText::EEllipsis );
       
  2149     TInt lineWidth = iconSize.iWidth - leftMargin - ellipsisWidth; // We use the same margin on right side, too
       
  2150     TInt lines = aStrings.MdcaCount() > KPostcardMaxAddressFocusLines ? 
       
  2151         KPostcardMaxAddressFocusLines : 
       
  2152         aStrings.MdcaCount();
       
  2153     // Following characters are converted to spaces, before showing them on text side.
       
  2154     TBuf<1> replaceChars;
       
  2155     replaceChars.Zero();
       
  2156     replaceChars.Append( CEditableText::EParagraphDelimiter );
       
  2157     
       
  2158     for( TInt a = 0; a < lines; a++ )
       
  2159     	{
       
  2160     	strPtr.Zero( );
       
  2161     	TPtrC origPtr = aStrings.MdcaPoint( a );
       
  2162     	if( origPtr.Length( ) < 1 )
       
  2163     		{ // There's no text so skip this..
       
  2164     		continue;
       
  2165     		}
       
  2166     	TInt index = 0;
       
  2167     	while( index < origPtr.Length( ) && font->TextWidthInPixels( origPtr.Mid( 0, index ) ) + leftMargin < ( lineWidth ) )
       
  2168     		{
       
  2169     		index++;
       
  2170     		}
       
  2171     	strPtr.Append( origPtr.Mid( 0, index ) );
       
  2172     	if( index < origPtr.Length( ) )
       
  2173     		{
       
  2174     		strPtr.Append( CEditableText::EEllipsis );
       
  2175     		index++;
       
  2176     		}
       
  2177     	TInt deltaX = leftMargin;
       
  2178     	if( mirrored )
       
  2179     	    {
       
  2180             deltaX = iconSize.iWidth - font->TextWidthInPixels( strPtr ) - leftMargin;
       
  2181     	    }
       
  2182     	TPoint point = TPoint( deltaX, top + ( a * delta ) );
       
  2183         
       
  2184         // Convert all line changes to spaces
       
  2185     	AknTextUtils::ReplaceCharacters(
       
  2186             strPtr,
       
  2187             replaceChars,
       
  2188             CEditableText::ESpace );
       
  2189     	
       
  2190 		if( mirrored )
       
  2191 		    {
       
  2192 		    CGraphicsContext::TDrawTextExtendedParam params;
       
  2193 		    params.iParRightToLeft = ETrue; // change the direction of text
       
  2194     		contextMask->DrawTextExtended( strPtr, point, params );
       
  2195 		    }
       
  2196 		else
       
  2197 		    {
       
  2198         	contextMask->DrawText( strPtr, point );
       
  2199 		    }
       
  2200     	}
       
  2201 	
       
  2202 	CleanupStack::PopAndDestroy( 3, deviceMask );   // deviceMask, contextMask, buf
       
  2203 	
       
  2204     CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
       
  2205 
       
  2206     // Ownership moves, so just pop.
       
  2207     CleanupStack::Pop( 2, bitmap ); // bitmapMask and bitmap
       
  2208 
       
  2209 	return icon;
       
  2210 
       
  2211 	}
       
  2212 
       
  2213 // ---------------------------------------------------------
       
  2214 // RefreshFocusLinesL
       
  2215 // ---------------------------------------------------------
       
  2216 void CPostcardAppUi::RefreshFocusLinesL( )
       
  2217     {
       
  2218     // Lets refresh the location of lines in greeting and recipients rects
       
  2219     if( !iController )
       
  2220         {
       
  2221         // If there's no controller -> just return
       
  2222         return; 
       
  2223         }
       
  2224         
       
  2225 	CFbsBitmap* dummyBmp = new (ELeave) CFbsBitmap( );
       
  2226 	CleanupStack::PushL( dummyBmp );
       
  2227 	dummyBmp->Create( TSize( 1, 1), EGray2 );
       
  2228 	
       
  2229 	CFbsBitmapDevice* dummyDevice = CFbsBitmapDevice::NewL( dummyBmp );
       
  2230 	CleanupStack::PushL( dummyDevice );
       
  2231 
       
  2232 	CFont* font = NULL;
       
  2233     CParaFormat paraFormat;
       
  2234     TParaFormatMask paraFormatMask;
       
  2235 	TCharFormat charFormat;
       
  2236 	TCharFormatMask charFormatMask;
       
  2237 
       
  2238 	PostcardLaf::MiniatureFont( charFormat, charFormatMask, paraFormat, paraFormatMask  );
       
  2239 
       
  2240 	dummyDevice->GetNearestFontToDesignHeightInTwips( font, charFormat.iFontSpec );
       
  2241 
       
  2242     TInt descent = font->DescentInPixels( );
       
  2243     
       
  2244     CleanupStack::PopAndDestroy( 2, dummyBmp ); // dummyBmp, dummyDevice
       
  2245     
       
  2246  	TInt delta = PostcardLaf::BaselineDelta( );
       
  2247 	TInt top = PostcardLaf::BaselineTop( );
       
  2248     TInt leftMargin = PostcardLaf::LeftMargin( );
       
  2249     TInt extraHeight = MsgEditorCommons::ScreenWidth( )>KPostcardLegacyWidth?1:0;
       
  2250     if( MsgEditorCommons::ScreenWidth( ) > KPostcardQvgaWidth )
       
  2251         {
       
  2252         extraHeight++;
       
  2253         }
       
  2254     
       
  2255     TInt rectLoop = EPostcardFocusAreaGreeting;
       
  2256     for ( rectLoop = 0; rectLoop < EPostcardFocusAreaLast; rectLoop++ )
       
  2257         {
       
  2258         TRect focusRect = rectLoop == EPostcardFocusAreaGreeting ? 
       
  2259             PostcardLaf::GreetingText() :
       
  2260             PostcardLaf::Address(); // Indicates the are where focus lines are drawn
       
  2261 
       
  2262     	// Indicates number of focus lines to draw. There is always 5 focus line in address side.
       
  2263     	// Focus line count in greeting text side depends on the used layout.
       
  2264         TInt rectLineCount = rectLoop == EPostcardFocusAreaGreeting ? 
       
  2265             PostcardLaf::GreetingFocusLineCount() : 
       
  2266             KPostcardMaxAddressFocusLines;
       
  2267         CArrayPtrFlat<TRect>* lineRects = new (ELeave) CArrayPtrFlat<TRect>( rectLineCount );
       
  2268         CleanupStack::PushL( lineRects );
       
  2269 
       
  2270         TRect* rect = NULL;
       
  2271         for (TInt i = 0; i < rectLineCount; i++)
       
  2272             {
       
  2273             rect = new (ELeave) TRect;
       
  2274             CleanupStack::PushL( rect );
       
  2275             lineRects->InsertL( i, rect );
       
  2276             CleanupStack::Pop( rect ); // rect -> just pop as it will be in lineRects
       
  2277             }
       
  2278 
       
  2279         TInt maxHeight = focusRect.Height( );
       
  2280         TInt lineNumber = 1;
       
  2281         
       
  2282         while( ETrue )
       
  2283             {
       
  2284             TInt y = focusRect.iTl.iY + top + ( lineNumber - 1 ) * delta + descent;
       
  2285             
       
  2286             lineRects->At( lineNumber - 1 )->SetRect( 
       
  2287                                 focusRect.iTl.iX + leftMargin,
       
  2288                                 y,
       
  2289                                 focusRect.iBr.iX - leftMargin,
       
  2290                                 y + extraHeight );
       
  2291             if( lineNumber >= rectLineCount || top + lineNumber * delta > maxHeight )
       
  2292                 {
       
  2293                 break;
       
  2294                 }
       
  2295             lineNumber++;
       
  2296             } 
       
  2297         // ownership moves to controller
       
  2298         CleanupStack::Pop( lineRects );
       
  2299 
       
  2300         if( rectLoop == 0 )
       
  2301             {
       
  2302             iController->SetGreetingLines( *lineRects );
       
  2303             }
       
  2304         else
       
  2305             {
       
  2306             iController->SetRecipientLines( *lineRects );
       
  2307             }
       
  2308         }
       
  2309     }
       
  2310 
       
  2311 // ---------------------------------------------------------
       
  2312 // CreateEmptyBitmapLC
       
  2313 // ---------------------------------------------------------
       
  2314 CFbsBitmap* CPostcardAppUi::CreateEmptyBitmapLC( const TSize& aSize )
       
  2315 	{
       
  2316 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap( );
       
  2317 	CleanupStack::PushL( bitmap );
       
  2318 	bitmap->Create( aSize, EGray2 );
       
  2319 	
       
  2320 	CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( bitmap );
       
  2321 	CleanupStack::PushL( device );
       
  2322 	
       
  2323 	CBitmapContext* context = NULL;
       
  2324 	device->CreateBitmapContext( context );	
       
  2325 	CleanupStack::PushL( context );
       
  2326 
       
  2327     context->SetPenStyle( CGraphicsContext::ENullPen );
       
  2328     context->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2329     context->SetBrushColor( KRgbRed );
       
  2330     context->DrawRect( TRect( TPoint( 0, 0 ), aSize ) );
       
  2331 
       
  2332     CleanupStack::PopAndDestroy( 2, device );   // context, device
       
  2333 
       
  2334 	return bitmap;
       
  2335 	}
       
  2336 
       
  2337 
       
  2338 // ---------------------------------------------------------
       
  2339 // ShowGlobalInformationNoteL
       
  2340 // ---------------------------------------------------------
       
  2341 void CPostcardAppUi::ShowGlobalInformationNoteL( TInt aResourceId, TBool aWaiting )
       
  2342     {
       
  2343     CErrorUI* errorUi = CErrorUI::NewLC(*iCoeEnv);
       
  2344     aWaiting ? errorUi->ShowGlobalErrorQueryL( aResourceId ) :
       
  2345                errorUi->ShowGlobalErrorNoteL( aResourceId );
       
  2346     CleanupStack::PopAndDestroy( errorUi );
       
  2347     }
       
  2348 
       
  2349 // ---------------------------------------------------------
       
  2350 // ShowInformationNoteL
       
  2351 // ---------------------------------------------------------
       
  2352 void CPostcardAppUi::ShowInformationNoteL( TInt aResourceId, TBool aWaiting )
       
  2353     {
       
  2354     HBufC* prompt = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  2355     ShowInformationNoteL( *prompt, aWaiting );
       
  2356     CleanupStack::PopAndDestroy( prompt );
       
  2357     }
       
  2358 
       
  2359 // ---------------------------------------------------------
       
  2360 // ShowInformationNoteL
       
  2361 // ---------------------------------------------------------
       
  2362 void CPostcardAppUi::ShowInformationNoteL( const TDesC& aText, TBool aWaiting )
       
  2363     {
       
  2364     CAknInformationNote* note = new ( ELeave )
       
  2365         CAknInformationNote( aWaiting );
       
  2366     note->ExecuteLD( aText );
       
  2367     }
       
  2368 
       
  2369 // ---------------------------------------------------------
       
  2370 // ShowConfirmationQueryL
       
  2371 // ---------------------------------------------------------
       
  2372 TInt CPostcardAppUi::ShowConfirmationQueryL( TInt aResourceId, TBool aOnlyOK/*=EFalse*/ ) const
       
  2373     {
       
  2374     HBufC* prompt = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  2375     TInt retVal = ShowConfirmationQueryL( *prompt, aOnlyOK );
       
  2376     CleanupStack::PopAndDestroy( prompt );
       
  2377     return retVal;
       
  2378     }
       
  2379 
       
  2380 // ---------------------------------------------------------
       
  2381 // ShowConfirmationQueryL
       
  2382 // ---------------------------------------------------------
       
  2383 TInt CPostcardAppUi::ShowConfirmationQueryL( const TDesC& aText, TBool aOnlyOK/*=EFalse*/ ) const
       
  2384     {
       
  2385     TInt dialogType=aOnlyOK?R_POSTCARD_CONFIRMABLE_QUERY:R_POSTCARD_CONFIRMATION_QUERY;
       
  2386     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  2387     TInt retVal = dlg->ExecuteLD( dialogType, aText );
       
  2388     return retVal;    
       
  2389     }
       
  2390 
       
  2391 // ---------------------------------------------------------
       
  2392 // ShowWaitNoteL
       
  2393 // ---------------------------------------------------------
       
  2394 TBool CPostcardAppUi::ShowWaitNoteL( TInt aResourceId, TBool aNoTimeout )
       
  2395     {
       
  2396     TInt waitNoteResource = R_POSTCARD_WAIT_NOTE;
       
  2397 
       
  2398     HBufC* string = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  2399     
       
  2400     iWaitDialog = new( ELeave )CAknWaitDialog(
       
  2401         reinterpret_cast<CEikDialog**>( &iWaitDialog ), aNoTimeout ); // ETrue means no delay in showing the note.
       
  2402     iWaitDialog->PrepareLC( waitNoteResource );
       
  2403     iWaitDialog->SetTextL( *string );
       
  2404     TInt success = iWaitDialog->RunLD();
       
  2405     CleanupStack::PopAndDestroy( string );
       
  2406     return success;
       
  2407     }
       
  2408 
       
  2409 // ---------------------------------------------------------
       
  2410 // RemoveWaitNote
       
  2411 // ---------------------------------------------------------
       
  2412 void CPostcardAppUi::RemoveWaitNote()
       
  2413     {
       
  2414     delete iWaitDialog;
       
  2415     iWaitDialog = NULL;
       
  2416     }
       
  2417 
       
  2418 // ---------------------------------------------------------
       
  2419 // Document
       
  2420 // ---------------------------------------------------------
       
  2421 CPostcardDocument& CPostcardAppUi::Document()
       
  2422     {
       
  2423     CMsgEditorDocument& doc = static_cast <CMsgEditorDocument&> ( *CEikAppUi::Document() );
       
  2424     return static_cast <CPostcardDocument&> ( doc );
       
  2425     }
       
  2426 
       
  2427 // ---------------------------------------------------------
       
  2428 // ContactHasData
       
  2429 // ---------------------------------------------------------
       
  2430 TBool CPostcardAppUi::ContactHasData( const CContactCard& aContact )
       
  2431 	{
       
  2432 	CContactItemFieldSet& fields = aContact.CardFields( );
       
  2433 	for( TInt i = 0; i < fields.Count( ); i++ )
       
  2434 		{
       
  2435 		CContactItemField& field = fields[i];
       
  2436 		if( field.TextStorage( )->Text( ).Length( ) > 0 )
       
  2437 			{
       
  2438 			return ETrue;
       
  2439 			}
       
  2440 		}
       
  2441 	return EFalse;	
       
  2442 	}
       
  2443 
       
  2444 // ---------------------------------------------------------
       
  2445 // ContactHasData
       
  2446 // ---------------------------------------------------------
       
  2447 TBool CPostcardAppUi::ContactHasData( )
       
  2448     {
       
  2449     // Call the overriden function with iContact
       
  2450     if(!iContact)
       
  2451     return EFalse;
       
  2452     return ContactHasData( *iContact );    
       
  2453     }
       
  2454 
       
  2455 
       
  2456 // ---------------------------------------------------------
       
  2457 // MandatoryAddressFields
       
  2458 // ---------------------------------------------------------
       
  2459 TInt CPostcardAppUi::MandatoryAddressFields( )
       
  2460 	{
       
  2461     return iCenRep->Get( KPocaKeyMandatoryFields );
       
  2462 	}
       
  2463 
       
  2464 // ---------------------------------------------------------
       
  2465 // ReadFromResourceLC
       
  2466 // ---------------------------------------------------------
       
  2467 HBufC* CPostcardAppUi::ReadFromResourceLC( TInt& aResourceId )
       
  2468 	{
       
  2469     return StringLoader::LoadLC( aResourceId, iCoeEnv );	
       
  2470 	}
       
  2471 
       
  2472 // ---------------------------------------------------------
       
  2473 // NavigateBetweenMessagesL
       
  2474 // ---------------------------------------------------------
       
  2475 TKeyResponse CPostcardAppUi::NavigateBetweenMessagesL( TBool aNextMessage )
       
  2476 	{
       
  2477     if( IsNextMessageAvailableL( aNextMessage ) )
       
  2478         {
       
  2479         NextMessageL( aNextMessage );
       
  2480         }
       
  2481     return EKeyWasConsumed;
       
  2482     }
       
  2483 
       
  2484 // ---------------------------------------------------------
       
  2485 // CheckLengthsL
       
  2486 // ---------------------------------------------------------
       
  2487 TBool CPostcardAppUi::CheckLengthsL( )
       
  2488 	{
       
  2489     if( iGreetingLength > MaxTextLength( EPostcardTextEditor ) )
       
  2490         {
       
  2491         DoEditGreetingL();
       
  2492         return EFalse;    	    
       
  2493         }
       
  2494 
       
  2495 	if( !ContactHasData( *iContact ) )
       
  2496 		{
       
  2497 		// No contact -> no need to show anything..
       
  2498     	return ETrue;
       
  2499 		}
       
  2500 
       
  2501     // Get length of address fields into a table. Table is initialized to
       
  2502     // zero because contact may be missing some address fields. Lengths are
       
  2503     // first fetched into a table and checked after that in order to do the
       
  2504     // check in correct order. If a some fields are too long they are presented
       
  2505     // to user in correct order for fixing.
       
  2506     TInt lengths[CPostcardAddressForm::ENumAddrFields];
       
  2507     Mem::FillZ( lengths, sizeof( lengths ) );
       
  2508     CContactItemFieldSet& set = iContact->CardFields();
       
  2509     for( TInt i = 0; i < set.Count(); i++ )
       
  2510         {
       
  2511         CContactItemField& field = set[i];
       
  2512         CContactTextField* textField = set[i].TextStorage();
       
  2513         if (textField)
       
  2514             {
       
  2515             TInt id = TPostcardUtils::IdFromContactItemName( field.Label() );
       
  2516             __ASSERT_DEBUG( id >= EPostcardAddressName &&
       
  2517                 id <= EPostcardAddressCountry, Panic( EPostcardPanicCoding ) );
       
  2518             lengths[id - EPostcardAddressName] = textField->Text().Length();
       
  2519             }
       
  2520         }
       
  2521     // Check length of fields
       
  2522     for( TInt i = EPostcardAddressName; i <= EPostcardAddressCountry; i++ )
       
  2523         {
       
  2524         if (lengths[i - EPostcardAddressName] > MaxTextLength(i))
       
  2525             {
       
  2526             // A field is too long, open the address dialog..
       
  2527             DoEditAddressL( TKeyEvent(), i );
       
  2528             return EFalse;
       
  2529             }
       
  2530         }
       
  2531     return ETrue;
       
  2532 	}
       
  2533 
       
  2534 // ---------------------------------------------------------
       
  2535 // CreateAddressStringForSendConfirmLC
       
  2536 // ---------------------------------------------------------
       
  2537 HBufC* CPostcardAppUi::CreateAddressStringForSendConfirmLC()
       
  2538     {
       
  2539     HBufC* buf = HBufC::NewLC( KPostcardMaxSendConfirmationLength );
       
  2540     TPtr bufPtr = buf->Des();
       
  2541 
       
  2542     _LIT( KNewline, "\n" );
       
  2543     CContactItemFieldSet& set = iContact->CardFields( );
       
  2544     for(TInt i = EPostcardAddressName; i <= EPostcardAddressCountry; i++ )
       
  2545         {
       
  2546         const CContactItemField* field = TPostcardUtils::FieldOrNull( set,
       
  2547             TPostcardUtils::ContactItemNameFromId( i ) );
       
  2548         if ( field )
       
  2549             {
       
  2550             TPtrC text = field->TextStorage()->Text();
       
  2551             TInt len = text.Length();
       
  2552             if( len && len < ( bufPtr.MaxLength() - bufPtr.Length() ) )
       
  2553                 {
       
  2554                 bufPtr.Append( text );
       
  2555                 bufPtr.Append( KNewline );
       
  2556                 }
       
  2557             }
       
  2558         }
       
  2559 
       
  2560     // Remove the last "\n" in case there's question mark in the end of the loc string
       
  2561     bufPtr.Delete( bufPtr.Length() - 1, 1 );
       
  2562     return buf;
       
  2563 	}
       
  2564 
       
  2565 // ---------------------------------------------------------
       
  2566 // QueryWaiterCallback
       
  2567 // ---------------------------------------------------------
       
  2568 void CPostcardAppUi::QueryWaiterCallbackL( TInt aResult )
       
  2569 	{
       
  2570 	if( aResult == EAknSoftkeySend )
       
  2571 		{
       
  2572 		// Proceed if send query result is send
       
  2573 		
       
  2574 		// Displaying extra charge query is optional
       
  2575         aResult = EAknSoftkeyOk;
       
  2576 		if( iCenRep->FeatureBits() & KPostcardFeatureIdExtraChargeNotification)
       
  2577 		    {
       
  2578             CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  2579             aResult = dlg->ExecuteLD( R_POSTCARD_EXTRA_CHARGE_QUERY );
       
  2580             }
       
  2581         if( aResult == EAknSoftkeyOk )
       
  2582             {
       
  2583             // OK, start sending
       
  2584             
       
  2585             TInt resourceId = R_POSTCARD_SENDING_POSTCARD;
       
  2586             if( IsPhoneOfflineL() )
       
  2587                 {
       
  2588                 resourceId = R_POSTCARD_SAVED_OUTBOX;
       
  2589                 }            
       
  2590             
       
  2591             ShowWaitNoteL( resourceId, ETrue );
       
  2592             iOperation = CPostcardOperationSave::NewL(
       
  2593                 *this,
       
  2594                 Document(),
       
  2595                 *this,
       
  2596                 FsSession(),
       
  2597                 *iContact,
       
  2598                 *iGreeting
       
  2599     	        );
       
  2600             iOperation->Start( ETrue );
       
  2601             
       
  2602             iAbsorber = CAknInputBlock::NewLC();
       
  2603             CleanupStack::Pop( iAbsorber );
       
  2604             iPocaFlags |= EPostcardClosing;
       
  2605             }
       
  2606 		}
       
  2607 
       
  2608 	if( iMessageQuery )
       
  2609 		{
       
  2610         iMessageQuery->CancelMsgQuery();
       
  2611         delete iMessageQuery;
       
  2612         iMessageQuery = NULL;		
       
  2613 		}
       
  2614 
       
  2615     delete iSendText;
       
  2616     iSendText = NULL;
       
  2617 	}
       
  2618 
       
  2619 // ---------------------------------------------------------
       
  2620 // QueryWaiterCallbackError
       
  2621 // ---------------------------------------------------------
       
  2622 void CPostcardAppUi::QueryWaiterCallbackError()
       
  2623     {
       
  2624     // Cleanup after QueryWaiterCallbackL() leaves
       
  2625 
       
  2626 	if( iMessageQuery )
       
  2627 		{
       
  2628         iMessageQuery->CancelMsgQuery();
       
  2629         delete iMessageQuery;
       
  2630         iMessageQuery = NULL;		
       
  2631 		}
       
  2632 
       
  2633     delete iSendText;
       
  2634     iSendText = NULL;
       
  2635 
       
  2636     RemoveWaitNote();
       
  2637 
       
  2638     delete iOperation;
       
  2639     iOperation = NULL;
       
  2640     }
       
  2641 
       
  2642 // ---------------------------------------------------------
       
  2643 // SetMiddleSoftkeyL
       
  2644 // ---------------------------------------------------------
       
  2645 void CPostcardAppUi::SetMiddleSoftkeyL()
       
  2646     {
       
  2647     TInt resourceId;
       
  2648     if ( iController->Frontpage() )
       
  2649         {
       
  2650         // Frontside is focused
       
  2651         if ( iMsgType == EPostcardSent )
       
  2652             {
       
  2653             resourceId = R_POSTCARD_MSK_BUTTON_EMPTY;
       
  2654             }
       
  2655         else
       
  2656             {
       
  2657             resourceId = R_POSTCARD_MSK_BUTTON_OPTIONS;
       
  2658             MenuBar()->SetContextMenuTitleResourceId(
       
  2659                 R_POSTCARD_CONTEXT_MENUBAR );
       
  2660             }
       
  2661         }
       
  2662     else
       
  2663         {
       
  2664         // Backside is focused
       
  2665         resourceId = iMsgType == EPostcardSent ?
       
  2666             R_POSTCARD_MSK_BUTTON_OPEN : R_POSTCARD_MSK_BUTTON_EDIT;
       
  2667         }
       
  2668     if ( resourceId != iMskResource )
       
  2669         {
       
  2670         const TInt KMskPosition = 3;
       
  2671         CEikButtonGroupContainer *cba = Cba();
       
  2672         cba->SetCommandL( KMskPosition, resourceId );
       
  2673         cba->DrawDeferred();
       
  2674         iMskResource = resourceId;
       
  2675         }
       
  2676     }
       
  2677 
       
  2678 // ---------------------------------------------------------
       
  2679 // GetZoomLevelL
       
  2680 // ---------------------------------------------------------
       
  2681 void CPostcardAppUi::GetZoomLevelL( TInt& aZoomLevel )
       
  2682     {
       
  2683     TInt err = iMsgEditorAppUiExtension->iSettingCachePlugin.GetValue( KAknLocalZoomLayoutSwitch, 
       
  2684                                                             aZoomLevel );
       
  2685                 
       
  2686     if ( err != KErrNone )
       
  2687         {
       
  2688         User::Leave( err );
       
  2689         }
       
  2690     }
       
  2691 
       
  2692 // ---------------------------------------------------------
       
  2693 // HandleLocalZoomChangeL
       
  2694 // ---------------------------------------------------------
       
  2695 //
       
  2696 void CPostcardAppUi::HandleLocalZoomChangeL( TMsgCommonCommands aNewZoom )
       
  2697     {
       
  2698     // Forward to base, which sets new zoom level to cenrep.
       
  2699     CMsgEditorAppUi::HandleLocalZoomChangeL( aNewZoom );
       
  2700     }
       
  2701 
       
  2702 // ---------------------------------------------------------
       
  2703 // CPostcardAppUi::BeginActiveWait
       
  2704 // ---------------------------------------------------------
       
  2705 //
       
  2706 void CPostcardAppUi::BeginActiveWait()
       
  2707     {
       
  2708     if ( iWait.IsStarted() )
       
  2709         {
       
  2710         return;
       
  2711         }
       
  2712     iWait.Start();
       
  2713     }
       
  2714 
       
  2715 // ---------------------------------------------------------
       
  2716 // CPostcardAppUi::EndActiveWait
       
  2717 // ---------------------------------------------------------
       
  2718 //
       
  2719 void CPostcardAppUi::EndActiveWait()
       
  2720     {
       
  2721     if ( iWait.IsStarted() )
       
  2722         {
       
  2723         iWait.AsyncStop();
       
  2724         }
       
  2725     }
       
  2726 
       
  2727 // ---------------------------------------------------------
       
  2728 // CPostcardAppUi::SetTitleIconL
       
  2729 // ---------------------------------------------------------
       
  2730 //
       
  2731 void CPostcardAppUi::SetTitleIconL()
       
  2732     {
       
  2733     SetTitleIconSizeL( iAppIcon->Bitmap() );
       
  2734     
       
  2735     // Create duplicates of the icon to be used
       
  2736     CFbsBitmap* bitmap = new( ELeave ) CFbsBitmap();
       
  2737     CleanupStack::PushL( bitmap );
       
  2738     
       
  2739     CFbsBitmap* bitmapMask = new( ELeave ) CFbsBitmap();
       
  2740     CleanupStack::PushL( bitmapMask );
       
  2741     
       
  2742     User::LeaveIfError( bitmap->Duplicate( iAppIcon->Bitmap()->Handle() ) );
       
  2743     User::LeaveIfError( bitmapMask->Duplicate( iAppIcon->Mask()->Handle() ) );
       
  2744 
       
  2745     iTitlePane->SetSmallPicture( bitmap, bitmapMask, ETrue );
       
  2746     iTitlePane->DrawNow();
       
  2747     
       
  2748     CleanupStack::Pop( bitmapMask );
       
  2749     CleanupStack::Pop( bitmap );
       
  2750     }
       
  2751 
       
  2752 // ---------------------------------------------------------
       
  2753 // CPostcardAppUi::CreateAndSetTitleIconL
       
  2754 // ---------------------------------------------------------
       
  2755 //
       
  2756 void CPostcardAppUi::CreateAndSetTitleIconL()
       
  2757     {
       
  2758     if ( iAppIcon )
       
  2759         {
       
  2760         delete iAppIcon;
       
  2761         iAppIcon = NULL;
       
  2762         }
       
  2763     
       
  2764     TParse parseDrive;
       
  2765     parseDrive.Set( Document().AppFullName( ), NULL, NULL );
       
  2766     TPtrC drive = parseDrive.Drive( );
       
  2767     
       
  2768     TParse fileParse;
       
  2769     fileParse.Set( KPostcardMifFile, &KDC_APP_BITMAP_DIR, NULL );
       
  2770     
       
  2771     TFileName fileName( fileParse.FullName( ) );
       
  2772     fileName.Insert( 0, drive );
       
  2773     
       
  2774     iAppIcon = AknsUtils::CreateGulIconL( 
       
  2775         AknsUtils::SkinInstance(), 
       
  2776         KAknsIIDQgnPropMcePostcardTitle,
       
  2777         fileParse.FullName(),
       
  2778         EMbmPostcardQgn_prop_mce_postcard_title,
       
  2779         EMbmPostcardQgn_prop_mce_postcard_title_mask );
       
  2780     
       
  2781     SetTitleIconL();
       
  2782     }
       
  2783 
       
  2784 // ---------------------------------------------------------
       
  2785 // CPostcardAppUi::IsPhoneOfflineL
       
  2786 // ---------------------------------------------------------
       
  2787 //
       
  2788 TBool CPostcardAppUi::IsPhoneOfflineL() const
       
  2789     {
       
  2790     if ( iPocaFlags & EPostcardFeatureOffline )
       
  2791         {    
       
  2792         return MsvUiServiceUtilitiesInternal::IsPhoneOfflineL();
       
  2793         }
       
  2794     else
       
  2795         {
       
  2796         return EFalse;
       
  2797         }       
       
  2798     }
       
  2799 
       
  2800 //  End of File