mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Add support for activating/deactivating server on-the-fly.
This commit is contained in:
parent
7289da9f41
commit
bc481bcc4d
@ -356,6 +356,13 @@ cString cSatipDiscover::GetServerList(void)
|
|||||||
return serversM.List();
|
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)
|
void cSatipDiscover::AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP)
|
||||||
{
|
{
|
||||||
debug16("%s (, %d, %d)", __PRETTY_FUNCTION__, deviceIdP, transponderP);
|
debug16("%s (, %d, %d)", __PRETTY_FUNCTION__, deviceIdP, transponderP);
|
||||||
|
@ -88,6 +88,7 @@ public:
|
|||||||
cSatipServer *GetServer(cSatipServer *serverP);
|
cSatipServer *GetServer(cSatipServer *serverP);
|
||||||
cSatipServers *GetServers(void);
|
cSatipServers *GetServers(void);
|
||||||
cString GetServerString(cSatipServer *serverP);
|
cString GetServerString(cSatipServer *serverP);
|
||||||
|
void ActivateServer(cSatipServer *serverP, bool onOffP);
|
||||||
void AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
void AttachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
||||||
void DetachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
void DetachServer(cSatipServer *serverP, int deviceIdP, int transponderP);
|
||||||
bool IsServerQuirk(cSatipServer *serverP, int quirkP);
|
bool IsServerQuirk(cSatipServer *serverP, int quirkP);
|
||||||
|
17
server.c
17
server.c
@ -88,6 +88,7 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo
|
|||||||
portM(portP),
|
portM(portP),
|
||||||
quirkM(eSatipQuirkNone),
|
quirkM(eSatipQuirkNone),
|
||||||
hasCiM(false),
|
hasCiM(false),
|
||||||
|
activeM(true),
|
||||||
createdM(time(NULL)),
|
createdM(time(NULL)),
|
||||||
lastSeenM(0)
|
lastSeenM(0)
|
||||||
{
|
{
|
||||||
@ -297,11 +298,11 @@ cSatipServer *cSatipServers::Find(int sourceP)
|
|||||||
|
|
||||||
cSatipServer *cSatipServers::Assign(int deviceIdP, int sourceP, int transponderP, int systemP)
|
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))
|
if (s->Matches(deviceIdP, sourceP, systemP, transponderP))
|
||||||
return s;
|
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))
|
if (s->Assign(deviceIdP, sourceP, systemP, transponderP))
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -319,6 +320,16 @@ cSatipServer *cSatipServers::Update(cSatipServer *serverP)
|
|||||||
return NULL;
|
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)
|
void cSatipServers::Attach(cSatipServer *serverP, int deviceIdP, int transponderP)
|
||||||
{
|
{
|
||||||
for (cSatipServer *s = First(); s; s = Next(s)) {
|
for (cSatipServer *s = First(); s; s = Next(s)) {
|
||||||
@ -413,7 +424,7 @@ cString cSatipServers::List(void)
|
|||||||
{
|
{
|
||||||
cString list = "";
|
cString list = "";
|
||||||
for (cSatipServer *s = First(); s; s = Next(s))
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
server.h
4
server.h
@ -62,6 +62,7 @@ private:
|
|||||||
int portM;
|
int portM;
|
||||||
int quirkM;
|
int quirkM;
|
||||||
bool hasCiM;
|
bool hasCiM;
|
||||||
|
bool activeM;
|
||||||
time_t createdM;
|
time_t createdM;
|
||||||
cTimeMs lastSeenM;
|
cTimeMs lastSeenM;
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ public:
|
|||||||
int GetModulesDVBT2(void);
|
int GetModulesDVBT2(void);
|
||||||
int GetModulesDVBC(void);
|
int GetModulesDVBC(void);
|
||||||
int GetModulesDVBC2(void);
|
int GetModulesDVBC2(void);
|
||||||
|
void Activate(bool onOffP) { activeM = onOffP; }
|
||||||
const char *Address(void) { return *addressM; }
|
const char *Address(void) { return *addressM; }
|
||||||
const char *Model(void) { return *modelM; }
|
const char *Model(void) { return *modelM; }
|
||||||
const char *Description(void) { return *descriptionM; }
|
const char *Description(void) { return *descriptionM; }
|
||||||
@ -95,6 +97,7 @@ public:
|
|||||||
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
|
bool Quirk(int quirkP) { return ((quirkP & eSatipQuirkMask) & quirkM); }
|
||||||
bool HasQuirk(void) { return (quirkM != eSatipQuirkNone); }
|
bool HasQuirk(void) { return (quirkM != eSatipQuirkNone); }
|
||||||
bool HasCI(void) { return hasCiM; }
|
bool HasCI(void) { return hasCiM; }
|
||||||
|
bool IsActive(void) { return activeM; }
|
||||||
void Update(void) { lastSeenM.Set(); }
|
void Update(void) { lastSeenM.Set(); }
|
||||||
uint64_t LastSeen(void) { return lastSeenM.Elapsed(); }
|
uint64_t LastSeen(void) { return lastSeenM.Elapsed(); }
|
||||||
time_t Created(void) { return createdM; }
|
time_t Created(void) { return createdM; }
|
||||||
@ -108,6 +111,7 @@ public:
|
|||||||
cSatipServer *Find(int sourceP);
|
cSatipServer *Find(int sourceP);
|
||||||
cSatipServer *Assign(int deviceIdP, int sourceP, int transponderP, int systemP);
|
cSatipServer *Assign(int deviceIdP, int sourceP, int transponderP, int systemP);
|
||||||
cSatipServer *Update(cSatipServer *serverP);
|
cSatipServer *Update(cSatipServer *serverP);
|
||||||
|
void Activate(cSatipServer *serverP, bool onOffP);
|
||||||
void Attach(cSatipServer *serverP, int deviceIdP, int transponderP);
|
void Attach(cSatipServer *serverP, int deviceIdP, int transponderP);
|
||||||
void Detach(cSatipServer *serverP, int deviceIdP, int transponderP);
|
void Detach(cSatipServer *serverP, int deviceIdP, int transponderP);
|
||||||
bool IsQuirk(cSatipServer *serverP, int quirkP);
|
bool IsQuirk(cSatipServer *serverP, int quirkP);
|
||||||
|
20
setup.c
20
setup.c
@ -86,6 +86,8 @@ eOSState cSatipEditSrcItem::ProcessKey(eKeys Key)
|
|||||||
class cSatipServerInfo : public cOsdMenu
|
class cSatipServerInfo : public cOsdMenu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
cSatipServer *serverM;
|
||||||
|
int activeM;
|
||||||
cString addressM;
|
cString addressM;
|
||||||
cString modelM;
|
cString modelM;
|
||||||
cString descriptionM;
|
cString descriptionM;
|
||||||
@ -101,6 +103,8 @@ public:
|
|||||||
|
|
||||||
cSatipServerInfo::cSatipServerInfo(cSatipServer *serverP)
|
cSatipServerInfo::cSatipServerInfo(cSatipServer *serverP)
|
||||||
: cOsdMenu(tr("SAT>IP Server"), 20),
|
: cOsdMenu(tr("SAT>IP Server"), 20),
|
||||||
|
serverM(serverP),
|
||||||
|
activeM(serverP && serverP->IsActive()),
|
||||||
addressM(serverP ? serverP->Address() : "---"),
|
addressM(serverP ? serverP->Address() : "---"),
|
||||||
modelM(serverP ? serverP->Model() : "---"),
|
modelM(serverP ? serverP->Model() : "---"),
|
||||||
descriptionM(serverP ? serverP->Description() : "---"),
|
descriptionM(serverP ? serverP->Description() : "---"),
|
||||||
@ -118,6 +122,7 @@ cSatipServerInfo::~cSatipServerInfo()
|
|||||||
|
|
||||||
void cSatipServerInfo::Setup(void)
|
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("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("Model"), *modelM), osUnknown, false));
|
||||||
Add(new cOsdItem(cString::sprintf("%s:\t%s", tr("Description"), *descriptionM), 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)
|
eOSState cSatipServerInfo::ProcessKey(eKeys keyP)
|
||||||
{
|
{
|
||||||
|
int oldActive = activeM;
|
||||||
eOSState state = cOsdMenu::ProcessKey(keyP);
|
eOSState state = cOsdMenu::ProcessKey(keyP);
|
||||||
|
|
||||||
if (state == osUnknown) {
|
if (state == osUnknown) {
|
||||||
@ -135,6 +141,12 @@ eOSState cSatipServerInfo::ProcessKey(eKeys keyP)
|
|||||||
default: state = osContinue; break;
|
default: state = osContinue; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyP != kNone && oldActive != activeM) {
|
||||||
|
cSatipDiscover::GetInstance()->ActivateServer(serverM, activeM);
|
||||||
|
Setup();
|
||||||
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +167,7 @@ cSatipServerItem::cSatipServerItem(cSatipServer *serverP)
|
|||||||
{
|
{
|
||||||
SetSelectable(true);
|
SetSelectable(true);
|
||||||
// Must begin with a '#' character!
|
// 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)
|
void cSatipServerItem::SetMenuItem(cSkinDisplayMenu *displayMenuP, int indexP, bool currentP, bool selectableP)
|
||||||
@ -468,10 +480,12 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP)
|
|||||||
int oldNumDisabledFilters = numDisabledFiltersM;
|
int oldNumDisabledFilters = numDisabledFiltersM;
|
||||||
eOSState state = cMenuSetupPage::ProcessKey(keyP);
|
eOSState state = cMenuSetupPage::ProcessKey(keyP);
|
||||||
|
|
||||||
// Ugly hack with hardcoded '#' character :(
|
// Ugly hack with hardcoded '+/-' characters :(
|
||||||
const char *p = Get(Current())->Text();
|
const char *p = Get(Current())->Text();
|
||||||
if (!hadSubMenu && !HasSubMenu() && (*p == '#') && (keyP == kOk))
|
if (!hadSubMenu && !HasSubMenu() && p && (*p == '+' || *p == '-') && (keyP == kOk))
|
||||||
return DeviceInfo();
|
return DeviceInfo();
|
||||||
|
if (hadSubMenu && !HasSubMenu())
|
||||||
|
Setup();
|
||||||
|
|
||||||
if (state == osUnknown) {
|
if (state == osUnknown) {
|
||||||
switch (keyP) {
|
switch (keyP) {
|
||||||
|
Loading…
Reference in New Issue
Block a user