// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
// 
//     Locale getLocale();
// 
//     List<KeyDesc> getKeycodes();
// 
//     /**
//      * Key descriptor.
//      */
//     class KeyDesc {
// 
//         int keyval;
//         String keyname = "";
//         int keycode;
//         int group;
//         int level;
// 
//         public KeyDesc(int keycode, String keyname) {
//             this.keyval = keycode;
//             this.keycode = keycode;
//             this.keyname = keyname;
//         }
// 
//         public List<Object> toList() {
//             final List<Object> list = new ArrayList<>(5);
//             list.add(keyval);
//             list.add(keyname);
//             list.add(keycode);
//             list.add(group);
//             list.add(level);
//             return list;
//         }
// 
//         @Override
//         public String toString() {
//             return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
//         }
//     }
// }
// 
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
// 
//     int keyval;
//     String keyname = "";
//     int keycode;
//     int group;
//     int level;
// 
//     public KeyDesc(int keycode, String keyname) {
//         this.keyval = keycode;
//         this.keycode = keycode;
//         this.keyname = keyname;
//     }
// 
//     public List<Object> toList() {
//         final List<Object> list = new ArrayList<>(5);
//         list.add(keyval);
//         list.add(keyname);
//         list.add(keycode);
//         list.add(group);
//         list.add(level);
//         return list;
//     }
// 
//     @Override
//     public String toString() {
//         return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
//     }
// }
// 
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
//     rgb24,
//     rgb32,
//     premult_argb32,
//     jpeg,
//     png,
//     pngP("png/P"),
//     pngL("png/L");
// 
//     private static final PictureEncoding[] values = values();
//     private final String code;
// 
//     PictureEncoding() {
//         code = name();
//     }
// 
//     PictureEncoding(String code) {
//         this.code = code;
//     }
// 
//     @Override
//     public String toString() {
//         return code;
//     }
// 
//     public static PictureEncoding decode(String code) {
//         for (PictureEncoding encoding : values) {
//             if (encoding.code.equals(code)) {
//                 return encoding;
//             }
//         }
//         throw new IllegalArgumentException("Unsupported picture encoding: " + code);
//     }
// 
//     public static String[] toString(PictureEncoding[] encodings) {
//         final String[] array = new String[encodings.length];
//         for (int i = 0; i < encodings.length; ++i) {
//             array[i] = encodings[i].toString();
//         }
//         return array;
//     }
// 
// }
// 
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
// 
// 	public static final String VERSION = "0.15.0";
// 	public static final String MIN_VERSION = "0.5";
// }


