mobilemessaging/unieditor/mtm/src/UniMtmUi.cpp
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *       Provides Uni MTM UI methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <apgcli.h>
       
    24 #include <msvuids.h>
       
    25 #include <mtmuidef.hrh>
       
    26 #include <mtmdef.h>
       
    27 #include <UniMtms.rsg>
       
    28 
       
    29 #include <msvstore.h>
       
    30 #include <mmsvattachmentmanager.h>
       
    31 
       
    32 #include <e32keys.h>
       
    33 #include <coemain.h>
       
    34 #include <eikenv.h>
       
    35 #include <eikdef.h>
       
    36 #include <eikmfne.h>
       
    37 #include <eikedwin.h>
       
    38 #include <eikcapc.h>
       
    39 #include <gulicon.h>
       
    40 #include <ErrorUI.h> //CErrorUI
       
    41 
       
    42 #include <aknPopup.h>
       
    43 #include <aknlists.h>
       
    44 #include <aknconsts.h>
       
    45 #include <akncontext.h>
       
    46 #include <akntabgrp.h>
       
    47 #include <AknQueryDialog.h>
       
    48 #include <aknnotewrappers.h>
       
    49 
       
    50 #include <centralrepository.h>    // link against centralrepository.lib
       
    51 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
    52 #include <messagingvariant.hrh>     // additional headers variation flags. 
       
    53 									// Currently MMS variation, no variataion for unieditor available.
       
    54 
       
    55 #include <StringLoader.h>
       
    56 
       
    57 #include <Muiumsginfo.h>
       
    58 #include <MuiuMsvUiServiceUtilities.h>
       
    59 #include <MuiuOperationWait.h>
       
    60 #include <muiumsguploadparam.h>
       
    61 
       
    62 #include <MtmExtendedCapabilities.hrh>
       
    63 
       
    64 #include <mmsgenutils.h>
       
    65 
       
    66 #include <unimsventry.h>
       
    67 
       
    68 #include "UniMtmUi.h"
       
    69 #include "UniMtmPanic.h"
       
    70 #include "UniMtmConst.h"
       
    71 #include "UniClientMtm.h"
       
    72 
       
    73 
       
    74 #include "UniEditorUids.hrh"
       
    75 
       
    76 // EXTERNAL FUNCTION PROTOTYPES  
       
    77 
       
    78 extern void Panic( TUniMtmPanic aPanic );
       
    79 
       
    80 // CONSTANTS
       
    81 
       
    82 
       
    83 _LIT( KCharLeftAddressIterator, "<" );
       
    84 _LIT( KCharRightAddressIterator, ">" );
       
    85 _LIT( KMmsCharCommaAndSpace, ", " );
       
    86 
       
    87 const TInt KMessageSize = 20;
       
    88 const TInt KZero = 0; //constant for memory check
       
    89 const TInt KMmsAdditionalCharsStringLength = 6;
       
    90 const TUint KMmsLRMarker = 0x200E;
       
    91 
       
    92 
       
    93 // MACROS
       
    94 
       
    95 // LOCAL CONSTANTS AND MACROS
       
    96 
       
    97 // MODULE DATA STRUCTURES
       
    98 
       
    99 // LOCAL FUNCTION PROTOTYPES
       
   100 
       
   101 // ==================== LOCAL FUNCTIONS ====================
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // NewUniMtmUiL
       
   105 // Factory function
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 EXPORT_C CBaseMtmUi* NewUniMtmUiL( CBaseMtm& aMtm, CRegisteredMtmDll& aRegisteredDll )
       
   109     {
       
   110     return CUniMtmUi::NewL( aMtm, aRegisteredDll );
       
   111     }
       
   112 
       
   113 
       
   114 // ================= MEMBER FUNCTIONS =======================
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CUniMtmUi::CUniMtmUi
       
   118 // C++ default constructor can NOT contain any code, that
       
   119 // might leave.
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 CUniMtmUi::CUniMtmUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll )
       
   123     :   CBaseMtmUi( aBaseMtm, aRegisteredMtmDll )
       
   124     {
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CUniMtmUi::ConstructL
       
   129 // Symbian OS default constructor can leave.
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 void CUniMtmUi::ConstructL()
       
   133     {
       
   134     CBaseMtmUi::ConstructL();
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CUniMtmUi::NewL
       
   139 // Two-phased constructor.
       
   140 // ---------------------------------------------------------
       
   141 // 
       
   142 CUniMtmUi* CUniMtmUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll )
       
   143     {
       
   144     CUniMtmUi* self = new ( ELeave ) CUniMtmUi( aBaseMtm, aRegisteredMtmDll );
       
   145     
       
   146     CleanupStack::PushL( self );
       
   147     self->ConstructL();
       
   148     CleanupStack::Pop( self );
       
   149     return self;
       
   150     }
       
   151 
       
   152     
       
   153 // ---------------------------------------------------------
       
   154 // CUniMtmUi::~CUniMtmUi
       
   155 // Destructor
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 CUniMtmUi::~CUniMtmUi()
       
   159     {
       
   160     
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CUniMtmUi::QueryCapability
       
   166 // Capability check for UI mtm specific functionality. These should
       
   167 // be minimal, as the default capability checking places are UI data MTM
       
   168 // (UI) and client MTM (engine).
       
   169 // ---------------------------------------------------------
       
   170 TInt CUniMtmUi::QueryCapability( TUid aCapability, TInt& aResponse )
       
   171     {
       
   172     return CBaseMtmUi::QueryCapability( aCapability, aResponse );
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // CUniMtmUi::CreateL
       
   177 // Launches Uni editor for creating a new message.
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 CMsvOperation* CUniMtmUi::CreateL( const TMsvEntry& aEntry, 
       
   181                                   CMsvEntry& aParent, 
       
   182                                   TRequestStatus& aStatus )
       
   183     {
       
   184     __ASSERT_DEBUG( aEntry.iMtm == Type(), Panic( EUniWrongMtm ) );
       
   185     __ASSERT_DEBUG( aEntry.iType == KUidMsvMessageEntry, Panic( EUniNotAMessage ) );
       
   186 
       
   187     if( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(
       
   188     	Session(),
       
   189         KZero ) )
       
   190         {
       
   191         User::Leave( KErrDiskFull );
       
   192         }
       
   193     
       
   194     return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage );
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // CUniMtmUi::DeleteServiceL
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 CMsvOperation* CUniMtmUi::DeleteServiceL( const TMsvEntry& /*aService*/, 
       
   202                                          TRequestStatus& /*aStatus*/ )
       
   203     {
       
   204     User::Leave( KErrNotSupported );
       
   205     return NULL;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // CUniMtmUi::DeleteFromL
       
   210 // ---------------------------------------------------------
       
   211 //
       
   212 CMsvOperation* CUniMtmUi::DeleteFromL( const CMsvEntrySelection& /*aSelection*/, 
       
   213                                       TRequestStatus& /*aStatus*/ )
       
   214     {
       
   215     User::Leave( KErrNotSupported );
       
   216     return NULL;
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // CUniMtmUi::CopyToL
       
   221 // Copy local outbox entry to remote server = called when sending the entry from MCE outbox
       
   222 // ---------------------------------------------------------
       
   223 //
       
   224 CMsvOperation* CUniMtmUi::CopyToL( const CMsvEntrySelection& aSelection, 
       
   225                                   TRequestStatus& aStatus )
       
   226     {
       
   227     return CopyMoveToL( aSelection, aStatus, ETrue );
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // CUniMtmUi::MoveToL
       
   232 // Move local outbox entry to remote server.
       
   233 // ---------------------------------------------------------
       
   234 //
       
   235 CMsvOperation* CUniMtmUi::MoveToL( const CMsvEntrySelection& aSelection, 
       
   236                                   TRequestStatus& aStatus )
       
   237     {
       
   238     return CopyMoveToL( aSelection, aStatus, EFalse );
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------
       
   242 // CUniMtmUi::CopyMoveToL
       
   243 // Performs either CopyToL or MoveToL operation.
       
   244 // ---------------------------------------------------------
       
   245 //
       
   246 CMsvOperation* CUniMtmUi::CopyMoveToL( const CMsvEntrySelection& aSelection, 
       
   247                                       TRequestStatus& aStatus, TBool aCopyOnly )
       
   248     {
       
   249     __ASSERT_DEBUG( iBaseMtm.Entry().Entry().iMtm==Type(), Panic( EUniWrongMtm ) );
       
   250     __ASSERT_DEBUG( iBaseMtm.Entry().Entry().iType==KUidMsvServiceEntry, Panic( EUniNotAService ) );
       
   251 
       
   252     // --- Carry out the operation ---
       
   253     TMsvEntry service ( BaseMtm().Entry().Entry() );
       
   254     //    Get CMsvEntry of parent of messages to be sent
       
   255     CMsvEntry* parentEntry = Session().GetEntryL( aSelection[0] );    
       
   256 
       
   257     CleanupStack::PushL( parentEntry );
       
   258     parentEntry->SetEntryL( parentEntry->Entry().Parent() );
       
   259     
       
   260     // Do the copy/move
       
   261     CMsvOperation* op = aCopyOnly ?
       
   262         parentEntry->CopyL( aSelection, service.Id(), aStatus ) :
       
   263         parentEntry->MoveL( aSelection, service.Id(), aStatus );
       
   264     
       
   265     CleanupStack::PopAndDestroy( parentEntry ); 
       
   266     return op;
       
   267     }
       
   268 
       
   269 // ---------------------------------------------------------
       
   270 // CUniMtmUi::CopyFromL
       
   271 // ---------------------------------------------------------
       
   272 //
       
   273 CMsvOperation* CUniMtmUi::CopyFromL(const CMsvEntrySelection& /*aSelection*/, 
       
   274                                     TMsvId /*aTargetId*/, 
       
   275                                     TRequestStatus& /*aStatus*/)
       
   276     {
       
   277     User::Leave( KErrNotSupported );
       
   278     return NULL;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------
       
   282 // CUniMtmUi::MoveFromL
       
   283 // ---------------------------------------------------------
       
   284 //
       
   285 CMsvOperation* CUniMtmUi::MoveFromL(const CMsvEntrySelection& /*aSelection*/, 
       
   286                                     TMsvId /*aTargetId*/, 
       
   287                                     TRequestStatus& /*aStatus*/)
       
   288     {
       
   289     User::Leave( KErrNotSupported );
       
   290     return NULL;
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------
       
   294 // CUniMtmUi::OpenL
       
   295 // Handles request to open existing message server entry (message/service)
       
   296 // ---------------------------------------------------------
       
   297 //
       
   298 CMsvOperation* CUniMtmUi::OpenL( TRequestStatus& aStatus )
       
   299     {
       
   300     __ASSERT_DEBUG( iBaseMtm.Entry().Entry().iMtm==Type(), Panic( EUniWrongMtm ) );
       
   301     const TMsvEntry& entry = BaseMtm().Entry().Entry();
       
   302     __ASSERT_DEBUG( !entry.ReadOnly(), Panic( EUniWrongParameters ));
       
   303     return EditL( aStatus );    
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------
       
   307 // CUniMtmUi::OpenL
       
   308 // Opens the first entry in a selection
       
   309 // ---------------------------------------------------------
       
   310 //
       
   311 CMsvOperation* CUniMtmUi::OpenL( TRequestStatus& aStatus, 
       
   312                                 const CMsvEntrySelection& aSelection )
       
   313     {
       
   314     __ASSERT_DEBUG( iBaseMtm.Entry().Entry().iMtm==Type(), Panic( EUniWrongMtm ) );
       
   315 
       
   316     BaseMtm().SwitchCurrentEntryL( aSelection[0] );
       
   317     return OpenL( aStatus );
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------
       
   321 // CUniMtmUi::CloseL
       
   322 // ---------------------------------------------------------
       
   323 //
       
   324 CMsvOperation* CUniMtmUi::CloseL( TRequestStatus& /*aStatus*/ )
       
   325     {
       
   326     User::Leave( KErrNotSupported );
       
   327     return NULL;
       
   328     }
       
   329 
       
   330 // ---------------------------------------------------------
       
   331 // CUniMtmUi::CloseL
       
   332 // ---------------------------------------------------------
       
   333 //
       
   334 CMsvOperation* CUniMtmUi::CloseL( TRequestStatus& /*aStatus*/, 
       
   335                                  const CMsvEntrySelection& /*aSelection*/ )
       
   336     {
       
   337     User::Leave( KErrNotSupported );
       
   338     return NULL;
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------
       
   342 // CUniMtmUi::EditL
       
   343 // Opens a message (editor) for editing.
       
   344 // ---------------------------------------------------------
       
   345 //
       
   346 CMsvOperation* CUniMtmUi::EditL( TRequestStatus& aStatus )
       
   347     {
       
   348     __ASSERT_DEBUG( iBaseMtm.Entry().Entry().iMtm==Type(), Panic( EUniWrongMtm ) );
       
   349 
       
   350     CMsvOperation* msvoperation = NULL;
       
   351 
       
   352     switch ( iBaseMtm.Entry().Entry().iType.iUid )
       
   353         {
       
   354         case KUidMsvMessageEntryValue:
       
   355             {
       
   356             if ( iBaseMtm.Entry().Entry().Connected() )
       
   357                 {
       
   358                 User::Leave( KErrLocked ); 
       
   359                 }
       
   360             msvoperation = LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() );
       
   361             }
       
   362             break;
       
   363 
       
   364         case KUidMsvServiceEntryValue:
       
   365         case KUidMsvAttachmentEntryValue:   // flow through
       
   366         case KUidMsvFolderEntryValue:       // flow through
       
   367         default:
       
   368             User::Leave( KErrNotSupported );
       
   369             break;
       
   370         }
       
   371 
       
   372     return msvoperation;
       
   373     }
       
   374 
       
   375 // ---------------------------------------------------------
       
   376 // CUniMtmUi::EditL
       
   377 // ---------------------------------------------------------
       
   378 //
       
   379 CMsvOperation* CUniMtmUi::EditL( TRequestStatus& aStatus, 
       
   380                                 const CMsvEntrySelection& aSelection )
       
   381     {
       
   382     BaseMtm().SwitchCurrentEntryL( aSelection[0] );
       
   383     return EditL( aStatus );
       
   384     }
       
   385 
       
   386 // ---------------------------------------------------------
       
   387 // CUniMtmUi::ViewL
       
   388 // Opens the message for reading in Viewer.
       
   389 // ---------------------------------------------------------
       
   390 //
       
   391 CMsvOperation* CUniMtmUi::ViewL( TRequestStatus& /*aStatus*/ )
       
   392     {
       
   393     User::Leave( KErrNotSupported );
       
   394     return NULL;
       
   395     }
       
   396 
       
   397 // ---------------------------------------------------------
       
   398 // CUniMtmUi::ViewL
       
   399 // ---------------------------------------------------------
       
   400 //
       
   401 CMsvOperation* CUniMtmUi::ViewL( TRequestStatus& /*aStatus*/, 
       
   402                                 const CMsvEntrySelection& /*aSelection*/ )
       
   403     {
       
   404     User::Leave( KErrNotSupported );
       
   405     return NULL;
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CUniMtmUi::LaunchEditorApplicationL()
       
   410 // Does the actual opening.
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 CMsvOperation* CUniMtmUi::LaunchEditorApplicationL( TRequestStatus& aStatus, 
       
   414                                                    CMsvSession& aSession, 
       
   415                                                    TEditorType aEditorType )
       
   416     {
       
   417     TEditorParameters temp;    
       
   418     
       
   419     if ( iBaseMtm.HasContext() )
       
   420         {
       
   421         temp.iId = iBaseMtm.Entry().EntryId();
       
   422         }
       
   423     
       
   424     switch( aEditorType )
       
   425         {
       
   426         case EReadOnly:
       
   427         case ESpecialEditor:
       
   428             User::Leave( KErrNotSupported );
       
   429             break;                             
       
   430         case ECreateNewMessage:
       
   431             temp.iFlags|=EMsgCreateNewMessage ;
       
   432             temp.iId=KMsvDraftEntryIdValue;
       
   433             break;
       
   434         case EEditExisting:  //fall through
       
   435         default:
       
   436             break;
       
   437         };
       
   438 
       
   439     temp.iFlags &= ~( EMtmUiFlagEditorPreferEmbedded|EMtmUiFlagEditorNoWaitForExit );
       
   440     temp.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded?EMsgLaunchEditorEmbedded:EMsgLaunchEditorStandAlone );
       
   441 
       
   442     TPckgC<TEditorParameters> paramPack( temp );
       
   443     
       
   444     return MsgEditorLauncher::LaunchEditorApplicationL(
       
   445         aSession,
       
   446         Type(),
       
   447         aStatus,
       
   448         temp,
       
   449         KNullDesC(),
       
   450         paramPack );
       
   451     }
       
   452 
       
   453 // ---------------------------------------------------------
       
   454 // CUniMtmUi::ForwardL
       
   455 // ---------------------------------------------------------
       
   456 //
       
   457 CMsvOperation* CUniMtmUi::ForwardL( TMsvId /*aDestination*/,
       
   458                                    TMsvPartList /*aPartList*/, 
       
   459                                    TRequestStatus& /*aCompletionStatus*/ )
       
   460     {
       
   461     User::Leave( KErrNotSupported );
       
   462     return NULL;
       
   463     }
       
   464 
       
   465 
       
   466 // ---------------------------------------------------------
       
   467 // CUniMtmUi::ReplyL
       
   468 // ---------------------------------------------------------
       
   469 //
       
   470 CMsvOperation* CUniMtmUi::ReplyL( TMsvId /*aDestination*/, 
       
   471                                  TMsvPartList /*aPartList*/, 
       
   472                                  TRequestStatus& /*aCompletionStatus*/ )
       
   473     {
       
   474     User::Leave( KErrNotSupported );
       
   475     return NULL;
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------
       
   479 // CUniMtmUi::CancelL
       
   480 // ---------------------------------------------------------
       
   481 //
       
   482 CMsvOperation* CUniMtmUi::CancelL( TRequestStatus& /*aStatus*/, 
       
   483                                   const CMsvEntrySelection& /*aSelection*/ )
       
   484     {
       
   485     User::Leave( KErrNotSupported );
       
   486     return NULL;
       
   487     }
       
   488 
       
   489 // ---------------------------------------------------------
       
   490 // CUniMtmUi::InvokeSyncFunctionL
       
   491 // ---------------------------------------------------------
       
   492 //
       
   493 void CUniMtmUi::InvokeSyncFunctionL( TInt aFunctionId, 
       
   494                                     const CMsvEntrySelection& aSelection, 
       
   495                                     TDes8& aParameter )
       
   496     {
       
   497     CBaseMtmUi::InvokeSyncFunctionL( aFunctionId, aSelection, aParameter );
       
   498     }
       
   499 
       
   500 // ---------------------------------------------------------
       
   501 // CUniMtmUi::InvokeAsyncFunctionL
       
   502 // ---------------------------------------------------------
       
   503 //
       
   504 CMsvOperation* CUniMtmUi::InvokeAsyncFunctionL( TInt aFunctionId, 
       
   505                                                const CMsvEntrySelection& aSelection, 
       
   506                                                TRequestStatus& aCompletionStatus, 
       
   507                                                TDes8& aParameter )
       
   508     {
       
   509     CMsvOperation* msvoperation = NULL;
       
   510 
       
   511     switch ( aFunctionId )
       
   512         {
       
   513     case KMtmUiFunctionMessageInfo:
       
   514         msvoperation = OpenMessageInfoL( aCompletionStatus, aParameter );
       
   515         break;
       
   516     default:
       
   517         msvoperation = CBaseMtmUi::InvokeAsyncFunctionL( aFunctionId, 
       
   518             aSelection, 
       
   519             aCompletionStatus, 
       
   520             aParameter);
       
   521         break;
       
   522         }
       
   523     return msvoperation;
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CUniMtmUi::DisplayProgressSummary
       
   528 // ---------------------------------------------------------
       
   529 //
       
   530 TInt CUniMtmUi::DisplayProgressSummary( const TDesC8& /*aProgress*/ ) const
       
   531     {
       
   532     // Not in use.
       
   533     return KErrNone;
       
   534     }
       
   535 
       
   536 // ---------------------------------------------------------
       
   537 // CUniMtmUi::GetResourceFileName
       
   538 // ---------------------------------------------------------
       
   539 //
       
   540 void CUniMtmUi::GetResourceFileName( TFileName& aFileName ) const
       
   541     {
       
   542     aFileName = KUniMtmResourceFile;
       
   543     }
       
   544 
       
   545 
       
   546 // ---------------------------------------------------------
       
   547 // CUniMtmUi::OpenMessageInfoL(TRequestStatus& aCompletionStatus, TDes8& aParameter)
       
   548 // Opens the Message Info popup.
       
   549 // ---------------------------------------------------------
       
   550 //
       
   551 CMsvOperation* CUniMtmUi::OpenMessageInfoL( TRequestStatus& aCompletionStatus, 
       
   552                                            TDes8& aParameter )
       
   553     {
       
   554     TInt popCount( 0 );
       
   555        
       
   556     // get additional headers variation info
       
   557     TInt addHeadersBitmask = 0;
       
   558     
       
   559     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
       
   560     repository->Get( KMuiuMmsFeatures, addHeadersBitmask );
       
   561     delete repository;
       
   562     repository = NULL;
       
   563     
       
   564     TBool priorityFeatureSupported = EFalse;
       
   565     
       
   566     // MMS Priority feature is enabled
       
   567     if ( addHeadersBitmask & KMmsFeatureIdPrioritySupport )
       
   568         {
       
   569         priorityFeatureSupported = ETrue;
       
   570         }
       
   571     
       
   572     // The items for Info are read from the message entry.
       
   573     // Note: Most of the stuff is in TMsvEntry, but not all -> MMS entry used all the way.
       
   574     TMsvEntry entry = BaseMtm().Entry().Entry();
       
   575     __ASSERT_DEBUG( entry.iType == KUidMsvMessageEntry, Panic( EUniNotAMessage ) );
       
   576     __ASSERT_DEBUG( entry.iMtm==Type(), Panic( EUniWrongMtm ) );
       
   577 
       
   578     static_cast<CUniClientMtm&>( iBaseMtm ).LoadMessageL();
       
   579 
       
   580     TUniMessageCurrentType currType = TUniMsvEntry::CurrentMessageType( entry );
       
   581     CMsgInfoMessageInfoDialog::TMessageInfoType infoType =
       
   582         CMsgInfoMessageInfoDialog::ESmsEditor;
       
   583 
       
   584     TMsgInfoMessageInfoData infoData;
       
   585     
       
   586     // Subject
       
   587     // TODO: When should we show subject?
       
   588     //       - MMS: yes
       
   589     //       - ordinary SMS: no?
       
   590     //       - SMS with header field
       
   591     //       - Email over SMS: yes?
       
   592     infoData.iSubject.Set( static_cast<CUniClientMtm&>( iBaseMtm ).SubjectL() );
       
   593 
       
   594     // Get correct time stamps
       
   595     infoData.iDateTime = entry.iDate;
       
   596     HBufC* msgType( NULL );
       
   597     switch ( currType )
       
   598         {
       
   599         case EUniMessageCurrentTypeMms:
       
   600             {
       
   601             infoType = CMsgInfoMessageInfoDialog::EMmsEditor;
       
   602             msgType = StringLoader::LoadLC( R_MSGTYPE_TEXT_MMS, iCoeEnv );
       
   603             popCount++;
       
   604             infoData.iType.Set( *msgType );
       
   605             break;
       
   606             }
       
   607         case EUniMessageCurrentTypeSms:
       
   608         default:
       
   609             {
       
   610             //infoType already set
       
   611             msgType = StringLoader::LoadLC( R_MSGTYPE_TEXT_SMS, iCoeEnv );
       
   612             popCount++;
       
   613             infoData.iType.Set( *msgType ); 
       
   614             break;
       
   615             }
       
   616         }
       
   617     
       
   618     // Size of message.
       
   619     if ( currType == EUniMessageCurrentTypeMms )
       
   620         {
       
   621         TInt sizeOfMessage = 0;
       
   622         if ( aParameter.Length() )
       
   623             { // We are called from editor.
       
   624             TPckgBuf <TInt> paramPack;
       
   625             const TInt paramSize = sizeof( TInt );
       
   626 
       
   627             paramPack.Copy( aParameter.Ptr(), paramSize );
       
   628             sizeOfMessage = KKilo * paramPack();
       
   629             }
       
   630         else
       
   631             {
       
   632             // Cannot get empty message size ok from client MTM, as it always contains something.
       
   633             if ( !IsMessageEmptyL() )
       
   634                 {
       
   635                 sizeOfMessage = static_cast<CUniClientMtm&>( iBaseMtm ).MessageSize();
       
   636                 }
       
   637             }
       
   638         // Finally make the UI string
       
   639         TBuf<KMessageSize> sizeString;
       
   640         MessageSizeToStringL( sizeString, sizeOfMessage );
       
   641         infoData.iSize.Set( sizeString );
       
   642         
       
   643         if ( priorityFeatureSupported )
       
   644             {
       
   645             HBufC* priority = NULL;
       
   646             switch ( entry.Priority() )
       
   647         	    {
       
   648                 case EMsvHighPriority:
       
   649             	    {
       
   650                     priority  = StringLoader::LoadLC( R_UNI_MMS_MESSAGE_PRIORITY_HIGH, iCoeEnv );
       
   651                     popCount++;
       
   652                     break;
       
   653             	    }
       
   654         	    case EMsvLowPriority:
       
   655         		    {
       
   656                     priority  = StringLoader::LoadLC( R_UNI_MMS_MESSAGE_PRIORITY_LOW, iCoeEnv );
       
   657                     popCount++;
       
   658         		    break;
       
   659         		    }
       
   660                 case EMsvMediumPriority:
       
   661                 default:
       
   662             	    {
       
   663         	        priority  = StringLoader::LoadLC( R_UNI_MMS_MESSAGE_PRIORITY_NORMAL, iCoeEnv );
       
   664                     popCount++;
       
   665                     break;
       
   666                     }
       
   667                 }
       
   668             
       
   669             infoData.iPriority.Set( *priority ); 
       
   670             }
       
   671         }
       
   672 
       
   673     // To
       
   674     const CMsvRecipientList& recipients = static_cast<CUniClientMtm&>( iBaseMtm ).AddresseeList();
       
   675     HBufC* toList( NULL );
       
   676     HBufC* ccList( NULL );
       
   677     HBufC* bccList( NULL );
       
   678       
       
   679     TurnRecipientsArrayIntoStringsLC(
       
   680                             recipients,
       
   681                             toList,
       
   682                             ccList,
       
   683                             bccList, 
       
   684                             addHeadersBitmask );
       
   685     if ( toList )
       
   686         {
       
   687         infoData.iTo.Set( *toList );
       
   688         popCount++;
       
   689         }
       
   690     if ( ccList )
       
   691         {
       
   692         infoData.iCC.Set( *ccList );
       
   693         popCount++;
       
   694         }
       
   695     if ( bccList )
       
   696         {
       
   697         infoData.iBCC.Set( *bccList );
       
   698         popCount++;
       
   699         }
       
   700 
       
   701     CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL();
       
   702 
       
   703     infoDialog->ExecuteLD( infoData, infoType );
       
   704     
       
   705     CleanupStack::PopAndDestroy( popCount );
       
   706 
       
   707     return CMsvCompletedOperation::NewL( Session(), 
       
   708         KUidMsvLocalServiceMtm, 
       
   709         KNullDesC8, 
       
   710         KMsvLocalServiceIndexEntryId, 
       
   711         aCompletionStatus );
       
   712     }
       
   713 
       
   714       
       
   715 // ---------------------------------------------------------
       
   716 // CUniMtmUi::TurnRecipientsArrayIntoStringsLC
       
   717 // Every created recipient buffer object increases pushed object count by one
       
   718 // ---------------------------------------------------------
       
   719 //
       
   720 void CUniMtmUi::TurnRecipientsArrayIntoStringsLC(
       
   721                             const   CMsvRecipientList&  aRecip,
       
   722                             HBufC*&                     aTo,
       
   723                             HBufC*&                     aCc,
       
   724                             HBufC*&                     aBcc, 
       
   725                             TInt                        aAddHeadersVariation ) const
       
   726     {
       
   727     TInt count = aRecip.Count();
       
   728     if ( count == 0 )
       
   729         {
       
   730         return;
       
   731         }
       
   732         
       
   733     TMsvEntry entry = BaseMtm().Entry().Entry();
       
   734         
       
   735     // indeces refers To, Cc, Bcc
       
   736     TInt recipTypesIndex = 0;
       
   737     const TInt KRecipTypesCount = 3;
       
   738     
       
   739     TMsvRecipientTypeValues recipType ( EMsvRecipientTo );
       
   740     
       
   741     // needs first round to check what is there
       
   742     TInt index = 0;
       
   743     TInt stringLengthTo = 0;
       
   744     TInt stringLengthCc = 0;
       
   745     TInt stringLengthBcc = 0;
       
   746     TInt* stringLength = &stringLengthTo;    
       
   747     for ( recipTypesIndex = 0; recipTypesIndex < KRecipTypesCount; recipTypesIndex++ )
       
   748         {
       
   749         if ( recipTypesIndex == 1 )
       
   750             {
       
   751             stringLength = &stringLengthCc;
       
   752             recipType = EMsvRecipientCc;
       
   753             }
       
   754         else if ( recipTypesIndex == 2 )
       
   755             {
       
   756             stringLength = &stringLengthBcc;
       
   757             recipType = EMsvRecipientBcc;
       
   758             }
       
   759             
       
   760         for ( index = 0; index < count; index++ )
       
   761             {
       
   762             if ( aRecip.Type( index ) == recipType )
       
   763                 {
       
   764                 ( *stringLength ) += TMmsGenUtils::Alias( aRecip[index] ).Length();
       
   765                 ( *stringLength ) += TMmsGenUtils::PureAddress( aRecip[index] ).Length();
       
   766                 // Additional space for chars: '<' '>' ',' + 2 x KMmsLRMarker
       
   767                 ( *stringLength ) += KMmsAdditionalCharsStringLength;
       
   768                 }
       
   769             }
       
   770         }
       
   771 
       
   772     if (    stringLengthTo
       
   773         ||  stringLengthCc
       
   774         ||  stringLengthBcc )
       
   775         {
       
   776         // needs second round to copy strigs:
       
   777         // if CC not variated On, append CC recipients to To: field
       
   778         // if BCC not variated On but CC variated On, append BCC recipients to Cc: field
       
   779         // if BCC not variated On and also CC variated Off, append BCC recipients to To: field    
       
   780         HBufC** recipients = NULL;
       
   781         recipType = EMsvRecipientTo;
       
   782         TInt bufLength( stringLengthTo ); 
       
   783         for ( recipTypesIndex = 0; recipTypesIndex < KRecipTypesCount; recipTypesIndex++ )
       
   784             {       
       
   785             recipients = NULL;
       
   786             if ( recipTypesIndex == 0 )
       
   787                 {
       
   788                 if ( ! ( aAddHeadersVariation & KMmsFeatureIdEditorCcField ) )
       
   789                     {
       
   790                     // CC not supported on the UI
       
   791                     bufLength += stringLengthCc;
       
   792                     if ( ! ( aAddHeadersVariation & KMmsFeatureIdEditorBccField ) )
       
   793                         {
       
   794                         // BCC not supported on the UI
       
   795                         bufLength += stringLengthBcc;
       
   796                         }
       
   797                     }
       
   798                 if ( bufLength )
       
   799                     {
       
   800                     aTo = HBufC::NewLC( bufLength );
       
   801                     recipients = &aTo;
       
   802                     }
       
   803                 else
       
   804                     {
       
   805                     continue;
       
   806                     }
       
   807                 }        
       
   808             else if ( recipTypesIndex == 1 )
       
   809                 {
       
   810                 recipType = EMsvRecipientCc;
       
   811                 if ( aAddHeadersVariation & KMmsFeatureIdEditorCcField )
       
   812                     {
       
   813                     // Cc supported on the UI
       
   814                     bufLength = stringLengthCc;
       
   815                     if ( ! ( aAddHeadersVariation & KMmsFeatureIdEditorBccField ) )
       
   816                         {
       
   817                         // BCC not supported on the UI
       
   818                         bufLength += stringLengthBcc;
       
   819                         }
       
   820                     if ( bufLength )
       
   821                         {
       
   822                         aCc = HBufC::NewLC( bufLength );    
       
   823                         recipients = &aCc;
       
   824                         }
       
   825                     else
       
   826                         {
       
   827                         continue;
       
   828                         }
       
   829                     }
       
   830                 else
       
   831                     {
       
   832                     // Cc not supported on the UI
       
   833                     recipients = &aTo;
       
   834                     }
       
   835                 }
       
   836             else if ( recipTypesIndex == 2 )
       
   837                 {
       
   838                 
       
   839                 recipType = EMsvRecipientBcc;
       
   840                 if ( aAddHeadersVariation & KMmsFeatureIdEditorBccField )
       
   841                     {
       
   842                     // BCC supported on the UI
       
   843                     bufLength = stringLengthBcc;
       
   844                     if ( bufLength )
       
   845                         {
       
   846                         aBcc = HBufC::NewLC( bufLength );    
       
   847                         recipients = &aBcc;
       
   848                         }
       
   849                     else
       
   850                         {
       
   851                         continue;
       
   852                         }
       
   853                     }
       
   854                 else if ( aAddHeadersVariation & KMmsFeatureIdEditorCcField )
       
   855                     {
       
   856                     // CC supported on the UI
       
   857                     recipients = &aCc;
       
   858                     }
       
   859                 else 
       
   860                     {
       
   861                     // BCC not supported on the UI
       
   862                     recipients = &aTo;
       
   863                     }
       
   864                     
       
   865                 }
       
   866             
       
   867             if (    recipients
       
   868                 &&  *recipients )
       
   869                 {                
       
   870                 TPtr listPtr = (*recipients)->Des();
       
   871                 for ( index=0; index < count; index++ )
       
   872                     {
       
   873                     if ( aRecip.Type( index ) == recipType )
       
   874                         {
       
   875                         TPtrC name = TMmsGenUtils::Alias( aRecip[index] );
       
   876                         TPtrC number = TMmsGenUtils::PureAddress( aRecip[index] );
       
   877                         if ( name.Length() )
       
   878                             {
       
   879                             listPtr.Append( name );
       
   880                             listPtr.Append( KMmsLRMarker );
       
   881                             listPtr.Append( KCharLeftAddressIterator );
       
   882                             listPtr.Append( number );
       
   883                             listPtr.Append( KCharRightAddressIterator );
       
   884                             listPtr.Append( KMmsLRMarker );
       
   885                             }
       
   886                         else
       
   887                             {
       
   888                             listPtr.Append( number );
       
   889                             }
       
   890                         
       
   891                         //append always and remove last one in the very end
       
   892                         listPtr.Append( KMmsCharCommaAndSpace );
       
   893                         }
       
   894                     }
       
   895                 }
       
   896             }
       
   897         
       
   898         // third round to strip the ", " off
       
   899         for ( recipTypesIndex = 0; recipTypesIndex < KRecipTypesCount; recipTypesIndex++ )
       
   900             {
       
   901             recipients = NULL;
       
   902             if ( recipTypesIndex == 0 
       
   903                 &&  aTo )
       
   904                 {
       
   905                 recipients = &aTo;
       
   906                 }   
       
   907             else if ( recipTypesIndex == 1 
       
   908                     &&  aCc )
       
   909                 {
       
   910                 recipients = &aCc;
       
   911                 }   
       
   912             else if ( recipTypesIndex == 2 
       
   913                     &&  aBcc )
       
   914                 {
       
   915                 recipients = &aBcc;
       
   916                 }
       
   917             if ( recipients
       
   918                 &&  *recipients )
       
   919                 {
       
   920                 TPtr listPtr = (*recipients)->Des();
       
   921                 if ( listPtr.Length() > KMmsCharCommaAndSpace().Length() )
       
   922                     {
       
   923                     listPtr.SetLength( listPtr.Length() - KMmsCharCommaAndSpace().Length() );
       
   924                     }
       
   925                 }
       
   926             }
       
   927         }
       
   928     }
       
   929 
       
   930 
       
   931 // ---------------------------------------------------------
       
   932 // CUniMtmUi::MessageSizeToStringL(TDes& aTarget, TInt aFileSize)
       
   933 // Converts message size in bytes to a kilobyte string. Rounds the bytes up to the
       
   934 // next full kilo. I.e:
       
   935 // 0 -> 0KB
       
   936 // 1 -> 1KB
       
   937 // 1024 -> 1KB
       
   938 // 1025 -> 2KB
       
   939 // ---------------------------------------------------------
       
   940 //
       
   941 void CUniMtmUi::MessageSizeToStringL( TDes& aTarget, TInt aFileSize ) const
       
   942     {
       
   943     TInt fileSize = aFileSize / KKilo;
       
   944     if ( aFileSize % KKilo )
       
   945         {
       
   946         fileSize++;
       
   947         }
       
   948 
       
   949     HBufC* buf = StringLoader::LoadLC( R_MSG_SIZE_KB, fileSize, iEikonEnv );
       
   950     TPtr ptr = buf->Des();
       
   951     ptr.Trim(); // remove possible white space from beginning
       
   952     aTarget.Append( ptr );
       
   953     CleanupStack::PopAndDestroy( buf ); 
       
   954     }
       
   955 
       
   956 // ---------------------------------------------------------
       
   957 // CUniMtmUi::IsMessageEmptyL()
       
   958 // Checks if the message is effectively empty or not
       
   959 // ---------------------------------------------------------
       
   960 //
       
   961 TBool CUniMtmUi::IsMessageEmptyL() const
       
   962     {
       
   963     TBool empty = EFalse;
       
   964         
       
   965     CMsvStore* store = static_cast<CUniClientMtm&>( iBaseMtm ).Entry().ReadStoreL();
       
   966     CleanupStack::PushL( store );
       
   967     MMsvAttachmentManager& attaManager = store->AttachmentManagerL();    
       
   968     TInt attaCount = attaManager.AttachmentCount();
       
   969     CleanupStack::PopAndDestroy( store );
       
   970 
       
   971     // Only attachments and subject are calculated
       
   972     // in message size.
       
   973     if ( attaCount == 0 &&
       
   974         static_cast<CUniClientMtm&>( iBaseMtm ).SubjectL().Length() == 0 )
       
   975         {
       
   976         // No attachments nor subject
       
   977         empty = ETrue;
       
   978         }
       
   979 
       
   980     return empty;
       
   981     }
       
   982     
       
   983 // ---------------------------------------------------------
       
   984 // CUniMtmUi::ConvertUtcToLocalTime
       
   985 //
       
   986 // ---------------------------------------------------------
       
   987 //
       
   988 void CUniMtmUi::ConvertUtcToLocalTime( TTime& aTime )
       
   989     {
       
   990     TLocale locale;
       
   991     // Add time difference
       
   992     aTime += locale.UniversalTimeOffset();
       
   993     if (locale.QueryHomeHasDaylightSavingOn())          
       
   994         { // and possible daylight saving time
       
   995         TTimeIntervalHours daylightSaving(1);          
       
   996         aTime += daylightSaving;
       
   997         }
       
   998     }
       
   999 
       
  1000 //  End of File