MythTV  master
metadatafactory.h
Go to the documentation of this file.
1 #ifndef METADATAFACTORY_H_
2 #define METADATAFACTORY_H_
3 
4 #include <utility>
5 
6 // Needed to perform a lookup
7 #include "metadatacommon.h"
9 #include "metadatadownload.h"
10 
11 // Needed to perform scans
12 #include "videoscan.h"
13 
14 // Symbol visibility
15 #include "mythmetaexp.h"
16 
17 class VideoMetadata;
18 class RecordingRule;
19 
21 {
22  public:
24  : QEvent(kEventType), m_results(res) {}
25  ~MetadataFactoryMultiResult() override;
26 
28 
29  static Type kEventType;
30 };
31 
33 {
34  public:
36  : QEvent(kEventType), m_result(res)
37  {
38  if (m_result)
39  {
40  m_result->IncrRef();
41  }
42  }
43  ~MetadataFactorySingleResult() override;
44 
45  MetadataLookup *m_result {nullptr};
46 
47  static Type kEventType;
48 };
49 
50 class META_PUBLIC MetadataFactoryNoResult : public QEvent
51 {
52  public:
54  : QEvent(kEventType), m_result(res)
55  {
56  if (m_result)
57  {
58  m_result->IncrRef();
59  }
60  }
61  ~MetadataFactoryNoResult() override;
62 
63  MetadataLookup *m_result {nullptr};
64 
65  static Type kEventType;
66 };
67 
69 {
70  public:
71  MetadataFactoryVideoChanges(QList<int> adds, QList<int> movs,
72  QList<int>dels) : QEvent(kEventType),
73  m_additions(std::move(adds)),
74  m_moved(std::move(movs)),
75  m_deleted(std::move(dels)) {}
76  ~MetadataFactoryVideoChanges() override;
77 
78  QList<int> m_additions; // newly added intids
79  QList<int> m_moved; // intids moved to new filename
80  QList<int> m_deleted; // orphaned/deleted intids
81 
82  static Type kEventType;
83 };
84 
85 class META_PUBLIC MetadataFactory : public QObject
86 {
87 
88  public:
89 
90  explicit MetadataFactory(QObject *parent);
91  ~MetadataFactory() override;
92 
93  void Lookup(ProgramInfo *pginfo, bool automatic = true,
94  bool getimages = true, bool allowgeneric = false);
95  void Lookup(VideoMetadata *metadata, bool automatic = true,
96  bool getimages = true, bool allowgeneric = false);
97  void Lookup(RecordingRule *recrule, bool automatic = true,
98  bool getimages = true, bool allowgeneric = false);
99  void Lookup(MetadataLookup *lookup);
100 
101  MetadataLookupList SynchronousLookup(const QString& title,
102  const QString& subtitle,
103  const QString& inetref,
104  int season,
105  int episode,
106  const QString& grabber,
107  bool allowgeneric = false);
108  MetadataLookupList SynchronousLookup(MetadataLookup *lookup);
109 
110  void VideoScan();
111  void VideoScan(const QStringList& hosts);
112 
113  bool IsRunning() { return m_lookupthread->isRunning() ||
114  m_imagedownload->isRunning() ||
115  m_videoscanner->isRunning(); };
116 
117  static bool VideoGrabbersFunctional();
118 
119  private:
120 
121  void customEvent(QEvent *levent) override; // QObject
122 
123  void OnMultiResult(const MetadataLookupList& list);
124  void OnSingleResult(MetadataLookup *lookup);
125  void OnNoResult(MetadataLookup *lookup);
126  void OnImageResult(MetadataLookup *lookup);
127 
128  void OnVideoResult(MetadataLookup *lookup);
129 
130  MetadataDownload *m_lookupthread {nullptr};
131  MetadataImageDownload *m_imagedownload {nullptr};
132 
133  VideoScannerThread *m_videoscanner {nullptr};
134  VideoMetadataListManager *m_mlm {nullptr};
135  bool m_scanning {false};
136 
137  // Variables used in synchronous mode
139  bool m_sync {false};
140 };
141 
146 META_PUBLIC LookupType GuessLookupType(const QString& inetref);
147 
148 #endif
MetadataFactoryNoResult(MetadataLookup *res)
MetadataFactoryMultiResult(const MetadataLookupList &res)
MetadataLookupList m_results
Holds information on recordings and videos.
Definition: programinfo.h:67
MetadataFactorySingleResult(MetadataLookup *res)
MetadataFactoryVideoChanges(QList< int > adds, QList< int > movs, QList< int >dels)
#define META_PUBLIC
Definition: mythmetaexp.h:9
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
META_PUBLIC LookupType GuessLookupType(ProgramInfo *pginfo)
MetadataLookupList m_returnList
LookupType