mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 23:00:36 +01:00
Dispatch commands via service on Android
This commit is contained in:
parent
9c66538ec1
commit
a13607646c
@ -1623,9 +1623,6 @@ class SidebandCore():
|
||||
connection.send(self._get_plugins_info())
|
||||
elif "send_message" in call:
|
||||
args = call["send_message"]
|
||||
RNS.log(str(call))
|
||||
RNS.log(str(args))
|
||||
RNS.log("Handling RPC send")
|
||||
send_result = self.send_message(
|
||||
args["content"],
|
||||
args["destination_hash"],
|
||||
@ -1635,7 +1632,13 @@ class SidebandCore():
|
||||
attachment=args["attachment"],
|
||||
image=args["image"],
|
||||
audio=args["audio"])
|
||||
RNS.log("RPC send complete")
|
||||
connection.send(send_result)
|
||||
elif "send_command" in call:
|
||||
args = call["send_command"]
|
||||
send_result = self.send_command(
|
||||
args["content"],
|
||||
args["destination_hash"],
|
||||
args["propagation"])
|
||||
connection.send(send_result)
|
||||
elif "get_lxm_progress" in call:
|
||||
args = call["get_lxm_progress"]
|
||||
@ -3896,6 +3899,30 @@ class SidebandCore():
|
||||
else:
|
||||
return False
|
||||
|
||||
def _service_send_command(self, content, destination_hash, propagation):
|
||||
if not RNS.vendor.platformutils.is_android():
|
||||
return False
|
||||
else:
|
||||
if self.is_client:
|
||||
try:
|
||||
if self.rpc_connection == None:
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
|
||||
self.rpc_connection.send({"send_command": {
|
||||
"content": content,
|
||||
"destination_hash": destination_hash,
|
||||
"propagation": propagation}
|
||||
})
|
||||
response = self.rpc_connection.recv()
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while sending command over RPC: "+str(e), RNS.LOG_DEBUG)
|
||||
RNS.trace_exception(e)
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def send_message(self, content, destination_hash, propagation, skip_fields=False, no_display=False, attachment = None, image = None, audio = None):
|
||||
if self.allow_service_dispatch and self.is_client:
|
||||
try:
|
||||
@ -3958,6 +3985,16 @@ class SidebandCore():
|
||||
return False
|
||||
|
||||
def send_command(self, content, destination_hash, propagation):
|
||||
if self.allow_service_dispatch and self.is_client:
|
||||
try:
|
||||
return self._service_send_command(content, destination_hash, propagation)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while sending message: "+str(e), RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
return False
|
||||
|
||||
else:
|
||||
try:
|
||||
if content == "":
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user