ui: Expose key imports from the dbus API.

This commit is contained in:
Damir Jelić 2019-04-18 16:56:53 +02:00
parent 2bb6ac7196
commit e43b8c750c
2 changed files with 29 additions and 3 deletions

View File

@ -156,12 +156,25 @@ class ProxyDaemon:
try:
client.export_keys(path, message.passphrase)
except OSError as e:
logger.warn(f"Error exporint keys for {client.user_id} to "
f"{path} {e}")
logger.warn(f"Error exporting keys for {client.user_id} to"
f" {path} {e}")
pass
elif isinstance(message, ImportKeysMessage):
pass
client = self.pan_clients.get(message.pan_user, None)
if not client:
return
path = os.path.abspath(message.file_path)
logger.info(f"Importing keys from {path}")
try:
client.import_keys(path, message.passphrase)
except (OSError, EncryptionError) as e:
logger.warn(f"Error importing keys for {client.user_id} "
f"from {path} {e}")
pass
def get_access_token(self, request):
# type: (aiohttp.web.BaseRequest) -> str

View File

@ -150,6 +150,19 @@ class Control(dbus.service.Object):
return
@dbus.service.method("org.pantalaimon.control.import_keys",
in_signature="sss")
def import_keys(self, pan_user, filepath, passphrase):
message = ImportKeysMessage(
pan_user,
filepath,
passphrase
)
self.queue.put(message)
return
def glib_loop(receive_queue, send_queue, data_dir):
DBusGMainLoop(set_as_default=True)