Permalink
Browse files

Fix Perl bindings config.xml parsing

for users who are using non-default values for database host name, port,
user name, password, or database name.  Though I plan to add proper XML
parsing to the bindings, this code will still be useful as a fallback
for those who don't have the proper XML parsing module installed, so it
makes sense to go ahead and push these changes, now.
  • Loading branch information...
1 parent fb132ff commit b10ca6a647248c29ab58f47d537bdacf360debd2 @sphery sphery committed May 30, 2012
Showing with 33 additions and 14 deletions.
  1. +33 −14 mythtv/bindings/perl/MythTV.pm
@@ -246,26 +246,37 @@ package MythTV;
print CONF <<EOF;
<Configuration>
<UPnP>
+ <UDN>
+ <MediaRenderer>$upnp->{usn}</MediaRenderer>
+ </UDN>
<MythFrontend>
<DefaultBackend>
<USN>$upnp->{usn}</USN>
<SecurityPin>$pin</SecurityPin>
- <DBHostName>$upnp->{db_host}</DBHostName>
- <DBUserName>$upnp->{db_user}</DBUserName>
- <DBPassword>$upnp->{db_pass}</DBPassword>
- <DBName>$upnp->{db_name}</DBName>
- <DBPort>$upnp->{db_port}</DBPort>
</DefaultBackend>
</MythFrontend>
</UPnP>
+ <LocalHostName>my-unique-identifier-goes-here</LocalHostName>
+ <Database>
+ <PingHost>1</PingHost>
+ <Host>$upnp->{db_host}</Host>
+ <UserName>$upnp->{db_user}</UserName>
+ <Password>$upnp->{db_pass}</Password>
+ <DatabaseName>$upnp->{db_name}</DatabaseName>
+ <Port>$upnp->{db_port}</Port>
+ </Database>
+ <WakeOnLAN>
+ <Enabled>0</Enabled>
+ <SQLReconnectWaitTime>0</SQLReconnectWaitTime>
+ <SQLConnectRetry>5</SQLConnectRetry>
+ <Command>echo 'WOLsqlServerCommand not set'</Command>
+ </WakeOnLAN>
</Configuration>
EOF
close CONF;
}
-# Read the mysql.txt file in use by MythTV. It could be in a couple places,
-# so try the usual suspects in the same order that mythtv does in
-# libs/libmyth/mythcontext.cpp
+# Read the config.xml file in use by MythTV.
our %mysql_conf = ('hostname' => hostname,
'db_host' => 'localhost',
'db_port' => '',
@@ -280,27 +291,35 @@ EOF
if ($line =~ m#<SecurityPin>(.*?)</SecurityPin>#) {
$mysql_conf{'upnp_pin'} = $1;
}
- elsif ($line =~ m#<DBHostName>(.*?)</DBHostName>#) {
+ elsif (($line =~ m#<Host>(.*?)</Host>#) ||
+ ($line =~ m#<DBHostName>(.*?)</DBHostName>#)) {
$mysql_conf{'db_host'} = $1;
}
- elsif ($line =~ m#<DBUserName>(.*?)</DBUserName>#) {
+ elsif (($line =~ m#<UserName>(.*?)</UserName>#) ||
+ ($line =~ m#<DBUserName>(.*?)</DBUserName>#)) {
$mysql_conf{'db_user'} = $1;
}
- elsif ($line =~ m#<DBPassword>(.*?)</DBPassword>#) {
+ elsif (($line =~ m#<Password>(.*?)</Password>#) ||
+ ($line =~ m#<DBPassword>(.*?)</DBPassword>#)) {
$mysql_conf{'db_pass'} = $1;
$mysql_conf{'db_pass'} =~ s/&amp;/&/sg;
$mysql_conf{'db_pass'} =~ s/&gt;/>/sg;
$mysql_conf{'db_pass'} =~ s/&lt;/</sg;
}
- elsif ($line =~ m#<DBName>(.*?)</DBName>#) {
+ elsif (($line =~ m#<DatabaseName>(.*?)</DatabaseName>#) ||
+ ($line =~ m#<DBName>(.*?)</DBName>#)) {
$mysql_conf{'db_name'} = $1;
}
- elsif ($line =~ m#<DBPort>(\d*?)</DBPort>#) {
+ elsif (($line =~ m#<Port>(\d*?)</Port>#) ||
+ ($line =~ m#<DBPort>(.*?)</DBPort>#)) {
$mysql_conf{'db_port'} = $1;
}
# Hostname override. Not sure if this is still valid or not
elsif ($line =~ m#<LocalHostName>(.*?)</LocalHostName>#) {
- $mysql_conf{'hostname'} = $1;
+ $profileoverride = $1;
+ if ($profileoverride ne "my-unique-identifier-goes-here") {
+ $mysql_conf{'hostname'} = $profileoverride;
+ }
}
}
close CONF;

0 comments on commit b10ca6a

Please sign in to comment.