source: titan/titan/moduleconfig.h @ 40035

Last change on this file since 40035 was 38743, checked in by obi, 8 years ago

fix

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