rdtk: initial commit

This commit is contained in:
Marc-André Moreau 2014-09-29 16:08:08 -04:00
parent 169a9c83ee
commit abd87ace55
22 changed files with 1977 additions and 103 deletions

View File

@ -632,6 +632,12 @@ if (IOS)
endif()
endif()
# RdTk
include_directories("${CMAKE_SOURCE_DIR}/rdtk/include")
include_directories("${CMAKE_BINARY_DIR}/rdtk/include")
add_subdirectory(rdtk)
if(WITH_CLIENT)
add_subdirectory(client)
endif()

View File

@ -46,7 +46,6 @@ typedef struct rdp_shadow_surface rdpShadowSurface;
typedef struct rdp_shadow_encoder rdpShadowEncoder;
typedef struct rdp_shadow_capture rdpShadowCapture;
typedef struct rdp_shadow_subsystem rdpShadowSubsystem;
typedef struct rdp_shadow_font rdpShadowFont;
typedef struct _RDP_SHADOW_ENTRY_POINTS RDP_SHADOW_ENTRY_POINTS;
typedef int (*pfnShadowSubsystemEntry)(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);

90
rdtk/CMakeLists.txt Normal file
View File

@ -0,0 +1,90 @@
# RdTk: Remote Desktop Toolkit
# rdtk cmake build script
#
# Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 2.8)
project(RdTk C)
set(CMAKE_COLOR_MAKEFILE ON)
# Include cmake modules
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckStructHasMember)
include(FindPkgConfig)
include(TestBigEndian)
# Include our extra modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
# Check for cmake compatibility (enable/disable features)
include(CheckCmakeCompat)
include(FindFeature)
include(AutoVersioning)
include(ConfigOptions)
include(CheckCCompilerFlag)
include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers)
# Soname versioning
set(RDTK_VERSION_MAJOR "1")
set(RDTK_VERSION_MINOR "1")
set(RDTK_VERSION_REVISION "0")
set(RDTK_VERSION "${RDTK_VERSION_MAJOR}.${RDTK_VERSION_MINOR}")
set(RDTK_VERSION_FULL "${RDTK_VERSION}.${RDTK_VERSION_REVISION}")
set(RDTK_VERSION_FULL ${RDTK_VERSION_FULL} PARENT_SCOPE)
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Default to build shared libs
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRDTK_EXPORTS")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
add_subdirectory(include)
add_subdirectory(librdtk)
# Exporting
if(${CMAKE_VERSION} VERSION_GREATER "2.8.10")
export(PACKAGE rdtk)
set(RDTK_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/RdTk")
set(RDTK_INCLUDE_DIR "include")
configure_package_config_file(RdTkConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/RdTkConfig.cmake
INSTALL_DESTINATION ${RDTK_CMAKE_INSTALL_DIR} PATH_VARS RDTK_INCLUDE_DIR)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/RdTkConfigVersion.cmake
VERSION ${RDTK_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RdTkConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/RdTkConfigVersion.cmake
DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
install(EXPORT RdTkTargets DESTINATION ${RDTK_CMAKE_INSTALL_DIR})
endif()

11
rdtk/RdTkConfig.cmake.in Normal file
View File

@ -0,0 +1,11 @@
@PACKAGE_INIT@
set(RdTk_VERSION_MAJOR "@RDTK_VERSION_MAJOR@")
set(RdTk_VERSION_MINOR "@RDTK_VERSION_MINOR@")
set(RdTk_VERSION_REVISION "@RDTK_VERSION_REVISION@")
set_and_check(RdTk_INCLUDE_DIR "@PACKAGE_RDTK_INCLUDE_DIR@")
include("${CMAKE_CURRENT_LIST_DIR}/RdTkTargets.cmake")

View File

@ -0,0 +1,20 @@
# RdTk: Remote Desktop Toolkit
# rdtk cmake build script
#
# Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
file(GLOB RDTK_HEADERS "rdtk/*.h")
install(FILES ${RDTK_HEADERS} DESTINATION include/rdtk COMPONENT headers)

46
rdtk/include/rdtk/api.h Normal file
View File

@ -0,0 +1,46 @@
/**
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RDTK_API_H
#define RDTK_API_H
#include <winpr/spec.h>
#if defined _WIN32 || defined __CYGWIN__
#ifdef RDTK_EXPORTS
#ifdef __GNUC__
#define RDTK_EXPORT __attribute__((dllexport))
#else
#define RDTK_EXPORT __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define RDTK_EXPORT __attribute__((dllimport))
#else
#define RDTK_EXPORT __declspec(dllimport)
#endif
#endif
#else
#if __GNUC__ >= 4
#define RDTK_EXPORT __attribute__ ((visibility("default")))
#else
#define RDTK_EXPORT
#endif
#endif
#endif /* RDTK_API_H */

52
rdtk/include/rdtk/rdtk.h Normal file
View File

@ -0,0 +1,52 @@
/**
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RDTK_H
#define RDTK_H
#include <rdtk/api.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
typedef struct rdtk_font rdtkFont;
typedef struct rdtk_glyph rdtkGlyph;
typedef struct rdtk_surface rdtkSurface;
#ifdef __cplusplus
extern "C" {
#endif
/* Surface */
RDTK_EXPORT rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline);
RDTK_EXPORT void rdtk_surface_free(rdtkSurface* surface);
/* Font */
RDTK_EXPORT int rdtk_font_draw_text(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, const char* text);
RDTK_EXPORT rdtkFont* rdtk_font_new(const char* path, const char* file);
RDTK_EXPORT void rdtk_font_free(rdtkFont* font);
#ifdef __cplusplus
}
#endif
#endif /* RDTK_H */

