Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * request_dispatcher.h - Web request dispatcher 00004 * 00005 * Created: Mon Oct 13 22:44:33 2008 00006 * Copyright 2006-2010 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __LIBS_WEBVIEW_REQUEST_DISPATCHER_H_ 00024 #define __LIBS_WEBVIEW_REQUEST_DISPATCHER_H_ 00025 00026 #include <string> 00027 #include <map> 00028 #include <stdint.h> 00029 00030 struct MHD_Connection; 00031 struct MHD_Response; 00032 00033 namespace fawkes { 00034 #if 0 /* just to make Emacs auto-indent happy */ 00035 } 00036 #endif 00037 00038 class WebRequestProcessor; 00039 class WebUrlManager; 00040 class WebPageHeaderGenerator; 00041 class WebPageFooterGenerator; 00042 class StaticWebReply; 00043 class WebUserVerifier; 00044 00045 class WebRequestDispatcher 00046 { 00047 public: 00048 WebRequestDispatcher(WebUrlManager *url_manager, 00049 WebPageHeaderGenerator *headergen = 0, 00050 WebPageFooterGenerator *footergen = 0); 00051 ~WebRequestDispatcher(); 00052 00053 static int process_request_cb(void *callback_data, 00054 struct MHD_Connection * connection, 00055 const char *url, 00056 const char *method, 00057 const char *version, 00058 const char *upload_data, 00059 size_t *upload_data_size, 00060 void **session_data); 00061 00062 void setup_basic_auth(const char *realm, WebUserVerifier *verifier); 00063 00064 private: 00065 struct MHD_Response * prepare_static_response(StaticWebReply *sreply); 00066 int queue_static_reply(struct MHD_Connection * connection, 00067 StaticWebReply *sreply); 00068 int queue_basic_auth_fail(struct MHD_Connection * connection); 00069 int process_request(struct MHD_Connection * connection, 00070 const char *url, 00071 const char *method, 00072 const char *version, 00073 const char *upload_data, 00074 size_t *upload_data_size, 00075 void **session_data); 00076 00077 private: 00078 WebUrlManager *__url_manager; 00079 00080 std::string __active_baseurl; 00081 WebPageHeaderGenerator *__page_header_generator; 00082 WebPageFooterGenerator *__page_footer_generator; 00083 00084 char *__realm; 00085 WebUserVerifier *__user_verifier; 00086 }; 00087 00088 } // end namespace fawkes 00089 00090 #endif