1 | #include "struct.h" |
---|
2 | #include "header.h" |
---|
3 | #include "debug.h" |
---|
4 | #include "crc32.h" |
---|
5 | #include "sock.h" |
---|
6 | |
---|
7 | |
---|
8 | #define SYSCODE 0 |
---|
9 | |
---|
10 | struct clist *config[LISTHASHSIZE] = {NULL}; |
---|
11 | struct clist *ownconfig[LISTHASHSIZE] = {NULL}; |
---|
12 | struct clist *rcconfig[LISTHASHSIZE] = {NULL}; |
---|
13 | struct clist *skinconfig[LISTHASHSIZE] = {NULL}; |
---|
14 | struct skin *skin = NULL; |
---|
15 | struct fb *fb = NULL; |
---|
16 | struct fb* skinfb = NULL; |
---|
17 | struct fb* accelfb = NULL; |
---|
18 | struct fb* fb1 = NULL; |
---|
19 | struct fb* lcdskinfb = NULL; |
---|
20 | struct font *font = NULL; |
---|
21 | struct rc *rc = NULL; |
---|
22 | struct dvbdev *dvbdev = NULL; |
---|
23 | struct channel *channel = NULL; |
---|
24 | struct transponder *transponder = NULL; |
---|
25 | struct provider *provider = NULL; |
---|
26 | struct sat *sat = NULL; |
---|
27 | struct service *service = NULL; |
---|
28 | struct mainbouquet *mainbouquet = NULL; |
---|
29 | struct mainplaylist *mainplaylist = NULL; |
---|
30 | struct pic *pic = NULL; |
---|
31 | struct rcmap *rcmap = NULL; |
---|
32 | struct inetwork *inetwork = NULL; |
---|
33 | struct stimerthread *stimerthread = NULL; |
---|
34 | struct rectimer *rectimer = NULL; |
---|
35 | struct subpage* subpage = NULL, *oldsubpage = NULL; |
---|
36 | struct epgscanlist* epgscanlist = NULL; |
---|
37 | struct screensaver* screensaver = NULL; |
---|
38 | struct channelcache* channelcache[CHANNELCACHEMAX] = {NULL}; |
---|
39 | struct transpondercache* transpondercache[TRANSPONDERCACHEMAX] = {NULL}; |
---|
40 | struct hdd* hdd = NULL; |
---|
41 | struct queue* queue = NULL; |
---|
42 | struct caservice caservice[MAXCASERVICE]; |
---|
43 | struct channelhistory channelhistory[MAXCHANNELHISTORY]; |
---|
44 | |
---|
45 | #ifdef SH4 |
---|
46 | #include "sh4port.h" |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifdef MIPSEL |
---|
50 | #include "mipselport.h" |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifdef I386 |
---|
54 | #include "i386port.h" |
---|
55 | #endif |
---|
56 | |
---|
57 | #include "ipkg.h" |
---|
58 | #include "queue.h" |
---|
59 | #include "channelcache.h" |
---|
60 | #include "transpondercache.h" |
---|
61 | #include "strconvert.h" |
---|
62 | #include "numinput.h" |
---|
63 | #include "textinput.h" |
---|
64 | #include "radiotext.h" |
---|
65 | #include "list.h" |
---|
66 | #include "config.h" |
---|
67 | #include "defaults.h" |
---|
68 | #include "ownconfig.h" |
---|
69 | #include "rcconfig.h" |
---|
70 | #include "skinconfig.h" |
---|
71 | #include "global.h" |
---|
72 | #include "stream.h" |
---|
73 | #include "dvbdev.h" |
---|
74 | #include "rotorcalc.h" |
---|
75 | #include "frontenddev.h" |
---|
76 | #include "dmxdev.h" |
---|
77 | #include "videodev.h" |
---|
78 | #include "audiodev.h" |
---|
79 | #include "cidev.h" |
---|
80 | #include "cadev.h" |
---|
81 | #ifdef CAMSUPP |
---|
82 | #include "ca.h" |
---|
83 | #endif |
---|
84 | #include "dvrdev.h" |
---|
85 | #include "cam.h" |
---|
86 | #include "dvb.h" |
---|
87 | #include "fb.h" |
---|
88 | #include "font.h" |
---|
89 | #include "rcmap.h" |
---|
90 | #include "rc.h" |
---|
91 | #include "sat.h" |
---|
92 | #include "transponder.h" |
---|
93 | #include "provider.h" |
---|
94 | #include "channel.h" |
---|
95 | #include "bouquets.h" |
---|
96 | #include "mainbouquets.h" |
---|
97 | #include "playlist.h" |
---|
98 | #include "mainplaylist.h" |
---|
99 | #include "pic.h" |
---|
100 | #include "filelist.h" |
---|
101 | #include "skinfunc.h" |
---|
102 | #include "skin.h" |
---|
103 | #include "inputhelp.h" |
---|
104 | #include "rcfunc.h" |
---|
105 | #include "listbox.h" |
---|
106 | #include "choicebox.h" |
---|
107 | #include "vfd.h" |
---|
108 | #include "timerthread.h" |
---|
109 | #include "service.h" |
---|
110 | #include "player.h" |
---|
111 | #include "dvdplayer.h" |
---|
112 | #include "timeshift.h" |
---|
113 | #include "record.h" |
---|
114 | #include "zap.h" |
---|
115 | #include "showiframe.h" |
---|
116 | #include "epgrecord.h" |
---|
117 | #include "multiepg.h" |
---|
118 | #include "gmultiepg.h" |
---|
119 | #include "epg.h" |
---|
120 | #include "epgscan.h" |
---|
121 | #include "menulist.h" |
---|
122 | #include "videomode.h" |
---|
123 | #include "inetwork.h" |
---|
124 | #include "keyactions.h" |
---|
125 | #include "scart.h" |
---|
126 | #include "standby.h" |
---|
127 | #include "dir.h" |
---|
128 | #include "spinner.h" |
---|
129 | #include "lnbconfig.h" |
---|
130 | #include "diseqcconfig.h" |
---|
131 | #include "tunerconfig.h" |
---|
132 | #include "epgsettings.h" |
---|
133 | #include "listedit.h" |
---|
134 | #include "channellist.h" |
---|
135 | #include "vfdisplay.h" |
---|
136 | #include "videosettings.h" |
---|
137 | #include "textbox.h" |
---|
138 | #include "autores.h" |
---|
139 | #include "language.h" |
---|
140 | #include "about.h" |
---|
141 | #include "serviceinfo.h" |
---|
142 | #include "avsettings.h" |
---|
143 | #include "mute.h" |
---|
144 | #include "volume.h" |
---|
145 | #include "timezone.h" |
---|
146 | #include "adjust.h" |
---|
147 | #include "skinadjust.h" |
---|
148 | #include "blindscanadjust.h" |
---|
149 | #include "moduleconfig.h" |
---|
150 | #include "possetup.h" |
---|
151 | #include "rectimer.h" |
---|
152 | #include "pin.h" |
---|
153 | #include "plugin.h" |
---|
154 | #include "recordpath.h" |
---|
155 | #include "subtitle.h" |
---|
156 | #include "audiotrack.h" |
---|
157 | #include "linkedchannel.h" |
---|
158 | #include "powerofftimer.h" |
---|
159 | #include "skinselector.h" |
---|
160 | #include "play.h" |
---|
161 | #include "satfinder.h" |
---|
162 | #include "menu.h" |
---|
163 | #include "channelbynr.h" |
---|
164 | #include "infobar.h" |
---|
165 | #include "network.h" |
---|
166 | #include "harddisk.h" |
---|
167 | #include "httpdfunc.h" |
---|
168 | #include "httpd.h" |
---|
169 | #include "download.h" |
---|
170 | #include "screensaver.h" |
---|
171 | #include "screensaveradjust.h" |
---|
172 | #include "scan.h" |
---|
173 | #include "restoredefault.h" |
---|
174 | #include "help.h" |
---|
175 | #include "httpdsettings.h" |
---|
176 | #include "epgsearch.h" |
---|
177 | #include "inadyn.h" |
---|
178 | #include "rguid.h" |
---|
179 | #include "channelhistroy.h" |
---|
180 | //#include "cardreader.h" |
---|
181 | //#include "sci.h" |
---|
182 | |
---|
183 | #define TIMECODE "" |
---|
184 | |
---|
185 | int createstartscreen() |
---|
186 | { |
---|
187 | addscreen("<screen name=framebuffer/>", 0, 0); |
---|
188 | if(skin == NULL) |
---|
189 | { |
---|
190 | err("can't set framebuffer skin"); |
---|
191 | return 1; |
---|
192 | } |
---|
193 | addscreen("<screen name=skinerror/>", 0, 0); |
---|
194 | status.skinerr = getscreen("skinerror"); |
---|
195 | skin->width = skinfb->width; |
---|
196 | skin->height = skinfb->height; |
---|
197 | skin->iwidth = skinfb->width; |
---|
198 | skin->iheight = skinfb->height; |
---|
199 | skin->rwidth = skinfb->width; |
---|
200 | skin->rheight = skinfb->height; |
---|
201 | skin->bgcol = 0; |
---|
202 | skin->transparent = 255; |
---|
203 | skin->flag = 1; |
---|
204 | |
---|
205 | return 0; |
---|
206 | } |
---|
207 | |
---|
208 | //exitcode: 1 power off |
---|
209 | //exitcode: 2 restart |
---|
210 | //exitcode: 3 Gui restart |
---|
211 | //flag: 0 do not check record |
---|
212 | //flag: 1 check record |
---|
213 | //flag: 2 check record / do write config |
---|
214 | //flag: 3 check record with timeout |
---|
215 | //flag: 4 check record with increase fixpowerofftime |
---|
216 | void oshutdown(int exitcode, int flag) |
---|
217 | { |
---|
218 | debug(1000, "in"); |
---|
219 | struct service* servicenode = service; |
---|
220 | void* threadstatus; |
---|
221 | int i = 0, faststop = 0, ret = 0; |
---|
222 | char* tmpstr = NULL; |
---|
223 | struct skin* logo = getscreen("logo"); |
---|
224 | |
---|
225 | //check if record running |
---|
226 | if((flag == 1 || flag == 2 || flag == 3 || flag == 4) && (status.recording > 0 || getrectimerbytimediff(300) != NULL)) |
---|
227 | { |
---|
228 | if(flag == 4 && status.fixpowerofftime > 1) |
---|
229 | { |
---|
230 | status.fixpowerofftime = time(NULL) + 900; //check powerofftimer again in 15min |
---|
231 | return; |
---|
232 | } |
---|
233 | int timeout = 0; |
---|
234 | if(flag == 3 || flag == 4) timeout = 15; |
---|
235 | if(textbox(_("Message"), _("Found running record\nor record is starting in next time.\nRealy shutdown ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, timeout, 1) == 2) |
---|
236 | return; |
---|
237 | } |
---|
238 | |
---|
239 | ret = servicestop(status.aktservice, 1, 0); |
---|
240 | if(ret == 1) return; |
---|
241 | |
---|
242 | if(exitcode == 1) |
---|
243 | tmpstr = getconfig("powerofflogo", NULL); |
---|
244 | else if(exitcode == 2) |
---|
245 | tmpstr = getconfig("restartlogo", NULL); |
---|
246 | else if(exitcode == 3) |
---|
247 | tmpstr = getconfig("guirestartlogo", NULL); |
---|
248 | |
---|
249 | if(tmpstr != NULL) |
---|
250 | { |
---|
251 | changepic(logo, tmpstr); |
---|
252 | tmpstr = NULL; |
---|
253 | drawscreen(logo, 0); |
---|
254 | } |
---|
255 | else |
---|
256 | clearfball(); |
---|
257 | |
---|
258 | //stop all records |
---|
259 | while(servicenode != NULL) |
---|
260 | { |
---|
261 | servicenode->recendtime = 1; |
---|
262 | servicenode = servicenode->next; |
---|
263 | } |
---|
264 | |
---|
265 | faststop = getconfigint("faststop", NULL); |
---|
266 | |
---|
267 | // Free memory, semaphores, etc. and say goodbye |
---|
268 | if(faststop == 0) cleanupvfd(); |
---|
269 | |
---|
270 | tmpstr = oitoa(status.servicetype); |
---|
271 | addconfig("servicetype", tmpstr); |
---|
272 | free(tmpstr); tmpstr = NULL; |
---|
273 | |
---|
274 | status.sec = 0; |
---|
275 | |
---|
276 | if(flag != 2) |
---|
277 | { |
---|
278 | int epgsave = getconfigint("epgsave", NULL); |
---|
279 | if((epgsave == 1 && exitcode == 3) || epgsave == 2) |
---|
280 | writeallconfig(1); //do not save epg |
---|
281 | else |
---|
282 | writeallconfig(0); //save epg |
---|
283 | } |
---|
284 | |
---|
285 | if(faststop == 0) |
---|
286 | { |
---|
287 | //stop timer thread |
---|
288 | i = 0; |
---|
289 | status.timerthreadaktion = STOP; |
---|
290 | while(status.timerthreadstatus != DEACTIVE) |
---|
291 | { |
---|
292 | usleep(100000); |
---|
293 | i++; if(i > 20) break; |
---|
294 | } |
---|
295 | |
---|
296 | if(i > 20) |
---|
297 | { |
---|
298 | err("detect hanging timer thread"); |
---|
299 | } |
---|
300 | else |
---|
301 | pthread_join(status.timerthread, &threadstatus); |
---|
302 | pthread_attr_destroy(&status.timerthreadattr); |
---|
303 | |
---|
304 | // free timerthread struct and stop all timer sub threads |
---|
305 | freetimer(0); |
---|
306 | |
---|
307 | status.skinerr = NULL; |
---|
308 | free(status.gateway); |
---|
309 | free(status.dnsserver1); |
---|
310 | free(status.dnsserver2); |
---|
311 | free(status.boxtype); |
---|
312 | free(status.httpauth); |
---|
313 | |
---|
314 | freeservice(); |
---|
315 | |
---|
316 | freescreen(); |
---|
317 | freepic(); |
---|
318 | freefont(); |
---|
319 | deinitfont(); |
---|
320 | |
---|
321 | freerectimer(); |
---|
322 | freechannelhistory(); |
---|
323 | freesat(); |
---|
324 | freeallplaylist(); |
---|
325 | freemainplaylist(); |
---|
326 | freeallbouquet(); |
---|
327 | freemainbouquet(); |
---|
328 | freechannel(0); |
---|
329 | freetransponder(); |
---|
330 | freeprovider(); |
---|
331 | freeownconfig(); |
---|
332 | freeepgscanlist(); |
---|
333 | freercconfig(); |
---|
334 | freeskinconfig(); |
---|
335 | freequeue(); |
---|
336 | freehdd(0); |
---|
337 | |
---|
338 | free(status.configfile); |
---|
339 | freeconfig(); |
---|
340 | |
---|
341 | freedvbdev(); |
---|
342 | |
---|
343 | closefb(fb); |
---|
344 | freefb(); |
---|
345 | |
---|
346 | closerc(); |
---|
347 | freerc(); |
---|
348 | freercmap(); |
---|
349 | free_shutdowntimervar(); |
---|
350 | freeinetwork(); |
---|
351 | } |
---|
352 | else |
---|
353 | freetimer(1); |
---|
354 | |
---|
355 | starthttpd(0); |
---|
356 | startrguid(0); |
---|
357 | initmutex(0); |
---|
358 | |
---|
359 | debug(1000, "out"); |
---|
360 | exit(exitcode); |
---|
361 | } |
---|
362 | |
---|
363 | int main(int argc, char *argv[]) |
---|
364 | { |
---|
365 | debug(1000, "in"); |
---|
366 | int ret = 0, serviceret = 0, skincheck = 0; |
---|
367 | char* tmpstr = NULL; |
---|
368 | struct sigaction sa; |
---|
369 | struct stimerthread *tmpthread = NULL; |
---|
370 | |
---|
371 | #ifdef SIMULATE |
---|
372 | // for mem leak debug |
---|
373 | setenv("MALLOC_TRACE", "/home/nit/titan/m.txt", 1); |
---|
374 | mtrace(); |
---|
375 | status.security = 1; |
---|
376 | #endif |
---|
377 | |
---|
378 | printf("[%s] copyright by %s - version %s\n", PROGNAME, COPYRIGHT, OVERSION); |
---|
379 | printf("[%s] crontribut: %s\n", PROGNAME, CRONTRIBUT); |
---|
380 | |
---|
381 | sa.sa_handler = (void *)sighandler; |
---|
382 | sigemptyset(&sa.sa_mask); |
---|
383 | sa.sa_flags = SA_RESTART; |
---|
384 | sigaction(SIGUSR1, &sa, NULL); |
---|
385 | sigaction(SIGSEGV, &sa, NULL); |
---|
386 | sigaction(SIGBUS, &sa, NULL); |
---|
387 | sigaction(SIGABRT, &sa, NULL); |
---|
388 | |
---|
389 | status.rguidfd = -1; |
---|
390 | status.sec = time(NULL); |
---|
391 | status.mainthread = pthread_self(); |
---|
392 | |
---|
393 | if(argc > 1) |
---|
394 | status.configfile = ostrcat(argv[1], "", 0, 0); |
---|
395 | else |
---|
396 | status.configfile = ostrcat(CONFIGFILE, "", 0, 0); |
---|
397 | |
---|
398 | printf("[%s] using config: %s\n", PROGNAME, status.configfile); |
---|
399 | ret = readconfig(status.configfile, config); |
---|
400 | if(ret != 0) |
---|
401 | return 100; |
---|
402 | readconfig(getconfig("ownconfig", NULL), ownconfig); |
---|
403 | readconfig(getconfig("rcconfig", NULL), rcconfig); |
---|
404 | |
---|
405 | skincheck = checkskin(); |
---|
406 | readconfig(getconfig("skinconfig", NULL), skinconfig); |
---|
407 | |
---|
408 | setprogress(100); |
---|
409 | setdefaults(); |
---|
410 | setdebuglevel(); |
---|
411 | initmutex(1); |
---|
412 | initvfd(); |
---|
413 | |
---|
414 | if(checkbox("UFS922") == 1) |
---|
415 | setfanspeed(-1, 0); |
---|
416 | |
---|
417 | ret = setvideomode(getconfig("av_videomode", NULL), 0); |
---|
418 | |
---|
419 | ret = setpolicy(getconfig("av_policy", NULL)); |
---|
420 | ret = setaspect(getconfig("av_aspect", NULL)); |
---|
421 | ret = setcolorformat(getconfig("av_colorformat", NULL)); |
---|
422 | ret = setaudiosource(getconfig("av_audiosource", NULL)); |
---|
423 | ret = setac3(getconfig("av_ac3mode", NULL)); |
---|
424 | ret = setmode3d(getconfig("av_mode3d", NULL)); |
---|
425 | ret = setvfdbrightness(getconfigint("vfdbrightness", NULL)); |
---|
426 | ret = addinetworkall(NULL); |
---|
427 | |
---|
428 | #ifndef SIMULATE |
---|
429 | int skipsecurety = 0; |
---|
430 | if(skipsecurety == 0) |
---|
431 | { |
---|
432 | if(ostrcmp(string_newline(gettimeinfo()), TIMECODE) == 1) |
---|
433 | { |
---|
434 | destroy(); |
---|
435 | exit(100); |
---|
436 | } |
---|
437 | if(ostrcmp(string_newline(gettimeinfovar()), TIMECODE) == 1) |
---|
438 | { |
---|
439 | destroy(); |
---|
440 | exit(100); |
---|
441 | } |
---|
442 | if(checkreseller() != 0) |
---|
443 | { |
---|
444 | destroy(); |
---|
445 | exit(100); |
---|
446 | } |
---|
447 | if(getsysinfo() != SYSCODE) |
---|
448 | { |
---|
449 | destroy(); |
---|
450 | exit(100); |
---|
451 | } |
---|
452 | if(file_exist("/mnt/swapextensions/etc/.vnumber") == 1) |
---|
453 | { |
---|
454 | destroy(); |
---|
455 | exit(100); |
---|
456 | } |
---|
457 | if(checkflash() != 0) |
---|
458 | { |
---|
459 | destroy(); |
---|
460 | exit(100); |
---|
461 | } |
---|
462 | char* tmpstr2 = NULL; |
---|
463 | tmpstr2 = getcpuid(); |
---|
464 | checkserial(tmpstr2); |
---|
465 | free(tmpstr2), tmpstr2 = NULL; |
---|
466 | } |
---|
467 | else |
---|
468 | status.security = 1; |
---|
469 | #endif |
---|
470 | |
---|
471 | ret = initfont(); |
---|
472 | if(ret != 0) |
---|
473 | return 100; |
---|
474 | ret = openfont(getconfig("fontfile1", NULL)); |
---|
475 | if(ret != 0) |
---|
476 | { |
---|
477 | err("open fontfile1 font"); |
---|
478 | return 100; |
---|
479 | } |
---|
480 | openfont(getconfig("fontfile2", NULL)); |
---|
481 | openfont(getconfig("fontfile3", NULL)); |
---|
482 | openfont(getconfig("fontfile4", NULL)); |
---|
483 | openfont(getconfig("fontfile5", NULL)); |
---|
484 | |
---|
485 | //skin defined fonts |
---|
486 | openfont(getskinconfig("fontfile1", NULL)); |
---|
487 | openfont(getskinconfig("fontfile2", NULL)); |
---|
488 | openfont(getskinconfig("fontfile3", NULL)); |
---|
489 | openfont(getskinconfig("fontfile4", NULL)); |
---|
490 | openfont(getskinconfig("fontfile5", NULL)); |
---|
491 | |
---|
492 | setvol(getconfigint("vol", NULL)); |
---|
493 | |
---|
494 | setlang(getconfig("lang", NULL)); |
---|
495 | initlocale(getconfig("localepath", NULL)); |
---|
496 | |
---|
497 | fb = openfb(getconfig("fbdev", NULL), 0); |
---|
498 | if(fb == NULL) |
---|
499 | return 100; |
---|
500 | clearfball(); |
---|
501 | enablemanualblit(); |
---|
502 | |
---|
503 | tmpstr = getconfig("fb1dev", NULL); |
---|
504 | if(tmpstr != NULL) |
---|
505 | fb1 = openfb(tmpstr, 1); |
---|
506 | tmpstr = NULL; |
---|
507 | |
---|
508 | if(status.usedirectfb != 1) |
---|
509 | { |
---|
510 | skinfb = addfb(SKINFB, 0, getconfigint("skinfbwidth", NULL), getconfigint("skinfbheight", NULL), 4, fb->fd, fb->fb + fb->varfbsize, fb->fixfbsize); |
---|
511 | if(skinfb != NULL) |
---|
512 | { |
---|
513 | ret = getfbsize(0); |
---|
514 | if(ret > 0) |
---|
515 | accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize); |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | debug(100, "use directfb"); |
---|
520 | status.usedirectfb = 1; |
---|
521 | } |
---|
522 | } |
---|
523 | |
---|
524 | if(status.usedirectfb == 1) |
---|
525 | { |
---|
526 | skinfb = fb; |
---|
527 | ret = getfbsize(0); |
---|
528 | if(ret > 0) |
---|
529 | accelfb = addfb(ACCELFB, 0, ret / 4, 1, 4, fb->fd, skinfb->fb + skinfb->varfbsize, fb->fixfbsize); |
---|
530 | } |
---|
531 | |
---|
532 | if(lcdskinfb == NULL) { |
---|
533 | unsigned char *mmapfb = malloc(4 * 320 * 240); |
---|
534 | /* dev=999 ist LCD Buffer */ |
---|
535 | lcdskinfb = addfb("lcdskinfb", 999, 320, 240, 4, -1, mmapfb, 4 * 320 * 240); |
---|
536 | mmapfb = NULL; |
---|
537 | } |
---|
538 | |
---|
539 | ret = createstartscreen(); |
---|
540 | if(ret != 0) return 100; |
---|
541 | |
---|
542 | //from here we can use starterror screen |
---|
543 | ret = openrc(); |
---|
544 | if(ret != 0) |
---|
545 | { |
---|
546 | tmpstr = ostrcat(tmpstr, _("Error: open rc device !!"), 1, 0); |
---|
547 | goto starterror; |
---|
548 | } |
---|
549 | ret = openrcsim(); |
---|
550 | if(ret != 0) |
---|
551 | { |
---|
552 | tmpstr = ostrcat(tmpstr, _("Error: open rcsim device !!"), 1, 0); |
---|
553 | goto starterror; |
---|
554 | } |
---|
555 | |
---|
556 | if(fegetdev() < 1) |
---|
557 | { |
---|
558 | tmpstr = ostrcat(tmpstr, _("Error: no frontend device found !!"), 1, 0); |
---|
559 | err("no frontend device found"); |
---|
560 | goto starterror; |
---|
561 | } |
---|
562 | if(dmxgetdev() < 1) |
---|
563 | { |
---|
564 | tmpstr = ostrcat(tmpstr, _("Error: no demux device found !!"), 1, 0); |
---|
565 | err("no demux device found"); |
---|
566 | goto starterror; |
---|
567 | } |
---|
568 | if(videogetdev() < 1) |
---|
569 | { |
---|
570 | tmpstr = ostrcat(tmpstr, _("Error: no video device found !!"), 1, 0); |
---|
571 | err("no video device found"); |
---|
572 | goto starterror; |
---|
573 | } |
---|
574 | if(audiogetdev() < 1) |
---|
575 | { |
---|
576 | tmpstr = ostrcat(tmpstr, _("Error: no audio device found !!"), 1, 0); |
---|
577 | err("no audio device found"); |
---|
578 | goto starterror; |
---|
579 | } |
---|
580 | ret = fecreatedummy(); |
---|
581 | ret = cagetdev(); |
---|
582 | ret = cigetdev(); |
---|
583 | ret = dvrgetdev(); |
---|
584 | |
---|
585 | //check skin |
---|
586 | if(skincheck > 0) |
---|
587 | { |
---|
588 | |
---|
589 | tmpstr = ostrcat(tmpstr, _("Error: skin not found !!"), 1, 0); |
---|
590 | err("skin not found"); |
---|
591 | goto starterror; |
---|
592 | } |
---|
593 | |
---|
594 | ret = readsat(getconfig("satfile", NULL)); |
---|
595 | ret = readtransponder(getconfig("transponderfile", NULL)); |
---|
596 | ret = readprovider(getconfig("providerfile", NULL)); |
---|
597 | ret = readchannel(getconfig("channelfile", NULL)); |
---|
598 | ret = readtransponderencoding(getconfig("transponderencodingfile", NULL)); |
---|
599 | |
---|
600 | status.aktservice = addservice(NULL); |
---|
601 | status.lastservice = addservice(NULL); |
---|
602 | |
---|
603 | //check if startchannel defined |
---|
604 | char* startchannellist = getconfig("startchannellist", NULL); |
---|
605 | int startserviceid = getconfigint("startserviceid", NULL); |
---|
606 | unsigned long starttransponderid = getconfiglu("starttransponderid", NULL); |
---|
607 | int startservicetype = getconfigint("startservicetype", NULL); |
---|
608 | if(startchannellist != NULL && startserviceid != 0) |
---|
609 | { |
---|
610 | if(startservicetype == 0) |
---|
611 | { |
---|
612 | addconfig("channellist", startchannellist); |
---|
613 | addconfigint("serviceid", startserviceid); |
---|
614 | addconfiglu("transponderid", starttransponderid); |
---|
615 | } |
---|
616 | else |
---|
617 | { |
---|
618 | addconfig("rchannellist", startchannellist); |
---|
619 | addconfigint("rserviceid", startserviceid); |
---|
620 | addconfiglu("rtransponderid", starttransponderid); |
---|
621 | } |
---|
622 | addconfigint("servicetype", startservicetype); |
---|
623 | } |
---|
624 | |
---|
625 | //tune to channel |
---|
626 | if(status.servicetype == 0) |
---|
627 | serviceret = servicestart(getchannel(getconfigint("serviceid", NULL), getconfiglu("transponderid", NULL)), getconfig("channellist", NULL), NULL, 0); |
---|
628 | else |
---|
629 | serviceret = servicestart(getchannel(getconfigint("rserviceid", NULL), getconfiglu("rtransponderid", NULL)), getconfig("rchannellist", NULL), NULL, 0); |
---|
630 | |
---|
631 | ret = readscreen(getconfig("skinfile", NULL), 0, 0); |
---|
632 | ret = readmainbouquet(getconfig("bouquetfile", NULL)); |
---|
633 | ret = readallbouquet(); |
---|
634 | ret = readmainplaylist(getconfig("playlistfile", NULL)); |
---|
635 | ret = readallplaylist(); |
---|
636 | ret = readrcmap(getconfig("rcmapfile", NULL)); |
---|
637 | ret = readepgscanlist(getconfig("epgchannelfile", NULL)); |
---|
638 | ret = settimezone(getconfig("timezone", NULL)); |
---|
639 | |
---|
640 | //start timer thread |
---|
641 | status.timerthreadaktion = START; |
---|
642 | pthread_attr_init(&status.timerthreadattr); |
---|
643 | pthread_attr_setstacksize(&status.timerthreadattr, 50000); |
---|
644 | pthread_attr_setdetachstate(&status.timerthreadattr, PTHREAD_CREATE_JOINABLE); |
---|
645 | ret = pthread_create(&status.timerthread, &status.timerthreadattr, timerthreadfunc, NULL); |
---|
646 | if(ret) |
---|
647 | { |
---|
648 | tmpstr = ostrcat(tmpstr, _("Error: create timer thread !!"), 1, 0); |
---|
649 | err("create timer thread"); |
---|
650 | goto starterror; |
---|
651 | } |
---|
652 | |
---|
653 | addtimer(&checkdate, START, 2000, -1, NULL, NULL, NULL); |
---|
654 | if((checkbox("ATEMIO500") == 0) && (checkbox("ATEMIO510") == 0)) |
---|
655 | addtimer(&updatevfd, START, 1000, -1, NULL, NULL, NULL); |
---|
656 | |
---|
657 | //first wizzard |
---|
658 | if(getconfigint("nofirstwizzard", NULL) == 0) |
---|
659 | { |
---|
660 | if(file_exist("/tmp/.scart")) |
---|
661 | { |
---|
662 | setvideomode("pal", 0); |
---|
663 | changefbresolution("pal"); |
---|
664 | } |
---|
665 | |
---|
666 | autoresolution(); |
---|
667 | firstwizzardstep1: |
---|
668 | if(checkbox("ATEMIO510") == 0) |
---|
669 | { |
---|
670 | status.updatevfd = PAUSE; |
---|
671 | screenavsettings(1); |
---|
672 | //this screen can reload the skin (on language change) |
---|
673 | //all skin changes before here than are deleted |
---|
674 | if(screenlanguage(2) == 2) return 100; |
---|
675 | screentunerconfig(); |
---|
676 | screennetwork_adapter(); |
---|
677 | writevfd("Setting OK ?"); |
---|
678 | if(textbox(_("First Wizzard"), _("Settings OK ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2) |
---|
679 | { |
---|
680 | goto firstwizzardstep1; |
---|
681 | } |
---|
682 | } |
---|
683 | char* msg = NULL; |
---|
684 | msg = command("cat /etc/imageinfo"); |
---|
685 | textbox(_("Info"), _(msg), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 680, 30, 0); |
---|
686 | free(msg), msg = NULL; |
---|
687 | // getserial(); |
---|
688 | |
---|
689 | writevfd(""); |
---|
690 | status.updatevfd = START; |
---|
691 | drawscreen(skin, 0); |
---|
692 | addconfig("nofirstwizzard", "1"); |
---|
693 | } |
---|
694 | else |
---|
695 | { |
---|
696 | // workaround, remove bootlogo on startup |
---|
697 | drawscreen(skin, 0); |
---|
698 | |
---|
699 | //check servicestart |
---|
700 | if(serviceret != 21) // no message if startchannel empty |
---|
701 | servicecheckret(serviceret, 0); |
---|
702 | } |
---|
703 | |
---|
704 | //start spinner thread |
---|
705 | addtimer(&checkspinner, START, 2000, -1, NULL, NULL, NULL); |
---|
706 | //start auto shutdown thread |
---|
707 | addtimer(&checkshutdowntimer, START, 10000, -1, NULL, NULL, NULL); |
---|
708 | |
---|
709 | status.lastrcaction = time(NULL); |
---|
710 | ret = loadplugin(); |
---|
711 | setosdtransparent(getskinconfigint("osdtransparent", NULL)); |
---|
712 | ret = readrectimer(getconfig("rectimerfile", NULL)); |
---|
713 | ret = setsaturation(getconfigint("vs_saturation", NULL)); |
---|
714 | ret = setbrightness(getconfigint("vs_brightness", NULL)); |
---|
715 | ret = setcontrast(getconfigint("vs_contrast", NULL)); |
---|
716 | ret = settint(getconfigint("vs_tint", NULL)); |
---|
717 | |
---|
718 | //set skinentrys locked |
---|
719 | #ifndef SIMULATE |
---|
720 | if(status.security == 0) setskinnodeslocked(1); |
---|
721 | #endif |
---|
722 | |
---|
723 | //start epg thread |
---|
724 | status.epgthread = addtimer(&epgthreadfunc, START, 1000, -1, NULL, NULL, NULL); |
---|
725 | //start record timer thread |
---|
726 | addtimer(&checkrectimer, START, 10000, -1, NULL, NULL, NULL); |
---|
727 | //check if cam socket connected |
---|
728 | addtimer(&checkcam, START, 3000, -1, NULL, NULL, NULL); |
---|
729 | //start stream server |
---|
730 | tmpthread = addtimer(&streamthreadfunc, START, 10000, -1, NULL, NULL, NULL); |
---|
731 | if(tmpthread != NULL) |
---|
732 | { |
---|
733 | tmpthread->flag = setbit(tmpthread->flag, 0); |
---|
734 | tmpthread = NULL; |
---|
735 | } |
---|
736 | //start epg scanlist |
---|
737 | status.epgscanlistthread = addtimer(&epgscanlistthread, START, 1000, 1, NULL, NULL, NULL); |
---|
738 | //get pmt |
---|
739 | addtimer(&dvbgetpmtthread, START, 2000, -1, NULL, NULL, NULL); |
---|
740 | //check hdd |
---|
741 | status.addhddall = addtimer(&addhddall, START, 6000, -1, NULL, NULL, NULL); |
---|
742 | //check net |
---|
743 | addtimer(&addinetworkall, START, 15000, -1, NULL, NULL, NULL); |
---|
744 | #ifdef CAMSUPP |
---|
745 | //start ca slot watching threads |
---|
746 | castart(); |
---|
747 | #endif |
---|
748 | //check skin nodes locked |
---|
749 | addtimer(&ckeckskinnodeslockedthread, START, 1000, 1, NULL, NULL, NULL); |
---|
750 | //check if box starts from a record |
---|
751 | addtimer(&checkboxstartthread, START, 1000, 1, NULL, NULL, NULL); |
---|
752 | //check net |
---|
753 | addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL); |
---|
754 | |
---|
755 | //start webserver |
---|
756 | starthttpd(1); |
---|
757 | |
---|
758 | //start rguid |
---|
759 | startrguid(1); |
---|
760 | |
---|
761 | //init the player |
---|
762 | playerinit(argc, argv); |
---|
763 | |
---|
764 | system(getconfig("skriptaftertv", NULL)); |
---|
765 | |
---|
766 | //must called direct befor screeninfobar |
---|
767 | if(getconfigint("saverun", NULL) == 1) |
---|
768 | { |
---|
769 | if(sigsetjmp(status.longjumpbuf, 1) != 0) |
---|
770 | { |
---|
771 | err("set sigsegjump"); |
---|
772 | } |
---|
773 | } |
---|
774 | |
---|
775 | //check free space in /var |
---|
776 | if(getfreespace("/var") / 1024 < 5) //5kb |
---|
777 | { |
---|
778 | 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); |
---|
779 | } |
---|
780 | |
---|
781 | //wait a little for epg to show in infobar |
---|
782 | sleep(1); |
---|
783 | screeninfobar(); |
---|
784 | |
---|
785 | //for testign screens |
---|
786 | //screenmanualscan(); |
---|
787 | //screeninputhelp(); |
---|
788 | //screendownload("test", "www.orf.at", NULL, 80, "test.html", 0); |
---|
789 | //screenrectimer(); |
---|
790 | //screenepgsettings(); |
---|
791 | //screenlnb("1"); |
---|
792 | //screendiseqc("1"); |
---|
793 | //screenlanguage(); |
---|
794 | //screenvideosettings(); |
---|
795 | //screenskinselect(); |
---|
796 | //screenrectimer(); |
---|
797 | //screennetwork_adapter(2); |
---|
798 | //screenpin(); |
---|
799 | //screenchannellist(); |
---|
800 | //recordstart(channel, RECDIRECT); |
---|
801 | //mc_main(); |
---|
802 | //screenmc_videoplayer(); |
---|
803 | //screenserviceinfo(); |
---|
804 | //screentunerconfig(); |
---|
805 | //screenvfdisplay(); |
---|
806 | //screenavsettings(1); |
---|
807 | //screenadjust(); |
---|
808 | //subtitlestart(); |
---|
809 | |
---|
810 | debug(1000, "out"); |
---|
811 | oshutdown(1, 1); |
---|
812 | return 0; |
---|
813 | |
---|
814 | starterror: |
---|
815 | 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); |
---|
816 | struct skin *starterror = getscreen("starterror"); |
---|
817 | if(tmpstr == NULL) |
---|
818 | tmpstr = ostrcat(tmpstr, _("Unknown Error."), 1, 0); |
---|
819 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
820 | tmpstr = ostrcat(tmpstr, _("Automatic stop in 5 seconds."), 1, 0); |
---|
821 | changetext(starterror, _(tmpstr)); |
---|
822 | drawscreen(starterror, 0); |
---|
823 | sleep(5); |
---|
824 | free(tmpstr); |
---|
825 | return 100; |
---|
826 | } |
---|