source: titan/plugins/hbbtv/hbbtv.h @ 19468

Last change on this file since 19468 was 19468, checked in by nit, 11 years ago

[titan] optimize

File size: 17.8 KB
Line 
1#ifndef OPERA_H
2#define OPERA_H
3
4struct hbbtvfav
5{
6        char* name;
7        char* addr;
8        struct hbbtvfav* next;
9};
10
11struct hbbtvfav *hbbtvfav = NULL;
12
13#define NAME "YWNATIVE"
14#define CONTROL_PIPE_W "/tmp/"NAME"_control_w"
15#define CONTROL_PIPE_R "/tmp/"NAME"_control_r"
16#define RC_TITAN "/tmp/rc_enigma2"
17
18extern struct skin* skin;
19
20void operareceivercb(char* cmd);
21
22int operarcsockfd = -1;
23int operarcconnfd = -1;
24int opera_control_r_fd = -1;
25int operarcthread_ok = 0;
26int operareceiverthread_ok = 0;
27//100 = live play
28//0 = pause
29//1 = play
30//2 = stop
31int operaservicestate = 100;
32char* operaplayurl = NULL;
33
34struct hbbtvfav* addhbbtvfav(char *line, int count, struct hbbtvfav* last)
35{
36        //debug(1000, "in");
37        struct hbbtvfav *newnode = NULL, *prev = NULL, *node = hbbtvfav;
38        int ret = 0;
39
40        newnode = (struct hbbtvfav*)calloc(1, sizeof(struct hbbtvfav));
41        if(newnode == NULL)
42        {
43                err("no memory");
44                return NULL;
45        }
46
47        newnode->name = malloc(1024);
48        if(newnode->name == NULL)
49        {
50                err("no mem");
51                free(newnode);
52                return NULL;
53        }
54
55        newnode->addr = malloc(1024);
56        if(newnode->addr == NULL)
57        {
58                err("no mem");
59                free(newnode->name);
60                free(newnode);
61                return NULL;
62        }
63
64        ret = sscanf(line, "%[^#]#%s", newnode->name, newnode->addr);
65        if(ret != 2)
66        {
67                if(count > 0)
68                {
69                        err("hbbtvfav line %d not ok", count);
70                }
71                else
72                {
73                        err("add hbbtvfav");
74                }
75                free(newnode->name);
76                free(newnode->addr);
77                free(newnode);
78                return NULL;
79        }
80
81        newnode->name = ostrshrink(newnode->name);
82        newnode->addr = ostrshrink(newnode->addr);
83
84        if(last == NULL)
85        {
86                while(node != NULL)
87                {
88                        prev = node;
89                        node = node->next;
90                }
91        }
92        else
93        {
94                prev = last;
95                node = last->next;
96        }
97
98        if(prev == NULL)
99                hbbtvfav = newnode;
100        else
101                prev->next = newnode;
102        newnode->next = node;
103
104        //debug(1000, "out");
105        return newnode;
106}
107
108int readhbbtvfav(const char* filename)
109{
110        debug(1000, "in");
111        FILE *fd = NULL;
112        char *fileline = NULL;
113        int linecount = 0, len = 0;
114        struct hbbtvfav* last = NULL, *tmplast = NULL;
115
116        fileline = malloc(MINMALLOC);
117        if(fileline == NULL)
118        {
119                err("no memory");
120                return 1;
121        }
122
123        fd = fopen(filename, "r");
124        if(fd == NULL)
125        {
126                perr("can't open %s", filename);
127                free(fileline);
128                return 1;
129        }
130
131        while(fgets(fileline, MINMALLOC, fd) != NULL)
132        {
133                if(fileline[0] == '#' || fileline[0] == '\n')
134                        continue;
135                len = strlen(fileline) - 1;
136                if(len >= 0 && fileline[len] == '\n')
137                        fileline[len] = '\0';
138                len--;
139                if(len >= 0 && fileline[len] == '\r')
140                        fileline[len] = '\0';
141
142                linecount++;
143
144                if(last == NULL) last = tmplast;
145                last = addhbbtvfav(fileline, linecount, last);
146                if(last != NULL) tmplast = last;
147        }
148
149        free(fileline);
150        fclose(fd);
151        return 0;
152}
153
154int delhbbtvfav(char* name)
155{
156        debug(1000, "in");
157        int ret = 1;
158        struct hbbtvfav *node = hbbtvfav, *prev = hbbtvfav;
159
160        while(node != NULL)
161        {
162                if(ostrcmp(node->name, name) == 0)
163                {
164                        if(node == hbbtvfav)
165                                hbbtvfav = node->next;
166                        else
167                                prev->next = node->next;
168
169                        free(node);
170                        node = NULL;
171                        ret = 0;
172                        break;
173                }
174
175                prev = node;
176                node = node->next;
177        }
178        debug(1000, "out");
179        return ret;
180}
181
182void freehbbtvfav()
183{
184        debug(1000, "in");
185        struct hbbtvfav *node = hbbtvfav, *prev = hbbtvfav;
186
187        while(node != NULL)
188        {
189                prev = node;
190                node = node->next;
191                if(prev != NULL)
192                        delhbbtvfav(prev->name);
193        }
194        debug(1000, "out");
195}
196
197void operarcthread()
198{
199        int ret = 0;
200
201        debug(788, "opera create rc socket");
202
203        ret = sockcreate(&operarcsockfd, RC_TITAN, 1);
204        if(ret != 0) return;
205
206        //closeonexec(operarcsockfd);
207
208        debug(788, "opera wait for rc accept");
209        operarcthread_ok = 1;
210        operarcconnfd = sockaccept(&operarcsockfd, 0);
211        debug(788, "opera got rc accept");
212}
213
214void operareceiverthread(struct stimerthread* self)
215{
216        int ret = 0, control_w_fd = -1;
217        fd_set rfds;
218        struct timeval tv;
219        unsigned char* buf = NULL;
220
221        if(self == NULL) return;
222
223        control_w_fd = open(CONTROL_PIPE_W, O_RDONLY);
224        if(control_w_fd < 0)
225        {
226                perr("open or create %s", CONTROL_PIPE_W);
227                return;
228        }
229
230        fcntl(control_w_fd, F_SETFL, fcntl(control_w_fd, F_GETFL) | O_NONBLOCK);
231        //closeonexec(control_w_fd);
232
233        buf = malloc(MINMALLOC);
234        if(buf == NULL)
235        {
236                close(control_w_fd);
237                err("no mem");
238                return;
239        }
240
241        debug(788, "opera receive thread start");
242
243        operareceiverthread_ok = 1;
244        while(self->aktion != STOP)
245        {
246                tv.tv_sec = 1;
247                tv.tv_usec = 0;
248                FD_ZERO(&rfds);
249                FD_SET(control_w_fd, &rfds);
250
251                ret = TEMP_FAILURE_RETRY(select(control_w_fd + 1, &rfds, NULL, NULL, &tv));
252
253                if(ret > 0)
254                {
255                        memset(buf, 0, MINMALLOC);
256                        unsigned char* pbuf = buf;
257                        while(pbuf - buf < MINMALLOC)
258                        {
259                                unsigned char c;
260
261                                ret = read(control_w_fd, &c, 1);
262                                if(ret == 1)
263                                {
264                                        if(c == '\n') break;
265                                        *pbuf = c;
266                                        pbuf++;
267                                }
268                        }
269                        if(pbuf != buf)
270                                operareceivercb((char*)buf);
271                }
272                else if(ret == 0) //timeout
273                        continue;
274                else //error
275                {
276                        perr("select failed");
277                        usleep(10000);
278                }
279         }
280
281         close(control_w_fd); control_w_fd = -1;
282         free(buf); buf = NULL;
283         debug(788, "opera receive thread end");
284}
285
286void operasendkey(char* rckey)
287{
288        if(operarcconnfd > -1 && rckey != NULL)
289                socksend(&operarcconnfd, (unsigned char*)rckey, strlen(rckey), -1);
290        else
291        {
292                err("no opera rc context sockfd=%d", operarcconnfd);
293        }
294}
295
296//flag 0: stop live tv and start play service
297//flag 1: stop play and start live service
298//flag 2: stop play
299int operaservice(char* url, int flag)
300{
301        char* tmpstr = NULL;
302
303        //stop live tv service and start play
304        if(flag == 0)
305        {
306                if(operaservicestate == 100)
307                {
308                        int ret = servicestop(status.aktservice, 1, 1);
309                        if(ret == 1) return 1;
310                }
311
312                free(operaplayurl); operaplayurl = NULL;
313                operaplayurl = ostrcat(url, NULL, 0, 0);
314                playerstop();
315                playerafterend();
316                playerstart(operaplayurl);
317                operaservicestate = 1;
318        }
319
320        //stop play and start live service
321        if(flag == 1 && operaservicestate != 100)
322        {
323                //stop player if running
324                playerstop();
325                playerafterend();
326                free(operaplayurl); operaplayurl = NULL;
327
328                if(status.aktservice->channel != NULL)
329                {
330                        tmpstr = ostrcat(status.aktservice->channellist, NULL, 0, 0);
331                        servicestart(status.aktservice->channel, tmpstr, NULL, 3);
332                }
333                else
334                {
335                        tmpstr = ostrcat(status.lastservice->channellist, NULL, 0, 0);
336                        servicestart(status.lastservice->channel, tmpstr, NULL, 0);
337                }
338                free(tmpstr); tmpstr = NULL;
339                operaservicestate = 100;
340        }
341
342        //stop play
343        if(flag == 2 && operaservicestate != 100)
344        {
345                playerstop();
346                playerafterend();
347                free(operaplayurl); operaplayurl = NULL;
348                operaservicestate = 2;
349        }
350
351        return 0;
352}
353
354void screenopera(char* url)
355{
356        int rcret = 0, i = 0;
357        char* tmpstr = NULL, *savedir = NULL, *dirbuf = NULL;;
358        struct stimerthread* operareceiver = NULL;
359        char* opera_root, *opera_bin = NULL, *opera_dir = NULL;
360        char* opera_home = NULL, *opera_fonts = NULL, *opera_widgets = NULL;
361
362        if(!file_exist(getconfig("hbbtvfavfile", NULL)))   
363        {
364                if(!file_exist("/var/swap/player"))   
365                        mkdir("/var/swap/player", 0777);
366               
367                char* cmd = NULL;
368                cmd = ostrcat("cp /var/etc/titan/hbbtvfav ", getconfig("hbbtvfavfile", NULL), 0, 0);
369                system(cmd);
370                free(cmd), cmd = NULL;
371        }
372
373        if(isdir("/var/usr/local/share/titan/plugins/hbbtv/opera"))
374                opera_root = ostrcat("/var/usr/local/share/titan/plugins/hbbtv/opera", NULL, 0, 0);
375        else
376                opera_root = ostrcat("/var/swap/titanplugins/hbbtv/opera", NULL, 0, 0);
377
378        opera_bin = ostrcat(opera_root, "/bin/opera", 0, 0);
379        opera_dir = ostrcat(opera_root, "/opera_dir", 0, 0);
380        opera_home = ostrcat(opera_root, "/opera_home/", 0, 0);
381        opera_fonts = ostrcat(opera_root, "/fonts", 0, 0);
382        opera_widgets = ostrcat(opera_root, "/widgets", 0, 0);
383
384        drawscreen(skin, 0, 0);
385
386        debug(788, "step 1, set env");
387        //setenv("DFBARGS", "pixelformat=ARGB,no-cursor,bg-none,no-linux-input-grab,no-vt", 1);
388        setenv("OPERA_MULTITAP", "NO", 1);
389        setenv("OPERA_SHOW_STATUSWINDOW", "NO", 1);
390        setenv("OPERA_FB_BORDERWIDTH", "0", 1);
391        setenv("OPERA_SHOW_IMEWINDOW", "NO", 1);
392        setenv("OPERA_SHOW_NAVIGATIONWINDOW", "NO", 1);
393        setenv("OPERA_SHOW_MOUSEPOINTER", "NO", 1);
394        setenv("OPERA_SHOW_HIGHLIGHT", "NO", 1);
395        setenv("OPERA_ESC_EXIT", "YES", 1);
396        setenv("FREETYPE_FONT_SET", "YES", 1);
397        setenv("OPERA_ROOT", opera_root, 1);
398        setenv("OPERA_FB_SIZE", "1280x720", 1);
399        setenv("OPERA_DIR", opera_dir, 1);
400        setenv("OPERA_HOME", opera_home, 1);
401        setenv("OPERA_FONTS", opera_fonts, 1);
402        setenv("OPERA_WIDGETS", opera_widgets, 1);
403        setenv("LD_LIBRARY_PATH", opera_root, 1); // + ":" + os.environ["LD_LIBRARY_PATH"]
404
405        unlink(CONTROL_PIPE_W);
406        unlink(CONTROL_PIPE_R);
407        unlink(RC_TITAN);
408
409        mkfifo(CONTROL_PIPE_W, 0666);
410        mkfifo(CONTROL_PIPE_R, 0666);
411        //mkfifo(RC_TITAN, 0666);
412
413        debug(788, "step 2, start opera");
414        //writesys("/proc/cpu/alignment", "0", 0);
415
416        operarcthread_ok = 0;
417        operareceiverthread_ok = 0;
418        addtimer(&operarcthread, START, 10, 1, NULL, NULL, NULL);
419        operareceiver = addtimer(&operareceiverthread, START, 10, 1, NULL, NULL, NULL);
420
421        //wait for threads
422        int count = 0;
423        while(operarcthread_ok == 0 || operareceiverthread_ok == 0)
424        {
425                usleep(100000);
426                count++;
427                if(count > 20) break;
428        }
429
430        //save working dir
431        dirbuf = malloc(PATH_MAX);
432        if(dirbuf != NULL)
433        {
434                savedir = getcwd(dirbuf, PATH_MAX);
435                chdir(opera_root);
436        }
437
438        fbsave();
439
440        tmpstr = ostrcat(tmpstr, opera_bin, 1, 0);
441        tmpstr = ostrcat(tmpstr, " -u ", 1, 0);
442        tmpstr = ostrcat(tmpstr, url, 1, 0);
443        tmpstr = ostrcat(tmpstr, " --dfb:mode=1280x720,no-debug,no-vt,no-vt-switch &", 1, 0);
444        system(tmpstr);
445        free(tmpstr); tmpstr = NULL;
446
447        //free all opera vars
448        free(opera_root); opera_root = NULL;
449        free(opera_bin); opera_bin = NULL;
450        free(opera_dir); opera_dir = NULL;
451        free(opera_home); opera_home = NULL;
452        free(opera_fonts); opera_fonts = NULL;
453        free(opera_widgets); opera_widgets = NULL;
454
455        //reset working dir
456        if(savedir != NULL)
457                chdir(dirbuf);
458        free(dirbuf); dirbuf = NULL;
459
460        while(1)
461        {
462                rcret = waitrc(NULL, 1000, 0);
463
464                //check for player EOF
465                if(operaservicestate < 2 && !playerisplaying())
466                        operaservice(NULL, 1);
467
468                if(rcret == getrcconfigint("rchbbtv", NULL) || rcret == getrcconfigint("rcrecord", NULL))
469                {
470                        //operasendkey("ESC\n");
471                        break;
472                }
473                else if(rcret == getrcconfigint("rcexit", NULL))
474                        operasendkey("BACK\n");
475                else if(rcret == getrcconfigint("rcred", NULL))
476                        operasendkey("RED\n");
477                else if(rcret == getrcconfigint("rcgreen", NULL))
478                        operasendkey("GREEN\n");
479                else if(rcret == getrcconfigint("rcyellow", NULL))
480                        operasendkey("YELLOW\n");
481                else if(rcret == getrcconfigint("rcblue", NULL))
482                        operasendkey("BLUE\n");
483                else if(rcret == getrcconfigint("rcok", NULL))
484                {
485                        operasendkey("OK\n");
486                        operasendkey("ENTER\n");
487                }
488                else if(rcret == getrcconfigint("rcup", NULL))
489                        operasendkey("UP\n");
490                else if(rcret == getrcconfigint("rcdown", NULL))
491                        operasendkey("DOWN\n");
492                else if(rcret == getrcconfigint("rcleft", NULL))
493                        operasendkey("LEFT\n");
494                else if(rcret == getrcconfigint("rcright", NULL))
495                        operasendkey("RIGHT\n");
496                else if(rcret == getrcconfigint("rc1", NULL))
497                        operasendkey("1\n");
498                else if(rcret == getrcconfigint("rc2", NULL))
499                        operasendkey("2\n");
500                else if(rcret == getrcconfigint("rc3", NULL))
501                        operasendkey("3\n");
502                else if(rcret == getrcconfigint("rc4", NULL))
503                        operasendkey("4\n");
504                else if(rcret == getrcconfigint("rc5", NULL))
505                        operasendkey("5\n");
506                else if(rcret == getrcconfigint("rc6", NULL))
507                        operasendkey("6\n");
508                else if(rcret == getrcconfigint("rc7", NULL))
509                        operasendkey("7\n");
510                else if(rcret == getrcconfigint("rc8", NULL))
511                        operasendkey("8\n");
512                else if(rcret == getrcconfigint("rc9", NULL))
513                        operasendkey("9\n");
514                else if(rcret == getrcconfigint("rc0", NULL))
515                        operasendkey("0\n");
516        }
517
518        if(operareceiver != NULL)
519        {
520                operareceiver->aktion = STOP;
521                while(operareceiver != NULL && operareceiver->status != DEACTIVE)
522                {
523                        usleep(100000);
524                        i++; if(i > 20) break;
525                }
526
527                if(i > 20)
528                {
529                        err("detect hanging timer sub thread (operareceiver)");
530                }
531        }
532
533        sockclose(&operarcsockfd);
534        sockclose(&operarcconnfd);
535        close(opera_control_r_fd);
536
537        debug(788, "killall -9 opera");
538        tmpstr = ostrcat(tmpstr, "killall -9 opera", 1, 0);
539        system(tmpstr);
540        free(tmpstr); tmpstr = NULL;
541
542        free(operaplayurl); operaplayurl = NULL;
543
544        //writesys("/proc/cpu/alignment", "3", 0);
545
546        //setvideomode("720p50", 0);
547        //changefbresolution("720p50");
548        //sleep(3);
549        fbrestore();
550
551        operaservice(NULL, 1); //stop play, start live tv
552
553        //reset tv pic size
554        status.tvpic = 1;
555        resettvpic();
556        clearfball();
557}
558
559void operareceivercb(char* cmd)
560{
561        int count = 0;
562        char* tmpstr = NULL;
563        struct splitstr* ret = NULL;
564
565        debug(788, "cmd=%s", cmd);
566
567        tmpstr = ostrcat(cmd, NULL, 0, 0);
568        ret = strsplit(tmpstr, " ", &count);
569
570        if(ret != NULL && count > 0)
571        {
572                if(ostrcmp("HELLO", (&ret[0])->part) == 0)
573                {
574                        opera_control_r_fd = open(CONTROL_PIPE_R, O_WRONLY);
575                        if(opera_control_r_fd < 0)
576                        {
577                                perr("open or create "CONTROL_PIPE_R);
578                        }
579                }
580                else if(ostrcmp("AvSetWin", (&ret[0])->part) == 0)
581                {
582                        int x = 0, y = 0, w = 0, h = 0;
583                        float xw = 720.0 / 1280.0;
584                        float yh = 576.0 / 720.0;
585                        char* position = NULL;
586
587                        if(count > 1) x = atoi((&ret[1])->part) * xw;
588                        if(count > 2) y = atoi((&ret[2])->part) * yh;
589                        if(count > 3) w = atoi((&ret[3])->part) * xw;
590                        if(count > 4) h = atoi((&ret[4])->part) * yh;
591
592                        if(w == 0 && h == 0)
593                        {
594                                w = 720;
595                                h = 576;
596                        }
597
598                        position = ostrcat(position, oitoax(x), 1, 1);
599                        position = ostrcat(position, " ", 1, 0);
600                        position = ostrcat(position, oitoax(y), 1, 1);
601                        position = ostrcat(position, " ", 1, 0);
602                        position = ostrcat(position, oitoax(w), 1, 1);
603                        position = ostrcat(position, " ", 1, 0);
604                        position = ostrcat(position, oitoax(h), 1, 1);
605
606                        debug(788, "change tv pic to: %s", position);
607                        writesys("/proc/stb/vmpeg/0/dst_all", position, 0);
608                }
609                else if(ostrcmp("AvGetFullScreen", (&ret[0])->part) == 0)
610                {
611                        char* w = NULL, *h = NULL;
612
613                        w = readsys("/proc/stb/vmpeg/0/dst_width", 1);
614                        h = readsys("/proc/stb/vmpeg/0/dst_height", 1);
615
616                        if(ostrcmp(w, "2d0") == 0 && ostrcmp(h, "240") == 0)
617                                write(opera_control_r_fd, "AvGetFullScreen 1\n", 18);
618                        else
619                                write(opera_control_r_fd, "AvGetFullScreen 0\n", 18);
620
621                        free(w); w = NULL;
622                        free(h); h = NULL;
623                }
624                else if(ostrcmp("AvGetVisible", (&ret[0])->part) == 0)
625                {
626                        unsigned long val = readsysul("/proc/stb/video/alpha", 1);
627
628                        if(val == 0)
629                                write(opera_control_r_fd, "AvGetVisible 1\n", 15);
630                        else
631                                write(opera_control_r_fd, "AvGetVisible 0\n", 15);
632                }
633                /*
634                else if(ostrncmp("AvSetVisible", (&ret[0])->part) == 0)
635                {
636                        //if(count > 1 && ostrcmp("1", (&ret[1])->part) == 0)
637                        //{
638                        //      writesys("/proc/stb/video/alpha", "255", 0);
639                        //else
640                        //      writesys("/proc/stb/video/alpha", "0", 0);
641                        //}
642                }
643                */
644                else if(ostrcmp("AvPlay", (&ret[0])->part) == 0)
645                {
646                        if(count > 2)
647                        {
648                                if(ostrcmp("100", (&ret[2])->part) == 0) //play or continue
649                                {
650                                        if(ostrcmp(operaplayurl, (&ret[1])->part) != 0) //different url, so play
651                                        {
652                                                operaservice((&ret[1])->part, 0); //stop live tv and play
653                                        }
654                                        else
655                                        {
656                                                playercontinue();
657                                                operaservicestate = 1;
658                                        }
659                                }
660                                else if(ostrcmp("0", (&ret[2])->part) == 0) //pause
661                                {
662                                        playerpause();
663                                        operaservicestate = 0;
664                                }
665                        }
666                }
667                else if(ostrcmp("AvStop", (&ret[0])->part) == 0)
668                {
669                        operaservice(NULL, 2); //stop play
670                }
671                else if(ostrcmp("AvGetPos", (&ret[0])->part) == 0)
672                {
673                        char* tmppos = NULL;
674                        unsigned long pos = 0;
675
676                        pos = playergetpts() / 90000;
677
678                        tmppos = ostrcat(tmppos, "AvGetPos ", 1, 0);
679                        tmppos = ostrcat(tmppos, olutoa(pos), 1, 1);
680                        tmppos = ostrcat(tmppos, "\n", 1, 0);
681
682                        if(tmppos != NULL)
683                                write(opera_control_r_fd, tmppos, strlen(tmppos));
684
685                        free(tmppos); tmppos = NULL;
686                }
687                else if(ostrcmp("AvGetDuration", (&ret[0])->part) == 0)
688                {
689                        char* tmplen = NULL;
690                        unsigned long len = 0;
691
692                        len = playergetlength();
693
694                        tmplen = ostrcat(tmplen, "AvGetDuration ", 1, 0);
695                        tmplen = ostrcat(tmplen, olutoa(len), 1, 1);
696                        tmplen = ostrcat(tmplen, "\n", 1, 0);
697
698                        if(tmplen != NULL)
699                                write(opera_control_r_fd, tmplen, strlen(tmplen));
700
701                        free(tmplen); tmplen = NULL;
702                }
703                else if(ostrcmp("AvGetState", (&ret[0])->part) == 0)
704                {
705                        char* tmpstate = NULL;
706
707                        tmpstate = ostrcat(tmpstate, "AvGetState ", 1, 0);
708                        if(operaservicestate == 1)
709                                tmpstate = ostrcat(tmpstate, "1", 1, 0);
710                        else
711                                tmpstate = ostrcat(tmpstate, "0", 1, 0);
712                        tmpstate = ostrcat(tmpstate, "\n", 1, 0);
713
714                        if(tmpstate != NULL)
715                                write(opera_control_r_fd, tmpstate, strlen(tmpstate));
716
717                        free(tmpstate); tmpstate = NULL;
718                }
719                else if(ostrcmp("ReleaseHandle", (&ret[0])->part) == 0)
720                {
721                        if(count > 1 && ostrcmp("1", (&ret[1])->part) == 0) //VOD
722                        {
723                                operaservice(NULL, 1); //stop play, start live tv
724                        }
725                }
726        }
727
728        free(tmpstr); tmpstr = NULL;
729        free(ret); ret = NULL;
730}
731
732void screenoperafav()
733{
734        //int ret = 0;
735        struct menulist* mlist = NULL, *mbox = NULL, *tmpmbox = NULL;
736        struct hbbtvfav *node = NULL;
737
738        //ret = servicestop(status.aktservice, 1, 0);
739        //if(ret == 1) return;
740        //setfbtransparent(255);
741
742        if(!file_exist(getconfig("hbbtvfavfile", NULL)))   
743        {
744                if(!file_exist("/var/swap/player"))   
745                        mkdir("/var/swap/player", 0777);
746               
747                char* cmd = NULL;
748                cmd = ostrcat("cp /var/etc/titan/hbbtvfav ", getconfig("hbbtvfavfile", NULL), 0, 0);
749                system(cmd);
750                free(cmd), cmd = NULL;
751        }
752
753        readhbbtvfav(getconfig("hbbtvfavfile", NULL));
754        node = hbbtvfav;
755
756        if(status.aktservice->channel != NULL && status.aktservice->channel->hbbtvurl != NULL)
757        {
758                debug(788, "hbbtvurl=%s", status.aktservice->channel->hbbtvurl);
759                tmpmbox = addmenulist(&mlist, "Channel HBBTV", NULL, NULL, 0, 0);
760                if(tmpmbox != NULL)
761                        tmpmbox->param = ostrcat(status.aktservice->channel->hbbtvurl, NULL, 0, 0);
762        }
763
764        while(node != NULL)
765        {
766                tmpmbox = addmenulist(&mlist, node->name, NULL, NULL, 0, 0);
767                if(tmpmbox != NULL)
768                        tmpmbox->param = ostrcat(node->addr, NULL, 0, 0);
769
770                node = node->next;
771        }
772
773start:
774        drawscreen(skin, 0, 0);
775        mbox = menulistbox(mlist, "menulist", "HBBTV Favoriten", NULL, NULL, 0, 0);
776        if(mbox != NULL)
777        {
778                if(mbox->param != NULL)
779                {
780                        drawscreen(skin, 0, 0);
781                        screenopera(mbox->param);
782                }
783                goto start;
784        }
785
786        freemenulist(mlist, 1);
787        freehbbtvfav();
788        //setosdtransparent(getskinconfigint("osdtransparent", NULL));
789        //if(status.lastservice != NULL)
790        //      servicestart(status.lastservice->channel, NULL, NULL, 0);
791        //flushrc(500);
792}
793
794#endif
Note: See TracBrowser for help on using the repository browser.