📄 readmsgwndproc.c
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: ReadMsgWndProc.c,v 1.13 2002/10/03 04:18:05 sdas Exp $
____________________________________________________________________________*/
#include <windows.h>
#include <commctrl.h>
#include <process.h>
#include "PluginInfo.h"
#include "HookProcs.h"
#include "UIutils.h"
#include "TextIO.h"
#include "Prefs.h"
#include "resource.h"
#include "pgpErrors.h"
#include "DecryptVerify.h"
#include "PGPsc.h"
#include "pgpdebug.h"
static BOOL DecryptVerifyMessage(HWND hwnd, PluginInfo *plugin);
static void EnableMenus(HWND hwnd, PluginInfo *plugin, BOOL bEnable);
extern int LoadAppropriateBitmaps(PluginInfo *plugin, UINT uiCommandId);
void RemoveReadToolbarButtons(PluginInfo *lppilPlugInf);
LRESULT CALLBACK ReadMsgWndProc(HWND hDlg,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
WNDPROC lpOldProc;
PluginInfo *plugin;
lpOldProc = (WNDPROC)GetProp( hDlg, "oldproc" );
plugin = GetPluginInfo(hDlg);
if (plugin != NULL)
{
if (msg == plugin->nCopyDoneMsg)
{
if (wParam)
{
if (!DecryptVerifyMessage(hDlg, plugin))
{
SetWindowLong(hDlg, GWL_STYLE, plugin->nWindowStyle);
RedrawWindow(hDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
}
}
else
{
SetWindowLong(hDlg, GWL_STYLE, plugin->nWindowStyle);
RedrawWindow(hDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
}
SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
RestoreClipboardText(hDlg);
return 0;
}
if (msg == plugin->nPasteDoneMsg)
{
SetWindowLong(hDlg, GWL_STYLE, plugin->nWindowStyle);
RedrawWindow(hDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
return 0;
}
}
switch(msg)
{
case WM_SIZE:
{
if (plugin->hEdit)
if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED))
PostMessage(hDlg, WM_EXITSIZEMOVE, 0, 0);
break;
}
case WM_SIZING:
case WM_EXITSIZEMOVE:
{
if (plugin->hEdit)
{
RECT rc;
GetClientRect(plugin->hMessage, &rc);
SetWindowPos(plugin->hEdit, HWND_TOP,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
SWP_SHOWWINDOW);
}
break;
}
case WM_TIMER:
if (wParam == AUTO_DECRYPT_TIMER)
{
KillTimer(hDlg, AUTO_DECRYPT_TIMER);
PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_DECRYPT, 0), 0);
return 0;
}
break;
case WM_MENUSELECT:
{
UINT uFlags = (UINT) HIWORD(wParam);
char szText[255];
BOOL bPluginMenu = FALSE;
switch(LOWORD(wParam))
{
case IDC_DECRYPT:
{
UIGetString(szText, 254, IDS_STATUS_DECRYPT);
bPluginMenu = TRUE;
break;
}
case IDC_PGPKEYS:
UIGetString(szText, 254, IDS_TOOLTIP_PGPKEYS);
bPluginMenu = TRUE;
break;
}
if (bPluginMenu)
{
CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam);
SendMessage(plugin->hStatusBar, SB_SETTEXT,
255 | SBT_NOBORDERS, (LPARAM) szText);
return 0;
}
break;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_DECRYPT:
{
if (SaveClipboardText(hDlg))
{
LONG nStyleMask = ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
plugin->nWindowStyle = GetWindowLong(hDlg, GWL_STYLE);
SetWindowLong(hDlg, GWL_STYLE, plugin->nWindowStyle & nStyleMask);
RedrawWindow(hDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
_beginthread(DoCopyThread, 0, hDlg);
}
return 0;
}
case IDC_OE5_PRINT:
{
if (plugin->bDisableMenus)
{
UIDisplayStringID(hDlg, IDS_E_CANTPRINT);
return 0;
}
break;
}
case IDC_REPLY:
case IDC_REPLYTOALL:
case IDC_REPLYTOGROUP:
case IDC_REPLYTOAUTHOR:
case IDC_REPLYTOGROUPANDAUTHOR:
case IDC_FORWARD:
case IDC_OE5_REPLY:
case IDC_OE5_REPLYTOALL:
case IDC_OE5_REPLYTOGROUP:
case IDC_OE5_FORWARD:
{
if (plugin->szOutput != NULL)
{
char *szText=NULL;
szText = (char *)calloc(strlen(plugin->szOutput)+1, 1);
if(NULL != szText)
{
strcpy(szText, plugin->szOutput);
free(plugin->szOutput);
plugin->szOutput = NULL;
}
SetReplyText(szText);//NOTE:szText can be NULL. this will free up the previous buffer
//and will not have a new buffer to work on
}
break;
}
case IDC_NEXT:
case IDC_PREVIOUS:
case IDC_NEXTUNREADARTICLE:
case IDC_NEXTUNREADTHREAD:
case IDC_NEXTUNREADMESSAGE:
case IDC_OE5_NEXT:
case IDC_OE5_PREVIOUS:
case IDC_OE5_NEXTUNREADTHREAD:
case IDC_OE5_NEXTUNREADMESSAGE:
{
if (plugin->szOutput != NULL)
{
free(plugin->szOutput);
plugin->szOutput = NULL;
DestroyWindow(plugin->hEdit);
ShowWindow(plugin->hMessage, SW_SHOW);
EnableMenus(hDlg, plugin, TRUE);
}
if (AutoDecrypt(plugin->memoryMgr))
SetTimer(hDlg, AUTO_DECRYPT_TIMER, AUTO_DECRYPT_TIMER_LENGTH, 0);
break;
}
}
break;
}
case WM_INITMENUPOPUP:
if (plugin->bOE5)
{
int nAddrBook;
MENUITEMINFO menuInfo;
char szAddrBook[256];
char szClose[256];
char szStatusBar[256];
char szMenu[256];
LRESULT lResult;
UIGetString(szAddrBook, 254, IDS_MENU_OEADDADDRBOOK);
UIGetString(szClose, 254, IDS_MENU_OECLOSE);
UIGetString(szStatusBar, 254, IDS_MENU_OESTATUSBAR);
nAddrBook = GetMenuItemCount((HMENU) wParam);
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_TYPE;
menuInfo.dwTypeData = szMenu;
menuInfo.cch = 255;
GetMenuItemInfo((HMENU) wParam, nAddrBook - 1, TRUE, &menuInfo);
if (strstr(szMenu, szAddrBook))
{
lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam,
lParam);
UIGetString(szMenu, 254, IDS_MENU_DECRYPT);
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_TYPE;
menuInfo.fType = MFT_SEPARATOR;
InsertMenuItem((HMENU) wParam, nAddrBook, TRUE, &menuInfo);
menuInfo.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
menuInfo.fType = MFT_STRING;
menuInfo.wID = IDC_DECRYPT;
menuInfo.fState = MFS_ENABLED;
menuInfo.dwTypeData = szMenu;
InsertMenuItem((HMENU) wParam, nAddrBook+1, TRUE, &menuInfo);
strcpy(szMenu, "&PGP");
menuInfo.fMask = MIIM_TYPE | MIIM_ID | MIIM_SUBMENU |
MIIM_STATE;
menuInfo.fType = MFT_STRING;
menuInfo.wID = IDC_PGPMENU;
menuInfo.fState = MFS_ENABLED;
menuInfo.hSubMenu = plugin->hPGPMenu;
menuInfo.dwTypeData = szMenu;
InsertMenuItem((HMENU) wParam, nAddrBook+2, TRUE, &menuInfo);
plugin->nPGPPosition = nAddrBook + 2;
return lResult;
}
else if (!strcmp(szMenu, "&PGP"))
{
lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam,
lParam);
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
menuInfo.fState = MFS_ENABLED;
SetMenuItemInfo((HMENU) wParam, IDC_DECRYPT, FALSE,
&menuInfo);
SetMenuItemInfo((HMENU) wParam, IDC_PGPMENU, FALSE,
&menuInfo);
SetMenuItemInfo(plugin->hPGPMenu, IDC_PREFS, FALSE,
&menuInfo);
SetMenuItemInfo(plugin->hPGPMenu, IDC_PGPKEYS, FALSE,
&menuInfo);
return lResult;
}
else if (strstr(szMenu, szClose))
{
UINT uFlags = MF_BYPOSITION;
lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam,
lParam);
if (plugin->bDisableMenus)
uFlags |= MF_GRAYED;
else
uFlags |= MF_ENABLED;
EnableMenuItem((HMENU) wParam, OE5_FILESAVEAS_MENU_POS,
uFlags);
EnableMenuItem((HMENU) wParam, OE5_FILESTATIONERY_MENU_POS,
uFlags);
EnableMenuItem((HMENU) wParam, OE5_FILEMOVE_MENU_POS,
uFlags);
EnableMenuItem((HMENU) wParam, OE5_FILECOPY_MENU_POS,
uFlags);
EnableMenuItem((HMENU) wParam, OE5_FILEPRINT_MENU_POS,
uFlags);
return lResult;
}
else if (strstr(szMenu, szStatusBar))
{
UINT uFlags = MF_BYPOSITION;
lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam,
lParam);
if (plugin->bDisableMenus)
uFlags |= MF_GRAYED;
else
uFlags |= MF_ENABLED;
EnableMenuItem((HMENU) wParam, OE5_VIEWTEXTSIZE_MENU_POS,
uFlags);
EnableMenuItem((HMENU) wParam, OE5_VIEWENCODING_MENU_POS,
uFlags);
return lResult;
}
}
break;
case WM_NOTIFY:
if ((((LPNMHDR) lParam)->code) == TTN_GETDISPINFO)
{
int idCtrl;
NMTTDISPINFO *pInfo;
BOOL bTooltip = FALSE;
idCtrl = ((LPNMHDR) lParam)->idFrom;
pInfo = (NMTTDISPINFO *) lParam;
switch (idCtrl)
{
case IDC_ENCRYPT_SMIME:
pInfo->lpszText = (LPTSTR) IDS_TOOLTIP_SMIME_ENCRYPT;
bTooltip = TRUE;
break;
case IDC_SIGN_SMIME:
pInfo->lpszText = (LPTSTR) IDS_TOOLTIP_SMIME_SIGN;
bTooltip = TRUE;
break;
case IDC_DECRYPT:
pInfo->lpszText = (LPTSTR) IDS_TOOLTIP_DECRYPT;
bTooltip = TRUE;
break;
case IDC_PGPKEYS:
pInfo->lpszText = (LPTSTR) IDS_TOOLTIP_PGPKEYS;
bTooltip = TRUE;
break;
}
if (bTooltip)
{
pInfo->hinst = UIGetInstance();
return 0;
}
}
break;
}
return CommonWndProc(hDlg, msg, wParam, lParam);
}
BOOL DecryptVerifyMessage(HWND hwnd, PluginInfo *plugin)
{
HWND hDocHost;
HWND hMimeEdit;
HWND hMessage;
HWND hAttach;
HWND hNoteHdr;
HWND hTo;
HFONT hFont;
char *szInput;
char *szOutput;
DWORD dwLength;
PGPSize nOutLength;
RECT rc;
char szExe[256];
char szDll[256];
PGPError nError = kPGPError_NoErr;
BOOL FYEO;
BOOL bSuccess = FALSE;
UIGetString(szExe, sizeof(szExe), IDS_EXE);
UIGetString(szDll, sizeof(szDll), IDS_DLL);
if (plugin->bOE5)
{
hDocHost = FindWindowEx(hwnd, NULL, "ME_DocHost", NULL);
hMimeEdit = FindWindowEx(hDocHost, NULL, "##MimeEdit_Server", NULL);
hMessage = FindWindowEx(hMimeEdit, NULL, "Internet Explorer_Server",
NULL);
}
else
{
hDocHost = FindWindowEx(hwnd, NULL, "Ath_DocHost", NULL);
hMessage = FindWindowEx(hDocHost, NULL, "Internet Explorer_Server",
NULL);
}
plugin->hMessage = hMessage;
hAttach = FindWindowEx(hwnd, NULL, "SysListView32", NULL);
if (plugin->szOutput == NULL)
{
if (!GetMessageText(hwnd, FALSE, &szInput))
return FALSE;
dwLength = strlen(szInput);
}
else
{
dwLength = GetWindowTextLength(plugin->hEdit);
szInput = (char *) calloc(dwLength+1, 1);
GetWindowText(plugin->hEdit, szInput, dwLength+1);
}
FixBadSpaces(szInput);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -