|
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: Message Preview Handler |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef _C_CS_PREVIEW_PLUGIN_HANDLER_H_ |
|
19 #define _C_CS_PREVIEW_PLUGIN_HANDLER_H_ |
|
20 |
|
21 //SYSTEM INCLUDES |
|
22 #include <msvapi.h> |
|
23 #include <f32file.h> |
|
24 #include <thumbnailmanager.h> |
|
25 #include <thumbnailmanagerobserver.h> |
|
26 #include <thumbnaildata.h> |
|
27 #include <sqldb.h> |
|
28 |
|
29 //USER INCLUDES |
|
30 #include <ccsdefs.h> |
|
31 #include "ccspreviewplugin.h" |
|
32 #include "UniDataModel.h" |
|
33 |
|
34 // FORWARD DECLARATION |
|
35 class CCsPlugin; |
|
36 class CMsvSession; |
|
37 class MCsPluginEventObserver; |
|
38 class MMsvSessionObserver; |
|
39 class CCsConversationEntry; |
|
40 class CCsPreviewPlugin; |
|
41 class CClientMtmRegistry; |
|
42 class CMmsClientMtm; |
|
43 class CUniDataModel; |
|
44 class MMsvAttachmentManager; |
|
45 |
|
46 enum MmsConformanceCheckErrors |
|
47 { |
|
48 EInsertSuccess = 0, EInsertQueryAbort, EInsertNotSupported |
|
49 }; |
|
50 |
|
51 /* |
|
52 * Thumbnail Request Data |
|
53 */ |
|
54 struct ThumbnailRequestData |
|
55 { |
|
56 /* |
|
57 * Request Id |
|
58 */ |
|
59 TThumbnailRequestId iRequestId; |
|
60 |
|
61 /* |
|
62 * Message Id |
|
63 */ |
|
64 TMsvId iMsgId; |
|
65 }; |
|
66 |
|
67 /** |
|
68 * This class interacts with MsvServer to fetch message data |
|
69 */ |
|
70 class CCsPreviewPluginHandler : public CBase, |
|
71 public MMsvSessionObserver, |
|
72 public MUniDataModelObserver, |
|
73 public MThumbnailManagerObserver |
|
74 { |
|
75 |
|
76 public: |
|
77 |
|
78 /** |
|
79 * Two phase construction |
|
80 */ |
|
81 static CCsPreviewPluginHandler* NewL(CCsPreviewPlugin *aMsgObserver); |
|
82 |
|
83 /** |
|
84 * Destructor |
|
85 */ |
|
86 virtual ~CCsPreviewPluginHandler(); |
|
87 |
|
88 public: |
|
89 //MMsvSessionObserver |
|
90 /** |
|
91 * Handles the MsvServer updates. Implemented for MMsvSessionObserver |
|
92 */ |
|
93 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, |
|
94 TAny* aArg2, TAny* aArg3); |
|
95 |
|
96 public: |
|
97 //MUniDataModelObserver |
|
98 /** |
|
99 */ |
|
100 void RestoreReady(TInt aParseResult, TInt aError); |
|
101 |
|
102 public: |
|
103 // Callbacks from MThumbnailManagerObserver for getting thumbnails |
|
104 void ThumbnailPreviewReady(MThumbnailData& aThumbnail, |
|
105 TThumbnailRequestId aId); |
|
106 |
|
107 void ThumbnailReady(TInt aError, MThumbnailData& aThumbnail, |
|
108 TThumbnailRequestId aId); |
|
109 |
|
110 public: |
|
111 |
|
112 /* |
|
113 * Compare by request Id. |
|
114 */ |
|
115 static TBool CompareByRequestId(const ThumbnailRequestData& aFirst, |
|
116 const ThumbnailRequestData& aSecond); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * Constructor |
|
122 */ |
|
123 CCsPreviewPluginHandler(); |
|
124 |
|
125 /** |
|
126 * 2nd phase construtor |
|
127 */ |
|
128 void ConstructL(CCsPreviewPlugin *aMsgPlugin); |
|
129 |
|
130 /** |
|
131 * Process each entry |
|
132 *@param aSelection, CMsvEntrySelections |
|
133 */ |
|
134 void HandleEventL(CMsvEntrySelection* aSelection); |
|
135 |
|
136 /** |
|
137 * Bind bodytext to sql statement. |
|
138 *@param sqlStmt, RSqlStatement |
|
139 *@param attachmentId, TMsvAttachmentId |
|
140 */ |
|
141 void BindBodyText(RSqlStatement& sqlStmt, TMsvAttachmentId attachmentId); |
|
142 |
|
143 /** |
|
144 * Get Thumbnail data from attachment |
|
145 *@param attachmentId, TMsvAttachmentId |
|
146 *@param mimeType, |
|
147 *@param msgId, message id |
|
148 */ |
|
149 void GetThumbNailL(TMsvAttachmentId attachmentId, TDesC8& mimeType, |
|
150 TMsvId msgId); |
|
151 |
|
152 /* |
|
153 * Process Thumbnail data |
|
154 * @param aThumbnail MThumbnailData |
|
155 * @param aId TThumbnailRequestId |
|
156 */ |
|
157 void HandleThumbnailReadyL(MThumbnailData& aThumbnail, |
|
158 TThumbnailRequestId aId); |
|
159 |
|
160 /** |
|
161 * Validates if message can be forwarded |
|
162 * The validation checks include slide count check,MMS size check and |
|
163 * media conformance checks and this fucntion should be called only for mms |
|
164 * @param aUniDataModel, instance of unidatamodel |
|
165 * @return true if message can be forwarded |
|
166 * false if message cant be forwarded |
|
167 */ |
|
168 TBool ValidateMsgForForward(CUniDataModel* aUniDataModel); |
|
169 |
|
170 /** |
|
171 * This shall return the particular slide attachments ids |
|
172 * @param aSlideNum slide count |
|
173 * @param aUniDataModel instance of unidatamodel |
|
174 * @return array of attachment id's |
|
175 */ |
|
176 RArray<TMsvAttachmentId>* GetSlideAttachmentIds( |
|
177 TInt aSlideNum, |
|
178 CUniDataModel* aUniDataModel); |
|
179 |
|
180 /** |
|
181 * This shall return list of attachment id's |
|
182 * @param aUniDataModel instance of unidatamodel |
|
183 * @return array of attachment id's |
|
184 */ |
|
185 RArray<TMsvAttachmentId>* GetAttachmentIdList( |
|
186 CUniDataModel* aUniDataModel); |
|
187 |
|
188 /** |
|
189 * This shall check the insert mode for the attachment file |
|
190 * @param aFileHandle instance of file handle |
|
191 * @return enum MmsConformanceCheckErrors |
|
192 */ |
|
193 TInt CheckModeForInsertL(RFile aFileHandle); |
|
194 |
|
195 /** |
|
196 * Finds the message's processing state |
|
197 * @param aMsgId, message id |
|
198 * @return, TInt from TCsPreviewMsgProcessingState enum |
|
199 */ |
|
200 TInt msgProcessingState(TMsvId aMsgId); |
|
201 |
|
202 /** |
|
203 * Sets message under processing to true |
|
204 * @param aMsgId, message id |
|
205 * @param aState, TInt from TCsPreviewMsgProcessingState enum |
|
206 */ |
|
207 void setMsgProcessingState(TMsvId aMsgId, TInt aState); |
|
208 |
|
209 private: |
|
210 //Data |
|
211 |
|
212 /** |
|
213 * MsvServer session object |
|
214 * Own |
|
215 */ |
|
216 CMsvSession* iSession; |
|
217 |
|
218 /** |
|
219 * iMsgObserver |
|
220 * The Observer interface |
|
221 * Not Own. |
|
222 */ |
|
223 CCsPreviewPlugin *iMsgObserver; |
|
224 |
|
225 /** |
|
226 * Mtm registry object |
|
227 * Own |
|
228 */ |
|
229 CClientMtmRegistry* iMtmRegistry; |
|
230 |
|
231 /** |
|
232 * Mms client mtm object |
|
233 * Own. |
|
234 */ |
|
235 CMmsClientMtm* iMmsMtm; |
|
236 |
|
237 /* |
|
238 * File session |
|
239 */ |
|
240 RFs ifsSession; |
|
241 |
|
242 /* |
|
243 * Thumbnail request array. |
|
244 * Own |
|
245 */ |
|
246 RArray<ThumbnailRequestData> iThumbnailRequestArray; |
|
247 |
|
248 /* |
|
249 * Thumbnail manager. |
|
250 * Own |
|
251 */ |
|
252 CThumbnailManager* iThumbnailManager; |
|
253 |
|
254 /* |
|
255 * Sqlite DB Handle |
|
256 */ |
|
257 RSqlDatabase iSqlDb; |
|
258 |
|
259 /** |
|
260 * Max MMS Size |
|
261 */ |
|
262 TInt iMaxMmsSize; |
|
263 |
|
264 /* |
|
265 * Mms creation mode |
|
266 */ |
|
267 TInt iCreationMode; |
|
268 |
|
269 /** |
|
270 * Conformance status |
|
271 */ |
|
272 TUint32 iConfStatus; |
|
273 |
|
274 }; |
|
275 |
|
276 #endif // _C_CS_PREVIEW_PLUGIN_HANDLER_H_ |