⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vncoptions.cpp

📁 realvnc是一个非常流行的远程控制程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//// Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.////  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.////  This file is part of the VNC system.////  The VNC system is free software; you can redistribute it and/or modify//  it under the terms of the GNU General Public License as published by//  the Free Software Foundation; either version 2 of the License, or//  (at your option) any later version.////  This program is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU General Public License for more details.////  You should have received a copy of the GNU General Public License//  along with this program; if not, write to the Free Software//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,//  USA.//// If the source code for the VNC system is not available from the place // whence you received this file, check http://www.uk.research.att.com/vnc or contact// the authors on vnc@uk.research.att.com for information on obtaining it.// VNCOptions.cpp: implementation of the VNCOptions class.#include "stdhdrs.h"#include "vncviewer.h"#include "VNCOptions.h"#include "Exception.h"VNCOptions::VNCOptions(){  for (int i = 0; i <= LASTENCODING; i++)    m_UseEnc[i] = false;  m_UseEnc[rfbEncodingRaw] = true;  m_UseEnc[rfbEncodingCopyRect] = true;  m_UseEnc[rfbEncodingRRE] = true;  m_UseEnc[rfbEncodingCoRRE] = true;  m_UseEnc[rfbEncodingHextile] = true;  m_UseEnc[rfbEncodingZRLE] = true;	  m_ViewOnly = false;  m_FullScreen = false;  autoDetect = true;  m_Use8Bit = false;#ifndef UNDER_CE  //m_PreferredEncoding = rfbEncodingHextile;  m_PreferredEncoding = rfbEncodingZRLE;#else  // With WinCE2.0, CoRRE seems more efficient since it  // reads the whole update in one socket call.  m_PreferredEncoding = rfbEncodingCoRRE;#endif  m_SwapMouse = false;  m_Emul3Buttons = true;  m_Emul3Timeout = 100; // milliseconds  m_Emul3Fuzz = 4;      // pixels away before emulation is cancelled  m_Shared = false;  m_DeiconifyOnBell = false;  m_DisableClipboard = false;  m_localCursor = DOTCURSOR;  m_scaling = false;  m_scale_num = 1;  m_scale_den = 1;	  m_host[0] = '\0';  m_port = -1;	  m_kbdname[0] = '\0';  m_kbdSpecified = false;	  m_logLevel = 0;  m_logToConsole = false;  m_logToFile = false;  m_logFilename[0] = '\0';	  m_delay=0;  m_connectionSpecified = false;  m_configSpecified = false;  m_configFilename[0] = '\0';  m_listening = false;  m_listenPort = INCOMING_PORT_OFFSET;  m_restricted = false;#ifdef UNDER_CE  m_palmpc = false;	  // Check for PalmPC aspect   HDC temp_hdc = GetDC(NULL);  int screen_width = GetDeviceCaps(temp_hdc, HORZRES);  if (screen_width < 320)  {    m_palmpc = true;  }  ReleaseDC(NULL,temp_hdc);  m_slowgdi = false;#endif}VNCOptions& VNCOptions::operator=(VNCOptions& s){  for (int i = rfbEncodingRaw; i<= LASTENCODING; i++)    m_UseEnc[i] = s.m_UseEnc[i];	  m_ViewOnly			= s.m_ViewOnly;  m_FullScreen		= s.m_FullScreen;  autoDetect = s.autoDetect;  m_Use8Bit			= s.m_Use8Bit;  m_PreferredEncoding = s.m_PreferredEncoding;  m_SwapMouse			= s.m_SwapMouse;  m_Emul3Buttons		= s.m_Emul3Buttons;  m_Emul3Timeout		= s.m_Emul3Timeout;  m_Emul3Fuzz			= s.m_Emul3Fuzz;      // pixels away before emulation is cancelled  m_Shared			= s.m_Shared;  m_DeiconifyOnBell	= s.m_DeiconifyOnBell;  m_DisableClipboard  = s.m_DisableClipboard;  m_scaling			= s.m_scaling;  m_scale_num			= s.m_scale_num;  m_scale_den			= s.m_scale_den;  m_localCursor		= s.m_localCursor;	  strcpy(m_host, s.m_host);  m_port				= s.m_port;	  strcpy(m_kbdname, s.m_kbdname);  m_kbdSpecified		= s.m_kbdSpecified;	  m_logLevel			= s.m_logLevel;  m_logToConsole		= s.m_logToConsole;  m_logToFile			= s.m_logToFile;  strcpy(m_logFilename, s.m_logFilename);  m_delay				= s.m_delay;  m_connectionSpecified = s.m_connectionSpecified;  m_configSpecified   = s.m_configSpecified;  strcpy(m_configFilename, s.m_configFilename);  m_listening			= s.m_listening;  m_listenPort			= s.m_listenPort;  m_restricted		= s.m_restricted;#ifdef UNDER_CE  m_palmpc			= s.m_palmpc;  m_slowgdi			= s.m_slowgdi;#endif  return *this;}VNCOptions::~VNCOptions(){	}inline bool SwitchMatch(LPCTSTR arg, LPCTSTR swtch) {  return (arg[0] == '-' || arg[0] == '/') &&    (_tcsicmp(&arg[1], swtch) == 0);}static void ArgError(LPTSTR msg) {  MessageBox(NULL,  msg, _T("Argument error"),MB_OK | MB_TOPMOST | MB_ICONSTOP);}// Greatest common denominator, by Euclidint gcd(int a, int b) {  if (a < b) return gcd(b,a);  if (b == 0) return a;  return gcd(b, a % b);}void VNCOptions::FixScaling() {  if (m_scale_num < 1 || m_scale_den < 1) {    MessageBox(NULL,  _T("Invalid scale factor - resetting to normal scale"),                _T("Argument error"),MB_OK | MB_TOPMOST | MB_ICONWARNING);    m_scale_num = 1;    m_scale_den = 1;	    m_scaling = false;  }  int g = gcd(m_scale_num, m_scale_den);  m_scale_num /= g;  m_scale_den /= g;	}void VNCOptions::SetFromCommandLine(LPTSTR szCmdLine) {  // We assume no quoting here.  // Copy the command line - we don't know what might happen to the original  int cmdlinelen = _tcslen(szCmdLine);  if (cmdlinelen == 0) return;	  TCHAR *cmd = new TCHAR[cmdlinelen + 1];  _tcscpy(cmd, szCmdLine);		// Count the number of spaces	// This may be more than the number of arguments, but that doesn't matter.  int nspaces = 0;  TCHAR *p = cmd;  TCHAR *pos = cmd;  while ( ( pos = _tcschr(p, ' ') ) != NULL ) {    nspaces ++;    p = pos + 1;  }	  // Create the array to hold pointers to each bit of string  TCHAR **args = new LPTSTR[nspaces + 1];	  // replace spaces with nulls and  // create an array of TCHAR*'s which points to start of each bit.  pos = cmd;  int i = 0;  args[i] = cmd;  bool inquote=false;  for (pos = cmd; *pos != 0; pos++) {    // Arguments are normally separated by spaces, unless there's quoting    if ((*pos == ' ') && !inquote) {      *pos = '\0';      p = pos + 1;      args[++i] = p;    }    if (*pos == '"') {        if (!inquote) {      // Are we starting a quoted argument?        args[i] = ++pos; // It starts just after the quote      } else {        *pos = '\0';     // Finish a quoted argument?      }      inquote = !inquote;    }  }  i++;  bool hostGiven = false, portGiven = false;  // take in order.  for (int j = 0; j < i; j++) {    if ( SwitchMatch(args[j], _T("help")) ||         SwitchMatch(args[j], _T("?")) ||         SwitchMatch(args[j], _T("h"))) {      ShowUsage();      PostQuitMessage(1);    } else if ( SwitchMatch(args[j], _T("listen"))) {      m_listening = true;      if (j+1 < i && args[j+1][0] >= '0' && args[j+1][0] <= '9') {        if (_stscanf(args[j+1], _T("%d"), &m_listenPort) != 1) {          ArgError(_T("Invalid listen port specified"));          continue;        }        j++;      }    } else if ( SwitchMatch(args[j], _T("restricted"))) {      m_restricted = true;    } else if ( SwitchMatch(args[j], _T("viewonly"))) {      m_ViewOnly = true;    } else if ( SwitchMatch(args[j], _T("fullscreen"))) {      m_FullScreen = true;    } else if ( SwitchMatch(args[j], _T("noauto"))) {      autoDetect = false;    } else if ( SwitchMatch(args[j], _T("8bit"))) {      m_Use8Bit = true;    } else if ( SwitchMatch(args[j], _T("shared"))) {      m_Shared = true;    } else if ( SwitchMatch(args[j], _T("swapmouse"))) {      m_SwapMouse = true;    } else if ( SwitchMatch(args[j], _T("nocursor"))) {      m_localCursor = NOCURSOR;    } else if ( SwitchMatch(args[j], _T("dotcursor"))) {      m_localCursor = DOTCURSOR;    } else if ( SwitchMatch(args[j], _T("normalcursor"))) {      m_localCursor = NORMALCURSOR;    } else if ( SwitchMatch(args[j], _T("belldeiconify") )) {      m_DeiconifyOnBell = true;    } else if ( SwitchMatch(args[j], _T("emulate3") )) {      m_Emul3Buttons = true;    } else if ( SwitchMatch(args[j], _T("noemulate3") )) {      m_Emul3Buttons = false;    } else if ( SwitchMatch(args[j], _T("scale") )) {      if (++j == i) {        ArgError(_T("No scaling factor specified"));        continue;      }      int numscales = _stscanf(args[j], _T("%d/%d"), &m_scale_num, &m_scale_den);      if (numscales < 1) {        ArgError(_T("Invalid scaling specified"));        continue;      }      if (numscales == 1)         m_scale_den = 1; // needed if you're overriding a previous setting    } else if ( SwitchMatch(args[j], _T("emulate3timeout") )) {      if (++j == i) {        ArgError(_T("No timeout specified"));        continue;      }      if (_stscanf(args[j], _T("%d"), &m_Emul3Timeout) != 1) {        ArgError(_T("Invalid timeout specified"));        continue;      }			    } else if ( SwitchMatch(args[j], _T("emulate3fuzz") )) {      if (++j == i) {        ArgError(_T("No fuzz specified"));        continue;      }      if (_stscanf(args[j], _T("%d"), &m_Emul3Fuzz) != 1) {        ArgError(_T("Invalid fuzz specified"));        continue;      }			    } else if ( SwitchMatch(args[j], _T("disableclipboard") )) {      m_DisableClipboard = true;    }#ifdef UNDER_CE    // Manual setting of palm vs hpc aspect ratio for dialog boxes.    else if ( SwitchMatch(args[j], _T("hpc") )) {      m_palmpc = false;    } else if ( SwitchMatch(args[j], _T("palm") )) {      m_palmpc = true;    } else if ( SwitchMatch(args[j], _T("slow") )) {      m_slowgdi = true;    } #endif    else if ( SwitchMatch(args[j], _T("delay") )) {      if (++j == i) {        ArgError(_T("No delay specified"));        continue;      }      if (_stscanf(args[j], _T("%d"), &m_delay) != 1) {        ArgError(_T("Invalid delay specified"));        continue;      }			    } else if ( SwitchMatch(args[j], _T("loglevel") )) {      if (++j == i) {        ArgError(_T("No loglevel specified"));        continue;      }      if (_stscanf(args[j], _T("%d"), &m_logLevel) != 1) {        ArgError(_T("Invalid loglevel specified"));        continue;      }			    } else if ( SwitchMatch(args[j], _T("console") )) {      m_logToConsole = true;    } else if ( SwitchMatch(args[j], _T("logfile") )) {      if (++j == i) {        ArgError(_T("No logfile specified"));        continue;      }      if (_stscanf(args[j], _T("%s"), &m_logFilename) != 1) {        ArgError(_T("Invalid logfile specified"));        continue;      } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -