2022-06-16 16:10:06 +01:00
|
|
|
from .iremote import IRemote
|
2023-06-25 02:38:59 +01:00
|
|
|
from .meta import action_fn
|
2022-03-21 11:20:53 +00:00
|
|
|
|
2022-03-26 23:00:09 +00:00
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
class Command(IRemote):
|
|
|
|
"""
|
|
|
|
Implements the common interface
|
2022-03-26 23:00:09 +00:00
|
|
|
|
2022-06-16 16:10:06 +01:00
|
|
|
Defines concrete implementation for command
|
|
|
|
"""
|
2022-03-26 23:00:09 +00:00
|
|
|
|
2022-03-21 11:20:53 +00:00
|
|
|
@classmethod
|
|
|
|
def make(cls, remote):
|
|
|
|
"""
|
|
|
|
Factory function for command class.
|
|
|
|
|
|
|
|
Returns a Command class of a kind.
|
|
|
|
"""
|
2022-03-26 23:00:09 +00:00
|
|
|
CMD_cls = type(
|
2022-06-16 16:10:06 +01:00
|
|
|
f"Command{remote.kind}",
|
2022-03-26 23:00:09 +00:00
|
|
|
(cls,),
|
|
|
|
{
|
|
|
|
**{
|
2023-06-25 02:38:59 +01:00
|
|
|
param: action_fn(param) for param in ["show", "shutdown", "restart"]
|
2022-03-26 23:00:09 +00:00
|
|
|
},
|
2023-06-25 02:38:59 +01:00
|
|
|
"hide": action_fn("show", val=0),
|
2022-03-26 23:00:09 +00:00
|
|
|
},
|
|
|
|
)
|
2022-03-21 11:20:53 +00:00
|
|
|
return CMD_cls(remote)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self) -> str:
|
2022-03-26 23:00:09 +00:00
|
|
|
return "Command"
|
2022-03-21 11:20:53 +00:00
|
|
|
|
|
|
|
def set_showvbanchat(self, val: bool):
|
2022-03-26 23:00:09 +00:00
|
|
|
self.setter("DialogShow.VBANCHAT", 1 if val else 0)
|
|
|
|
|
2022-03-21 11:20:53 +00:00
|
|
|
showvbanchat = property(fset=set_showvbanchat)
|
|
|
|
|
|
|
|
def set_lock(self, val: bool):
|
2022-03-26 23:00:09 +00:00
|
|
|
self.setter("lock", 1 if val else 0)
|
|
|
|
|
2022-03-21 11:20:53 +00:00
|
|
|
lock = property(fset=set_lock)
|
2022-07-16 21:52:41 +01:00
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
self._remote.apply_config("reset")
|