Using Briefcase lite for the iPhone with Windows
« Back to news
Transfer files using the iPhone from a Windows PC without resorting to jail breaking and best of all its free! If you don’t care about the technical details just download the following and install and configure openSSH for Windows (information on doing that can be found here).
Download OpenSSH
Download Bonjour for Windows
Download Bonjour advertiser (binary)
Download Bonjour advertiser (source)
For those interested, read on for all the gory details…
Before you start, you'll want to make sure you have the following:
- For C/C++ Development
- Windows C/C++ compiler
- For Python Development
- Visual studio (at least .NET 2003)
This article is divided into the following sections:
- Problem Description
- Solution (Common)
- Doing it the C/C++ way
- Doing it the Python way
- Getting Openssh up and running
- Comments
- Troubleshooting
1. Problem Description
Briefcase lite does not allow you to manually connect to a machine by entering an ip address. The only way to access another machine (and a list of the services available on it) is to discovery it using the MDNS protocol (multicast DNS which is a Zeroconf solution). This protocol can be supported on the Mac and Windows using Apples Bonjour.
Once briefcase has discovered a machine, it needs to ensure that an SSH server is running to allow it to perform the actual file transfer. This is where you run into problem on Windows. On a Mac the SSH server is automagically advertised via Bonjour but on Windows it isn’t even included and if you download one such as Openssh, it won’t be advertised and thus briefcase will presume there is no transfer service available and won’t display the machine in its list.
In order to get things working properly, the SSH service must be registered with Bonjour. This can be done by writing a small application in either Python or C/C++.
2. Solution (Common)
- Install Bonjour and the Bonjour SDK from here.
3. Doing it the C/C++ way
- Download some source code I knocked up which will register an SSH service with Bonjour
Download Bonjour advertiser for Windows(source)
4. Doing it the Python way
- After pythons installed you will want to set the PYTHONPATH environment variable, with a default install you can do this using the following: “set PYTHONPATH=C:\Python26\Lib”
- Compile BonjourPY (requires MSVC++) get it here.
- Download the swig binary for Windows here
- Download the tar for BonjourPY and extract.
- Compile bonjourPY from a visual studio command line (from the start menu run Microsoft Visual Studio XXX -> Visual Studio XXX Tools -> Visual Studio XXX Command Prompt or run a cmd line and manually execute "C:\Program Files\Microsoft Visual Studio XXX\CommonX\Tools\vsvars32.bat" replacing X as appropriate.
- Compile the bonjour dll (Based on steps from here).
- Create a new win32 dll project in visual studio (unselect use precompiled headers if you can)
- Add the file bonjour_wrap.c from the bonjourPY directory to the project under source files
- Set the configuration to release (Build -> configuration manager)
Edit the projects properties and change the following:
- Under C/C++ general tab add C:\Python26\include;C:\Program Files\Bonjour SDK\Include to Additional include directories, under code generation ensure the runtime library is Muilt-threaded (/MT) and under precompiled headers change it to "Not using precompiled headers".
- Under the linker tab under general add C:\Program Files\Bonjour SDK\lib\win32; C:\Python26\libs to the additional libraries directory and under the input tab add python26.lib dnssd.lib under additional dependencies
- Build it
- Go to the release output directory and rename the dll file to _bonjour.pyd. Create a directory in C:\python26\Lib called bonjour and then copy the above to it. Under the extracted bonjourPY source directory you should see a bonjour directory. Copy the __init__.py file from it to the bonjour directory in python26\Lib.
5. Getting Openssh up and running
- Download it from here
- Install and follow the simple readme to add a username. At the very minimum you must add groups and passwords for example:
mkgroup -l >> ..\etc\group
mkpasswd -l >> ..\etc\passwd
- Change your users home directory to point to your C or D drive by editing your passwd file (on a default install it's located at: C:\Program Files\OpenSSH\etc\passwd), find your username and then you will see something like “/home/USERNAME”. Change this to /cygdrive/DRIVE_LETTER (e.g. /cygdrive/c for your primary drive).
- (Optional) Although I won’t discuss this step in detail, there are ways to create links to your other drives from the C drive so that you could for example access your D drive through a folder such as c:\volumes\d_drive. This can be done by using a feature called junctions. Google for junction link magic if you’re interested.
- Run services.msc and start the openssh service (If you are using Windows Vista you will first need to ensure the cygrunsrv.exe executable is set to Windows XP SP2 compatibility mode for all users. This can be done by right clicking on the executable, selecting properties and then opening the all users settings and finally selecting the appropriate options.)
6. Comments
You may be wondering why I went to all that effort using python when it’s so much easier to use C/C++. The answer is quite simple, I wanted to have a dabble in python (its been on my TODO list for quite some time) and it was the first way I discovered of doing it. Hopefully if you’re purely a python developer and couldn’t have done it using C/C++ you found this information useful.
7. Troubleshooting
Q: I get an error message compiling about a missing python26_d.lib
A: You need to change the build configuration to release
Q: I get the error "ImportError: No module named _bonjour"
A: You need to build the dll as explained above
Q: I get the error "ImportError: No module named bonjour"
A: You need to copy the appropriate files to the python26 lib directory as explained above
8. Contact
If you have any questions, comments etc please feel free to email me. All my details can be found here.