Merge pull request #743 from FreeRDP/channels

Channel System Refactoring Phase 1
This commit is contained in:
Marc-André Moreau 2012-09-26 12:31:59 -07:00
commit 94dfdf5a4d
207 changed files with 5608 additions and 1164 deletions

View File

@ -170,6 +170,8 @@ set(FREERDP_KEYMAP_PATH "${FREERDP_DATA_PATH}/keymaps")
# Path to put plugins
set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp")
set(FREERDP_CLIENT_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}/client")
set(FREERDP_SERVER_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}/server")
# Path to put extensions
set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp/extensions")

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -32,3 +30,7 @@ foreach(FILEPATH ${FILEPATHS})
endif()
endforeach(FILEPATH)
if(WITH_SERVER_CHANNELS)
add_subdirectory(server)
endif()

View File

@ -0,0 +1,31 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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 "audin")
set(MODULE_PREFIX "CHANNEL_AUDIN")
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
if(WITH_SERVER_CHANNELS)
add_subdirectory(server)
set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE)
set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE)
set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE)
endif()

View File

@ -0,0 +1,10 @@
set(CHANNEL_TYPE "dynamic")
set(CHANNEL_SHORT_NAME "audin")
set(CHANNEL_LONG_NAME "Audio Input Redirection Virtual Channel Extension")
set(CHANNEL_SPECIFICATIONS "[MS-RDPEAI]")
string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION)
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON)

View File

@ -41,4 +41,3 @@ endif()
if(WITH_PULSEAUDIO)
add_subdirectory(pulse)
endif()

View File

@ -20,7 +20,19 @@
#ifndef __AUDIN_MAIN_H
#define __AUDIN_MAIN_H
#include "drdynvc_types.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <freerdp/dvc.h>
#include <freerdp/types.h>
#include <freerdp/utils/debug.h>
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__)
#else
#define DEBUG_DVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
#endif
typedef boolean (*AudinReceive) (uint8* data, int size, void* user_data);

View File

@ -0,0 +1,29 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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_PREFIX "CHANNEL_AUDIN_SERVER")
set(${MODULE_PREFIX}_SRCS
audin.c
PARENT_SCOPE)
if(WITH_MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE)
else()
set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE)
endif()

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -17,20 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(CLIPRDR_SRCS
cliprdr_constants.h
cliprdr_format.c
cliprdr_format.h
cliprdr_main.c
cliprdr_main.h)
add_library(cliprdr ${CLIPRDR_SRCS})
set_target_properties(cliprdr PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(cliprdr freerdp)
else()
target_link_libraries(cliprdr freerdp-utils)
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
install(TARGETS cliprdr DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -0,0 +1,36 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 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(CLIPRDR_SRCS
cliprdr_constants.h
cliprdr_format.c
cliprdr_format.h
cliprdr_main.c
cliprdr_main.h)
add_library(cliprdr ${CLIPRDR_SRCS})
set_target_properties(cliprdr PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(cliprdr freerdp)
else()
target_link_libraries(cliprdr freerdp-utils)
endif()
install(TARGETS cliprdr DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -143,8 +143,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3
}
else
{
format_name->name = freerdp_uniconv_in(cliprdr->uniconv, s->p, 32);
format_name->length = strlen(format_name->name);
format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) s->p, &format_name->name, 32 / 2);
}
stream_seek(s, 32);
@ -187,8 +186,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32
break;
}
format_name->name = freerdp_uniconv_in(cliprdr->uniconv, stream_get_tail(s), name_len);
format_name->length = strlen(format_name->name);
format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &format_name->name, name_len / 2);
stream_seek(s, name_len + 2);
}
}

View File

@ -82,8 +82,6 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, STREAM* s)
static void cliprdr_process_connect(rdpSvcPlugin* plugin)
{
DEBUG_CLIPRDR("connecting");
((cliprdrPlugin*) plugin)->uniconv = freerdp_uniconv_new();
}
void cliprdr_print_general_capability_flags(uint32 flags)
@ -267,11 +265,6 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
static void cliprdr_process_terminate(rdpSvcPlugin* plugin)
{
cliprdrPlugin* cliprdr_plugin = (cliprdrPlugin*) plugin;
if (cliprdr_plugin->uniconv != NULL)
freerdp_uniconv_free(cliprdr_plugin->uniconv);
xfree(plugin);
}

View File

@ -35,7 +35,6 @@ typedef struct _CLIPRDR_FORMAT_NAME CLIPRDR_FORMAT_NAME;
struct cliprdr_plugin
{
rdpSvcPlugin plugin;
UNICONV* uniconv;
boolean received_caps;
boolean use_long_format_names;
boolean stream_fileclip_enabled;

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -17,27 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(DRDYNVC_SRCS
drdynvc_main.c
drdynvc_main.h
drdynvc_types.h
dvcman.c
dvcman.h
)
add_library(drdynvc ${DRDYNVC_SRCS})
set_target_properties(drdynvc PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(drdynvc freerdp)
else()
target_link_libraries(drdynvc freerdp-utils)
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH})
if(NOT WIN32)
add_subdirectory(tsmf)
endif()
add_subdirectory(audin)

View File

