]> icculus.org git repositories - duncan/yast2-web-wt.git/blob - src/YWebUIComponent.h
crap
[duncan/yast2-web-wt.git] / src / YWebUIComponent.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQUIComponent.h
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16                 Stanislav Visnovsky <visnov@suse.cz>
17
18 /-*/
19
20 #ifndef YWebUIComponent_h
21 #define YWebUIComponent_h
22
23 #include <YUIComponent.h>
24
25 #define y2log_component "web-ui"
26 #include <ycp/y2log.h>
27
28 #include "YWebUI.h"
29
30 extern void *start_webserver_thread( void * yui );
31
32 class YWebUIComponent :  public YUIComponent
33 {
34 public:
35
36     YWebUIComponent(): YUIComponent() {}
37
38     /**
39      * Create a Web UI. This is called from within setServerOptions().
40      *
41      * Reimplemented from YUIComponent.
42      **/
43     virtual YUI * createUI( int argc, char **argv, bool with_threads, const char * macro_file )
44     {
45         // save the arguments for the UI thread (http server args etc)
46         YWebUI::_argc = argc;
47         YWebUI::_argv = argv;
48
49         pthread_t webserver_thread;
50         pthread_attr_t attr;
51         pthread_attr_init( & attr );
52
53         if( pthread_create( & webserver_thread, & attr, start_webserver_thread, 0 ) > 0 )
54         {
55             y2internal ("Could not create Web server thread, aborting");
56             abort();
57         }
58
59         y2milestone( "Server thread running");
60
61         // wait until the UI thread is ready
62         while (! YWebUI::ui() )
63         {
64             sleep( 1 );
65         }
66         return YWebUI::ui(); 
67     }
68
69     /**
70      * Returns the name of this YaST2 component.
71      *
72      * Reimplemented from YUIComponent.
73      **/
74     virtual string name() const { return "web"; }
75
76 };
77
78
79 #endif // YWebUIComponent_h