blob: c818d335f2a993be015da5ff098761577f88062b [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
DRCb65bb932011-06-24 03:17:00 +00003 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Pierre Ossman5156d5e2011-03-09 09:42:34 +00004 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */
20
Peter Åstrandc359f362011-08-23 12:04:46 +000021#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
Pierre Ossman5156d5e2011-03-09 09:42:34 +000025#include <string.h>
26#include <stdio.h>
Pierre Ossman2a7a8d62013-02-15 08:33:39 +000027#include <ctype.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000028#include <stdlib.h>
29#include <errno.h>
30#include <signal.h>
31#include <locale.h>
32#include <sys/stat.h>
33
34#ifdef WIN32
35#include <direct.h>
36#define mkdir(path, mode) _mkdir(path)
37#endif
38
Pierre Ossman6b9622d2014-07-21 16:42:12 +020039#if !defined(WIN32) && !defined(__APPLE__)
40#include <X11/Xlib.h>
41#include <X11/XKBlib.h>
42#endif
43
Pierre Ossman5156d5e2011-03-09 09:42:34 +000044#include <rfb/Logger_stdio.h>
45#include <rfb/SecurityClient.h>
46#include <rfb/Security.h>
47#ifdef HAVE_GNUTLS
48#include <rfb/CSecurityTLS.h>
49#endif
50#include <rfb/LogWriter.h>
51#include <rfb/Timer.h>
Peter Åstrand8a2b0812012-08-08 11:49:01 +000052#include <rfb/Exception.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000053#include <network/TcpSocket.h>
DRC4426f002011-10-12 20:02:55 +000054#include <os/os.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000055
56#include <FL/Fl.H>
57#include <FL/Fl_Widget.H>
Pierre Ossman8eb35082012-03-27 12:50:54 +000058#include <FL/Fl_PNG_Image.H>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000059#include <FL/fl_ask.H>
Pierre Ossmanb8858222011-04-29 11:51:38 +000060#include <FL/x.H>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000061
62#include "i18n.h"
63#include "parameters.h"
64#include "CConn.h"
Pierre Ossman561ff0c2011-05-13 14:04:59 +000065#include "ServerDialog.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000066#include "UserDialog.h"
Adam Tkac8ac4b302013-01-23 13:55:46 +000067#include "vncviewer.h"
Pierre Ossman5156d5e2011-03-09 09:42:34 +000068
DRCb65bb932011-06-24 03:17:00 +000069#ifdef WIN32
Pierre Ossman8eb35082012-03-27 12:50:54 +000070#include "resource.h"
DRCb65bb932011-06-24 03:17:00 +000071#include "win32.h"
72#endif
73
Pierre Ossman5156d5e2011-03-09 09:42:34 +000074rfb::LogWriter vlog("main");
75
76using namespace network;
77using namespace rfb;
78using namespace std;
79
Pierre Ossmandc96cb42014-09-22 12:19:26 +020080static const char _aboutText[] = N_("TigerVNC Viewer %d-bit v%s (%s)\n"
81 "%s\n"
82 "Copyright (C) 1999-2013 TigerVNC Team and many others (see README.txt)\n"
83 "See http://www.tigervnc.org for information on TigerVNC.");
84static char aboutText[1024];
85
DRCd8e93dc2011-07-28 22:13:40 +000086extern const char* buildTime;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000087
Adam Tkac8ac4b302013-01-23 13:55:46 +000088char vncServerName[VNCSERVERNAMELEN] = { '\0' };
89
Pierre Ossman5156d5e2011-03-09 09:42:34 +000090static bool exitMainloop = false;
Pierre Ossmane2ef5c12011-07-12 16:56:34 +000091static const char *exitError = NULL;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000092
Pierre Ossmane2ef5c12011-07-12 16:56:34 +000093void exit_vncviewer(const char *error)
Pierre Ossman5156d5e2011-03-09 09:42:34 +000094{
Pierre Ossmane2ef5c12011-07-12 16:56:34 +000095 // Prioritise the first error we get as that is probably the most
96 // relevant one.
97 if ((error != NULL) && (exitError == NULL))
98 exitError = strdup(error);
99
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000100 exitMainloop = true;
101}
102
Pierre Ossmanb8858222011-04-29 11:51:38 +0000103void about_vncviewer()
104{
105 fl_message_title(_("About TigerVNC Viewer"));
Pierre Ossmandc96cb42014-09-22 12:19:26 +0200106 fl_message("%s", aboutText);
Pierre Ossmanb8858222011-04-29 11:51:38 +0000107}
108
109static void about_callback(Fl_Widget *widget, void *data)
110{
111 about_vncviewer();
112}
113
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000114static void CleanupSignalHandler(int sig)
115{
116 // CleanupSignalHandler allows C++ object cleanup to happen because it calls
117 // exit() rather than the default which is to abort.
Pierre Ossman8ca4c1d2014-09-22 12:54:26 +0200118 vlog.info(_("CleanupSignalHandler called"));
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000119 exit(1);
120}
121
122static void init_fltk()
123{
124 // Basic text size (10pt @ 96 dpi => 13px)
125 FL_NORMAL_SIZE = 13;
126
127#ifndef __APPLE__
128 // Select a FLTK scheme and background color that looks somewhat
129 // close to modern Linux and Windows.
130 Fl::scheme("gtk+");
131 Fl::background(220, 220, 220);
132#else
133 // On Mac OS X there is another scheme that fits better though.
134 Fl::scheme("plastic");
135#endif
136
Henrik Andersson3b837032011-09-19 13:46:55 +0000137 // Proper Gnome Shell integration requires that we set a sensible
138 // WM_CLASS for the window.
139 Fl_Window::default_xclass("vncviewer");
140
Pierre Ossman8eb35082012-03-27 12:50:54 +0000141 // Set the default icon for all windows.
142#ifdef HAVE_FLTK_ICONS
143#ifdef WIN32
144 HICON lg, sm;
145
146 lg = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
147 IMAGE_ICON, GetSystemMetrics(SM_CXICON),
148 GetSystemMetrics(SM_CYICON),
149 LR_DEFAULTCOLOR | LR_SHARED);
150 sm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
151 IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
152 GetSystemMetrics(SM_CYSMICON),
153 LR_DEFAULTCOLOR | LR_SHARED);
154
155 Fl_Window::default_icons(lg, sm);
156#elif ! defined(__APPLE__)
157 const int icon_sizes[] = {48, 32, 24, 16};
158
159 Fl_PNG_Image *icons[4];
160 int count;
161
162 count = 0;
163
164 // FIXME: Follow icon theme specification
165 for (size_t i = 0;i < sizeof(icon_sizes)/sizeof(icon_sizes[0]);i++) {
166 char icon_path[PATH_MAX];
167 bool exists;
168
Pierre Ossman6a007bd2012-09-11 10:56:21 +0000169 sprintf(icon_path, "%s/icons/hicolor/%dx%d/apps/tigervnc.png",
Pierre Ossman8eb35082012-03-27 12:50:54 +0000170 DATA_DIR, icon_sizes[i], icon_sizes[i]);
171
172#ifndef WIN32
173 struct stat st;
174 if (stat(icon_path, &st) != 0)
175#else
176 struct _stat st;
177 if (_stat(icon_path, &st) != 0)
178 return(false);
179#endif
180 exists = false;
181 else
182 exists = true;
183
184 if (exists) {
185 icons[count] = new Fl_PNG_Image(icon_path);
186 if (icons[count]->w() == 0 ||
187 icons[count]->h() == 0 ||
188 icons[count]->d() != 4) {
189 delete icons[count];
190 continue;
191 }
192
193 count++;
194 }
195 }
196
197 Fl_Window::default_icons((const Fl_RGB_Image**)icons, count);
198
199 for (int i = 0;i < count;i++)
200 delete icons[i];
201#endif
202#endif // FLTK_HAVE_ICONS
203
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000204 // This makes the "icon" in dialogs rounded, which fits better
205 // with the above schemes.
206 fl_message_icon()->box(FL_UP_BOX);
207
208 // Turn off the annoying behaviour where popups track the mouse.
209 fl_message_hotspot(false);
210
211 // Avoid empty titles for popups
212 fl_message_title_default(_("TigerVNC Viewer"));
213
214#ifdef WIN32
215 // Most "normal" Windows apps use this font for UI elements.
216 Fl::set_font(FL_HELVETICA, "Tahoma");
217#endif
218
219 // FLTK exposes these so that we can translate them.
220 fl_no = _("No");
221 fl_yes = _("Yes");
222 fl_ok = _("OK");
223 fl_cancel = _("Cancel");
224 fl_close = _("Close");
Pierre Ossmanb8858222011-04-29 11:51:38 +0000225
226#ifdef __APPLE__
Peter Åstrandb7c55242011-08-29 13:14:51 +0000227 /* Needs trailing space */
228 static char fltk_about[16];
229 snprintf(fltk_about, sizeof(fltk_about), "%s ", _("About"));
230 Fl_Mac_App_Menu::about = fltk_about;
231 static char fltk_hide[16];
232 snprintf(fltk_hide, sizeof(fltk_hide), "%s ", _("Hide"));
233 Fl_Mac_App_Menu::hide = fltk_hide;
234 static char fltk_quit[16];
235 snprintf(fltk_quit, sizeof(fltk_quit), "%s ", _("Quit"));
236 Fl_Mac_App_Menu::quit = fltk_quit;
237
Pierre Ossman41ba6032011-06-16 11:09:31 +0000238 Fl_Mac_App_Menu::print = ""; // Don't want the print item
239 Fl_Mac_App_Menu::services = _("Services");
Pierre Ossman41ba6032011-06-16 11:09:31 +0000240 Fl_Mac_App_Menu::hide_others = _("Hide Others");
241 Fl_Mac_App_Menu::show = _("Show All");
Pierre Ossman41ba6032011-06-16 11:09:31 +0000242
Pierre Ossmanb8858222011-04-29 11:51:38 +0000243 fl_mac_set_about(about_callback, NULL);
244#endif
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000245}
246
247static void mkvnchomedir()
248{
249 // Create .vnc in the user's home directory if it doesn't already exist
250 char* homeDir = NULL;
251
252 if (getvnchomedir(&homeDir) == -1) {
253 vlog.error(_("Could not create VNC home directory: can't obtain home "
254 "directory path."));
255 } else {
256 int result = mkdir(homeDir, 0755);
257 if (result == -1 && errno != EEXIST)
258 vlog.error(_("Could not create VNC home directory: %s."), strerror(errno));
259 delete [] homeDir;
260 }
261}
262
263static void usage(const char *programName)
264{
265 fprintf(stderr,
266 "\nusage: %s [parameters] [host:displayNum] [parameters]\n"
267 " %s [parameters] -listen [port] [parameters]\n",
268 programName, programName);
269 fprintf(stderr,"\n"
270 "Parameters can be turned on with -<param> or off with -<param>=0\n"
271 "Parameters which take a value can be specified as "
272 "-<param> <value>\n"
273 "Other valid forms are <param>=<value> -<param>=<value> "
274 "--<param>=<value>\n"
275 "Parameter names are case-insensitive. The parameters are:\n\n");
276 Configuration::listParams(79, 14);
277 exit(1);
278}
279
Adam Tkac8ac4b302013-01-23 13:55:46 +0000280#ifndef WIN32
281static int
282interpretViaParam(char *remoteHost, int *remotePort, int localPort)
283{
284 const int SERVER_PORT_OFFSET = 5900;
285 char *pos = strchr(vncServerName, ':');
286 if (pos == NULL)
287 *remotePort = SERVER_PORT_OFFSET;
288 else {
289 int portOffset = SERVER_PORT_OFFSET;
290 size_t len;
291 *pos++ = '\0';
292 len = strlen(pos);
293 if (*pos == ':') {
294 /* Two colons is an absolute port number, not an offset. */
295 pos++;
296 len--;
297 portOffset = 0;
298 }
299 if (!len || strspn (pos, "-0123456789") != len )
300 return 1;
301 *remotePort = atoi(pos) + portOffset;
302 }
303
304 if (*vncServerName != '\0')
305 strncpy(remoteHost, vncServerName, VNCSERVERNAMELEN);
306 else
307 strncpy(remoteHost, "localhost", VNCSERVERNAMELEN);
308
309 remoteHost[VNCSERVERNAMELEN - 1] = '\0';
310
311 snprintf(vncServerName, VNCSERVERNAMELEN, "localhost::%d", localPort);
312 vncServerName[VNCSERVERNAMELEN - 1] = '\0';
313 vlog.error(vncServerName);
314
315 return 0;
316}
317
318static void
319createTunnel(const char *gatewayHost, const char *remoteHost,
320 int remotePort, int localPort)
321{
Pierre Ossmanf8d525b2014-07-09 17:02:27 +0200322 const char *cmd = getenv("VNC_VIA_CMD");
323 char *cmd2, *percent;
Adam Tkac8ac4b302013-01-23 13:55:46 +0000324 char lport[10], rport[10];
325 sprintf(lport, "%d", localPort);
326 sprintf(rport, "%d", remotePort);
327 setenv("G", gatewayHost, 1);
328 setenv("H", remoteHost, 1);
329 setenv("R", rport, 1);
330 setenv("L", lport, 1);
Adam Tkac8ac4b302013-01-23 13:55:46 +0000331 if (!cmd)
332 cmd = "/usr/bin/ssh -f -L \"$L\":\"$H\":\"$R\" \"$G\" sleep 20";
333 /* Compatibility with TigerVNC's method. */
Pierre Ossmanf8d525b2014-07-09 17:02:27 +0200334 cmd2 = strdup(cmd);
335 while ((percent = strchr(cmd2, '%')) != NULL)
Adam Tkac8ac4b302013-01-23 13:55:46 +0000336 *percent = '$';
Pierre Ossmanf8d525b2014-07-09 17:02:27 +0200337 system(cmd2);
338 free(cmd2);
Adam Tkac8ac4b302013-01-23 13:55:46 +0000339}
340
341static int mktunnel()
342{
343 const char *gatewayHost;
344 char remoteHost[VNCSERVERNAMELEN];
345 int localPort = findFreeTcpPort();
346 int remotePort;
347
348 gatewayHost = strDup(via.getValueStr());
349 if (interpretViaParam(remoteHost, &remotePort, localPort) != 0)
350 return 1;
351 createTunnel(gatewayHost, remoteHost, remotePort, localPort);
352
353 return 0;
354}
355#endif /* !WIN32 */
356
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000357int main(int argc, char** argv)
358{
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000359 UserDialog dlg;
360
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000361 setlocale(LC_ALL, "");
Pierre Ossman0878eca2012-03-27 13:03:22 +0000362 bindtextdomain(PACKAGE_NAME, LOCALE_DIR);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000363 textdomain(PACKAGE_NAME);
364
Pierre Ossmandc96cb42014-09-22 12:19:26 +0200365 // Generate the about string now that we get the proper translation
366 snprintf(aboutText, sizeof(aboutText), _aboutText,
367 (int)sizeof(size_t)*8, PACKAGE_VERSION, __BUILD__, buildTime);
368
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000369 rfb::SecurityClient::setDefaults();
370
371 // Write about text to console, still using normal locale codeset
Pierre Ossmandc96cb42014-09-22 12:19:26 +0200372 fprintf(stderr,"\n%s\n", aboutText);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000373
374 // Set gettext codeset to what our GUI toolkit uses. Since we are
375 // passing strings from strerror/gai_strerror to the GUI, these must
376 // be in GUI codeset as well.
377 bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
378 bind_textdomain_codeset("libc", "UTF-8");
379
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000380 rfb::initStdIOLoggers();
Pierre Ossmanc8719ad2012-04-26 14:27:52 +0000381#ifdef WIN32
382 rfb::initFileLogger("C:\\temp\\vncviewer.log");
383#else
384 rfb::initFileLogger("/tmp/vncviewer.log");
385#endif
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000386 rfb::LogWriter::setLogParams("*:stderr:30");
387
388#ifdef SIGHUP
389 signal(SIGHUP, CleanupSignalHandler);
390#endif
391 signal(SIGINT, CleanupSignalHandler);
392 signal(SIGTERM, CleanupSignalHandler);
393
394 init_fltk();
395
Pierre Ossman6b9622d2014-07-21 16:42:12 +0200396#if !defined(WIN32) && !defined(__APPLE__)
397 fl_open_display();
398 XkbSetDetectableAutoRepeat(fl_display, True, NULL);
399#endif
400
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000401 Configuration::enableViewerParams();
402
Peter Åstrand8a2b0812012-08-08 11:49:01 +0000403 /* Load the default parameter settings */
404 const char* defaultServerName;
405 try {
406 defaultServerName = loadViewerParameters(NULL);
407 } catch (rfb::Exception& e) {
408 fl_alert("%s", e.str());
409 }
410
DRC5aa06502011-06-23 22:04:46 +0000411 int i = 1;
412 if (!Fl::args(argc, argv, i) || i < argc)
413 for (; i < argc; i++) {
414 if (Configuration::setParam(argv[i]))
415 continue;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000416
DRC5aa06502011-06-23 22:04:46 +0000417 if (argv[i][0] == '-') {
418 if (i+1 < argc) {
419 if (Configuration::setParam(&argv[i][1], argv[i+1])) {
420 i++;
421 continue;
422 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000423 }
DRC5aa06502011-06-23 22:04:46 +0000424 usage(argv[0]);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000425 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000426
Adam Tkac8ac4b302013-01-23 13:55:46 +0000427 strncpy(vncServerName, argv[i], VNCSERVERNAMELEN);
428 vncServerName[VNCSERVERNAMELEN - 1] = '\0';
DRC5aa06502011-06-23 22:04:46 +0000429 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000430
431 if (!::autoSelect.hasBeenSet()) {
432 // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used
Peter Åstrand8a2b0812012-08-08 11:49:01 +0000433 if (::preferredEncoding.hasBeenSet() || ::fullColour.hasBeenSet() ||
434 ::fullColourAlias.hasBeenSet()) {
435 ::autoSelect.setParam(false);
436 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000437 }
438 if (!::fullColour.hasBeenSet() && !::fullColourAlias.hasBeenSet()) {
439 // Default to FullColor=0 if AutoSelect=0 && LowColorLevel is set
440 if (!::autoSelect && (::lowColourLevel.hasBeenSet() ||
441 ::lowColourLevelAlias.hasBeenSet())) {
442 ::fullColour.setParam(false);
443 }
444 }
445 if (!::customCompressLevel.hasBeenSet()) {
446 // Default to CustomCompressLevel=1 if CompressLevel is used.
Peter Åstrand8a2b0812012-08-08 11:49:01 +0000447 if(::compressLevel.hasBeenSet()) {
448 ::customCompressLevel.setParam(true);
449 }
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000450 }
451
452 mkvnchomedir();
453
454 CSecurity::upg = &dlg;
455#ifdef HAVE_GNUTLS
456 CSecurityTLS::msg = &dlg;
457#endif
458
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000459 Socket *sock = NULL;
460
DRC3e7ed812013-02-26 10:34:22 +0000461#ifndef WIN32
Adam Tkac571089b2013-02-19 14:30:32 +0000462 /* Specifying -via and -listen together is nonsense */
463 if (listenMode && strlen(via.getValueStr()) > 0) {
Pierre Ossman8ca4c1d2014-09-22 12:54:26 +0200464 vlog.error(_("Parameters -listen and -via are incompatible"));
465 fl_alert(_("Parameters -listen and -via are incompatible"));
Adam Tkac571089b2013-02-19 14:30:32 +0000466 exit_vncviewer();
467 return 1;
468 }
DRC3e7ed812013-02-26 10:34:22 +0000469#endif
Adam Tkac571089b2013-02-19 14:30:32 +0000470
471 if (listenMode) {
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000472 try {
473 int port = 5500;
474 if (isdigit(vncServerName[0]))
475 port = atoi(vncServerName);
476
477 TcpListener listener(NULL, port);
478
Pierre Ossman8ca4c1d2014-09-22 12:54:26 +0200479 vlog.info(_("Listening on port %d\n"), port);
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000480 sock = listener.accept();
481 } catch (rdr::Exception& e) {
482 vlog.error("%s", e.str());
483 fl_alert("%s", e.str());
484 exit_vncviewer();
485 return 1;
486 }
487
488 } else {
489 if (vncServerName[0] == '\0') {
490 ServerDialog::run(defaultServerName, vncServerName);
491 if (vncServerName[0] == '\0')
492 return 1;
493 }
Pierre Ossman561ff0c2011-05-13 14:04:59 +0000494
Adam Tkac8ac4b302013-01-23 13:55:46 +0000495#ifndef WIN32
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000496 if (strlen (via.getValueStr()) > 0 && mktunnel() != 0)
497 usage(argv[0]);
Adam Tkac8ac4b302013-01-23 13:55:46 +0000498#endif
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000499 }
Adam Tkac8ac4b302013-01-23 13:55:46 +0000500
Pierre Ossman2a7a8d62013-02-15 08:33:39 +0000501 CConn *cc = new CConn(vncServerName, sock);
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000502
503 while (!exitMainloop) {
504 int next_timer;
505
506 next_timer = Timer::checkTimeouts();
507 if (next_timer == 0)
508 next_timer = INT_MAX;
509
510 if (Fl::wait((double)next_timer / 1000.0) < 0.0) {
511 vlog.error(_("Internal FLTK error. Exiting."));
512 break;
513 }
514 }
515
Pierre Ossmane2ef5c12011-07-12 16:56:34 +0000516 delete cc;
517
518 if (exitError != NULL)
Pierre Ossmanf52740e2012-04-25 15:43:56 +0000519 fl_alert("%s", exitError);
Pierre Ossmane2ef5c12011-07-12 16:56:34 +0000520
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000521 return 0;
522}