source: titan/titan/titan.c @ 25930

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

next step

File size: 29.0 KB
Line 
1#include "struct.h"
2#include "header.h"
3#include "debug.h"
4#include "crc32.h"
5#include "sock.h"
6
7#define SYSCODE 0UL
8#define HTTPAUTH "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0="
9
10struct clist *config[LISTHASHSIZE] = {NULL};
11struct clist *ownconfig[LISTHASHSIZE] = {NULL};
12struct clist *rcconfig[LISTHASHSIZE] = {NULL};
13struct clist *skinconfig[LISTHASHSIZE] = {NULL};
14struct skin *skin = NULL;
15struct fb *fb = NULL;
16struct fb* skinfb = NULL;
17struct fb* accelfb = NULL;
18struct fb* fb1 = NULL;
19struct fb* lcdskinfb = NULL;
20struct font *font = NULL;
21struct rc *rc = NULL;
22struct dvbdev *dvbdev = NULL;
23struct dvbdev *dvbdevsim = NULL;
24struct channel *channel = NULL;
25struct transponder *transponder = NULL;
26struct provider *provider = NULL;
27struct sat *sat = NULL;
28struct service *service = NULL;
29struct mainbouquet *mainbouquet = NULL;
30struct mainplaylist *mainplaylist = NULL;
31struct pic *pic = NULL;
32struct rcmap *rcmap = NULL;
33struct inetwork *inetwork = NULL;
34struct stimerthread *stimerthread = NULL;
35struct rectimer *rectimer = NULL;
36struct subpage* subpage = NULL, *oldsubpage = NULL;
37struct epgscanlist* epgscanlist = NULL;
38struct screensaver* screensaver = NULL;
39struct channelcache* channelcache[CHANNELCACHEMAX] = {NULL};
40struct transpondercache* transpondercache[TRANSPONDERCACHEMAX] = {NULL};
41struct hdd* hdd = NULL;
42struct queue* queue = NULL;
43struct caservice caservice[MAXCASERVICE];
44struct channelhistory channelhistory[MAXCHANNELHISTORY];
45struct mostzap* mostzap = NULL;
46struct mediadbfilter* mediadbfilter = NULL;
47struct mediadbcategory* mediadbcategory = NULL;
48struct mediadb* mediadb = NULL;
49struct mediadbcache* mediadbcache[MEDIADBCACHEMAX] = {NULL};
50struct unicable* unicable = NULL;
51struct oldentry* oldentry = NULL;
52struct newsletter* newsletter = NULL;
53struct extepgcache* extepgcache = NULL;
54struct extepgchannel* extepgchannel = NULL;
55struct extepgconfig* extepgconfig = NULL;
56struct lastsubtitle* lastsubtitle = NULL;
57struct style* style = NULL;
58struct download* bgdownload[MAXBGDOWNLOAD] = {NULL};
59struct channelslot *channelslot = NULL;
60
61#ifdef SH4
62#include "sh4port.h"
63#endif
64
65#ifdef MIPSEL
66#include "mipselport.h"
67#endif
68
69#ifdef I386
70#include "i386port.h"
71#endif
72
73#include "oldentry.h"
74#include "tpk.h"
75#include "jsmn.h"
76#include "queue.h"
77#include "channelcache.h"
78#include "transpondercache.h"
79#include "strconvert.h"
80#include "numinput.h"
81#include "textinput.h"
82#include "radiotext.h"
83#include "list.h"
84#include "config.h"
85#include "defaults.h"
86#include "ownconfig.h"
87#include "rcconfig.h"
88#include "skinconfig.h"
89#include "thumb.h"
90#include "global.h"
91#include "stream.h"
92#include "dvbdev.h"
93#include "rotorcalc.h"
94#include "frontenddev.h"
95#include "dmxdev.h"
96#include "videodev.h"
97#include "audiodev.h"
98#include "cidev.h"
99#include "cadev.h"
100#include "scdev.h"
101#include "ca.h"
102#include "dvrdev.h"
103#include "cam.h"
104#include "dvb.h"
105#include "fb.h"
106#include "font.h"
107#include "rcmap.h"
108#include "rc.h"
109#include "sat.h"
110#include "transponder.h"
111#include "provider.h"
112#include "channel.h"
113#include "bouquets.h"
114#include "mainbouquets.h"
115#include "playlist.h"
116#include "mainplaylist.h"
117#include "pic.h"
118#include "filelist.h"
119#include "skinfunc.h"
120#include "style.h"
121#include "skin.h"
122#include "inputhelp.h"
123#include "rcfunc.h"
124#include "listbox.h"
125#include "choicebox.h"
126#include "vfd.h"
127#include "timerthread.h"
128#include "service.h"
129#include "pip.h"
130#include "player.h"
131#include "dvdplayer.h"
132#include "timeshift.h"
133#include "record.h"
134#include "zap.h"
135#include "showiframe.h"
136#include "epgrecord.h"
137#include "multiepg.h"
138#include "gmultiepg.h"
139#include "epg.h"
140#include "eit.h"
141#include "extepg.h"
142#include "epgscan.h"
143#include "menulist.h"
144#include "videomode.h"
145#include "inetwork.h"
146#include "keyactions.h"
147#include "scart.h"
148#include "standby.h"
149#include "dir.h"
150#include "spinner.h"
151#include "lnbconfig.h"
152#include "diseqcconfig.h"
153#include "tunerconfig.h"
154#include "epgsettings.h"
155#include "listedit.h"
156#include "channellist.h"
157#include "vfdisplay.h"
158#include "videosettings.h"
159#include "textbox.h"
160#include "autores.h"
161#include "language.h"
162#include "about.h"
163#include "serviceinfo.h"
164#include "avsettings.h"
165#include "mute.h"
166#include "volume.h"
167#include "timezone.h"
168#include "adjust.h"
169#include "skinadjust.h"
170#include "blindscanadjust.h"
171#include "moduleconfig.h"
172#include "scconfig.h"
173#include "possetup.h"
174#include "rectimer.h"
175#include "pin.h"
176#include "plugin.h"
177#include "recordpath.h"
178#include "subtitle.h"
179#include "audiotrack.h"
180#include "linkedchannel.h"
181#include "powerofftimer.h"
182#include "skinselector.h"
183#include "play.h"
184#include "satfinder.h"
185#include "menu.h"
186#include "channelbynr.h"
187#include "infobar.h"
188#include "network.h"
189#include "harddisk.h"
190#include "httpdfunc.h"
191#include "httpd.h"
192#include "download.h"
193#include "copyfile.h"
194#include "screensaver.h"
195#include "screensaveradjust.h"
196#include "scan.h"
197#include "restoredefault.h"
198#include "help.h"
199#include "httpdsettings.h"
200#include "epgsearch.h"
201#include "inadyn.h"
202#include "rguid.h"
203#include "channelhistroy.h"
204#include "mostzap.h"
205#include "settings_redbutton.h"
206#include "settings_bluebutton.h"
207#include "extensions.h"
208#include "system_update.h"
209#include "system_backup.h"
210#include "system_backup_restore.h"
211#include "info.h"
212#include "softcam.h"
213#include "id3.h"
214#include "mediadbcache.h"
215#include "mediadb.h"
216#include "mediadbsettings.h"
217#include "colorpicker.h"
218#include "ocrypt.h"
219#include "unlock.h"
220#include "md5.h"
221#include "rc4.h"
222#include "textinputhist.h"
223#include "system_infos.h"
224#include "system_infos_sysinfo.h"
225#include "unicable.h"
226#include "newsletter.h"
227#include "dirsort.h"
228#include "shortepg.h"
229#include "mediadbedit.h"
230#include "tpchoice.h"
231#include "marker.h"
232#include "timeshiftsettings.h"
233#include "log.h"
234#include "bgdownload.h"
235#include "fancontrol.h"
236#include "channelslot.h"
237#include "hwtest.h"
238#include "settings_autostart.h"
239#include "settings_overclocking.h"
240
241#define TIMECODE ""
242
243void demomodethread(struct stimerthread* self)
244{
245        textbox(_("Message"), _("!!! This is a DEMO Version !!!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 600, 0, 1);
246}
247
248int createstartscreen()
249{
250        addscreen("<screen name=framebuffer/>", 0, 0);
251        if(skin == NULL)
252        {
253                err("can't set framebuffer skin");
254                return 1;
255        }
256        addscreen("<screen name=skinerror/>", 0, 0);
257        status.skinerr = getscreen("skinerror");
258        skin->width = skinfb->width;
259        skin->height = skinfb->height;
260        skin->iwidth = skinfb->width;
261        skin->iheight = skinfb->height;
262        skin->rwidth = skinfb->width;
263        skin->rheight = skinfb->height;
264        skin->bgcol = 0;
265        skin->transparent = 255;
266        skin->flag = 1;
267
268        return 0;
269}
270
271//exitcode: 1 power off
272//exitcode: 2 restart
273//exitcode: 3 Gui restart
274//flag: 0 do not check record
275//flag: 1 check record
276//flag: 2 check record / don't write config
277//flag: 3 check record with timeout
278//flag: 4 check record with increase fixpowerofftime
279//flag: 5 check record with increase powerofftime
280void oshutdown(int exitcode, int flag)
281{
282        struct dvbdev* dvbnode = dvbdev;
283        struct service* servicenode = service;
284        void* threadstatus;
285        int i = 0, faststop = 0, ret = 0;
286        char* tmpstr = NULL;
287        struct skin* logo = getscreen("logo");
288        pthread_attr_t writethreadattr = {};
289        pthread_t writethread = '\0';
290
291        //stop permanent timeshift
292        if(status.timeshift == 1)
293                timeshiftstop(3);
294
295        //check if record running
296        if((flag == 1 || flag == 2 || flag == 3 || flag == 4 || flag == 5) && (status.recording > 0 || getrectimerbytimediff(300) != NULL))
297        {
298                if(flag == 4 && status.fixpowerofftime > 1)
299                {
300                                status.fixpowerofftime = time(NULL) + 900; //check powerofftimer again in 15min
301                                return;
302                }
303                if(flag == 5 && status.sd_timer != NULL && status.sd_timer->active)
304                {
305                                status.sd_timer->shutdown_time = time(NULL) + 900; //check powerofftimer again in 15min
306                                return;
307                }
308
309                if(textbox(_("Message"), _("Found running record\nor record is starting in next time.\nReally shutdown ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) != 1)
310                        return;
311        }
312
313        //check if download is running
314        for(i = 0; i < MAXBGDOWNLOAD; i++)
315        {
316                if(bgdownload[i] != NULL && bgdownload[i]->ret == -1)
317                {
318                        if(textbox(_("Message"), _("Found running download\nReally shutdown ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) != 1)
319                                return;
320                        break;
321                }
322        }
323
324        ret = servicestop(status.aktservice, 1, 1);
325        if(ret == 1) return;
326       
327        if(exitcode == 1)
328                tmpstr = getconfig("userpowerofflogo", NULL);
329        else if(exitcode == 2)
330                tmpstr = getconfig("userrestartlogo", NULL);
331        else if(exitcode == 3)
332                tmpstr = getconfig("userguirestartlogo", NULL);
333       
334        if(tmpstr != NULL) {
335                if(file_exist(tmpstr) == 0)
336                        tmpstr = NULL;
337        }       
338        if(tmpstr == NULL) {   
339                if(exitcode == 1)
340                        tmpstr = getconfig("powerofflogo", NULL);
341                else if(exitcode == 2)
342                        tmpstr = getconfig("restartlogo", NULL);
343                else if(exitcode == 3)
344                        tmpstr = getconfig("guirestartlogo", NULL);
345        }
346                       
347        if(tmpstr != NULL)
348        {
349                changepic(logo, tmpstr);
350                tmpstr = NULL;
351                drawscreen(logo, 0, 0);
352        }
353        else
354                clearfball();
355
356        //stop all records
357        while(servicenode != NULL)
358        {
359                servicenode->recendtime = 1;
360                servicenode = servicenode->next;
361        }
362
363        faststop = getconfigint("faststop", NULL);
364
365        // Free memory, semaphores, etc. and say goodbye
366        if(faststop == 0) cleanupvfd();
367
368        if(status.servicetype != 99) //don't save tmp servicetype
369        {
370                tmpstr = oitoa(status.servicetype);
371                addconfig("servicetype", tmpstr);
372                free(tmpstr); tmpstr = NULL;
373        }
374
375        status.sec = 0;
376
377        if(flag != 2)
378        {
379                //start write thread
380                pthread_attr_init(&writethreadattr);
381                pthread_attr_setstacksize(&writethreadattr, 50000);
382                pthread_attr_setdetachstate(&writethreadattr, PTHREAD_CREATE_JOINABLE);
383
384                int epgsave = getconfigint("epgsave", NULL);
385                if((epgsave == 1 && exitcode == 3) || epgsave == 2)
386                        ret = pthread_create(&writethread, &writethreadattr, writeallconfigthread1, NULL); //do not save epg
387                else
388                        ret = pthread_create(&writethread, &writethreadattr, writeallconfigthread0, NULL); //save epg
389                if(ret)
390                {
391                        err("create write thread");
392                }
393        }
394
395        //reset ci devices
396        while(dvbnode != NULL)
397        {
398                if(dvbnode->type == CIDEV && dvbnode->fd > -1)
399                {
400                        if(dvbnode->caslot != NULL) dvbnode->caslot->status = 101;
401                        usleep(10000);
402                        careset(dvbnode, dvbnode->devnr);
403                }
404                dvbnode = dvbnode->next;
405        }
406
407        if(faststop == 0)
408        {
409                //wait for write thread
410                if(writethread != '\0')
411                        pthread_join(writethread, &threadstatus);
412                pthread_attr_destroy(&writethreadattr);
413
414                //stop timer thread
415                i = 0;
416                status.timerthreadaktion = STOP;
417                while(status.timerthreadstatus != DEACTIVE)
418                {
419                        usleep(100000);
420                        i++; if(i > 20) break;
421                }
422
423                if(i > 20)
424                {
425                        err("detect hanging timer thread");
426                }
427                else if(status.timerthread != '\0')
428                        pthread_join(status.timerthread, &threadstatus);
429                pthread_attr_destroy(&status.timerthreadattr);
430
431                // free timerthread struct and stop all timer sub threads
432                freetimer(0);
433
434                status.skinerr = NULL;
435                free(status.gateway);
436                free(status.dnsserver1);
437                free(status.dnsserver2);
438                free(status.boxtype);
439                free(status.httpauth);
440                free(status.bgpic);
441
442                freeservice();
443                freecaservice();
444
445                freescreen();
446                freepic();
447                freefont();
448                deinitfont();
449
450                freerectimer();
451                freemostzap(0);
452                freechannelhistory();
453                freesat();
454                freeallplaylist();
455                freemainplaylist();
456                freeallbouquet();
457                freemainbouquet(0);
458                freechannel(0);
459                freetransponder();
460                freeprovider();
461                freeownconfig();
462                freeepgscanlist();
463                freercconfig();
464                freeskinconfig();
465                freequeue();
466                freehdd(0);
467
468                free(status.configfile);
469                freeconfig();
470
471                freedvbdev(0);
472
473                closefb(fb);
474                freefb();
475
476                closerc();
477                freerc();
478                freercmap();
479                free_shutdowntimervar();
480                freeinetwork();
481                freeoldentry();
482                freeextepgconfig();
483                freelastsubtitle();
484                freebgdownload();
485                freechannelslot();
486        }
487        else
488                freetimer(1);
489
490        if(exitcode == 1)
491                setcecstandby(1);
492
493        starthttpd(0);
494        startrguid(0);
495        initmutex(0);
496
497        if(faststop != 0)
498        {
499                //wait for write thread
500                if(writethread != '\0')
501                        pthread_join(writethread, &threadstatus);
502                pthread_attr_destroy(&writethreadattr);
503        }
504
505        exit(exitcode);
506}
507
508int main(int argc, char *argv[])
509{
510        int ret = 0, serviceret = 0, skincheck = 0;
511        char* tmpstr = NULL;
512        unsigned char *mmapfb = NULL;
513        struct sigaction sa;
514        struct stimerthread *tmpthread = NULL;
515        //struct sched_param schedparam;
516
517#ifdef SIMULATE
518        // for mem leak debug
519        setenv("MALLOC_TRACE", "/home/nit/titan/m.txt", 1);
520        mtrace();
521        status.security = 1;
522#endif
523
524        printf("[%s] copyright by %s - version %s\n", PROGNAME, COPYRIGHT, OVERSION);
525        printf("[%s] crontribut: %s\n", PROGNAME, CRONTRIBUT);
526
527        sa.sa_handler = (void *)sighandler;
528        sigemptyset(&sa.sa_mask);
529        sa.sa_flags = SA_RESTART;
530       
531        initsignal(&sa);
532
533        status.rguidfd = -1;
534        status.sec = time(NULL);
535        status.mainthread = pthread_self();
536
537        if(argc > 1)
538                status.configfile = ostrcat(argv[1], NULL, 0, 0);
539        else
540                status.configfile = ostrcat(CONFIGFILE, NULL, 0, 0);
541
542        printf("[%s] using config: %s\n", PROGNAME, status.configfile);
543        ret = readconfig(status.configfile, config);
544        if(ret != 0)
545                return 100;
546
547        //start timer thread
548        status.timerthreadaktion = START;
549        pthread_attr_init(&status.timerthreadattr);
550        pthread_attr_setstacksize(&status.timerthreadattr, 50000);
551        pthread_attr_setdetachstate(&status.timerthreadattr, PTHREAD_CREATE_JOINABLE);
552        ret = pthread_create(&status.timerthread, &status.timerthreadattr, timerthreadfunc, NULL);
553        if(ret)
554        {
555                err("create timer thread");
556                return 100;
557        }
558
559        //change working dir to /tmp
560        //chdir("/tmp");
561
562        //set main scheduler priority
563        //schedparam.sched_priority = 10;
564        //pthread_setschedparam(pthread_self(), SCHED_RR, &schedparam);
565
566        readconfig(getconfig("ownconfig", NULL), ownconfig);
567        readconfig(getconfig("rcconfig", NULL), rcconfig);
568
569        skincheck = checkskin();
570        readconfig(getconfig("skinconfig", NULL), skinconfig);
571
572        setprogress(100);
573        setdefaults();
574        setdebuglevel();
575        initmutex(1);
576        m_lock(&status.waitrcmutex, 24);
577        initvfd();
578
579        if(checkbox("UFS922") == 1)
580                setfanspeed(-1, 0);
581
582        system(getconfig("skriptbeforetv", NULL));
583        ret = setcecstandby(0);
584        ret = setvideomode(getconfig("av_videomode", NULL), 0);
585        ret = setpolicy(getconfig("av_policy", NULL));
586        ret = setaspect(getconfig("av_aspect", NULL));
587        ret = setcolorformat(getconfig("av_colorformat", NULL), 0);
588        ret = setcolorformat(getconfig("av_colorformatscart", NULL), 1);
589        ret = setaudiosource(getconfig("av_audiosource", NULL));
590        ret = setac3(getconfig("av_ac3mode", NULL));
591        ret = setmode3d(getconfig("av_mode3d", NULL));
592        ret = setvfdbrightness(getconfigint("vfdbrightness", NULL));
593        ret = setaudiodelaybitstream(getconfig("audiodelaybitstream", NULL));
594        ret = addinetworkall(NULL);
595       
596#ifndef SIMULATE
597        if(getconfigint("sos", NULL) == 0)
598        {
599                if(ostrcmp(string_newline(gettimeinfo()), TIMECODE) == 1)
600                {
601                        printf("error: 1\n");
602                        destroy();
603                        exit(100);
604                }
605                if(ostrcmp(string_newline(gettimeinfovar()), TIMECODE) == 1)
606                {
607                        printf("error: 2\n");           
608                        destroy();
609                        exit(100);
610                }
611                if(checkreseller() != 0)
612                {
613                        printf("error: 3\n");           
614                        destroy();
615                        exit(100);
616                }
617                if(getsysinfo() != SYSCODE)
618                {
619                        printf("error: 4\n");           
620                        destroy();
621                        exit(100);
622                }
623                if(file_exist("/mnt/swapextensions/etc/.vnumber") == 1)
624                {
625                        printf("error: 5\n");           
626                        destroy();
627                        exit(100);
628                }
629                if(checkflash() != 0)
630                {
631                        printf("error: 6\n");           
632                        destroy();
633                        exit(100);
634                }
635                if(checkbox("ATEMIO520__") == 1 && checkhighflash() != 0)
636                {
637                        printf("error: 7\n");           
638                        destroy();
639                        exit(100);
640                }
641                if(checkbox("UFS910") == 1 && checklowflash() != 0)
642                {
643                        printf("error: 8\n");           
644                        destroy();
645                        exit(100);
646                }
647       
648                char* cpuid = getcpuid();
649                checkserial(cpuid);
650                free(cpuid); cpuid = NULL;
651        }
652        else
653        {
654                status.security = 1;
655                startnet();
656                setskinnodeslocked(0);
657        }
658#endif
659
660        ret = initfont();
661        if(ret != 0)
662                return 100;
663        ret = openfont(getconfig("fontfile1", NULL));
664        if(ret != 0)
665        {
666                err("open fontfile1 font");
667                return 100;
668        }
669        openfont(getconfig("fontfile2", NULL));
670        openfont(getconfig("fontfile3", NULL));
671        openfont(getconfig("fontfile4", NULL));
672        openfont(getconfig("fontfile5", NULL));
673
674        //skin defined fonts
675        openfont(getskinconfig("fontfile1", NULL));
676        openfont(getskinconfig("fontfile2", NULL));
677        openfont(getskinconfig("fontfile3", NULL));
678        openfont(getskinconfig("fontfile4", NULL));
679        openfont(getskinconfig("fontfile5", NULL));
680
681        if(checkbox("ATEMIO5000") != 1)
682                setvol(getconfigint("vol", NULL));
683       
684        setlang(getconfig("lang", NULL));
685        initlocale(getconfig("localepath", NULL));
686
687        fb = openfb(getconfig("fbdev", NULL), 0);
688        if(fb == NULL)
689                return 100;
690        clearfball();
691        enablemanualblit();
692
693        tmpstr = getconfig("fb1dev", NULL);
694        if(tmpstr != NULL)
695                fb1 = openfb(tmpstr, 1);
696        tmpstr = NULL;
697
698        if(status.usedirectfb != 1)
699        {
700                skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize);
701                if(skinfb != NULL)
702                {
703                        ret = getfbsize(0);
704                        if(ret > 0)
705                                accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize);
706                }
707                else
708                {
709                        debug(100, "use directfb");
710                        status.usedirectfb = 1;
711                }
712        }
713
714        if(status.usedirectfb == 1)
715        {
716                skinfb = fb;
717                ret = getfbsize(0);
718                if(ret > 0)
719                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize);
720        }
721
722        //if(lcdskinfb == NULL) {
723                //mmapfb = malloc(4 * 320 * 240);
724                //mmapfb = malloc(4 * 1024 * 768);
725                //mmapfb = NULL;
726                /* dev=999 ist LCD Buffer */
727                //lcdskinfb = addfb("lcdskinfb", 999, 320, 240, 4, -1, mmapfb, 4 * 320 * 240);
728                //lcdskinfb = addfb("lcdskinfb", 999, 1024, 768, 4, -1, mmapfb, 4 * 1024 * 768);
729                // mmapfb = NULL;
730        //}
731
732        ret = createstartscreen();
733        if(ret != 0) return 100;
734
735        //from here we can use starterror screen
736        ret = openrc();
737        if(ret != 0)
738        {
739                tmpstr = ostrcat(tmpstr, _("Error: open rc device !!"), 1, 0);
740                goto starterror;
741        }
742
743        if(fegetdev() < 1)
744        {
745                tmpstr = ostrcat(tmpstr, _("Error: no frontend device found !!"), 1, 0);
746                err("no frontend device found");
747                goto starterror;
748        }
749        if(dmxgetdev() < 1)
750        {
751                tmpstr = ostrcat(tmpstr, _("Error: no demux device found !!"), 1, 0);
752                err("no demux device found");
753                goto starterror;
754        }
755        if(videogetdev() < 1)
756        {
757                tmpstr = ostrcat(tmpstr, _("Error: no video device found !!"), 1, 0);
758                err("no video device found");
759                goto starterror;
760        }
761        if(audiogetdev() < 1)
762        {
763                tmpstr = ostrcat(tmpstr, _("Error: no audio device found !!"), 1, 0);
764                err("no audio device found");
765                goto starterror;
766        }
767        ret = fecreatedummy();
768        ret = cagetdev();
769        ret = cigetdev();
770        ret = dvrgetdev();
771        ret = scgetdev();
772        settunerstatus();
773
774        //start ca slot watching threads
775        castart();
776
777        //check skin
778        if(skincheck > 0)
779        {
780
781                tmpstr = ostrcat(tmpstr, _("Error: skin not found !!"), 1, 0);
782                err("skin not found");
783                goto starterror;
784        }
785
786        ret = readsat(getconfig("satfile", NULL));
787        ret = readtransponder(getconfig("transponderfile", NULL));
788        ret = readprovider(getconfig("providerfile", NULL));
789        ret = readchannel(getconfig("channelfile", NULL));
790        ret = readtransponderencoding(getconfig("transponderencodingfile", NULL));
791        ret = readmostzap(getconfig("mostzapfile", NULL));
792        ret = readlastsubtitle(getconfig("lastsubtitle", NULL));
793        ret = readchannelslot(getconfig("channelslotfile", NULL));
794
795        status.aktservice = addservice(NULL);
796        status.lastservice = addservice(NULL);
797        status.pipservice = addservice(NULL);
798
799        //check if startchannel defined
800        char* startchannellist = getconfig("startchannellist", NULL);
801        int startserviceid = getconfigint("startserviceid", NULL);
802        uint64_t starttransponderid = getconfigllu("starttransponderid", NULL);
803        int startservicetype = getconfigint("startservicetype", NULL);
804        if(startchannellist != NULL && startserviceid != 0)
805        {
806                if(startservicetype == 0)
807                {
808                        addconfig("channellist", startchannellist);
809                        addconfigint("serviceid", startserviceid);
810                        addconfigllu("transponderid", starttransponderid);
811                }
812                else
813                {
814                        addconfig("rchannellist", startchannellist);
815                        addconfigint("rserviceid", startserviceid);
816                        addconfigllu("rtransponderid", starttransponderid);
817                }
818                addconfigint("servicetype", startservicetype);
819        }
820
821        //tune to channel
822        if(status.servicetype == 0)
823                serviceret = servicestart(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0);
824        else
825                serviceret = servicestart(getchannel(getconfigint("rserviceid", NULL), getconfigllu("rtransponderid", NULL)), getconfig("rchannellist", NULL),  NULL, 0);
826
827        ret = readscreen(getconfig("skinfile", NULL), 0, 0);
828        ret = readmainbouquet(getconfig("bouquetfile", NULL));
829        ret = readallbouquet();
830        ret = readmainplaylist(getconfig("playlistfile", NULL));
831        ret = readallplaylist();
832        ret = readrcmap(getconfig("rcmapfile", NULL));
833        ret = readepgscanlist(getconfig("epgchannelfile", NULL));
834        ret = settimezone(getconfig("timezone", NULL));
835        ret = readextepgconfig(getconfig("extepgfile", NULL));
836       
837        //set volume on start
838        if(checkbox("ATEMIO5000") == 1)
839        {
840                setvol(getconfigint("vol", NULL));
841                system("fbset 1280x720-1");
842        }
843
844        //check to remove preinstalled tpk packages
845        ret = tpkupdatepre();
846
847        addtimer(&checkdate, START, 2000, -1, NULL, NULL, NULL);
848        if(checkbox("ATEMIO510") == 0)
849                addtimer(&updatevfd, START, 1000, -1, NULL, NULL, NULL);
850
851        if(getconfigint("firststart", NULL) == 1)
852        {
853                if(file_exist("/var/etc/.scart"))
854                {
855                        setvideomode("pal", 0);
856                        changefbresolution("pal", 0);
857                        autoresolution();
858                }
859                addconfig("firststart", "0");
860        }
861
862        if(getconfig("remotecontrol", NULL) == NULL)
863        {
864                if(checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
865                {
866                        struct menulist* mlist = NULL, *mbox = NULL;
867                        addmenulist(&mlist, _("RemoteControl Old Version"), "0", NULL, 0, 0);
868                        addmenulist(&mlist, _("RemoteControl Long Version"), "1", NULL, 0, 0);
869                       
870                        mbox = menulistbox(mlist, "remotecontrol", _("Select Your Remote Control"), NULL, NULL, 3, 0);
871                        if(mbox != NULL)
872                        {
873                                debug(10, "mbox->name %s", mbox->name);
874                                debug(10, "mbox->text %s", mbox->text);
875                                addconfig("remotecontrol", mbox->text);
876                                writeallconfig(1);                             
877                        }
878                }
879        }
880                       
881        //first wizzard
882        if(getconfigint("nofirstwizzard", NULL) < 2)
883        {
884                if(file_exist("/var/etc/.scart"))
885                {
886                        setvideomode("pal", 0);
887                        changefbresolution("pal", 0);
888                }
889
890                autoresolution();
891                       
892                if(getconfigint("nofirstwizzard", NULL) == 0)
893                {
894firstwizzardstep1:
895
896                        status.updatevfd = PAUSE;
897//                      screenavsettings(1);
898//                      resettvpic();
899                        //this screen can reload the skin (on language change)
900                        //all skin changes before here than are deleted
901//                      if(screenlanguage(2) == 2) return 100;
902//                      resettvpic();
903
904                        screentunerconfig();
905                        resettvpic();
906                        screenscanconfig(1);
907                        resettvpic();
908//                      screennetwork_adapter();
909//                      resettvpic();
910                        writevfd("Setting OK ?");
911                        if(textbox(_("First Wizzard"), _("Settings OK ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2)
912                        {
913                                goto firstwizzardstep1;
914                        }
915                }
916                resettvpic();
917
918                char* msg = NULL;
919                msg = readfiletomem("/etc/imageinfo", 0);
920                textbox(_("Info"), _(msg), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 680, 30, 0);
921                free(msg); msg = NULL;
922               
923                writevfd("");
924                status.updatevfd = START;
925                drawscreen(skin, 0, 0);
926                addconfig("nofirstwizzard", "2");
927        }
928        else
929        {
930                // workaround, remove bootlogo on startup
931                drawscreen(skin, 0, 0);
932
933                //check servicestart
934                if(serviceret != 21) // no message if startchannel empty
935                        servicecheckret(serviceret, 0);
936        }
937
938        //start auto shutdown thread
939        addtimer(&checkshutdowntimer, START, 10000, -1, NULL, NULL, NULL);
940        //start demo mode
941        if(checkbox("WHITEBOX") == 1)
942                addtimer(&demomodethread, START, 600000, -1, NULL, NULL, NULL);
943
944        status.lastrcaction = time(NULL);
945        ret = loadplugin();
946        setosdtransparent(getskinconfigint("osdtransparent", NULL));
947        ret = setsaturation(getconfigint("vs_saturation", NULL));
948        ret = setbrightness(getconfigint("vs_brightness", NULL));
949        ret = setcontrast(getconfigint("vs_contrast", NULL));
950        ret = settint(getconfigint("vs_tint", NULL));
951       
952#ifndef SIMULATE
953        //set skinentrys locked
954        if(status.security == 0)
955                setskinnodeslocked(1);
956        else
957                setskinnodeslocked(0);
958#endif
959
960        //start epg thread
961        status.epgthread = addtimer(&epgthreadfunc, START, 1000, -1, NULL, NULL, NULL);
962        //start record timer thread (on delay change you must change rectimer.h also)
963        status.rectimerthread = addtimer(&checkrectimer, START, 1000, -1, NULL, NULL, NULL);
964        //check if cam socket connected
965        addtimer(&checkcam, START, 3000, -1, NULL, NULL, NULL);
966        //start stream server
967        tmpthread = addtimer(&streamthreadfunc, START, 10000, -1, NULL, NULL, NULL);
968        if(tmpthread != NULL)
969        {
970                tmpthread->flag = setbit(tmpthread->flag, 0);
971                tmpthread = NULL;
972        }
973        //start epg scanlist
974        status.epgscanlistthread = addtimer(&epgscanlistthread, START, 1000, 1, NULL, NULL, NULL);
975        //get pmt
976        if(getconfigint("checkpmtalways", NULL) == 1)
977                addtimer(&dvbgetpmtthread, START, 2000, -1, NULL, NULL, NULL);
978        //check hdd
979        status.addhddall = addtimer(&addhddall, START, 6000, -1, NULL, NULL, NULL);
980        //check net
981        addtimer(&addinetworkall, START, 15000, -1, NULL, NULL, NULL);
982        //check kill net (security)
983        addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL);
984        //check old entrys and remove from mem
985        addtimer(&oldentrythreadfunc, START, 60000 * 60, -1, NULL, NULL, NULL);
986
987        //start newsletter
988        startnewsletter(1);
989
990        //thumb create thread
991        startthumb(1);
992
993        //start webserver
994        starthttpd(1);
995       
996        //start rguid
997        startrguid(1);
998
999        //init the player
1000        playerinit(argc, argv);
1001       
1002        //start spinner thread
1003        addtimer(&checkspinner, START, 2000, -1, NULL, NULL, NULL);
1004
1005        system(getconfig("skriptaftertv", NULL));
1006
1007        //for atemio to unlock box with stick
1008        if(file_exist("/media/hdd/movie/titankey"))
1009        {
1010                char* cpuid = getcpuid();
1011                char* cmd = ostrcat("/media/hdd/movie/titankey ", cpuid, 0, 0);
1012                system(cmd);
1013                checkserial(cpuid);
1014                free(cmd); cmd = NULL;
1015
1016                if(status.security == 1)
1017                {
1018                        char* mac = getmacfromcmdline();
1019                        if(mac != NULL)
1020                        {
1021                                cmd = ostrcat(cmd, cpuid, 1, 0);
1022                                cmd = ostrcat(cmd, ",", 1, 0);
1023                                cmd = ostrcat(cmd, mac, 1, 0);
1024                               
1025                                free(mac); mac = NULL;
1026                        }
1027                        else
1028                                cmd = ostrcat(cmd, cpuid, 1, 0);
1029
1030                        writesys("/media/hdd/movie/codelist.txt", cmd, 3);
1031                        textbox(_("Message"), _("Receiver successful unlocked"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1032                }
1033
1034                free(cpuid); cpuid = NULL;
1035                free(cmd); cmd = NULL;
1036        }
1037
1038        //must called direct befor screeninfobar
1039        if(getconfigint("saverun", NULL) == 1)
1040        {
1041                ret = sigsetjmp(status.longjumpbuf, 1);
1042                if(ret != 0 && ret != 999)
1043                {
1044                        err("set sigsegjump");
1045                }
1046        }
1047       
1048        if(checkbox("UFS910") == 0 && checkbox("UFS922") == 0)
1049        {
1050                //check free space in /var
1051                if(getfreespace("/var") / 1024 < 50) //200kb
1052                        textbox(_("Message"), _("Free space in /var to little!\nThis can make problems!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1053                else
1054                {
1055                        //check writeable in /var
1056                        if(mkdir("/var/writetest", 0777) != 0 && errno != EEXIST)
1057                        {
1058                                if(textbox(_("Message"), _("/var not writeable!\nRepair it?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) == 1)
1059                                {
1060                                        system("repairjffs2.sh var &"); //this script kills titan an reboot
1061                                        sleep(10);
1062                                }
1063                        }
1064                        rmdir("/var/writetest");
1065                }
1066       
1067                //check free space in /mnt
1068                if(getfreespace("/mnt") / 1024 < 50) //200kb
1069                        textbox(_("Message"), _("Free space in /mnt to little!\nThis can make problems!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1070                else
1071                {
1072                        //check writeable in /mnt
1073                        if(mkdir("/mnt/writetest", 0777) != 0 && errno != EEXIST)
1074                        {
1075                                if(textbox(_("Message"), _("/mnt not writeable!\nRepair it?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 15, 0) == 1)
1076                                {
1077                                        system("repairjffs2.sh mnt &"); //this script kills titan an reboot
1078                                        sleep(10);
1079                                }
1080                        }
1081                        rmdir("/mnt/writetest");
1082                }
1083        }
1084
1085        addtimer(&guestthread, START, 1000, 1, NULL, NULL, NULL);
1086
1087        screeninfobar();
1088
1089        //for testign screens
1090        //screenmanualscan();
1091        //screeninputhelp();
1092        //screendownload("test", "www.orf.at", NULL, 80, "test.html", 0);
1093        //screenrectimer();
1094        //screenepgsettings();
1095        //screenlnb("1");
1096        //screendiseqc("1");
1097        //screenlanguage();
1098        //screenvideosettings();
1099        //screenskinselect();
1100        //screenrectimer();
1101        //screennetwork_adapter(2);
1102        //screenpin();
1103        //screenchannellist();
1104        //recordstart(channel, RECDIRECT);
1105        //mc_main();
1106        //screenmc_videoplayer();
1107        //screenserviceinfo();
1108        //screentunerconfig();
1109        //screenvfdisplay();
1110        //screenavsettings(1);
1111        //screenadjust();
1112        //subtitlestart();
1113
1114        if(mmapfb != NULL) {
1115                free(mmapfb); mmapfb=NULL;
1116        }
1117        oshutdown(1, 1);
1118        return 0;
1119
1120starterror:
1121        addscreen("<screen hspace=5 vspace=5 type=textbox name=starterror posx=center posy=center bordersize=2 bordercol=#ffffff fontsize=30 fontcol=#ffffff width=600 height=150/>", 0, 0);
1122        struct skin *starterror = getscreen("starterror");
1123        if(tmpstr == NULL)
1124                tmpstr = ostrcat(tmpstr, _("Unknown Error."), 1, 0);
1125        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
1126        tmpstr = ostrcat(tmpstr, _("Automatic stop in 10 seconds."), 1, 0);
1127        changetext(starterror, _(tmpstr));
1128        drawscreen(starterror, 0, 0);
1129        sleep(10);
1130        free(tmpstr);
1131        return 100;
1132}
Note: See TracBrowser for help on using the repository browser.