MythTV  master
mhegic.h
Go to the documentation of this file.
1 /* MHEG Interaction Channel
2  * Copyright 2011 Lawrence Rust <lvr at softsystem dot co dot uk>
3  */
4 #ifndef MHEGIC_H
5 #define MHEGIC_H
6 
7 #include <QObject>
8 #include <QString>
9 #include <QUrl>
10 #include <QMutex>
11 #include <QHash>
12 
13 class QByteArray;
14 class NetStream;
15 
16 class MHInteractionChannel : public QObject
17 {
18  Q_OBJECT
19 
20 public:
21  explicit MHInteractionChannel(QObject* parent = nullptr);
22  ~MHInteractionChannel() override;
23 
24  // Properties
25 public:
26  // Get network status
28  static EStatus status();
29 
30  // Operations
31 public:
32  // Is a file ready to read?
33  bool CheckFile(const QString &csPath, const QByteArray &cert = QByteArray());
34  // Read a file
35  enum EResult { kError = -1, kSuccess = 0, kPending };
36  EResult GetFile(const QString &csPath, QByteArray &data,
37  const QByteArray &cert = QByteArray() );
38 
39  // Implementation
40 private slots:
41  // NetStream signals
42  void slotFinished(QObject *obj);
43 
44 private:
45  Q_DISABLE_COPY(MHInteractionChannel)
46  mutable QMutex m_mutex;
47  using map_t = QHash< QUrl, NetStream* >;
48  map_t m_pending; // Pending requests
49  map_t m_finished; // Completed requests
50 };
51 
52 #endif /* ndef MHEGIC_H */
MHInteractionChannel::slotFinished
void slotFinished(QObject *obj)
Definition: mhegic.cpp:172
MHInteractionChannel::status
static EStatus status()
Definition: mhegic.cpp:46
MHInteractionChannel::~MHInteractionChannel
~MHInteractionChannel() override
Definition: mhegic.cpp:35
MHInteractionChannel::kError
@ kError
Definition: mhegic.h:35
MHInteractionChannel::GetFile
EResult GetFile(const QString &csPath, QByteArray &data, const QByteArray &cert=QByteArray())
Definition: mhegic.cpp:109
MHInteractionChannel::EResult
EResult
Definition: mhegic.h:35
MHInteractionChannel::m_mutex
QMutex m_mutex
Definition: mhegic.h:46
MHInteractionChannel::m_finished
map_t m_finished
Definition: mhegic.h:49
MHInteractionChannel::map_t
QHash< QUrl, NetStream * > map_t
Definition: mhegic.h:47
MHInteractionChannel::kSuccess
@ kSuccess
Definition: mhegic.h:35
MHInteractionChannel::kPending
@ kPending
Definition: mhegic.h:35
MHInteractionChannel::EStatus
EStatus
Definition: mhegic.h:27
MHInteractionChannel::m_pending
map_t m_pending
Definition: mhegic.h:48
MHInteractionChannel
Definition: mhegic.h:17
MHInteractionChannel::kDisabled
@ kDisabled
Definition: mhegic.h:27
NetStream
Stream content from a URI.
Definition: netstream.h:31
MHInteractionChannel::CheckFile
bool CheckFile(const QString &csPath, const QByteArray &cert=QByteArray())
Definition: mhegic.cpp:75
MHInteractionChannel::MHInteractionChannel
MHInteractionChannel(QObject *parent=nullptr)
Definition: mhegic.cpp:28
MHInteractionChannel::kActive
@ kActive
Definition: mhegic.h:27
MHInteractionChannel::kInactive
@ kInactive
Definition: mhegic.h:27