Blog

  • How To: Use the FtpWebRequest

    Networking In The Hand includes a full desktop-compatible implementation of the FtpWebRequest class. This plugs into the WebRequest class so that calling WebRequest.Create() with an FTP Uri will create an object of type FtpWebRequest. Because FTP support isn’t built into the Compact Framework you have to register the class with this prefix using the the following code (only required once in your code):-


    InTheHand.Net.FtpWebRequest.RegisterPrefix();


    We have already looked at performing simple operations with the WebClient class. for more complex FTP operations you can use the FtpWebRequest directly. For example retrieving the modification date of a specific file:-


    FtpWebRequest requestDate = (FtpWebRequest)FtpWebRequest.Create(requestUri);
    requestDate.Method = WebRequestMethods.Ftp.GetDateTimestamp;
    if (wc.Credentials != null)
    {
       requestDate.Credentials = wc.Credentials;
    }
    FtpWebResponse responseDate = null;

    responseDate = (FtpWebResponse)requestDate.GetResponse();

    if (responseDate != null)
    {
       MessageBox.Show(responseDate.LastModified.ToString());
       responseDate.Close();
    }

  • How To: Use the WebClient

    Networking In The Hand includes the WebClient class which is a helper class which makes it easier to do uploading and downloading of data using HTTP and FTP transports. For example rather than creating an HttpWebRequest, setting a number of properties, getting the response and reading the response stream and copying the data into a file, why not use DownloadFile to perform a single operation to write the data from a specific Uri to a local file:-


    WebClient wc = new WebClient();
    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
       wc.DownloadFile(uriTarget, saveFileDialog1.FileName);
    }


    Additional methods provide the ability to download a string, and download a byte array containing the data. There are a similar set of operations for uploading:-


    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
       wc.UploadFile(uriDestination, openFileDialog1.FileName);
    }


    Not only does this work with the HTTP transport, but also with the FTP support which is also part of the library – the only difference is the Uri that you pass in. If your site requires a username/password you can set the Credentials property of the WebClient once and they will be used for all subsequent operations.

  • Fix: SMS Interception on T-Mobile Dash

    A number of customers have been reporting issues with SMS interception on the T-Mobile Dash handset. On these devices the SMS interception does not work through either the Microsoft or In The Hand class libraries. This is specific to the T-Mobile ROM as other branded versions of the same device, such as the HTC S620, do not have the problem. The culprit is a badly behaved IMessageFilter implementation which stops the standard interceptor from working. You can fix this issue by removing the entry from the registry. Take a look at this registry key:-


    HKEY_LOCAL_MACHINESoftwareMicrosoft/Software/Inbox/Svc/Sms/Rules


    In here you’ll find 2 entries by default on Windows Mobile 5.0:-


    {1000BC1C-F4A3-4210-B197-4AEBF2CEE6F5}


    {77990A0E-60B8-4103-B9AF-17157E4274FD}


    If you find additional entries here try deleting them (make a backup first so that you can restore if necessary) then reset the phone. This should allow the normal SMS interception mechanism to work again.


    On Windows Mobile 6 the above registry key is not present by default, therefore the standard SMS interception will work without any additional rules registered.

  • How To: Use the Ping class

    Networking In The Hand includes the Ping class (In the InTheHand.Net.NetworkInformation namespace). The component allows you to determine if a network path to a particular host is available and whether the host is responding. It doesn’t guarantee that a particular service is running on the server (HTTP, FTP etc). You can perform a Ping in a couple of lines of code, the class has been designed to be an exact subset of the equivalent class in the full .NET framework. The following is an example of the simplest ping request using a default payload and timeout settings.

    InTheHand.Net.NetworkInformation.Ping p = new InTheHand.Net.NetworkInformation.Ping();
    InTheHand.Net.NetworkInformation.PingReply reply = p.Send(“www.google.com”);


    if (reply.Status == IPStatus.Success)
    {
       string message = string.Format(“Address: {0}rnRoundTrip time: {1}rnTime to live: {2}rnDon’t fragment: {3}rnBuffer size: {0}”,
          reply.Address.ToString(),
          reply.RoundtripTime,
          reply.Options.Ttl,
          reply.Options.DontFragment,
          reply.Buffer.Length);

       MessageBox.Show(message, “Ping”);
    }
    else
    {
       MessageBox.Show(reply.Status.ToString(), “Ping”);
    }


    The class allows you to further customise the request. You can specify your own data payload for example, or set a different timeout value (the default is 5 seconds).

  • How To: Use the AuthenticationDialog

    Networking In The Hand 2.0 offers a new dialog which allows you to prompt the user for networking credentials. The dialog is designed for the best appearance depending on your platform, for example the screenshots below show both Windows Mobile 5.0 Pocket PC and Windows Mobile 6 Standard Landscape:-


     


       


    If your application stores authentication details you can pre-populate the dialog. Optionally you can display a Save Settings checkbox on the form. The following code snippet shows how to display the dialog and return the credentials as an ICredentials object:-


    private ICredentials GetCredentials(string resourceName)
    {
       InTheHand.Windows.Forms.AuthenticationDialog ad = new InTheHand.Windows.Forms.AuthenticationDialog();


       ad.ResourceName = resourceName;
       if(ad.ShowDialog() == DialogResult.OK)
       {
            return new NetworkCredential(ad.Username, ad.Password, ad.Domain);
       }
       else
       {
          return null;
       }


    }

  • New Networking Component

    In The Hand Ltd today released Networking In The Hand, a developer library for the .NET Compact Framework 2.0 and 3.5 Beta. This library adds additional networking functionality not found in in the Compact Framework while matching the object model used in the full .NET framework to make it easy to share your code between platforms. Functionality includes:-




    • InTheHand.Net.WebClient – Provides helper methods for working with information upload and download over HTTP and FTP transports, and any other WebRequest based implementations.


    • InTheHand.Net.FtpWebRequest – Provides a complete desktop compatible implementation of the WebRequest pattern for FTP.


    • InTheHand.Net.WebRequestMethods – Provides a reference of all the HTTP and FTP methods (GET/POST etc)


    • InTheHand.Net.NetworkInformation.Ping – Perform a Ping and determine network availability and performance.


    • InTheHand.Net.NetworkInformation.IPGlobalProperties – Retrieve a wide range of networking statistics to measure traffic and help identify faults.

    The library is licensed on a per-developer basis with no additional royalties required to distribute the runtime with your applications. Full details on the product can be found on the product details page – https://inthehand.com/content/Networking.aspx. A fully functionality Evaluation version is available to download – https://inthehand.com/wp-content/uploads/folders/evals/entry4014.aspx.

  • Stephen Fry is Blogging

    Stephen Fry, intellectual and comic hero has not only started blogging, but started talking about mobile devices. Definitely worth a read.


    (from Dave Sussman)

  • Friday Fun: Untamed Workforce

    There are videos and photos doing the rounds from a new spoof information site for Windows Mobile which takes a light-hearted look at mobile working. Why not take a look?


     


  • HTC S620 Windows Mobile 6 Upgrade Experience

    Late last week HTC quietly released the Windows Mobile 6 upgrade for the S620. A few eagle eyed bloggers posted about it. The first thing I found was that the upgrade process doesn’t work with Windows Vista, when it reboots the device into bootloader mode the computer fails to connect. I had to run the upgrade from a Windows XP machine (where it worked flawlessy). Upon rebooting I had a fresh clean Windows Mobile 6 device. I noticed that HTC had left the default “Mobile Operator” screen during boot up, only after running its initial setup was this removed. Everything was working great, I was able to setup my exchange server in ActiveSync and get all my PIM data back onto the device. The lock dialog is slightly altered in this release, rather than tapping the right softkey to cancel you have to tap the right soft-key to open the menu and select the second option (option 1 is “Reset Password” but is disabled). The reason I often cancel this screen is because I just want to check the home screen for the time / next appointment. The time can optionally be displayed on the unlock screen but only for the key lock, I no longer use that because my exchange provider enforces a password.


    There are a few fancy UI features, the improvements to the calendar day screen are welcome along with the ability to edit task items. Essentially there are few differences to Windows Mobile 5.0 in the look and feel and layout of start menu and applications. One interesting change is that the alarm can now be set to operate only on weekdays, or every day. It’s still not as flexible as other approaches, and the default sound applied to the alarm is rather alarming to say the least!


    With my initial success I then tried docking the device with my main Vista machine. On this machine I’m running the latest Windows Mobile Device Center 6.1. When I connected the S620 popped up a message telling me to upgrade to ActiveSync 4.5 or later on my PC. Fellow MVP Jaap van Ekris was able to point out a simple workaround. Just go to Start > Settings > Connections > USB to PC and uncheck “Enable advanced network functionality”. It now partners correctly with my Vista machine.

  • Tech Ed Developers 2007 EMEA for Mobile and Embedded Developers

    In November Microsoft will be hosting the twin conferences of Tech Ed Developers and Tech Ed IT Forum in Barcelona. Tech Ed Developers runs the week of 5th to 9th and covers 14 different tracks, one of which is Mobile & Embedded. This will cover the latest versions of all of Microsoft’s Mobile & Embedded products from the .NET Micro Framework through to Windows Mobile, Windows Embedded CE and Robotics studio, and of course the .NET Compact Framework.



    This year I’ll be delivering a session on networking technologies available to Windows Mobile developers. This will cover a broad spectrum from personal area networking (Bluetooth and IrDA) through to cellular network specific (SMS, GPRS etc) and internet standards (FTP, HTTP etc). We will look at which technologies are appropriate for which scenarios, the relative costs and how to implement them. It’s going to be an interactive session and will include plenty of code snippets and an interactive demo or two.


    My co-authors Andy Wigley and Daniel Moth will also be delivering sessions in the Mobile & Embedded track and we plan to get together for a book signing during the event. Registration for the conference is available with a €300 off the full price until 28th September.