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

📄 vncviewerapp32.cpp

📁 teamviewer source code vc++
💻 CPP
字号:
//  Copyright (C) 2006 Teamviewer GmbH. All Rights Reserved.
//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
//
//  This file is part of TeamViewer.
//
//  TeamViewer 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 TeamViewer is not available from the place 
//  whence you received this file, check http://www.teamviewer.com
//  for information on obtaining it.

#include "stdhdrs.h"
#include "VNCviewerApp32.h"
#include "..\winvnc\winvnc\vncServer.h"
#include "..\winvnc\winvnc\vncMenu.h"
#include "..\winvnc\winvnc\global.h"
#include "SessionDialog.h"

extern vncMenu* menu;
VNCviewerApp32 *VNCviewerApp32::m_instance;

extern char sz_A1[64];
extern char sz_A5[64];

VNCviewerApp32::VNCviewerApp32(HINSTANCE hInstance, PSTR szCmdLine) :
	VNCviewerApp(hInstance, szCmdLine)
{
	VNCviewerApp32(hInstance, szCmdLine, NULL);
}

// --------------------------------------------------------------------------
VNCviewerApp32::VNCviewerApp32(HINSTANCE hInstance, PSTR szCmdLine, vncServer *server) :
	VNCviewerApp(hInstance, szCmdLine)
{
	m_server = server;
    Is_Viewer = false;

	RegisterSounds();
	
}

bool VNCviewerApp32::NewConnection(TCHAR *host, int port) {

	UpdateOptions();
	ClientConnection *pcc = new ClientConnection(this, host,port);
    Is_Viewer = true;
	try {
		int res = pcc->Run();
		if(res != 1)			// failed or change to server mode -> clientconnection is no longer needed
			delete pcc;
		if(res != 0)
		{
			SessionDialog::ConnectionSucceded();
			return res>0;
		}
		else
		{
			SessionDialog::ConnectionFailed();
			return false;
		}
	} catch (Exception &e) {
		SessionDialog::ConnectionFailed();
		e.Report();	
		while(pcc->m_pFileTransfer->m_fFileTransferRunning)  // Wait until window closed
			Sleep(50);
		delete pcc;  //TR@2004: delete seems too dangerous, lots of crashes on Win98
        Is_Viewer = false;
		return false;
	} 
}

void VNCviewerApp32::NewConnection(SOCKET sock, int newmode) {
	SYSTEMTIME dummytime;
	GetSystemTime(&dummytime);
	NewConnection(sock, newmode, "", dummytime, 0);
}

void VNCviewerApp32::NewConnection(SOCKET sock, int newmode, string serverUser, SYSTEMTIME start, int lastMode) {

	UpdateOptions();
	// newmode = the initial connection mode (presentation, teamwork client..)
	ClientConnection *pcc = new ClientConnection(this, sock, newmode);
	pcc->m_lastServermode = lastMode;

    Is_Viewer = true;
	try {
		pcc->Run();
		if(serverUser != "")
		{
			pcc->connectionLogStartTime = start;
			pcc->connectionLogUser = serverUser;
		}
	} catch (Exception &e) {
		e.Report();	
		while(pcc->m_pFileTransfer->m_fFileTransferRunning)
			Sleep(50);
		delete pcc;  //TR@2004: delete seems too dangerous, lots of crashes on Win98
        Is_Viewer = false;
	} 
}

// Register the Bell sound event

const char* BELL_APPL_KEY_NAME  = "AppEvents\\Schemes\\Apps\\VNCviewer";
const char* BELL_LABEL = "VNCviewerBell";

void VNCviewerApp32::RegisterSounds() {
	
	HKEY hBellKey;
	char keybuf[256];
	
	if(isNoSave)
		return;

	sprintf(keybuf, "AppEvents\\EventLabels\\%s", BELL_LABEL);
	// First create a label for it
	if ( RegCreateKey(HKEY_CURRENT_USER, keybuf, &hBellKey)  == ERROR_SUCCESS ) {
		RegSetValue(hBellKey, NULL, REG_SZ, "Bell", 0);
		RegCloseKey(hBellKey);
		
		// Then put the detail in the app-specific area
		
		if ( RegCreateKey(HKEY_CURRENT_USER, BELL_APPL_KEY_NAME, &hBellKey)  == ERROR_SUCCESS ) {
			
			sprintf(keybuf, "%s\\%s", BELL_APPL_KEY_NAME, BELL_LABEL);
			RegCreateKey(HKEY_CURRENT_USER, keybuf, &hBellKey);
			RegSetValue(hBellKey, NULL, REG_SZ, "Bell", 0);
			RegCloseKey(hBellKey);
			
			sprintf(keybuf, "%s\\%s\\.current", BELL_APPL_KEY_NAME, BELL_LABEL);
			if (RegOpenKey(HKEY_CURRENT_USER, keybuf, &hBellKey) != ERROR_SUCCESS) {
				RegCreateKey(HKEY_CURRENT_USER, keybuf, &hBellKey);
				RegSetValue(hBellKey, NULL, REG_SZ, "ding.wav", 0);
			}
			RegCloseKey(hBellKey);
			
			sprintf(keybuf, "%s\\%s\\.default", BELL_APPL_KEY_NAME, BELL_LABEL);
			if (RegOpenKey(HKEY_CURRENT_USER, keybuf, &hBellKey) != ERROR_SUCCESS) {
				RegCreateKey(HKEY_CURRENT_USER, keybuf, &hBellKey);
				RegSetValue(hBellKey, NULL, REG_SZ, "ding.wav", 0);
			}
			RegCloseKey(hBellKey);
		}
		
	} 
	
}

VNCviewerApp32::~VNCviewerApp32() { }
	
void VNCviewerApp32::UpdateOptions()
{
	if(!m_options.m_SetFromCommandLine)
	{
		m_options.m_Quality = menu->m_properties.Remote_Quality();
		m_options.m_Compression = menu->m_properties.Remote_Compression();
		m_options.m_Use8Bit = menu->m_properties.Remote_Colors();
	}
	m_options.m_nServerScale = menu->m_properties.Remote_ServerScale();
	m_options.m_ViewOnly = menu->m_properties.Remote_ViewOnly();
	m_options.m_RemoveWallpaper = menu->m_properties.Remote_RemoveWallpaper();
	m_options.m_DisableInput = menu->m_properties.Remote_DisableInput();
	m_options.m_BlackScreen = menu->m_properties.Remote_BlackScreen();
	m_options.m_scaling = menu->m_properties.Remote_Scaling();
	m_options.m_fAutoScaling = menu->m_properties.Remote_Autoscaling();
	m_options.m_set_scale_num = menu->m_properties.Remote_ScaleBy();

	m_options.ShowRemoteCursor(menu->m_properties.Remote_ShowRemoteCursor());

	
	m_options.ApplyQuality();
	m_options.FixScaling();
}

⌨️ 快捷键说明

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