diff --git a/discover.c b/discover.c index a559e85..511f5c4 100644 --- a/discover.c +++ b/discover.c @@ -356,6 +356,13 @@ cString cSatipDiscover::GetServerList(void) return serversM.List(); } +void cSatipDiscover::ActivateServer(cSatipServer *serverP, bool onOffP) +{ + debug16("%s (, %d)", __PRETTY_FUNCTION__, onOffP); + cMutexLock MutexLock(&mutexM); + serversM.Activate(serverP, onOffP); +} + void cSatipDiscover::AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP) { debug16("%s (, %d, %d)", __PRETTY_FUNCTION__, deviceIdP, transponderP); diff --git a/discover.h b/discover.h index ff38b61..dd284ed 100644 --- a/discover.h +++ b/discover.h @@ -88,6 +88,7 @@ public: cSatipServer *GetServer(cSatipServer *serverP); cSatipServers *GetServers(void); cString GetServerString(cSatipServer *serverP); + void ActivateServer(cSatipServer *serverP, bool onOffP); void AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP); void DetachServer(cSatipServer *serverP, int deviceIdP, int transponderP); bool IsServerQuirk(cSatipServer *serverP, int quirkP); diff --git a/server.c b/server.c index 7e08502..ae2de1d 100644 --- a/server.c +++ b/server.c @@ -88,6 +88,7 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo portM(portP), quirkM(eSatipQuirkNone), hasCiM(false), + activeM(true), createdM(time(NULL)), lastSeenM(0) { @@ -297,11 +298,11 @@ cSatipServer *cSatipServers::Find(int sourceP) cSatipServer *cSatipServers::Assign(int deviceIdP, int sourceP, int transponderP, int systemP) { - for (cSatipServer *s = First(); s; s = Next(s)) { + for (cSatipServer *s = First(); s && s->IsActive(); s = Next(s)) { if (s->Matches(deviceIdP, sourceP, systemP, transponderP)) return s; } - for (cSatipServer *s = First(); s; s = Next(s)) { + for (cSatipServer *s = First(); s && s->IsActive(); s = Next(s)) { if (s->Assign(deviceIdP, sourceP, systemP, transponderP)) return s; } @@ -319,6 +320,16 @@ cSatipServer *cSatipServers::Update(cSatipServer *serverP) return NULL; } +void cSatipServers::Activate(cSatipServer *serverP, bool onOffP) +{ + for (cSatipServer *s = First(); s; s = Next(s)) { + if (s == serverP) { + s->Activate(onOffP); + break; + } + } +} + void cSatipServers::Attach(cSatipServer *serverP, int deviceIdP, int transponderP) { for (cSatipServer *s = First(); s; s = Next(s)) { @@ -413,7 +424,7 @@ cString cSatipServers::List(void) { cString list = ""; for (cSatipServer *s = First(); s; s = Next(s)) - list = cString::sprintf("%s%s|%s|%s\n", *list, s->Address(), s->Model(), s->Description()); + list = cString::sprintf("%s%c %s|%s|%s\n", *list, s->IsActive() ? '+' : '-', s->Address(), s->Model(), s->Description()); return list; } diff --git a/server.h b/server.h index 63821b6..657a55b 100644 --- a/server.h +++ b/server.h @@ -62,6 +62,7 @@ private: int portM; int quirkM; bool hasCiM; + bool activeM; time_t createdM; cTimeMs lastSeenM; @@ -87,6 +88,7 @@ public: int GetModulesDVBT2(void); int GetModulesDVBC(void); int GetModulesDVBC2(void); + void Activate(bool onOffP) { activeM = onOffP; } const char *Address(void) { return *addressM; } const char *Model(void) { return *modelM; } const char *Description(void) { return *descriptionM; } @@ -95,6 +97,7 @@ public: bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); } bool HasQuirk(void) { return (quirkM != eSatipQuirkNone); } bool HasCI(void) { return hasCiM; } + bool IsActive(void) { return activeM; } void Update(void) { lastSeenM.Set(); } uint64_t LastSeen(void) { return lastSeenM.Elapsed(); } time_t Created(void) { return createdM; } @@ -108,6 +111,7 @@ public: cSatipServer *Find(int sourceP); cSatipServer *Assign(int deviceIdP, int sourceP, int transponderP, int systemP); cSatipServer *Update(cSatipServer *serverP); + void Activate(cSatipServer *serverP, bool onOffP); void Attach(cSatipServer *serverP, int deviceIdP, int transponderP); void Detach(cSatipServer *serverP, int deviceIdP, int transponderP); bool IsQuirk(cSatipServer *serverP, int quirkP); diff --git a/setup.c b/setup.c index a67dd14..1900263 100644 --- a/setup.c +++ b/setup.c @@ -86,6 +86,8 @@ eOSState cSatipEditSrcItem::ProcessKey(eKeys Key) class cSatipServerInfo : public cOsdMenu { private: + cSatipServer *serverM; + int activeM; cString addressM; cString modelM; cString descriptionM; @@ -101,6 +103,8 @@ public: cSatipServerInfo::cSatipServerInfo(cSatipServer *serverP) : cOsdMenu(tr("SAT>IP Server"), 20), + serverM(serverP), + activeM(serverP && serverP->IsActive()), addressM(serverP ? serverP->Address() : "---"), modelM(serverP ? serverP->Model() : "---"), descriptionM(serverP ? serverP->Description() : "---"), @@ -118,6 +122,7 @@ cSatipServerInfo::~cSatipServerInfo() void cSatipServerInfo::Setup(void) { + Add(new cMenuEditBoolItem(trVDR("Active"), &activeM)); Add(new cOsdItem(cString::sprintf("%s:\t%s", tr("Address"), *addressM), osUnknown, false)); Add(new cOsdItem(cString::sprintf("%s:\t%s", tr("Model"), *modelM), osUnknown, false)); Add(new cOsdItem(cString::sprintf("%s:\t%s", tr("Description"), *descriptionM), osUnknown, false)); @@ -127,6 +132,7 @@ void cSatipServerInfo::Setup(void) eOSState cSatipServerInfo::ProcessKey(eKeys keyP) { + int oldActive = activeM; eOSState state = cOsdMenu::ProcessKey(keyP); if (state == osUnknown) { @@ -135,6 +141,12 @@ eOSState cSatipServerInfo::ProcessKey(eKeys keyP) default: state = osContinue; break; } } + + if (keyP != kNone && oldActive != activeM) { + cSatipDiscover::GetInstance()->ActivateServer(serverM, activeM); + Setup(); + } + return state; } @@ -155,7 +167,7 @@ cSatipServerItem::cSatipServerItem(cSatipServer *serverP) { SetSelectable(true); // Must begin with a '#' character! - SetText(*cString::sprintf("# %s (%s)\t%s", serverM->Address(), serverM->Model(), serverM->Description())); + SetText(*cString::sprintf("%s %s (%s)\t%s", serverM->IsActive() ? "+" : "-", serverM->Address(), serverM->Model(), serverM->Description())); } void cSatipServerItem::SetMenuItem(cSkinDisplayMenu *displayMenuP, int indexP, bool currentP, bool selectableP) @@ -468,10 +480,12 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP) int oldNumDisabledFilters = numDisabledFiltersM; eOSState state = cMenuSetupPage::ProcessKey(keyP); - // Ugly hack with hardcoded '#' character :( + // Ugly hack with hardcoded '+/-' characters :( const char *p = Get(Current())->Text(); - if (!hadSubMenu && !HasSubMenu() && (*p == '#') && (keyP == kOk)) + if (!hadSubMenu && !HasSubMenu() && p && (*p == '+' || *p == '-') && (keyP == kOk)) return DeviceInfo(); + if (hadSubMenu && !HasSubMenu()) + Setup(); if (state == osUnknown) { switch (keyP) {