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 endtime shorter than aktual time"); |
---|
146 | return 1; |
---|
147 | } |
---|
148 | if(recnode->end <= recnode->begin) |
---|
149 | { |
---|
150 | *ret = _("Timer endtime shorter than 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\nWould you add the timer?"); |
---|
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 | printf("checkrectimer start\n"); |
---|
456 | |
---|
457 | if(self == NULL) return; |
---|
458 | |
---|
459 | //wait for right time |
---|
460 | while(self->aktion != STOP && time(NULL) < 1072224000) // 01.01.2004 |
---|
461 | usleep(1 * 1000000); |
---|
462 | |
---|
463 | //on first start read rectimer and set cec |
---|
464 | if(self->delay == 1000) |
---|
465 | { |
---|
466 | ret = 5; |
---|
467 | while(self->aktion != STOP && ret != 0) |
---|
468 | { |
---|
469 | usleep(1 * 1000000); |
---|
470 | ret = ret - 1; |
---|
471 | } |
---|
472 | ret = 0; |
---|
473 | readrectimer(getconfig("rectimerfile", NULL)); |
---|
474 | checkboxstart(); |
---|
475 | } |
---|
476 | |
---|
477 | //wait for start all programs |
---|
478 | ret = 30; |
---|
479 | while(self->aktion != STOP && ret != 0) |
---|
480 | { |
---|
481 | usleep(1 * 1000000); |
---|
482 | ret = ret - 1; |
---|
483 | } |
---|
484 | ret = 0; |
---|
485 | |
---|
486 | //on first start read rectimer |
---|
487 | if(self->delay == 1000) |
---|
488 | { |
---|
489 | self->delay = 10000; |
---|
490 | //readrectimer(getconfig("rectimerfile", NULL)); |
---|
491 | epgscancreatetimer(); |
---|
492 | //checkboxstart(); |
---|
493 | } |
---|
494 | |
---|
495 | m_lock(&status.rectimermutex, 1); |
---|
496 | t = time(NULL); |
---|
497 | node = rectimer; |
---|
498 | |
---|
499 | while(node != NULL) |
---|
500 | { |
---|
501 | if(node->disabled != 0) |
---|
502 | { |
---|
503 | node = node->next; |
---|
504 | continue; |
---|
505 | } |
---|
506 | |
---|
507 | if(node->justplay == 1) |
---|
508 | { |
---|
509 | begin = node->begin; |
---|
510 | end = node->end + 180; |
---|
511 | } |
---|
512 | else |
---|
513 | { |
---|
514 | begin = node->begin; |
---|
515 | end = node->end; |
---|
516 | } |
---|
517 | |
---|
518 | if(t >= begin && t < end && node->disabled == 0 && node->status == 0) |
---|
519 | { |
---|
520 | if(node->repeate != 0) |
---|
521 | { |
---|
522 | //copy repeate timer |
---|
523 | newnode = addrectimernode(NULL, NULL); |
---|
524 | if(newnode != NULL) |
---|
525 | { |
---|
526 | copyrectimer(node, newnode); |
---|
527 | recrepeatecalc(newnode); |
---|
528 | } |
---|
529 | node->repeate = 0; |
---|
530 | status.writerectimer = 1; |
---|
531 | } |
---|
532 | chnode = getchannel(node->serviceid, node->transponderid); |
---|
533 | if(node->justplay == 1) |
---|
534 | { |
---|
535 | //ret = servicestart(chnode, NULL, node->channellist, 0); |
---|
536 | ret = servicestart(chnode, node->channellist, NULL, 0); |
---|
537 | if(ret == 20 || ret == 22) ret = 0; |
---|
538 | } |
---|
539 | else |
---|
540 | { |
---|
541 | //workaround for standby recording |
---|
542 | char* cmd = NULL; |
---|
543 | cmd = ostrcat("ls -al ", getconfig("rec_path", NULL), 0, 0); |
---|
544 | // cmd = ostrcat(cmd, " >/dev/null", 1, 0); |
---|
545 | printf("cmd: %s\n", cmd); |
---|
546 | system(cmd); |
---|
547 | free(cmd), cmd = NULL; |
---|
548 | sleep(1); |
---|
549 | cmd = NULL; |
---|
550 | cmd = ostrcat("ls -al ", getconfig("rec_path", NULL), 0, 0); |
---|
551 | // cmd = ostrcat(cmd, " >/dev/null", 1, 0); |
---|
552 | printf("cmd: %s\n", cmd); |
---|
553 | system(cmd); |
---|
554 | free(cmd), cmd = NULL; |
---|
555 | |
---|
556 | // workaround end |
---|
557 | ret = recordstart(chnode, -1, 0, RECTIMER, node->end, node); |
---|
558 | if(ret == 14) ret = 0; |
---|
559 | } |
---|
560 | |
---|
561 | if(ret != 0) |
---|
562 | { |
---|
563 | node->status = 3; |
---|
564 | status.writerectimer = 1; |
---|
565 | break; |
---|
566 | } |
---|
567 | else |
---|
568 | { |
---|
569 | if(node->justplay == 1) |
---|
570 | node->status = 2; |
---|
571 | else |
---|
572 | node->status = 1; |
---|
573 | status.writerectimer = 1; |
---|
574 | } |
---|
575 | } |
---|
576 | if(t > node->end && (node->status == 0 || node->status == 4) && node->end != 0) |
---|
577 | { |
---|
578 | if(node->status == 4) |
---|
579 | node->status = 5; |
---|
580 | else |
---|
581 | node->status = 3; |
---|
582 | free(node->errstr); |
---|
583 | node->errstr = ostrcat(_("not started akttime higher than timer endtime"), NULL, 0, 0); |
---|
584 | status.writerectimer = 1; |
---|
585 | } |
---|
586 | //for epgscan |
---|
587 | if(t >= begin && t < end && node->disabled == 0 && node->status == 4) |
---|
588 | { |
---|
589 | node->status = 5; |
---|
590 | status.writerectimer = 1; |
---|
591 | |
---|
592 | if(status.standby == 0) |
---|
593 | { |
---|
594 | int tret = textbox(_("Message"), _("EPG Scan activate standby?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 20, 0); |
---|
595 | |
---|
596 | if(tret == 0 || tret == 1) |
---|
597 | { |
---|
598 | status.standby = 2; |
---|
599 | addtimer(&screenstandby, START, 1000, 1, NULL, NULL, NULL); |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | node = node->next; |
---|
604 | } |
---|
605 | |
---|
606 | m_unlock(&status.rectimermutex, 1); |
---|
607 | |
---|
608 | if(node != NULL && node->disabled == 0 && node->status < 4) |
---|
609 | { |
---|
610 | if(node->justplay == 1) |
---|
611 | { |
---|
612 | char* retstr = servicecheckret(ret, 1); |
---|
613 | free(node->errstr); |
---|
614 | node->errstr = ostrcat(retstr, NULL, 0, 0); |
---|
615 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
616 | free(retstr); retstr = NULL; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | char* retstr = recordcheckret(NULL, ret, 15); |
---|
621 | free(node->errstr); |
---|
622 | node->errstr = ostrcat(retstr, NULL, 0, 0); |
---|
623 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
624 | free(retstr); retstr = NULL; |
---|
625 | } |
---|
626 | status.writerectimer = 1; |
---|
627 | } |
---|
628 | |
---|
629 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
630 | } |
---|
631 | |
---|
632 | int addrectimer(char *buf) |
---|
633 | { |
---|
634 | struct rectimer* node = NULL; |
---|
635 | char* buf1 = buf; |
---|
636 | char* line = NULL; |
---|
637 | |
---|
638 | line = malloc(MINMALLOC); |
---|
639 | if(line == NULL) |
---|
640 | { |
---|
641 | err("no memory"); |
---|
642 | return 1; |
---|
643 | } |
---|
644 | |
---|
645 | while(*buf != '\0') |
---|
646 | { |
---|
647 | buf++; |
---|
648 | if(*buf == '\n' || *buf == '\0') |
---|
649 | { |
---|
650 | if(*buf == '\n') |
---|
651 | { |
---|
652 | buf++; |
---|
653 | snprintf(line, buf - buf1, "%s", buf1); |
---|
654 | } |
---|
655 | else |
---|
656 | snprintf(line, buf - buf1 + 1, "%s", buf1); |
---|
657 | buf1 = buf; |
---|
658 | |
---|
659 | if(ostrstr(line, "<timer ") != NULL || ostrstr(line, "<log ") != NULL || ostrstr(line, "<epgscan ") != NULL) |
---|
660 | node = addrectimernode(line, node); |
---|
661 | } |
---|
662 | } |
---|
663 | free(line); |
---|
664 | return 0; |
---|
665 | } |
---|
666 | |
---|
667 | int readrectimer(char *filename) |
---|
668 | { |
---|
669 | char *buf = NULL; |
---|
670 | |
---|
671 | buf = readfiletomem(filename, 1); |
---|
672 | |
---|
673 | if(buf != NULL) |
---|
674 | { |
---|
675 | addrectimer(buf); |
---|
676 | //timers can change on load, so we save it |
---|
677 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
678 | free(buf); |
---|
679 | } |
---|
680 | return 0; |
---|
681 | } |
---|
682 | |
---|
683 | //flag 0 = set mutex |
---|
684 | //flag 1 = don't set mutex |
---|
685 | void delrectimer(struct rectimer* rectimernode, int write, int flag) |
---|
686 | { |
---|
687 | if(flag == 0) m_lock(&status.rectimermutex, 1); |
---|
688 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
689 | |
---|
690 | while(node != NULL) |
---|
691 | { |
---|
692 | if(node == rectimernode) |
---|
693 | { |
---|
694 | status.writerectimer = 1; |
---|
695 | |
---|
696 | //record is aktiv (del from stopservice) |
---|
697 | if(node->servicenode != NULL) |
---|
698 | { |
---|
699 | node->status = 2; |
---|
700 | free(node->errstr); |
---|
701 | node->errstr = ostrcat(_("stopped from user"), NULL, 0, 0); |
---|
702 | //stop recording |
---|
703 | node->servicenode->recendtime = 2; |
---|
704 | if(flag == 0) |
---|
705 | m_unlock(&status.rectimermutex, 1); |
---|
706 | return; |
---|
707 | } |
---|
708 | |
---|
709 | if(node == rectimer) |
---|
710 | { |
---|
711 | rectimer = node->next; |
---|
712 | if(rectimer != NULL) |
---|
713 | rectimer->prev = NULL; |
---|
714 | } |
---|
715 | else |
---|
716 | { |
---|
717 | prev->next = node->next; |
---|
718 | if(node->next != NULL) |
---|
719 | node->next->prev = prev; |
---|
720 | } |
---|
721 | |
---|
722 | free(node->name); |
---|
723 | node->name = NULL; |
---|
724 | |
---|
725 | free(node->timestamp); |
---|
726 | node->timestamp = NULL; |
---|
727 | |
---|
728 | free(node->recpath); |
---|
729 | node->recpath = NULL; |
---|
730 | |
---|
731 | free(node->channellist); |
---|
732 | node->channellist = NULL; |
---|
733 | |
---|
734 | free(node->errstr); |
---|
735 | node->errstr = NULL; |
---|
736 | |
---|
737 | free(node->pincode); |
---|
738 | node->pincode = NULL; |
---|
739 | |
---|
740 | free(node); |
---|
741 | node = NULL; |
---|
742 | break; |
---|
743 | } |
---|
744 | |
---|
745 | prev = node; |
---|
746 | node = node->next; |
---|
747 | } |
---|
748 | |
---|
749 | if(write == 1) |
---|
750 | writerectimer(getconfig("rectimerfile", NULL), 1); |
---|
751 | |
---|
752 | if(flag == 0) |
---|
753 | m_unlock(&status.rectimermutex, 1); |
---|
754 | } |
---|
755 | |
---|
756 | void deloldrectimer() |
---|
757 | { |
---|
758 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
759 | |
---|
760 | while(node != NULL) |
---|
761 | { |
---|
762 | prev = node; |
---|
763 | node = node->next; |
---|
764 | if(prev != NULL && checkrectimertime(prev) == 1) |
---|
765 | delrectimer(prev, 1, 0); |
---|
766 | } |
---|
767 | } |
---|
768 | |
---|
769 | void freerectimer() |
---|
770 | { |
---|
771 | struct rectimer *node = rectimer, *prev = rectimer; |
---|
772 | |
---|
773 | while(node != NULL) |
---|
774 | { |
---|
775 | prev = node; |
---|
776 | node = node->next; |
---|
777 | if(prev != NULL) |
---|
778 | delrectimer(prev, 0, 0); |
---|
779 | } |
---|
780 | } |
---|
781 | |
---|
782 | //flag 0: lock |
---|
783 | //flag 1: don't lock |
---|
784 | int writerectimer(const char *filename, int flag) |
---|
785 | { |
---|
786 | FILE *fd = NULL; |
---|
787 | struct rectimer *node = NULL; |
---|
788 | int ret = 0; |
---|
789 | char* type = NULL; |
---|
790 | time_t curtime = time(NULL), rectime = 0x7FFFFFFF; |
---|
791 | |
---|
792 | if(status.writerectimer == 0) return 0; |
---|
793 | |
---|
794 | //check if rectimer loadet |
---|
795 | if(status.rectimerthread == NULL || (status.rectimerthread != NULL && status.rectimerthread->delay == 1000)) |
---|
796 | { |
---|
797 | err("can't write rectimer, not loaded yet"); |
---|
798 | return 1; |
---|
799 | } |
---|
800 | |
---|
801 | if(flag == 0) m_lock(&status.rectimermutex, 1); |
---|
802 | sortrectimer(); |
---|
803 | node = rectimer; |
---|
804 | |
---|
805 | fd = fopen(filename, "w"); |
---|
806 | if(fd == NULL) |
---|
807 | { |
---|
808 | if(flag == 0) m_unlock(&status.rectimermutex, 1); |
---|
809 | status.writerectimer = 0; |
---|
810 | perr("can't open %s", filename); |
---|
811 | return 1; |
---|
812 | } |
---|
813 | |
---|
814 | while(node != NULL) |
---|
815 | { |
---|
816 | //don't write for del marked or old timers |
---|
817 | if(checkrectimertime(node) == 1) |
---|
818 | { |
---|
819 | node = node->next; |
---|
820 | continue; |
---|
821 | } |
---|
822 | |
---|
823 | if(node->name == NULL) node->name = ostrcat(node->name, NULL, 1, 0); |
---|
824 | if(node->channellist == NULL) node->channellist = ostrcat(node->channellist, NULL, 1, 0); |
---|
825 | if(node->errstr == NULL) node->errstr = ostrcat(node->errstr, NULL, 1, 0); |
---|
826 | if(node->pincode == NULL) node->pincode = ostrcat(node->pincode, "0000", 1, 0); |
---|
827 | if(node->recpath == NULL) node->recpath = ostrcat(node->recpath, NULL, 1, 0); |
---|
828 | if(node->status == 0 || node->status == 1) |
---|
829 | type = "timer"; |
---|
830 | else if(node->status == 4 || node->status == 5) |
---|
831 | type = "epgscan"; |
---|
832 | else |
---|
833 | type = "log"; |
---|
834 | |
---|
835 | 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); |
---|
836 | |
---|
837 | if(ret < 0) |
---|
838 | { |
---|
839 | perr("writting file %s", filename); |
---|
840 | } |
---|
841 | |
---|
842 | //get wakeup time |
---|
843 | if(node->status == 0 || node->status == 1 || node->status == 4) |
---|
844 | { |
---|
845 | if(node->begin < rectime && node->begin > curtime) |
---|
846 | rectime = node->begin; |
---|
847 | } |
---|
848 | node = node->next; |
---|
849 | } |
---|
850 | |
---|
851 | fclose(fd); |
---|
852 | //write wakeup time to proc |
---|
853 | setwakeuptimerdev(rectime); |
---|
854 | debugrectimer(); |
---|
855 | |
---|
856 | if(flag == 0) m_unlock(&status.rectimermutex, 1); |
---|
857 | |
---|
858 | status.writerectimer = 0; |
---|
859 | return 0; |
---|
860 | } |
---|
861 | |
---|
862 | 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) |
---|
863 | { |
---|
864 | unsigned char ret = 0; |
---|
865 | int aktday = rectimergetaktday(); |
---|
866 | |
---|
867 | if(repeate == NULL) return 0; |
---|
868 | if(repeatetype == NULL) return 0; |
---|
869 | |
---|
870 | if(ostrcmp(repeate->ret, "0") == 0) return 0; |
---|
871 | |
---|
872 | if(ostrcmp(repeatetype->ret, "0") == 0) return 127; |
---|
873 | if(ostrcmp(repeatetype->ret, "1") == 0) |
---|
874 | { |
---|
875 | if(day->ret == NULL) return aktday; |
---|
876 | if(ostrcmp(day->ret, "0") == 0) |
---|
877 | { |
---|
878 | if(newnode == 1) |
---|
879 | return aktday; |
---|
880 | else |
---|
881 | return 1; |
---|
882 | } |
---|
883 | if(ostrcmp(day->ret, "1") == 0) return 2; |
---|
884 | if(ostrcmp(day->ret, "2") == 0) return 4; |
---|
885 | if(ostrcmp(day->ret, "3") == 0) return 8; |
---|
886 | if(ostrcmp(day->ret, "4") == 0) return 16; |
---|
887 | if(ostrcmp(day->ret, "5") == 0) return 32; |
---|
888 | if(ostrcmp(day->ret, "6") == 0) return 64; |
---|
889 | } |
---|
890 | if(ostrcmp(repeatetype->ret, "2") == 0) return 31; |
---|
891 | if(ostrcmp(repeatetype->ret, "3") == 0) |
---|
892 | { |
---|
893 | if(mon == NULL || tue == NULL || wed == NULL || thur == NULL || fri == NULL || sat == NULL || sun == NULL) return aktday; |
---|
894 | if(ostrcmp(mon->ret, "1") == 0) ret = setbit(ret, 0); |
---|
895 | if(ostrcmp(tue->ret, "1") == 0) ret = setbit(ret, 1); |
---|
896 | if(ostrcmp(wed->ret, "1") == 0) ret = setbit(ret, 2); |
---|
897 | if(ostrcmp(thur->ret, "1") == 0) ret = setbit(ret, 3); |
---|
898 | if(ostrcmp(fri->ret, "1") == 0) ret = setbit(ret, 4); |
---|
899 | if(ostrcmp(sat->ret, "1") == 0) ret = setbit(ret, 5); |
---|
900 | if(ostrcmp(sun->ret, "1") == 0) ret = setbit(ret, 6); |
---|
901 | if(ret == 0) ret = aktday; |
---|
902 | return ret; |
---|
903 | } |
---|
904 | |
---|
905 | return 127; |
---|
906 | } |
---|
907 | |
---|
908 | void recjustplayhidden(int justplay, struct skin* end, struct skin* path, struct skin* after) |
---|
909 | { |
---|
910 | if(justplay == 0) |
---|
911 | { |
---|
912 | end->hidden = NO; |
---|
913 | path->hidden = NO; |
---|
914 | after->hidden = NO; |
---|
915 | } |
---|
916 | else |
---|
917 | { |
---|
918 | end->hidden = YES; |
---|
919 | path->hidden = YES; |
---|
920 | after->hidden = YES; |
---|
921 | } |
---|
922 | } |
---|
923 | |
---|
924 | int rectimergetaktday() |
---|
925 | { |
---|
926 | int ret = 1; |
---|
927 | struct tm* loctime = NULL; |
---|
928 | |
---|
929 | time_t akttime = time(NULL); |
---|
930 | loctime = olocaltime(&akttime); |
---|
931 | if(loctime != NULL) |
---|
932 | { |
---|
933 | if(loctime->tm_wday == 0) ret = 64; |
---|
934 | if(loctime->tm_wday == 1) ret = 1; |
---|
935 | if(loctime->tm_wday == 2) ret = 2; |
---|
936 | if(loctime->tm_wday == 3) ret = 4; |
---|
937 | if(loctime->tm_wday == 4) ret = 8; |
---|
938 | if(loctime->tm_wday == 5) ret = 16; |
---|
939 | if(loctime->tm_wday == 6) ret = 32; |
---|
940 | } |
---|
941 | free(loctime); loctime = NULL; |
---|
942 | |
---|
943 | return ret; |
---|
944 | } |
---|
945 | |
---|
946 | 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) |
---|
947 | { |
---|
948 | repeatetype->hidden = YES; |
---|
949 | day->hidden = YES; |
---|
950 | mon->hidden = YES; |
---|
951 | tue->hidden = YES; |
---|
952 | wed->hidden = YES; |
---|
953 | thur->hidden = YES; |
---|
954 | fri->hidden = YES; |
---|
955 | sat->hidden = YES; |
---|
956 | sun->hidden = YES; |
---|
957 | |
---|
958 | if(repeate == 0) return; |
---|
959 | |
---|
960 | if(repeate == 127 && ostrcmp(repeatetype->ret, "3") != 0) //dayly |
---|
961 | { |
---|
962 | repeatetype->hidden = NO; |
---|
963 | setchoiceboxselection(repeatetype, "0"); |
---|
964 | return; |
---|
965 | } |
---|
966 | if(repeate == 31 && ostrcmp(repeatetype->ret, "3") != 0) //workday |
---|
967 | { |
---|
968 | repeatetype->hidden = NO; |
---|
969 | setchoiceboxselection(repeatetype, "2"); |
---|
970 | return; |
---|
971 | } |
---|
972 | if((repeate == 1 || repeate == 2 || repeate == 4 || repeate == 8 || repeate == 16 || repeate == 32 || repeate == 64) && ostrcmp(repeatetype->ret, "3") != 0) //weekly |
---|
973 | { |
---|
974 | repeatetype->hidden = NO; |
---|
975 | setchoiceboxselection(repeatetype, "1"); |
---|
976 | day->hidden = NO; |
---|
977 | if(repeate == 1) setchoiceboxselection(day, "0"); |
---|
978 | else if(repeate == 2) setchoiceboxselection(day, "1"); |
---|
979 | else if(repeate == 4) setchoiceboxselection(day, "2"); |
---|
980 | else if(repeate == 8) setchoiceboxselection(day, "3"); |
---|
981 | else if(repeate == 16) setchoiceboxselection(day, "4"); |
---|
982 | else if(repeate == 32) setchoiceboxselection(day, "5"); |
---|
983 | else if(repeate == 64) setchoiceboxselection(day, "6"); |
---|
984 | return; |
---|
985 | } |
---|
986 | |
---|
987 | //user defined |
---|
988 | repeatetype->hidden = NO; |
---|
989 | setchoiceboxselection(repeatetype, "3"); |
---|
990 | mon->hidden = NO; |
---|
991 | tue->hidden = NO; |
---|
992 | wed->hidden = NO; |
---|
993 | thur->hidden = NO; |
---|
994 | fri->hidden = NO; |
---|
995 | sat->hidden = NO; |
---|
996 | sun->hidden = NO; |
---|
997 | if(checkbit(repeate, 0) == 1) setchoiceboxselection(mon, "1"); |
---|
998 | if(checkbit(repeate, 1) == 1) setchoiceboxselection(tue, "1"); |
---|
999 | if(checkbit(repeate, 2) == 1) setchoiceboxselection(wed, "1"); |
---|
1000 | if(checkbit(repeate, 3) == 1) setchoiceboxselection(thur, "1"); |
---|
1001 | if(checkbit(repeate, 4) == 1) setchoiceboxselection(fri, "1"); |
---|
1002 | if(checkbit(repeate, 5) == 1) setchoiceboxselection(sat, "1"); |
---|
1003 | if(checkbit(repeate, 6) == 1) setchoiceboxselection(sun, "1"); |
---|
1004 | } |
---|
1005 | |
---|
1006 | //flag 0: called from menu (manuel timer) |
---|
1007 | //flag 1: call from epg timer |
---|
1008 | void screenrectimerext(struct rectimer* node, int flag) |
---|
1009 | { |
---|
1010 | int ret = 0, rcret = 0, edaylight = 0, bdaylight = 0, newnode = 0, tmpservicetype = 0, tmprepeate = 0; |
---|
1011 | struct skin* rectimerext = getscreen("rectimerext"); |
---|
1012 | struct skin* listbox = getscreennode(rectimerext, "listbox"); |
---|
1013 | struct skin* name = getscreennode(rectimerext, "name"); |
---|
1014 | struct skin* justplay = getscreennode(rectimerext, "justplay"); |
---|
1015 | struct skin* repeate = getscreennode(rectimerext, "repeate"); |
---|
1016 | struct skin* repeatetype = getscreennode(rectimerext, "repeatetype"); |
---|
1017 | struct skin* day = getscreennode(rectimerext, "day"); |
---|
1018 | struct skin* mon = getscreennode(rectimerext, "mon"); |
---|
1019 | struct skin* tue = getscreennode(rectimerext, "tue"); |
---|
1020 | struct skin* wed = getscreennode(rectimerext, "wed"); |
---|
1021 | struct skin* thur = getscreennode(rectimerext, "thur"); |
---|
1022 | struct skin* fri = getscreennode(rectimerext, "fri"); |
---|
1023 | struct skin* sat = getscreennode(rectimerext, "sat"); |
---|
1024 | struct skin* sun = getscreennode(rectimerext, "sun"); |
---|
1025 | struct skin* begin = getscreennode(rectimerext, "begin"); |
---|
1026 | struct skin* end = getscreennode(rectimerext, "end"); |
---|
1027 | struct skin* recchannel = getscreennode(rectimerext, "channel"); |
---|
1028 | struct skin* path = getscreennode(rectimerext, "path"); |
---|
1029 | struct skin* after = getscreennode(rectimerext, "after"); |
---|
1030 | struct skin* pincode = getscreennode(rectimerext, "pincode"); |
---|
1031 | struct skin* tmp = NULL; |
---|
1032 | char* tmpstr = NULL, *buf = NULL, *buf1 = NULL, *tmpchannellist = NULL; |
---|
1033 | struct tm* loctime = NULL; |
---|
1034 | time_t akttime = time(NULL); |
---|
1035 | |
---|
1036 | if(node == NULL) |
---|
1037 | { |
---|
1038 | newnode = 1; |
---|
1039 | node = addrectimernode(NULL, NULL); |
---|
1040 | tmpservicetype = status.servicetype; |
---|
1041 | if(tmpservicetype == 0) |
---|
1042 | tmpchannellist = ostrcat(getconfig("channellist", NULL), NULL, 0, 0); |
---|
1043 | else |
---|
1044 | tmpchannellist = ostrcat(getconfig("rchannellist", NULL), NULL, 0, 0); |
---|
1045 | } |
---|
1046 | else |
---|
1047 | { |
---|
1048 | tmpservicetype = node->servicetype; |
---|
1049 | tmpchannellist = ostrcat(node->channellist, NULL, 0, 0); |
---|
1050 | } |
---|
1051 | |
---|
1052 | if(node == NULL) |
---|
1053 | { |
---|
1054 | err("NULL detect"); |
---|
1055 | return; |
---|
1056 | } |
---|
1057 | |
---|
1058 | listbox->aktline = 1; |
---|
1059 | listbox->aktpage = -1; |
---|
1060 | begin->aktpage = 0; |
---|
1061 | end->aktpage = 0; |
---|
1062 | name->aktpage = 0; |
---|
1063 | |
---|
1064 | changeinput(name, node->name); |
---|
1065 | |
---|
1066 | addchoicebox(justplay, "0", _("record")); |
---|
1067 | addchoicebox(justplay, "1", _("switch channel")); |
---|
1068 | if(newnode == 0) |
---|
1069 | { |
---|
1070 | tmpstr = oitoa(node->justplay); |
---|
1071 | setchoiceboxselection(justplay, tmpstr); |
---|
1072 | free(tmpstr); tmpstr = NULL; |
---|
1073 | } |
---|
1074 | else |
---|
1075 | setchoiceboxselection(justplay, "0"); |
---|
1076 | |
---|
1077 | addchoicebox(repeate, "0", _("once")); |
---|
1078 | addchoicebox(repeate, "1", _("repeate")); |
---|
1079 | if(newnode == 0) |
---|
1080 | { |
---|
1081 | tmprepeate = node->repeate; |
---|
1082 | if(node->repeate == 0) |
---|
1083 | setchoiceboxselection(repeate, "0"); |
---|
1084 | else |
---|
1085 | setchoiceboxselection(repeate, "1"); |
---|
1086 | } |
---|
1087 | else |
---|
1088 | setchoiceboxselection(repeate, "0"); |
---|
1089 | |
---|
1090 | addchoicebox(repeatetype, "0", _("daily")); |
---|
1091 | addchoicebox(repeatetype, "1", _("weekly")); |
---|
1092 | addchoicebox(repeatetype, "2", _("workdays")); |
---|
1093 | addchoicebox(repeatetype, "3", _("user defined")); |
---|
1094 | changeret(repeatetype, NULL); |
---|
1095 | setchoiceboxselection(repeatetype, "0"); |
---|
1096 | |
---|
1097 | addchoicebox(day, "0", _("Monday")); |
---|
1098 | addchoicebox(day, "1", _("Tuesday")); |
---|
1099 | addchoicebox(day, "2", _("Wednesday")); |
---|
1100 | addchoicebox(day, "3", _("Thursday")); |
---|
1101 | addchoicebox(day, "4", _("Friday")); |
---|
1102 | addchoicebox(day, "5", _("Saturday")); |
---|
1103 | addchoicebox(day, "6", _("Sunday")); |
---|
1104 | changeret(day, NULL); |
---|
1105 | setchoiceboxselection(day, "0"); |
---|
1106 | |
---|
1107 | addchoicebox(mon, "0", _("no")); |
---|
1108 | addchoicebox(mon, "1", _("yes")); |
---|
1109 | changeret(mon, NULL); |
---|
1110 | setchoiceboxselection(mon, "0"); |
---|
1111 | |
---|
1112 | addchoicebox(tue, "0", _("no")); |
---|
1113 | addchoicebox(tue, "1", _("yes")); |
---|
1114 | changeret(tue, NULL); |
---|
1115 | setchoiceboxselection(tue, "0"); |
---|
1116 | |
---|
1117 | addchoicebox(wed, "0", _("no")); |
---|
1118 | addchoicebox(wed, "1", _("yes")); |
---|
1119 | changeret(wed, NULL); |
---|
1120 | setchoiceboxselection(wed, "0"); |
---|
1121 | |
---|
1122 | addchoicebox(thur, "0", _("no")); |
---|
1123 | addchoicebox(thur, "1", _("yes")); |
---|
1124 | changeret(thur, NULL); |
---|
1125 | setchoiceboxselection(thur, "0"); |
---|
1126 | |
---|
1127 | addchoicebox(fri, "0", _("no")); |
---|
1128 | addchoicebox(fri, "1", _("yes")); |
---|
1129 | changeret(fri, NULL); |
---|
1130 | setchoiceboxselection(fri, "0"); |
---|
1131 | |
---|
1132 | addchoicebox(sat, "0", _("no")); |
---|
1133 | addchoicebox(sat, "1", _("yes")); |
---|
1134 | changeret(sat, NULL); |
---|
1135 | setchoiceboxselection(sat, "0"); |
---|
1136 | |
---|
1137 | addchoicebox(sun, "0", _("no")); |
---|
1138 | addchoicebox(sun, "1", _("yes")); |
---|
1139 | changeret(sun, NULL); |
---|
1140 | setchoiceboxselection(sun, "0"); |
---|
1141 | |
---|
1142 | recrepeatehidden(node->repeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1143 | recjustplayhidden(node->justplay, end, path, after); |
---|
1144 | |
---|
1145 | buf = malloc(MINMALLOC); |
---|
1146 | if(buf == NULL) |
---|
1147 | { |
---|
1148 | err("no memory"); |
---|
1149 | return; |
---|
1150 | } |
---|
1151 | |
---|
1152 | changemask(begin, "00:00 00-00-0000"); |
---|
1153 | if(newnode == 0) |
---|
1154 | loctime = localtime(&node->begin); |
---|
1155 | else |
---|
1156 | loctime = localtime(&akttime); |
---|
1157 | bdaylight = loctime->tm_isdst; |
---|
1158 | strftime(buf, MINMALLOC, "%H:%M %d-%m-%Y", loctime); |
---|
1159 | buf1 = ostrcat(buf, NULL, 0, 0); |
---|
1160 | changeinput(begin, buf1); |
---|
1161 | free(buf1); buf1 = NULL; |
---|
1162 | |
---|
1163 | changemask(end, "00:00 00-00-0000"); |
---|
1164 | if(newnode == 0) |
---|
1165 | loctime = localtime(&node->end); |
---|
1166 | else |
---|
1167 | { |
---|
1168 | akttime += 300; |
---|
1169 | loctime = localtime(&akttime); |
---|
1170 | } |
---|
1171 | edaylight = loctime->tm_isdst; |
---|
1172 | strftime(buf, MINMALLOC, "%H:%M %d-%m-%Y", loctime); |
---|
1173 | buf1 = ostrcat(buf, NULL, 1, 0); |
---|
1174 | changeinput(end, buf1); |
---|
1175 | free(buf1); buf1 = NULL; |
---|
1176 | |
---|
1177 | if(flag == 1) |
---|
1178 | recchannel->hidden = YES; |
---|
1179 | else |
---|
1180 | recchannel->hidden = NO; |
---|
1181 | |
---|
1182 | changeinput(recchannel, NULL); |
---|
1183 | if(newnode == 0) |
---|
1184 | { |
---|
1185 | recchannel->handle = (char*)getchannel(node->serviceid, node->transponderid); |
---|
1186 | if(recchannel->handle != NULL) |
---|
1187 | addchoicebox(recchannel, ((struct channel*)recchannel->handle)->name, ((struct channel*)recchannel->handle)->name); |
---|
1188 | } |
---|
1189 | else |
---|
1190 | { |
---|
1191 | if(status.aktservice->channel != NULL) |
---|
1192 | { |
---|
1193 | addchoicebox(recchannel, status.aktservice->channel->name, status.aktservice->channel->name); |
---|
1194 | recchannel->handle = (char*)status.aktservice->channel; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | |
---|
1198 | if(newnode == 0) |
---|
1199 | changeinput(path, node->recpath); |
---|
1200 | else |
---|
1201 | changeinput(path, getconfig("rec_path", NULL)); |
---|
1202 | |
---|
1203 | addchoicebox(after, "0", _("auto")); |
---|
1204 | addchoicebox(after, "1", _("nothing")); |
---|
1205 | addchoicebox(after, "2", _("standby")); |
---|
1206 | addchoicebox(after, "3", _("power off")); |
---|
1207 | if(newnode == 0) |
---|
1208 | { |
---|
1209 | tmpstr = oitoa(node->afterevent); |
---|
1210 | setchoiceboxselection(after, tmpstr); |
---|
1211 | free(tmpstr); tmpstr = NULL; |
---|
1212 | } |
---|
1213 | |
---|
1214 | changemask(pincode, "0000"); |
---|
1215 | if(newnode == 0) |
---|
1216 | changeinput(pincode, node->pincode); |
---|
1217 | else |
---|
1218 | changeinput(pincode, "0000"); |
---|
1219 | |
---|
1220 | drawscreen(rectimerext, 0, 0); |
---|
1221 | addscreenrc(rectimerext, listbox); |
---|
1222 | |
---|
1223 | tmp = listbox->select; |
---|
1224 | while(1) |
---|
1225 | { |
---|
1226 | addscreenrc(rectimerext, tmp); |
---|
1227 | rcret = waitrc(rectimerext, 0, 2); |
---|
1228 | tmp = listbox->select; |
---|
1229 | |
---|
1230 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
1231 | { |
---|
1232 | if(name->ret != NULL && strlen(name->ret) > 0) |
---|
1233 | { |
---|
1234 | char* tmppath = NULL; |
---|
1235 | |
---|
1236 | tmppath = ostrcat(tmppath, name->ret, 1, 0); |
---|
1237 | tmppath = strstrip(tmppath); |
---|
1238 | delspezchar(tmppath, 2); |
---|
1239 | tmppath = ostrcat("/", tmppath, 0, 1); |
---|
1240 | tmppath = ostrcat(getconfig("rec_path", NULL), tmppath, 0, 1); |
---|
1241 | |
---|
1242 | if(tmppath != NULL && mkdir(tmppath, 0777) == 0) |
---|
1243 | { |
---|
1244 | changeinput(path, tmppath); |
---|
1245 | changetext(path, tmppath); |
---|
1246 | } |
---|
1247 | else |
---|
1248 | textbox(_("Message"), "Can't create Path", _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1249 | |
---|
1250 | drawscreen(rectimerext, 0, 0); |
---|
1251 | free(tmppath); tmppath = NULL; |
---|
1252 | } |
---|
1253 | continue; |
---|
1254 | } |
---|
1255 | |
---|
1256 | if(listbox->select != NULL && listbox->select->ret != NULL && ostrcmp(listbox->select->name, "justplay") == 0) |
---|
1257 | { |
---|
1258 | recjustplayhidden(atoi(listbox->select->ret), end, path, after); |
---|
1259 | } |
---|
1260 | |
---|
1261 | tmprepeate = recrepeateget(newnode, repeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1262 | if(listbox->select != NULL && (ostrcmp(listbox->select->name, "repeate") == 0 || ostrcmp(listbox->select->name, "repeatetype") == 0)) |
---|
1263 | { |
---|
1264 | recrepeatehidden(tmprepeate, repeatetype, day, mon, tue, wed, thur, fri, sat, sun); |
---|
1265 | } |
---|
1266 | drawscreen(rectimerext, 0, 0); |
---|
1267 | |
---|
1268 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
1269 | { |
---|
1270 | if(newnode == 1 || flag == 1) delrectimer(node, 1, 0); |
---|
1271 | break; |
---|
1272 | } |
---|
1273 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
1274 | { |
---|
1275 | if(listbox->select != NULL && ostrcmp(listbox->select->name, "path") == 0) |
---|
1276 | { |
---|
1277 | clearscreen(rectimerext); |
---|
1278 | tmpstr = screendir(listbox->select->ret, "", NULL, NULL, NULL, NULL, 0, "SELECT", 0, NULL, 0, NULL, 0, 700, 0, 650, 0, 0); |
---|
1279 | if(tmpstr != NULL) |
---|
1280 | changeinput(listbox->select, tmpstr); |
---|
1281 | free(tmpstr); tmpstr = NULL; |
---|
1282 | |
---|
1283 | drawscreen(rectimerext, 0, 0); |
---|
1284 | continue; |
---|
1285 | } |
---|
1286 | if(listbox->select != NULL && ostrcmp(listbox->select->name, "channel") == 0) |
---|
1287 | { |
---|
1288 | clearscreen(rectimerext); |
---|
1289 | int saveservicetype = status.servicetype; |
---|
1290 | struct channel* tmpchnode = (struct channel*)recchannel->handle; |
---|
1291 | |
---|
1292 | status.servicetype = tmpservicetype; |
---|
1293 | if(tmpservicetype == 0) |
---|
1294 | { |
---|
1295 | addconfigtmp("channellist", tmpchannellist); |
---|
1296 | if(tmpchnode != NULL) |
---|
1297 | { |
---|
1298 | addconfiginttmp("serviceid", tmpchnode->serviceid); |
---|
1299 | addconfigllutmp("transponderid", tmpchnode->transponderid); |
---|
1300 | } |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | addconfigtmp("rchannellist", tmpchannellist); |
---|
1305 | if(tmpchnode != NULL) |
---|
1306 | { |
---|
1307 | addconfiginttmp("rserviceid", tmpchnode->serviceid); |
---|
1308 | addconfigllutmp("rtransponderid", tmpchnode->transponderid); |
---|
1309 | } |
---|
1310 | } |
---|
1311 | |
---|
1312 | screenchannellist(&tmpchnode, &tmpchannellist, 1); |
---|
1313 | |
---|
1314 | recchannel->handle = (char*)tmpchnode; |
---|
1315 | |
---|
1316 | status.servicetype = saveservicetype; |
---|
1317 | delconfigtmp("channellist"); |
---|
1318 | delconfigtmp("rchannellist"); |
---|
1319 | delconfigtmp("serviceid"); |
---|
1320 | delconfigtmp("rserviceid"); |
---|
1321 | delconfigtmp("transponderid"); |
---|
1322 | delconfigtmp("rtransponderid"); |
---|
1323 | |
---|
1324 | if((struct channel*)recchannel->handle != NULL) |
---|
1325 | { |
---|
1326 | changeinput(listbox->select, ((struct channel*)recchannel->handle)->name); |
---|
1327 | } |
---|
1328 | |
---|
1329 | drawscreen(rectimerext, 0, 0); |
---|
1330 | continue; |
---|
1331 | } |
---|
1332 | |
---|
1333 | free(node->name); node->name = NULL; |
---|
1334 | node->name = ostrcat(name->ret, NULL, 0, 0); |
---|
1335 | if(justplay->ret != NULL) |
---|
1336 | node->justplay = atoi(justplay->ret); |
---|
1337 | if(begin->ret != NULL) |
---|
1338 | { |
---|
1339 | loctime->tm_isdst = bdaylight; |
---|
1340 | tmpstr = strptime(begin->ret, "%H:%M %d-%m-%Y", loctime); |
---|
1341 | if(tmpstr != NULL) |
---|
1342 | node->begin = mktime(loctime); |
---|
1343 | |
---|
1344 | if((flag == 1 || newnode == 1) && node->justplay == 0) |
---|
1345 | node->begin -= getconfigint("recforerun", NULL) * 60; |
---|
1346 | |
---|
1347 | node->begin -= (node->begin % 60); |
---|
1348 | |
---|
1349 | if(node->justplay == 1) |
---|
1350 | node->end = node->begin + 1; |
---|
1351 | } |
---|
1352 | if(end->ret != NULL && node->justplay == 0) |
---|
1353 | { |
---|
1354 | loctime->tm_isdst = edaylight; |
---|
1355 | tmpstr = strptime(end->ret, "%H:%M %d-%m-%Y", loctime); |
---|
1356 | if(tmpstr != NULL) |
---|
1357 | node->end = mktime(loctime); |
---|
1358 | |
---|
1359 | if((flag == 1 || newnode == 1) && node->justplay == 0) |
---|
1360 | node->end += getconfigint("recoverrun", NULL) * 60; |
---|
1361 | node->end -= (node->end % 60); |
---|
1362 | } |
---|
1363 | if(after->ret != NULL) |
---|
1364 | node->afterevent = atoi(after->ret); |
---|
1365 | |
---|
1366 | if(pincode->ret != NULL) |
---|
1367 | node->pincode = ostrcat(pincode->ret, NULL, 0, 0); |
---|
1368 | else |
---|
1369 | node->pincode = ostrcat("0000", NULL, 0, 0); |
---|
1370 | |
---|
1371 | if(tmprepeate > 127) tmprepeate = 0; |
---|
1372 | node->repeate = tmprepeate; |
---|
1373 | |
---|
1374 | free(node->recpath); node->recpath = NULL; |
---|
1375 | node->recpath = ostrcat(path->ret, NULL, 0, 0); |
---|
1376 | |
---|
1377 | free(node->channellist); node->channellist = NULL; |
---|
1378 | node->channellist = tmpchannellist; |
---|
1379 | |
---|
1380 | node->servicetype = tmpservicetype; |
---|
1381 | |
---|
1382 | if(recchannel->handle != NULL) |
---|
1383 | { |
---|
1384 | node->serviceid = ((struct channel*)recchannel->handle)->serviceid; |
---|
1385 | node->transponderid = ((struct channel*)recchannel->handle)->transponderid; |
---|
1386 | } |
---|
1387 | |
---|
1388 | char* checkret = NULL; |
---|
1389 | ret = checkrectimeradd(node, &checkret); |
---|
1390 | if(ret != 0) |
---|
1391 | { |
---|
1392 | if(ret == 2) |
---|
1393 | { |
---|
1394 | ret = textbox(_("Message"), checkret, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1395 | if(ret == 2) |
---|
1396 | ret = 99; |
---|
1397 | else |
---|
1398 | ret = 0; |
---|
1399 | } |
---|
1400 | if(ret == 1 || ret == 99) |
---|
1401 | { |
---|
1402 | node->status = 3; |
---|
1403 | free(node->errstr); node->errstr = NULL; |
---|
1404 | node->errstr = ostrcat(checkret, NULL, 0, 0); |
---|
1405 | stringreplacecharonce(node->errstr, '\n', '\0'); |
---|
1406 | if(ret == 1) textbox(_("Message"), checkret, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
1407 | } |
---|
1408 | } |
---|
1409 | |
---|
1410 | //check if record is running and change endtime |
---|
1411 | m_lock(&status.servicemutex, 2); |
---|
1412 | struct service* tmpservice = getservicebyrectimestamp(node->timestamp, 1); |
---|
1413 | if(tmpservice != NULL) |
---|
1414 | tmpservice->recendtime = node->end; |
---|
1415 | m_unlock(&status.servicemutex, 2); |
---|
1416 | |
---|
1417 | if(newnode == 1 || flag == 1) node->disabled = 0; |
---|
1418 | status.writerectimer = 1; |
---|
1419 | writerectimer(getconfig("rectimerfile", NULL), 0); |
---|
1420 | break; |
---|
1421 | } |
---|
1422 | } |
---|
1423 | |
---|
1424 | if(flag == 1) resettvpic(); |
---|
1425 | |
---|
1426 | delownerrc(rectimerext); |
---|
1427 | clearscreen(rectimerext); |
---|
1428 | } |
---|
1429 | |
---|
1430 | //flag 0: show normal |
---|
1431 | //flag 1: show log |
---|
1432 | void screenrectimer() |
---|
1433 | { |
---|
1434 | int rcret = 0, flag = 0; |
---|
1435 | struct skin* recordtimer = getscreen("rectimer"); |
---|
1436 | struct skin* listbox = getscreennode(recordtimer, "listbox"); |
---|
1437 | struct skin* b1 = getscreennode(recordtimer, "b1"); |
---|
1438 | struct skin* b2 = getscreennode(recordtimer, "b2"); |
---|
1439 | struct skin* b3 = getscreennode(recordtimer, "b3"); |
---|
1440 | struct skin* b4 = getscreennode(recordtimer, "b4"); |
---|
1441 | struct skin* tmp = NULL; |
---|
1442 | struct rectimer* rectimernode = NULL; |
---|
1443 | struct tm *loctime = NULL; |
---|
1444 | struct channel* chnode = NULL; |
---|
1445 | char* buf = NULL, *tmpstr = NULL; |
---|
1446 | |
---|
1447 | buf = malloc(MINMALLOC); |
---|
1448 | if(buf == NULL) |
---|
1449 | { |
---|
1450 | err("no memory"); |
---|
1451 | return; |
---|
1452 | } |
---|
1453 | |
---|
1454 | start: |
---|
1455 | deloldrectimer(); |
---|
1456 | |
---|
1457 | tmp = NULL; |
---|
1458 | listbox->aktpage = -1; |
---|
1459 | listbox->select = NULL; |
---|
1460 | rectimernode = rectimer; |
---|
1461 | |
---|
1462 | while(rectimernode != NULL) |
---|
1463 | { |
---|
1464 | if((flag == 0 && (rectimernode->status == 2 || rectimernode->status == 3)) || (flag == 1 && (rectimernode->status == 0 || rectimernode->status == 1)) || rectimernode->status == 4 || rectimernode->status == 5) |
---|
1465 | { |
---|
1466 | rectimernode = rectimernode->next; |
---|
1467 | continue; |
---|
1468 | } |
---|
1469 | |
---|
1470 | tmp = addlistbox(recordtimer, listbox, tmp, 1); |
---|
1471 | if(tmp != NULL) |
---|
1472 | { |
---|
1473 | loctime = localtime(&rectimernode->begin); |
---|
1474 | strftime(buf, MINMALLOC, "%d-%m-%Y %H:%M", loctime); |
---|
1475 | tmpstr = ostrcat(tmpstr, buf, 1, 0); |
---|
1476 | if(rectimernode->justplay == 0) |
---|
1477 | { |
---|
1478 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1479 | loctime = localtime(&rectimernode->end); |
---|
1480 | strftime(buf, MINMALLOC, "%d-%m-%Y %H:%M", loctime); |
---|
1481 | tmpstr = ostrcat(tmpstr, buf, 1, 0); |
---|
1482 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1483 | tmpstr = ostrcat(tmpstr, _("rec"), 1, 0); |
---|
1484 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1485 | if(rectimernode->repeate == 0) |
---|
1486 | tmpstr = ostrcat(tmpstr, _("once"), 1, 0); |
---|
1487 | else |
---|
1488 | tmpstr = ostrcat(tmpstr, _("repeate"), 1, 0); |
---|
1489 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1490 | } |
---|
1491 | else |
---|
1492 | { |
---|
1493 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1494 | tmpstr = ostrcat(tmpstr, _("switch"), 1, 0); |
---|
1495 | tmpstr = ostrcat(tmpstr, " - ", 1, 0); |
---|
1496 | if(rectimernode->repeate == 0) |
---|
1497 | tmpstr = ostrcat(tmpstr, _("once"), 1, 0); |
---|
1498 | else |
---|
1499 | tmpstr = ostrcat(tmpstr, _("repeate"), 1, 0); |
---|
1500 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1501 | } |
---|
1502 | |
---|
1503 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
1504 | if(rectimernode->name != NULL) |
---|
1505 | { |
---|
1506 | if(rectimernode->name == NULL || strlen(rectimernode->name) == 0) |
---|
1507 | tmpstr = ostrcat(tmpstr, "---", 1, 0); |
---|
1508 | else |
---|
1509 | tmpstr = ostrcat(tmpstr, rectimernode->name, 1, 0); |
---|
1510 | } |
---|
1511 | chnode = getchannel(rectimernode->serviceid, rectimernode->transponderid); |
---|
1512 | if(chnode != NULL && chnode->name != NULL && strlen(chnode->name) > 0) |
---|
1513 | { |
---|
1514 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1515 | tmpstr = ostrcat(tmpstr, chnode->name, 1, 0); |
---|
1516 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1517 | } |
---|
1518 | |
---|
1519 | tmpstr = ostrcat(tmpstr, "\n", 1, 0); |
---|
1520 | if(rectimernode->status == 0) |
---|
1521 | tmpstr = ostrcat(tmpstr, _("waiting"), 1, 0); |
---|
1522 | else if(rectimernode->status == 1) |
---|
1523 | tmpstr = ostrcat(tmpstr, _("running"), 1, 0); |
---|
1524 | else if(rectimernode->status == 2) |
---|
1525 | tmpstr = ostrcat(tmpstr, _("success"), 1, 0); |
---|
1526 | else if(rectimernode->status == 3) |
---|
1527 | tmpstr = ostrcat(tmpstr, _("error"), 1, 0); |
---|
1528 | |
---|
1529 | if(flag == 1 && rectimernode->errstr != NULL && strlen(rectimernode->errstr) != 0) |
---|
1530 | { |
---|
1531 | tmpstr = ostrcat(tmpstr, " (", 1, 0); |
---|
1532 | tmpstr = ostrcat(tmpstr, rectimernode->errstr, 1, 0); |
---|
1533 | tmpstr = ostrcat(tmpstr, ")", 1, 0); |
---|
1534 | } |
---|
1535 | |
---|
1536 | changetext(tmp, tmpstr); |
---|
1537 | free(tmpstr); tmpstr = NULL; |
---|
1538 | tmp->handle = (char*)rectimernode; |
---|
1539 | tmp->height = 110; |
---|
1540 | tmp->type = TEXTBOX; |
---|
1541 | |
---|
1542 | if(rectimernode->disabled == 1) |
---|
1543 | tmp->fontcol = convertcol("deaktivcol"); |
---|
1544 | } |
---|
1545 | rectimernode = rectimernode->next; |
---|
1546 | } |
---|
1547 | |
---|
1548 | if(flag == 0) |
---|
1549 | { |
---|
1550 | b1->hidden = NO; |
---|
1551 | b2->hidden = NO; |
---|
1552 | b3->hidden = NO; |
---|
1553 | b4->hidden = NO; |
---|
1554 | } |
---|
1555 | else |
---|
1556 | { |
---|
1557 | b1->hidden = YES; |
---|
1558 | b2->hidden = YES; |
---|
1559 | b3->hidden = YES; |
---|
1560 | b4->hidden = YES; |
---|
1561 | } |
---|
1562 | |
---|
1563 | drawscreen(recordtimer, 0, 0); |
---|
1564 | addscreenrc(recordtimer, listbox); |
---|
1565 | |
---|
1566 | while(1) |
---|
1567 | { |
---|
1568 | rcret = waitrc(recordtimer, 5000, 0); |
---|
1569 | |
---|
1570 | if(flag == 0 && rcret == getrcconfigint("rcblue", NULL)) |
---|
1571 | { |
---|
1572 | flag = 1; |
---|
1573 | delmarkedscreennodes(recordtimer, 1); |
---|
1574 | goto start; |
---|
1575 | } |
---|
1576 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
1577 | { |
---|
1578 | if(flag == 0) |
---|
1579 | break; |
---|
1580 | else |
---|
1581 | { |
---|
1582 | flag = 0; |
---|
1583 | delmarkedscreennodes(recordtimer, 1); |
---|
1584 | goto start; |
---|
1585 | } |
---|
1586 | } |
---|
1587 | if(flag == 0 && rcret == getrcconfigint("rcgreen", NULL)) |
---|
1588 | { |
---|
1589 | clearscreen(recordtimer); |
---|
1590 | screenrectimerext(NULL, 0); |
---|
1591 | delmarkedscreennodes(recordtimer, 1); |
---|
1592 | goto start; |
---|
1593 | } |
---|
1594 | if(flag == 0 && listbox->select != NULL) |
---|
1595 | { |
---|
1596 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
1597 | { |
---|
1598 | clearscreen(recordtimer); |
---|
1599 | screenrectimerext((struct rectimer*)listbox->select->handle, 0); |
---|
1600 | delmarkedscreennodes(recordtimer, 1); |
---|
1601 | goto start; |
---|
1602 | } |
---|
1603 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
1604 | { |
---|
1605 | delrectimer((struct rectimer*)listbox->select->handle, 1, 0); |
---|
1606 | |
---|
1607 | delmarkedscreennodes(recordtimer, 1); |
---|
1608 | goto start; |
---|
1609 | } |
---|
1610 | if(rcret == getrcconfigint("rcyellow", NULL)) |
---|
1611 | { |
---|
1612 | if(((struct rectimer*)listbox->select->handle)->disabled == 1) |
---|
1613 | ((struct rectimer*)listbox->select->handle)->disabled = 0; |
---|
1614 | else |
---|
1615 | ((struct rectimer*)listbox->select->handle)->disabled = 1; |
---|
1616 | |
---|
1617 | delmarkedscreennodes(recordtimer, 1); |
---|
1618 | goto start; |
---|
1619 | } |
---|
1620 | if(rcret == RCTIMEOUT) |
---|
1621 | { |
---|
1622 | delmarkedscreennodes(recordtimer, 1); |
---|
1623 | goto start; |
---|
1624 | } |
---|
1625 | } |
---|
1626 | } |
---|
1627 | |
---|
1628 | free(buf); buf = NULL; |
---|
1629 | delmarkedscreennodes(recordtimer, 1); |
---|
1630 | delownerrc(recordtimer); |
---|
1631 | clearscreen(recordtimer); |
---|
1632 | } |
---|
1633 | |
---|
1634 | int addrecepg(struct channel* chnode, struct epg* epgnode, char* channellist) |
---|
1635 | { |
---|
1636 | struct rectimer* node = NULL; |
---|
1637 | |
---|
1638 | deloldrectimer(); |
---|
1639 | |
---|
1640 | if(chnode == NULL || epgnode == NULL) |
---|
1641 | return 1; |
---|
1642 | |
---|
1643 | node = addrectimernode(NULL, NULL); |
---|
1644 | if(node != NULL) |
---|
1645 | { |
---|
1646 | node->name = ostrcat(epgnode->title, NULL, 0, 0); |
---|
1647 | node->begin = epgnode->starttime; |
---|
1648 | node->end = epgnode->endtime; |
---|
1649 | |
---|
1650 | node->repeate = 0; |
---|
1651 | |
---|
1652 | node->recpath = ostrcat(getconfig("rec_path", NULL), NULL, 0, 0); |
---|
1653 | node->servicetype = status.servicetype; |
---|
1654 | if(node->servicetype == 0) |
---|
1655 | { |
---|
1656 | if(channellist == NULL) |
---|
1657 | node->channellist = ostrcat(getconfig("channellist", NULL), NULL, 0, 0); |
---|
1658 | else |
---|
1659 | node->channellist = ostrcat(channellist, NULL, 0, 0); |
---|
1660 | } |
---|
1661 | else |
---|
1662 | { |
---|
1663 | if(channellist == NULL) |
---|
1664 | node->channellist = ostrcat(getconfig("rchannellist", NULL), NULL, 0, 0); |
---|
1665 | else |
---|
1666 | node->channellist = ostrcat(channellist, NULL, 0, 0); |
---|
1667 | } |
---|
1668 | node->serviceid = chnode->serviceid; |
---|
1669 | node->transponderid = chnode->transponderid; |
---|
1670 | screenrectimerext(node, 1); |
---|
1671 | } |
---|
1672 | |
---|
1673 | return 0; |
---|
1674 | } |
---|
1675 | |
---|
1676 | #endif |
---|