source: titan/titan/titan.c @ 22550

Last change on this file since 22550 was 22539, checked in by nit, 11 years ago

[titan] add scconfig to menu

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