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

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

[titan] plugin optimize, plugin scriptexec, rcgui stanby fix, optimize transponder, optimize channel, optimize png render

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