diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-07 22:54:11 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-07 22:54:11 +0300 |
commit | ab8714c350485b27303b6a8f711f6cbed92efad8 (patch) | |
tree | 7b2762e7b6f7f3b64107afb149df27a7cfa247b0 | |
parent | dfe1e876c6d8ad77a66ae242482e8cc2b6be48c3 (diff) |
modified: new_gpg.rc
modified: options.cpp
modified: resource.h
-rw-r--r-- | new_gpg.rc | 36 | ||||
-rw-r--r-- | options.cpp | 68 | ||||
-rw-r--r-- | resource.h | 10 |
3 files changed, 108 insertions, 6 deletions
@@ -46,6 +46,41 @@ END #endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_LOAD_PUBLIC_KEY DIALOGEX 0, 0, 279, 84
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Load Public GPG key"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "ОК",ID_OK,7,63,50,14
+ PUSHBUTTON "Load from file",ID_LOD_FROM_FILE,208,63,54,14
+ EDITTEXT IDC_EDIT1,7,7,255,51,ES_AUTOHSCROLL
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_LOAD_PUBLIC_KEY, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 272
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 77
+ END
+END
+#endif // APSTUDIO_INVOKED
+
#endif // русский resources
/////////////////////////////////////////////////////////////////////////////
@@ -70,6 +105,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN
CONTROL "",IDC_USERLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,17,254,112
CTEXT "Userlist:",IDC_STATIC,25,7,201,8
+ PUSHBUTTON "Load PubKey",IDC_LOAD_KEY_BUTTON,7,135,54,14
END
IDD_OPT_GPG_BIN DIALOGEX 0, 0, 268, 214
diff --git a/options.cpp b/options.cpp index d39cdcb..dcadd7d 100644 --- a/options.cpp +++ b/options.cpp @@ -16,6 +16,7 @@ #include "commonheaders.h" #include <uxtheme.h> +#include <map> extern HINSTANCE hInst; @@ -50,7 +51,12 @@ int GpgOptInit(WPARAM wParam,LPARAM lParam) return 0; } +static HWND hwndLoadPublicKey = NULL; +HWND hCaller; +std::map<int, HANDLE> user_data; + +void ShowLoadPublicKeyDialog(HWND hwndCaller); static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList=GetDlgItem(hwndDlg, IDC_USERLIST); @@ -96,6 +102,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ListView_SetItemText(hwndList, iRow, 2, UniGetContactSettingUtf(hContact, szModuleName, "GPGPubKey", _T("not set"))); if(DBGetContactSettingByte(hContact, szModuleName, "GPGEncryption", 0)) ListView_SetItemState(hwndList, iRow, 0x2000, 0xF000); + user_data[i] = hContact; ZeroMemory(&item,sizeof(item)); i++; } @@ -110,8 +117,9 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { switch (LOWORD(wParam)) { - case IDC_USERLIST: - break; + case IDC_LOAD_KEY_BUTTON: + ShowLoadPublicKeyDialog(hwndDlg); + return TRUE; default: break; } @@ -124,7 +132,12 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { if(hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1)) { - int iIndex = hdr->iItem; + int i = hdr->iItem; + HANDLE hContact = user_data[i+1]; + if(ListView_GetItemState(hwndList, i, 0xF000) == 0x2000) + DBWriteContactSettingByte(hContact, szModuleName, "GPGEncryption", 1); + else + DBWriteContactSettingByte(hContact, szModuleName, "GPGEncryption", 0); } switch (((LPNMHDR)lParam)->code) { @@ -197,3 +210,52 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP return FALSE; } +static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + return TRUE; + } + + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + default: + break; + } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) + { + + case PSN_APPLY: + { + return TRUE; + } + } + } + break; + } + + return FALSE; +} + +void ShowLoadPublicKeyDialog(HWND hwndCaller) +{ + hCaller = hwndCaller; + if (hwndLoadPublicKey == NULL) + { + hwndLoadPublicKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOAD_PUBLIC_KEY), NULL, DlgProcLoadPublicKey); + } + SetForegroundWindow(hwndLoadPublicKey); +} @@ -2,6 +2,7 @@ // Microsoft Visual C++ generated include file.
// Used by new_gpg.rc
//
+#define IDD_LOAD_PUBLIC_KEY 102
#define IDD_OPT_GPG 104
#define IDD_OPT_GPG_BIN 105
#define IDC_SET_BIN_PATH 1016
@@ -9,15 +10,18 @@ #define IDC_BIN_PATH 1018
#define IDC_HOME_DIR 1019
#define IDC_USERLIST 1020
-#define IDC_LIST1 1021
+#define IDC_LOAD_KEY_BUTTON 1022
+#define ID_OK 1023
+#define ID_LOD_FROM_FILE 1024
+#define IDC_EDIT1 1025
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1022
+#define _APS_NEXT_CONTROL_VALUE 1026
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|