[git] GPGME - branch, master, updated. gpgme-1.6.0-244-gde69fa4

by Justus Winter cvs at cvs.gnupg.org
Thu Jul 28 14:27:46 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  de69fa496c09386d5e99747670d6887cf52dd09e (commit)
       via  355d7072863ac1f0f725e77141a59f3ed8a5e4af (commit)
       via  78f7bf4dcf75206faae5776c2ee4166628313532 (commit)
       via  3d4dc3f0218234a27103bdb6f93b17c0703b71a2 (commit)
      from  6a7ee33abd5059f5ae2f70a7dd9f610c16552f8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit de69fa496c09386d5e99747670d6887cf52dd09e
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jul 28 12:40:54 2016 +0200

    python: Support the Assuan engine.
    
    * lang/python/gpgme.i: Add typemaps for the Assuan protocol callbacks.
    * lang/python/helpers.c (_pyme_assuan_{data,inquire,status}_cb): New
    functions.
    * lang/python/private.h (_pyme_assuan_{data,inquire,status}_cb): New
    prototypes.
    * lang/python/pyme/core.py (Context.assuan_transact): New method.
    * lang/python/pyme/util.py (percent_escape): New function.
    * lang/python/tests/Makefile.am (py_tests): Add new test.
    * lang/python/tests/t-protocol-assuan.py: New file.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index a372edd..24adf74 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -443,6 +443,60 @@
   $2 = $input;
 }
 
+

