summaryrefslogtreecommitdiff
path: root/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'options.cpp')
-rw-r--r--options.cpp68
1 files changed, 65 insertions, 3 deletions
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);
+}