2 * @file Reservation.cpp
\r
9 #include "Raym/Log.h"
\r
12 #include "ry0/iPTd/Reservation.h"
\r
13 #include "ry0/iPTd/Controller.h"
\r
15 using namespace Raym;
\r
22 static const time_t OFFSET_OF_SUPPRESSION_TIME = -600; // 録画開始前に休止の抑制を開始する時間(秒単位)
\r
24 Reservation::Reservation()
\r
28 _reservations = NULL;
\r
29 _reservation_seq_id = -1;
\r
32 Reservation::~Reservation()
\r
36 RELEASE(_reservations);
\r
39 Reservation *Reservation::alloc()
\r
41 return new Reservation();
\r
44 Reservation *Reservation::initWithController(Controller *controller, String *path)
\r
46 _controller = controller;
\r
47 _path = path->retain();
\r
49 _reservations = Dictionary::alloc()->initWithContentsOfFile(_path);
\r
50 if (_reservations == NULL)
\r
52 DebugLog1("because \"%s\" is not exists, created.", _path->cString());
\r
53 _reservations = Dictionary::alloc()->initWithCapacity(0);
\r
54 _reservation_seq_id = 1;
\r
58 DebugLog1("reservations file: \"%s\"", _path->cString());
\r
61 _reservation_seq_id = _reservations->integerForKey(KEY_EPG_LAST_RESV_ID);
\r
67 bool Reservation::canTerminate()
\r
72 time_t now = time(NULL);
\r
74 for (int tuner = 0; tuner < _controller->_tunerCount; ++tuner)
\r
76 Array *array = _reservations->arrayForKey(_controller->_tuners[tuner]->name());
\r
77 if ((array == NULL) || (array->count() == 0))
\r
84 Dictionary *epg = (Dictionary *)array->objectAtIndex(0);
\r
87 Controller::getTimeWithEPG(epg, &start, &end);
\r
89 if (start + OFFSET_OF_SUPPRESSION_TIME <= now)
\r