source: titan/titan/moduleconfig.h @ 38723

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

change ci caid names

File size: 15.0 KB
RevLine 
[17946]1#ifndef MODULECONFIG_H
2#define MODULECONFIG_H
3
[22298]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                        {
[22302]16                                tmp = addlistbox(channelslotlist, listbox, tmp, 1);
[22298]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                {
[22328]55                        if(delchannelslot(((struct channelslot*)listbox->select->handle)->serviceid, ((struct channelslot*)listbox->select->handle)->transponderid) == 0)
[22298]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
[22328]73                        if(tmpchnode != NULL && getchannelslot(tmpchnode->serviceid, tmpchnode->transponderid) == NULL)
[22298]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                }
[22342]89                if(rcret == getrcconfigint("rcyellow", NULL))
90                {
91                        clearscreen(channelslotlist);
92                        struct mainbouquet* mbouquet = screenmainbouquet();
93                       
[22343]94                        mainbouquet2channelslot(mbouquet, slot);
[22342]95                        delmarkedscreennodes(channelslotlist, 1);
96                        createchannelslotlist(channelslotlist, listbox, slot);
97                       
98                        drawscreen(channelslotlist, 0, 0);
99                }
[22298]100        }
101
102        delmarkedscreennodes(channelslotlist, 1);
103        delownerrc(channelslotlist);
104        clearscreen(channelslotlist);
105}
106
[17946]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
[38723]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
[17946]166                                if(checkdoublecaid(dvbnode, ret[i].part) == 1)
167                                {
168                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
[38723]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
[17946]178                                        tmpstr = ostrcat(tmpstr, _("double"), 1, 0);
179                                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
180                                }
181                                else
[38723]182                                {
[17946]183                                        tmpstr = ostrcat(tmpstr, ret[i].part, 1, 0);
[38723]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);
[17946]192
193                                changetext(tmp, tmpstr);
194                                free(tmpstr); tmpstr = NULL;
195
196                                addchoicebox(tmp, "0", _("activate"));
[34050]197                                addchoicebox(tmp, "1", _("deactivate"));
[17946]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
[20546]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");
[20657]261        struct skin* extmoduldetect = getscreennode(moduleadjust, "extmoduldetect");
[20546]262
263        struct skin* tmp = NULL;
264
[23739]265        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
[20657]266                extmoduldetect->hidden = NO;
267        else
268                extmoduldetect->hidden = YES;
269
[20546]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
[20696]291        addchoicebox(extmoduldetect, "0", _("no"));
292        addchoicebox(extmoduldetect, "1", _("yes"));
[20661]293        setchoiceboxselection(extmoduldetect, getownconfig("extmoduldetect"));
[20657]294
[20546]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
[23739]316                        if(checkbox("ATEMIO7600") == 1 || checkbox("ATEMIO510") == 1 || checkbox("ATEVIO700") == 1 || checkbox("ATEVIO7000") == 1 || checkbox("WHITEBOX") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
[20657]317                        {
[20660]318                                if(extmoduldetect->ret != NULL)
[20657]319                                        addownconfig("extmoduldetect", extmoduldetect->ret);
320                        }
321
[20546]322                        break;
323                }
324        }
325
326        delownerrc(moduleadjust);
327        clearscreen(moduleadjust);
328}
329
[17946]330void screenmoduleconfig()
331{
[20513]332        int rcret = 0, i = 0, reset = 0, allready = 1;
[17946]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");
[22298]338        struct skin* b6 = getscreennode(moduleconfig, "b6");
[20513]339        struct skin* load = getscreen("loading");
[17946]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
[28436]347        b3->usesavebg = 1;
348        b4->usesavebg = 1;
349        b5->usesavebg = 1;
350        b6->usesavebg = 1;
[17946]351
352start:
[20513]353        i = 0, allready = 1;
[17946]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                                {
[20512]372                                        if(dvbnode->caslot->name == NULL || dvbnode->caslot->status == 0)
[17946]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                                {
[20513]381                                        if(dvbnode->caslot->status == 0 || dvbnode->caslot->status == 100)
[17946]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                                }
[20513]388                                if(dvbnode->caslot->status != 2) allready = 0;
[17946]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;
[17954]401                                changetext(tmp, _("Module Type"));
[17946]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        }
[20513]417        if(allready == 1) reset = 0;
[17946]418
[20548]419
[20513]420        clearscreen(load);
[17946]421        drawscreen(moduleconfig, 0, 0);
[20548]422        if(reset > 0)
423        {
424                reset--;
425                drawscreen(load, 0, 0);
426        }
[17946]427        addscreenrc(moduleconfig, listbox);
428
429        tmp = listbox->select;
[28435]430        int count = 0;
[17946]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;
[28435]437               
438                printf("listbox->select->text: %s\n",listbox->select->text);
439                printf("listbox->select->name: %s\n",listbox->select->name);
[17946]440
[28435]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)
[17946]443                {
444                        b3->hidden = NO;
445                        b4->hidden = NO;
446                        b5->hidden = NO;
[22298]447                        b6->hidden = NO;
[17946]448                }
449                else
450                {
451                        b3->hidden = YES;
452                        b4->hidden = YES;
453                        b5->hidden = YES;
[22298]454                        b6->hidden = YES;
[17946]455                }
[28435]456                count++;
457                printf("count: %d\n",count);
458                printf("reset: %d\n",reset);
459
[20513]460                clearscreen(load);
[17946]461                drawscreen(moduleconfig, 0, 0);
[20548]462                if(reset > 0) drawscreen(load, 0, 0);
[17946]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)
[20513]479                        {
[20499]480                                ((struct dvbdev*)listbox->select->handle)->caslot->status = 100;
[20548]481                                reset = 5;
[20513]482                                drawscreen(load, 0, 0);
483                        }
[17946]484                }
485                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcgreen", NULL))
486                {
487                        if((struct dvbdev*)listbox->select->handle != NULL)
[20513]488                        {
[20514]489                                drawscreen(load, 0, 0);
[17946]490                                caappmenu((struct dvbdev*)listbox->select->handle);
[20514]491                                sleep(7);
[20513]492                                reset = 0;
493                        }
[17946]494                }
[17957]495                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcyellow", NULL))
[17946]496                {
497                        if((struct dvbdev*)listbox->select->handle != NULL)
[20513]498                        {
[17946]499                                screencaidlock((struct dvbdev*)listbox->select->handle);
[20513]500                                reset = 0;
501                        }
[17946]502                }
[22310]503                if(listbox->select != NULL && listbox->select->handle != NULL && rcret == getrcconfigint("rcblue", NULL))
[20546]504                {
[22310]505                        clearscreen(moduleconfig);
506                        screenchannelslot(((struct dvbdev*)listbox->select->handle)->devnr);
[20555]507                        drawscreen(moduleconfig, 0, 0);
[20546]508                }
[22310]509                if(rcret == getrcconfigint("rcmenu", NULL))
[22298]510                {
[22310]511                        screenmoduleadjust();
512                        reset = 0;
[22298]513                        drawscreen(moduleconfig, 0, 0);
514                }
515               
[17946]516                if(rcret == RCTIMEOUT) goto start;
517        }
518
519        delmarkedscreennodes(moduleconfig, 1);
520        delownerrc(moduleconfig);
[20513]521        clearscreen(load);
[17946]522        clearscreen(moduleconfig);
523}
524
525#endif
Note: See TracBrowser for help on using the repository browser.