亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? daemon.cpp

?? tightvnc源碼
?? CPP
字號:
//  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.
//
// TightVNC distribution homepage on the Web: http://www.tightvnc.com/
//
// 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.


// Daemon.cpp: implementation of the Daemon class.

#include "stdhdrs.h"
#include "vncviewer.h"
#include "Daemon.h"
#include "Exception.h"
#include "ClientConnection.h"
#include "AboutBox.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#define DAEMON_CLASS_NAME "VNCviewer Daemon"

Daemon::Daemon(int port)
{

	// Create a dummy window
	WNDCLASSEX wndclass;

	wndclass.cbSize			= sizeof(wndclass);
	wndclass.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
	wndclass.lpfnWndProc	= Daemon::WndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= pApp->m_instance;
	wndclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName	= (const char *) NULL;
	wndclass.lpszClassName	= DAEMON_CLASS_NAME;
	wndclass.hIconSm		= LoadIcon(NULL, IDI_APPLICATION);

	RegisterClassEx(&wndclass);

	m_hwnd = CreateWindow(DAEMON_CLASS_NAME,
				DAEMON_CLASS_NAME,
				WS_OVERLAPPEDWINDOW,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				200, 200,
				NULL,
				NULL,
				pApp->m_instance,
				NULL);
	
	// record which client created this window
	SetWindowLong(m_hwnd, GWL_USERDATA, (LONG) this);

	// Load a popup menu
	m_hmenu = LoadMenu(pApp->m_instance, MAKEINTRESOURCE(IDR_TRAYMENU));

	// Create a listening socket
    struct sockaddr_in addr;

    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = INADDR_ANY;

    m_sock = socket(AF_INET, SOCK_STREAM, 0);
	if (!m_sock)
		throw WarningException("Error creating Daemon socket");

	int one = 1, res = 0;
	//res = setsockopt(m_sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &one, sizeof(one));
	//if (res == SOCKET_ERROR)  {
	//	closesocket(m_sock);
	//	m_sock = 0;
	//	throw WarningException("Error setting Daemon socket options");
	//}

	res = bind(m_sock, (struct sockaddr *)&addr, sizeof(addr));
	if (res == SOCKET_ERROR) {
		closesocket(m_sock);
		m_sock = 0;
		throw WarningException("Error binding Daemon socket");
	}

	res = listen(m_sock, 5);
	if (res == SOCKET_ERROR) {
		closesocket(m_sock);
		m_sock = 0;
		throw WarningException("Error when Daemon listens");
	}

	// Send a message to specified window on an incoming connection
	WSAAsyncSelect (m_sock,  m_hwnd,  WM_SOCKEVENT, FD_ACCEPT);

	// Create the tray icon
	AddTrayIcon();

	// A timer checks that the tray icon is intact
	m_timer = SetTimer( m_hwnd, IDT_TRAYTIMER,  15000, NULL);
}

void Daemon::AddTrayIcon() {
	vnclog.Print(4, _T("Adding tray icon\n"));
	SendTrayMsg(NIM_ADD);
}

void Daemon::CheckTrayIcon() {
	vnclog.Print(8, _T("Checking tray icon\n"));
	if (!SendTrayMsg(NIM_MODIFY)) {
		vnclog.Print(4, _T("Tray icon not there - reinstalling\n"));
		AddTrayIcon();
	};
}

void Daemon::RemoveTrayIcon() {
	vnclog.Print(4, _T("Deleting tray icon\n"));
	SendTrayMsg(NIM_DELETE);
}

bool Daemon::SendTrayMsg(DWORD msg)
{
	m_nid.hWnd = m_hwnd;
	m_nid.cbSize = sizeof(m_nid);
	m_nid.uID = IDR_TRAY;	// never changes after construction
	m_nid.hIcon = LoadIcon(pApp->m_instance, MAKEINTRESOURCE(IDR_TRAY));
	m_nid.uFlags = NIF_ICON | NIF_MESSAGE;
	m_nid.uCallbackMessage = WM_TRAYNOTIFY;
	m_nid.szTip[0] = '\0';
	// Use resource string as tip if there is one
	if (LoadString(pApp->m_instance, IDR_TRAY, m_nid.szTip, sizeof(m_nid.szTip))) {
		m_nid.uFlags |= NIF_TIP;
	}
	return (bool) (Shell_NotifyIcon(msg, &m_nid) != 0);
}

