emailuis/emailui/inc/freestyleemailuimailboxdeleter.h
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Mailbox deleter.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef FREESTYLEEMAILUIMAILBOXDELETER_H
       
    19 #define FREESTYLEEMAILUIMAILBOXDELETER_H
       
    20 
       
    21 // SYSTEM INCLUDE FILES
       
    22 #include <e32base.h>
       
    23 #include <AknWaitDialog.h>
       
    24 
       
    25 // INTERNAL INCLUDE FILES
       
    26 #include "MFSMailRequestObserver.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CFSMailClient;
       
    30 class TFSMailMsgId;
       
    31 class CFSMailBox;
       
    32 
       
    33 class MFSEmailUiMailboxDeleteObserver
       
    34     {
       
    35 public:
       
    36     
       
    37     /**
       
    38      * Called when selected mailboxes have been deleted.
       
    39      */
       
    40     virtual void MailboxDeletionComplete() = 0;
       
    41 
       
    42 protected:
       
    43     
       
    44     MFSEmailUiMailboxDeleteObserver() {};
       
    45     
       
    46     ~MFSEmailUiMailboxDeleteObserver() {};
       
    47     };
       
    48 
       
    49 
       
    50 // Mailbox deleter
       
    51 class CFSEmailUiMailboxDeleter : public CBase, 
       
    52                                  public MProgressDialogCallback, 
       
    53                                  public MFSMailRequestObserver
       
    54     {
       
    55 public:
       
    56     
       
    57     /**
       
    58      * Constructs a CFSEmailUiMailboxDeleter instance and returns a pointer to 
       
    59      * it.
       
    60      * @param aMailClient Reference to a valid CFSMailClient.
       
    61      * @param aObserver Observer for receiving notification when mailbox 
       
    62      * deletion has been completed.
       
    63      * @return CFSEmailUiMailboxDeleter Pointer to class instance.
       
    64      */
       
    65     static CFSEmailUiMailboxDeleter* NewL( CFSMailClient& aMailClient, 
       
    66                                            MFSEmailUiMailboxDeleteObserver& aObserver );
       
    67 
       
    68     /**
       
    69      * Constructs a CFSEmailUiMailboxDeleter instance and returns a pointer to 
       
    70      * it.
       
    71      * @param aMailClient Reference to a valid CFSMailClient.
       
    72      * @param aObserver Observer for receiving notification when mailbox 
       
    73      * deletion has been completed.
       
    74      * @return CFSEmailUiMailboxDeleter Pointer to class instance. 
       
    75      */
       
    76     static CFSEmailUiMailboxDeleter* NewLC( CFSMailClient& aMailClient, 
       
    77                                             MFSEmailUiMailboxDeleteObserver& aObserver );
       
    78 
       
    79     /**
       
    80      * Destructor.
       
    81      */
       
    82     ~CFSEmailUiMailboxDeleter();
       
    83     
       
    84 public:    
       
    85     
       
    86 	/**
       
    87      * Displays a list of available mailboxes and allows the user to mark 
       
    88      * one or more mailboxes for deletion. Deletes the selected mailboxes and
       
    89      * notifies the observer given in the construction when the deletion is
       
    90      * complete.
       
    91      */
       
    92     void DeleteMailboxL();
       
    93 
       
    94 protected: // from MProgressDialogCallback
       
    95 
       
    96     void DialogDismissedL( TInt aButtonId );
       
    97 
       
    98 protected: // from MFSMailRequestObserver
       
    99 
       
   100     void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
       
   101     
       
   102 protected:
       
   103     
       
   104     void ConstructL();
       
   105     
       
   106     CFSEmailUiMailboxDeleter( CFSMailClient& aMailClient, 
       
   107                               MFSEmailUiMailboxDeleteObserver& aObserver  );
       
   108 
       
   109 private:
       
   110     
       
   111     /**
       
   112      * Deletes a single mailbox.
       
   113      * @param aMailboxes Array containing the mailbox to be deleted.
       
   114      * @return ETrue if user confirmed the deletion, EFalse if not.
       
   115      */
       
   116     TBool DeleteSingleMailboxL( const RPointerArray<CFSMailBox>& aMailboxes );
       
   117     
       
   118     /**
       
   119      * Deletes multiple mailboxes.
       
   120      * @param aMailboxes Array containing the mailboxes to be deleted.
       
   121      * @return ETrue if user confirmed the deletion, EFalse if not.
       
   122      */
       
   123     TBool DeleteMultipleMailboxesL( const RPointerArray<CFSMailBox>& aMailboxes );
       
   124     
       
   125     /**
       
   126      *  Confirms mailbox deletion. Behavior depends on the number of mailboxes
       
   127      *  to be deleted. aMailboxName is not used if aCount > 1.
       
   128      *  @param aCount Number of mailboxes to be removed.
       
   129      *  @param aMailboxName Name of the (first) mailbox to delete.
       
   130      *  @return ETrue if user confirmed the deletion, EFalse if not.
       
   131      */
       
   132     TBool ConfirmMailboxDeletionL( TInt aCount, const TDesC& aMailboxName );
       
   133 
       
   134     /**
       
   135      * Creates the mark icon.
       
   136      * @return The listbox mark icon.
       
   137      */
       
   138     CGulIcon* CreateMarkIconLC();
       
   139     
       
   140     /**
       
   141      * Creates the default mailbox icon for unbranded mailboxes.
       
   142      * @return The default mailbox icon.
       
   143      */
       
   144     CGulIcon* CreateDefaultMailboxIconLC();
       
   145 
       
   146     /**
       
   147      * Creates the listbox model and icon array for the listbox.
       
   148      * @param aModel Listbox model.
       
   149      * @param aIconArray Icon array.
       
   150      * @param aMailboxes Mailboxes to be added to the listbox model.
       
   151      */
       
   152     void CreateListboxModelAndIconArrayL( CDesCArrayFlat& aModel,
       
   153                                           CArrayPtr<CGulIcon>& aIconArray, 
       
   154                                           const RPointerArray<CFSMailBox>& aMailboxes );
       
   155 
       
   156     /**
       
   157      * Deletes next mailbox in iMailboxesToDelete.
       
   158      */
       
   159     void DoDeleteNextMailboxL();
       
   160                                           
       
   161 private: // data
       
   162 
       
   163     // Mail client
       
   164     CFSMailClient& iMailClient;
       
   165     
       
   166     // Observer
       
   167     MFSEmailUiMailboxDeleteObserver& iObserver; 
       
   168     
       
   169     // Mailboxes to delete
       
   170     RArray<TFSMailMsgId> iMailboxesToDelete;
       
   171    
       
   172     // Operation id of the currently ongoing delete operation
       
   173     TInt iMailboxDeleteOperationId;
       
   174 
       
   175     // Wait dialog
       
   176     CAknWaitDialog* iWaitDialog;
       
   177         
       
   178     };
       
   179 
       
   180 #endif // FREESTYLEEMAILUIMAILBOXDELETER_H