Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
DRC | c5dc038 | 2011-05-13 21:42:14 +0000 | [diff] [blame] | 19 | package com.tigervnc.rfb; |
Constantin Kaplinsky | 90d8a50 | 2008-04-14 09:45:50 +0000 | [diff] [blame] | 20 | |
DRC | c5dc038 | 2011-05-13 21:42:14 +0000 | [diff] [blame] | 21 | import com.tigervnc.rdr.*; |
Brian Hinz | e768141 | 2011-05-17 21:00:34 +0000 | [diff] [blame] | 22 | import java.util.*; |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 23 | |
DRC | c5dc038 | 2011-05-13 21:42:14 +0000 | [diff] [blame] | 24 | public class CMsgWriterV3 extends CMsgWriter { |
| 25 | |
| 26 | public CMsgWriterV3(ConnParams cp_, OutStream os_) { super(cp_, os_); } |
| 27 | |
| 28 | public void writeClientInit(boolean shared) { |
| 29 | os.writeU8(shared?1:0); |
| 30 | endMsg(); |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 31 | } |
| 32 | |
DRC | c5dc038 | 2011-05-13 21:42:14 +0000 | [diff] [blame] | 33 | public void startMsg(int type) { |
| 34 | os.writeU8(type); |
| 35 | } |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 36 | |
DRC | c5dc038 | 2011-05-13 21:42:14 +0000 | [diff] [blame] | 37 | public void endMsg() { |
| 38 | os.flush(); |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 39 | } |
Brian Hinz | e768141 | 2011-05-17 21:00:34 +0000 | [diff] [blame] | 40 | |
| 41 | public void writeSetDesktopSize(int width, int height, |
| 42 | ScreenSet layout) |
| 43 | { |
| 44 | if (!cp.supportsSetDesktopSize) |
| 45 | throw new Exception("Server does not support SetDesktopSize"); |
| 46 | |
| 47 | startMsg(MsgTypes.msgTypeSetDesktopSize); |
| 48 | os.pad(1); |
| 49 | |
| 50 | os.writeU16(width); |
| 51 | os.writeU16(height); |
| 52 | |
| 53 | os.writeU8(layout.num_screens()); |
| 54 | os.pad(1); |
| 55 | |
| 56 | for (Iterator iter = layout.screens.iterator(); iter.hasNext(); ) { |
| 57 | Screen refScreen = (Screen)iter.next(); |
| 58 | os.writeU32(refScreen.id); |
| 59 | os.writeU16(refScreen.dimensions.tl.x); |
| 60 | os.writeU16(refScreen.dimensions.tl.y); |
| 61 | os.writeU16(refScreen.dimensions.width()); |
| 62 | os.writeU16(refScreen.dimensions.height()); |
| 63 | os.writeU32(refScreen.flags); |
| 64 | } |
| 65 | |
| 66 | endMsg(); |
| 67 | } |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 68 | } |