source: titan/titan/scan.h @ 40793

Last change on this file since 40793 was 40793, checked in by gost, 7 years ago

fix

File size: 76.1 KB
RevLine 
[9546]1#ifndef SCAN_H
2#define SCAN_H
3
[10129]4uint8_t changeservicetype(uint8_t type)
[9573]5{
[10129]6        int ret = type;
7
8        switch(type)
9        {
[10165]10                case 0x01:
[22108]11                case 0x06:
12                case 0x0B:
[10129]13                case 0x11:
[22108]14                case 0x16:
[10129]15                case 0x19:
[22108]16                case 0x1C:
[10129]17                case 0x9A:
18                case 0x86:
19                case 0xC3:
20                case 0xC5:
21                case 0xC6:
22                        ret = 0;
23                        break;
[10165]24                case 0x02:
[22108]25                case 0x07:
26                case 0x0A:
[10165]27                        ret = 1;
28                        break;
[10129]29        }
30
31        return ret;
32}
33
[18431]34struct transponder* satsystemdesc(unsigned char* buf, uint64_t transportid, unsigned short onid, int orbitalpos)
[10165]35{
[14108]36        int polarization = 0, modulation = 0, system = 0;
[14784]37        int rolloff = 0, fec = 0;
38        unsigned int frequency = 0, symbolrate = 0;
[18431]39        uint64_t id = 0;
[14182]40        struct transponder *tpnode = NULL;
[14108]41
[19409]42        if(buf == NULL) return NULL;
43
[14108]44        frequency = (
45                ((buf[2] >> 4) * 100000000) +
46                ((buf[2] & 0x0F) * 10000000) +
47                ((buf[3] >> 4) * 1000000) +
48                ((buf[3] & 0x0F) * 100000) +
49                ((buf[4] >> 4) * 10000) +
50                ((buf[4] & 0x0F) * 1000) +
51                ((buf[5] >> 4) * 100) +
52                ((buf[5] & 0x0F) * 10)
53        );
54
[19407]55        rolloff = (buf[8] >> 4) & 0x03; //0=rolloff_0_35, 1=rolloff_0_25, 2=rolloff_0_20, 3=rolloff_auto
56        system = (buf[8] >> 2) & 0x01; //0=DVB_S, 1=DVB_S2
57        modulation = (buf[8]) & 0x03; //1=QPSK, 2=PSK_8, 3=QAM_16
[14108]58
59        symbolrate = (
60                ((buf[9] >> 4) * 100000000) +
61                ((buf[9] & 0x0F) * 10000000) +
62                ((buf[10] >> 4) * 1000000) +
63                ((buf[10] & 0x0F) * 100000) +
64                ((buf[11] >> 4) * 10000) +
65                ((buf[11] & 0x0F) * 1000) +
66                ((buf[12] >> 4) * 100)
67        );
68
[19407]69        fec = (buf[12]) & 0x0F;
70
71        switch(fec)
[14108]72        {
73                case 0x01:
74                        fec = FEC_1_2;
75                        break;
76                case 0x02:
77                        fec = FEC_2_3;
78                        break;
79                case 0x03:
80                        fec = FEC_3_4;
81                        break;
82                case 0x04:
83                        fec = FEC_5_6;
84                        break;
85                case 0x05:
86                        fec = FEC_7_8;
87                        break;
[19407]88                case 0x06:
89                        fec = FEC_8_9;
90                        break;
91                case 0x07:
92                        fec = FEC_3_5;
93                        break;
94                case 0x08:
95                        fec = FEC_4_5;
96                        break;
97                case 0x09:
98                        fec = FEC_9_10;
99                        break;
[14108]100                case 0x0F:
101                        fec = FEC_NONE;
102                        break;
103                default:
104                        fec = FEC_AUTO;
105                        break;
106        }
107
[19407]108        polarization = (buf[8] >> 5) & 0x03; //0=H, 1=V
[14108]109
110        //workarounds for braindead broadcasters (e.g. on Telstar 12 at 15.0W)
111        if(frequency >= 100000000) frequency /= 10;
112        if(symbolrate >= 50000000) symbolrate /= 10;
113
[19407]114        frequency = (int)1000 * (int)round((double)frequency / (double)1000);
[14108]115
[14216]116        if(frequency > 15000000) return NULL;
[14108]117
[18548]118        id = ((onid << 16) | transportid) & 0xffffffff;
[14108]119
[36335]120        if(gettransponder(id) == NULL)
[14182]121        {
122                tpnode = createtransponder(id, FE_QPSK, orbitalpos, frequency, INVERSION_AUTO, symbolrate, polarization, fec, modulation, rolloff, 0, system);
123                status.writetransponder = 1;
124        }
[14216]125
[36335]126        debug(500, "nitscan: id=%llu freq=%d sr=%d fec=%d pol=%d modulation=%d system=%d tpnode=%p", id, frequency, symbolrate, fec, polarization, modulation, system, tpnode);
127
[14182]128        return tpnode;
[14108]129}
130
[19407]131struct transponder* cablesystemdesc(unsigned char* buf, uint64_t transportid, unsigned short onid, int orbitalpos)
132{
133        int modulation = 0, fec = 0;
134        unsigned int frequency = 0, symbolrate = 0;
135        uint64_t id = 0;
136        struct transponder *tpnode = NULL;
137
[19409]138        if(buf == NULL) return NULL;
139
[19407]140        frequency = (
141                ((buf[2] >> 4) * 1000000000) +
142                ((buf[2] & 0x0F) * 100000000) +
143                ((buf[3] >> 4) * 10000000) +
144                ((buf[3] & 0x0F) * 1000000) +
145                ((buf[4] >> 4) * 100000) +
146                ((buf[4] & 0x0F) * 10000) +
147                ((buf[5] >> 4) * 1000) +
148                ((buf[5] & 0x0F) * 100)
149        );
150
151        modulation = buf[8]; //0=QAM_AUTO, 1=QAM_16, 2=QAM_32, 3=QAM_64, 4=QAM_128, 5=QAM_256
152
153        symbolrate = (
154                ((buf[9] >> 4) * 100000000) +
155                ((buf[9] & 0x0F) * 10000000) +
156                ((buf[10] >> 4) * 1000000) +
157                ((buf[10] & 0x0F) * 100000) +
158                ((buf[11] >> 4) * 10000) +
159                ((buf[11] & 0x0F) * 1000) +
160                ((buf[12] >> 4) * 100)
161        );
162
163        fec = (buf[12]) & 0x0F;
164
165        switch(fec)
166        {
167                case 0x01:
168                        fec = FEC_1_2;
169                        break;
170                case 0x02:
171                        fec = FEC_2_3;
172                        break;
173                case 0x03:
174                        fec = FEC_3_4;
175                        break;
176                case 0x04:
177                        fec = FEC_5_6;
178                        break;
179                case 0x05:
180                        fec = FEC_7_8;
181                        break;
182                case 0x06:
183                        fec = FEC_8_9;
184                        break;
185                case 0x07:
186                        fec = FEC_3_5;
187                        break;
188                case 0x08:
189                        fec = FEC_4_5;
190                        break;
191                case 0x09:
192                        fec = FEC_9_10;
193                        break;
194                case 0x0F:
195                        fec = FEC_NONE;
196                        break;
197                default:
198                        fec = FEC_AUTO;
199                        break;
200        }
201
202        id = ((onid << 16) | transportid) & 0xffffffff;
[36344]203        id = id | ((uint64_t)1 << 32);
[19407]204
[36361]205        if(gettransponder(id) == NULL)
[36817]206        //if(gettransponderbydetail(id, FE_QAM, orbitalpos, frequency, INVERSION_AUTO, symbolrate, 0, fec, modulation, 0, 0, 0, 0) == NULL)
[19407]207        {
208                tpnode = createtransponder(id, FE_QAM, orbitalpos, frequency, INVERSION_AUTO, symbolrate, 0, fec, modulation, 0, 0, 0);
209                status.writetransponder = 1;
210        }
211
[36335]212        debug(500, "nitscan: id=%llu freq=%d sr=%d fec=%d modulation=%d tpnode=%p", id, frequency, symbolrate, fec, modulation, tpnode);
213
[19407]214        return tpnode;
215}
216
[19409]217struct transponder* terrsystemdesc(unsigned char* buf, uint64_t transportid, unsigned short onid, int orbitalpos)
218{
219        int modulation = 0, hp = 0, lp = 0;
220        int bandwidth = 0, hierarchy = 0, guardinterval = 0;
221        int transmission = 0;
222        unsigned int frequency = 0;
223        uint64_t id = 0;
224        struct transponder *tpnode = NULL;
225
226        if(buf == NULL) return NULL;
227
228        frequency = (buf[2] << 24) | (buf[3] << 16);
229        frequency |= (buf[4] << 8) | buf[5];
230        frequency *= 10;
231
232        bandwidth = BANDWIDTH_8_MHZ + ((buf[6] >> 5) & 0x3);
233        modulation = (buf[7] >> 6) & 0x3;
234        hierarchy = HIERARCHY_NONE + ((buf[7] >> 3) & 0x3);
235
236        hp = (buf[7] & 0x7);
237        switch(hp)
238        {
239                case 0x00:
240                        hp = FEC_1_2;
241                        break;
242                case 0x01:
243                        hp = FEC_2_3;
244                        break;
245                case 0x02:
246                        hp = FEC_3_4;
247                        break;
248                case 0x03:
249                        hp = FEC_5_6;
250                        break;
251                case 0x04:
252                        hp = FEC_7_8;
253                        break;
254                default:
255                        hp = FEC_AUTO;
256                        break;
257        }
258
259        lp = ((buf[8] >> 5) & 0x7);
260        switch(lp)
261        {
262                case 0x00:
263                        lp = FEC_1_2;
264                        break;
265                case 0x01:
266                        lp = FEC_2_3;
267                        break;
268                case 0x02:
269                        lp = FEC_3_4;
270                        break;
271                case 0x03:
272                        lp = FEC_5_6;
273                        break;
274                case 0x04:
275                        lp = FEC_7_8;
276                        break;
277                default:
278                        lp = FEC_AUTO;
279                        break;
280        }
281
282        guardinterval = GUARD_INTERVAL_1_32 + ((buf[8] >> 3) & 0x3);
283
284        transmission = (buf[8] & 0x2);
285        switch(transmission)
286        {
287                case 0x00:
288                        transmission = TRANSMISSION_MODE_2K;
289                        break;
290                case 0x01:
291                        transmission = TRANSMISSION_MODE_8K;
292                        break;
293                case 0x02:
294                        transmission = TRANSMISSION_MODE_AUTO;
295                        break;
296                default:
297                        transmission = TRANSMISSION_MODE_AUTO;
298                        break;
299        }
300
301        //other_frequency_flag = (buf[8] & 0x01);
302
303        id = ((onid << 16) | transportid) & 0xffffffff;
[36344]304        id = id | ((uint64_t)2 << 32);
[19409]305
[36335]306        if(gettransponder(id) == NULL)
[19409]307        {
308                tpnode = createtransponder(id, FE_OFDM, orbitalpos, frequency, INVERSION_AUTO, bandwidth, lp, hp, modulation, guardinterval, transmission, hierarchy);
309                status.writetransponder = 1;
310        }
311
[36335]312        debug(500, "nitscan: id=%llu freq=%d bandwidth=%d hp=%d lp=%d modulation=%d guard=%d trans=%d hierarchy=%d tpnode=%p", id, frequency, bandwidth, hp, lp, modulation, guardinterval, transmission, hierarchy, tpnode);
313
[19409]314        return tpnode;
315}
316
[40787]317//struct transponder* terrsystemdesc2(unsigned char* buf, uint64_t transportid, unsigned short onid, int orbitalpos)
318int terrsystemdesc2(unsigned char* buf, uint64_t transportid, unsigned short onid, int orbitalpos)
319{
320        int modulation = 0, hp = 0, lp = 0;
321        int bandwidth = 0, hierarchy = 0, guardinterval = 0;
322        int transmission = 0;
[40790]323        int inversion = 0;
[40787]324        int plp_id = 0;
325        unsigned int frequency = 0;
326        uint64_t id = 0;
327        struct transponder *tpnode = NULL;
328        int addtrans = 0;
329       
330        if(buf == NULL) return -1;
331               
332        int dlen = buf[1];
333        if (dlen < 5)
334        {
335                debug(500, "exit DVB-T2 desc... length < 5");
336                return -1;     
337        }
338       
339
340        bandwidth = ((buf[6] >> 2) & 0x0f);
341        switch (bandwidth)
342        {
343                case 0: bandwidth = 8000000; break;
344                case 1: bandwidth = 7000000; break;
345                case 2: bandwidth = 6000000; break;
346                case 3: bandwidth = 5000000; break;
347                case 4: bandwidth = 1712000; break;
348                case 5: bandwidth = 10000000; break;
349                default: bandwidth = 0; break;
350        }
351        guardinterval = ((buf[7] >> 5) & 0x3);
352        switch (guardinterval)
353        {
354                case 0: guardinterval = GUARD_INTERVAL_1_32; break;
355                case 1: guardinterval = GUARD_INTERVAL_1_16; break;
356                case 2: guardinterval = GUARD_INTERVAL_1_8; break;
357                case 3: guardinterval = GUARD_INTERVAL_1_4; break;
358                case 4: guardinterval = GUARD_INTERVAL_1_128; break;
359                case 5: guardinterval = GUARD_INTERVAL_19_128; break;
360                case 6: guardinterval = GUARD_INTERVAL_19_256; break;
361                case 7: guardinterval = GUARD_INTERVAL_AUTO; break;
362        }
363        transmission = (buf[7] >> 2 & 0x3);
364        switch (transmission)
365        {
[40788]366                case 0: transmission = TRANSMISSION_MODE_2K; break;
367                case 1: transmission = TRANSMISSION_MODE_8K; break;
368                case 2: transmission = TRANSMISSION_MODE_4K; break;
369                case 3: transmission = TRANSMISSION_MODE_1K; break;
370                case 4: transmission = TRANSMISSION_MODE_16K; break;
371                case 5: transmission = TRANSMISSION_MODE_32K; break;
372                default: transmission = TRANSMISSION_MODE_AUTO; break;
[40787]373        }
374        plp_id = buf[3];
375        hp = lp = FEC_AUTO;
376        hierarchy = HIERARCHY_AUTO;
377        modulation = QAM_AUTO;
[40788]378        //inversion = INVERSION_UNKNOWN;
379        inversion = INVERSION_AUTO;
380        //system = SYSTEM_DVB_T2;
[40791]381       
[40793]382        unsigned char* loop1 = buf + 8;     //call_id
383        unsigned char* loop2 = buf + 11;    //centre_frequency if Flag == 1
384        unsigned char* loop3 = buf + 10;    //centre_frequency if Flag == 0
[40787]385        unsigned int cfre = 0;
[40788]386        int i1 = 0;
[40787]387        int i2 = 0;
388        int step1 = 0;
389        int sillen = 0;
390        int fllen = 0;
391       
392        int flag = (buf[7] & 0x1);
393
394        id = ((onid << 16) | transportid) & 0xffffffff;
395        id = id | ((uint64_t)2 << 32);
396
397        if (flag == 0)
398        {
[40788]399                for(i1 = 0; i1 < dlen-6; i1=i1+step1)
[40787]400                {
401                        step1 = 6;
402               
[40788]403                        cfre = ((loop3[i1] << 24) & 0xff000000);
404                        cfre = cfre | ((loop3[i1+1] << 16) & 0xff0000);
405                        cfre = cfre | ((loop3[i1+2] << 8) & 0xff00);
406                        cfre = cfre | (loop3[i1+3] & 0xff);
[40787]407                        frequency = cfre * 10;
408                        debug(500, "nitscan DVB-T2 - Flag=%d -> id=%llu freq=%d bandwidth=%d hp=%d lp=%d modulation=%d guard=%d trans=%d hierarchy=%d tpnode=%p", flag, id, frequency, bandwidth, hp, lp, modulation, guardinterval, transmission, hierarchy, tpnode);
409                        tpnode = createtransponder(id, FE_OFDM, orbitalpos, frequency, inversion, bandwidth, lp, hp, modulation, guardinterval, transmission, hierarchy);
410                        if(tpnode != NULL)
411                                addtrans++;
412                        else
413                                err("not add nitscan DVB-T2 - Flag=%d -> id=%llu frequency:%s", flag, id, frequency);
[40788]414                        sillen = loop3[i1+4];
[40787]415                        step1 = step1 + sillen;
416                }
417        }
418        else
419        {
[40788]420                for(i1 = 0; i1 < dlen-6; i1=i1+step1)
[40787]421                {       
[40788]422                        fllen = loop1[i1+2];
[40787]423                        step1 = 3;
[40789]424                        step1 = step1 + fllen;
[40787]425                        for(i2 = 0; i2 < fllen; i2=i2+4)
426                        {
427                                cfre = ((loop2[i2] << 24) & 0xff000000);
428                                cfre = cfre | ((loop2[i2+1] << 16) & 0xff0000);
429                                cfre = cfre | ((loop2[i2+2] << 8) & 0xff00);
430                                cfre = cfre | (loop2[i2+3] & 0xff);
431                                frequency = cfre * 10;
432                                debug(500, "nitscan DVB-T2 - Flag=%d -> id=%llu freq=%d bandwidth=%d hp=%d lp=%d modulation=%d guard=%d trans=%d hierarchy=%d tpnode=%p", flag, id, frequency, bandwidth, hp, lp, modulation, guardinterval, transmission, hierarchy, tpnode);
433                                tpnode = createtransponder(id, FE_OFDM, orbitalpos, frequency, inversion, bandwidth, lp, hp, modulation, guardinterval, transmission, hierarchy);
434                                if(tpnode != NULL)
435                                        addtrans++;
436                                else
437                                        err("not add nitscan DVB-T2 - Flag=%d -> id=%llu frequency:%s", flag, id, frequency);
438                        }
439                        sillen = loop2[i2];
440                        step1 = step1 + sillen;
441                }
442        }
443        //return tpnode;
444        return addtrans;
445}
446
[14216]447int parsenit(unsigned char* buf, uint8_t* lastsecnr, int orbitalpos)
[14108]448{
[14534]449        int ret = 0;
[10129]450
[14216]451        if(buf == NULL) return ret;
[10165]452
[14050]453        //unsigned char buf[MINMALLOC];
[10165]454
455        // position in buffer
[14050]456        unsigned short pos = 0;
457        unsigned short pos2 = 0;
[10165]458
459        // network_information_section elements
[14050]460        unsigned short seclen = 0;
461        unsigned short desclen = 0;
462        unsigned short tdesclen = 0;
463        unsigned short looplen = 0;
[18431]464        uint64_t transponderid = 0;
[14050]465        unsigned short onid = 0;
466        unsigned short nid = 0;
[14216]467        unsigned char secnr = 0;
[10165]468
[14216]469        seclen = ((buf[1] & 0x0F) << 8) + buf[2];
470        nid = ((buf[3] << 8)| buf[4]);
471        desclen = ((buf[8] & 0x0F) << 8) | buf[9];
472        secnr = buf[6];
473        *lastsecnr = buf[7];
474        debug(500, "nitscan: section %d last %d nid %d", secnr, *lastsecnr, nid);
475
476        for(pos = 10; pos < desclen + 10; pos += buf[pos + 1] + 2)
[10165]477        {
[14216]478                switch(buf[pos])
479                {
480                        case 0x0F:
481                                //private_data_indicator_desc(buf + pos);
482                                break;
483                        case 0x40:
484                                //network_name_desc(buf + pos);
485                                break;
486                        case 0x4A:
487                                //linkage_desc(buf + pos);
488                                break;
489                        case 0x5B:
490                                //multilingual_networkname_desc(buf + pos);
491                                break;
492                        case 0x5F:
493                                //private_data_specifier_desc(buf + pos);
494                                break;
495                        case 0x80:
496                                break;
497                        case 0x90:
498                                break;
499                }
500        }
[10165]501
[14216]502        looplen = ((buf[pos] & 0x0F) << 8) | buf[pos + 1];
503        if (!looplen) return ret;
[10165]504
[14216]505        for(pos += 2; pos < seclen - 3; pos += tdesclen + 6)
506        {
507                transponderid = (buf[pos] << 8) | buf[pos + 1];
508                onid = (buf[pos + 2] << 8) | buf[pos + 3];
509                tdesclen = ((buf[pos + 4] & 0x0F) << 8) | buf[pos + 5];
510
511                for(pos2 = pos + 6; pos2 < pos + tdesclen + 6; pos2 += buf[pos2 + 1] + 2)
[10165]512                {
[14216]513                        switch(buf[pos2])
[10165]514                        {
[40787]515                                case 0x41: //service_list_descriptor
[14216]516                                        //servicelistdesc(buf + pos2, transponderid, onid);
517                                        break;
[40787]518                                case 0x43: //satellite_delivery_system_descriptor
[14218]519                                        if(satsystemdesc(buf + pos2, transponderid, onid, orbitalpos) != NULL)
520                                        {
[18239]521                                                scaninfo.tpnew++;
[14218]522                                                if(scaninfo.scantype != 0)
523                                                        scaninfo.tpmax++;
524                                        }
[14216]525                                        break;
[40787]526                                case 0x44: //cable_delivery_system_descriptor
[19407]527                                        if(cablesystemdesc(buf + pos2, transponderid, onid, orbitalpos) != NULL)
528                                        {
529                                                scaninfo.tpnew++;
530                                                if(scaninfo.scantype != 0)
531                                                        scaninfo.tpmax++;
532                                        }
[14216]533                                        break;
[40787]534                                case 0x5A: //terrestrial_delivery_system_descriptor
[19409]535                                        if(terrsystemdesc(buf + pos2, transponderid, onid, orbitalpos) != NULL)
536                                        {
537                                                scaninfo.tpnew++;
538                                                if(scaninfo.scantype != 0)
539                                                        scaninfo.tpmax++;
540                                        }
[14216]541                                        break;
[40787]542                                case 0x62: //frequency_list_descriptor
[14216]543                                        //frequencylistdesc(buf + pos2);
544                                        break;
[40787]545                                case 0x7F: //extension_descriptor
546                                        {
547                                                switch(buf[pos2+2])
548                                                case 0x04: //T2_delivery_system_descriptor
549                                                        ret = terrsystemdesc2(buf + pos2, transponderid, onid, orbitalpos);
550                                                        //if(terrsystemdesc2(buf + pos2, transponderid, onid, orbitalpos) > 0)
551                                                        if(ret > 0)
552                                                        {
553                                                                scaninfo.tpnew = scaninfo.tpnew + ret;
554                                                                if(scaninfo.scantype != 0)
555                                                                        scaninfo.tpmax = scaninfo.tpmax + ret;
556                                                        }
557                                                        ret = 0;
558                                                        break;
559                                        }
560                                        break;
[10165]561                        }
562                }
563        }
564
565        return ret;
566}
567
[11810]568//flag 0: from scan
[11811]569//flag 1: from update channelname
[20631]570int findchannel(struct dvbdev* fenode, struct transponder* tpnode, unsigned char *buf, uint8_t* lastsecnr, struct skin* scan, struct skin* listbox, int ichangename, int flag)
[10129]571{
[20631]572        int ret = -1, changed = 0;
[18431]573        uint64_t transponderid = 0;
[10110]574        struct skin* node = NULL;
[10129]575        struct channel* chnode = NULL;
[10110]576
577        // position in buffer
578        unsigned short pos;
579        unsigned short pos2;
580
581        // service_description_section elements
582        unsigned short seclen;
[10129]583        uint8_t secnr;
[10718]584        unsigned short onid, tid;
[10110]585        unsigned short serviceid;
586        unsigned short desclooplen;
587        unsigned short running;
588        int eitscheduleflag;
589        int eitpresentfollowingflag;
590        int camode;
591        uint8_t servicetype = 0;
592        uint8_t providerlen = 0;
593        char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL;
[18431]594        uint64_t* tmpuint64 = NULL;
[36817]595
[36349]596        struct transponder* tphelp = NULL;
[10110]597
[18328]598        if(buf == NULL || fenode == NULL || fenode->feinfo == NULL) return ret;
[14534]599
[10110]600        seclen = ((buf[1] & 0x0F) << 8) | buf[2];
[10129]601        secnr = buf[6];
602        *lastsecnr = buf[7];
[10718]603        tid = (buf[3] << 8) | buf[4];
[10110]604        onid = (buf[8] << 8) | buf[9];
[36817]605
[18548]606        transponderid = ((onid << 16) | tid) & 0xffffffff;
[36344]607        if(fenode->feinfo->type == FE_QAM)
608                transponderid = transponderid | ((uint64_t)1 << 32);
609        else if(fenode->feinfo->type == FE_OFDM)
610                transponderid = transponderid | ((uint64_t)2 << 32);
[36817]611
[36363]612        //if(tpnode != NULL && (tpnode->id != transponderid || scaninfo.fenode->feinfo->type == FE_QAM || scaninfo.fenode->feinfo->type == FE_OFDM) && tpnode->id != 99)
613        if(tpnode != NULL && tpnode->id != transponderid && tpnode->id != 99)
[12234]614        {
[36349]615                tphelp = gettransponder(transponderid);
616                if(tphelp != NULL)
617                {
[36365]618                        deltranspondercache(tphelp->id, tphelp);
619                        tphelp->id = 0;
620                        modifytranspondercache(tphelp->id, tphelp);
[36357]621                        debug(500, "set old tid: %llu to 0", transponderid);
[36817]622
[36365]623                        //changetransponderid(tphelp, 0);
624                        //debug(500, "set old tid: %llu to 0", transponderid);
[36349]625                }
[14871]626                changetransponderid(tpnode, transponderid);
[12234]627                status.writetransponder = 1;
628        }
629
[18431]630        debug(500, "SDT nr: %d, lastnr: %d, len: %d, tid: %d, onid: %d, transponderid: %llu", secnr, *lastsecnr, seclen, tid, onid, transponderid);
[10110]631
632        for(pos = 11; pos < seclen - 1; pos += desclooplen + 5)
633        {
634                serviceid = (buf[pos] << 8) | buf[pos + 1];
635                eitscheduleflag = buf[pos + 2] & 0x02;
636                eitpresentfollowingflag = buf[pos + 2] & 0x01;
637                running = buf[pos + 3] & 0xE0;
638                camode = buf[pos + 3] & 0x10;
639                desclooplen = ((buf[pos + 3] & 0x0F) << 8) | buf[pos + 4];
[11810]640                if(flag == 0 && scaninfo.onlyfree == 1 && camode > 0) continue;
[10110]641
642                for(pos2 = pos + 5; pos2 < pos + desclooplen + 5; pos2 += buf[pos2 + 1] + 2)
643                {
644                        switch(buf[pos2])
645                        {
646                                case 0x48:
647                                        servicetype = buf[pos2 + 2];
[10129]648                                        servicetype = changeservicetype(servicetype);
[10110]649                                        providerlen = buf[pos2 + 3];
[36817]650
[11811]651                                        //providername
[10110]652                                        tmpstr1 = strndup((char*)&(buf[pos2 + 4]), providerlen);
[11811]653                                        //channelname
[10110]654                                        tmpstr2 = strndup((char*)&(buf[pos2 + 4 + providerlen + 1]), (2 + buf[pos2 + 1]) - (4 + providerlen + 1));
655
[20632]656                                        tmpstr1 = string_strip_whitechars(tmpstr1);
657                                        tmpstr2 = string_strip_whitechars(tmpstr2);
[10165]658                                        if(tmpstr1 == NULL || strlen(tmpstr1) == 0) tmpstr1 = ostrcat(tmpstr1, "unknown", 1, 0);
659                                        if(tmpstr2 == NULL || strlen(tmpstr2) == 0) tmpstr2 = ostrcat(tmpstr2, "unknown", 1, 0);
660
[14863]661                                        tmpstr1 = strutf8(tpnode, tmpstr1, strlen(tmpstr1), 0, 1, 0);
[10836]662                                        tmpstr1 = stringreplacechar(tmpstr1, '#', '_');
[14863]663                                        tmpstr2 = strutf8(tpnode, tmpstr2, strlen(tmpstr2), 0, 1, 1);
[10836]664                                        tmpstr2 = stringreplacechar(tmpstr2, '#', '_');
[10165]665
[10110]666                                        //add to listbox
[11811]667                                        chnode = getchannel(serviceid, transponderid);
668                                        if(flag == 0) node = addlistbox(scan, listbox, node, 1);
[10110]669                                        if(node != NULL)
670                                        {
[10129]671                                                switch(servicetype)
672                                                {
673                                                        case 0:
674                                                                scaninfo.tvcount++;
675                                                                if(chnode == NULL) scaninfo.newtvcount++;
676                                                                break;
677                                                        case 1:
678                                                                scaninfo.radiocount++;
679                                                                if(chnode == NULL) scaninfo.newradiocount++;
680                                                                break;
681                                                        default:
682                                                                scaninfo.datacount++;
683                                                                if(chnode == NULL) scaninfo.newdatacount++;
684                                                                break;
685                                                }
[10110]686                                                tmpstr = ostrcat(tmpstr2, " (", 0, 0);
[19650]687                                                tmpstr = ostrcat(tmpstr, tmpstr1, 1, 0);
688                                                tmpstr = ostrcat(tmpstr, " - ", 1, 0);
[10165]689                                                if(servicetype == 0)
[19650]690                                                        tmpstr = ostrcat(tmpstr, _("TV"), 1, 0);
[10165]691                                                else if(servicetype == 1)
[19650]692                                                        tmpstr = ostrcat(tmpstr, _("Radio"), 1, 0);
[10165]693                                                else
[19650]694                                                        tmpstr = ostrcat(tmpstr, _("Data"), 1, 0);
[20631]695
696                                                changed = 0;
[19650]697                                                if(chnode != NULL && chnode->name != NULL && strlen(chnode->name) > 0 && ostrcmp(tmpstr2, chnode->name) != 0)
698                                                {
699                                                        tmpstr = ostrcat(tmpstr, " - ", 1, 0);
700                                                        tmpstr = ostrcat(tmpstr, chnode->name, 1, 0);
[20631]701                                                        if(ichangename == 1) changed = 1;
[19650]702                                                }
703                                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
[10254]704                                                changetext(node, tmpstr);
[20631]705
706                                                if(chnode != NULL && chnode->transponder != NULL && changed == 0)
707                                                        node->fontcol = convertcol("deaktivcol");
708
[10165]709                                                changeparam1(node, tmpstr1);
710                                                changeparam2(node, tmpstr2);
[36335]711                                                tmpuint64 = (uint64_t*)calloc(1, sizeof(uint64_t) * 3);
[18431]712                                                if(tmpuint64 != NULL)
[10165]713                                                {
[18431]714                                                        tmpuint64[0] = serviceid;
715                                                        tmpuint64[1] = transponderid;
716                                                        tmpuint64[2] = servicetype;
[10165]717                                                }
718                                                free(node->name);
[18431]719                                                node->name = (char*)tmpuint64;
[10110]720                                        }
[36817]721
[11811]722                                        if(flag == 1 && chnode != NULL && ostrcmp(chnode->name, tmpstr2) != 0)
723                                        {
724                                                free(chnode->name);
725                                                chnode->name = ostrcat(tmpstr2, NULL, 0, 0);
[11908]726                                                status.writechannel = 1;
[11811]727                                        }
[36817]728
[10110]729                                        free(tmpstr); tmpstr = NULL;
730                                        free(tmpstr1); tmpstr1 = NULL;
731                                        free(tmpstr2); tmpstr2 = NULL;
732
733                                        ret = 0;
734                                        break;
735                        }
736                }
737        }
738
739        return ret;
740}
741
[18431]742uint64_t findtransponderid(struct dvbdev* fenode, unsigned char *buf)
[14534]743{
[18431]744        uint64_t transponderid = 0;
[14534]745        unsigned short onid, tid;
746
[18328]747        if(buf == NULL || fenode == NULL || fenode->feinfo == NULL) return 0;
[14534]748
749        tid = (buf[3] << 8) | buf[4];
750        onid = (buf[8] << 8) | buf[9];
[36817]751
[18548]752        transponderid = ((onid << 16) | tid) & 0xffffffff;
[14534]753
[36344]754        if(fenode->feinfo->type == FE_QAM)
755                transponderid = transponderid | ((uint64_t)1 << 32);
756        else if(fenode->feinfo->type == FE_OFDM)
757                transponderid = transponderid | ((uint64_t)2 << 32);
[18328]758
[18431]759        debug(500, "found SDT transponderid: %llu", transponderid);
[14534]760
761        return transponderid;
762}
763
[19525]764unsigned int satblindscan(struct stimerthread* timernode, int onlycalc)
[14534]765{
[14586]766        int festatus = 0;
[18431]767        uint64_t transponderid = 0;
[14534]768        unsigned char* buf = NULL;
769        struct dvbdev* fenode = NULL;
770        struct transponder* tpnode = NULL;
771
[14804]772        unsigned int frequency = 0, symbolrate = 0;
[19324]773        int polarization = 0, modulation = 0, system = 0, fec = 0;
[14550]774
[14804]775        unsigned int minfrequency = getconfigint("blindminfrequency", NULL) * 1000;
776        unsigned int maxfrequency = getconfigint("blindmaxfrequency", NULL) * 1000;
777        unsigned int stepfrequency = getconfigint("blindstepfrequency", NULL) * 1000;
778        unsigned int minsymbolrate = getconfigint("blindminsignalrate", NULL) * 1000;
779        unsigned int maxsymbolrate = getconfigint("blindmaxsignalrate", NULL) * 1000;
780        unsigned int stepsymbolrate = getconfigint("blindstepsignalrate", NULL) * 1000;
[19402]781        unsigned int usedefaultsr = getconfigint("blindusedefaultsr", NULL);
[19404]782        unsigned int onlydvbs = getconfigint("blindonlydvbs", NULL);
783        unsigned int usedefaultfec = getconfigint("blindusedefaultfec", NULL);
[36817]784
[19525]785        int minmodulation = 1, maxmodulation = 2, stepmodulation = 1;
[14586]786        int minpolarization = 0, maxpolarization = 1, steppolarization = 1;
787        int minsystem = 0, maxsystem = 1, stepsystem = 1;
[19324]788        int minfec = 0, maxfec = 8, stepfec = 1;
[14534]789
[19404]790        if(onlydvbs == 1)
791        {
792                maxmodulation = 0;
793                maxsystem = 0;
794        }
795
[19402]796        if(usedefaultsr == 1)
797        {
798                minsymbolrate = 0;
799                maxsymbolrate = 3;
800                stepsymbolrate = 1;
801        }
802
[19404]803        if(usedefaultfec == 1)
804                maxfec = 6;
805
[14586]806        int countfrequency = ((maxfrequency + stepfrequency) - minfrequency) / stepfrequency;
807        int countsymbolrate = ((maxsymbolrate + stepsymbolrate) - minsymbolrate) / stepsymbolrate;
808        int countmodulation = ((maxmodulation + stepmodulation) - minmodulation) / stepmodulation;
809        int countpolarization = ((maxpolarization + steppolarization) - minpolarization) / steppolarization;
[19324]810        int countfec = ((maxfec + stepfec) - minfec) / stepfec;
[14784]811        int systemcount = ((maxsystem + stepsystem) - minsystem) / stepsystem;
[36817]812
[19525]813        if(onlycalc == 1) return systemcount * countpolarization * countmodulation * countsymbolrate * countfrequency * countfec;
814
815        if(scaninfo.fenode == NULL || timernode == NULL) return -1;
[19159]816        int timeout = scaninfo.timeout / 5;
817        if(timeout < 1000000) timeout = 1000000;
[19324]818        scaninfo.blindmax += systemcount * countpolarization * countmodulation * countsymbolrate * countfrequency * countfec;
[14586]819
820        for(frequency = minfrequency; frequency <= maxfrequency; frequency += stepfrequency)
[14534]821        {
822
[19402]823                int csymbolrate = 0;
824                for(csymbolrate = minsymbolrate; csymbolrate <= maxsymbolrate; csymbolrate += stepsymbolrate)
[14550]825                {
[19402]826                        if(usedefaultsr == 1)
827                        {
[19404]828                                switch(csymbolrate)
[19402]829                                {
830                                        case 0:
831                                                symbolrate = 22000 * 1000;
832                                                break;
833                                        case 1:
834                                                symbolrate = 27500 * 1000;
835                                                break;
836                                        case 2:
837                                                symbolrate = 30000 * 1000;
838                                                break;
839                                }
840                        }
841                        else
842                                symbolrate = csymbolrate;
[14534]843
[14586]844                        for(modulation = minmodulation; modulation <= maxmodulation; modulation += stepmodulation)
[14534]845                        {
[36817]846
[19525]847                                for(polarization = minpolarization; polarization <= maxpolarization; polarization += steppolarization)
[14550]848                                {
[14534]849
[19525]850                                        for(fec = minfec; fec <= maxfec; fec += stepfec)
[14578]851                                        {
[14534]852
[19324]853                                                for(system = minsystem; system <= maxsystem; system += stepsystem)
854                                                {
855                                                        scaninfo.blindcount++;
[14550]856
[19324]857                                                        tpnode = createtransponder(99, scaninfo.fenode->feinfo->type, scaninfo.orbitalpos, frequency, INVERSION_AUTO, symbolrate, polarization, fec, modulation, 0, 0, system);
[14550]858
[19324]859                                                        debug(500, "blindscan: frequ=%d, sr=%d, modulation=%d, fec=%d, system=%d, orbitalpos=%d", frequency, symbolrate, modulation, fec, system, scaninfo.orbitalpos);
[14550]860
[19324]861                                                        if(tpnode != NULL)
[14578]862                                                        {
863
[19324]864                                                                fenode = fegetfree(tpnode, 0, scaninfo.fenode);
865                                                                if(fenode == NULL )
866                                                                {
867                                                                        debug(500, "Frontend for scan not free");
868                                                                        deltransponderbyid(99);
869                                                                        continue;
870                                                                }
[14578]871
[19324]872                                                                //frontend tune
873                                                                if(fenode->feinfo->type == FE_QPSK)
874                                                                {
875                                                                        feset(fenode, tpnode);
876                                                                        fetunedvbs(fenode, tpnode);
877                                                                }
878                                                                else
879                                                                {
880                                                                        debug(500, "Frontend type unknown");
881                                                                        deltransponderbyid(99);
882                                                                        continue;
883                                                                }
[14578]884
[19324]885                                                                festatus = fewait(fenode);
886                                                                if(debug_level == 200) fereadstatus(fenode);
887                                                                if(festatus != 0)
888                                                                {
889                                                                        debug(500, "tuning failed");
890                                                                        deltransponderbyid(99);
891                                                                        continue;
892                                                                }
[14578]893
[19324]894                                                                buf = dvbgetsdt(fenode, 0, timeout);
895                                                                transponderid = findtransponderid(fenode, buf);
896                                                                free(buf); buf = NULL;
[14578]897
[36335]898                                                                if(transponderid == 0 || gettransponder(transponderid) != NULL)
[19324]899                                                                {
900                                                                        deltransponderbyid(99);
901                                                                        continue;
902                                                                }
903
904                                                                if(tpnode->id != transponderid)
905                                                                {
[36352]906                                                                        struct transponder* tphelp = gettransponder(transponderid);
907                                                                        if(tphelp != NULL)
908                                                                        {
909                                                                                deltransponderbyid(transponderid);
[36359]910                                                                                debug(500, "delete old tid: %llu", transponderid);
[36352]911                                                                        }
[19324]912                                                                        scaninfo.newblindcount++;
913                                                                        changetransponderid(tpnode, transponderid);
914                                                                        status.writetransponder = 1;
915                                                                }
[14578]916                                                        }
[19324]917                                                        deltransponderbyid(99);
918                                                        if(timernode->aktion != START) break;
[14578]919                                                }
[14586]920                                                if(timernode->aktion != START) break;
[14578]921                                        }
[14586]922                                        if(timernode->aktion != START) break;
[14550]923                                }
[14586]924                                if(timernode->aktion != START) break;
[14534]925                        }
[14586]926                        if(timernode->aktion != START) break;
[14534]927                }
[14586]928                if(timernode->aktion != START) break;
[14534]929        }
[36817]930
[19525]931        return 0;
[14534]932}
933
[19525]934unsigned int cableblindscan(struct stimerthread* timernode, int onlycalc)
935{
936        int festatus = 0;
937        uint64_t transponderid = 0;
938        unsigned char* buf = NULL;
939        struct dvbdev* fenode = NULL;
940        struct transponder* tpnode = NULL;
941
942        unsigned int frequency = 0, symbolrate = 0;
943        int modulation = 0, fec = 0;
944
945        unsigned int minfrequency = getconfigint("cblindminfrequency", NULL) * 1000;
946        unsigned int maxfrequency = getconfigint("cblindmaxfrequency", NULL) * 1000;
947        unsigned int stepfrequency = getconfigint("cblindstepfrequency", NULL) * 1000;
948        unsigned int minsymbolrate = getconfigint("cblindminsignalrate", NULL) * 1000;
949        unsigned int maxsymbolrate = getconfigint("cblindmaxsignalrate", NULL) * 1000;
950        unsigned int stepsymbolrate = getconfigint("cblindstepsignalrate", NULL) * 1000;
951        unsigned int usedefaultsr = getconfigint("cblindusedefaultsr", NULL);
952        unsigned int usedefaultfec = getconfigint("cblindusedefaultfec", NULL);
[36817]953
[19525]954        int minmodulation = 0, maxmodulation = 4, stepmodulation = 1;
955        int minfec = 0, maxfec = 8, stepfec = 1;
956
957        if(usedefaultsr == 1)
958        {
959                minsymbolrate = 0;
960                maxsymbolrate = 3;
961                stepsymbolrate = 1;
962        }
963
964        if(usedefaultfec == 1)
965                maxfec = 6;
966
967        int countfrequency = ((maxfrequency + stepfrequency) - minfrequency) / stepfrequency;
968        int countsymbolrate = ((maxsymbolrate + stepsymbolrate) - minsymbolrate) / stepsymbolrate;
969        int countmodulation = ((maxmodulation + stepmodulation) - minmodulation) / stepmodulation;
970        int countfec = ((maxfec + stepfec) - minfec) / stepfec;
[36817]971
[19525]972        if(onlycalc == 1) return countmodulation * countsymbolrate * countfrequency * countfec;
[36817]973
[19525]974        if(scaninfo.fenode == NULL || timernode == NULL) return -1;
975        int timeout = scaninfo.timeout / 5;
976        if(timeout < 1000000) timeout = 1000000;
977        scaninfo.blindmax += countmodulation * countsymbolrate * countfrequency * countfec;
978
979        for(frequency = minfrequency; frequency <= maxfrequency; frequency += stepfrequency)
980        {
981
982                int csymbolrate = 0;
983                for(csymbolrate = minsymbolrate; csymbolrate <= maxsymbolrate; csymbolrate += stepsymbolrate)
984                {
985                        if(usedefaultsr == 1)
986                        {
987                                switch(csymbolrate)
988                                {
989                                        case 0:
990                                                symbolrate = 22000 * 1000;
991                                                break;
992                                        case 1:
993                                                symbolrate = 27500 * 1000;
994                                                break;
995                                        case 2:
996                                                symbolrate = 30000 * 1000;
997                                                break;
998                                }
999                        }
1000                        else
1001                                symbolrate = csymbolrate;
1002
1003                        for(modulation = minmodulation; modulation <= maxmodulation; modulation += stepmodulation)
1004                        {
1005
1006                                for(fec = minfec; fec <= maxfec; fec += stepfec)
1007                                {
1008                                        scaninfo.blindcount++;
1009
1010                                        tpnode = createtransponder(99, scaninfo.fenode->feinfo->type, scaninfo.orbitalpos, frequency, INVERSION_AUTO, symbolrate, 0, fec, modulation, 0, 0, 0);
1011
1012                                        debug(500, "blindscan: frequ=%d, sr=%d, modulation=%d, fec=%d, orbitalpos=%d", frequency, symbolrate, modulation, fec, scaninfo.orbitalpos);
1013
1014                                        if(tpnode != NULL)
1015                                        {
1016
1017                                                fenode = fegetfree(tpnode, 0, scaninfo.fenode);
1018                                                if(fenode == NULL )
1019                                                {
1020                                                        debug(500, "Frontend for scan not free");
1021                                                        deltransponderbyid(99);
1022                                                        continue;
1023                                                }
1024
1025                                                //frontend tune
1026                                                if(fenode->feinfo->type == FE_QAM)
1027                                                        fetunedvbc(fenode, tpnode);
1028                                                else
1029                                                {
1030                                                        debug(500, "Frontend type unknown");
1031                                                        deltransponderbyid(99);
1032                                                        continue;
1033                                                }
1034
1035                                                festatus = fewait(fenode);
1036                                                if(debug_level == 200) fereadstatus(fenode);
1037                                                if(festatus != 0)
1038                                                {
1039                                                        debug(500, "tuning failed");
1040                                                        deltransponderbyid(99);
1041                                                        continue;
1042                                                }
1043
1044                                                buf = dvbgetsdt(fenode, 0, timeout);
1045                                                transponderid = findtransponderid(fenode, buf);
1046                                                free(buf); buf = NULL;
1047
[36335]1048                                                if(transponderid == 0 || gettransponder(transponderid) != NULL)
[19525]1049                                                {
1050                                                        deltransponderbyid(99);
1051                                                        continue;
1052                                                }
1053
1054                                                if(tpnode->id != transponderid)
1055                                                {
[36353]1056                                                        struct transponder* tphelp = gettransponder(transponderid);
1057                                                        if(tphelp != NULL)
1058                                                        {
1059                                                                deltransponderbyid(transponderid);
[36359]1060                                                                debug(500, "delete old tid: %llu", transponderid);
[36353]1061                                                        }
[19525]1062                                                        scaninfo.newblindcount++;
1063                                                        changetransponderid(tpnode, transponderid);
1064                                                        status.writetransponder = 1;
1065                                                }
1066                                        }
1067                                        deltransponderbyid(99);
1068                                        if(timernode->aktion != START) break;
1069                                }
1070                                if(timernode->aktion != START) break;
1071                        }
1072                        if(timernode->aktion != START) break;
1073                }
1074                if(timernode->aktion != START) break;
1075        }
[36817]1076
[19525]1077        return 0;
1078}
1079
1080unsigned int terrblindscan(struct stimerthread* timernode, int onlycalc)
1081{
1082        int festatus = 0;
1083        uint64_t transponderid = 0;
1084        unsigned char* buf = NULL;
1085        struct dvbdev* fenode = NULL;
1086        struct transponder* tpnode = NULL;
1087
1088        unsigned int frequency = 0;
1089        int hp = 0, lp = 0, modulation = 0, bandwidth = 0, transmission = 0, guardinterval = 0, hierarchy = 0;
1090
1091        unsigned int minfrequency = getconfigint("tblindminfrequency", NULL) * 1000;
1092        unsigned int maxfrequency = getconfigint("tblindmaxfrequency", NULL) * 1000;
1093        unsigned int stepfrequency = getconfigint("tblindstepfrequency", NULL) * 1000;
[36817]1094
[19525]1095        int minhp = 0, maxhp = 3, stephp = 1;
1096        int minlp = 0, maxlp = 3, steplp = 1;
1097        int minmodulation = 0, maxmodulation = 2, stepmodulation = 1;
1098        int minbandwidth = 0, maxbandwidth = 2, stepbandwidth = 1;
1099        int mintransmission = 0, maxtransmission = 1, steptransmission = 1;
1100        int minguardinterval = 0, maxguardinterval = 3, stepguardinterval = 1;
1101        int minhierarchy = 0, maxhierarchy = 3, stephierarchy = 1;
1102
1103        int countfrequency = ((maxfrequency + stepfrequency) - minfrequency) / stepfrequency;
1104        int counthp = ((maxhp + stephp) - minhp) / stephp;
1105        int countlp = ((maxlp + steplp) - minlp) / steplp;
1106        int countmodulation = ((maxmodulation + stepmodulation) - minmodulation) / stepmodulation;
1107        int countbandwidth = ((maxbandwidth + stepbandwidth) - minbandwidth) / stepbandwidth;
1108        int counttransmission = ((maxtransmission + steptransmission) - mintransmission) / steptransmission;
1109        int countguardinterval = ((maxguardinterval + stepguardinterval) - minguardinterval) / stepguardinterval;
1110        int counthierarchy = ((maxhierarchy + stephierarchy) - minhierarchy) / stephierarchy;
[36817]1111
[19525]1112        if(onlycalc == 1) return counthierarchy * countguardinterval * countmodulation * counttransmission * countfrequency * countbandwidth * countlp * counthp;
[36817]1113
[19525]1114        if(scaninfo.fenode == NULL || timernode == NULL) return -1;
1115        int timeout = scaninfo.timeout / 5;
1116        if(timeout < 1000000) timeout = 1000000;
1117        scaninfo.blindmax += counthierarchy * countguardinterval * countmodulation * counttransmission * countfrequency * countbandwidth * countlp * counthp;
1118
1119        for(frequency = minfrequency; frequency <= maxfrequency; frequency += stepfrequency)
1120        {
1121
1122                for(hp = minhp; hp <= maxhp; hp += stephp)
1123                {
1124
1125                        for(lp = minlp; lp <= maxlp; lp += steplp)
1126                        {
1127
1128                                for(modulation = minmodulation; modulation <= maxmodulation; modulation += stepmodulation)
1129                                {
1130
1131                                        for(bandwidth = minbandwidth; bandwidth <= maxbandwidth; bandwidth += stepbandwidth)
1132                                        {
1133
1134                                                for(transmission = mintransmission; transmission <= maxtransmission; transmission += steptransmission)
1135                                                {
[36817]1136
[19525]1137                                                        for(guardinterval = minguardinterval; guardinterval <= maxguardinterval; guardinterval += stepguardinterval)
1138                                                        {
[36817]1139
[19525]1140                                                                for(hierarchy = minhierarchy; hierarchy <= maxhierarchy; hierarchy += stephierarchy)
1141                                                                {
1142                                                                        scaninfo.blindcount++;
[36817]1143
[19525]1144                                                                        tpnode = createtransponder(99, scaninfo.fenode->feinfo->type, scaninfo.orbitalpos, frequency, INVERSION_AUTO, bandwidth, lp, hp, modulation, guardinterval, transmission, hierarchy);
[36817]1145
[19525]1146                                                                        debug(500, "blindscan: frequ=%d, modulation=%d, hp=%d, lp=%d, bandwidth=%d, guardinterval=%d, transmission=%d, hierarchy=%d, orbitalpos=%d", frequency, modulation, hp, lp, bandwidth, guardinterval, transmission, hierarchy, scaninfo.orbitalpos);
[36817]1147
[19525]1148                                                                        if(tpnode != NULL)
1149                                                                        {
[36817]1150
[19525]1151                                                                                fenode = fegetfree(tpnode, 0, scaninfo.fenode);
1152                                                                                if(fenode == NULL )
1153                                                                                {
1154                                                                                        debug(500, "Frontend for scan not free");
1155                                                                                        deltransponderbyid(99);
1156                                                                                        continue;
1157                                                                                }
[36817]1158
[19525]1159                                                                                //frontend tune
1160                                                                                if(fenode->feinfo->type == FE_OFDM)
1161                                                                                {
1162                                                                                        feset(fenode, tpnode);
1163                                                                                        fetunedvbs(fenode, tpnode);
1164                                                                                }
1165                                                                                else
1166                                                                                {
1167                                                                                        debug(500, "Frontend type unknown");
1168                                                                                        deltransponderbyid(99);
1169                                                                                        continue;
1170                                                                                }
[36817]1171
[19525]1172                                                                                festatus = fewait(fenode);
1173                                                                                if(debug_level == 200) fereadstatus(fenode);
1174                                                                                if(festatus != 0)
1175                                                                                {
1176                                                                                        debug(500, "tuning failed");
1177                                                                                        deltransponderbyid(99);
1178                                                                                        continue;
1179                                                                                }
[36817]1180
[19525]1181                                                                                buf = dvbgetsdt(fenode, 0, timeout);
1182                                                                                transponderid = findtransponderid(fenode, buf);
1183                                                                                free(buf); buf = NULL;
[36817]1184
[36335]1185                                                                                if(transponderid == 0 || gettransponder(transponderid) != NULL)
[19525]1186                                                                                {
1187                                                                                        deltransponderbyid(99);
1188                                                                                        continue;
1189                                                                                }
[36817]1190
[19525]1191                                                                                if(tpnode->id != transponderid)
1192                                                                                {
[36353]1193                                                                                        struct transponder* tphelp = gettransponder(transponderid);
1194                                                                                        if(tphelp != NULL)
1195                                                                                        {
1196                                                                                                deltransponderbyid(transponderid);
[36359]1197                                                                                                debug(500, "delete old tid: %llu", transponderid);
[36353]1198                                                                                        }
[19525]1199                                                                                        scaninfo.newblindcount++;
1200                                                                                        changetransponderid(tpnode, transponderid);
1201                                                                                        status.writetransponder = 1;
1202                                                                                }
1203                                                                        }
1204                                                                        deltransponderbyid(99);
1205                                                                        if(timernode->aktion != START) break;
1206                                                                }
1207                                                                if(timernode->aktion != START) break;
1208                                                        }
1209                                                        if(timernode->aktion != START) break;
1210                                                }
1211                                                if(timernode->aktion != START) break;
1212                                        }
1213                                        if(timernode->aktion != START) break;
1214                                }
1215                                if(timernode->aktion != START) break;
1216                        }
1217                        if(timernode->aktion != START) break;
1218                }
1219                if(timernode->aktion != START) break;
1220        }
[36817]1221
[19525]1222        return 0;
1223}
1224
1225void blindscan(struct stimerthread* timernode)
1226{
1227        if(scaninfo.fenode == NULL) return;
[36817]1228
[19525]1229        if(scaninfo.fenode->feinfo->type == FE_QPSK)
1230                satblindscan(timernode, 0);
1231        else if(scaninfo.fenode->feinfo->type == FE_QAM)
1232                cableblindscan(timernode, 0);
1233        else if(scaninfo.fenode->feinfo->type == FE_OFDM)
1234                terrblindscan(timernode, 0);
1235}
1236
[10129]1237void doscan(struct stimerthread* timernode)
[10110]1238{
[10129]1239        int festatus = 0, secnr = 0;
1240        uint8_t lastsecnr = 0xff;
[10110]1241        unsigned char* buf = NULL;
[10129]1242        struct transponder* tpnode = NULL;
[10261]1243        struct dvbdev* fenode = NULL;
[17636]1244        //struct channel* chnode = NULL;
[10338]1245        struct sat* satnode = sat;
[14216]1246        int nitscan = 1;
[9573]1247
[10211]1248        if(scaninfo.fenode == NULL || scaninfo.tpnode == NULL || timernode == NULL)
1249        {
1250                scaninfo.threadend = 1;
1251                return;
1252        }
[9573]1253
[10129]1254        debug(500, "channel scan thread start");
1255
[10338]1256        //sat loop
1257        satnode = sat;
1258        while(satnode != NULL && timernode->aktion == START)
[9573]1259        {
[10338]1260                if(satnode->scan == 0)
[10129]1261                {
[10338]1262                        satnode = satnode->next;
[10129]1263                        continue;
1264                }
[10338]1265                scaninfo.satname = satnode->name;
[10129]1266
[10338]1267                if(scaninfo.scantype == 0)
1268                        tpnode = scaninfo.tpnode;
1269                else if(scaninfo.scantype == 1)
1270                        tpnode = transponder;
1271                else if(scaninfo.scantype == 2 || scaninfo.scantype == 3)
[10129]1272                {
[10338]1273                        tpnode = transponder;
1274                        scaninfo.orbitalpos = satnode->orbitalpos;
[10129]1275                }
[14534]1276
[14586]1277                if(scaninfo.blindscan == 1) blindscan(timernode);
[36817]1278
[14216]1279                nitscan = 1;
[10338]1280                //transponder loop
1281                while(tpnode != NULL && timernode->aktion == START)
[10129]1282                {
[10338]1283                        if(scaninfo.orbitalpos != tpnode->orbitalpos)
1284                        {
1285                                tpnode = tpnode->next;
1286                                if(scaninfo.scantype == 0) break;
1287                                continue;
1288                        }
[36817]1289
[10338]1290                        fenode = fegetfree(tpnode, 0, scaninfo.fenode);
1291                        if(fenode == NULL || (scaninfo.scantype != 3 && fenode != scaninfo.fenode))
1292                        {
1293                                scaninfo.tpcount++;
1294                                tpnode = tpnode->next;
1295                                debug(500, "Frontend for scan not free");
1296                                if(scaninfo.scantype == 0) break;
1297                                continue;
1298                        }
[10129]1299
[10338]1300                        //frontend tune
1301                        if(fenode->feinfo->type == FE_QPSK)
[10326]1302                        {
[10338]1303                                feset(fenode, tpnode);
[24042]1304                                if(fetunedvbs(fenode, tpnode) != 0)
1305                                {
[36335]1306                                        scaninfo.tpcount++;
[36369]1307                                        if(scaninfo.cleartransponder == 1)
[36359]1308                                        {
[36383]1309                                                debug(500, "delete tuning failed id=%llu freq=%d orbitalpos=%d tpnode=%p", tpnode->id, tpnode->frequency, tpnode->orbitalpos, tpnode);
1310                                                deltransponderonscan(tpnode->id, tpnode->frequency, tpnode->orbitalpos);
[36359]1311                                        }
[24042]1312                                        tpnode = tpnode->next;
1313                                        debug(500, "tuning failed");
1314                                        if(scaninfo.scantype == 0) break;
1315                                        continue;
1316                                }
[10326]1317                        }
[10338]1318                        else if(fenode->feinfo->type == FE_QAM)
[24042]1319                        {
[24050]1320                                if(fetunedvbc(fenode, tpnode) != 0)
[24042]1321                                {
[36335]1322                                        scaninfo.tpcount++;
[36369]1323                                        if(scaninfo.cleartransponder == 1)
[36359]1324                                        {
[36383]1325                                                debug(500, "delete tuning failed id=%llu freq=%d orbitalpos=%d tpnode=%p", tpnode->id, tpnode->frequency, tpnode->orbitalpos, tpnode);
1326                                                deltransponderonscan(tpnode->id, tpnode->frequency, tpnode->orbitalpos);
[36359]1327                                        }
[24042]1328                                        tpnode = tpnode->next;
1329                                        debug(500, "tuning failed");
1330                                        if(scaninfo.scantype == 0) break;
1331                                        continue;
1332                                }
1333                        }
[10338]1334                        else if(fenode->feinfo->type == FE_OFDM)
[24042]1335                        {
1336                                if(fetunedvbt(fenode, tpnode) != 0)
1337                                {
[36335]1338                                        scaninfo.tpcount++;
[36369]1339                                        if(scaninfo.cleartransponder == 1)
[36359]1340                                        {
[36383]1341                                                debug(500, "delete tuning failed id=%llu freq=%d orbitalpos=%d tpnode=%p", tpnode->id, tpnode->frequency, tpnode->orbitalpos, tpnode);
1342                                                deltransponderonscan(tpnode->id, tpnode->frequency, tpnode->orbitalpos);
[36359]1343                                        }
[24042]1344                                        tpnode = tpnode->next;
1345                                        debug(500, "tuning failed");
1346                                        if(scaninfo.scantype == 0) break;
1347                                        continue;
1348                                }
1349                        }
[10338]1350                        else
1351                        {
1352                                scaninfo.tpcount++;
1353                                tpnode = tpnode->next;
1354                                debug(500, "Frontend type unknown");
1355                                if(scaninfo.scantype == 0) break;
1356                                continue;
1357                        }
[10326]1358
[10338]1359                        festatus = fewait(fenode);
1360                        if(debug_level == 200) fereadstatus(fenode);
1361                        if(festatus != 0)
1362                        {
1363                                scaninfo.tpcount++;
[36369]1364                                if(scaninfo.cleartransponder == 1)
[36359]1365                                {
[36383]1366                                        debug(500, "delete tuning failed id=%llu freq=%d orbitalpos=%d tpnode=%p", tpnode->id, tpnode->frequency, tpnode->orbitalpos, tpnode);
1367                                        deltransponderonscan(tpnode->id, tpnode->frequency, tpnode->orbitalpos);
[36359]1368                                }
[10338]1369                                tpnode = tpnode->next;
[24042]1370                                debug(500, "tuning failed last");
[10338]1371                                if(scaninfo.scantype == 0) break;
1372                                continue;
1373                        }
1374
1375                        //del channels from transponder if selected
[17636]1376                        //if(scaninfo.scantype != 3 && scaninfo.clear == 1)
1377                        //{
1378                        //      struct channel* tmpchannel = NULL;
1379                        //      chnode = channel;
1380                        //      while(chnode != NULL)
1381                        //      {
1382                        //              tmpchannel = chnode->next;
1383                        //              if(chnode->transponder == tpnode)
1384                        //                      delchannel(chnode->serviceid, chnode->transponderid, 1);
1385                        //              chnode = tmpchannel;
1386                        //      }
1387                        //}
[10338]1388
[14216]1389                        //get nit
1390                        if(scaninfo.networkscan == 1 && nitscan == 1)
1391                        {
1392                                lastsecnr = 0xff;
1393                                secnr = 0;
1394                                while(secnr <= lastsecnr && secnr <= 256)
1395                                {
1396                                        if(timernode->aktion != START) break;
[18239]1397                                        buf = dvbgetnit(fenode, secnr, scaninfo.timeout * 2);
[14216]1398                                        if(buf != NULL)
1399                                        {
1400                                                parsenit(buf, &lastsecnr, satnode->orbitalpos);
[19359]1401                                                nitscan = 1; //1 = scan all transponder for nit / 0 = scan only first transponder for nit
[14216]1402                                        }
1403                                        else
1404                                                break;
1405                                        free(buf); buf = NULL;
1406                                        secnr++;
1407                                }
1408                        }
1409
[10338]1410                        lastsecnr = 0xff;
1411                        secnr = 0;
1412                        while(secnr <= lastsecnr && secnr <= 256)
1413                        {
1414                                if(timernode->aktion != START) break;
[12202]1415#ifndef SIMULATE
[10338]1416                                buf = dvbgetsdt(fenode, secnr, scaninfo.timeout);
[12202]1417#endif
[10338]1418                                if(buf != NULL)
[20631]1419                                        findchannel(fenode, tpnode, buf, &lastsecnr, scaninfo.scanscreen, scaninfo.listbox, scaninfo.changename, 0);
[10338]1420                                else
1421                                        break;
1422                                free(buf); buf = NULL;
1423                                secnr++;
1424                        }
[36817]1425
[10338]1426                        scaninfo.tpcount++;
1427                        if(scaninfo.scantype == 0) break;
1428                        tpnode = tpnode->next;
[10129]1429                }
[10338]1430                if(scaninfo.scantype == 0 || scaninfo.scantype == 1) break;
1431                satnode = satnode->next;
[9573]1432        }
[10165]1433        scaninfo.threadend = 1;
[10129]1434        debug(500, "channel scan thread end");
[9573]1435}
1436
[20631]1437void scanaddchannel(struct skin* node, int scantype, struct transponder* tp1, int ichangename)
[10165]1438{
1439        int serviceid = 0;
[18431]1440        uint64_t transponderid = 0;
[10165]1441        int servicetype = 0;
1442        int providerid = 0;
1443        struct provider* providernode = NULL;
1444        char* tmpstr = NULL;
1445        struct transponder* tp2 = NULL;
[19631]1446        struct channel* chnode = NULL;
[10165]1447
1448        if(node == NULL || node->name == NULL) return;
1449
[18431]1450        serviceid = ((uint64_t*)node->name)[0];
1451        transponderid = ((uint64_t*)node->name)[1];
1452        servicetype = ((uint64_t*)node->name)[2];
[19631]1453
[19634]1454        chnode = getchannel(serviceid, transponderid);
[19807]1455        if(chnode == NULL || (chnode != NULL && chnode->transponder == NULL))
[10165]1456        {
1457                //check if provider valid
1458                providernode = getproviderbyname(node->param1);
1459                if(providernode != NULL)
1460                        providerid = providernode->providerid;
1461                else
1462                {
[14782]1463                        providerid = getlastproviderid() + 1;
[10165]1464                        tmpstr = ostrcat(tmpstr, oitoa(providerid), 1, 1);
1465                        tmpstr = ostrcat(tmpstr, "#", 1, 0);
1466                        tmpstr = ostrcat(tmpstr, node->param1, 1, 0);
1467                        tmpstr = ostrcat(tmpstr, "#0", 1, 0);
1468                        addprovider(tmpstr, 1, NULL);
1469                        free(tmpstr); tmpstr = NULL;
1470                }
1471
1472                //check if transponder valid
1473                if(scantype == 0)
1474                {
[36335]1475                        tp2 = gettransponder(transponderid);
[19806]1476
1477                        if(tp2 == NULL && tp1 != NULL)
1478                        {
[19820]1479                                tp2 = gettransponderbydetail(0, tp1->fetype, tp1->orbitalpos, tp1->frequency, tp1->inversion, tp1->symbolrate, tp1->polarization, tp1->fec, tp1->modulation, tp1->rolloff, tp1->pilot, tp1->system, 1);
1480                                if(tp2 != NULL)
[19806]1481                                        changetransponderid(tp2, transponderid);
1482                        }
1483
[10165]1484                        if(tp2 == NULL) //create new transponder
1485                                copytransponder(tp1, tp2, transponderid);
1486                        else //change transponder
[14218]1487                                copytransponder(tp1, tp2, 99);
[10165]1488                }
1489
[10331]1490                if(servicetype != 0 && servicetype != 1)
[10165]1491                        servicetype = 0;
1492
[19807]1493                if(chnode == NULL)
1494                {
[36335]1495                        if(createchannel(node->param2, transponderid, providerid, serviceid, servicetype, 0, -1, -1, -1, -1, 0, -1) != NULL)
[19807]1496                                node->fontcol = convertcol("deaktivcol");
1497                }
1498                else
[10165]1499                        node->fontcol = convertcol("deaktivcol");
1500        }
[10287]1501        else
[19631]1502        {
[10287]1503                node->fontcol = convertcol("deaktivcol");
[19631]1504                //change channel name if selected
[20631]1505                if(ichangename == 1 && node->param2 != NULL && strlen(node->param2) > 0 && ostrcmp(node->param2, chnode->name) != 0)
[19631]1506                {
[19634]1507                        free(chnode->name);
1508                        chnode->name = ostrcat(node->param2, NULL, 0, 0);
[19649]1509                        status.writetransponder = 1;
[19631]1510                }
1511        }
[10165]1512}
1513
[10338]1514void scansetallsat(int fetype)
[9573]1515{
[12202]1516        int i = 0, orbitalpos = 0;
1517        struct sat* satnode = NULL;
1518        struct dvbdev* dvbnode = dvbdev;
1519        char* tmpstr = NULL, *tmpnr = NULL;
[10338]1520
[12202]1521        while(dvbnode != NULL)
[10338]1522        {
[24221]1523                if(dvbnode->type == FRONTENDDEV && dvbnode->feinfo != NULL && dvbnode->felock < 1 && dvbnode->deactive == 0 && (fetype == -1 || dvbnode->feinfo->type == fetype))
[12202]1524                {
1525
1526                        tmpstr = ostrcat(dvbnode->feshortname, "_sat", 0, 0);
[12521]1527                        for(i = 1; i <= getmaxsat(dvbnode->feshortname); i++)
[12202]1528                        {
1529                                tmpnr = oitoa(i);
1530                                orbitalpos = getconfigint(tmpstr, tmpnr);
1531                                free(tmpnr); tmpnr = NULL;
1532
1533                                satnode = getsatbyorbitalpos(orbitalpos);
[18192]1534                                if(satnode != NULL && (fetype == -1 || satnode->fetype == fetype))
[12202]1535                                        satnode->scan = 1;
1536                        }
1537                        free(tmpstr); tmpstr = NULL;
1538                }
1539                dvbnode = dvbnode->next;
[10338]1540        }
1541}
1542
1543void scansetmultisat(struct skin* scan)
1544{
1545        struct skin* node = scan;
1546        struct sat* satnode = NULL;
1547
1548        while(node != NULL && node->name != NULL)
1549        {
1550                if(ostrcmp(node->ret, "1") == 0)
1551                {
1552                        satnode = getsatbyorbitalpos(atoi(node->name));
1553                        if(satnode != NULL)
1554                                satnode->scan = 1;
1555                }
1556                node = node->next;
1557        }
1558}
1559
[17636]1560void delchannelbysat(int orbitalpos)
1561{
1562        struct transponder* transpondernode = transponder;
1563        struct channel* chnode = NULL;
1564
1565        while(transpondernode != NULL)
1566        {
1567                if(transpondernode->orbitalpos == orbitalpos)
1568                {
[18675]1569                        struct channel* tmpchannel = NULL;
[17636]1570                        chnode = channel;
1571                        while(chnode != NULL)
1572                        {
[18675]1573                                tmpchannel = chnode->next;
[17636]1574                                if(chnode->transponder == transpondernode)
1575                                        delchannel(chnode->serviceid, chnode->transponderid, 1);
[18675]1576                                chnode = tmpchannel;
[17636]1577                        }
1578                }
1579                transpondernode = transpondernode->next;
1580        }
1581}
1582
1583void delchannelbymultisat()
1584{
1585        struct sat* satnode = sat;
1586
1587        while(satnode != NULL)
1588        {
1589                if(satnode->scan == 1)
1590                        delchannelbysat(satnode->orbitalpos);
1591                satnode = satnode->next;
1592        }
1593}
1594
[36369]1595void screenscan(struct transponder* transpondernode, struct skin* mscan, char* tuner, int scantype, int orbitalpos, unsigned int frequency, int inversion, unsigned int symbolrate, int polarization, int fec, int modulation, int rolloff, int pilot, int networkscan, int onlyfree, int clear, int blindscan, int ichangename, int system, int favtype, int emptybouquet, int unusedbouquetchannels, int unusedsatprovider, int cleartransponder, int timeout, int flag)
[10338]1596{
[36358]1597        int rcret = 0, tpmax = 0, i = 0, alladded = 0, endmsgshow = 0, tpdel = 0;
[30470]1598
1599        struct skin* scan = NULL;
1600        if(flag == 1)
1601                scan = getscreen("scanauto");
1602        else
1603                scan = getscreen("scanmanual");
1604
[10110]1605        struct skin* progress = getscreennode(scan, "progress");
[9573]1606        struct skin* listbox = getscreennode(scan, "listbox");
[10338]1607        struct skin* satname = getscreennode(scan, "satname");
[9573]1608        struct skin* tpcount = getscreennode(scan, "tpcount");
1609        struct skin* foundtv = getscreennode(scan, "foundtv");
[10129]1610        struct skin* foundradio = getscreennode(scan, "foundradio");
[9573]1611        struct skin* founddata = getscreennode(scan, "founddata");
[14586]1612        struct skin* foundblind = getscreennode(scan, "foundblind");
[12202]1613        struct skin* b2 = getscreennode(scan, "b2");
1614        struct skin* b3 = getscreennode(scan, "b3");
[22445]1615        struct skin* load = getscreen("loading");
[9573]1616        struct transponder* tpnode = NULL;
[10129]1617        struct dvbdev* fenode = NULL, *dvbnode = dvbdev;
1618        struct stimerthread* timernode = NULL;
[10338]1619        struct sat* satnode = NULL;
[11402]1620        struct channel* chnode = NULL;
[10129]1621        char* tmpstr = NULL;
[9573]1622
[10110]1623        listbox->aktline = 1;
1624        listbox->aktpage = -1;
1625        progress->progresssize = 0;
[10129]1626        memset(&scaninfo, 0, sizeof(struct scaninfo));
[10110]1627
[12202]1628        b2->hidden = NO;
1629        b3->hidden = NO;
1630
[10129]1631        addscreenrc(scan, listbox);
[10338]1632        if(scantype != 3)
[10129]1633        {
[10338]1634                while(dvbnode != NULL)
[10129]1635                {
[18177]1636                        if(dvbnode->type == FRONTENDDEV && dvbnode->feinfo != NULL && dvbnode->felock < 1)
[10129]1637                        {
[10338]1638                                if(ostrcmp(dvbnode->feshortname, tuner) == 0)
1639                                {
1640                                        fenode = dvbnode;
1641                                        break;
1642                                }
[10129]1643                        }
[10338]1644                        dvbnode = dvbnode->next;
[10129]1645                }
[10338]1646                if(fenode == NULL) return;
[10129]1647        }
[10338]1648        else if(scantype == 3)
1649                fenode = dvbdev;
[9573]1650
[10129]1651        if(scantype == 0) //single transponder
[10110]1652        {
1653                if(fenode != NULL && fenode->feinfo != NULL)
[10254]1654                {
[11402]1655                        //del channels from transponder if selected
1656                        if(clear == 1)
1657                        {
[18675]1658                                struct channel* tmpchannel = NULL;
[11402]1659                                chnode = channel;
1660                                while(chnode != NULL)
1661                                {
[18675]1662                                        tmpchannel = chnode->next;
[11402]1663                                        if(chnode->transponder == transpondernode)
1664                                                delchannel(chnode->serviceid, chnode->transponderid, 1);
[18675]1665                                        chnode = tmpchannel;
[11402]1666                                }
1667                        }
1668
[10338]1669                        debug(500, "fetype=%d, orbitalpos=%d, frequ=%d, inverion=%d, symbolrate=%d, polarization=%d, fec=%d, modulation=%d, rolloff=%d, pilot=%d, system=%d", fenode->feinfo->type, orbitalpos, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, system);
[14218]1670                        tpnode = createtransponder(99, fenode->feinfo->type, orbitalpos, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, system);
[10254]1671                }
[10338]1672                if(tpnode != NULL)
1673                {
1674                        tpmax = 1;
1675                        satnode = getsatbyorbitalpos(tpnode->orbitalpos);
1676                        if(satnode != NULL) satnode->scan = 1;
1677                }
[10110]1678        }
[10129]1679        else if(scantype == 1) //single sat
1680        {
[17636]1681                if(clear == 1) delchannelbysat(orbitalpos);
[10129]1682                tpnode = transponder;
1683                while(tpnode != NULL)
1684                {
[10338]1685                        if(tpnode->orbitalpos == orbitalpos)
[10129]1686                                tpmax++;
1687                        tpnode = tpnode->next;
1688                }
1689                tpnode = transponder;
[10338]1690                satnode = getsatbyorbitalpos(orbitalpos);
1691                if(satnode != NULL) satnode->scan = 1;
[10129]1692        }
[10338]1693        else if(scantype == 2 || scantype == 3) //2: multi sat, 3: all
1694        {
[17636]1695                if(scantype == 2)
1696                {
1697                        scansetmultisat(mscan);
1698                        if(clear == 1) delchannelbymultisat();
1699                }
[12202]1700                if(scantype == 3)
1701                {
[18192]1702                        scansetallsat(-1);
[12202]1703                        b2->hidden = YES;
1704                        b3->hidden = YES;
1705                        //del all channel for auto. search
[36336]1706                        if(clear == 1)
1707                        {
1708                                freechannel(1);
[36369]1709                                if(unusedsatprovider == 1)
1710                                {
1711                                        delunusedsat();
1712                                        delunusedtransponder();
1713                                        delunusedchannel();
1714                                        //delunusedepgchannel();
1715                                        delunusedprovider();
1716                                }
[36336]1717                        }
[12202]1718                }
[36336]1719
[10338]1720                satnode = sat;
1721                while(satnode != NULL)
1722                {
1723                        if(satnode->scan != 0)
1724                        {
1725                                tpnode = transponder;
1726                                while(tpnode != NULL)
1727                                {
1728                                        if(tpnode->orbitalpos == satnode->orbitalpos)
1729                                                tpmax++;
1730                                        tpnode = tpnode->next;
1731                                }
1732                        }
1733                        satnode = satnode->next;
1734                }
1735                tpnode = transponder;
1736        }
[9573]1737
[10129]1738        scaninfo.fenode = fenode;
1739        scaninfo.tpnode = tpnode;
1740        scaninfo.scanscreen = scan;
1741        scaninfo.listbox = listbox;
1742        scaninfo.timeout = timeout;
1743        scaninfo.scantype = scantype;
[10338]1744        scaninfo.orbitalpos = orbitalpos;
[10165]1745        scaninfo.onlyfree = onlyfree;
[14050]1746        scaninfo.networkscan = networkscan;
[14550]1747        scaninfo.blindscan = blindscan;
[20631]1748        scaninfo.changename = ichangename;
[10326]1749        scaninfo.clear = clear;
[14218]1750        scaninfo.tpmax = tpmax;
[36358]1751        scaninfo.tpdel = tpdel;
[36369]1752        scaninfo.cleartransponder = cleartransponder;
[10129]1753        timernode = addtimer(&doscan, START, 1000, 1, NULL, NULL, NULL);
[9573]1754
[10129]1755        while(1)
[10110]1756        {
[10338]1757                //satname
[18177]1758                tmpstr = ostrcat(tmpstr, _("Sat/Provider: "), 1, 0);
[10338]1759                tmpstr = ostrcat(tmpstr, scaninfo.satname, 1, 0);
1760                changetext(satname, tmpstr);
1761                free(tmpstr); tmpstr = NULL;
1762
[10129]1763                //transpondercount
[10338]1764                tmpstr = ostrcat(tmpstr, _("Transponder: "), 1, 0);
[10129]1765                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.tpcount), 1, 1);
1766                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
[14218]1767                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.tpmax), 1, 1);
[36817]1768                tmpstr = ostrcat(tmpstr, _(" New: "), 1, 0);
[18239]1769                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.tpnew), 1, 1);
[36817]1770                tmpstr = ostrcat(tmpstr, _(" Del: "), 1, 0);
[36358]1771                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.tpdel), 1, 1);
[10254]1772                changetext(tpcount, tmpstr);
[10129]1773                free(tmpstr); tmpstr = NULL;
1774
1775                //tvcount
[10335]1776                tmpstr = ostrcat(tmpstr, _("TV: "), 1, 0);
[10129]1777                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.newtvcount), 1, 1);
1778                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1779                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.tvcount), 1, 1);
[10254]1780                changetext(foundtv, tmpstr);
[10129]1781                free(tmpstr); tmpstr = NULL;
1782
1783                //radiocount
[10335]1784                tmpstr = ostrcat(tmpstr, _("Radio: "), 1, 0);
[10129]1785                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.newradiocount), 1, 1);
1786                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1787                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.radiocount), 1, 1);
[10254]1788                changetext(foundradio, tmpstr);
[10129]1789                free(tmpstr); tmpstr = NULL;
1790
1791                //datacount
[10254]1792                tmpstr = ostrcat(tmpstr, _("Data: "), 1, 0);
[10129]1793                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.newdatacount), 1, 1);
1794                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1795                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.datacount), 1, 1);
[10254]1796                changetext(founddata, tmpstr);
[10129]1797                free(tmpstr); tmpstr = NULL;
1798
[14586]1799                //blindcount
1800                tmpstr = ostrcat(tmpstr, _("Blindscan: "), 1, 0);
1801                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.newblindcount), 1, 1);
1802                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1803                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.blindcount), 1, 1);
1804                tmpstr = ostrcat(tmpstr, " / ", 1, 0);
1805                tmpstr = ostrcat(tmpstr, oitoa(scaninfo.blindmax), 1, 1);
1806                changetext(foundblind, tmpstr);
1807                free(tmpstr); tmpstr = NULL;
1808
[14218]1809                if(scaninfo.tpmax == 0)
[10165]1810                        progress->progresssize = 100;
1811                else
[14218]1812                        progress->progresssize = (100 / (float)scaninfo.tpmax) * scaninfo.tpcount;
[10129]1813
[16511]1814                drawscreen(scan, 0, 0);
[10129]1815                rcret = waitrc(scan, 1000, 0);
[36817]1816
[24240]1817                if(scantype != 3 && scaninfo.threadend == 1 && endmsgshow == 0)
1818                {
[24248]1819                        if(scaninfo.tvcount + scaninfo.radiocount + scaninfo.datacount == 0)
[34468]1820                                textbox(_("Message"), _("Channel scan ended.\nNothing found."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0);
[24248]1821                        else
[34468]1822                                textbox(_("Message"), _("Channel scan ended."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0);
[36817]1823                        endmsgshow = 1;
[24240]1824                }
[12202]1825
1826                if(scantype != 3 && rcret == getrcconfigint("rcred", NULL))
[20631]1827                        scanaddchannel(listbox->select, scantype, tpnode, ichangename);
[12202]1828
1829                if((scantype != 3 && rcret == getrcconfigint("rcgreen", NULL)) || (scantype == 3 && scaninfo.threadend == 1 && alladded < 2))
1830                {
1831                        struct skin* lnode = listbox;
[17641]1832
[12202]1833                        long deaktivcol = convertcol("deaktivcol");
[14323]1834                        if(scantype == 3 && alladded == 0)
[12202]1835                        {
1836                                alladded = 1;
1837                                continue;
1838                        }
1839                        alladded = 2;
[17641]1840
1841                        drawscreen(load, 0, 0);
[12202]1842                        while(lnode != NULL)
1843                        {
1844                                if(lnode->fontcol != deaktivcol && lnode->del == 1)
[20631]1845                                        scanaddchannel(lnode, scantype, tpnode, ichangename);
[12202]1846                                lnode = lnode->next;
1847                        }
[17641]1848                        clearscreen(load);
[24248]1849                        if(scaninfo.tvcount + scaninfo.radiocount + scaninfo.datacount == 0)
[34468]1850                                textbox(_("Message"), _("Channel scan ended.\nNothing found."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0);
[24248]1851                        else
[36820]1852                                textbox(_("Message"), _("Scan completed, changes have been saved."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0);
[12202]1853                }
1854
[10129]1855                if(rcret == getrcconfigint("rcexit", NULL))
1856                {
[10740]1857                        if(timernode != NULL && scaninfo.threadend == 0)
[10129]1858                        {
1859                                timernode->aktion = STOP;
[19360]1860                                while(i < 4 && scaninfo.threadend == 0)
[10211]1861                                {
[24284]1862                                        textbox(_("Message"), _("Wait for channel scan end"), NULL, 0, NULL, 0, NULL, 0, NULL, 0, 800, 200, 3, 0);
[10211]1863                                        i++;
1864                                }
[10129]1865                        }
1866                        break;
1867                }
[10110]1868        }
[9573]1869
[15143]1870        if(scantype == 0) deltransponderbyid(99);
[14329]1871        if(clear == 1)
1872        {
[24218]1873                // favtype 0 = unchanged
1874                // favtype 1 = create new
1875                // favtype 2 = delete
1876
1877                if(favtype == 1)
[24159]1878                {
[24160]1879                        freemainbouquet(1);
[24159]1880                        struct provider *pnode = provider;
[36817]1881
[24159]1882                        while(pnode != NULL)
1883                        {
[24223]1884                                provider2bouquet(pnode->providerid, 1);
[24159]1885                                pnode = pnode->next;
1886                        }
1887                }
[24218]1888                else if(favtype == 2)
1889                        freemainbouquet(1);
1890
[24222]1891                if(emptybouquet == 1)
1892                        delemptymainbouquet(1);
[36817]1893
[24226]1894                if(unusedbouquetchannels == 1)
[14337]1895                        delunusedbouquetchannels(0);
1896                else
1897                        delunusedbouquetchannels(1);
[36817]1898
[36404]1899                if(cleartransponder == 1 && unusedsatprovider == 1)
1900                        deltransponderbyid(0);
[14329]1901        }
[10110]1902        delmarkedscreennodes(scan, 1);
[10129]1903        delownerrc(scan);
[10110]1904        clearscreen(scan);
[10338]1905        resetsatscan();
[22445]1906        drawscreen(load, 0, 0);
[36336]1907        sortchannel();
1908        sortprovider();
1909        clearscreen(load);
[9573]1910}
1911
[19414]1912void changescantype(char* scantype, struct skin* scan, struct skin* listbox, struct skin* tuner, struct skin* satellite, struct skin* id, struct skin* system, struct skin* frequency, struct skin* inversion, struct skin* symbolrate, struct skin* polarization, struct skin* fec, struct skin* modulation, struct skin* rolloff, struct skin* pilot, struct skin* hp, struct skin* lp, struct skin* bandwidth, struct skin* transmission, struct skin* guardinterval, struct skin* hierarchy, struct skin* b4, struct skin* b5, int flag)
[9590]1913{
1914        struct sat* satnode = sat;
1915        struct skin* tmp = NULL;
[10338]1916        char* tmpstr = NULL, *tmpstr1 = NULL, *tmpnr = NULL;
1917        char* feshortname = NULL;
1918        int i, orbitalpos = 0;
[9590]1919
[10338]1920        if(tuner != NULL) feshortname = tuner->ret;
1921
[10343]1922        tuner->hidden = NO;
[19327]1923        id->hidden = NO;
[9590]1924        system->hidden = NO;
1925        frequency->hidden = NO;
1926        inversion->hidden = NO;
1927        symbolrate->hidden = NO;
1928        polarization->hidden = NO;
1929        fec->hidden = NO;
1930        modulation->hidden = NO;
1931        rolloff->hidden = NO;
1932        pilot->hidden = NO;
[19414]1933        hp->hidden = NO;
1934        lp->hidden = NO;
1935        bandwidth->hidden = NO;
1936        transmission->hidden = NO;
1937        guardinterval->hidden = NO;
1938        hierarchy->hidden = NO;
[9590]1939        satellite->hidden = NO;
[19332]1940        b4->hidden = NO;
1941        b5->hidden = NO;
[9590]1942        delmarkedscreennodes(scan, 1);
1943
[19439]1944        if(flag == 0 && ostrcmp(scantype, "0") == 0 && ostrcmp(system->ret, "0") == 0)
[19399]1945        {
1946                modulation->hidden = YES;
1947                rolloff->hidden = YES;
1948                pilot->hidden = YES;
1949        }
1950
[10338]1951        if(ostrcmp(scantype, "1") == 0 || ostrcmp(scantype, "2") == 0 || ostrcmp(scantype, "3") == 0)
[9590]1952        {
[19327]1953                id->hidden = YES;
[9590]1954                system->hidden = YES;
1955                frequency->hidden = YES;
1956                inversion->hidden = YES;
1957                symbolrate->hidden = YES;
1958                polarization->hidden = YES;
1959                fec->hidden = YES;
1960                modulation->hidden = YES;
1961                rolloff->hidden = YES;
1962                pilot->hidden = YES;
[19414]1963                hp->hidden = YES;
1964                lp->hidden = YES;
1965                bandwidth->hidden = YES;
1966                transmission->hidden = YES;
1967                guardinterval->hidden = YES;
1968                hierarchy->hidden = YES;
[19332]1969                b4->hidden = YES;
1970                b5->hidden = YES;
[9590]1971        }
[10338]1972        if(ostrcmp(scantype, "2") == 0 && feshortname != NULL)
[9590]1973        {
1974                satellite->hidden = YES;
[10338]1975
1976                tmpstr = ostrcat(feshortname, "_sat", 0, 0);
[12521]1977                for(i = 1; i <= getmaxsat(feshortname); i++)
[9590]1978                {
[10338]1979                        tmpnr = oitoa(i);
1980                        orbitalpos = getconfigint(tmpstr, tmpnr);
1981                        free(tmpnr); tmpnr = NULL;
1982
1983                        satnode = getsatbyorbitalpos(orbitalpos);
1984                        if(satnode != NULL && satnode->fetype == FE_QPSK)
[9590]1985                        {
1986                                tmp = addlistbox(scan, listbox, tmp, 1);
1987                                if(tmp != NULL)
1988                                {
[10338]1989                                        tmpstr1 = oitoa(satnode->orbitalpos);
1990                                        changename(tmp, tmpstr1);
1991                                        free(tmpstr1); tmpstr1 = NULL;
[10254]1992                                        changetext(tmp, satnode->name);
[9590]1993                                        tmp->type = CHOICEBOX;
1994                                        addchoicebox(tmp, "0", _("no"));
1995                                        addchoicebox(tmp, "1", _("yes"));
1996                                }
1997                        }
1998                }
[10338]1999                free(tmpstr); tmpstr = NULL;
[9590]2000        }
[10338]2001        if(ostrcmp(scantype, "3") == 0)
2002        {
2003                tuner->hidden = YES;
2004                satellite->hidden = YES;
2005        }
[18177]2006
[18192]2007        if(flag == 2)
[18177]2008        {
2009                system->hidden = YES;
2010                inversion->hidden = YES;
2011                polarization->hidden = YES;
2012                rolloff->hidden = YES;
2013                pilot->hidden = YES;
2014                satellite->hidden = YES;
2015        }
[19414]2016
2017        if(flag == 3)
2018        {
2019                system->hidden = YES;
2020                polarization->hidden = YES;
2021                rolloff->hidden = YES;
2022                pilot->hidden = YES;
2023                satellite->hidden = YES;
2024                symbolrate->hidden = YES;
2025                fec->hidden = YES;
2026        }
2027        else
2028        {
2029                hp->hidden = YES;
2030                lp->hidden = YES;
2031                bandwidth->hidden = YES;
2032                transmission->hidden = YES;
2033                guardinterval->hidden = YES;
2034                hierarchy->hidden = YES;
2035        }
[9590]2036}
2037
[10254]2038void scanchangesat(struct skin* sat, struct transponder* tpnode, char* feshortname)
2039{
2040        char* tmpstr = NULL;
2041
[10281]2042        changeinput(sat, NULL);
2043        changechoiceboxvalue(sat, NULL);
[18165]2044        tmpstr = getsatstring(feshortname, FE_QPSK);
[10254]2045        changeinput(sat, tmpstr);
2046        free(tmpstr); tmpstr = NULL;
[18165]2047        tmpstr = getorbitalposstring(feshortname, FE_QPSK);
[10254]2048        changechoiceboxvalue(sat, tmpstr);
2049        free(tmpstr); tmpstr = NULL;
2050        if(tpnode != NULL)
2051        {
2052                tmpstr = oitoa(tpnode->orbitalpos);
2053                setchoiceboxselection(sat, tmpstr);
2054                free(tmpstr); tmpstr = NULL;
2055        }
2056}
2057
[18192]2058//flag 0: manual scan (DVB-S)
2059//flag 1: auto scan (all)
2060//flag 2: manual scan (DVB-C)
2061//flag 3: manual scan (DVB-T)
[10338]2062void screenscanconfig(int flag)
[9546]2063{
[18177]2064        int rcret = 0, fetype = -1;
[14784]2065        unsigned int ifrequency = -1, isymbolrate = -1;
2066        int iscantype = -1, isat = -1;
2067        int iinversion = -1, ipolarization = -1;
[14550]2068        int ifec = -1, imodulation = -1, irolloff = -1, ipilot = -1, isystem = -1;
[24228]2069        int inetworkscan = -1, ionlyfree = -1, iclear = -1, iblindscan = -1, ichangename = -1;
2070        int ifavtype = -1, iemptybouquet = -1, iunusedbouquetchannels = -1;
[36369]2071        int iunusedsatprovider = -1, icleartransponder = -1;
[36336]2072
[10269]2073        int i = 0, treffer = 0, tunercount = 0;
[36817]2074
[30463]2075        struct skin* scan = NULL;
2076        if(flag == 1)
[30470]2077                scan = getscreen("scanadjustauto");
[30463]2078        else
[30470]2079                scan = getscreen("scanadjustmanual");
[30463]2080
[9546]2081        struct skin* listbox = getscreennode(scan, "listbox");
2082        struct skin* tuner = getscreennode(scan, "tuner");
2083        struct skin* scantype = getscreennode(scan, "scantype");
[9590]2084        struct skin* sat = getscreennode(scan, "sat");
[19327]2085        struct skin* id = getscreennode(scan, "id");
[9573]2086        struct skin* system = getscreennode(scan, "system");
[9546]2087        struct skin* frequency = getscreennode(scan, "frequency");
2088        struct skin* inversion = getscreennode(scan, "inversion");
2089        struct skin* symbolrate = getscreennode(scan, "symbolrate");
2090        struct skin* polarization = getscreennode(scan, "polarization");
2091        struct skin* fec = getscreennode(scan, "fec");
2092        struct skin* modulation = getscreennode(scan, "modulation");
2093        struct skin* rolloff = getscreennode(scan, "rolloff");
2094        struct skin* pilot = getscreennode(scan, "pilot");
[19414]2095        struct skin* hp = getscreennode(scan, "hp");
2096        struct skin* lp = getscreennode(scan, "lp");
2097        struct skin* bandwidth = getscreennode(scan, "bandwidth");
2098        struct skin* transmission = getscreennode(scan, "transmission");
2099        struct skin* guardinterval = getscreennode(scan, "guardinterval");
2100        struct skin* hierarchy = getscreennode(scan, "hierarchy");
[9546]2101        struct skin* networkscan = getscreennode(scan, "networkscan");
2102        struct skin* clear = getscreennode(scan, "clear");
[9573]2103        struct skin* onlyfree = getscreennode(scan, "onlyfree");
[14550]2104        struct skin* blindscan = getscreennode(scan, "blindscan");
[19631]2105        struct skin* changename = getscreennode(scan, "changename");
[24209]2106        struct skin* favtype = getscreennode(scan, "favtype");
[24218]2107        struct skin* emptybouquet = getscreennode(scan, "emptybouquet");
[36369]2108        struct skin* unusedsatprovider = getscreennode(scan, "unusedsatprovider");
2109        struct skin* cleartransponder = getscreennode(scan, "cleartransponder");
[24226]2110        struct skin* unusedbouquetchannels = getscreennode(scan, "unusedbouquetchannels");
[36336]2111
[19332]2112        struct skin* b4 = getscreennode(scan, "b4");
2113        struct skin* b5 = getscreennode(scan, "b5");
[9546]2114        struct skin* tmp = NULL;
[10269]2115        char* tmpstr = NULL, *tmpnr = NULL, *feshortname = NULL;
[9573]2116        struct transponder* tpnode = NULL;
[10129]2117        struct dvbdev* dvbnode = dvbdev;
[36817]2118
[14055]2119        listbox->aktline = 1;
2120        listbox->aktpage = -1;
[9546]2121
[10110]2122        if(status.recording > 0 || status.streaming > 0)
2123        {
[34468]2124                textbox(_("Message"), _("Scan is not allowed if record or stream is running !"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0);
[10110]2125                return;
2126        }
2127
[10343]2128        //del old values
[10281]2129        changeinput(tuner, NULL);
2130        changechoiceboxvalue(tuner, NULL);
[10343]2131        changeinput(scantype, NULL);
2132        changechoiceboxvalue(scantype, NULL);
2133        changeinput(sat, NULL);
2134        changechoiceboxvalue(sat, NULL);
2135        changeinput(system, NULL);
2136        changechoiceboxvalue(system, NULL);
2137        changeinput(inversion, NULL);
2138        changechoiceboxvalue(inversion, NULL);
2139        changeinput(polarization, NULL);
2140        changechoiceboxvalue(polarization, NULL);
2141        changeinput(fec, NULL);
2142        changechoiceboxvalue(fec, NULL);
2143        changeinput(modulation, NULL);
2144        changechoiceboxvalue(modulation, NULL);
2145        changeinput(rolloff, NULL);
2146        changechoiceboxvalue(rolloff, NULL);
2147        changeinput(pilot, NULL);
2148        changechoiceboxvalue(pilot, NULL);
[19414]2149        changeinput(hp, NULL);
2150        changeinput(lp, NULL);
2151        changeinput(bandwidth, NULL);
2152        changeinput(transmission, NULL);
2153        changeinput(guardinterval, NULL);
2154        changeinput(hierarchy, NULL);
2155        changechoiceboxvalue(hp, NULL);
2156        changechoiceboxvalue(lp, NULL);
2157        changechoiceboxvalue(bandwidth, NULL);
2158        changechoiceboxvalue(transmission, NULL);
2159        changechoiceboxvalue(guardinterval, NULL);
2160        changechoiceboxvalue(hierarchy, NULL);
[10343]2161
[19399]2162        frequency->aktpage = 0;
2163        symbolrate->aktpage = 0;
2164
[18192]2165        if(flag == 0) fetype = FE_QPSK;
2166        if(flag == 2) fetype = FE_QAM;
2167        if(flag == 3) fetype = FE_OFDM;
[18177]2168
[10343]2169        //tuner
[10129]2170        while(dvbnode != NULL)
2171        {
[24221]2172                if(dvbnode->type == FRONTENDDEV && dvbnode->feinfo != NULL && dvbnode->felock < 1 && dvbnode->deactive == 0 && (flag == 1 || dvbnode->feinfo->type == fetype))
[10129]2173                {
[10269]2174                        treffer = 0;
2175                        if(dvbnode->feshortname != NULL)
2176                        {
2177                                tmpstr = ostrcat(dvbnode->feshortname, "_sat", 0, 0);
[12521]2178                                for(i = 1; i <= getmaxsat(dvbnode->feshortname); i++)
[10269]2179                                {
2180                                        tmpnr = oitoa(i);
2181                                        if(getconfigint(tmpstr, tmpnr) != 0)
2182                                        {
2183                                                treffer = 1;
2184                                                break;
2185                                        }
2186                                        free(tmpnr); tmpnr = NULL;
2187                                }
2188                                free(tmpnr); tmpnr = NULL;
2189                                free(tmpstr); tmpstr = NULL;
2190                        }
2191
2192                        if(treffer == 0)
2193                        {
2194                                dvbnode = dvbnode->next;
2195                                continue;
2196                        }
2197
2198                        tunercount++;
[10254]2199                        if(feshortname == NULL) feshortname = dvbnode->feshortname;
[10269]2200
[10129]2201                        tmpstr = ostrcat(tmpstr, dvbnode->feinfo->name, 1, 0);
2202                        tmpstr = ostrcat(tmpstr, " (", 1, 0);
2203                        tmpstr = ostrcat(tmpstr, oitoa(dvbnode->adapter), 1, 1);
2204                        tmpstr = ostrcat(tmpstr, "/", 1, 0);
2205                        tmpstr = ostrcat(tmpstr, oitoa(dvbnode->devnr), 1, 1);
2206                        tmpstr = ostrcat(tmpstr, ")", 1, 0);
2207                        addchoicebox(tuner, dvbnode->feshortname, tmpstr);
2208                        free(tmpstr); tmpstr = NULL;
2209                }
2210                dvbnode = dvbnode->next;
2211        }
[9546]2212
[10269]2213        if(tunercount < 1)
2214        {
[34468]2215                textbox(_("Message"), _("No Tuner configured"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0);
[10269]2216                return;
2217        }
2218
2219        rcret = servicestop(status.aktservice, 1, 1);
[19440]2220        if(rcret == 1) return;
[10269]2221
2222        if(status.aktservice->channel != NULL)
2223                tpnode = status.aktservice->channel->transponder;
[36817]2224
[24157]2225        //clear akt and last channel, so all channel can delete
2226        freechannelhistory();
2227        status.lastservice->channel = NULL;
2228        status.aktservice->channel = NULL;
[10269]2229
[19328]2230start:
[10269]2231
[10338]2232        if(flag == 0)
2233        {
2234                addchoicebox(scantype, "0", _("Single Transponder"));
2235                addchoicebox(scantype, "1", _("Single Sat"));
2236                addchoicebox(scantype, "2", _("Multi Sat"));
2237                setchoiceboxselection(scantype, "0");
2238        }
[18192]2239        else if(flag == 2 || flag == 3)
[18177]2240        {
2241                addchoicebox(scantype, "0", _("Single Transponder"));
2242                addchoicebox(scantype, "1", _("Single Provider"));
2243                setchoiceboxselection(scantype, "0");
2244        }
[10338]2245        else
2246        {
2247                addchoicebox(scantype, "3", _("Auto Scan"));
2248                setchoiceboxselection(scantype, "3");
2249        }
[9546]2250
2251        //sat
[10254]2252        scanchangesat(sat, tpnode, feshortname);
[9546]2253
[19327]2254        //id
2255        if(tpnode != NULL)
2256                tmpstr = ollutoa(tpnode->id);
2257        changeinput(id, tmpstr);
2258        free(tmpstr); tmpstr = NULL;
2259
[9573]2260        //system
[11023]2261        tmpstr = transpondergetsystemstr(tpnode, 1);
[9573]2262        changeinput(system, tmpstr);
2263        free(tmpstr); tmpstr = NULL;
[11023]2264        tmpstr = transpondergetsystemstr(tpnode, 2);
[9573]2265        changechoiceboxvalue(system, tmpstr);
2266        free(tmpstr); tmpstr = NULL;
2267        if(tpnode != NULL)
2268        {
2269                tmpstr = oitoa(tpnode->system);
2270                setchoiceboxselection(system, tmpstr);
2271                free(tmpstr); tmpstr = NULL;
2272        }
2273
[9546]2274        //frequency
[9573]2275        if(tpnode != NULL)
2276                tmpstr = oitoa(tpnode->frequency / 1000);
[9546]2277        else
[19562]2278        {
2279                if(flag == 3)
2280                        tmpstr = ostrcat(tmpstr, "000000", 1, 0);
2281                else
2282                        tmpstr = ostrcat(tmpstr, "00000", 1, 0);
2283        }
[19563]2284        if(flag == 2 || flag == 3)
[19562]2285        {
2286                changemask(frequency, "000000");
2287                changeinput(frequency, tmpstr);
2288                frequency->input = mask(frequency->input, 6, "0");
2289        }
2290        else
2291        {
2292                changemask(frequency, "00000");
2293                changeinput(frequency, tmpstr);
2294                frequency->input = mask(frequency->input, 5, "0");
2295        }
[9546]2296        free(tmpstr); tmpstr = NULL;
2297
[9573]2298        //inversion
[11023]2299        tmpstr = transpondergetinversionstr(tpnode, 1);
[9573]2300        changeinput(inversion, tmpstr);
2301        free(tmpstr); tmpstr = NULL;
[11023]2302        tmpstr = transpondergetinversionstr(tpnode, 2);
[9573]2303        changechoiceboxvalue(inversion, tmpstr);
2304        free(tmpstr); tmpstr = NULL;
2305        if(tpnode != NULL)
2306        {
2307                tmpstr = oitoa(tpnode->inversion);
2308                setchoiceboxselection(inversion, tmpstr);
2309                free(tmpstr); tmpstr = NULL;
2310        }
2311
2312        //symbolrate
2313        if(tpnode != NULL)
2314                tmpstr = oitoa(tpnode->symbolrate / 1000);
2315        else
2316                tmpstr = ostrcat(tmpstr, "00000", 1, 0);
2317        changemask(symbolrate, "00000");
2318        changeinput(symbolrate, tmpstr);
[19542]2319        symbolrate->input = mask(symbolrate->input, 5, "0");
[9573]2320        free(tmpstr); tmpstr = NULL;
2321
2322        //polarization
[11023]2323        tmpstr = transpondergetpolarizationstr(tpnode, 1);
[9573]2324        changeinput(polarization, tmpstr);
2325        free(tmpstr); tmpstr = NULL;
[11023]2326        tmpstr = transpondergetpolarizationstr(tpnode, 2);
[9573]2327        changechoiceboxvalue(polarization, tmpstr);
2328        free(tmpstr); tmpstr = NULL;
2329        if(tpnode != NULL)
2330        {
2331                tmpstr = oitoa(tpnode->polarization);
2332                setchoiceboxselection(polarization, tmpstr);
2333                free(tmpstr); tmpstr = NULL;
2334        }
2335
2336        //fec
[19440]2337        tmpstr = transpondergetfecstr(tpnode, fetype, 1);
[9573]2338        changeinput(fec, tmpstr);
2339        free(tmpstr); tmpstr = NULL;
[19440]2340        tmpstr = transpondergetfecstr(tpnode, fetype, 2);
[9573]2341        changechoiceboxvalue(fec, tmpstr);
2342        free(tmpstr); tmpstr = NULL;
2343        if(tpnode != NULL)
2344        {
2345                tmpstr = oitoa(tpnode->fec);
2346                setchoiceboxselection(fec, tmpstr);
2347                free(tmpstr); tmpstr = NULL;
2348        }
2349
2350        //modulation
[19440]2351        tmpstr = transpondergetmodulationstr(tpnode, fetype, 1);
[9573]2352        changeinput(modulation, tmpstr);
2353        free(tmpstr); tmpstr = NULL;
[19440]2354        tmpstr = transpondergetmodulationstr(tpnode, fetype, 2);
[9573]2355        changechoiceboxvalue(modulation, tmpstr);
2356        free(tmpstr); tmpstr = NULL;
2357        if(tpnode != NULL)
2358        {
2359                tmpstr = oitoa(tpnode->modulation);
2360                setchoiceboxselection(modulation, tmpstr);
2361                free(tmpstr); tmpstr = NULL;
2362        }
2363
2364        //rolloff
[11023]2365        tmpstr = transpondergetrolloffstr(tpnode, 1);
[9573]2366        changeinput(rolloff, tmpstr);
2367        free(tmpstr); tmpstr = NULL;
[11023]2368        tmpstr = transpondergetrolloffstr(tpnode, 2);
[9573]2369        changechoiceboxvalue(rolloff, tmpstr);
2370        free(tmpstr); tmpstr = NULL;
2371        if(tpnode != NULL)
2372        {
2373                tmpstr = oitoa(tpnode->rolloff);
2374                setchoiceboxselection(rolloff, tmpstr);
2375                free(tmpstr); tmpstr = NULL;
2376        }
2377
2378        //pilot
[11023]2379        tmpstr = transpondergetpilotstr(tpnode, 1);
[9573]2380        changeinput(pilot, tmpstr);
2381        free(tmpstr); tmpstr = NULL;
[11023]2382        tmpstr = transpondergetpilotstr(tpnode, 2);
[9573]2383        changechoiceboxvalue(pilot, tmpstr);
2384        free(tmpstr); tmpstr = NULL;
2385        if(tpnode != NULL)
2386        {
2387                tmpstr = oitoa(tpnode->pilot);
2388                setchoiceboxselection(pilot, tmpstr);
2389                free(tmpstr); tmpstr = NULL;
2390        }
2391
[19414]2392        //hp
[19440]2393        tmpstr = transpondergetfecstr(tpnode, fetype, 1);
[19414]2394        changeinput(hp, tmpstr);
2395        free(tmpstr); tmpstr = NULL;
[19440]2396        tmpstr = transpondergetfecstr(tpnode, fetype, 2);
[19414]2397        changechoiceboxvalue(hp, tmpstr);
2398        free(tmpstr); tmpstr = NULL;
2399        if(tpnode != NULL)
2400        {
2401                tmpstr = oitoa(tpnode->fec);
2402                setchoiceboxselection(hp, tmpstr);
2403                free(tmpstr); tmpstr = NULL;
2404        }
2405
2406        //lp
[19440]2407        tmpstr = transpondergetfecstr(tpnode, fetype, 1);
[19414]2408        changeinput(lp, tmpstr);
2409        free(tmpstr); tmpstr = NULL;
[19440]2410        tmpstr = transpondergetfecstr(tpnode, fetype, 2);
[19414]2411        changechoiceboxvalue(lp, tmpstr);
2412        free(tmpstr); tmpstr = NULL;
2413        if(tpnode != NULL)
2414        {
2415                tmpstr = oitoa(tpnode->polarization);
2416                setchoiceboxselection(lp, tmpstr);
2417                free(tmpstr); tmpstr = NULL;
2418        }
2419
2420        //bandwidth
2421        tmpstr = transpondergetbandwidthstr(tpnode, 1);
2422        changeinput(bandwidth, tmpstr);
2423        free(tmpstr); tmpstr = NULL;
2424        tmpstr = transpondergetbandwidthstr(tpnode, 2);
2425        changechoiceboxvalue(bandwidth, tmpstr);
2426        free(tmpstr); tmpstr = NULL;
2427        if(tpnode != NULL)
2428        {
2429                tmpstr = oitoa(tpnode->symbolrate);
2430                setchoiceboxselection(bandwidth, tmpstr);
2431                free(tmpstr); tmpstr = NULL;
2432        }
2433
2434        //guardinterval
2435        tmpstr = transpondergetguardintervalstr(tpnode, 1);
2436        changeinput(guardinterval, tmpstr);
2437        free(tmpstr); tmpstr = NULL;
2438        tmpstr = transpondergetguardintervalstr(tpnode, 2);
2439        changechoiceboxvalue(guardinterval, tmpstr);
2440        free(tmpstr); tmpstr = NULL;
2441        if(tpnode != NULL)
2442        {
2443                tmpstr = oitoa(tpnode->rolloff);
2444                setchoiceboxselection(guardinterval, tmpstr);
2445                free(tmpstr); tmpstr = NULL;
2446        }
2447
2448        //transmission
2449        tmpstr = transpondergettransmissionstr(tpnode, 1);
2450        changeinput(transmission, tmpstr);
2451        free(tmpstr); tmpstr = NULL;
2452        tmpstr = transpondergettransmissionstr(tpnode, 2);
2453        changechoiceboxvalue(transmission, tmpstr);
2454        free(tmpstr); tmpstr = NULL;
2455        if(tpnode != NULL)
2456        {
2457                tmpstr = oitoa(tpnode->pilot);
2458                setchoiceboxselection(transmission, tmpstr);
2459                free(tmpstr); tmpstr = NULL;
2460        }
2461
2462        //hierarchy
2463        tmpstr = transpondergethierarchystr(tpnode, 1);
2464        changeinput(hierarchy, tmpstr);
2465        free(tmpstr); tmpstr = NULL;
2466        tmpstr = transpondergethierarchystr(tpnode, 2);
2467        changechoiceboxvalue(hierarchy, tmpstr);
2468        free(tmpstr); tmpstr = NULL;
2469        if(tpnode != NULL)
2470        {
2471                tmpstr = oitoa(tpnode->system);
2472                setchoiceboxselection(hierarchy, tmpstr);
2473                free(tmpstr); tmpstr = NULL;
2474        }
2475
[9573]2476        //networkscan
2477        addchoicebox(networkscan, "0", _("no"));
2478        addchoicebox(networkscan, "1", _("yes"));
2479
2480        //clear
2481        addchoicebox(clear, "0", _("no"));
2482        addchoicebox(clear, "1", _("yes"));
2483
2484        //only free
2485        addchoicebox(onlyfree, "0", _("no"));
2486        addchoicebox(onlyfree, "1", _("yes"));
2487
[14550]2488        //blindscan
2489        addchoicebox(blindscan, "0", _("no"));
2490        addchoicebox(blindscan, "1", _("yes"));
2491
[19631]2492        //changename
[35213]2493        addchoicebox(changename, "1", _("yes"));
[19631]2494        addchoicebox(changename, "0", _("no"));
2495
[24209]2496        //favtype
[24218]2497        addchoicebox(favtype, "0", _("Unchanged"));
2498        addchoicebox(favtype, "1", _("Create new"));
2499        addchoicebox(favtype, "2", _("Delete All"));
[24209]2500
[24218]2501        //emptybouquet
2502        addchoicebox(emptybouquet, "0", _("no"));
2503        addchoicebox(emptybouquet, "1", _("yes"));
2504
[24226]2505        //unusedbouquetchannels
2506        addchoicebox(unusedbouquetchannels, "0", _("no"));
2507        addchoicebox(unusedbouquetchannels, "1", _("yes"));
2508
[36369]2509        //unusedsatprovider
2510        addchoicebox(unusedsatprovider, "0", _("no"));
2511        addchoicebox(unusedsatprovider, "1", _("yes"));
[36336]2512
[36369]2513        //cleartransponder
2514        addchoicebox(cleartransponder, "0", _("no"));
2515        addchoicebox(cleartransponder, "1", _("yes"));
[36336]2516
[19414]2517        drawscreen(scan, 2, 0);
2518        changescantype(scantype->ret, scan, listbox, tuner, sat, id, system, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, hp, lp, bandwidth, transmission, guardinterval, hierarchy, b4, b5, flag);
[16511]2519        drawscreen(scan, 0, 0);
[9546]2520        addscreenrc(scan, listbox);
2521
2522        tmp = listbox->select;
2523        while(1)
2524        {
2525                addscreenrc(scan, tmp);
[36336]2526
2527                if(clear->ret != NULL && ostrcmp(clear->ret, "1") == 0)
2528                {
2529                        emptybouquet->hidden = NO;
2530                        unusedbouquetchannels->hidden = NO;
[36369]2531                        unusedsatprovider->hidden = NO;
2532                        cleartransponder->hidden = NO;
[36336]2533                }
2534                else
2535                {
2536                        emptybouquet->hidden = YES;
2537                        unusedbouquetchannels->hidden = YES;
[36369]2538                        unusedsatprovider->hidden = YES;
2539                        cleartransponder->hidden = YES;
[36336]2540                }
2541                drawscreen(scan, 0, 0);
2542
[9546]2543                rcret = waitrc(scan, 0, 0);
2544                tmp = listbox->select;
2545
[10186]2546                if(scantype->ret != NULL) iscantype = atoi(scantype->ret);
2547                if(sat->ret != NULL) isat = atoi(sat->ret);
2548                if(system->ret != NULL) isystem = atoi(system->ret);
2549                if(frequency->ret != NULL) ifrequency = atoi(frequency->ret) * 1000;
2550                if(inversion->ret != NULL) iinversion = atoi(inversion->ret);
2551                if(symbolrate->ret != NULL) isymbolrate = atoi(symbolrate->ret) * 1000;
2552                if(polarization->ret != NULL) ipolarization = atoi(polarization->ret);
2553                if(fec->ret != NULL) ifec = atoi(fec->ret);
2554                if(modulation->ret != NULL) imodulation = atoi(modulation->ret);
2555                if(rolloff->ret != NULL) irolloff = atoi(rolloff->ret);
2556                if(pilot->ret != NULL) ipilot = atoi(pilot->ret);
[19414]2557
2558                if(flag == 3)
2559                {
2560                        if(hp->ret != NULL) ifec = atoi(hp->ret);
2561                        if(lp->ret != NULL) ipolarization = atoi(lp->ret);
2562                        if(bandwidth->ret != NULL) isymbolrate = atoi(bandwidth->ret);
2563                        if(transmission->ret != NULL) ipilot = atoi(transmission->ret);
2564                        if(guardinterval->ret != NULL) irolloff = atoi(guardinterval->ret);
2565                        if(hierarchy->ret != NULL) isystem = atoi(hierarchy->ret);
2566                }
2567
[10186]2568                if(networkscan->ret != NULL) inetworkscan = atoi(networkscan->ret);
2569                if(onlyfree->ret != NULL) ionlyfree = atoi(onlyfree->ret);
2570                if(clear->ret != NULL) iclear = atoi(clear->ret);
[14550]2571                if(blindscan->ret != NULL) iblindscan = atoi(blindscan->ret);
[19631]2572                if(changename->ret != NULL) ichangename = atoi(changename->ret);
[24209]2573                if(favtype->ret != NULL) ifavtype = atoi(favtype->ret);
[24218]2574                if(emptybouquet->ret != NULL) iemptybouquet = atoi(emptybouquet->ret);
[24226]2575                if(unusedbouquetchannels->ret != NULL) iunusedbouquetchannels = atoi(unusedbouquetchannels->ret);
[36369]2576                if(unusedsatprovider->ret != NULL) iunusedsatprovider = atoi(unusedsatprovider->ret);
2577                if(cleartransponder->ret != NULL) icleartransponder = atoi(cleartransponder->ret);
[10186]2578
[9546]2579                if(rcret == getrcconfigint("rcexit", NULL)) break;
[19325]2580                if(rcret == getrcconfigint("rcok", NULL)) break;
[10254]2581                if(listbox->select != NULL && ostrcmp(listbox->select->name, "tuner") == 0)
2582                {
2583                        scanchangesat(sat, tpnode, listbox->select->ret);
[19414]2584                        changescantype(scantype->ret, scan, listbox, tuner, sat, id, system, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, hp, lp, bandwidth, transmission, guardinterval, hierarchy, b4, b5, flag);
[16511]2585                        drawscreen(scan, 0, 0);
[10254]2586                }
[9590]2587                if(listbox->select != NULL && ostrcmp(listbox->select->name, "scantype") == 0)
2588                {
[19414]2589                        changescantype(scantype->ret, scan, listbox, tuner, sat, id, system, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, hp, lp, bandwidth, transmission, guardinterval, hierarchy, b4, b5, flag);
[16511]2590                        drawscreen(scan, 0, 0);
[9590]2591                }
[19399]2592                if(listbox->select != NULL && ostrcmp(listbox->select->name, "system") == 0)
2593                {
[19414]2594                        changescantype(scantype->ret, scan, listbox, tuner, sat, id, system, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, hp, lp, bandwidth, transmission, guardinterval, hierarchy, b4, b5, flag);
[19399]2595                        drawscreen(scan, 0, 0);
2596                }
[12534]2597                if(rcret == getrcconfigint("rcred", NULL))
[9546]2598                {
[9573]2599                        clearscreen(scan);
[36369]2600                        screenscan(tpnode, scan->child, tuner->ret, iscantype, isat, ifrequency, iinversion, isymbolrate, ipolarization, ifec, imodulation, irolloff, ipilot, inetworkscan, ionlyfree, iclear, iblindscan, ichangename, isystem, ifavtype, iemptybouquet, iunusedbouquetchannels, iunusedsatprovider, icleartransponder, 5000000, flag);
[16511]2601                        drawscreen(scan, 0, 0);
[9546]2602                }
[15418]2603                if(rcret == getrcconfigint("rcgreen", NULL) && tpnode != NULL && iscantype == 0)
[10186]2604                {
[14218]2605                        struct transponder* tp1 = createtransponder(99, tpnode->fetype, isat, ifrequency, iinversion, isymbolrate, ipolarization, ifec, imodulation, irolloff, ipilot, isystem);
2606                        copytransponder(tp1, tpnode, 99);
[15143]2607                        deltransponderbyid(99);
[12501]2608                        textbox(_("Message"), _("Transponder changed"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
[16511]2609                        drawscreen(scan, 0, 0);
[10186]2610                }
[19328]2611                if(rcret == getrcconfigint("rcyellow", NULL) && iscantype == 0)
2612                {
2613                        struct transponder* tp = tpchoicescreen(isat, flag);
2614                        if(tp != NULL)
2615                        {
2616                                tpnode = tp;
2617                                goto start;
2618                        }
2619                        else
2620                                drawscreen(scan, 0, 0);
2621                }
[14332]2622                else if(rcret == getrcconfigint("rcok", NULL))
2623                        break;
[9546]2624        }
2625
[9590]2626        delmarkedscreennodes(scan, 1);
[9546]2627        delownerrc(scan);
2628        clearscreen(scan);
[10338]2629        resetsatscan();
[12269]2630
2631        if(status.lastservice->channel == NULL)
2632        {
[24167]2633                if(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)) != NULL)
2634                {
2635                        if(status.servicetype == 0)
2636                                servicecheckret(servicestart(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0), 0);
2637                        else
2638                                servicecheckret(servicestart(getchannel(getconfigint("rserviceid", NULL), getconfigllu("rtransponderid", NULL)), getconfig("rchannellist", NULL),  NULL, 0), 0);
2639                }
[12269]2640        }
2641        else
2642        {
2643                tmpstr = ostrcat(status.lastservice->channellist, NULL, 0, 0);
2644                servicecheckret(servicestart(status.lastservice->channel, tmpstr, NULL, 0), 0);
2645                free(tmpstr); tmpstr = NULL;
2646        }
[19802]2647
2648        //recalc channels
2649        struct channel* chnode = channel;
2650        while(chnode != NULL)
2651        {
2652                if(chnode->servicetype != 99)
2653                {
[36335]2654                        chnode->transponder = gettransponder(chnode->transponderid);
[19802]2655                        chnode->provider = getprovider(chnode->providerid);
2656                }
2657                chnode = chnode->next;
2658        }
[36817]2659
[13874]2660        writeallconfig(1);
[10859]2661}
[9546]2662
2663#endif
Note: See TracBrowser for help on using the repository browser.