Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




LUCRARE DE DIPLOMA Aplicatii ale Dispozitivelor Mobile intr-o Firma de Distributie

Informatica


UNIVERSITATEA BABEȘ - BOLYAI

FACULTATEA DE MATEMATICĂ ȘI INFORMATICĂ

INFORMATICĂ-ENGLEZA



LUCRARE DE DIPLOMĂ

Aplica ii ale Dispozitivelor Mobile

într-o Firmă de Distribuție

Conducător științific

Lector dr. Suciu Dan Mircea

Absolvent

Silveșan-Gherman Iulia

Table of contents

Introduction

1.1 Introduction

1.2. Types of Mobile Devices

1.2.1 Smartphones

1.2.1.1. General characteristics and utilities

1.2.1.2. Operating Systems

1.2.2. Mobile computers

1.2.2.1. Introduction to PDA's

1.2.2.2. Characteristics of PDA's

1.2.2.2.1.Touch screen

1.2.2.2.2.Memory cards

1.2.2.2.3. Wired connectivity

1.2.2.2.4. Wireless connectivity

1.2.2.2.5. Synchronization

1.2.2.2.6.Automobile navigation

1.2.2.2.7. Ruggedized PDAs

1.2.2.3. PDA usage

1.2.2.3.1. Medical and scientific uses

1.2.2.3.2. Mobile in education

1.2.2.3.3. Sporting uses

1.2.2.3.4. PDA for people with disabilities

1.2.2.4. Operating Systems for PDA's

1.2.3. Handheld game consoles

1.2.4. Pocket PC

1.2.4.1. General Characteristics

1.2.4.2. Operating Systems

1.4. Mobile device security

2.1. Using SQL Server 2005 Compact Edition and Other Data Stores

2.1.1.Using SQL Server 2005 Compact Edition Databases

2.1.1.1. Creating a Database Using Visual Studio 2005

2.1.1.2. Creating a Database Using SQL Server 2005 Management Studio

2.1.1.3. Installing the SQL CE runtime on target devices

2.1.1.4.Connecting to an Existing Database...................22

2.1.1.4.1.Creating a Table

2.1.1.4.2. Creating a Foreign Key

.1.4.3.Creating an Index

2.1.1.4.4. Deciphering SqlCeExceptions

2.1.1.4.5. Updating the Database with a DataSet

2.1.1.4.6. Updating the Database with a SqlCeResultSet

2.2.Getting Connected............................31

2.2.1.Understanding Connections on Windows Mobile................31

2.2.2Using Desktop Passthrough........................32

2.3. Developing with Windows Mobile

2.3.1. Personal Information Management

2.3.1.1. PimItem 

.3.1.2. Appointments

2.3.1.3. Tasks

2.3.1.4. Reminders

2.3.1.5. Contacts

2.3.1.5.1. ChooseContactDialog

2.3.1.6. Custom Properties

2.3.1.7. Messaging

2.3.1.7.1. E-Mail 

2.3.1.7.1.1. Sending and Receiving

2.3.1.7.1.2. Composing a New Message

2.3.1.7.2. SMS

2.3.1.8.Pictures

2.3.1.9. Camera

2.4. Communication Technologies

2.4.1.Using Serial Ports

2.4.2. Virtual Serial Ports

3.System Analysis and Design

3.1.Problem statement

3.2.Use cases

3.3. Sequence diagrams

3.4.1.For Server

3.4.2 For client 

4. User's Guide

Conclusions

Bibliography

Introduction

This paper's purpose is developing a client - server application, having as a client a Pocket Pc Emulator. The main issues where connecting the server part to a existing database and sending data from the server to the mobile device emulator and the other way, too.

The first chapter, "Mobile devices", presents the types of mobile devices that are used in programming, their characteristics and the operating systems they accept.

The second chapter, "Mobile devices in .NET" , shows a few programming techniques used in C# , ways of connection between a server and a client and also database access, to SQL Server.

The third chapter presents the System Analysis and Design, illustrating the diagrams used for developing a proper solution to the problem.

The last chapter is the User's Guide, presenting how the application is used and what its results are.

Many mobile devices applications have chosen to develop this kind of application using a Web Service. My solution is implemented using sockets, to prove that the communication between a console application server and a mobile device application client is not that different from a console application server and a normal window form client.

1. Mobile devices

1.1 Introduction

A mobile device (also known as converged device, handheld device, handheld computer, "Palmtop" or simply handheld) is a pocket-sized computing device, typically having a display screen with touch input or a miniature keyboard. In the case of the personal digital assistant (PDA) the input and output are combined into a touch-screen interface. Smartphones and PDAs are popular amongst those who require the assistance and convenience of a conventional computer, in environments where carrying one would not be practical.

1.2. Types of Mobile Devices

1.2.1 Smartphones

1.2.1.1. General characteristics and utilities

A Smartphone is a a mobile phone offering advanced capabilities beyond a typical mobile phone, often with PC-like functionality. There is no industry standard definition of a smartphone. For some, it is a phone that runs complete operating system software providing a standardized interface and platform for application developers. For others, it is simply a phone with advanced features.

According to David Wood, EVP at Symbian, "Smart phones differ from ordinary mobile phones in two fundamental ways: how they are built and what they can do."

Most devices considered smartphones today use an identifiable operating system, often with the ability to add applications (e.g. for enhanced data processing, connectivity or entertainment) - in contrast to regular phones which only support sandboxed applications (like Java games).These smartphone applications may be developed by the manufacturer of the device, by the network operator or by any other third-party software developer.

Smart phones, in fact, bear as much in common with PCs as with mobiles. The essence of the smart phone to many people is that it's programmable. Analyst house Ovum distinguishes a smart phone from a feature phone by its open operating system and the ability to freely add and remove applications.

A useful smart phone has two components: the device itself, and the service. The device is small and looks like either a phone, or a PDA (personal digital assistant). It offers both telephone service, and data services such as email, calendaring, web browsing, and storing contacts. Most phones have a microprocessor, some memory, a screen, a keyboard of some sort, and a wireless modem. The service is through a service provider, which sells a set of services for a monthly fee. These services will specify the number of minutes, whether one can send/receive data (such as email or pictures), the speed of the connection, etc. [2]

In terms of features, most smartphones support full featured email capabilities with the functionality of a complete personal organizer. Other functionality might include an additional interface such as a miniature QWERTY keyboard, a touch screen or a D-pad, a built-in camera, contact management, an accelerometer, built-in navigation hardware and software, the ability to read business documents in a variety of formats such as PDF and Microsoft Office, media software for playing music, browsing photos and viewing video clips, internet browsers or even just secure access to company mail.Thanks to more powerful processors and more flexible OSs, many of these phones can play 3D games and MP3s, record and play back video, and bring together SMS and e-mail.

1.2.1.2. Operating Systems

Many smart phones come with freely extensible OSs that can host third-party applications. These applications let one expand a phone's capabilities-giving it true smarts.

BlackBerry OS is extremely e-mail focused. BlackBerry devices hook up to corporate or Web-based e-mail servers for up-to-the-minute e-mail. (One can do this with third-party software on other smart phones.) It's also very easy to read and send e-mail on any BlackBerry. But only a few third-party applications are available to enhance the OS. Even if it is focused on easy operation and was originally designed for business,recently it has seen a surge in third-party applications and has been improved to offer full multimedia support

Microsoft Windows Mobile for Smartphones allows one to sync with PCs and Microsoft Exchange servers and offers an e-mail application similar to Outlook. There are three versions of Windows Smartphone: the first-released Smartphone 2002; the considerably faster Smartphone 2003; and Smartphone 2003 Second Edition (which adds support for higher-resolution screens). Windows Mobile is enjoying great popularity because of the low barrier to entry for third-party developers to write new applications for the platform.

Palm OS is best known for its easy-to-use PIM applications, stylus-based input method, and vast array of third-party apps. Another advantage of Palm OS is that it's already been test driven for years on PDAs.

Some phones opt for proprietary operating systems, with few or no third-party applications. Many of these have keyboards, which make them good for sending and receiving SMS and e-mail .It was developed by PalmSource(now a subsidiary of ACCESS). PalmSource traditionally used its own platform developed by Palm Inc. Access Linux Platform(ALP) is an improvement that was planned to be launched in the first half of 2007.It will use technical specifications from the Linux Phone Standards Forum. The Access Linux Platform will include an emulation layer to support applications developed for Palm-based devices.

Symbian is perhaps the least known among U.S. consumers, yet it is Europe's most popular smart-phone OS. It comes in various flavors, but all the Symbian phones we tested use the Series 60 version. Symbian uses much less memory and battery power than Windows Smartphone, the other major phone-only OS represented in this roundup.

As with Palm or Windows, third-party Symbian applications do everything from read Microsoft Office documents to help one plan routes through unfamiliar cities.

When it comes to carriers, one're limited by where one live, work, and travel, as well as whatever contract one're locked into.

U.S. carriers primarily use three cellular technologies: GSM (AT&T Wireless, Cingular Wireless, and T-Mobile), CDMA (Sprint PCS and Verizon Wireless), and iDen (Nextel). GSM phones can also be sold unlocked, ready to use on any of the three GSM carriers.

Smart phones are still in their infancy, and it takes patience from early adopters to tap their power. But one'll be surprised at what one can accomplish with these gadgets. They may even drag one away from oner good old PDA.

As Symbian lags behind other companies in the relatively small but highly visible North American market, this matches the success of its largest shareholder and customer, Nokia, in all markets except Japan. Nokia itself enjoys 52.9% of the smartphone market. In Japan Symbian is strong due to a relationship with NTT DoCoMo, with only one of the 44 Symbian handsets released in Japan coming from Nokia. It is used by all the major handset manufacturers, including BenQ, LG, Motorola, Samsung, and Sony Ericsson. Various implementations of user interfaces on top of Symbian are incompatible, which along with the requirement that applications running on mobile phones be signed is hindering the potential for a truly widely accepted mobile application platform. It has received some adverse press attention due to virus threats (actually trojan horses)

iPhone OS is an operating system 12212c28m used for iPhones. It derived from Mac OS X. Third party applications can be made available for normal iPhone users by creating a web service that can be accessed via the included web browser. Native application support was recently announced in March 2008 and currently requires a beta version of the iPhone OS which is available to developers and corporations for testing purposes. The new release of iPhone OS should be made available in early July 2008.

Linux operating system is the strongest in China,where it is used by Motorola, and in Japan, used by DoCoMo.Rather than being a platform in its own right, Linux is used as a basis for a number of different platforms developed by several vendors, including Motorola and TrollTech, which are mostly incompatible.PalmSource(now Access) is moving towards an interface running on Linux.Another platform based on Linux is being developed by Motorola, NEC, NTT DoCoMo, Panasonic, Samsung, and Vodafone.

1.2.2. Mobile computers

1.2.2.1. Introduction to PDA's

The most representative mobile computer,besides the famous laptop,of course, is the personal diggital assistant(PDA).

A PDA (Personal Digital Assistant) is a computer that fits in oner hand. These small computers are sometimes called palmtops and are a great way to store telephone numbers, email addresses, access the internet, make calculations, keep a digital calendar and play games.

Today's PDA is very small in size, fits comfortably in a pocket and generally has good battery life which allows one to recharge the device at night or when at the office. A PDA usually includes a small screen usually bigger than a digital phone, however smaller than the smallest laptop, a small QWERTY keyboard that is made for thumb typing and a stylus which is a metal or plastic pen to input data or communicate with the device by a touch pad screen.

While components and specifications change throughout the years, today one can find PDA's with lots of RAM memory, storage in either miniature hard drives or compact flash cards or sticks and some can be expanded by a PC card that fits into a PCMCIA slot. Newer palmtop computers have USB ports to plug in a variety of peripherals to use with oner PDA.

Today, one can find great features on many palmtop computers including internet access, the ability to send and receive email and files, mp3 player with onboard storage and game playing functions. Some palmtop computers have even morphed into an all in one device that includes a wireless phone.

A PDA is a great tool to stay organized. They are very popular with road warriors, corporate professionals, college students, etc. There are many different types of palmtop computers that range in price and features. For instance, one can purchase a palmtop computer that fulfills basic requirements such as telephone and address book, calendar, calculator and other travel functions for less than $100. Most of these low end palmtop computers also include infrared synching which means that one can send and receive data from oner palmtop computer to a host of other computers.

A moderately priced PDA includes extra functions such as a color screen, large amounts of memory and storage capabilities, USB port and can play video games. If one are looking for a high end palmtop computer, one will find almost every available option loaded onto these super high tech devices including a wireless phone, mp3 player, the ability to handle large files, lots of memory, Bluetooth capability. Currently, a typical PDA has a touch screen for entering data, a memory card slot for data storage and at least one of the following for connectivity: IrDA, Bluetooth and/or WiFi. However, many PDAs(typically those used primarily as telephones) may not have a touch screen, using softkeys, a directional pad and either the numeric keypad or a thumb keyboard for input.

Software typically required to be a PDA includes an appointment calendar, a to-do list, an address book for contacts and some sort of note program. Connected PDAs also typically include E-mail and Web support.

1.2.2.2. Characteristics of PDA's

1.2.2.2.1.Touch screen

Many original PDAs, such as the Apple Newton and the Palm Pilot, featured touch screens for user interaction, having only a few buttons usually reserved for shortcuts to often used programs. Touch screen PDAs, including Windows Pocket PC devices, usually have a detachable stylus that can be used on the touch screen. Interaction is then done by tapping the screen to activate buttons or menu choices, and dragging the stylus to, for example, highlight. Text input is usually done in one of four ways:

  • Using a virtual keyboard, where a keyboard is shown on the touch screen. Input is done by tapping letters on the screen.
  • Using external keyboard or chorded keyboardconnected by USB or Bluetooth.
  • Using letter or word recognition, where letters or words are written on the touch screen, and then "translated" to letters in the currently activated text field. Despite rigorous research and development projects, end-users experience mixed results with this input method, with some finding it frustrating and inaccurate, while others are satisfied with the quality.Recognition and computation of handwritten horizontal and vertical formulas such as "1 + 2 =" was also under development.
  • Stroke recognition (termed Graffiti by Palm). In this system a predefined set of strokes represents the various characters needed. The user learns to draw these strokes on the screen or in an input area. The strokes are often simplified character shapes to make them easier to remember.

PDAs for business use, including the BlackBerry and Treo, have full keyboards and scroll wheels or thumb wheels to facilitate data entry and navigation, in addition to supporting touch-screen input. There are also full-size foldable keyboards available that plug directly, or use wireless technology to interface with the PDA and allow for normal typing. BlackBerry has additional functionality, such as push-based email and applications.

Newer PDAs, such as the Apple iPhone and iPod touch include new user interfaces using other means of input. The iPhone and iPod touch uses a technology called Multi-touch.

1.2.2.2.2.Memory cards

Although many early PDAs did not have memory card slots, now most have either an SD (Secure Digital) and/or a Compact Flash slot. Although originally designed for memory, SDIO and Compact Flash cards are available for such things as Wi-Fi and Webcams. Some PDAs also have a USB port, mainly for USB flash drives.

As more PDAs include telephone support, to keep the size down, many now offer miniSD or microSD slots instead of full-sized SD slots.

1.2.2.2.3. Wired connectivity

While many earlier PDAs connected via serial ports or other proprietary format, many today connect via USB cable. This served primarily to connect to a computer, and few, if any PDAs were able to connect to each other out of the box using cables, as USB requires one machine to act as a host - functionality which was not often planned. Some PDAs were able to connect to the internet, either by means of one of these cables, or by using an extension card with an ethernet port/RJ-45 adaptor.

1.2.2.2.4. Wireless connectivity

Most modern PDAs have   Bluetooth wireless connectivity, an increasingly popular tool for mobile devices. It can be used to connect keyboards, headsets, GPS and many other accessories, as well as sending files between PDAs. Many mid-range and superior PDAs have Wi-Fi/WLAN/802.11- connectivity, used for connecting to Wi-Fi hotspots or wireless networks. Older PDAs predominantly have an IrDA(infrared) port; however fewer current models have the technology, as it is slowly being phased out due to support for Bluetooth and Wi-Fi. IrDA allows communication between two PDAs: a PDA and any device with an IrDA port or adapter. Most universal PDA keyboards use infrared technology because many older PDAs have it, and infrared technology is low-cost and has the advantage of being permitted aboard aircraft.

1.2.2.2.5. Synchronization

An important function of PDAs is synchronizing data with a PC. This allows up-to-date contact information stored on software such as Microsoft Outlook or ACT! to update the database on the PDA. The data synchronization ensures that the PDA has an accurate list of contacts, appointments and e-mail, allowing users to access the same information on the PDA as the host computer.

The synchronizing also prevents the loss of information stored on the device in case it is lost, stolen, or destroyed. Another advantage is that data input is usually a lot quicker on a PC, since text input via a touch screen is still not quite optimal. Transferring data to a PDA via the computer is therefore a lot quicker than having to manually input all data on the handheld device.

Most PDAs come with the ability to synchronize to a PC. This is done through synchronization software provided with the handheld, such as HotSync Manager, which comes with Palm OS handhelds, Microsoft ActiveSync for older versions of Windows or Windows Mobile Device Center on Windows Vista, which comes with Windows Mobile handhelds.

1.2.2.2.6.Automobile navigation

Many PDAs are used in car kits and are fitted with differential Global Positioning System (GPS) receivers to provide realtime automobile navigation. PDAs are increasingly being fitted as standard on new cars.

Many systems can also display traffic conditions, dynamic routing and roadside mobile radar guns.

1.2.2.2.7. Ruggedized PDAs

For many years businesses and government organizations have relied upon rugged PDAs also known as entreprise digital assistants (EDAs) for mobile data applications. Typical applications include supply chain management in warehouses, package delivery, route accounting, medical treatment and record keeping in hospitals, facilities maintenance and management, parking enforcement, access control and security, capital asset maintenance, meter reading by utilities, and "wireless waitress" applications in restaurants and hospitality venues. A common feature of EDAs are the integration of Data Capture devices like Bar Code and Smart Card Readers.

1.2.2.3. PDA usage

1.2.2.3.1. Medical and scientific uses

In medicine, PDAs have been shown to aid diagnosis and drug selection and some studies have concluded that their use by patients to record symptoms improves the effectiveness of communication with hospitals during follow-up. The first landmark study in testing the effectiveness of PDAs in a medical setting was conducted at the Brigham & Women's Hospital and Massachusetts General Hospitals in affiliation with Harvard Medical School. Led by the team of Steven Labkoff, MD and Sandeep Shah, the Constellation project used Apple's Newton (first PDA in the market) to cater to the demands of the medical professionals. Constellation's objective was to test how clinicians in various medical environments (wired vs un wired) would use medical reference books on a hand-held device. The study validated the hypothesis that PDAs with medical content would be used to a greater degree (>40% more often) in unwired environments. Today, the company evolved from the effort Skyscape offers a wide range of resources including drug information, treatment options, guidelines, evidence based information and journal summaries including the drug & safety alerts. Other entrants include Epocrates and ABX guide, which supply drug databases, treatment information and relevant news in formats specific to mobile devices and services such as AvantGo translate medical journals into readable formats and provide updates from journals. WardWatch organizes medical records to remind doctors making ward rounds of information such as the treatment regimens of patients and programs. Finally, Pendragon and Syware provide tools for conducting research with mobile devices, and connecting to a central server allowing the user to enter data into a centralized database using their PDA. Additionally, Microsoft Visual Studio and Sun Java provide programming tools for developing survey instruments on the handheld. These development tools allow for integration with SQL databases that are stored on the handheld and can be synchronized with a desktop/server based database.

Recently the development of Sensor Web technology has led to discussion of using wearable bodily sensors to monitor ongoing conditions like diabetes and epilepsy and alerting medical staff or the patient themselves to the treatment required via communication between the web and PDAs.

Mobile in education

As mobile technology has become very common, it is no surprise that personal computing has become a vital learning tool by this time. Educational institutes have commenced a trend of integrating PDAs into their teaching practices (mobile learning). With the capabilities of PDAs, teachers are now able to provide a collaborative learning experience for their students. They are also preparing their students for possible practical uses of mobile computing upon their graduation.

PDAs and handheld devices have recently allowed for digital note taking. This has increased student's productivity by allowing individuals to quickly spell-check, modify, and amend their class notes or e-notes. Educators are currently able to distribute course material through the use of the internet connectivity or infrared file sharing functions of the PDA. With concerns to class material, textbook publishers have begun to release e-books, or electronic textbooks, which can be uploaded directly to a PDA. This then lessens the effort of carrying multiple textbooks at one time.

To meet the instructive needs sought by educational institutes, software companies have developed programs with the learning aspects in mind. Simple programs such as dictionaries, thesauri, and word processing software are important to the digital note taking process. In addition to these simple programs, encyclopedias and digital planning lessons have created added functionality for users.

With the increase in mobility of PDAs, school boards and educational institutes have now encountered issues with these devices. School boards are now concerned with students utilizing the internet connectivity to share test answers or to gossip during class time, which creates disruptions. Many school boards have modernized their computer policies to address these new concerns. Software companies such as Scantron Corp. have now created a program for distributing digital quizzes. The quiz software disables the infrared function on PDAs, which eliminates the element of information sharing among individuals during the examination. Many colleges encourage the use of PDAs.

1.2.2.3.3. Sporting uses

PDAs are used by glider pilots for pre-flight planning and to assist navigation in cross-country competitions. They are linked to a GPS to produce moving-map displays showing the tracks to turn-points, airspace hazards and other tactical information.

PDAs can be used by road rally enthusiasts. PDA software can be used for calculating distance, speed, time, and GPS navigation as well as unassisted navigation.

1.2.2.3.4. PDA for people with disabilities

PDAs offer varying degrees of accesibility for people with differing abilities, based on the particular device and service. People with vision, hearing, mobility, and speech impairments may be able to use PDAs on a limited basis, and this may be enhanced by the addition og aceesibility software (speech recognition) for verbal input instead of manual input.Universal design is relevant to PDAs as well as other technology, and a viable solution for many user-access issues, though it has yet to be consistently integrated into the design of popular consumer PDA devices.

PDAs have recently become quite useful in the TBI/PTSD population, especially seen in troops returning home from Operation Iraqi Freedom(OIF)/Operation Enduring Freedom(OEF). PDAs address memory issues and help these men and women out with daily life organization and reminders. As of quite recently, the Department of Veterans' Affaiars (VA) has begun issuing thousands of PDAs to troops who present the need for them. Occupational therapists have taken on a crucial role within this population helping these veterans return to the normalcy of life they once had.

1.2.2.4. Operating Systems for PDA's

Many PDAs run using a variation of the ARM arhitecture (usually denoted by the Intel Xscale trademark). This encompasses a class of RISC microprocessors that are widely used in mobile devices and embedded systems, and its design was influenced strongly by a popular 1970s/1980s CPU, the MOS Technology 6502.

The currently major PDA operating systems are:

Palm OS- owned by Palm Source

Window Mobile Professional and Classic for use onPocket PCs, (based on the Window CE kernel) - owned by Microsoft

iPhone OS- owned by Apple Inc.

BlackBerry OS - owned by Research in Motion.

Many operating systems based on the Linux kernel - free.

Symbian OS (formerly EPOC) owned by Motorola ,Panasonic,Nokia,Samsung, Siemens and Sony Ericsson.

1.2.3. Handheld game consoles

A handheld game console is a lightweight, portable electronic machine for playing video games. Unlike video games consoles, the controls, screen and speakers are all part of a single unit. Throughout the 1970s and 1980s, several companies made lightweight table-top or handheld electronic game devices. Today, these machines are not considered strictly consoles, since they often would only play a single game. The first true handheld game console with interchangeable cartridges was the Milton Bradley Microvision in 1979. Nintendo has dominated the handheld market since the release of the Game Boy in 1989, and is often credited as popularizing the handheld console concept.

1.2.4. Pocket PC

1.2.4.1. General Characteristics

According to Microsoft, , the Pocket PC is "a handheld device that enables users to store and retrieve e-mail, contacts, appointments, tasks, play multimedia files,games , exchange text messages with Windows Live Messenger (formerly known as MSN Messenger), browse the Web, and more."

From a technical standpoint, "Pocket PC" is a Microsoft specification that sets various hardware and software requirements for mobile devices bearing the "Pocket PC" label.

For instance, any device which is to be classified as a Pocket PC must:

  • Run Microsoft's Windows Mobile, PocketPC edition
  • Come bundled with a specific suite of applications in ROM
  • Include a touchscreen
  • Include a directional pad or touchpad
  • Include a set of hardware application buttons
  • Be based on an ARM version 4 compatible CPU, Intel XScale CPU, MIPS CPU or SH3 CPU. (As of the Pocket PC 2002 specification, ARM-based CPUs are required.)

Currently there are thousands of applications for handhelds adhering to the Microsoft Pocket PC specification, many of which are freeware. Some of these devices also include mobile phone features. Microsoft compliant Pocket PCs can also be used with many other add-ons like GPS receivers, barcode readers, RFID readers, and cameras.

1.2.4.2. Operating Systems

Windows Mobile for Pocket PC carries these standard features in most of its versions:

  • Today Screen shows the current date, owner information, upcoming appointments, mail messages, and tasks. Users can customize the screen by selecting what information they wish to be displayed. It also includes the notification bar, which includes icons to notify the status of Bluetooth, etc. Programs can be installed which adds extra items to the Today screen. One of these is Microsoft Money for Pocket PC. The background image can be customised directly through the Pocket PC, or themes can be created and synchronized onto the Pocket PC.
  • The taskbar shows the current time, the volume, and the connectivity status. When a program or message box is open the blank space after the clock is filled with an OK or close icon. The main feature of the taskbar is the Start Button, which is designed similarly to the Start Button which features on desktop versions of Windows. The Start Menu features recently opened programs at the top, nine customizable menu entries, and links to the program, settings, find (search), and help.
  • Office Mobile, a suite of Mobile versions of Microsoft Office applications is included in Windows Mobile. It includes Word Mobile, Excel Mobile and PowerPoint Mobile (included since Windows Mobile 5.0). These versions include many of the features which are used in desktop versions, but some other features like inserting tables and images have not been included in pre 5.0 versions
  • Windows Media Player for Windows Mobile is bundled with the Windows Mobile software. Currently, all new Windows Mobile 6 Devices include Version 10.3 (Build 18123) of the player. For Older devices, Version 10 is available for download for only specified devices- these include devices from the Dell Axim range. The player supports .WMA,.WMV, .MP3 and .AVI files. Currently MPEG files are not supported, and a third-party program must be downloaded to play these, and WAV files are played in a separate player. Some versions are also capable of playing .M4A audio.
  • Internet Connecting Sharing (ICS) which in mobile phones allows attached computers to share internet connections via USB and Bluetooth. Wi-Fi enabled phones can also act as a mobile hotspot via WMWiFiRouter allowing computers within range to connect to the internet using the mobile phone's data plan.

1.4. Mobile device security

Mobile devices have wireless capability to connect to the Internet and office/home computer systems. However wireless capability poses a number of security risks. Managing the risks to mobile assets requires a knowledge of the threats posed to mobile devices and the vulnerabilities that may allow those threats to be realized. The Mobile Device Vulnerability Database (MDVD) is an online database for collecting vulnerability and countermeasure information on mobile computing devices and their technologies (Smart phone, personal digital assistant, Wi-Fi, Bluetooth,WiMAX,VOIP,etc) with references to all vulnerability and countermeasure information.

2. Mobile Devices in .NET

The .NET Compact Framework brings the benefits of managed code development to mobile devices with a slimmed-down class library and an execution engine optimized for use on Microsoft Windows CE-based operating systems. The .NET Compact Framework doesn't support the full feature set of the desktop framework, but that is what users expect on a small, battery-powered device. . But it covers programming with managed application programming interfaces (APIs) specific to different platforms, such as the Microsoft.WindowsMobile APIs available under Windows Mobile 5.0.

2.1. Using SQL Server 2005 Compact Edition and Other Data Stores

Most mobile applications require data to be stored, organized, and viewed. A simple application can simply persist data in a file, whereas more complex applications can benefit by using a database because of its capability of organizing data in tables, providing fast searching using indexes, and representing master-child relationships between data in different tables through foreign keys. As well as storing the data, the application usually must display data to users so that they can read and update it.

I will now present the different ways one can organize and persist data. First, I will explains how to create Microsoft SQL Server 2005 Compact Edition databases to use in the application, and then how one can use the visual designer tools in Microsoft Visual Studio 2005 to define project data sources and bind them to controls in the graphical user interface (GUI).Also, how to program the SqlCeResultSet object, which allows fast, updatable access to data in a SQL Server 2005 Compact Edition database and is a high-performance alternative to the typical ADO.NET TableAdapter-DataTable pattern. Finally, for those situations in which a database is too complex a solution, I will present how to use lighter-weight data stores such as simple class objects that one can persist using Extensible Markup Language (XML) serialization.

2.1.1.Using SQL Server 2005 Compact Edition Databases

SQL Server 2005 Compact Edition (SQL Server CE) is a lightweight relational database that supports data types that are compatible with full SQL Server 2005. It runs in-process in the application, meaning that it does not require a separate server process to operate. One can use it in Microsoft .NET Compact Framework applications running on Microsoft Windows CE or Windows Mobile, and also in .NET Framework applications running on Windows 2000, Windows XP, or Windows Vista. SQL Server CE also comes with application programming interfaces (APIs).

The previous version of this product, called SQL Server CE 2.0, was supported for managed applications built using .NET Compact Framework version 1.0. Existing applications built with .NET Compact Framework 1.0 and SQL Server CE 2.0 will run on devices that have the .NET Compact Framework 2.0 runtime installed, but one cannot create new .NET Compact Framework 2.0 applications using SQL Server CE 2.0; one must use SQL Server 2005 Compact Edition.

2.1.1.1. Creating a Database Using Visual Studio 2005

One way to create a new database is to use the Add New Item dialog box in Visual Studio, which adds a SQL Server Mobile database to oner project and sets up a connection to the database in the Server Explorer window. Visual Studio creates the database and then displays the Data Source Configuration Wizard, which one can use to design a DataSet or SqlCeResultSet graphically to read and update data from tables in the database. At this stage, one have created an empty database that contains no tables, and so one should close the wizard.

Alternatively, and perhaps more easily, one can create a database by using the Add Connection dialog box. Click the Connect To Database icon at the top of the Server Explorer window, or click Connect To Database on the Tools menu. In the Add Connection dialog box, as shown in the figure above, first ensure that the Data Source box at the top displays .NET Framework Data Provider for SQL Server CE. If it does not, click Change to open a dialog box where one can select it. Then click Create to open the Create New SQL Server 2005 Compact Edition Database dialog box. Note that creating a database in this way does not actually add it to the project, and so one can use the Add Existing Item dialog box to navigate to the newly created database file and include it in owner project.

After one has added a database to the project, one must ensure that the database will be deployed to oner target device. In the Properties dialog box, verify that the Build Action property is set to Content and the Copy To Output Directory property is set to Copy If Newer.

Options for Database Security:

In the Create New Database dialog box, one must specify the path to the database and optionally select the required sort order and/or specify a database password. If one sets a password, one must include it in the connection string every time one opens a database connection, and so this password forms the first line of defence against unauthorized access to the data in the database.

If one specifies a password, one can also specify that the data in the database be encrypted. The database password alone protects access to the database for usual methods of connection such as by using SQL Server Management Studio, Visual Studio, or through code, but a determined attacker could still dump out the raw data and so gain access to it; encryption provides a deterrent against such an attack.

2.1.1.2. Creating a Database Using SQL Server 2005 Management Studio

One can also create and modify Compact Edition databases in SQL Server 2005 Management Studio. To create or connect to a SQL Server CE database, open the Connect To Server dialog box, and select SQL Server Compact Edition in the Server Type drop-down list. Then, in the Database File text box, enter the path to an existing database, or select <New Database > from the drop-down list, as shown in the figure above. If one selects to create a new database, the same Create New SQL Server 2005 Compact Edition Database dialog box opens, which includes identical security options as described previously.

From a developer's point of view, nearly everything one can do with SQL Server CE databases using SQL Server 2005 Management Studio can be done in the Server Explorer window in Visual Studio 2005.

2.1.1.3. Installing the SQL CE runtime on target devices

To run an application that uses SQL Server CE, first the runtime has to be installed on the device. During application development, Visual Studio automatically installs the run-time components onto the development device or emulator the first time one debugs an application that uses SQL Server CE.

The SQL Server CE runtime comes in three .cab files. They can be obtained in the following ways: If one need to get the run-time .cab files so that one can install the runtime on a number of devices, one can do so in two different ways:

Visual Studio 2005 -> drive:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0.

Server 2005 -> drive:\Program Files\Microsoft SQL Server 2005 Mobile Edition\Device\Mobile\v3.0.

Whichever method one choose, the directory structure is the same:

One will find the .cab files for devices that run Windows Mobile 2003 and Windows CE 4.0 in the \wce400\armv4 folder. (Only Pocket PC targets with Advanced RISC Machines [ARM] microprocessors are supported on Windows Mobile 2003.)

The .cab files for devices that run Windows CE 5.0 and Windows Mobile 5.0 are in the \wce500\ processor folder, where processor is one of the supported microprocessors, such as armv4i, mipsii, or x86.

One needs three .cab files:

The main runtime, called sqlce30. platform .wce5. processor .cab, where platform is phone for smartphone, ppc for Pocket PC, and blank for Windows CE.

Replication support, called sqlce30.repl. platform .wce5. processor .cab. This cab contains support for using Remote Data Access (RDA) or replication.

Development support, including the Query Analyzer tool, which is in sqlce30.dev.ENU. platform .wce5. processor .cab.

Connecting to an Existing Database

One can use the Connect To Database dialog boxes in both Visual Studio 2005 and SQL Server Management Studio to connect to an existing database. That database can be in the file system on the computer or on a network share on the local area network (LAN). However, the database can also be on a mobile device that one currently has connected to the development computer using Microsoft ActiveSync technology. SQL Server Management Studio offers a similar ability to connect to a device if one selects the <Browse for more > option in the Database File text box in the Connect To Server dialog box.

