|
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: Implementation of ECOM plug-in service interface. Provides |
|
15 * screenshot service. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef SCREENSHOOTPLUGIN_H |
|
21 #define SCREENSHOOTPLUGIN_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <HtiServicePluginInterface.h> |
|
25 #include <w32std.h> |
|
26 #include <f32file.h> |
|
27 #include "HtiTextRcg.h" |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CImageEncoder; |
|
32 |
|
33 |
|
34 // CLASS DECLARATIONS |
|
35 class MICLObserver |
|
36 { |
|
37 public: |
|
38 virtual void ICLComplete( TInt anError) = 0; |
|
39 }; |
|
40 |
|
41 class CICLHandler : public CActive |
|
42 { |
|
43 public: |
|
44 CICLHandler(CImageEncoder* aService, MICLObserver* anObserver); |
|
45 ~CICLHandler(); |
|
46 |
|
47 void Start(); |
|
48 |
|
49 protected: //from CActive |
|
50 void RunL(); |
|
51 void DoCancel(); |
|
52 //TInt RunError(TInt aError); |
|
53 |
|
54 protected: |
|
55 MICLObserver* iObserver; |
|
56 CImageEncoder* iService; |
|
57 }; |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 class MSeriesShotTimerObserver |
|
64 { |
|
65 public: |
|
66 virtual void TimerExpired( TInt aId ) = 0; |
|
67 }; |
|
68 |
|
69 |
|
70 |
|
71 class CSeriesShotTimer : public CTimer |
|
72 { |
|
73 public: |
|
74 static CSeriesShotTimer* NewL(MSeriesShotTimerObserver* aObserver, |
|
75 TInt aId, |
|
76 TTimeIntervalMicroSeconds32 aTime); |
|
77 ~CSeriesShotTimer(); |
|
78 void Start(); |
|
79 |
|
80 protected: |
|
81 void ConstructL(); |
|
82 CSeriesShotTimer(MSeriesShotTimerObserver* aObserver, |
|
83 TInt aId, |
|
84 TTimeIntervalMicroSeconds32 aTime); |
|
85 public: // from CTimer |
|
86 void RunL(); |
|
87 |
|
88 private: |
|
89 MSeriesShotTimerObserver* iObserver; |
|
90 TInt iId; |
|
91 TTimeIntervalMicroSeconds32 iTime; |
|
92 }; |
|
93 |
|
94 |
|
95 class MSeriesShotObserver |
|
96 { |
|
97 public: |
|
98 virtual void SeriesShotCompletedL( HBufC8* aMsg ) = 0; |
|
99 virtual TBool StartShotL(TRect aRegion, TDisplayMode aDisplayMode, TDesC8 &aMimeType) = 0; |
|
100 }; |
|
101 |
|
102 |
|
103 class CHtiScreenshotServicePlugin; // forward declaration |
|
104 |
|
105 class CSeriesShot : public CBase, |
|
106 public MSeriesShotTimerObserver |
|
107 { |
|
108 enum TTimerType |
|
109 { |
|
110 EDuration, |
|
111 EInterval |
|
112 }; |
|
113 public: |
|
114 static CSeriesShot* NewL( MSeriesShotObserver* aServicePluginObserver ); |
|
115 CSeriesShot( MSeriesShotObserver* aServicePluginObserver ); |
|
116 virtual ~CSeriesShot(); |
|
117 |
|
118 void StartL( TTimeIntervalMicroSeconds32 aDuration, |
|
119 TTimeIntervalMicroSeconds32 aInterval, |
|
120 TDisplayMode aDisplayMode, |
|
121 TRect aRegion, |
|
122 TPtrC8 aMime); |
|
123 TBool IsOngoing(); |
|
124 void SaveImage( TDesC8* aImage, TBool isCompressed ); |
|
125 void TriggerNewShot(); |
|
126 void Cancel(); |
|
127 void EncodeCompleted(); |
|
128 HBufC8* ConstructCompletedMessageL(); |
|
129 |
|
130 protected: |
|
131 void ConstructL(); |
|
132 void ClearShots(); |
|
133 void GetMIMEExtension(TDesC8 &aMime, TDes &aExt); |
|
134 |
|
135 public: // from MSeriesShotTimerObserver |
|
136 void TimerExpired(TInt aId); |
|
137 |
|
138 private: |
|
139 MSeriesShotObserver* iServicePluginObserver; |
|
140 CSeriesShotTimer* iDurationTimer; |
|
141 CSeriesShotTimer* iIntervalTimer; |
|
142 TDisplayMode iDisplayMode; |
|
143 TInt iIndex; |
|
144 RFs iFs; |
|
145 TBool isEncoding; |
|
146 TBuf8<30> iMimeType; |
|
147 TBuf<10> iExtension; |
|
148 TRect iRegion; |
|
149 }; |
|
150 |
|
151 |
|
152 |
|
153 class CHtiScreenshotServicePlugin : public CHTIServicePluginInterface, |
|
154 public MICLObserver, |
|
155 public MSeriesShotObserver |
|
156 { |
|
157 public: |
|
158 |
|
159 static CHtiScreenshotServicePlugin* NewL(); |
|
160 |
|
161 // Interface implementation |
|
162 TBool IsBusy(); |
|
163 void ProcessMessageL(const TDesC8& aMessage, THtiMessagePriority aPriority); |
|
164 void NotifyMemoryChange( TInt aAvailableMemory ); |
|
165 |
|
166 // Observer implementation |
|
167 void ICLComplete( TInt anError); // from MICLObserver |
|
168 void SeriesShotCompletedL( HBufC8* aMsg ); // from MSeriesShotObserver |
|
169 TBool StartShotL(TRect aRegion, TDisplayMode aDisplayMode, TDesC8 &aMimeType); // from MSeriesShotObserver |
|
170 |
|
171 protected: |
|
172 |
|
173 void ProcessTextRcgMessageL(const TDesC8& aMessage); |
|
174 void ProcessTextBitmapMessageL(const TDesC8& aMessage); |
|
175 |
|
176 void SendTextRecgReplyL(const TBool aResult, const TRect& aLocation, |
|
177 const TInt aFontIndex); |
|
178 |
|
179 |
|
180 /** |
|
181 * Selects fonts based on predefined platform-dependent strategy |
|
182 * |
|
183 */ |
|
184 TBool RecognizeTextL(const TDesC& aText, |
|
185 TRect& aResult, |
|
186 TInt& aFontIndex); |
|
187 |
|
188 /** |
|
189 * Extracts string from incoming request and convert it to unicode |
|
190 * for non-unicode request |
|
191 * aResult should have enough length |
|
192 * Function returns either offset for a next parameter in aRequest |
|
193 * or some symbian error code |
|
194 */ |
|
195 TInt ParseString( const TDesC8& aRequest, |
|
196 TInt anOffset, |
|
197 TBool aUnicode, |
|
198 TDes& aResult); |
|
199 |
|
200 void CopyUnicode( TDes & aTo, const TDesC8& aFrom ); |
|
201 |
|
202 /** |
|
203 * Extract from request font description (font name, height, style) |
|
204 */ |
|
205 TInt ParseFontSpec( const TDesC8& aRequest, |
|
206 TInt anOffset, |
|
207 TBool aUnicode, |
|
208 TFontSpec& aResult); |
|
209 |
|
210 CWsScreenDevice* GetScreenDeviceL(); |
|
211 |
|
212 void CreateBitmapL( TRect& aRegion, TDisplayMode aMode = ENone); |
|
213 |
|
214 void SelectEncoder( const TUid aEncoderUid ); |
|
215 |
|
216 //encode iScreen |
|
217 void EncodeBitmapL(const TDesC8& aImageTypeMIME = KNullDesC8); |
|
218 |
|
219 inline TInt ParseInt16( const TUint8* aStart ); |
|
220 inline TInt ParseInt32( const TUint8* aStart ); |
|
221 |
|
222 /** |
|
223 * Compress content of iEncodedBitmap descriptor |
|
224 */ |
|
225 TInt Compress(); |
|
226 |
|
227 CHtiScreenshotServicePlugin(); |
|
228 void ConstructL(); |
|
229 |
|
230 virtual ~CHtiScreenshotServicePlugin(); |
|
231 |
|
232 //void InitFontCache(); |
|
233 |
|
234 TBool IsMIMETypeSupported(TDesC8 &aMime); |
|
235 |
|
236 void SetScreenNumber(TInt aScreenNumber); |
|
237 |
|
238 void HandleRotateScreen(const TDesC8& aData); |
|
239 protected: |
|
240 CFbsBitmap* iScreen; //raw screen bitmap |
|
241 HBufC8* iEncodedBitmap; //ready to send |
|
242 |
|
243 RWsSession iWs; |
|
244 CWsScreenDevice* iScreenDevice; |
|
245 |
|
246 CImageEncoder* iBitmapEncoder; |
|
247 CICLHandler* iICLHandler; |
|
248 |
|
249 TBool iCompress; |
|
250 |
|
251 //text recognition algorithms |
|
252 CHtiTextRcg iTextRcg; |
|
253 //fonts to use for recognition |
|
254 RArray<TFontSpec> iFontCache; |
|
255 |
|
256 // Series shot implementation |
|
257 CSeriesShot* iSeriesShot; |
|
258 |
|
259 // Members for deltacapture |
|
260 TBool iDeltaCapture; |
|
261 CFbsBitmap* iPreviousBitmap; |
|
262 TRect iDeltaRect; |
|
263 }; |
|
264 |
|
265 #endif // SCREENSHOOTPLUGIN_H |