2011-11-28 16:23:57 +01:00
|
|
|
/*
|
|
|
|
* $Id: menu.c,v 1.10 2010/07/19 13:49:31 schmirl Exp $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vdr/menuitems.h>
|
|
|
|
#include <vdr/thread.h>
|
|
|
|
#include <vdr/player.h>
|
|
|
|
|
|
|
|
#include "server/menu.h"
|
|
|
|
#include "server/setup.h"
|
|
|
|
#include "server/server.h"
|
|
|
|
#include "server/suspend.h"
|
|
|
|
|
|
|
|
cStreamdevServerMenu::cStreamdevServerMenu(): cOsdMenu(tr("Streamdev Connections"), 4, 20) {
|
|
|
|
cThreadLock lock;
|
2016-03-21 00:28:02 +01:00
|
|
|
#if APIVERSNUM >= 20300
|
|
|
|
cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
|
|
|
|
#else
|
2011-11-28 16:23:57 +01:00
|
|
|
const cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
|
2016-03-21 00:28:02 +01:00
|
|
|
#endif
|
2011-11-28 16:23:57 +01:00
|
|
|
for (cServerConnection *s = clients.First(); s; s = clients.Next(s))
|
2014-11-07 23:01:08 +01:00
|
|
|
Add(new cOsdItem(s->ToText('\t')));
|
2011-11-28 16:23:57 +01:00
|
|
|
SetHelpKeys();
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
cStreamdevServerMenu::~cStreamdevServerMenu() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStreamdevServerMenu::SetHelpKeys() {
|
2012-03-31 16:19:44 +02:00
|
|
|
SetHelp(Count() ? tr("Disconnect") : NULL, NULL, NULL, tr("Suspend"));
|
2011-11-28 16:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cStreamdevServerMenu::Disconnect() {
|
|
|
|
cOsdItem *item = Get(Current());
|
|
|
|
if (item) {
|
|
|
|
cThreadLock lock;
|
2016-03-21 00:28:02 +01:00
|
|
|
#if APIVERSNUM >= 20300
|
|
|
|
cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
|
|
|
|
#else
|
2011-11-28 16:23:57 +01:00
|
|
|
const cList<cServerConnection>& clients = cStreamdevServer::Clients(lock);
|
2016-03-21 00:28:02 +01:00
|
|
|
#endif
|
2011-11-28 16:23:57 +01:00
|
|
|
const char *text = item->Text();
|
|
|
|
for (cServerConnection *s = clients.First(); s; s = clients.Next(s)) {
|
2014-11-07 23:01:08 +01:00
|
|
|
if (!strcmp(text, s->ToText('\t'))) {
|
2011-11-28 16:23:57 +01:00
|
|
|
s->Close();
|
|
|
|
Del(Current());
|
|
|
|
SetHelpKeys();
|
|
|
|
Display();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cStreamdevServerMenu::Suspend() {
|
2012-03-31 16:19:44 +02:00
|
|
|
if (!cSuspendCtl::IsActive()) {
|
2011-11-28 16:23:57 +01:00
|
|
|
cControl::Launch(new cSuspendCtl);
|
|
|
|
return osBack;
|
|
|
|
}
|
|
|
|
return osContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cStreamdevServerMenu::ProcessKey(eKeys Key) {
|
|
|
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
|
|
|
case kRed: return Disconnect();
|
|
|
|
case kBlue: return Suspend();
|
|
|
|
case kOk: return osBack;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|