// Process window messages
LRESULT CALLBACK Daemon::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
	// This is a static method, so we don't know which instantiation we're 
	// dealing with. We have stored a pseudo-this in the window user data, 
	// though.
	Daemon *_this = (Daemon *) GetWindowLong(hwnd, GWL_USERDATA);

	switch (iMsg) {

	case WM_CREATE:
		{
			return 0;
		}

	case WM_SOCKEVENT:
		{
			assert(HIWORD(lParam) == 0);
			// A new socket created by accept might send messages to
			// this procedure. We can ignore them.
			if(wParam != _this->m_sock) {
				return 0;
			}

			switch(lParam) {
			case FD_ACCEPT:
				{
					SOCKET hNewSock;
					hNewSock = accept(_this->m_sock, NULL, NULL);
					WSAAsyncSelect(hNewSock, hwnd, 0, 0);
					unsigned long nbarg = 0;
					ioctlsocket(hNewSock, FIONBIO, &nbarg);

					pApp->NewConnection(hNewSock);
					
					break;
				}
			case FD_READ:
				{
					unsigned long numbytes;
					ioctlsocket(_this->m_sock, FIONREAD, &numbytes);
					recv(_this->m_sock, _this->netbuf, numbytes, 0);
					break;
				}
			case FD_CLOSE:
				vnclog.Print(5, _T("Daemon connection closed\n"));
				DestroyWindow(hwnd);
				break;
			}
			
			return 0;
		}
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case ID_NEWCONN:
			pApp->NewConnection();
			break;
		case IDC_OPTIONBUTTON:
			pApp->m_options.DoDialog();
			pApp->m_options.SaveOpt(".listen", KEY_VNCVIEWER_HISTORI);
			break;
		case ID_CLOSEDAEMON:
			PostQuitMessage(0);
			break;
		case IDD_APP_ABOUT:
			ShowAboutBox();
			break;
		}
		return 0;
	case WM_TRAYNOTIFY:
		{
			HMENU hSubMenu = GetSubMenu(_this->m_hmenu, 0);
			if (lParam==WM_LBUTTONDBLCLK) {
				// double click: execute first menu item
				::SendMessage(_this->m_nid.hWnd, WM_COMMAND, 
					GetMenuItemID(hSubMenu, 0), 0);
			} else if (lParam==WM_RBUTTONUP) {
				if (hSubMenu == NULL) { 
					vnclog.Print(2, _T("No systray submenu\n"));
					return 0;
				}
				// Make first menu item the default (bold font)
				::SetMenuDefaultItem(hSubMenu, 0, TRUE);
				
				// Display the menu at the current mouse location. There's a "bug"
				// (Microsoft calls it a feature) in Windows 95 that requires calling
				// SetForegroundWindow. To find out more, search for Q135788 in MSDN.
				//
				POINT mouse;
				GetCursorPos(&mouse);
				::SetForegroundWindow(_this->m_nid.hWnd);
				::TrackPopupMenu(hSubMenu, 0, mouse.x, mouse.y, 0,
					_this->m_nid.hWnd, NULL);
				
			} 
			return 0;
		}
	case WM_TIMER:
		_this->CheckTrayIcon();
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	
	return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

