source: titan/titan/titan.c @ 34349

Last change on this file since 34349 was 34349, checked in by gost, 8 years ago

fix

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