pantalaimon: Version the dbus API.

This commit is contained in:
Damir Jelić 2019-05-10 11:27:45 +02:00
parent 840e568eac
commit 671fe9dbd0
2 changed files with 30 additions and 30 deletions

View File

@ -108,7 +108,7 @@ class PanCompleter(Completer):
def complete_users(self, last_word, pan_user):
devices = self.devices.list(
pan_user,
dbus_interface="org.pantalaimon.devices"
dbus_interface="org.pantalaimon1.devices"
)
users = set(device["user_id"] for device in devices)
compl_words = self.filter_words(users, last_word)
@ -122,7 +122,7 @@ class PanCompleter(Completer):
devices = self.devices.list_user_devices(
pan_user,
user_id,
dbus_interface="org.pantalaimon.devices"
dbus_interface="org.pantalaimon1.devices"
)
device_ids = [device["device_id"] for device in devices]
compl_words = self.filter_words(device_ids, last_word)
@ -143,7 +143,7 @@ class PanCompleter(Completer):
def complete_pan_users(self, last_word):
users = self.ctl.list_users(
dbus_interface="org.pantalaimon.control"
dbus_interface="org.pantalaimon1.control"
)
compl_words = self.filter_words([i[0] for i in users], last_word)
@ -284,23 +284,23 @@ class PanCtl:
def __attrs_post_init__(self):
self.bus = dbus.SessionBus()
self.ctl = self.bus.get_object(
"org.pantalaimon",
"/org/pantalaimon/Control",
"org.pantalaimon1",
"/org/pantalaimon1/Control",
introspect=True
)
self.devices = self.bus.get_object(
"org.pantalaimon",
"/org/pantalaimon/Devices",
"org.pantalaimon1",
"/org/pantalaimon1/Devices",
introspect=True
)
self.bus.add_signal_receiver(
self.show_sas,
dbus_interface="org.pantalaimon.devices",
dbus_interface="org.pantalaimon1.devices",
signal_name="sas_show"
)
self.bus.add_signal_receiver(
self.show_info,
dbus_interface="org.pantalaimon.control",
dbus_interface="org.pantalaimon1.control",
signal_name="info"
)
@ -354,7 +354,7 @@ class PanCtl:
def list_users(self):
"""List the daemons users."""
users = self.ctl.list_users(
dbus_interface="org.pantalaimon.control"
dbus_interface="org.pantalaimon1.control"
)
print("pantalaimon users:")
for user, device in users:
@ -365,7 +365,7 @@ class PanCtl:
args.pan_user,
args.path,
args.passphrase,
dbus_interface="org.pantalaimon.control"
dbus_interface="org.pantalaimon1.control"
)
def export_keys(self, args):
@ -373,7 +373,7 @@ class PanCtl:
args.pan_user,
args.path,
args.passphrase,
dbus_interface="org.pantalaimon.control"
dbus_interface="org.pantalaimon1.control"
)
def confirm_sas(self, args):
@ -381,7 +381,7 @@ class PanCtl:
args.pan_user,
args.user_id,
args.device_id,
dbus_interface="org.pantalaimon.devices"
dbus_interface="org.pantalaimon1.devices"
)
def accept_sas(self, args):
@ -389,14 +389,14 @@ class PanCtl:
args.pan_user,
args.user_id,
args.device_id,
dbus_interface="org.pantalaimon.devices"
dbus_interface="org.pantalaimon1.devices"
)
def list_devices(self, args):
devices = self.devices.list_user_devices(
args.pan_user,
args.user_id,
dbus_interface="org.pantalaimon.devices"
dbus_interface="org.pantalaimon1.devices"
)
print_formatted_text(

View File

@ -29,11 +29,11 @@ DBusGMainLoop(set_as_default=True)
class Devices(dbus.service.Object):
def __init__(self, bus_name, queue, device_list):
super().__init__(bus_name, "/org/pantalaimon/Devices")
super().__init__(bus_name, "/org/pantalaimon1/Devices")
self.device_list = device_list
self.queue = queue
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="s",
out_signature="aa{ss}")
def list(self, pan_user):
@ -49,7 +49,7 @@ class Devices(dbus.service.Object):
return device_list
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="ss",
out_signature="aa{ss}")
def list_user_devices(self, pan_user, user_id):
@ -65,7 +65,7 @@ class Devices(dbus.service.Object):
return device_list.values()
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="sss")
def verify(self, pan_user, user_id, device_id):
message = DeviceVerifyMessage(
@ -76,7 +76,7 @@ class Devices(dbus.service.Object):
self.queue.put(message)
return
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="sss")
def unverify(self, pan_user, user_id, device_id):
message = DeviceUnverifyMessage(
@ -87,7 +87,7 @@ class Devices(dbus.service.Object):
self.queue.put(message)
return
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="sss")
def start_verify(self, pan_user, user_id, device_id):
device_store = self.device_list.get(pan_user)
@ -101,20 +101,20 @@ class Devices(dbus.service.Object):
return
@dbus.service.signal(
dbus_interface="org.pantalaimon.devices",
dbus_interface="org.pantalaimon1.devices",
signature="sssa(ss)"
)
def sas_show(self, pan_user, user_id, device_id, auth_string):
pass
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="sss")
def confirm_sas(self, pan_user, user_id, device_id):
message = DeviceConfirmSasMessage(pan_user, user_id, device_id)
self.queue.put(message)
return
@dbus.service.method("org.pantalaimon.devices",
@dbus.service.method("org.pantalaimon1.devices",
in_signature="sss")
def accept_sas(self, pan_user, user_id, device_id):
message = DeviceAcceptSasMessage(pan_user, user_id, device_id)
@ -140,16 +140,16 @@ class Devices(dbus.service.Object):
class Control(dbus.service.Object):
def __init__(self, bus_name, queue, user_list=None):
super().__init__(bus_name, "/org/pantalaimon/Control")
super().__init__(bus_name, "/org/pantalaimon1/Control")
self.users = user_list
self.queue = queue
@dbus.service.method("org.pantalaimon.control",
@dbus.service.method("org.pantalaimon1.control",
out_signature="a(ss)")
def list_users(self):
return self.users
@dbus.service.method("org.pantalaimon.control",
@dbus.service.method("org.pantalaimon1.control",
in_signature="sss")
def export_keys(self, pan_user, filepath, passphrase):
message = ExportKeysMessage(
@ -161,7 +161,7 @@ class Control(dbus.service.Object):
return
@dbus.service.method("org.pantalaimon.control",
@dbus.service.method("org.pantalaimon1.control",
in_signature="sss")
def import_keys(self, pan_user, filepath, passphrase):
message = ImportKeysMessage(
@ -174,7 +174,7 @@ class Control(dbus.service.Object):
return
@dbus.service.signal(
dbus_interface="org.pantalaimon.control",
dbus_interface="org.pantalaimon1.control",
signature="s"
)
def info(self, message):
@ -198,7 +198,7 @@ class GlibT:
def __attrs_post_init__(self):
self.loop = None
self.bus_name = dbus.service.BusName("org.pantalaimon",
self.bus_name = dbus.service.BusName("org.pantalaimon1",
bus=dbus.SessionBus(),
do_not_queue=True)