@ -1,5 +1,5 @@
# FreeRDP: A Remote Desktop Protocol Client
# libfreerdp-server-channels cmake build script
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
@ -17,18 +17,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(FREERDP_SERVER_CHANNELS_SRCS
audin.c
rdpsnd.c)
set(DRDYNVC_SRCS
drdynvc_main.c
drdynvc_main.h
drdynvc_types.h
dvcman.c
dvcman.h
)
add_library(freerdp-server-channels ${FREERDP_SERVER_CHANNELS_SRCS})
set_target_properties(freerdp-server-channels PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
add_library(drdynvc ${DRDYNVC_SRCS})
set_target_properties(drdynvc PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(freerdp-server-channels freerdp)
target_link_libraries(drdynvc freerdp)
else()
target_link_libraries(freerdp-server-channels freerdp-channels freerdp-utils)
target_link_libraries(drdynvc freerdp-utils)
endif()
install(TARGETS freerdp-server-channels DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -17,20 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(RAIL_SRCS
rail_main.c
rail_main.h
rail_orders.c
rail_orders.h)
add_library(rail ${RAIL_SRCS})
set_target_properties(rail PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(rail freerdp)
else()
target_link_libraries(rail freerdp-utils)
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
install(TARGETS rail DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -17,20 +17,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(DISK_SRCS
disk_file.c
disk_file.h
disk_main.c)
set(RAIL_SRCS
rail_main.c
rail_main.h
rail_orders.c
rail_orders.h)
include_directories(..)
add_library(disk ${DISK_SRCS})
set_target_properties(disk PROPERTIES PREFIX "")
add_library(rail ${RAIL_SRCS})
set_target_properties(rail PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(disk freerdp)
target_link_libraries(rail freerdp)
else()
target_link_libraries(disk freerdp-utils)
target_link_libraries(rail freerdp-utils)
endif()
install(TARGETS disk DESTINATION ${FREERDP_PLUGIN_PATH})
install(TARGETS rail DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -29,7 +29,6 @@
struct rdp_rail_order
{
UNICONV* uniconv;
RDP_PLUGIN_DATA* plugin_data;
void* plugin;
RAIL_HANDSHAKE_ORDER handshake;

View File

@ -24,6 +24,7 @@
#include <freerdp/utils/rail.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/unicode.h>
#include "rail_orders.h"
@ -66,8 +67,8 @@ static const char* const RAIL_ORDER_TYPE_STRINGS[] =
void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_UNICODE_STRING* unicode_string)
{
char* buffer;
size_t length = 0;
WCHAR* buffer;
int length = 0;
if (unicode_string->string != NULL)
xfree(unicode_string->string);
@ -78,7 +79,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_
if (string == NULL || strlen(string) < 1)
return;
buffer = freerdp_uniconv_out(rail_order->uniconv, string, &length);
length = freerdp_AsciiToUnicodeAlloc(string, &buffer, 0) * 2;
unicode_string->string = (uint8*) buffer;
unicode_string->length = (uint16) length;
@ -253,15 +254,24 @@ void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam)
break;
case SPI_SET_WORK_AREA:
freerdp_write_rectangle_16(s, &sysparam->workArea);
stream_write_uint16(s, sysparam->workArea.left); /* left (2 bytes) */
stream_write_uint16(s, sysparam->workArea.top); /* top (2 bytes) */
stream_write_uint16(s, sysparam->workArea.right); /* right (2 bytes) */
stream_write_uint16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */
break;
case SPI_DISPLAY_CHANGE:
freerdp_write_rectangle_16(s, &sysparam->displayChange);
stream_write_uint16(s, sysparam->displayChange.left); /* left (2 bytes) */
stream_write_uint16(s, sysparam->displayChange.top); /* top (2 bytes) */
stream_write_uint16(s, sysparam->displayChange.right); /* right (2 bytes) */
stream_write_uint16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */
break;
case SPI_TASKBAR_POS:
freerdp_write_rectangle_16(s, &sysparam->taskbarPos);
stream_write_uint16(s, sysparam->taskbarPos.left); /* left (2 bytes) */
stream_write_uint16(s, sysparam->taskbarPos.top); /* top (2 bytes) */
stream_write_uint16(s, sysparam->taskbarPos.right); /* right (2 bytes) */
stream_write_uint16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */
break;
case SPI_SET_HIGH_CONTRAST:
@ -631,7 +641,7 @@ rdpRailOrder* rail_order_new()
if (rail_order != NULL)
{
rail_order->uniconv = freerdp_uniconv_new();
}
return rail_order;
@ -641,7 +651,7 @@ void rail_order_free(rdpRailOrder* rail_order)
{
if (rail_order != NULL)
{
freerdp_uniconv_free(rail_order->uniconv);
xfree(rail_order);
}
}

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -17,36 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(RDPDR_SRCS
rdpdr_constants.h
rdpdr_types.h
rdpdr_capabilities.c
rdpdr_capabilities.h
devman.c
devman.h
irp.c
irp.h
rdpdr_main.c
rdpdr_main.h)
add_library(rdpdr ${RDPDR_SRCS})
set_target_properties(rdpdr PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(rdpdr freerdp)
else()
target_link_libraries(rdpdr freerdp-utils)
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH})
if(NOT WIN32)
add_subdirectory(disk)
add_subdirectory(printer)
add_subdirectory(parallel)
add_subdirectory(serial)
endif()
if(WITH_PCSC)
add_subdirectory(smartcard)
endif()

View File

@ -0,0 +1,52 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 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(RDPDR_SRCS
rdpdr_constants.h
rdpdr_types.h
rdpdr_capabilities.c
rdpdr_capabilities.h
devman.c
devman.h
irp.c
irp.h
rdpdr_main.c
rdpdr_main.h)
add_library(rdpdr ${RDPDR_SRCS})
set_target_properties(rdpdr PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(rdpdr freerdp)
else()
target_link_libraries(rdpdr freerdp-utils)
endif()
install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH})
if(NOT WIN32)
add_subdirectory(disk)
add_subdirectory(printer)
add_subdirectory(parallel)
add_subdirectory(serial)
endif()
if(WITH_PCSC)
add_subdirectory(smartcard)
endif()

View File

@ -0,0 +1,40 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 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 "disk")
set(MODULE_PREFIX "CHANNEL_DEVICE_DISK")
set(${MODULE_PREFIX}_SRCS
disk_file.c
disk_file.h
disk_main.c)
include_directories(..)
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS freerdp winpr)
else()
set(${MODULE_PREFIX}_LIBS freerdp-utils winpr-synch winpr-thread)
endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -36,8 +36,10 @@
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/svc_plugin.h>
#ifdef HAVE_UNISTD_H
@ -425,7 +427,6 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
uint64 size;
char* fullpath;
struct STAT st;
UNICONV* uniconv;
struct timeval tv[2];
uint64 LastWriteTime;
uint32 FileAttributes;
@ -485,9 +486,8 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
stream_seek_uint8(input); /* ReplaceIfExists */
stream_seek_uint8(input); /* RootDirectory */
stream_read_uint32(input, FileNameLength);
uniconv = freerdp_uniconv_new();
s = freerdp_uniconv_in(uniconv, stream_get_tail(input), FileNameLength);
freerdp_uniconv_free(uniconv);
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(input), &s, FileNameLength / 2);
fullpath = disk_file_combine_fullpath(file->basepath, s);
xfree(s);
@ -517,12 +517,11 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, uint8 InitialQuery,
const char* path, STREAM* output)
{
struct dirent* ent;
char* ent_path;
struct STAT st;
UNICONV* uniconv;
size_t len;
int length;
boolean ret;
WCHAR* ent_path;
struct STAT st;
struct dirent* ent;
DEBUG_SVC("path %s FsInformationClass %d InitialQuery %d", path, FsInformationClass, InitialQuery);
@ -549,6 +548,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
do
{
ent = readdir(file->dir);
if (ent == NULL)
continue;
@ -570,27 +570,27 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
}
memset(&st, 0, sizeof(struct STAT));
ent_path = xmalloc(strlen(file->fullpath) + strlen(ent->d_name) + 2);
sprintf(ent_path, "%s/%s", file->fullpath, ent->d_name);
if (STAT(ent_path, &st) != 0)
ent_path = (WCHAR*) malloc(strlen(file->fullpath) + strlen(ent->d_name) + 2);
sprintf((char*) ent_path, "%s/%s", file->fullpath, ent->d_name);
if (STAT((char*) ent_path, &st) != 0)
{
DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno);
DEBUG_WARN("stat %s failed. errno = %d", (char*) ent_path, errno);
}
DEBUG_SVC(" pattern %s matched %s", file->pattern, ent_path);
xfree(ent_path);
uniconv = freerdp_uniconv_new();
ent_path = freerdp_uniconv_out(uniconv, ent->d_name, &len);
freerdp_uniconv_free(uniconv);
length = freerdp_AsciiToUnicodeAlloc(ent->d_name, &ent_path, 0) * 2;
ret = true;
switch (FsInformationClass)
{
case FileDirectoryInformation:
/* http://msdn.microsoft.com/en-us/library/cc232097.aspx */
stream_write_uint32(output, 64 + len); /* Length */
stream_check_size(output, 64 + len);
stream_write_uint32(output, 64 + length); /* Length */
stream_check_size(output, 64 + length);
stream_write_uint32(output, 0); /* NextEntryOffset */
stream_write_uint32(output, 0); /* FileIndex */
stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@ -600,14 +600,14 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
stream_write_uint64(output, st.st_size); /* EndOfFile */
stream_write_uint64(output, st.st_size); /* AllocationSize */
stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
stream_write_uint32(output, len); /* FileNameLength */
stream_write(output, ent_path, len);
stream_write_uint32(output, length); /* FileNameLength */
stream_write(output, ent_path, length);
break;
case FileFullDirectoryInformation:
/* http://msdn.microsoft.com/en-us/library/cc232068.aspx */
stream_write_uint32(output, 68 + len); /* Length */
stream_check_size(output, 68 + len);
stream_write_uint32(output, 68 + length); /* Length */
stream_check_size(output, 68 + length);
stream_write_uint32(output, 0); /* NextEntryOffset */
stream_write_uint32(output, 0); /* FileIndex */
stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@ -617,15 +617,15 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
stream_write_uint64(output, st.st_size); /* EndOfFile */
stream_write_uint64(output, st.st_size); /* AllocationSize */
stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
stream_write_uint32(output, len); /* FileNameLength */
stream_write_uint32(output, length); /* FileNameLength */
stream_write_uint32(output, 0); /* EaSize */
stream_write(output, ent_path, len);
stream_write(output, ent_path, length);
break;
case FileBothDirectoryInformation:
/* http://msdn.microsoft.com/en-us/library/cc232095.aspx */
stream_write_uint32(output, 93 + len); /* Length */
stream_check_size(output, 93 + len);
stream_write_uint32(output, 93 + length); /* Length */
stream_check_size(output, 93 + length);
stream_write_uint32(output, 0); /* NextEntryOffset */
stream_write_uint32(output, 0); /* FileIndex */
stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@ -635,22 +635,22 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
stream_write_uint64(output, st.st_size); /* EndOfFile */
stream_write_uint64(output, st.st_size); /* AllocationSize */
stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
stream_write_uint32(output, len); /* FileNameLength */
stream_write_uint32(output, length); /* FileNameLength */
stream_write_uint32(output, 0); /* EaSize */
stream_write_uint8(output, 0); /* ShortNameLength */
/* Reserved(1), MUST NOT be added! */
stream_write_zero(output, 24); /* ShortName */
stream_write(output, ent_path, len);
stream_write(output, ent_path, length);
break;
case FileNamesInformation:
/* http://msdn.microsoft.com/en-us/library/cc232077.aspx */
stream_write_uint32(output, 12 + len); /* Length */
stream_check_size(output, 12 + len);
stream_write_uint32(output, 12 + length); /* Length */
stream_check_size(output, 12 + length);
stream_write_uint32(output, 0); /* NextEntryOffset */
stream_write_uint32(output, 0); /* FileIndex */
stream_write_uint32(output, len); /* FileNameLength */
stream_write(output, ent_path, len);
stream_write_uint32(output, length); /* FileNameLength */
stream_write(output, ent_path, length);
break;
default:

View File

@ -39,14 +39,17 @@
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/list.h>
#include <freerdp/utils/thread.h>
#include <freerdp/utils/svc_plugin.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include "rdpdr_constants.h"
#include "rdpdr_types.h"
#include "disk_file.h"
typedef struct _DISK_DEVICE DISK_DEVICE;
struct _DISK_DEVICE
{
DEVICE device;
@ -54,15 +57,17 @@ struct _DISK_DEVICE
char* path;
LIST* files;
HANDLE mutex;
HANDLE thread;
LIST* irp_list;
freerdp_thread* thread;
HANDLE irpEvent;
HANDLE stopEvent;
DEVMAN* devman;
pcRegisterDevice UnregisterDevice;
};
static uint32
disk_map_posix_err(int fs_errno)
static uint32 disk_map_posix_err(int fs_errno)
{
uint32 rc;
@ -90,7 +95,9 @@ disk_map_posix_err(int fs_errno)
rc = STATUS_UNSUCCESSFUL;
break;
}
DEBUG_SVC("errno 0x%x mapped to 0x%x", fs_errno, rc);
return rc;
}
@ -101,7 +108,8 @@ static DISK_FILE* disk_get_file_by_id(DISK_DEVICE* disk, uint32 id)
for (item = disk->files->head; item; item = item->next)
{
file = (DISK_FILE*)item->data;
file = (DISK_FILE*) item->data;
if (file->id == id)
return file;
}
@ -115,7 +123,6 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
uint32 CreateDisposition;
uint32 CreateOptions;
uint32 PathLength;
UNICONV* uniconv;
char* path;
uint32 FileId;
uint8 Information;
@ -126,9 +133,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
stream_read_uint32(irp->input, CreateOptions);
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
FileId = irp->devman->id_sequence++;
@ -238,7 +243,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
}
else
{
buffer = (uint8*)xmalloc(Length);
buffer = (uint8*) xmalloc(Length);
if (!disk_file_read(file, buffer, &Length))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -255,11 +260,13 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
}
stream_write_uint32(irp->output, Length);
if (Length > 0)
{
stream_check_size(irp->output, Length);
stream_write(irp->output, buffer, Length);
}
xfree(buffer);
irp->Complete(irp);
@ -378,11 +385,10 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
STREAM* output = irp->output;
struct STATVFS svfst;
struct STAT st;
UNICONV* uniconv;
char *volumeLabel = {"FREERDP"}; /* TODO:: Add sub routine to correctly pick up Volume Label name for each O/S supported*/
char *diskType = {"FAT32"};
char* outStr;
size_t len;
char* volumeLabel = {"FREERDP"};
char* diskType = {"FAT32"};
WCHAR* outStr;
int length;
stream_read_uint32(irp->input, FsInformationClass);
@ -393,17 +399,15 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
{
case FileFsVolumeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
uniconv = freerdp_uniconv_new();
outStr = freerdp_uniconv_out(uniconv, volumeLabel, &len);
freerdp_uniconv_free(uniconv);
stream_write_uint32(output, 17 + len); /* Length */
stream_check_size(output, 17 + len);
length = freerdp_AsciiToUnicodeAlloc(volumeLabel, &outStr, 0) * 2;
stream_write_uint32(output, 17 + length); /* Length */
stream_check_size(output, 17 + length);
stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */
stream_write_uint32(output, svfst.f_fsid); /* VolumeSerialNumber */
stream_write_uint32(output, len); /* VolumeLabelLength */
stream_write_uint32(output, length); /* VolumeLabelLength */
stream_write_uint8(output, 0); /* SupportsObjects */
/* Reserved(1), MUST NOT be added! */
stream_write(output, outStr, len); /* VolumeLabel (Unicode) */
stream_write(output, outStr, length); /* VolumeLabel (Unicode) */
xfree(outStr);
break;
@ -419,19 +423,16 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
case FileFsAttributeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
uniconv = freerdp_uniconv_new();
outStr = freerdp_uniconv_out(uniconv, diskType, &len);
freerdp_uniconv_free(uniconv);
stream_write_uint32(output, 12 + len); /* Length */
stream_check_size(output, 12 + len);
length = freerdp_AsciiToUnicodeAlloc(diskType, &outStr, 0) * 2;
stream_write_uint32(output, 12 + length); /* Length */
stream_check_size(output, 12 + length);
stream_write_uint32(output,
FILE_CASE_SENSITIVE_SEARCH |
FILE_CASE_PRESERVED_NAMES |
FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
stream_write_uint32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */
stream_write_uint32(output, len); /* FileSystemNameLength */
stream_write(output, outStr, len); /* FileSystemName (Unicode) */
stream_write_uint32(output, length); /* FileSystemNameLength */
stream_write(output, outStr, length); /* FileSystemName (Unicode) */
xfree(outStr);
break;
@ -470,7 +471,6 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
uint32 FsInformationClass;
uint8 InitialQuery;
uint32 PathLength;
UNICONV* uniconv;
char* path;
stream_read_uint32(irp->input, FsInformationClass);
@ -478,9 +478,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
stream_read_uint32(irp->input, PathLength);
stream_seek(irp->input, 23); /* Padding */
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
file = disk_get_file_by_id(disk, irp->FileId);
@ -581,12 +579,14 @@ static void disk_process_irp_list(DISK_DEVICE* disk)
while (1)
{
if (freerdp_thread_is_stopped(disk->thread))
if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0)
break;
freerdp_thread_lock(disk->thread);
irp = (IRP*)list_dequeue(disk->irp_list);
freerdp_thread_unlock(disk->thread);
WaitForSingleObject(disk->mutex, INFINITE);
irp = (IRP*) list_dequeue(disk->irp_list);
ReleaseMutex(disk->mutex);
if (irp == NULL)
break;
@ -597,63 +597,65 @@ static void disk_process_irp_list(DISK_DEVICE* disk)
static void* disk_thread_func(void* arg)
{
DISK_DEVICE* disk = (DISK_DEVICE*)arg;
DISK_DEVICE* disk = (DISK_DEVICE*) arg;
while (1)
{
freerdp_thread_wait(disk->thread);
WaitForSingleObject(disk->irpEvent, INFINITE);
if (freerdp_thread_is_stopped(disk->thread))
if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0)
break;
freerdp_thread_reset(disk->thread);
ResetEvent(disk->irpEvent);
disk_process_irp_list(disk);
}
freerdp_thread_quit(disk->thread);
return NULL;
}
static void disk_irp_request(DEVICE* device, IRP* irp)
{
DISK_DEVICE* disk = (DISK_DEVICE*)device;
DISK_DEVICE* disk = (DISK_DEVICE*) device;
freerdp_thread_lock(disk->thread);
WaitForSingleObject(disk->mutex, INFINITE);
list_enqueue(disk->irp_list, irp);
freerdp_thread_unlock(disk->thread);
ReleaseMutex(disk->mutex);
freerdp_thread_signal(disk->thread);
SetEvent(disk->irpEvent);
}
static void disk_free(DEVICE* device)
{
DISK_DEVICE* disk = (DISK_DEVICE*)device;
IRP* irp;
DISK_FILE* file;
DISK_DEVICE* disk = (DISK_DEVICE*) device;
freerdp_thread_stop(disk->thread);
freerdp_thread_free(disk->thread);
SetEvent(disk->stopEvent);
CloseHandle(disk->thread);
CloseHandle(disk->irpEvent);
CloseHandle(disk->mutex);
while ((irp = (IRP*)list_dequeue(disk->irp_list)) != NULL)
while ((irp = (IRP*) list_dequeue(disk->irp_list)) != NULL)
irp->Discard(irp);
list_free(disk->irp_list);
while ((file = (DISK_FILE*)list_dequeue(disk->files)) != NULL)
while ((file = (DISK_FILE*) list_dequeue(disk->files)) != NULL)
disk_file_free(file);
list_free(disk->files);
xfree(disk);
}
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
DISK_DEVICE* disk;
char* name;
char* path;
int i, len;
int i, length;
DISK_DEVICE* disk;
name = (char*)pEntryPoints->plugin_data->data[1];
path = (char*)pEntryPoints->plugin_data->data[2];
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
if (name[0] && path[0])
{
@ -664,20 +666,24 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
disk->device.IRPRequest = disk_irp_request;
disk->device.Free = disk_free;
len = strlen(name);
disk->device.data = stream_new(len + 1);
for (i = 0; i <= len; i++)
length = strlen(name);
disk->device.data = stream_new(length + 1);
for (i = 0; i <= length; i++)
stream_write_uint8(disk->device.data, name[i] < 0 ? '_' : name[i]);
disk->path = path;
disk->files = list_new();
disk->irp_list = list_new();
disk->thread = freerdp_thread_new();
disk->mutex = CreateMutex(NULL, FALSE, NULL);
disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) disk_thread_func, disk, CREATE_SUSPENDED, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)disk);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
freerdp_thread_start(disk->thread, disk_thread_func, disk);
ResumeThread(disk->thread);
}
return 0;