This ability to connect to a database on a device is a welcome new feature in SQL Server 2005 Compact Edition. This couldn't have been done with SQL CE 2.0 databases using the tools shipped with that version of the product, although excellent third-party products exist that one can use to do this, including SQL CE Console from Primeworks and RemoteSQLCe from GUI Innovations.

2.1.1.4.1.Creating a Table

In Visual Studio, open Server Explorer and expand the folders under the connection to the database. Right-click the Tables folder, and click Create Table so that the Create Table dialog box opens.

In the New Table dialog box one can define the columns in a new table ProductCategory table, which are just two, ProductCategoryID and Name.The first thing to observe in the figure above is how both columns have been set to disallow Null values, which means that if one tries to store a value in the database with a null value, the SQL CE runtime will throw an exception-an example of how one can set constraints on the data in the database to ensure that it is not possible to store incorrect or invalid data.

The second thing to observe is that the ProductCategoryID column is defined as a Primary key, meaning that the database will create an index in this table to assist lookups using the ProductCategoryID value. Also, Unique is set to true on both fields, meaning that a database constraint is applied to ensure that every record in this table has a unique value in both fields. ProductCategoryID is also defined as an Identity field, meaning that each time one add a new record to this table, the database will assign a unique value to this field. The Identity Seed is 1, which is the value that is used for the very first record one add to this table, and Identity Increment is also 1 so that for each subsequent record, the value assigned increments from the previous record by 1.

2.1.1.4.2. Creating a Foreign Key

If we also create a Product table,having as column ProductCategoryID, which cannot be null and clearly is intended to match a valid ProductCategoryID in the ProductCategory table,we have an example of a foreign key, meaning that for each Product record, the value stored in this column must match the ProductCategoryID of an existing record in the ProductCategory table.One could write code in the application to check that this relationship is working correctly, but it is much easier to let the database do the checking.

The database design tools built into Visual Studio do not offer any direct way to create a foreign key, and so the developer will have to execute a Transact-SQL (T-SQL) query against the database. If one has access to SQL Server Management Studio, one can connect to the database and then create and execute a query such as the following:

ALTER TABLE Product
ADD CONSTRAINT Product_ProductCategory_FK
FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory(ProductCategoryID)
ON DELETE CASCADE
ON UPDATE CASCADE

This query creates a foreign key constraint so that the database will not allow a value to be entered in the ProductCategoryID column in the Product table that does not already exist in the ProductCategory table. The ON DELETE CASCADE clause means that if a record in the master table (ProductCategory) is deleted, records in the child table (Product) that referenced the ProductCategoryID of the deleted record are also deleted. ON UPDATE CASCADE means that if the ProductCategoryID of a master record is changed to a new value, the ProductCategoryID value in any child records is updated to match automatically. If one don't want this behavior, one can use ON UPDATE NO ACTION (the default) instead of CASCADE.

If one does not have access to SQL Server Management Studio, one can use Visual Studio 2005 to execute a query, although the technique for doing this is a little obtuse. Right-click oner database in Server Explorer, and then click New Query, which opens the Query Graphical Designer that one would typically use to build SELECT statements to read data from the database. Close the Add Table dialog box, and then delete the SELECT FROM statements in the query pane. Write oner query here, right-click the query pane, and then click Execute SQL.

Two other courses of action are to execute the query using the Query Analyzer tool on the device or to write some code to do it.

.1.4.3.Creating an Index

Developers often overlook one step in improving the performance of SQL Server CE databases. Let's consider the foreign key just created. If the code has read a Product record and it is requested to find out the name of the ProductCategory, one reads the ProductCategoryID value from the Product record and look up the corresponding record in the ProductCategory table. The ProductCategoryID field is the primary key of the ProductCategory table, and SQL Server CE has built an index for it so that the lookup is very fast.

Let's also consider the reverse operation. If one has a ProductCategory record and one wants to find all the Products that are in that product category, one needs to find all records in the Product table that have a ProductCategoryID that matches the value in the ProductCategory record. Although it is created a foreign key constraint linking these two tables, SQL Server CE did not create an index to help in the lookup now wanted. The only way that SQL Server CE can find the required records is to do a full table scan, as shown in the figure above, which could take a long time if the Product table contains many thousands of records.

It is good practice to create an index on the foreign key field in a child table to help with these common searches. To do this in Visual Studio 2005, locate the Product table in Server Explorer, right-click Indexes, and then click Create Index. In the New Index dialog box give the index a suitable name, and click Add to select the column(s) that make up the index .One should create indexes where appropriate to help lookup performance.Every time a record is added, the database must maintain the indexes in addition to adding the new record.

2.1.1.4.4. Deciphering SqlCeExceptions

The SQL Server CE runtime raises a SqlCeException when an operation fails. SqlCeException has an Errors property of type SqlCeErrorCollection that always contains at least one SqlCeError instance describing the error condition that has occurred. A SqlCeError object exposes more details of the error in its HResult, NativeError, NumericErrorParameters, and ErrorParameters properties.

The SqlCeException object also has Message and NativeError properties that are set to the same values as the properties of the same name in the first SqlCeError object in the Errors collection; this is a change from SQL CE 2.0, where one must interrogate the Errors collection to find the real cause of an error because the SqlCeException object does not set these properties.

The cause of an error is usually clear to the developer from the Message property, but if one wants to identify specific errors programmatically, instead of searching for specific text in the Message property, it is better to read the NativeError and HResult properties. If one wants to investigate the cause of an error further, the best resource for findng out more is the Troubleshooting book in the SQL Server Compact Edition (SSCE) Books Online, which lists the error numbers and their meanings.

2.1.1.4.5. Updating the Database with a DataSet

The two tables presented above are represented in the DataSet / SqlCeResultSet, one for Products and one for ProductCategory. The Products table contains columns only from the products table in the database, and the ProductCategory table contains columns that are found only in the corresponding table in the database. When a table is dragged directly from Server Explorer onto the Data Designer,what one is really doing is defining a database query that performs a T-SQL SELECT statement on the columns in only that table. With such a simple query, the tools can generate corresponding INSERT, UPDATE, and DELETE statements.One can see the generated statements in the Data Designer window, select one of the TableAdapter objects, and thento the Properties dialog box, where there are the SelectCommand, InsertCommand, DeleteCommand, and UpdateCommand properties that contain the T-SQL commands that the TableAdapter object uses to interact with the database.

When one calls the TableAdapter. Fill method, it executes a T-SQL SELECT statement to read the data from the database using the data in the SelectCommand property and loads it into the DataTable in the DataSet. It closes the connection to the database, and now the application code works with the data in the DataTable, displaying the data and possibly updating or deleting records, or inserting new records.

Whenever one updates, inserts, or deletes records in a DataTable, the DataTable records this activity by setting the RowState of the affected row to DataRowStatus. Modified, DataRowState.Added, or DataRowState.Deleted, respectively. Unchanged rows have a RowState of DataRowStatus.Unchanged. When one call the TableAdapter.Update method, the TableAdapter object first finds all rows in the source DataTable in the DataSet that have the RowState DataRowStatus.Deleted, and then uses the DeleteCommand to delete the corresponding record in the database. It then finds all rows in the DataTable with the RowState DataRowStatus.Inserted and uses the command in the InsertCommand property to insert the record into the database. Finally, it finds rows with the status DataRowStatus.Updated and uses the UpdateCommand to update the database rows.

All this happens "under the covers" so that the code to read records from the database and then later to update the database is not much more complex than a call to the Fill and Update methods of the relevant TableAdapter .

Many developers who are starting out with DataSets make the mistake of making changes to data in a DataTable and then calling the AcceptChanges method of the DataSet before calling the TableAdapter.Update method. What AcceptChanges actually does is set the RowState of every row to DataRowState.Unchanged. If one calls TableAdapter.Update after one has accepted changes, the TableAdapter will not be able to discover which rows have changed and so is unable to make any changes to the database.

However, the AcceptChanges method can be useful in certain circumstances, for example, when one want to send a DataTable one has built in code to another component and then discover the changes onerself when it is returned.

2.1.1.4.6. Updating the Database with a SqlCeResultSet

As with the strongly typed DataSet, one can use a strongly typed SqlCeResultSet to insert, delete, and update records in the database-but only if the SqlCeResultSet performs a query on a single database table. If the query involves a JOIN across multiple tables, one can use a SqlCeResultSet (or a DataSet) only to read records, not update them.

To insert a record,the tool-generated strongly typed SqlCeResultSet provides a convenient Add<table>Record method with arguments appropriate to that record. For example, the code to add a record to the Product table is:

productRS.AddProductRecord(
"Contoso Single Rope", "Red/Blue", 155.95M, "60m", 1);

