2009-09-29 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / plugin / npstream-request.cpp
blobb0fb5fe6bfb83e367cf9777b5915cf355e9e4577
1 /*
2 * npstream-downloader.cpp: NPStream Browser downloader
4 * Contact:
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2008 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
13 #include <config.h>
14 #include "plugin-downloader.h"
15 #include "browser-bridge.h"
16 #include "npstream-request.h"
18 void
19 npstream_request_set_stream_data (Downloader *downloader, NPP npp, NPStream *stream)
21 PluginDownloader *pd = (PluginDownloader *) downloader->GetDownloaderState ();
23 if (pd != NULL) {
24 NPStreamRequest *req = (NPStreamRequest *) pd->getRequest ();
26 if (req != NULL) {
27 req->SetNPP (npp);
28 req->SetStream (stream);
31 stream->pdata = pd;
34 void
35 NPStreamRequest::Abort ()
37 if (npp != NULL && stream != NULL) {
38 NPN_DestroyStream (npp, stream, NPRES_USER_BREAK);
39 stream = NULL;
43 bool
44 NPStreamRequest::GetResponse (DownloaderResponseStartedHandler started, DownloaderResponseDataAvailableHandler available, DownloaderResponseFinishedHandler finished, gpointer context)
46 PluginDownloader *pd = (PluginDownloader *) context;
48 if (instance != NULL) {
49 StreamNotify *notify = new StreamNotify (StreamNotify::DOWNLOADER, pd->dl);
50 NPError err = NPN_GetURLNotify (instance->GetInstance (), uri, NULL, notify);
52 if (err != NPERR_NO_ERROR) {
53 const char *msg;
55 switch (err) {
56 case NPERR_GENERIC_ERROR:
57 msg = "generic error";
58 break;
59 case NPERR_OUT_OF_MEMORY_ERROR:
60 msg = "out of memory";
61 break;
62 case NPERR_INVALID_URL:
63 msg = "invalid url requested";
64 break;
65 case NPERR_FILE_NOT_FOUND:
66 msg = "file not found";
67 break;
68 default:
69 msg = "unknown error";
70 break;
73 pd->dl->NotifyFailed (msg);
74 return false;
76 return true;
78 return false;
81 void
82 NPStreamRequest::SetHttpHeader (const char *name, const char *value)
84 g_warning ("NPStream does not support SetHttpHeader");
87 void
88 NPStreamRequest::SetBody (void *body, int length)
90 g_warning ("NPStream does not support SetBody");