From bde88d78b1303029b1893dac962c7e8e54d38ec6 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 3 Nov 2014 23:57:08 +0200 Subject: [PATCH] Added a command-line switch for manually defining a SAT>IP server. --- HISTORY | 4 +++- README | 4 ++++ discover.c | 14 ++++++++------ discover.h | 2 +- po/ca_ES.po | 4 ++-- po/de_DE.po | 4 ++-- po/es_ES.po | 4 ++-- po/fi_FI.po | 4 ++-- satip.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 9 files changed, 66 insertions(+), 21 deletions(-) diff --git a/HISTORY b/HISTORY index b43cbc9..58323db 100644 --- a/HISTORY +++ b/HISTORY @@ -65,7 +65,7 @@ VDR Plugin 'satip' Revision History - Added a validity check for the session member. - Added a session id quirk for Triax TSS 400. -2014-11-01: Version 0.3.4 +2014-11-11: Version 0.3.4 - Fixed the cable only device detection. - Added support for blacklisted sources. @@ -73,3 +73,5 @@ VDR Plugin 'satip' Revision History - Added a preliminary support for Fritz!WLAN Repeater DVB-C (Thanks to Christian Wick). - Added a new device status menu. +- Added a command-line switch for manually defining a + SAT>IP server. diff --git a/README b/README index 017dbb9..a6317f2 100644 --- a/README +++ b/README @@ -44,6 +44,10 @@ The plugin accepts a "--devices" (-d) command-line parameter defaulting to one. This parameter defines how many simultaneous transponders can be received, if there are available SAT>IP tuners. +The plugin accepts also a "--server" (-s) command-line parameter, that +can be used to manually configure one SAT>IP server, if autodetection +via UPnP somehow can't be used. + SAT>IP satellite positions (aka. signal sources) shall be defined via sources.conf. If the source description begins with a number, it's used as SAT>IP signal source selection parameter. Otherwise, the default diff --git a/discover.c b/discover.c index 1daee87..928f390 100644 --- a/discover.c +++ b/discover.c @@ -32,11 +32,15 @@ cSatipDiscover *cSatipDiscover::GetInstance(void) return instanceS; } -bool cSatipDiscover::Initialize(void) +bool cSatipDiscover::Initialize(const char *serverAddrP, const char *serverDescriptionP, const char *serverModelP) { - debug("cSatipDiscover::%s()", __FUNCTION__); - if (instanceS) - instanceS->Activate(); + debug("cSatipDiscover::%s(%s, %s, %s)", __FUNCTION__, serverAddrP ? serverAddrP : "auto", serverDescriptionP ? serverDescriptionP : "auto", serverModelP ? serverModelP : "auto"); + if (instanceS) { + if (serverAddrP && serverDescriptionP && serverModelP) + instanceS->AddServer(serverAddrP, serverDescriptionP, serverModelP); + else + instanceS->Activate(); + } return true; } @@ -98,8 +102,6 @@ cSatipDiscover::cSatipDiscover() serversM(new cSatipServers()) { debug("cSatipDiscover::%s()", __FUNCTION__); - // Start the thread - Start(); } cSatipDiscover::~cSatipDiscover() diff --git a/discover.h b/discover.h index b53318d..ef6a087 100644 --- a/discover.h +++ b/discover.h @@ -52,7 +52,7 @@ protected: public: static cSatipDiscover *GetInstance(void); - static bool Initialize(void); + static bool Initialize(const char *serverAddrP, const char *serverDescriptionP, const char *serverModelP); static void Destroy(void); virtual ~cSatipDiscover(); void TriggerScan(void) { probeIntervalM.Set(0); } diff --git a/po/ca_ES.po b/po/ca_ES.po index 768544c..33e2820 100644 --- a/po/ca_ES.po +++ b/po/ca_ES.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-01 11:01+0200\n" -"PO-Revision-Date: 2014-11-01 11:01+0200\n" +"POT-Creation-Date: 2014-11-11 11:11+0200\n" +"PO-Revision-Date: 2014-11-11 11:11+0200\n" "Last-Translator: Gabriel Bonich \n" "Language-Team: Catalan \n" "Language: ca\n" diff --git a/po/de_DE.po b/po/de_DE.po index a0668a8..a50bc92 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-01 11:01+0200\n" -"PO-Revision-Date: 2014-11-01 11:01+0200\n" +"POT-Creation-Date: 2014-11-11 11:11+0200\n" +"PO-Revision-Date: 2014-11-11 11:11+0200\n" "Last-Translator: Frank Neumann \n" "Language-Team: German \n" "Language: de\n" diff --git a/po/es_ES.po b/po/es_ES.po index 8c42597..bfbd979 100644 --- a/po/es_ES.po +++ b/po/es_ES.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-01 11:01+0200\n" -"PO-Revision-Date: 2014-11-01 11:01+0200\n" +"POT-Creation-Date: 2014-11-11 11:11+0200\n" +"PO-Revision-Date: 2014-11-11 11:11+0200\n" "Last-Translator: Gabriel Bonich \n" "Language-Team: Spanish \n" "Language: es\n" diff --git a/po/fi_FI.po b/po/fi_FI.po index b13a2d6..6730686 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-11-01 11:01+0200\n" -"PO-Revision-Date: 2014-11-01 11:01+0200\n" +"POT-Creation-Date: 2014-11-11 11:11+0200\n" +"PO-Revision-Date: 2014-11-11 11:11+0200\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: Finnish \n" "Language: fi\n" diff --git a/satip.c b/satip.c index 9a7122a..649fbae 100644 --- a/satip.c +++ b/satip.c @@ -31,7 +31,10 @@ static const char DESCRIPTION[] = trNOOP("SAT>IP Devices"); class cPluginSatip : public cPlugin { private: unsigned int deviceCountM; - cSatipDiscover *discoverM; + cString serverAddrM; + cString serverDescriptionM; + cString serverModelM; + void ParseServer(const char *paramP); int ParseSources(const char *valueP, int *sourcesP); int ParseFilters(const char *valueP, int *filtersP); public: @@ -59,7 +62,9 @@ public: cPluginSatip::cPluginSatip(void) : deviceCountM(1), - discoverM(NULL) + serverAddrM(), + serverDescriptionM(), + serverModelM() { //debug("cPluginSatip::%s()", __FUNCTION__); // Initialize any member variables here. @@ -77,7 +82,8 @@ const char *cPluginSatip::CommandLineHelp(void) { debug("cPluginSatip::%s()", __FUNCTION__); // Return a string that describes all known command line options. - return " -d , --devices= number of devices to be created\n"; + return " -d , --devices= number of devices to be created\n" + " -s ;;, --server=;; use a hard-coded SAT>IP server\n"; } bool cPluginSatip::ProcessArgs(int argc, char *argv[]) @@ -86,15 +92,19 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[]) // Implement command line argument processing here if applicable. static const struct option long_options[] = { { "devices", required_argument, NULL, 'd' }, + { "server", required_argument, NULL, 's' }, { NULL, no_argument, NULL, 0 } }; int c; - while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:s:", long_options, NULL)) != -1) { switch (c) { case 'd': deviceCountM = atoi(optarg); break; + case 's': + ParseServer(optarg); + break; default: return false; } @@ -109,7 +119,7 @@ bool cPluginSatip::Initialize(void) if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) error("Unable to initialize CURL"); SatipConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); - cSatipDiscover::GetInstance()->Initialize(); + cSatipDiscover::GetInstance()->Initialize(*serverAddrM, *serverDescriptionM, *serverModelM); return cSatipDevice::Initialize(deviceCountM); } @@ -178,6 +188,33 @@ cMenuSetupPage *cPluginSatip::SetupMenu(void) return new cSatipPluginSetup(); } +void cPluginSatip::ParseServer(const char *paramP) +{ + debug("cPluginSatip::%s(%s)", __FUNCTION__, paramP); + int n = 0; + char *s, *p = (char *)paramP; + char *r = strtok_r(p, ";", &s); + while (r) { + r = skipspace(r); + //debug("cPluginSatip::%s(): serverparam[%d]=%s", __FUNCTION__, n, r); + switch (n++) { + case 0: + serverAddrM = r; + break; + case 1: + serverModelM = r; + break; + case 2: + serverDescriptionM = r; + break; + default: + break; + } + r = strtok_r(NULL, ";", &s); + } + //debug("cPluginSatip::%s(): ipaddr=%s model=%s desc=%s", __FUNCTION__, *serverAddrM, *serverModelM, *serverDescriptionM); +} + int cPluginSatip::ParseSources(const char *valueP, int *sourcesP) { debug("cPluginSatip::%s(%s)", __FUNCTION__, valueP);