source: titan/titan/moduleconfig.h @ 32089

Last change on this file since 32089 was 28436, checked in by obi, 10 years ago

step 2 cleanup

File size: 14.3 KB
Line 
1#ifndef MODULECONFIG_H
2#define MODULECONFIG_H
3
4void createchannelslotlist(struct skin* channelslotlist, struct skin* listbox, int slot)
5{
6        struct channelslot *node = channelslot;
7        struct skin* tmp = NULL;
8
9        while(node != NULL)
10        {
11                if(node->slot == slot)
12                {
13                        struct channel* chnode = getchannel(node->serviceid, node->transponderid);
14                        if(chnode != NULL)
15                        {
16                                tmp = addlistbox(channelslotlist, listbox, tmp, 1);
17                                if(tmp != NULL)
18                                {
19                                        changetext(tmp, chnode->name);
20                                        tmp->handle = (char*)node;
21                                }
22                        }
23                }
24                node = node->next;
25        }
26}
27
28void screenchannelslot(int slot)
29{
30        int rcret = 0;
31        struct skin* channelslotlist = getscreen("channelslotlist");
32        struct skin* listbox = getscreennode(channelslotlist, "listbox");
33        char* tmpstr = NULL, *tmpchannellist = NULL;
34
35        if(status.servicetype == 0)
36                tmpchannellist = ostrcat(getconfig("channellist", NULL), NULL, 0, 0);
37        else
38                tmpchannellist = ostrcat(getconfig("rchannellist", NULL), NULL, 0, 0);
39
40        channelslotlist->aktline = 1;
41        channelslotlist->aktpage = -1;
42
43        createchannelslotlist(channelslotlist, listbox, slot);
44
45        drawscreen(channelslotlist, 0, 0);
46        addscreenrc(channelslotlist, listbox);
47
48        while(1)
49        {
50                rcret = waitrc(channelslotlist, 0, 0);
51
52                if(rcret == getrcconfigint("rcok", NULL)) break;
53                if(rcret == getrcconfigint("rcred", NULL) && listbox->select != NULL && listbox->select->handle != NULL)
54                {
55                        if(delchannelslot(((struct channelslot*)listbox->select->handle)->serviceid, ((struct channelslot*)listbox->select->handle)->transponderid) == 0)
56                        {
57                                listbox->aktline--;
58                                listbox->aktpage = -1;
59                                delmarkedscreennodes(channelslotlist, 1);
60                                createchannelslotlist(channelslotlist, listbox, slot);
61                                drawscreen(channelslotlist, 0, 0);
62                        }
63                }
64                if(rcret == getrcconfigint("rcgreen", NULL))
65                {
66                        clearscreen(channelslotlist);
67                        int saveservicetype = status.servicetype;
68                        struct channel* tmpchnode = NULL;
69
70                        screenchannellist(&tmpchnode, &tmpchannellist, 1);
71                        status.servicetype = saveservicetype;
72
73                        if(tmpchnode != NULL && getchannelslot(tmpchnode->serviceid, tmpchnode->transponderid) == NULL)
74                        {
75                                tmpstr = ostrcat(oitoa(tmpchnode->transponderid), "#", 1, 0);
76                                tmpstr = ostrcat(tmpstr, ollutoa(tmpchnode->serviceid), 1, 1);
77                                tmpstr = ostrcat(tmpstr, "#", 1, 0);
78                                tmpstr = ostrcat(tmpstr, oitoa(slot), 1, 1);
79                                if(addchannelslot(tmpstr, 1, NULL) != NULL)
80                                {
81                                        delmarkedscreennodes(channelslotlist, 1);
82                                        createchannelslotlist(channelslotlist, listbox, slot);
83                                }
84                                free(tmpstr); tmpstr = NULL;
85                        }
86
87                        drawscreen(channelslotlist, 0, 0);
88                }
89                if(rcret == getrcconfigint("rcyellow", NULL))
90                {
91                        clearscreen(channelslotlist);
92                        struct mainbouquet* mbouquet = screenmainbouquet();
93                       
94                        mainbouquet2channelslot(mbouquet, slot);
95                        delmarkedscreennodes(channelslotlist, 1);
96                        createchannelslotlist(channelslotlist, listbox, slot);
97                       
98                        drawscreen(channelslotlist, 0, 0);
99                }
100        }
101
102        delmarkedscreennodes(channelslotlist, 1);
103        delownerrc(channelslotlist);
104        clearscreen(channelslotlist);
105}
106
107int checkdoublecaid(struct dvbdev* excdvbnode, char* caid)
108{
109        struct dvbdev* dvbnode = dvbdev;
110
111        if(caid == NULL) return 0;
112
113        while(dvbnode != NULL)
114        {
115                if(dvbnode->type == CIDEV && dvbnode->caslot != NULL && dvbnode->caslot->caids != NULL && dvbnode != excdvbnode)
116                {
117                        if(ostrstr(dvbnode->caslot->caids, caid) != NULL)
118                                return 1;
119
120                }
121                dvbnode = dvbnode->next;
122        }
123        return 0;
124}
125
126void screencaidlock(struct dvbdev* dvbnode)
127{
128        int rcret = -1, count = 0, i = 0;
129        struct skin* caidlock = getscreen("caidlock");
130        struct skin* listbox = getscreennode(caidlock, "listbox");
131        struct skin* tmp = NULL;
132        char* tmpstr = NULL, *configname = NULL, *caids = NULL;
133        struct splitstr* ret = NULL;
134
135        listbox->aktline = 1;
136        listbox->aktpage = -1;
137
138        if(dvbnode == NULL || dvbnode->caslot == NULL || dvbnode->caslot->caids == NULL) return;
139
140        configname = ostrcat("camblacklist_", oitoa(dvbnode->devnr), 0, 1);
141        char* lockcaids = getconfig(configname, NULL);
142
143        caids = ostrcat(dvbnode->caslot->caids, NULL, 0, 0);
144        ret = strsplit(caids, "#", &count);
145
146        if(ret != NULL)
147        {
148                for(i = 0; i < count; i++)
149                {
150                        tmp = addlistbox(caidlock, listbox, tmp, 1);
151                        if(tmp != NULL)
152                        {
153                                tmp->type = CHOICEBOX;
154
155                                if(checkdoublecaid(dvbnode, ret[i].part) == 1)
156                                {
157                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
158                                        tmpstr = ostrcat(tmpstr, " (", 1, 0);
159                                        tmpstr = ostrcat(tmpstr, _("double"), 1, 0);
160                                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
161                                }
162                                else
163                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
164
165                                changetext(tmp, tmpstr);
166                                free(tmpstr); tmpstr = NULL;
167
168                                addchoicebox(tmp, "0", _("activate"));
169                                addchoicebox(tmp, "1", _("deaktivate"));
170                                if(ostrstr(lockcaids, ret[i].part) != NULL)
171                                        setchoiceboxselection(tmp, "1");
172                                else
173                                        setchoiceboxselection(tmp, "0");
174                                changename(tmp, ret[i].part);
175                        }
176                }
177        }
178
179        free(caids); caids = NULL;
180        free(ret); ret = NULL;
181        drawscreen(caidlock, 0, 0);
182        addscreenrc(caidlock, listbox);
183
184        tmp = listbox->select;
185        while(1)
186        {
187                addscreenrc(caidlock, tmp);
188                rcret = waitrc(caidlock, 0, 0);
189                tmp = listbox->select;
190
191                if(rcret == getrcconfigint("rcexit", NULL)) break;
192                if(rcret == getrcconfigint("rcok", NULL))
193                {
194                        tmp = listbox;
195                        while(tmp != NULL)
196                        {
197                                if(tmp->del == 1 && ostrcmp(tmp->ret, "1") == 0)
198                                {
199                                        tmpstr = ostrcat(tmpstr, "#", 1, 0);
200                                        tmpstr = ostrcat(tmpstr, tmp->name, 1, 0);
201                                        tmpstr = ostrcat(tmpstr, "#", 1, 0);
202                                }
203                                tmp = tmp->next;
204                        }
205
206                        if(tmpstr != NULL)
207                                addconfig(configname, tmpstr);
208                        else
209                                delconfig(configname);
210
211                        free(tmpstr); tmpstr = NULL;
212                        break;
213                }
214        }
215
216        free(configname); configname = NULL;
217        delmarkedscreennodes(caidlock, 1);
218        delownerrc(caidlock);
219        clearscreen(caidlock);
220}
221
222void screenmoduleadjust()
223{
224        int rcret = 0;
225
226        struct skin* moduleadjust = getscreen("moduleadjust");
227        struct skin* listbox = getscreennode(moduleadjust, "listbox");
228        struct skin* nocamsg = getscreennode(moduleadjust, "nocamsg");
229        struct skin* camwait = getscreennode(moduleadjust, "camwait");
230        struct skin* checkcamdecrypt = getscreennode(moduleadjust, "checkcamdecrypt");
231        struct skin* caskipprivat = getscreennode(moduleadjust, "caskipprivat");
232        struct skin* casendallcaids = getscreennode(moduleadjust, "casendallcaids");
233        struct skin* extmoduldetect = getscreennode(moduleadjust, "extmoduldetect");
234
235        struct skin* tmp = NULL;
236
237        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
238                extmoduldetect->hidden = NO;
239        else
240                extmoduldetect->hidden = YES;
241
242        addchoicebox(nocamsg, "0", _("yes"));
243        addchoicebox(nocamsg, "1", _("no"));
244        setchoiceboxselection(nocamsg, getconfig("nocamsg", NULL));
245
246        addchoicebox(camwait, "25", _("slow"));
247        addchoicebox(camwait, "15", _("middle"));
248        addchoicebox(camwait, "5", _("fast"));
249        setchoiceboxselection(camwait, getconfig("camwait", NULL));
250
251        addchoicebox(checkcamdecrypt, "0", _("no"));
252        addchoicebox(checkcamdecrypt, "1", _("yes"));
253        setchoiceboxselection(checkcamdecrypt, getconfig("checkcamdecrypt", NULL));
254
255        addchoicebox(caskipprivat, "0", _("no"));
256        addchoicebox(caskipprivat, "1", _("yes"));
257        setchoiceboxselection(caskipprivat, getconfig("caskipprivat", NULL));
258
259        addchoicebox(casendallcaids, "0", _("no"));
260        addchoicebox(casendallcaids, "1", _("yes"));
261        setchoiceboxselection(casendallcaids, getconfig("casendallcaids", NULL));
262
263        addchoicebox(extmoduldetect, "0", _("no"));
264        addchoicebox(extmoduldetect, "1", _("yes"));
265        setchoiceboxselection(extmoduldetect, getownconfig("extmoduldetect"));
266
267        drawscreen(moduleadjust, 0, 0);
268        addscreenrc(moduleadjust, listbox);
269
270        tmp = listbox->select;
271        while(1)
272        {
273                addscreenrc(moduleadjust, tmp);
274                rcret = waitrc(moduleadjust, 0, 0);
275                tmp = listbox->select;
276
277                if(rcret == getrcconfigint("rcexit", NULL)) break;
278                if(rcret == getrcconfigint("rcok", NULL))
279                {
280                        addconfigscreencheck("nocamsg", nocamsg, "0");
281                        addconfigscreencheck("camwait", camwait, "25");
282                        addconfigscreencheck("checkcamdecrypt", checkcamdecrypt, "0");
283                        addconfigscreencheck("caskipprivat", caskipprivat, "0");
284                        status.caskipprivat = getconfigint("caskipprivat", NULL);
285                        addconfigscreencheck("casendallcaids", casendallcaids, "0");
286                        status.casendallcaids = getconfigint("casendallcaids", NULL);
287
288                        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
289                        {
290                                if(extmoduldetect->ret != NULL)
291                                        addownconfig("extmoduldetect", extmoduldetect->ret);
292                        }
293
294                        break;
295                }
296        }
297
298        delownerrc(moduleadjust);
299        clearscreen(moduleadjust);
300}
301
302void screenmoduleconfig()
303{
304        int rcret = 0, i = 0, reset = 0, allready = 1;
305        struct skin* moduleconfig = getscreen("moduleconfig");
306        struct skin* listbox = getscreennode(moduleconfig, "listbox");
307        struct skin* b3 = getscreennode(moduleconfig, "b3");
308        struct skin* b4 = getscreennode(moduleconfig, "b4");
309        struct skin* b5 = getscreennode(moduleconfig, "b5");
310        struct skin* b6 = getscreennode(moduleconfig, "b6");
311        struct skin* load = getscreen("loading");
312        struct skin* tmp = NULL;
313        struct dvbdev* dvbnode = NULL;
314        char* tmpstr = NULL, *tmpnr = NULL;
315
316        listbox->aktline = 1;
317        listbox->aktpage = -1;
318
319        b3->usesavebg = 1;
320        b4->usesavebg = 1;
321        b5->usesavebg = 1;
322        b6->usesavebg = 1;
323
324start:
325        i = 0, allready = 1;
326        dvbnode = dvbdev;
327        tmp = NULL;
328        delmarkedscreennodes(moduleconfig, 1);
329
330        while(dvbnode != NULL)
331        {
332                if(dvbnode->type == CIDEV)
333                {
334                        i++;
335                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
336                        if(tmp != NULL)
337                        {
338                                tmpstr = ostrcat(tmpstr, _("Slot "), 1, 0);
339                                tmpnr = oitoa(i);
340                                tmpstr = ostrcat(tmpstr, tmpnr, 1, 1);
341                                tmpstr = ostrcat(tmpstr, ": ", 1, 0);
342                                if(dvbnode->caslot != NULL)
343                                {
344                                        if(dvbnode->caslot->name == NULL || dvbnode->caslot->status == 0)
345                                                tmpstr = ostrcat(tmpstr, _("unknown"), 1, 0);
346                                        else
347                                                tmpstr = ostrcat(tmpstr, dvbnode->caslot->name, 1, 0);
348                                }
349                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
350                                tmpstr = ostrcat(tmpstr, _("Status: "), 1, 0);
351                                if(dvbnode->caslot != NULL)
352                                {
353                                        if(dvbnode->caslot->status == 0 || dvbnode->caslot->status == 100)
354                                                tmpstr = ostrcat(tmpstr, _("empty"), 1, 0);
355                                        if(dvbnode->caslot->status == 1)
356                                                tmpstr = ostrcat(tmpstr, _("initializing"), 1, 0);
357                                        if(dvbnode->caslot->status == 2)
358                                                tmpstr = ostrcat(tmpstr, _("ready"), 1, 0);
359                                }
360                                if(dvbnode->caslot->status != 2) allready = 0;
361                                changetext(tmp, tmpstr);
362                                free(tmpstr); tmpstr = NULL;
363                                tmp->height = (listbox->fontsize * 2) + (2 * 2);
364                                tmp->type = TEXTBOX;
365                                tmp->handle = (void*)dvbnode;
366                        }
367                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
368                        if(tmp != NULL)
369                        {
370                                tmpstr = ostrcat(tmpstr, "camtype_", 1, 0);
371                                tmpstr = ostrcat(tmpstr, oitoa(i - 1), 1, 1);
372                                tmp->type = CHOICEBOX;
373                                changetext(tmp, _("Module Type"));
374                                addchoicebox(tmp, "0", _("Single Service"));
375                                addchoicebox(tmp, "1", _("Multiple Service"));
376                                setchoiceboxselection(tmp, getconfig(tmpstr, NULL));
377                                changename(tmp, tmpstr);
378                                free(tmpstr); tmpstr = NULL;
379                        }
380                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
381                        if(tmp != NULL)
382                        {
383                                tmp->height = 20;
384                                tmp->deaktivcol = 1;
385                        }
386                }
387                dvbnode = dvbnode->next;
388        }
389        if(allready == 1) reset = 0;
390
391
392        clearscreen(load);
393        drawscreen(moduleconfig, 0, 0);
394        if(reset > 0)
395        {
396                reset--;
397                drawscreen(load, 0, 0);
398        }
399        addscreenrc(moduleconfig, listbox);
400
401        tmp = listbox->select;
402        int count = 0;
403        while(1)
404        {
405                if(listbox->select != NULL && (listbox->select->type & CHOICEBOX))
406                        addscreenrc(moduleconfig, tmp);
407                rcret = waitrc(moduleconfig, 2000, 0);
408                tmp = listbox->select;
409               
410                printf("listbox->select->text: %s\n",listbox->select->text);
411                printf("listbox->select->name: %s\n",listbox->select->name);
412
413                if(listbox->select != NULL && listbox->select->handle != NULL && ostrstr(listbox->select->text, "Status: empty") == NULL)
414//              if(listbox->select != NULL && listbox->select->handle != NULL)
415                {
416                        b3->hidden = NO;
417                        b4->hidden = NO;
418                        b5->hidden = NO;
419                        b6->hidden = NO;
420                }
421                else
422                {
423                        b3->hidden = YES;
424                        b4->hidden = YES;
425                        b5->hidden = YES;
426                        b6->hidden = YES;
427                }
428                count++;
429                printf("count: %d\n",count);
430                printf("reset: %d\n",reset);
431
432                clearscreen(load);
433                drawscreen(moduleconfig, 0, 0);
434                if(reset > 0) drawscreen(load, 0, 0);
435
436                if(rcret == getrcconfigint("rcexit", NULL)) break;
437                if(rcret == getrcconfigint("rcok", NULL))
438                {
439                        tmp = listbox;
440                        while(tmp != NULL)
441                        {
442                                if(ostrncmp("camtype_", tmp->name, 8) == 0)
443                                        addconfigscreencheck(tmp->name, tmp, "0");
444                                tmp = tmp->next;
445                        }
446                        break;
447                }
448                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcred", NULL))
449                {
450                        if(((struct dvbdev*)listbox->select->handle)->caslot != NULL)
451                        {
452                                ((struct dvbdev*)listbox->select->handle)->caslot->status = 100;
453                                reset = 5;
454                                drawscreen(load, 0, 0);
455                        }
456                }
457                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcgreen", NULL))
458                {
459                        if((struct dvbdev*)listbox->select->handle != NULL)
460                        {
461                                drawscreen(load, 0, 0);
462                                caappmenu((struct dvbdev*)listbox->select->handle);
463                                sleep(7);
464                                reset = 0;
465                        }
466                }
467                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcyellow", NULL))
468                {
469                        if((struct dvbdev*)listbox->select->handle != NULL)
470                        {
471                                screencaidlock((struct dvbdev*)listbox->select->handle);
472                                reset = 0;
473                        }
474                }
475                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcblue", NULL))
476                {
477                        clearscreen(moduleconfig);
478                        screenchannelslot(((struct dvbdev*)listbox->select->handle)->devnr);
479                        drawscreen(moduleconfig, 0, 0);
480                }
481                if(rcret == getrcconfigint("rcmenu", NULL))
482                {
483                        screenmoduleadjust();
484                        reset = 0;
485                        drawscreen(moduleconfig, 0, 0);
486                }
487               
488                if(rcret == RCTIMEOUT) goto start;
489        }
490
491        delmarkedscreennodes(moduleconfig, 1);
492        delownerrc(moduleconfig);
493        clearscreen(load);
494        clearscreen(moduleconfig);
495}
496
497#endif
Note: See TracBrowser for help on using the repository browser.