vnc.c File Reference

Manages VNC server and screens. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <pthread.h>
#include <rfb/rfb.h>
#include "scale.h"
#include "timeutil.h"
#include "execsh.h"
#include "lang.h"
#include "display.h"
#include "cover.h"
#include "vnc.h"
#include "img.h"
#include "keys.h"
#include "xmlint.h"
#include "theme.h"

Include dependency graph for vnc.c:


Data Structures

struct  screen_data
 Data of a VNC screen. More...
struct  client_data
 Data of a VNC client. More...

Defines

#define VNC_JAVA_CLASSES_DIR   "/opt/veronica/classes"
#define VNC_MOUSE_BT_LEFT   1
#define VNC_MOUSE_BT_MIDDLE   2
#define VNC_MOUSE_BT_RIGHT   4
#define VNC_MOUSE_WHEEL_UP   8
#define VNC_MOUSE_WHEEL_DOWN   16
#define VNC_HALT_DELAY_SEC   2.0f
#define VNC_COVER_LOOKUP_MSEC   1000
#define VNC_DEFER_UPDATE_USEC   10000
#define VNC_COLOR_BPP   4
#define VNC_CURSOR_WIDTH   11
#define VNC_CURSOR_HEIGHT   17

Functions

static void vnc_client_gone (rfbClientPtr client_ctx)
static enum rfbNewClientAction vnc_new_client (rfbClientPtr client_ctx)
static int vnc_check_ptr_over_btn_region (struct theme_button *button, int x, int y)
static int vnc_check_ptr_over_region (int x1, int y1, int x2, int y2, int x, int y)
static int vnc_check_ptr_transparency (struct img_bitmap *bitmap, int x, int y)
static void vnc_check_screensaver ()
static void vnc_blit_button (struct theme *theme, struct theme_button *button, rfbScreenInfoPtr screen)
static void vnc_check_button_events (struct theme_button *button, int button_mask, rfbClientPtr client_ctx)
static void vnc_check_nonbutton_events (int button_mask, rfbClientPtr client_ctx)
static void vnc_check_wheel_events (int button_mask, rfbClientPtr client_ctx)
static void vnc_do_ptr (int button_mask, int x, int y, rfbClientPtr client_ctx)
static void vnc_do_key (rfbBool down, rfbKeySym key, rfbClientPtr client_ctx)
static rfbScreenInfoPtr vnc_init_screen (int argc, char **argv, struct config *config, int index)
static void vnc_update_display_region (rfbScreenInfoPtr screen, unsigned char *display_buffer, int x1, int y1, int x2, int y2)
static void vnc_update_cover (rfbScreenInfoPtr screen, struct img_bitmap *cover)
static void vnc_cleanup_screen (rfbScreenInfoPtr screen)
void * vnc_process_events (void *arg)
static void vnc_termination_handler (int sig)
void vnc_startup (int argc, char **argv, struct config *config)

Variables

static char x_cursor []
static int keep_going = 1
static int signal_caught = 0
static int screensaver_mode = 0

Detailed Description

Accomplishes the following tasks:

Define Documentation

#define VNC_JAVA_CLASSES_DIR   "/opt/veronica/classes"

Java classes directory.

#define VNC_MOUSE_BT_LEFT   1

Bitmask of left mouse button (see vnc_do_ptr).

#define VNC_MOUSE_BT_MIDDLE   2

Bitmask of middle mouse button (see vnc_do_ptr).

#define VNC_MOUSE_BT_RIGHT   4

Bitmask of right mouse button (see vnc_do_ptr).

#define VNC_MOUSE_WHEEL_UP   8

Bitmask of mouse wheel up action (see vnc_do_ptr).

#define VNC_MOUSE_WHEEL_DOWN   16

Bitmask of mouse wheel down action (see vnc_do_ptr).

#define VNC_HALT_DELAY_SEC   2.0f

Controls the 'halt' button behaviour.

If the button is released within VNC_HALT_DELAY_SEC seconds the Hifidelio performs a standby. Otherwise, a shutdown is performed.

#define VNC_COVER_LOOKUP_MSEC   1000

Cover art lookup interval in milliseconds.

#define VNC_DEFER_UPDATE_USEC   10000

VNC event handling interval in microseconds.

#define VNC_COLOR_BPP   4

Color depth of VNC screen (bytes per pixel).

#define VNC_CURSOR_WIDTH   11

VNC cursor width (see x_cursor).

#define VNC_CURSOR_HEIGHT   17

VNC cursor height (see x_cursor).


Function Documentation

static void vnc_client_gone ( rfbClientPtr  client_ctx  )  [static]

Called if a client quits the connection.

Parameters:
client_ctx client context

static enum rfbNewClientAction vnc_new_client ( rfbClientPtr  client_ctx  )  [static]

Called if a new client connects to the VNC server.

Parameters:
client_ctx client context
Returns:
an action code whether the client is accepted

static int vnc_check_ptr_over_btn_region ( struct theme_button button,
int  x,
int  y 
) [static]

Determines whether the pointer touches a button region.

Parameters:
button button data
x x-position of pointer
y y-position of pointer
Returns:
1 if the pointer touches the button region, else 0

static int vnc_check_ptr_over_region ( int  x1,
int  y1,
int  x2,
int  y2,
int  x,
int  y 
) [static]

