[PATCH] Re: [mythtv] Feature Request
DanM
dan at milkcarton.com
Tue Oct 14 00:05:34 EDT 2003
Jim Chandler wrote:
> Where do feature requests get submitted to? I looked on
You usually do the work and submit the patch; thats the feature request
process :-) But I was bored this evening so I decided to code this up as
this is a feature I would like as well.
A vast majority of this code is borrowed from John Danners' mythvideo
pin code stuff.
-dan
--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdzlolyb\nu.pax\nlek.n";char *strchr(const char*,int);
while(*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);}return 0;}
Days never finished, massa's got me workin, someday massa set me free...
-------------- next part --------------
Index: libs/libmyth/themedmenu.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/themedmenu.cpp,v
retrieving revision 1.58
diff -u -d -r1.58 themedmenu.cpp
--- libs/libmyth/themedmenu.cpp 13 Oct 2003 21:23:29 -0000 1.58
+++ libs/libmyth/themedmenu.cpp 14 Oct 2003 06:49:21 -0000
@@ -1827,7 +1827,24 @@
menufiles.back().row = currentrow;
menufiles.back().col = currentcolumn;
- parseMenu(rest);
+ if(rest == "main_settings.xml")
+ {
+ if(gContext->GetNumSetting("SetupPinCodeRequired", 0))
+ {
+ if(checkPinCode("SetupPinCodeTime", "SetupPinCode", "Setup Pin:"))
+ {
+ parseMenu(rest);
+ }
+ }
+ else
+ {
+ parseMenu(rest);
+ }
+ }
+ else
+ {
+ parseMenu(rest);
+ }
}
else if (action.left(6) == "UPMENU")
{
@@ -1881,3 +1898,74 @@
return false;
}
+
+bool ThemedMenu::checkPinCode(QString timestamp_setting, QString password_setting, QString text)
+{
+ QDateTime curr_time = QDateTime::currentDateTime();
+ QString last_time_stamp = gContext->GetSetting(timestamp_setting);
+ QString password = gContext->GetSetting(password_setting);
+ if(password.length() < 1)
+ {
+ return true;
+ }
+
+ //
+ // See if we recently (and succesfully)
+ // asked for a password
+ //
+
+ if(last_time_stamp.length() < 1)
+ {
+ //
+ // Probably first time used
+ //
+
+ cerr << "themedmenu.o: Could not read password/pin time stamp. "
+ << "This is only an issue if it happens repeatedly. " << endl;
+ }
+ else
+ {
+ QDateTime last_time = QDateTime::fromString(last_time_stamp, Qt::TextDate);
+ if(last_time.secsTo(curr_time) < 120)
+ {
+ //
+ // Two minute window
+ //
+ last_time_stamp = curr_time.toString(Qt::TextDate);
+ gContext->SetSetting(timestamp_setting, last_time_stamp);
+ gContext->SaveSetting(timestamp_setting, last_time_stamp);
+ return true;
+ }
+ }
+
+ //
+ // See if there is a password set
+ //
+
+ if(password.length() > 0)
+ {
+ bool ok = false;
+ MythPasswordDialog *pwd = new MythPasswordDialog(text,
+ &ok,
+ password,
+ gContext->GetMainWindow());
+ pwd->exec();
+ delete pwd;
+ if(ok)
+ {
+ //
+ // All is good
+ //
+
+ last_time_stamp = curr_time.toString(Qt::TextDate);
+ gContext->SetSetting(timestamp_setting, last_time_stamp);
+ gContext->SaveSetting(timestamp_setting, last_time_stamp);
+ return true;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ return false;
+}
Index: libs/libmyth/themedmenu.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/themedmenu.h,v
retrieving revision 1.29
diff -u -d -r1.29 themedmenu.h
--- libs/libmyth/themedmenu.h 13 Oct 2003 21:23:29 -0000 1.29
+++ libs/libmyth/themedmenu.h 14 Oct 2003 06:49:21 -0000
@@ -147,6 +147,7 @@
void clearToBackground(void);
void drawInactiveButtons(void);
void drawScrollArrows(QPainter *p);
+ bool checkPinCode(QString timestamp_setting, QString password_setting, QString text);
QString prefix;
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.97
diff -u -d -r1.97 globalsettings.cpp
--- programs/mythfrontend/globalsettings.cpp 8 Oct 2003 00:45:41 -0000 1.97
+++ programs/mythfrontend/globalsettings.cpp 14 Oct 2003 06:49:22 -0000
@@ -682,6 +682,32 @@
};
};
+class SetupPinCode: public LineEditSetting, public GlobalSetting {
+public:
+ SetupPinCode():
+ GlobalSetting("SetupPinCode") {
+ setLabel("Setup Pin Code");
+ setHelpText("This PIN is used to control access to the setup menues."
+ "If you want to use this feature, then setting the value "
+ "to all numbers will make your life much easier. If you "
+ "don't want to be bothered by PC dialogs, please set it "
+ "to be blank.");
+ };
+};
+
+class SetupPinCodeRequired: public CheckBoxSetting, public GlobalSetting {
+public:
+ SetupPinCodeRequired():
+ GlobalSetting("SetupPinCodeRequired") {
+ setLabel(QObject::tr("Require Setup PIN"));
+ setValue(false);
+ setHelpText(QObject::tr("If set, you will not be able to return "
+ "to this screen and reset the Setup "
+ "PIN without first entering the current PIN. You have "
+ "been warned."));
+ };
+};
+
class XineramaScreen: public SpinBoxSetting, public GlobalSetting {
public:
XineramaScreen():
@@ -1163,6 +1189,8 @@
VerticalConfigurationGroup* general = new VerticalConfigurationGroup(false);
general->addChild(new AllowQuitShutdown());
general->addChild(new HaltCommand());
+ general->addChild(new SetupPinCodeRequired());
+ general->addChild(new SetupPinCode());
general->addChild(new EnableXbox());
addChild(general);
}
More information about the mythtv-dev
mailing list