Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | // |
| 19 | // OptionsDialog.h |
| 20 | // |
| 21 | |
| 22 | #ifndef __OPTIONSDIALOG_H__ |
| 23 | #define __OPTIONSDIALOG_H__ |
| 24 | |
| 25 | #include "TXDialog.h" |
| 26 | #include "TXLabel.h" |
| 27 | #include "TXEntry.h" |
| 28 | #include "TXButton.h" |
| 29 | #include "TXCheckbox.h" |
| 30 | #include "parameters.h" |
| 31 | |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 32 | #define SECOND_COL_XPAD 350 |
| 33 | |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 34 | class OptionsDialogCallback { |
| 35 | public: |
| 36 | virtual void setOptions() = 0; |
| 37 | virtual void getOptions() = 0; |
| 38 | }; |
| 39 | |
| 40 | class OptionsDialog : public TXDialog, public TXButtonCallback, |
| 41 | public TXCheckboxCallback, public TXEntryCallback { |
| 42 | public: |
| 43 | OptionsDialog(Display* dpy, OptionsDialogCallback* cb_) |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 44 | : TXDialog(dpy, 450, 450, _("VNC Viewer: Connection Options")), cb(cb_), |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 45 | |
| 46 | /* Encoding and color level */ |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 47 | formatAndEnc(dpy, _("Encoding and Color Level:"), this), |
| 48 | inputs(dpy, _("Inputs:"), this), |
| 49 | misc(dpy, _("Misc:"), this), |
| 50 | autoSelect(dpy, _("Auto select"), this, false, this), |
| 51 | fullColour(dpy, _("Full (all available colors)"), this, true, this), |
| 52 | mediumColour(dpy, _("Medium (256 colors)"), this, true, this), |
| 53 | lowColour(dpy, _("Low (64 colors)"), this, true, this), |
| 54 | veryLowColour(dpy, _("Very low (8 colors)"), this, true, this), |
| 55 | tight(dpy, "Tight", this, true, this), |
| 56 | zrle(dpy, "ZRLE", this, true, this), |
| 57 | hextile(dpy, "Hextile", this, true, this), |
| 58 | raw(dpy, "Raw", this, true, this), |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 59 | |
| 60 | /* Compression */ |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 61 | customCompressLevel(dpy, _("Custom compression level:"), this, false, this), |
| 62 | compressLevel(dpy, this, this, false, 30), |
| 63 | compressLevelLabel(dpy, _("level (1=fast, 9=best)"), this), |
| 64 | noJpeg(dpy, _("Allow JPEG compression:"), this, false, this), |
| 65 | qualityLevel(dpy, this, this, false, 30), |
| 66 | qualityLevelLabel(dpy, _("quality (1=poor, 9=best)"), this), |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 67 | |
| 68 | /* Inputs */ |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 69 | viewOnly(dpy, _("View only (ignore mouse & keyboard)"), this, false, this), |
| 70 | acceptClipboard(dpy, _("Accept clipboard from server"), this, false, this), |
| 71 | sendClipboard(dpy, _("Send clipboard to server"), this, false, this), |
| 72 | sendPrimary(dpy, _("Send primary selection & cut buffer as clipboard"), |
| 73 | this, false, this), |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 74 | |
| 75 | /* Misc */ |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 76 | shared(dpy, _("Shared (don't disconnect other viewers)"), this, false,this), |
| 77 | fullScreen(dpy, _("Full-screen mode"), this, false, this), |
| 78 | useLocalCursor(dpy, _("Render cursor locally"), this, false, this), |
| 79 | dotWhenNoCursor(dpy, _("Show dot when no cursor"), this, false, this), |
| 80 | okButton(dpy, _("OK"), this, this, 60), |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 81 | cancelButton(dpy, _("Cancel"), this, this, 60) |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 82 | |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 83 | #ifdef HAVE_GNUTLS |
| 84 | , |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 85 | /* Security */ |
| 86 | security(dpy, _("Security:"), this), |
| 87 | secVeNCrypt(dpy, _("Extended encryption and authentication methods (VeNCrypt)"), |
| 88 | this, false, this), |
| 89 | |
| 90 | /* Encryption */ |
| 91 | encryption(dpy, _("Session encryption:"), this), |
| 92 | encNone(dpy, _("None"), this, false, this), |
| 93 | encTLS(dpy, _("TLS with anonymous certificates"), this, false, this), |
| 94 | encX509(dpy, _("TLS with X509 certificates"), this, false, this), |
| 95 | cacert(dpy, _("Path to X509 CA certificate"), this), |
| 96 | ca(dpy, this, this, false, 350), |
| 97 | crlcert(dpy, _("Path to X509 CRL file"), this), |
| 98 | crl(dpy, this, this, false, 350), |
| 99 | |
| 100 | /* Authentication */ |
| 101 | authentication(dpy, _("Authentication:"), this), |
| 102 | secNone(dpy, _("None"), this, false, this), |
| 103 | secVnc(dpy, _("Standard VNC (insecure without encryption)"), |
| 104 | this, false, this), |
| 105 | secPlain(dpy, _("Username and password (insecure without encryption)"), |
| 106 | this, false, this) |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 107 | #endif |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 108 | { |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 109 | /* Render the first collumn */ |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 110 | int y = yPad; |
| 111 | formatAndEnc.move(xPad, y); |
| 112 | y += formatAndEnc.height(); |
| 113 | autoSelect.move(xPad, y); |
| 114 | int x2 = xPad + autoSelect.width() + xPad*5; |
| 115 | y += autoSelect.height(); |
| 116 | tight.move(xPad, y); |
| 117 | fullColour.move(x2, y); |
| 118 | y += tight.height(); |
| 119 | zrle.move(xPad, y); |
| 120 | mediumColour.move(x2, y); |
| 121 | y += zrle.height(); |
| 122 | hextile.move(xPad, y); |
| 123 | lowColour.move(x2, y); |
| 124 | y += hextile.height(); |
| 125 | raw.move(xPad, y); |
| 126 | veryLowColour.move(x2, y); |
| 127 | y += raw.height() + yPad*2; |
| 128 | |
| 129 | customCompressLevel.move(xPad, y); |
| 130 | y += customCompressLevel.height(); |
| 131 | compressLevel.move(xPad*10, y); |
| 132 | compressLevelLabel.move(xPad*20, y); |
| 133 | y += compressLevel.height(); |
| 134 | |
| 135 | noJpeg.move(xPad, y); |
| 136 | y += noJpeg.height(); |
| 137 | qualityLevel.move(xPad*10, y); |
| 138 | qualityLevelLabel.move(xPad*20, y); |
| 139 | y += qualityLevel.height(); |
| 140 | |
| 141 | y += yPad*4; |
| 142 | inputs.move(xPad, y); |
| 143 | y += inputs.height(); |
| 144 | viewOnly.move(xPad, y); |
| 145 | y += viewOnly.height(); |
| 146 | acceptClipboard.move(xPad, y); |
| 147 | y += acceptClipboard.height(); |
| 148 | sendClipboard.move(xPad, y); |
| 149 | y += sendClipboard.height(); |
| 150 | sendPrimary.move(xPad, y); |
| 151 | y += sendPrimary.height(); |
| 152 | |
| 153 | y += yPad*4; |
| 154 | misc.move(xPad, y); |
| 155 | y += misc.height(); |
| 156 | shared.move(xPad, y); |
| 157 | y += shared.height(); |
| 158 | fullScreen.move(xPad, y); |
| 159 | y += fullScreen.height(); |
| 160 | useLocalCursor.move(xPad, y); |
| 161 | y += useLocalCursor.height(); |
| 162 | dotWhenNoCursor.move(xPad, y); |
| 163 | y += dotWhenNoCursor.height(); |
| 164 | |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 165 | #ifdef HAVE_GNUTLS |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 166 | /* Render the second collumn */ |
| 167 | y = yPad; |
| 168 | xPad += SECOND_COL_XPAD; |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 169 | resize(750, height()); |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 170 | |
| 171 | security.move(xPad, y); |
| 172 | y += security.height(); |
| 173 | secVeNCrypt.move(xPad, y); |
| 174 | y += secVeNCrypt.height(); |
| 175 | |
| 176 | encryption.move(xPad, y); |
| 177 | y += encryption.height(); |
| 178 | encNone.move(xPad, y); |
| 179 | y += encNone.height(); |
| 180 | encTLS.move(xPad, y); |
| 181 | y += encTLS.height(); |
| 182 | encX509.move(xPad, y); |
| 183 | y += encX509.height(); |
| 184 | cacert.move(xPad, y); |
| 185 | y += cacert.height(); |
| 186 | ca.move(xPad, y); |
| 187 | y += ca.height(); |
| 188 | crlcert.move(xPad, y); |
| 189 | y += crlcert.height(); |
| 190 | crl.move(xPad, y); |
| 191 | y += crl.height(); |
| 192 | |
| 193 | authentication.move(xPad, y); |
| 194 | y += authentication.height(); |
| 195 | secNone.move(xPad, y); |
| 196 | y += secNone.height(); |
| 197 | secVnc.move(xPad, y); |
| 198 | y += secVnc.height(); |
| 199 | secPlain.move(xPad, y); |
| 200 | y += secPlain.height(); |
Adam Tkac | 2d4ee58 | 2011-01-07 12:44:43 +0000 | [diff] [blame] | 201 | |
| 202 | xPad -= SECOND_COL_XPAD; |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 203 | #endif |
| 204 | |
| 205 | /* Render "OK" and "Cancel" buttons */ |
| 206 | okButton.move(width() - xPad*12 - cancelButton.width() - okButton.width(), |
| 207 | height() - yPad*4 - okButton.height()); |
| 208 | cancelButton.move(width() - xPad*6 - cancelButton.width(), |
| 209 | height() - yPad*4 - cancelButton.height()); |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 210 | |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 211 | setBorderWidth(1); |
| 212 | } |
| 213 | |
| 214 | virtual void initDialog() { |
| 215 | if (cb) cb->setOptions(); |
| 216 | tight.disabled(autoSelect.checked()); |
| 217 | zrle.disabled(autoSelect.checked()); |
| 218 | hextile.disabled(autoSelect.checked()); |
| 219 | raw.disabled(autoSelect.checked()); |
| 220 | fullColour.disabled(autoSelect.checked()); |
| 221 | mediumColour.disabled(autoSelect.checked()); |
| 222 | lowColour.disabled(autoSelect.checked()); |
| 223 | veryLowColour.disabled(autoSelect.checked()); |
| 224 | sendPrimary.disabled(!sendClipboard.checked()); |
| 225 | dotWhenNoCursor.disabled(!useLocalCursor.checked()); |
| 226 | compressLevel.disabled(!customCompressLevel.checked()); |
Pierre Ossman | 78b2359 | 2009-03-12 12:25:11 +0000 | [diff] [blame] | 227 | qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked()); |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | virtual void takeFocus(Time time) { |
| 231 | //XSetInputFocus(dpy, entry.win, RevertToParent, time); |
| 232 | } |
| 233 | |
| 234 | virtual void buttonActivate(TXButton* b) { |
| 235 | if (b == &okButton) { |
| 236 | if (cb) cb->getOptions(); |
| 237 | unmap(); |
| 238 | } else if (b == &cancelButton) { |
| 239 | unmap(); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | virtual void checkboxSelect(TXCheckbox* checkbox) { |
| 244 | if (checkbox == &autoSelect) { |
| 245 | tight.disabled(autoSelect.checked()); |
| 246 | zrle.disabled(autoSelect.checked()); |
| 247 | hextile.disabled(autoSelect.checked()); |
| 248 | raw.disabled(autoSelect.checked()); |
| 249 | fullColour.disabled(autoSelect.checked()); |
| 250 | mediumColour.disabled(autoSelect.checked()); |
| 251 | lowColour.disabled(autoSelect.checked()); |
| 252 | veryLowColour.disabled(autoSelect.checked()); |
Pierre Ossman | 78b2359 | 2009-03-12 12:25:11 +0000 | [diff] [blame] | 253 | qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked()); |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 254 | } else if (checkbox == &fullColour || checkbox == &mediumColour || |
| 255 | checkbox == &lowColour || checkbox == &veryLowColour) { |
| 256 | fullColour.checked(checkbox == &fullColour); |
| 257 | mediumColour.checked(checkbox == &mediumColour); |
| 258 | lowColour.checked(checkbox == &lowColour); |
| 259 | veryLowColour.checked(checkbox == &veryLowColour); |
| 260 | } else if (checkbox == &tight || checkbox == &zrle || checkbox == &hextile || checkbox == &raw) { |
| 261 | tight.checked(checkbox == &tight); |
| 262 | zrle.checked(checkbox == &zrle); |
| 263 | hextile.checked(checkbox == &hextile); |
| 264 | raw.checked(checkbox == &raw); |
| 265 | } else if (checkbox == &sendClipboard) { |
| 266 | sendPrimary.disabled(!sendClipboard.checked()); |
| 267 | } else if (checkbox == &useLocalCursor) { |
| 268 | dotWhenNoCursor.disabled(!useLocalCursor.checked()); |
| 269 | } else if (checkbox == &customCompressLevel) { |
| 270 | compressLevel.disabled(!customCompressLevel.checked()); |
| 271 | } else if (checkbox == &noJpeg) { |
Pierre Ossman | 78b2359 | 2009-03-12 12:25:11 +0000 | [diff] [blame] | 272 | qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked()); |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 273 | #ifdef HAVE_GNUTLS |
Adam Tkac | b7bafc5 | 2010-09-15 14:13:17 +0000 | [diff] [blame] | 274 | } else if (checkbox == &secVeNCrypt) { |
| 275 | encTLS.checked(false); |
| 276 | encTLS.disabled(!secVeNCrypt.checked()); |
| 277 | encX509.checked(false); |
| 278 | encX509.disabled(!secVeNCrypt.checked()); |
| 279 | secPlain.checked(false); |
| 280 | secPlain.disabled(!secVeNCrypt.checked()); |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 281 | #endif |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | virtual void entryCallback(TXEntry* e, Detail detail, Time time) { |
| 286 | } |
| 287 | |
| 288 | OptionsDialogCallback* cb; |
| 289 | TXLabel formatAndEnc, inputs, misc; |
| 290 | TXCheckbox autoSelect; |
| 291 | TXCheckbox fullColour, mediumColour, lowColour, veryLowColour; |
| 292 | TXCheckbox tight, zrle, hextile, raw; |
| 293 | |
| 294 | TXCheckbox customCompressLevel; TXEntry compressLevel; TXLabel compressLevelLabel; |
| 295 | TXCheckbox noJpeg; TXEntry qualityLevel; TXLabel qualityLevelLabel; |
| 296 | |
| 297 | TXCheckbox viewOnly, acceptClipboard, sendClipboard, sendPrimary; |
| 298 | TXCheckbox shared, fullScreen, useLocalCursor, dotWhenNoCursor; |
| 299 | TXButton okButton, cancelButton; |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 300 | |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 301 | #ifdef HAVE_GNUTLS |
Adam Tkac | e3cb0c3 | 2010-09-15 14:12:38 +0000 | [diff] [blame] | 302 | TXLabel security; |
| 303 | TXCheckbox secVeNCrypt; |
| 304 | |
| 305 | TXLabel encryption; |
| 306 | TXCheckbox encNone, encTLS, encX509; |
| 307 | TXLabel cacert; TXEntry ca; TXLabel crlcert; TXEntry crl; |
| 308 | |
| 309 | TXLabel authentication; |
| 310 | TXCheckbox secNone, secVnc, secPlain; |
Pierre Ossman | fa4b3ac | 2010-09-30 09:06:51 +0000 | [diff] [blame] | 311 | #endif |
Constantin Kaplinsky | b30ae7f | 2006-05-25 05:04:46 +0000 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | #endif |