[svn] GpgEX - r19 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Sun Sep 16 18:27:21 CEST 2007
Author: marcus
Date: 2007-09-16 18:27:20 +0200 (Sun, 16 Sep 2007)
New Revision: 19
Modified:
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/gpgex.cc
Log:
2007-09-16 Marcus Brinkmann <marcus at g10code.de>
* gpgex.cc (gpgex_t::QueryContextMenu): Implement popup menu
correctly, such that the explorer can clean up correctly (in the
file dialog).
(gpgex_t::GetCommandString): Implement help texts.
(start_help): New function.
(gpgex_t::InvokeCommand): Call start_help.
* Makefile.am (gpgex_LDADD): Add -loleaut32.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-09-11 14:53:06 UTC (rev 18)
+++ trunk/src/ChangeLog 2007-09-16 16:27:20 UTC (rev 19)
@@ -1,3 +1,13 @@
+2007-09-16 Marcus Brinkmann <marcus at g10code.de>
+
+ * gpgex.cc (gpgex_t::QueryContextMenu): Implement popup menu
+ correctly, such that the explorer can clean up correctly (in the
+ file dialog).
+ (gpgex_t::GetCommandString): Implement help texts.
+ (start_help): New function.
+ (gpgex_t::InvokeCommand): Call start_help.
+ * Makefile.am (gpgex_LDADD): Add -loleaut32.
+
2007-09-11 Marcus Brinkmann <marcus at g10code.de>
* client.cc (client_t::call_assuan): Send --nohup as argument to
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-09-11 14:53:06 UTC (rev 18)
+++ trunk/src/Makefile.am 2007-09-16 16:27:20 UTC (rev 19)
@@ -37,9 +37,6 @@
main.h main.cc \
$(ICONS)
-#gpgex_LDADD = $(srcdir)/gpgex.def \
-# -L . -lshell32 -lcomdlg32 -loleaut32 -ladvapi32
-
libgpg-error.a:
ln -sf $(shell $(GPG_ERROR_CONFIG) --prefix)/lib/libgpg-error.a
@@ -49,9 +46,13 @@
clean-local:
rm -f libgpg-error.a libassuan.a
+#gpgex_LDADD = $(srcdir)/gpgex.def \
+# -L . -lshell32 -lcomdlg32 -ladvapi32
+
+# We need -loleaut32 for start_help() in gpgex.cc.
gpgex_LDADD = $(srcdir)/gpgex.def -L . \
-lshell32 -lgdi32 -lole32 -luuid \
- ./libassuan.a ./libgpg-error.a -lws2_32
+ ./libassuan.a ./libgpg-error.a -lws2_32 -loleaut32
.rc.o:
$(WINDRES) -I $(srcdir) -I . `test -f '$<' || echo '$(srcdir)/'`$< $@
Modified: trunk/src/gpgex.cc
===================================================================
--- trunk/src/gpgex.cc 2007-09-11 14:53:06 UTC (rev 18)
+++ trunk/src/gpgex.cc 2007-09-16 16:27:20 UTC (rev 19)
@@ -31,6 +31,9 @@
#include <windows.h>
+/* For the start_help() function. */
+#include <exdisp.h>
+
#include "main.h"
#include "client.h"
@@ -46,7 +49,8 @@
#define ID_CMD_ENCRYPT 5
#define ID_CMD_SIGN 6
#define ID_CMD_IMPORT 7
-#define ID_CMD_MAX 7
+#define ID_CMD_POPUP 8
+#define ID_CMD_MAX 8
#define ID_CMD_STR_HELP _("Help on GpgEX")
#define ID_CMD_STR_DECRYPT_VERIFY _("Decrypt and verify")
@@ -291,8 +295,13 @@
if (popup == NULL)
return TRACE_RES (HRESULT_FROM_WIN32 (GetLastError ()));
- res = InsertMenu (hMenu, indexMenu++, MF_BYPOSITION | MF_STRING | MF_POPUP,
- (UINT) popup, _("More GpgEX options"));
+ MENUITEMINFO mii = { sizeof (MENUITEMINFO) };
+ mii.fMask = MIIM_SUBMENU | MIIM_STRING | MIIM_ID;
+ mii.wID = idCmdFirst + ID_CMD_POPUP;
+ mii.hSubMenu = popup;
+ mii.dwTypeData = (CHAR *) _("More GpgEX options");
+
+ res = InsertMenuItem (hMenu, indexMenu++, TRUE, &mii);
if (!res)
{
DWORD last_error = GetLastError ();
@@ -364,26 +373,137 @@
gpgex_t::GetCommandString (UINT idCommand, UINT uFlags, LPUINT lpReserved,
LPSTR pszName, UINT uMaxNameLen)
{
+ const char *txt;
+
TRACE_BEG5 (DEBUG_CONTEXT_MENU, "gpgex_t::GetCommandString", this,
"idCommand=%u, uFlags=%x, lpReserved=%lu, pszName=%p, "
"uMaxNameLen=%u",
idCommand, uFlags, lpReserved, pszName, uMaxNameLen);
- if (idCommand != 0)
+ if (! (uFlags & GCS_HELPTEXT))
return TRACE_RES (E_INVALIDARG);
- if (! (uFlags & GCS_HELPTEXT))
+ if (idCommand > ID_CMD_MAX)
return TRACE_RES (E_INVALIDARG);
+ switch (idCommand)
+ {
+ case ID_CMD_HELP:
+ txt = "Invoke the GpgEX documentation.";
+ break;
+
+ case ID_CMD_DECRYPT_VERIFY:
+ txt = "Decrypt and verify the marked files.";
+ break;
+
+ case ID_CMD_DECRYPT:
+ txt = "Decrypt the marked files.";
+ break;
+
+ case ID_CMD_VERIFY:
+ txt = "Verify the marked files.";
+ break;
+
+ case ID_CMD_ENCRYPT_SIGN:
+ txt = "Encrypt and sign the marked files.";
+ break;
+
+ case ID_CMD_ENCRYPT:
+ txt = "Encrypt the marked files.";
+ break;
+
+ case ID_CMD_SIGN:
+ txt = "Sign the marked files.";
+ break;
+
+ case ID_CMD_IMPORT:
+ txt = "Import the marked files.";
+ break;
+
+ case ID_CMD_POPUP:
+ txt = "Show more GpgEX options.";
+ break;
+
+ default:
+ return TRACE_RES (E_INVALIDARG);
+ }
+
if (uFlags & GCS_UNICODE)
- lstrcpynW ((LPWSTR) pszName, L"GpgEX help string (unicode)", uMaxNameLen);
+ {
+ /* FIXME: Convert to unicode. */
+ lstrcpynW ((LPWSTR) pszName, L"(Unicode help not available yet)",
+ uMaxNameLen);
+ }
else
- lstrcpynA (pszName, "GpgEX help string (ASCII)", uMaxNameLen);
+ lstrcpynA (pszName, txt, uMaxNameLen);
return TRACE_RES (S_OK);
}
+/* FIXME: Might be exported in a helper utility. Also, it might be
+ that we use KDE's help browser? */
+static void
+start_help (HWND hwnd)
+{
+ HRESULT res;
+ CLSID clsid;
+ LPUNKNOWN browser = NULL;
+ IWebBrowser2 *web = NULL;
+
+ CLSIDFromProgID (OLESTR ("InternetExplorer.Application"), &clsid);
+ res = CoCreateInstance (clsid, NULL, CLSCTX_SERVER, IID_IUnknown, (void **) &browser);
+ if (! SUCCEEDED (res))
+ {
+ MessageBox (hwnd, "Can not open browser", "GpgEX", MB_ICONINFORMATION);
+ return;
+ }
+
+ browser->QueryInterface (IID_IWebBrowser2, (void **) &web);
+ browser->Release ();
+
+ /* FIXME: Pick a good configuration. */
+ // Only for IE7?
+ // web->put_Resizable (VARIANT_TRUE);
+ web->put_ToolBar (FALSE);
+ web->put_AddressBar (VARIANT_FALSE);
+ web->put_MenuBar (VARIANT_FALSE);
+ web->put_StatusBar (VARIANT_FALSE);
+ // width, height
+ web->put_Visible (VARIANT_TRUE);
+
+ /* FIXME: Replace by real URL. */
+ BSTR url = SysAllocString ((const OLECHAR *) L"http://www.gpg4win.org/");
+ VARIANT vars[4];
+ memset (vars, 0, sizeof (vars));
+ res = web->Navigate (url, vars, vars + 1, vars + 2, vars + 3);
+ SysFreeString (url);
+ if (!SUCCEEDED (res))
+ {
+ web->Release ();
+ return;
+ }
+
+#if 0
+ VARIANT_BOOL busy;
+ do
+ {
+ web->get_Busy (&busy);
+ Sleep (500);
+ }
+ while (busy == VARIANT_TRUE);
+
+
+ HWND hwnd = NULL;
+ web->get_HWND (&hwnd);
+#endif
+
+ Sleep (5000);
+ web->Release ();
+
+}
+
+
STDMETHODIMP
gpgex_t::InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
{
@@ -402,38 +522,37 @@
switch (LOWORD (lpcmi->lpVerb))
{
case ID_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);
- }
+ start_help (lpcmi->hwnd);
break;
+
case ID_CMD_DECRYPT_VERIFY:
client.decrypt_verify (this->filenames);
break;
+
case ID_CMD_DECRYPT:
client.decrypt (this->filenames);
break;
+
case ID_CMD_VERIFY:
client.verify (this->filenames);
break;
+
case ID_CMD_ENCRYPT_SIGN:
client.encrypt_sign (this->filenames);
break;
+
case ID_CMD_ENCRYPT:
client.encrypt (this->filenames);
break;
+
case ID_CMD_SIGN:
client.sign (this->filenames);
break;
+
case ID_CMD_IMPORT:
client.import (this->filenames);
break;
+
default:
return TRACE_RES (E_INVALIDARG);
break;
More information about the Gnupg-commits
mailing list