Mercurial > libervia-backend
comparison sat_frontends/bridge/dbus_bridge.py @ 3042:964abd07dc03
bridge (dbus): AsyncIO version of D-Bus bridge:
The frontends D-Bus bridge has now an AIOBridge version which can be instantiated to use asyncio (the loop must be managed by frontends).
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 01 Oct 2019 22:49:10 +0200 |
parents | a1bc34f90fa5 |
children | 2cc2f65379f7 |
comparison
equal
deleted
inserted
replaced
3041:72583524cfd3 | 3042:964abd07dc03 |
---|---|
15 # GNU Affero General Public License for more details. | 15 # GNU Affero General Public License for more details. |
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 import asyncio | |
21 import dbus | |
22 import ast | |
20 from sat.core.i18n import _ | 23 from sat.core.i18n import _ |
21 from bridge_frontend import BridgeException | 24 from .bridge_frontend import BridgeException |
22 import dbus | |
23 from sat.core.log import getLogger | 25 from sat.core.log import getLogger |
26 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError | |
27 from dbus.mainloop.glib import DBusGMainLoop | |
28 | |
29 DBusGMainLoop(set_as_default=True) | |
24 log = getLogger(__name__) | 30 log = getLogger(__name__) |
25 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError | 31 |
26 | |
27 from dbus.mainloop.glib import DBusGMainLoop | |
28 DBusGMainLoop(set_as_default=True) | |
29 | |
30 import ast | |
31 | 32 |
32 const_INT_PREFIX = "org.salutatoi.SAT" # Interface prefix | 33 const_INT_PREFIX = "org.salutatoi.SAT" # Interface prefix |
33 const_ERROR_PREFIX = const_INT_PREFIX + ".error" | 34 const_ERROR_PREFIX = const_INT_PREFIX + ".error" |
34 const_OBJ_PATH = '/org/salutatoi/SAT/bridge' | 35 const_OBJ_PATH = '/org/salutatoi/SAT/bridge' |
35 const_CORE_SUFFIX = ".core" | 36 const_CORE_SUFFIX = ".core" |
57 except (SyntaxError, ValueError, TypeError): | 58 except (SyntaxError, ValueError, TypeError): |
58 condition = '' | 59 condition = '' |
59 return BridgeException(name, message, condition) | 60 return BridgeException(name, message, condition) |
60 | 61 |
61 | 62 |
62 class Bridge(object): | 63 class Bridge: |
63 | 64 |
64 def bridgeConnect(self, callback, errback): | 65 def bridgeConnect(self, callback, errback): |
65 try: | 66 try: |
66 self.sessions_bus = dbus.SessionBus() | 67 self.sessions_bus = dbus.SessionBus() |
67 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, | 68 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, |
77 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': | 78 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': |
78 log.error(_("D-Bus is not launched, please see README to see instructions on how to launch it")) | 79 log.error(_("D-Bus is not launched, please see README to see instructions on how to launch it")) |
79 errback(BridgeInitError) | 80 errback(BridgeInitError) |
80 else: | 81 else: |
81 errback(e) | 82 errback(e) |
82 callback() | 83 else: |
84 callback() | |
83 #props = self.db_core_iface.getProperties() | 85 #props = self.db_core_iface.getProperties() |
84 | 86 |
85 def register_signal(self, functionName, handler, iface="core"): | 87 def register_signal(self, functionName, handler, iface="core"): |
86 if iface == "core": | 88 if iface == "core": |
87 self.db_core_iface.connect_to_signal(functionName, handler) | 89 self.db_core_iface.connect_to_signal(functionName, handler) |
806 else: | 808 else: |
807 if errback is None: | 809 if errback is None: |
808 errback = log.error | 810 errback = log.error |
809 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 811 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
810 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 812 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
813 | |
814 | |
815 class AIOBridge(Bridge): | |
816 | |
817 def register_signal(self, functionName, handler, iface="core"): | |
818 loop = asyncio.get_running_loop() | |
819 async_handler = lambda *args: asyncio.run_coroutine_threadsafe(handler(*args), loop) | |
820 return super().register_signal(functionName, async_handler, iface) | |
821 | |
822 def __getattribute__(self, name): | |
823 """ usual __getattribute__ if the method exists, else try to find a plugin method """ | |
824 try: | |
825 return object.__getattribute__(self, name) | |
826 except AttributeError: | |
827 # The attribute is not found, we try the plugin proxy to find the requested method | |
828 def getPluginMethod(*args, **kwargs): | |
829 loop = asyncio.get_running_loop() | |
830 fut = loop.create_future() | |
831 method = getattr(self.db_plugin_iface, name) | |
832 reply_handler = lambda ret=None: loop.call_soon_threadsafe( | |
833 fut.set_result, ret) | |
834 error_handler = lambda err: loop.call_soon_threadsafe( | |
835 fut.set_exception, dbus_to_bridge_exception(err)) | |
836 method( | |
837 *args, | |
838 **kwargs, | |
839 timeout=const_TIMEOUT, | |
840 reply_handler=reply_handler, | |
841 error_handler=error_handler | |
842 ) | |
843 return fut | |
844 | |
845 return getPluginMethod | |
846 | |
847 def bridgeConnect(self): | |
848 loop = asyncio.get_running_loop() | |
849 fut = loop.create_future() | |
850 super().bridgeConnect( | |
851 callback=lambda: loop.call_soon_threadsafe(fut.set_result, None), | |
852 errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e) | |
853 ) | |
854 return fut | |
855 | |
856 def actionsGet(self, profile_key="@DEFAULT@"): | |
857 loop = asyncio.get_running_loop() | |
858 fut = loop.create_future() | |
859 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
860 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
861 self.db_core_iface.actionsGet(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
862 return fut | |
863 | |
864 def addContact(self, entity_jid, profile_key="@DEFAULT@"): | |
865 loop = asyncio.get_running_loop() | |
866 fut = loop.create_future() | |
867 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
868 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
869 self.db_core_iface.addContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
870 return fut | |
871 | |
872 def asyncDeleteProfile(self, profile): | |
873 loop = asyncio.get_running_loop() | |
874 fut = loop.create_future() | |
875 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
876 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
877 self.db_core_iface.asyncDeleteProfile(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
878 return fut | |
879 | |
880 def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@"): | |
881 loop = asyncio.get_running_loop() | |
882 fut = loop.create_future() | |
883 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
884 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
885 self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
886 return fut | |
887 | |
888 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, profile_key="@DEFAULT@"): | |
889 loop = asyncio.get_running_loop() | |
890 fut = loop.create_future() | |
891 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
892 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
893 self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
894 return fut | |
895 | |
896 def connect(self, profile_key="@DEFAULT@", password='', options={}): | |
897 loop = asyncio.get_running_loop() | |
898 fut = loop.create_future() | |
899 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
900 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
901 self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
902 return fut | |
903 | |
904 def delContact(self, entity_jid, profile_key="@DEFAULT@"): | |
905 loop = asyncio.get_running_loop() | |
906 fut = loop.create_future() | |
907 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
908 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
909 self.db_core_iface.delContact(entity_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
910 return fut | |
911 | |
912 def discoFindByFeatures(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@"): | |
913 loop = asyncio.get_running_loop() | |
914 fut = loop.create_future() | |
915 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
916 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
917 self.db_core_iface.discoFindByFeatures(namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
918 return fut | |
919 | |
920 def discoInfos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"): | |
921 loop = asyncio.get_running_loop() | |
922 fut = loop.create_future() | |
923 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
924 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
925 self.db_core_iface.discoInfos(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
926 return fut | |
927 | |
928 def discoItems(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"): | |
929 loop = asyncio.get_running_loop() | |
930 fut = loop.create_future() | |
931 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
932 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
933 self.db_core_iface.discoItems(entity_jid, node, use_cache, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
934 return fut | |
935 | |
936 def disconnect(self, profile_key="@DEFAULT@"): | |
937 loop = asyncio.get_running_loop() | |
938 fut = loop.create_future() | |
939 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
940 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
941 self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
942 return fut | |
943 | |
944 def encryptionNamespaceGet(self, arg_0): | |
945 loop = asyncio.get_running_loop() | |
946 fut = loop.create_future() | |
947 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
948 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
949 self.db_core_iface.encryptionNamespaceGet(arg_0, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
950 return fut | |
951 | |
952 def encryptionPluginsGet(self): | |
953 loop = asyncio.get_running_loop() | |
954 fut = loop.create_future() | |
955 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
956 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
957 self.db_core_iface.encryptionPluginsGet(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
958 return fut | |
959 | |
960 def encryptionTrustUIGet(self, to_jid, namespace, profile_key): | |
961 loop = asyncio.get_running_loop() | |
962 fut = loop.create_future() | |
963 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
964 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
965 self.db_core_iface.encryptionTrustUIGet(to_jid, namespace, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
966 return fut | |
967 | |
968 def getConfig(self, section, name): | |
969 loop = asyncio.get_running_loop() | |
970 fut = loop.create_future() | |
971 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
972 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
973 self.db_core_iface.getConfig(section, name, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
974 return fut | |
975 | |
976 def getContacts(self, profile_key="@DEFAULT@"): | |
977 loop = asyncio.get_running_loop() | |
978 fut = loop.create_future() | |
979 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
980 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
981 self.db_core_iface.getContacts(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
982 return fut | |
983 | |
984 def getContactsFromGroup(self, group, profile_key="@DEFAULT@"): | |
985 loop = asyncio.get_running_loop() | |
986 fut = loop.create_future() | |
987 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
988 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
989 self.db_core_iface.getContactsFromGroup(group, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
990 return fut | |
991 | |
992 def getEntitiesData(self, jids, keys, profile): | |
993 loop = asyncio.get_running_loop() | |
994 fut = loop.create_future() | |
995 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
996 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
997 self.db_core_iface.getEntitiesData(jids, keys, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
998 return fut | |
999 | |
1000 def getEntityData(self, jid, keys, profile): | |
1001 loop = asyncio.get_running_loop() | |
1002 fut = loop.create_future() | |
1003 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1004 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1005 self.db_core_iface.getEntityData(jid, keys, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1006 return fut | |
1007 | |
1008 def getFeatures(self, profile_key): | |
1009 loop = asyncio.get_running_loop() | |
1010 fut = loop.create_future() | |
1011 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1012 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1013 self.db_core_iface.getFeatures(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1014 return fut | |
1015 | |
1016 def getMainResource(self, contact_jid, profile_key="@DEFAULT@"): | |
1017 loop = asyncio.get_running_loop() | |
1018 fut = loop.create_future() | |
1019 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1020 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1021 self.db_core_iface.getMainResource(contact_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1022 return fut | |
1023 | |
1024 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): | |
1025 loop = asyncio.get_running_loop() | |
1026 fut = loop.create_future() | |
1027 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1028 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1029 self.db_core_iface.getParamA(name, category, attribute, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1030 return fut | |
1031 | |
1032 def getParamsCategories(self): | |
1033 loop = asyncio.get_running_loop() | |
1034 fut = loop.create_future() | |
1035 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1036 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1037 self.db_core_iface.getParamsCategories(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1038 return fut | |
1039 | |
1040 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@"): | |
1041 loop = asyncio.get_running_loop() | |
1042 fut = loop.create_future() | |
1043 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1044 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1045 self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1046 return fut | |
1047 | |
1048 def getPresenceStatuses(self, profile_key="@DEFAULT@"): | |
1049 loop = asyncio.get_running_loop() | |
1050 fut = loop.create_future() | |
1051 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1052 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1053 self.db_core_iface.getPresenceStatuses(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1054 return fut | |
1055 | |
1056 def getReady(self): | |
1057 loop = asyncio.get_running_loop() | |
1058 fut = loop.create_future() | |
1059 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1060 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1061 self.db_core_iface.getReady(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1062 return fut | |
1063 | |
1064 def getVersion(self): | |
1065 loop = asyncio.get_running_loop() | |
1066 fut = loop.create_future() | |
1067 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1068 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1069 self.db_core_iface.getVersion(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1070 return fut | |
1071 | |
1072 def getWaitingSub(self, profile_key="@DEFAULT@"): | |
1073 loop = asyncio.get_running_loop() | |
1074 fut = loop.create_future() | |
1075 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1076 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1077 self.db_core_iface.getWaitingSub(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1078 return fut | |
1079 | |
1080 def historyGet(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@"): | |
1081 loop = asyncio.get_running_loop() | |
1082 fut = loop.create_future() | |
1083 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1084 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1085 self.db_core_iface.historyGet(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1086 return fut | |
1087 | |
1088 def isConnected(self, profile_key="@DEFAULT@"): | |
1089 loop = asyncio.get_running_loop() | |
1090 fut = loop.create_future() | |
1091 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1092 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1093 self.db_core_iface.isConnected(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1094 return fut | |
1095 | |
1096 def launchAction(self, callback_id, data, profile_key="@DEFAULT@"): | |
1097 loop = asyncio.get_running_loop() | |
1098 fut = loop.create_future() | |
1099 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1100 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1101 self.db_core_iface.launchAction(callback_id, data, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1102 return fut | |
1103 | |
1104 def loadParamsTemplate(self, filename): | |
1105 loop = asyncio.get_running_loop() | |
1106 fut = loop.create_future() | |
1107 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1108 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1109 self.db_core_iface.loadParamsTemplate(filename, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1110 return fut | |
1111 | |
1112 def menuHelpGet(self, menu_id, language): | |
1113 loop = asyncio.get_running_loop() | |
1114 fut = loop.create_future() | |
1115 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1116 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1117 self.db_core_iface.menuHelpGet(menu_id, language, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1118 return fut | |
1119 | |
1120 def menuLaunch(self, menu_type, path, data, security_limit, profile_key): | |
1121 loop = asyncio.get_running_loop() | |
1122 fut = loop.create_future() | |
1123 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1124 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1125 self.db_core_iface.menuLaunch(menu_type, path, data, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1126 return fut | |
1127 | |
1128 def menusGet(self, language, security_limit): | |
1129 loop = asyncio.get_running_loop() | |
1130 fut = loop.create_future() | |
1131 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1132 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1133 self.db_core_iface.menusGet(language, security_limit, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1134 return fut | |
1135 | |
1136 def messageEncryptionGet(self, to_jid, profile_key): | |
1137 loop = asyncio.get_running_loop() | |
1138 fut = loop.create_future() | |
1139 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1140 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1141 self.db_core_iface.messageEncryptionGet(to_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1142 return fut | |
1143 | |
1144 def messageEncryptionStart(self, to_jid, namespace='', replace=False, profile_key="@NONE@"): | |
1145 loop = asyncio.get_running_loop() | |
1146 fut = loop.create_future() | |
1147 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1148 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1149 self.db_core_iface.messageEncryptionStart(to_jid, namespace, replace, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1150 return fut | |
1151 | |
1152 def messageEncryptionStop(self, to_jid, profile_key): | |
1153 loop = asyncio.get_running_loop() | |
1154 fut = loop.create_future() | |
1155 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1156 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1157 self.db_core_iface.messageEncryptionStop(to_jid, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1158 return fut | |
1159 | |
1160 def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@"): | |
1161 loop = asyncio.get_running_loop() | |
1162 fut = loop.create_future() | |
1163 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1164 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1165 self.db_core_iface.messageSend(to_jid, message, subject, mess_type, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1166 return fut | |
1167 | |
1168 def namespacesGet(self): | |
1169 loop = asyncio.get_running_loop() | |
1170 fut = loop.create_future() | |
1171 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1172 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1173 self.db_core_iface.namespacesGet(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1174 return fut | |
1175 | |
1176 def paramsRegisterApp(self, xml, security_limit=-1, app=''): | |
1177 loop = asyncio.get_running_loop() | |
1178 fut = loop.create_future() | |
1179 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1180 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1181 self.db_core_iface.paramsRegisterApp(xml, security_limit, app, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1182 return fut | |
1183 | |
1184 def profileCreate(self, profile, password='', component=''): | |
1185 loop = asyncio.get_running_loop() | |
1186 fut = loop.create_future() | |
1187 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1188 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1189 self.db_core_iface.profileCreate(profile, password, component, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1190 return fut | |
1191 | |
1192 def profileIsSessionStarted(self, profile_key="@DEFAULT@"): | |
1193 loop = asyncio.get_running_loop() | |
1194 fut = loop.create_future() | |
1195 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1196 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1197 self.db_core_iface.profileIsSessionStarted(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1198 return fut | |
1199 | |
1200 def profileNameGet(self, profile_key="@DEFAULT@"): | |
1201 loop = asyncio.get_running_loop() | |
1202 fut = loop.create_future() | |
1203 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1204 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1205 self.db_core_iface.profileNameGet(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1206 return fut | |
1207 | |
1208 def profileSetDefault(self, profile): | |
1209 loop = asyncio.get_running_loop() | |
1210 fut = loop.create_future() | |
1211 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1212 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1213 self.db_core_iface.profileSetDefault(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1214 return fut | |
1215 | |
1216 def profileStartSession(self, password='', profile_key="@DEFAULT@"): | |
1217 loop = asyncio.get_running_loop() | |
1218 fut = loop.create_future() | |
1219 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1220 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1221 self.db_core_iface.profileStartSession(password, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1222 return fut | |
1223 | |
1224 def profilesListGet(self, clients=True, components=False): | |
1225 loop = asyncio.get_running_loop() | |
1226 fut = loop.create_future() | |
1227 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1228 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1229 self.db_core_iface.profilesListGet(clients, components, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1230 return fut | |
1231 | |
1232 def progressGet(self, id, profile): | |
1233 loop = asyncio.get_running_loop() | |
1234 fut = loop.create_future() | |
1235 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1236 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1237 self.db_core_iface.progressGet(id, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1238 return fut | |
1239 | |
1240 def progressGetAll(self, profile): | |
1241 loop = asyncio.get_running_loop() | |
1242 fut = loop.create_future() | |
1243 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1244 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1245 self.db_core_iface.progressGetAll(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1246 return fut | |
1247 | |
1248 def progressGetAllMetadata(self, profile): | |
1249 loop = asyncio.get_running_loop() | |
1250 fut = loop.create_future() | |
1251 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1252 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1253 self.db_core_iface.progressGetAllMetadata(profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1254 return fut | |
1255 | |
1256 def rosterResync(self, profile_key="@DEFAULT@"): | |
1257 loop = asyncio.get_running_loop() | |
1258 fut = loop.create_future() | |
1259 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1260 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1261 self.db_core_iface.rosterResync(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1262 return fut | |
1263 | |
1264 def saveParamsTemplate(self, filename): | |
1265 loop = asyncio.get_running_loop() | |
1266 fut = loop.create_future() | |
1267 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1268 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1269 self.db_core_iface.saveParamsTemplate(filename, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1270 return fut | |
1271 | |
1272 def sessionInfosGet(self, profile_key): | |
1273 loop = asyncio.get_running_loop() | |
1274 fut = loop.create_future() | |
1275 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1276 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1277 self.db_core_iface.sessionInfosGet(profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1278 return fut | |
1279 | |
1280 def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): | |
1281 loop = asyncio.get_running_loop() | |
1282 fut = loop.create_future() | |
1283 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1284 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1285 self.db_core_iface.setParam(name, value, category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1286 return fut | |
1287 | |
1288 def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"): | |
1289 loop = asyncio.get_running_loop() | |
1290 fut = loop.create_future() | |
1291 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1292 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1293 self.db_core_iface.setPresence(to_jid, show, statuses, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1294 return fut | |
1295 | |
1296 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): | |
1297 loop = asyncio.get_running_loop() | |
1298 fut = loop.create_future() | |
1299 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1300 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1301 self.db_core_iface.subscription(sub_type, entity, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1302 return fut | |
1303 | |
1304 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): | |
1305 loop = asyncio.get_running_loop() | |
1306 fut = loop.create_future() | |
1307 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
1308 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
1309 self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
1310 return fut |