summaryrefslogtreecommitdiff
path: root/wrappers/python
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroenwijenbergh@protonmail.com>2022-04-19 15:02:45 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-19 15:02:45 +0200
commit723ecacc8528be0e96db42392f1781ddf5894bea (patch)
tree1debf1d6d0c50adb32939db3cc84e5130d1fb818 /wrappers/python
parent5f40a8d10a17182f744cb7ac11087d170dd49560 (diff)
Profiles: Implement basic functionality for sending a profile_id
Diffstat (limited to 'wrappers/python')
-rw-r--r--wrappers/python/eduvpncommon/__init__.py1
-rw-r--r--wrappers/python/eduvpncommon/main.py7
-rw-r--r--wrappers/python/main.py6
3 files changed, 14 insertions, 0 deletions
diff --git a/wrappers/python/eduvpncommon/__init__.py b/wrappers/python/eduvpncommon/__init__.py
index 056ce18..50af8eb 100644
--- a/wrappers/python/eduvpncommon/__init__.py
+++ b/wrappers/python/eduvpncommon/__init__.py
@@ -38,6 +38,7 @@ lib.Deregister.argtypes, lib.Deregister.restype = [], None
lib.Register.argtypes, lib.Register.restype = [c_char_p, c_char_p, VPNStateChange, c_int], c_void_p
lib.GetOrganizationsList.argtypes, lib.GetOrganizationsList.restype = [], DataError
lib.GetServersList.argtypes, lib.GetServersList.restype = [], DataError
+lib.SendData.argtypes, lib.SendData.restype = [c_char_p], None
# 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.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None
diff --git a/wrappers/python/eduvpncommon/main.py b/wrappers/python/eduvpncommon/main.py
index 53b9831..8d2de9c 100644
--- a/wrappers/python/eduvpncommon/main.py
+++ b/wrappers/python/eduvpncommon/main.py
@@ -47,6 +47,10 @@ def register_callback(eduvpn):
)
+def SendData(data):
+ lib.SendData(data.encode("utf-8"))
+
+
class EduVPN(object):
def __init__(self, name, config_directory):
self.event_handler = EventHandler()
@@ -75,6 +79,9 @@ class EduVPN(object):
def callback(self, old_state, new_state, data):
self.event.run(old_state, new_state, data)
+ def send_data(self, data):
+ return SendData(data)
+
class EventHandler(object):
def __init__(self):
diff --git a/wrappers/python/main.py b/wrappers/python/main.py
index d6a568e..bc29239 100644
--- a/wrappers/python/main.py
+++ b/wrappers/python/main.py
@@ -11,6 +11,12 @@ def oauth_initialized(url):
webbrowser.open(url)
+@_eduvpn.event.on("Ask_Profile", eduvpn.StateType.Enter)
+def ask_profile(profiles):
+ print("ASK PROFILE CB", profiles)
+ _eduvpn.send_data("prefer-openvpn")
+
+
success = _eduvpn.register(debug=True)
if not success: