mobilemessaging/mmsui/notmtmsrc/MMBoxDialog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation of the CMMBoxDialog class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include <eikmenup.h>
       
    22 #include <aknViewAppUi.h>               // iAvkonViewAppUi
       
    23 #include <AknWaitDialog.h>              // CAknWaitDialog
       
    24 #include <eikprogi.h>                   // CEikProgressInfo
       
    25 #include <AknQueryDialog.h>             // CAknQueryDialog
       
    26 #include <aknlists.h>
       
    27 #include <StringLoader.h>               // StringLoader
       
    28 #include <akntitle.h>                   // CAknTitlePane
       
    29 #include <AknIconArray.h>               // CAknIconArray
       
    30 // message includes
       
    31 #include <msvapi.h>                     // for CMsvSession
       
    32 #include <msvstd.h>                     // SelectionOrder
       
    33 #include <akninputblock.h>              // CAknInputBlock
       
    34 #include <MuiuMsvProgressReporterOperation.h> // MsvProgressReporterOperation
       
    35 #include <MuiuMsgEmbeddedEditorWatchingOperation.h> // CMsgEmbeddedEditorWatchingOperation
       
    36 #include <data_caging_path_literals.hrh> 
       
    37 #include <muiumsvuiserviceutilitiesinternal.h>
       
    38 
       
    39 #include <MuiuOperationWait.h>          // CMuiuOperationWait
       
    40 #include <csxhelp/mce.hlp.hrh>
       
    41 #include <hlplch.h>                     // For HlpLauncher 
       
    42 #include <bldvariant.hrh>
       
    43 #include <featmgr.h>                    // FeatureManager
       
    44 #include <muiu.mbg>                     // bitmaps
       
    45 #include <msvids.h>                     // for KMsvInboxIndexEntryId
       
    46 #include <mtclreg.h>
       
    47 #include <AknsUtils.h>                  // For skinned stuff
       
    48 #include <eikmenub.h>                   // For CEikMenuBar
       
    49 #include <aknnotewrappers.h>            // CAknInformationNote
       
    50 #include <mmsnotificationclient.h>      // For Notification Client MTM
       
    51 #include <aknnavi.h>                    // For navipane
       
    52 #include <aknnavide.h>                  // CAknNavigationDecorator
       
    53 #include <akntabgrp.h>                  // CAknTabGroup
       
    54 #include <aknenv.h>                     // CAknEnv
       
    55 
       
    56 #include <NotUi.rsg>
       
    57 #include "NotUi.hrh"                    // for EMsgControlIdMMBoxListBox
       
    58 #include "MMBoxDialog.h"
       
    59 #include "NotMtmUi.h"
       
    60 #include "NotMtmUiData.h"
       
    61 #include "MmsMtmConst.h"
       
    62 
       
    63 //  LOCAL CONSTANTS AND MACROS
       
    64 const TInt KMMBoxBitmapArrayGranularity = 4;
       
    65 const TInt KMMBoxMaxStatusInfoLength = 256;
       
    66 const TInt KDateSize            = 30;
       
    67 const TInt KMMBoxDialogFetchOperationsGranularity = 1;
       
    68 const TInt KLocalKilo = 1024;
       
    69 const TUid KUidMsvMessageListSortOrder={0x10005359};
       
    70 
       
    71 _LIT( KMMBoxMarkReplacement, "1");
       
    72 #define IS_PHONE_OFF_LINEL() MsvUiServiceUtilitiesInternal::IsPhoneOfflineL()
       
    73 //#if defined ( _DEBUG )
       
    74 // Enables notifications view testing without mmbox (to some extent).
       
    75 // Uses Inbox as notifications folder instead of mmbox folder.
       
    76 //#define MMS_NOTIFICATIONS_TESTING_WO_MMBOX 1
       
    77 //#endif
       
    78 
       
    79 
       
    80 //
       
    81 //
       
    82 // CMMBoxDialog
       
    83 //
       
    84 //
       
    85 
       
    86 // ----------------------------------------------------
       
    87 // CMMBoxDialog::CMMBoxDialog
       
    88 // ----------------------------------------------------
       
    89 CMMBoxDialog::CMMBoxDialog( CNotMtmUi&  aUi, 
       
    90                             CNotMtmUiData&  aUiData, 
       
    91                             CMsvSession& aSession, 
       
    92                             TInt& aExitCode ):
       
    93     iUi( aUi ),
       
    94     iUiData( aUiData ),
       
    95     iClientMtm( NULL ),
       
    96     iSession( aSession ),
       
    97     iNaviDecorator( NULL ),
       
    98     iMMBoxFolderId( KMsvGlobalInBoxIndexEntryId ),
       
    99     iFetchOperations( KMMBoxDialogFetchOperationsGranularity ),
       
   100     iDeleteSelection( NULL ),
       
   101     iExitCode( aExitCode ),
       
   102     iFlags( 0 ),
       
   103     iOriginalOrder ( KMsvNoGrouping, EMsvSortByDateReverse, EFalse )
       
   104     {
       
   105     iExitCode = KErrNone;
       
   106     iMarkReplacementText.Copy( KMMBoxMarkReplacement );
       
   107     }
       
   108 
       
   109 // ----------------------------------------------------
       
   110 // CMMBoxDialog::~CMMBoxDialog
       
   111 // ----------------------------------------------------
       
   112 CMMBoxDialog::~CMMBoxDialog()
       
   113     {
       
   114     LOGTEXT(_L8("MMBoxDialog: Destructor "));
       
   115     iSession.RemoveObserver( *this );
       
   116     delete iClientMtm;
       
   117     delete iMtmReg;
       
   118     // do not delete iNavipane - it's just a pointer
       
   119     delete iOldTitleText;
       
   120     delete iDeleteOperation;
       
   121     delete iOpenOperation;
       
   122     for ( TInt cc=iFetchOperations.Count()-1; cc>=0; cc-- )
       
   123         {
       
   124         delete iFetchOperations[cc];
       
   125         iFetchOperations.Delete(cc);
       
   126         }    
       
   127     iFetchOperations.ResetAndDestroy();
       
   128     delete iDeleteSelection;
       
   129     delete iUpdateOperation;
       
   130     delete iWaitDialog;
       
   131     delete iMessages;
       
   132     }
       
   133 
       
   134 // ----------------------------------------------------
       
   135 // CMMBoxDialog::NewL
       
   136 // ----------------------------------------------------
       
   137 CMMBoxDialog* CMMBoxDialog::NewL(   CNotMtmUi&  aUi, 
       
   138                                     CNotMtmUiData&  aUiData, 
       
   139                                     CMsvSession& aSession, 
       
   140                                     TInt& aExitCode )
       
   141     {
       
   142     CMMBoxDialog* self= new(ELeave) CMMBoxDialog( aUi, 
       
   143         aUiData, aSession, aExitCode );
       
   144     CleanupStack::PushL(self);
       
   145     self->ConstructL( );
       
   146     CleanupStack::Pop( );
       
   147     return self;
       
   148     }
       
   149 
       
   150 // ----------------------------------------------------
       
   151 // CMMBoxDialog::ConstructL
       
   152 // ----------------------------------------------------
       
   153 void CMMBoxDialog::ConstructL( )
       
   154     {
       
   155     LOGTEXT(_L8("MMBoxDialog: Construct start"));
       
   156     CAknDialog::ConstructL( R_NOT_MMBOX_MENUBAR );
       
   157     LOGTEXT(_L8("MMBoxDialog: Construct 2"));
       
   158     iMessages = CMMBoxArray::NewL( iSession, iUiData );
       
   159     LOGTEXT(_L8("MMBoxDialog: Construct 3"));
       
   160     iSession.AddObserverL( *this );
       
   161 
       
   162     // Prepare FeatureManager, read values to members and uninitialize FeatureManager
       
   163     FeatureManager::InitializeLibL( );
       
   164     if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   165         {
       
   166         iFlags |= EHelpSupported;
       
   167         }
       
   168     FeatureManager::UnInitializeLib( );
       
   169 
       
   170     CEikStatusPane *sp = iEikonEnv->AppUiFactory( )->StatusPane( );
       
   171       
       
   172     if ( sp )
       
   173         {
       
   174         iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   175         ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   176         }
       
   177     LOGTEXT(_L8("MMBoxDialog: Constructor end "));
       
   178     }
       
   179 
       
   180 // ----------------------------------------------------
       
   181 // CMMBoxDialog::PreLayoutDynInitL
       
   182 // ----------------------------------------------------
       
   183 void CMMBoxDialog::PreLayoutDynInitL( )
       
   184     {
       
   185     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL start"));
       
   186     CEikColumnListBox* listBox = ListBox( );
       
   187     listBox->SetListBoxObserver( this );
       
   188 
       
   189     // Create scroll bar
       
   190     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 2"));
       
   191     listBox->CreateScrollBarFrameL( );
       
   192     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 3"));
       
   193     CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>( iEikonEnv->EikAppUi() );
       
   194     if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
       
   195         {
       
   196         // For EDoubleSpan type scrollbar
       
   197         listBox->ScrollBarFrame( )->CreateDoubleSpanScrollBarsL(EFalse, EFalse); // non-window owning scrollbar
       
   198         listBox->ScrollBarFrame( )->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
       
   199         }
       
   200     else
       
   201         {
       
   202         listBox->ScrollBarFrame( )->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead);
       
   203         }
       
   204     listBox->ScrollBarFrame( )->SetScrollBarVisibilityL(
       
   205         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   206 
       
   207     // Set data
       
   208     listBox->Model( )->SetItemTextArray( iMessages );
       
   209     listBox->Model( )->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   210 
       
   211     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 4"));
       
   212     HBufC* emptyText = StringLoader::LoadLC( 
       
   213         R_NOT_MMBOX_EMPTY_STRING, 
       
   214         iCoeEnv );
       
   215     listBox->View( )->SetListEmptyTextL( *emptyText );
       
   216     CleanupStack::PopAndDestroy( emptyText );
       
   217 
       
   218     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 5"));
       
   219     StoreTitleTextAndNavipaneAndSetNewL( );
       
   220     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 6"));
       
   221 
       
   222     iMtmReg = CClientMtmRegistry::NewL( iSession );
       
   223     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 7"));
       
   224 	iClientMtm = (CMmsNotificationClientMtm*)iMtmReg->NewMtmL( KUidMsgMMSNotification );
       
   225     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 8"));
       
   226 
       
   227 #ifndef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
   228     iMMBoxFolderId = iClientMtm->GetMmboxFolderL( );
       
   229 #else
       
   230     LOGTEXT(_L8("MMBoxDialog: MMS_NOTIFICATIONS_TESTING_WO_MMBOX on"));
       
   231 #endif
       
   232     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 9"));
       
   233 
       
   234     CArrayPtrFlat<CGulIcon>* icons 
       
   235         = new( ELeave ) CAknIconArray( 
       
   236         KMMBoxBitmapArrayGranularity ); 
       
   237 
       
   238     CleanupStack::PushL( icons );
       
   239 
       
   240     // create icon array
       
   241     TFileName fileName;
       
   242     fileName.Copy( KAvkonBitmapFile );
       
   243     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL Append bitmaps"));
       
   244     // this must be first because of SetItemMarkReplacement index.
       
   245     AppendSkinnedIconL( fileName, EMbmAvkonQgn_prop_checkbox_on, icons );
       
   246     AppendSkinnedIconL( fileName, EMbmAvkonQgn_prop_checkbox_off, icons );
       
   247     
       
   248     // priority icons
       
   249     AppendSkinnedIconL( fileName, EMbmAvkonQgn_indi_mce_priority_high, icons );
       
   250     AppendSkinnedIconL( fileName, EMbmAvkonQgn_indi_mce_priority_low, icons );
       
   251     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL Append bitmaps end"));
       
   252 
       
   253     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   254         ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
       
   255             TUid::Uid(EEikStatusPaneUidNavi) ) );
       
   256     iNaviPane->PushDefaultL();
       
   257 
       
   258     REINTERPRET_CAST( CAknDoubleGraphicStyleListBox*, listBox)->
       
   259         ItemDrawer( )->FormattedCellData()->SetIconArrayL( icons );
       
   260     listBox->ItemDrawer( )->SetItemMarkReplacement( iMarkReplacementText );
       
   261     CleanupStack::Pop( icons ); // icons
       
   262 
       
   263     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 10"));
       
   264     UpdateMMBoxArrayL( );
       
   265     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL 11"));
       
   266     UpdateNavipaneL( );
       
   267     LOGTEXT(_L8("MMBoxDialog: PreLayoutDynInitL end"));
       
   268     }
       
   269 
       
   270 // ----------------------------------------------------
       
   271 // CMMBoxDialog::PostLayoutDynInitL
       
   272 // ----------------------------------------------------
       
   273 void CMMBoxDialog::PostLayoutDynInitL()
       
   274     {
       
   275     LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL start"));
       
   276 
       
   277     if ( IS_PHONE_OFF_LINEL() )
       
   278         {   // We are in offline at the moment -> just return
       
   279         return;
       
   280         }
       
   281 
       
   282     if( !iUi.CheckSettingsL( ) )
       
   283         { // AP is not valid -> just return 
       
   284         return;
       
   285         }
       
   286     
       
   287     TMmboxInfo info;
       
   288 
       
   289     TInt err=0;
       
   290     TInt ret=0;
       
   291     TRAP( err, ret = iClientMtm->MmboxInfoL( info ) );
       
   292 
       
   293 #ifdef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
   294     ret = 1;
       
   295     info.error = 0;
       
   296     info.date.HomeTime();
       
   297 #endif
       
   298 
       
   299     if( err )
       
   300         {
       
   301         LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL info leave"));
       
   302         return;
       
   303         }
       
   304     else if( ret )
       
   305         {
       
   306         LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL info found"));
       
   307         TInt startUpdate;
       
   308         if( info.error )
       
   309             {
       
   310             LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL info update was not success"));
       
   311 	        HBufC* buf;		// a buffer for strings
       
   312             buf = 
       
   313                 StringLoader::LoadL( R_NOT_MMBOX_LAST_UPDATE_ERROR, iCoeEnv );
       
   314             CleanupStack::PushL( buf );
       
   315 
       
   316             startUpdate = ShowConfirmationQueryL( *buf );
       
   317 
       
   318             CleanupStack::PopAndDestroy( buf );
       
   319             }
       
   320         else
       
   321             {
       
   322             LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL info update was success last"));
       
   323 
       
   324             TTime date( info.date );
       
   325 
       
   326             // Date is GMT so add offset + dst
       
   327     	    TLocale locale;
       
   328             date += locale.UniversalTimeOffset();
       
   329     	    if (locale.QueryHomeHasDaylightSavingOn())          
       
   330     		    {
       
   331     		    TTimeIntervalHours daylightSaving(1);          
       
   332     		    date += daylightSaving;
       
   333     		    }
       
   334 
       
   335 	        HBufC* buf;		// a buffer for strings
       
   336             HBufC* dateFormat = StringLoader::LoadLC( R_QTN_DATE_SHORT, iCoeEnv );
       
   337             TBuf<KDateSize> dateString;
       
   338             date.FormatL( dateString, *dateFormat );
       
   339             CleanupStack::PopAndDestroy(); //dateFormat
       
   340 
       
   341             dateFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL, iCoeEnv );
       
   342             TBuf<KDateSize> timeString;
       
   343             date.FormatL( timeString, *dateFormat );
       
   344             CleanupStack::PopAndDestroy(); //dateFormat
       
   345 
       
   346             CDesC16ArrayFlat* array = new(ELeave) CDesC16ArrayFlat( 2 );
       
   347             CleanupStack::PushL( array );
       
   348             array->AppendL( timeString );
       
   349             array->AppendL( dateString );
       
   350             buf = 
       
   351                 StringLoader::LoadL( R_NOT_MMBOX_TIMED_QUERY, *array, iCoeEnv );
       
   352             CleanupStack::PopAndDestroy( array );
       
   353             CleanupStack::PushL( buf );
       
   354 
       
   355             startUpdate = ShowConfirmationQueryL( *buf );
       
   356 
       
   357             CleanupStack::PopAndDestroy( buf );
       
   358             }
       
   359         if( !startUpdate )
       
   360             { // User did not accept the "Update?" query
       
   361             return;
       
   362             }
       
   363         }
       
   364     else
       
   365         {
       
   366         if( !ShowConfirmationQueryL( R_NOT_MMBOX_TIMELESS_QUERY ) )
       
   367             {
       
   368             return;
       
   369             }
       
   370         }
       
   371 
       
   372     // If we end up here, user confirmed the update
       
   373     LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL 2"));
       
   374     UpdateListL( );
       
   375     LOGTEXT(_L8("MMBoxDialog: PostLayoutDynInitL end"));
       
   376 
       
   377     return;
       
   378     }
       
   379 
       
   380 // ----------------------------------------------------
       
   381 // CMMBoxDialog::AppendSkinnedIconL
       
   382 // ----------------------------------------------------
       
   383 void CMMBoxDialog::AppendSkinnedIconL(    
       
   384     TFileName& aFileName, 
       
   385     TInt aIconIndex, 
       
   386     CArrayPtrFlat<CGulIcon>* aIcons)
       
   387     {
       
   388     LOGTEXT(_L8("MMBoxDialog: AppendSkinnedIconL start"));
       
   389     TAknsItemID skinId;
       
   390     switch ( aIconIndex )
       
   391         {
       
   392         case EMbmAvkonQgn_prop_checkbox_off:
       
   393             {
       
   394             skinId.Set( KAknsIIDQgnPropCheckboxOff );
       
   395             break;
       
   396             }
       
   397         case EMbmAvkonQgn_prop_checkbox_on:
       
   398             {
       
   399             skinId.Set( KAknsIIDQgnPropCheckboxOn );
       
   400             break;
       
   401             }
       
   402         case EMbmAvkonQgn_indi_mce_priority_high:
       
   403             {
       
   404             skinId.Set( KAknsIIDQgnIndiMcePriorityHigh );
       
   405             break;
       
   406             }
       
   407         case EMbmAvkonQgn_indi_mce_priority_low:
       
   408             {
       
   409             skinId.Set( KAknsIIDQgnIndiMcePriorityLow );
       
   410             break;
       
   411             }
       
   412         default:
       
   413             {
       
   414             User::Leave( KErrNotFound );
       
   415             break;
       
   416             }
       
   417         }
       
   418 
       
   419     CFbsBitmap* bitmap = NULL;
       
   420     CFbsBitmap* mask = NULL;
       
   421 
       
   422     LOGTEXT(_L8("MMBoxDialog: AppendSkinnedIconL 2"));
       
   423     AknsUtils::CreateIconL(
       
   424         AknsUtils::SkinInstance(),
       
   425         skinId,
       
   426         bitmap,
       
   427         mask,
       
   428         aFileName,
       
   429         aIconIndex,
       
   430         aIconIndex + 1 ); //mask
       
   431     LOGTEXT(_L8("MMBoxDialog: AppendSkinnedIconL 3"));
       
   432 
       
   433     CleanupStack::PushL( bitmap );
       
   434     CleanupStack::PushL( mask );        
       
   435 
       
   436     CGulIcon* icon = NULL;
       
   437     icon = CGulIcon::NewL( bitmap, mask );
       
   438     CleanupStack::Pop( mask );
       
   439     CleanupStack::Pop( bitmap );
       
   440     CleanupStack::PushL( icon );
       
   441     aIcons->AppendL( icon );
       
   442     CleanupStack::Pop( icon ); // icon    
       
   443     LOGTEXT(_L8("MMBoxDialog: AppendSkinnedIconL end"));
       
   444     }
       
   445 
       
   446 // ----------------------------------------------------
       
   447 // CMMBoxDialog::OkToExitL
       
   448 // ----------------------------------------------------
       
   449 TBool CMMBoxDialog::OkToExitL(TInt aButtonId)
       
   450     {
       
   451     LOGTEXT(_L8("MMBoxDialog: OkToExitL start"));
       
   452     CAknInputBlock::NewLC(  ); // Absorb keys
       
   453     TBool okToExit = CAknDialog::OkToExitL( aButtonId );
       
   454 
       
   455     if ( okToExit )
       
   456         {
       
   457         LOGTEXT(_L8("MMBoxDialog: OkToExitL RestoreTitleText.."));
       
   458         TRAP_IGNORE( RestoreTitleTextAndNavipaneL() );
       
   459         }
       
   460 
       
   461     CleanupStack::PopAndDestroy(); // CAknInputBlock
       
   462 
       
   463     if( iExitCode == EEikCmdExit )
       
   464         {
       
   465         LOGTEXT(_L8("MMBoxDialog: OkToExitL RunAppShutter"));
       
   466         CAknEnv::RunAppShutter();
       
   467         }
       
   468 
       
   469     LOGTEXT(_L8("MMBoxDialog: OkToExitL end"));
       
   470     return okToExit;
       
   471     }
       
   472 
       
   473 // ----------------------------------------------------
       
   474 // CMMBoxDialog::ProcessCommandL
       
   475 // ----------------------------------------------------
       
   476 void CMMBoxDialog::ProcessCommandL( TInt aCommandId )
       
   477     {
       
   478     LOGTEXT(_L8("MMBoxDialog: ProcessCommand start"));
       
   479     CAknDialog::ProcessCommandL( aCommandId ) ;
       
   480 
       
   481     switch ( aCommandId )
       
   482         {
       
   483         case EMMBoxOpen:
       
   484             LOGTEXT(_L8("MMBoxDialog: ProcessCommand OpenNotification start"));
       
   485             OpenNotificationL( );
       
   486             break;
       
   487         case EMMBoxRetrieveSelected:
       
   488             LOGTEXT(_L8("MMBoxDialog: ProcessCommand RetrieveL start"));
       
   489             FetchL( );
       
   490             break;
       
   491         case EMMBoxRetrieveAll:
       
   492             LOGTEXT(_L8("MMBoxDialog: ProcessCommand RetrieveAll start"));
       
   493             FetchL( ETrue );
       
   494             break;
       
   495         case EMMBoxDeleteSelected:
       
   496             LOGTEXT(_L8("MMBoxDialog: ProcessCommand Delete start"));
       
   497             DeleteL( );
       
   498             break;
       
   499         case EMMBoxDeleteAll:
       
   500             LOGTEXT(_L8("MMBoxDialog: ProcessCommand DeleteAll start"));
       
   501             DeleteL( ETrue );
       
   502             break;
       
   503         case EMMBoxUpdateList:
       
   504             LOGTEXT(_L8("MMBoxDialog: ProcessCommand UpdateList start"));
       
   505             UpdateListL( );
       
   506             break;
       
   507         case EMMBoxViewStatus:
       
   508             LOGTEXT(_L8("MMBoxDialog: ProcessCommand ViewStatus start"));
       
   509             ShowStatusL( );
       
   510             break;
       
   511         case EMMBoxSortMessagesByDate:
       
   512             LOGTEXT(_L8("MMBoxDialog: ProcessCommand SortByDate start"));
       
   513             SortMessagesByL( EMMBoxSortByDate );
       
   514             break;
       
   515         case EMMBoxSortMessagesBySender:
       
   516             LOGTEXT(_L8("MMBoxDialog: ProcessCommand SortBySender start"));
       
   517             SortMessagesByL( EMMBoxSortByName );
       
   518             break;
       
   519         case EMMBoxSortMessagesBySubject:
       
   520             LOGTEXT(_L8("MMBoxDialog: ProcessCommand SortBySubject start"));
       
   521             SortMessagesByL( EMMBoxSortBySubject );
       
   522             break;
       
   523         case EAknCmdHelp:
       
   524             LOGTEXT(_L8("MMBoxDialog: ProcessCommand Help start"));
       
   525             LaunchHelpL();                
       
   526             break;
       
   527         case EAknCmdExit:
       
   528             {
       
   529             LOGTEXT(_L8("MMBoxDialog: ProcessCommand Exit start"));
       
   530             iExitCode = EEikCmdExit;
       
   531             TryExitL( EAknCmdExit );
       
   532             }
       
   533             break;
       
   534 
       
   535         default :
       
   536             LOGTEXT(_L8("MMBoxDialog: ProcessCommand default break"));
       
   537             break;
       
   538         }
       
   539     }
       
   540 
       
   541 // ----------------------------------------------------
       
   542 // CMMBoxDialog::DynInitMenuPaneL
       
   543 // ----------------------------------------------------
       
   544 void CMMBoxDialog::DynInitMenuPaneL(
       
   545     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   546     {
       
   547     LOGTEXT(_L8("MMBoxDialog: ProcessCommand DynInitMenuPaneL start"));
       
   548     if ( aResourceId == R_NOT_MMBOX_MENUPANE )
       
   549         {
       
   550         LOGTEXT(_L8("MMBoxDialog: ProcessCommand DynInitMenuPaneL menupane"));
       
   551         if( !( iFlags & EHelpSupported ) )
       
   552             {
       
   553             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   554             }
       
   555 
       
   556         TMmboxInfo info;
       
   557         TInt ret = 0;
       
   558         TRAPD( err, ret = iClientMtm->MmboxInfoL( info ) );
       
   559 
       
   560 #ifdef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
   561         ret = 1;
       
   562 #endif
       
   563 
       
   564         if( err || !ret )
       
   565             {// No info available
       
   566             aMenuPane->SetItemDimmed( EMMBoxViewStatus, ETrue ); 
       
   567             }
       
   568 
       
   569         if ( ListBox()->Model()->NumberOfItems() == 0 )
       
   570             {
       
   571             aMenuPane->SetItemDimmed( EMMBoxOpen, ETrue ); 
       
   572             aMenuPane->SetItemDimmed( EMMBoxRetrieveMenu, ETrue ); 
       
   573             aMenuPane->SetItemDimmed( EMMBoxDeleteMenu, ETrue ); 
       
   574             }
       
   575         else
       
   576             {
       
   577             TMsvEntry entry = 
       
   578                 iMessages->Entry( ListBox( )->CurrentItemIndex( ) );
       
   579 
       
   580             if( ListBox()->Model()->NumberOfItems() == 1 )
       
   581                 { // Operation support is only checked if there's only one entry
       
   582                   // Otherwise we let the user try to start the functions..
       
   583                 if( iUiData.OperationSupportedL( KMtmUiFunctionFetchMMS, entry ) )
       
   584                     {
       
   585                     aMenuPane->SetItemDimmed( EMMBoxRetrieveMenu, ETrue ); 
       
   586                     }
       
   587                 if( iUiData.OperationSupportedL( KMtmUiFunctionDeleteMessage, entry ) )
       
   588                     {
       
   589                     aMenuPane->SetItemDimmed( EMMBoxDeleteMenu, ETrue ); 
       
   590                     }
       
   591                 }
       
   592 
       
   593             if( iUiData.OperationSupportedL( KMtmUiFunctionOpenMessage, entry ) )
       
   594                 {
       
   595                 aMenuPane->SetItemDimmed( EMMBoxOpen, ETrue ); 
       
   596                 }
       
   597             }
       
   598         LOGTEXT(_L8("MMBoxDialog: ProcessCommand DynInitMenuPaneL end"));
       
   599         }
       
   600     }
       
   601 
       
   602 // ----------------------------------------------------
       
   603 // CMMBoxDialog::OfferKeyEventL
       
   604 // ----------------------------------------------------
       
   605 TKeyResponse CMMBoxDialog::OfferKeyEventL(
       
   606     const TKeyEvent& aKeyEvent, 
       
   607     TEventCode aType )
       
   608     {
       
   609     LOGTEXT(_L8("MMBoxDialog: ProcessCommand OfferKeyEvent"));
       
   610     CEikColumnListBox* listBox = ListBox();
       
   611     if ( listBox && aType == EEventKey && ( iUpdateOperation || iDeleteOperation ) )
       
   612         {   // When an operation is going on, we do not need keypresses
       
   613         LOGTEXT(_L8("MMBoxDialog: ProcessCommand OfferKeyEvent operation in progress"));
       
   614         return EKeyWasNotConsumed;
       
   615         }
       
   616     if ( listBox && aType == EEventKey && aKeyEvent.iCode == EKeyBackspace &&
       
   617          listBox->Model()->NumberOfItems() > 0 )
       
   618         { // C-key
       
   619         LOGTEXT(_L8("MMBoxDialog: ProcessCommand OfferKeyEvent Delete"));
       
   620         DeleteL( );
       
   621         return EKeyWasConsumed;
       
   622         }
       
   623     else if ( listBox && aType == EEventKey && aKeyEvent.iCode == EKeyOK )
       
   624         {   // Selection Key here!!!
       
   625         LOGTEXT(_L8("MMBoxDialog: ProcessCommand OfferKeyEvent Selection key"));
       
   626         listBox->View()->ToggleItemL( listBox->CurrentItemIndex() );
       
   627         return EKeyWasConsumed;
       
   628         }
       
   629     else if( aType == EEventKey && aKeyEvent.iCode == EKeyEscape )
       
   630         {
       
   631         if( !OkToExitL( -1 ) )
       
   632             {
       
   633             return EKeyWasConsumed;
       
   634             }
       
   635         }
       
   636 
       
   637     return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   638     }
       
   639 
       
   640 // ----------------------------------------------------
       
   641 // CMMBoxDialog::HandleListBoxEventL
       
   642 // ----------------------------------------------------
       
   643 void CMMBoxDialog::HandleListBoxEventL(
       
   644     CEikListBox* /*aListBox*/, 
       
   645     TListBoxEvent /*aEventType*/ )
       
   646     {
       
   647     }
       
   648 
       
   649 // ----------------------------------------------------
       
   650 // CMMBoxDialog::UpdateMMBoxArrayL
       
   651 // ----------------------------------------------------
       
   652 void CMMBoxDialog::UpdateMMBoxArrayL()
       
   653     {
       
   654     LOGTEXT(_L8("MMBoxDialog: UpdateMMBoxArray start"));
       
   655 
       
   656     iMessages->RefreshArrayL( iMMBoxFolderId );
       
   657 
       
   658     //	TInt newIndex = 
       
   659 	ListBox()->ScrollToMakeItemVisible( ListBox()->CurrentItemIndex( ) );
       
   660     ListBox()->DrawNow( );
       
   661     
       
   662     SetMSKL();
       
   663 
       
   664     LOGTEXT(_L8("MMBoxDialog: UpdateMMBoxArray end"));
       
   665     }
       
   666 
       
   667 // ----------------------------------------------------
       
   668 // CMMBoxDialog::ListBox
       
   669 // ----------------------------------------------------
       
   670 CEikColumnListBox* CMMBoxDialog::ListBox() const
       
   671     {
       
   672     return((CEikColumnListBox*)Control(EMsgControlIdMMBoxListBox));
       
   673     }
       
   674 
       
   675 // ----------------------------------------------------
       
   676 // CMMBoxDialog::StoreTitleTextAndNavipaneAndSetNewL
       
   677 // ----------------------------------------------------
       
   678 void CMMBoxDialog::StoreTitleTextAndNavipaneAndSetNewL()
       
   679     {
       
   680     LOGTEXT(_L8("MMBoxDialog: StoreTitleTextAndNavipane.. start"));
       
   681     CEikStatusPane* sp = iEikonEnv->AppUiFactory( )->StatusPane( );
       
   682     // Fetch pointer to the default title pane control
       
   683     CAknTitlePane* title=(CAknTitlePane *)sp->ControlL(
       
   684         TUid::Uid(EEikStatusPaneUidTitle));
       
   685 
       
   686     delete iOldTitleText;
       
   687     iOldTitleText = NULL;
       
   688     iOldTitleText = HBufC::NewL( title->Text()->Length() + 1 );
       
   689     TPtr tempText = iOldTitleText->Des();
       
   690     tempText.Copy( (*title->Text()) );
       
   691 
       
   692     HBufC* newTitle = StringLoader::LoadLC( 
       
   693         R_NOT_MMBOX_TITLE_TEXT, 
       
   694         iCoeEnv );
       
   695     title->SetTextL( *newTitle );
       
   696     CleanupStack::PopAndDestroy( newTitle );
       
   697 
       
   698     iNaviOld = iNaviPane->Top( );
       
   699 
       
   700     CMsvEntry* entry=iSession.GetEntryL(KMsvRootIndexEntryId);
       
   701     CleanupStack::PushL( entry );
       
   702     if ( entry->HasStoreL() )
       
   703         {
       
   704         CMsvStore* store = entry->ReadStoreL();
       
   705         CleanupStack::PushL( store );
       
   706         if ( store->IsPresentL( KUidMsvMessageListSortOrder ) )
       
   707             { // Read it first
       
   708             RMsvReadStream readStream;
       
   709             readStream.OpenLC( *store, KUidMsvMessageListSortOrder );
       
   710             iOriginalOrder.InternalizeL( readStream );
       
   711             CleanupStack::PopAndDestroy( ); // readStream
       
   712             // Then remove it
       
   713 /*            CMsvStore* store2 = entry->EditStoreL();
       
   714             CleanupStack::PushL( store2 );
       
   715             store->Remove(KUidMsvMessageListSortOrder);
       
   716             store->CommitL();
       
   717             CleanupStack::PopAndDestroy( store2 ); // store2
       
   718   */
       
   719             }
       
   720         CleanupStack::PopAndDestroy( store ); // store
       
   721         }
       
   722     CleanupStack::PopAndDestroy( entry );
       
   723     LOGTEXT(_L8("MMBoxDialog: StoreTitleTextAndNavipane.. end"));
       
   724     }
       
   725 
       
   726 // ----------------------------------------------------
       
   727 // CMMBoxDialog::RestoreTitleTextL
       
   728 // ----------------------------------------------------
       
   729 void CMMBoxDialog::RestoreTitleTextAndNavipaneL()
       
   730     {
       
   731     LOGTEXT(_L8("MMBoxDialog: RestoreTitleTextAndNavipane.. start"));
       
   732     CEikStatusPane* sp = iEikonEnv->AppUiFactory( )->StatusPane( );
       
   733     // Fetch pointer to the default title pane control
       
   734     CAknTitlePane* title=(CAknTitlePane *)sp->ControlL(
       
   735         TUid::Uid(EEikStatusPaneUidTitle));
       
   736 
       
   737     title->SetTextL( iOldTitleText->Des() );
       
   738     delete iOldTitleText;
       
   739     iOldTitleText = NULL;
       
   740 
       
   741     iNaviPane->Pop( iNaviDecorator );
       
   742     delete iNaviDecorator;
       
   743     iNaviDecorator = NULL;
       
   744 
       
   745     if( iNaviOld )
       
   746         {
       
   747         iNaviPane->PushL( *iNaviOld );
       
   748         }
       
   749     iNaviOld = NULL;
       
   750 
       
   751     if( iFlags & ESortTypeChanged )
       
   752         {
       
   753         // Remove the one set by MMBoxList
       
   754         CMsvEntry* entry=iSession.GetEntryL( KMsvRootIndexEntryId );
       
   755         CleanupStack::PushL( entry );
       
   756         CMsvStore* store = entry->EditStoreL();
       
   757         CleanupStack::PushL( store );
       
   758         store->Remove(KUidMsvMessageListSortOrder);
       
   759         store->CommitL();
       
   760         CleanupStack::PopAndDestroy( 2 ); // store, entry
       
   761 
       
   762         // If the original sory type was not the default one -> write it..
       
   763         TMsvSelectionOrdering def( KMsvNoGrouping, EMsvSortByDateReverse, EFalse );
       
   764         if( !(iOriginalOrder == def) )
       
   765             {
       
   766             CMsvEntry* entry=iSession.GetEntryL( KMsvRootIndexEntryId );
       
   767             CleanupStack::PushL( entry );
       
   768  	        CMsvStore* store = entry->EditStoreL();
       
   769  	        CleanupStack::PushL( store );
       
   770  	        RMsvWriteStream writeStream;
       
   771  	        writeStream.AssignLC( *store, KUidMsvMessageListSortOrder );
       
   772  	        iOriginalOrder.ExternalizeL( writeStream );
       
   773  	        writeStream.CommitL();
       
   774  	        store->CommitL();
       
   775  	        CleanupStack::PopAndDestroy( 3 ); // store, writestream, entry
       
   776             }   
       
   777         }    
       
   778     LOGTEXT(_L8("MMBoxDialog: RestoreTitleTextAndNavipane.. end"));
       
   779     }
       
   780 
       
   781 // ----------------------------------------------------
       
   782 // CMMBoxDialog::OpCompleted
       
   783 // ----------------------------------------------------
       
   784 void CMMBoxDialog::OpCompleted(
       
   785     CMsvSingleOpWatcher& aOpWatcher,
       
   786     TInt aCompletionCode )
       
   787     {
       
   788     LOGTEXT(_L8("MMBoxDialog: OpCompleted start"));
       
   789     TBool tryToExit = EFalse;
       
   790     CMsvOperation* op=&aOpWatcher.Operation();
       
   791     TRAP_IGNORE( tryToExit = DoOperationCompletedL(op, aCompletionCode ));  
       
   792     if ( tryToExit )
       
   793         {
       
   794         LOGTEXT(_L8("MMBoxDialog: OpCompleted tryToExit"));
       
   795         return;
       
   796         }
       
   797 
       
   798     if ( iDeleteOperation && iDeleteOperation->Operation().Id()==op->Id() )
       
   799         {
       
   800         LOGTEXT(_L8("MMBoxDialog: OpCompleted DeleteOperation"));
       
   801         TInt error = op->iStatus.Int( );
       
   802         // Check the entries one by one
       
   803         TInt failedOnes = 0;
       
   804         TInt totalOnes = 0;
       
   805         if( iDeleteSelection )
       
   806             { // This means user did not answer "No" to "Delete message" question
       
   807             for( TInt loop = 0; loop < iDeleteSelection->Count( ); loop++ )
       
   808                 {
       
   809                 TMsvEntry entry;
       
   810                 TMsvId service = -1;
       
   811                 totalOnes++;            
       
   812                 if ( iSession.GetEntry(iDeleteSelection->At(loop), service, entry ) != KErrNotFound )
       
   813                 	{
       
   814                     LOGTEXT(_L8("MMBoxDialog: OpCompleted DeleteOp Entry found after delete"));
       
   815                     failedOnes++;
       
   816                 	}
       
   817                 }
       
   818             }
       
   819         if( error || failedOnes )
       
   820             {
       
   821             LOGTEXT2(_L16("MMBoxDialog: OpCompleted DeleteOperation Error: %d"), error);
       
   822             if( failedOnes == 1)
       
   823                 {
       
   824                 LOGTEXT(_L8("MMBoxDialog: OpCompleted DeleteOp 1 failed"));
       
   825                 TRAP_IGNORE( ShowConfirmationQueryL( R_NOT_MMBOX_INFO_DELETE_FAILED, ETrue ) );
       
   826                 }
       
   827             else
       
   828                 {
       
   829                 LOGTEXT(_L8("MMBoxDialog: OpCompleted DeleteOp many failed"));
       
   830                 TRAP_IGNORE ( ShowConfirmationQueryL(   failedOnes,
       
   831                                                         totalOnes,                          
       
   832                                                         R_NOT_MMBOX_INFO_DELETE_FAILED_MANY ) );
       
   833                 }
       
   834             }
       
   835         delete iDeleteSelection;
       
   836         iDeleteSelection = NULL;
       
   837         delete iDeleteOperation;
       
   838         iDeleteOperation = NULL;
       
   839         }
       
   840 
       
   841     else if ( iOpenOperation && iOpenOperation->Operation().Id()==op->Id() )
       
   842         {
       
   843         if( !( iFlags & EDoNotDeleteOpen ) )
       
   844             {
       
   845             LOGTEXT(_L8("MMBoxDialog: OpCompleted OpenOperation"));
       
   846             delete iOpenOperation;
       
   847             iOpenOperation = NULL;
       
   848             }
       
   849         iFlags &= ~EDoNotDeleteOpen;    // Reset this anyway
       
   850         }
       
   851 
       
   852     else if ( iUpdateOperation && iUpdateOperation->Operation().Id()==op->Id() )
       
   853         {
       
   854         LOGTEXT(_L8("MMBoxDialog: OpCompleted UpdateOperation"));
       
   855 
       
   856         if( iWaitDialog )   // Remove the wait note from the screen
       
   857             {
       
   858             delete iWaitDialog;
       
   859             iWaitDialog=NULL;
       
   860             }
       
   861                 
       
   862         TInt error = op->iStatus.Int( );        
       
   863 
       
   864         delete iUpdateOperation;
       
   865         iUpdateOperation = NULL;
       
   866 
       
   867         if( error )
       
   868             {
       
   869             LOGTEXT2(_L16("MMBoxDialog: OpCompleted DeleteOperation Error: %d"), error);
       
   870             TRAP_IGNORE( ShowInformationNoteL( R_NOT_MMBOX_INFO_UNABLE_UPDATE, EFalse ) );
       
   871             }
       
   872         else
       
   873             {
       
   874             LOGTEXT(_L8("MMBoxDialog: OpCompleted UpdateOperation Success"));
       
   875             TMmboxInfo info;
       
   876             TBool infoExists=EFalse;
       
   877             TRAPD( err, infoExists=iClientMtm->MmboxInfoL( info ) );
       
   878 
       
   879 #ifdef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
   880             infoExists = 1;
       
   881             info.mmboxQuotaInBytes = 100500;
       
   882             info.mmboxTotalInBytes = 98000;
       
   883 #endif
       
   884 
       
   885             if( infoExists && !err )
       
   886                 {
       
   887                 if( info.mmboxTotalInBytes == 0 )
       
   888                     {
       
   889                     TRAP_IGNORE( ShowInformationNoteL( R_NOT_MMBOX_INFO_NO_MSGS, EFalse ) );
       
   890                     }
       
   891                 else 
       
   892 	               {
       
   893                    if( info.mmboxQuotaInBytes > 0 )
       
   894                        { // Make sure there will be no "division by zero"
       
   895     	               TReal res = (TReal)info.mmboxTotalInBytes/(TReal)info.mmboxQuotaInBytes;
       
   896 	                   if( res > 0.8 )
       
   897 	                        {
       
   898 	                        TRAP_IGNORE( ShowConfirmationQueryL( R_NOT_MMBOX_QUERY_80_USED, ETrue ) );
       
   899 	                        }
       
   900                        }
       
   901 	                }
       
   902                 }
       
   903             LOGTEXT(_L8("MMBoxDialog: OpCompleted UpdateOperation 2"));
       
   904             TRAP_IGNORE( UpdateNavipaneL( ));  
       
   905             // We just need to trap this, we can ignore the error code
       
   906             }
       
   907         }
       
   908     else
       
   909         { // Let's save the fetch operations last as there can be many..
       
   910         for ( TInt cc=iFetchOperations.Count()-1; cc>=0; cc-- )
       
   911             {
       
   912             if ( iFetchOperations[cc]->Operation( ).Id( ) == op->Id( ) )
       
   913                 {
       
   914                 LOGTEXT(_L8("MMBoxDialog: OpCompleted FetchOperation"));
       
   915                 delete iFetchOperations[cc];
       
   916                 iFetchOperations.Delete(cc);
       
   917                 }
       
   918             }
       
   919         }
       
   920     LOGTEXT(_L8("MMBoxDialog: OpCompleted End"));
       
   921     ListBox()->DrawDeferred();
       
   922     }
       
   923 
       
   924 // ----------------------------------------------------
       
   925 // CMMBoxDialog::DoOperationCompletedL
       
   926 // ----------------------------------------------------
       
   927 TBool CMMBoxDialog::DoOperationCompletedL(
       
   928     CMsvOperation* aOperation, 
       
   929     TInt aCompletionCode )
       
   930     {
       
   931 
       
   932     if ( !aOperation )
       
   933         {
       
   934         return EFalse;
       
   935         }
       
   936 
       
   937     if( iOpenOperation && iOpenOperation->Operation( ).Id( ) == aOperation->Id( ) )
       
   938         {
       
   939         iFlags &= ~EDoNotDeleteOpen;
       
   940         LOGTEXT(_L8("MMBoxDialog: DoOpCompleted Open"));
       
   941         if ( aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitNext ||
       
   942             aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitPrevious )
       
   943             {
       
   944             LOGTEXT(_L8("MMBoxDialog: DoOpCompleted Next/Prev Message"));
       
   945             HandleOpenNextPreviousL( aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitNext );
       
   946             iFlags |= EDoNotDeleteOpen;
       
   947             }
       
   948         else if ( aCompletionCode == EEikCmdExit )
       
   949             {
       
   950             LOGTEXT(_L8("MMBoxDialog: DoOpCompleted Exit"));
       
   951             delete iOpenOperation;
       
   952             iOpenOperation = NULL;
       
   953             iExitCode = EEikCmdExit;
       
   954             return ETrue;
       
   955             }
       
   956         }
       
   957     else if( iUpdateOperation && iUpdateOperation->Operation( ).Id( ) == aOperation->Id( ) )
       
   958         {
       
   959         LOGTEXT(_L8("MMBoxDialog: DoOpCompleted Update"));
       
   960         UpdateMMBoxArrayL();
       
   961         }
       
   962     else if ( iDeleteOperation && iDeleteOperation->Operation( ).Id( ) == aOperation->Id( ) )
       
   963         {
       
   964         LOGTEXT(_L8("MMBoxDialog: DoOpCompleted Delete"));
       
   965         UpdateMMBoxArrayL();
       
   966         }
       
   967     else
       
   968         {
       
   969         // Nothing special to be done (for example for fetch operations)
       
   970         }
       
   971     return EFalse;
       
   972     }
       
   973 
       
   974 // ----------------------------------------------------
       
   975 // CMMBoxDialog::LaunchHelpL
       
   976 // launch help using context
       
   977 // 
       
   978 // ----------------------------------------------------
       
   979 void CMMBoxDialog::LaunchHelpL()
       
   980     {   
       
   981     if ( iFlags & EHelpSupported )
       
   982         {
       
   983         LOGTEXT(_L8("MMBoxDialog: LaunchHelpL"));
       
   984         CCoeAppUi* appUi = ControlEnv()->AppUi();
       
   985         if ( appUi )
       
   986             {
       
   987             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), appUi->AppHelpContextL() );
       
   988             }
       
   989         LOGTEXT(_L8("MMBoxDialog: LaunchHelpL End"));
       
   990         }
       
   991     }
       
   992 
       
   993 // ----------------------------------------------------
       
   994 // CMMBoxDialog::GetHelpContext
       
   995 // returns helpcontext as aContext
       
   996 // 
       
   997 // ----------------------------------------------------
       
   998 void CMMBoxDialog::GetHelpContext
       
   999         ( TCoeHelpContext& aContext ) const
       
  1000     {  
       
  1001     const TUid KUidMce ={0x100058C5};      
       
  1002     aContext.iMajor = KUidMce;
       
  1003     aContext.iContext = KMCE_HLP_MMS_NOTIFICATIONS;
       
  1004     }
       
  1005 
       
  1006 // ----------------------------------------------------
       
  1007 // CMMBoxDialog::
       
  1008 // ----------------------------------------------------
       
  1009 TInt  CMMBoxDialog::DecodeProgress (
       
  1010             const TDesC8& /*aProgress*/,
       
  1011             TBuf<CBaseMtmUi::EProgressStringMaxLen>& /*aReturnString*/,
       
  1012             TInt& /*aTotalEntryCount*/,
       
  1013             TInt& /*aEntriesDone*/,
       
  1014             TInt& /*aCurrentEntrySize*/,
       
  1015             TInt& /*aCurrentBytesTrans*/, TBool /*aInternal*/ )
       
  1016     {
       
  1017     // At the moment there are no operations who would need this function.
       
  1018     // Only delete operation uses ProgressDecoder, but that progress is
       
  1019     // asked from NotMtmUi object.
       
  1020     return KErrNone;
       
  1021     }
       
  1022 
       
  1023 // ----------------------------------------------------
       
  1024 // CMMBoxDialog::
       
  1025 // ----------------------------------------------------
       
  1026 void CMMBoxDialog::SortMessagesByL( TMMBoxSortType aType )
       
  1027     {
       
  1028     // Lets memorize the id of the current focused one
       
  1029    LOGTEXT(_L8("MMBoxDialog: SortMessageByL start"));
       
  1030     TMsvId focused = KErrNotFound;
       
  1031     
       
  1032     if( iMessages->MdcaCount() > 0 )
       
  1033         {
       
  1034         focused= iMessages->EntryId( ListBox( )->CurrentItemIndex( ) );
       
  1035         }
       
  1036     
       
  1037     // Lets set the sorting type
       
  1038     TMsvSelectionOrdering newType = iMessages->SetSortType( aType );
       
  1039 
       
  1040     // Lets find the focused one again
       
  1041     TInt index = 0;
       
  1042     TInt newFocused = KErrNotFound;
       
  1043     while( index < iMessages->MdcaCount( ) )
       
  1044         {
       
  1045         if( iMessages->EntryId( index ) == focused )
       
  1046             {
       
  1047             newFocused = index;
       
  1048             break;
       
  1049             }
       
  1050         index++;
       
  1051         }
       
  1052     
       
  1053     //Let's set the new focused item and draw the listbox
       
  1054     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 2"));
       
  1055     if( newFocused != KErrNotFound )
       
  1056         {
       
  1057         LOGTEXT(_L8("MMBoxDialog: SortMessageByL 3"));
       
  1058         ListBox( )->SetCurrentItemIndexAndDraw( newFocused );
       
  1059         }
       
  1060 
       
  1061     iFlags |= ESortTypeChanged;
       
  1062 
       
  1063     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 4"));
       
  1064     CMsvEntry* entry=iSession.GetEntryL( KMsvRootIndexEntryId );
       
  1065     CleanupStack::PushL( entry );
       
  1066     CMsvStore* store = entry->EditStoreL();
       
  1067     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 5"));
       
  1068     CleanupStack::PushL( store );
       
  1069     store->Remove(KUidMsvMessageListSortOrder);
       
  1070     store->CommitL();
       
  1071     CleanupStack::PopAndDestroy( 1 ); // store
       
  1072 
       
  1073     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 6"));
       
  1074  	CMsvStore* store2 = entry->EditStoreL();
       
  1075  	CleanupStack::PushL( store2 );
       
  1076     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 7"));
       
  1077  	RMsvWriteStream writeStream;
       
  1078  	writeStream.AssignLC( *store2, KUidMsvMessageListSortOrder );
       
  1079     LOGTEXT(_L8("MMBoxDialog: SortMessageByL 8"));
       
  1080  	newType.ExternalizeL( writeStream );
       
  1081  	writeStream.CommitL();
       
  1082  	store2->CommitL();
       
  1083  	CleanupStack::PopAndDestroy( 3 ); // store, writestream, entry
       
  1084 
       
  1085     LOGTEXT(_L8("MMBoxDialog: SortMessagesByL End"));
       
  1086     }
       
  1087 
       
  1088 // ----------------------------------------------------
       
  1089 // CMMBoxDialog::
       
  1090 // ----------------------------------------------------
       
  1091 void CMMBoxDialog::OpenNotificationL( )
       
  1092     {
       
  1093     LOGTEXT(_L8("MMBoxDialog: OpenNotificationL start"));
       
  1094 
       
  1095     CMsvOperation* op=NULL;
       
  1096     CAknInputBlock::NewLC(  );
       
  1097 
       
  1098     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL( *this );
       
  1099     CleanupStack::PushL(singleOpWatcher);
       
  1100 
       
  1101     TMsvEntry entry = 
       
  1102         iMessages->Entry( ListBox( )->CurrentItemIndex( ) );
       
  1103 
       
  1104     if ( entry.iType != KUidMsvMessageEntry )
       
  1105         { // No message -> wrong kind of entry
       
  1106         CleanupStack::PopAndDestroy( 2 ); // singleOpWatcher, CAknInputBlock
       
  1107         return;
       
  1108         }
       
  1109     else
       
  1110         {
       
  1111         iOpenOperation = singleOpWatcher;
       
  1112         }
       
  1113 
       
  1114     iUi.BaseMtm().SwitchCurrentEntryL( entry.Id( ) );
       
  1115     iUi.SetPreferences( iUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
       
  1116 
       
  1117     LOGTEXT(_L8("MMBoxDialog: OpenNotificationL 2"));
       
  1118     op = iUi.OpenL(singleOpWatcher->iStatus );
       
  1119     LOGTEXT(_L8("MMBoxDialog: OpenNotificationL 3"));
       
  1120 
       
  1121     CleanupStack::Pop( singleOpWatcher );
       
  1122 
       
  1123     singleOpWatcher->SetOperation(op);
       
  1124 
       
  1125     CleanupStack::PopAndDestroy( ); // CAknInputBlock::NewLC(  );
       
  1126     LOGTEXT(_L8("MMBoxDialog: OpenL End"));
       
  1127     }
       
  1128 
       
  1129 // ----------------------------------------------------
       
  1130 // CMMBoxDialog::
       
  1131 // ----------------------------------------------------
       
  1132 void CMMBoxDialog::FetchL( TBool aAll/*=EFalse*/ )
       
  1133     {
       
  1134     if ( IS_PHONE_OFF_LINEL() )
       
  1135         {   // We are in offline at the moment -> Infonote
       
  1136         ShowInformationNoteL( R_NOTMTM_OFFLINE_NOT_POSSIBLE, EFalse );
       
  1137         return;
       
  1138         }
       
  1139 
       
  1140     CMsvEntrySelection* sel = SelectionL( aAll );
       
  1141     CleanupStack::PushL( sel );
       
  1142 
       
  1143     // Lets see which ones are already deleted from server.
       
  1144     TInt all = 0; // includes all notifications in the selection
       
  1145     TInt bad = 0; // includes notifications that are not stored in mmbox
       
  1146     for( TInt i = 0; i<sel->Count( ); i++ )
       
  1147         {
       
  1148         TMsvEntry entry;
       
  1149         TMsvId service=-1;
       
  1150         iSession.GetEntry( sel->At( i ), service, entry );
       
  1151         if( ( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) &&
       
  1152               ( entry.iMtmData2 & KMmsStoredInMMBox ) )
       
  1153             {
       
  1154             all++;
       
  1155             }
       
  1156         else
       
  1157             {
       
  1158             if( ( entry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd )
       
  1159                 {
       
  1160                 bad++;
       
  1161                 all++;
       
  1162                 }
       
  1163             }
       
  1164         }
       
  1165 
       
  1166     if( bad == 1 )
       
  1167         {
       
  1168         // One already deleted
       
  1169         ShowInformationNoteL( R_NOT_MMBOX_INFO_FETCH_FAILED_ONE, EFalse );
       
  1170         if( all == bad )
       
  1171             { // Just one notification -> leave from the function
       
  1172             CleanupStack::PopAndDestroy( sel );
       
  1173             return;
       
  1174             }
       
  1175         }
       
  1176     else if (bad > 0)
       
  1177         {
       
  1178         if( all == bad )
       
  1179             { // All notifications were bad
       
  1180             ShowInformationNoteL( R_NOT_MMBOX_INFO_FETCH_FAILED_ANY, EFalse );
       
  1181             LOGTEXT(_L8("MMBoxDialog: FetchL All bad - just return"));
       
  1182             CleanupStack::PopAndDestroy( sel );
       
  1183             return;
       
  1184             }
       
  1185         else
       
  1186             { // Some were bad, so one can continue fetching
       
  1187             ShowInformationNoteL( R_NOT_MMBOX_INFO_FETCH_FAILED_SOME, EFalse );
       
  1188             LOGTEXT(_L8("MMBoxDialog: FetchL Some bad - warn"));
       
  1189             }
       
  1190         }
       
  1191     else // bad == 0
       
  1192         {
       
  1193         if( all == 0 )
       
  1194             { // No notifications at all -> no note and just leave
       
  1195             LOGTEXT(_L8("MMBoxDialog: FetchL Selection empty - just return"));
       
  1196             CleanupStack::PopAndDestroy( sel );
       
  1197             return;
       
  1198             }
       
  1199         // else just continue as there were no bad notifications
       
  1200         }
       
  1201 
       
  1202     TMsvId origId = iClientMtm->Entry().Entry().Id();
       
  1203 
       
  1204     if( sel->Count( ) == 1 )
       
  1205         {
       
  1206         iClientMtm->SwitchCurrentEntryL( sel->At( 0 ) );
       
  1207         iClientMtm->LoadMessageL( );
       
  1208         TTime currentTime;
       
  1209         currentTime.HomeTime( );
       
  1210         TTime expiryTime = iClientMtm->ExpiryDate( );
       
  1211         iClientMtm->SwitchCurrentEntryL( origId );
       
  1212         iClientMtm->LoadMessageL( );
       
  1213 	    TLocale locale;
       
  1214         expiryTime += locale.UniversalTimeOffset();
       
  1215 	    if (locale.QueryHomeHasDaylightSavingOn())          
       
  1216 		    {
       
  1217 		    TTimeIntervalHours daylightSaving(1);          
       
  1218 		    expiryTime += daylightSaving;
       
  1219 		    }
       
  1220 
       
  1221         if( currentTime > expiryTime )
       
  1222             {   // Message is expired
       
  1223             TBool res = EFalse;
       
  1224             TRAPD( err, res=ShowConfirmationQueryL( R_NOT_MMBOX_QUEST_MSG_EXPIRED ) );
       
  1225             if ( err || !res )
       
  1226                 {   // User did not want to fetch expired message or the function leaved
       
  1227             CleanupStack::PopAndDestroy( sel );
       
  1228                 return;
       
  1229                 } // else we continue
       
  1230             }
       
  1231         }
       
  1232 
       
  1233     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL(*this);
       
  1234     CleanupStack::PushL(singleOpWatcher);
       
  1235 
       
  1236     TBuf8<1> buf;
       
  1237 
       
  1238     CMsvOperation* op = NULL;
       
  1239 
       
  1240     LOGTEXT(_L8("MMBoxDialog: FetchL 2"));
       
  1241     TRAPD( err, 
       
  1242             op= iUi.InvokeAsyncFunctionL( 
       
  1243             KMtmUiFunctionFetchMMS, 
       
  1244             *sel, 
       
  1245             singleOpWatcher->iStatus, 
       
  1246             buf) );
       
  1247     LOGTEXT(_L8("MMBoxDialog: FetchL 3"));
       
  1248 
       
  1249     if( op == NULL || err )
       
  1250         {
       
  1251         LOGTEXT(_L8("MMBoxDialog: FetchL NULL op or left"));
       
  1252         CleanupStack::PopAndDestroy( singleOpWatcher );
       
  1253         CleanupStack::PopAndDestroy( sel );
       
  1254         return;
       
  1255         }
       
  1256 
       
  1257     CleanupStack::Pop( singleOpWatcher );
       
  1258    
       
  1259     singleOpWatcher->SetOperation( op );
       
  1260     iFetchOperations.AppendL( singleOpWatcher );
       
  1261 
       
  1262     CleanupStack::PopAndDestroy( sel );
       
  1263 
       
  1264     LOGTEXT(_L8("MMBoxDialog: FetchL End"));
       
  1265     return;
       
  1266     }
       
  1267 
       
  1268 // ----------------------------------------------------
       
  1269 // CMMBoxDialog::DeleteL
       
  1270 // ----------------------------------------------------
       
  1271 void CMMBoxDialog::DeleteL( TBool aAll/*=EFalse*/ )
       
  1272     {
       
  1273     LOGTEXT(_L8("MMBoxDialog: DeleteL start"));
       
  1274 
       
  1275     if ( IS_PHONE_OFF_LINEL() )
       
  1276         {   // We are in offline at the moment -> Infonote
       
  1277         ShowInformationNoteL( R_NOTMTM_OFFLINE_NOT_POSSIBLE, EFalse );
       
  1278         return;
       
  1279         }
       
  1280 
       
  1281     CAknInputBlock::NewLC( );
       
  1282 
       
  1283     if( iDeleteSelection )
       
  1284         {
       
  1285         // We should never end up in here because delete op has a wait note but just in case
       
  1286         delete iDeleteSelection;
       
  1287         iDeleteSelection = NULL;
       
  1288         }
       
  1289 
       
  1290     iDeleteSelection = SelectionL( aAll );
       
  1291     LOGTEXT(_L8("MMBoxDialog: DeleteL 2"));
       
  1292 
       
  1293     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL(*this);
       
  1294     CleanupStack::PushL(singleOpWatcher);
       
  1295 
       
  1296     TBuf8<1> buf;
       
  1297 
       
  1298     LOGTEXT(_L8("MMBoxDialog: DeleteL 3"));
       
  1299     CMsvOperation* op= iUi.InvokeAsyncFunctionL( 
       
  1300         KMtmUiFunctionDeleteMessage, 
       
  1301         *iDeleteSelection, 
       
  1302         singleOpWatcher->iStatus, 
       
  1303         buf);
       
  1304 
       
  1305     LOGTEXT(_L8("MMBoxDialog: DeleteL 4"));
       
  1306     if( op == NULL )
       
  1307         {
       
  1308         // Lets just make a completed operation so
       
  1309         // the progress dialog is not shown
       
  1310         LOGTEXT(_L8("MMBoxDialog: Delete NULL op"));
       
  1311         delete iDeleteSelection;
       
  1312         iDeleteSelection = NULL;
       
  1313         TPckgC < TMsvId > progress = 0;
       
  1314         op = CMsvCompletedOperation::NewL( iSession, 
       
  1315             KUidMsgMMSNotification,
       
  1316             progress,
       
  1317             KMsvLocalServiceIndexEntryId, singleOpWatcher->iStatus );
       
  1318         }
       
  1319     LOGTEXT(_L8("MMBoxDialog: DeleteL 5"));
       
  1320 
       
  1321     CleanupStack::Pop( singleOpWatcher );
       
  1322     
       
  1323     singleOpWatcher->SetOperation( op );
       
  1324     iDeleteOperation = singleOpWatcher;
       
  1325 
       
  1326     CleanupStack::PopAndDestroy( ); // CAknInputBlock
       
  1327 
       
  1328     LOGTEXT(_L8("MMBoxDialog: DeleteL End"));
       
  1329     return;
       
  1330     }
       
  1331 
       
  1332 // ----------------------------------------------------
       
  1333 // CMMBoxDialog::SelectionL
       
  1334 // ----------------------------------------------------
       
  1335 CMsvEntrySelection* CMMBoxDialog::SelectionL( TBool aAll/*=EFalse*/ )
       
  1336     {
       
  1337     LOGTEXT(_L8("MMBoxDialog: Selection Start"));
       
  1338     CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection;
       
  1339     CleanupStack::PushL( sel );
       
  1340 
       
  1341     if( aAll )
       
  1342         {
       
  1343 	    LOGTEXT(_L8("MMBoxDialog: Selection: Use all"));
       
  1344         TInt index = 0;
       
  1345         while( index < iMessages->MdcaCount( ) )
       
  1346             {
       
  1347 	        LOGTEXT(_L8("MMBoxDialog: Selection: Use all: append"));
       
  1348             sel->AppendL( iMessages->EntryId( index ) );
       
  1349             index++;
       
  1350             }
       
  1351         }
       
  1352     else
       
  1353         {
       
  1354         const CListBoxView::CSelectionIndexArray* indexes = 
       
  1355             ListBox( )->SelectionIndexes( );
       
  1356         TInt index = 0;
       
  1357         
       
  1358         if( indexes->Count( ) < 1 )
       
  1359             { // Lets use the current one as there are no selected ones
       
  1360 	        LOGTEXT(_L8("MMBoxDialog: Selection: No selected so just use current"));
       
  1361             sel->AppendL( iMessages->EntryId( ListBox( )->CurrentItemIndex( ) ) );
       
  1362             }
       
  1363         else 
       
  1364 	        {
       
  1365             LOGTEXT(_L8("MMBoxDialog: Selection: Selected items"));
       
  1366 	        while( index < indexes->Count( ) )
       
  1367             	{
       
  1368 	            LOGTEXT(_L8("MMBoxDialog: Selection: Selected items added one"));
       
  1369             	TInt lbIndex = indexes->At(index);
       
  1370             	sel->AppendL( iMessages->EntryId( lbIndex ) );
       
  1371             	index++;
       
  1372             	}
       
  1373 	        }
       
  1374         }
       
  1375 
       
  1376     LOGTEXT(_L8("MMBoxDialog: Selection Done"));
       
  1377     CleanupStack::Pop( sel );
       
  1378     LOGTEXT(_L8("MMBoxDialog: Selection End"));
       
  1379     return sel;
       
  1380     }
       
  1381 
       
  1382 // ----------------------------------------------------
       
  1383 // CMMBoxDialog::
       
  1384 // ----------------------------------------------------
       
  1385 void CMMBoxDialog::ShowStatusL( )
       
  1386     {
       
  1387     LOGTEXT(_L8("MMBoxDialog: ShowStatus Start"));
       
  1388 	HBufC* status;	// holds the text
       
  1389 	HBufC* buf;		// a buffer for strings
       
  1390 
       
  1391     TMmboxInfo info;
       
  1392     TInt ret = 0;
       
  1393     TRAPD( err, ret=iClientMtm->MmboxInfoL( info ) )
       
  1394 
       
  1395 #ifdef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
  1396     ret = 1;
       
  1397     info.date.HomeTime();
       
  1398 #endif
       
  1399 
       
  1400     if( err || !ret )
       
  1401         {
       
  1402         return; // No quota data available -> just return;
       
  1403         }
       
  1404     TTime messageDate = info.date;
       
  1405     
       
  1406     // messageDate is GMT so add time offset
       
  1407     TLocale locale;
       
  1408     messageDate += locale.UniversalTimeOffset();
       
  1409     if (locale.QueryHomeHasDaylightSavingOn())          
       
  1410 	    {
       
  1411 	    TTimeIntervalHours daylightSaving(1);          
       
  1412 	    messageDate += daylightSaving;
       
  1413 	    }
       
  1414     
       
  1415     TInt usedQuota = info.mmboxTotalInBytes/KLocalKilo;
       
  1416     if (  info.mmboxTotalInBytes % KLocalKilo )
       
  1417             {
       
  1418             usedQuota++;
       
  1419             }
       
  1420     TInt fullQuota = info.mmboxQuotaInBytes/KLocalKilo;
       
  1421     if (  info.mmboxQuotaInBytes % KLocalKilo )
       
  1422             {
       
  1423             fullQuota++;
       
  1424             }
       
  1425 
       
  1426 	CEikFormattedCellListBox* listBox = new ( ELeave ) CAknDoublePopupMenuStyleListBox;
       
  1427 	CleanupStack::PushL( listBox );
       
  1428 
       
  1429 	CAknPopupList* popupList;
       
  1430     popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY__OK, 
       
  1431 									AknPopupLayouts::EMenuDoubleWindow);
       
  1432 	CleanupStack::PushL( popupList );
       
  1433 
       
  1434     LOGTEXT(_L8("MMBoxDialog: ShowStatus 2"));
       
  1435     TInt flags = CEikListBox::EDisableHighlight;
       
  1436 	listBox->ConstructL( popupList, flags );
       
  1437 	listBox->CreateScrollBarFrameL( ETrue );
       
  1438 	listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
       
  1439 															CEikScrollBarFrame::EAuto );
       
  1440     // Lets add the heading
       
  1441 
       
  1442 	status = StringLoader::LoadLC( R_NOT_MMBOX_STATUS_TITLE );
       
  1443 	popupList->SetTitleL( *status );
       
  1444 	CleanupStack::PopAndDestroy( status );	// status
       
  1445 	status = NULL;
       
  1446 
       
  1447 	MDesCArray* itemList = listBox->Model()->ItemTextArray();
       
  1448 	CDesCArray* itemArray = ( CDesCArray* ) itemList;
       
  1449 
       
  1450     // Lets add the first label "Updated"
       
  1451 
       
  1452     LOGTEXT(_L8("MMBoxDialog: ShowStatus 3"));
       
  1453 	status = HBufC::NewLC( KMMBoxMaxStatusInfoLength );
       
  1454 	buf = StringLoader::LoadLC( R_NOT_MMBOX_UPDATE_LABEL );	// first line - bold text
       
  1455 	status->Des().Append( *buf );
       
  1456 	status->Des().Append( TChar( '\t' ) );
       
  1457 
       
  1458     // Lets add the update time
       
  1459 
       
  1460     LOGTEXT(_L8("MMBoxDialog: ShowStatus 4"));
       
  1461     HBufC* dateFormat = StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv );
       
  1462     TBuf<KDateSize> dateString;
       
  1463     messageDate.FormatL( dateString, *dateFormat );
       
  1464     CleanupStack::PopAndDestroy(); //dateFormat
       
  1465 
       
  1466     dateFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv );
       
  1467     TBuf<KDateSize> timeString;
       
  1468     messageDate.FormatL( timeString, *dateFormat );
       
  1469     CleanupStack::PopAndDestroy(); //dateFormat
       
  1470 
       
  1471     LOGTEXT(_L8("MMBoxDialog: ShowStatus 5"));
       
  1472     CDesC16ArrayFlat* array = new(ELeave) CDesC16ArrayFlat( 2 );
       
  1473     CleanupStack::PushL( array );
       
  1474     array->AppendL( timeString );
       
  1475     array->AppendL( dateString );
       
  1476     buf = 
       
  1477         StringLoader::LoadL( R_NOT_MMBOX_INFO_TIME, *array, iCoeEnv );
       
  1478     status->Des().Append( *buf );
       
  1479     CleanupStack::PopAndDestroy( array );
       
  1480     CleanupStack::PushL( buf );
       
  1481 
       
  1482     itemArray->AppendL( *status );
       
  1483 	CleanupStack::PopAndDestroy(3);	// buf, buf, status
       
  1484 	buf = NULL;
       
  1485 	status = NULL;
       
  1486 
       
  1487     // Lets add the 2nd label "Storage in use"
       
  1488 
       
  1489     LOGTEXT(_L8("MMBoxDialog: ShowStatus 6"));
       
  1490 	status = HBufC::NewLC( KMMBoxMaxStatusInfoLength );
       
  1491 	buf = StringLoader::LoadLC( R_NOT_MMBOX_STORAGE_LABEL );	// first line - bold text
       
  1492 	status->Des().Append( *buf );
       
  1493 	status->Des().Append( TChar( '\t' ) );
       
  1494 
       
  1495     // Lets add the "X %" stuff
       
  1496 
       
  1497 	TInt percentage = 100;
       
  1498 
       
  1499 	if( fullQuota > 0 )
       
  1500 		{
       
  1501 		percentage = TInt((((TReal)usedQuota/(TReal)fullQuota)+TReal(0.005))*100);
       
  1502 		}
       
  1503 
       
  1504 	buf = StringLoader::LoadLC( R_NOT_MMBOX_STORAGE_DATA, percentage, iCoeEnv );
       
  1505 
       
  1506     status->Des().Append( *buf );
       
  1507     itemArray->AppendL( *status );
       
  1508 
       
  1509     CleanupStack::PopAndDestroy( 3 );	// buf, buf, status
       
  1510 	buf = NULL;
       
  1511 	status = NULL;
       
  1512 
       
  1513     // Lets add the 3rd label "Quota used"
       
  1514 
       
  1515 	status = HBufC::NewLC( KMMBoxMaxStatusInfoLength );
       
  1516 	buf = StringLoader::LoadLC( R_NOT_MMBOX_QUOTA_LABEL );	// first line - bold text
       
  1517 	status->Des().Append( *buf );
       
  1518 	status->Des().Append( TChar( '\t' ) );
       
  1519 
       
  1520     // Lets add the " 5 / 5" stuff
       
  1521 
       
  1522     LOGTEXT(_L8("MMBoxDialog: ShowStatus 7"));
       
  1523     CArrayFixFlat<TInt>* array3 = new(ELeave) CArrayFixFlat<TInt>( 2 );
       
  1524     CleanupStack::PushL( array3 );
       
  1525     array3->AppendL( usedQuota );
       
  1526     array3->AppendL( fullQuota );
       
  1527     buf = 
       
  1528         StringLoader::LoadL( R_NOT_MMBOX_QUOTA_DATA, *array3, iCoeEnv );
       
  1529     CleanupStack::PopAndDestroy( array3 ); //array3
       
  1530     CleanupStack::PushL( buf );
       
  1531 
       
  1532     status->Des().Append( *buf );
       
  1533     itemArray->AppendL( *status );
       
  1534 
       
  1535     CleanupStack::PopAndDestroy( 3 );	// buf, buf, status
       
  1536 	buf = NULL;
       
  1537 	status = NULL;
       
  1538 
       
  1539 	CleanupStack::Pop( popupList );	// popupList 
       
  1540 
       
  1541 	// Show Dialog
       
  1542     LOGTEXT(_L8("MMBoxDialog: ShowStatus 8"));
       
  1543 	popupList->ExecuteLD( );
       
  1544 	// cleanup
       
  1545 	CleanupStack::PopAndDestroy( listBox );	//listBox
       
  1546 	listBox = NULL;
       
  1547     LOGTEXT(_L8("MMBoxDialog: ShowStatus End"));
       
  1548     }
       
  1549 
       
  1550 // ----------------------------------------------------
       
  1551 // CMMBoxDialog::UpdateListL
       
  1552 // ----------------------------------------------------
       
  1553 void CMMBoxDialog::UpdateListL( )
       
  1554     {
       
  1555     LOGTEXT(_L8("MMBoxDialog: UpdateListL start"));
       
  1556     if ( IS_PHONE_OFF_LINEL() )
       
  1557         {   // We are in offline at the moment -> Infonote
       
  1558         ShowInformationNoteL( R_NOTMTM_OFFLINE_NOT_POSSIBLE, EFalse );
       
  1559         return;
       
  1560         }
       
  1561     LOGTEXT(_L8("MMBoxDialog: UpdateListL 2"));
       
  1562 
       
  1563     if( !iUi.CheckSettingsL( ) )
       
  1564         { // AP is not valid so just return ->
       
  1565         return;
       
  1566         }
       
  1567     LOGTEXT(_L8("MMBoxDialog: UpdateListL 3"));
       
  1568 
       
  1569     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL(*this);
       
  1570     CleanupStack::PushL(singleOpWatcher);
       
  1571 
       
  1572     CMsvOperation* updateOp = iClientMtm->UpdateMmBoxListL(
       
  1573                         singleOpWatcher->iStatus );
       
  1574 
       
  1575     if( updateOp == NULL )
       
  1576         {
       
  1577         // Unable to update the list -> show error
       
  1578         LOGTEXT(_L8("MMBoxDialog: UpdateList NULL op"));
       
  1579         CleanupStack::PopAndDestroy( singleOpWatcher );
       
  1580         ShowInformationNoteL( R_NOT_MMBOX_INFO_UNABLE_UPDATE, EFalse );
       
  1581         return;
       
  1582         }
       
  1583 
       
  1584     CleanupStack::Pop( singleOpWatcher );    
       
  1585     iUpdateOperation = singleOpWatcher;
       
  1586     iUpdateOperation->SetOperation( updateOp );
       
  1587 
       
  1588     ShowWaitNoteL( R_NOT_MMBOX_WAIT_UPDATING_NOTIF, ETrue );
       
  1589 
       
  1590     LOGTEXT(_L8("MMBoxDialog: UpdateList End"));
       
  1591     return;
       
  1592     }
       
  1593 
       
  1594 // ---------------------------------------------------------
       
  1595 // CMMBoxDialog::ShowInformationNoteL
       
  1596 // ---------------------------------------------------------
       
  1597 //
       
  1598 void CMMBoxDialog::ShowInformationNoteL( TInt aResourceID, TBool aWaiting )
       
  1599     {
       
  1600     HBufC* string = NULL;
       
  1601     string = StringLoader::LoadLC( aResourceID, iCoeEnv );
       
  1602 
       
  1603     CAknInformationNote* note = new ( ELeave )
       
  1604         CAknInformationNote( aWaiting );
       
  1605     note->ExecuteLD( *string );
       
  1606 
       
  1607     CleanupStack::PopAndDestroy(); //string
       
  1608     }
       
  1609 
       
  1610 // ---------------------------------------------------------
       
  1611 // CMMBoxDialog::ShowConfirmationQueryL
       
  1612 // ---------------------------------------------------------
       
  1613 //
       
  1614 TInt CMMBoxDialog::ShowConfirmationQueryL( TInt aResourceId, TBool aOnlyOK/*=EFalse*/ ) const
       
  1615     {
       
  1616     HBufC* prompt = StringLoader::LoadLC( aResourceId, iCoeEnv );
       
  1617     TInt retVal = ShowConfirmationQueryL( *prompt, aOnlyOK );
       
  1618     CleanupStack::PopAndDestroy( prompt );
       
  1619     return retVal;
       
  1620     }
       
  1621 
       
  1622 // ---------------------------------------------------------
       
  1623 // CMMBoxDialog::ShowConfirmationQueryL
       
  1624 // ---------------------------------------------------------
       
  1625 //
       
  1626 TInt CMMBoxDialog::ShowConfirmationQueryL( const TDesC& aText, TBool aOnlyOK/*=EFalse*/ ) const
       
  1627     {
       
  1628     TInt dialogType=aOnlyOK?R_NOTUI_CONFIRMABLE_QUERY:R_NOTUI_CONFIRMATION_QUERY;
       
  1629     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
  1630     TInt retVal = dlg->ExecuteLD( dialogType, aText );
       
  1631     return retVal;    
       
  1632     }
       
  1633 
       
  1634 // ---------------------------------------------------------
       
  1635 // CMMBoxDialog::HandleSessionEventL
       
  1636 // ---------------------------------------------------------
       
  1637 //
       
  1638 void CMMBoxDialog::HandleSessionEventL(TMsvSessionEvent aEvent, 
       
  1639         TAny* /*aArg1*/, TAny* aArg2, TAny* /*aArg3*/)
       
  1640     {
       
  1641     LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Start"));
       
  1642     switch( aEvent )
       
  1643         {
       
  1644         case EMsvEntriesCreated:
       
  1645         case EMsvEntriesDeleted:
       
  1646         case EMsvEntriesChanged:
       
  1647 			{
       
  1648 			TMsvId parentId = KMsvNullIndexEntryId;
       
  1649 			if ( aArg2 != NULL )
       
  1650 				{	
       
  1651 				parentId = *(TMsvId*)aArg2;
       
  1652 				}
       
  1653 			if( parentId == iMMBoxFolderId )
       
  1654 				{ // in MMBoxFolder
       
  1655 				ListBox( )->ClearSelection( );
       
  1656                 if( !iOpenOperation && !iUpdateOperation && !iDeleteOperation )
       
  1657                     { // Lets close the menubar because something has been changed..
       
  1658 				    LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Close menubar"));
       
  1659                     iMenuBar->StopDisplayingMenuBar( );
       
  1660 				    LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Close menubar END"));
       
  1661                     }
       
  1662 				if ( aEvent == EMsvEntriesCreated )
       
  1663 					{
       
  1664 				    LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Addition"));
       
  1665 				    ListBox()->HandleItemAdditionL();
       
  1666 					ListBox()->ScrollToMakeItemVisible( ListBox()->CurrentItemIndex( ) );
       
  1667 					ListBox()->DrawNow();
       
  1668 				    LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Addition End"));
       
  1669 					}
       
  1670 				else if ( aEvent == EMsvEntriesDeleted )
       
  1671 					{
       
  1672 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal"));
       
  1673 					// Store the current selected item
       
  1674                     TInt index = ListBox()->CurrentItemIndex();
       
  1675                     // Refresh is needed to get the entry updated after the sessionevent
       
  1676                     iMessages->RefreshArrayL( iMMBoxFolderId );
       
  1677                     // Let's tell the listbox an item was removed
       
  1678 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal 2"));
       
  1679 					ListBox()->HandleItemRemovalL();
       
  1680                     // If current entry is out of boundaries, move the position
       
  1681                     TInt count = iMessages->MdcaCount( );
       
  1682                     if( index >= count || index < 0 )
       
  1683                         {
       
  1684     					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal Change the index"));
       
  1685                         index = count - 1;
       
  1686                         }
       
  1687                     if( count > 0 )
       
  1688                         { // Lets make sure when don't highlight in an empty listbox
       
  1689     					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal Entries left"));
       
  1690 					    ListBox()->SetCurrentItemIndex( index );
       
  1691     					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal Entries Update SB"));
       
  1692                         ListBox()->UpdateScrollBarsL( );
       
  1693                         }
       
  1694                     else 
       
  1695                         {
       
  1696                         SetMSKL();
       
  1697                         }
       
  1698 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal DrawNow"));
       
  1699                     DrawNow();
       
  1700 					ListBox()->DrawNow();
       
  1701 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Item Removal End"));
       
  1702                     }
       
  1703 				else
       
  1704 					{
       
  1705 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Entry Change"));
       
  1706                     // Refresh is needed to get the entry updated after the sessionevent
       
  1707                     iMessages->RefreshArrayL( iMMBoxFolderId );
       
  1708 					ListBox()->DrawNow();
       
  1709 					LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent Handle Entry Change END"));
       
  1710 					}
       
  1711 				}
       
  1712 			break;
       
  1713 			}
       
  1714 
       
  1715         case EMsvCloseSession:
       
  1716             {
       
  1717             iSession.RemoveObserver( *this );
       
  1718             break;
       
  1719             }
       
  1720 
       
  1721         default:
       
  1722             {
       
  1723             break;
       
  1724             }
       
  1725         }
       
  1726     LOGTEXT(_L8("MMBoxDialog: HandleSessionEvent End"));
       
  1727     }
       
  1728 
       
  1729 // ---------------------------------------------------------
       
  1730 // CMMBoxDialog::UpdateNavipaneL
       
  1731 // ---------------------------------------------------------
       
  1732 //
       
  1733 void CMMBoxDialog::UpdateNavipaneL( )
       
  1734     {
       
  1735     LOGTEXT(_L8("MMBoxDialog: UpdateNavipaneL start"));
       
  1736 	HBufC* buf;		// a buffer for strings
       
  1737 
       
  1738     TMmboxInfo info;
       
  1739     TInt ret = 0;
       
  1740     TRAPD( err, ret=iClientMtm->MmboxInfoL( info ) );
       
  1741     
       
  1742 #ifdef MMS_NOTIFICATIONS_TESTING_WO_MMBOX
       
  1743     ret = 1;
       
  1744     info.date.HomeTime();
       
  1745     User::After( 1000000 );
       
  1746 #endif
       
  1747     
       
  1748     if( !err && ret )
       
  1749         {
       
  1750         TTime updateDate = info.date;
       
  1751 
       
  1752 	    TLocale locale;
       
  1753         updateDate += locale.UniversalTimeOffset();
       
  1754 	    if (locale.QueryHomeHasDaylightSavingOn())          
       
  1755 		    {
       
  1756 		    TTimeIntervalHours daylightSaving(1);          
       
  1757 		    updateDate += daylightSaving;
       
  1758 		    }
       
  1759 
       
  1760         TTime currentDate;
       
  1761         currentDate.HomeTime( );
       
  1762 
       
  1763         TDateTime update = updateDate.DateTime( );
       
  1764         TDateTime current = currentDate.DateTime( );
       
  1765         if( update.Day( ) == current.Day( ) &&            
       
  1766             update.Month( ) == current.Month( ) &&
       
  1767             update.Year( ) == current.Year( ) )
       
  1768             {   // It's the same day
       
  1769 
       
  1770             HBufC* dateFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL, iCoeEnv );
       
  1771             TBuf<KDateSize> timeString;
       
  1772             updateDate.FormatL( timeString, *dateFormat );
       
  1773             CleanupStack::PopAndDestroy(); //dateFormat
       
  1774 
       
  1775             CDesC16ArrayFlat* array = new(ELeave) CDesC16ArrayFlat( 1 );
       
  1776             CleanupStack::PushL( array );
       
  1777             array->AppendL( timeString );
       
  1778             buf = 
       
  1779                 StringLoader::LoadL( R_NOT_MMBOX_NAVI_TIME, *array, iCoeEnv );
       
  1780             CleanupStack::PopAndDestroy( array );
       
  1781             CleanupStack::PushL( buf );
       
  1782             
       
  1783             }
       
  1784         else
       
  1785             {   // It's not the same day
       
  1786             HBufC* dateFormat = StringLoader::LoadLC( R_QTN_DATE_SHORT, iCoeEnv );
       
  1787             TBuf<KDateSize> dateString;
       
  1788             updateDate.FormatL( dateString, *dateFormat );
       
  1789             CleanupStack::PopAndDestroy(); //dateFormat
       
  1790 
       
  1791             CDesC16ArrayFlat* array = new(ELeave) CDesC16ArrayFlat( 1 );
       
  1792             CleanupStack::PushL( array );
       
  1793             array->AppendL( dateString );
       
  1794             buf = 
       
  1795                 StringLoader::LoadL( R_NOT_MMBOX_NAVI_DATE, *array, iCoeEnv );
       
  1796             CleanupStack::PopAndDestroy( array );
       
  1797             CleanupStack::PushL( buf );
       
  1798             }
       
  1799         }
       
  1800     else
       
  1801         {
       
  1802         buf = HBufC::NewL(0);
       
  1803         CleanupStack::PushL( buf );
       
  1804         }
       
  1805 
       
  1806     delete iNaviDecorator;
       
  1807     iNaviDecorator = NULL;
       
  1808 
       
  1809     iNaviDecorator = iNaviPane->CreateTabGroupL();
       
  1810     CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>
       
  1811         ( iNaviDecorator->DecoratedControl() );
       
  1812 
       
  1813     tabGroup->AddTabL( 0, *buf );
       
  1814 
       
  1815     tabGroup->SetActiveTabById( 0 );
       
  1816     tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab );
       
  1817 
       
  1818 	CleanupStack::PopAndDestroy( buf );	// buf, buf, status
       
  1819     
       
  1820     iNaviPane->PushL( *iNaviDecorator );  // Make it visible
       
  1821     LOGTEXT(_L8("MMBoxDialog: UpdateNavipaneL End"));
       
  1822     }
       
  1823 
       
  1824 // ----------------------------------------------------
       
  1825 // CMMBoxDialog::HandleOpenNextPreviousL
       
  1826 // ----------------------------------------------------
       
  1827 void CMMBoxDialog::HandleOpenNextPreviousL( TBool aOpenNext )
       
  1828     {
       
  1829     LOGTEXT(_L8("MMBoxDialog: Open Next/Prev Start"));
       
  1830     TInt newIndex = ListBox( )->CurrentItemIndex( );
       
  1831 
       
  1832     if( iOpenOperation )
       
  1833         {
       
  1834         delete iOpenOperation;
       
  1835         iOpenOperation = NULL;
       
  1836         }
       
  1837 
       
  1838     newIndex += aOpenNext?1:-1;
       
  1839 
       
  1840     if( newIndex < 0 || newIndex >= iMessages->MdcaCount( ) )
       
  1841         { // Index out of array -> lets just ignore this..
       
  1842         return;
       
  1843         }
       
  1844 
       
  1845     ListBox()->SetCurrentItemIndex( newIndex );
       
  1846     ListBox()->DrawDeferred();
       
  1847 
       
  1848     TMsvEntry entry = iMessages->Entry( newIndex );
       
  1849 
       
  1850     if( iUiData.OperationSupportedL( KMtmUiFunctionOpenMessage, entry ) )
       
  1851         {
       
  1852         return;
       
  1853         }
       
  1854 
       
  1855     OpenNotificationL( );    
       
  1856     }
       
  1857 
       
  1858 // ---------------------------------------------------------
       
  1859 // ShowWaitNoteLC
       
  1860 // ---------------------------------------------------------
       
  1861 
       
  1862 void CMMBoxDialog::ShowWaitNoteLC(
       
  1863     TInt aNoteTxtResourceId, 
       
  1864     TBool aVisibilityDelayOff )
       
  1865     {
       
  1866     ConstructWaitNoteLC( aVisibilityDelayOff );
       
  1867     HBufC* text = StringLoader::LoadLC( aNoteTxtResourceId, iCoeEnv );
       
  1868     iWaitDialog->SetTextL( *text );
       
  1869     CleanupStack::PopAndDestroy( ); // text
       
  1870     iWaitDialog->RunLD( );
       
  1871     }
       
  1872 
       
  1873 // ---------------------------------------------------------
       
  1874 // ConstructWaitNoteLC
       
  1875 // ---------------------------------------------------------
       
  1876 
       
  1877 void CMMBoxDialog::ConstructWaitNoteLC(
       
  1878     TBool aVisibilityDelayOff )
       
  1879     {
       
  1880     delete iWaitDialog;
       
  1881     iWaitDialog = NULL;
       
  1882     iWaitDialog = new (ELeave) CAknWaitDialog( 
       
  1883         reinterpret_cast<CEikDialog**>( &iWaitDialog ), 
       
  1884         aVisibilityDelayOff );
       
  1885     CleanupStack::PushL( TCleanupItem( CleanupWaitDialog, (TAny**)&iWaitDialog ) ); 
       
  1886     iWaitDialog->PrepareLC( R_NOTUI_WAIT_NOTE );
       
  1887     }
       
  1888 
       
  1889 // ----------------------------------------------------
       
  1890 // CMMBoxDialog::CleanupWaitDialog
       
  1891 // ----------------------------------------------------
       
  1892 void CMMBoxDialog::CleanupWaitDialog(TAny* aAny)
       
  1893     {
       
  1894     CAknWaitDialog** dialog = (CAknWaitDialog**) aAny;
       
  1895     if ( dialog && *dialog )
       
  1896         {
       
  1897         delete *dialog;
       
  1898         *dialog = NULL;
       
  1899         }
       
  1900     }
       
  1901 
       
  1902 // ---------------------------------------------------------
       
  1903 // ShowWaitNoteL
       
  1904 // ---------------------------------------------------------
       
  1905 
       
  1906 void CMMBoxDialog::ShowWaitNoteL(
       
  1907     TInt aNoteTxtResourceId, 
       
  1908     TBool aVisibilityDelayOff )
       
  1909     {
       
  1910     HBufC* text = StringLoader::LoadLC( aNoteTxtResourceId, iCoeEnv );
       
  1911     delete iWaitDialog;
       
  1912     iWaitDialog = NULL;
       
  1913     iWaitDialog = new (ELeave) CAknWaitDialog( 
       
  1914         reinterpret_cast<CEikDialog**>( &iWaitDialog ), 
       
  1915         aVisibilityDelayOff );
       
  1916     iWaitDialog->SetTextL( *text );
       
  1917     CleanupStack::PopAndDestroy( ); // text
       
  1918     iWaitDialog->PrepareLC( R_NOTUI_WAIT_NOTE );
       
  1919     iWaitDialog->RunLD( );
       
  1920     }
       
  1921 
       
  1922 // ---------------------------------------------------------
       
  1923 // SetMSKL
       
  1924 // ---------------------------------------------------------
       
  1925 void CMMBoxDialog::SetMSKL()
       
  1926     {
       
  1927     const TInt KMskPosition = 3;
       
  1928     CEikColumnListBox* listBox = ListBox();
       
  1929     if ( listBox->Model()->NumberOfItems() > 0 )
       
  1930         {
       
  1931         TInt resourceId;
       
  1932         if ( listBox->View()->ItemIsSelected( listBox->CurrentItemIndex() ) )
       
  1933             {
       
  1934             resourceId = R_NOT_MMBOX_MSK_BUTTON_UNMARK;
       
  1935             }
       
  1936         else
       
  1937             {
       
  1938             resourceId = R_NOT_MMBOX_MSK_BUTTON_MARK;
       
  1939             }
       
  1940             
       
  1941         CEikButtonGroupContainer &cba = ButtonGroupContainer();
       
  1942         cba.SetCommandL( KMskPosition, resourceId );
       
  1943         cba.DrawDeferred();
       
  1944         }
       
  1945     else
       
  1946         {
       
  1947         CEikButtonGroupContainer &cba = ButtonGroupContainer();
       
  1948         cba.SetCommandL( KMskPosition, R_NOT_MMBOX_MSK_BUTTON_EMPTY );
       
  1949         cba.DrawDeferred();
       
  1950         }
       
  1951     }
       
  1952 
       
  1953 // ---------------------------------------------------------
       
  1954 // ShowConfirmationQueryL
       
  1955 // ---------------------------------------------------------
       
  1956 TInt CMMBoxDialog::ShowConfirmationQueryL(  TInt    aCount,
       
  1957                                             TInt    aTotalOnes,                          
       
  1958                                             TInt    aResource )
       
  1959     {
       
  1960     CArrayFixFlat<TInt>* arr = new(ELeave) CArrayFixFlat<TInt>( 2 );
       
  1961     CleanupStack::PushL( arr );
       
  1962     arr->AppendL( aCount );
       
  1963     arr->AppendL( aTotalOnes );
       
  1964     HBufC* buf = 
       
  1965         StringLoader::LoadL( aResource, *arr, iCoeEnv );
       
  1966     CleanupStack::PopAndDestroy( arr );
       
  1967     CleanupStack::PushL( buf );
       
  1968 
       
  1969     TInt ret = ShowConfirmationQueryL( *buf, ETrue );
       
  1970 
       
  1971     CleanupStack::PopAndDestroy( buf );
       
  1972     return ret;
       
  1973     }
       
  1974 //  End of File