source: titan/plugins/optimize/optimize.h @ 26912

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

[titan] change transponderid unsigned long to uint64_t

File size: 7.1 KB
Line 
1#ifndef OPTIMIZE_H
2#define OPTIMIZE_H
3
4extern struct transponder* transponder;
5extern struct channel* channel;
6extern struct mainbouquet* mainbouquet;
7extern struct epgscanlist* epgscanlist;
8extern struct sat* sat;
9extern struct provider* provider;
10
11void delmarkedsat(struct skin* listbox)
12{
13        struct skin* node = listbox;
14
15        while(node != NULL)
16        {
17                if(node->del == 1 && ostrcmp(node->ret, "1") == 0)
18                {
19                        delsat(node->handle);
20                        node->handle = NULL;
21                }
22                node = node->next;
23        }
24}
25
26void delunusedtransponder()
27{
28        struct transponder* node = transponder;
29        struct transponder* prev = NULL;
30
31        while(node != NULL)
32        {
33                prev = node;
34                node = node->next;
35
36                if(getsatbyorbitalpos(prev->orbitalpos) == NULL)
37                        deltransponder(prev);
38        }
39}
40
41void delunusedchannel()
42{
43        struct channel* node = channel;
44        struct channel* prev = NULL;
45
46        while(node != NULL)
47        {
48                prev = node;
49                node = node->next;
50
51                if(prev->transponder == NULL)
52                        delchannel(prev->serviceid, prev->transponderid, 0);
53        }
54}
55
56void delunusedbouquet()
57{
58        struct mainbouquet* mnode = mainbouquet;
59        struct bouquet* first = NULL;
60        struct bouquet* node = NULL;
61        struct bouquet* prev = NULL;
62
63        while(mnode != NULL)
64        {
65                first = mnode->bouquet;
66                node = mnode->bouquet;
67                while(node != NULL)
68                {
69                        prev = node;   
70                        node = node->next;
71                        if(getchannel(prev->serviceid, prev->transponderid) == NULL)
72                                delbouquet(prev->serviceid, prev->transponderid, &first);
73                }
74                mnode = mnode->next;
75        }
76}
77
78void delunusedepgchannel()
79{
80        struct epgscanlist* node = epgscanlist;
81        struct epgscanlist* prev = NULL;
82
83        while(node != NULL)
84        {
85                prev = node;   
86                node = node->next;
87                if(getchannel(prev->serviceid, prev->transponderid) == NULL)
88                        delepgscanlist(node->serviceid, node->transponderid);
89        }
90}
91
92void delunusedprovider()
93{
94        struct provider* node = provider;
95        struct provider* prev = NULL;
96
97        while(node != NULL)
98        {
99                prev = node;   
100                node = node->next;
101                delprovidernotused(prev);
102        }
103}
104
105int getsatcount()
106{
107        int count = 0;
108        struct sat* node = sat;
109
110        while(node != NULL)
111        {
112                count++;
113                node = node->next;
114        }
115
116        return count;
117}
118
119int gettranspondercount(int orbitalpos)
120{
121        int count = 0;
122        struct transponder* node = transponder;
123
124        while(node != NULL)
125        {
126                if(orbitalpos == 0 || node->orbitalpos == orbitalpos)
127                        count++;
128                node = node->next;
129        }
130
131        return count;
132}
133
134int getchannelcount(uint64_t transponderid)
135{
136        int count = 0;
137        struct channel* node = channel;
138
139        while(node != NULL)
140        {
141                if(transponderid == 0 || node->transponderid == transponderid)
142                        count++;
143                node = node->next;
144        }
145
146        return count;
147}
148
149int getmainbouquetcount()
150{
151        int count = 0;
152        struct mainbouquet* node = mainbouquet;
153
154        while(node != NULL)
155        {
156                count++;
157                node = node->next;
158        }
159
160        return count;
161}
162
163int getbouquetcount()
164{
165        int count = 0;
166        struct mainbouquet* mnode = mainbouquet;
167        struct bouquet* node = NULL;
168
169        while(mnode != NULL)
170        {
171                node = mnode->bouquet;
172                while(node != NULL)
173                {
174                        count++;
175                        node = node->next;
176                }
177                mnode = mnode->next;
178        }
179
180        return count;
181}
182
183int getepgchannelcount()
184{
185        int count = 0;
186        struct epgscanlist* node = epgscanlist;
187
188        while(node != NULL)
189        {
190                count++;
191                node = node->next;
192        }
193
194        return count;
195}
196
197int getprovidercount()
198{
199        int count = 0;
200        struct provider* node = provider;
201
202        while(node != NULL)
203        {
204                count++;
205                node = node->next;
206        }
207
208        return count;
209}
210
211void screenoptimize()
212{
213        int rcret = 0, count = 0;
214        struct skin* optimize = getscreen("optimize");
215        struct skin* listbox = getscreennode(optimize, "listbox");
216        struct skin* c1 = getscreennode(optimize, "c1");
217        struct skin* c2 = getscreennode(optimize, "c2");
218        struct skin* c3 = getscreennode(optimize, "c3");
219        struct skin* c4 = getscreennode(optimize, "c4");
220        struct skin* c5 = getscreennode(optimize, "c5");
221        struct skin* c6 = getscreennode(optimize, "c6");
222        struct skin* c7 = getscreennode(optimize, "c7");
223        //struct skin* c8 = getscreennode(optimize, "c8");
224        //struct skin* c9 = getscreennode(optimize, "c9");
225        struct skin* tmp = NULL;
226        struct sat* satnode = NULL;
227        char* tmpstr = NULL, *tmpnr = NULL;
228
229start:
230        satnode = sat;
231        tmp = NULL;
232        delmarkedscreennodes(optimize, 1);
233        optimize->aktline = 1;
234        optimize->aktpage = -1;
235       
236        while(satnode != NULL)
237        {
238                tmp = addlistbox(optimize, listbox, tmp, 1);
239                if(tmp != NULL)
240                {
241                        count = gettranspondercount(satnode->orbitalpos);
242                        tmpnr = oitoa(count);
243
244                        tmpstr = ostrcat(tmpstr, satnode->name, 1, 0);
245                        tmpstr = ostrcat(tmpstr, " - TP: ", 1, 0);
246                        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
247
248                        changetext(tmp, tmpstr);
249                        free(tmpnr); tmpnr = NULL;
250                        free(tmpstr); tmpstr = NULL;
251
252                        tmp->type = CHOICEBOX;
253                        addchoicebox(tmp, "0", _("hold"));
254                        addchoicebox(tmp, "1", _("delete"));
255
256                        tmp->handle = satnode->name;
257                }
258
259                satnode = satnode->next;
260        }
261
262        count = getsatcount();
263        tmpnr = oitoa(count);
264        tmpstr = ostrcat(tmpstr, _("SatCount: "), 1, 0);
265        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
266        changetext(c1, tmpstr);
267        free(tmpnr); tmpnr = NULL;
268        free(tmpstr); tmpstr = NULL;
269       
270        count = gettranspondercount(0);
271        tmpnr = oitoa(count);
272        tmpstr = ostrcat(tmpstr, _("Transponder: "), 1, 0);
273        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
274        changetext(c2, tmpstr);
275        free(tmpnr); tmpnr = NULL;
276        free(tmpstr); tmpstr = NULL;
277       
278        count = getchannelcount(0);
279        tmpnr = oitoa(count);
280        tmpstr = ostrcat(tmpstr, _("ChannelCount: "), 1, 0);
281        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
282        changetext(c3, tmpstr);
283        free(tmpnr); tmpnr = NULL;
284        free(tmpstr); tmpstr = NULL;
285       
286        count = getmainbouquetcount();
287        tmpnr = oitoa(count);
288        tmpstr = ostrcat(tmpstr, _("BouquetCount: "), 1, 0);
289        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
290        changetext(c4, tmpstr);
291        free(tmpnr); tmpnr = NULL;
292        free(tmpstr); tmpstr = NULL;
293       
294        count = getbouquetcount();
295        tmpnr = oitoa(count);
296        tmpstr = ostrcat(tmpstr, _("BouquetEntrys: "), 1, 0);
297        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
298        changetext(c5, tmpstr);
299        free(tmpnr); tmpnr = NULL;
300        free(tmpstr); tmpstr = NULL;
301       
302        count = getepgchannelcount();
303        tmpnr = oitoa(count);
304        tmpstr = ostrcat(tmpstr, _("EpgChannels: "), 1, 0);
305        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
306        changetext(c6, tmpstr);
307        free(tmpnr); tmpnr = NULL;
308        free(tmpstr); tmpstr = NULL;
309       
310        count = getprovidercount();
311        tmpnr = oitoa(count);
312        tmpstr = ostrcat(tmpstr, _("ProviderCount: "), 1, 0);
313        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
314        changetext(c7, tmpstr);
315        free(tmpnr); tmpnr = NULL;
316        free(tmpstr); tmpstr = NULL;
317       
318/*
319        count = 0;
320        tmpnr = oitoa(count);
321        tmpstr = ostrcat(tmpstr, _("unused: "), 1, 0);
322        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
323        changetext(c8, tmpstr);
324        free(tmpnr); tmpnr = NULL;
325        free(tmpstr); tmpstr = NULL;
326       
327        count = 0;
328        tmpnr = oitoa(count);
329        tmpstr = ostrcat(tmpstr, _("unused: "), 1, 0);
330        tmpstr = ostrcat(tmpstr, tmpnr, 1, 0);
331        changetext(c9, tmpstr);
332        free(tmpnr); tmpnr = NULL;
333        free(tmpstr); tmpstr = NULL;
334*/
335       
336        drawscreen(optimize, 0, 0);
337        addscreenrc(optimize, listbox);
338
339        tmp = listbox->select;
340        while(1)
341        {
342                addscreenrc(optimize, tmp);
343                rcret = waitrc(optimize, 0, 0);
344                tmp = listbox->select;
345
346                if(rcret == getrcconfigint("rcexit", NULL)) break;
347                if(rcret == getrcconfigint("rcok", NULL))
348                {
349                        delmarkedsat(listbox);
350                        delunusedtransponder();
351                        delunusedchannel();
352                        delunusedbouquet();
353                        delunusedepgchannel();
354                        delunusedprovider();
355                       
356                        goto start;
357                }
358        }
359
360        delmarkedscreennodes(optimize, 1);
361        delownerrc(optimize);
362        clearscreen(optimize);
363}
364
365#endif
Note: See TracBrowser for help on using the repository browser.