Skip to content
Browse files

Complete mythtv-setup modifications for new EIT crosssource feature. …

…videosourcemaps now handled correctly for cloned cardinputs.
  • Loading branch information...
1 parent c37f105 commit 4e064254019866b589584d48e632f106b0bbfd18 @pinkylinc committed May 28, 2012
Showing with 161 additions and 78 deletions.
  1. +76 −6 mythtv/libs/libmythtv/cardutil.cpp
  2. +71 −70 mythtv/libs/libmythtv/videosource.cpp
  3. +14 −2 mythtv/libs/libmythtv/videosource.h
View
82 mythtv/libs/libmythtv/cardutil.cpp
@@ -825,7 +825,7 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
" livetvorder = :V9 "
"WHERE cardinputid = :INPUTID");
- for (uint j = 0; j < 11; j++)
+ for (uint j = 0; j < 10; j++)
{
query2.bindValue(QString(":V%1").arg(j),
query.value(j).toString());
@@ -844,7 +844,6 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
else
{
// create new input for dst with data from src
-
query2.prepare(
"INSERT cardinput "
"SET cardid = :CARDID, "
@@ -860,7 +859,7 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
" livetvorder = :V9 ");
query2.bindValue(":CARDID", dst_cardid);
- for (uint j = 0; j < 11; j++)
+ for (uint j = 0; j < 10; j++)
{
query2.bindValue(QString(":V%1").arg(j),
query.value(j).toString());
@@ -879,7 +878,7 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
"WHERE cardid = :CARDID AND "
" inputname = :NAME");
query2.bindValue(":CARDID", dst_cardid);
- query2.bindValue(":NAME", query.value(1).toString());
+ query2.bindValue(":NAME", query.value(0).toString());
if (!query2.exec())
{
MythDB::DBError("clone_cardinput -- "
@@ -893,7 +892,6 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
ok = false;
break;
}
-
dst_inputid = query2.value(0).toUInt();
}
@@ -910,7 +908,6 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
if (diseqc.Load(src_inputs[i]))
diseqc.Store(dst_inputid);
}
-
// delete extra inputs in dst
for (uint i = 0; i < dst_inputs.size(); i++)
{
@@ -921,6 +918,77 @@ static bool clone_cardinputs(uint src_cardid, uint dst_cardid)
return ok;
}
+static bool clone_videosourcemap(uint src_cardid, uint dst_cardid)
+{
+ vector<uint> src_inputs = CardUtil::GetInputIDs(src_cardid);
+ vector<uint> dst_inputs = CardUtil::GetInputIDs(dst_cardid);
+ vector<QString> src_names;
+ vector<QString> dst_names;
+ QMap<uint,bool> dst_keep;
+
+ for (uint i = 0; i < src_inputs.size(); i++)
+ src_names.push_back(CardUtil::GetInputName(src_inputs[i]));
+
+ for (uint i = 0; i < dst_inputs.size(); i++)
+ dst_names.push_back(CardUtil::GetInputName(dst_inputs[i]));
+
+ bool ok = true;
+
+ MSqlQuery query(MSqlQuery::InitCon());
+ MSqlQuery query2(MSqlQuery::InitCon());
+
+ for (uint i = 0; i < src_inputs.size(); i++)
+ {
+ // Remove clone videosourcemaps
+ MSqlQuery query3(MSqlQuery::InitCon());
+ query3.prepare(
+ "DELETE FROM videosourcemap "
+ "WHERE cardinputid = :INPUTID ");
+ query3.bindValue(":INPUTID", dst_inputs[i]);
+
+ if (!query3.exec())
+ {
+ MythDB::DBError("clone_videosourcemap()", query3);
+ ok = false;
+ break;
+ }
+
+ query.prepare(
+ "SELECT sourceid, type "
+ "FROM videosourcemap "
+ "WHERE cardinputid = :INPUTID");
+ query.bindValue(":INPUTID", src_inputs[i]);
+ if (!query.exec())
+ {
+ MythDB::DBError("clone_videosourcemap -- get data", query);
+ ok = false;
+ break;
+ }
+
+ while (query.next())
+ {
+ // create new input for dst with data from src
+ query2.prepare(
+ "INSERT videosourcemap "
+ "SET sourceid = :V0, "
+ " cardinputid = :INPUTID, "
+ " type = :V1 ");
+
+ query2.bindValue(":V0", query.value(0).toString());
+ query2.bindValue(":V1", query.value(1).toString());
+ query2.bindValue(":INPUTID", dst_inputs[i]);
+
+ if (!query2.exec())
+ {
+ MythDB::DBError("clone_videosourcemap -- insert data", query2);
+ ok = false;
+ break;
+ }
+ }
+ }
+ return ok;
+}
+
bool CardUtil::CloneCard(uint src_cardid, uint orig_dst_cardid)
{
QString type = CardUtil::GetRawCardType(src_cardid);
@@ -937,6 +1005,8 @@ bool CardUtil::CloneCard(uint src_cardid, uint orig_dst_cardid)
return false;
}
+ clone_videosourcemap(src_cardid, dst_cardid);
+
return true;
}
View
141 mythtv/libs/libmythtv/videosource.cpp
@@ -159,8 +159,6 @@ QString VideoSourceMapDBStorage::GetSetClause(MSqlBindings& bindings) const
bindings.insert(colTag, user->GetDBValue());
-LOG(VB_GENERAL, LOG_INFO, QString("VideoSourceMapDBStorage::GetSetClause: Column = %1, Value = %2").arg(GetColumnName()).arg(user->GetDBValue()));
-
return query;
}
@@ -538,7 +536,8 @@ CrossSourceCardInputSel::CrossSourceCardInputSel(
{
setLabel(QObject::tr(_label));
setHelpText(QObject::tr(_helptext));
- LOG(VB_GENERAL, LOG_INFO, QString("CrossSourceCardInputSel::CrossSourceCardInputSel: maptype = %1, sourceid = %2").arg(maptype).arg(QString::number(sourceid)));
+ LOG(VB_GENERAL, LOG_DEBUG, QString("CrossSourceCardInputSel::CrossSourceCardInputSel: "
+ "maptype = %1, sourceid = %2").arg(maptype).arg(QString::number(sourceid)));
};
void CrossSourceCardInputSel::fillSelections()
@@ -548,6 +547,7 @@ void CrossSourceCardInputSel::fillSelections()
addSelection("(None)", "0");
cardinputs_map["(None)"] = -1;
+ initialcid = 0;
// We do this manually because we want custom labels. If
// SelectSetting provided a facility to edit the labels, we
@@ -589,11 +589,12 @@ void CrossSourceCardInputSel::fillSelections()
for (int i = 0; i < inputLabels.size(); i++, j++)
{
- addSelection(inputLabels[i], QString::number( cardInputs[i]->getInputID() ));
- if (cardInputs[i]->setSourceMap(maptype, sourceid))
+ int cardinputid = cardInputs[i]->getInputID();
+ addSelection(inputLabels[i], QString::number( cardinputid ));
+ if (cardInputs[i]->setSourceMap(maptype, sourceid, cardinputid))
{
- this->setValue( QString::number( cardInputs[i]->getInputID() ) );
- LOG(VB_GENERAL, LOG_INFO, QString("CrossSourceCardInputSel::fillSelections: setValue for %1").arg(inputLabels[i]));
+ initialcid = cardinputid;
+ this->setValue( QString::number(initialcid));
}
cardinputs.push_back(cardInputs[i]);
cardinputs_map[inputLabels[i]] = j;
@@ -603,29 +604,25 @@ void CrossSourceCardInputSel::fillSelections()
void CrossSourceCardInputSel::Save(void)
{
- // Clear cardinputid from the videosourcemap entry so that it will be updated with any new value
- MSqlQuery query(MSqlQuery::InitCon());
- query.prepare("UPDATE videosourcemap "
- "SET cardinputid = 0 "
- "WHERE sourceid = :SOURCEID "
- "AND type = :MAPTYPE ");
- query.bindValue(":SOURCEID", sourceid);
- query.bindValue(":MAPTYPE", maptype);
- if (!query.exec())
- MythDB::DBError("CrossSourceCardInputSel::Save", query);
-
int val = cardinputs_map[ getSelectionLabel() ];
-
- LOG(VB_GENERAL, LOG_INFO, QString("CrossSourceCardInputSel::Save: Label = %1, Val = %2").arg(getSelectionLabel()).arg(QString::number(val)));
-
if ((val >= 0) && (cardinputs[val]))
{
- LOG(VB_GENERAL, LOG_INFO, QString("CrossSourceCardInputSel::Save: Saving entry for sourceid %1").arg(QString::number(sourceid)));
-
- cardinputs[val]->reload(); //Update id in event that cardinput didn't previously exist
- cardinputs[val]->setSourceMap(maptype, parent.getSourceID()); //Update sourceid in the event that videosource didn't previously exist.
+ cardinputs[val]->reload(); // Update id in event that cardinput didn't previously exist
+ cardinputs[val]->setSourceMap(maptype, sourceid, initialcid); // Update sourceid in the event that videosource didn't previously exist.
cardinputs[val]->Save();
}
+ else
+ {
+ // Remove entry and sync with cardinput clones
+ for (uint i = 0; i < cardinputs.size(); i++)
+ {
+ if (initialcid == cardinputs[i]->getInputID())
+ {
+ CardUtil::DeleteVideoSourceMap( cardinputs[i]->getMapID() );
+ cardinputs[i]->SyncDB();
+ }
+ }
+ }
}
CrossSource_config::CrossSource_config(const VideoSource& _parent) :
@@ -675,10 +672,7 @@ void CrossSource_config::Save(void)
eitcombobox->Save();
scancombobox->Save();
useeit->Save();
- // Delete any orphaned or unused videosource maps
- CardUtil::DeleteOrphanVideoSourceMaps();
- // Delete any unused inputs
- CardUtil::DeleteUnusedInputs();
+
}
NoGrabber_config::NoGrabber_config(const VideoSource& _parent) :
@@ -2953,6 +2947,7 @@ void StartingChannel::SetSourceID(const QString &sourceid)
// Get the existing starting channel
QString startChan = CardUtil::GetStartingChannel(getInputID());
+
DBChanInfoList channels = ChannelUtil::GetAllChannels(sourceid.toUInt());
if (channels.empty())
@@ -3058,6 +3053,9 @@ CardInput::CardInput(bool isDTVcard, bool isDVBcard,
inputname(new InputName(*this)),
sourcemapid(new SourceMapID()),
sourceid(new SourceID(*this)),
+
+ sourcecid(new SourceMapCID(*this)),
+
sourcemaptype(new VideoSourceMapType(*this)),
startchan(new StartingChannel(*this)),
scan(new TransButtonSetting()),
@@ -3085,6 +3083,7 @@ CardInput::CardInput(bool isDTVcard, bool isDVBcard,
basic->addChild(new InputDisplayName(*this));
basic->addChild(sourceid);
+ basic->addChild(sourcecid);
basic->addChild(sourcemaptype);
maptype = QString("main");
@@ -3180,46 +3179,62 @@ void CardInput::SetSourceID(const QString &sourceid)
int CardInput::findSourceMapID(void) const
{
MSqlQuery query(MSqlQuery::InitCon());
- query.prepare(
- "SELECT mapid "
- "FROM videosourcemap "
- "WHERE (cardinputid = :CARDINPUTID OR "
- " cardinputid = 0) "
- "AND (type = :MAPTYPE OR "
- " type = '') "
- "ORDER BY cardinputid");
- query.bindValue(":CARDINPUTID", getInputID());
- query.bindValue(":MAPTYPE", maptype);
+
+ if (sourceid->getValue() > 0)
+ {
+ query.prepare(
+ "SELECT mapid "
+ "FROM videosourcemap "
+ "WHERE cardinputid = :CARDINPUTID AND "
+ " sourceid = :SOURCEID AND "
+ " (type = :MAPTYPE OR "
+ " type = '') ");
+
+ query.bindValue(":CARDINPUTID", initialcid);
+ query.bindValue(":SOURCEID", sourceid->getValue());
+ query.bindValue(":MAPTYPE", maptype);
+ }
+ else
+ {
+ query.prepare(
+ "SELECT mapid "
+ "FROM videosourcemap "
+ "WHERE cardinputid = :CARDINPUTID AND "
+ " (type = :MAPTYPE OR "
+ " type = '') ");
+
+ query.bindValue(":CARDINPUTID", initialcid);
+ query.bindValue(":MAPTYPE", maptype);
+ }
if (!query.exec())
{
MythDB::DBError("CardInput::findSourceMapID", query);
}
else if (query.next())
{
- LOG(VB_GENERAL, LOG_INFO, QString("CardInput::findSourceMapID = %1, filter = %2, maptype = %3, sourceid = %4, cardinputid = %5.")
+ LOG(VB_GENERAL, LOG_DEBUG, QString("CardInput::findSourceMapID = %1, filter = %2, maptype = %3, sourceid = %4, cardinputid = %5.")
.arg(query.value(0).toString()).arg(maptype).arg(sourcemaptype->getValue()).arg(sourceid->getValue()).arg(getInputID()));
return (query.value(0).toInt());
}
- LOG(VB_GENERAL, LOG_INFO, QString("CardInput::findSourceMapID = 0, filter = %1, maptype = %2, sourceid = %3, cardinputid = %4.")
- .arg(maptype).arg(sourcemaptype->getValue()).arg(sourceid->getValue()).arg(getInputID()));
- return 0;
+
+ return 0;
}
-bool CardInput::setSourceMap(const QString &_maptype, const int _sourceid)
+bool CardInput::setSourceMap(const QString &_maptype, const int _sourceid, const int _initialcid)
{
maptype = _maptype;
+ initialcid = _initialcid;
+ sourceid->setValue(QString::number(_sourceid));
loadByID(getInputID());
- bool current = (sourceid->getValue().toInt() > 0);
- LOG(VB_GENERAL, LOG_INFO, QString("CardInput::setSourceMap: Filter = %1, maptype = %2, sourceid = %3, cardinputid = %4.")
- .arg(maptype).arg(sourcemaptype->getValue()).arg(sourceid->getValue()).arg(getInputID()));
+ bool exists = (sourceid->getValue().toInt() > 0);
sourcemaptype->setValue(maptype);
sourceid->setValue(QString::number(_sourceid));
- return current;
+ return exists;
}
QString CardInput::getSourceName(void) const
@@ -3426,30 +3441,16 @@ void CardInput::reload(void)
void CardInput::Save(void)
{
-LOG(VB_GENERAL, LOG_INFO, QString("CardInput::Save - About to save..."));
-
ConfigurationWizard::Save();
-
-LOG(VB_GENERAL, LOG_INFO, QString("CardInput::Save - Save finished. Now updating..."));
-
+ sourcecid->setValue(getInputID());
+ sourcecid->Save();
externalInputSettings->Store(getInputID());
+ LOG(VB_GENERAL, LOG_DEBUG, QString("CardInput::Save - videosourcemap cardinputid updated with %1... now syncing card clones").arg(getInputID()));
+ SyncDB();
+}
- // Update cardinputid from with a valid ID as it may be a new entry
- // FIXME: Perhaps this could be replaced with a simpledbstorage class?
- MSqlQuery query(MSqlQuery::InitCon());
- query.prepare("UPDATE videosourcemap "
- "SET cardinputid = :CARDINPUTID "
- "WHERE cardinputid = 0 "
- "AND type = :MAPTYPE ");
- query.bindValue(":CARDINPUTID", getInputID());
- query.bindValue(":MAPTYPE", maptype);
- if (!query.exec())
- MythDB::DBError("CardInput::Save", query);
-
-LOG(VB_GENERAL, LOG_INFO, QString("CardInput::Save - videosourcemap cardinputid updated... now cleaning up"));
-
- // FIXME: NEED TO CHECK CLONING WITH THE NEW SOURCEID MODEL
-
+void CardInput::SyncDB(void)
+{
// Handle any cloning we may need to do
uint src_cardid = cardid->getValue().toUInt();
QString type = CardUtil::GetRawCardType(src_cardid);
@@ -3471,9 +3472,9 @@ LOG(VB_GENERAL, LOG_INFO, QString("CardInput::Save - videosourcemap cardinputid
CardUtil::DeleteOrphanVideoSourceMaps();
// Delete any unused inputs
CardUtil::DeleteUnusedInputs();
-LOG(VB_GENERAL, LOG_INFO, QString("CardInput::Save - Cleanup finished"));
}
+
int CardInputDBStorage::getInputID(void) const
{
return m_parent.getInputID();
View
16 mythtv/libs/libmythtv/videosource.h
@@ -18,7 +18,6 @@ class CardInput;
class CardID;
class InputName;
class SourceID;
-class SourceIDtest;
class VideoSourceMapType;
class DiSEqCDevTree;
class DiSEqCDevSettings;
@@ -228,6 +227,7 @@ class CrossSourceCardInputSel : public TransComboBoxSetting
private:
QString maptype;
uint sourceid;
+ int initialcid;
const VideoSource &parent;
};
@@ -824,10 +824,11 @@ class CardInput : public QObject, public ConfigurationWizard
int getInputID(void) const { return id->intValue(); };
int getMapID(void) const { return sourcemapid->intValue(); };
- bool setSourceMap(const QString &_maptype, const int _sourceid);
+ bool setSourceMap(const QString &_maptype, const int _sourceid, const int _initialcid);
void loadByID(int id);
void loadByInput(int cardid, QString input);
void reload();
+ void SyncDB(void);
QString getSourceName(void) const;
virtual void Save(void);
virtual void Save(QString /*destination*/) { Save(); }
@@ -858,14 +859,25 @@ class CardInput : public QObject, public ConfigurationWizard
setName("CardInputID");
}
};
+ class SourceMapCID : public IntegerSetting, public VideoSourceMapDBStorage
+ {
+ public:
+ SourceMapCID(const CardInput &parent) :
+ IntegerSetting(this), VideoSourceMapDBStorage(this, parent, "cardinputid")
+ {
+ setVisible(false);
+ }
+ };
ID *id;
CardID *cardid;
InputName *inputname;
SourceMapID *sourcemapid;
SourceID *sourceid;
+ SourceMapCID *sourcecid;
VideoSourceMapType *sourcemaptype;
QString maptype;
+ uint initialcid;
StartingChannel *startchan;
TransButtonSetting *scan;
TransButtonSetting *srcfetch;

0 comments on commit 4e06425

Please sign in to comment.
Something went wrong with that request. Please try again.