From acc3bba849e191562eb0b2e1b3ef518159362cbe Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 11 Aug 2010 14:56:55 +0300 Subject: modified: main.cpp modified: messages.cpp modified: new_gpg.rc modified: resource.h --- main.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 7adec85..eeefe97 100644 --- a/main.cpp +++ b/main.cpp @@ -26,7 +26,7 @@ void test() TCHAR cmd[512]; _tcscpy(cmd, _T("--list-secret-keys")); pxExecute(cmd, "", &out, &code); - MessageBoxA(0, out.c_str(), "test", MB_OK); +// MessageBoxA(0, out.c_str(), "test", MB_OK); } @@ -34,11 +34,106 @@ HWND hwndFirstRun = NULL; static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) { + HWND hwndList=GetDlgItem(hwndDlg, IDC_KEY_LIST); + LVCOLUMN col = {0}; + LVITEM item = {0}; + NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); + col.pszText = _T("Fingerprint"); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.fmt = LVCFMT_LEFT; + col.cx = 50; + ListView_InsertColumn(hwndList, 0, &col); + ZeroMemory(&col,sizeof(col)); + col.pszText = _T("Email"); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.fmt = LVCFMT_LEFT; + col.cx = 30; + ListView_InsertColumn(hwndList, 1, &col); + ZeroMemory(&col,sizeof(col)); + col.pszText = _T("Name"); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.fmt = LVCFMT_LEFT; + col.cx = 250; + ListView_InsertColumn(hwndList, 2, &col); + ZeroMemory(&col,sizeof(col)); + col.pszText = _T("Creation date"); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.fmt = LVCFMT_LEFT; + col.cx = 30; + ListView_InsertColumn(hwndList, 3, &col); + ZeroMemory(&col,sizeof(col)); + col.pszText = _T("Key length"); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.fmt = LVCFMT_LEFT; + col.cx = 30; + ListView_InsertColumn(hwndList, 4, &col); + ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_FULLROWSELECT); + int i = 1, iRow = 0; + { //parse gpg output + item.mask = LVIF_TEXT; + item.iItem = i; + item.iSubItem = 0; + item.pszText = _T(""); + { + string out; + DWORD code; +// iRow = ListView_InsertItem(hwndList, &item); + string::size_type p = 0, p2 = 0, stop = 0; + { + TCHAR cmd[512]; + _tcscpy(cmd, _T("--list-secret-keys")); + pxExecute(cmd, "", &out, &code); + } + while(p != string::npos) + { + if((p = out.find("sec ", p) + 5) == string::npos) + break; + if(p < stop) + break; + stop = p; + p2 = out.find("/", p) - 1; + TCHAR *tmp = mir_a2t(out.substr(p,p2-p).c_str()); + item.pszText = tmp; + iRow = ListView_InsertItem(hwndList, &item); + ListView_SetItemText(hwndList, iRow, 4, tmp); + mir_free(tmp); + p2+=2; + p = out.find(" ", p2); + tmp = mir_a2t(out.substr(p2,p-p2).c_str()); + ListView_SetItemText(hwndList, iRow, 0, tmp); + mir_free(tmp); + p = out.find("uid ", p); + p2 = out.find_first_not_of(" ", p+5); + p = out.find(" ", p2); + tmp = mir_a2t(out.substr(p2,p-p2).c_str()); + ListView_SetItemText(hwndList, iRow, 2, tmp); + mir_free(tmp); + p = out.find("<", p) + 1; + p2 = out.find(">", p); + tmp = mir_a2t(out.substr(p,p2-p).c_str()); + ListView_SetItemText(hwndList, iRow, 1, tmp); + mir_free(tmp); + p = out.find("ssb ", p2) + 6; + p = out.find(" ", p) + 1; + p2 = out.find("\n", p); + tmp = mir_a2t(out.substr(p,p2-p-1).c_str()); + ListView_SetItemText(hwndList, iRow, 3, tmp); + mir_free(tmp); + i++; + } + } + ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);// not sure about this + ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); + ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE); + ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); + ListView_SetColumnWidth(hwndList, 4, LVSCW_AUTOSIZE); + } + return TRUE; } -- cgit v1.2.3