64
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: FreestyleEmailUi attachments list model and model item definition.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef __FREESTYLEEMAILUI_ATTACHMENTSLISTMODEL_H__
|
|
20 |
#define __FREESTYLEEMAILUI_ATTACHMENTSLISTMODEL_H__
|
|
21 |
|
|
22 |
// SYSTEM INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
//<cmail>
|
|
25 |
#include "fstreelist.h"
|
|
26 |
//</cmail>
|
|
27 |
|
|
28 |
// INTERNAL INCLUDES
|
|
29 |
#include "FreestyleEmailDownloadInformationMediator.h"
|
|
30 |
|
|
31 |
// FORWARD DECLARATIONS
|
|
32 |
class CFreestyleEmailUiAppUi;
|
|
33 |
class CFSMailMessage;
|
|
34 |
|
|
35 |
// CONSTANTS
|
|
36 |
// Limit values of download progress
|
|
37 |
const TInt KNone = 0;
|
|
38 |
const TInt KComplete = 100;
|
|
39 |
|
|
40 |
// data of one attachment
|
|
41 |
struct TAttachmentData
|
|
42 |
{
|
|
43 |
// size of the attachment in bytes
|
|
44 |
TInt fileSize;
|
|
45 |
// download progress in %, 0-100
|
|
46 |
TInt downloadProgress;
|
|
47 |
// attachment file type
|
|
48 |
TFileType fileType;
|
|
49 |
// attachment file name
|
|
50 |
TFileName fileName;
|
|
51 |
// attachment tree entry id in attachment list
|
|
52 |
TFsTreeItemId treeId;
|
|
53 |
// attachment message part information
|
|
54 |
TPartData partData;
|
|
55 |
};
|
|
56 |
|
|
57 |
// Observer interface used to inform view about updates in model
|
|
58 |
class MFSEmailUiAttachmentsStatusObserver
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
/**
|
|
62 |
* Informs that the status of the given attachment has changed.
|
|
63 |
* @param aIndex The index of the changed object in the model. Note that
|
|
64 |
* it's possible that a new object has been added to the model.
|
|
65 |
* In that case, this index is greater than the previous last
|
|
66 |
* index of the model. KErrNotFound indicates that the list
|
|
67 |
* was completely updated and thus UI needs to refresh
|
|
68 |
* itself totally.
|
|
69 |
*/
|
|
70 |
virtual void DownloadStatusChangedL( TInt aIndex ) = 0;
|
|
71 |
};
|
|
72 |
|
|
73 |
|
|
74 |
//////////////////////////////////////////////////////////////////////////////
|
|
75 |
// Base class contains common functionality for the Attachments list model and
|
|
76 |
// Download Manager model
|
|
77 |
class CFSEmailUiAttachmentsModelBase : public CBase, public MFSEmailDownloadInformationObserver
|
|
78 |
{
|
|
79 |
public: // methods
|
|
80 |
~CFSEmailUiAttachmentsModelBase();
|
|
81 |
|
|
82 |
// starts download
|
|
83 |
TBool StartDownloadL( TFsTreeItemId aTreeId );
|
|
84 |
TBool StartDownloadL( const TAttachmentData& aAttachment );
|
|
85 |
// saves attachment
|
|
86 |
TBool SaveAttachmentL( TFsTreeItemId aTreeId, const TDesC& aFileName, TInt& aSavedCount );
|
|
87 |
TBool SaveAttachmentL( const TAttachmentData& aAttachment, const TDesC& aFileName, TInt& aSavedCount );
|
|
88 |
// cancels download operation
|
|
89 |
void CancelDownloadL( TFsTreeItemId aTreeId );
|
|
90 |
void CancelDownloadL( const TAttachmentData& aAttachment );
|
|
91 |
// removes the downloaded file contents
|
|
92 |
void RemoveContentL( TFsTreeItemId aTreeId );
|
|
93 |
void RemoveContentL( const TAttachmentData& aAttachment );
|
|
94 |
// is the message part currently being downloaded
|
|
95 |
TBool IsDownloading( const TAttachmentData& aAttachment );
|
|
96 |
// is the message part completely downloaded
|
|
97 |
TBool IsCompletelyDownloadedL( const TAttachmentData& aAttachment );
|
|
98 |
// is the message part an embedded message object
|
|
99 |
TBool IsMessage( const TAttachmentData& aAttachment ) const;
|
|
100 |
// returns ETrue if there has been at least one download started after program start
|
|
101 |
TBool IsThereAnyCurrentDownloads();
|
|
102 |
// Creates and returns a size description matching the given size. Ownership is transferred to CleanupStack.
|
|
103 |
static HBufC* CreateSizeDescLC( TInt aSize );
|
|
104 |
// Get AppUi handle
|
|
105 |
CFreestyleEmailUiAppUi& AppUi();
|
|
106 |
|
|
107 |
public: // pure virtual methods
|
|
108 |
// get attachment data from list using tree entry
|
|
109 |
virtual TAttachmentData* GetItem( TFsTreeItemId aTreeId ) = 0;
|
|
110 |
// get attachment data from list using tree entry
|
|
111 |
virtual TAttachmentData& GetItemL( TFsTreeItemId aTreeId ) = 0;
|
|
112 |
// get message object related to the given tree entry
|
|
113 |
virtual TPartData GetMessageL( TFsTreeItemId aTreeId ) = 0;
|
|
114 |
// downloads all attachments
|
|
115 |
virtual TBool DownloadAllAttachmentsL() = 0;
|
|
116 |
// saves all attachments
|
|
117 |
virtual TBool SaveAllAttachmentsL( const TDesC& aFileName ) = 0;
|
|
118 |
// cancels all downloads
|
|
119 |
virtual void CancelAllDownloadsL() = 0;
|
|
120 |
// check if model contains any attachment of message type
|
|
121 |
virtual TBool IsThereAnyMessageAttachments() const = 0;
|
|
122 |
|
|
123 |
protected: // methods
|
|
124 |
CFSEmailUiAttachmentsModelBase( CFreestyleEmailUiAppUi& aAppUi );
|
|
125 |
void ConstructL();
|
|
126 |
|
|
127 |
protected: // data
|
|
128 |
CFreestyleEmailUiAppUi& iAppUi;
|
|
129 |
};
|
|
130 |
|
|
131 |
|
|
132 |
/////////////////////////////
|
|
133 |
// The Attachments list model
|
|
134 |
class CFSEmailUiAttachmentsListModel : public CFSEmailUiAttachmentsModelBase
|
|
135 |
{
|
|
136 |
public:
|
|
137 |
// download progress infromation callback, from MFSEmailDownloadInformationObserver
|
|
138 |
virtual void RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart );
|
|
139 |
// two-phased constructor
|
|
140 |
static CFSEmailUiAttachmentsListModel* NewL( CFreestyleEmailUiAppUi& aAppUi, MFSEmailUiAttachmentsStatusObserver& aObserver );
|
|
141 |
// two-phased constructor
|
|
142 |
static CFSEmailUiAttachmentsListModel* NewLC(CFreestyleEmailUiAppUi& aAppUi, MFSEmailUiAttachmentsStatusObserver& aObserver );
|
|
143 |
// destructor
|
|
144 |
~CFSEmailUiAttachmentsListModel();
|
|
145 |
// returns the whole model
|
|
146 |
const RArray<TAttachmentData>& GetModel();
|
|
147 |
// adds node id to attachment data
|
|
148 |
void SetNodeIdL( TInt aAttachmentIndex, TFsTreeItemId aTreeItemId );
|
|
149 |
// updates attachment list
|
|
150 |
void UpdateListL( TPartData aMessage );
|
|
151 |
void UpdateListL( CFSMailMessage* aEmbeddedMessage );
|
|
152 |
// Creates and returns mail subject text. Ownership is transferred to CleanupStack.
|
|
153 |
HBufC* CreateMailSubjectTextLC() const;
|
|
154 |
// Returns ETrue if there is multiple attachment downloads requested
|
|
155 |
TBool IsMultiplyDownloadsOngoing();
|
|
156 |
|
|
157 |
public: // from CFSEmailUiAttachmentsModelBase
|
|
158 |
// get attachment data from list using tree entry
|
|
159 |
TAttachmentData* GetItem( TFsTreeItemId aTreeId );
|
|
160 |
// get attachment data from list using tree entry
|
|
161 |
TAttachmentData& GetItemL( TFsTreeItemId aTreeId );
|
|
162 |
// get message object related to the given tree entry
|
|
163 |
TPartData GetMessageL( TFsTreeItemId aTreeId );
|
|
164 |
// downloads all attachments
|
|
165 |
TBool DownloadAllAttachmentsL();
|
|
166 |
// saves all attachments
|
|
167 |
TBool SaveAllAttachmentsL( const TDesC& aFileName );
|
|
168 |
// cancels all downloads
|
|
169 |
void CancelAllDownloadsL();
|
|
170 |
// check if model contains any attachment of message type
|
|
171 |
TBool IsThereAnyMessageAttachments() const;
|
|
172 |
// check if model contains any attachment of non-message type
|
|
173 |
TBool IsThereAnyNonMessageAttachments() const;
|
|
174 |
|
|
175 |
private:
|
|
176 |
CFSEmailUiAttachmentsListModel( CFreestyleEmailUiAppUi& aAppUi, MFSEmailUiAttachmentsStatusObserver& aObserver );
|
|
177 |
void ConstructL();
|
|
178 |
|
|
179 |
private:
|
|
180 |
MFSEmailUiAttachmentsStatusObserver& iObserver;
|
|
181 |
TPartData iMessage;
|
|
182 |
RArray<TAttachmentData> iAttachments;
|
|
183 |
};
|
|
184 |
|
|
185 |
#endif //__FREESTYLEEMAILUI_MAILLISTMODEL_H__
|
|
186 |
|