|
1 /* |
|
2 * Copyright (c) 2004 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 the License "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: Encapsulates all the necessary information for a single page |
|
15 * to be able to re-display the page. |
|
16 * History Entry objects are stored on the History Stack. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "historyentry.h" |
|
24 #include <fbs.h> |
|
25 #include <s32mem.h> |
|
26 #include <uri8.h> |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // MACROS |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 |
|
38 // MODULE DATA STRUCTURES |
|
39 |
|
40 // LOCAL FUNCTION PROTOTYPES |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 |
|
44 // ========================== FUNCTIONS ========================= |
|
45 |
|
46 HistoryEntry* HistoryEntry::initWithUrlAndFormData( const TPtrC8& url, const TPtrC8& requestUrl, |
|
47 TPtrC& formContentType, WebCore::FormData* formData, HistoryCallback* callback, TBool ifWmlType) |
|
48 { |
|
49 HistoryEntry* entry = new HistoryEntry; |
|
50 if (entry) { |
|
51 entry->m_ifWmlMode = ifWmlType; |
|
52 entry->m_requestUrl = requestUrl.Alloc(); |
|
53 entry->m_responseUrl = url.Alloc(); |
|
54 int offset = 0; |
|
55 if (requestUrl.Find(_L8("http://")) == 0) { |
|
56 offset = 7; |
|
57 } |
|
58 else if (requestUrl.Find(_L8("https://")) == 0) { |
|
59 offset = 8; |
|
60 } |
|
61 entry->m_pageTitle = HBufC::New(requestUrl.Length() - offset); |
|
62 if (entry->m_pageTitle) { |
|
63 entry->m_pageTitle->Des().Copy(requestUrl.Mid(offset)); |
|
64 } |
|
65 entry->m_callback = callback; |
|
66 entry->m_zoomLevel = 0; |
|
67 entry->m_minZoomLevel = 0; |
|
68 if (formData && formContentType.Length()) { |
|
69 entry->m_postContentType = formContentType.Alloc(); |
|
70 entry->m_formData = formData; |
|
71 entry->m_callback->setUse(true, entry->m_formData); |
|
72 } |
|
73 |
|
74 if (!entry->m_requestUrl || !entry->m_pageTitle || (formData && formContentType.Length() && !entry->m_postContentType)) { |
|
75 delete entry; |
|
76 entry = NULL; |
|
77 } |
|
78 } |
|
79 return entry; |
|
80 } |
|
81 |
|
82 /** |
|
83 */ |
|
84 //void HistoryEntry::setRequestUrlL (const TDesC& requestUrl); |
|
85 |
|
86 /** |
|
87 */ |
|
88 //void HistoryEntry::setResponseUrlL (const TDesC& responseUrl); |
|
89 |
|
90 /** |
|
91 */ |
|
92 void HistoryEntry::setPosition (const TPoint& position) |
|
93 { |
|
94 m_position.SetXY(position.iX, position.iY); |
|
95 } |
|
96 |
|
97 /** |
|
98 */ |
|
99 void HistoryEntry::setZoomLevel (int zoomLevel) |
|
100 { |
|
101 m_zoomLevel = zoomLevel; |
|
102 } |
|
103 /** |
|
104 */ |
|
105 void HistoryEntry::setMinZoomLevel (int zoomLevel) |
|
106 { |
|
107 m_minZoomLevel = zoomLevel; |
|
108 } |
|
109 |
|
110 /** |
|
111 */ |
|
112 void HistoryEntry::setPageTitle(const TDesC& pageTitle) |
|
113 { |
|
114 if (pageTitle.Length()) { |
|
115 HBufC* title = m_pageTitle; |
|
116 m_pageTitle = NULL; |
|
117 m_pageTitle = pageTitle.Alloc(); |
|
118 if (m_pageTitle) { |
|
119 delete title; |
|
120 } |
|
121 else { |
|
122 m_pageTitle = title; |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 /** |
|
128 */ |
|
129 void HistoryEntry::setActiveBoxId (int id) |
|
130 { |
|
131 m_activeBoxId = id; |
|
132 } |
|
133 |
|
134 |
|
135 /** |
|
136 */ |
|
137 //void HistoryEntry::addFormData (WebCore::FormData* formData); |
|
138 |
|
139 /** |
|
140 */ |
|
141 //void HistoryEntry::setPostContentTypeL (TPtrC8 postContentType); |
|
142 |
|
143 void HistoryEntry::storeThumbnail(const CFbsBitmap* thumbnail, const TRect& area) |
|
144 { |
|
145 delete m_thumbnail; |
|
146 m_thumbnail = 0; |
|
147 if (!m_thumbnailBuf) { |
|
148 TRAP_IGNORE(m_thumbnailBuf = CBufFlat::NewL(4096)); |
|
149 } |
|
150 if (m_thumbnailBuf) { |
|
151 RBufWriteStream stream(*m_thumbnailBuf); |
|
152 TRAPD(err, thumbnail->ExternalizeRectangleL(stream, area)); |
|
153 stream.Close(); |
|
154 if (err) { |
|
155 delete m_thumbnailBuf; |
|
156 m_thumbnailBuf = 0; |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 /** |
|
162 */ |
|
163 CFbsBitmap* HistoryEntry::constructThumbnailL() |
|
164 { |
|
165 if (!m_thumbnail && m_thumbnailBuf) { |
|
166 m_thumbnail = new (ELeave) CFbsBitmap(); |
|
167 RBufReadStream stream(*m_thumbnailBuf); |
|
168 CleanupClosePushL(stream); |
|
169 m_thumbnail->InternalizeL(stream); |
|
170 CleanupStack::PopAndDestroy(); // stream |
|
171 } |
|
172 return m_thumbnail; |
|
173 } |
|
174 |
|
175 /** |
|
176 */ |
|
177 void HistoryEntry::deleteThumbnail() |
|
178 { |
|
179 delete m_thumbnail; |
|
180 m_thumbnail = NULL; |
|
181 } |
|
182 |
|
183 /** |
|
184 */ |
|
185 HistoryEntry::~HistoryEntry() |
|
186 { |
|
187 delete m_requestUrl; |
|
188 delete m_responseUrl; |
|
189 delete m_pageTitle; |
|
190 |
|
191 if(m_formData) { |
|
192 m_callback->setUse(false, m_formData); |
|
193 } |
|
194 delete m_thumbnail; |
|
195 delete m_postContentType; |
|
196 delete m_thumbnailBuf; |
|
197 } |
|
198 |
|
199 /** |
|
200 */ |
|
201 HistoryEntry::HistoryEntry() |
|
202 { |
|
203 m_requestUrl = NULL;; |
|
204 m_responseUrl = NULL; |
|
205 m_pageTitle = NULL;; |
|
206 m_position = TPoint(0,0); |
|
207 m_activeBoxId = 0; |
|
208 m_formData = NULL; |
|
209 m_postContentType = NULL; |
|
210 m_thumbnail = NULL; |
|
211 m_creationTime.HomeTime(); |
|
212 m_thumbnailBuf = NULL; |
|
213 m_ifWmlMode = false; |
|
214 } |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 /* |
|
227 |
|
228 void HistoryEntry::SetRequestUrlL (const TDesC& aRequestUrl) |
|
229 { |
|
230 delete m_requestUrl; |
|
231 m_requestUrl = NULL; |
|
232 m_requestUrl = aRequestUrl.AllocL(); |
|
233 } |
|
234 |
|
235 void HistoryEntry::SetResponseUrlL (const TDesC& aResponseUrl) |
|
236 { |
|
237 delete m_responseUrl; |
|
238 m_responseUrl = NULL; |
|
239 m_responseUrl = aResponseUrl.AllocL(); |
|
240 } |
|
241 |
|
242 |
|
243 void HistoryEntry::AddPostData (CPostDataParts* aPostData) |
|
244 { |
|
245 if(iPostData) |
|
246 { |
|
247 iPostData->Deref(); |
|
248 } |
|
249 iPostData = aPostData; |
|
250 if(iPostData) |
|
251 { |
|
252 iPostData->Ref(); |
|
253 } |
|
254 } |
|
255 |
|
256 |
|
257 void HistoryEntry::SetPostContentTypeL (TPtrC8 aPostContentType) |
|
258 { |
|
259 delete m_postContentType; |
|
260 m_postContentType = NULL; |
|
261 // |
|
262 m_postContentType = HBufC::NewL( aPostContentType.Length() ); |
|
263 m_postContentType->Des().Copy( aPostContentType ); |
|
264 } |
|
265 |
|
266 */ |
|
267 // End of File |