View File

@ -50,6 +50,7 @@
#include <freerdp/utils/thread.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpdr_constants.h"
@ -70,18 +71,15 @@ typedef struct _PARALLEL_DEVICE PARALLEL_DEVICE;
static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
{
uint32 PathLength;
char* path;
UNICONV* uniconv;
uint32 PathLength;
stream_seek(irp->input, 28);
/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
parallel->id = irp->devman->id_sequence++;
parallel->file = open(parallel->path, O_RDWR);

View File

@ -230,16 +230,15 @@ static void printer_free(DEVICE* device)
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
{
PRINTER_DEVICE* printer_dev;
char* port;
UNICONV* uniconv;
uint32 Flags;
size_t DriverNameLen;
char* DriverName;
size_t PrintNameLen;
char* PrintName;
int DriverNameLen;
WCHAR* DriverName;
int PrintNameLen;
WCHAR* PrintName;
uint32 CachedFieldsLen;
uint8* CachedPrinterConfigData;
PRINTER_DEVICE* printer_dev;
port = xmalloc(10);
snprintf(port, 10, "PRN%d", printer->id);
@ -259,13 +258,12 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
DEBUG_SVC("Printer %s registered", printer->name);
Flags = 0;
if (printer->is_default)
Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;
uniconv = freerdp_uniconv_new();
DriverName = freerdp_uniconv_out(uniconv, printer->driver, &DriverNameLen);
PrintName = freerdp_uniconv_out(uniconv, printer->name, &PrintNameLen);
freerdp_uniconv_free(uniconv);
DriverNameLen = freerdp_AsciiToUnicodeAlloc(printer->driver, &DriverName, 0) * 2;
PrintNameLen = freerdp_AsciiToUnicodeAlloc(printer->name, &PrintName, 0) * 2;
printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
@ -279,6 +277,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
stream_write_uint16(printer_dev->device.data, 0);
stream_write(printer_dev->device.data, PrintName, PrintNameLen);
stream_write_uint16(printer_dev->device.data, 0);
if (CachedFieldsLen > 0)
{
stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);

View File

@ -94,17 +94,15 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr)
static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
{
char* s;
STREAM* data_out;
UNICONV* uniconv;
WCHAR* computerNameW;
size_t computerNameLenW;
uniconv = freerdp_uniconv_new();
if (!rdpdr->computerName[0])
gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
s = freerdp_uniconv_out(uniconv, rdpdr->computerName, &computerNameLenW);
computerNameLenW = freerdp_AsciiToUnicodeAlloc(rdpdr->computerName, &computerNameW, 0) * 2;
data_out = stream_new(16 + computerNameLenW + 2);
stream_write_uint16(data_out, RDPDR_CTYP_CORE);
@ -113,11 +111,10 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
stream_write_uint32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
stream_write_uint32(data_out, 0); /* codePage, must be set to zero */
stream_write_uint32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */
stream_write(data_out, s, computerNameLenW);
stream_write(data_out, computerNameW, computerNameLenW);
stream_write_uint16(data_out, 0); /* null terminator */
xfree(s);
freerdp_uniconv_free(uniconv);
xfree(computerNameW);
svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out);
}
@ -235,11 +232,11 @@ static boolean rdpdr_process_irp(rdpdrPlugin* rdpdr, STREAM* data_in)
static void rdpdr_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
rdpdrPlugin* rdpdr = (rdpdrPlugin*) plugin;
uint16 component;
uint16 packetID;
uint32 deviceID;
uint32 status;
rdpdrPlugin* rdpdr = (rdpdrPlugin*) plugin;
stream_read_uint16(data_in, component);
stream_read_uint16(data_in, packetID);