+
+/* The assuan protocol callbacks.  */
+%typemap(in) (gpgme_assuan_data_cb_t data_cb, void *data_cb_value) {
+  if ($input == Py_None)
+    $1 = $2 = NULL;
+  else
+    {
+      if (! PyTuple_Check($input))
+        return PyErr_Format(PyExc_TypeError, "callback must be a tuple");
+      if (PyTuple_Size($input) != 2)
+        return PyErr_Format(PyExc_TypeError,
+                            "callback must be a tuple of size 2");
+      if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
+        return PyErr_Format(PyExc_TypeError, "second item must be callable");
+      $1 = _pyme_assuan_data_cb;
+      $2 = $input;
+    }
+}
+
+%typemap(in) (gpgme_assuan_inquire_cb_t inq_cb, void *inq_cb_value) {
+  if ($input == Py_None)
+    $1 = $2 = NULL;
+  else
+    {
+      if (! PyTuple_Check($input))
+        return PyErr_Format(PyExc_TypeError, "callback must be a tuple");
+      if (PyTuple_Size($input) != 2)
+        return PyErr_Format(PyExc_TypeError,
+                            "callback must be a tuple of size 2");
+      if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
+        return PyErr_Format(PyExc_TypeError, "second item must be callable");
+      $1 = _pyme_assuan_inquire_cb;
+      $2 = $input;
+    }
+}
+
+%typemap(in) (gpgme_assuan_status_cb_t stat_cb, void *stat_cb_value) {
+  if ($input == Py_None)
+    $1 = $2 = NULL;
+  else
+    {
+      if (! PyTuple_Check($input))
+        return PyErr_Format(PyExc_TypeError, "callback must be a tuple");
+      if (PyTuple_Size($input) != 2)
+        return PyErr_Format(PyExc_TypeError,
+                            "callback must be a tuple of size 2");
+      if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
+        return PyErr_Format(PyExc_TypeError, "second item must be callable");
+      $1 = _pyme_assuan_status_cb;
+      $2 = $input;
+    }
+}
+
 /* Include the unmodified <gpgme.h> for cc, and the cleaned-up local
    version for SWIG.  We do, however, want to hide certain fields on
    some structs, which we provide prior to including the version for
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 2b38172..90173e4 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -937,3 +937,119 @@ pygpgme_data_new_from_cbs(PyObject *self,
   Py_INCREF(Py_None);
   return Py_None;
 }
+
+

+
+/* The assuan callbacks.  */
+
+gpgme_error_t
+_pyme_assuan_data_cb (void *hook, const void *data, size_t datalen)
+{
+  gpgme_error_t err = 0;
+  PyObject *pyhook = (PyObject *) hook;
+  PyObject *self = NULL;
+  PyObject *func = NULL;
+  PyObject *py_data = NULL;
+  PyObject *retval = NULL;
+
+  assert (PyTuple_Check(pyhook));
+  assert (PyTuple_Size(pyhook) == 2);
+  self = PyTuple_GetItem(pyhook, 0);
+  func = PyTuple_GetItem(pyhook, 1);
+  assert (PyCallable_Check(func));
+
+  py_data = PyBytes_FromStringAndSize(data, datalen);
+  if (py_data == NULL)
+    return NULL;	/* raise */
+
+  retval = PyObject_CallFunctionObjArgs(func, py_data, NULL);
+  if (PyErr_Occurred())
+    err = pygpgme_exception2code();
+  Py_DECREF(py_data);
+  Py_XDECREF(retval);
+
+ leave:
+  if (err)
+    pygpgme_stash_callback_exception(self);
+  return err;
+}
+
+gpgme_error_t
+_pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
+                         gpgme_data_t *r_data)
+{
+  gpgme_error_t err = 0;
+  PyObject *pyhook = (PyObject *) hook;
+  PyObject *self = NULL;
+  PyObject *func = NULL;
+  PyObject *py_name = NULL;
+  PyObject *py_args = NULL;
+  PyObject *retval = NULL;
+
+  assert (PyTuple_Check(pyhook));
+  assert (PyTuple_Size(pyhook) == 2);
+  self = PyTuple_GetItem(pyhook, 0);
+  func = PyTuple_GetItem(pyhook, 1);
+  assert (PyCallable_Check(func));
+
+  py_name = PyUnicode_FromString(name);
+  if (py_name == NULL)
+    return NULL;	/* raise */
+
+  py_args = PyUnicode_FromString(args);
+  if (py_args == NULL)
+    return NULL;	/* raise */
+
+  retval = PyObject_CallFunctionObjArgs(func, py_name, py_args, NULL);
+  if (PyErr_Occurred())
+    err = pygpgme_exception2code();
+  Py_DECREF(py_name);
+  Py_DECREF(py_args);
+  Py_XDECREF(retval);
+
+  /* FIXME: Returning data is not yet implemented.  */
+  r_data = NULL;
+
+ leave:
+  if (err)
+    pygpgme_stash_callback_exception(self);
+  return err;
+}
+
+gpgme_error_t
+_pyme_assuan_status_cb (void *hook, const char *status, const char *args)
+{
+  gpgme_error_t err = 0;
+  PyObject *pyhook = (PyObject *) hook;
+  PyObject *self = NULL;
+  PyObject *func = NULL;
+  PyObject *py_status = NULL;
+  PyObject *py_args = NULL;
+  PyObject *retval = NULL;
+
+  assert (PyTuple_Check(pyhook));
+  assert (PyTuple_Size(pyhook) == 2);
+  self = PyTuple_GetItem(pyhook, 0);
+  func = PyTuple_GetItem(pyhook, 1);
+  assert (PyCallable_Check(func));
+
+  py_status = PyUnicode_FromString(status);
+  if (py_status == NULL)
+    return NULL;	/* raise */
+
+  py_args = PyUnicode_FromString(args);
+  if (py_args == NULL)
+    return NULL;	/* raise */
+
+  retval = PyObject_CallFunctionObjArgs(func, py_status, py_args, NULL);
+  if (PyErr_Occurred())
+    err = pygpgme_exception2code();
+  Py_DECREF(py_status);
+  Py_DECREF(py_args);
+  Py_XDECREF(retval);
+
+ leave:
+  if (err)
+    pygpgme_stash_callback_exception(self);
+  return err;
+}
diff --git a/lang/python/private.h b/lang/python/private.h
index cb21f06..88b9653 100644
--- a/lang/python/private.h
+++ b/lang/python/private.h
@@ -35,4 +35,12 @@ PyObject *pygpgme_wrap_fragile_result(PyObject *fragile, const char *classname);
 gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
 		       const char *args, int fd);
 
