1 | #ifndef RECTIMER_H |
---|
2 | #define RECTIMER_H |
---|
3 | |
---|
4 | void debugrectimer() |
---|
5 | { |
---|
6 | struct rectimer* node = rectimer; |
---|
7 | |
---|
8 | while(node != NULL) |
---|
9 | { |
---|
10 | printf("--------------------------------\n"); |
---|
11 | printf("name: %s\n", node->name); |
---|
12 | printf("start: %lu end: %lu\n", node->begin, node->end); |
---|
13 | printf("currently time: %ld\n", time(NULL)); |
---|
14 | printf("channellist: %s\n", node->channellist); |
---|
15 | printf("serviceid: %d transponderid: %llu\n", node->serviceid, node->transponderid); |
---|
16 | printf("--------------------------------\n"); |
---|
17 | node = node->next; |
---|
18 | } |
---|
19 | } |
---|
20 | |
---|
21 | void sortrectimer() |
---|
22 | { |
---|
23 | struct rectimer *nodea = NULL, *nodeb = NULL, *nodec = NULL, *noded = NULL; |
---|
24 | struct rectimer *nodetmp = NULL, *node = rectimer; |
---|
25 | |
---|
26 | if(node != NULL) |
---|
27 | { |
---|
28 | while (noded != node->next) |
---|
29 | { |
---|
30 | nodec = node; |
---|
31 | nodea = node; |
---|
32 | nodeb = nodea->next; |
---|
33 | |
---|
34 | while (nodea != noded) |
---|
35 | { |
---|
36 | if (nodea->begin >= nodeb->begin) |
---|
37 | { |
---|
38 | if (nodea == node) |
---|
39 | { |
---|
40 | nodetmp = nodeb->next; |
---|
41 | nodeb->next = nodea; |
---|
42 | nodea->next = nodetmp; |
---|
43 | node = nodeb; |
---|
44 | nodec = nodeb; |
---|
45 | } |
---|
46 | else |
---|
47 | { |
---|
48 | nodetmp = nodeb->next; |
---|
49 | nodeb->next = nodea; |
---|
50 | nodea->next = nodetmp; |
---|
51 | nodec->next = nodeb; |
---|
52 | nodec = nodeb; |
---|
53 | } |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | nodec = nodea; |
---|
58 | nodea = nodea->next; |
---|
59 | } |
---|
60 | nodeb = nodea->next; |
---|
61 | if (nodeb == noded) |
---|
62 | noded = nodea; |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | struct rectimer* prev = NULL; |
---|
68 | nodetmp = node; |
---|
69 | while(nodetmp != NULL) |
---|
70 | { |
---|
71 | nodetmp->prev = prev; |
---|
72 | prev = nodetmp; |
---|
73 | |
---|
74 | nodetmp = nodetmp->next; |
---|
75 | } |
---|
76 | |
---|
77 | rectimer = node; |
---|
78 | } |
---|
79 | |
---|
80 | int checkrectimerconflict(struct rectimer* recnode) |
---|
81 | { |
---|
82 | struct dvbdev* dvbnode = dvbdev; |
---|
83 | struct transponder* tpnode = NULL; |
---|
84 | struct rectimer* node = rectimer; |
---|
85 | |
---|
86 | if(recnode == NULL) return 0; |
---|
87 | |
---|
88 | while(dvbnode != NULL) |
---|
89 | { |
---|
90 | if(dvbnode->type == FRONTENDDEV) |
---|
91 | { |
---|
92 | adddvbdev(ostrcat(dvbnode->dev, NULL, 0, 0), dvbnode->adapter, dvbnode->devnr, dvbnode->fd, FRONTENDDEV, dvbnode->feinfo, NULL, dvbnode->fehyprid, 1); |
---|
93 | } |
---|
94 | dvbnode = dvbnode->next; |
---|
95 | } |
---|
96 | dvbnode = NULL; |
---|
97 | |
---|
98 | if(dvbdevsim == NULL) return 0; |
---|
99 | |
---|
100 | tpnode = gettransponder(recnode->transponderid); |
---|
101 | dvbnode = fegetfree(tpnode, 3, dvbdevsim); |
---|
102 | if(dvbnode != NULL) |
---|
103 | dvbnode->felock = 1; |
---|
104 | |
---|
105 | while(node != NULL) |
---|
106 | { |
---|
107 | if(recnode != node && node->status < 2) |
---|
108 | { |
---|
109 | if((recnode->begin >= node->begin && recnode->begin < node->end) || (recnode->end >= node->begin && recnode->end < node->end)) |
---|
110 | { |
---|
111 | tpnode = gettransponder(node->transponderid); |
---|
112 | dvbnode = fegetfree(tpnode, 3, dvbdevsim); |
---|
113 | if(dvbnode == NULL) |
---|
114 | { |
---|
115 | freedvbdev(1); |
---|
116 | dvbdevsim = NULL; |
---|
117 | return 2; |
---|
118 | } |
---|
119 | else |
---|
120 | dvbnode->felock = 1; |
---|
121 | } |
---|
122 | } |
---|
123 | node = node->next; |
---|
124 | } |
---|
125 | |
---|
126 | freedvbdev(1); |
---|
127 | dvbdevsim = NULL; |
---|
128 | return 0; |
---|
129 | } |
---|
130 | |
---|
131 | int checkrectimeradd(struct rectimer* recnode, char** ret) |
---|
132 | { |
---|
133 | if(recnode == NULL) |
---|
134 | { |
---|
135 | *ret = _("undefined error"); |
---|
136 | return 1; |
---|
137 | } |
---|
138 | if(recnode->begin == 0 || recnode->end == 0) |
---|
139 | { |
---|
140 | *ret = _("Timer starttime or endtime not ok"); |
---|
141 | return 1; |
---|
142 | } |
---|
143 | if(recnode->end <= time(NULL)) |
---|
144 | { |
---|
145 | *ret = _("Timer end is in the past"); |
---|
146 | return 1; |
---|
147 | } |
---|
148 | if(recnode->end <= recnode->begin) |
---|
149 | { |
---|
150 | *ret = _("Timer end is before start time"); |
---|
151 | return 1; |
---|
152 | } |
---|
153 | if(recnode->serviceid < 1) |
---|
154 | { |
---|
155 | *ret = _("Timer service ID not ok"); |
---|
156 | return 1; |
---|
157 | } |
---|
158 | if(recnode->transponderid < 1) |
---|
159 | { |
---|
160 | *ret = _("Timer transponder ID not ok"); |
---|
161 | return 1; |
---|
162 | } |
---|
163 | |
---|
164 | if(checkrectimerconflict(recnode) != 0) |
---|
165 | { |
---|
166 | *ret = _("Timer conflicts with other timer\nAdd timer anyway?"); |
---|
167 | return 2; |
---|
168 | } |
---|
169 | |
---|
170 | return 0; |
---|
171 | } |
---|
172 | |
---|
173 | void recrepeatecalc(struct rectimer* node) |
---|
174 | { |
---|
175 | time_t daysec = 24 * 60 * 60; |
---|
176 | struct tm* loctime = NULL; |
---|
177 | int rectimerday = -1, rep = 0, i = 0, daylight = 0; |
---|
178 | |
---|
179 | if(node->repeate == 0) return; |
---|
180 | status.writerectimer = 1; |
---|
181 | |
---|
182 | //get rectimer start day |
---|
183 | loctime = olocaltime(&node->begin); |
---|
184 | if(loctime != NULL) |
---|
185 | { |
---|
186 | rectimerday = loctime->tm_wday - 1; |
---|
187 | daylight = loctime->tm_isdst; |
---|
188 | } |
---|
189 | free(loctime); loctime = NULL; |
---|
190 | if(rectimerday == -1) rectimerday = 6; |
---|
191 | |
---|
192 | rep = (node->repeate & 0xff) | ((node->repeate & 0xff) << 7); |
---|
193 | |
---|
194 | for(i = 0; i < 7; i++) |
---|
195 | { |
---|
196 | node->begin = node->begin + daysec; |
---|
197 | node->end = node->end + daysec; |
---|
198 | rectimerday++; |
---|
199 | if(rectimerday > 6) rectimerday = 0; |
---|
200 | if(checkbit(rep, rectimerday) == 1) |
---|
201 | break; |
---|
202 | } |
---|
203 | |
---|
204 | //check if begin > akttime |
---|
205 | while(node->begin < time(NULL)) |
---|
206 | { |
---|
207 | for(i = 0; i < 7; i++) |
---|
208 | { |
---|
209 | node->begin = node->begin + daysec; |
---|
210 | node->end = node->end + daysec; |
---|
211 | rectimerday++; |
---|
212 | if(rectimerday > 6) rectimerday = 0; |
---|
213 | if(checkbit(rep, rectimerday) == 1) |
---|
214 | break; |
---|
215 | } |
---|
216 | } |
---|
217 | |
---|
218 | //calc daylight |
---|
219 | loctime = olocaltime(&node->begin); |
---|
220 | if(loctime != NULL) |
---|
221 | { |
---|
222 | if(loctime->tm_isdst > daylight) |
---|
223 | { |
---|
224 | node->begin = node->begin - 3600; |
---|
225 | node->end = node->end - 3600; |
---|
226 | } |
---|
227 | else if(loctime->tm_isdst < daylight) |
---|
228 | { |
---|
229 | node->begin = node->begin + 3600; |
---|
230 | node->end = node->end + 3600; |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | int checkrectimertime(struct rectimer* node) |
---|
236 | { |
---|
237 | //don't load old timers |
---|
238 | if(time(NULL) - node->end > 604800 && (node->status == 2 || node->status == 3 || node->status == 5)) |
---|
239 | return 1; |
---|
240 | |
---|
241 | if(time(NULL) > node->end && node->repeate == 0 && node->status == 0) |
---|
242 | return 1; |
---|
243 | |
---|
244 | //recalc old repeat timer |
---|
245 | if(time(NULL) > node->end && node->repeate != 0 && node->status == 0) |
---|
246 | recrepeatecalc(node); |
---|
247 | |
---|
248 | return 0; |
---|
249 | } |
---|
250 | |
---|
251 | void copyrectimer(struct rectimer* src, struct rectimer* dst) |
---|
252 | { |
---|
253 | dst->timestamp = ostrcat(src->timestamp, NULL, 0, 0); |
---|
254 | dst->name = ostrcat(src->name, NULL, 0, 0); |
---|
255 | dst->begin = src->begin; |
---|
256 | dst->end = src->end; |
---|
257 | dst->repeate = src->repeate; |
---|
258 | dst->afterevent = src->afterevent; |
---|
259 | dst->disabled = src->disabled; |
---|
260 | dst->justplay = src->justplay; |
---|
261 | dst->recpath = ostrcat(src->recpath, NULL, 0, 0); |
---|
262 | dst->servicetype = src->servicetype; |
---|
263 | dst->channellist = ostrcat(src->channellist, NULL, 0, 0); |
---|
264 | dst->serviceid = src->serviceid; |
---|
265 | dst->transponderid = src->transponderid; |
---|
266 | } |
---|
267 | |
---|
268 | struct rectimer* addrectimernode(char* line, struct rectimer* last) |
---|
269 | { |
---|
270 | char *ret = NULL; |
---|
271 | struct rectimer *newnode = NULL, *prev = NULL, *node = rectimer; |
---|
272 | |
---|
273 | newnode = (struct rectimer*)calloc(1, sizeof(struct rectimer)); |
---|
274 | if(newnode == NULL) |
---|
275 | { |
---|
276 | err("no memory"); |
---|
277 | return NULL; |
---|
278 | } |
---|
279 | |
---|
280 | status.writerectimer = 1; |
---|
281 | newnode->timestamp = NULL; |
---|
282 | |
---|
283 | if(line != NULL) |
---|
284 | { |
---|
285 | ret = getxmlentry(line, " begin="); |
---|
286 | if(ret != NULL) |
---|
287 | { |
---|
288 | newnode->begin = atol(ret); |
---|
289 | free(ret); |
---|
290 | } |
---|
291 | ret = getxmlentry(line, " end="); |
---|
292 | if(ret != NULL) |
---|
293 | { |
---|
294 | newnode->end = atol(ret); |
---|
295 | free(ret); |
---|
296 | } |
---|
297 | ret = getxmlentry(line, " repeated="); |
---|
298 | if(ret != NULL) |
---|
299 | { |
---|
300 | newnode->repeate = atoi(ret); |
---|
301 | free(ret); |
---|
302 | } |
---|
303 | ret = getxmlentry(line, " afterevent="); |
---|
304 | if(ret != NULL) |
---|
305 | { |
---|
306 | newnode->afterevent = atoi(ret); |
---|
307 | free(ret); |
---|
308 | } |
---|
309 | ret = getxmlentry(line, " pincode="); |
---|
310 | if(ret != NULL) |
---|
311 | newnode->pincode = ret; |
---|
312 | ret = getxmlentry(line, " disabled="); |
---|
313 | if(ret != NULL) |
---|
314 | { |
---|
315 | newnode->disabled = atoi(ret); |
---|
316 | free(ret); |
---|
317 | } |
---|
318 | ret = getxmlentry(line, " justplay="); |
---|
319 | if(ret != NULL) |
---|
320 | { |
---|
321 | newnode->justplay = atoi(ret); |
---|
322 | free(ret); |
---|
323 | } |
---|
324 | ret = getxmlentry(line, " serviceid="); |
---|
325 | if(ret != NULL) |
---|
326 | { |
---|
327 | newnode->serviceid = atoi(ret); |
---|
328 | free(ret); |
---|
329 | } |
---|
330 | ret = getxmlentry(line, " transponderid="); |
---|
331 | if(ret != NULL) |
---|
332 | { |
---|
333 | newnode->transponderid = strtoull(ret, NULL, 10); |
---|
334 | free(ret); |
---|
335 | } |
---|
336 | ret = getxmlentry(line, " status="); |
---|
337 | if(ret != NULL) |
---|
338 | { |
---|
339 | newnode->status = atol(ret); |
---|
340 | if(newnode->status == 1) newnode->status = 0; |
---|
341 | free(ret); |
---|
342 | } |
---|
343 | ret = getxmlentry(line, " timestamp="); |
---|
344 | if(ret != NULL) |
---|
345 | { |
---|
346 | newnode->timestamp = ret; |
---|
347 | } |
---|
348 | ret = getxmlentry(line, " name="); |
---|
349 | if(ret != NULL) |
---|
350 | newnode->name = ret; |
---|
351 | ret = getxmlentry(line, " recpath="); |
---|
352 | if(ret != NULL) |
---|
353 | newnode->recpath = ret; |
---|
354 | ret = getxmlentry(line, " channellist="); |
---|
355 | if(ret != NULL) |
---|
356 | newnode->channellist = ret; |
---|
357 | ret = getxmlentry(line, " errstr="); |
---|
358 | if(ret != NULL) |
---|
359 | newnode->errstr = ret; |
---|
360 | |
---|
361 | if(checkrectimertime(newnode) == 1) |
---|
362 | { |
---|
363 | free(newnode); |
---|
364 | return NULL; |
---|
365 | } |
---|
366 | } |
---|
367 | else |
---|
368 | { |
---|
369 | newnode->disabled = 1; |
---|
370 | newnode->afterevent = getconfigint("def_rectimer_after", NULL); |
---|
371 | } |
---|
372 | |
---|
373 | if(newnode->timestamp == NULL) |
---|
374 | newnode->timestamp = gettimestamp(); |
---|
375 | |
---|
376 | if(last == NULL) |
---|
377 | { |
---|
378 | while(node != NULL && newnode->begin >= node->begin) |
---|
379 | { |
---|
380 | prev = node; |
---|
381 | node = node->next; |
---|
382 | } |
---|
383 | } |
---|
384 | else |
---|
385 | { |
---|
386 | prev = last; |
---|
387 | node = last->next; |
---|
388 | } |
---|
389 | |
---|
390 | if(prev == NULL) |
---|
391 | rectimer = newnode; |
---|
392 | else |
---|
393 | { |
---|
394 | prev->next = newnode; |
---|
395 | newnode->prev = prev; |
---|
396 | } |
---|
397 | newnode->next = node; |
---|
398 | if(node != NULL) node->prev = newnode; |
---|
399 | |
---|
400 | return newnode; |
---|
401 | } |
---|
402 | |
---|
403 | struct rectimer* getrectimerbytimediff(time_t timediff) |
---|
404 | { |
---|
405 | struct rectimer* node = rectimer; |
---|
406 | time_t akttime = time(NULL); |
---|
407 | |
---|
408 | while(node != NULL) |
---|
409 | { |
---|
410 | if(node->begin > akttime && node->begin <= akttime + timediff) |
---|
411 | return node; |
---|
412 | |
---|
413 | node = node->next; |
---|
414 | } |
---|
415 | |
---|
416 | return NULL; |
---|
417 | } |
---|
418 | |
---|
419 | struct rectimer* getrectimerbytimestamp(char* timestamp) |
---|
420 | { |
---|
421 | struct rectimer* node = rectimer; |
---|
422 | |
---|
423 | while(node != NULL) |
---|
424 | { |
---|
425 | if(ostrcmp(node->timestamp, timestamp) == 0) |
---|
426 | return node; |
---|
427 | |
---|
428 | node = node->next; |
---|
429 | } |
---|
430 | |
---|
431 | return NULL; |
---|
432 | } |
---|
433 | |
---|
434 | struct rectimer* getrectimerbyservice(struct service* servicenode) |
---|
435 | { |
---|
436 | struct rectimer* node = rectimer; |
---|
437 | |
---|
438 | while(node != NULL) |
---|
439 | { |
---|
440 | if(node->servicenode == servicenode) |
---|
441 | return node; |
---|
442 | |
---|
443 | node = node->next; |
---|
444 | } |
---|
445 | |
---|
446 | return NULL; |
---|
447 | } |
---|
448 | |
---|
449 | void checkrectimer(struct stimerthread* self) |
---|
450 | { |
---|
451 | int ret = 0; |
---|
452 | struct rectimer* node = NULL, *newnode = NULL; |
---|
453 | struct channel* chnode = NULL; |
---|
454 | time_t t = 0, begin = 0, end = 0; |
---|
455 | |
---|
456 | if(self == NULL) return; |
---|
457 | |
---|
458 | //wait for right time |
---|
459 | while(self->aktion != STOP && time(NULL) < 1072224000) // 01.01.2004 |
---|
460 | usleep(1 * 1000000); |
---|
461 | |
---|
462 | //on first start read rectimer and set cec |
---|
463 | if(self->delay == 1000) |
---|
464 | { |
---|
465 | ret = 5; |
---|
466 | while(self->aktion != STOP && ret != 0) |
---|
467 | { |
---|
468 | usleep(1 * 1000000); |
---|
469 | ret = ret - 1; |
---|
470 | } |
---|
471 | ret = 0; |
---|
472 | readrectimer(getconfig("rectimerfile", NULL)); |
---|
473 | checkboxstart(); |
---|
474 | } |
---|
475 | |
---|
476 | //wait for start all programs |
---|
477 | ret = 30; |
---|
478 | while(self->aktion != STOP && ret != 0) |
---|
479 | { |
---|
480 | usleep(1 * 1000000); |
---|
481 | ret = ret - 1; |
---|
482 | } |
---|
483 | ret = 0; |
---|
484 | |
---|
485 | //on first start read rectimer |
---|
486 | if(self->delay == 1000) |
---|
487 | { |
---|
488 | self->delay = 10000; |
---|
489 | //readrectimer(getconfig("rectimerfile", NULL)); |
---|
490 | epgscancreatetimer(); |
---|
491 | //checkboxstart(); |
---|
492 | } |
---|
493 | |
---|
494 | m_lock(&status.rectimermutex, 1); |
---|
495 | t = time(NULL); |
---|
496 | node = rectimer; |
---|
497 | |
---|
498 | while(node != NULL) |
---|
499 | { |
---|
500 | if(node->disabled != 0) |
---|
501 | { |
---|
502 | node = node->next; |
---|
503 | continue; |
---|
504 | } |
---|
505 | |
---|
506 | if(node->justplay == 1) |
---|
507 | { |
---|
508 | begin = node->begin; |
---|
509 | end = node->end + 180; |
---|
510 | } |
---|
511 | else |
---|
512 | { |
---|
513 | begin = node->begin; |
---|
514 | end = node->end; |
---|
515 | } |
---|
516 | |
---|
517 | if(t >= begin && t < end && node->disabled == 0 && node->status == 0) |
---|
518 | { |
---|
519 | if(node->repeate != 0) |
---|
520 | { |
---|
521 | //copy repeate timer |
---|
522 | newnode = addrectimernode(NULL, NULL); |
---|
523 | if(newnode != NULL) |
---|
524 | { |
---|
525 | copyrectimer(node, newnode); |
---|
526 | recrepeatecalc(newnode); |
---|
527 | } |
---|
528 | node->repeate = 0; |
---|
529 | status.writerectimer = 1; |
---|
530 | } |
---|
531 | chnode = getchannel(node->serviceid, node->transponderid); |
---|
532 | if(node->justplay == 1) |
---|
533 | { |
---|
534 | //ret = servicestart(chnode, NULL, node->channellist, 0); |
---|
535 | ret = servicestart(chnode, node->channellist, NULL, 0); |
---|
536 | if(ret == 20 || ret == 22) ret = 0; |
---|
537 | } |
---|
538 | else |
---|
539 | { |
---|
540 | ret = recordstart(chnode, -1, 0, RECTIMER, node->end, node); |
---|
541 | if(ret == 14) ret = 0; |
---|
542 | } |
---|
543 | |
---|
544 | if(ret != 0) |
---|
545 | { |
---|
546 | node->status = 3; |
---|
547 | status.writerectimer = 1; |
---|
548 | break; |
---|
549 | } |
---|
550 | else |
---|
551 | { |
---|
552 | if(node->justplay == 1) |
---|
553 | node->status = 2; |
---|
554 | else |
---|
555 | node->status = 1; |
---|
556 | status.writerectimer = 1; |
---|
557 | } |
---|
558 | } |
---|
559 | if(t > node->end && (node->status == 0 || node->status == 4) && node->end != 0) |
---|
560 | { |
---|
561 | if(node->status == 4) |
---|
562 | node->status = 5; |
---|
563 | else |
---|
564 | node->status = 3; |
---|
565 | free(node->errstr); |
---|
566 | node->errstr = ostrcat(_("not started akttime higher than timer endtime"), NULL, 0, 0); |
---|
567 | status.writerectimer = 1; |
---|
568 | } |
---|
569 | //for epgscan |
---|
570 | if(t >= begin && t < end && node->disabled == 0 && node->status == 4) |
---|
571 | { |
---|
572 | node->status = 5; |
---|
573 | status.writerectimer = 1; |
---|
574 | |
---|
575 | if(status.standby == 0) |
---|
576 | { |
---|
577 | int tret = textbox(_("Message"), _("EPG Scan activate standby?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 20, 0); |
---|
578 | |
---|
579 | if(tret == 0 || tret == 1) |
---|
580 | { |
---|
581 | status.standby = 2; |
---|
582 | addtimer(&screenstandby, START, 1000, 1, NULL, NULL, NULL); |
---|
583 | } |
---|
584 | } |
---|
585 | } |
---|
586 | node = node->next; |
---|
587 | } |
---|
588 | |
---|
589 | m_unlock(&status.rectimermutex, 1); |
---|
590 | |
---|
591 | if(node != NULL && node->disabled == 0 && node->status < 4) |
---|
592 | { |
---|
593 | if(node->justplay == 1) |
---|
594 | { |
---|
595 | char* retstr = servicecheckret(ret, 1); |
---|
596 | free(node->errstr); |
---|
597 | node->errstr = ostrcat(retstr, NULL, 0, 0); |
---|
598 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
599 | free(retstr); retstr = NULL; |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | char* retstr = recordcheckret(NULL, ret, 15); |
---|
604 | free(node->errstr); |
---|
605 | node->errstr = ostrcat(retstr, NULL, 0, 0); |
---|
606 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
607 | free(retstr); retstr = NULL; |
---|
608 | } |
---|
609 | status.writerectimer = 1; |
---|
610 | } |
---|
611 | |
---|
612 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
613 | } |
---|
614 | |
---|
615 | int addrectimer(char *buf) |
---|
616 | { |
---|
617 | struct rectimer* node = NULL; |
---|
618 | char* buf1 = buf; |
---|
619 | char* line = NULL; |
---|
620 | |
---|
621 | line = malloc(MINMALLOC); |
---|
622 | if(line == NULL) |
---|
623 | { |
---|
624 | err("no memory"); |
---|
625 | return 1; |
---|
626 | } |
---|
627 | |
---|
628 | while(*buf != '\0') |
---|
629 | { |
---|
630 | buf++; |
---|
631 | if(*buf == '\n' || *buf == '\0') |
---|
632 | { |
---|
633 | if(*buf == '\n') |
---|
634 | { |
---|
635 | buf++; |
---|
636 | snprintf(line, buf - buf1, "%s", buf1); |
---|
637 | } |
---|
638 | else |
---|
639 | snprintf(line, buf - buf1 + 1, "%s", buf1); |
---|
640 | buf1 = buf; |
---|
641 | |
---|
642 | if(ostrstr(line, "<timer ") != NULL || ostrstr(line, "<log ") != NULL || ostrstr(line, "<epgscan ") != NULL) |
---|
643 | node = addrectimernode(line, node); |
---|
644 | } |
---|
645 | } |
---|
646 | free(line); |
---|
647 | return 0; |
---|
648 | } |
---|
649 | |
---|
650 | int readrectimer(char *filename) |
---|
651 | { |
---|
652 | char *buf = NULL; |
---|
653 | |
---|
654 | buf = readfiletomem(filename, 1); |
---|
655 | |
---|
656 | if(buf != NULL) |
---|
657 | { |
---|
658 | addrectimer(buf); |
---|
659 | //timers can change on load, so we save it |
---|
660 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
661 | free(buf); |
---|
662 | } |
---|
663 | return 0; |
---|
664 | } |
---|
665 | |
---|
666 | //flag 0 = set mutex |
---|
667 | //flag 1 = don't set mutex |
---|
668 | void delrectimer(struct rectimer* rectimernode, int write, int flag) |
---|
669 | { |
---|
670 | if(flag == 0) m_lock(&status.rectimermutex, 1); |
---|
671 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
672 | |
---|
673 | while(node != NULL) |
---|
674 | { |
---|
675 | if(node == rectimernode) |
---|
676 | { |
---|
677 | status.writerectimer = 1; |
---|
678 | |
---|
679 | //record is aktiv (del from stopservice) |
---|
680 | if(node->servicenode != NULL) |
---|
681 | { |
---|
682 | node->status = 2; |
---|
683 | free(node->errstr); |
---|
684 | node->errstr = ostrcat(_("stopped from user"), NULL, 0, 0); |
---|
685 | //stop recording |
---|
686 | node->servicenode->recendtime = 2; |
---|
687 | if(flag == 0) |
---|
688 | m_unlock(&status.rectimermutex, 1); |
---|
689 | return; |
---|
690 | } |
---|
691 | |
---|
692 | if(node == rectimer) |
---|
693 | { |
---|
694 | rectimer = node->next; |
---|
695 | if(rectimer != NULL) |
---|
696 | rectimer->prev = NULL; |
---|
697 | } |
---|
698 | else |
---|
699 | { |
---|
700 | prev->next = node->next; |
---|
701 | if(node->next != NULL) |
---|
702 | node->next->prev = prev; |
---|
703 | } |
---|
704 | |
---|
705 | free(node->name); |
---|
706 | node->name = NULL; |
---|
707 | |
---|
708 | free(node->timestamp); |
---|
709 | node->timestamp = NULL; |
---|
710 | |
---|
711 | free(node->recpath); |
---|
712 | node->recpath = NULL; |
---|
713 | |
---|
714 | free(node->channellist); |
---|
715 | node->channellist = NULL; |
---|
716 | |
---|
717 | free(node->errstr); |
---|
718 | node->errstr = NULL; |
---|
719 | |
---|
720 | free(node->pincode); |
---|
721 | node->pincode = NULL; |
---|
722 | |
---|
723 | free(node); |
---|
724 | node = NULL; |
---|
725 | break; |
---|
726 | } |
---|
727 | |
---|
728 | prev = node; |
---|
729 | node = node->next; |
---|
730 | } |
---|
731 | |
---|
732 | if(write == 1) |
---|
733 | writerectimer(getconfig("rectimerfile", NULL), 1); |
---|
734 | |
---|
735 | if(flag == 0) |
---|
736 | m_unlock(&status.rectimermutex, 1); |
---|
737 | } |
---|
738 | |
---|
739 | void deloldrectimer() |
---|
740 | { |
---|
741 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
742 | |
---|
743 | while(node != NULL) |
---|
744 | { |
---|
745 | prev = node; |
---|
746 | node = node->next; |
---|
747 | if(prev != NULL && checkrectimertime(prev) == 1) |
---|
748 | delrectimer(prev, 1, 0); |
---|
749 | } |
---|
750 | } |
---|
751 | |
---|
752 | void deloldrectimerlog() |
---|
753 | { |
---|
754 | struct rectimer* rectimernode = NULL; |
---|
755 | struct rectimer* rectimernodenext = NULL; |
---|
756 | |
---|
757 | rectimernode = rectimer; |
---|
758 | while(rectimernode != NULL) |
---|
759 | { |
---|
760 | rectimernodenext = rectimernode->next; |
---|
761 | if(rectimernode->status == 2 || rectimernode->status == 3) |
---|
762 | delrectimer(rectimernode, 0, 0); |
---|
763 | rectimernode = rectimernodenext; |
---|
764 | } |
---|
765 | m_lock(&status.rectimermutex, 1); |
---|
766 | writerectimer(getconfig("rectimerfile", NULL), 1); |
---|
767 | m_unlock(&status.rectimermutex, 1); |
---|
768 | } |
---|
769 | |
---|
770 | |
---|
771 | void freerectimer() |
---|
772 | { |
---|
773 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
774 | |
---|
775 | while(node != NULL) |
---|
776 | { |
---|
777 | prev = node; |
---|
778 | node = node->next; |
---|
779 | if(prev != NULL) |
---|
780 | delrectimer(prev, 0, 0); |
---|
781 | } |
---|
782 | } |
---|
783 | |
---|
784 | //flag 0: lock |
---|
785 | //flag 1: don't lock |
---|
786 | int writerectimer(const char *filename, int flag) |
---|
787 | { |
---|
788 | FILE *fd = NULL; |
---|
789 | struct rectimer *node = NULL; |
---|
790 | int ret = 0; |
---|
791 | char* type = NULL; |
---|
792 | time_t curtime = time(NULL), rectime = 0x7FFFFFFF; |
---|
793 | |
---|
794 | if(status.writerectimer == 0) return 0; |
---|
795 | |
---|
796 | //check if rectimer loadet |
---|
797 | if(status.rectimerthread == NULL || (status.rectimerthread != NULL && status.rectimerthread->delay == 1000)) |
---|
798 | { |
---|
799 | err("can't write rectimer, not loaded yet"); |
---|
800 | return 1; |
---|
801 | } |
---|
802 | |
---|
803 | if(flag == 0) m_lock(&status.rectimermutex, 1); |
---|
804 | sortrectimer(); |
---|
805 | node = rectimer; |
---|
806 | |
---|
807 | fd = fopen(filename, "w"); |
---|
808 | if(fd == NULL) |
---|
809 | { |
---|
810 | if(flag == 0) m_unlock(&status.rectimermutex, 1); |
---|
811 | status.writerectimer = 0; |
---|
812 | perr("can't open %s", filename); |
---|
813 | return 1; |
---|
814 | } |
---|
815 | |
---|
816 | while(node != NULL) |
---|
817 | { |
---|
818 | //don't write for del marked or old timers |
---|
819 | if(checkrectimertime(node) == 1) |
---|
820 | { |
---|
821 | node = node->next; |
---|
822 | continue; |
---|
823 | } |
---|
824 | |
---|
825 | if(node->name == NULL) node->name = ostrcat(node->name, NULL, 1, 0); |
---|
826 | if(node->channellist == NULL) node->channellist = ostrcat(node->channellist, NULL, 1, 0); |
---|
827 | if(node->errstr == NULL) node->errstr = ostrcat(node->errstr, NULL, 1, 0); |
---|
828 | if(node->pincode == NULL) node->pincode = ostrcat(node->pincode, "0000", 1, 0); |
---|
829 | if(node->recpath == NULL) node->recpath = ostrcat(node->recpath, NULL, 1, 0); |
---|
830 | if(node->status == 0 || node->status == 1) |
---|
831 | type = "timer"; |
---|
832 | else if(node->status == 4 || node->status == 5) |
---|
833 | type = "epgscan"; |
---|
834 | else |
---|
835 | type = "log"; |
---|
836 | |
---|
837 | ret = fprintf(fd, "<%s begin=\"%lu\" end=\"%lu\" serviceid=\"%d\" transponderid=\"%llu\" channellist=\"%s\" repeated=\"%d\" name=\"%s\" afterevent=\"%d\" pincode=\"%s\" disabled=\"%d\" justplay=\"%d\", recpath=\"%s\", timestamp=\"%s\", status=\"%d\" errstr=\"%s\">\n</%s>\n", type, node->begin, node->end, node->serviceid, node->transponderid, node->channellist, node->repeate, node->name, node->afterevent, node->pincode, node->disabled, node->justplay, node->recpath, node->timestamp, node->status, node->errstr, type); |
---|
838 | |
---|
839 | if(ret < 0) |
---|
840 | { |
---|
841 | perr("writing file %s", filename); |
---|
842 | } |
---|
843 | |
---|
844 | //get wakeup time |
---|
845 | if(node->status == 0 || node->status == 1 || node->status == 4) |
---|
846 | { |
---|
847 | if(node->begin < rectime && node->begin > curtime) |
---|
848 | rectime = node->begin; |
---|
849 | } |
---|
850 | node = node->next; |
---|
851 | } |
---|
852 | |
---|
853 | fclose(fd); |
---|
854 | //write wakeup time to proc |
---|
855 | setwakeuptimerdev(rectime); |
---|
856 | debugrectimer(); |
---|
857 | |
---|
858 | if(flag == 0) m_unlock(&status.rectimermutex, 1); |
---|
859 | |
---|
860 | status.writerectimer = 0; |
---|
861 | return 0; |
---|
862 | } |
---|
863 | |
---|
864 | int recrepeateget(int newnode, struct skin* repeate, struct skin* repeatetype, struct skin* day, struct skin* mon, struct skin* tue, struct skin* wed, struct skin* thur, struct skin* fri, struct skin* sat, struct skin* sun) |
---|
865 | { |
---|
866 | unsigned char ret = 0; |
---|
867 | int aktday = rectimergetaktday(); |
---|
868 | |
---|
869 | if(repeate == NULL) return 0; |
---|
870 | if(repeatetype == NULL) return 0; |
---|
871 | |
---|
872 | if(ostrcmp(repeate->ret, "0") == 0) return 0; |
---|
873 | |
---|
874 | if(ostrcmp(repeatetype->ret, "0") == 0) return 127; |
---|
875 | if(ostrcmp(repeatetype->ret, "1") == 0) |
---|
876 | { |
---|
877 | if(day->ret == NULL) return aktday; |
---|
878 | if(ostrcmp(day->ret, "0") == 0) |
---|
879 | { |
---|
880 | if(newnode == 1) |
---|
881 | return aktday; |
---|
882 | else |
---|
883 | return 1; |
---|
884 | } |
---|
885 | if(ostrcmp(day->ret, "1") == 0) return 2; |
---|
886 | if(ostrcmp(day->ret, "2") == 0) return 4; |
---|
887 | if(ostrcmp(day->ret, "3") == 0) return 8; |
---|
888 | if(ostrcmp(day->ret, "4") == 0) return 16; |
---|
889 | if(ostrcmp(day->ret, "5") == 0) return 32; |
---|
890 | if(ostrcmp(day->ret, "6") == 0) return 64; |
---|
891 | } |
---|
892 | if(ostrcmp(repeatetype->ret, "2") == 0) return 31; |
---|
893 | if(ostrcmp(repeatetype->ret, "3") == 0) |
---|
894 | { |
---|
895 | if(mon == NULL || tue == NULL || wed == NULL || thur == NULL || fri == NULL || sat == NULL || sun == NULL) return aktday; |
---|
896 | if(ostrcmp(mon->ret, "1") == 0) ret = setbit(ret, 0); |
---|
897 | if(ostrcmp(tue->ret, "1") == 0) ret = setbit(ret, 1); |
---|
898 | if(ostrcmp(wed->ret, "1") == 0) ret = setbit(ret, 2); |
---|
899 | if(ostrcmp(thur->ret, "1") == 0) ret = setbit(ret, 3); |
---|
900 | if(ostrcmp(fri->ret, "1") == 0) ret = setbit(ret, 4); |
---|
901 | if(ostrcmp(sat->ret, "1") == 0) ret = setbit(ret, 5); |
---|
902 | if(ostrcmp(sun->ret, "1") == 0) ret = setbit(ret, 6); |
---|
903 | if(ret == 0) ret = aktday; |
---|
904 | return ret; |
---|
905 | } |
---|
906 | |
---|
907 | return 127; |
---|
908 | } |
---|
909 | |
---|
910 | void recjustplayhidden(int justplay, struct skin* end, struct skin* path, struct skin* after) |
---|
911 | { |
---|
912 | if(justplay == 0) |
---|
913 | { |
---|
914 | end->hidden = NO; |
---|
915 | path->hidden = NO; |
---|
916 | after->hidden = NO; |
---|
917 | } |
---|
918 | else |
---|
919 | { |
---|
920 | end->hidden = YES; |
---|
921 | path->hidden = YES; |
---|
922 | after->hidden = YES; |
---|
923 | } |
---|
924 | } |
---|
925 | |
---|
926 | int rectimergetaktday() |
---|
927 | { |
---|
928 | int ret = 1; |
---|
929 | struct tm* loctime = NULL; |
---|
930 | |
---|
931 | time_t akttime = time(NULL); |
---|
932 | loctime = olocaltime(&akttime); |
---|
933 | if(loctime != NULL) |
---|
934 | { |
---|
935 | if(loctime->tm_wday == 0) ret = 64; |
---|
936 | if(loctime->tm_wday == 1) ret = 1; |
---|
937 | if(loctime->tm_wday == 2) ret = 2; |
---|
938 | if(loctime->tm_wday == 3) ret = 4; |
---|
939 | if(loctime->tm_wday == 4) ret = 8; |
---|
940 | if(loctime->tm_wday == 5) ret = 16; |
---|
941 | if(loctime->tm_wday == 6) ret = 32; |
---|
942 | } |
---|
943 | free(loctime); loctime = NULL; |
---|
944 | |
---|
945 | return ret; |
---|
946 | } |
---|
947 | |
---|
948 | void recrepeatehidden(int repeate, struct skin* repeatetype, struct skin* day, struct skin* mon, struct skin* tue, struct skin* wed, struct skin* thur, struct skin* fri, struct skin* sat, struct skin* sun) |
---|
949 | { |
---|
950 | repeatetype->hidden = YES; |
---|
951 | day->hidden = YES; |
---|
952 | mon->hidden = YES; |
---|
953 | tue->hidden = YES; |
---|
954 | wed->hidden = YES; |
---|
955 | thur->hidden = YES; |
---|
956 | fri->hidden = YES; |
---|
957 | sat->hidden = YES; |
---|
958 | sun->hidden = YES; |
---|
959 | |
---|
960 | if(repeate == 0) return; |
---|
961 | |
---|
962 | if(repeate == 127 && ostrcmp(repeatetype->ret, "3") != 0) //dayly |
---|
963 | { |
---|
964 | repeatetype->hidden = NO; |
---|
965 | setchoiceboxselection(repeatetype, "0"); |
---|
966 | return; |
---|
967 | } |
---|
968 | if(repeate == 31 && ostrcmp(repeatetype->ret, "3") != 0) //workday |
---|
969 | { |
---|
970 | repeatetype->hidden = NO; |
---|
971 | setchoiceboxselection(repeatetype, "2"); |
---|
972 | return; |
---|
973 | } |
---|
974 | if((repeate == 1 || repeate == 2 || repeate == 4 || repeate == 8 || repeate == 16 || repeate == 32 || repeate == 64) && ostrcmp(repeatetype->ret, "3") != 0) //weekly |
---|
975 | { |
---|
976 | repeatetype->hidden = NO; |
---|
977 | setchoiceboxselection(repeatetype, "1"); |
---|
978 | day->hidden = NO; |
---|
979 | if(repeate == 1) setchoiceboxselection(day, "0"); |
---|
980 | else if(repeate == 2) setchoiceboxselection(day, "1"); |
---|
981 | else if(repeate == 4) setchoiceboxselection(day, "2"); |
---|
982 | else if(repeate == 8) setchoiceboxselection(day, "3"); |
---|
983 | else if(repeate == 16) setchoiceboxselection(day, "4"); |
---|
984 | else if(repeate == 32) setchoiceboxselection(day, "5"); |
---|
985 | else if(repeate == 64) setchoiceboxselection(day, "6"); |
---|
986 | return; |
---|
987 | } |
---|
988 | |
---|
989 | //user defined |
---|
990 | repeatetype->hidden = NO; |
---|
991 | setchoiceboxselection(repeatetype, "3"); |
---|
992 | mon->hidden = NO; |
---|
993 | tue->hidden = NO; |
---|
994 | wed->hidden = NO; |
---|
995 | thur->hidden = NO; |
---|
996 | fri->hidden = NO; |
---|
997 | sat->hidden = NO; |
---|
998 | sun->hidden = NO; |
---|
999 | if(checkbit(repeate, 0) == 1) setchoiceboxselection(mon, "1"); |
---|
1000 | if(checkbit(repeate, 1) == 1) setchoiceboxselection(tue, "1"); |
---|
1001 | if(checkbit(repeate, 2) == 1) setchoiceboxselection(wed, "1"); |
---|
1002 | if(checkbit(repeate, 3) == 1) setchoiceboxselection(thur, "1"); |
---|
1003 | if(checkbit(repeate, 4) == 1) setchoiceboxselection(fri, "1"); |
---|
1004 | if(checkbit(repeate, 5) == 1) setchoiceboxselection(sat, "1"); |
---|
1005 | if(checkbit(repeate, 6) == 1) setchoiceboxselection(sun, "1"); |
---|
1006 | } |
---|
1007 | |
---|
1008 | //flag 0: called from menu (manuel timer) |
---|
1009 | //flag 1: call from epg timer |
---|
1010 | void screenrectimerext(struct rectimer* node, int flag) |
---|
1011 | { |
---|
1012 | int ret = 0, rcret = 0, edaylight = 0, bdaylight = 0, newnode = 0, tmpservicetype = 0, tmprepeate = 0; |
---|
1013 | struct skin* rectimerext = getscreen("rectimerext"); |
---|
1014 | struct skin* listbox = getscreennode(rectimerext, "listbox"); |
---|
1015 | struct skin* name = getscreennode(rectimerext, "name"); |
---|
1016 | struct skin* justplay = getscreennode(rectimerext, "justplay"); |
---|
1017 | struct skin* repeate = getscreennode(rectimerext, "repeate"); |
---|
1018 | struct skin* repeatetype = getscreennode(rectimerext, "repeatetype"); |
---|
1019 | struct skin* day = getscreennode(rectimerext, "day"); |
---|
1020 | struct skin* mon = getscreennode(rectimerext, "mon"); |
---|
1021 | struct skin* tue = getscreennode(rectimerext, "tue"); |
---|
1022 | struct skin* wed = getscreennode(rectimerext, "wed"); |
---|
1023 | struct skin* thur = getscreennode(rectimerext, "thur"); |
---|
1024 | struct skin* fri = getscreennode(rectimerext, "fri"); |
---|
1025 | struct skin* sat = getscreennode(rectimerext, "sat"); |
---|
1026 | struct skin* sun = getscreennode(rectimerext, "sun"); |
---|
1027 | struct skin* begin = getscreennode(rectimerext, "begin"); |
---|
1028 | struct skin* end = getscreennode(rectimerext, "end"); |
---|
1029 | struct skin* recchannel = getscreennode(rectimerext, "channel"); |
---|
1030 | struct skin* path = getscreennode(rectimerext, "path"); |
---|
1031 | struct skin* after = getscreennode(rectimerext, "after"); |
---|
1032 | struct skin* pincode = getscreennode(rectimerext, "pincode"); |
---|
1033 | struct skin* tmp = NULL; |
---|
1034 | char* tmpstr = NULL, *buf = NULL, *buf1 = NULL, *tmpchannellist = NULL; |
---|
1035 | struct tm* loctime = NULL; |
---|
1036 | time_t akttime = time(NULL); |
---|
1037 | |
---|
1038 | if(node == NULL) |
---|
1039 | { |
---|
1040 | newnode = 1; |
---|
1041 | node = addrectimernode(NULL, NULL); |
---|
1042 | tmpservicetype = status.servicetype; |
---|
1043 | if(tmpservicetype == 0) |
---|
1044 | tmpchannellist = ostrcat(getconfig("channellist", NULL), NULL, 0, 0); |
---|
1045 | else |
---|
1046 | tmpchannellist = ostrcat(getconfig("rchannellist", NULL), NULL, 0, 0); |
---|
1047 | } |
---|
1048 | else |
---|
1049 | { |
---|
1050 | tmpservicetype = node->servicetype; |
---|
1051 | tmpchannellist = ostrcat(node->channellist, NULL, 0, 0); |
---|
1052 | } |
---|
1053 | |
---|
1054 | if(node == NULL) |
---|
1055 | { |
---|
1056 | err("NULL detect"); |
---|
1057 | return; |
---|
1058 | } |
---|
1059 | |
---|
1060 | listbox->aktline = 1; |
---|
1061 | listbox->aktpage = -1; |
---|
1062 | begin->aktpage = 0; |
---|
1063 | end->aktpage = 0; |
---|
1064 | name->aktpage = 0; |
---|
1065 | |
---|
1066 | changeinput(name, node->name); |
---|
1067 | |
---|
1068 | if(status.pvr == 1) |
---|
1069 | addchoicebox(justplay, "0", _("record")); |
---|
1070 | addchoicebox(justplay, "1", _("switch channel")); |
---|
1071 | if(newnode == 0) |
---|
1072 | { |
---|
1073 | tmpstr = oitoa(node->justplay); |
---|
1074 | setchoiceboxselection(justplay, tmpstr); |
---|
1075 | free(tmpstr); tmpstr = NULL; |
---|
1076 | } |
---|
1077 | else |
---|
1078 | setchoiceboxselection(justplay, "0"); |
---|
1079 | |
---|
1080 | addchoicebox(repeate, "0", _("once")); |
---|
1081 | addchoicebox(repeate, "1", _("repeat")); |
---|
1082 | if(newnode == 0) |
---|
1083 | { |
---|
1084 | tmprepeate = node->repeate; |
---|
1085 | if(node->repeate == 0) |
---|
1086 | setchoiceboxselection(repeate, "0"); |
---|
1087 | else |
---|
1088 | setchoiceboxselection(repeate, "1"); |
---|
1089 | } |
---|
1090 | else |
---|
1091 | setchoiceboxselection(repeate, "0"); |
---|
1092 | |
---|
1093 | addchoicebox(repeatetype, "0", _("daily")); |
---|
1094 | addchoicebox(repeatetype, "1", _("weekly")); |
---|
1095 | addchoicebox(repeatetype, "2", _("workdays")); |
---|
1096 | addchoicebox(repeatetype, "3", _("user defined")); |
---|
1097 | changeret(repeatetype, NULL); |
---|
1098 | setchoiceboxselection(repeatetype, "0"); |
---|
1099 | |
---|
1100 | addchoicebox(day, "0", _("Monday")); |
---|
1101 | addchoicebox(day, "1", _("Tuesday")); |
---|
1102 | addchoicebox(day, "2", _("Wednesday")); |
---|
1103 | addchoicebox(day, "3", _("Thursday")); |
---|
1104 | addchoicebox(day, "4", _("Friday")); |
---|
1105 | addchoicebox(day, "5", _("Saturday")); |
---|
1106 | addchoicebox(day, "6", _("Sunday")); |
---|
1107 | changeret(day, NULL); |
---|
1108 | setchoiceboxselection(day, "0"); |
---|
1109 | |
---|
1110 | addchoicebox(mon, "0", _("no")); |
---|
1111 | addchoicebox(mon, "1", _("yes")); |
---|
1112 | changeret(mon, NULL); |
---|
1113 | setchoiceboxselection(mon, "0"); |
---|
1114 | |
---|
1115 | addchoicebox(tue, "0", _("no")); |
---|
1116 | addchoicebox(tue, "1", _("yes")); |
---|
1117 | changeret(tue, NULL); |
---|
1118 | setchoiceboxselection(tue, "0"); |
---|
1119 | |
---|
1120 | addchoicebox(wed, "0", _("no")); |
---|
1121 | addchoicebox(wed, "1", _("yes")); |
---|
1122 | changeret(wed, NULL); |
---|
1123 | setchoiceboxselection(wed, "0"); |
---|
1124 | |
---|
1125 | addchoicebox(thur, "0", _("no")); |
---|
1126 | addchoicebox(thur, "1", _("yes")); |
---|
1127 | changeret(thur, NULL); |
---|
1128 | setchoiceboxselection(thur, "0"); |
---|
1129 | |
---|
1130 | addchoicebox(fri, "0", _("no")); |
---|
1131 | addchoicebox(fri, "1", _("yes")); |
---|
1132 | changeret(fri, NULL); |
---|
1133 | setchoiceboxselection(fri, "0"); |
---|
1134 | |
---|
1135 | addchoicebox(sat, "0", _("no")); |
---|
1136 | addchoicebox(sat, "1", _("yes")); |
---|
1137 | changeret(sat, NULL); |
---|
1138 | setchoiceboxselection(sat, "0"); |
---|
1139 | |
---|
1140 | addchoicebox(sun, "0", _("no")); |
---|
1141 | addchoicebox(sun, "1", _("yes")); |
---|
1142 | changeret(sun, NULL); |
---|
1143 | setchoiceboxselection(sun, "0"); |
---|
1144 | |
---|
1145 | recrepeatehidden(node->repeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1146 | recjustplayhidden(node->justplay, end, path, after); |
---|
1147 | |
---|
1148 | buf = malloc(MINMALLOC); |
---|
1149 | if(buf == NULL) |
---|
1150 | { |
---|
1151 | err("no memory"); |
---|
1152 | return; |
---|
1153 | } |
---|
1154 | |
---|
1155 | changemask(begin, "00:00 00-00-0000"); |
---|
1156 | if(newnode == 0) |
---|
1157 | loctime = localtime(&node->begin); |
---|
1158 | else |
---|
1159 | loctime = localtime(&akttime); |
---|
1160 | bdaylight = loctime->tm_isdst; |
---|
1161 | strftime(buf, MINMALLOC, "%H:%M %d-%m-%Y", loctime); |
---|
1162 | buf1 = ostrcat(buf, NULL, 0, 0); |
---|
1163 | changeinput(begin, buf1); |
---|
1164 | free(buf1); buf1 = NULL; |
---|
1165 | |
---|
1166 | changemask(end, "00:00 00-00-0000"); |
---|
1167 | if(newnode == 0) |
---|
1168 | loctime = localtime(&node->end); |
---|
1169 | else |
---|
1170 | { |
---|
1171 | akttime += 300; |
---|
1172 | loctime = localtime(&akttime); |
---|
1173 | } |
---|
1174 | edaylight = loctime->tm_isdst; |
---|
1175 | strftime(buf, MINMALLOC, "%H:%M %d-%m-%Y", loctime); |
---|
1176 | buf1 = ostrcat(buf, NULL, 1, 0); |
---|
1177 | changeinput(end, buf1); |
---|
1178 | free(buf1); buf1 = NULL; |
---|
1179 | |
---|
1180 | if(flag == 1) |
---|
1181 | recchannel->hidden = YES; |
---|
1182 | else |
---|
1183 | recchannel->hidden = NO; |
---|
1184 | |
---|
1185 | changeinput(recchannel, NULL); |
---|
1186 | if(newnode == 0) |
---|
1187 | { |
---|
1188 | recchannel->handle = (char*)getchannel(node->serviceid, node->transponderid); |
---|
1189 | if(recchannel->handle != NULL) |
---|
1190 | addchoicebox(recchannel, ((struct channel*)recchannel->handle)->name, ((struct channel*)recchannel->handle)->name); |
---|
1191 | } |
---|
1192 | else |
---|
1193 | { |
---|
1194 | if(status.aktservice->channel != NULL) |
---|
1195 | { |
---|
1196 | addchoicebox(recchannel, status.aktservice->channel->name, status.aktservice->channel->name); |
---|
1197 | recchannel->handle = (char*)status.aktservice->channel; |
---|
1198 | } |
---|
1199 | } |
---|
1200 | |
---|
1201 | if(newnode == 0) |
---|
1202 | changeinput(path, node->recpath); |
---|
1203 | else |
---|
1204 | changeinput(path, getconfig("rec_path", NULL)); |
---|
1205 | |
---|
1206 | addchoicebox(after, "0", _("auto")); |
---|
1207 | addchoicebox(after, "1", _("nothing")); |
---|
1208 | addchoicebox(after, "2", _("standby")); |
---|
1209 | addchoicebox(after, "3", _("power off")); |
---|
1210 | if(newnode == 0) |
---|
1211 | { |
---|
1212 | tmpstr = oitoa(node->afterevent); |
---|
1213 | setchoiceboxselection(after, tmpstr); |
---|
1214 | free(tmpstr); tmpstr = NULL; |
---|
1215 | } |
---|
1216 | |
---|
1217 | changemask(pincode, "0000"); |
---|
1218 | if(newnode == 0) |
---|
1219 | changeinput(pincode, node->pincode); |
---|
1220 | else |
---|
1221 | changeinput(pincode, "0000"); |
---|
1222 | |
---|
1223 | drawscreen(rectimerext, 0, 0); |
---|
1224 | addscreenrc(rectimerext, listbox); |
---|
1225 | |
---|
1226 | tmp = listbox->select; |
---|
1227 | while(1) |
---|
1228 | { |
---|
1229 | addscreenrc(rectimerext, tmp); |
---|
1230 | rcret = waitrc(rectimerext, 0, 2); |
---|
1231 | tmp = listbox->select; |
---|
1232 | |
---|
1233 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
1234 | { |
---|
1235 | if(name->ret != NULL && strlen(name->ret) > 0) |
---|
1236 | { |
---|
1237 | char* tmppath = NULL; |
---|
1238 | |
---|
1239 | tmppath = ostrcat(tmppath, name->ret, 1, 0); |
---|
1240 | tmppath = strstrip(tmppath); |
---|
1241 | delspezchar(tmppath, 2); |
---|
1242 | tmppath = ostrcat("/", tmppath, 0, 1); |
---|
1243 | tmppath = ostrcat(getconfig("rec_path", NULL), tmppath, 0, 1); |
---|
1244 | |
---|
1245 | if(tmppath != NULL && file_exist(tmppath)) |
---|
1246 | { |
---|
1247 | debug(10, "skip create folder exist: %s", tmppath); |
---|
1248 | } |
---|
1249 | else if(tmppath != NULL && mkdir(tmppath, 0777) == 0) |
---|
1250 | { |
---|
1251 | debug(10, "create Folder: %s", tmppath); |
---|
1252 | changeinput(path, tmppath); |
---|
1253 | // changetext(path, tmppath); |
---|
1254 | } |
---|
1255 | else |
---|
1256 | { |
---|
1257 | debug(10, "error: cant create Folder: %s", tmppath); |
---|
1258 | textbox(_("Message"), "Can't create Path", _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1259 | } |
---|
1260 | |
---|
1261 | drawscreen(rectimerext, 0, 0); |
---|
1262 | free(tmppath); tmppath = NULL; |
---|
1263 | } |
---|
1264 | continue; |
---|
1265 | } |
---|
1266 | |
---|
1267 | if(listbox->select != NULL && listbox->select->ret != NULL && ostrcmp(listbox->select->name, "justplay") == 0) |
---|
1268 | { |
---|
1269 | recjustplayhidden(atoi(listbox->select->ret), end, path, after); |
---|
1270 | } |
---|
1271 | |
---|
1272 | tmprepeate = recrepeateget(newnode, repeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1273 | if(listbox->select != NULL && (ostrcmp(listbox->select->name, "repeate") == 0 || ostrcmp(listbox->select->name, "repeatetype") == 0)) |
---|
1274 | { |
---|
1275 | recrepeatehidden(tmprepeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1276 | } |
---|
1277 | drawscreen(rectimerext, 0, 0); |
---|
1278 | |
---|
1279 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
1280 | { |
---|
1281 | if(newnode == 1 || flag == 1) delrectimer(node, 1, 0); |
---|
1282 | break; |
---|
1283 | } |
---|
1284 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
1285 | { |
---|
1286 | if(listbox->select != NULL && ostrcmp(listbox->select->name, "path") == 0) |
---|
1287 | { |
---|
1288 | clearscreen(rectimerext); |
---|
1289 | tmpstr = screendir(listbox->select->ret, "", NULL, NULL, NULL, NULL, 0, "SELECT", 0, NULL, 0, NULL, 0, 700, 0, 650, 0, 0); |
---|
1290 | if(tmpstr != NULL) |
---|
1291 | changeinput(listbox->select, tmpstr); |
---|
1292 | free(tmpstr); tmpstr = NULL; |
---|
1293 | |
---|
1294 | drawscreen(rectimerext, 0, 0); |
---|
1295 | continue; |
---|
1296 | } |
---|
1297 | if(listbox->select != NULL && ostrcmp(listbox->select->name, "channel") == 0) |
---|
1298 | { |
---|
1299 | clearscreen(rectimerext); |
---|
1300 | int saveservicetype = status.servicetype; |
---|
1301 | struct channel* tmpchnode = (struct channel*)recchannel->handle; |
---|
1302 | |
---|
1303 | status.servicetype = tmpservicetype; |
---|
1304 | if(tmpservicetype == 0) |
---|
1305 | { |
---|
1306 | addconfigtmp("channellist", tmpchannellist); |
---|
1307 | if(tmpchnode != NULL) |
---|
1308 | { |
---|
1309 | addconfiginttmp("serviceid", tmpchnode->serviceid); |
---|
1310 | addconfigllutmp("transponderid", tmpchnode->transponderid); |
---|
1311 | } |
---|
1312 | } |
---|
1313 | else |
---|
1314 | { |
---|
1315 | addconfigtmp("rchannellist", tmpchannellist); |
---|
1316 | if(tmpchnode != NULL) |
---|
1317 | { |
---|
1318 | addconfiginttmp("rserviceid", tmpchnode->serviceid); |
---|
1319 | addconfigllutmp("rtransponderid", tmpchnode->transponderid); |
---|
1320 | } |
---|
1321 | } |
---|
1322 | |
---|
1323 | screenchannellist(&tmpchnode, &tmpchannellist, 1); |
---|
1324 | |
---|
1325 | recchannel->handle = (char*)tmpchnode; |
---|
1326 | |
---|
1327 | status.servicetype = saveservicetype; |
---|
1328 | delconfigtmp("channellist"); |
---|
1329 | delconfigtmp("rchannellist"); |
---|
1330 | delconfigtmp("serviceid"); |
---|
1331 | delconfigtmp("rserviceid"); |
---|
1332 | delconfigtmp("transponderid"); |
---|
1333 | delconfigtmp("rtransponderid"); |
---|
1334 | |
---|
1335 | if((struct channel*)recchannel->handle != NULL) |
---|
1336 | { |
---|
1337 | changeinput(listbox->select, ((struct channel*)recchannel->handle)->name); |
---|
1338 | } |
---|
1339 | |
---|
1340 | drawscreen(rectimerext, 0, 0); |
---|
1341 | continue; |
---|
1342 | } |
---|
1343 | |
---|
1344 | free(node->name); node->name = NULL; |
---|
1345 | node->name = ostrcat(name->ret, NULL, 0, 0); |
---|
1346 | if(justplay->ret != NULL) |
---|
1347 | node->justplay = atoi(justplay->ret); |
---|
1348 | if(begin->ret != NULL) |
---|
1349 | { |
---|
1350 | loctime->tm_isdst = bdaylight; |
---|
1351 | tmpstr = strptime(begin->ret, "%H:%M %d-%m-%Y", loctime); |
---|
1352 | if(tmpstr != NULL) |
---|
1353 | node->begin = mktime(loctime); |
---|
1354 | |
---|
1355 | if((flag == 1 || newnode == 1) && node->justplay == 0) |
---|
1356 | node->begin -= getconfigint("recforerun", NULL) * 60; |
---|
1357 | |
---|
1358 | node->begin -= (node->begin % 60); |
---|
1359 | |
---|
1360 | if(node->justplay == 1) |
---|
1361 | node->end = node->begin + 1; |
---|
1362 | } |
---|
1363 | if(end->ret != NULL && node->justplay == 0) |
---|
1364 | { |
---|
1365 | loctime->tm_isdst = edaylight; |
---|
1366 | tmpstr = strptime(end->ret, "%H:%M %d-%m-%Y", loctime); |
---|
1367 | if(tmpstr != NULL) |
---|
1368 | node->end = mktime(loctime); |
---|
1369 | |
---|
1370 | if((flag == 1 || newnode == 1) && node->justplay == 0) |
---|
1371 | node->end += getconfigint("recoverrun", NULL) * 60; |
---|
1372 | node->end -= (node->end % 60); |
---|
1373 | } |
---|
1374 | if(after->ret != NULL) |
---|
1375 | node->afterevent = atoi(after->ret); |
---|
1376 | |
---|
1377 | if(pincode->ret != NULL) |
---|
1378 | node->pincode = ostrcat(pincode->ret, NULL, 0, 0); |
---|
1379 | else |
---|
1380 | node->pincode = ostrcat("0000", NULL, 0, 0); |
---|
1381 | |
---|
1382 | if(tmprepeate > 127) tmprepeate = 0; |
---|
1383 | node->repeate = tmprepeate; |
---|
1384 | |
---|
1385 | free(node->recpath); node->recpath = NULL; |
---|
1386 | node->recpath = ostrcat(path->ret, NULL, 0, 0); |
---|
1387 | |
---|
1388 | free(node->channellist); node->channellist = NULL; |
---|
1389 | node->channellist = tmpchannellist; |
---|
1390 | |
---|
1391 | node->servicetype = tmpservicetype; |
---|
1392 | |
---|
1393 | if(recchannel->handle != NULL) |
---|
1394 | { |
---|
1395 | node->serviceid = ((struct channel*)recchannel->handle)->serviceid; |
---|
1396 | node->transponderid = ((struct channel*)recchannel->handle)->transponderid; |
---|
1397 | } |
---|
1398 | |
---|
1399 | char* checkret = NULL; |
---|
1400 | ret = checkrectimeradd(node, &checkret); |
---|
1401 | if(ret != 0) |
---|
1402 | { |
---|
1403 | if(ret == 2) |
---|
1404 | { |
---|
1405 | ret = textbox(_("Error"), checkret, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1406 | if(ret == 2) |
---|
1407 | ret = 99; |
---|
1408 | else |
---|
1409 | ret = 0; |
---|
1410 | } |
---|
1411 | if(ret == 1 || ret == 99) |
---|
1412 | { |
---|
1413 | node->status = 3; |
---|
1414 | free(node->errstr); node->errstr = NULL; |
---|
1415 | node->errstr = ostrcat(checkret, NULL, 0, 0); |
---|
1416 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
1417 | if(ret == 1) textbox(_("Error"), checkret, _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1418 | } |
---|
1419 | } |
---|
1420 | |
---|
1421 | //check if record is running and change endtime |
---|
1422 | m_lock(&status.servicemutex, 2); |
---|
1423 | struct service* tmpservice = getservicebyrectimestamp(node->timestamp, 1); |
---|
1424 | if(tmpservice != NULL) |
---|
1425 | tmpservice->recendtime = node->end; |
---|
1426 | m_unlock(&status.servicemutex, 2); |
---|
1427 | |
---|
1428 | if(newnode == 1 || flag == 1) node->disabled = 0; |
---|
1429 | status.writerectimer = 1; |
---|
1430 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
1431 | break; |
---|
1432 | } |
---|
1433 | } |
---|
1434 | |
---|
1435 | if(flag == 1) resettvpic(); |
---|
1436 | |
---|
1437 | delownerrc(rectimerext); |
---|
1438 | clearscreen(rectimerext); |
---|
1439 | } |
---|
1440 | |
---|
1441 | //flag 0: show normal |
---|
1442 | //flag 1: show log |
---|
1443 | void screenrectimer() |
---|
1444 | { |
---|
1445 | int rcret = 0, flag = 0; |
---|
1446 | struct skin* recordtimer = getscreen("rectimer"); |
---|
1447 | struct skin* listbox = getscreennode(recordtimer, "listbox"); |
---|
1448 | struct skin* b1 = getscreennode(recordtimer, "b1"); |
---|
1449 | struct skin* b2 = getscreennode(recordtimer, "b2"); |
---|
1450 | struct skin* b3 = getscreennode(recordtimer, "b3"); |
---|
1451 | struct skin* t3 = getscreennode(recordtimer, "t3"); |
---|
1452 | struct skin* b4 = getscreennode(recordtimer, "b4"); |
---|
1453 | struct skin* tmp = NULL; |
---|
1454 | struct rectimer* rectimernode = NULL; |
---|
1455 | struct tm *loctime = NULL; |
---|
1456 | struct channel* chnode = NULL; |
---|
1457 | char* buf = NULL, *tmpstr = NULL; |
---|
1458 | |
---|
1459 | buf = malloc(MINMALLOC); |
---|
1460 | if(buf == NULL) |
---|
1461 | { |
---|
1462 | err("no memory"); |
---|
1463 | return; |
---|
1464 | } |
---|
1465 | |
---|
1466 | start: |
---|
1467 | deloldrectimer(); |
---|
1468 | |
---|
1469 | tmp = NULL; |
---|
1470 | listbox->aktpage = -1; |
---|
1471 | listbox->select = NULL; |
---|
1472 | rectimernode = rectimer; |
---|
1473 | |
---|
1474 | while(rectimernode != NULL) |
---|
1475 | { |
---|
1476 | if((flag == 0 && (rectimernode->status == 2 || rectimernode->status == 3)) || (flag == 1 && (rectimernode->status == 0 || rectimernode->status == 1)) || rectimernode->status == 4 || rectimernode->status == 5) |
---|
1477 | { |
---|
1478 | rectimernode = rectimernode->next; |
---|
1479 | continue; |
---|
1480 | } |
---|
1481 | |
---|
1482 | tmp = addlistbox(recordtimer, listbox, tmp, 1); |
---|
1483 | if(tmp != NULL) |
---|
1484 | { |
---|
1485 | loctime = localtime(&rectimernode->begin); |
---|
1486 | strftime(buf, MINMALLOC, "%d-%m-%Y %H:%M", loctime); |
---|
1487 | tmpstr = ostrcat(tmpstr, buf, 1, 0); |
---|
1488 | if(rectimernode->justplay == 0) |
---|
1489 | { |
---|
1490 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1491 | loctime = localtime(&rectimernode->end); |
---|
1492 | strftime(buf, MINMALLOC, "%d-%m-%Y %H:%M", loctime); |
---|
1493 | tmpstr = ostrcat(tmpstr, buf, 1, 0); |
---|
1494 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1495 | tmpstr = ostrcat(tmpstr, _("rec"), 1, 0); |
---|
1496 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1497 | if(rectimernode->repeate == 0) |
---|
1498 | tmpstr = ostrcat(tmpstr, _("once"), 1, 0); |
---|
1499 | else |
---|
1500 | tmpstr = ostrcat(tmpstr, _("repeat"), 1, 0); |
---|
1501 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1502 | } |
---|
1503 | else |
---|
1504 | { |
---|
1505 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1506 | tmpstr = ostrcat(tmpstr, _("switch"), 1, 0); |
---|
1507 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1508 | if(rectimernode->repeate == 0) |
---|
1509 | tmpstr = ostrcat(tmpstr, _("once"), 1, 0); |
---|
1510 | else |
---|
1511 | tmpstr = ostrcat(tmpstr, _("repeat"), 1, 0); |
---|
1512 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1513 | } |
---|
1514 | |
---|
1515 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
1516 | if(rectimernode->name != NULL) |
---|
1517 | { |
---|
1518 | if(rectimernode->name == NULL || strlen(rectimernode->name) == 0) |
---|
1519 | tmpstr = ostrcat(tmpstr, "---", 1, 0); |
---|
1520 | else |
---|
1521 | tmpstr = ostrcat(tmpstr, rectimernode->name, 1, 0); |
---|
1522 | } |
---|
1523 | chnode = getchannel(rectimernode->serviceid, rectimernode->transponderid); |
---|
1524 | if(chnode != NULL && chnode->name != NULL && strlen(chnode->name) > 0) |
---|
1525 | { |
---|
1526 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1527 | tmpstr = ostrcat(tmpstr, chnode->name, 1, 0); |
---|
1528 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1529 | } |
---|
1530 | |
---|
1531 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
1532 | if(rectimernode->status == 0) |
---|
1533 | tmpstr = ostrcat(tmpstr, _("waiting"), 1, 0); |
---|
1534 | else if(rectimernode->status == 1) |
---|
1535 | tmpstr = ostrcat(tmpstr, _("running"), 1, 0); |
---|
1536 | else if(rectimernode->status == 2) |
---|
1537 | tmpstr = ostrcat(tmpstr, _("success"), 1, 0); |
---|
1538 | else if(rectimernode->status == 3) |
---|
1539 | tmpstr = ostrcat(tmpstr, _("error"), 1, 0); |
---|
1540 | |
---|
1541 | if(flag == 1 && rectimernode->errstr != NULL && strlen(rectimernode->errstr) != 0) |
---|
1542 | { |
---|
1543 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1544 | tmpstr = ostrcat(tmpstr, rectimernode->errstr, 1, 0); |
---|
1545 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1546 | } |
---|
1547 | |
---|
1548 | changetext(tmp, tmpstr); |
---|
1549 | free(tmpstr); tmpstr = NULL; |
---|
1550 | tmp->handle = (char*)rectimernode; |
---|
1551 | tmp->height = 110; |
---|
1552 | tmp->type = TEXTBOX; |
---|
1553 | |
---|
1554 | if(rectimernode->disabled == 1) |
---|
1555 | tmp->fontcol = convertcol("deaktivcol"); |
---|
1556 | } |
---|
1557 | rectimernode = rectimernode->next; |
---|
1558 | } |
---|
1559 | |
---|
1560 | if(flag == 0) |
---|
1561 | { |
---|
1562 | b1->hidden = NO; |
---|
1563 | b2->hidden = NO; |
---|
1564 | b3->hidden = NO; |
---|
1565 | b4->hidden = NO; |
---|
1566 | if(t3 == status.skinerr) |
---|
1567 | changetext(b3,_("STOP/START")); |
---|
1568 | else |
---|
1569 | changetext(t3,_("STOP/START")); |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | b1->hidden = NO; |
---|
1574 | b2->hidden = YES; |
---|
1575 | b3->hidden = NO; |
---|
1576 | b4->hidden = YES; |
---|
1577 | if(t3 == status.skinerr) |
---|
1578 | changetext(b3,_("Clear list")); |
---|
1579 | else |
---|
1580 | changetext(t3,_("Clear list")); |
---|
1581 | } |
---|
1582 | |
---|
1583 | drawscreen(recordtimer, 0, 0); |
---|
1584 | addscreenrc(recordtimer, listbox); |
---|
1585 | |
---|
1586 | while(1) |
---|
1587 | { |
---|
1588 | rcret = waitrc(recordtimer, 5000, 0); |
---|
1589 | |
---|
1590 | if(flag == 0 && rcret == getrcconfigint("rcblue", NULL)) |
---|
1591 | { |
---|
1592 | flag = 1; |
---|
1593 | delmarkedscreennodes(recordtimer, 1); |
---|
1594 | goto start; |
---|
1595 | } |
---|
1596 | if(flag == 1 && rcret == getrcconfigint("rcred", NULL) && listbox->select != NULL) // delete log |
---|
1597 | { |
---|
1598 | flag = 1; |
---|
1599 | delrectimer((struct rectimer*)listbox->select->handle, 1, 0); |
---|
1600 | |
---|
1601 | delmarkedscreennodes(recordtimer, 1); |
---|
1602 | goto start; |
---|
1603 | } |
---|
1604 | |
---|
1605 | if(flag == 1 && rcret == getrcconfigint("rcyellow", NULL)) // delete all log entrys |
---|
1606 | { |
---|
1607 | flag = 1; |
---|
1608 | deloldrectimerlog(); |
---|
1609 | delmarkedscreennodes(recordtimer, 1); |
---|
1610 | goto start; |
---|
1611 | } |
---|
1612 | |
---|
1613 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
1614 | { |
---|
1615 | if(flag == 0) |
---|
1616 | break; |
---|
1617 | else |
---|
1618 | { |
---|
1619 | flag = 0; |
---|
1620 | delmarkedscreennodes(recordtimer, 1); |
---|
1621 | goto start; |
---|
1622 | } |
---|
1623 | } |
---|
1624 | if(flag == 0 && rcret == getrcconfigint("rcgreen", NULL)) |
---|
1625 | { |
---|
1626 | clearscreen(recordtimer); |
---|
1627 | screenrectimerext(NULL, 0); |
---|
1628 | delmarkedscreennodes(recordtimer, 1); |
---|
1629 | goto start; |
---|
1630 | } |
---|
1631 | if(flag == 0 && listbox->select != NULL) |
---|
1632 | { |
---|
1633 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
1634 | { |
---|
1635 | clearscreen(recordtimer); |
---|
1636 | screenrectimerext((struct rectimer*)listbox->select->handle, 0); |
---|
1637 | delmarkedscreennodes(recordtimer, 1); |
---|
1638 | goto start; |
---|
1639 | } |
---|
1640 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
1641 | { |
---|
1642 | delrectimer((struct rectimer*)listbox->select->handle, 1, 0); |
---|
1643 | |
---|
1644 | delmarkedscreennodes(recordtimer, 1); |
---|
1645 | goto start; |
---|
1646 | } |
---|
1647 | if(rcret == getrcconfigint("rcyellow", NULL)) |
---|
1648 | { |
---|
1649 | if(((struct rectimer*)listbox->select->handle)->disabled == 1) |
---|
1650 | ((struct rectimer*)listbox->select->handle)->disabled = 0; |
---|
1651 | else |
---|
1652 | ((struct rectimer*)listbox->select->handle)->disabled = 1; |
---|
1653 | |
---|
1654 | delmarkedscreennodes(recordtimer, 1); |
---|
1655 | goto start; |
---|
1656 | } |
---|
1657 | if(rcret == RCTIMEOUT) |
---|
1658 | { |
---|
1659 | delmarkedscreennodes(recordtimer, 1); |
---|
1660 | goto start; |
---|
1661 | } |
---|
1662 | } |
---|
1663 | } |
---|
1664 | |
---|
1665 | free(buf); buf = NULL; |
---|
1666 | delmarkedscreennodes(recordtimer, 1); |
---|
1667 | delownerrc(recordtimer); |
---|
1668 | clearscreen(recordtimer); |
---|
1669 | } |
---|
1670 | |
---|
1671 | int addrecepg(struct channel* chnode, struct epg* epgnode, char* channellist) |
---|
1672 | { |
---|
1673 | struct rectimer* node = NULL; |
---|
1674 | |
---|
1675 | deloldrectimer(); |
---|
1676 | |
---|
1677 | if(chnode == NULL || epgnode == NULL) |
---|
1678 | return 1; |
---|
1679 | |
---|
1680 | node = addrectimernode(NULL, NULL); |
---|
1681 | if(node != NULL) |
---|
1682 | { |
---|
1683 | node->name = ostrcat(epgnode->title, NULL, 0, 0); |
---|
1684 | node->begin = epgnode->starttime; |
---|
1685 | node->end = epgnode->endtime; |
---|
1686 | |
---|
1687 | node->repeate = 0; |
---|
1688 | |
---|
1689 | node->recpath = ostrcat(getconfig("rec_path", NULL), NULL, 0, 0); |
---|
1690 | node->servicetype = status.servicetype; |
---|
1691 | if(node->servicetype == 0) |
---|
1692 | { |
---|
1693 | if(channellist == NULL) |
---|
1694 | node->channellist = ostrcat(getconfig("channellist", NULL), NULL, 0, 0); |
---|
1695 | else |
---|
1696 | node->channellist = ostrcat(channellist, NULL, 0, 0); |
---|
1697 | } |
---|
1698 | else |
---|
1699 | { |
---|
1700 | if(channellist == NULL) |
---|
1701 | node->channellist = ostrcat(getconfig("rchannellist", NULL), NULL, 0, 0); |
---|
1702 | else |
---|
1703 | node->channellist = ostrcat(channellist, NULL, 0, 0); |
---|
1704 | } |
---|
1705 | node->serviceid = chnode->serviceid; |
---|
1706 | node->transponderid = chnode->transponderid; |
---|
1707 | screenrectimerext(node, 1); |
---|
1708 | } |
---|
1709 | |
---|
1710 | return 0; |
---|
1711 | } |
---|
1712 | |
---|
1713 | #endif |
---|