source: titan/titan/titan.c @ 36069

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

[titan] nemesis... fix oled skin path

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