-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_logs.c
112 lines (90 loc) · 3.03 KB
/
menu_logs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
Copyright (C) 2007 Christian Wieninger
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
The author can be reached at cwieninger@gmx.de
The project's page is at http://winni.vdr-developer.org/taskman
*/
#include <string>
#include <sstream>
#include "menu_logs.h"
#include <vdr/interface.h>
using namespace std;
// --- cMenuTaskLog ----------------------------------------------------------
cMenuTaskLog::cMenuTaskLog(cTask* Task, time_t Start)
: cMenuText(Task?Task->Name():"", ""), task(Task), start(Start)
{
ostringstream info;
if (task)
{
time_t lastStart = task->LastStart();
if (task->Active() && lastStart == start)
{
info << tr("Start") << ": " << *DateString(lastStart) << " " << *TimeString(lastStart) << endl;
info << tr("Current output") << ":" << endl << task->CurrentOutput();
}
else
info << task->taskLog.Read(start, true);
}
SetText(info.str().c_str());
}
// --- cMenuTaskLogItem ----------------------------------------------------------
cMenuTaskLogItem::cMenuTaskLogItem(cTask* Task, time_t Start)
: task(Task), start(Start)
{
Set();
}
void cMenuTaskLogItem::Set()
{
if (!task) return;
ostringstream line;
line << string(task->Active() && start == task->LastStart()?"#":"") << "\t" << *DateString(start) << "\t" << *TimeString(start);
SetText(strdup(line.str().c_str()), false);
}
// --- cMenuTaskLogs ----------------------------------------------------------
cMenuTaskLogs::cMenuTaskLogs(cTask* Task)
:cOsdMenu(tr("Log entries"), 2, 20), task(Task)
{
Set();
}
void cMenuTaskLogs::Set()
{
int current = Current();
Clear();
if (task->Active())
Add(new cMenuTaskLogItem(task, task->LastStart())); // current log
task->taskLog.Read();
std::vector<time_t>::iterator i;
for(uint i = 0; i<task->taskLog.logTimes.size(); i++)
Add(new cMenuTaskLogItem(task, task->taskLog.logTimes[i]));
SetCurrent(Get(current));
}
eOSState cMenuTaskLogs::Info()
{
cMenuTaskLogItem *item = (cMenuTaskLogItem *)Get(Current());
if (!item) return osContinue;
return AddSubMenu(new cMenuTaskLog(item->task, item->start));
}
eOSState cMenuTaskLogs::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if (!HasSubMenu() && state == osUnknown) {
switch (Key) {
case kOk:
state = Info();
break;
default: break;
}
}
return state;
}