~ubuntu-branches/ubuntu/karmic/kaffeine/karmic

« back to all changes in this revision

Viewing changes to kaffeine/src/input/dvb/plugins/epg/kaffeinedvbevents.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2008-01-22 13:50:29 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080122135029-zc52zvfzp99m6brl
Tags: 0.8.6-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * kaffeinedvbevents.h
 
3
 *
 
4
 * Copyright (C) 2003-2007 Christophe Thommeret <hftom@free.fr>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
19
 */
 
20
 
 
21
#ifndef KAFFEINEDVBEVENTS_H
 
22
#define KAFFEINEDVBEVENTS_H
 
23
 
 
24
#include <qtimer.h>
 
25
#include <qmutex.h>
 
26
#include <qfile.h>
 
27
#include <qobject.h>
 
28
 
 
29
#include <kparts/part.h>
 
30
 
 
31
#include "kaffeinedvbsection.h"
 
32
 
 
33
 
 
34
 
 
35
class ShortEvent
 
36
{
 
37
 
 
38
public:
 
39
 
 
40
        ShortEvent();
 
41
        ~ShortEvent();
 
42
 
 
43
        QString name;
 
44
        QString text;
 
45
};
 
46
 
 
47
class EventDesc
 
48
{
 
49
 
 
50
public:
 
51
 
 
52
        EventDesc();
 
53
        ~EventDesc();
 
54
 
 
55
        QString source;
 
56
        unsigned char tid;
 
57
        unsigned short sid;
 
58
        unsigned short tsid;
 
59
        unsigned short nid;
 
60
        unsigned char sn;
 
61
        unsigned char lsn;
 
62
        unsigned short eid;
 
63
        unsigned char running;
 
64
        QDateTime startDateTime;
 
65
        QTime duration;
 
66
        QPtrList<ShortEvent> shortEvents;
 
67
        QPtrList<QString> extEvents;
 
68
        QString title;
 
69
        QString subtitle;
 
70
        unsigned int loop;
 
71
};
 
72
 
 
73
 
 
74
 
 
75
class EventSid
 
76
{
 
77
public:
 
78
        EventSid( int s );
 
79
        ~EventSid();
 
80
        int getSid() { return sid; }
 
81
        void lock() { mutex.lock(); }
 
82
        void unlock() { mutex.unlock(); }
 
83
        QPtrList<EventDesc> *getEvents() { return &events; }
 
84
        EventDesc *getEventDesc( int n );
 
85
        int getNDesc() { return events.count(); }
 
86
        void remove( EventDesc *d );
 
87
private:
 
88
        QMutex mutex;
 
89
        int sid;
 
90
        QPtrList<EventDesc> events;
 
91
};
 
92
 
 
93
 
 
94
 
 
95
class EventTsid
 
96
{
 
97
public:
 
98
        EventTsid( int n, int t );
 
99
        ~EventTsid();
 
100
        int getTsid() { return tsid; }
 
101
        int getNid() { return nid; }
 
102
        EventSid *getEventSid( int sid );
 
103
        EventSid *getNEventSid( int n );
 
104
        int getNSid() { return sidList.count(); }
 
105
        EventDesc *getEventDesc( int sid, int n );
 
106
private:
 
107
        QMutex mutex;
 
108
        int tsid, nid;
 
109
        QPtrList<EventSid> sidList;
 
110
};
 
111
 
 
112
 
 
113
 
 
114
class EventSource
 
115
{
 
116
public:
 
117
        EventSource( QString src );
 
118
        ~EventSource();
 
119
        EventSid *getEventSid( int nid, int tsid, int sid );
 
120
        EventTsid *getNEventTsid( int n );
 
121
        int getNTsid() { return tsidList.count(); }
 
122
        EventDesc *getEventDesc( int nid, int tsid, int sid, int n );
 
123
        QString getSource() { return source; }
 
124
private:
 
125
        QMutex mutex;
 
126
        QString source;
 
127
        QPtrList<EventTsid> tsidList;
 
128
};
 
129
 
 
130
 
 
131
 
 
132
class EventTable : public QObject, public QThread
 
133
{
 
134
        Q_OBJECT
 
135
public:
 
136
        EventTable();
 
137
        ~EventTable();
 
138
        EventSource *getEventSource( QString src );
 
139
        EventDesc *getEventDesc( QString src, int nid, int tsid, int sid, int n );
 
140
        EventSource *getNEventSource( int n );
 
141
        int getNSource() { return srcList.count(); }
 
142
        void doClean( bool b );
 
143
        void saveEpg();
 
144
        void loadEpg();
 
145
protected:
 
146
        virtual void run();
 
147
private:
 
148
        bool validString( QFile &f, EventDesc *d, int len, int buflen, int nev );
 
149
        QMutex mutex;
 
150
        QPtrList<EventSource> srcList;
 
151
        QTimer cleanTimer;
 
152
        bool epgLoaded;
 
153
private slots:
 
154
        void setClean();
 
155
};
 
156
 
 
157
 
 
158
 
 
159
class KDE_EXPORT KaffeineEpgPlugin : public KParts::Part,  public KaffeineDVBsection
 
160
{
 
161
        Q_OBJECT
 
162
public:
 
163
        KaffeineEpgPlugin( QObject* parent, const char* name );
 
164
        virtual ~KaffeineEpgPlugin();
 
165
        virtual bool go( QString /*src*/, int /*freqKhz*/ ) { return false; }
 
166
        virtual void stop() {}
 
167
        void setTable( EventTable *table ) { events = table; }
 
168
 
 
169
protected:
 
170
        bool safeLen( unsigned char* buf );
 
171
 
 
172
        unsigned char secbuf[4096];
 
173
        int readSize;
 
174
        EventTable *events;
 
175
};
 
176
 
 
177
#endif /* KAFFEINEDVBEVENTS_H */