[svn] GpgEX - r10 - in trunk: . m4 po src
svn author marcus
cvs at cvs.gnupg.org
Tue Sep 4 18:07:32 CEST 2007
Author: marcus
Date: 2007-09-04 18:07:02 +0200 (Tue, 04 Sep 2007)
New Revision: 10
Added:
trunk/m4/gpg-error.m4
trunk/m4/libassuan.m4
trunk/src/client.cc
trunk/src/client.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/po/POTFILES.in
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/gpgex.cc
trunk/src/main.cc
trunk/src/main.h
Log:
2007-09-04 Marcus Brinkmann <marcus at g10code.de>
* m4/libassuan.m4, m4/gpg-error.m4: New files.
* configure.ac: Check for libgpg-error and libassuan.
* po/POTFILES.in: Add src/client.cc, src/gpgex.h and src/gpgex.cc.
src/
2007-09-04 Marcus Brinkmann <marcus at g10code.de>
* Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Remove $(GPGME_CFLAGS),
add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS).
(gpgex_SOURCES): Add client.h and client.cc.
(libgpg-error.a, libassuan.a, clean-local): New targets.
(gpgex_LDADD): Add ./libassuan.a and ./libgpg-error.a.
* client.h, client.cc: New files.
* gpgex.cc: Include client.h.
(gpgex_t::InvokeCommand): Use client class to implement bunch of
functionality.
* main.h: Include <gpg-error.h>.
(DEBUG_ASSUAN, REGKEY, TRACE_GPGERR): New macros.
* main.cc: Include <gpg-error.h> and <assuan.h>.
(REGKEY): Deleted.
(debug_init): Free filename and add DEBUG_ASSUAN to debug flags.
(DllMain): Set assuan log stream and prefix, and the error source.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/ChangeLog 2007-09-04 16:07:02 UTC (rev 10)
@@ -1,3 +1,9 @@
+2007-09-04 Marcus Brinkmann <marcus at g10code.de>
+
+ * m4/libassuan.m4, m4/gpg-error.m4: New files.
+ * configure.ac: Check for libgpg-error and libassuan.
+ * po/POTFILES.in: Add src/client.cc, src/gpgex.h and src/gpgex.cc.
+
2007-09-03 Marcus Brinkmann <marcus at g10code.de>
* m4/Makefile.am (EXTRA_DIST): Remove gpgme.m4 and gpg-error.m4.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/configure.ac 2007-09-04 16:07:02 UTC (rev 10)
@@ -29,6 +29,11 @@
PACKAGE_GT=${PACKAGE_NAME}
VERSION=$PACKAGE_VERSION
+NEED_GPG_ERROR_VERSION=1.4
+
+NEED_LIBASSUAN_API=1
+NEED_LIBASSUAN_VERSION=0.9.3
+
AC_CONFIG_SRCDIR(src/gpgex.def)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_TARGET
@@ -36,6 +41,9 @@
AC_GNU_SOURCE
+have_gpg_error=no
+have_libassuan=no
+
AC_SUBST(PACKAGE)
AC_SUBST(PACKAGE_GT)
AC_SUBST(VERSION)
@@ -169,12 +177,52 @@
AC_SUBST(W32LIBS)
+#
+# libgpg-error is a library with error codes shared between GnuPG
+# related projects.
+#
+AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
+ have_gpg_error=yes,have_gpg_error=no)
+AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_USER_1,
+ [The default error source for GpgEX.])
#
+# libassuan is used for IPC
+#
+AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
+ have_libassuan=yes,have_libassuan=no)
+
+
+AH_BOTTOM([
+/* We don't want the old assuan codes anymore. */
+#define _ASSUAN_ONLY_GPG_ERRORS 1
+])
+
+#
# Print errors here so that they are visible all
# together and the user can acquire them all together.
#
die=no
+if test "$have_gpg_error" = "no"; then
+ die=yes
+ AC_MSG_NOTICE([[
+***
+*** You need libgpg-error to build this program.
+** This library is for example available at
+*** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
+*** (at least version $NEED_GPG_ERROR_VERSION is required.)
+***]])
+fi
+if test "$have_libassuan" = "no"; then
+ die=yes
+ AC_MSG_NOTICE([[
+***
+*** You need libassuan to build this program.
+*** This library is for example available at
+*** ftp://ftp.gnupg.org/pub/gcrypt/libassuan/
+*** (at least version $NEED_LIBASSUAN_VERSION is required).
+***]])
+fi
if test "$die" = "yes"; then
AC_MSG_ERROR([[
***
Added: trunk/m4/gpg-error.m4
===================================================================
--- trunk/m4/gpg-error.m4 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/m4/gpg-error.m4 2007-09-04 16:07:02 UTC (rev 10)
@@ -0,0 +1,56 @@
+dnl Autoconf macros for libgpg-error
+
+dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
+dnl
+AC_DEFUN([AM_PATH_GPG_ERROR],
+[ AC_ARG_WITH(gpg-error-prefix,
+ AC_HELP_STRING([--with-gpg-error-prefix=PFX],
+ [prefix where GPG Error is installed (optional)]),
+ gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
+ if test x$gpg_error_config_prefix != x ; then
+ if test x${GPG_ERROR_CONFIG+set} != xset ; then
+ GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
+ fi
+ fi
+
+ AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
+ min_gpg_error_version=ifelse([$1], ,0.0,$1)
+ AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
+ ok=no
+ if test "$GPG_ERROR_CONFIG" != "no" ; then
+ req_major=`echo $min_gpg_error_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpg_error_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
+ major=`echo $gpg_error_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $gpg_error_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -ge "$req_minor"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
+ GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ GPG_ERROR_CFLAGS=""
+ GPG_ERROR_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPG_ERROR_CFLAGS)
+ AC_SUBST(GPG_ERROR_LIBS)
+])
+
Added: trunk/m4/libassuan.m4
===================================================================
--- trunk/m4/libassuan.m4 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/m4/libassuan.m4 2007-09-04 16:07:02 UTC (rev 10)
@@ -0,0 +1,175 @@
+dnl Autoconf macros for libassuan
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; as a special exception the author gives
+dnl unlimited permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+dnl This file is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+dnl
+dnl Common code used for libassuan detection [internal]
+dnl Returns ok set to yes or no.
+dnl
+AC_DEFUN([_AM_PATH_LIBASSUAN_COMMON],
+[ AC_ARG_WITH(libassuan-prefix,
+ AC_HELP_STRING([--with-libassuan-prefix=PFX],
+ [prefix where LIBASSUAN is installed (optional)]),
+ libassuan_config_prefix="$withval", libassuan_config_prefix="")
+ if test x$libassuan_config_prefix != x ; then
+ libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix"
+ if test x${LIBASSUAN_CONFIG+set} != xset ; then
+ LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config
+ fi
+ fi
+ AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no)
+
+ tmp=ifelse([$1], ,1:0.9.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_libassuan_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_libassuan_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_libassuan_api=0
+ min_libassuan_version="$tmp"
+ fi
+
+ if test "$LIBASSUAN_CONFIG" != "no" ; then
+ libassuan_version=`$LIBASSUAN_CONFIG --version`
+ fi
+ libassuan_version_major=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ libassuan_version_minor=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ libassuan_version_micro=`echo $libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+
+ AC_MSG_CHECKING(for LIBASSUAN ifelse([$2], ,,[$2 ])- version >= $min_libassuan_version)
+ ok=no
+ if test "$LIBASSUAN_CONFIG" != "no" ; then
+ ifelse([$2], ,,[if `$LIBASSUAN_CONFIG --thread=$2 2> /dev/null` ; then])
+ req_major=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_libassuan_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ if test "$libassuan_version_major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$libassuan_version_major" -eq "$req_major"; then
+ if test "$libassuan_version_minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$libassuan_version_minor" -eq "$req_minor"; then
+ if test "$libassuan_version_micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ ifelse([$2], ,,[fi])
+ fi
+
+ if test $ok = yes; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+
+ if test $ok = yes; then
+ if test "$req_libassuan_api" -gt 0 ; then
+ tmp=`$LIBASSUAN_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ AC_MSG_CHECKING([LIBASSUAN ifelse([$2], ,,[$2 ])API version])
+ if test "$req_libassuan_api" -eq "$tmp" ; then
+ AC_MSG_RESULT(okay)
+ else
+ ok=no
+ AC_MSG_RESULT([does not match. want=$req_libassuan_api got=$tmp.])
+ fi
+ fi
+ fi
+ fi
+
+])
+
+dnl AM_CHECK_LIBASSUAN([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test whether libassuan has at least MINIMUM-VERSION. This is
+dnl used to test for features only available in newer versions.
+dnl
+AC_DEFUN([AM_CHECK_LIBASSUAN],
+[ _AM_PATH_LIBASSUAN_COMMON($1)
+ if test $ok = yes; then
+ ifelse([$2], , :, [$2])
+ else
+ ifelse([$3], , :, [$3])
+ fi
+])
+
+
+
+
+dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN],
+[ _AM_PATH_LIBASSUAN_COMMON($1)
+ if test $ok = yes; then
+ LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags`
+ LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs`
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_CFLAGS=""
+ LIBASSUAN_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_CFLAGS)
+ AC_SUBST(LIBASSUAN_LIBS)
+])
+
+
+dnl AM_PATH_LIBASSUAN_PTH([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTH_CFLAGS and LIBASSUAN_PTH_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTH],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pth)
+ if test $ok = yes; then
+ LIBASSUAN_PTH_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pth --cflags`
+ LIBASSUAN_PTH_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pth --libs`
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_PTH_CFLAGS=""
+ LIBASSUAN_PTH_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_PTH_CFLAGS)
+ AC_SUBST(LIBASSUAN_PTH_LIBS)
+])
+
+
+dnl AM_PATH_LIBASSUAN_PTHREAD([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libassuan and define LIBASSUAN_PTHREAD_CFLAGS
+dnl and LIBASSUAN_PTHREAD_LIBS
+dnl
+AC_DEFUN([AM_PATH_LIBASSUAN_PTHREAD],
+[ _AM_PATH_LIBASSUAN_COMMON($1,pthread)
+ if test $ok = yes; then
+ LIBASSUAN_PTHREAD_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pthread --cflags`
+ LIBASSUAN_PTHREAD_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --thread=pthread --libs`
+ ifelse([$2], , :, [$2])
+ else
+ LIBASSUAN_PTHREAD_CFLAGS=""
+ LIBASSUAN_PTHREAD_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBASSUAN_PTHREAD_CFLAGS)
+ AC_SUBST(LIBASSUAN_PTHREAD_LIBS)
+])
+
Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/po/POTFILES.in 2007-09-04 16:07:02 UTC (rev 10)
@@ -1 +1,4 @@
src/main.cc
+src/client.cc
+src/gpgex.h
+src/gpgex.cc
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/ChangeLog 2007-09-04 16:07:02 UTC (rev 10)
@@ -1,3 +1,21 @@
+2007-09-04 Marcus Brinkmann <marcus at g10code.de>
+
+ * Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Remove $(GPGME_CFLAGS),
+ add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS).
+ (gpgex_SOURCES): Add client.h and client.cc.
+ (libgpg-error.a, libassuan.a, clean-local): New targets.
+ (gpgex_LDADD): Add ./libassuan.a and ./libgpg-error.a.
+ * client.h, client.cc: New files.
+ * gpgex.cc: Include client.h.
+ (gpgex_t::InvokeCommand): Use client class to implement bunch of
+ functionality.
+ * main.h: Include <gpg-error.h>.
+ (DEBUG_ASSUAN, REGKEY, TRACE_GPGERR): New macros.
+ * main.cc: Include <gpg-error.h> and <assuan.h>.
+ (REGKEY): Deleted.
+ (debug_init): Free filename and add DEBUG_ASSUAN to debug flags.
+ (DllMain): Set assuan log stream and prefix, and the error source.
+
2007-09-03 Marcus Brinkmann <marcus at g10code.de>
* bitmaps.h, bitmaps.cc, icons.rc, icon-key-12.bmp,
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/Makefile.am 2007-09-04 16:07:02 UTC (rev 10)
@@ -15,8 +15,8 @@
EXTRA_DIST = versioninfo.rc.in
EXEEXT = .dll
-AM_CFLAGS = $(GPGME_CFLAGS) -shared
-AM_CXXFLAGS = $(GPGME_CFLAGS) -shared
+AM_CFLAGS = $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) -shared
+AM_CXXFLAGS = $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) -shared
nodist_gpgex_SOURCES = versioninfo.rc
gpgex_SOURCES = \
@@ -28,12 +28,24 @@
gpgex-factory.h gpgex-factory.cc \
bitmaps.h bitmaps.cc \
gpgex.h gpgex.cc \
+ client.h client.cc \
main.h main.cc
#gpgex_LDADD = $(srcdir)/gpgex.def \
# -L . -lshell32 -lcomdlg32 -loleaut32 -ladvapi32
+
+libgpg-error.a:
+ ln -s $(shell $(GPG_ERROR_CONFIG) --prefix)/lib/libgpg-error.a
+
+libassuan.a:
+ ln -s $(shell $(LIBASSUAN_CONFIG) --prefix)/lib/libassuan.a
+
+clean-local:
+ rm -f libgpg-error.a libassuan.a
+
gpgex_LDADD = $(srcdir)/gpgex.def -L . \
- -lshell32 -lgdi32 -lws2_32 -lole32 -luuid
+ -lshell32 -lgdi32 -lws2_32 -lole32 -luuid \
+ ./libassuan.a ./libgpg-error.a
.rc.o:
$(WINDRES) -I $(srcdir) -I . `test -f '$<' || echo '$(srcdir)/'`$< $@
Added: trunk/src/client.cc
===================================================================
--- trunk/src/client.cc 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/client.cc 2007-09-04 16:07:02 UTC (rev 10)
@@ -0,0 +1,161 @@
+/* client.cc - gpgex assuan client implementation
+ Copyright (C) 2007 g10 Code GmbH
+
+ This file is part of GpgEX.
+
+ GpgEX 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 of the License, or (at your option) any later version.
+
+ GpgEX 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <vector>
+#include <string>
+#include <stdexcept>
+
+using std::vector;
+using std::string;
+
+#include <windows.h>
+
+#include <assuan.h>
+
+#include "registry.h"
+#include "main.h"
+
+#include "client.h"
+
+
+static const char *
+default_socket_name (void)
+{
+ static string name;
+
+ if (name.size() == 0)
+ {
+ char *dir = NULL;
+
+ /* FIXME: Wrong directory. */
+ dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY,
+ "Install Directory");
+ if (dir)
+ {
+ try { name = ((string) dir) + "\\S.kleopatra"; } catch (...) {}
+ free ((void *) dir);
+ }
+ }
+
+ return name.c_str ();
+}
+
+
+bool
+client_t::call_assuan (const char *cmd, vector<string> &filenames)
+{
+ int rc = 0;
+ assuan_context_t ctx = NULL;
+ const char *socket_name;
+ string msg;
+
+ TRACE_BEG2 (DEBUG_ASSUAN, "client_t::call_assuan", this,
+ "%s on %u files", cmd, filenames.size ());
+
+ socket_name = default_socket_name ();
+ if (! socket_name || ! *socket_name)
+ {
+ (void) TRACE_LOG ("invalid socket name");
+ rc = gpg_error (GPG_ERR_INV_ARG);
+ goto leave;
+ }
+
+ (void) TRACE_LOG1 ("socket name: %s", socket_name);
+ rc = assuan_socket_connect (&ctx, socket_name, -1);
+ if (rc)
+ goto leave;
+
+ try
+ {
+ /* Set the input files. FIXME: Might need to set the output files
+ as well. */
+ for (unsigned int i = 0; i < filenames.size (); i++)
+ {
+ msg = "INPUT FILE=\"" + filenames[i] + "\" --continued";
+
+ (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
+
+ rc = assuan_transact (ctx, msg.c_str (),
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (rc)
+ goto leave;
+ }
+
+ /* Set the --nohup option, so that the operation continues and
+ completes in the background. */
+ msg = "OPTION --nohup";
+ (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
+ rc = assuan_transact (ctx, msg.c_str (),
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (rc)
+ goto leave;
+
+ msg = cmd;
+ (void) TRACE_LOG1 ("sending cmd: %s", msg.c_str ());
+ rc = assuan_transact (ctx, msg.c_str (),
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ catch (std::bad_alloc)
+ {
+ rc = gpg_error (GPG_ERR_ENOMEM);
+ }
+ catch (...)
+ {
+ rc = gpg_error (GPG_ERR_GENERAL);
+ }
+
+ /* Fall-through. */
+ leave:
+ TRACE_GPGERR (rc);
+ if (ctx)
+ assuan_disconnect (ctx);
+ if (rc)
+ {
+ MessageBox (this->window,
+ _("Can not access Kleopatra, see log file for details"),
+ "GpgEX", MB_ICONINFORMATION);
+ }
+
+ return rc ? false : true;
+}
+
+
+void
+client_t::decrypt_verify (vector<string> &filenames)
+{
+ this->call_assuan ("DECRYPT_VERIFY", filenames);
+}
+
+
+void
+client_t::encrypt_sign (vector<string> &filenames)
+{
+ this->call_assuan ("ENCRPYT_SIGN", filenames);
+}
+
+void
+client_t::import (vector<string> &filenames)
+{
+ this->call_assuan ("IMPORT", filenames);
+}
Added: trunk/src/client.h
===================================================================
--- trunk/src/client.h 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/client.h 2007-09-04 16:07:02 UTC (rev 10)
@@ -0,0 +1,50 @@
+/* client.h - gpgex assuan client interface
+ Copyright (C) 2007 g10 Code GmbH
+
+ This file is part of GpgEX.
+
+ GpgEX 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 of the License, or (at your option) any later version.
+
+ GpgEX 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef CLIENT_H
+#define CLIENT_H
+
+#include <vector>
+#include <string>
+
+using std::vector;
+using std::string;
+
+#include <windows.h>
+
+class client_t
+{
+ private:
+ HWND window;
+
+ bool call_assuan (const char *cmd, vector<string> &filenames);
+
+ public:
+ client_t (HWND window_handle)
+ : window (window_handle)
+ {
+ }
+
+ void decrypt_verify (vector<string> &filenames);
+ void encrypt_sign (vector<string> &filenames);
+ void import (vector<string> &filenames);
+};
+
+#endif /* ! CLIENT_H */
Modified: trunk/src/gpgex.cc
===================================================================
--- trunk/src/gpgex.cc 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/gpgex.cc 2007-09-04 16:07:02 UTC (rev 10)
@@ -32,6 +32,7 @@
#include <windows.h>
#include "main.h"
+#include "client.h"
#include "gpgex.h"
@@ -350,9 +351,7 @@
STDMETHODIMP
gpgex_t::InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
{
- string cmd;
-
- TRACE_BEG1 (DEBUG_CONTEXT_MENU, "gpgex_t::GetCommandString", this,
+ TRACE_BEG1 (DEBUG_CONTEXT_MENU, "gpgex_t::InvokeCommand", this,
"lpcmi=%p", lpcmi);
/* If lpVerb really points to a string, ignore this function call
@@ -360,38 +359,38 @@
if (HIWORD (lpcmi->lpVerb) != 0)
return TRACE_RES (E_INVALIDARG);
+ client_t client (lpcmi->hwnd);
+
/* Get the command index, which is the offset to IDCMDFIRST of
QueryContextMenu, ie zero based). */
switch (LOWORD (lpcmi->lpVerb))
{
case ID_CMD_HELP:
- cmd = "HELP";
+ {
+ string msg;
+ unsigned int i;
+
+ msg = "Invoked Help on files:\n\n";
+ for (i = 0; i < this->filenames.size (); i++)
+ msg = msg + this->filenames[i] + '\n';
+
+ MessageBox (lpcmi->hwnd, msg.c_str (), "GpgEX", MB_ICONINFORMATION);
+ }
break;
case ID_CMD_VERIFY_DECRYPT:
- cmd = "VERIFY_DECRYPT";
+ client.decrypt_verify (this->filenames);
break;
case ID_CMD_SIGN_ENCRYPT:
- cmd = "SIGN_ENCRYPT";
+ client.encrypt_sign (this->filenames);
break;
case ID_CMD_IMPORT:
- cmd = "IMPORT";
+ client.import (this->filenames);
break;
default:
return TRACE_RES (E_INVALIDARG);
break;
}
- /* FIXME: Need to send commands to Kleopatra. */
-
- string msg;
- unsigned int i;
-
- msg = "Invoked " + cmd + "on files:\n\n";
- for (i = 0; i < this->filenames.size (); i++)
- msg = msg + this->filenames[i] + '\n';
-
- MessageBox (lpcmi->hwnd, msg.c_str (), "GpgEX", MB_ICONINFORMATION);
-
return TRACE_RES (S_OK);
}
Modified: trunk/src/main.cc
===================================================================
--- trunk/src/main.cc 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/main.cc 2007-09-04 16:07:02 UTC (rev 10)
@@ -26,6 +26,9 @@
#include <windows.h>
#include <shlobj.h>
+#include <gpg-error.h>
+#include <assuan.h>
+
#include "registry.h"
#include "gpgex-class.h"
#include "gpgex-factory.h"
@@ -42,10 +45,6 @@
LONG gpgex_server::refcount;
-/* Registry key for this software. */
-#define REGKEY "Software\\GNU\\GnuPG"
-
-
static char *
get_locale_dir (void)
{
@@ -141,11 +140,12 @@
return;
debug_file = fopen (filename, "a");
+ free (filename);
if (!debug_file)
return;
/* FIXME: Make this configurable eventually. */
- debug_flags = DEBUG_INIT | DEBUG_CONTEXT_MENU;
+ debug_flags = DEBUG_INIT | DEBUG_CONTEXT_MENU | DEBUG_ASSUAN;
}
@@ -198,6 +198,13 @@
debug_init ();
+ if (debug_flags & DEBUG_ASSUAN)
+ {
+ assuan_set_assuan_log_stream (debug_file);
+ assuan_set_assuan_log_prefix ("gpgex:assuan");
+ }
+ assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
+
(void) TRACE0 (DEBUG_INIT, "DllMain", hinst,
"reason=DLL_PROCESS_ATTACH");
}
Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h 2007-09-03 21:51:34 UTC (rev 9)
+++ trunk/src/main.h 2007-09-04 16:07:02 UTC (rev 10)
@@ -23,12 +23,18 @@
#include <windows.h>
+#include <gpg-error.h>
+
#include "w32-gettext.h"
#define _(a) gettext (a)
#define N_(a) gettext_noop (a)
+/* Registry key for this software. */
+#define REGKEY "Software\\GNU\\GnuPG"
+
+
/* We use a class just for namespace cleanliness. */
class gpgex_server
{
@@ -63,6 +69,7 @@
#define DEBUG_INIT 1
#define DEBUG_CONTEXT_MENU 2
+#define DEBUG_ASSUAN 4
#define STRINGIFY(v) #v
@@ -163,6 +170,13 @@
name, STRINGIFY (tag), (void *) tag, arg1, arg2, arg3, \
arg4, arg5, arg6), 0)
+#define TRACE_GPGERR(err) \
+ err == 0 ? (TRACE_SUC ()) : \
+ (_gpgex_debug (_gpgex_trace_level, "%s (%s=0x%x): error: %s <%s>\n", \
+ _gpgex_trace_func, _gpgex_trace_tagname, \
+ _gpgex_trace_tag, gpg_strerror (err), \
+ gpg_strsource (err)), (err))
+
#define TRACE_RES(err) \
err == S_OK ? (TRACE_SUC ()) : \
(_gpgex_debug (_gpgex_trace_level, "%s (%s=0x%x): %s: ec=%x\n", \
More information about the Gnupg-commits
mailing list