Daemon::~Daemon()
{
	
	KillTimer(m_hwnd, m_timer);
	RemoveTrayIcon();
	DestroyMenu(m_hmenu);
	shutdown(m_sock, SD_BOTH);
	closesocket(m_sock);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.日本不卡| 国产精品日产欧美久久久久| 国产亚洲欧美中文| 亚洲午夜av在线| 成人av网址在线| 日韩欧美视频一区| 一区二区三区四区av| 国产成人av电影在线观看| 欧美私人免费视频| 中文字幕一区二区三区不卡在线 | 国产精品欧美久久久久一区二区| 亚洲激情男女视频| 丁香婷婷综合网| 久久久久久**毛片大全| 日本欧美韩国一区三区| 欧美中文字幕一区| 中文字幕一区二区在线观看| 国产黄人亚洲片| 久久精品一区八戒影视| 精品一区二区三区蜜桃| 7777精品伊人久久久大香线蕉| 亚洲欧美综合另类在线卡通| 国产美女精品在线| 精品欧美乱码久久久久久1区2区| 日韩在线卡一卡二| 欧洲国内综合视频| 亚洲自拍偷拍九九九| 色婷婷av一区二区三区之一色屋| 国产精品久久影院| www.日本不卡| 一区视频在线播放| av激情亚洲男人天堂| 中文字幕在线观看一区二区| 白白色 亚洲乱淫| 亚洲欧美电影一区二区| 色综合久久中文综合久久牛| 国产精品国产成人国产三级| 91丨九色porny丨蝌蚪| 亚洲色图另类专区| 在线精品视频一区二区三四| 亚洲一区二区三区美女| 欧美三级在线看| 午夜精品福利一区二区蜜股av| 欧美日韩三级视频| 日韩主播视频在线| 欧美大度的电影原声| 国产一区二区不卡在线| 欧美国产精品中文字幕| 91免费精品国自产拍在线不卡| 一区二区理论电影在线观看| 91精品国产综合久久蜜臀| 久久成人免费日本黄色| 中文字幕乱码亚洲精品一区| 色婷婷久久久久swag精品| 婷婷国产在线综合| 欧美zozozo| av影院午夜一区| 午夜精品福利久久久| 久久影院视频免费| 丁香桃色午夜亚洲一区二区三区| 自拍视频在线观看一区二区| 欧美日本在线看| 国产成人超碰人人澡人人澡| 亚洲女与黑人做爰| 精品国产乱码久久久久久久久| 国产91在线看| 日本最新不卡在线| 国产精品久久夜| 欧美顶级少妇做爰| 成人爱爱电影网址| 三级影片在线观看欧美日韩一区二区| 精品国偷自产国产一区| 色综合久久久久综合99| 不卡在线视频中文字幕| 亚洲一区二区三区激情| 国产亚洲欧洲997久久综合 | 精品国产乱码久久久久久久久| 国产麻豆欧美日韩一区| 亚洲一区二区三区四区不卡| 久久丝袜美腿综合| 91麻豆精品国产91久久久资源速度| 国产精品亚洲视频| 日本美女视频一区二区| 中文字幕亚洲不卡| 久久综合一区二区| 91精品国产综合久久久久| 成人美女视频在线看| 久久99精品久久只有精品| 亚洲成人激情av| 自拍视频在线观看一区二区| 久久久激情视频| 91精品国产91热久久久做人人| av不卡在线播放| 国产精品 日产精品 欧美精品| 首页亚洲欧美制服丝腿| 亚洲精品视频一区二区| 国产色婷婷亚洲99精品小说| 日韩欧美视频一区| 777奇米四色成人影色区| 91视频免费看| 成人在线一区二区三区| 精品写真视频在线观看| 日韩精品乱码av一区二区| 一区二区高清免费观看影视大全| 国产日本一区二区| 国产日韩一级二级三级| 67194成人在线观看| 91超碰这里只有精品国产| 欧美无砖砖区免费| 欧美色中文字幕| 欧洲精品在线观看| 欧美在线|欧美| 欧美性高清videossexo| 欧美视频在线观看一区| 欧美三级一区二区| 欧美日韩一本到| 69堂精品视频| 欧美一区二区网站| 欧美精品一区二区精品网| 久久久九九九九| 国产蜜臀av在线一区二区三区| 国产日韩欧美麻豆| 亚洲国产成人自拍| 亚洲嫩草精品久久| 亚洲成av人片在线观看| 天堂va蜜桃一区二区三区漫画版| 婷婷丁香久久五月婷婷| 久久99精品一区二区三区| 国产在线精品免费| 成人av先锋影音| 在线观看亚洲一区| 欧美一区二区三区视频在线| 久久久久久久久久久黄色 | 欧美一区二区三区四区五区| 欧美成人激情免费网| 欧美激情在线观看视频免费| 中文字幕亚洲欧美在线不卡| 亚洲主播在线播放| 蜜臀99久久精品久久久久久软件| 激情综合亚洲精品| av电影在线观看不卡| 欧美精品一二三区| 国产午夜亚洲精品羞羞网站| 亚洲精品日产精品乱码不卡| 日本午夜一区二区| 成人精品高清在线| 欧美日韩视频在线第一区 | 午夜影视日本亚洲欧洲精品| 日韩av在线免费观看不卡| 国产精品综合久久| 欧洲国内综合视频| 久久先锋影音av| 亚洲欧美日韩在线| 久久99久久99| 91成人免费电影| 精品盗摄一区二区三区| 日韩理论电影院| 久久99深爱久久99精品| 91看片淫黄大片一级| 精品奇米国产一区二区三区| 亚洲免费电影在线| 国内精品免费在线观看| 欧美日韩一区三区| 国产欧美一区二区精品性色| 午夜视黄欧洲亚洲| 成人av一区二区三区| 欧美成人综合网站| 樱桃视频在线观看一区| 国产综合久久久久久久久久久久| 欧美少妇bbb| 综合久久久久综合| 国产成人精品亚洲日本在线桃色 | 亚洲日韩欧美一区二区在线| 免费av成人在线| 91九色02白丝porn| 国产精品妹子av| 韩国理伦片一区二区三区在线播放| 91小视频免费看| 国产精品久久久久久久久搜平片| 九色porny丨国产精品| 在线免费一区三区| 综合av第一页| av影院午夜一区| 国产性色一区二区| 精品一区二区三区免费播放| 欧美精品v日韩精品v韩国精品v| 亚洲免费观看高清完整版在线观看熊| 国产成人自拍网| 久久综合色天天久久综合图片| 奇米色777欧美一区二区| 欧美日本乱大交xxxxx| 亚洲最快最全在线视频| 91久久精品一区二区三区| 裸体在线国模精品偷拍| 欧美午夜影院一区| 亚洲综合偷拍欧美一区色| 色老头久久综合| 亚洲影视在线播放| 欧美在线|欧美| 亚洲午夜电影网|