31
|
1 |
/*
|
|
2 |
* Copyright (c) 2006,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: CUniEditorProcessImageOperation class definition.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef __UNIEDITORPROCESSIMAGEOPERATION_H
|
|
21 |
#define __UNIEDITORPROCESSIMAGEOPERATION_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <f32file.h>
|
|
27 |
#include <msvapi.h>
|
|
28 |
#include <apmstd.h>
|
|
29 |
|
|
30 |
#include <msgunieditorimageprocessor.h>
|
|
31 |
#include <cmsvattachment.h>
|
|
32 |
#include <QObject>
|
|
33 |
|
|
34 |
// FORWARD DECLARATIONS
|
|
35 |
|
|
36 |
class CMsgImageInfo;
|
|
37 |
class CMsgImageControl;
|
|
38 |
class CUniEditorDocument;
|
|
39 |
class MMsvAttachmentManager;
|
|
40 |
class CMsvStore;
|
|
41 |
class HbAction;
|
|
42 |
// DATA TYPES
|
|
43 |
|
|
44 |
// CLASS DECLARATION
|
|
45 |
|
|
46 |
enum TUniEditorProcessImageOperationEvent
|
|
47 |
{
|
|
48 |
EUniEditorProcessImageOperationProcessing,
|
|
49 |
EUniEditorProcessImageOperationComplete,
|
|
50 |
EUniEditorProcessImageOperationError,
|
|
51 |
// Cancel is called for active operation
|
|
52 |
EUniEditorProcessImageOperationCancel
|
|
53 |
};
|
|
54 |
|
|
55 |
class MUniEditorProcessImageOperationObserver
|
|
56 |
{
|
|
57 |
public:
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Notifies Image process operation result and the new file to be used
|
|
61 |
*/
|
|
62 |
virtual void EditorOperationEvent(
|
|
63 |
TUniEditorProcessImageOperationEvent aEvent,
|
|
64 |
TFileName aFileName) = 0;
|
|
65 |
};
|
|
66 |
|
|
67 |
/**
|
|
68 |
* CUniEditorProcessImageOperation
|
|
69 |
*
|
|
70 |
* @since 3.2
|
|
71 |
*/
|
|
72 |
class CUniEditorProcessImageOperation : public QObject,public CActive,
|
|
73 |
public MUniImageProcessorCallback
|
|
74 |
{
|
|
75 |
Q_OBJECT
|
|
76 |
|
|
77 |
public: // new operations
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Factory method
|
|
81 |
*/
|
|
82 |
static CUniEditorProcessImageOperation* NewL(
|
|
83 |
MUniEditorProcessImageOperationObserver &aObserver);
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Start image process operation
|
|
87 |
*
|
|
88 |
* @param aImageInfo
|
|
89 |
*
|
|
90 |
*/
|
|
91 |
void Process( CMsgImageInfo* aImageInfo);
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Destructor
|
|
95 |
*/
|
|
96 |
virtual ~CUniEditorProcessImageOperation();
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Detaches image info object.
|
|
100 |
*/
|
|
101 |
CMsgImageInfo* DetachImageInfo();
|
|
102 |
|
|
103 |
|
|
104 |
protected:
|
|
105 |
|
|
106 |
/**
|
|
107 |
* From CActive
|
|
108 |
*/
|
|
109 |
void RunL();
|
|
110 |
|
|
111 |
/**
|
|
112 |
* From CActive
|
|
113 |
*/
|
|
114 |
TInt RunError( TInt aError );
|
|
115 |
|
|
116 |
/**
|
|
117 |
* From CActive.
|
|
118 |
*/
|
|
119 |
void DoCancel();
|
|
120 |
/**
|
|
121 |
* From CUniEditorOperation
|
|
122 |
*/
|
|
123 |
void DoCancelCleanup();
|
|
124 |
|
|
125 |
/**
|
|
126 |
* From MUniImageProcessorCallback
|
|
127 |
*/
|
|
128 |
void ImageProcessingReady( TSize aBitmapSize,
|
|
129 |
TInt aFileSize,
|
|
130 |
TBool aCompressed );
|
|
131 |
|
|
132 |
private: // new operations
|
|
133 |
|
|
134 |
/**
|
|
135 |
* C++ constructor
|
|
136 |
*/
|
|
137 |
CUniEditorProcessImageOperation(
|
|
138 |
MUniEditorProcessImageOperationObserver &aObserver);
|
|
139 |
|
|
140 |
/**
|
|
141 |
* 2nd phase constructor.
|
|
142 |
*/
|
|
143 |
void ConstructL();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Returns optimal send image size.
|
|
147 |
*/
|
|
148 |
TSize ImageSendSize() const;
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Checks whether some processing is needed for the image.
|
|
152 |
* Stores the possible processing method to "iProcessMethod".
|
|
153 |
*
|
|
154 |
* @return EFalse if aborted by user,
|
|
155 |
* ETrue otherwise
|
|
156 |
*/
|
|
157 |
TBool CheckNeedToProcess();
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Creates empty attachment.
|
|
161 |
*/
|
|
162 |
void CreateEmptyAttachmentL();
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Start check step.
|
|
166 |
*/
|
|
167 |
void DoStartCheck();
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Start process step.
|
|
171 |
*/
|
|
172 |
void DoStartProcessL();
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Start resolve step.
|
|
176 |
*/
|
|
177 |
void DoStartResolveL();
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Processing ready.
|
|
181 |
*/
|
|
182 |
void DoReady();
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Performs error handling without state change.
|
|
186 |
*/
|
|
187 |
void DoErrorWithoutStateChange();
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Opens file by file name. If it fails with KErrPermissionDenied,
|
|
191 |
* file is searched from message store and opened from there
|
|
192 |
*/
|
|
193 |
RFile OpenFileForReadingL();
|
|
194 |
|
|
195 |
/**
|
|
196 |
* CompleteSelf
|
|
197 |
*/
|
|
198 |
void CompleteSelf( TInt aError );
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Sets operation pending.
|
|
202 |
*/
|
|
203 |
void SetPending();
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Completes operation
|
|
207 |
*/
|
|
208 |
void CompleteOperation( TInt aError );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Check image size
|
|
212 |
*/
|
|
213 |
void checkLargeImage();
|
|
214 |
|
|
215 |
private slots:
|
|
216 |
|
|
217 |
/**
|
|
218 |
* This slot is called when large image insertion query dialog is launched.
|
|
219 |
* @param action selected action (yes or no).
|
|
220 |
*/
|
|
221 |
void onDialogLargeImage(HbAction* action);
|
|
222 |
|
|
223 |
private: // data
|
|
224 |
|
|
225 |
enum TUniProcessStates
|
|
226 |
{
|
|
227 |
EUniProcessImgCheck,
|
|
228 |
EUniProcessImgProcess,
|
|
229 |
EUniProcessImgResolve,
|
|
230 |
EUniProcessImgReady,
|
|
231 |
EUniProcessImgError
|
|
232 |
};
|
|
233 |
|
|
234 |
enum TUniProcessMethods
|
|
235 |
{
|
|
236 |
EUniProcessImgMethodNone = 0x0,
|
|
237 |
EUniProcessImgMethodScale = 0x1,
|
|
238 |
EUniProcessImgMethodConvert = 0x2,
|
|
239 |
EUniProcessImgMethodCompress = 0x4
|
|
240 |
};
|
|
241 |
|
|
242 |
CMsgImageInfo* iImageInfo;
|
|
243 |
|
|
244 |
CMsgImageInfo* iNewImageInfo;
|
|
245 |
RFile iNewImageFile;
|
|
246 |
|
|
247 |
CUniImageProcessor* iImageProcessor;
|
|
248 |
|
|
249 |
TInt iProcessMethod;
|
|
250 |
|
|
251 |
TSize iScaleSize;
|
|
252 |
TSize iScaleSizeResult;
|
|
253 |
TDataType iTargetType;
|
|
254 |
TBool iExactImageScaling;
|
|
255 |
TInt iOperationState;
|
|
256 |
MUniEditorProcessImageOperationObserver &iObserver;
|
|
257 |
TInt iMaxMmsSize;
|
|
258 |
TInt iMaxImageWidth;
|
|
259 |
TInt iMaxImageHeight;
|
|
260 |
TInt iMmsCreationMode;
|
|
261 |
RFs iFs;
|
|
262 |
TBool largeImageQuery;
|
|
263 |
};
|
|
264 |
|
|
265 |
#endif //__UNIEDITORPROCESSIMAGEOPERATION_H
|