Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
server.h
1 
2 /***************************************************************************
3  * server.h - Web server encapsulation around libmicrohttpd
4  *
5  * Created: Sun Aug 30 17:38:37 2009
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __LIBS_WEBVIEW_SERVER_H_
24 #define __LIBS_WEBVIEW_SERVER_H_
25 
26 #include <sys/types.h>
27 
28 struct MHD_Daemon;
29 
30 namespace fawkes {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 class Logger;
36 class WebRequestDispatcher;
37 class WebUserVerifier;
38 
39 class WebServer {
40  public:
41  WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
42  fawkes::Logger *logger = 0);
43  WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
44  const char *key_pem_filepath, const char *cert_pem_filepath,
45  fawkes::Logger *logger = 0);
46  ~WebServer();
47 
48  void process();
49 
50  void setup_basic_auth(const char *realm, WebUserVerifier *verifier);
51 
52  private:
53  static char * read_file(const char *filename);
54 
55  private:
56  struct MHD_Daemon *__daemon;
57  WebRequestDispatcher *__dispatcher;
58  fawkes::Logger *__logger;
59 
60  unsigned short int __port;
61 
62  char *__ssl_key_mem;
63  char *__ssl_cert_mem;
64 };
65 
66 } // end namespace fawkes
67 
68 #endif