qtewin.cpp
来自「远程桌面登陆软件 用rdesktop 但不基于Xwindows 可基于(nano」· C++ 代码 · 共 2,176 行 · 第 1/5 页
CPP
2,176 行
/* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. User interface services - QT Emb System Copyright (C) Jay Sorg 2004-2005 This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifdef SHARP #include <qpe/qpeapplication.h>#else #include <qapplication.h>#endif//#include <qcursor.h>#include <qmainwindow.h>#include <qwidget.h>#include <qpainter.h>#include <qimage.h>#include <qsocketnotifier.h>#include <qscrollview.h>#include <qmessagebox.h>#include <qpushbutton.h>#include <qlineedit.h>#include <qcombobox.h>#include <qlabel.h>#include <qfile.h>#include <qcheckbox.h>#include <qpopupmenu.h>#include <stdlib.h>#include <stdarg.h> // va_list va_start va_end#include <unistd.h> // gethostname#include <pwd.h> // getpwuid#include "../rdesktop.h"#include "qtewin.h"//QTR-JP#include <qbitmap.h>#include <qclipboard.h>#include <qcolor.h>#ifdef SHARP #include <qcopchannel_qws.h>#endif#include <qevent.h>#include <qlayout.h>#include <qpixmap.h>#include <qbrush.h>#include <qtabwidget.h>#include <qtextcodec.h>#include <errno.h>#include <fcntl.h>#include <langinfo.h>#include <locale.h>#include <time.h>#include <sys/select.h>#include <sys/time.h>#include <sys/stat.h>//QTR-JPextern int g_tcp_port_rdp;BOOL g_encryption = True;int g_bitmap_cache = 1;int g_bitmap_cache_persist_enable = 0;int g_bitmap_cache_precache = 1;int g_use_rdp5 = 1;int g_desktop_save = 1;BOOL g_bitmap_compression = True;int g_polygon_ellipse_orders = 0;uint32 g_rdp5_performanceflags = RDP5_DISABLE_NOTHING;int g_console_session = 0;//int g_keylayout = 0x409; /* Defaults to US keyboard layout *///int g_keyboard_type = 0x4;>-/* Defaults to US keyboard layout *///int g_keyboard_subtype = 0x0;>--/* Defaults to US keyboard layout *///int g_keyboard_functionkeys = 0xc;>-/* Defaults to US keyboard layout */int g_width = 640;int g_height = 480;//int g_server_bpp = 8;int g_server_depth = 8;char g_hostname[16] = "";char g_username[100] = "";#ifdef WITH_RDPSNDextern int g_dsp_busy;extern int g_dsp_fd;int g_rdpsnd = 0;static QSocketNotifier* g_SoundNotifier = 0;#endif//static int g_client_width = 640;//static int g_client_height = 480;uint32 g_flags = RDP_LOGON_NORMAL;char g_server[64] = "";char g_domain[16] = "";char g_password[16] = "";char g_shell[128] = "";char g_directory[32] = "";static int g_fullscreen = 0;static int g_global_sock = 0;static int g_deactivated = 0;static uint32 g_ext_disc_reason = 0;static QSocketNotifier* g_SocketNotifier = 0;#ifdef SHARP static QPEApplication * g_App = 0;#else static QApplication* g_App = 0;#endifstatic QMyMainWindow * g_MW = 0;static QMyScrollView * g_SV = 0;//static struct QColorMap * g_CM = 0;//static uint8 * g_BS = 0; /* the screen data *///static int g_clipx = 0;//static int g_clipy = 0;//static int g_clipcx = 0;//static int g_clipcy = 0;/* Session Directory redirection */BOOL g_redirect = False;char g_redirect_server[64];char g_redirect_domain[16];char g_redirect_password[64];char g_redirect_username[64];char g_redirect_cookie[128];uint32 g_redirect_flags = 0;//QTR-JP//int g_polygon_ellipse_orders = 1;BOOL packet_encryption = True;int g_bitmap_cache_persist_enableSD = 0;int g_bitmap_cache_persist_enableHDD = 0;int g_keylayout = 0x0;int g_keyboard_type = 0x0;int g_keyboard_subtype = 0x0;int g_keyboard_functionkeys = 0x0;int g_key = 0;int g_Ctrl = 0;int g_OK = 0;int g_LeftHand =0;int g_dragscroll = 0;int g_scrollpixel = 10;BOOL g_Clip = False;char g_codepage[16] = "";extern RDPDR_DEVICE g_rdpdr_device[];extern uint32 g_num_devices;struct QColorMap{ uint32 RGBColors[256]; int NumColors;};static struct QColorMap * g_CM = 0;static QPixmap * g_BS = 0;static QPixmap * g_DS = 0;static QPainter * g_P1 = 0;static QPainter * g_P2 = 0;static QColor g_Color1;static QColor g_Color2;static QRegion * g_ClipRect;static Qt::RasterOp g_OpCodes[16] = { Qt::ClearROP, // BLACKNESS 0 //not available Qt/Embedded Qt::NorROP, // NOTSRCERASE DSon //not available Qt/Embedded Qt::NotAndROP, // DSna //not available Qt/Embedded Qt::NotCopyROP, // NOTSRCCOPY Sn //not available Qt/Embedded Qt::AndNotROP, // SRCERASE SDna //not available Qt/Embedded Qt::NotROP, // DSTINVERT Dn //ok bug? Qt::XorROP, // SRCINVERT DSx //ok Qt::NandROP, // DSan //not available Qt/Embedded Qt::AndROP, // SRCAND DSa //not available Qt/Embedded Qt::NotXorROP, // DSxn //not available Qt/Embedded Qt::NopROP, // D //not available Qt/Embedded Qt::NotOrROP, // MERGEPAINT DSno //not available Qt/Embedded Qt::CopyROP, // SRCCOPY S //ok Qt::OrNotROP, // SDno //not available Qt/Embedded Qt::OrROP, // SRCPAINT DSo //not available Qt/Embedded Qt::SetROP // WHITENESS 1 //not available Qt/Embedded};#define QTRVER "qtrdesktop-jp 1.4.1-2.0test"//QTR-JP/******************************************************************************/void* operator new[]( size_t size ){ return malloc( size );}void* operator new( size_t size ){ return malloc( size );}void operator delete[]( void *p ){ free( p );}void operator delete[]( void *p, size_t size ){ free( p );}void operator delete( void *p ){ free( p );}void operator delete( void *p, size_t size ){ free( p );}/******************************************************************************/uint32 Color15to32(uint32 InColor){ uint32 r, g, b; r = (InColor & 0x7c00) >> 10; r = (r * 0xff) / 0x1f; g = (InColor & 0x03e0) >> 5; g = (g * 0xff) / 0x1f; b = (InColor & 0x001f); b = (b * 0xff) / 0x1f; return (r << 16) | (g << 8) | b;}//*****************************************************************************uint32 Color16to32(uint32 InColor){ uint32 r, g, b; r = (InColor & 0xf800) >> 11; r = (r * 0xff) / 0x1f; g = (InColor & 0x07e0) >> 5; g = (g * 0xff) / 0x3f; b = (InColor & 0x001f); b = (b * 0xff) / 0x1f; return (r << 16) | (g << 8) | b;}//*****************************************************************************uint32 Color24to32(uint32 InColor){ return ((InColor & 0x00ff0000) >> 16) | ((InColor & 0x000000ff) << 16) | (InColor & 0x0000ff00);}//*****************************************************************************void SetColorx(QColor * Color, uint32 InColor){ switch (g_server_depth) { case 8: if (g_CM == NULL || InColor > 255) { Color->setRgb(0); return; } Color->setRgb(g_CM->RGBColors[InColor]); break; case 15: Color->setRgb(Color15to32(InColor)); break; case 16: Color->setRgb(Color16to32(InColor)); break; case 24: Color->setRgb(Color24to32(InColor)); break; default: Color->setRgb(0); }}/******************************************************************************/void SetOpCode(int opcode){ if (opcode >= 0 && opcode < 16) { Qt::RasterOp op = g_OpCodes[opcode]; if (op != Qt::CopyROP) { g_P1->setRasterOp(op); g_P2->setRasterOp(op); } }}/******************************************************************************///void SetOpCode(int opcode)QPixmap * SetOpCode2(int opcode, int cx, int cy, int x, int y, QImage * src_image){ //test int i, j; QPixmap * Pixmap; QImage *dest_image; QRgb *dest_ptr; QRgb *src_ptr; Pixmap = new QPixmap(cx,cy); dest_image = new QImage(cx,cy,32); bitBlt(Pixmap,0,0,g_BS,x,y,cx,cy,Qt::CopyROP,true); *dest_image = *Pixmap; switch (opcode){ case 0: //Qt::ClearROP break; case 1: //Qt::NorROP break; case 2: //Qt::NotAndROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); src_ptr = (QRgb*)src_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr = ~*src_ptr & *dest_ptr; dest_ptr++; src_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 3: //Qt::NotCopyROP break; case 4: //AndNotROP break; case 5: //Qt::NotROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr = ~*dest_ptr; dest_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 6: //Qt::XorROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); src_ptr = (QRgb*)src_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr ^= *src_ptr; dest_ptr++; src_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 7: //Qt::NandROP break; case 8: //Qt::AndROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); src_ptr = (QRgb*)src_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr &= *src_ptr; dest_ptr++; src_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 9: //Qt::NotXorROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); src_ptr = (QRgb*)src_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr |= *src_ptr; dest_ptr++; src_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 10: //Qt::NopROP break; case 11: //Qt::NotOrROP break; //case 12: //Qt::CopyROP //break; case 13: //Qt::OrNotROP break; case 14: //Qt::OrROP for (i = 0; i < cy; i++) { dest_ptr = (QRgb*)dest_image->scanLine(i); src_ptr = (QRgb*)src_image->scanLine(i); for (j = 0; j < cx; j++) { *dest_ptr |= *src_ptr; dest_ptr++; src_ptr++; } } *Pixmap = *dest_image; delete dest_image; break; case 15: //Qt::SetROP break; } return Pixmap;}/******************************************************************************/void ResetOpCode(int opcode){ //if (opcode != 12) //{ g_P1->setRasterOp(Qt::CopyROP); g_P2->setRasterOp(Qt::CopyROP); //} /* if (opcode >= 0 && opcode < 16) { Qt::RasterOp op = g_OpCodes[opcode]; if (op != Qt::CopyROP) { g_P1->setRasterOp(Qt::CopyROP); g_P2->setRasterOp(Qt::CopyROP); } } */}/******************************************************************************/BOOL str_startswith(const char *s, const char *prefix){ return (strncmp(s, prefix, strlen(prefix)) == 0);}/******************************************************************************/char * next_arg(char *src, char needle){ char *nextval; char *p; char *mvp = 0; /* EOS */ if (*src == (char) 0x00)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?