Determines whether the pointer touches a given region.

Parameters:
x1 upper left x-coordinate of region
y1 upper left y-coordinate of region
x2 lower right x-coordinate of region
y2 lower right y-coordinate of region
x x-position of pointer
y y-position of pointer
Returns:
1 if the pointer touches the region, else 0

static int vnc_check_ptr_transparency ( struct img_bitmap bitmap,
int  x,
int  y 
) [static]

Determines whether the pointer touches a transparent region in a bitmap.

Parameters:
bitmap bitmap data
x x-position of pointer
y y-position of pointer
Returns:
1 if the region is transparent, else 0

static void vnc_check_screensaver (  )  [static]

Checks if the Hifidelio screensaver is active and sends a dummy keypress if necessary.

static void vnc_blit_button ( struct theme theme,
struct theme_button button,
rfbScreenInfoPtr  screen 
) [static]

Blits a button in the VNC screen's frame buffer.

If the button is active, the buttons bitmap is used as source. Otherwise, the layout bitmap is used.

Parameters:
theme theme data
button button data
screen screen context

static void vnc_check_button_events ( struct theme_button button,
int  button_mask,
rfbClientPtr  client_ctx 
) [static]

Checks the mouse button events for the given button and sends commands to the XML interface according to the user's actions.

Parameters:
button button data
button_mask current mouse button mask
client_ctx client context

static void vnc_check_nonbutton_events ( int  button_mask,
rfbClientPtr  client_ctx 
) [static]

Checks mouse button events if the pointer doesn't touch a button region in the current theme.

Pressing the left mouse button acts as cursor-left and pressing the right button as cursor-right in this case.

Parameters:
button_mask current mouse button mask
client_ctx client context

static void vnc_check_wheel_events ( int  button_mask,
rfbClientPtr  client_ctx 
) [static]

Checks mouse wheel events and generates key-events (cursor-up, cursor-down) if necessary.

Parameters:
button_mask current mouse button mask
client_ctx client context

static void vnc_do_ptr ( int  button_mask,
int  x,
int  y,
rfbClientPtr  client_ctx 
) [static]

Handles pointer events.

Parameters:
button_mask mouse button mask
x x-coordinate of pointer
y y-coordinate of pointer
client_ctx client context

static void vnc_do_key ( rfbBool  down,
rfbKeySym  key,
rfbClientPtr  client_ctx 
) [static]

Handles keyboard events and sends commands to the XML interface according to the user's actions.

Parameters:
down key state flag; 1: pressed, 0: released
key keyboard code
client_ctx client context

static rfbScreenInfoPtr vnc_init_screen ( int  argc,
char **  argv,
struct config config,
int  index 
) [static]

Initializes a VNC screen.

Performs the following tasks:

  • loading of theme data
  • framebuffer allocation
  • display scaling preparations
  • VNC screen initialization

Parameters:
argc command line argument count
argv command line arguments
config VNC configuration
index,: VNC screen index
Returns:
pointer to an rfbScreenInfo structures or NULL if an error occured

static void vnc_update_display_region ( rfbScreenInfoPtr  screen,
unsigned char *  display_buffer,
int  x1,
int  y1,
int  x2,
int  y2 
) [static]

Updates a display region in the screen's framebuffer.

Parameters:
screen screen context
display_buffer display buffer
x1 upper left x-coordinate
y1 upper left y-coordinate
x2 lower right x-coordinate
y2 lower right y-coordinate

static void vnc_update_cover ( rfbScreenInfoPtr  screen,
struct img_bitmap cover 
) [static]

Updates the cover region.

Displays the background if no cover is available.

Parameters:
screen screen context
cover cover art bitmap

static void vnc_cleanup_screen ( rfbScreenInfoPtr  screen  )  [static]

VNC screen cleanup.

Frees allocated memory.

Parameters:
screen VNC screen data

void* vnc_process_events ( void *  arg  ) 

Thread function that controls the event loop for a vnc screen.

Parameters:
arg VNC screen data

static void vnc_termination_handler ( int  sig  )  [static]

Program termination signal handler.

Parameters:
sig signal caught

void vnc_startup ( int  argc,
char **  argv,
struct config config 
)

Launches VNC screens and controls the refresh loop.

Parameters:
argc command line argument count
argv command line arguments
config VNC configuration data


Variable Documentation

char x_cursor[] [static]

Initial value:

    "           "
    " x         "
    " xx        "
    " xxx       "
    " xxxx      "
    " xxxxx     "
    " xxxxxx    "
    " xxxxxxx   "
    " xxxxxxxx  "
    " xxxxxxxxx "
    " xxxxxx    "
    " xxxxxx    "
    " xx  xxx   "
    " x   xxx   "
    "      xxx  "
    "      xx   "
    "           "
VNC cursor ASCII map.

int keep_going = 1 [static]

Global flag that keeps the VNC server running.

int signal_caught = 0 [static]

Last signal handled in vnc_termination_handler.

int screensaver_mode = 0 [static]

Hifidelio screensaver mode (1 = active, 0 = off).

This value gets updated with every display refresh.


Generated on Mon Mar 29 01:39:34 2010 for Veronica by  doxygen 1.5.8