diff options
Diffstat (limited to 'wrappers/python/eduvpn_common')
| -rw-r--r-- | wrappers/python/eduvpn_common/loader.py | 4 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 9 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/types.py | 11 |
3 files changed, 16 insertions, 8 deletions
diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index 360ec04..d258dab 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -1,5 +1,5 @@ import pathlib -from ctypes import CDLL, c_char_p, c_int, c_void_p, cdll +from ctypes import CDLL, c_char_p, c_int, c_longlong, c_void_p, cdll, POINTER from eduvpn_common import __version__ from eduvpn_common.types import ( @@ -66,7 +66,7 @@ def initialize_functions(lib: CDLL) -> None: c_int, c_int, c_char_p, - c_int, + POINTER(c_longlong), ], c_char_p, ) diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index 84ae9ab..4582c8d 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -1,7 +1,7 @@ import ctypes import json from enum import IntEnum -from typing import Any, Callable, Iterator +from typing import Any, Callable, Iterator, Optional from eduvpn_common.event import EventHandler from eduvpn_common.loader import initialize_functions, load_lib @@ -151,16 +151,17 @@ class EduVPN(object): if register_err: forwardError(register_err) - def add_server(self, _type: ServerType, _id: str, ni: bool = False) -> None: + def add_server(self, _type: ServerType, _id: str, ot: Optional[int] = None) -> None: """Add a server :param _type: ServerType: The type of server e.g. SERVER.INSTITUTE_ACCESS :param _id: str: The identifier of the server, e.g. "https://vpn.example.com/" - :param ni: bool: Whether the server should be added non interactively, meaning no callbacks + :param ot: Optional[int]: The time when OAuth was last started. + if != None the server is added without any interactivity :raises WrappedError: An error by the Go library """ - add_err = self.go_cookie_function(self.lib.AddServer, int(_type), _id, ni) + add_err = self.go_cookie_function(self.lib.AddServer, int(_type), _id, ot) if add_err: forwardError(add_err) diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py index 837ead6..e9a1e86 100644 --- a/wrappers/python/eduvpn_common/types.py +++ b/wrappers/python/eduvpn_common/types.py @@ -1,5 +1,5 @@ -from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char, c_char_p, c_int, c_size_t, c_ulonglong, c_void_p, cast -from typing import Any, Iterator, List, Tuple +from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, byref, c_char, c_char_p, c_int, c_longlong, c_size_t, c_ulonglong, c_void_p, cast +from typing import Any, Iterator, List, Optional, Tuple class DataError(Structure): @@ -29,6 +29,12 @@ TokenGetter = CFUNCTYPE(c_void_p, c_char_p, c_int, POINTER(c_char), c_size_t) TokenSetter = CFUNCTYPE(c_void_p, c_char_p, c_int, c_char_p) +def conv_longlongp(val: Optional[int]) -> POINTER(c_longlong): + if val is None: + return None + return byref(c_longlong(val)) + + def encode_args(args: List[Any], types: List[Any]) -> Iterator[Any]: """Encode the arguments ready to be used by the Go library @@ -44,6 +50,7 @@ def encode_args(args: List[Any], types: List[Any]) -> Iterator[Any]: # c_char_p needs the str to be encoded to bytes encode_map = { c_char_p: lambda x: x.encode("utf-8"), + POINTER(c_longlong): conv_longlongp, } if t in encode_map: arg = encode_map[t](arg) |
