summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/GPGw/userdialog.cpp
blob: 0227a5d549cad3ccf126d8a309ead5da5d71096d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "../commonheaders.h"
#include "gpgw.h"

void RefreshListView(HWND hLV);

INT_PTR CALLBACK UserIdDialogProcedure(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
  static char *keyid;
  HWND hLV = GetDlgItem(hdlg,IDC_KEYLIST);

  switch(msg)
  {
    case WM_INITDIALOG:
    {
	  int i;
   	  LVCOLUMN lvc;
	  static char *szColHdr[] = { "Key ID", "User ID" };
   	  static int iColWidth[] = { 110, 255 };
   	  keyid = (char *)lparam;

   	  ZeroMemory(&lvc,sizeof(LVCOLUMN));
   	  lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
   	  lvc.fmt = LVCFMT_LEFT;
   	  for (i = 0; i < 2; i++) {
   		  lvc.iSubItem = i;
   		  lvc.pszText = szColHdr[i];
   		  lvc.cx = iColWidth[i];
   		  ListView_InsertColumn(hLV, i, &lvc);
   	  }

   	  RefreshListView(hLV);

	  ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
      ListView_SetItemState(hLV, 0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
	  EnableWindow(hLV, TRUE);
	}
    break;
    case WM_COMMAND:
      switch(LOWORD(wparam))
      {
	  case IDOK:
		  ListView_GetItemText(hLV, ListView_GetNextItem(hLV, -1, LVNI_SELECTED), 0, keyid, keyidsize);
	  case IDCANCEL:
          EndDialog(hdlg, wparam);
          return TRUE;
          break;
      case IDC_REFRESH:
		  updateKeyUserIDs(publickeyuserid);
		  updateKeyUserIDs(secretkeyuserid);
		  RefreshListView(hLV);
		  break;
      }
      break;
  }

  return FALSE;
}


void RefreshListView(HWND hLV) {

      LVITEM lvi;
	  int i;

	  ListView_DeleteAllItems(hLV);
   	  ZeroMemory(&lvi,sizeof(LVITEM));
      lvi.mask = LVIF_TEXT;
      for (i = 0; i < getKeyUserIDCount(publickeyuserid); i++) {

			char keyid[keyidsize];
			char *userid;
    		char *keyuserid = getKeyUserID(publickeyuserid, i);

		    userid = getNextPart(keyid, keyuserid, txtidseparator);

    		lvi.iItem++;
      		lvi.pszText = keyid;
      		ListView_SetItemText(hLV, ListView_InsertItem(hLV, &lvi), 1, userid);
      }
}