source: titan/titan/pin.h @ 12534

Last change on this file since 12534 was 12534, checked in by obi, 12 years ago

[titan] change all save buttons to ok

File size: 5.2 KB
Line 
1#ifndef PIN_H
2#define PIN_H
3
4//type = 0 (allways)
5//type = 1 (only if channelprotect yes)
6//type = 2 (only if menuprotect yes)
7int screenpincheck(int type, char* pin)
8{
9        if(type == 1)
10        {
11                if(getconfigint("channelprotect", NULL) == 0) return 0;
12                if(time(NULL) < status.protecttime) return 0;
13                if(pin != NULL && ostrcmp(pin, getconfig("pincode", NULL)) == 0) return 0;
14        }
15        if(type == 2 && getconfigint("menuprotect", NULL) == 0) return 0;
16
17        int rcret = 0, ret = 1;
18        struct skin* pincheck = getscreen("pincheck");
19
20        changemask(pincheck, "0000");
21        changeinput(pincheck, "0000");
22
23        drawscreen(pincheck, 0);
24        addscreenrc(pincheck, pincheck);
25
26        while(1)
27        {
28                rcret = waitrc(pincheck, 0, 0);
29       
30                if(rcret == getrcconfigint("rcexit", NULL)) break;
31                if(rcret == getrcconfigint("rcok", NULL))
32                {
33                        if(type == 1)
34                        {
35                                if(ostrcmp(pincheck->ret, getconfig("pincode", NULL)) == 0)
36                                {
37                                        status.protecttime = time(NULL) + (getconfigint("protecttime", NULL) * 60);
38                                        ret = 0;
39                                }
40                        }
41                        else
42                        {
43                                if(ostrcmp(pincheck->ret, getconfig("pincodemenu", NULL)) == 0)
44                                        ret = 0;
45                        }
46                        break;
47                }
48        }
49
50        delownerrc(pincheck);
51        clearscreen(pincheck);
52        drawscreen(skin, 0);
53        return ret;
54}
55
56void screenmenuprotect()
57{
58        int rcret = 0;
59        struct skin* node = skin;
60        struct skin* child = NULL;
61        struct skin* menuprotect = getscreen("menuprotect");
62        struct skin* listbox = getscreennode(menuprotect, "listbox");
63        struct skin* tmp = NULL;
64        char* tmpstr = NULL;
65
66        while(node != NULL)
67        {
68                child = node->child;
69                while(child != NULL)
70                {
71                        if(child->type == MENU)
72                        {
73                                tmp = addlistbox(menuprotect, listbox, tmp, 1);
74                                if(tmp != NULL)
75                                {
76                                        changetext(tmp, child->text);
77                                        changename(tmp, child->name);
78                                        tmp->type = CHOICEBOX;
79                                        tmp->del = 1;
80                                        tmp->height = listbox->fontsize + 2;
81                                        addchoicebox(tmp, "0", _("no"));
82                                        addchoicebox(tmp, "1", _("yes"));
83                                        addchoicebox(tmp, "2", _("hidden"));
84                                        tmpstr = ostrcat("protect_", tmp->name, 0, 0);
85                                        setchoiceboxselection(tmp, getconfig(tmpstr, NULL));
86                                        free(tmpstr);
87                                }
88                        }
89                        child = child->next;
90                }
91                node = node->next;
92        }
93
94        drawscreen(menuprotect, 0);
95        addscreenrc(menuprotect, listbox);
96
97        tmp = listbox->select;
98        while(1)
99        {
100                addscreenrc(menuprotect, tmp);
101                rcret = waitrc(menuprotect, 0, 0);
102                tmp = listbox->select;
103       
104                if(rcret == getrcconfigint("rcexit", NULL)) break;
105                if(rcret == getrcconfigint("rcok", NULL))
106                {
107                        node = menuprotect->child;
108                        while(node != NULL)
109                        {
110                                tmpstr = ostrcat("protect_", node->name, 0, 0);
111                                addconfigscreencheck(tmpstr, node, "0");
112                                free(tmpstr); tmpstr = NULL;
113                                node = node->next;
114                        }
115                        break;
116                }
117        }
118
119        delmarkedscreennodes(menuprotect, 1);
120        delownerrc(menuprotect);
121        clearscreen(menuprotect);
122}
123
124void screenpin()
125{
126        char*tmpstr = NULL;
127
128        tmpstr = ostrcat("protect_", "childprotection", 0, 0);
129        if(getconfigint(tmpstr, NULL) == 0)
130        {
131                int pinret = screenpincheck(0, NULL);
132                if(pinret == 1) return;
133        }
134        free(tmpstr); tmpstr = NULL;
135
136        int rcret = 0;
137        struct skin* pin = getscreen("pin");
138        struct skin* listbox = getscreennode(pin, "listbox");
139        struct skin* pincode = getscreennode(pin, "pincode");
140        struct skin* pincodemenu = getscreennode(pin, "pincodemenu");
141        struct skin* channelprotect = getscreennode(pin, "channelprotect");
142        struct skin* ageprotect = getscreennode(pin, "ageprotect");
143        struct skin* menuprotect = getscreennode(pin, "menuprotect");
144        struct skin* protecttime = getscreennode(pin, "protecttime");
145        struct skin* tmp = NULL;
146
147        changemask(pincodemenu, "0000");
148        changeinput(pincodemenu, getconfig("pincodemenu", NULL));
149
150        changemask(pincode, "0000");
151        changeinput(pincode, getconfig("pincode", NULL));
152
153        addchoicebox(channelprotect, "0", _("no"));
154        addchoicebox(channelprotect, "1", _("yes"));
155        setchoiceboxselection(channelprotect, getconfig("channelprotect", NULL));
156       
157        addchoicebox(protecttime, "0", _("no"));
158        addchoicebox(protecttime, "30", "30");
159        addchoicebox(protecttime, "60", "60");
160        addchoicebox(protecttime, "90", "90");
161        addchoicebox(protecttime, "120", "120");
162        addchoicebox(protecttime, "150", "150");
163        addchoicebox(protecttime, "180", "180");
164        addchoicebox(protecttime, "210", "210");
165        addchoicebox(protecttime, "30000000", _("endless"));
166        setchoiceboxselection(protecttime, getconfig("protecttime", NULL));
167
168        changeinput(ageprotect, "0\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18");
169        setchoiceboxselection(ageprotect, getconfig("ageprotect", NULL));
170
171        addchoicebox(menuprotect, "0", _("no"));
172        addchoicebox(menuprotect, "1", _("yes"));
173        setchoiceboxselection(menuprotect, getconfig("menuprotect", NULL));
174
175        drawscreen(pin, 0);
176        addscreenrc(pin, listbox);
177
178        tmp = listbox->select;
179        while(1)
180        {
181                addscreenrc(pin, tmp);
182                rcret = waitrc(pin, 0, 0);
183                tmp = listbox->select;
184       
185                if(rcret == getrcconfigint("rcexit", NULL)) break;
186                if(rcret == getrcconfigint("rcred", NULL))
187                {
188                        clearscreen(pin);
189                        screenmenuprotect();
190                        drawscreen(pin, 0);
191                }
192                if(rcret == getrcconfigint("rcok", NULL))
193                {
194                        addconfigscreen("pincodemenu", pincodemenu);
195                        addconfigscreen("pincode", pincode);
196                        addconfigscreencheck("channelprotect", channelprotect, "0");
197                        addconfigscreencheck("ageprotect", ageprotect, "0");
198                        addconfigscreencheck("menuprotect", menuprotect, "0");
199                        addconfigscreencheck("protecttime", protecttime, "0");
200                        break;
201                }
202        }
203
204        delownerrc(pin);
205        clearscreen(pin);
206}
207
208#endif
Note: See TracBrowser for help on using the repository browser.