If one goes to the definition of this method (in Visual Studio, right-click the code that calls this method, and then click Go To Definition), one can see what the tool-generated code does:

public void AddProductRecord(string Name, string Color,
decimal ListPrice, string Size, int ProductCategoryID)

It creates a SqlCeUpdateableRecord by calling base.CreateRecord(), where base in this case is the parent class, which is a SqlCeResultSet. Then it sets the values in the correct columns and calls the Insert method of the SqlCeResultSet to insert it into the database.

Deleting records is very simple. Again, the tools have generated a method for this actin in the strongly typed SqlCeResultSet:

public void DeleteRecord()

To update a record, one simply positions the cursor at the required record using a call to Read (which reads the next record in sequence) or ReadAbsolute (which reads a specific record by index number), make the changes, and then call the SqlCeResultSet.Update method. For example:

// Create a typed SqlCeResultSet.
using (ProductsResultSetResultSets.ProductResultSet productRS =
new ProductsResultSetResultSets.ProductResultSet())

finally

}

Getting Connected

Mobile application developers often spend a lot of time and effort on interacting with the mobile device platform on tasks that are not directly related to the business functionality of the application but that are still essential to a successful solution. Mobile devices usually support a number of different networking technologies, including direct cable connections or wireless connections over a mobile phone network, such as WiFi or Bluetooth.

Understanding Connections on Windows Mobile

Microsoft Windows Mobile includes settings that are responsible for all the configured connections on the device. Because the settings screens manage a variety of connection types, they can sometimes look confusing, but they are central to how the Connection Manager on the device works.

One can access the settings by tapping Start, Settings, and on the Connections tab, tapping the Connections item. This opens the Settings dialog box, as shown in the figure below, which contains two tabs labeled Tasks and Advanced. The first thing to notice is that the tasks are split into two clearly defined groups: My ISP, which contains tasks related to connections to the Internet, and My Work Network, which contains tasks relevant to connecting to a corporate network either directly or by using a virtual private network (VPN) connection. Work refers to a corporate network; one would typically use it to access servers within oner firewall, including, for example, a Microsoft Exchange Server. The Internet destination network supports all other traffic destined for the wider Internet. The concept of two main destination networks-Internet and Work-is central to the way Connection Manager works.

If the device was supplied by a mobile operator, it should have available Internet connections set up for the user.

Using Desktop Passthrough

Microsoft ActiveSync is an application shipped for the desktop Windows operating system to support connecting and synchronizing devices that run Windows Mobile. In the Windows Vista operating system, ActiveSync received a face-lift and is now called the Windows Mobile Device Center-but it is still the same ActiveSync technology under the hood.

ActiveSync works over universal serial bus (USB), serial, or Bluetooth connections and provides a passthrough network connection so that one can access the wider Internet using the desktop computer rather than establish a GPRS or similar wireless connection.

ActiveSync uses the same concept of destination networks as Connection Manager when routing requests from the device. From ActiveSync on the desktop, one can specify to which of these network types the computer is connected in the Connection Settings dialog box, as shown in the figure below. The default setting in the This Computer Is Connected To box is Automatic, so any attempt to access either a Work or an Internet resource should be passed through the ActiveSync connection. One is unlikely to need to change this setting.

There are no APIs to allow one to change these settings programmatically. On the device side, the connection is invisible and appears just as if the device has an active Internet connection. Sometimes, for example, when one wants to upload certain information only when one is on a high-bandwidth connection with no costs to send data, one may need to know if the device is connected through ActiveSync or another connection such as a mobile phone network. In Windows Mobile 5.0, the Microsoft.WindowsMobile.Status.SystemState class contains the ConnectionsDesktopCount property one can query to determine whether the connection is active. It might seem odd to expose it in this way because the device can have only one desktop connection active at a time, but it follows the pattern used for all other connection types.

On older devices, one can indirectly determine the type of connection by checking whether one can resolve the host name used by ActiveSync. If one is connected by ActiveSync, the host name PPP_PEER will resolve to the Internet Protocol (IP) address of the desktop, and the device will be assigned its own address in the same range. When an ActiveSync connection is established, devices that run Windows Mobile and Windows CE close connections to other networks, such as WiFi, GPRS, or Code-Division Multiple Access (CDMA).

public static bool DesktopPassthrough

catch

}
}

The technique of using the System.Net.Dns class is equally useful to look up the IP address of remote computers over any IP-based network. As long as one can connect to a Domain Name System (DNS) server on the network and he passes a valid host name, one can determine the IP address. If one is programming using sockets he/she must specify the IP address of the remote host to connect to, so he must perform a DNS lookup on the remote host name to obtain the IP

Developing with Windows Mobile

The Microsoft Windows Mobile operating system contains a number of application programming interfaces (APIs) that are exclusive to Windows Mobile-powered devices Windows Mobile 5.0 and later feature a set of managed APIs that can easily be used in both Microsoft .NET Compact Framework version 1.0 and version 2.0 projects.

The Windows Mobile managed APIs include functionality for a number of different areas, but by far the most complex and widely used is the Microsoft.WindowsMobil . PocketOutlook library, an easy-to-use managed class library around two separate native APIs: the Microsoft Office Pocket Outlook Object Model (POOM), which is responsible for Calendar, Contacts, and Tasks on the device, and Windows CE Mail API (CEMAPI), which handles all e-mail and Short Message Service (SMS) functionality on the device. In Windows Mobile 5.0, this set of functionality was renamed Outlook Mobile; however, the programming interface retains the Pocket Outlook name. All activities using the Pocket Outlook functionality are based on the central OutlookSession class. Therefore, one should create an instance somewhere central to the application, for example, as a member of the main application form. The following sample application uses this approach: The session is initialized in the Form_Load method.

using Microsoft.WindowsMobile.PocketOutlook;

2.3.1. Personal Information Management

The Pocket Outlook Object Model, the native API on which this managed class library is built, is designed as a subset of the Outlook Object Model present in the desktop Microsoft Office Outlook application. With the Pocket Outlook Object Model, one can access the Calendar, Contacts, and Tasks data held on the device; these are referred to as Personal Information Management (PIM) items.

Because of the limitations of the applications on the device, the Pocket Outlook Object Model is notably missing a number of features that an experienced Outlook developer is familiar with. For example, each type of data has only a single folder, whereas Outlook supports a rich nested folder structure. There is no e-mail support in the Pocket Outlook Object Model. All of the PIM data held on the device can be synchronized with Outlook on the user's desktop computer or a Microsoft Exchange Server, depending on the synchronization settings applied.

2.3.1.1. PimItem

All individual PIM items are derived from the PimItem base class. This class defines standard functionality supported by all item types such as the ability to display the item to the user with the ShowDialog() method and the ability to copy and delete items. Each PimItem is uniquely identified by its ItemId property. Internally, the ItemId contains a numerical ID assigned by the database engine on the device. These IDs do not persist across a backup and restore and are not synchronized with desktop Outlook.

All of the properties in the PimItem-derived classes have accompanying events that fire if the property value is changed. For example, the Body property, which contains the plain text notes for the item, has an accompanying BodyChanged event. These events reflect only changes made in oner own code-if the user modifies items in the standard PIM applications or in a third-party application, the data in oner application will not automatically update. All items contain a Categories property, which is a string value containing the names of categories to which the item is assigned. Internally, Pocket Outlook maintains a master categories list that is not exposed through the managed class library.

.3.1.2. Appointments

Windows Mobile supports both one-time and recurring appointments. One can create a new Appointment either by using the AppointmentCollection.AddNew() method or the Appointment constructor. If one uses the Appointment constructor, one must call AppointmentCollection.Add() to add the new item to the calendar on the device; otherwise, when one calls Update() to save the item, an exception will be thrown. Strongly typed collection classes are implemented for each of the item types, and these support a number of standard .NET interfaces and with them one can easily data-bind controls to the PIM data. For example, the sample application that accompanies this chapter displays all the Appointment data in a DataGrid control using just the following code:

private void OutlookForm_Load(object sender, System.EventArgs e)

One can data-bind to controls just as one would with other collections or data sources. The Appointment class offers a range of unique properties for setting the start and end times for the event. Appointments can be marked as all-day events by setting the AllDayEvent property to true. This ignores the time component of the Start and End properties, and it also affects the way the items are displayed in the Calendar application. All-day events are always listed at the top of the day view and do not scroll out of view. Appointment behavior is also affected by the BusyStatus property, which one can use to set the status to Free, Busy, Tentative, and Out Of Office. Each status has a color key when the items are displayed in the Calendar application.The figure below shows a few different types of appointment.

2.3.1.3. Tasks

