Debian Codegraph @

src/DownloadManager.hpp

raw
1 //Defines the DMPlugin base class, and dm_plugin_loader function
2
3 // For all support, instructions and copyright go to:
4 // http://e2guardian.org/
5 // Released under the GPL v2, with the OpenSSL exception described in the README file.
6
7 #ifndef __HPP_DOWNLOADMANAGER
8 #define __HPP_DOWNLOADMANAGER
9
10 // INCLUDES
11
12 #include "String.hpp"
13 #include "ConfigVar.hpp"
14 #include "Socket.hpp"
15 #include "HTTPHeader.hpp"
16 #include "ListContainer.hpp"
17 #include "FOptionContainer.hpp"
18 #include "DataBuffer.hpp"
19 #include "Plugin.hpp"
20
21 #include <stdexcept>
22
23 // DECLARATIONS
24
25 class DMPlugin;
26
27 // class factory functions for DM plugins
28 typedef DMPlugin *dmcreate_t(ConfigVar &);
29
30 // the DMPlugin interface - inherit & implement this to make download managers
31 class DMPlugin : public Plugin
32 {
33 public:
34 DMPlugin(ConfigVar &definition);
35 virtual ~DMPlugin(){};
36
37 // plugin initialise/quit routines.
38 // if lastplugin is true, this is being loaded as the fallback option,
39 // and needn't load in purely request matching related options.
40 virtual int init(void *args);
41 virtual int quit()
42 {
43 return 0;
44 };
45
46 // will this download manager handle this request?
47 // virtual bool willHandle(HTTPHeader *requestheader, HTTPHeader *docheader);
48
49 // download the body for the given request
50 virtual int in(DataBuffer *d, Socket *sock, Socket *peersock,
51 HTTPHeader *requestheader, HTTPHeader *docheader, bool wantall, int *headersent, bool *toobig)
52 = 0;
53
54 // send a download link to the client (the actual link, and the clean "display" version of the link)
55 virtual bool sendLink(Socket &peersock, String &linkurl, String &prettyurl);
56
57 int story_entry;
58
59 private:
60 // regular expression for matching supported user agents
61 RegExp ua_match;
62 // if there isn't one, set this flag
63 bool alwaysmatchua;
64
65 protected:
66 // our configuration values
67 // derived classes could definitely have a use for these
68 ConfigVar cv;
69
70 // standard lists
71 //ListContainer mimetypelist;
72 //ListContainer extensionlist;
73 // .. and their enable flags
74 //bool mimelistenabled;
75 //bool extensionlistenabled;
76
77
78 // read managedmimetypelist and managedextensionlist
79 //bool readStandardLists();
80 };
81
82 // create an instance of the plugin given in the configuration file
83 DMPlugin *dm_plugin_load(const char *pluginConfigPath);
84
85 #endif