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