2022-06-16 16:10:06 +01:00
|
|
|
from .error import VMCMDErrors
|
|
|
|
from .iremote import IRemote
|
2022-03-21 11:20:53 +00:00
|
|
|
from .meta import action_prop
|
|
|
|
|
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,),
|
|
|
|
{
|
|
|
|
**{
|
|
|
|
param: action_prop(param)
|
|
|
|
for param in ["show", "shutdown", "restart"]
|
|
|
|
},
|
|
|
|
"hide": action_prop("show", val=0),
|
|
|
|
},
|
|
|
|
)
|
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")
|