Skip to content

Commit

Permalink
Hostname vs. NetBIOS name!
Browse files Browse the repository at this point in the history
  • Loading branch information
aassif committed Mar 1, 2021
1 parent 100371d commit f8cb2b0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Findnlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
find_path(NLOHMANNJSON_INCLUDE_DIR nlohmann/json.hpp)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NlohmannJson DEFAULT_MSG NLOHMANNJSON_INCLUDE_DIR)
find_package_handle_standard_args(nlohmann_json DEFAULT_MSG NLOHMANNJSON_INCLUDE_DIR)

if(NLOHMANNJSON_FOUND)
if(nlohmann_json_FOUND)
set(NLOHMANNJSON_INCLUDE_DIRS ${NLOHMANNJSON_INCLUDE_DIR})
endif()

Expand Down
2 changes: 1 addition & 1 deletion pvr.freebox/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.freebox"
version="6.1.2"
version="6.1.3"
name="PVR Freebox TV"
provider-name="aassif">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
12 changes: 10 additions & 2 deletions pvr.freebox/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ msgid "Convert French categories into standard categories."
msgstr ""

msgctxt "#30025"
msgid "Server"
msgid "Server (DNS)"
msgstr ""

msgctxt "#30026"
msgid "Server name or IP address."
msgid "Server's host name or IP address."
msgstr ""

msgctxt "#30027"
Expand All @@ -140,3 +140,11 @@ msgctxt "#30030"
msgid "HLS"
msgstr ""

msgctxt "#30031"
msgid "Server (NetBIOS)"
msgstr ""

msgctxt "#30032"
msgid "Server's NetBIOS name."
msgstr ""

16 changes: 12 additions & 4 deletions pvr.freebox/resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ msgid "Convert French categories into standard categories."
msgstr "Conversion des catégories françaises en catégories standard."

msgctxt "#30025"
msgid "Server"
msgstr "Serveur"
msgid "Server (DNS)"
msgstr "Serveur (DNS)"

msgctxt "#30026"
msgid "Server name or IP address."
msgstr "Nom du serveur ou adresse IP."
msgid "Server's host name or IP address."
msgstr "Nom d'hôte du serveur ou adresse IP."

msgctxt "#30027"
msgid "Protocol"
Expand All @@ -140,3 +140,11 @@ msgctxt "#30030"
msgid "HLS"
msgstr "HLS"

msgctxt "#30031"
msgid "Server (NetBIOS)"
msgstr "Serveur (NetBIOS)"

msgctxt "#30032"
msgid "Server's NetBIOS name"
msgstr "Nom NetBIOS du serveur."

7 changes: 6 additions & 1 deletion pvr.freebox/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
<section id="section" label="30002" description="30002">
<category id="category" label="30002" description="30002">
<group id="pvr.freebox.general" label="30002">
<setting id="server" type="string" label="30025" help="30026">
<setting id="hostname" type="string" label="30025" help="30026">
<level>2</level>
<default>mafreebox.freebox.fr</default>
<control type="edit" format="string" />
</setting>
<setting id="netbios" type="string" label="30031" help="30032">
<level>2</level>
<default>FREEBOX</default>
<control type="edit" format="string" />
</setting>
<setting id="delay" type="integer" label="30003" help="30004">
<level>0</level>
<default>10</default>
Expand Down
43 changes: 31 additions & 12 deletions src/Freebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ bool Freebox::ProcessChannels ()
for (auto & s : *f)
data.emplace_back (ParseSource (s["type"]),
ParseQuality (s["quality"]),
freebox_replace_server (s["rtsp"], m_server),
freebox_replace_server (s["hls"], m_server));
freebox_replace_server (s["rtsp"], m_hostname),
freebox_replace_server (s["hls"], m_hostname));
}
#if 0
if (! kodi::vfs::DirectoryExists (m_path + "logos"))
Expand Down Expand Up @@ -927,22 +927,34 @@ Freebox::~Freebox ()
CloseSession ();
}

void Freebox::SetServer (const string & server)
void Freebox::SetHostName (const string & hostname)
{
lock_guard<recursive_mutex> lock (m_mutex);
m_server = server;
m_hostname = hostname;
}

string Freebox::GetServer () const
string Freebox::GetHostName () const
{
lock_guard<recursive_mutex> lock (m_mutex);
return m_server;
return m_hostname;
}

void Freebox::SetNetBIOS (const string & netbios)
{
lock_guard<recursive_mutex> lock (m_mutex);
m_netbios = netbios;
}

string Freebox::GetNetBIOS () const
{
lock_guard<recursive_mutex> lock (m_mutex);
return m_netbios;
}