View File

@ -79,23 +79,21 @@ static boolean serial_check_fds(SERIAL_DEVICE* serial);
static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
{
char* path;
SERIAL_TTY* tty;
uint32 PathLength;
uint32 FileId;
char* path;
UNICONV* uniconv;
stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
FileId = irp->devman->id_sequence++;
tty = serial_tty_new(serial->path, FileId);
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -122,6 +120,7 @@ static void serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp)
SERIAL_TTY* tty;
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -153,6 +152,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
DEBUG_SVC("length %u offset %llu", Length, Offset);
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -179,11 +179,13 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
}
stream_write_uint32(irp->output, Length);
if (Length > 0)
{
stream_check_size(irp->output, Length);
stream_write(irp->output, buffer, Length);
}
xfree(buffer);
irp->Complete(irp);
@ -202,6 +204,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
DEBUG_SVC("length %u offset %llu", Length, Offset);
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -243,6 +246,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
stream_seek(irp->input, 20); /* Padding */
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;

View File

@ -37,33 +37,34 @@
#include "scard_main.h"
static void
scard_free(DEVICE* dev)
static void scard_free(DEVICE* dev)
{
SCARD_DEVICE* scard = (SCARD_DEVICE*)dev;
IRP* irp;
COMPLETIONIDINFO* CompletionIdInfo;
SCARD_DEVICE* scard = (SCARD_DEVICE*) dev;
freerdp_thread_stop(scard->thread);
freerdp_thread_free(scard->thread);
while ((irp = (IRP*)list_dequeue(scard->irp_list)) != NULL)
while ((irp = (IRP*) list_dequeue(scard->irp_list)) != NULL)
irp->Discard(irp);
list_free(scard->irp_list);
/* Begin TS Client defect workaround. */
while ((CompletionIdInfo = (COMPLETIONIDINFO*)list_dequeue(scard->CompletionIds)) != NULL)
while ((CompletionIdInfo = (COMPLETIONIDINFO*) list_dequeue(scard->CompletionIds)) != NULL)
xfree(CompletionIdInfo);
list_free(scard->CompletionIds);
/* End TS Client defect workaround. */
xfree(dev);
return;
}
static void
scard_process_irp(SCARD_DEVICE* scard, IRP* irp)
static void scard_process_irp(SCARD_DEVICE* scard, IRP* irp)
{
switch (irp->MajorFunction)
{
@ -80,16 +81,14 @@ scard_process_irp(SCARD_DEVICE* scard, IRP* irp)
}
}
static void
scard_process_irp_list(SCARD_DEVICE* scard)
static void scard_process_irp_list(SCARD_DEVICE* scard)
{
IRP *irp;
IRP* irp;
while (!freerdp_thread_is_stopped(scard->thread))
{
freerdp_thread_lock(scard->thread);
irp = (IRP *) list_dequeue(scard->irp_list);
irp = (IRP*) list_dequeue(scard->irp_list);
freerdp_thread_unlock(scard->thread);
if (irp == NULL)
@ -99,16 +98,14 @@ scard_process_irp_list(SCARD_DEVICE* scard)
}
}
struct scard_irp_thread_args {
struct scard_irp_thread_args
{
SCARD_DEVICE* scard;
IRP* irp;
freerdp_thread* thread;
};
static void
scard_process_irp_thread_func(struct scard_irp_thread_args* args)
static void scard_process_irp_thread_func(struct scard_irp_thread_args* args)
{
scard_process_irp(args->scard, args->irp);
@ -116,9 +113,7 @@ scard_process_irp_thread_func(struct scard_irp_thread_args* args)
xfree(args);
}
static void *
scard_thread_func(void* arg)
static void* scard_thread_func(void* arg)
{
SCARD_DEVICE* scard = (SCARD_DEVICE*) arg;
@ -138,16 +133,14 @@ scard_thread_func(void* arg)
return NULL;
}
/* Begin TS Client defect workaround. */
static COMPLETIONIDINFO*
scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
static COMPLETIONIDINFO* scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
{
/*
* Search from the beginning of the LIST for one outstanding "CompletionID"
* that matches the one passed in. If there is one, mark it as a duplicate
* if it is not already marked.
*/
/*
* Search from the beginning of the LIST for one outstanding "CompletionID"
* that matches the one passed in. If there is one, mark it as a duplicate
* if it is not already marked.
*/
LIST_ITEM* item;
COMPLETIONIDINFO* CompletionIdInfo;
@ -164,18 +157,18 @@ scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
return CompletionIdInfo;
}
}
return NULL; /* Either no items in the list or no match. */
}
static boolean
scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
static boolean scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
{
/*
* Search from the end of the LIST for one outstanding "CompletionID"
* that matches the one passed in. Remove it from the list and free the
* memory associated with it. Return whether or not it was marked
* as a duplicate.
*/
/*
* Search from the end of the LIST for one outstanding "CompletionID"
* that matches the one passed in. Remove it from the list and free the
* memory associated with it. Return whether or not it was marked
* as a duplicate.
*/
LIST_ITEM* item;
COMPLETIONIDINFO* CompletionIdInfo;
boolean duplicate;
@ -195,21 +188,22 @@ scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId)
return duplicate;
}
}
/* This function should only be called when there is
* at least one outstanding CompletionID item in the list.
*/
DEBUG_WARN("Error!!! No CompletionIDs (or no matching IDs) in the list!");
return false;
}
static void
scard_irp_complete(IRP* irp)
static void scard_irp_complete(IRP* irp)
{
/* This function is (mostly) a copy of the statically-declared "irp_complete()"
* function except that this function adds extra operations for the
* smart card's handling of duplicate "CompletionID"s. This function needs
* to be in this file so that "scard_irp_request()" can reference it.
*/
/* This function is (mostly) a copy of the statically-declared "irp_complete()"
* function except that this function adds extra operations for the
* smart card's handling of duplicate "CompletionID"s. This function needs
* to be in this file so that "scard_irp_request()" can reference it.
*/
int pos;
boolean duplicate;
SCARD_DEVICE* scard = (SCARD_DEVICE*)irp->device;
@ -247,13 +241,10 @@ scard_irp_complete(IRP* irp)
}
/* End TS Client defect workaround. */
static void
scard_irp_request(DEVICE* device, IRP* irp)
static void scard_irp_request(DEVICE* device, IRP* irp)
{
COMPLETIONIDINFO* CompletionIdInfo;
SCARD_DEVICE* scard = (SCARD_DEVICE*)device;
SCARD_DEVICE* scard = (SCARD_DEVICE*) device;
/* Begin TS Client defect workaround. */
CompletionIdInfo= xnew(COMPLETIONIDINFO);

View File

@ -1,9 +1,7 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 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.
@ -17,30 +15,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(RDPSND_SRCS
rdpsnd_main.c
rdpsnd_main.h)
set(MODULE_NAME "rdpsnd")
set(MODULE_PREFIX "CHANNEL_RDPSND")
add_library(rdpsnd ${RDPSND_SRCS})
set_target_properties(rdpsnd PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(rdpsnd freerdp)
else()
target_link_libraries(rdpsnd freerdp-utils)
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()
install(TARGETS rdpsnd DESTINATION ${FREERDP_PLUGIN_PATH})
if(WITH_ALSA)
add_subdirectory(alsa)
if(WITH_SERVER_CHANNELS)
add_subdirectory(server)
set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE)
set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE)
set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE)
endif()
if(WITH_PULSEAUDIO)
add_subdirectory(pulse)
endif()
if(WITH_MACAUDIO)
add_subdirectory(mac_audio)
endif()

