Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
49efb607
Commit
49efb607
authored
Jul 18, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Migrate: library to migrate deprecated settings
parent
8df98932
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
120 additions
and
11 deletions
+120
-11
Makefile.am
Makefile.am
+1
-0
Data.cxx
src/config/Data.cxx
+15
-0
Data.hxx
src/config/Data.hxx
+3
-0
Global.cxx
src/config/Global.cxx
+3
-1
Migrate.cxx
src/config/Migrate.cxx
+63
-0
Migrate.hxx
src/config/Migrate.hxx
+31
-0
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+0
-10
run_filter.cxx
test/run_filter.cxx
+2
-0
run_output.cxx
test/run_output.cxx
+2
-0
No files found.
Makefile.am
View file @
49efb607
...
...
@@ -1011,6 +1011,7 @@ libconf_a_SOURCES = \
src/config/Parser.cxx src/config/Parser.hxx
\
src/config/Global.cxx src/config/Global.hxx
\
src/config/File.cxx src/config/File.hxx
\
src/config/Migrate.cxx src/config/Migrate.hxx
\
src/config/Templates.cxx src/config/Templates.hxx
\
src/config/Domain.cxx src/config/Domain.hxx
\
src/config/Option.hxx
...
...
src/config/Data.cxx
View file @
49efb607
...
...
@@ -180,3 +180,18 @@ ConfigData::FindBlock(ConfigBlockOption option,
return
nullptr
;
}
ConfigBlock
&
ConfigData
::
MakeBlock
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
)
{
auto
*
block
=
const_cast
<
ConfigBlock
*>
(
FindBlock
(
option
,
key
,
value
));
if
(
block
==
nullptr
)
{
auto
new_block
=
std
::
make_unique
<
ConfigBlock
>
();
new_block
->
AddBlockParam
(
key
,
value
);
block
=
new_block
.
get
();
AddBlock
(
option
,
std
::
move
(
new_block
));
}
return
*
block
;
}
src/config/Data.hxx
View file @
49efb607
...
...
@@ -101,6 +101,9 @@ struct ConfigData {
gcc_pure
const
ConfigBlock
*
FindBlock
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
)
const
;
ConfigBlock
&
MakeBlock
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
);
};
#endif
src/config/Global.cxx
View file @
49efb607
...
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "Global.hxx"
#include "Migrate.hxx"
#include "Data.hxx"
#include "Block.hxx"
#include "File.hxx"
...
...
@@ -48,7 +49,8 @@ GetGlobalConfig() noexcept
void
ReadConfigFile
(
Path
path
)
{
return
ReadConfigFile
(
config_data
,
path
);
ReadConfigFile
(
config_data
,
path
);
Migrate
(
config_data
);
}
static
void
...
...
src/config/Migrate.cxx
0 → 100644
View file @
49efb607
/*
* Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Migrate.hxx"
#include "Data.hxx"
#include "Block.hxx"
static
void
MigrateParamToBlockParam
(
ConfigData
&
config
,
ConfigOption
old_option
,
ConfigBlockOption
new_block_option
,
const
char
*
block_id_key
,
const
char
*
block_id_value
,
const
char
*
block_value_key
)
noexcept
{
const
auto
*
param
=
config
.
GetParam
(
old_option
);
if
(
param
==
nullptr
)
return
;
auto
&
block
=
config
.
MakeBlock
(
new_block_option
,
block_id_key
,
block_id_value
);
if
(
block
.
GetBlockParam
(
block_value_key
)
==
nullptr
)
block
.
AddBlockParam
(
block_value_key
,
param
->
value
,
param
->
line
);
}
static
void
MigrateCurlProxyConfig
(
ConfigData
&
config
)
noexcept
{
MigrateParamToBlockParam
(
config
,
ConfigOption
::
HTTP_PROXY_HOST
,
ConfigBlockOption
::
INPUT
,
"plugin"
,
"curl"
,
"proxy"
);
MigrateParamToBlockParam
(
config
,
ConfigOption
::
HTTP_PROXY_PORT
,
ConfigBlockOption
::
INPUT
,
"plugin"
,
"curl"
,
"proxy_port"
);
MigrateParamToBlockParam
(
config
,
ConfigOption
::
HTTP_PROXY_USER
,
ConfigBlockOption
::
INPUT
,
"plugin"
,
"curl"
,
"proxy_user"
);
MigrateParamToBlockParam
(
config
,
ConfigOption
::
HTTP_PROXY_PASSWORD
,
ConfigBlockOption
::
INPUT
,
"plugin"
,
"curl"
,
"proxy_password"
);
}
void
Migrate
(
ConfigData
&
config
)
noexcept
{
MigrateCurlProxyConfig
(
config
);
}
src/config/Migrate.hxx
0 → 100644
View file @
49efb607
/*
* Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_MIGRATE_HXX
#define MPD_CONFIG_MIGRATE_HXX
struct
ConfigData
;
/**
* Migrate deprecated #Config settings to new-style settings.
*/
void
Migrate
(
ConfigData
&
config
)
noexcept
;
#endif
src/input/plugins/CurlInputPlugin.cxx
View file @
49efb607
...
...
@@ -31,7 +31,6 @@
#include "../IcyInputStream.hxx"
#include "IcyMetaDataParser.hxx"
#include "../InputPlugin.hxx"
#include "config/Global.hxx"
#include "config/Block.hxx"
#include "tag/Builder.hxx"
#include "tag/Tag.hxx"
...
...
@@ -328,15 +327,6 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
proxy_user
=
block
.
GetBlockValue
(
"proxy_user"
);
proxy_password
=
block
.
GetBlockValue
(
"proxy_password"
);
if
(
proxy
==
nullptr
)
{
/* deprecated proxy configuration */
proxy
=
config_get_string
(
ConfigOption
::
HTTP_PROXY_HOST
);
proxy_port
=
config_get_positive
(
ConfigOption
::
HTTP_PROXY_PORT
,
0
);
proxy_user
=
config_get_string
(
ConfigOption
::
HTTP_PROXY_USER
);
proxy_password
=
config_get_string
(
ConfigOption
::
HTTP_PROXY_PASSWORD
,
""
);
}
verify_peer
=
block
.
GetBlockValue
(
"verify_peer"
,
true
);
verify_host
=
block
.
GetBlockValue
(
"verify_host"
,
true
);
}
...
...
test/run_filter.cxx
View file @
49efb607
...
...
@@ -21,6 +21,7 @@
#include "config/Param.hxx"
#include "config/Data.hxx"
#include "config/File.hxx"
#include "config/Migrate.hxx"
#include "fs/Path.hxx"
#include "AudioParser.hxx"
#include "AudioFormat.hxx"
...
...
@@ -79,6 +80,7 @@ try {
ConfigData
config
;
ReadConfigFile
(
config
,
config_path
);
Migrate
(
config
);
/* parse the audio format */
...
...
test/run_output.cxx
View file @
49efb607
...
...
@@ -24,6 +24,7 @@
#include "config/Param.hxx"
#include "config/Data.hxx"
#include "config/File.hxx"
#include "config/Migrate.hxx"
#include "config/Option.hxx"
#include "config/Block.hxx"
#include "event/Thread.hxx"
...
...
@@ -124,6 +125,7 @@ try {
ConfigData
config
;
ReadConfigFile
(
config
,
config_path
);
Migrate
(
config
);
EventThread
io_thread
;
io_thread
.
Start
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment