WEBINAR:
On-Demand
Application Security Testing: An Integral Part of DevOps
Defining the Message Format
After the text and image are encoded, they need to be packaged properly so that they can be sent as an SMS message. In this application, the body of a SMS message can contain either text or an image (or both).
The preamble of the message's body is prefixed by the <*> tag. Text content is enclosed within the <t> element. Text data that is compressed is enclosed within the <c> element. For images, content is enclosed within the <i> element and, if it is compressed, enclosed within the <c> element. Here are some message samples:
- <*><t><c>.........</c></t>: Text only (compressed)
- <*><t>.........</t>: Text only (uncompressed)
- <*><i><c>.........</c></i>: Image only (compressed)
- <*><i>.........</i>: Image only (uncompressed)
- <*><t><c>.........</c></t><i><c>....</c></i>: Text and Image compressed
- <*><t>.........</t><i><c>....</c></i>: Text uncompressed and Image compressed
Creating the Application
Using Visual Studio 2005, create a new Windows Mobile 5.0 Pocket PC application and name it as
SMS_Pictures. In the default
Form1, populate it with the following controls shown in
Figure 2 and
3.

Figure 2. TabPage1: Populating the controls in TabPage1. | |  Figure 3. TabPage2: Populating the controls in TabPage2. |
Until .NET Compact Framework 3.5 is released, you have to rely on third-party components for compression. For compression using the .NET Compact Framework 2.0, I used the "ComponentOne Zip for Mobile Devices - Subscription - 2007v1" (check out their web site for pricing information). For this article, I used the available trial edition.
Once the "ComponentOne Zip for Mobile Devices" is downloaded and installed on your computer, add a reference to the C1.CF.C1Zip.2.dll library, which by default is located in C:\Program Files\ComponentOne Studio.NET 2.0\bin\.
Switch to the code-behind of Form1 and import the following namespaces:
Imports System.IO
Imports Microsoft.WindowsMobile.PocketOutlook
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInterception
Imports C1.C1Zip
Declare the following two member variables:
Public Class Form1
Private msgInterceptor As MessageInterceptor
Private SMS_Message As New SmsMessage
Define the
CompressString() and
ExpandString() functions respectively to compress and expand a string (see
Listing 1).
Author's Note: These two functions are taken from the sample code accompanying the "ComponentOne Zip for Mobile Devices." |