1 | #ifndef EPGSEARCH_H |
---|
2 | #define EPGSEARCH_H |
---|
3 | |
---|
4 | int searchepg(char* search, char* search1, char* search2, int searchtype, struct skin* epgsearch, struct skin* listbox) |
---|
5 | { |
---|
6 | int allepg = 1, count = 0; |
---|
7 | char* result = NULL, *epgdesc = NULL, *tmpstr = NULL; |
---|
8 | char* buf = NULL; |
---|
9 | struct channel* chnode = channel; |
---|
10 | struct epg* epgnode = NULL; |
---|
11 | struct skin* tmp = NULL; |
---|
12 | struct tm *loctime = NULL; |
---|
13 | time_t akttime = time(NULL) + 7200; |
---|
14 | |
---|
15 | if(search == NULL || strlen(search) < 2) return 1; |
---|
16 | |
---|
17 | listbox->aktline = 1; |
---|
18 | listbox->aktpage = -1; |
---|
19 | |
---|
20 | buf = malloc(MINMALLOC); |
---|
21 | if(buf == NULL) |
---|
22 | { |
---|
23 | err("no mem"); |
---|
24 | return 1; |
---|
25 | } |
---|
26 | |
---|
27 | if(textbox(_("Message"), _("Search only aktual epg ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) |
---|
28 | allepg = 0; |
---|
29 | |
---|
30 | while(chnode != NULL) |
---|
31 | { |
---|
32 | epgnode = getepgakt(chnode); |
---|
33 | while(epgnode != NULL) |
---|
34 | { |
---|
35 | if(allepg == 0 && epgnode->starttime > akttime) break; |
---|
36 | |
---|
37 | result = NULL; |
---|
38 | count = 0; |
---|
39 | |
---|
40 | start: |
---|
41 | if(searchtype == 0 || searchtype == 2 || searchtype == 3) |
---|
42 | { |
---|
43 | if(epgnode->title != NULL) |
---|
44 | result = ostrstrcase(epgnode->title, search); |
---|
45 | } |
---|
46 | if(searchtype == 3 && result == NULL) |
---|
47 | { |
---|
48 | if(epgnode->subtitle != NULL) |
---|
49 | result = ostrstrcase(epgnode->subtitle, search); |
---|
50 | } |
---|
51 | if((searchtype == 1 || searchtype == 2 || searchtype == 3) && result == NULL) |
---|
52 | { |
---|
53 | epgdesc = epgdescunzip(epgnode); |
---|
54 | if(epgdesc != NULL) |
---|
55 | { |
---|
56 | result = ostrstrcase(epgdesc, search); |
---|
57 | free(epgdesc); epgdesc = NULL; |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | if(result == NULL && count == 0 && search1 != NULL) |
---|
62 | { |
---|
63 | count = 1; |
---|
64 | if(ostrcmp(search, search1) != 0) |
---|
65 | { |
---|
66 | search = search1; |
---|
67 | goto start; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | if(result == NULL && count == 1 && search2 != NULL) |
---|
72 | { |
---|
73 | count = 2; |
---|
74 | search = search2; |
---|
75 | goto start; |
---|
76 | } |
---|
77 | |
---|
78 | if(result != NULL) |
---|
79 | { |
---|
80 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
81 | if(tmp != NULL) |
---|
82 | { |
---|
83 | tmpstr = ostrcat(chnode->name, " - ", 0, 0); |
---|
84 | changetext(tmp, tmpstr); |
---|
85 | free(tmpstr); tmpstr = NULL; |
---|
86 | |
---|
87 | tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0); |
---|
88 | |
---|
89 | loctime = olocaltime(&epgnode->starttime); |
---|
90 | if(loctime != NULL) |
---|
91 | strftime(buf, MINMALLOC, "%d-%m-%Y %H:%M -", loctime); |
---|
92 | free(loctime); loctime = NULL; |
---|
93 | loctime = olocaltime(&epgnode->endtime); |
---|
94 | if(loctime != NULL) |
---|
95 | strftime(&buf[18], MINMALLOC - 19, " %H:%M", loctime); |
---|
96 | free(loctime); loctime = NULL; |
---|
97 | |
---|
98 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
99 | tmpstr = ostrcat(tmpstr, buf, 1, 0); |
---|
100 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
101 | |
---|
102 | changetext2(tmp, tmpstr); |
---|
103 | free(tmpstr); tmpstr = NULL; |
---|
104 | tmp->handle = (char*)chnode; |
---|
105 | tmp->handle1 = (char*)epgnode; |
---|
106 | } |
---|
107 | |
---|
108 | } |
---|
109 | epgnode = epgnode->next; |
---|
110 | } |
---|
111 | chnode = chnode->next; |
---|
112 | } |
---|
113 | |
---|
114 | free(buf); |
---|
115 | return 0; |
---|
116 | } |
---|
117 | |
---|
118 | void screenepgsearch(char* text) |
---|
119 | { |
---|
120 | int rcret = -1, ret = 0, genre = 0; |
---|
121 | struct skin* epgsearch = getscreen("epgsearch"); |
---|
122 | struct skin* listbox = getscreennode(epgsearch, "listbox"); |
---|
123 | char* search = NULL; |
---|
124 | struct skin* tmp = NULL; |
---|
125 | |
---|
126 | if(text != NULL) |
---|
127 | { |
---|
128 | delmarkedscreennodes(epgsearch, 1); |
---|
129 | searchepg(text, NULL, NULL, 0, epgsearch, listbox); |
---|
130 | } |
---|
131 | |
---|
132 | listbox->aktline = 1; |
---|
133 | listbox->aktpage = -1; |
---|
134 | |
---|
135 | addscreenrc(epgsearch, listbox); |
---|
136 | drawscreen(epgsearch, 0, 0); |
---|
137 | |
---|
138 | while(1) |
---|
139 | { |
---|
140 | rcret = waitrc(epgsearch, 0, 0); |
---|
141 | |
---|
142 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
143 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
144 | { |
---|
145 | if(listbox->select != NULL) |
---|
146 | { |
---|
147 | if(genre == 0) |
---|
148 | servicecheckret(servicestart((struct channel*)listbox->select->handle, NULL, NULL, 0), 0); |
---|
149 | else |
---|
150 | { |
---|
151 | genre = 0; |
---|
152 | char* s1 = ostrcat(listbox->select->text, NULL, 0, 0); |
---|
153 | char* s2 = ostrcat(listbox->select->handle, NULL, 0, 0); |
---|
154 | char* s3 = ostrcat(listbox->select->handle1, NULL, 0, 0); |
---|
155 | delmarkedscreennodes(epgsearch, 1); |
---|
156 | searchepg(s1, s2, s3, 3, epgsearch, listbox); |
---|
157 | free(s1); s1 = NULL; |
---|
158 | free(s2); s2 = NULL; |
---|
159 | free(s3); s3 = NULL; |
---|
160 | drawscreen(epgsearch, 0, 0); |
---|
161 | continue; |
---|
162 | } |
---|
163 | } |
---|
164 | break; |
---|
165 | } |
---|
166 | |
---|
167 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
168 | { |
---|
169 | if(listbox->select != NULL && genre == 0) |
---|
170 | { |
---|
171 | ret = addrecepg((struct channel*)listbox->select->handle, (struct epg*)listbox->select->handle1, NULL); |
---|
172 | drawscreen(epgsearch, 0, 0); |
---|
173 | continue; |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | if(rcret == getrcconfigint("rcgreen", NULL)) |
---|
178 | { |
---|
179 | search = textinput("Search", NULL); |
---|
180 | if(search != NULL) |
---|
181 | { |
---|
182 | genre = 0; |
---|
183 | delmarkedscreennodes(epgsearch, 1); |
---|
184 | searchepg(search, NULL, NULL, 0, epgsearch, listbox); |
---|
185 | free(search); search = NULL; |
---|
186 | } |
---|
187 | drawscreen(epgsearch, 0, 0); |
---|
188 | continue; |
---|
189 | } |
---|
190 | |
---|
191 | if(rcret == getrcconfigint("rcyellow", NULL)) |
---|
192 | { |
---|
193 | search = textinput("Search", NULL); |
---|
194 | if(search != NULL) |
---|
195 | { |
---|
196 | genre = 0; |
---|
197 | delmarkedscreennodes(epgsearch, 1); |
---|
198 | searchepg(search, NULL, NULL, 1, epgsearch, listbox); |
---|
199 | free(search); search = NULL; |
---|
200 | } |
---|
201 | drawscreen(epgsearch, 0, 0); |
---|
202 | continue; |
---|
203 | } |
---|
204 | |
---|
205 | if(rcret == getrcconfigint("rcblue", NULL)) |
---|
206 | { |
---|
207 | search = textinput("Search", NULL); |
---|
208 | if(search != NULL) |
---|
209 | { |
---|
210 | genre = 0; |
---|
211 | delmarkedscreennodes(epgsearch, 1); |
---|
212 | searchepg(search, NULL, NULL, 2, epgsearch, listbox); |
---|
213 | free(search); search = NULL; |
---|
214 | } |
---|
215 | drawscreen(epgsearch, 0, 0); |
---|
216 | continue; |
---|
217 | } |
---|
218 | |
---|
219 | if(rcret == getrcconfigint("rcmenu", NULL)) |
---|
220 | { |
---|
221 | tmp = NULL; |
---|
222 | genre = 1; |
---|
223 | delmarkedscreennodes(epgsearch, 1); |
---|
224 | |
---|
225 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
226 | if(tmp != NULL) |
---|
227 | { |
---|
228 | changetext(tmp, _("Action")); |
---|
229 | tmp->handle = "Action"; |
---|
230 | tmp->handle1 = NULL; |
---|
231 | } |
---|
232 | |
---|
233 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
234 | if(tmp != NULL) |
---|
235 | { |
---|
236 | changetext(tmp, _("Animation")); |
---|
237 | tmp->handle = "Animation"; |
---|
238 | tmp->handle1 = NULL; |
---|
239 | } |
---|
240 | |
---|
241 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
242 | if(tmp != NULL) |
---|
243 | { |
---|
244 | changetext(tmp, _("History")); |
---|
245 | tmp->handle = "History"; |
---|
246 | tmp->handle1 = NULL; |
---|
247 | } |
---|
248 | |
---|
249 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
250 | if(tmp != NULL) |
---|
251 | { |
---|
252 | changetext(tmp, _("Doku")); |
---|
253 | tmp->handle = "Doku"; |
---|
254 | tmp->handle1 = NULL; |
---|
255 | } |
---|
256 | |
---|
257 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
258 | if(tmp != NULL) |
---|
259 | { |
---|
260 | changetext(tmp, _("Thriller")); |
---|
261 | tmp->handle = "Thriller"; |
---|
262 | tmp->handle1 = NULL; |
---|
263 | } |
---|
264 | |
---|
265 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
266 | if(tmp != NULL) |
---|
267 | { |
---|
268 | changetext(tmp, _("Child")); |
---|
269 | tmp->handle = "Child"; |
---|
270 | tmp->handle1 = NULL; |
---|
271 | } |
---|
272 | |
---|
273 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
274 | if(tmp != NULL) |
---|
275 | { |
---|
276 | changetext(tmp, _("Fantasy")); |
---|
277 | tmp->handle = "Fantasy"; |
---|
278 | tmp->handle1 = NULL; |
---|
279 | } |
---|
280 | |
---|
281 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
282 | if(tmp != NULL) |
---|
283 | { |
---|
284 | changetext(tmp, _("Horror")); |
---|
285 | tmp->handle = "Horror"; |
---|
286 | tmp->handle1 = NULL; |
---|
287 | } |
---|
288 | |
---|
289 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
290 | if(tmp != NULL) |
---|
291 | { |
---|
292 | changetext(tmp, _("Comedy")); |
---|
293 | tmp->handle = "Comedy"; |
---|
294 | tmp->handle1 = NULL; |
---|
295 | } |
---|
296 | |
---|
297 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
298 | if(tmp != NULL) |
---|
299 | { |
---|
300 | changetext(tmp, _("War")); |
---|
301 | tmp->handle = "War"; |
---|
302 | tmp->handle1 = NULL; |
---|
303 | } |
---|
304 | |
---|
305 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
306 | if(tmp != NULL) |
---|
307 | { |
---|
308 | changetext(tmp, _("Scifi")); |
---|
309 | tmp->handle = "Scifi"; |
---|
310 | tmp->handle1 = "Fiction"; |
---|
311 | } |
---|
312 | |
---|
313 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
314 | if(tmp != NULL) |
---|
315 | { |
---|
316 | changetext(tmp, _("Sport")); |
---|
317 | tmp->handle = "Sport"; |
---|
318 | tmp->handle1 = NULL; |
---|
319 | } |
---|
320 | |
---|
321 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
322 | if(tmp != NULL) |
---|
323 | { |
---|
324 | changetext(tmp, _("Western")); |
---|
325 | tmp->handle = "Western"; |
---|
326 | tmp->handle1 = NULL; |
---|
327 | } |
---|
328 | |
---|
329 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
330 | if(tmp != NULL) |
---|
331 | { |
---|
332 | changetext(tmp, _("Eastern")); |
---|
333 | tmp->handle = "Eastern"; |
---|
334 | tmp->handle1 = NULL; |
---|
335 | } |
---|
336 | |
---|
337 | tmp = addlistbox(epgsearch, listbox, tmp, 1); |
---|
338 | if(tmp != NULL) |
---|
339 | { |
---|
340 | changetext(tmp, _("Music")); |
---|
341 | tmp->handle = "Music"; |
---|
342 | tmp->handle1 = NULL; |
---|
343 | } |
---|
344 | |
---|
345 | drawscreen(epgsearch, 0, 0); |
---|
346 | continue; |
---|
347 | } |
---|
348 | |
---|
349 | } |
---|
350 | |
---|
351 | delmarkedscreennodes(epgsearch, 1); |
---|
352 | delownerrc(epgsearch); |
---|
353 | clearscreen(epgsearch); |
---|
354 | } |
---|
355 | |
---|
356 | #endif |
---|