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-2008 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 __PLUGINS_WEBVIEW_REQUEST_DISPATCHER_H_ 00024 #define __PLUGINS_WEBVIEW_REQUEST_DISPATCHER_H_ 00025 00026 #include <string> 00027 #include <map> 00028 #include <stdint.h> 00029 00030 struct MHD_Connection; 00031 00032 namespace fawkes { 00033 #if 0 /* just to make Emacs auto-indent happy */ 00034 } 00035 #endif 00036 00037 class WebRequestProcessor; 00038 class WebPageHeaderGenerator; 00039 class WebPageFooterGenerator; 00040 class StaticWebReply; 00041 00042 class WebRequestDispatcher 00043 { 00044 public: 00045 WebRequestDispatcher(WebPageHeaderGenerator *headergen = 0, 00046 WebPageFooterGenerator *footergen = 0); 00047 00048 void add_processor(const char *url_prefix, WebRequestProcessor *processor); 00049 void remove_processor(const char *url_prefix); 00050 00051 00052 static int process_request_cb(void *callback_data, 00053 struct MHD_Connection * connection, 00054 const char *url, 00055 const char *method, 00056 const char *version, 00057 const char *upload_data, 00058 size_t *upload_data_size, 00059 void **session_data); 00060 00061 int queue_static_reply(struct MHD_Connection * connection, 00062 StaticWebReply *sreply); 00063 int process_request(struct MHD_Connection * connection, 00064 const char *url, 00065 const char *method, 00066 const char *version, 00067 const char *upload_data, 00068 size_t *upload_data_size, 00069 void **session_data); 00070 00071 private: 00072 std::map<std::string, WebRequestProcessor *> __processors; 00073 WebRequestProcessor *__startpage_processor; 00074 00075 std::string __active_baseurl; 00076 WebPageHeaderGenerator *__page_header_generator; 00077 WebPageFooterGenerator *__page_footer_generator; 00078 }; 00079 00080 } // end namespace fawkes 00081 00082 #endif