Go to the documentation of this file.
17 "SELECT mplexid, atsc_minor_chan, serviceid "
19 "WHERE deleted IS NULL AND "
20 " sourceid = :SOURCEID");
34 mplexid = (32767 == mplexid) ? 0 : mplexid;
36 if (mplexid && (
minor || prognum))
50 "WHERE sourceid = :SOURCEID");
73 "WHERE name = :NAME");
94 "WHERE deleted IS NULL AND "
95 " sourceid = :SOURCEID");
100 QMap<QString,uint> counts;
101 const QRegularExpression sepExpr(R
"((_|-|#|\.))");
104 const QString channum =
query.
value(0).toString();
105 const int where = channum.indexOf(sepExpr);
106 if (channum.rightRef(2).startsWith(
"0"))
109 counts[(where < 0) ?
"" : QString(channum.at(where))]++;
112 uint max = counts[
"_"];
113 static const std::array<const QString,5> s_spacers {
"",
"-",
"#",
".",
"0" };
114 for (
const auto & spacer : s_spacers)
116 if (counts[spacer] > max)
118 max = counts[spacer];
137 "WHERE deleted IS NULL AND "
138 " sourceid = :SOURCEID");
151 "FROM dtv_multiplex "
152 "WHERE sourceid = :SOURCEID");
155 std::vector<uint> list;
169 QString &grabber, QString &userid,
170 QString &passwd, QString &lineupid)
174 "SELECT xmltvgrabber, userid, password, lineupid "
176 "WHERE sourceid = :SOURCEID");
202 "SELECT cardtype, inputname "
204 "WHERE capturecard.sourceid = :SOURCEID");
214 QString inputtype =
query.
value(0).toString().toUpper();
215 QString inputname =
query.
value(1).toString().toUpper();
216 inputtype = ((inputtype ==
"DVB") && (!inputname.startsWith(
"DVB"))) ?
235 QMap<QString,uint> counts;
236 for (
const auto &
type : qAsConst(
types))
244 counts[
"ANALOG_TUNING"]++;
246 counts[
"DIGITAL_TUNING"]++;
248 counts[
"VIRTUAL_TUNING"]++;
252 ((counts[
"ANALOG_TUNING"] != 0U) && (counts[
"DIGITAL_TUNING"] != 0U)) ||
253 ((counts[
"VIRTUAL_TUNING"] != 0U) && (counts[
"DIGITAL_TUNING"] != 0U));
254 bool enc_mismatch = (counts[
"ENCODER"] != 0U) && (counts[
"NOT_ENCODER"] != 0U);
255 bool scan_mismatch = (counts[
"SCAN"] != 0U) && (counts[
"NO_SCAN"] != 0U);
259 uint a = counts[
"ANALOG_TUNERS"];
260 uint d = counts[
"DIGITAL_TUNERS"];
261 uint v = counts[
"VIRTUAL_TUNERS"];
262 LOG(VB_GENERAL, LOG_NOTICE,
263 QString(
"SourceUtil::IsProperlyConnected(): ") +
264 QString(
"Connected to %1 analog, %2 digital and %3 virtual "
266 QString(
"Can not mix digital with other tuning information."));
271 uint a = counts[
"ENCODER"];
272 uint d = counts[
"NOT_ENCODER"];
273 LOG(VB_GENERAL, LOG_NOTICE,
274 QString(
"SourceUtil::IsProperlyConnected(): ") +
275 QString(
"Source ID %1 ").
arg(sourceid) +
276 QString(
"appears to be connected\n\t\t\tto %1 encoder%2, ")
277 .
arg(a).
arg((1 == a) ?
"":
"s") +
278 QString(
"and %1 non-encoder%2. ")
280 QString(
"This is probably a bad idea."));
285 uint a = counts[
"SCAN"];
286 uint d = counts[
"NO_SCAN"];
287 LOG(VB_GENERAL, LOG_NOTICE,
288 QString(
"SourceUtil::IsProperlyConnected(): ") +
289 QString(
"Source ID %1 ").
arg(sourceid) +
290 QString(
"appears to be connected\n\t\t\t"
291 "to %1 scanable input%2, ")
292 .
arg(a).
arg((1 == a) ?
"":
"s") +
293 QString(
"and %1 non-scanable input%2. ")
295 QString(
"This may be a problem."));
299 return !tune_mismatch;
301 return !tune_mismatch && !enc_mismatch && !scan_mismatch;
308 bool encoder = std::all_of(
types.cbegin(),
types.cend(), isencoder);
317 "SELECT atsc_minor_chan, serviceid "
319 "WHERE deleted IS NULL AND "
320 " sourceid = :SOURCEID");
323 bool has_any_chan =
false;
335 return (strict && !has_any_chan) ?
false: encoder;
344 return std::all_of(
types.cbegin(),
types.cend(), unscannable);
350 auto ccpresent = [](
uint input)
353 return std::any_of(inputs.cbegin(), inputs.cend(), ccpresent);
380 "SELECT sourceid FROM videosource WHERE sourceid = :SOURCEID");
399 args.append(
"--only-update-channels");
403 args.append(QString(
"--sourceid"));
404 args.append(QString::number(sourceid));
406 if (!inputtype.isEmpty())
408 args.append(QString(
"--cardtype"));
409 args.append(inputtype);
419 "mythfilldatabase --only-update-channels";
421 cmd += QString(
" --sourceid %1").arg(sourceid);
422 if (!inputtype.isEmpty())
423 cmd += QString(
" --cardtype %1").arg(inputtype);
433 const QString& grabber,
const QString& userid,
434 const QString& freqtable,
const QString& lineupid,
435 const QString& password,
bool useeit,
436 const QString& configpath,
int nitid,
441 query.
prepare(
"UPDATE videosource SET name = :NAME, xmltvgrabber = :XMLTVGRABBER, "
442 "userid = :USERID, freqtable = :FREQTABLE, lineupid = :LINEUPID,"
443 "password = :PASSWORD, useeit = :USEEIT, configpath = :CONFIGPATH, "
444 "dvb_nit_id = :NITID, bouquet_id = :BOUQUETID, region_id = :REGIONID, "
445 "scanfrequency = :SCANFREQUENCY "
446 "WHERE sourceid = :SOURCEID");
455 query.
bindValue(
":CONFIGPATH", configpath.isEmpty() ?
nullptr : configpath);
472 const QString& grabber,
const QString& userid,
473 const QString& freqtable,
const QString& lineupid,
474 const QString& password,
bool useeit,
475 const QString& configpath,
int nitid,
480 query.
prepare(
"INSERT INTO videosource (name,xmltvgrabber,userid,freqtable,lineupid,"
481 "password,useeit,configpath,dvb_nit_id,bouquet_id,region_id, scanfrequency) "
482 "VALUES (:NAME, :XMLTVGRABBER, :USERID, :FREQTABLE, :LINEUPID, :PASSWORD, "
483 ":USEEIT, :CONFIGPATH, :NITID, :BOUQUETID, :REGIONID, :SCANFREQUENCY)");
492 query.
bindValue(
":CONFIGPATH", configpath.isEmpty() ?
nullptr : configpath);
526 "WHERE sourceid = :SOURCEID");
537 "SET deleted = NOW(), mplexid = 0, sourceid = 0 "
538 "WHERE deleted IS NULL AND sourceid = :SOURCEID");
550 "WHERE sourceid = :SOURCEID");
564 "WHERE sourceid = :SOURCEID");
591 "SET deleted = NOW(), mplexid = 0, sourceid = 0 "
592 "WHERE deleted IS NULL");
600 return (
query.
exec(
"TRUNCATE TABLE program") &&
601 query.
exec(
"TRUNCATE TABLE videosource") &&
603 query.
exec(
"TRUNCATE TABLE programrating") &&
604 query.
exec(
"TRUNCATE TABLE programgenres") &&
605 query.
exec(
"TRUNCATE TABLE dtv_multiplex") &&
606 query.
exec(
"TRUNCATE TABLE diseqc_config") &&
607 query.
exec(
"TRUNCATE TABLE diseqc_tree") &&
608 query.
exec(
"TRUNCATE TABLE eit_cache") &&
609 query.
exec(
"TRUNCATE TABLE channelgroup") &&
610 query.
exec(
"TRUNCATE TABLE channelgroupnames"));
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static std::vector< uint > GetInputIDs(const QString &videodevice=QString(), const QString &rawtype=QString(), const QString &inputname=QString(), QString hostname=QString())
Returns all inputids of inputs that uses the specified videodevice if specified, and optionally rawty...
static bool IsTuningVirtual(const QString &rawtype)
static bool DeleteSource(uint sourceid)
static QString GetSourceName(uint sourceid)
static bool IsCableCardPresent(uint sourceid)
static uint GetChannelCount(uint sourceid)
static bool IsProperlyConnected(uint sourceid, bool strict=false)
static std::vector< uint > GetMplexIDs(uint sourceid)
QVariant value(int i) const
arg(title).arg(filename).arg(doDelete))
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static QString GetChannelSeparator(uint sourceid)
static const struct wl_interface * types[]
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static QString GetChannelFormat(uint sourceid)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
static bool IsAnySourceScanable(void)
static bool IsSourceIDValid(uint sourceid)
static bool UpdateChannelsFromListings(uint sourceid, const QString &inputtype=QString(), bool wait=false)
static bool IsTuningDigital(const QString &rawtype)
static bool IsEncoder(const QString &rawtype)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
static bool UpdateSource(uint sourceid, const QString &sourcename, const QString &grabber, const QString &userid, const QString &freqtable, const QString &lineupid, const QString &password, bool useeit, const QString &configpath, int nitid, uint bouquetid, uint regionid, uint scanfrequency)
uint Wait(std::chrono::seconds timeout=0s)
static bool IsUnscanable(uint sourceid)
static bool HasDigitalChannel(uint sourceid)
static void DeleteScansFromSource(uint sourceid)
@ kMSRunShell
run process through shell
@ kMSAutoCleanup
automatically delete if backgrounded
static QString GetRawInputType(uint inputid)
static bool IsCableCardPresent(uint inputid, const QString &inputType)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QString GetAppBinDir(void)
static bool DeleteAllSources(void)
static bool IsEncoder(uint sourceid, bool strict=false)
static bool GetListingsLoginData(uint sourceid, QString &grabber, QString &userid, QString &passwd, QString &lineupid)
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
static const iso6937table * d
static uint GetConnectionCount(uint sourceid)
static int CreateSource(const QString &sourcename, const QString &grabber, const QString &userid, const QString &freqtable, const QString &lineupid, const QString &password, bool useeit, const QString &configpath, int nitid, uint bouquetid, uint regionid, uint scanfrequency)
static QStringList get_inputtypes(uint sourceid)
static bool IsTuningAnalog(const QString &rawtype)
static bool IsUnscanable(const QString &rawtype)
static uint GetSourceID(const QString &name)
MSqlQuery query(MSqlQuery::InitCon())
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.