source: titan/titan/titan.c @ 39001

Last change on this file since 39001 was 38317, checked in by obi, 8 years ago

add rec check before onlineupdate

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