// NOT thread-safe !
string Freebox::URL (const string & query) const
{
return "http://" + m_server + query;
return "http://" + m_hostname + query;
}

void Freebox::SetSource (Source s)
Expand Down Expand Up @@ -1224,9 +1236,15 @@ ADDON_STATUS Freebox::Create ()

ADDON_STATUS Freebox::SetSetting (const string & settingName, const kodi::CSettingValue & settingValue)
{
/**/ if (settingName == "server")
/**/ if (settingName == "hostname")
{
SetHostName (settingValue.GetString ());
return ADDON_STATUS_NEED_RESTART;
}

else if (settingName == "netbios")
{
SetServer (settingValue.GetString ());
SetNetBIOS (settingValue.GetString ());
return ADDON_STATUS_NEED_RESTART;
}

Expand Down Expand Up @@ -1259,7 +1277,8 @@ ADDON_STATUS Freebox::SetSetting (const string & settingName, const kodi::CSetti

void Freebox::ReadSettings ()
{
m_server = kodi::GetSettingString ("server", PVR_FREEBOX_DEFAULT_SERVER);
m_hostname = kodi::GetSettingString ("hostname", PVR_FREEBOX_DEFAULT_HOSTNAME);
m_netbios = kodi::GetSettingString ("netbios", PVR_FREEBOX_DEFAULT_NETBIOS);
m_delay = kodi::GetSettingInt ("delay", PVR_FREEBOX_DEFAULT_DELAY);
m_tv_source = kodi::GetSettingEnum<Source> ("source", PVR_FREEBOX_DEFAULT_SOURCE);
m_tv_quality = kodi::GetSettingEnum<Quality> ("quality", PVR_FREEBOX_DEFAULT_QUALITY);
Expand Down Expand Up @@ -1304,7 +1323,7 @@ PVR_ERROR Freebox::GetBackendVersion (string & version)

PVR_ERROR Freebox::GetBackendHostname (string & hostname)
{
hostname = GetServer ();
hostname = GetHostName ();
return PVR_ERROR_NO_ERROR;
}

Expand Down Expand Up @@ -1542,7 +1561,7 @@ PVR_ERROR Freebox::GetRecordingStreamProperties (const kodi::addon::PVRRecording
return PVR_ERROR_SERVER_ERROR;

const Recording & r = i->second;
string stream = "smb://" + m_server + '/' + r.media + '/' + r.path + '/' + r.filename;
string stream = "smb://" + m_netbios + '/' + r.media + '/' + r.path + '/' + r.filename;
properties.emplace_back (PVR_STREAM_PROPERTY_STREAMURL, stream);
properties.emplace_back (PVR_STREAM_PROPERTY_ISREALTIMESTREAM, "false");

Expand Down
12 changes: 8 additions & 4 deletions src/Freebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
#define PVR_FREEBOX_STRING_CHANNEL_QUALITY_LD 30018
#define PVR_FREEBOX_STRING_CHANNEL_QUALITY_3D 30019

#define PVR_FREEBOX_DEFAULT_SERVER "mafreebox.freebox.fr"
#define PVR_FREEBOX_DEFAULT_HOSTNAME "mafreebox.freebox.fr"
#define PVR_FREEBOX_DEFAULT_NETBIOS "FREEBOX"
#define PVR_FREEBOX_DEFAULT_DELAY 10
#define PVR_FREEBOX_DEFAULT_SOURCE Source::IPTV
#define PVR_FREEBOX_DEFAULT_QUALITY Quality::HD
Expand Down Expand Up @@ -382,8 +383,10 @@ class ATTRIBUTE_HIDDEN Freebox :
void ReadSettings ();

// Freebox Server.
void SetServer (const std::string &);
std::string GetServer () const;
void SetHostName (const std::string &);
std::string GetHostName () const;
void SetNetBIOS (const std::string &);
std::string GetNetBIOS () const;

// Source setting.
void SetSource (Source);
Expand Down Expand Up @@ -469,7 +472,8 @@ class ATTRIBUTE_HIDDEN Freebox :
// Add-on path.
std::string m_path;
// Freebox Server.
std::string m_server = PVR_FREEBOX_DEFAULT_SERVER;
std::string m_hostname = PVR_FREEBOX_DEFAULT_HOSTNAME;
std::string m_netbios = PVR_FREEBOX_DEFAULT_NETBIOS;
// Delay between queries.
int m_delay = PVR_FREEBOX_DEFAULT_DELAY;
// Freebox OS //////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f8cb2b0

Please sign in to comment.