source: titan/titan/scan.h @ 24226

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

update channelscan

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