source: titan/titan/httpdsettings.h @ 15349

Last change on this file since 15349 was 14651, checked in by nit, 12 years ago

[titan] add config rgui server

File size: 3.8 KB
Line 
1#ifndef HTTDPSETTINGS_H
2#define HTTPDSETTINGS_H
3
4void screenhttpdsettings()
5{
6        int rcret = 0, i = 0;
7        struct skin* httpdsettings = getscreen("httpdsettings");
8        struct skin* listbox = getscreennode(httpdsettings, "listbox");
9        struct skin* httpdstart = getscreennode(httpdsettings, "httpdstart");
10        struct skin* user = getscreennode(httpdsettings, "user");
11        struct skin* password = getscreennode(httpdsettings, "password");
12        struct skin* httpdport = getscreennode(httpdsettings, "httpdport");
13        struct skin* streamport = getscreennode(httpdsettings, "streamport");
14        struct skin* rguidstart = getscreennode(httpdsettings, "rguidstart");
15        struct skin* rguidport = getscreennode(httpdsettings, "rguidport");
16        struct skin* tmp = NULL;
17        char* tmpstr = NULL, *pos = NULL;
18
19        addchoicebox(httpdstart, "0", _("no"));
20        addchoicebox(httpdstart, "1", _("yes"));
21        setchoiceboxselection(httpdstart, getconfig("httpdstart", NULL));
22
23        tmpstr = ostrcat(getconfig("httpauth", NULL), NULL, 0, 0);
24        if(tmpstr != NULL)
25        {
26                pos = strstr(tmpstr, ":");
27                if(pos != NULL)
28                {
29                        pos[0] = '\0';
30                        changeinput(user, tmpstr);
31                        pos++;
32                        changeinput(password, pos);
33                }
34        }
35        free(tmpstr); tmpstr = NULL;
36
37        changemask(httpdport, "00000");
38        changeinput(httpdport, getconfig("httpdport", NULL));
39        if(httpdport->input != NULL)
40        {
41                for(i = 0; i < 6 - strlen(httpdport->input); i++)
42                        httpdport->input = ostrcat("0", httpdport->input, 0, 1);
43        }
44
45        changemask(streamport, "00000");
46        changeinput(streamport, getconfig("streamport", NULL));
47        if(streamport->input != NULL)
48        {
49                for(i = 0; i < 6 - strlen(streamport->input); i++)
50                        streamport->input = ostrcat("0", streamport->input, 0, 1);
51        }
52       
53        addchoicebox(rguidstart, "0", _("no"));
54        addchoicebox(rguidstart, "1", _("yes"));
55        setchoiceboxselection(rguidstart, getconfig("rguidstart", NULL));
56
57        changemask(rguidport, "00000");
58        changeinput(rguidport, getconfig("rguidport", NULL));
59        if(rguidport->input != NULL)
60        {
61                for(i = 0; i < 6 - strlen(rguidport->input); i++)
62                        rguidport->input = ostrcat("0", rguidport->input, 0, 1);
63        }
64
65        drawscreen(httpdsettings, 0);
66        addscreenrc(httpdsettings, listbox);
67
68        tmp = listbox->select;
69        while(1)
70        {
71                addscreenrc(httpdsettings, tmp);
72                rcret = waitrc(httpdsettings, 0, 0);
73                tmp = listbox->select;
74
75                if(rcret == getrcconfigint("rcexit", NULL)) break;
76                if(rcret == getrcconfigint("rcok", NULL))
77                {
78                        if(httpdstart->ret != NULL)
79                        {
80                                if(ostrcmp(getconfig("httpdstart", NULL), httpdstart->ret) != 0)
81                                {
82                                        addconfigscreen("httpdstart", httpdstart);
83                                        if(ostrcmp(httpdstart->ret, "0") == 0)
84                                                starthttpd(0);
85                                        else
86                                                starthttpd(1);
87                                }
88                        }
89                        if(user->ret != NULL && password->ret != NULL && strlen(user->ret) > 0 && strlen(password->ret) > 0)
90                        {
91                                tmpstr = ostrcat(tmpstr, user->ret, 1, 0);
92                                tmpstr = ostrcat(tmpstr, ":", 1, 0);
93                                tmpstr = ostrcat(tmpstr, password->ret, 1, 0);
94                                addconfig("httpauth", tmpstr);
95                                free(tmpstr); tmpstr = NULL;
96                        }
97                        else
98                                delconfig("httpauth");
99                        free(status.httpauth);
100                        status.httpauth = ostrcat(getconfig("httpauth", NULL), NULL, 0, 0);
101                        if(httpdport->ret != NULL)
102                        {
103                                int hport = atoi(httpdport->ret);
104                                if(hport != 80)
105                                        addconfigint("httpdport", hport);
106                        }
107                        if(streamport->ret != NULL)
108                        {
109                                int sport = atoi(streamport->ret);
110                                if(sport != 22222)
111                                        addconfigint("streamport", sport);
112                        }
113                        if(rguidstart->ret != NULL)
114                        {
115                                if(ostrcmp(getconfig("rguidstart", NULL), rguidstart->ret) != 0)
116                                {
117                                        addconfigscreen("rguidstart", rguidstart);
118                                        if(ostrcmp(rguidstart->ret, "0") == 0)
119                                                startrguid(0);
120                                        else
121                                                startrguid(1);
122                                }
123                        }
124                        if(rguidport->ret != NULL)
125                        {
126                                int rport = atoi(rguidport->ret);
127                                if(rport != 22233)
128                                        addconfigint("rguidport", rport);
129                        }
130                        break;
131                }
132        }
133
134        delownerrc(httpdsettings);
135        clearscreen(httpdsettings);
136}
137
138#endif
Note: See TracBrowser for help on using the repository browser.