The Task item is used to store the user's to-do list. Tasks have properties for setting due date, completion status, and priority. Other than the task-specific properties, working with tasks is the same as working with the other item types. The DateCompleted and Complete properties are linked-because DateCompleted is read-only, the value is set to the current time whenever the Complete property is set to true. Because tasks are synchronized with the user's Outlook task list, they can be very useful for recording outstanding work from a mobile application. The following code example shows how to create a Task item.

private void SaveTask(string customerid, int jobNumber, string description)

2.3.1.4. Reminders

A reminder can be set for appointment and task items. The time of appointment reminders can be overridden using the ReminderMinutesBeforeStart property. For task items, one set the ReminderTime property using the exact DateTime value. One can also set the way in which the reminder behaves by using a number of Boolean properties:

ReminderDialog

ReminderLED

ReminderRepeat

ReminderSound

ReminderVibrate

If the ReminderSound property is set to true, one can override the default reminder sound by passing the full path of a .wav audio file to the ReminderSoundFile property. The following example shows how to create an Appointment and set a reminder.

private void AppointmentWithReminder(DateTime start, TimeSpan duration,
string subject)

2.3.1.5. Contacts

Contact is another class derived from PimItem, and it contains properties to describe the various contact methods for that item, including telephone numbers, e-mail addresses, and postal addresses. Each communication type includes multiple properties so that a contact can contain both a HomeTelephoneNumber and a BusinessTelephoneNumber, for example. As with the other PIM, the ContactCollection supports data binding.

The display string used for a contact can be retrieved from the contact's FileAs property, which is automatically generated based on the FirstName and LastName properties one provide, although one can manually change the FileAs property if required. When one create a new contact, all fields are optional; however, one should at least set the FileAs or the name properties. The following code shows how to add a new Contact item.


Contact c = session.Contacts.Items.AddNew();
c.FirstName = "Michael";
c.LastName = "Allen";
c.Email1Address = "[email protected]";
c.MobileTelephoneNumber = "555-0132";
c.CompanyName = "Contoso Pharmaceuticals";
c.Update();

2.3.1.5.1. ChooseContactDialog

Unique to contacts is the functionality to display the list of contacts to the user so that the user can choose a specific contact, such as is common when creating an e-mail message. The Microsoft.WindowsMobile.Forms namespace includes a component specifically designed to address this-the ChooseContactDialog. This can be used to select a specific contact, select a specific property of a contact, or select a combination of both. When selecting contacts, one can also apply a restrict filter using the same syntax as used with the ContactCollection.Restrict() method. With the RequiredProperties property, one can specify which properties must be present on the items to be shown. For example, the user can choose not to show contact items that have no e-mail address. Some special entries in the ContactProperty enumeration act as wildcards; for example, ContactProperty.AllEmail is equivalent to combining the Email1Address, Email2Address, and Email3Address properties. If the selected contact has more than one matching property, a second screen is shown to the user so that the user can choose the specific property to use. The prompt on this screen is defined with the ChoosePropertyText property. The following code example shows the ChooseContactDialog being used to select a specific e-mail address:

ChooseContactDialog ccd = new ChooseContactDialog();
ccd.ChoosePropertyText = "Select an email address:";
ccd.ChooseContactOnly = false;
ccd.Owner = this;
ccd.Title = "Choose an email recipient";
ccd.RequiredProperties = new ContactProperty[] ;

if (ccd.ShowDialog() == DialogResult.OK)

In Windows Mobile 6, some additional properties are available, such as EnableGlobalAddressListLookup. This is a Boolean property that when set to true allows the user to browse the Global Address List (GAL) as well as the user's local contacts. Another useful addition is the NoUIOnSingleOrNoMatch property. When set to true, the dialog box is not shown to the user if there is no possible choice or only one possible option. The ChooseContactDialog dialog box has a look and feel just like the standard Contacts application.

2.3.1.6. Custom Properties

The standard properties available on the PIM items are sufficient for most uses but are, as expected, a subset of those available in Outlook. One can add his own custom properties to items; however, these are not synchronized and are not displayed in the standard Outlook Mobile dialog boxes for viewing and editing items. Each type of PimItem has a specific set of strongly typed properties, and it also has the Properties collection, which is of the type PimPropertySet. This collection allows one to access property values from their property identifiers using the AppointmentProperty, ContactProperty, and TaskProperty enumerations. It also supports retrieving properties by using their name, and it is this mechanism that is used to retrieve custom properties. A custom property must first be added to the collection by using the Add method. It is not necessary to specify the type of the property, in which case a string type will be used, but an additional override of the Add method accepts a .NET type:

c.Properties.Add("LastInvoice", typeof(int));
c.Properties["LastInvoice"] = 3124;

Although Add takes a Type, custom properties can be of only a few specific types-anything else results in an ArgumentException being thrown. The supported property types are the following:

Bool

Byte[]

DateTime

Double

Int16

Int32

UInt16

UInt32

String (default)

After one has added a custom property to a particular item, that property is available to the whole collection of that item type. So, for example, one needs to add the LastInvoice property only once to a contact, and then one can directly set that property on any other contact. It is oner responsibility to ensure that whatever value one assign to the property matches the type used when creating the custom property; otherwise, an ArgumentException will be thrown.

2.3.1.7. Messaging

The messaging system on Windows Mobile encompasses the e-mail and SMS functionality. The managed class libraries give one the ability to send both e-mail and SMS messages and perform some basic automation of the messaging application.

2.3.1.7.1. E-Mail

The EmailMessage class represents a single e-mail message and contains properties to set the recipients, message contents, and file attachments. The managed APIs do not include functionality to read messages already on the device, which would require Platform Invocation Services (PInvoke) around the CEMAPI functionality or use of a third-party library such as Mobile In The Hand

To send an e-mail message programmatically, first one must create a new instance of EmailMessage. The To property contains a RecipientCollection that represents one or more recipients for the message. The EmailMessage class also contains collections of carbon copy (CC) and blind carbon copy (BCC) recipients. A Recipient object is created using either just an e-mail address or a display name and an e-mail address.

The message contains string properties to set the subject line and the message body. One can set some additional properties on the message, including the Importance (High, Low, or Normal) and Sensitivity (Private, Confidential, Personal, and Normal). The message also contains an Attachments property. This is an AttachmentCollection that can be used to attach files to the message. An Attachment contains a single property that is the full path to the file. The file must exist at this location or an ArgumentException will be thrown. The following code sample shows a complete example of creating an e-mail message, populating the recipients, creating the message contents, and adding a file attachment:

private void SendGenericEmail()

2.3.1.7.1.1. Sending and Receiving

The default behavior for the messaging application is for messages to be placed in the Outbox until the e-mail account is explicitly synchronized by the user. This gives the user complete control over when to establish a network connection for exchanging this data. One can programmatically force a send and receive operation on the user's behalf by using the MessagingApplication.Synchronize method. There are a couple of overloads for this method, the default of which takes no arguments and performs a send and receive on the currently active e-mail account. The two other overloads take either an EmailAccount argument or a string that contains the name of the account. The synchronization occurs asynchronously, and there is no way to determine whether the operation was successful or when it completed. The sample application has a Sync button that calls the following code:


private void btnSync_Click(object sender, EventArgs e)

2.3.1.7.1.2. Composing a New Message

Rather than build a message in oner own code, one may prefer to present the user with the standard new message dialog box. With the MessagingApplication.DisplayComposeForm method, one can do this. This method is very flexible because it features numerous overloads so that one can prepopulate the form before showing it to the user and specify which e-mail account to use. The sample application includes a Compose button that calls this method, passing in the recipient address, subject and body, and a file attachment:

private void btnCompose_Click(object sender, EventArgs e)
;

if (File.Exists(openFileDialog1.FileName))
;
}
MessagingApplication.DisplayComposeForm(
session.EmailAccounts[0].Name, txtEmailAddr.Text,
"Populated Compose Form", txtBody.Text, attachments);
}

2.3.1.7.2. SMS

The SmsMessage type is similar to its e-mail equivalent, and both are derived from the base Message class. Because SMS is a simpler messaging system, it has fewer properties than e-mail does. The other big difference is that SMS messages are always sent immediately (subject to cellular network coverage) rather than being placed in the Outbox until a connection is made. An individual SMS message is 160 characters long; however, one can work around this limitation by splitting a long message across multiple SMS messages. The messages are then reassembled on the receiving device. Because each 160-character message is billed as a separate message, and because many mobile phones don't have user interfaces suited to reading long text content, one should keep SMS messages concise.

One can send an SMS message to multiple recipients by passing several Recipient objects to the To collection; however, these are sent internally as separate messages and therefore each copy is billed as a separate message. One can optionally request a delivery report for the message that will be received in the SMS Inbox when the recipient device acknowledges receipt of the message. Because SMS is a store-and-forward mechanism, a message can take some time to get to its destination based on network traffic levels and the recipient's cellular coverage. The operations to send a single SMS message are shown in the following code example:

