source: titan/titan/titan.c @ 27941

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

enable sec

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