diff options
| author | Justus Winter <[email protected]> | 2016-09-16 12:56:29 +0000 | 
|---|---|---|
| committer | Justus Winter <[email protected]> | 2016-09-16 12:56:29 +0000 | 
| commit | a458e7fe2006d92bd5a838e2747fb66bbac4b1b8 (patch) | |
| tree | 7460cc8f3ba21fec51a0a706f17747887ef37d96 /lang/python/helpers.c | |
| parent | core: Fix typos. (diff) | |
| download | gpgme-a458e7fe2006d92bd5a838e2747fb66bbac4b1b8.tar.gz gpgme-a458e7fe2006d92bd5a838e2747fb66bbac4b1b8.zip | |
python: Adapt to 'gpgme_op_interact'.
* lang/python/examples/inter-edit.py: Update example.
* lang/python/gpgme.i (gpgme_edit_cb_t): Turn into
'gpgme_interact_cb_t'.
* lang/python/helpers.c (_pyme_edit_cb): Turn into
'_pyme_interact_cb_t'.
* lang/python/private.h (_pyme_edit_cb): Likewise.
* lang/python/pyme/constants/__init__.py: Replace numeric status codes
with the keywords.
* lang/python/pyme/constants/status.py: Likewise.
* lang/python/pyme/core.py (Context.interact): New method.
(Context.op_edit): Deprecate, update docstring, implement using
Context.interact.
* lang/python/tests/t-edit.py: Test both interfaces.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/helpers.c')
| -rw-r--r-- | lang/python/helpers.c | 23 | 
1 files changed, 19 insertions, 4 deletions
| diff --git a/lang/python/helpers.c b/lang/python/helpers.c index bc8aed40..bb2128c9 100644 --- a/lang/python/helpers.c +++ b/lang/python/helpers.c @@ -656,11 +656,16 @@ pyme_set_status_cb(PyObject *self, PyObject *cb) {    Py_INCREF(Py_None);    return Py_None;  } + -/* Edit callbacks.  */ -gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status, -		       const char *args, int fd) { + +/* Interact callbacks.  */ +gpgme_error_t +_pyme_interact_cb(void *opaque, const char *keyword, +                  const char *args, int fd) +{    PyObject *func = NULL, *dataarg = NULL, *pyargs = NULL, *retval = NULL; +  PyObject *py_keyword;    PyObject *pyopaque = (PyObject *) opaque;    gpgme_error_t err_status = 0;    PyObject *self = NULL; @@ -678,7 +683,15 @@ gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status,      pyargs = PyTuple_New(2);    } -  PyTuple_SetItem(pyargs, 0, PyLong_FromLong((long) status)); +  if (keyword) +    py_keyword = PyUnicode_FromString(keyword); +  else +    { +      Py_INCREF(Py_None); +      py_keyword = Py_None; +    } + +  PyTuple_SetItem(pyargs, 0, py_keyword);    PyTuple_SetItem(pyargs, 1, PyUnicode_FromString(args));    if (dataarg) {      Py_INCREF(dataarg);		/* Because GetItem doesn't give a ref but SetItem taketh away */ @@ -726,7 +739,9 @@ gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status,    Py_XDECREF(retval);    return err_status;  } + +  /* Data callbacks.  */  /* Read up to SIZE bytes into buffer BUFFER from the data object with | 
