Skip to content

Commit 61b3352

Browse files
committed
configure settings.xml during build to define USB not supported
This change it to settings.xml.in and set on add-on compile the settings usable or not. Is done by change the `<visible>` value and set of default connection type. The settings are still inside to prevent problems if something tries somewhere to read it. Further can for build the cmake configuration value "-DUSB_DEVICE_SUPPORT=0" used and if wanted to disable USB support.
1 parent 3e8be30 commit 61b3352

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

CMakeLists.txt

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ project(pvr.rtlradio)
44
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
55

66
option(DISTRIBUTION_BUILD "Linux distribution build (without use of depends folder)" OFF)
7-
87
if(CORE_SYSTEM_NAME STREQUAL windowsstore)
98
set(USB_DEVICE_SUPPORT False)
109
else()
11-
set(USB_DEVICE_SUPPORT True)
10+
option(USB_DEVICE_SUPPORT "Build add-on with USB device support, if set to \"OFF\" RTL-SDR can only be accessed via network" ON)
11+
endif()
12+
13+
# Set values used about configure of settings.xml.in on add-on
14+
if(NOT USB_DEVICE_SUPPORT)
15+
set(SETTINGS_XML_IN_CONNECTION_TYPE_NOTE "USB device not suppoted on this add-on, due to this the following setting is not usable and marked as not visible.")
16+
set(SETTINGS_XML_IN_CONNECTION_TYPE_DEFAULT "1")
17+
set(SETTINGS_XML_IN_CONNECTION_TYPE_VISIBLE "false")
18+
set(SETTINGS_XML_IN_NO_USB_BEGIN "<!--")
19+
set(SETTINGS_XML_IN_NO_USB_END "-->")
20+
else()
21+
set(SETTINGS_XML_IN_CONNECTION_TYPE_NOTE "USB device supported on this add-on.")
22+
set(SETTINGS_XML_IN_CONNECTION_TYPE_DEFAULT "0")
23+
set(SETTINGS_XML_IN_CONNECTION_TYPE_VISIBLE "true")
24+
set(SETTINGS_XML_IN_NO_USB_BEGIN "")
25+
set(SETTINGS_XML_IN_NO_USB_END "")
1226
endif()
1327

1428
find_package(Kodi REQUIRED)

pvr.rtlradio/resources/settings.xml pvr.rtlradio/resources/settings.xml.in

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
<category id="device" label="30000">
66
<group id="1" label="-1">
77

8+
<!-- @SETTINGS_XML_IN_CONNECTION_TYPE_NOTE@ -->
89
<setting id="device_connection" type="integer" label="30100" help="30500">
910
<level>0</level>
10-
<default>0</default>
11+
<visible>@SETTINGS_XML_IN_CONNECTION_TYPE_VISIBLE@</visible>
12+
<default>@SETTINGS_XML_IN_CONNECTION_TYPE_DEFAULT@</default>
1113
<constraints>
1214
<options>
1315
<option label="30200">0</option>
@@ -17,8 +19,10 @@
1719
<control type="spinner" format="integer"/>
1820
</setting>
1921

22+
<!-- @SETTINGS_XML_IN_CONNECTION_TYPE_NOTE@ -->
2023
<setting id="device_connection_usb_index" parent="device_connection" type="integer" label="30101" help="30501">
2124
<level>0</level>
25+
<visible>@SETTINGS_XML_IN_CONNECTION_TYPE_VISIBLE@</visible>
2226
<default>0</default>
2327
<constraints>
2428
<minimum>0</minimum>
@@ -37,9 +41,11 @@
3741
<constraints>
3842
<allowempty>true</allowempty>
3943
</constraints>
44+
@SETTINGS_XML_IN_NO_USB_BEGIN@
4045
<dependencies>
4146
<dependency type="visible" setting="device_connection" operator="is">1</dependency>
4247
</dependencies>
48+
@SETTINGS_XML_IN_NO_USB_END@
4349
<control type="edit" format="ip">
4450
<heading>30102</heading>
4551
</control>
@@ -53,9 +59,11 @@
5359
<minimum>0</minimum>
5460
<maximum>65535</maximum>
5561
</constraints>
62+
@SETTINGS_XML_IN_NO_USB_BEGIN@
5663
<dependencies>
5764
<dependency type="visible" setting="device_connection" operator="is">1</dependency>
5865
</dependencies>
66+
@SETTINGS_XML_IN_NO_USB_END@
5967
<control type="edit" format="integer">
6068
<heading>30103</heading>
6169
</control>

src/addon.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,12 @@ ADDON_STATUS addon::Create(void)
11531153
}
11541154

11551155
// Load the device settings
1156+
#ifdef USB_DEVICE_SUPPORT
11561157
m_settings.device_connection =
11571158
kodi::addon::GetSettingEnum("device_connection", device_connection::usb);
1159+
#else
1160+
m_settings.device_connection = device_connection::rtltcp;
1161+
#endif
11581162
m_settings.device_connection_usb_index =
11591163
kodi::addon::GetSettingInt("device_connection_usb_index", 0);
11601164
m_settings.device_connection_tcp_host =

0 commit comments

Comments
 (0)