private void SendGenericSms()

2.3.1.8.Pictures

The Microsoft.WindowsMobile.Forms namespace contains two components for working with pictures: SelectPictureDialog provides an alternative to the traditional OpenFileDialog by displaying images using thumbnails. This makes it much easier to work with image files because one can see what one is choosing rather than just picking by the file name alone.The figure below shows the standard appearance of the SelectPictureDialog.

Using the default settings, one can open the dialog box by using just a couple of lines of code. If the device has a built-in camera, the first item in the list on the picker will be a link to the camera application. One can customize this behavior by disabling access to the camera by setting CameraAccess to false. One can also add his own title to the dialog box by using the Title property. One can toggle whether distributed rights management (DRM) content is displayed to the user. One of the properties of this dialog box, LockDirectory, is documented as being able to block the user from browsing outside the InitialDirectory one specify; in actual fact, this property is not implemented, and the user will still be able to browse outside the initial directory. The following example shows how to set up and display the SelectPictureDialog:

private void mnuChoose_Click(object sender, EventArgs e)

}

2.3.1.9. Camera

As well as providing a method to select a picture already on the device, one can programmatically invoke the camera to add picture-taking functionality to the application. The CameraCaptureDialog provides a simple interface over the platform's camera support. The API is consistent across all Windows Mobile-powered devices, even though each manufacturer is responsible for implementing the camera functionality and user interface. For this reason, the actual camera dialog box can vary between different devices

The dialog box can be set to still image or video mode, and one can specify a preferred resolution for the output, although device capabilities can vary. The following code example shows how to invoke the camera dialog box:

private void mnuCapture_Click(object sender, EventArgs e)

2.4. Communication Technologies

2.4.1.Using Serial Ports

Serial ports are a communication technology that one can use to talk to peripheral devices attached to his device. The technology is tried and tested, and lots of specialist hardware sensors and accessories such as Global Positioning System (GPS) receivers communicate by using serial ports. .NET Compact Framework version 2.0 supports the SerialPort component, which was also introduced in version 2.0 of the full framework.The key port properties exposed are listed in the table below.

SerialPort Properties

Property

Description

PortName

This is the full name for the port without the trailing colon.

BaudRate

Physical baud rate in bits per second; this must match that used on the remote device.

StopBits

Number of stop-bits transmitted, usually 1.

NewLine

Determines the character used to represent a new line. Used by the ReadLine() method. Examples are \r and \r\n.

Using the SerialPort component, I tried to build a simple terminal application designed to connect to a serial port and send and receive data. This is a very simple application with a single form. The SerialPort component exposes events when data is received, and these are marshaled through to the UI thread. The SerialPort component has defined buffers that are used for both incoming and outgoing data. The class exposes a simple set of properties, methods, and events and works directly with the Windows CE file APIs under the hood. A simple way of testing the application is to open a port connected to a GPS receiver. When a connection is established, the device will send back National Marine Electronics Association (NMEA) text data.

Before one can open a SerialPort, one needs to know the port name. The SerialPort class exposes a static method GetPortNames() to return a list of available serial ports. We call this on the Load event of our main form and assign the resulting string array to a ComboBox:

private void Form1_Load(object sender, EventArgs e)

The user can choose the port from the ComboBox and set other properties such as BaudRate, and then tap Connect. In the method handling this menu item, we provide the code to establish a connection if the current state is disconnected or to disconnect the current connection. After the port is opened, a handler is set up for the DataReceived event, and this event is raised whenever the port has data ready for processing.

private void mnuConnect_Click(object sender, EventArgs e)

else

catch


}
}

The spPort_DataReceived method receives data and appends it to a TextBox. Because this event is not raised on the user interface thread, we must use Control.Invoke to another method ShowNewData, which updates the TextBox.

//method invoked on ui thread to append text to text box
void ShowNewData(string data)

//custom delegate to receive a single string for marshaling
//to the user interface thread
private delegate void InvokerDelegate(string data);

//event handler for serial port data received
void spPort_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e)
);
}

We can send data to the port using the SerialPort Write and WriteLine methods. WriteLine writes a string and follows it with the newline character that is defined on the specific serial port. Tapping the Send button in our sample sends the contents of the outgoing text box to the serial port:

//Send an outgoing message to the remote device (appends a line break).
private void btnSend_Click(object sender, EventArgs e)

}
}

As with any other networking or communication technology we have described, one can encode oner data in any way one see fit. The example application works only with devices that return data as plain text and will display garbage characters if binary data is used.

2.4.2. Virtual Serial Ports

Most devices support serial port emulation to expose Bluetooth devices to legacy applications that support only serial ports. For example, navigation software expects a GPS receiver to be connected to a serial port; in the case of a Bluetooth receiver, one must assign a virtual serial port that can be selected from in the navigation software. Because the way these are configured can vary between devices and the Bluetooth networking stack used on the device, it is not possible to provide definitive instructions. On Windows Mobile 5.0, when the Microsoft Bluetooth stack is used, there is a section of the Bluetooth control panel used to configure virtual serial ports, and these are configured in the device registry. After a virtual port is set up on the device, one use it programmatically just as one would a device connected by a serial cable.

3.System Analysis and Design

3.1.Problem statement

Implement a client server application to simulate the activity of a commercial agent. The client introduces the agent id and waits for the days in which he has to go to work. He chooses the day and then he waits for the shops that need to be supplied. The agent will then choose the shop to visit, and the list of products from the stock will appear. The agent will choose the products ordered and introduce the quantity required.

The application is implemented in Visual Studio 2005, C# . The server part is a Console Application, it is implemented on .NET framework and is connected to a database created in SQL Server. The client is implemented on a Pocket PC Emulator, with .NET Compact Framework.

3.2.Use cases

The only actor in this application is the agent:

  The agent logins to the application by introducing the id.Then the list of days appear. He chooses the day and he obtains the list of shops. He chooses the shop and he obtains the list of products. He chooses the product and makes a new order

3.3. Sequence diagrams

I chose to draw the sequence diagrams for :

  • Login

GetProducts

3.4.Class diagrams

For Server

3.4.2 For client

4. User's Guide

The user starts the server, that is waiting for clients to connect to it.

He then starts the client, the Pocket PC Emulator, which will open the Login Window:.

The user introduces the Agent ID and sends the data to the server, which will send back the working days:

The user will then select a day and click the "Go to work button".

The data will be sent to the server, and then, the client will receive a response regarding the shops the agent has to see that day:

The agent-user will choose the shop he will visit first, send the data to the server, and it will send back the products that are on the stock and the quantity available. The agent will than choose the product he wants to order and introduce the quantity in its textbox. The update will be made, by decreasing the stock quantity of the chosen product.

Conclusions

This paper is meant to show the way I simulated the activity of a distribution enterprise, by implementing the steps one of its commercial agents has to follow in order to take orders from the shops he has to visit.

As a first part, I presented general characteristics of mobile devices and the operation system they support, in order to be able to develop applications on them.

The solution is implemented in Visual Studio, so the next step was to write about some more specific programming features used in order to make the implementation. A very interesting aspect seemed to be the connectivity to a database in SQL Server and of course the connection between the server and the Pocket PC Emulator, which is the way in which I chose to implement the client, so that it could be closer to real life.

Regarding the implementation, I created the use case diagrams, sequence diagrams and class diagrams to show the way in which the solution was designed to be implemented.

And of course, the last step was writing the user guide, to make the application easy to be compiled.

My application is just a simple part of what ordering is a distribution enterprise means. Its purpose is to show the efficiency of mobile devices programming in real world and it can be expanded to a larger one, with more elements in the database and more requirements.

Bibliography

Andy Wigley , Daniel Mothand, Peter Foot. "Microsoft Mobile Development Handbook", Microsoft Press,2007

Frank H.P. Fitzek and Frank Reichert , "Mobile Phone Programming and its Application to Wireless Networking", Ed. Springer

John L.Cook, "WAP servlets professional developer's guide", Ed. New York

D.Floyd, "Mobile application security system", Publication: BELL LABS TECHNICAL JOURNAL, 11, no. 3, (2006): 191-198

P Alatalo; J Jarvenoja; J Karvonen; A Keronen; P Kuvaja,"Mobile Application Architecture"

Publisher: Berlin ; New York : Springer-Verlag,

R. Stieger, D. Brooke " Mobile Application reference design accelerates development "

by R Stieger; D Brooke, Publication: RF DESIGN.

Paul Yao. Dudiv Durant, .NET Compact Framework Programming with C# , Publishor Addison Wesley Proffesional


Document Info


Accesari: 6157
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )