x11-ssh-askpass.h revision 8db30ca8
1/* x11-ssh-askpass.h: A generic X11-based password dialog for OpenSSH. 2 * created 1999-Nov-17 03:40 Jim Knoble <jmknoble@pobox.com> 3 * autodate: 1999-Nov-23 01:45 4 * 5 * by Jim Knoble <jmknoble@pobox.com> 6 * Copyright � 1999 Jim Knoble 7 * 8 * Disclaimer: 9 * 10 * The software is provided "as is", without warranty of any kind, 11 * express or implied, including but not limited to the warranties of 12 * merchantability, fitness for a particular purpose and 13 * noninfringement. In no event shall the author(s) be liable for any 14 * claim, damages or other liability, whether in an action of 15 * contract, tort or otherwise, arising from, out of or in connection 16 * with the software or the use or other dealings in the software. 17 * 18 * Portions of this code are distantly derived from code in xscreensaver 19 * by Jamie Zawinski <jwz@jwz.org>. That code says: 20 * 21 * --------8<------------------------------------------------8<-------- 22 * xscreensaver, Copyright (c) 1991-1999 Jamie Zawinski <jwz@jwz.org> 23 * 24 * Permission to use, copy, modify, distribute, and sell this software and its 25 * documentation for any purpose is hereby granted without fee, provided that 26 * the above copyright notice appear in all copies and that both that 27 * copyright notice and this permission notice appear in supporting 28 * documentation. No representations are made about the suitability of this 29 * software for any purpose. It is provided "as is" without express or 30 * implied warranty. 31 * --------8<------------------------------------------------8<-------- 32 * 33 * The remainder of this code falls under the same permissions and 34 * provisions as those of the xscreensaver code. 35 */ 36 37#ifndef H_X11_SSH_ASKPASS 38#define H_X11_SSH_ASKPASS 39 40#include <X11/Xlib.h> 41#include <X11/Intrinsic.h> 42#include <X11/Shell.h> 43 44#define EXIT_STATUS_ACCEPT 0 45#define EXIT_STATUS_CANCEL 1 46#define EXIT_STATUS_NO_MEMORY 2 47#define EXIT_STATUS_ERROR 3 48#define EXIT_STATUS_ANOMALY 127 49 50typedef struct 51{ 52 Pixel foreground; 53 Pixel background; 54 Dimension width; 55 Dimension height; 56 Position x; 57 Position y; 58} WidgetInfo; 59 60typedef struct 61{ 62 WidgetInfo w; 63 Pixel topShadowColor; 64 Pixel bottomShadowColor; 65 Dimension shadowThickness; 66 Pixel borderColor; 67 Dimension borderWidth; 68 Dimension interiorWidth; 69 Dimension interiorHeight; 70 Dimension horizontalSpacing; 71 Dimension verticalSpacing; 72} Widget3dInfo; 73 74typedef struct 75{ 76 char *text; 77 XFontStruct *font; 78 int textLength; 79 int direction; 80 int ascent; 81 int descent; 82 XCharStruct overall; 83 WidgetInfo w; 84} LabelInfo; 85 86typedef struct 87{ 88 Widget3dInfo w3; 89 LabelInfo label; 90 Bool pressed; 91} ButtonInfo; 92 93typedef struct 94{ 95 Widget3dInfo w3; 96 int count; 97 int current; 98 int minimumCount; 99 int maximumCount; 100} MasterIndicatorInfo; 101 102typedef struct 103{ 104 MasterIndicatorInfo *parent; 105 WidgetInfo w; 106 Bool isLit; 107} IndicatorElement; 108 109typedef struct 110{ 111 Window dialogWindow; 112 113 XSizeHints *sizeHints; 114 XWMHints *wmHints; 115 XClassHint *classHints; 116 XTextProperty windowName; 117 118 char *title; 119 Widget3dInfo w3; 120 121 LabelInfo label; 122 123 MasterIndicatorInfo indicator; 124 IndicatorElement *indicators; 125 126 ButtonInfo okButton; 127 ButtonInfo cancelButton; 128 129 int pressedButton; 130} DialogInfo; 131 132#define NO_BUTTON 0 133#define OK_BUTTON 1 134#define CANCEL_BUTTON 2 135 136typedef struct 137{ 138 char *appName; 139 char *appClass; 140 141 int argc; 142 char **argv; 143 144 char *buf; 145 int bufSize; 146 int bufIndex; 147 148 Display *dpy; 149 Screen *screen; 150 Window rootWindow; 151 Pixel black; 152 Pixel white; 153 Colormap colormap; 154 155 XtAppContext appContext; 156 Widget toplevelShell; 157 XrmDatabase resourceDb; 158 159 Atom wmDeleteWindowAtom; 160 161 GC fillGC; 162 GC borderGC; 163 GC textGC; 164 GC brightGC; 165 GC dimGC; 166 167 Bool grabKeyboard; 168 Bool grabPointer; 169 Bool grabServer; 170 Bool isKeyboardGrabbed; 171 Bool isPointerGrabbed; 172 Bool isServerGrabbed; 173 174 DialogInfo *dialog; 175} AppInfo; 176 177void outOfMemory(AppInfo *app, int line); 178void freeIf(void *p); 179void freeFontIf(AppInfo *app, XFontStruct *f); 180 181XFontStruct *getFontResource(AppInfo *app, char *instanceName, char *className); 182char *getStringResourceWithDefault(char *instanceName, char *className, 183 char *defaultText); 184 185void calcLabelTextExtents(LabelInfo *label); 186void calcTotalButtonExtents(ButtonInfo *button); 187void calcButtonExtents(ButtonInfo *button); 188void balanceButtonExtents(ButtonInfo *button1, ButtonInfo *button2); 189void calcButtonLabelPosition(ButtonInfo *button); 190 191void createDialog(AppInfo *app); 192void destroyDialog(AppInfo *app); 193void createDialogWindow(AppInfo *app); 194void createGCs(AppInfo *app); 195void destroyGCs(AppInfo *app); 196 197void paintLabel(AppInfo *app, Drawable draw, LabelInfo label); 198void paintButton(AppInfo *app, Drawable draw, ButtonInfo button); 199void paintIndicator(AppInfo *app, Drawable draw, IndicatorElement indicator); 200void updateIndicatorElement(AppInfo *app, int i); 201void updateIndicators(AppInfo *app, int condition); 202void paintDialog(AppInfo *app); 203 204void grabKeyboard(AppInfo *app); 205void ungrabKeyboard(AppInfo *app); 206void grabPointer(AppInfo *app); 207void ungrabPointer(AppInfo *app); 208void grabServer(AppInfo *app); 209void ungrabServer(AppInfo *app); 210 211void cleanUp(AppInfo *app); 212void exitApp(AppInfo *app, int exitCode); 213 214void acceptAction(AppInfo *app); 215void cancelAction(AppInfo *app); 216 217void backspacePassphrase(AppInfo *app); 218void erasePassphrase(AppInfo *app); 219void addToPassphrase(AppInfo *app, char c); 220 221void handleKeyPress(AppInfo *app, XKeyEvent *event); 222Bool eventIsInsideButton(AppInfo *app, XButtonEvent *event, ButtonInfo button); 223void handleButtonPress(AppInfo *app, XButtonEvent *event); 224 225#endif /* H_X11_SSH_ASKPASS */ 226