source: titan/titan/moduleconfig.h @ 38729

Last change on this file since 38729 was 38729, checked in by Stephan, 8 years ago

caid next try

File size: 15.0 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                                // show caid in hex
156                                int caid_int = 0;
157                                char* caid = ostrcat(ret[i].part, NULL, 0, 0);
158                                sscanf(caid, "%X", &caid_int);
159                                caid_int = strtol(caid , NULL, 16);
160                                free(caid), caid = NULL;
161
162                                char* caid_hex = malloc(50);
163                                if(caid_hex != NULL)
164                                        sprintf(caid_hex, "%d", caid_int);
165
166                                if(checkdoublecaid(dvbnode, ret[i].part) == 1)
167                                {
168                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
169                                        if(caid_hex != NULL)
170                                        {
171                                                tmpstr = ostrcat(tmpstr, " (", 1, 0);
172                                                tmpstr = ostrcat(tmpstr, caid_hex, 1, 0);
173                                                tmpstr = ostrcat(tmpstr, ") (", 1, 0);
174                                        }
175                                        else
176                                                tmpstr = ostrcat(tmpstr, " (", 1, 0);
177
178                                        tmpstr = ostrcat(tmpstr, _("double"), 1, 0);
179                                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
180                                }
181                                else
182                                {
183                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
184                                        if(caid_hex != NULL)
185                                        {
186                                                tmpstr = ostrcat(tmpstr, " (", 1, 0);
187                                                tmpstr = ostrcat(tmpstr, caid_hex, 1, 0);
188                                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
189                                        }
190                                }
191                                free(caid_hex);
192
193                                changetext(tmp, tmpstr);
194                                free(tmpstr); tmpstr = NULL;
195
196                                addchoicebox(tmp, "0", _("used"));
197                                addchoicebox(tmp, "1", _("locked"));
198                                if(ostrstr(lockcaids, ret[i].part) != NULL)
199                                        setchoiceboxselection(tmp, "1");
200                                else
201                                        setchoiceboxselection(tmp, "0");
202                                changename(tmp, ret[i].part);
203                        }
204                }
205        }
206
207        free(caids); caids = NULL;
208        free(ret); ret = NULL;
209        drawscreen(caidlock, 0, 0);
210        addscreenrc(caidlock, listbox);
211
212        tmp = listbox->select;
213        while(1)
214        {
215                addscreenrc(caidlock, tmp);
216                rcret = waitrc(caidlock, 0, 0);
217                tmp = listbox->select;
218
219                if(rcret == getrcconfigint("rcexit", NULL)) break;
220                if(rcret == getrcconfigint("rcok", NULL))
221                {
222                        tmp = listbox;
223                        while(tmp != NULL)
224                        {
225                                if(tmp->del == 1 && ostrcmp(tmp->ret, "1") == 0)
226                                {
227                                        tmpstr = ostrcat(tmpstr, "#", 1, 0);
228                                        tmpstr = ostrcat(tmpstr, tmp->name, 1, 0);
229                                        tmpstr = ostrcat(tmpstr, "#", 1, 0);
230                                }
231                                tmp = tmp->next;
232                        }
233
234                        if(tmpstr != NULL)
235                                addconfig(configname, tmpstr);
236                        else
237                                delconfig(configname);
238
239                        free(tmpstr); tmpstr = NULL;
240                        break;
241                }
242        }
243
244        free(configname); configname = NULL;
245        delmarkedscreennodes(caidlock, 1);
246        delownerrc(caidlock);
247        clearscreen(caidlock);
248}
249
250void screenmoduleadjust()
251{
252        int rcret = 0;
253
254        struct skin* moduleadjust = getscreen("moduleadjust");
255        struct skin* listbox = getscreennode(moduleadjust, "listbox");
256        struct skin* nocamsg = getscreennode(moduleadjust, "nocamsg");
257        struct skin* camwait = getscreennode(moduleadjust, "camwait");
258        struct skin* checkcamdecrypt = getscreennode(moduleadjust, "checkcamdecrypt");
259        struct skin* caskipprivat = getscreennode(moduleadjust, "caskipprivat");
260        struct skin* casendallcaids = getscreennode(moduleadjust, "casendallcaids");
261        struct skin* extmoduldetect = getscreennode(moduleadjust, "extmoduldetect");
262
263        struct skin* tmp = NULL;
264
265        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
266                extmoduldetect->hidden = NO;
267        else
268                extmoduldetect->hidden = YES;
269
270        addchoicebox(nocamsg, "0", _("yes"));
271        addchoicebox(nocamsg, "1", _("no"));
272        setchoiceboxselection(nocamsg, getconfig("nocamsg", NULL));
273
274        addchoicebox(camwait, "25", _("slow"));
275        addchoicebox(camwait, "15", _("middle"));
276        addchoicebox(camwait, "5", _("fast"));
277        setchoiceboxselection(camwait, getconfig("camwait", NULL));
278
279        addchoicebox(checkcamdecrypt, "0", _("no"));
280        addchoicebox(checkcamdecrypt, "1", _("yes"));
281        setchoiceboxselection(checkcamdecrypt, getconfig("checkcamdecrypt", NULL));
282
283        addchoicebox(caskipprivat, "0", _("no"));
284        addchoicebox(caskipprivat, "1", _("yes"));
285        setchoiceboxselection(caskipprivat, getconfig("caskipprivat", NULL));
286
287        addchoicebox(casendallcaids, "0", _("no"));
288        addchoicebox(casendallcaids, "1", _("yes"));
289        setchoiceboxselection(casendallcaids, getconfig("casendallcaids", NULL));
290
291        addchoicebox(extmoduldetect, "0", _("no"));
292        addchoicebox(extmoduldetect, "1", _("yes"));
293        setchoiceboxselection(extmoduldetect, getownconfig("extmoduldetect"));
294
295        drawscreen(moduleadjust, 0, 0);
296        addscreenrc(moduleadjust, listbox);
297
298        tmp = listbox->select;
299        while(1)
300        {
301                addscreenrc(moduleadjust, tmp);
302                rcret = waitrc(moduleadjust, 0, 0);
303                tmp = listbox->select;
304
305                if(rcret == getrcconfigint("rcexit", NULL)) break;
306                if(rcret == getrcconfigint("rcok", NULL))
307                {
308                        addconfigscreencheck("nocamsg", nocamsg, "0");
309                        addconfigscreencheck("camwait", camwait, "25");
310                        addconfigscreencheck("checkcamdecrypt", checkcamdecrypt, "0");
311                        addconfigscreencheck("caskipprivat", caskipprivat, "0");
312                        status.caskipprivat = getconfigint("caskipprivat", NULL);
313                        addconfigscreencheck("casendallcaids", casendallcaids, "0");
314                        status.casendallcaids = getconfigint("casendallcaids", NULL);
315
316                        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
317                        {
318                                if(extmoduldetect->ret != NULL)
319                                        addownconfig("extmoduldetect", extmoduldetect->ret);
320                        }
321
322                        break;
323                }
324        }
325
326        delownerrc(moduleadjust);
327        clearscreen(moduleadjust);
328}
329
330void screenmoduleconfig()
331{
332        int rcret = 0, i = 0, reset = 0, allready = 1;
333        struct skin* moduleconfig = getscreen("moduleconfig");
334        struct skin* listbox = getscreennode(moduleconfig, "listbox");
335        struct skin* b3 = getscreennode(moduleconfig, "b3");
336        struct skin* b4 = getscreennode(moduleconfig, "b4");
337        struct skin* b5 = getscreennode(moduleconfig, "b5");
338        struct skin* b6 = getscreennode(moduleconfig, "b6");
339        struct skin* load = getscreen("loading");
340        struct skin* tmp = NULL;
341        struct dvbdev* dvbnode = NULL;
342        char* tmpstr = NULL, *tmpnr = NULL;
343
344        listbox->aktline = 1;
345        listbox->aktpage = -1;
346
347        b3->usesavebg = 1;
348        b4->usesavebg = 1;
349        b5->usesavebg = 1;
350        b6->usesavebg = 1;
351
352start:
353        i = 0, allready = 1;
354        dvbnode = dvbdev;
355        tmp = NULL;
356        delmarkedscreennodes(moduleconfig, 1);
357
358        while(dvbnode != NULL)
359        {
360                if(dvbnode->type == CIDEV)
361                {
362                        i++;
363                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
364                        if(tmp != NULL)
365                        {
366                                tmpstr = ostrcat(tmpstr, _("Slot "), 1, 0);
367                                tmpnr = oitoa(i);
368                                tmpstr = ostrcat(tmpstr, tmpnr, 1, 1);
369                                tmpstr = ostrcat(tmpstr, ": ", 1, 0);
370                                if(dvbnode->caslot != NULL)
371                                {
372                                        if(dvbnode->caslot->name == NULL || dvbnode->caslot->status == 0)
373                                                tmpstr = ostrcat(tmpstr, _("unknown"), 1, 0);
374                                        else
375                                                tmpstr = ostrcat(tmpstr, dvbnode->caslot->name, 1, 0);
376                                }
377                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
378                                tmpstr = ostrcat(tmpstr, _("Status: "), 1, 0);
379                                if(dvbnode->caslot != NULL)
380                                {
381                                        if(dvbnode->caslot->status == 0 || dvbnode->caslot->status == 100)
382                                                tmpstr = ostrcat(tmpstr, _("empty"), 1, 0);
383                                        if(dvbnode->caslot->status == 1)
384                                                tmpstr = ostrcat(tmpstr, _("initializing"), 1, 0);
385                                        if(dvbnode->caslot->status == 2)
386                                                tmpstr = ostrcat(tmpstr, _("ready"), 1, 0);
387                                }
388                                if(dvbnode->caslot->status != 2) allready = 0;
389                                changetext(tmp, tmpstr);
390                                free(tmpstr); tmpstr = NULL;
391                                tmp->height = (listbox->fontsize * 2) + (2 * 2);
392                                tmp->type = TEXTBOX;
393                                tmp->handle = (void*)dvbnode;
394                        }
395                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
396                        if(tmp != NULL)
397                        {
398                                tmpstr = ostrcat(tmpstr, "camtype_", 1, 0);
399                                tmpstr = ostrcat(tmpstr, oitoa(i - 1), 1, 1);
400                                tmp->type = CHOICEBOX;
401                                changetext(tmp, _("Module Type"));
402                                addchoicebox(tmp, "0", _("Single Service"));
403                                addchoicebox(tmp, "1", _("Multiple Service"));
404                                setchoiceboxselection(tmp, getconfig(tmpstr, NULL));
405                                changename(tmp, tmpstr);
406                                free(tmpstr); tmpstr = NULL;
407                        }
408                        tmp = addlistbox(moduleconfig, listbox, tmp, 1);
409                        if(tmp != NULL)
410                        {
411                                tmp->height = 20;
412                                tmp->deaktivcol = 1;
413                        }
414                }
415                dvbnode = dvbnode->next;
416        }
417        if(allready == 1) reset = 0;
418
419
420        clearscreen(load);
421        drawscreen(moduleconfig, 0, 0);
422        if(reset > 0)
423        {
424                reset--;
425                drawscreen(load, 0, 0);
426        }
427        addscreenrc(moduleconfig, listbox);
428
429        tmp = listbox->select;
430        int count = 0;
431        while(1)
432        {
433                if(listbox->select != NULL && (listbox->select->type & CHOICEBOX))
434                        addscreenrc(moduleconfig, tmp);
435                rcret = waitrc(moduleconfig, 2000, 0);
436                tmp = listbox->select;
437
438                printf("listbox->select->text: %s\n",listbox->select->text);
439                printf("listbox->select->name: %s\n",listbox->select->name);
440
441                if(listbox->select != NULL && listbox->select->handle != NULL && ostrstr(listbox->select->text, "Status: empty") == NULL)
442//              if(listbox->select != NULL && listbox->select->handle != NULL)
443                {
444                        b3->hidden = NO;
445                        b4->hidden = NO;
446                        b5->hidden = NO;
447                        b6->hidden = NO;
448                }
449                else
450                {
451                        b3->hidden = YES;
452                        b4->hidden = YES;
453                        b5->hidden = YES;
454                        b6->hidden = YES;
455                }
456                count++;
457                printf("count: %d\n",count);
458                printf("reset: %d\n",reset);
459
460                clearscreen(load);
461                drawscreen(moduleconfig, 0, 0);
462                if(reset > 0) drawscreen(load, 0, 0);
463
464                if(rcret == getrcconfigint("rcexit", NULL)) break;
465                if(rcret == getrcconfigint("rcok", NULL))
466                {
467                        tmp = listbox;
468                        while(tmp != NULL)
469                        {
470                                if(ostrncmp("camtype_", tmp->name, 8) == 0)
471                                        addconfigscreencheck(tmp->name, tmp, "0");
472                                tmp = tmp->next;
473                        }
474                        break;
475                }
476                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcred", NULL))
477                {
478                        if(((struct dvbdev*)listbox->select->handle)->caslot != NULL)
479                        {
480                                ((struct dvbdev*)listbox->select->handle)->caslot->status = 100;
481                                reset = 5;
482                                drawscreen(load, 0, 0);
483                        }
484                }
485                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcgreen", NULL))
486                {
487                        if((struct dvbdev*)listbox->select->handle != NULL)
488                        {
489                                drawscreen(load, 0, 0);
490                                caappmenu((struct dvbdev*)listbox->select->handle);
491                                sleep(7);
492                                reset = 0;
493                        }
494                }
495                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcyellow", NULL))
496                {
497                        if((struct dvbdev*)listbox->select->handle != NULL)
498                        {
499                                screencaidlock((struct dvbdev*)listbox->select->handle);
500                                reset = 0;
501                        }
502                }
503                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcblue", NULL))
504                {
505                        clearscreen(moduleconfig);
506                        screenchannelslot(((struct dvbdev*)listbox->select->handle)->devnr);
507                        drawscreen(moduleconfig, 0, 0);
508                }
509                if(rcret == getrcconfigint("rcmenu", NULL))
510                {
511                        screenmoduleadjust();
512                        reset = 0;
513                        drawscreen(moduleconfig, 0, 0);
514                }
515
516                if(rcret == RCTIMEOUT) goto start;
517        }
518
519        delmarkedscreennodes(moduleconfig, 1);
520        delownerrc(moduleconfig);
521        clearscreen(load);
522        clearscreen(moduleconfig);
523}
524
525#endif
Note: See TracBrowser for help on using the repository browser.