#include <aclapi.h>
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
#include "ssh.h"
#include "tree234.h"
#define IDM_CLOSE 0x0010
#define IDM_VIEWKEYS 0x0020
-#define IDM_ABOUT 0x0030
+#define IDM_ADDKEY 0x0030
+#define IDM_ABOUT 0x0040
#define APPNAME "Pageant"
switch (msg) {
case WM_INITDIALOG:
+ SetForegroundWindow(hwnd);
+ SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
p = (struct PassphraseProcStruct *)lParam;
passphrase = p->passphrase;
if (p->comment)
}
} else
*passphrase = '\0';
- ret = loadrsakey(filename, key, passphrase);
+ ret = loadrsakey(filename, key, NULL, passphrase);
attempts++;
} while (ret == -1);
if (comment) free(comment);
}
/*
+ * Prompt for a key file to add, and add it.
+ */
+static void prompt_add_keyfile(void) {
+ OPENFILENAME of;
+ char filename[FILENAME_MAX];
+ memset(&of, 0, sizeof(of));
+#ifdef OPENFILENAME_SIZE_VERSION_400
+ of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+#else
+ of.lStructSize = sizeof(of);
+#endif
+ of.hwndOwner = hwnd;
+ of.lpstrFilter = "All Files\0*\0\0\0";
+ of.lpstrCustomFilter = NULL;
+ of.nFilterIndex = 1;
+ of.lpstrFile = filename; *filename = '\0';
+ of.nMaxFile = sizeof(filename);
+ of.lpstrFileTitle = NULL;
+ of.lpstrInitialDir = NULL;
+ of.lpstrTitle = "Select Private Key File";
+ of.Flags = 0;
+ if (GetOpenFileName(&of)) {
+ add_keyfile(filename);
+ keylist_update();
+ }
+}
+
+/*
* Dialog-box function for the key list box.
*/
static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
enum234 e;
struct RSAKey *key;
- OPENFILENAME of;
- char filename[FILENAME_MAX];
switch (msg) {
case WM_INITDIALOG:
case 101: /* add key */
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
- memset(&of, 0, sizeof(of));
-#ifdef OPENFILENAME_SIZE_VERSION_400
- of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
-#else
- of.lStructSize = sizeof(of);
-#endif
- of.hwndOwner = hwnd;
- of.lpstrFilter = "All Files\0*\0\0\0";
- of.lpstrCustomFilter = NULL;
- of.nFilterIndex = 1;
- of.lpstrFile = filename; *filename = '\0';
- of.nMaxFile = sizeof(filename);
- of.lpstrFileTitle = NULL;
- of.lpstrInitialDir = NULL;
- of.lpstrTitle = "Select Private Key File";
- of.Flags = 0;
- if (GetOpenFileName(&of)) {
- add_keyfile(filename);
- keylist_update();
- }
+ prompt_add_keyfile();
}
return 0;
case 102: /* remove key */
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
+ case IDM_ADDKEY:
+ prompt_add_keyfile();
+ break;
case IDM_ABOUT:
if (!aboutbox) {
aboutbox = CreateDialog (instance, MAKEINTRESOURCE(213),
DestroyIcon(hicon);
systray_menu = CreatePopupMenu();
- /* accelerators used: vxa */
+ /* accelerators used: vkxa */
AppendMenu (systray_menu, MF_ENABLED, IDM_VIEWKEYS, "&View Keys");
+ AppendMenu (systray_menu, MF_ENABLED, IDM_ADDKEY, "Add &Key");
AppendMenu (systray_menu, MF_ENABLED, IDM_ABOUT, "&About");
AppendMenu (systray_menu, MF_ENABLED, IDM_CLOSE, "E&xit");
}