2 * npstream-downloader.cpp: NPStream Browser downloader
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.
14 #include "plugin-downloader.h"
15 #include "browser-bridge.h"
16 #include "npstream-request.h"
19 npstream_request_set_stream_data (Downloader
*downloader
, NPP npp
, NPStream
*stream
)
21 PluginDownloader
*pd
= (PluginDownloader
*) downloader
->GetDownloaderState ();
24 NPStreamRequest
*req
= (NPStreamRequest
*) pd
->getRequest ();
28 req
->SetStream (stream
);
35 NPStreamRequest::Abort ()
37 if (npp
!= NULL
&& stream
!= NULL
) {
38 NPN_DestroyStream (npp
, stream
, NPRES_USER_BREAK
);
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
) {
56 case NPERR_GENERIC_ERROR
:
57 msg
= "generic error";
59 case NPERR_OUT_OF_MEMORY_ERROR
:
60 msg
= "out of memory";
62 case NPERR_INVALID_URL
:
63 msg
= "invalid url requested";
65 case NPERR_FILE_NOT_FOUND
:
66 msg
= "file not found";
69 msg
= "unknown error";
73 pd
->dl
->NotifyFailed (msg
);
82 NPStreamRequest::SetHttpHeader (const char *name
, const char *value
)
84 g_warning ("NPStream does not support SetHttpHeader");
88 NPStreamRequest::SetBody (void *body
, int length
)
90 g_warning ("NPStream does not support SetBody");