summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/mythinstall/autocard.cpp
diff options
context:
space:
mode:
authorGreg Frost <gregfrost1@bigpond.com>2009-08-01 23:56:22 (GMT)
committerGreg Frost <gregfrost1@bigpond.com>2009-08-01 23:56:22 (GMT)
commit3f300e50406f82e3fde4f48dd7c14fa79cbcd99a (patch)
treebf1e47d23befa44bba74f5d47c109fe3dfbc069e /abs/core-testing/mythinstall/autocard.cpp
parentd5b30b14e06db375bcf5069f23f47213a65adeed (diff)
downloadlinhes_pkgbuild-3f300e50406f82e3fde4f48dd7c14fa79cbcd99a.zip
linhes_pkgbuild-3f300e50406f82e3fde4f48dd7c14fa79cbcd99a.tar.gz
linhes_pkgbuild-3f300e50406f82e3fde4f48dd7c14fa79cbcd99a.tar.bz2
LinHES-config mythinstall: add mythinstall with changes for tz autodetect
Diffstat (limited to 'abs/core-testing/mythinstall/autocard.cpp')
-rwxr-xr-xabs/core-testing/mythinstall/autocard.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/abs/core-testing/mythinstall/autocard.cpp b/abs/core-testing/mythinstall/autocard.cpp
new file mode 100755
index 0000000..585fba7
--- /dev/null
+++ b/abs/core-testing/mythinstall/autocard.cpp
@@ -0,0 +1,186 @@
+#include "libmyth/mythcontext.h"
+#include "libmyth/mythdbcon.h"
+#include <qsqldatabase.h>
+#include <qheader.h>
+#include <qcursor.h>
+#include <qlayout.h>
+#include <iostream>
+#include "autocard.h"
+#include <stdlib.h>
+#include <cstdlib>
+
+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(gContext->GetMainWindow(),
+ "", 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 );
+ 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 );
+
+
+ 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;
+}