trunk 20080912
[gitenigma.git] / src / timer.h
blobbbec5652f5df4ca87fd5b018ad7457fe02483348
1 #ifndef __apps__enigma__timer_h
2 #define __apps__enigma__timer_h
4 #include <lib/dvb/serviceplaylist.h>
5 #include <lib/gui/listbox.h>
6 #include <lib/gui/emessage.h>
7 #include <sselect.h>
8 #include <epgwindow.h>
10 class eTextInputField;
11 class eNumber;
12 class eButton;
13 class eComboBox;
14 class eCheckbox;
16 class eTimerManager: public Object
18 static eTimerManager *instance;
19 FILE *logfile;
20 // eTimerManager actionHandler stuff
21 enum
23 zap, prepareEvent, startCountdown, setNextEvent,
24 startEvent, pauseEvent, restartEvent, stopEvent,
25 startRecording, stopRecording, restartRecording,
26 pauseRecording, spinUpHarddiscs, oldService,
27 updateDuration
28 } nextAction;
30 eTimer actionTimer; // to start timer related actions
31 void actionHandler(); // the action Handler
32 ///////////////////////////
34 // for multiple use timer and connection objects..
35 eTimer timer;
36 Connection conn, conn2;
38 // the timerlist self...
39 ePlaylist *timerlist;
40 eServiceReference timerlistref;
41 eServiceReference playbackRef;
43 // nextStarting event, or the current running Event
44 std::list<ePlaylistEntry>::iterator nextStartingEvent;
46 bool setdeepstandbywakeup;
48 // all methods are NOT always connected to the eDVB Signals
49 void switchedService( const eServiceReferenceDVB&, int err );
50 void leaveService( const eServiceReferenceDVB& );
52 long getSecondsToBegin();
53 long getSecondsToEnd();
55 void writeToLogfile( const char *str );
56 void writeToLogfile( eString str );
57 public:
58 enum { erase, update };
59 eTimerManager();
60 ~eTimerManager();
61 static eTimerManager *getInstance() { return instance; }
62 bool updateRunningEvent( int duration, int after_event );
63 bool removeEventFromTimerList( eWidget *w, const ePlaylistEntry& entry, int type=erase );
64 bool removeEventFromTimerList( eWidget *w, const eServiceReference *ref, const EITEvent *evt);
65 void cleanupEvents();
66 void clearEvents();
67 bool addEventToTimerList( eWidget *w, const eServiceReference *ref, const EITEvent *evt, int type = ePlaylistEntry::RecTimerEntry|ePlaylistEntry::recDVR|ePlaylistEntry::stateWaiting, const ePlaylistEntry *exclude=0 );
68 bool addEventToTimerList( eWidget *w, const ePlaylistEntry& entry, const ePlaylistEntry *exclude=0 );
69 int addEventToTimerList(const ePlaylistEntry& entry);
70 int deleteEventFromTimerList(const ePlaylistEntry& entry, bool force=false);
71 int modifyEventInTimerList(const ePlaylistEntry& old_entry, const ePlaylistEntry& new_entry, bool force=false);
72 bool eventAlreadyInList( eWidget *w, EITEvent &e, eServiceReference &ref );
73 void abortEvent(int err);
74 void loadTimerList();
75 void saveTimerList();
76 void timeChanged();
77 int getTimerCount() { return timerlist->getConstList().size(); }
78 ePlaylistEntry* findEvent( eServiceReference *service, EITEvent *evt );
79 void disableDeepstandbyWakeup() { setdeepstandbywakeup=false; }
80 template <class Z>
81 void forEachEntry(Z ob)
83 if (timerlist)
84 for (std::list<ePlaylistEntry>::iterator i(timerlist->getList().begin()); i != timerlist->getList().end(); ++i)
85 ob(&*i);
89 class eListBoxEntryTimer: public eListBoxEntry
91 friend class eListBox<eListBoxEntryTimer>;
92 friend class eTimerListView;
93 friend struct _selectEvent;
94 static gFont TimeFont, DescrFont;
95 static gPixmap *ok, *failed;
96 static int timeXSize, dateXSize;
97 int TimeYOffs, DescrYOffs;
98 eTextPara *paraDate, *paraTime, *paraDescr, *paraService;
99 ePlaylistEntry *entry;
100 const eString &redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int hilited);
101 static int getEntryHeight();
102 eString hlp;
103 public:
104 bool operator < ( const eListBoxEntry& ref ) const
106 return entry->time_begin < ((eListBoxEntryTimer&)ref).entry->time_begin;
108 eListBoxEntryTimer(eListBox<eListBoxEntryTimer> *listbox, ePlaylistEntry *entry);
109 ~eListBoxEntryTimer();
112 class eTimerListView:public eWindow
114 eListBox<eListBoxEntryTimer>* events;
115 eButton *add, *erase, *cleanup;
116 public:
117 eTimerListView();
118 void fillTimerList();
119 void entrySelected(eListBoxEntryTimer *entry);
120 void addPressed();
121 void erasePressed();
122 void cleanupPressed();
125 class eTimerEditView: public eWindow
127 eCheckbox *multiple, *cMo, *cTue, *cWed, *cThu, *cFr, *cSa, *cSu;
128 eComboBox *bday, *bmonth, *byear, *eday, *emonth, *eyear, *type, *after_event;
129 eTextInputField *event_name;
130 eLabel *lBegin, *lEnd;
131 eNumber *btime, *etime;
132 eButton *bSelectService, *bApply, *bScanEPG;
133 tm beginTime, endTime;
134 eServiceReference tmpService;
135 ePlaylistEntry *curEntry;
136 int event_id;
137 private:
138 void scanEPGPressed();
139 void multipleChanged( int );
140 void setMultipleCheckboxes( int type );
141 void createWidgets();
142 void fillInData( time_t begTime, int duration, int type, eServiceReference& ref );
143 void applyPressed();
144 void showServiceSelector();
145 void comboBoxClosed( eComboBox *combo, eListBoxEntryText* );
146 void updateDateTime( const tm& beginTime, const tm& endTime, int what );
147 void updateDay( eComboBox* dayCombo, int year, int month, int day );
148 void focusNext(int*)
150 eWidget::focusNext(eWidget::focusDirNext);
152 bool getData( time_t& beginTime, int& duration );
153 int eventHandler( const eWidgetEvent &e );
154 void changeTime( int dir );
155 public:
156 eTimerEditView(ePlaylistEntry* e=0);
157 eTimerEditView( const EITEvent &e, int type, eServiceReference ref );
160 #endif