2009-11-13 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / plugin / plugin-downloader.h
blob53d34360c40b6e08854d4ee15b7f1872815c802b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * plugin-downloader.h: Plugin downloader
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #ifndef __PLUGIN_DOWNLOADER_H__
15 #define __PLUGIN_DOWNLOADER_H__
17 class PluginDownloader;
19 #include "moonlight.h"
20 #include "runtime.h"
21 #include "downloader.h"
22 #include "plugin.h"
23 #include "plugin-class.h"
26 G_BEGIN_DECLS
28 guint32 plugin_downloader_started (DownloaderResponse *response, gpointer state);
29 guint32 plugin_downloader_available (DownloaderResponse *response, gpointer state, char *buffer, guint32 length);
30 guint32 plugin_downloader_finished (DownloaderResponse *response, gpointer state, gpointer data);
32 G_END_DECLS
34 class PluginDownloader {
35 private:
36 DownloaderResponse *response;
37 DownloaderRequest *request;
38 DownloaderResponseHeaderCallback response_header_callback;
39 gpointer response_header_context;
40 uint64_t offset;
41 bool finished;
43 protected:
44 char *uri;
45 char *verb;
47 public:
48 PluginDownloader (Downloader *dl);
49 virtual ~PluginDownloader ();
51 void Abort ();
52 void Open (const char *verb, const char *uri, bool custom_header_support, bool disable_cache);
53 void Send ();
55 guint32 Read (char *buffer, guint32 length);
56 void Started ();
57 void Finished (bool success, gpointer data, const char *uri);
59 void SetHttpHeader (const char *header, const char *value);
60 void SetBody (void *body, guint32 length);
62 void SetResponseHeaderCallback (DownloaderResponseHeaderCallback callback, gpointer context);
64 PluginInstance *GetPlugin ();
66 void setResponse (DownloaderResponse *response);
67 DownloaderResponse *getResponse () { return response; }
68 DownloaderRequest *getRequest ();
70 Downloader *dl;
73 void npstream_request_set_stream_data (Downloader *downloader, NPP npp, NPStream *stream);
74 void downloader_initialize (void);
75 void downloader_destroy (void);
77 #endif // __PLUGIN_DOWNLOADER_H__