source: titan/titan/channelhistroy.h @ 42987

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

[titan] revert

File size: 3.0 KB
Line 
1#ifndef CHANNELHISTORY_H
2#define CHANNELHISTORY_H
3
4void freechannelhistory()
5{
6        int i = 0;
7
8        for(i = 0; i < MAXCHANNELHISTORY; i++)
9        {
10                channelhistory[i].chnode = NULL;
11                free(channelhistory[i].channellist);
12                channelhistory[i].channellist = NULL;
13        }
14}
15
16void delchannelhistory(struct channel* chnode)
17{
18        int i = 0;
19        if(chnode == NULL) return;
20
21        for(i = 0; i < MAXCHANNELHISTORY; i++)
22        {
23                if(channelhistory[i].chnode == chnode)         
24                {
25                        channelhistory[i].chnode = NULL;
26                        free(channelhistory[i].channellist);
27                        channelhistory[i].channellist = NULL;
28                }
29        }
30}
31
32void addchannelhistory(struct channel* chnode, char* channellist)
33{
34        int i = 0;
35        struct channel* tmpchannel = NULL;
36        char* tmpstr = NULL;
37
38        if(chnode == NULL || channellist == NULL) return;
39
40        for(i = 0; i < MAXCHANNELHISTORY - 1; i++)
41        {
42                if(channelhistory[i].chnode == chnode)         
43                {
44                        tmpchannel = channelhistory[i].chnode;
45                        tmpstr = channelhistory[i].channellist;
46                        channelhistory[i].chnode = channelhistory[i + 1].chnode;
47                        channelhistory[i].channellist = channelhistory[i + 1].channellist;
48                        channelhistory[i + 1].chnode = tmpchannel;
49                        channelhistory[i + 1].channellist = tmpstr;
50                }
51        }
52
53        free(channelhistory[MAXCHANNELHISTORY - 1].channellist);
54        channelhistory[MAXCHANNELHISTORY - 1].channellist = NULL;
55        for(i = MAXCHANNELHISTORY - 1; i > 0 ; i--)
56        {
57                channelhistory[i].chnode = channelhistory[i - 1].chnode;
58                channelhistory[i].channellist = channelhistory[i - 1].channellist;
59        }
60
61        channelhistory[0].chnode = chnode;
62        channelhistory[0].channellist = ostrcat(channellist, NULL, 0, 0);
63}
64
65void screenchannelhistory()
66{
67        int rcret = -1, i = 0;
68        struct skin* chistory = getscreen("channelhistory");
69        struct skin* listbox = getscreennode(chistory, "listbox");
70        struct skin* tmp = NULL;
71        struct epg* epgnode = NULL;
72        char* tmpstr = NULL;
73
74        listbox->aktline = 1;
75        listbox->aktpage = -1;
76
77        for(i = 1; i < MAXCHANNELHISTORY; i++)
78        {
79                if(channelhistory[i].chnode != NULL && channelhistory[i].channellist != NULL)
80                {
81                        tmp = addlistbox(chistory, listbox, tmp, 1);
82                        if(tmp != NULL)
83                        {
84                                changetext(tmp, channelhistory[i].chnode->name);
85
86                                epgnode = getepgakt(channelhistory[i].chnode);
87                                if(epgnode != NULL)
88                                {
89                                        tmpstr = ostrcat(tmpstr, " - ", 1, 0);
90                                        tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
91                                        changetext2(tmp, tmpstr);
92                                        free(tmpstr); tmpstr = NULL;
93                                }
94
95                                tmp->handle = (char*)channelhistory[i].chnode;
96                                tmp->handle1 = channelhistory[i].channellist;
97                        }
98                }
99        }
100
101        addscreenrc(chistory, listbox);
102        drawscreen(chistory, 0, 0);
103
104        while(1)
105        {
106                rcret = waitrc(chistory, 0, 0);
107
108                if(rcret == getrcconfigint("rcexit", NULL)) break;
109                if(rcret == getrcconfigint("rcok", NULL) || rcret == getrcconfigint("rcrecall", NULL))
110                {
111                        if(listbox->select != NULL && listbox->select->handle != NULL && listbox->select->handle1 != NULL)
112                                servicecheckret(servicestart((struct channel*)listbox->select->handle, listbox->select->handle1, NULL, 0), 0);
113
114                        break;
115                }
116        }
117
118        delmarkedscreennodes(chistory, 1);
119        delownerrc(chistory);
120        clearscreen(chistory);
121        drawscreen(skin, 0, 0);
122}
123
124#endif
Note: See TracBrowser for help on using the repository browser.