From 8402c30a6e31928d7e2352d2e3b3360fdaad8222 Mon Sep 17 00:00:00 2001 From: dmacvicar Date: Tue, 13 Nov 2007 13:34:26 +0000 Subject: [PATCH] - move the UICOmponent functions to its own fle disable creating a separate thread for now git-svn-id: http://svn.opensuse.org/svn/yast/branches/tmp/sh/mod-ui/web-wt@42015 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/CMakeLists.txt | 2 +- src/YWebUI.h | 4 ++++ src/YWebUIComponent.cc | 41 +++++++++++++++++++++++++++++++++++++++++ src/YWebUIComponent.h | 32 +++----------------------------- 4 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 src/YWebUIComponent.cc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86b9d91..1ec4cf3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ SET(yast_web_module_SRCS ) SET(web_yast_plugin_SRCS - Y2CCWeb.cc YWebApplication.cc YWebDialog.cc YWebPushButton.cc YWebLabel.cc YWebUI_builtins.cc YWebUI_core.cc YWebUI_widgets.cc YWebWidgetFactory.cc + Y2CCWeb.cc YWebApplication.cc YWebDialog.cc YWebPushButton.cc YWebLabel.cc YWebUIComponent.cc YWebUI_builtins.cc YWebUI_core.cc YWebUI_widgets.cc YWebWidgetFactory.cc ) SET(web_yast_plugin_HEADERS diff --git a/src/YWebUI.h b/src/YWebUI.h index 287b077..3b97bc7 100644 --- a/src/YWebUI.h +++ b/src/YWebUI.h @@ -24,6 +24,7 @@ #include #include +#include class YEvent; class YWebOptionalWidgetFactory; @@ -33,6 +34,9 @@ using std::string; using std::vector; +Wt::WApplication *createApplication(const Wt::WEnvironment& env); +void *start_webserver_thread( void * yui ); + class YWebUI: public Wt::WApplication, public YUI { public: diff --git a/src/YWebUIComponent.cc b/src/YWebUIComponent.cc new file mode 100644 index 0000000..32c84bf --- /dev/null +++ b/src/YWebUIComponent.cc @@ -0,0 +1,41 @@ + +#include "YWebUIComponent.h" +#include "YWebUI.h" + +YWebUIComponent::YWebUIComponent() + : YUIComponent() +{ + +} + +YUI * YWebUIComponent::createUI( int argc, char **argv, bool with_threads, const char * macro_file ) +{ + // save the arguments for the UI thread (http server args etc) + YWebUI::_argc = argc; + YWebUI::_argv = argv; + + + WRun(YWebUI::_argc, YWebUI::_argv, &createApplication); + return YWebUI::ui(); + + pthread_t webserver_thread; + pthread_attr_t attr; + pthread_attr_init( & attr ); + + if( pthread_create( & webserver_thread, & attr, start_webserver_thread, 0 ) > 0 ) + { + y2internal ("Could not create Web server thread, aborting"); + abort(); + } + + y2milestone( "Server thread running"); + + // wait until the UI thread is ready + while (! YWebUI::ui() ) + { + sleep( 1 ); + } + return YWebUI::ui(); +} + +string YWebUIComponent::name() const { return "web"; } \ No newline at end of file diff --git a/src/YWebUIComponent.h b/src/YWebUIComponent.h index 87afaf8..5036b36 100644 --- a/src/YWebUIComponent.h +++ b/src/YWebUIComponent.h @@ -27,51 +27,25 @@ #include "YWebUI.h" -extern void *start_webserver_thread( void * yui ); - class YWebUIComponent : public YUIComponent { public: - YWebUIComponent(): YUIComponent() {} + YWebUIComponent(); /** * Create a Web UI. This is called from within setServerOptions(). * * Reimplemented from YUIComponent. **/ - virtual YUI * createUI( int argc, char **argv, bool with_threads, const char * macro_file ) - { - // save the arguments for the UI thread (http server args etc) - YWebUI::_argc = argc; - YWebUI::_argv = argv; - - pthread_t webserver_thread; - pthread_attr_t attr; - pthread_attr_init( & attr ); - - if( pthread_create( & webserver_thread, & attr, start_webserver_thread, 0 ) > 0 ) - { - y2internal ("Could not create Web server thread, aborting"); - abort(); - } - - y2milestone( "Server thread running"); - - // wait until the UI thread is ready - while (! YWebUI::ui() ) - { - sleep( 1 ); - } - return YWebUI::ui(); - } + virtual YUI * createUI( int argc, char **argv, bool with_threads, const char * macro_file ); /** * Returns the name of this YaST2 component. * * Reimplemented from YUIComponent. **/ - virtual string name() const { return "web"; } + virtual string name() const; }; -- 2.39.2