Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pjd committed Apr 22, 2012
2 parents 0e8bced + a1551d0 commit 4b6119c
Show file tree
Hide file tree
Showing 90 changed files with 5,713 additions and 4,165 deletions.
14 changes: 10 additions & 4 deletions channels/drdynvc/audin/alsa/audin_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,20 @@ int FreeRDPAudinDeviceEntry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
alsa->iface.SetFormat = audin_alsa_set_format;
alsa->iface.Close = audin_alsa_close;
alsa->iface.Free = audin_alsa_free;
alsa->device_name[0] = '\0';

data = pEntryPoints->plugin_data;
if (data && data->data[0] && strcmp(data->data[0], "audin") == 0 &&
data->data[1] && strcmp(data->data[1], "alsa") == 0)
if (data)
{
if (data[2].size)
strncpy(alsa->device_name, (char*)data->data[2], sizeof(alsa->device_name));
char *data2 = (char *) (data->data[2]);
if (data->data[0] && (strcmp(data->data[0], "audin") == 0) &&
data->data[1] && (strcmp(data->data[1], "alsa") == 0) &&
data2 && (*data2 != '\0'))
{
strncpy(alsa->device_name, data2, sizeof(alsa->device_name));
}
}

if (alsa->device_name[0] == '\0')
{
strcpy(alsa->device_name, "default");
Expand Down
19 changes: 3 additions & 16 deletions channels/rdpdr/disk/disk_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@
#include "rdpdr_types.h"
#include "disk_file.h"

#define FILE_TIME_SYSTEM_TO_RDP(_t) \
(((uint64)(_t) + 11644473600LL) * 10000000LL)
#define FILE_TIME_RDP_TO_SYSTEM(_t) \
(((_t) == 0LL || (_t) == (uint64)(-1LL)) ? 0 : (time_t)((_t) / 10000000LL - 11644473600LL))

#define FILE_ATTR_SYSTEM_TO_RDP(_f, _st) ( \
(S_ISDIR(_st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : 0) | \
(_f->filename[0] == '.' ? FILE_ATTRIBUTE_HIDDEN : 0) | \
(_f->delete_pending ? FILE_ATTRIBUTE_TEMPORARY : 0) | \
(st.st_mode & S_IWUSR ? 0 : FILE_ATTRIBUTE_READONLY))


static boolean disk_file_wildcard_match(const char* pattern, const char* filename)
{
const char *p = pattern, *f = filename;
Expand Down Expand Up @@ -194,7 +182,7 @@ static boolean disk_file_init(DISK_FILE* file, uint32 DesiredAccess, uint32 Crea
boolean exists;
#ifndef WIN32
boolean largeFile = false;
#endif
#endif
int oflag = 0;

if (STAT(file->fullpath, &st) == 0)
Expand All @@ -203,7 +191,7 @@ static boolean disk_file_init(DISK_FILE* file, uint32 DesiredAccess, uint32 Crea
#ifndef WIN32
if (st.st_size > (unsigned long)0x07fffffff)
largeFile = true;
#endif
#endif
exists = true;
}
else
Expand Down Expand Up @@ -582,9 +570,8 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno);
}

xfree(ent_path);

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);
Expand Down
21 changes: 21 additions & 0 deletions channels/rdpdr/disk/disk_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define __DISK_FILE_H

#include <sys/types.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
#include <dirent.h>

Expand All @@ -30,19 +31,39 @@
#define OPEN open
#define LSEEK lseek
#define FSTAT fstat
#define STATVFS statvfs
#elif defined(__APPLE__) || defined(__FreeBSD__)
#define STAT stat
#define OPEN open
#define LSEEK lseek
#define FSTAT fstat
#define STATVFS statvfs
#define O_LARGEFILE 0
#else
#define STAT stat64
#define OPEN open64
#define LSEEK lseek64
#define FSTAT fstat64
#define STATVFS statvfs64
#endif

#define EPOCH_DIFF 11644473600LL

#define FILE_TIME_SYSTEM_TO_RDP(_t) \
(((uint64)(_t) + EPOCH_DIFF) * 10000000LL)
#define FILE_TIME_RDP_TO_SYSTEM(_t) \
(((_t) == 0LL || (_t) == (uint64)(-1LL)) ? 0 : (time_t)((_t) / 10000000LL - EPOCH_DIFF))

#define FILE_ATTR_SYSTEM_TO_RDP(_f, _st) ( \
(S_ISDIR(_st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : 0) | \
(_f->filename[0] == '.' ? FILE_ATTRIBUTE_HIDDEN : 0) | \
(_f->delete_pending ? FILE_ATTRIBUTE_TEMPORARY : 0) | \
(st.st_mode & S_IWUSR ? 0 : FILE_ATTRIBUTE_READONLY))





typedef struct _DISK_FILE DISK_FILE;
struct _DISK_FILE
{
Expand Down
78 changes: 54 additions & 24 deletions channels/rdpdr/disk/disk_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
* limitations under the License.
*/

#ifndef _WIN32
#define __USE_LARGEFILE64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE

#include <sys/time.h>
#endif


#include "config.h"
#include <errno.h>
#include <stdio.h>
Expand All @@ -44,8 +53,10 @@ struct _DISK_DEVICE

LIST* irp_list;
freerdp_thread* thread;
};

DEVMAN* devman;
pcRegisterDevice UnregisterDevice;
};

static uint32
disk_map_posix_err(int fs_errno)
Expand Down Expand Up @@ -117,6 +128,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
freerdp_uniconv_free(uniconv);

FileId = irp->devman->id_sequence++;

file = disk_file_new(disk->path, path, FileId,
DesiredAccess, CreateDisposition, CreateOptions);

Expand All @@ -135,7 +147,6 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)

/* map errno to windows result*/
irp->IoStatus = disk_map_posix_err(file->err);

disk_file_free(file);
}
else
Expand Down Expand Up @@ -362,55 +373,74 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
{
uint32 FsInformationClass;
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;

stream_read_uint32(irp->input, FsInformationClass);

STATVFS(disk->path, &svfst);
STAT(disk->path, &st);

switch (FsInformationClass)
{
case FileFsVolumeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
stream_write_uint32(output, 34); /* Length */
stream_check_size(output, 34);
stream_write_uint64(output, 0); /* VolumeCreationTime */
stream_write_uint32(output, 0); /* VolumeSerialNumber */
stream_write_uint32(output, 16); /* VolumeLabelLength */
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);
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_uint8(output, 0); /* SupportsObjects */
stream_write_uint8(output, 0); /* Reserved */
stream_write(output, "F\0R\0E\0E\0R\0D\0P\0\0\0", 16); /* VolumeLabel (Unicode) */
/* Reserved(1), MUST NOT be added! */
stream_write(output, outStr, len); /* VolumeLabel (Unicode) */
xfree(outStr);
break;

case FileFsSizeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232107.aspx */
stream_write_uint32(output, 24); /* Length */
stream_check_size(output, 24);
stream_write_uint64(output, 0x1000000); /* TotalAllocationUnits */
stream_write_uint64(output, 0x800000); /* AvailableAllocationUnits */
stream_write_uint64(output, svfst.f_blocks); /* TotalAllocationUnits */
stream_write_uint64(output, svfst.f_bavail); /* AvailableAllocationUnits */
stream_write_uint32(output, 1); /* SectorsPerAllocationUnit */
stream_write_uint32(output, 0x400); /* BytesPerSector */
stream_write_uint32(output, svfst.f_bsize); /* BytesPerSector */
break;

case FileFsAttributeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
stream_write_uint32(output, 22); /* Length */
stream_check_size(output, 22);
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);
stream_write_uint32(output,
FILE_CASE_SENSITIVE_SEARCH |
FILE_CASE_PRESERVED_NAMES |
FILE_CASE_SENSITIVE_SEARCH |
FILE_CASE_PRESERVED_NAMES |
FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
stream_write_uint32(output, 510); /* MaximumComponentNameLength */
stream_write_uint32(output, 10); /* FileSystemNameLength */
stream_write(output, "F\0A\0T\03\02\0", 10); /* FileSystemName */
stream_write_uint32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */
stream_write_uint32(output, len); /* FileSystemNameLength */
stream_write(output, outStr, len); /* FileSystemName (Unicode) */
xfree(outStr);
break;

case FileFsFullSizeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232104.aspx */
stream_write_uint32(output, 32); /* Length */
stream_check_size(output, 32);
stream_write_uint64(output, 0x1000000); /* TotalAllocationUnits */
stream_write_uint64(output, 0x800000); /* CallerAvailableAllocationUnits */
stream_write_uint64(output, 0x800000); /* ActualAvailableAllocationUnits */
stream_write_uint64(output, svfst.f_blocks); /* TotalAllocationUnits */
stream_write_uint64(output, svfst.f_bavail); /* CallerAvailableAllocationUnits */
stream_write_uint64(output, svfst.f_bfree); /* AvailableAllocationUnits */
stream_write_uint32(output, 1); /* SectorsPerAllocationUnit */
stream_write_uint32(output, 0x400); /* BytesPerSector */
stream_write_uint32(output, svfst.f_bsize); /* BytesPerSector */
break;

case FileFsDeviceInformation:
Expand Down Expand Up @@ -601,7 +631,7 @@ static void disk_free(DEVICE* device)

freerdp_thread_stop(disk->thread);
freerdp_thread_free(disk->thread);

while ((irp = (IRP*)list_dequeue(disk->irp_list)) != NULL)
irp->Discard(irp);
list_free(disk->irp_list);
Expand Down
11 changes: 3 additions & 8 deletions client/DirectFB/df_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,19 @@ void df_send_mouse_wheel_event(rdpInput* input, sint16 axisrel, uint16 x, uint16

void df_send_keyboard_event(rdpInput* input, boolean down, uint8 keycode, uint8 function)
{
uint16 flags;
uint8 vkcode;
uint8 scancode;
boolean extended;
RDP_SCANCODE rdp_scancode;

if (keycode)
vkcode = keymap[keycode];
else if (function)
vkcode = functionmap[function];
else
return;

scancode = freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(vkcode, &extended);

flags = (extended) ? KBD_FLAGS_EXTENDED : 0;
flags |= (down) ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE;
rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(vkcode);

input->KeyboardEvent(input, flags, scancode);
freerdp_input_send_keyboard_event_2(input, down, rdp_scancode);
}

boolean df_event_process(freerdp* instance, DFBEvent* event)
Expand Down
60 changes: 25 additions & 35 deletions client/Windows/wf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ extern HCURSOR g_default_cursor;

LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
{
DWORD flags;
wfInfo* wfi;
uint8 scanCode;
RDP_SCANCODE rdp_scancode;
rdpInput* input;
uint16 kbdFlags;
PKBDLLHOOKSTRUCT p;

DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd, nCode, wParam);
Expand All @@ -52,13 +50,11 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP:
wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
p = (PKBDLLHOOKSTRUCT) lParam;
scanCode = (uint8) p->scanCode;
input = wfi->instance->input;
flags = p->flags;
kbdFlags = 0;
rdp_scancode = mk_rdp_scancode((uint8) p->scanCode, p->flags & LLKHF_EXTENDED);

DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X",
(wParam == WM_KEYDOWN), scanCode, flags, p->vkCode);
(wParam == WM_KEYDOWN), (uint8) p->scanCode, p->flags, p->vkCode);

