source: titan/titan/skinfunc.h @ 30698

Last change on this file since 30698 was 30614, checked in by obi, 9 years ago

fix

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