View File

@ -4,6 +4,8 @@ set(CHANNEL_SHORT_NAME "rdpsnd")
set(CHANNEL_LONG_NAME "Audio Output Virtual Channel Extension")
set(CHANNEL_SPECIFICATIONS "[MS-RDPEA]")
string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION)
if(WIN32)
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF)
else()

View File

@ -0,0 +1,46 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 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(RDPSND_SRCS
rdpsnd_main.c
rdpsnd_main.h)
add_library(rdpsnd ${RDPSND_SRCS})
set_target_properties(rdpsnd PROPERTIES PREFIX "")
if(WITH_MONOLITHIC_BUILD)
target_link_libraries(rdpsnd freerdp)
else()
target_link_libraries(rdpsnd freerdp-utils)
endif()
install(TARGETS rdpsnd DESTINATION ${FREERDP_PLUGIN_PATH})
if(WITH_ALSA)
add_subdirectory(alsa)
endif()
if(WITH_PULSEAUDIO)
add_subdirectory(pulse)
endif()
if(WITH_MACAUDIO)
add_subdirectory(mac_audio)
endif()

View File

@ -0,0 +1,29 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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_PREFIX "CHANNEL_RDPSND_SERVER")
set(${MODULE_PREFIX}_SRCS
rdpsnd.c
PARENT_SCOPE)
if(WITH_MONOLITHIC_BUILD)
set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE)
else()
set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE)
endif()

