source: titan/titan/skinfunc.h @ 32089

Last change on this file since 32089 was 32089, checked in by Stephan, 8 years ago

[oled] symbol for streaming

File size: 26.3 KB
Line 
1#ifndef SKINFUNC_H
2#define SKINFUNC_H
3
4char* getplaytext(struct skin* node, char* path)
5{
6        char* tmpstr = NULL;
7
8        if(status.pause > 0 && status.slowspeed == 0)
9                tmpstr = ostrcat("Pause", NULL, 0, 0);
10        else if(status.play > 0)
11                tmpstr = ostrcat("Play", NULL, 0, 0);
12        else if(status.playspeed == 1)
13                tmpstr = ostrcat(">> 2x", NULL, 0, 0);
14        else if(status.playspeed == 2)
15                tmpstr = ostrcat(">> 4x", NULL, 0, 0);
16        else if(status.playspeed == 3)
17                tmpstr = ostrcat(">> 8x", NULL, 0, 0);
18        else if(status.playspeed == 4)
19                tmpstr = ostrcat(">> 16x", NULL, 0, 0);
20        else if(status.playspeed == 5)
21                tmpstr = ostrcat(">> 32x", NULL, 0, 0);
22        else if(status.playspeed == 6)
23                tmpstr = ostrcat(">> 64x", NULL, 0, 0);
24        else if(status.playspeed == 7)
25                tmpstr = ostrcat(">> 128x", NULL, 0, 0);
26        else if(status.playspeed == -1)
27                tmpstr = ostrcat("<< 2x", NULL, 0, 0);
28        else if(status.playspeed == -2)
29                tmpstr = ostrcat("<< 4x", NULL, 0, 0);
30        else if(status.playspeed == -3)
31                tmpstr = ostrcat("<< 8x", NULL, 0, 0);
32        else if(status.playspeed == -4)
33                tmpstr = ostrcat("<< 16x", NULL, 0, 0);
34        else if(status.playspeed == -5)
35                tmpstr = ostrcat("<< 32x", NULL, 0, 0);
36        else if(status.playspeed == -6)
37                tmpstr = ostrcat("<< 64x", NULL, 0, 0);
38        else if(status.playspeed == -7)
39                tmpstr = ostrcat("<< 128x", NULL, 0, 0);
40        else if(status.slowspeed == 1)
41                tmpstr = ostrcat("|| 2x", NULL, 0, 0);
42        else if(status.slowspeed == 2)
43                tmpstr = ostrcat("|| 4x", NULL, 0, 0);
44        else if(status.slowspeed == 3)
45                tmpstr = ostrcat("|| 8x", NULL, 0, 0);
46        else if(status.slowspeed == 4)
47                tmpstr = ostrcat("|| 16x", NULL, 0, 0);
48        else if(status.slowspeed == 5)
49                tmpstr = ostrcat("|| 32x", NULL, 0, 0);
50        else if(status.slowspeed == 6)
51                tmpstr = ostrcat("|| 64x", NULL, 0, 0);
52        else if(status.slowspeed == 7)
53                tmpstr = ostrcat("|| 128x", NULL, 0, 0);
54
55        return tmpstr;
56}
57
58char* getplaypic(struct skin* node, char* path)
59{
60        char* tmpstr = NULL;
61
62        if(status.pause > 0 && status.slowspeed == 0)
63                tmpstr = ostrcat("pause.png", NULL, 0, 0);
64        else if(status.play > 0)
65                tmpstr = ostrcat("play.png", NULL, 0, 0);
66        else if(status.playspeed == 1)
67                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
68        else if(status.playspeed == 2)
69                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
70        else if(status.playspeed == 3)
71                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
72        else if(status.playspeed == 4)
73                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
74        else if(status.playspeed == 5)
75                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
76        else if(status.playspeed == 6)
77                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
78        else if(status.playspeed == 7)
79                tmpstr = ostrcat("forward1.png", NULL, 0, 0);
80        else if(status.playspeed == -1)
81                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
82        else if(status.playspeed == -2)
83                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
84        else if(status.playspeed == -3)
85                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
86        else if(status.playspeed == -4)
87                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
88        else if(status.playspeed == -5)
89                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
90        else if(status.playspeed == -6)
91                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
92        else if(status.playspeed == -7)
93                tmpstr = ostrcat("rewind1.png", NULL, 0, 0);
94        else if(status.slowspeed == 1)
95                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
96        else if(status.slowspeed == 2)
97                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
98        else if(status.slowspeed == 3)
99                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
100        else if(status.slowspeed == 4)
101                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
102        else if(status.slowspeed == 5)
103                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
104        else if(status.slowspeed == 6)
105                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
106        else if(status.slowspeed == 7)
107                tmpstr = ostrcat("slow1.png", NULL, 0, 0);
108
109        if(tmpstr != NULL)
110        {
111                if(path != NULL && tmpstr != NULL)
112                        tmpstr = ostrcat("/", tmpstr, 0, 1);
113                tmpstr = ostrcat(path, tmpstr, 0, 1);
114        }
115       
116        return tmpstr;
117}
118
119char* getreccount(struct skin* node)
120{
121        char* tmpstr = NULL;
122
123        if(status.recording > 0)
124                tmpstr = oitoa(status.recording);
125
126        return tmpstr;
127}
128
129char* getrec(struct skin* node, char* path)
130{
131        char* tmpstr = NULL;
132
133        if(status.recording > 0)
134        {
135                tmpstr = ostrcat("rec.png", NULL, 0, 0);
136
137                if(path != NULL)
138                        tmpstr = ostrcat("/", tmpstr, 0, 1);
139                tmpstr = ostrcat(path, tmpstr, 0, 1);
140        }
141       
142        return tmpstr;
143}
144
145#ifdef MIPSEL
146///rec png
147        char* getoledrec(struct skin* node, char* path)
148        {
149                char* tmpstr = NULL;
150
151                if(status.recording > 0)
152                {
153                        tmpstr = ostrcat("oled_rec.png", NULL, 0, 0);
154
155                        if(path != NULL)
156                                tmpstr = ostrcat("/", tmpstr, 0, 1);
157                        tmpstr = ostrcat(path, tmpstr, 0, 1);
158                }
159       
160                return tmpstr;
161        }
162///mute png
163        char* getoledmute(struct skin* node, char* path)
164                {
165                        char* tmpstr = NULL;
166
167                        if(status.mute > 0)
168                        {
169                                tmpstr = ostrcat("oled_mute.png", NULL, 0, 0);
170
171                                if(path != NULL)
172                                        tmpstr = ostrcat("/", tmpstr, 0, 1);
173                                tmpstr = ostrcat(path, tmpstr, 0, 1);
174                        }
175               
176                        return tmpstr;
177                }
178
179///timeshift png
180        char* getoledtimeshift(struct skin* node, char* path)
181                {
182                        char* tmpstr = NULL;
183
184                        if(status.timeshift > 0)
185                        {
186                                tmpstr = ostrcat("oled_timeshift.png", NULL, 0, 0);
187
188                                if(path != NULL)
189                                        tmpstr = ostrcat("/", tmpstr, 0, 1);
190                                tmpstr = ostrcat(path, tmpstr, 0, 1);
191                        }
192               
193                        return tmpstr;
194                }
195
196///streaming png
197        char* getoledstreaming(struct skin* node, char* path)
198                {
199                        char* tmpstr = NULL;
200
201                        if(status.streaming > 0)
202                        {
203                                tmpstr = ostrcat("oled_streaming.png", NULL, 0, 0);
204
205                                if(path != NULL)
206                                        tmpstr = ostrcat("/", tmpstr, 0, 1);
207                                tmpstr = ostrcat(path, tmpstr, 0, 1);
208                        }
209               
210                        return tmpstr;
211                }
212
213#endif
214
215
216char* getcrypt(struct skin* node, char* path)
217{
218        char* tmpstr = NULL;
219
220        if(status.aktservice->channel != NULL)
221        {
222                if(status.aktservice->channel->crypt > 0)
223                        tmpstr = ostrcat("crypt.png", NULL, 0, 0);
224                else
225                        tmpstr = ostrcat("nocrypt.png", NULL, 0, 0);
226
227                if(path != NULL)
228                        tmpstr = ostrcat("/", tmpstr, 0, 1);
229                tmpstr = ostrcat(path, tmpstr, 0, 1);
230        }
231       
232        return tmpstr;
233}
234
235char* getaspectmode(struct skin* node, char* path)
236{
237        char* tmpstr = NULL;
238
239        tmpstr = getaspect();
240        if(ostrcmp(tmpstr, "4:3") == 0)
241        {
242                free(tmpstr); tmpstr = NULL;
243                tmpstr = ostrcat(tmpstr, "4_3.png", 1, 0);
244        }
245        if(ostrcmp(tmpstr, "16:9") == 0)
246        {
247                free(tmpstr); tmpstr = NULL;
248                tmpstr = ostrcat(tmpstr, "16_9.png", 1, 0);
249        }
250
251        if(path != NULL)
252                tmpstr = ostrcat("/", tmpstr, 0, 1);
253        tmpstr = ostrcat(path, tmpstr, 0, 1);
254
255        return tmpstr;
256}
257
258char* getsdhd(struct skin* node, char* path)
259{
260        char* tmpstr = NULL;
261
262        videoreadqwidth(status.aktservice->videodev);
263
264        if(getaktvideosize() == 0) //videosize is ok
265        {
266                if(status.videosize.w == 720)
267                        tmpstr = ostrcat("sd.png", NULL, 0, 0);
268                else if(status.videosize.w == 1280)
269                        tmpstr = ostrcat("hdready.png", NULL, 0, 0);
270                else if(status.videosize.w == 1920)
271                        tmpstr = ostrcat("hd.png", NULL, 0, 0);
272        }
273       
274        if(tmpstr == NULL) tmpstr = ostrcat("novideo.png", NULL, 0, 0);
275
276        if(path != NULL)
277                tmpstr = ostrcat("/", tmpstr, 0, 1);
278        tmpstr = ostrcat(path, tmpstr, 0, 1);
279
280        return tmpstr;
281}
282       
283char* getresolution(struct skin* node, char* path)
284{
285        char* tmpstr = NULL;
286
287        if(fb->width == 720 && fb->height == 576)
288                tmpstr = ostrcat("576.png", NULL, 0, 0);
289        else if(fb->width == 1280 && fb->height == 720)
290                tmpstr = ostrcat("720.png", NULL, 0, 0);
291        else if(fb->width == 1920 && fb->height == 1080)
292                tmpstr = ostrcat("1080.png", NULL, 0, 0);
293
294        if(path != NULL)
295                tmpstr = ostrcat("/", tmpstr, 0, 1);
296        tmpstr = ostrcat(path, tmpstr, 0, 1);
297       
298        return tmpstr;
299}
300
301char* getteletext(struct skin* node, char* path)
302{
303        char* tmpstr = NULL;
304
305        if(status.aktservice->channel != NULL)
306        {
307                if(status.aktservice->channel->txtpid > 0)
308                        tmpstr = ostrcat("teletext.png", NULL, 0, 0);
309                else
310                        tmpstr = ostrcat("noteletext.png", NULL, 0, 0);
311
312                if(path != NULL)
313                        tmpstr = ostrcat("/", tmpstr, 0, 1);
314                tmpstr = ostrcat(path, tmpstr, 0, 1);
315        }
316       
317        return tmpstr;
318}
319
320char* getsoundtype(struct skin* node, char* path)
321{
322        char* tmpstr = NULL;
323
324        if(status.aktservice->channel != NULL)
325        {
326                switch(status.aktservice->channel->audiocodec)
327                {
328                        case AC3:
329                                tmpstr = ostrcat("ac3.png", NULL, 0, 0);
330                                break;
331                        case MPEGA:
332                                tmpstr = ostrcat("mpega.png", NULL, 0, 0);
333                                break;
334                        case DTS:
335                                tmpstr = ostrcat("dts.png", NULL, 0, 0);
336                                break;
337                        case LPCM:
338                                tmpstr = ostrcat("lpcm.png", NULL, 0, 0);
339                                break;
340                        case AAC:
341                                tmpstr = ostrcat("aac.png", NULL, 0, 0);
342                                break;
343                        case AACHE:
344                                tmpstr = ostrcat("aache.png", NULL, 0, 0);
345                                break;
346                }
347                if(path != NULL)
348                        tmpstr = ostrcat("/", tmpstr, 0, 1);
349                tmpstr = ostrcat(path, tmpstr, 0, 1);
350        }
351       
352        return tmpstr;
353}
354
355char* getprovidername(struct skin* node)
356{
357        char* tmpstr = NULL;
358
359        if(status.aktservice->channel != NULL && status.aktservice->channel->provider != NULL)
360                tmpstr = ostrcat(status.aktservice->channel->provider->name, NULL, 0, 0);
361
362        return tmpstr;
363}
364
365char* getsatname(struct skin* node)
366{
367        struct sat* satnode = NULL;
368        char* tmpstr = NULL;
369
370        if(status.aktservice->channel != NULL && status.aktservice->channel->transponder != NULL)
371        {
372                satnode = getsatbyorbitalpos(status.aktservice->channel->transponder->orbitalpos);
373                if(satnode != NULL)
374                        tmpstr = ostrcat(satnode->name, NULL, 0, 0);
375        }
376
377        return tmpstr;
378}
379
380char* getber(struct skin* node, char* format)
381{
382        uint32_t ber = 0;
383        char* buf = NULL, *buf1 = NULL;
384
385        ber = fereadber(status.aktservice->fedev);
386
387        buf = malloc(MINMALLOC);
388        if(buf == NULL)
389        {
390                err("no mem");
391                return NULL;
392        }
393       
394        snprintf(buf, MINMALLOC, format, ber);
395        buf1 = ostrcat(buf, NULL, 1, 0);
396
397        return buf1;
398}
399
400char* getsignal(struct skin* node, char* format)
401{
402        uint16_t signal = 0;
403        char* buf = NULL, *buf1 = NULL;
404
405        signal = fereadsignalstrength(status.aktservice->fedev);
406        signal = (signal * 100) / 0xffff;
407
408        buf = malloc(MINMALLOC);
409        if(buf == NULL)
410        {
411                err("no mem");
412                return NULL;
413        }
414       
415        snprintf(buf, MINMALLOC, format, signal);
416        buf1 = ostrcat(buf, NULL, 1, 0);
417
418        return buf1;
419}
420
421char* getunc(struct skin* node, char* format)
422{
423        uint32_t unc = 0;
424        char* buf = NULL, *buf1 = NULL;
425
426        unc = fereaduncorrectedblocks(status.aktservice->fedev);
427
428        buf = malloc(MINMALLOC);
429        if(buf == NULL)
430        {
431                err("no mem");
432                return NULL;
433        }
434       
435        snprintf(buf, MINMALLOC, format, unc);
436        buf1 = ostrcat(buf, NULL, 1, 0);
437
438        return buf1;
439}
440
441char* getsnr(struct skin* node, char* format)
442{
443        uint16_t snr = 0;
444        char* buf = NULL, *buf1 = NULL;
445
446       
447        snr = fereadsnr(status.aktservice->fedev);
448        snr = (snr * 100) / 0xffff;
449       
450        buf = malloc(MINMALLOC);
451        if(buf == NULL)
452        {
453                err("no mem");
454                return NULL;
455        }
456       
457        snprintf(buf, MINMALLOC, format, snr);
458        buf1 = ostrcat(buf, NULL, 1, 0);
459
460        return buf1;
461}
462
463char* getepgtimeline(struct skin* node, int akt)
464{       
465        struct epg* epgnode = NULL;
466        struct channel* chnode = NULL;
467        char* tmpstr = NULL, *tmpnr = NULL;
468        int proz = 0;
469
470        if(akt == 0) chnode = status.markedchannel;
471        if(akt == 1) chnode = status.aktservice->channel;
472        if(akt == 2 && node != NULL) chnode = (struct channel*)node->handle;
473
474        if(chnode != NULL)
475        {
476                epgnode = getepgakt(chnode);
477                if(epgnode != NULL)
478                {
479                        proz = (time(NULL) - epgnode->starttime) * 100 / (epgnode->endtime - epgnode->starttime);
480                        tmpnr = oitoa(proz);
481                        tmpstr = ostrcat(tmpstr, tmpnr, 1, 1);
482                        return tmpstr;
483                }
484        }
485        return NULL;
486}
487
488char* getepgmarkedtimeline(struct skin* node)
489{
490        return getepgtimeline(node, 0);
491}
492
493char* getepgakttimeline(struct skin* node)
494{
495        return getepgtimeline(node, 1);
496}
497
498char* getepgchanneltimeline(struct skin* node)
499{
500        return getepgtimeline(node, 2);
501}
502
503char* getaktchannelname(struct skin* node)
504{
505        char* tmpstr = NULL;
506
507        if(status.aktservice->channel != NULL)
508        {
509                tmpstr = ostrcat(tmpstr, status.aktservice->channel->name, 1, 0);
510                return tmpstr;
511        }
512        return NULL;
513}
514
515char* getepgtime(struct skin* node, char* format, int akt, int type)
516{
517        // akt 0 = marked channel
518        // akt 1 = akt channel now
519        // akt 2 = akt channel next
520
521        // type 0 = starttime
522        // type 1 = endtime
523        // type 2 = remainingtime
524
525        struct epg* epgnode = NULL;
526        struct tm *loctime = NULL;
527        struct channel* chnode = NULL;
528        char *buf = NULL, *buf1 = NULL;
529        time_t min = 0;
530       
531        if(format == NULL)
532        {
533                err("NULL detect");
534                return NULL;
535        }
536
537        if(akt == 0) chnode = status.markedchannel;
538        if(akt == 1 || akt == 2) chnode = status.aktservice->channel;
539
540        if(chnode != NULL)
541        {
542                epgnode = getepgakt(chnode);
543
544                if(akt == 2)
545                {
546                        if(epgnode != NULL)
547                                epgnode = epgnode->next;
548                }
549
550                if(epgnode != NULL)
551                {
552                        if(type == 0)
553                                loctime = olocaltime(&epgnode->starttime);
554                        else if(type == 1)
555                                loctime = olocaltime(&epgnode->endtime);
556                        else if(type == 2)
557                        {
558                                if(akt == 1)
559                                        min = ((epgnode->endtime - (epgnode->endtime % 60)) - (time(NULL) - (time(NULL) % 60))) / 60;
560                                else if(akt == 2)
561                                        min = ((epgnode->endtime - (epgnode->endtime % 60)) - (epgnode->starttime - (epgnode->starttime % 60))) / 60;
562                                if(min < 0) min = 0;
563                        }
564
565                        buf = malloc(MINMALLOC);
566                        if(buf == NULL)
567                        {
568                                free(loctime);
569                                err("no memory");
570                                return NULL;
571                        }
572
573                        if(type == 2)
574                                snprintf(buf, MINMALLOC, format, min);
575                        else if(loctime != NULL)
576                                ostrftime(buf, MINMALLOC, format, loctime);
577                        buf1 = ostrcat(buf, NULL, 1, 0);
578
579                        buf1 = translate_time(buf1, 0);
580
581                        free(loctime); loctime = NULL;
582                        return buf1;
583                }
584        }
585        return NULL;
586}
587
588char* getepgakttimeremaining(struct skin* node, char* format)
589{
590        return getepgtime(node, format, 1, 2);
591}
592
593char* getepgnexttimeremaining(struct skin* node, char* format)
594{
595        return getepgtime(node, format, 2, 2);
596}
597
598char* getepgmarkedstart(struct skin* node, char* format)
599{
600        return getepgtime(node, format, 0, 0);
601}
602
603char* getepgmarkedend(struct skin* node, char* format)
604{
605        return getepgtime(node, format, 0, 1);
606}
607
608char* getepgaktstart(struct skin* node, char* format)
609{
610        return getepgtime(node, format, 1, 0);
611}
612
613char* getepgaktend(struct skin* node, char* format)
614{
615        return getepgtime(node, format, 1, 1);
616}
617
618char* getepgnextstart(struct skin* node, char* format)
619{
620        return getepgtime(node, format, 2, 0);
621}
622
623char* getepgnextend(struct skin* node, char* format)
624{
625        return getepgtime(node, format, 2, 1);
626}
627
628char* getepgaktsubtitle(struct skin* node)
629{
630        struct epg* epgnode = NULL;
631        char* tmpstr = NULL;
632
633        epgnode = getepgakt(status.aktservice->channel);
634        if(epgnode != NULL)
635        {
636                tmpstr = ostrcat(tmpstr, epgnode->subtitle, 1, 0);
637                return tmpstr;
638        }
639
640        return NULL;
641}
642
643char* getepgakttitle(struct skin* node)
644{
645        struct epg* epgnode = NULL;
646        char* tmpstr = NULL;
647
648        epgnode = getepgakt(status.aktservice->channel);
649        if(epgnode != NULL)
650        {
651                tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
652                return tmpstr;
653        }
654
655        return NULL;
656}
657
658char* getepgnexttitle(struct skin* node)
659{
660        struct epg* epgnode = NULL;
661        char* tmpstr = NULL;
662
663        epgnode = getepgakt(status.aktservice->channel);
664        if(epgnode != NULL)
665        {
666                epgnode = epgnode->next;
667                if(epgnode != NULL)
668                {
669                        tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
670                        return tmpstr;
671                }
672        }
673
674        return NULL;
675}
676
677char* getepgaktdesc(struct skin* node)
678{
679        struct epg* epgnode = NULL;
680
681        if(status.aktservice->channel != NULL)
682        {
683                epgnode = getepgakt(status.aktservice->channel);
684                if(epgnode != NULL)
685                        return epgdescunzip(epgnode);
686        }
687
688        return NULL;
689}
690
691char* getepgnextdesc(struct skin* node)
692{
693        struct epg* epgnode = NULL;
694
695        if(status.aktservice->channel != NULL)
696        {
697                epgnode = getepgakt(status.aktservice->channel);
698                if(epgnode != NULL)
699                {
700                        epgnode = epgnode->next;
701                        if(epgnode != NULL)
702                                return epgdescunzip(epgnode);
703                }
704        }
705
706        return NULL;
707}
708
709char* getepgmarkeddesc(struct skin* node)
710{
711        struct epg* epgnode = NULL;
712
713        if(status.markedchannel != NULL)
714        {
715                epgnode = getepgakt(status.markedchannel);
716                if(epgnode != NULL)
717                        return epgdescunzip(epgnode);
718        }
719
720        return NULL;
721}
722
723char* getepgmarkedlist(struct skin* node, char* ccount)
724{
725        struct epg* epgnode = NULL;
726        char* tmpstr = NULL, *buf = NULL;
727        int count = atoi(ccount);
728        struct tm* loctime = NULL;
729
730        buf = malloc(MINMALLOC);
731        if(buf == NULL)
732        {
733                err("no memory");
734                return NULL;
735        }
736
737        if(status.markedchannel != NULL)
738        {
739                epgnode = getepgakt(status.markedchannel);
740                while(epgnode != NULL)
741                {
742                        epgnode = epgnode->next;
743                        if(epgnode != NULL)
744                        {
745                                loctime = olocaltime(&epgnode->starttime);
746                                if(loctime != NULL)
747                                        strftime(buf, MINMALLOC, "%H:%M", loctime);
748                                free(loctime); loctime = NULL;
749                                tmpstr = ostrcat(tmpstr, buf, 1, 0);
750                                tmpstr = ostrcat(tmpstr, " ", 1, 0);
751                                tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
752                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
753                                count--;
754                        }
755                        if(count < 1) break;
756                }
757        }
758
759        free(buf);
760        return tmpstr;
761}
762
763char* getepgpicon(struct skin* node)
764{
765        char* tmpstr = NULL;
766       
767        if(status.epgchannel != NULL)
768                tmpstr = createpiconpath(status.epgchannel, 0);
769        return tmpstr;
770}
771
772char* getpicon(struct skin* node)
773{
774        char* tmpstr = NULL;
775        tmpstr = createpiconpath(status.aktservice->channel, 0);
776        return tmpstr;
777}
778
779char* getalternatepicon(struct skin* node)
780{
781        char* tmpstr = NULL;
782        tmpstr = createpiconpath(status.aktservice->channel, 1);
783        return tmpstr;
784}
785
786char* gettime(struct skin* node, char* format)
787{
788        time_t sec;
789        struct tm *loctime = NULL;
790        char *buf = NULL, *buf1 = NULL;
791
792        if(format == NULL)
793        {
794                err("NULL detect");
795                return NULL;
796        }
797
798        buf = malloc(MINMALLOC);
799        if(buf == NULL)
800        {
801                err("no memory");
802                return NULL;
803        }
804
805        sec = time(NULL);
806        loctime = olocaltime(&sec);
807
808        if(loctime != NULL)
809        {
810                ostrftime(buf, MINMALLOC, format, loctime);
811                buf1 = ostrcat(buf, NULL, 1, 0);
812        }
813
814        buf1 = translate_time(buf1, 1);
815
816        free(loctime);
817        return buf1;
818}
819
820char* getchannelnr(struct skin* node, struct channel* chnode)
821{
822        char *tmpstr = NULL, *tmpnr = NULL;
823
824        if(chnode == NULL) chnode = status.aktservice->channel;
825
826        if(status.servicetype == 0)
827                tmpstr = getconfig("channellist", NULL);
828        else
829                tmpstr = getconfig("rchannellist", NULL);
830        if(ostrncmp("(BOUQUET)-", tmpstr, 10) == 0 && strlen(tmpstr) > 10)
831        {
832                struct mainbouquet* mainbouquetnode = NULL;
833                int count = 0;
834
835                mainbouquetnode = getmainbouquet(tmpstr + 10);
836                if(mainbouquetnode != NULL && mainbouquetnode->bouquet != NULL)
837                {
838                        struct bouquet* bnode = mainbouquetnode->bouquet;
839
840                        while(bnode != NULL)
841                        {
842                                if(bnode->channel == chnode)
843                                {
844                                        tmpnr = oitoa(mainbouquetnode->bouquet->nr + count);
845                                        return tmpnr;
846                                }
847                                count++;
848                                bnode = bnode->next;
849                        }
850                }
851                return tmpnr;
852        }
853        else
854                return tmpnr;
855}
856
857char* getakttuner(struct skin* node)
858{
859        char* tmpstr = NULL;
860
861        if(status.aktservice->fedev != NULL)
862        {
863                tmpstr = oitoa(status.aktservice->fedev->devnr);
864                return tmpstr;
865        }
866
867        return NULL;
868}
869
870char* getchannellistname(struct skin* node)
871{
872        char* tmpstr = NULL, *tmpstr1 = NULL;
873
874        if(status.servicetype == 0)
875                tmpstr = getconfig("channellist", NULL);
876        else
877                tmpstr = getconfig("rchannellist", NULL);
878
879        if(tmpstr != NULL)
880        {
881                if(ostrncmp("(BOUQUET)-", tmpstr, 10) == 0 && strlen(tmpstr) > 10)
882                        tmpstr1 = ostrcat(tmpstr1, tmpstr + 10, 1, 0);
883
884                else if(ostrncmp("(A-Z)-", tmpstr, 6) == 0 && strlen(tmpstr) > 6)
885                        tmpstr1 = ostrcat(tmpstr1, tmpstr + 6, 1, 0);
886
887                else if(ostrncmp("(SAT)-", tmpstr, 6) == 0 && strlen(tmpstr) > 6)
888                        tmpstr1 = ostrcat(tmpstr1, tmpstr + 6, 1, 0);
889
890                else if(ostrncmp("(PROVIDER)-", tmpstr, 11) == 0 && strlen(tmpstr) > 6)
891                        tmpstr1 = ostrcat(tmpstr1, tmpstr + 11, 1, 0);
892        }
893
894        return tmpstr1;
895}
896
897char* getpowerofftime(struct skin* node, char* format)
898{
899        char* buf = NULL, *buf1 = NULL;
900        int resttime = 0;
901
902        if(format == NULL) return NULL;
903
904        if(status.sd_timer != NULL && status.sd_timer->active)
905        {
906                buf = malloc(MINMALLOC);
907                if(buf == NULL)
908                {
909                        err("no mem");
910                        return NULL;
911                }
912
913                resttime = (status.sd_timer->shutdown_time - time(NULL)) / 60;
914                if(resttime < 0) resttime = 0;
915                snprintf(buf, MINMALLOC, format, resttime);
916                buf1 = ostrcat(buf, NULL, 1, 0);
917        }
918
919        return buf1;
920}
921
922char* gettvpic(struct skin* node, char* pos)
923{
924        struct splitstr* ret = NULL;
925        char* tmpstr = NULL;
926        int count = 0, left = 0, top = 0, width = 0;
927
928        if(pos != NULL)
929        {
930                tmpstr = ostrcat(pos, NULL, 0, 0);
931                ret = strsplit(tmpstr, ":", &count);
932                if(count == 3)
933                {
934                        if((&ret[0])->part != NULL)
935                                left = atoi((&ret[0])->part);
936                        if((&ret[1])->part != NULL)
937                                top = atoi((&ret[1])->part);
938                        if((&ret[2])->part != NULL)
939                                width = atoi((&ret[2])->part);
940                       
941                        setvmpegrect(status.aktservice->videodev, left, top, width, 0);
942                }
943                free(tmpstr); tmpstr = NULL;
944        }
945
946        free(ret); ret = NULL;
947        return NULL;
948}
949
950char* getrecfreesize(struct skin* node)
951{
952        int ret = 0;
953
954        if(status.showrecfreesize > 0)
955        {
956                unsigned long long full = getfullspace(getconfig("rec_path", NULL)) / (1024 * 1024);
957                unsigned long long free = getfreespace(getconfig("rec_path", NULL)) / (1024 * 1024);
958
959                if(full > 0 && full >= free) ret = ((full - free) * 100) / full;
960
961                if(ret < 0) ret = 0;
962                if(ret > 100) ret = 100;
963        }
964
965        return oitoa(ret);
966}
967
968char* getrecfreesizetext(struct skin* node)
969{
970        int ret = 0;
971        char* tmpstr = NULL;
972
973        if(status.showrecfreesize > 0)
974        {
975                unsigned long long full = getfullspace(getconfig("rec_path", NULL)) / (1024 * 1024);
976                unsigned long long free = getfreespace(getconfig("rec_path", NULL)) / (1024 * 1024);
977
978                if(full > 0 && full >= free) ret = ((full - free) * 100) / full;
979
980                if(ret < 0) ret = 0;
981                if(ret > 100) ret = 100;
982               
983                if(status.showrecfreesize == 1)
984                        tmpstr = ostrcat(oitoa(ret), " %", 1, 0);
985                else
986                        tmpstr = ostrcat(ollutoa(free), " MB", 1, 0);
987        }
988
989        return tmpstr;
990}
991
992char* gethbbtv(struct skin* node, char* path)
993{
994        char* tmpstr = NULL;
995
996        if(status.aktservice->channel != NULL)
997        {
998    if(status.aktservice->channel->hbbtvurl != NULL)
999      tmpstr = ostrcat("hbbtv_on.png", "", 0, 0);
1000    else
1001      tmpstr = ostrcat("hbbtv_off.png", "", 0, 0);
1002
1003                if(path != NULL)
1004                        tmpstr = ostrcat("/", tmpstr, 0, 1);
1005                tmpstr = ostrcat(path, tmpstr, 0, 1);
1006        }
1007       
1008        return tmpstr;
1009}
1010
1011char* getimgname(struct skin* node)
1012{
1013        return getimgnamereal();
1014}
1015
1016char* getoscamcaid(struct skin* node)
1017{
1018        char* buf = NULL, *tmpstr = NULL;
1019
1020        buf = readfiletomem("/tmp/ecm.info", 1);
1021        tmpstr = ostrstr(buf, "caid:");
1022        if(tmpstr != NULL)
1023        {
1024                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1025                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1026        }
1027        free(buf); buf = NULL;
1028
1029        return tmpstr;
1030}
1031
1032char* getoscampid(struct skin* node)
1033{
1034        char* buf = NULL, *tmpstr = NULL;
1035
1036        buf = readfiletomem("/tmp/ecm.info", 1);
1037        tmpstr = ostrstr(buf, "pid:");
1038        if(tmpstr != NULL)
1039        {
1040                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1041                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1042        }
1043        free(buf); buf = NULL;
1044
1045        return tmpstr;
1046}
1047
1048char* getoscamprov(struct skin* node)
1049{
1050        char* buf = NULL, *tmpstr = NULL;
1051
1052        buf = readfiletomem("/tmp/ecm.info", 1);
1053        tmpstr = ostrstr(buf, "prov:");
1054        if(tmpstr != NULL)
1055        {
1056                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1057                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1058        }
1059        free(buf); buf = NULL;
1060
1061        return tmpstr;
1062}
1063
1064char* getoscamreader(struct skin* node)
1065{
1066        char* buf = NULL, *tmpstr = NULL;
1067
1068        buf = readfiletomem("/tmp/ecm.info", 1);
1069        tmpstr = ostrstr(buf, "reader:");
1070        if(tmpstr != NULL)
1071        {
1072                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1073                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1074        }
1075        free(buf); buf = NULL;
1076
1077        return tmpstr;
1078}
1079
1080char* getoscamfrom(struct skin* node)
1081{
1082        char* buf = NULL, *tmpstr = NULL;
1083
1084        buf = readfiletomem("/tmp/ecm.info", 1);
1085        tmpstr = ostrstr(buf, "from:");
1086        if(tmpstr != NULL)
1087        {
1088                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1089                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1090        }
1091        free(buf); buf = NULL;
1092
1093        return tmpstr;
1094}
1095
1096char* getoscamprotocol(struct skin* node)
1097{
1098        char* buf = NULL, *tmpstr = NULL;
1099
1100        buf = readfiletomem("/tmp/ecm.info", 1);
1101        tmpstr = ostrstr(buf, "protocol:");
1102        if(tmpstr != NULL)
1103        {
1104                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1105                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1106        }
1107        free(buf); buf = NULL;
1108
1109        return tmpstr;
1110}
1111
1112char* getoscamhops(struct skin* node)
1113{
1114        char* buf = NULL, *tmpstr = NULL;
1115
1116        buf = readfiletomem("/tmp/ecm.info", 1);
1117        tmpstr = ostrstr(buf, "hops:");
1118        if(tmpstr != NULL)
1119        {
1120                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1121                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1122        }
1123        free(buf); buf = NULL;
1124
1125        return tmpstr;
1126}
1127
1128char* getoscamecmtime(struct skin* node)
1129{
1130        char* buf = NULL, *tmpstr = NULL;
1131
1132        buf = readfiletomem("/tmp/ecm.info", 1);
1133        tmpstr = ostrstr(buf, "ecm time:");
1134        if(tmpstr != NULL)
1135        {
1136                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1137                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1138        }
1139        free(buf); buf = NULL;
1140
1141        return tmpstr;
1142}
1143
1144char* getoscamcw0(struct skin* node)
1145{
1146        char* buf = NULL, *tmpstr = NULL;
1147
1148        buf = readfiletomem("/tmp/ecm.info", 1);
1149        tmpstr = ostrstr(buf, "cw0:");
1150        if(tmpstr != NULL)
1151        {
1152                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1153                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1154        }
1155        free(buf); buf = NULL;
1156
1157        return tmpstr;
1158}
1159
1160char* getoscamcw1(struct skin* node)
1161{
1162        char* buf = NULL, *tmpstr = NULL;
1163
1164        buf = readfiletomem("/tmp/ecm.info", 1);
1165        tmpstr = ostrstr(buf, "cw1:");
1166        if(tmpstr != NULL)
1167        {
1168                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1169                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1170        }
1171        free(buf); buf = NULL;
1172
1173        return tmpstr;
1174}
1175
1176char* getoscamsystem(struct skin* node)
1177{
1178        char* buf = NULL, *tmpstr = NULL;
1179
1180        buf = readfiletomem("/tmp/ecm.info", 1);
1181        tmpstr = ostrstr(buf, "system:");
1182        if(tmpstr != NULL)
1183        {
1184                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1185                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1186        }
1187        free(buf); buf = NULL;
1188
1189        return tmpstr;
1190}
1191
1192char* getoscamsource(struct skin* node)
1193{
1194        char* buf = NULL, *tmpstr = NULL;
1195
1196        buf = readfiletomem("/tmp/ecm.info", 1);
1197        tmpstr = ostrstr(buf, "source:");
1198        if(tmpstr != NULL)
1199        {
1200                tmpstr = stringreplacecharonce(tmpstr, '\n', '\0');
1201                tmpstr = ostrcat(tmpstr, NULL, 0, 0);
1202        }
1203        free(buf); buf = NULL;
1204
1205        return tmpstr;
1206}
1207
1208char* getemu(struct skin* node)
1209{
1210        char* tmpstr = NULL;
1211        char* tmpstr1 = NULL;
1212        tmpstr = string_newline(command("emu.sh infoname"));
1213
1214        if(ostrstr(tmpstr, "not found") != NULL)
1215        {
1216                free(tmpstr);
1217                tmpstr = NULL;
1218        }
1219        else
1220        {
1221                        tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
1222                        free(tmpstr),tmpstr = NULL;                     
1223                        tmpstr = ostrcat("emu: ", tmpstr1, 0, 0);                       
1224                        free(tmpstr1),tmpstr1 = NULL;
1225        }
1226        return tmpstr;
1227}
1228
1229char* getbufferstatus(struct skin* node)
1230{
1231        int ret = 0;
1232
1233#ifdef EPLAYER4
1234/*
1235        GstMessage *msg = NULL;
1236        gint percent = 0;
1237        gst_message_parse_buffering (msg, &percent);
1238        g_print ("Buffering (%3d%%)\r", percent);
1239        ret = (int)percent;
1240*/
1241        ret = status.bufferpercent;
1242#else
1243        int size = 0, status = 0;
1244        size = playergetbuffersize();
1245        if(size > 0)
1246                status = playergetbufferstatus();
1247
1248        if(size > 0 && size >= status) ret = 100 - (((size - status) * 100) / size);
1249#endif         
1250               
1251        if(ret < 0) ret = 0;
1252        if(ret > 100) ret = 100;
1253
1254        return oitoa(ret);
1255}
1256
1257char* getwlanlinkquality(struct skin* node)
1258{
1259        int quality = 0;
1260
1261        quality = wlanlinkquality();
1262
1263        if(quality < 0) quality = 0;
1264        if(quality > 100) quality = 100;
1265
1266        return oitoa(quality);
1267}
1268
1269char* getwlanlinkqualitytext(struct skin* node)
1270{
1271        int quality = 0;
1272        char* tmpstr = NULL;
1273
1274        quality = wlanlinkquality();
1275
1276        if(quality < 0) quality = 0;
1277        if(quality > 100) quality = 100;
1278
1279        tmpstr = ostrcat(oitoa(quality), " %", 1, 0);
1280
1281        return tmpstr;
1282}
1283
1284#endif
Note: See TracBrowser for help on using the repository browser.