import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;
/*
 * Copyright (C) 2020 Jakub Ksiezniak
 *
 *     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.,
 *     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package xpra.protocol.packets;




public class HelloRequest extends xpra.protocol.IOPacket {

    private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};

	private final Map<String, Object> caps = new LinkedHashMap<>();

	public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) {
		super("hello");
		caps.put("version", ProtocolConstants.VERSION);

		final int[] screenDims = new int[] { screenWidth, screenHeight };
		caps.put("desktop_size", screenDims);
		caps.put("dpi", 96);
//		caps.put("dpi.x", 0);
//		caps.put("dpi.y", 0);
		caps.put("client_type", "Java");
		caps.put("screen_sizes", new int[][] { screenDims });
		caps.put("encodings", PictureEncoding.toString(encodings));
		caps.put("encodings.core", PictureEncoding.toString(encodings));
		caps.put("encodings.window-icon", new String[] {PictureEncoding.png.toString()});
		caps.put("encodings.cursor", new String[] {PictureEncoding.png.toString()});
        caps.put("encoding.icons.max_size", CAPS_MAX_ICON_SIZE);

		caps.put("zlib", true);
		caps.put("clipboard", false);
		caps.put("notifications", true);
		caps.put("cursors", true);
		caps.put("named_cursors", true);
		caps.put("bell", true);
		caps.put("bencode", true);
		caps.put("rencode", true);
		caps.put("chunked_compression", true);
		if (defaultEncoding != null) {
			caps.put("encoding", defaultEncoding.toString());
			if (PictureEncoding.jpeg.equals(defaultEncoding)) {
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
// 
//     Locale getLocale();
// 
//     List<KeyDesc> getKeycodes();
// 
//     /**
//      * Key descriptor.
//      */
//     class KeyDesc {
// 
//         int keyval;
//         String keyname = "";
//         int keycode;
//         int group;
//         int level;
// 
//         public KeyDesc(int keycode, String keyname) {
//             this.keyval = keycode;
//             this.keycode = keycode;
//             this.keyname = keyname;
//         }
// 
//         public List<Object> toList() {
//             final List<Object> list = new ArrayList<>(5);
//             list.add(keyval);
//             list.add(keyname);
//             list.add(keycode);
//             list.add(group);
//             list.add(level);
//             return list;
//         }
// 
//         @Override
//         public String toString() {
//             return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
//         }
//     }
// }
// 
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
// 
//     int keyval;
//     String keyname = "";
//     int keycode;
//     int group;
//     int level;
// 
//     public KeyDesc(int keycode, String keyname) {
//         this.keyval = keycode;
//         this.keycode = keycode;
//         this.keyname = keyname;
//     }
// 
//     public List<Object> toList() {
//         final List<Object> list = new ArrayList<>(5);
//         list.add(keyval);
//         list.add(keyname);
//         list.add(keycode);
//         list.add(group);
//         list.add(level);
//         return list;
//     }
// 
//     @Override
//     public String toString() {
//         return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
//     }
// }
// 
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
//     rgb24,
//     rgb32,
//     premult_argb32,
//     jpeg,
//     png,
//     pngP("png/P"),
//     pngL("png/L");
// 
//     private static final PictureEncoding[] values = values();
//     private final String code;
// 
//     PictureEncoding() {
//         code = name();
//     }
// 
//     PictureEncoding(String code) {
//         this.code = code;
//     }
// 
//     @Override
//     public String toString() {
//         return code;
//     }
// 
//     public static PictureEncoding decode(String code) {
//         for (PictureEncoding encoding : values) {
//             if (encoding.code.equals(code)) {
//                 return encoding;
//             }
//         }
//         throw new IllegalArgumentException("Unsupported picture encoding: " + code);
//     }
// 
//     public static String[] toString(PictureEncoding[] encodings) {
//         final String[] array = new String[encodings.length];
//         for (int i = 0; i < encodings.length; ++i) {
//             array[i] = encodings[i].toString();
//         }
//         return array;
//     }
// 
// }
// 
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
// 
// 	public static final String VERSION = "0.15.0";
// 	public static final String MIN_VERSION = "0.5";
// }


// Path: xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;

/*
 * Copyright (C) 2020 Jakub Ksiezniak
 *
 *     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.,
 *     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package xpra.protocol.packets;




public class HelloRequest extends xpra.protocol.IOPacket {

    private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};

	private final Map<String, Object> caps = new LinkedHashMap<>();

	public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) {
		super("hello");
		caps.put("version", ProtocolConstants.VERSION);

		final int[] screenDims = new int[] { screenWidth, screenHeight };
		caps.put("desktop_size", screenDims);
		caps.put("dpi", 96);
//		caps.put("dpi.x", 0);
//		caps.put("dpi.y", 0);
		caps.put("client_type", "Java");
		caps.put("screen_sizes", new int[][] { screenDims });
		caps.put("encodings", PictureEncoding.toString(encodings));
		caps.put("encodings.core", PictureEncoding.toString(encodings));
		caps.put("encodings.window-icon", new String[] {PictureEncoding.png.toString()});
		caps.put("encodings.cursor", new String[] {PictureEncoding.png.toString()});
        caps.put("encoding.icons.max_size", CAPS_MAX_ICON_SIZE);

		caps.put("zlib", true);
		caps.put("clipboard", false);
		caps.put("notifications", true);
		caps.put("cursors", true);
		caps.put("named_cursors", true);
		caps.put("bell", true);
		caps.put("bencode", true);
		caps.put("rencode", true);
		caps.put("chunked_compression", true);
		if (defaultEncoding != null) {
			caps.put("encoding", defaultEncoding.toString());
			if (PictureEncoding.jpeg.equals(defaultEncoding)) {
				caps.put("jpeg", 40);