+gpgme_error_t _pyme_assuan_data_cb (void *hook,
+				    const void *data, size_t datalen);
+gpgme_error_t _pyme_assuan_inquire_cb (void *hook,
+				       const char *name, const char *args,
+				       gpgme_data_t *r_data);
+gpgme_error_t _pyme_assuan_status_cb (void *hook,
+				      const char *status, const char *args);
+
 #endif /* _PYME_PRIVATE_H_ */
diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index 216e26f..b25808d 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -31,6 +31,7 @@ from . import pygpgme
 from .errors import errorcheck, GPGMEError
 from . import constants
 from . import errors
+from . import util
 
 class GpgmeWrapper(object):
     """Base wrapper class
@@ -467,6 +468,55 @@ class Context(GpgmeWrapper):
             plainbytes = data.read()
         return plainbytes, result
 
+    def assuan_transact(self, command,
+                        data_cb=None, inquire_cb=None, status_cb=None):
+        """Issue a raw assuan command
+
+        This function can be used to issue a raw assuan command to the
+        engine.
+
+        If command is a string or bytes, it will be used as-is.  If it
+        is an iterable of strings, it will be properly escaped and
+        joined into an well-formed assuan command.
+
+        Keyword arguments:
+        data_cb		-- a callback receiving data lines
+        inquire_cb	-- a callback providing more information
+        status_cb	-- a callback receiving status lines
+
+        Returns:
+        result		-- the result of command as GPGMEError
+
+        Raises:
+        GPGMEError	-- as signaled by the underlying library
+
+        """
+
+        if isinstance(command, (str, bytes)):
+            cmd = command
+        else:
+            cmd = " ".join(util.percent_escape(f) for f in command)
+
+        errptr = pygpgme.new_gpgme_error_t_p()
+
+        err = pygpgme.gpgme_op_assuan_transact_ext(
+            self.wrapped,
+            cmd,
+            (weakref.ref(self), data_cb) if data_cb else None,
+            (weakref.ref(self), inquire_cb) if inquire_cb else None,
+            (weakref.ref(self), status_cb) if status_cb else None,
+            errptr)
+
+        if self._callback_excinfo:
+            pygpgme.pygpgme_raise_callback_exception(self)
+
+        errorcheck(err)
+
+        status = pygpgme.gpgme_error_t_p_value(errptr)
+        pygpgme.delete_gpgme_error_t_p(errptr)
+
+        return GPGMEError(status) if status != 0 else None
+
     @property
     def signers(self):
         """Keys used for signing"""
diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py
index bbd28fe..7eb6353 100644
--- a/lang/python/pyme/util.py
+++ b/lang/python/pyme/util.py
@@ -31,3 +31,9 @@ def process_constants(prefix, scope):
                  if identifier.startswith(prefix)}
     scope.update(constants)
     return list(constants.keys())
+
+def percent_escape(s):
+    return ''.join(
+        '%{0:2x}'.format(ord(c))
+        if c == '+' or c == '"' or c == '%' or ord(c) <= 0x20 else c
+        for c in s)
diff --git a/lang/python/tests/Makefile.am b/lang/python/tests/Makefile.am
index b2e725f..bc571fe 100644
--- a/lang/python/tests/Makefile.am
+++ b/lang/python/tests/Makefile.am
@@ -49,7 +49,8 @@ py_tests = t-wrapper.py \
 	t-wait.py \
 	t-encrypt-large.py \
 	t-file-name.py \
-	t-idiomatic.py
+	t-idiomatic.py \
+	t-protocol-assuan.py
 
 TESTS = initial.py $(py_tests) final.py
 EXTRA_DIST = support.py $(TESTS) encrypt-only.asc sign-only.asc
diff --git a/lang/python/tests/t-protocol-assuan.py b/lang/python/tests/t-protocol-assuan.py
new file mode 100755
index 0000000..30907a1
--- /dev/null
+++ b/lang/python/tests/t-protocol-assuan.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2016 g10 Code GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GPGME is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+import pyme
+
+with pyme.Context(protocol=pyme.constants.PROTOCOL_ASSUAN) as c:
+    # Do nothing.
+    c.assuan_transact('nop')
+    c.assuan_transact('NOP')
+    c.assuan_transact(['NOP'])
+
+    err = c.assuan_transact('idontexist')
+    assert err.getsource() == pyme.errors.SOURCE_GPGAGENT
+    assert err.getcode() == pyme.errors.ASS_UNKNOWN_CMD
+
+    # Invoke the pinentry to get a confirmation.
+    c.assuan_transact(['GET_CONFIRMATION', 'Hello there'])
+
+    data = []
+    def data_cb(line):
+        data.append(line)
+
+    err = c.assuan_transact(['GETINFO', 'version'], data_cb=data_cb)
+    assert not err
+    assert len(data) == 1
+
+    data = []
+    err = c.assuan_transact(['GETINFO', 's2k_count'], data_cb=data_cb)
+    if not err:
+        assert len(data) == 1
+        assert int(data[0]) > 0
+
+    # XXX HELP sends status lines if we could use ASSUAN_CONVEY_COMMENTS.
+
+    status = []
+    def status_cb(line, args):
+        status.append((line, args))
+
+    alphas_grip = '76F7E2B35832976B50A27A282D9B87E44577EB66'
+    err = c.assuan_transact(['KEYINFO', alphas_grip], status_cb=status_cb)
+    if not err:
+        assert len(status) == 1
+        line, args = status[0]
+        assert line.startswith('KEYINFO')
+        assert args.startswith(alphas_grip)
+
+    # XXX: test these callbacks, e.g. using PRESET_PASSPHRASE
+    # XXX: once issue2428 is resolved
+    def inq_cb(name, args):
+        print("inq_cb", name, args)

commit 355d7072863ac1f0f725e77141a59f3ed8a5e4af
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jul 28 11:16:35 2016 +0200

    python: Improve engine information handling.
    
    * lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos.
    * lang/python/pyme/core.py (Context.engine_info): New property.
    (Context.{g,s}et_engine_info): Improve docstrings.
    * lang/python/pyme/results.py (EngineInfo): New class.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 2b186c4..a372edd 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -324,7 +324,7 @@
 
 // Make types containing 'next' field to be lists
 %ignore next;
-%typemap(out) gpgme_sig_notation_t, gpgme_engine_info_t, gpgme_subkey_t,
+%typemap(out) gpgme_sig_notation_t, gpgme_subkey_t,
    gpgme_key_sig_t, gpgme_user_id_t, gpgme_invalid_key_t,
    gpgme_recipient_t, gpgme_new_signature_t, gpgme_signature_t,
    gpgme_import_status_t, gpgme_conf_arg_t, gpgme_conf_opt_t,
@@ -409,6 +409,26 @@
   Py_DECREF(fragile);
 }
 
+%typemap(out) gpgme_engine_info_t {
+  int i;
+  int size = 0;
+  $1_ltype curr;
+  for (curr = $1; curr != NULL; curr = curr->next) {
+    size++;
+  }
+  $result = PyList_New(size);
+  for (i=0,curr=$1; i<size; i++,curr=curr->next) {
+    PyObject *fragile, *o;
+    fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
+                                 %newpointer_flags);
+    o = pygpgme_wrap_fragile_result(fragile, "EngineInfo");
+    if (o == NULL)
+      return NULL;	/* raise */
+    Py_DECREF(fragile);
+    PyList_SetItem($result, i, o);
+  }
+}
+
 

 
 // Include mapper for edit callbacks
diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index 3ca4747..216e26f 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -666,17 +666,39 @@ class Context(GpgmeWrapper):
         if pygpgme.pygpgme_set_status_cb:
             self.set_status_cb(None)
 
+    @property
+    def engine_info(self):
+        """Configuration of the engine currently in use"""
+        p = self.protocol
+        infos = [i for i in self.get_engine_info() if i.protocol == p]
+        assert len(infos) == 1
+        return infos[0]
+
     def get_engine_info(self):
-        """Returns this context specific engine info"""
+        """Get engine configuration
+
+        Returns information about all configured and installed
+        engines.
+
+        Returns:
+        infos		-- a list of engine infos
+
+        """
         return pygpgme.gpgme_ctx_get_engine_info(self.wrapped)
 
-    def set_engine_info(self, proto, file_name, home_dir=None):
-        """Changes the configuration of the crypto engine implementing the
-    protocol 'proto' for the context. 'file_name' is the file name of
-    the executable program implementing this protocol. 'home_dir' is the
-    directory name of the configuration directory (engine's default is
-    used if omitted)."""
-        errorcheck(pygpgme.gpgme_ctx_set_engine_info(self.wrapped, proto, file_name, home_dir))
+    def set_engine_info(self, proto, file_name=None, home_dir=None):
+        """Change engine configuration
+
+        Changes the configuration of the crypto engine implementing
+        the protocol 'proto' for the context.
+
+        Keyword arguments:
+        file_name	-- engine program file name (unchanged if None)
+        home_dir	-- configuration directory (unchanged if None)
+
+        """
+        errorcheck(pygpgme.gpgme_ctx_set_engine_info(
+            self.wrapped, proto, file_name, home_dir))
 
     def wait(self, hang):
         """Wait for asynchronous call to finish. Wait forever if hang is True.