View File

@ -0,0 +1,40 @@
# RdTk: Remote Desktop Toolkit
#
# Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "rdtk")
set(MODULE_PREFIX "RDTK")
include_directories(${OPENSSL_INCLUDE_DIR})
set(${MODULE_PREFIX}_SRCS
rdtk_resources.c
rdtk_resources.h
rdtk_surface.c
rdtk_surface.h
rdtk_font.c
rdtk_font.h)
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
list(APPEND ${MODULE_PREFIX}_LIBS winpr)
list(APPEND ${MODULE_PREFIX}_LIBS freerdp)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT RdTkTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "RdTk")

View File

@ -1,5 +1,5 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
@ -22,12 +22,16 @@
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/print.h>
#include "shadow.h"
#include "rdtk_resources.h"
#include "rdtk_surface.h"
#include "shadow_font.h"
#include "rdtk_font.h"
int shadow_font_draw_glyph(rdpShadowSurface* surface, int nXDst, int nYDst, rdpShadowFont* font, rdpShadowGlyph* glyph)
static rdtkFont* g_Font = NULL;
int rdtk_font_draw_glyph(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, rdtkGlyph* glyph)
{
int x, y;
int nXSrc;
@ -114,25 +118,31 @@ int shadow_font_draw_glyph(rdpShadowSurface* surface, int nXDst, int nYDst, rdpS
return 1;
}
int shadow_font_draw_text(rdpShadowSurface* surface, int nXDst, int nYDst, rdpShadowFont* font, const char* text)
int rdtk_font_draw_text(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, const char* text)
{
int index;
int length;
rdpShadowGlyph* glyph;
rdtkGlyph* glyph;
if (!font)
{
rdtk_load_embedded_fonts();
font = g_Font;
}
length = strlen(text);
for (index = 0; index < length; index++)
{
glyph = &font->glyphs[text[index] - 32];
shadow_font_draw_glyph(surface, nXDst, nYDst, font, glyph);
rdtk_font_draw_glyph(surface, nXDst, nYDst, font, glyph);
nXDst += (glyph->width + 1);
}
return 1;
}
char* shadow_font_load_descriptor_file(const char* filename, int* pSize)
char* rdtk_font_load_descriptor_file(const char* filename, int* pSize)
{
BYTE* buffer;
FILE* fp = NULL;
@ -185,7 +195,7 @@ char* shadow_font_load_descriptor_file(const char* filename, int* pSize)
return (char*) buffer;
}
int shadow_font_convert_descriptor_code_to_utf8(const char* str, BYTE* utf8)
int rdtk_font_convert_descriptor_code_to_utf8(const char* str, BYTE* utf8)
{
int len = strlen(str);
@ -221,7 +231,7 @@ int shadow_font_convert_descriptor_code_to_utf8(const char* str, BYTE* utf8)
return 1;
}
int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
int rdtk_font_parse_descriptor_buffer(rdtkFont* font, BYTE* buffer, int size)
{
char* p;
char* q;
@ -231,16 +241,9 @@ int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
char* tok[4];
int index;
int count;
int size;
char* buffer;
rdpShadowGlyph* glyph;
rdtkGlyph* glyph;
buffer = shadow_font_load_descriptor_file(filename, &size);
if (!buffer)
return -1;
p = strstr(buffer, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
p = strstr((char*) buffer, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
if (!p)
return -1;
@ -349,8 +352,8 @@ int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
p = q + 1;
printf("size: %d family: %s height: %d style: %s\n",
font->size, font->family, font->height, font->style);
//printf("size: %d family: %s height: %d style: %s\n",
// font->size, font->family, font->height, font->style);
beg = p;
count = 0;
@ -378,7 +381,7 @@ int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
}
font->glyphCount = count;
font->glyphs = (rdpShadowGlyph*) calloc(font->glyphCount, sizeof(rdpShadowGlyph));
font->glyphs = (rdtkGlyph*) calloc(font->glyphCount, sizeof(rdtkGlyph));
if (!font->glyphs)
return -1;
@ -524,7 +527,7 @@ int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
return -1;
*q = '\0';
shadow_font_convert_descriptor_code_to_utf8(p, glyph->code);
rdtk_font_convert_descriptor_code_to_utf8(p, glyph->code);
*q = '"';
p = q + 1;
@ -540,11 +543,24 @@ int shadow_font_load_descriptor(rdpShadowFont* font, const char* filename)
return 1;
}
rdpShadowFont* shadow_font_new(const char* path, const char* file)
int rdtk_font_load_descriptor(rdtkFont* font, const char* filename)
{
int size;
char* buffer;
buffer = rdtk_font_load_descriptor_file(filename, &size);
if (!buffer)
return -1;
return rdtk_font_parse_descriptor_buffer(font, (BYTE*) buffer, size);
}
rdtkFont* rdtk_font_new(const char* path, const char* file)
{
int status;
int length;
rdpShadowFont* font;
rdtkFont* font;
char* fontBaseFile;
char* fontImageFile;
char* fontDescriptorFile;
@ -580,7 +596,7 @@ rdpShadowFont* shadow_font_new(const char* path, const char* file)
if (!PathFileExistsA(fontDescriptorFile))
return NULL;
font = (rdpShadowFont*) calloc(1, sizeof(rdpShadowFont));
font = (rdtkFont*) calloc(1, sizeof(rdtkFont));
if (!font)
return NULL;
@ -595,7 +611,7 @@ rdpShadowFont* shadow_font_new(const char* path, const char* file)
if (status < 0)
return NULL;
status = shadow_font_load_descriptor(font, fontDescriptorFile);
status = rdtk_font_load_descriptor(font, fontDescriptorFile);
free(fontImageFile);
free(fontDescriptorFile);
@ -603,10 +619,56 @@ rdpShadowFont* shadow_font_new(const char* path, const char* file)
return font;
}
void shadow_font_free(rdpShadowFont* font)
rdtkFont* rdtk_embedded_font_new(BYTE* imageData, int imageSize, BYTE* descriptorData, int descriptorSize)
{
int status;
rdtkFont* font;
font = (rdtkFont*) calloc(1, sizeof(rdtkFont));
if (!font)
return NULL;
font->image = winpr_image_new();
if (!font->image)
return NULL;
status = winpr_image_read_buffer(font->image, imageData, imageSize);
if (status < 0)
return NULL;
status = rdtk_font_parse_descriptor_buffer(font, descriptorData, descriptorSize);
return font;
}
void rdtk_font_free(rdtkFont* font)
{
if (!font)
return;
free(font);
}
int rdtk_load_embedded_fonts()
{
if (!g_Font)
{
int imageSize;
int descriptorSize;
BYTE* imageData = NULL;
BYTE* descriptorData = NULL;
imageSize = rdtk_get_embedded_resource_file("source_serif_pro_regular_12.png", &imageData);
descriptorSize = rdtk_get_embedded_resource_file("source_serif_pro_regular_12.xml", &descriptorData);
if ((imageSize < 0) || (descriptorSize < 0))
return -1;
g_Font = rdtk_embedded_font_new(imageData, imageSize, descriptorData, descriptorSize);
}
return 1;
}

View File

@ -1,5 +1,5 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
@ -16,16 +16,16 @@
* limitations under the License.
*/
#ifndef FREERDP_SHADOW_SERVER_FONT_H
#define FREERDP_SHADOW_SERVER_FONT_H
#ifndef RDTK_FONT_PRIVATE_H
#define RDTK_FONT_PRIVATE_H
#include <freerdp/server/shadow.h>
#include <rdtk/rdtk.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/image.h>
struct rdp_shadow_glyph
struct rdtk_glyph
{
int width;
int offsetX;
@ -36,9 +36,8 @@ struct rdp_shadow_glyph
int rectHeight;
BYTE code[4];
};
typedef struct rdp_shadow_glyph rdpShadowGlyph;
struct rdp_shadow_font
struct rdtk_font
{
int size;
int height;
@ -46,21 +45,18 @@ struct rdp_shadow_font
char* style;
wImage* image;
int glyphCount;
rdpShadowGlyph* glyphs;
rdtkGlyph* glyphs;
};
#ifdef __cplusplus
extern "C" {
#endif
int shadow_font_draw_text(rdpShadowSurface* surface, int nXDst, int nYDst, rdpShadowFont* font, const char* text);
int shadow_font_draw_glyph(rdpShadowSurface* surface, int nXDst, int nYDst, rdpShadowFont* font, rdpShadowGlyph* glyph);
rdpShadowFont* shadow_font_new(const char* path, const char* file);
void shadow_font_free(rdpShadowFont* font);
int rdtk_load_embedded_fonts();
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_FONT_H */
#endif /* RDTK_FONT_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
/**
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RDTK_RESOURCES_PRIVATE_H
#define RDTK_RESOURCES_PRIVATE_H
#include <rdtk/rdtk.h>
#ifdef __cplusplus
extern "C" {
#endif
int rdtk_get_embedded_resource_file(const char* filename, BYTE** pData);
#ifdef __cplusplus
}
#endif
#endif /* RDTK_RESOURCES_PRIVATE_H */

View File

@ -0,0 +1,72 @@
/**
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rdtk_surface.h"
rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline)
{
rdtkSurface* surface;
surface = (rdtkSurface*) calloc(1, sizeof(rdtkSurface));
if (!surface)
return NULL;
surface->width = width;
surface->height = height;
if (scanline < 0)
scanline = width * 4;
surface->scanline = scanline;
surface->data = data;
surface->owner = FALSE;
if (!data)
{
surface->scanline = (surface->width + (surface->width % 4)) * 4;
surface->data = (BYTE*) malloc(surface->scanline * surface->height);
if (!surface->data)
return NULL;
ZeroMemory(surface->data, surface->scanline * surface->height);
surface->owner = TRUE;
}
return surface;
}
void rdtk_surface_free(rdtkSurface* surface)
{
if (!surface)
return;
if (surface->owner)
free(surface->data);
free(surface);
}

View File

@ -0,0 +1,45 @@
/**
* RdTk: Remote Desktop Toolkit
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RDTK_SURFACE_PRIVATE_H
#define RDTK_SURFACE_PRIVATE_H
#include <rdtk/rdtk.h>
struct rdtk_surface
{
int width;
int height;
int scanline;
BYTE* data;
BOOL owner;
};
#ifdef __cplusplus
extern "C" {
#endif
rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline);
void rdtk_surface_free(rdtkSurface* surface);
#ifdef __cplusplus
}
#endif
#endif /* RDTK_SURFACE_PRIVATE_H */

View File

@ -151,6 +151,8 @@ include_directories(${OPENSSL_INCLUDE_DIR})
set(${MODULE_PREFIX}_SRCS
shadow_client.c
shadow_client.h
shadow_lobby.c
shadow_lobby.h
shadow_input.c
shadow_input.h
shadow_screen.c
@ -167,8 +169,6 @@ set(${MODULE_PREFIX}_SRCS
shadow_encomsp.h
shadow_remdesk.c
shadow_remdesk.h
shadow_font.c
shadow_font.h
shadow_subsystem.c
shadow_subsystem.h
shadow_server.c
@ -217,6 +217,8 @@ list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client)
list(APPEND ${MODULE_PREFIX}_LIBS winpr)
list(APPEND ${MODULE_PREFIX}_LIBS winpr-makecert-tool)
list(APPEND ${MODULE_PREFIX}_LIBS rdtk)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT server)

View File

@ -29,7 +29,7 @@
#include "shadow_capture.h"
#include "shadow_channels.h"
#include "shadow_subsystem.h"
#include "shadow_font.h"
#include "shadow_lobby.h"
#ifdef __cplusplus
extern "C" {

View File

@ -33,8 +33,6 @@
#define TAG CLIENT_TAG("shadow")
extern rdpShadowFont* g_Font;
void shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
{
rdpSettings* settings;
@ -132,41 +130,6 @@ BOOL shadow_client_capabilities(freerdp_peer* peer)
return TRUE;
}
int shadow_client_init_lobby(rdpShadowClient* client)
{
int width;
int height;
RECTANGLE_16 invalidRect;
rdpShadowSurface* lobby;
rdpContext* context = (rdpContext*) client;
rdpSettings* settings = context->settings;
width = settings->DesktopWidth;
height = settings->DesktopHeight;
lobby = client->lobby = shadow_surface_new(client->server, 0, 0, width, height);
if (!client->lobby)
return -1;
freerdp_image_fill(lobby->data, PIXEL_FORMAT_XRGB32, lobby->scanline,
0, 0, lobby->width, lobby->height, 0x3BB9FF);
if (g_Font)
{
shadow_font_draw_text(lobby, 16, 16, g_Font, "Welcome to the shadow server!");
}
invalidRect.left = 0;
invalidRect.top = 0;
invalidRect.right = width;
invalidRect.bottom = height;
region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect);
return 1;
}
BOOL shadow_client_post_connect(freerdp_peer* peer)
{
int authStatus;

View File

@ -0,0 +1,64 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rdtk/rdtk.h>
#include "shadow.h"
#include "shadow_lobby.h"
int shadow_client_init_lobby(rdpShadowClient* client)
{
int width;
int height;
rdtkSurface* surface;
RECTANGLE_16 invalidRect;
rdpShadowSurface* lobby;
rdpContext* context = (rdpContext*) client;
rdpSettings* settings = context->settings;
width = settings->DesktopWidth;
height = settings->DesktopHeight;
lobby = client->lobby = shadow_surface_new(client->server, 0, 0, width, height);
if (!client->lobby)
return -1;
freerdp_image_fill(lobby->data, PIXEL_FORMAT_XRGB32, lobby->scanline,
0, 0, lobby->width, lobby->height, 0x3BB9FF);
surface = rdtk_surface_new(lobby->data, lobby->width, lobby->height, lobby->scanline);
rdtk_font_draw_text(surface, 16, 16, NULL, "Welcome to the shadow server!");
rdtk_surface_free(surface);
invalidRect.left = 0;
invalidRect.top = 0;
invalidRect.right = width;
invalidRect.bottom = height;
region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect);
return 1;
}

View File

@ -0,0 +1,39 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_SHADOW_SERVER_LOBBY_H
#define FREERDP_SHADOW_SERVER_LOBBY_H
#include <freerdp/server/shadow.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <rdtk/rdtk.h>
#ifdef __cplusplus
extern "C" {
#endif
int shadow_client_init_lobby(rdpShadowClient* client);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_LOBBY_H */

View File

@ -41,8 +41,6 @@
#define TAG SERVER_TAG("shadow")
rdpShadowFont* g_Font = NULL;
static COMMAND_LINE_ARGUMENT_A shadow_args[] =
{
{ "port", COMMAND_LINE_VALUE_REQUIRED, "<number>", NULL, NULL, -1, NULL, "Server port" },
@ -529,22 +527,6 @@ int shadow_server_init_certificate(rdpShadowServer* server)
return 1;
}
int shadow_server_init_fonts(rdpShadowServer* server)
{
char* fontPath;
rdpShadowFont* font;
fontPath = GetCombinedPath(server->ConfigPath, "shadow/fonts");
font = shadow_font_new(fontPath, "source_serif_pro_regular_12");
g_Font = font;
free(fontPath);
return 1;
}
int shadow_server_init(rdpShadowServer* server)
{
int status;
@ -569,8 +551,6 @@ int shadow_server_init(rdpShadowServer* server)
if (status < 0)
return -1;
shadow_server_init_fonts(server);
server->listener = freerdp_listener_new();
if (!server->listener)

View File

@ -47,6 +47,8 @@ WINPR_API int winpr_bitmap_write(const char* filename, BYTE* data, int width, in
WINPR_API int winpr_image_write(wImage* image, const char* filename);
WINPR_API int winpr_image_read(wImage* image, const char* filename);
WINPR_API int winpr_image_read_buffer(wImage* image, BYTE* buffer, int size);
WINPR_API wImage* winpr_image_new();
WINPR_API void winpr_image_free(wImage* image, BOOL bFreeBuffer);

View File

@ -182,6 +182,27 @@ int winpr_image_png_read_fp(wImage* image, FILE* fp)
return 1;
}
int winpr_image_png_read_buffer(wImage* image, BYTE* buffer, int size)
{
UINT32 width;
UINT32 height;
int lodepng_status;
lodepng_status = lodepng_decode32(&(image->data), &width, &height, buffer, size);
if (lodepng_status)
return -1;
image->width = width;
image->height = height;
image->bitsPerPixel = 32;
image->bytesPerPixel = 4;
image->scanline = image->bytesPerPixel * image->width;
return 1;
}
int winpr_image_bitmap_read_fp(wImage* image, FILE* fp)
{
int index;
@ -246,6 +267,75 @@ int winpr_image_bitmap_read_fp(wImage* image, FILE* fp)
return 1;
}
int winpr_image_bitmap_read_buffer(wImage* image, BYTE* buffer, int size)
{
int index;
BOOL vFlip;
BYTE* pSrcData;
BYTE* pDstData;
WINPR_BITMAP_FILE_HEADER bf;
WINPR_BITMAP_INFO_HEADER bi;
pSrcData = buffer;
CopyMemory(&bf, pSrcData, sizeof(WINPR_BITMAP_FILE_HEADER));
pSrcData += sizeof(WINPR_BITMAP_FILE_HEADER);
if ((bf.bfType[0] != 'B') || (bf.bfType[1] != 'M'))
return -1;
image->type = WINPR_IMAGE_BITMAP;
CopyMemory(&bi, pSrcData, sizeof(WINPR_BITMAP_INFO_HEADER));
pSrcData += sizeof(WINPR_BITMAP_INFO_HEADER);
if ((pSrcData - buffer) != bf.bfOffBits)
{
pSrcData = &buffer[bf.bfOffBits];
}
image->width = bi.biWidth;
if (bi.biHeight < 0)
{
vFlip = FALSE;
image->height = -1 * bi.biHeight;
}
else
{
vFlip = TRUE;
image->height = bi.biHeight;
}
image->bitsPerPixel = bi.biBitCount;
image->bytesPerPixel = (image->bitsPerPixel / 8);
image->scanline = (bi.biSizeImage / bi.biHeight);
image->data = (BYTE*) malloc(bi.biSizeImage);
if (!image->data)
return -1;
if (!vFlip)
{
CopyMemory(image->data, pSrcData, bi.biSizeImage);
pSrcData += bi.biSizeImage;
}
else
{
pDstData = &(image->data[(image->height - 1) * image->scanline]);
for (index = 0; index < image->height; index++)
{
CopyMemory(pDstData, pSrcData, image->scanline);
pSrcData += image->scanline;
pDstData -= image->scanline;
}
}
return 1;
}
int winpr_image_read(wImage* image, const char* filename)
{
FILE* fp;
@ -282,6 +372,31 @@ int winpr_image_read(wImage* image, const char* filename)
return status;
}
int winpr_image_read_buffer(wImage* image, BYTE* buffer, int size)
{
BYTE sig[8];
int status = -1;
if (size < 8)
return -1;
CopyMemory(sig, buffer, 8);
if ((sig[0] == 'B') && (sig[1] == 'M'))
{
image->type = WINPR_IMAGE_BITMAP;
status = winpr_image_bitmap_read_buffer(image, buffer, size);
}
else if ((sig[0] == 0x89) && (sig[1] == 'P') && (sig[2] == 'N') && (sig[3] == 'G') &&
(sig[4] == '\r') && (sig[5] == '\n') && (sig[6] == 0x1A) && (sig[7] == '\n'))
{
image->type = WINPR_IMAGE_PNG;
status = winpr_image_png_read_buffer(image, buffer, size);
}
return status;
}
wImage* winpr_image_new()
{
wImage* image;