MythTV  master
metadataimagedownload.h
Go to the documentation of this file.
1 #ifndef METADATAIMAGEDOWNLOAD_H
2 #define METADATAIMAGEDOWNLOAD_H
3 
4 #include <QString>
5 #include <QStringList>
6 #include <QMutex>
7 
8 #include "mthread.h"
9 #include "mythmetaexp.h"
10 #include "metadatacommon.h"
11 
12 typedef struct {
13  QString title;
14  QVariant data;
15  QString url;
17 
18 class META_PUBLIC ImageDLEvent : public QEvent
19 {
20  public:
21  explicit ImageDLEvent(MetadataLookup *lookup) :
22  QEvent(kEventType),
23  m_item(lookup)
24  {
25  if (m_item)
26  {
27  m_item->IncrRef();
28  }
29  }
31  {
32  if (m_item)
33  {
34  m_item->DecrRef();
35  m_item = nullptr;
36  }
37  }
38 
39  MetadataLookup *m_item {nullptr};
40 
41  static Type kEventType;
42 };
43 
44 class META_PUBLIC ImageDLFailureEvent : public QEvent
45 {
46  public:
47  explicit ImageDLFailureEvent(MetadataLookup *lookup) :
48  QEvent(kEventType),
49  m_item(lookup)
50  {
51  if (m_item)
52  {
53  m_item->IncrRef();
54  }
55  }
57  {
58  if (m_item)
59  {
60  m_item->DecrRef();
61  m_item = nullptr;
62  }
63  }
64 
65  MetadataLookup *m_item {nullptr};
66 
67  static Type kEventType;
68 };
69 
70 class META_PUBLIC ThumbnailDLEvent : public QEvent
71 {
72  public:
73  explicit ThumbnailDLEvent(ThumbnailData *data) :
74  QEvent(kEventType),
75  m_thumb(data) {}
77  {
78  delete m_thumb;
79  m_thumb = nullptr;
80  }
81 
82  ThumbnailData *m_thumb {nullptr};
83 
84  static Type kEventType;
85 };
86 
88 {
89  public:
90 
91  explicit MetadataImageDownload(QObject *parent)
92  : MThread("MetadataImageDownload"), m_parent(parent) {}
94 
95  void addThumb(QString title, QString url, QVariant data);
96  void addDownloads(MetadataLookup *lookup);
97  void cancel();
98 
99  protected:
100 
101  void run() override; // MThread
102 
103  private:
104 
105  ThumbnailData* moreThumbs();
106 
107  QObject *m_parent;
109  QList<ThumbnailData*> m_thumbnailList;
110  QMutex m_mutex;
111 };
112 
113 META_PUBLIC QString getDownloadFilename(const QString& title, const QString& url);
115  const QString& url);
116 
118 META_PUBLIC QString getStorageGroupURL(VideoArtworkType type, const QString& host);
119 META_PUBLIC QString getLocalStorageGroupPath(VideoArtworkType type, const QString& host);
121 
123 
124 #endif /* METADATAIMAGEDOWNLOAD_H */
META_PUBLIC void cleanThumbnailCacheDir(void)
META_PUBLIC QString getLocalStorageGroupPath(VideoArtworkType type, const QString &host)
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
MetadataLookupList m_downloadList
ImageDLFailureEvent(MetadataLookup *lookup)
META_PUBLIC QString getStorageGroupName(VideoArtworkType type)
virtual void run(void)
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: mthread.cpp:318
MetadataType
QList< ThumbnailData * > m_thumbnailList
VideoArtworkType
ThumbnailDLEvent(ThumbnailData *data)
META_PUBLIC QString getDownloadFilename(const QString &title, const QString &url)
#define META_PUBLIC
Definition: mythmetaexp.h:9
META_PUBLIC QString getLocalWritePath(MetadataType metadatatype, VideoArtworkType type)
static Type kEventType
ImageDLEvent(MetadataLookup *lookup)
MetadataImageDownload(QObject *parent)
META_PUBLIC QString getStorageGroupURL(VideoArtworkType type, const QString &host)