diff --git a/lang/python/pyme/results.py b/lang/python/pyme/results.py
index aa9b38e..374d982 100644
--- a/lang/python/pyme/results.py
+++ b/lang/python/pyme/results.py
@@ -113,3 +113,6 @@ class KeylistResult(Result):
 
 class VFSMountResult(Result):
     pass
+
+class EngineInfo(Result):
+    pass

commit 78f7bf4dcf75206faae5776c2ee4166628313532
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jul 28 10:59:46 2016 +0200

    python: Add accessors for the protocol.
    
    * lang/python/pyme/core.py (Context.__init__): Add 'protocol'
    parameter.
    (Context.protocol): New accessors.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index 6ca8cb8..3ca4747 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -169,6 +169,7 @@ class Context(GpgmeWrapper):
 
     def __init__(self, armor=False, textmode=False, offline=False,
                  signers=[], pinentry_mode=constants.PINENTRY_MODE_DEFAULT,
+                 protocol=constants.PROTOCOL_OpenPGP,
                  wrapped=None):
         """Construct a context object
 
@@ -178,6 +179,7 @@ class Context(GpgmeWrapper):
         offline		-- do not contact external key sources (default False)
         signers		-- list of keys used for signing (default [])
         pinentry_mode	-- pinentry mode (default PINENTRY_MODE_DEFAULT)
+        protocol	-- protocol to use (default PROTOCOL_OpenPGP)
 
         """
         if wrapped:
