source: titan/titan/titan.c @ 34355

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

fix

File size: 32.2 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  ret = 1;
661  if(file_exist("/var/etc/.usbimage"))
662        ret = 0;
663 
664#ifndef SIMULATE
665        if(getconfigint("sos", NULL) == 0)
666        {
667                if(ostrcmp(string_newline(gettimeinfo()), TIMECODE) == 1)
668                {
669                        printf("error: 1\n");
670                        destroy();
671                        exit(100);
672                }
673                if(ostrcmp(string_newline(gettimeinfovar()), TIMECODE) == 1)
674                {
675                        printf("error: 2\n");           
676                        destroy();
677                        exit(100);
678                }
679                if(checkreseller() != 0)
680                {
681                        printf("error: 3\n");           
682                        destroy();
683                        exit(100);
684                }
685                if(ret > 0)
686                {
687                        if(getsysinfo() != SYSCODE)
688                        {
689                                printf("error: 4\n");           
690                                destroy();
691                                exit(100);
692                        }
693                }
694                if(file_exist("/mnt/swapextensions/etc/.vnumber") == 1)
695                {
696                        printf("error: 5\n");           
697                        destroy();
698                        exit(100);
699                }
700                if(ret > 0)
701                {
702                        if(checkflash() != 0)
703                        {
704                                printf("error: 6\n");           
705                                destroy();
706                                exit(100);
707                        }
708                }
709                if(ret > 0)
710                {
711                        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)
712                        {
713                                printf("error: 7\n");           
714                                destroy();
715                                exit(100);
716                        }
717                }
718                if(checkbox("UFS910") == 1 && checklowflash() != 0)
719                {
720                        printf("error: 8\n");           
721                        destroy();
722                        exit(100);
723                }
724       
725                char* cpuid = getcpuid();
726                checkserial(cpuid);
727                free(cpuid); cpuid = NULL;
728        }
729        else
730        {
731                status.security = 5;
732                startnet();
733                setskinnodeslocked(0);
734        }
735#endif
736
737        if(file_exist("/mnt/config/dualboot.enigma2"))
738        {
739                printf("error: found /mnt/config/dualboot.enigma2\n");
740                return 0;
741        }
742
743        ret = initfont();
744        if(ret != 0)
745                return 100;
746        ret = openfont(getconfig("fontfile1", NULL));
747        if(ret != 0)
748        {
749                err("open fontfile1 font");
750                return 100;
751        }
752        openfont(getconfig("fontfile2", NULL));
753        openfont(getconfig("fontfile3", NULL));
754        openfont(getconfig("fontfile4", NULL));
755        openfont(getconfig("fontfile5", NULL));
756
757        //skin defined fonts
758        openfont(getskinconfig("fontfile1", NULL));
759        openfont(getskinconfig("fontfile2", NULL));
760        openfont(getskinconfig("fontfile3", NULL));
761        openfont(getskinconfig("fontfile4", NULL));
762        openfont(getskinconfig("fontfile5", NULL));
763
764
765        setvol(getconfigint("vol", NULL));
766
767       
768        setlang(getconfig("lang", NULL));
769        initlocale(getconfig("localepath", NULL));
770
771#ifdef MIPSEL
772        bcm_accel_init();
773#endif
774
775        fb = openfb(getconfig("fbdev", NULL), 0);
776        if(fb == NULL)
777                return 100;
778        clearfball();
779        enablemanualblit();
780       
781        tmpstr = getconfig("fb1dev", NULL);
782        if(tmpstr != NULL)
783                fb1 = openfb(tmpstr, 1);
784        tmpstr = NULL;
785
786#ifdef MIPSEL
787        waitvsync();
788        setfbosd();
789        status.usedirectfb = 1;
790#endif
791
792        if(status.usedirectfb != 1)
793        {
794                skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize);
795                if(skinfb != NULL)
796                {
797                        ret = getfbsize(0);
798                        if(ret > 0)
799                                accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize);
800                }
801                else
802                {
803                        debug(100, "use directfb");
804                        status.usedirectfb = 1;
805                }
806        }
807        if(status.usedirectfb == 1)
808        {
809                skinfb = fb;
810#ifndef MIPSEL
811                ret = getfbsize(0);
812                if(ret > 0)
813                        accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize);
814#endif
815        }
816
817        //if(lcdskinfb == NULL) {
818                //mmapfb = malloc(4 * 320 * 240);
819                //mmapfb = malloc(4 * 1024 * 768);
820                //mmapfb = NULL;
821                /* dev=999 ist LCD Buffer */
822                //lcdskinfb = addfb("lcdskinfb", 999, 320, 240, 4, -1, mmapfb, 4 * 320 * 240);
823                //lcdskinfb = addfb("lcdskinfb", 999, 1024, 768, 4, -1, mmapfb, 4 * 1024 * 768);
824                // mmapfb = NULL;
825        //}
826
827        ret = createstartscreen();
828        if(ret != 0) return 100;
829
830        //from here we can use starterror screen
831        ret = openrc();
832        if(ret != 0)
833        {
834                tmpstr = ostrcat(tmpstr, _("Error: open rc device !!"), 1, 0);
835                goto starterror;
836        }
837
838        if(fegetdev() < 1)
839        {
840                tmpstr = ostrcat(tmpstr, _("Error: no frontend device found !!"), 1, 0);
841                err("no frontend device found");
842                goto starterror;
843        }
844        if(dmxgetdev() < 1)
845        {
846                tmpstr = ostrcat(tmpstr, _("Error: no demux device found !!"), 1, 0);
847                err("no demux device found");
848                goto starterror;
849        }
850        if(videogetdev() < 1)
851        {
852                tmpstr = ostrcat(tmpstr, _("Error: no video device found !!"), 1, 0);
853                err("no video device found");
854                goto starterror;
855        }
856        if(audiogetdev() < 1)
857        {
858                tmpstr = ostrcat(tmpstr, _("Error: no audio device found !!"), 1, 0);
859                err("no audio device found");
860                goto starterror;
861        }
862        ret = fecreatedummy();
863        ret = cagetdev();
864        ret = cigetdev();
865        ret = dvrgetdev();
866        ret = scgetdev();
867#ifdef MIPSEL
868        if(checkchipset("BCM7424") == 1) //inihdp
869                ret = encodergetdev();
870#endif
871
872        settunerstatus();
873
874        //start ca slot watching threads
875        castart();
876
877        //check skin
878        if(skincheck > 0)
879        {
880
881                tmpstr = ostrcat(tmpstr, _("Error: skin not found !!"), 1, 0);
882                err("skin not found");
883                goto starterror;
884        }
885
886        ret = readsat(getconfig("satfile", NULL));
887        ret = readtransponder(getconfig("transponderfile", NULL));
888        ret = readprovider(getconfig("providerfile", NULL));
889        ret = readchannel(getconfig("channelfile", NULL));
890        ret = readtransponderencoding(getconfig("transponderencodingfile", NULL));
891        ret = readmostzap(getconfig("mostzapfile", NULL));
892        ret = readlastsubtitle(getconfig("lastsubtitle", NULL));
893        ret = readchannelslot(getconfig("channelslotfile", NULL));
894
895        status.aktservice = addservice(NULL);
896        status.lastservice = addservice(NULL);
897        status.pipservice = addservice(NULL);
898
899        //check if startchannel defined
900        char* startchannellist = getconfig("startchannellist", NULL);
901        int startserviceid = getconfigint("startserviceid", NULL);
902        uint64_t starttransponderid = getconfigllu("starttransponderid", NULL);
903        int startservicetype = getconfigint("startservicetype", NULL);
904        if(startchannellist != NULL && startserviceid != 0)
905        {
906                if(startservicetype == 0)
907                {
908                        addconfig("channellist", startchannellist);
909                        addconfigint("serviceid", startserviceid);
910                        addconfigllu("transponderid", starttransponderid);
911                }
912                else
913                {
914                        addconfig("rchannellist", startchannellist);
915                        addconfigint("rserviceid", startserviceid);
916                        addconfigllu("rtransponderid", starttransponderid);
917                }
918                addconfigint("servicetype", startservicetype);
919        }
920        setvol(getconfigint("vol", NULL));
921        //tune to channel
922        if(status.servicetype == 0)
923                serviceret = servicestart(getchannel(getconfigint("serviceid", NULL), getconfigllu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0);
924        else
925                serviceret = servicestart(getchannel(getconfigint("rserviceid", NULL), getconfigllu("rtransponderid", NULL)), getconfig("rchannellist", NULL),  NULL, 0);
926
927        if(checkbox("IPBOX9000") == 1 && !file_exist("/tmp/.opticum9600.workaround"))
928        {
929                printf("opticum.workaround start\n");
930                system("touch /tmp/.opticum9600.workaround");
931                oshutdown(3, 1);
932                printf("opticum.workaround end\n");
933        }
934
935        ret = readscreen(getconfig("skinfile", NULL), 0, 0);
936        ret = readmainbouquet(getconfig("bouquetfile", NULL));
937        ret = readallbouquet();
938        ret = readmainplaylist(getconfig("playlistfile", NULL));
939        ret = readallplaylist();
940        ret = readrcmap(getconfig("rcmapfile", NULL));
941        ret = readepgscanlist(getconfig("epgchannelfile", NULL));
942        ret = settimezone(getconfig("timezone", NULL));
943        ret = readextepgconfig(getconfig("extepgfile", NULL));
944       
945        if(checkbox("VUSOLO2") == 1)
946                system("fbset 1280x720-1");
947
948
949        //check to remove preinstalled tpk packages
950        ret = tpkupdatepre();
951
952        addtimer(&checkdate, START, 2000, -1, NULL, NULL, NULL);
953        if(checkbox("ATEMIO510") == 0)
954                addtimer(&updatevfd, START, 1000, -1, NULL, NULL, NULL);
955
956        if(getconfigint("firststart", NULL) == 1)
957        {
958                if(file_exist("/var/etc/.scart"))
959                {
960                        setvideomode("pal", 0);
961                        changefbresolution("pal", 0);
962                        autoresolution();
963                }
964                addconfig("firststart", "0");
965        }
966
967        if(getconfig("remotecontrol", NULL) == NULL)
968        {
969                if(checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1)
970                {
971                        //autopo work
972                        char* tmptxt = NULL;
973                        tmptxt = ostrcat(tmptxt, _("RemoteControl Old Version"), 0, 0);
974                        tmptxt = ostrcat(tmptxt, _("RemoteControl Long Version"), 0, 0);
975                        free(tmptxt), tmptxt = NULL;
976
977                        struct menulist* mlist = NULL, *mbox = NULL;
978                        addmenulist(&mlist, "RemoteControl Old Version", "0", NULL, 0, 0);
979                        addmenulist(&mlist, "RemoteControl Long Version", "1", NULL, 0, 0);
980                        // remotecontrol try menulist
981                        mbox = menulistbox(mlist, "menulist", _("Select Your Remote Control"), _("Choose your Remotecontrol Model from the following list"), NULL, NULL, 3, 0);
982                        if(mbox != NULL)
983                        {
984                                debug(10, "mbox->name %s", mbox->name);
985                                debug(10, "mbox->text %s", mbox->text);
986                                addconfig("remotecontrol", mbox->text);
987                                writeallconfig(1);                             
988                        }
989                }
990        }
991                       
992        //first wizzard
993        if(getconfigint("nofirstwizzard", NULL) < 2)
994        {
995                if(file_exist("/var/etc/.scart"))
996                {
997                        setvideomode("pal", 0);
998                        changefbresolution("pal", 0);
999                }
1000
1001                autoresolution();
1002                       
1003                if(getconfigint("nofirstwizzard", NULL) == 0)
1004                {
1005firstwizzardstep1:
1006
1007                        status.updatevfd = PAUSE;
1008//                      screenavsettings(1);
1009//                      resettvpic();
1010                        //this screen can reload the skin (on language change)
1011                        //all skin changes before here than are deleted
1012//                      if(screenlanguage(2) == 2) return 100;
1013//                      resettvpic();
1014
1015                        screentunerconfig();
1016                        resettvpic();
1017                        screenscanconfig(1);
1018                        resettvpic();
1019//                      screennetwork_adapter();
1020//                      resettvpic();
1021                        writevfd("Setting OK ?");
1022                        if(textbox(_("First Wizzard"), _("Settings OK ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2)
1023                        {
1024                                goto firstwizzardstep1;
1025                        }
1026                }
1027                resettvpic();
1028
1029                char* msg = NULL;
1030                msg = readfiletomem("/etc/imageinfo", 0);
1031                textbox(_("Info"), _(msg), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 680, 30, 0);
1032                free(msg); msg = NULL;
1033               
1034                writevfd("");
1035                status.updatevfd = START;
1036                drawscreen(skin, 0, 0);
1037                addconfig("nofirstwizzard", "2");
1038        }
1039        else
1040        {
1041                // workaround, remove bootlogo on startup
1042                drawscreen(skin, 0, 0);
1043
1044                //check servicestart
1045                if(serviceret != 21) // no message if startchannel empty
1046                        servicecheckret(serviceret, 0);
1047        }
1048
1049// fixt manual start
1050        resettvpic();
1051
1052        //start auto shutdown thread
1053        addtimer(&checkshutdowntimer, START, 10000, -1, NULL, NULL, NULL);
1054        //start demo mode
1055        if(checkbox("WHITEBOX") == 1)
1056                addtimer(&demomodethread, START, 600000, -1, NULL, NULL, NULL);
1057
1058        status.lastrcaction = time(NULL);
1059        ret = loadplugin();
1060        setosdtransparent(getskinconfigint("osdtransparent", NULL));
1061        ret = setsaturation(getconfigint("vs_saturation", NULL));
1062        ret = setbrightness(getconfigint("vs_brightness", NULL));
1063        ret = setcontrast(getconfigint("vs_contrast", NULL));
1064        ret = settint(getconfigint("vs_tint", NULL));
1065       
1066#ifndef SIMULATE
1067        //set skinentrys locked
1068        if(status.security == 0)
1069                setskinnodeslocked(1);
1070        else
1071                setskinnodeslocked(0);
1072#endif
1073
1074        //start epg thread
1075        status.epgthread = addtimer(&epgthreadfunc, START, 1000, -1, NULL, NULL, NULL);
1076        //start record timer thread (on delay change you must change rectimer.h also)
1077        status.rectimerthread = addtimer(&checkrectimer, START, 1000, -1, NULL, NULL, NULL);
1078        //check if cam socket connected
1079        addtimer(&checkcam, START, 3000, -1, NULL, NULL, NULL);
1080        //start stream server
1081        tmpthread = addtimer(&streamthreadfunc, START, 10000, -1, NULL, NULL, NULL);
1082        if(tmpthread != NULL)
1083        {
1084                tmpthread->flag = setbit(tmpthread->flag, 0);
1085                tmpthread = NULL;
1086        }
1087        //start epg scanlist
1088        status.epgscanlistthread = addtimer(&epgscanlistthread, START, 1000, 1, NULL, NULL, NULL);
1089        //get pmt
1090        if(getconfigint("checkpmtalways", NULL) == 1)
1091                addtimer(&dvbgetpmtthread, START, 2000, -1, NULL, NULL, NULL);
1092        //check hdd
1093        status.addhddall = addtimer(&addhddall, START, 6000, -1, NULL, NULL, NULL);
1094        //check net
1095        addtimer(&addinetworkall, START, 15000, -1, NULL, NULL, NULL);
1096        //check kill net (security)
1097        addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL);
1098        //check old entrys and remove from mem
1099        addtimer(&oldentrythreadfunc, START, 60000 * 60, -1, NULL, NULL, NULL);
1100
1101        //start newsletter
1102        startnewsletter(1);
1103
1104        //thumb create thread
1105        startthumb(1);
1106
1107        //start webserver
1108        starthttpd(1);
1109       
1110        //start rguid
1111        startrguid(1);
1112
1113        //init the player
1114        playerinit(argc, argv);
1115       
1116        //start spinner thread
1117        addtimer(&checkspinner, START, 2000, -1, NULL, NULL, NULL);
1118
1119        system(getconfig("skriptaftertv", NULL));
1120
1121        // work
1122        resettvpic();
1123       
1124        char* cmd = NULL;
1125#ifdef SH4
1126        cmd = ostrcat("/media/hdd/movie/titankey.sh4", NULL, 0, 0);
1127#endif
1128
1129#ifdef MIPSEL
1130        cmd = ostrcat("/media/hdd/movie/titankey.mipsel", NULL, 0, 0);
1131#endif
1132
1133        //for atemio to unlock box with stick
1134        if(file_exist(cmd))
1135        {
1136                char* cpuid = getcpuid();
1137                cmd = ostrcat(cmd, " ", 1, 0);
1138                cmd = ostrcat(cmd, cpuid, 1, 0);
1139
1140                system(cmd);
1141                checkserial(cpuid);
1142                free(cmd); cmd = NULL;
1143
1144                if(status.security >= 1)
1145                {
1146                        char* mac = getmacfromcmdline();
1147                        if(mac != NULL)
1148                        {
1149                                cmd = ostrcat(cmd, cpuid, 1, 0);
1150                                cmd = ostrcat(cmd, ",", 1, 0);
1151                                cmd = ostrcat(cmd, mac, 1, 0);
1152                               
1153                                free(mac); mac = NULL;
1154                        }
1155                        else
1156                                cmd = ostrcat(cmd, cpuid, 1, 0);
1157
1158                        writesys("/media/hdd/movie/codelist.txt", cmd, 3);
1159                        textbox(_("Message"), _("Receiver successful unlocked"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1160                }
1161
1162                free(cpuid); cpuid = NULL;
1163        }
1164        free(cmd); cmd = NULL;
1165
1166        //must called direct befor screeninfobar
1167        if(getconfigint("saverun", NULL) == 1)
1168        {
1169                ret = sigsetjmp(status.longjumpbuf, 1);
1170                if(ret != 0 && ret != 999)
1171                {
1172                        err("set sigsegjump");
1173                }
1174        }
1175       
1176        if(checkbox("UFS910") == 0 && checkbox("UFS922") == 0)
1177        {
1178                //check free space in /var
1179                if(getfreespace("/var") / 1024 < 50) //200kb
1180                        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);
1181                else
1182                {
1183                        //check writeable in /var
1184                        if(mkdir("/var/writetest", 0777) != 0 && errno != EEXIST)
1185                        {
1186                                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)
1187                                {
1188                                        system("repairjffs2.sh var &"); //this script kills titan an reboot
1189                                        sleep(10);
1190                                }
1191                        }
1192                        rmdir("/var/writetest");
1193                }
1194       
1195                //check free space in /mnt
1196                if(getfreespace("/mnt") / 1024 < 50) //200kb
1197                        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);
1198                else
1199                {
1200                        //check writeable in /mnt
1201                        if(mkdir("/mnt/writetest", 0777) != 0 && errno != EEXIST)
1202                        {
1203                                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)
1204                                {
1205                                        system("repairjffs2.sh mnt &"); //this script kills titan an reboot
1206                                        sleep(10);
1207                                }
1208                        }
1209                        rmdir("/mnt/writetest");
1210                }
1211        }
1212
1213        addtimer(&guestthread, START, 1000, 1, NULL, NULL, NULL);
1214        startinternreader(1);
1215       
1216        screeninfobar();
1217
1218        //for testign screens
1219        //screenmanualscan();
1220        //screeninputhelp();
1221        //screendownload("test", "www.orf.at", NULL, 80, "test.html", 0);
1222        //screenrectimer();
1223        //screenepgsettings();
1224        //screenlnb("1");
1225        //screendiseqc("1");
1226        //screenlanguage();
1227        //screenvideosettings();
1228        //screenskinselect();
1229        //screenrectimer();
1230        //screennetwork_adapter(2);
1231        //screenpin();
1232        //screenchannellist();
1233        //recordstart(channel, RECDIRECT);
1234        //mc_main();
1235        //screenmc_videoplayer();
1236        //screenserviceinfo();
1237        //screentunerconfig();
1238        //screenvfdisplay();
1239        //screenavsettings(1);
1240        //screenadjust();
1241        //subtitlestart();
1242
1243        if(mmapfb != NULL) {
1244                free(mmapfb); mmapfb=NULL;
1245        }
1246        oshutdown(1, 1);
1247        return 0;
1248
1249starterror:
1250        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);
1251        struct skin *starterror = getscreen("starterror");
1252        if(tmpstr == NULL)
1253                tmpstr = ostrcat(tmpstr, _("Unknown Error."), 1, 0);
1254        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
1255        tmpstr = ostrcat(tmpstr, _("Automatic stop in 10 seconds."), 1, 0);
1256        changetext(starterror, _(tmpstr));
1257        drawscreen(starterror, 0, 0);
1258        sleep(10);
1259        free(tmpstr);
1260        return 100;
1261}
Note: See TracBrowser for help on using the repository browser.