29 |
29 |
30 #include "PluginSkin.h" |
30 #include "PluginSkin.h" |
31 #include "PluginStream.h" |
31 #include "PluginStream.h" |
32 #include "PluginHandler.h" |
32 #include "PluginHandler.h" |
33 |
33 |
34 #include "NetScapePlugInStreamLoader.h" |
34 #include "NetscapePlugInStreamLoader.h" |
35 |
35 |
36 using namespace WebCore; |
36 using namespace WebCore; |
37 |
37 |
38 |
38 |
39 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
39 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
40 { |
40 { |
41 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
41 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
42 CleanupStack::PushL( self ); |
42 CleanupStack::PushL( self ); |
43 self->ConstructL( url, pluginskin, frame, notifydata, notify ); |
43 self->ConstructL( url, pluginskin, frame, notifydata ); |
44 CleanupStack::Pop(); |
44 CleanupStack::Pop(); |
45 return self; |
45 return self; |
46 } |
46 } |
47 |
47 |
48 |
48 |
49 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
49 NetscapePlugInStreamLoaderClient* NetscapePlugInStreamLoaderClient::NewL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
50 { |
50 { |
51 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
51 NetscapePlugInStreamLoaderClient* self = new (ELeave) NetscapePlugInStreamLoaderClient(); |
52 CleanupStack::PushL( self ); |
52 CleanupStack::PushL( self ); |
53 |
53 |
54 self->ConstructL( request, pluginskin, frame, notifydata, notify ); |
54 self->ConstructL( request, pluginskin, frame, notifydata ); |
55 |
55 |
56 CleanupStack::Pop(); |
56 CleanupStack::Pop(); |
57 return self; |
57 return self; |
58 } |
58 } |
59 |
59 |
60 void NetscapePlugInStreamLoaderClient::ConstructL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
60 void NetscapePlugInStreamLoaderClient::ConstructL(const String& url, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
61 { |
61 { |
62 m_loader = 0; |
62 m_loader = 0; |
63 m_request = 0; |
63 m_request = 0; |
64 m_pluginstream = 0; |
64 m_pluginstream = 0; |
65 m_pluginskin = pluginskin; |
|
66 m_notifydata = notifydata; |
|
67 m_frame = frame; |
65 m_frame = frame; |
68 m_notify = notify; |
|
69 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
66 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
70 m_request = new (ELeave) ResourceRequest(m_frame->loader()->completeURL(url)); |
67 m_request = new (ELeave) ResourceRequest(m_frame->loader()->completeURL(url)); |
71 |
68 |
72 if ( !m_frame->loader()->canLoad(m_request->url(), frame->document()) ) |
69 if ( !m_frame->loader()->canLoad(m_request->url(), frame->document()) ) |
73 return; |
70 return; |
79 m_loader = NetscapePlugInStreamLoader::create(frame,this); |
76 m_loader = NetscapePlugInStreamLoader::create(frame,this); |
80 if (m_loader) |
77 if (m_loader) |
81 m_loader->setShouldBufferData(false); |
78 m_loader->setShouldBufferData(false); |
82 } |
79 } |
83 |
80 |
84 void NetscapePlugInStreamLoaderClient::ConstructL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata, TBool notify/*=EFalse*/) |
81 void NetscapePlugInStreamLoaderClient::ConstructL(const ResourceRequest& request, PluginSkin* pluginskin, Frame* frame, void* notifydata) |
85 { |
82 { |
86 |
83 |
87 m_loader = 0; |
84 m_loader = 0; |
88 m_request = 0; |
85 m_request = 0; |
89 m_pluginstream = 0; |
86 m_pluginstream = 0; |
90 m_pluginskin = pluginskin; |
|
91 m_notifydata = notifydata; |
|
92 m_frame = frame; |
87 m_frame = frame; |
93 m_notify = notify; |
|
94 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
88 m_pluginstream = new (ELeave) PluginStream(pluginskin, this, notifydata); |
95 m_request = new (ELeave) ResourceRequest(request.url()); |
89 m_request = new (ELeave) ResourceRequest(request.url()); |
96 |
90 |
97 m_request->setCachePolicy(request.cachePolicy()); |
91 m_request->setCachePolicy(request.cachePolicy()); |
98 m_request->setTimeoutInterval(request.timeoutInterval()); |
92 m_request->setTimeoutInterval(request.timeoutInterval()); |
153 m_loader->cancel(); |
145 m_loader->cancel(); |
154 } |
146 } |
155 |
147 |
156 void NetscapePlugInStreamLoaderClient::cancelWithError(const ResourceError& error) |
148 void NetscapePlugInStreamLoaderClient::cancelWithError(const ResourceError& error) |
157 { |
149 { |
158 if (m_loader && !m_loader->isDone()){ |
150 if (m_loader && !m_loader->isDone()) |
159 m_loader->cancel(error); |
151 m_loader->cancel(error); |
160 } |
152 } |
161 } |
|
162 |
153 |
163 void NetscapePlugInStreamLoaderClient::didReceiveResponse(const ResourceResponse& response) |
154 void NetscapePlugInStreamLoaderClient::didReceiveResponse(const ResourceResponse& response) |
164 { |
155 { |
165 int status = response.httpStatusCode(); |
156 int status = response.httpStatusCode(); |
166 if (status < 200 || status >= 300) { |
157 if (status < 200 || status >= 300) { |
167 cancelWithError(ResourceError(String(response.url()), KErrGeneral, String(response.url()), String(response.httpStatusText()))); |
158 cancelWithError(ResourceError(String(response.url()), KErrGeneral, String(response.url()), String(response.httpStatusText()))); |
168 return; |
159 return; |
169 } |
160 } |
170 |
161 |
171 // Currently we fill only response encoding type in the header field of NPStream structure, as url,MimeType and content-Length |
|
172 // are already a part of NPStream Structure |
|
173 |
|
174 HBufC8* headerPtr = HBufC8::NewLC(response.textEncodingName().length() + 1); |
|
175 headerPtr->Des().Copy(response.textEncodingName().des()); |
|
176 headerPtr->Des().Append('\0'); |
|
177 const char* headers = (const char*)headerPtr->Ptr(); |
|
178 |
|
179 if (m_pluginstream) { |
162 if (m_pluginstream) { |
180 TRAP(m_error, m_pluginstream->createNPStreamL(response.url().des(), response.mimeType().des(), response.expectedContentLength(), headers)); |
163 TRAP(m_error, m_pluginstream->createNPStreamL(response.url().des(), response.mimeType().des(), response.expectedContentLength())); |
181 } |
164 } |
182 |
165 |
183 CleanupStack::PopAndDestroy(headerPtr); |
|
184 } |
166 } |
185 |
167 |
186 void NetscapePlugInStreamLoaderClient::didReceiveData(const char* data, int length, long long lengthReceived) |
168 void NetscapePlugInStreamLoaderClient::didReceiveData(const char* data, int length, long long lengthReceived) |
187 { |
169 { |
188 |
170 |
207 } |
189 } |
208 |
190 |
209 void NetscapePlugInStreamLoaderClient::didFail(const ResourceError& error) |
191 void NetscapePlugInStreamLoaderClient::didFail(const ResourceError& error) |
210 { |
192 { |
211 if (m_pluginstream) { |
193 if (m_pluginstream) { |
212 int err = error.errorCode() ? error.errorCode() : KErrCancel; |
194 m_pluginstream->destroyStream(error.errorCode() ? error.errorCode() : KErrCancel); |
213 HBufC* failedURL = HBufC::NewLC(error.failingURL().length()); |
|
214 failedURL->Des().Copy(error.failingURL()); |
|
215 m_pluginstream->destroyStream(err, failedURL); |
|
216 CleanupStack::PopAndDestroy(failedURL); |
|
217 } |
195 } |
218 } |
196 } |
219 |
197 |
220 void NetscapePlugInStreamLoaderClient::didCancel(const ResourceError& error) |
198 void NetscapePlugInStreamLoaderClient::didCancel(const ResourceError& error) |
221 { |
199 { |
222 if (m_pluginstream) { |
200 if (m_pluginstream) { |
223 int err = error.errorCode() ? error.errorCode() : KErrCancel; |
201 m_pluginstream->destroyStream(error.errorCode() ? error.errorCode() : KErrCancel); |
224 HBufC* failedURL = HBufC::NewLC(error.failingURL().length()); |
202 } |
225 failedURL->Des().Copy(error.failingURL()); |
203 } |
226 m_pluginstream->destroyStream(err, failedURL); |
204 |
227 CleanupStack::PopAndDestroy(failedURL); |
205 |
228 } |
206 |
229 } |
207 |
230 |
208 |
231 |
209 |
232 |
|
233 |
|
234 |
|
235 |
|