View File

@ -0,0 +1,21 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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.
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()

View File

@ -0,0 +1,9 @@
set(CHANNEL_TYPE "static")
set(CHANNEL_SHORT_NAME "sample")
set(CHANNEL_LONG_NAME "Sample Virtual Channel Extension")
set(CHANNEL_SPECIFICATIONS "")
string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION)
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF)

View File

@ -0,0 +1,34 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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.
foreach(MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES})
string(TOUPPER "CHANNEL_${MODULE_NAME}" MODULE_PREFIX)
message(STATUS "Adding built-in channel server module: ${MODULE_NAME}")
foreach(SRC ${${MODULE_PREFIX}_SERVER_SRCS})
set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${MODULE_NAME}/server/${SRC}")
endforeach()
set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${MODULE_PREFIX}_SERVER_LIBS})
endforeach()
add_library(freerdp-server ${CHANNEL_SERVER_SRCS})
set_target_properties(freerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
target_link_libraries(freerdp-server ${CHANNEL_SERVER_LIBS})
install(TARGETS freerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -1,8 +0,0 @@
set(CHANNEL_TYPE "static")
set(CHANNEL_SHORT_NAME "skel")
set(CHANNEL_LONG_NAME "Skeleton Code Virtual Channel Extension")
set(CHANNEL_SPECIFICATIONS "")
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF)

View File

@ -0,0 +1,22 @@
# FreeRDP: A Remote Desktop Protocol Client
# FreeRDP cmake build script
#
# Copyright 2012 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.
if(WITH_CLIENT_CHANNELS)
add_subdirectory(client)
endif()

View File

@ -0,0 +1,15 @@
set(CHANNEL_TYPE "dynamic")
set(CHANNEL_SHORT_NAME "tsmf")
set(CHANNEL_LONG_NAME "Video Redirection Virtual Channel Extension")
set(CHANNEL_SPECIFICATIONS "[MS-RDPEV]")
string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION)
if(WIN32)
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF)
else()
option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON)
endif()

View File

@ -20,7 +20,7 @@
#ifndef __TSMF_AUDIO_H
#define __TSMF_AUDIO_H
#include "drdynvc_types.h"
#include "tsmf_types.h"
typedef struct _ITSMFAudioDevice ITSMFAudioDevice;

Some files were not shown because too many files have changed in this diff Show More