Пример #1
0
static void
pygpgme_context_dealloc(PyGpgmeContext *self)
{
    gpgme_passphrase_cb_t passphrase_cb;
    gpgme_progress_cb_t progress_cb;
    PyObject *callback;

    if (self->ctx) {
        /* free the passphrase callback */
        gpgme_get_passphrase_cb(self->ctx, &passphrase_cb, (void **)&callback);
        if (passphrase_cb == pygpgme_passphrase_cb) {
            Py_DECREF(callback);
        }

        /* free the progress callback */
        gpgme_get_progress_cb(self->ctx, &progress_cb, (void **)&callback);
        if (progress_cb == pygpgme_progress_cb) {
            Py_DECREF(callback);
        }

        gpgme_release(self->ctx);
    }
    self->ctx = NULL;
    PyObject_Del(self);
}
Пример #2
0
static PyObject *
pygpgme_context_get_progress_cb(PyGpgmeContext *self)
{
    gpgme_progress_cb_t progress_cb;
    PyObject *callback;

    /* free the progress callback */
    gpgme_get_progress_cb(self->ctx, &progress_cb, (void **)&callback);
    if (progress_cb == pygpgme_progress_cb) {
        Py_INCREF(callback);
        return callback;
    } else {
        Py_RETURN_NONE;
    }
}
Пример #3
0
/* The worker for the asynchronous commands.  */
static DWORD WINAPI
waiter_thread (void *dummy)
{
  gpgme_ctx_t ctx;
  gpg_error_t err;
  void *a_voidptr;
  closure_data_t closure_data;

  (void)dummy;

  while (!shutdown_gpgme)
    {
      /*  Note: We don't use hang because this will end up in a tight
          loop and does not do a voluntary context switch.  Thus we do
          this by ourself.  Actually it would be better to start
          gpgme_wait only if we really have something to do but that
          is a bit more complicated.  */
      EnterCriticalSection (&waiter_thread_lock);
      ctx = gpgme_wait (NULL, &err, 0);
      LeaveCriticalSection (&waiter_thread_lock);
      if (ctx)
        {
          gpgme_get_progress_cb (ctx, NULL, &a_voidptr);
          closure_data = a_voidptr;
          assert (closure_data);
          assert (closure_data->closure);
          closure_data->closure (closure_data, ctx, err);
          xfree (closure_data);
          gpgme_release (ctx);
        }
      else if (err)
        log_debug ("%s:%s: gpgme_wait failed: %s\n", SRCNAME, __func__, 
                   gpg_strerror (err));
      else
        Sleep (50);
    }
  ExitThread (0);
  return 0;
}
Пример #4
0
static int
pygpgme_context_set_progress_cb(PyGpgmeContext *self, PyObject *value)
{
    gpgme_progress_cb_t progress_cb;
    PyObject *callback;

    /* free the progress callback */
    gpgme_get_progress_cb(self->ctx, &progress_cb, (void **)&callback);
    if (progress_cb == pygpgme_progress_cb) {
        Py_DECREF(callback);
    }

    /* callback of None == unset */
    if (value == Py_None)
        value = NULL;

    if (value != NULL) {
        Py_INCREF(value);
        gpgme_set_progress_cb(self->ctx, pygpgme_progress_cb, value);
    } else {
        gpgme_set_progress_cb(self->ctx, NULL, NULL);
    }
    return 0;
}