Commit 15dd71ba authored by Jonh Wendell S. Santana's avatar Jonh Wendell S. Santana
Browse files

Stuff

svn path=/trunk/; revision=7
parent 7c00da51
......@@ -3,10 +3,10 @@ Vinagre Installation Instructions
You'll need the devel packages of the following libraries:
- gtk+-2.0
- gtk+-2.0 >= 2.11
- libglade-2.0
- gconf-2.0
- gnutls
- gtk-vnc widget (http://gtk-vnc.sf.net)
To compile it, just do:
......
......@@ -33,8 +33,8 @@ AM_GLIB_GNU_GETTEXT
# Check required GNOME libraries
#*******************************************************************************
GLIB_REQUIRED=2.10.0
GTK_REQUIRED=2.10.0
GLIB_REQUIRED=2.11.0
GTK_REQUIRED=2.11.0
LIBGLADE_REQUIRED=2.6.0
GCONF_REQUIRED=2.16.0
......@@ -42,23 +42,16 @@ PKG_CHECK_MODULES(VINAGRE, \
glib-2.0 >= $GLIB_REQUIRED \
gtk+-2.0 >= $GTK_REQUIRED \
libglade-2.0 >= $LIBGLADE_REQUIRED \
gconf-2.0 >= $GCONF_REQUIRED)
gconf-2.0 >= $GCONF_REQUIRED \
gtk-vnc-1.0)
AC_SUBST(VINAGRE_CFLAGS)
AC_SUBST(VINAGRE_LIBS)
#*******************************************************************************
# Check for gnutls for gtk-vnc
#*******************************************************************************
PKG_CHECK_MODULES(GTKVNC, [gnutls])
AC_SUBST(GTKVNC_CFLAGS)
AC_SUBST(GTKVNC_LIBS)
#*******************************************************************************
# Check for Avahi
#*******************************************************************************
AVAHI_REQUIRED=0.6.17
AVAHI_REQUIRED=0.6.18
AC_ARG_ENABLE(avahi,
AS_HELP_STRING([--enable-avahi],[Enable use of avahi]),
......@@ -73,7 +66,7 @@ AVAHI_CFLAGS=
AVAHI_LIBS=
if test "x$VINAGRE_ENABLE_AVAHI" = "xyes" ; then
PKG_CHECK_MODULES(AVAHI,
[avahi-client >= $AVAHI_REQUIRED avahi-glib >= $AVAHI_REQUIRED ])
[avahi-ui >= $AVAHI_REQUIRED])
AVAHI_CFLAGS="$AVAHI_CFLAGS -DVINAGRE_HAVE_AVAHI"
fi
AC_SUBST(AVAHI_CFLAGS)
......@@ -87,7 +80,6 @@ Makefile
data/Makefile
data/vinagre.desktop.in
src/Makefile
src/gtk-vnc/Makefile
po/Makefile.in
])
......
SUBDIRS = gtk-vnc
INCLUDES = \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
......@@ -13,12 +11,6 @@ INCLUDES = \
bin_PROGRAMS = vinagre
if VINAGRE_AVAHI
VINAGRE_AVAHI_SRC = \
avahi-ui.h \
avahi-ui.c
endif
vinagre_SOURCES = \
vinagre-commands.c vinagre-commands.h \
vinagre-connect.c vinagre-connect.h \
......@@ -32,12 +24,10 @@ vinagre_SOURCES = \
vinagre-tab.c vinagre-tab.h \
vinagre-utils.c vinagre-utils.h \
vinagre-window.c vinagre-window.h \
vinagre-ui.h vinagre-window-private.h \
$(VINAGRE_AVAHI_SRC)
vinagre-ui.h vinagre-window-private.h
vinagre_LDADD = \
$(VINAGRE_LIBS) \
gtk-vnc/libgtkvnc.la \
$(GTKVNC_LIBS) \
$(AVAHI_LIBS)
This diff is collapsed.
#ifndef fooavahiuihfoo
#define fooavahiuihfoo
/* $Id$ */
/***
This file is part of avahi.
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
avahi 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 Lesser General
Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
#include <gtk/gtkwidget.h>
#include <gtk/gtkdialog.h>
#include <avahi-client/client.h>
/** \file avahi-ui.h A Gtk dialog for browsing for services */
G_BEGIN_DECLS
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define AUI_TYPE_SERVICE_DIALOG (aui_service_dialog_get_type())
#define AUI_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialog))
#define AUI_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass))
#define AUI_IS_SERVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AUI_TYPE_SERVICE_DIALOG))
#define AUI_IS_SERVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), AUI_TYPE_SERVICE_DIALOG))
#define AUI_SERVICE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AUI_TYPE_SERVICE_DIALOG, AuiServiceDialogClass))
typedef struct _AuiServiceDialogPrivate AuiServiceDialogPrivate;
typedef struct _AuiServiceDialogClass AuiServiceDialogClass;
struct _AuiServiceDialogClass {
GtkDialogClass parent_class;
/* Padding for future expansion */
void (*_aui_reserved1)(void);
void (*_aui_reserved2)(void);
void (*_aui_reserved3)(void);
void (*_aui_reserved4)(void);
};
struct _AuiServiceDialog {
GtkDialog parent_instance;
AuiServiceDialogPrivate *priv;
};
/* ServiceDialog */
GType aui_service_dialog_get_type(void) G_GNUC_CONST;
#endif
/** The GTK service dialog structure */
typedef struct _AuiServiceDialog AuiServiceDialog;
/** Create a new service browser dialog with the specific title,
* parent window and the speicified buttons. The buttons are specified
* in a similar way to GtkFileChooserDialog. Please note that at least
* one button has to respond GTK_RESPONSE_ACCEPT. */
GtkWidget* aui_service_dialog_new(
const gchar *title,
GtkWindow *parent,
const gchar *first_button_text, ...) G_GNUC_NULL_TERMINATED;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GtkWidget *aui_service_dialog_new_valist(
gchar *title,
GtkWindow *parent,
const gchar *first_button_text,
va_list varargs);
#endif
/** Select the service types to browse for. Takes a NULL terminated list of DNS-SD service types. i.e. _http._tcp */
void aui_service_dialog_set_browse_service_types(AuiServiceDialog *d, const gchar *type, ...) G_GNUC_NULL_TERMINATED;
/** Same as aui_service_dialog_set_browse_service_types() but take a NULL terminated array */
void aui_service_dialog_set_browse_service_typesv(AuiServiceDialog *d, const gchar *const*type);
/** Return the service types currently browsed for. i.e. what was previously set with aui_service_dialog_set_browse_service_types() */
const gchar*const* aui_service_dialog_get_browse_service_types(AuiServiceDialog *d);
/** Set the domain to browse in */
void aui_service_dialog_set_domain(AuiServiceDialog *d, const gchar *domain);
/** Query the domain that is browsed in */
const gchar* aui_service_dialog_get_domain(AuiServiceDialog *d);
/** Set the service type for the service to select */
void aui_service_dialog_set_service_type(AuiServiceDialog *d, const gchar *name);
/** Query the service type of the currently selected service */
const gchar* aui_service_dialog_get_service_type(AuiServiceDialog *d);
/** Set the service name for the service to select */
void aui_service_dialog_set_service_name(AuiServiceDialog *d, const gchar *name);
/** Query the service name of the currently select service */
const gchar* aui_service_dialog_get_service_name(AuiServiceDialog *d);
/** Return the IP address of the selected service. (Only valid if host name resolving has not been disabled via aui_service_dialog_set_resolve_host_name()) */
const AvahiAddress* aui_service_dialog_get_address(AuiServiceDialog *d);
/** Return the IP port number of the selected service */
guint16 aui_service_dialog_get_port(AuiServiceDialog *d);
/** Return the host name of the selected service */
const gchar* aui_service_dialog_get_host_name(AuiServiceDialog *d);
/** Return the TXT metadata of the selected service */
const AvahiStringList *aui_service_dialog_get_txt_data(AuiServiceDialog *d);
/** Disable/Enable automatic service resolving. Disabling this feature
* will require you to resolve the selected service on our own. I.e. the port
* number, the TXT data and the host name/IP address will not be
* available after a service has been selected. This functionality
* offers a certain optimization in the traffic imposed on the
* network. Most people will not want to touch this. */
void aui_service_dialog_set_resolve_service(AuiServiceDialog *d, gboolean resolve);
/** Query the last status of aui_service_dialog_set_resolve_service() */
gboolean aui_service_dialog_get_resolve_service(AuiServiceDialog *d);
/** Disable/Enable automatic host name resolving. Disabling this
* feature will cause aui_service_dialog_get_address() return NULL in
* all case because avahi-ui will not resolve the host name of the
* selected service to an address. This is a slight optimization
* regarding the traffic imposed by this query to the network. By
* default, avahi-ui will resolve the host names of selected services. */
void aui_service_dialog_set_resolve_host_name(AuiServiceDialog *d, gboolean resolve);
/** Query the last status of aui_service_dialog_set_resolve_host_name() */
gboolean aui_service_dialog_get_resolve_host_name(AuiServiceDialog *d);
/** Select the address family to look for services of. This can be
used to look only for IPv6 services or only for IPv4 services. By
default avahi-ui will browse for both IPv4 and IPv6 services.*/
void aui_service_dialog_set_address_family(AuiServiceDialog *d, AvahiProtocol proto);
/** Query the address family we're looking for. */
AvahiProtocol aui_service_dialog_get_address_family(AuiServiceDialog *d);
G_END_DECLS
#endif
INCLUDES = \
-I$(top_builddir) \
$(VINAGRE_CFLAGS) \
$(GTKVNC_CFLAGS)
noinst_LTLIBRARIES = libgtkvnc.la
libgtkvnc_la_SOURCES = \
blt.h \
blt1.h \
continuation.c \
continuation.h \
coroutine.c \
coroutine.h \
d3des.c \
d3des.h \
gvnc.c \
gvnc.h \
vncdisplay.c \
vncdisplay.h \
vncshmimage.c \
vncshmimage.h
#define src_pixel_t SPLICE(uint, SPLICE(SRC, _t))
#define dst_pixel_t SPLICE(uint, SPLICE(DST, _t))
#define SUFFIX() SPLICE(SRC,SPLICE(x,DST))
#define BLIT SPLICE(gvnc_blt_, SUFFIX())
#define FILL SPLICE(gvnc_fill_, SUFFIX())
#define FAST_FILL SPLICE(gvnc_fill_fast_, SUFFIX())
#define SUBRECT SPLICE(gvnc_hextile_, SUFFIX())
static void FAST_FILL(struct gvnc *gvnc, src_pixel_t *sp,
int x, int y, int width, int height)
{
uint8_t *dst = gvnc_get_local(gvnc, x, y);
int i;
for (i = 0; i < 1; i++) {
int j;
dst_pixel_t *dp = (dst_pixel_t *)dst;
for (j = 0; j < width; j++) {
*dp = *sp;
dp++;
}
dst += gvnc->local.linesize;
}
for (i = 1; i < height; i++) {
memcpy(dst, dst - gvnc->local.linesize, width * sizeof(*sp));
dst += gvnc->local.linesize;
}
}
static void FILL(struct gvnc *gvnc, src_pixel_t *sp,
int x, int y, int width, int height)
{
uint8_t *dst = gvnc_get_local(gvnc, x, y);
struct vnc_pixel_format *f = &gvnc->fmt;
int i;
for (i = 0; i < 1; i++) {
dst_pixel_t *dp = (dst_pixel_t *)dst;
int j;
for (j = 0; j < width; j++) {
*dp = ((*sp >> f->red_shift) & gvnc->rm) << gvnc->rp
| ((*sp >> f->green_shift) & gvnc->gm) << gvnc->gp
| ((*sp >> f->blue_shift) & gvnc->bm) << gvnc->bp;
dp++;
}
dst += gvnc->local.linesize;
}
for (i = 1; i < height; i++) {
memcpy(dst, dst - gvnc->local.linesize, width * sizeof(dst_pixel_t));
dst += gvnc->local.linesize;
}
}
static void BLIT(struct gvnc *gvnc, uint8_t *src, int pitch, int x, int y, int w, int h)
{
uint8_t *dst = gvnc_get_local(gvnc, x, y);
struct vnc_pixel_format *f = &gvnc->fmt;
int i;
for (i = 0; i < h; i++) {
dst_pixel_t *dp = (dst_pixel_t *)dst;
src_pixel_t *sp = (src_pixel_t *)src;
int j;
for (j = 0; j < w; j++) {
*dp = ((*sp >> f->red_shift) & gvnc->rm) << gvnc->rp
| ((*sp >> f->green_shift) & gvnc->gm) << gvnc->gp
| ((*sp >> f->blue_shift) & gvnc->bm) << gvnc->bp;
dp++;
sp++;
}
dst += gvnc->local.linesize;
src += pitch;
}
}
static void SUBRECT(struct gvnc *gvnc, uint8_t flags, uint16_t x, uint16_t y,
uint16_t width, uint16_t height, src_pixel_t *fg, src_pixel_t *bg)
{
int stride = width * sizeof(src_pixel_t);
int i;
if (flags & 0x01) {
/* Raw tile */
if (gvnc->perfect_match) {
int i;
uint8_t *dst = gvnc_get_local(gvnc, x, y);
for (i = 0; i < height; i++) {
gvnc_read(gvnc, dst, stride);
dst += gvnc->local.linesize;
}
} else {
uint8_t data[16 * 16 * sizeof(src_pixel_t)];
gvnc_read(gvnc, data, stride * height);
BLIT(gvnc, data, stride, x, y, width, height);
}
} else {
/* Background Specified */
if (flags & 0x02)
gvnc_read(gvnc, bg, sizeof(*bg));
/* Foreground Specified */
if (flags & 0x04)
gvnc_read(gvnc, fg, sizeof(*fg));
if (gvnc->perfect_match)
FAST_FILL(gvnc, bg, x, y, width, height);
else
FILL(gvnc, bg, x, y, width, height);
/* AnySubrects */
if (flags & 0x08) {
uint8_t n_rects = gvnc_read_u8(gvnc);
for (i = 0; i < n_rects; i++) {
uint8_t xy, wh;
/* SubrectsColored */
if (flags & 0x10)
gvnc_read(gvnc, fg, sizeof(*fg));
xy = gvnc_read_u8(gvnc);
wh = gvnc_read_u8(gvnc);
if (gvnc->perfect_match)
FAST_FILL(gvnc, fg,
x + nibhi(xy), y + niblo(xy),
nibhi(wh) + 1, niblo(wh) + 1);
else
FILL(gvnc, fg,
x + nibhi(xy), y + niblo(xy),
nibhi(wh) + 1, niblo(wh) + 1);
}
}
}
}
#undef SUBRECT
#undef FILL
#undef FAST_FILL
#undef BLIT
#undef dst_pixel_t
#undef src_pixel_t
/*
* Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2 as
* published by the Free Software Foundation.
*
* GTK VNC Widget
*/
#define DST 8
#include "blt.h"
#undef DST
#define DST 16
#include "blt.h"
#undef DST
#define DST 32
#include "blt.h"
#undef DST
/*
* Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2 as
* published by the Free Software Foundation.
*
* GTK VNC Widget
*/
#include "continuation.h"
int cc_init(struct continuation *cc)
{
if (getcontext(&cc->uc) == -1)
return -1;
cc->uc.uc_link = &cc->last;
cc->uc.uc_stack.ss_sp = cc->stack;
cc->uc.uc_stack.ss_size = cc->stack_size;
cc->uc.uc_stack.ss_flags = 0;
makecontext(&cc->uc, (void *)cc->entry, 1, cc);
return 0;
}
int cc_release(struct continuation *cc)
{
if (cc->release)
return cc->release(cc);
return 0;
}
int cc_swap(struct continuation *from, struct continuation *to)
{
to->exited = 0;
if (getcontext(&to->last) == -1)
return -1;
else if (to->exited == 0)
to->exited = 1;
else if (to->exited == 1)
return 1;
swapcontext(&from->uc, &to->uc);
return 0;
}
/*
* Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2 as
* published by the Free Software Foundation.
*
* GTK VNC Widget
*/
#ifndef _CONTINUATION_H_
#define _CONTINUATION_H_
#include <ucontext.h>
struct continuation
{
char *stack;
size_t stack_size;
void (*entry)(struct continuation *cc);
int (*release)(struct continuation *cc);
/* private */
ucontext_t uc;
ucontext_t last;
int exited;
};
int cc_init(struct continuation *cc);
int cc_release(struct continuation *cc);
/* you can use an uninitialized struct continuation for from if you do not have
the current continuation handy. */
int cc_swap(struct continuation *from, struct continuation *to);
#define offset_of(type, member) ((unsigned long)(&((type *)0)->member))
#define container_of(obj, type, member) \
(type *)(((char *)obj) - offset_of(type, member))
#endif
/*
* Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2 as
* published by the Free Software Foundation.
*
* GTK VNC Widget
*/
#include <sys/types.h>
#include <sys/mman.h>
#include "coroutine.h"
int coroutine_release(struct coroutine *co)
{
return cc_release(&co->cc);
}
static int _coroutine_release(struct continuation *cc)
{
struct coroutine *co = container_of(cc, struct coroutine, cc);
if (co->release) {
int ret = co->release(co);
if (ret < 0)
return ret;
}
return munmap(cc->stack, cc->stack_size);
}
static void coroutine_trampoline(struct continuation *cc)
{
struct coroutine *co = container_of(cc, struct coroutine, cc);
co->data = co->entry(co->data);
}
int coroutine_init(struct coroutine *co)
{
if (co->stack_size == 0)
co->stack_size = 16 << 20;
co->cc.stack_size = co->stack_size;
co->cc.stack = mmap(0, co->stack_size,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_SHARED | MAP_ANONYMOUS | MAP_GROWSDOWN,
-1, 0);
if (co->cc.stack == MAP_FAILED)
return -1;
co->cc.entry = coroutine_trampoline;
co->cc.release = _coroutine_release;
co->exited = 0;
return cc_init(&co->cc);
}
#if 0
static __thread struct coroutine system;
static __thread struct coroutine *current;
#else
static struct coroutine system;
static struct coroutine *current;
#endif
struct coroutine *coroutine_self(void)
{
if (current == 0)
current = &system;
return current;
}
void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
{
int ret;
to->caller = from;
to->data = arg;
current = to;
ret = cc_swap(&from->cc, &to->cc);
if (ret == 0)
return from->data;