@@ -194,6 +196,7 @@ class Context(GpgmeWrapper):
         self.offline = offline
         self.signers = signers
         self.pinentry_mode = pinentry_mode
+        self.protocol = protocol
 
     def encrypt(self, plaintext, recipients=[], sign=True, sink=None,
                 passphrase=None, always_trust=False, add_encrypt_to=False,
@@ -487,6 +490,14 @@ class Context(GpgmeWrapper):
     def pinentry_mode(self, value):
         self.set_pinentry_mode(value)
 
+    @property
+    def protocol(self):
+        """Protocol to use"""
+        return self.get_protocol()
+    @protocol.setter
+    def protocol(self, value):
+        self.set_protocol(value)
+
     _ctype = 'gpgme_ctx_t'
     _cprefix = 'gpgme_'
 

commit 3d4dc3f0218234a27103bdb6f93b17c0703b71a2
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jul 28 10:20:20 2016 +0200

    python: Expose less functions to the Python world.
    
    * lang/python/Makefile.am (EXTRA_DIST, COPY_FILES): Add new file.
    * lang/python/gpgme.i: Include new file and add comments.
    * lang/python/helpers.c: Include new file.
    * lang/python/helpers.h: Move functions we do not need to expose...
    * lang/python/private.h: ... here.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 0ac1dd0..3651db9 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -20,7 +20,7 @@ EXTRA_DIST = \
 	README \
 	MANIFEST.in \
 	gpgme.i \
-	helpers.c helpers.h \
+	helpers.c helpers.h private.h \
 	gpgme-h-clean.py \
 	examples \
 	pyme
@@ -34,7 +34,7 @@ COPY_FILES = \
 	$(srcdir)/gpgme-h-clean.py \
 	$(srcdir)/pyme \
 	$(srcdir)/examples \
-	$(srcdir)/helpers.c $(srcdir)/helpers.h
+	$(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
 
 # For VPATH builds we need to copy some files because Python's
 # distutils are not VPATH-aware.
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index c1e0074..2b186c4 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -476,8 +476,10 @@ struct _gpgme_sig_notation
 %}
 FILE *fdopen(int fildes, const char *mode);
 
+/* We include both headers in the generated c code...  */
 %{
 #include "helpers.h"
+#include "private.h"
 
 /* SWIG support for helpers.c  */
 PyObject *
@@ -499,4 +501,6 @@ pygpgme_unwrap_gpgme_ctx_t(PyObject *wrapped)
 }
 %}
 
