19 "SELECT mplexid, atsc_minor_chan, serviceid " 21 "WHERE sourceid = :SOURCEID");
35 mplexid = (32767 == mplexid) ? 0 : mplexid;
37 if (mplexid && (
minor || prognum))
51 "WHERE sourceid = :SOURCEID");
59 else if (!query.
next())
64 return query.
value(0).toString();
72 "WHERE sourceid = :SOURCEID");
77 QMap<QString,uint> counts;
78 const QRegExp sepExpr(
"(_|-|#|\\.)");
81 const QString channum = query.
value(0).toString();
82 const int where = channum.indexOf(sepExpr);
83 if (channum.right(2).startsWith(
"0"))
86 counts[(where < 0) ?
"" : QString(channum.at(where))]++;
89 uint max = counts[
"_"];
90 static const char *spacers[6] = {
"",
"-",
"#",
".",
"0",
nullptr };
91 for (
uint i=0; (spacers[i] !=
nullptr); ++i)
93 if (counts[spacers[i]] > max)
95 max = counts[spacers[i]];
114 "WHERE sourceid = :SOURCEID");
117 return query.
value(0).toUInt();
127 "FROM dtv_multiplex " 128 "WHERE sourceid = :SOURCEID");
139 list.push_back(query.
value(0).toUInt());
145 QString &grabber, QString &userid,
146 QString &passwd, QString &lineupid)
150 "SELECT xmltvgrabber, userid, password, lineupid " 152 "WHERE sourceid = :SOURCEID");
164 grabber = query.
value(0).toString();
165 userid = query.
value(1).toString();
166 passwd = query.
value(2).toString();
167 lineupid = query.
value(3).toString();
178 "SELECT cardtype, inputname " 180 "WHERE capturecard.sourceid = :SOURCEID");
190 QString inputtype = query.
value(0).toString().toUpper();
191 QString inputname = query.
value(1).toString().toUpper();
192 inputtype = ((inputtype ==
"DVB") && (!inputname.startsWith(
"DVB"))) ?
211 QMap<QString,uint> counts;
212 QStringList::const_iterator it = types.begin();
213 for (; it != types.end(); ++it)
221 counts[
"ANALOG_TUNING"]++;
223 counts[
"DIGITAL_TUNING"]++;
225 counts[
"VIRTUAL_TUNING"]++;
229 (counts[
"ANALOG_TUNING"] && counts[
"DIGITAL_TUNING"]) ||
230 (counts[
"VIRTUAL_TUNING"] && counts[
"DIGITAL_TUNING"]);
231 bool enc_mismatch = counts[
"ENCODER"] && counts[
"NOT_ENCODER"];
232 bool scan_mismatch = counts[
"SCAN"] && counts[
"NO_SCAN"];
236 uint a = counts[
"ANALOG_TUNERS"];
237 uint d = counts[
"DIGITAL_TUNERS"];
238 uint v = counts[
"VIRTUAL_TUNERS"];
239 LOG(VB_GENERAL, LOG_NOTICE,
240 QString(
"SourceUtil::IsProperlyConnected(): ") +
241 QString(
"Connected to %1 analog, %2 digital and %3 virtual " 242 "tuners\n\t\t\t").arg(a).arg(
d).arg(v) +
243 QString(
"Can not mix digital with other tuning information."));
248 uint a = counts[
"ENCODER"];
249 uint d = counts[
"NOT_ENCODER"];
250 LOG(VB_GENERAL, LOG_NOTICE,
251 QString(
"SourceUtil::IsProperlyConnected(): ") +
252 QString(
"Source ID %1 ").arg(sourceid) +
253 QString(
"appears to be connected\n\t\t\tto %1 encoder%2, ")
254 .arg(a).arg((1 == a) ?
"":
"s") +
255 QString(
"and %1 non-encoder%2. ")
256 .arg(
d).arg((1 ==
d) ?
"":
"s") +
257 QString(
"This is probably a bad idea."));
262 uint a = counts[
"SCAN"];
263 uint d = counts[
"NO_SCAN"];
264 LOG(VB_GENERAL, LOG_NOTICE,
265 QString(
"SourceUtil::IsProperlyConnected(): ") +
266 QString(
"Source ID %1 ").arg(sourceid) +
267 QString(
"appears to be connected\n\t\t\t" 268 "to %1 scanable input%2, ")
269 .arg(a).arg((1 == a) ?
"":
"s") +
270 QString(
"and %1 non-scanable input%2. ")
271 .arg(
d).arg((1 ==
d) ?
"":
"s") +
272 QString(
"This may be a problem."));
276 return !tune_mismatch;
278 return !tune_mismatch && !enc_mismatch && !scan_mismatch;
286 QStringList::const_iterator it = types.begin();
287 for (; it != types.end(); ++it)
297 "SELECT atsc_minor_chan, serviceid " 299 "WHERE sourceid = :SOURCEID");
302 bool has_any_chan =
false;
309 encoder &= !query.
value(0).toInt() && !query.
value(1).toInt();
314 return (strict && !has_any_chan) ?
false: encoder;
319 bool unscanable =
true;
321 QStringList::const_iterator it = types.begin();
322 for (; it != types.end(); ++it)
325 return types.empty() || unscanable;
330 bool ccpresent =
false;
332 vector<uint>::iterator it = inputs.begin();
333 for (; it != inputs.end(); ++it)
346 query.
prepare(
"SELECT sourceid FROM videosource");
370 args.append(
"--only-update-channels");
374 args.append(QString(
"--sourceid"));
375 args.append(QString::number(sourceid));
377 if (!inputtype.isEmpty())
379 args.append(QString(
"--cardtype"));
380 args.append(inputtype);
390 "mythfilldatabase --only-update-channels";
392 cmd += QString(
" --sourceid %1").arg(sourceid);
393 if (!inputtype.isEmpty())
394 cmd += QString(
" --cardtype %1").arg(inputtype);
404 QString grabber, QString userid,
405 QString freqtable, QString lineupid,
406 QString password,
bool useeit,
407 QString configpath,
int nitid)
411 query.
prepare(
"UPDATE videosource SET name = :NAME, xmltvgrabber = :XMLTVGRABBER, " 412 "userid = :USERID, freqtable = :FREQTABLE, lineupid = :LINEUPID," 413 "password = :PASSWORD, useeit = :USEEIT, configpath = :CONFIGPATH, " 414 "dvb_nit_id = :NITID WHERE sourceid = :SOURCEID");
417 query.
bindValue(
":XMLTVGRABBER", grabber);
419 query.
bindValue(
":FREQTABLE", freqtable);
423 query.
bindValue(
":CONFIGPATH", configpath);
437 QString grabber, QString userid,
438 QString freqtable, QString lineupid,
439 QString password,
bool useeit,
440 QString configpath,
int nitid)
444 query.
prepare(
"INSERT INTO videosource (name,xmltvgrabber,userid,freqtable,lineupid," 445 "password,useeit,configpath,dvb_nit_id) VALUES (:NAME, :XMLTVGRABBER, " 446 ":USERID, :FREQTABLE, :LINEUPID, :PASSWORD, :USEEIT, :CONFIGPATH, :NITID)");
449 query.
bindValue(
":XMLTVGRABBER", grabber);
451 query.
bindValue(
":FREQTABLE", freqtable);
455 query.
bindValue(
":CONFIGPATH", configpath);
464 query.
prepare(
"SELECT MAX(sourceid) FROM videosource");
475 sourceid = query.
value(0).toInt();
485 query.
prepare(
"DELETE FROM channel " 486 "WHERE sourceid = :SOURCEID");
496 query.
prepare(
"DELETE FROM dtv_multiplex " 497 "WHERE sourceid = :SOURCEID");
507 query.
prepare(
"UPDATE capturecard " 509 "WHERE sourceid = :SOURCEID");
519 query.
prepare(
"DELETE FROM videosource " 520 "WHERE sourceid = :SOURCEID");
537 query.
prepare(
"UPDATE capturecard " 545 return (query.
exec(
"TRUNCATE TABLE channel") &&
546 query.
exec(
"TRUNCATE TABLE program") &&
547 query.
exec(
"TRUNCATE TABLE videosource") &&
548 query.
exec(
"TRUNCATE TABLE credits") &&
549 query.
exec(
"TRUNCATE TABLE programrating") &&
550 query.
exec(
"TRUNCATE TABLE programgenres") &&
551 query.
exec(
"TRUNCATE TABLE dtv_multiplex") &&
552 query.
exec(
"TRUNCATE TABLE diseqc_config") &&
553 query.
exec(
"TRUNCATE TABLE diseqc_tree") &&
554 query.
exec(
"TRUNCATE TABLE eit_cache") &&
555 query.
exec(
"TRUNCATE TABLE channelgroup") &&
556 query.
exec(
"TRUNCATE TABLE channelgroupnames"));
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static vector< uint > GetMplexIDs(uint sourceid)
void Run(time_t timeout=0)
Runs a command inside the /bin/sh shell. Returns immediately.
void bindValue(const QString &placeholder, const QVariant &val)
static bool IsCableCardPresent(uint sourceid)
automatically delete if backgrounded
static uint GetChannelCount(uint sourceid)
static bool DeleteSource(uint sourceid)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static bool IsAnySourceScanable(void)
static bool IsUnscanable(const QString &rawtype)
static bool IsUnscanable(uint sourceid)
static bool IsEncoder(const QString &rawtype)
static QString GetSourceName(uint sourceid)
QVariant value(int i) const
static QString GetChannelFormat(uint sourceid)
static QStringList get_inputtypes(uint sourceid)
static int CreateSource(QString sourcename, QString grabber, QString userid, QString freqtable, QString lineupid, QString password, bool useeit, QString configpath, int nitid)
static bool UpdateChannelsFromListings(uint sourceid, QString inputtype=QString(), bool wait=false)
static bool HasDigitalChannel(uint sourceid)
static const uint16_t * d
QString GetAppBinDir(void)
run process through shell
static QString GetChannelSeparator(uint sourceid)
static bool IsCableCardPresent(uint inputid, const QString &inputType)
bool isActive(void) const
static vector< uint > GetInputIDs(QString videodevice=QString(), QString rawtype=QString(), QString inputname=QString(), QString hostname=QString())
Returns all inputids of inputs that uses the specified videodevice if specified, and optionally rawty...
static bool IsTuningDigital(const QString &rawtype)
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
uint myth_system(const QString &command, uint flags, uint timeout)
static uint GetConnectionCount(uint sourceid)
uint Wait(time_t timeout=0)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
#define LOG(_MASK_, _LEVEL_, _STRING_)
static bool IsTuningVirtual(const QString &rawtype)
static bool DeleteAllSources(void)
static QString GetRawInputType(uint inputid)
static bool IsTuningAnalog(const QString &rawtype)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static bool IsEncoder(uint sourceid, bool strict=false)
static bool GetListingsLoginData(uint sourceid, QString &grabber, QString &userid, QString &passwd, QString &lineupid)
static void DBError(const QString &where, const MSqlQuery &query)
static bool IsProperlyConnected(uint sourceid, bool strict=false)
static bool UpdateSource(uint sourceid, QString sourcename, QString grabber, QString userid, QString freqtable, QString lineupid, QString password, bool useeit, QString configpath, int nitid)