source: titan/titan/skinfunc.h @ 32105

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

[webif] led bar gray when mute
[oled] symbols only for nemesis

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