+/* ... but only the public definitions here.  They will be exposed to
+   the Python world, so let's be careful.  */
 %include "helpers.h"
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index d6cbb88..2b38172 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -24,7 +24,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include "Python.h"
+
 #include "helpers.h"
+#include "private.h"
 
 static PyObject *GPGMEError = NULL;
 
diff --git a/lang/python/helpers.h b/lang/python/helpers.h
index beb2682..4bfb664 100644
--- a/lang/python/helpers.h
+++ b/lang/python/helpers.h
@@ -26,25 +26,12 @@
 #define write(fd, str, sz) {DWORD written; WriteFile((HANDLE) fd, str, sz, &written, 0);}
 #endif
 
-void pygpgme_exception_init(void);
-gpgme_error_t pygpgme_exception2code(void);
-
-PyObject *object_to_gpgme_t(PyObject *input, const char *objtype, int argnum);
-PyObject *object_to_gpgme_data_t(PyObject *input, int argnum,
-				 gpgme_data_t *wrapper,
-				 PyObject **bytesio, Py_buffer *view);
-
-PyObject *pygpgme_wrap_fragile_result(PyObject *fragile, const char *classname);
-
 PyObject *pygpgme_raise_callback_exception(PyObject *self);
 
 PyObject *pygpgme_set_passphrase_cb(PyObject *self, PyObject *cb);
 PyObject *pygpgme_set_progress_cb(PyObject *self, PyObject *cb);
 PyObject *pygpgme_set_status_cb(PyObject *self, PyObject *cb);
 
-gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
-		       const char *args, int fd);
-
 PyObject *pygpgme_data_new_from_cbs(PyObject *self, PyObject *pycbs,
 				    gpgme_data_t *r_data);
 
diff --git a/lang/python/private.h b/lang/python/private.h
new file mode 100644
index 0000000..cb21f06
--- /dev/null
+++ b/lang/python/private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 g10 Code GmbH
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * GPGME is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gpgme.h>
+
+#ifndef _PYME_PRIVATE_H_
+#define _PYME_PRIVATE_H_
+
+void pygpgme_exception_init(void);
+gpgme_error_t pygpgme_exception2code(void);
+
+PyObject *object_to_gpgme_t(PyObject *input, const char *objtype, int argnum);
+PyObject *object_to_gpgme_data_t(PyObject *input, int argnum,
+				 gpgme_data_t *wrapper,
+				 PyObject **bytesio, Py_buffer *view);
+
+PyObject *pygpgme_wrap_fragile_result(PyObject *fragile, const char *classname);
+
+gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status,
+		       const char *args, int fd);
+
+#endif /* _PYME_PRIVATE_H_ */

-----------------------------------------------------------------------

Summary of changes:
 lang/python/Makefile.am                |   4 +-
 lang/python/gpgme.i                    |  80 +++++++++++++++++++++-
 lang/python/helpers.c                  | 118 +++++++++++++++++++++++++++++++++
 lang/python/helpers.h                  |  13 ----
 lang/python/private.h                  |  46 +++++++++++++
 lang/python/pyme/core.py               |  99 ++++++++++++++++++++++++---
 lang/python/pyme/results.py            |   3 +
 lang/python/pyme/util.py               |   6 ++
 lang/python/tests/Makefile.am          |   3 +-
 lang/python/tests/t-protocol-assuan.py |  66 ++++++++++++++++++
 10 files changed, 413 insertions(+), 25 deletions(-)
 create mode 100644 lang/python/private.h
 create mode 100755 lang/python/tests/t-protocol-assuan.py


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list