source: titan/titan/httpdsettings.h @ 24222

Last change on this file since 24222 was 20194, checked in by nit, 11 years ago

[titan] add extern ip for webif

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