osd-contiki/apps/vnc/vnc-viewer.h

327 lines
7.2 KiB
C
Raw Normal View History

2006-06-18 01:08:35 +02:00
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki VNC client.
*
*
*/
#ifndef VNC_VIEWER_H_
#define VNC_VIEWER_H_
2006-06-18 01:08:35 +02:00
struct vnc_viewer_state;
/*typedef unsigned long uint32_t;*/
2006-06-18 01:08:35 +02:00
void vnc_viewer_init(void);
void vnc_viewer_appcall(void *nullptr);
void vnc_viewer_connect(uint16_t *server, uint8_t display);
2006-06-18 01:08:35 +02:00
void vnc_viewer_close(void);
/* Callback: redraws the VNC viewer bitmap area. */
void vnc_viewer_refresh(void);
#define VNC_POINTER_EVENT RFB_POINTER_EVENT
#define VNC_KEY_EVENT RFB_KEY_EVENT
#define VNC_UPDATERQ_EVENT 7
#define VNC_VIEWER_POST_POINTER_EVENT(x, y, button) \
vnc_viewer_post_event(VNC_POINTER_EVENT, button, x, y, 0)
#define VNC_VIEWER_POST_KEY_EVENT(key) \
vnc_viewer_post_event(VNC_KEY_EVENT, key, 0, 0, 0)
#define VNC_VIEWER_POST_UPDATERQ_EVENT(x1,y1,x2,y2) \
vnc_viewer_post_event(VNC_UPDATERQ_EVENT, x1, y1, x2, y2)
void vnc_viewer_post_event(uint8_t event,
uint16_t data1, uint16_t data2,
uint16_t data3, uint16_t data4);
2006-06-18 01:08:35 +02:00
/* UIP_APPCALL: the name of the application function. This function
must return void and take no arguments (i.e., C type "void
appfunc(void)"). */
#ifndef UIP_APPCALL
#define UIP_APPCALL vnc_viewer_app
#endif
struct vnc_key_event {
uint8_t down;
uint16_t key;
2006-06-18 01:08:35 +02:00
};
struct vnc_pointer_event {
uint8_t buttonmask;
uint16_t x, y;
2006-06-18 01:08:35 +02:00
};
struct vnc_updaterq_event {
uint16_t x, y;
uint16_t w, h;
2006-06-18 01:08:35 +02:00
};
struct vnc_event {
uint8_t type;
2006-06-18 01:08:35 +02:00
union {
struct vnc_key_event key;
struct vnc_pointer_event ptr;
struct vnc_updaterq_event urq;
} ev;
};
enum vnc_sendmsg {
VNC_SEND_NONE,
VNC_SEND_VERSION,
VNC_SEND_AUTH,
VNC_SEND_CINIT,
VNC_SEND_PFMT,
VNC_SEND_ENCODINGS,
VNC_SEND_UPDATERQ,
VNC_SEND_UPDATERQ_INC,
VNC_SEND_EVENTS,
};
enum vnc_waitmsg {
VNC_WAIT_NONE,
VNC_WAIT_VERSION,
VNC_WAIT_AUTH,
VNC_WAIT_AUTH_RESPONSE,
VNC_WAIT_SINIT,
VNC_WAIT_UPDATE,
VNC_WAIT_UPDATE_RECT,
};
enum vnc_rectstate {
VNC_RECTSTATE_NONE,
VNC_RECTSTATE_RAW,
VNC_RECTSTATE_RRE,
};
struct vnc_viewer_state {
uint8_t close;
uint16_t w, h;
2006-06-18 01:08:35 +02:00
uint8_t sendmsg;
2006-06-18 01:08:35 +02:00
uint8_t waitmsg;
2006-06-18 01:08:35 +02:00
uint16_t rectsleft;
2006-06-18 01:08:35 +02:00
uint8_t rectstate;
uint32_t rectstateleft;
uint16_t rectstatex, rectstatey;
uint16_t rectstateh, rectstatew;
uint16_t rectstatex0, rectstatey0;
uint16_t rectstatex2, rectstatey2;
2006-06-18 01:08:35 +02:00
uint16_t eventptr_acked;
uint16_t eventptr_unacked;
uint16_t eventptr_next;
2006-06-18 01:08:35 +02:00
#define VNC_EVENTQUEUE_SIZE 32
struct vnc_event event_queue[VNC_EVENTQUEUE_SIZE];
uint16_t bufferleft;
uint16_t buffersize;
2006-06-18 01:08:35 +02:00
#define VNC_BUFFERSIZE 64
uint8_t buffer[VNC_BUFFERSIZE];
2006-06-18 01:08:35 +02:00
};
Support for z80(sdcc) port. In order to support, some core modules are modified as follows: core/sys/dsc.h - If CTK_CONF_ICONS is diabled, the whole icon-related code is disabled. - DSC_HEADER is changed to remove extra semicolon. core/sys/process.h - process_data_t is expressed by void* in signatures (known bug on sdcc). core/sys/autostart.h - autostart_processes is changed to remove extra semicolon. core/sys/cc.h - CC_CONF_ASSIGN_AGGREGATE is introduced. - CC_CONF_INC_CAST_POINTER is introduced, a workaround of a kind of sdcc bug for an increment. core/net/hc.c core/net/uip_arp.c core/net/uaodv.c - Aggregation assignments are changed to uip_ipaddr_copy. core/net/psock.c core/net/uipbuf.c core/net/dhcpc.c apps/shell/shell.c core/ctk/vnc-server.c core/ctk/vnc-out.c - "register" keyword in a signature cannot be used in sdcc, CC_REGISTER_ARG is used instead. core/net/uip-over-mesh.c - An extra semicolon is removed. apps/dhcp/dhcp-dsc.c apps/shell/shell-dsc. apps/ftp/ftp-dsc.c apps/process-list/process-list-dsc.c apps/email/email-dsc.c apps/webserver/webserver-dsc.c apps/vnc/vnc-dsc.c apps/vnc/vnc-viewer.h apps/webbrowser/www-dsc.c apps/about/about-dsc.c apps/irc/irc-dsc.c apps/telnet/telnet-dsc.c apps/telnetd/telnetd-dsc.c apps/netconf/netconf-dsc.c apps/directory/directory-dsc.c pps/calc/calc-dsc.c - Modify an extern type to a real declaration, which is static to prevent a compile error. core/net/mac/xmac.c - Variables cannot be defined in a head of block on sdcc. core/ctk/ctk.h core/ctk/ctk.c apps/program-handler/program-handler.c - If CTK_CONF_ICONS is diabled, the whole icon-related code is disabled. Makefile.include - Add a set of configuration for an assembler. - $(CLEAN) variable is introduced for customized cleanup. apps/process-list/process-list.c - PROCESSLIST_CONF_HEIGHT is introduced to address smaller screen size. core/lib/ctk-filedialog.c - FILES_CONF_HEIGHT is introduced to address smaller screen size. - "register" keyword in a signature cannot be used in sdcc, CC_REGISTER_ARG is used instead. apps/vnc/vnc-viewer.c - A cast is added to prevent a compile error. - "register" keyword in a signature cannot be used in sdcc, CC_REGISTER_ARG is used instead. apps/webbrowser/webclient.c - CC_CONF_INC_CAST_POINTER is introduced, a workaround of a kind of sdcc bug for an increment. core/loader/elfloader.c - A cast is added to prevent a compile error. core/net/rime/rimeaddr.c - An initialization is added to prevent a compile error. core/net/rime/rudolph0.c - NULL is changed to 0, because NULL causes a compile error. core/net/rime/route-discovery.c - Add an argument to match the definition of nf_callbacks. cpu/z80/strcasecmp.h cpu/z80/strcasecmp.c cpu/z80/contiki-sdcc-conf.h cpu/z80/mtarch.c cpu/z80/mtarch.h cpu/z80/Makefile.z80 - New files to make compilation availble on sdcc. - Added support for multithreading.
2007-08-30 16:39:16 +02:00
extern static struct vnc_viewer_state vnc_viewer_state;
2006-06-18 01:08:35 +02:00
/* Definitions of the RFB (Remote Frame Buffer) protocol
structures and constants. */
#include "net/uipopt.h"
/* Generic rectangle - x, y coordinates, width and height. */
struct rfb_rect {
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
2006-06-18 01:08:35 +02:00
};
/* Pixel format definition. */
struct rfb_pixel_format {
uint8_t bps; /* Bits per pixel: 8, 16 or 32. */
uint8_t depth; /* Color depth: 8-32 */
uint8_t endian; /* 1 - big endian (motorola), 0 - little endian
2006-06-18 01:08:35 +02:00
(x86) */
uint8_t truecolor; /* 1 - true color is used, 0 - true color is not used. */
2006-06-18 01:08:35 +02:00
/* The following fields are only used if true color is used. */
uint16_t red_max, green_max, blue_max;
uint8_t red_shift, green_shift, blue_shift;
uint8_t pad1;
uint16_t pad2;
2006-06-18 01:08:35 +02:00
};
/* RFB authentication constants. */
#define RFB_AUTH_FAILED 0
#define RFB_AUTH_NONE 1
#define RFB_AUTH_VNC 2
#define RFB_VNC_AUTH_OK 0
#define RFB_VNC_AUTH_FAILED 1
#define RFB_VNC_AUTH_TOOMANY 2
/* RFB message types. */
/* From server to client: */
#define RFB_FB_UPDATE 0
#define RFB_SET_COLORMAP_ENTRIES 1
#define RFB_BELL 2
#define RFB_SERVER_CUT_TEXT 3
/* From client to server. */
#define RFB_SET_PIXEL_FORMAT 0
#define RFB_FIX_COLORMAP_ENTRIES 1
#define RFB_SET_ENCODINGS 2
#define RFB_FB_UPDATE_REQ 3
#define RFB_KEY_EVENT 4
#define RFB_POINTER_EVENT 5
#define RFB_CLIENT_CUT_TEXT 6
/* Encoding types. */
#define RFB_ENC_RAW 0
#define RFB_ENC_COPYRECT 1
#define RFB_ENC_RRE 2
#define RFB_ENC_CORRE 3
#define RFB_ENC_HEXTILE 4
/* Message definitions. */
/* Server to client messages. */
struct rfb_server_init {
uint16_t width;
uint16_t height;
2006-06-18 01:08:35 +02:00
struct rfb_pixel_format format;
uint8_t namelength[4];
2006-06-18 01:08:35 +02:00
/* Followed by name. */
};
struct rfb_fb_update {
uint8_t type;
uint8_t pad;
uint16_t rects; /* Number of rectanges (struct rfb_fb_update_rect_hdr +
2006-06-18 01:08:35 +02:00
data) that follows. */
};
struct rfb_fb_update_rect_hdr {
struct rfb_rect rect;
uint8_t encoding[4];
2006-06-18 01:08:35 +02:00
};
struct rfb_copy_rect {
uint16_t srcx;
uint16_t srcy;
2006-06-18 01:08:35 +02:00
};
struct rfb_rre_hdr {
uint16_t subrects[2]; /* Number of subrectangles (struct
2006-06-18 01:08:35 +02:00
rfb_rre_subrect) to follow. */
uint8_t bgpixel;
2006-06-18 01:08:35 +02:00
};
struct rfb_rre_subrect {
uint8_t pixel;
2006-06-18 01:08:35 +02:00
struct rfb_rect rect;
};
struct rfb_corre_rect {
uint8_t x;
uint8_t y;
uint8_t w;
uint8_t h;
2006-06-18 01:08:35 +02:00
};
/* Client to server messages. */
struct rfb_set_pixel_format {
uint8_t type;
uint8_t pad;
uint16_t pad2;
2006-06-18 01:08:35 +02:00
struct rfb_pixel_format format;
};
struct rfb_fix_colormap_entries {
uint8_t type;
uint8_t pad;
uint16_t firstcolor;
uint16_t colors;
2006-06-18 01:08:35 +02:00
};
struct rfb_set_encodings {
uint8_t type;
uint8_t pad;
uint16_t encodings;
2006-06-18 01:08:35 +02:00
};
struct rfb_fb_update_request {
uint8_t type;
uint8_t incremental;
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
2006-06-18 01:08:35 +02:00
};
struct rfb_key_event {
uint8_t type;
uint8_t down;
uint16_t pad;
uint8_t key[4];
2006-06-18 01:08:35 +02:00
};
#define RFB_BUTTON_MASK1 1
#define RFB_BUTTON_MASK2 2
#define RFB_BUTTON_MASK3 4
struct rfb_pointer_event {
uint8_t type;
uint8_t buttonmask;
uint16_t x;
uint16_t y;
2006-06-18 01:08:35 +02:00
};
#endif /* VNC_VIEWER_H_ */