MythTV  master
channelimporter.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /*
3  * Copyright (C) Daniel Kristjansson 2007
4  *
5  * This file is licensed under GPL v2 or (at your option) any later version.
6  *
7  */
8 
9 #ifndef CHANNEL_IMPORTER_H
10 #define CHANNEL_IMPORTER_H
11 
12 // C++ headers
13 #include <cstring>
14 
15 // Qt headers
16 #include <QMap>
17 #include <QString>
18 #include <QCoreApplication>
19 
20 // MythTV headers
21 #include "mythtvexp.h"
22 #include "scaninfo.h"
23 #include "channelscantypes.h"
24 #include "mythmainwindow.h"
25 
28  kOCTCancel = +0,
29  kOCTOk = +1,
30  kOCTOkAll = +2,
31 };
32 
34 {
35  public:
37  {
38  memset(m_atscChannels, 0, sizeof(m_atscChannels));
39  memset(m_dvbChannels, 0, sizeof(m_dvbChannels));
40  memset(m_scteChannels, 0, sizeof(m_scteChannels));
41  memset(m_mpegChannels, 0, sizeof(m_mpegChannels));
42  memset(m_ntscChannels, 0, sizeof(m_ntscChannels));
43  }
44 
45  // totals
51 
52  // per channel counts
53  QMap<uint,uint> m_progNumCnt;
54  QMap<uint,uint> m_atscNumCnt;
55  QMap<uint,uint> m_atscMinCnt;
56  QMap<uint,uint> m_atscMajCnt;
57  QMap<QString,uint> m_chanNumCnt;
58 };
59 
61 {
62  public:
64 
71 };
72 
74 {
75  Q_DECLARE_TR_FUNCTIONS(ChannelImporter)
76 
77  public:
78  ChannelImporter(bool gui, bool interactive,
79  bool _delete, bool insert, bool save,
80  bool fta_only, bool lcn_only, bool complete_only,
81  bool full_channel_search,
82  bool remove_duplicates,
83  ServiceRequirements service_requirements,
84  bool success = false) :
85  m_useGui(gui),
86  m_isInteractive(interactive),
87  m_doDelete(_delete),
88  m_doInsert(insert),
89  m_doSave(save),
90  m_ftaOnly(fta_only),
91  m_lcnOnly(lcn_only),
92  m_completeOnly(complete_only),
93  m_fullChannelSearch(full_channel_search),
94  m_removeDuplicates(remove_duplicates),
95  m_success(success),
96  m_serviceRequirements(service_requirements) { }
97 
98  void Process(const ScanDTVTransportList &_transports, int sourceid = -1);
99 
100  protected:
102  {
107  };
109  {
113  };
115  {
119  };
120 
122  {
123  kChannelTypeFirst = 0,
124 
125  kChannelTypeNonConflictingFirst = kChannelTypeFirst,
126  kATSCNonConflicting = kChannelTypeFirst,
131  kChannelTypeNonConflictingLast = kNTSCNonConflicting,
132 
134  kATSCConflicting = kChannelTypeConflictingFirst,
139  kChannelTypeConflictingLast = kNTSCConflicting,
140  kChannelTypeLast = kChannelTypeConflictingLast,
141  };
142 
143  static QString toString(ChannelType type);
144 
145  static void MergeSameFrequency(ScanDTVTransportList &transports);
146  static void RemoveDuplicates(ScanDTVTransportList &transports, ScanDTVTransportList &duplicates);
147  void FilterServices(ScanDTVTransportList &transports) const;
148  static void FilterRelocatedServices(ScanDTVTransportList &transports);
149 
150  ScanDTVTransportList GetDBTransports(
151  uint sourceid, ScanDTVTransportList &transports) const;
152 
153  uint DeleteChannels(ScanDTVTransportList &transports);
154  uint DeleteUnusedTransports(uint sourceid);
155 
156  void InsertChannels(const ScanDTVTransportList &transports,
157  const ChannelImporterBasicStats &info);
158 
159  ScanDTVTransportList InsertChannels(
160  const ScanDTVTransportList &transports,
161  const ChannelImporterBasicStats &info,
162  InsertAction action,
163  ChannelType type,
164  ScanDTVTransportList &inserted,
165  ScanDTVTransportList &skipped);
166 
167  ScanDTVTransportList UpdateChannels(
168  const ScanDTVTransportList &transports,
169  const ChannelImporterBasicStats &info,
170  UpdateAction action,
171  ChannelType type,
172  ScanDTVTransportList &updated,
173  ScanDTVTransportList &skipped) const;
174 
176  DeleteAction QueryUserDelete(const QString &msg);
177 
179  InsertAction QueryUserInsert(const QString &msg);
180 
182  UpdateAction QueryUserUpdate(const QString &msg);
183 
185  OkCancelType QueryUserResolve(
186  const ScanDTVTransport &transport,
187  ChannelInsertInfo &chan);
188 
190  OkCancelType QueryUserInsert(
191  const ScanDTVTransport &transport,
192  ChannelInsertInfo &chan);
193 
194  static QString ComputeSuggestedChannelNum(
195  const ChannelInsertInfo &chan);
196 
197  OkCancelType ShowManualChannelPopup(
198  MythMainWindow *parent, const QString& title,
199  const QString& message, QString &text);
200 
201  OkCancelType ShowResolveChannelPopup(
202  MythMainWindow *parent, const QString& title,
203  const QString& message, QString &text);
204 
205  static void FixUpOpenCable(ScanDTVTransportList &transports);
206 
207  static ChannelImporterBasicStats CollectStats(
208  const ScanDTVTransportList &transports);
209 
210  static ChannelImporterUniquenessStats CollectUniquenessStats(
211  const ScanDTVTransportList &transports,
212  const ChannelImporterBasicStats &info);
213 
214  static QString FormatChannels(
215  const ScanDTVTransportList &transports,
216  const ChannelImporterBasicStats *info = nullptr);
217 
218  static QString FormatChannel(
219  const ScanDTVTransport &transport,
220  const ChannelInsertInfo &chan,
221  const ChannelImporterBasicStats *info = nullptr);
222 
223  static QString SimpleFormatChannel(
224  const ScanDTVTransport &transport,
225  const ChannelInsertInfo &chan);
226 
227  static QString FormatTransport(
228  const ScanDTVTransport &transport);
229 
230  static QString FormatTransports(
231  const ScanDTVTransportList &transports_in);
232 
233  static QString GetSummary(
234  const ChannelImporterBasicStats &info,
235  const ChannelImporterUniquenessStats &stats);
236 
237  static bool IsType(
238  const ChannelImporterBasicStats &info,
239  const ChannelInsertInfo &chan, ChannelType type);
240 
241  static void CountChannels(
242  const ScanDTVTransportList &transports,
243  const ChannelImporterBasicStats &info,
244  ChannelType type, uint &new_chan, uint &old_chan);
245 
246  static int SimpleCountChannels(
247  const ScanDTVTransportList &transports);
248 
249  static bool CheckChannelNumber(
250  const QString &num,
251  const ChannelInsertInfo &chan);
252 
253  static void AddChanToCopy(
254  ScanDTVTransport &transport_copy,
255  const ScanDTVTransport &transport,
256  const ChannelInsertInfo &chan);
257 
258  private:
259  bool m_useGui;
263  bool m_doSave;
264  bool m_ftaOnly {true}; // Only FreeToAir (non-encrypted) channels desired post scan?
265  bool m_lcnOnly {false}; // Only services with logical channel numbers desired post scan?
266  bool m_completeOnly {true}; // Only services with complete scandata desired post scan?
267  bool m_keepChannelNumbers {true}; // Keep existing channel numbers on channel update
268  bool m_fullChannelSearch {false}; // Full search for old channels across transports in database
269  bool m_removeDuplicates {false}; // Remove duplicate transports and channels in scan
270  bool m_success {false}; // To pass information IPTV channel scan succeeded
271 
272  ServiceRequirements m_serviceRequirements; // Services desired post scan
273  QEventLoop m_eventLoop;
274 };
275 
276 #endif // CHANNEL_IMPORTER_H
ChannelImporter::kSCTEConflicting
@ kSCTEConflicting
Definition: channelimporter.h:136
ChannelImporterBasicStats::m_chanNumCnt
QMap< QString, uint > m_chanNumCnt
Definition: channelimporter.h:57
RemoveDuplicates
Definition: channelscanmiscsettings.h:174
OkCancelType
OkCancelType
Definition: channelimporter.h:26
ChannelImporter::m_isInteractive
bool m_isInteractive
Definition: channelimporter.h:260
ChannelImporter::kUpdateIgnoreAll
@ kUpdateIgnoreAll
Definition: channelimporter.h:118
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
mythtvexp.h
kOCTCancel
@ kOCTCancel
Definition: channelimporter.h:28
ChannelImporter::m_doInsert
bool m_doInsert
Definition: channelimporter.h:262
ChannelImporter::kDVBConflicting
@ kDVBConflicting
Definition: channelimporter.h:135
ChannelImporterBasicStats::m_scteChannels
uint m_scteChannels[3]
Definition: channelimporter.h:48
ChannelImporter::kNTSCNonConflicting
@ kNTSCNonConflicting
Definition: channelimporter.h:130
ScanDTVTransportList
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
ChannelImporter::kUpdateManual
@ kUpdateManual
Definition: channelimporter.h:117
ChannelImporter::kChannelTypeConflictingFirst
@ kChannelTypeConflictingFirst
Definition: channelimporter.h:133
ChannelImporterUniquenessStats::m_uniqueProgNum
uint m_uniqueProgNum
Definition: channelimporter.h:65
ChannelImporter::UpdateAction
UpdateAction
Definition: channelimporter.h:114
ChannelImporter::m_doDelete
bool m_doDelete
Definition: channelimporter.h:261
ChannelImporterBasicStats::m_atscNumCnt
QMap< uint, uint > m_atscNumCnt
Definition: channelimporter.h:54
ChannelImporter::m_serviceRequirements
ServiceRequirements m_serviceRequirements
Definition: channelimporter.h:272
kOCTOk
@ kOCTOk
Definition: channelimporter.h:29
ChannelInsertInfo
Definition: channelinfo.h:135
ChannelImporter::DeleteAction
DeleteAction
Definition: channelimporter.h:101
ChannelImporter::m_useGui
bool m_useGui
Definition: channelimporter.h:259
ChannelImporterBasicStats::m_atscChannels
uint m_atscChannels[3]
Definition: channelimporter.h:46
ChannelImporterBasicStats::m_ntscChannels
uint m_ntscChannels[3]
Definition: channelimporter.h:50
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
ChannelImporter::kMPEGConflicting
@ kMPEGConflicting
Definition: channelimporter.h:137
channelscantypes.h
ChannelImporterBasicStats::m_atscMajCnt
QMap< uint, uint > m_atscMajCnt
Definition: channelimporter.h:56
ChannelImporter::kDeleteAll
@ kDeleteAll
Definition: channelimporter.h:103
ChannelImporter::kDVBNonConflicting
@ kDVBNonConflicting
Definition: channelimporter.h:127
ChannelImporter::kSCTENonConflicting
@ kSCTENonConflicting
Definition: channelimporter.h:128
scaninfo.h
ChannelImporter::kInsertManual
@ kInsertManual
Definition: channelimporter.h:111
uint
unsigned int uint
Definition: compat.h:140
ChannelImporter::m_eventLoop
QEventLoop m_eventLoop
Definition: channelimporter.h:273
ChannelImporter::kDeleteManual
@ kDeleteManual
Definition: channelimporter.h:104
ChannelImporterBasicStats::m_mpegChannels
uint m_mpegChannels[3]
Definition: channelimporter.h:49
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
ChannelImporterUniquenessStats::m_uniqueChanNum
uint m_uniqueChanNum
Definition: channelimporter.h:68
ChannelImporterBasicStats::m_progNumCnt
QMap< uint, uint > m_progNumCnt
Definition: channelimporter.h:53
ChannelImporter::ChannelImporter
ChannelImporter(bool gui, bool interactive, bool _delete, bool insert, bool save, bool fta_only, bool lcn_only, bool complete_only, bool full_channel_search, bool remove_duplicates, ServiceRequirements service_requirements, bool success=false)
Definition: channelimporter.h:78
kOCTCancelAll
@ kOCTCancelAll
Definition: channelimporter.h:27
ChannelImporter::kMPEGNonConflicting
@ kMPEGNonConflicting
Definition: channelimporter.h:129
ChannelImporter::kDeleteIgnoreAll
@ kDeleteIgnoreAll
Definition: channelimporter.h:105
ChannelImporter::kInsertAll
@ kInsertAll
Definition: channelimporter.h:110
ChannelImporter
Definition: channelimporter.h:73
ChannelImporterUniquenessStats::m_uniqueTotal
uint m_uniqueTotal
Definition: channelimporter.h:69
ChannelImporter::kUpdateAll
@ kUpdateAll
Definition: channelimporter.h:116
ChannelImporterUniquenessStats::m_uniqueAtscMin
uint m_uniqueAtscMin
Definition: channelimporter.h:67
ChannelImporterUniquenessStats::m_maxAtscMajCnt
uint m_maxAtscMajCnt
Definition: channelimporter.h:70
build_compdb.action
action
Definition: build_compdb.py:9
ChannelImporter::InsertAction
InsertAction
Definition: channelimporter.h:108
ChannelImporterBasicStats::ChannelImporterBasicStats
ChannelImporterBasicStats()
Definition: channelimporter.h:36
ChannelImporterBasicStats
Definition: channelimporter.h:33
ChannelImporterUniquenessStats::m_uniqueAtscNum
uint m_uniqueAtscNum
Definition: channelimporter.h:66
ServiceRequirements
ServiceRequirements
Definition: channelscantypes.h:4
mythmainwindow.h
ChannelImporterUniquenessStats::ChannelImporterUniquenessStats
ChannelImporterUniquenessStats()=default
ChannelImporter::kInsertIgnoreAll
@ kInsertIgnoreAll
Definition: channelimporter.h:112
ChannelImporter::m_doSave
bool m_doSave
Definition: channelimporter.h:263
ChannelImporterBasicStats::m_atscMinCnt
QMap< uint, uint > m_atscMinCnt
Definition: channelimporter.h:55
ChannelImporterBasicStats::m_dvbChannels
uint m_dvbChannels[3]
Definition: channelimporter.h:47
ChannelImporter::ChannelType
ChannelType
Definition: channelimporter.h:121
MythMainWindow
Definition: mythmainwindow.h:32
ChannelImporterUniquenessStats
Definition: channelimporter.h:60
ChannelImporter::kNTSCConflicting
@ kNTSCConflicting
Definition: channelimporter.h:138
ScanDTVTransport
Definition: dtvmultiplex.h:115
ChannelImporter::kDeleteInvisibleAll
@ kDeleteInvisibleAll
Definition: channelimporter.h:106
kOCTOkAll
@ kOCTOkAll
Definition: channelimporter.h:30