summaryrefslogtreecommitdiffstats
path: root/abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-12-09 23:00:51 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-12-09 23:00:51 (GMT)
commit23b63734b90bb8c37d88673383002cbd210cdc99 (patch)
tree8179ce273843f1527fc515c1fd59df75d0d9c77d /abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp
parent9c7a9f742bbe8a69bdf50335e8218a45c3f28721 (diff)
downloadlinhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.zip
linhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.tar.gz
linhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.tar.bz2
mythinstall: pull in MythVantage src to LH tree.
more cleanup to many modules. access can now disable remotes and screensaver
Diffstat (limited to 'abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp')
-rwxr-xr-xabs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp182
1 files changed, 182 insertions, 0 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp b/abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp
new file mode 100755
index 0000000..cfd7fb3
--- /dev/null
+++ b/abs/core/mythinstall/MythVantage-app/mythinstall/autocard.cpp
@@ -0,0 +1,182 @@
+//#include "libmyth/mythdbcon.h"
+#include "mythdbcon.h"
+#include <mythtv/mythdbcon.h>
+#include "autocard.h"
+#include <stdlib.h>
+
+AutoCard::AutoCard(void) :
+ listbox(new ListBoxSetting(this))
+{
+ listbox->setLabel(tr("Cards"));
+ addChild(listbox);
+}
+void AutoCard::popup_menu(void)
+{
+ QString name = listbox->getValue();
+// //cout << "in popup" << name << endl;
+ QString uniqid = name.section(' ', -1);
+ QString description = name.section('*',-3,-3);
+ description = description.section('.',1);
+ description = description.stripWhiteSpace();
+// //cout << uniqid << endl;
+// //cout << "descriptn" << endl;
+// //cout << description << endl;
+ if (name.isEmpty() || name == "Default")
+ return;
+
+ QString message = tr("Cardme:") +
+ QString("\n'%1'?").arg(name);
+
+ DialogCode value = MythPopupBox::Show2ButtonPopup(GetMythMainWindow(),
+ "", message,
+ tr("Add Card"),
+ tr("Do not Add"), kDialogCodeButton0);
+
+ if ( value == kDialogCodeButton1)
+ {
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("update autocard set devicestatus ='unused' where uniqid=:UNIQID and description=:DESCRIPTION;");
+ query.bindValue(":UNIQID",uniqid );
+ query.bindValue(":DESCRIPTION",description );
+ //FINDME
+ // if (!query.exec())
+ // MythContext::DBError("Autocard::popup", query);
+
+ int lastIndex = listbox->getValueIndex(name);
+ lastValue = "";
+ load();
+ listbox->setValue(lastIndex);
+ }
+ else if (value == kDialogCodeButton0)
+ {
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("update autocard set devicestatus ='will-add' where uniqid=:UNIQID and description=:DESCRIPTION;");
+ query.bindValue(":UNIQID",uniqid );
+ query.bindValue(":DESCRIPTION",description );
+
+//FNDME
+// if (!query.exec())
+// MythContext::DBError("Autocard::popup", query);
+
+ int lastIndex = listbox->getValueIndex(name);
+ lastValue = "";
+ load();
+ listbox->setValue(lastIndex);
+
+
+
+
+ }
+
+
+ listbox->setFocus();
+}
+
+
+
+QStringList AutoCard::GetNames(void)
+{
+ QStringList names;
+ QString device;
+ QString description;
+ QString displayname ;
+ QString status ;
+ QString uniqid;
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("SELECT dev,description,uniqid,devicestatus FROM autocard order by uniqid");
+ if (query.exec() && query.isActive() && query.size() > 0)
+ {
+ while (query.next())
+ {
+ device=query.value(0).toString();
+ description=query.value(1).toString();
+ uniqid=query.value(2).toString();
+ status=query.value(3).toString();
+ //displayname=device;
+ displayname=". ";
+ displayname.append(description);
+ displayname.append(" * ");
+ displayname.append(status);
+ displayname.append(" * ");
+
+ displayname.append(uniqid);
+ names << displayname ;
+ }
+
+ return names;
+ }
+}
+
+void AutoCard::open(QString name)
+{
+ lastValue = name;
+ bool created = false;
+ //cout << name << endl;
+ if (name == "Mark all cards for addition")
+ {
+ //cout <<"updating all cards" << endl;
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("update autocard set devicestatus='will-add' where devicestatus='unused' order by uniqid");
+ query.exec();
+ }
+ else if ( name == "Perform actions" )
+ {
+ // write udev rules and reload udev
+
+ system ("sudo autocard.py -w -i");
+ system ("sudo autocard.py -r");
+
+ }
+ else if ( name == "Exit" )
+ {
+ // write udev rules and reload udev
+ exit(0);
+ }
+ else
+ {
+ popup_menu();
+// bool ok = MythPopupBox::showGetTextPopup(gContext->GetMainWindow(),
+// tr("Create New Playback Group"),
+// tr("Enter group name or press SELECT to enter text via the "
+// "On Screen Keyboard"), name);
+
+
+ }
+
+};
+
+void AutoCard::load(void)
+{
+ listbox->clearSelections();
+
+
+ QStringList names = AutoCard::GetNames();
+ while (!names.isEmpty())
+ {
+ listbox->addSelection(names.front());
+ names.pop_front();
+ }
+ listbox->addSelection("Mark all cards for addition");
+ listbox->addSelection("Perform actions");
+ listbox->addSelection("Exit");
+ listbox->setValue(lastValue);
+
+}
+
+
+int AutoCard::exec(void)
+{
+ while (ConfigurationDialog::exec() == QDialog::Accepted)
+ open(listbox->getValue());
+
+ return QDialog::Rejected;
+}
+
+
+MythDialog* AutoCard::dialogWidget(MythMainWindow* parent,
+ const char* widgetName)
+{
+ dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
+ connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(popup_menu()));
+ return dialog;
+}