[mythtv] [PATCH] Add support for specifying directory to use for
configuration
Nathan Neulinger
nneul at umr.edu
Sun Feb 13 00:32:07 UTC 2005
This patch adds a global named "relative_conf_dir" to mythcontext, and uses
that instead of the hardwired .mythtv everywhere.
Also added (just to mythfrontend for now) a "--confdir .mythtv" command
line option to allow specifying which dir to use relative to the homedir.
I use myth on my primary desktop system and usually like watching programs
in a 800x600 window, however, occasionally I like to watch stuff full
screen. Mythfrontend as it stands now doesn't provide any non-tedious way
to accomplish that.
Here's how I'm using this new facility:
1. Two menu items to start up mythfrontend:
A) mythfrontend
B) mythfrontend --confdir .mythtv-fullscreen
2. Two config dirs. .mythtv is the same as .mythtv-fullscreen, except
the -fullscreen one specifies a LocalHostName to pick a different
set of preferences that are configured to display full screen,
and other tuning more suitable for large display.
Patch is attached and should be fairly non-invasive. Only change I made that I
was at all unsure about was adding the include of mythcontext.h to oldsettings.cpp.
-- Nathan
------------------------------------------------------------
Nathan Neulinger EMail: nneul at umr.edu
University of Missouri - Rolla Phone: (573) 341-6679
UMR Information Technology Fax: (573) 341-4216
-------------- next part --------------
Index: libs/libmyth/mythcontext.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.cpp,v
retrieving revision 1.152
diff -u -r1.152 mythcontext.cpp
--- libs/libmyth/mythcontext.cpp 11 Feb 2005 01:27:43 -0000 1.152
+++ libs/libmyth/mythcontext.cpp 13 Feb 2005 00:18:43 -0000
@@ -43,6 +43,7 @@
MythContext *gContext = NULL;
int print_verbose_messages = VB_IMPORTANT | VB_GENERAL;
+QString relative_conf_dir = ".mythtv";
class MythContextPrivate
{
@@ -288,7 +289,7 @@
bool MythContextPrivate::WriteSettingsFile(const DatabaseParams ¶ms,
bool overwrite)
{
- QString path = QDir::homeDirPath() + "/.mythtv/mysql.txt";
+ QString path = QDir::homeDirPath() + "/" + relative_conf_dir + "/mysql.txt";
QFile * f = new QFile(path);
if (!overwrite && f->exists())
@@ -296,14 +297,14 @@
return false;
}
- QString dirpath = QDir::homeDirPath() + "/.mythtv";
+ QString dirpath = QDir::homeDirPath() + "/" + relative_conf_dir;
QDir createDir(dirpath);
if (!createDir.exists())
{
if (!createDir.mkdir(dirpath, true))
{
- VERBOSE(VB_IMPORTANT, "Could not create ~/.mythtv");
+ VERBOSE(VB_IMPORTANT, QString("Could not create %1").arg(dirpath));
return false;
}
}
@@ -881,7 +882,7 @@
void MythContext::ClearOldImageCache(void)
{
- QString cachedirname = QDir::homeDirPath() + "/.mythtv/themecache/";
+ QString cachedirname = QDir::homeDirPath() + "/" + relative_conf_dir + "/themecache/";
d->themecachedir = cachedirname + GetSetting("Theme") + "." +
QString::number(d->m_screenwidth) + "." +
@@ -925,7 +926,7 @@
void MythContext::RemoveCacheDir(const QString &dirname)
{
- QString cachedirname = QDir::homeDirPath() + "/.mythtv/themecache/";
+ QString cachedirname = QDir::homeDirPath() + "/" + relative_conf_dir + "/themecache/";
if (!dirname.startsWith(cachedirname))
return;
@@ -1151,7 +1152,7 @@
QString MythContext::FindThemeDir(const QString &themename)
{
- QString testdir = QDir::homeDirPath() + "/.mythtv/themes/" + themename;
+ QString testdir = QDir::homeDirPath() + "/" + relative_conf_dir + "/themes/" + themename;
QDir dir(testdir);
if (dir.exists())
Index: libs/libmyth/mythcontext.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.h,v
retrieving revision 1.180
diff -u -r1.180 mythcontext.h
--- libs/libmyth/mythcontext.h 31 Jan 2005 17:15:16 -0000 1.180
+++ libs/libmyth/mythcontext.h 13 Feb 2005 00:18:43 -0000
@@ -132,6 +132,7 @@
#define MYTH_PROTO_VERSION "14"
extern int print_verbose_messages;
+extern QString relative_conf_dir;
class MythContextPrivate;
Index: libs/libmyth/mythdialogs.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythdialogs.cpp,v
retrieving revision 1.102
diff -u -r1.102 mythdialogs.cpp
--- libs/libmyth/mythdialogs.cpp 8 Feb 2005 08:38:23 -0000 1.102
+++ libs/libmyth/mythdialogs.cpp 13 Feb 2005 00:18:44 -0000
@@ -45,7 +45,7 @@
static void *SpawnLirc(void *param)
{
MythMainWindow *main_window = (MythMainWindow *)param;
- QString config_file = QDir::homeDirPath() + "/.mythtv/lircrc";
+ QString config_file = QDir::homeDirPath() + "/" + relative_conf_dir + "/lircrc";
QString program("mythtv");
LircClient *cl = new LircClient(main_window);
if (!cl->Init(config_file, program))
@@ -59,7 +59,7 @@
static void *SpawnJoystickMenu(void *param)
{
MythMainWindow *main_window = (MythMainWindow *)param;
- QString config_file = QDir::homeDirPath() + "/.mythtv/joystickmenurc";
+ QString config_file = QDir::homeDirPath() + "/" + relative_conf_dir + "/joystickmenurc";
JoystickMenuClient *js = new JoystickMenuClient(main_window);
if (!js->Init(config_file))
js->Process();
Index: libs/libmyth/oldsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/oldsettings.cpp,v
retrieving revision 1.5
diff -u -r1.5 oldsettings.cpp
--- libs/libmyth/oldsettings.cpp 20 Jan 2004 07:12:17 -0000 1.5
+++ libs/libmyth/oldsettings.cpp 13 Feb 2005 00:18:44 -0000
@@ -10,6 +10,7 @@
#include "oldsettings.h"
+#include "mythcontext.h"
#include <qstring.h>
#include <fstream>
#include <cstdlib>
@@ -120,7 +121,8 @@
if (ReadSettings(setname))
result = true;
- setname = QDir::homeDirPath() + "/.mythtv/" + filename;
+ setname = QDir::homeDirPath() + "/" + relative_conf_dir +
+ "/" + filename;
if (ReadSettings(setname))
result = true;
Index: libs/libmyth/themedmenu.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/themedmenu.cpp,v
retrieving revision 1.102
diff -u -r1.102 themedmenu.cpp
--- libs/libmyth/themedmenu.cpp 11 Feb 2005 02:37:52 -0000 1.102
+++ libs/libmyth/themedmenu.cpp 13 Feb 2005 00:18:44 -0000
@@ -2306,7 +2306,8 @@
QString ThemedMenuPrivate::findMenuFile(const QString &menuname)
{
- QString testdir = QDir::homeDirPath() + "/.mythtv/" + menuname;
+ QString testdir = QDir::homeDirPath() + "/" + relative_conf_dir +
+ "/" + menuname;
QFile file(testdir);
if (file.exists())
return testdir;
Index: libs/libmythtv/osd.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/osd.cpp,v
retrieving revision 1.111
diff -u -r1.111 osd.cpp
--- libs/libmythtv/osd.cpp 10 Feb 2005 07:33:01 -0000 1.111
+++ libs/libmythtv/osd.cpp 13 Feb 2005 00:18:45 -0000
@@ -246,7 +246,8 @@
QString OSD::FindTheme(QString name)
{
- QString testdir = QDir::homeDirPath() + "/.mythtv/osd/" + name;
+ QString testdir = QDir::homeDirPath() + "/" + relative_conf_dir +
+ "/osd/" + name;
QDir dir(testdir);
if (dir.exists())
@@ -267,7 +268,8 @@
TTFFont *OSD::LoadFont(QString name, int size)
{
- QString fullname = QDir::homeDirPath() + "/.mythtv/" + name;
+ QString fullname = QDir::homeDirPath() + "/" + relative_conf_dir +
+ "/" + name;
TTFFont *font = new TTFFont((char *)fullname.ascii(), size, vid_width,
vid_height, hmult);
Index: libs/libmythtv/videosource.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videosource.cpp,v
retrieving revision 1.66
diff -u -r1.66 videosource.cpp
--- libs/libmythtv/videosource.cpp 11 Feb 2005 19:06:14 -0000 1.66
+++ libs/libmythtv/videosource.cpp 13 Feb 2005 00:18:45 -0000
@@ -393,8 +393,8 @@
"list of available channels"));
pdlg.show();
- QString filename = QString("%1/.mythtv/%2.xmltv")
- .arg(QDir::homeDirPath()).arg(parent.getSourceName());
+ QString filename = QString("%1/%2/%3.xmltv")
+ .arg(QDir::homeDirPath()).arg(relative_conf_dir).arg(parent.getSourceName());
QString command = QString("tv_grab_uk --config-file '%1' --configure --retry-limit %2 --retry-delay %3 --postalcode %4 --provider %5 --auto-new-channels add")
.arg(filename)
.arg(2)
@@ -448,8 +448,8 @@
if (grabber == "tv_grab_de") {
command = "tv_grab_de --configure";
} else {
- QString filename = QString("%1/.mythtv/%2.xmltv")
- .arg(QDir::homeDirPath()).arg(parent.getSourceName());
+ QString filename = QString("%1/%2/%3.xmltv")
+ .arg(QDir::homeDirPath()).arg(relative_conf_dir).arg(parent.getSourceName());
command = QString("%1 --config-file '%2' --configure")
.arg(grabber).arg(filename);
Index: libs/libmythui/mythmainwindow.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythui/mythmainwindow.cpp,v
retrieving revision 1.5
diff -u -r1.5 mythmainwindow.cpp
--- libs/libmythui/mythmainwindow.cpp 11 Sep 2004 15:31:37 -0000 1.5
+++ libs/libmythui/mythmainwindow.cpp 13 Feb 2005 00:18:45 -0000
@@ -30,7 +30,8 @@
static void *SpawnLirc(void *param)
{
MythMainWindow *main_window = (MythMainWindow *)param;
- QString config_file = QDir::homeDirPath() + "/.mythtv/lircrc";
+ QString config_file = QDir::homeDirPath() + "/" +
+ relative_conf_dir + "/lircrc";
QString program("mythtv");
LircClient *cl = new LircClient(main_window);
if (!cl->Init(config_file, program))
Index: libs/libmythui/oldsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythui/oldsettings.cpp,v
retrieving revision 1.1
diff -u -r1.1 oldsettings.cpp
--- libs/libmythui/oldsettings.cpp 24 Aug 2004 05:03:50 -0000 1.1
+++ libs/libmythui/oldsettings.cpp 13 Feb 2005 00:18:45 -0000
@@ -120,7 +120,7 @@
if (ReadSettings(setname))
result = true;
- setname = QDir::homeDirPath() + "/.mythtv/" + filename;
+ setname = QDir::homeDirPath() + "/" . relative_conf_dir + "/" + filename;
if (ReadSettings(setname))
result = true;
Index: libs/libmythui/themedmenu.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythui/themedmenu.cpp,v
retrieving revision 1.5
diff -u -r1.5 themedmenu.cpp
--- libs/libmythui/themedmenu.cpp 21 Jan 2005 06:50:19 -0000 1.5
+++ libs/libmythui/themedmenu.cpp 13 Feb 2005 00:18:45 -0000
@@ -1956,7 +1956,8 @@
QString ThemedMenuPrivate::findMenuFile(const QString &menuname)
{
- QString testdir = QDir::homeDirPath() + "/.mythtv/" + menuname;
+ QString testdir = QDir::homeDirPath() + "/" + relative_conf_dir
+ + "/" + menuname;
QFile file(testdir);
if (file.exists())
return testdir;
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfilldatabase/filldata.cpp,v
retrieving revision 1.156
diff -u -r1.156 filldata.cpp
--- programs/mythfilldatabase/filldata.cpp 9 Feb 2005 21:35:13 -0000 1.156
+++ programs/mythfilldatabase/filldata.cpp 13 Feb 2005 00:18:47 -0000
@@ -1861,7 +1861,7 @@
static QString SetupIconCacheDirectory()
{
- QString fileprefix = QDir::homeDirPath() + "/.mythtv";
+ QString fileprefix = QDir::homeDirPath() + "/" + relative_conf_dir;
QDir dir(fileprefix);
if (!dir.exists())
@@ -2518,7 +2518,7 @@
QString filename = QString(tempfilename);
QString home = QDir::homeDirPath();
- QString configfile = QString("%1/.mythtv/%2.xmltv").arg(home)
+ QString configfile = QString("%1/%2/%3.xmltv").arg(home).arg(relative_conf_dir)
.arg(source.name);
QString command;
Index: programs/mythfrontend/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/main.cpp,v
retrieving revision 1.183
diff -u -r1.183 main.cpp
--- programs/mythfrontend/main.cpp 9 Feb 2005 16:45:34 -0000 1.183
+++ programs/mythfrontend/main.cpp 13 Feb 2005 00:18:47 -0000
@@ -852,6 +852,22 @@
cout << MYTH_BINARY_VERSION << endl;
exit(0);
}
+ else if (!strcmp(a.argv()[argpos],"--confdir"))
+ {
+ if (a.argc() > argpos)
+ {
+ relative_conf_dir = a.argv()[argpos+1];
+ if (logfile.startsWith("-"))
+ {
+ cerr << "Invalid or missing argument to --confdir option\n";
+ return -1;
+ }
+ else
+ {
+ ++argpos;
+ }
+ }
+ }
else if ((argpos + 1 == a.argc()) &&
!QString(a.argv()[argpos]).startsWith("-"))
{
@@ -901,7 +917,7 @@
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
cerr << "Unable to ignore SIGPIPE\n";
- QString fileprefix = QDir::homeDirPath() + "/.mythtv";
+ QString fileprefix = QDir::homeDirPath() + "/" + relative_conf_dir;
QDir dir(fileprefix);
if (!dir.exists())
Index: setup/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/setup/main.cpp,v
retrieving revision 1.52
diff -u -r1.52 main.cpp
--- setup/main.cpp 4 Feb 2005 19:36:04 -0000 1.52
+++ setup/main.cpp 13 Feb 2005 00:18:48 -0000
@@ -126,7 +126,7 @@
gContext->SetSetting("Theme", "blue");
gContext->LoadQtConfig();
- QString fileprefix = QDir::homeDirPath() + "/.mythtv";
+ QString fileprefix = QDir::homeDirPath() + "/" + relative_conf_dir;
QDir dir(fileprefix);
if (!dir.exists())
More information about the mythtv-dev
mailing list