diff options
Diffstat (limited to 'wrappers/python/src')
| -rw-r--r-- | wrappers/python/src/__init__.py | 2 | ||||
| -rw-r--r-- | wrappers/python/src/main.py | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py index 1df305b..e417371 100644 --- a/wrappers/python/src/__init__.py +++ b/wrappers/python/src/__init__.py @@ -42,6 +42,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 # We have to use c_void_p instead of c_char_p to free it properly # See https://stackoverflow.com/questions/13445568/python-ctypes-how-to-free-memory-getting-invalid-pointer-error +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.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py index 5474ade..9c2fb41 100644 --- a/wrappers/python/src/main.py +++ b/wrappers/python/src/main.py @@ -43,6 +43,18 @@ def Connect(name, url): data_error = lib.Connect(name_bytes, url_bytes) return GetDataError(data_error) +def SetConnected(name): + name_bytes = name.encode("utf-8") + ptr_err = lib.SetConnected(name_bytes) + err_string = GetPtrString(ptr_err) + return err_string + +def SetDisconnected(name): + name_bytes = name.encode("utf-8") + ptr_err = lib.SetDisconnected(name_bytes) + err_string = GetPtrString(ptr_err) + return err_string + # This has to be global as otherwise the callback is not alive callback_function = None @@ -85,6 +97,11 @@ class EduVPN(object): def connect(self, url): return Connect(self.name, url) + def set_disconnected(self): + return SetDisconnected(self.name) + + def set_connected(self): + return SetConnected(self.name) @property def event(self): |
