00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _CHANNEL_IMPORTER_H_
00010 #define _CHANNEL_IMPORTER_H_
00011
00012
00013 #include <string.h>
00014
00015
00016 #include <QMap>
00017 #include <QString>
00018
00019
00020 #include "mythtvexp.h"
00021 #include "scaninfo.h"
00022 #include "channelscantypes.h"
00023 #include "mythmainwindow.h"
00024
00025 typedef enum {
00026 kOCTCancelAll = -1,
00027 kOCTCancel = +0,
00028 kOCTOk = +1,
00029 } OkCancelType;
00030
00031 class ChannelImporterBasicStats
00032 {
00033 public:
00034 ChannelImporterBasicStats()
00035 {
00036 memset(atsc_channels, 0, sizeof(atsc_channels));
00037 memset(dvb_channels, 0, sizeof(dvb_channels));
00038 memset(scte_channels, 0, sizeof(scte_channels));
00039 memset(mpeg_channels, 0, sizeof(mpeg_channels));
00040 memset(ntsc_channels, 0, sizeof(ntsc_channels));
00041 }
00042
00043
00044 uint atsc_channels[3];
00045 uint dvb_channels [3];
00046 uint scte_channels[3];
00047 uint mpeg_channels[3];
00048 uint ntsc_channels[3];
00049
00050
00051 QMap<uint,uint> prognum_cnt;
00052 QMap<uint,uint> atscnum_cnt;
00053 QMap<uint,uint> atscmin_cnt;
00054 QMap<uint,uint> atscmaj_cnt;
00055 QMap<QString,uint> channum_cnt;
00056 };
00057
00058 class ChannelImporterUniquenessStats
00059 {
00060 public:
00061 ChannelImporterUniquenessStats() :
00062 unique_prognum(0), unique_atscnum(0),
00063 unique_atscmin(0), unique_channum(0),
00064 unique_total(0), max_atscmajcnt(0)
00065 {
00066 }
00067
00068 uint unique_prognum;
00069 uint unique_atscnum;
00070 uint unique_atscmin;
00071 uint unique_channum;
00072 uint unique_total;
00073 uint max_atscmajcnt;
00074 };
00075
00076 class MTV_PUBLIC ChannelImporter
00077 {
00078 public:
00079 ChannelImporter(bool gui, bool interactive,
00080 bool _delete, bool insert, bool save,
00081 bool fta_only, ServiceRequirements service_requirements) :
00082 use_gui(gui), is_interactive(interactive),
00083 do_delete(_delete),
00084 do_insert(insert), do_save(save), m_fta_only(fta_only),
00085 m_service_requirements(service_requirements) { }
00086
00087 void Process(const ScanDTVTransportList&);
00088
00089 protected:
00090 typedef enum
00091 {
00092 kDeleteAll,
00093 kDeleteManual,
00094 kDeleteIgnoreAll,
00095 kDeleteInvisibleAll,
00096 } DeleteAction;
00097 typedef enum
00098 {
00099 kInsertAll,
00100 kInsertManual,
00101 kInsertIgnoreAll,
00102 } InsertAction;
00103 typedef enum
00104 {
00105 kUpdateAll,
00106 kUpdateManual,
00107 kUpdateIgnoreAll,
00108 } UpdateAction;
00109
00110 typedef enum
00111 {
00112 kChannelTypeFirst = 0,
00113
00114 kChannelTypeNonConflictingFirst = kChannelTypeFirst,
00115 kATSCNonConflicting = kChannelTypeFirst,
00116 kDVBNonConflicting,
00117 kSCTENonConflicting,
00118 kMPEGNonConflicting,
00119 kNTSCNonConflicting,
00120 kChannelTypeNonConflictingLast = kNTSCNonConflicting,
00121
00122 kChannelTypeConflictingFirst,
00123 kATSCConflicting = kChannelTypeConflictingFirst,
00124 kDVBConflicting,
00125 kSCTEConflicting,
00126 kMPEGConflicting,
00127 kNTSCConflicting,
00128 kChannelTypeConflictingLast = kNTSCConflicting,
00129 kChannelTypeLast = kChannelTypeConflictingLast,
00130 } ChannelType;
00131
00132 QString toString(ChannelType type);
00133
00134 void CleanupDuplicates(ScanDTVTransportList &transports) const;
00135 void FilterServices(ScanDTVTransportList &transports) const;
00136 ScanDTVTransportList GetDBTransports(
00137 uint sourceid, ScanDTVTransportList&) const;
00138
00139 uint DeleteChannels(ScanDTVTransportList&);
00140 uint DeleteUnusedTransports(uint sourceid);
00141
00142 void InsertChannels(const ScanDTVTransportList&,
00143 const ChannelImporterBasicStats&);
00144
00145 ScanDTVTransportList InsertChannels(
00146 const ScanDTVTransportList &transports,
00147 const ChannelImporterBasicStats &info,
00148 InsertAction action, ChannelType type,
00149 ScanDTVTransportList &filtered);
00150
00151 ScanDTVTransportList UpdateChannels(
00152 const ScanDTVTransportList &transports,
00153 const ChannelImporterBasicStats &info,
00154 UpdateAction action, ChannelType type,
00155 ScanDTVTransportList &filtered);
00156
00158 DeleteAction QueryUserDelete(const QString &msg);
00159
00161 InsertAction QueryUserInsert(const QString &msg);
00162
00164 UpdateAction QueryUserUpdate(const QString &msg);
00165
00167 OkCancelType QueryUserResolve(
00168 const ChannelImporterBasicStats &info,
00169 const ScanDTVTransport &transport,
00170 ChannelInsertInfo &chan);
00171
00173 OkCancelType QueryUserInsert(
00174 const ChannelImporterBasicStats &info,
00175 const ScanDTVTransport &transport,
00176 ChannelInsertInfo &chan);
00177
00178 static QString ComputeSuggestedChannelNum(
00179 const ChannelImporterBasicStats &info,
00180 const ScanDTVTransport &transport,
00181 const ChannelInsertInfo &chan);
00182
00183 static OkCancelType ShowManualChannelPopup(
00184 MythMainWindow *parent, QString title,
00185 QString message, QString &text);
00186
00187 static void FixUpOpenCable(ScanDTVTransportList &transports);
00188
00189 static ChannelImporterBasicStats CollectStats(
00190 const ScanDTVTransportList &transports);
00191
00192 static ChannelImporterUniquenessStats CollectUniquenessStats(
00193 const ScanDTVTransportList &transports,
00194 const ChannelImporterBasicStats &info);
00195
00196 static QString FormatChannels(
00197 const ScanDTVTransportList &transports,
00198 const ChannelImporterBasicStats &info);
00199
00200 static QString FormatChannel(
00201 const ScanDTVTransport &transport,
00202 const ChannelInsertInfo &chan,
00203 const ChannelImporterBasicStats *info = NULL);
00204
00205 static QString SimpleFormatChannel(
00206 const ScanDTVTransport &transport,
00207 const ChannelInsertInfo &chan);
00208
00209 static QString GetSummary(
00210 uint transport_count,
00211 const ChannelImporterBasicStats &info,
00212 const ChannelImporterUniquenessStats &stats);
00213
00214 static bool IsType(
00215 const ChannelImporterBasicStats &info,
00216 const ChannelInsertInfo &chan, ChannelType type);
00217
00218 static void CountChannels(
00219 const ScanDTVTransportList &transports,
00220 const ChannelImporterBasicStats &info,
00221 ChannelType type, uint &new_chan, uint &old_chan);
00222
00223 private:
00224 bool use_gui;
00225 bool is_interactive;
00226 bool do_delete;
00227 bool do_insert;
00228 bool do_save;
00230 bool m_fta_only;
00232 ServiceRequirements m_service_requirements;
00233 };
00234
00235 #endif // _CHANNEL_IMPORTER_H_