25
|
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 |
/**
|
|
95 |
* Deletes the given mailbox. Displays also a confirmation dialog.
|
|
96 |
* @param aMailboxId The ID of the mail box to delete.
|
|
97 |
*/
|
|
98 |
void DeleteMailboxL( const TFSMailMsgId& aMailboxId );
|
|
99 |
|
|
100 |
|
|
101 |
protected: // from MProgressDialogCallback
|
|
102 |
|
|
103 |
void DialogDismissedL( TInt aButtonId );
|
|
104 |
|
|
105 |
protected: // from MFSMailRequestObserver
|
|
106 |
|
|
107 |
void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
|
|
108 |
|
|
109 |
protected:
|
|
110 |
|
|
111 |
void ConstructL();
|
|
112 |
|
|
113 |
CFSEmailUiMailboxDeleter( CFSMailClient& aMailClient,
|
|
114 |
MFSEmailUiMailboxDeleteObserver& aObserver );
|
|
115 |
|
|
116 |
private:
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Returns the mailboxes that can be deleted. Note that the given array is
|
|
120 |
* left in the clean up stack.
|
|
121 |
* @param aMailboxes The array where the mailboxes are added to.
|
|
122 |
* @return The number of deletable mailboxes found.
|
|
123 |
*/
|
|
124 |
TInt GetDeletableMailboxesLC( RPointerArray<CFSMailBox>& aMailboxes );
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Deletes a single mailbox.
|
|
128 |
* @param aMailboxes Array containing the mailbox to be deleted.
|
|
129 |
* @return ETrue if user confirmed the deletion, EFalse if not.
|
|
130 |
*/
|
|
131 |
TBool DeleteSingleMailboxL( const RPointerArray<CFSMailBox>& aMailboxes );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Deletes multiple mailboxes.
|
|
135 |
* @param aMailboxes Array containing the mailboxes to be deleted.
|
|
136 |
* @return ETrue if user confirmed the deletion, EFalse if not.
|
|
137 |
*/
|
|
138 |
TBool DeleteMultipleMailboxesL( const RPointerArray<CFSMailBox>& aMailboxes );
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Deletes the selected mailboxes i.e. those of which IDs are in the
|
|
142 |
* iMailboxesToDelete array.
|
|
143 |
*/
|
|
144 |
void DoDeleteSelectedMailboxesL();
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Confirms mailbox deletion. Behavior depends on the number of mailboxes
|
|
148 |
* to be deleted. aMailboxName is not used if aCount > 1.
|
|
149 |
* @param aCount Number of mailboxes to be removed.
|
|
150 |
* @param aMailboxName Name of the (first) mailbox to delete.
|
|
151 |
* @return ETrue if user confirmed the deletion, EFalse if not.
|
|
152 |
*/
|
|
153 |
TBool ConfirmMailboxDeletionL( TInt aCount, const TDesC& aMailboxName );
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Creates the mark icon.
|
|
157 |
* @return The listbox mark icon.
|
|
158 |
*/
|
|
159 |
CGulIcon* CreateMarkIconLC();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Creates the default mailbox icon for unbranded mailboxes.
|
|
163 |
* @return The default mailbox icon.
|
|
164 |
*/
|
|
165 |
CGulIcon* CreateDefaultMailboxIconLC();
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Creates the listbox model and icon array for the listbox.
|
|
169 |
* @param aModel Listbox model.
|
|
170 |
* @param aIconArray Icon array.
|
|
171 |
* @param aMailboxes Mailboxes to be added to the listbox model.
|
|
172 |
*/
|
|
173 |
void CreateListboxModelAndIconArrayL( CDesCArrayFlat& aModel,
|
|
174 |
CArrayPtr<CGulIcon>& aIconArray,
|
|
175 |
const RPointerArray<CFSMailBox>& aMailboxes );
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Deletes next mailbox in iMailboxesToDelete.
|
|
179 |
*/
|
|
180 |
void DoDeleteNextMailboxL();
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Callback that calls DoDeleteNextMailboxL().
|
|
184 |
*/
|
|
185 |
static TInt IdleCallbackL(TAny* aPtr);
|
|
186 |
|
|
187 |
private: // data
|
|
188 |
|
|
189 |
// Mail client
|
|
190 |
CFSMailClient& iMailClient;
|
|
191 |
|
|
192 |
// Observer
|
|
193 |
MFSEmailUiMailboxDeleteObserver& iObserver;
|
|
194 |
|
|
195 |
// Mailboxes to delete
|
|
196 |
RArray<TFSMailMsgId> iMailboxesToDelete;
|
|
197 |
|
|
198 |
// Operation id of the currently ongoing delete operation
|
|
199 |
TInt iMailboxDeleteOperationId;
|
|
200 |
|
|
201 |
// Wait dialog
|
|
202 |
CAknWaitDialog* iWaitDialog;
|
|
203 |
|
|
204 |
// Idletimer. This is used in RequestResponseL() to ensure that
|
|
205 |
// iMailboxDeleteOperationId gets updated properly when deleting multiple
|
|
206 |
// mailboxes.
|
|
207 |
CIdle* iIdle;
|
|
208 |
|
|
209 |
};
|
|
210 |
|
|
211 |
#endif // FREESTYLEEMAILUIMAILBOXDELETER_H
|