summaryrefslogtreecommitdiff
path: root/wrappers/python
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-06-21 16:52:55 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-06-21 16:52:55 +0200
commitb4d744a80aa79d45f8a46119920abc1279ad4f20 (patch)
treec308df90904cdaf1657bd1480f6104ecfbbc2063 /wrappers/python
parentf6c074f4fb99fa29927d3b62dd10457bd659f3ed (diff)
State: Add functions for getting/setting a connection identifier
e.g. the uuid of the connection in case of NetworkManager on Linux
Diffstat (limited to 'wrappers/python')
-rw-r--r--wrappers/python/src/__init__.py2
-rw-r--r--wrappers/python/src/main.py34
2 files changed, 32 insertions, 4 deletions
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py
index c96a1b2..bc9b3df 100644
--- a/wrappers/python/src/__init__.py
+++ b/wrappers/python/src/__init__.py
@@ -61,6 +61,8 @@ lib.CancelOAuth.argtypes, lib.CancelOAuth.restype = [c_char_p], c_void_p
lib.SetProfileID.argtypes, lib.SetProfileID.restype = [c_char_p, c_char_p], c_void_p
lib.SetConnected.argtypes, lib.SetConnected.restype = [c_char_p], c_void_p
lib.SetDisconnected.argtypes, lib.SetDisconnected.restype = [c_char_p], c_void_p
+lib.GetIdentifier.argtypes, lib.GetIdentifier.restype = [c_char_p], DataError
+lib.SetIdentifier.argtypes, lib.SetIdentifier.restype = [c_char_p, c_char_p], c_void_p
lib.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None
diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py
index 47e2893..687f40f 100644
--- a/wrappers/python/src/main.py
+++ b/wrappers/python/src/main.py
@@ -105,6 +105,20 @@ def SetDisconnected(name: str) -> str:
return err_string
+def SetIdentifier(name: str, identifier: str) -> str:
+ name_bytes = name.encode("utf-8")
+ identifier_bytes = identifier.encode("utf-8")
+ ptr_err = lib.SetIdentifier(name_bytes, identifier_bytes)
+ err_string = GetPtrString(ptr_err)
+ return err_string
+
+
+def GetIdentifier(name: str) -> Tuple[str, str]:
+ name_bytes = name.encode("utf-8")
+ identifier, identifier_err = GetDataError(lib.GetIdentifier(name_bytes))
+ return identifier, identifier_err
+
+
# This has to be global as otherwise the callback is not alive
callback_function = None
@@ -189,8 +203,12 @@ class EduVPN(object):
if config_err:
raise Exception(config_err)
+ def set_connected(self) -> None:
+ connect_err = SetConnected(self.name)
return config, config_type
+ if connect_err:
+ raise Exception(connect_err)
def set_disconnected(self) -> None:
disconnect_err = SetDisconnected(self.name)
@@ -198,11 +216,19 @@ class EduVPN(object):
if disconnect_err:
raise Exception(disconnect_err)
- def set_connected(self) -> None:
- connect_err = SetConnected(self.name)
+ def get_identifier(self) -> str:
+ identifier, identifier_err = GetIdentifier(self.name)
- if connect_err:
- raise Exception(connect_err)
+ if identifier_err:
+ raise Exception(identifier_err)
+
+ return identifier
+
+ def set_identifier(self, identifier: str) -> None:
+ identifier_err = SetIdentifier(self.name, identifier)
+
+ if identifier_err:
+ raise Exception(identifier_err)
@property
def event(self) -> EventHandler: