Bug 47729

Summary: Support file transfer on windows.
Product: Telepathy Reporter: Siraj Razick <siraj>
Component: salutAssignee: Siraj Razick <siraj>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: olli.salli
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: Windows (All)   
URL: http://cgit.collabora.com/git/user/siraj/telepathy-salut.git/commit/?h=ft-windows&id=bf1c4181ffe5d134e8616e78d0ac27abb5a30e41
Whiteboard: review+
i915 platform: i915 features:

Description Siraj Razick 2012-03-22 11:09:17 UTC
Current code skips file transfer support in tp-salut
Comment 1 Siraj Razick 2012-03-22 11:10:16 UTC
initial patch :please note I didn't test it yet.. i'm doing it atm .
Comment 2 Olli Salli 2012-03-22 11:31:46 UTC
Okay, some mistakes spotted

> #ifdef G_OS_WIN32
>   struct sockaddr_in addr;
> #else
>   struct sockaddr_un addr;
> #endif

is followed by

>      new_fd = accept (g_io_channel_unix_get_fd (source),
>          (struct sockaddr *) &addr, &addrlen);

This code is wrong on Unix too - it always uses a sockaddr_un to store the peer address, even when the socket is actually a IPv4 or a IPv6 socket. But it's also wrong on Windows - it might use the IPv4 address struct to store a IPv6 address, which'll surely lead to corrupted stack because IPv6 addresses are significantly longer.

the addr variable is not actually read in the function after accept stores the address in it - and is not passed anywhere - so the easiest fix is to just remove the addr variable and pass NULL as the two latter arguments to accept().

Note that despite the name, g_io_channel_unix_get_fd is really the correct function to use even on Windows... From GLib docs:

"On Windows this function returns the file descriptor or socket of the GIOChannel."

However, this is not right:

> #ifdef G_OS_WIN32
>      channel = g_io_channel_win32_new_fd (new_fd);

new_fd is a socket, so you must use g_io_channel_win32_new_socket so the correct IO implementation in GLib is used (it really has to be different for sockets and files on Windows :()

Also, in get_socket_channel():

>   fd = g_socket_get_fd (sock);
>   io_channel = g_io_channel_unix_new (fd);

Here as well, instead of the unix_new() call we must use win32_new_socket() on windows.
Comment 3 Olli Salli 2012-03-22 11:58:56 UTC
*** Bug 47272 has been marked as a duplicate of this bug. ***
Comment 4 Siraj Razick 2012-03-22 14:11:37 UTC
new patch with the changes
Comment 5 Siraj Razick 2012-03-24 20:19:47 UTC
working patch, along with contact-manager/contact patch
Comment 6 Olli Salli 2012-03-25 07:53:22 UTC
OK - can be merged after the bug 47429 branch which this is based on is merged, provided you test file transfer again to verify the fixes for it are implemented correctly.
Comment 7 Olli Salli 2012-03-26 08:45:43 UTC
Merged, will be in 0.7.2. Thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.