if (wfi->fs_toggle &&
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
Expand All @@ -70,44 +66,38 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
return 1;
}

if (scanCode == 0x45) /* NumLock-ish */
if (rdp_scancode == RDP_SCANCODE_NUMLOCK_EXTENDED)
{
if (flags & LLKHF_EXTENDED)
/* Windows sends NumLock as extended - rdp doesn't */
DEBUG_KBD("hack: NumLock (x45) should not be extended");
rdp_scancode = RDP_SCANCODE_NUMLOCK;
}
else if (rdp_scancode == RDP_SCANCODE_NUMLOCK)
{
/* Windows sends Pause as if it was a RDP NumLock (handled above).
* It must however be sent as a one-shot Ctrl+NumLock */
if (wParam == WM_KEYDOWN)
{
/* Windows sends NumLock as extended - rdp doesn't */
DEBUG_KBD("hack: NumLock (x45) should not be extended");
flags &= ~LLKHF_EXTENDED;
DEBUG_KBD("Pause, sent as Ctrl+NumLock");
freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_NUMLOCK);
freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_NUMLOCK);
}
else
{
/* Windows sends Pause as if it was a RDP NumLock (handled above).
* It must however be sent as a one-shot Ctrl+NumLock */
if (wParam == WM_KEYDOWN)
{
DEBUG_KBD("Pause, sent as Ctrl+NumLock");
input->KeyboardEvent(input, KBD_FLAGS_DOWN, 0x1D); /* Ctrl down */
input->KeyboardEvent(input, KBD_FLAGS_DOWN, 0x45); /* NumLock down */
input->KeyboardEvent(input, KBD_FLAGS_RELEASE, 0x1D); /* Ctrl up */
input->KeyboardEvent(input, KBD_FLAGS_RELEASE, 0x45); /* NumLock up */
}
else
{
DEBUG_KBD("Pause up");
}

return 1;
DEBUG_KBD("Pause up");
}
}

if ((scanCode == 0x36) && (flags & LLKHF_EXTENDED))
return 1;
}
else if (rdp_scancode == RDP_SCANCODE_RSHIFT_EXTENDED)
{
DEBUG_KBD("hack: right shift (x36) should not be extended");
flags &= ~LLKHF_EXTENDED;
DEBUG_KBD("right shift (x36) should not be extended");
rdp_scancode = RDP_SCANCODE_RSHIFT;
}

kbdFlags |= (flags & LLKHF_UP) ? KBD_FLAGS_RELEASE : KBD_FLAGS_DOWN;
kbdFlags |= (flags & LLKHF_EXTENDED) ? KBD_FLAGS_EXTENDED : 0;
input->KeyboardEvent(input, kbdFlags, scanCode);
freerdp_input_send_keyboard_event_2(input, !(p->flags & LLKHF_UP), rdp_scancode);

if (p->vkCode == VK_CAPITAL)
DEBUG_KBD("caps lock is processed on client side too to toggle caps lock indicator");
Expand Down
Loading

0 comments on commit 4b6119c

Please sign in to comment.