Tài liệu PalmOS Web Application Developer''''s Guide - Pdf 84

1 YEAR UPGRADE
BUYER PROTECTION PLAN
Palm OS
Ben Combee
R. Eric Lyons
David C. Matthews
Rory Lysaght
Foreword by
Adam Tow
Web Application
Developing and Delivering PQAs with Web Clipping
• Step-by-Step Instructions for Creating Palm Web Applications Using
Web Clipping Technology
• Hundreds of Developing & Deploying Sidebars, Security Alerts, and
Web Clipping Code Explained
• Complete Coverage of Design for Internet-Enabled Mobile Devices
Developer’s Guide

With more than 1,500,000 copies of our MCSE, MCSD, CompTIA, and Cisco
study guides in print, we continue to look for ways we can better serve the
information needs of our readers. One way we do that is by listening.
Readers like yourself have been telling us they want an Internet-based ser-
vice that would extend and enhance the value of our books. Based on
reader feedback and our own strategic plan, we have created a Web site
that we hope will exceed your expectations.
is an interactive treasure trove of useful infor-
mation focusing on our book topics and related technologies. The site
offers the following features:

One-year warranty against content obsolescence due to vendor
product upgrades. You can access online updates for any affected

Syngress Publishing, Inc., the author(s), and any person or firm involved in the writing, editing, or production
(collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from
the Work.
There is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The Work is sold
AS IS and WITHOUT WARRANTY.You may have other legal rights, which vary from state to state.
In no event will Makers be liable to you for damages, including any loss of profits, lost savings, or other incidental
or consequential damages arising out from the Work or its contents. Because some states do not allow the exclu-
sion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.
You should always use reasonable case, including backup and other appropriate precautions, when working
with computers, networks, data, and files.
Syngress Media®, Syngress®, and “Career Advancement Through Skill Enhancement®,”are registered trademarks
of Syngress Media, Inc. “Ask the Author™,” “Ask the Author UPDATE™,”“Mission Critical™,” and “Hack
Proofing™” are trademarks of Syngress Publishing, Inc. Brands and product names mentioned in this book are
trademarks or service marks of their respective companies.
KEY SERIAL NUMBER
001 DJG4T945T5
002 AKLRT4MLE4
003 VMERL3N54N
004 SGD34B39UN
005 8LU8MU6N7H
006 NFG4RNTEM4
007 BWBVHTR46T
008 QPB9R565MR
009 83N5M4BKAS
010 GT6YH22WFC
PUBLISHED BY
Syngress Publishing, Inc.
800 Hingham Street
Rockland, MA 02370
Palm OS Web Application Developer’s Guide: Including PQA and Web Clipping

Bunkell, and Klaus Beran of Harcourt International for making certain that our
vision remains worldwide in scope.
Anneke Baeten, Annabel Dent, and Laurie Giles of Harcourt Australia for all
their help.
David Buckland,Wendi Wong, Daniel Loh, Marie Chieng, Lucy Chong, Leslie Lim,
Audrey Gan, and Joseph Chan of Transquest Publishers for the enthusiasm with
which they receive our books.
Kwon Sung June at Acorn Publishing for his support.
Ethan Atkin at Cranbury International for his help in expanding the Syngress
program.
Joe Pisco, Helen Moyer, and the great folks at InterCity Press for all their help.
139_palm_FM 6/11/01 12:37 PM Page v
Ben Combee would like to thank the following people for their support and contri-
butions to the book:
Thank you to Charles Wilson, John Wirth, and Anil Patel.To David Fedor, Danny
Epstein, Peter Epstein, Ken Krugler, Keith Rollin, and the other helpful Palm
employees that contribute to the online forums.To Neil Rhodes, Aaron Ardiri, and
John Marshall for their work on free development tools for the Palm.To Vernard and
Kim Martin, Charles and Heather Patisaul, and finally to Lamar, Rose, Cyndi, and
Kaye Combee.
Acknowledgments
vi
139_palm_FM 6/11/01 12:37 PM Page vi
vii
Contributors
David C. Matthews is an Independent Consultant located in Huntsville,
AL. He has over 20 years of full life cycle software development experi-
ence and currently specializes in wireless Web technologies. He has con-
tributed to several books on developing PalmOS Web clipping
applications, DHTML, and JavaScript. David has also overseen several

Mobile’s server products. His Palm development work includes the award-
winning OneTouch Mail (recipient of the 1998 Best Handheld Software
award, Mobile Computing Magazine) and OmniSky products, as well as
BeamLink. Hari has a bachelor’s degree in Computer Science from
R.E.C Calicut, India. He currently resides in Richardson,TX. Hari would
like to thank his wife, Suma, for her love and support. Hari would also
like to thank his collegues Alex Farcasiu, Joan Garcia, and all his friends at
JP Mobile for their help.
139_palm_FM 6/11/01 12:37 PM Page viii
ix
Adam Tow has been passionate about the handheld industry ever since
he purchased his first handheld, the Apple Newton MessagePad, in
September, 1993. Adam is currently the Manager of Technology at Palm,
Inc., the worldwide leader of mobile computing, where he is actively
involved in the company’s wireless initiatives. Prior to joining Palm, Adam
founded and directed Foundation Systems, a mobile computing solutions
firm, where he consulted with Palm and OmniSky on the release of two
critically acclaimed consumer wireless devices, the Palm VII organizer and
the OmniSky Palm V handheld. Adam has presented on Web clipping
development at PalmSource and the Palm Developer’s Conference. In
addition, his company’s software for the Newton and Palm OS platforms
has been sold in over 22 countries and has been featured in publications
such as Pen Computing Magazine, Mobile Computing, and the San Francisco
Chronicle. He has been interviewed in Interface Magazine and on C|Net
and ZDNN. He is the founding member of the Stanford Palm User
Group.
Adam received his bachelor’s degree from Stanford University in
Symbolic Systems, with a focus in Human-Computer Interaction. His
other passions include photography, digital multimedia, and online jour-
nalism. Adam can be reached on the Web at www.tow.com/ or via e-mail

ping application for Safeway UK. He is interested in embedded program-
ming on small devices and their use in e-business. Calvin resides in
Poughkeepsie, NY.
Technical Reviewer
139_palm_FM 6/11/01 12:37 PM Page x
xi
This CD-ROM contains the code files that are used in each chapter of this book.
The code files for each chapter are located in a “chXX” directory. For example, the
files for Chapter 8 are in ch08.The organizational structure of these directories
varies. For some chapters, the files are named by the figure number. In other chap-
ters, the files are organized by the projects that are presented within the chapter.
Files ending with .htm and .html are HTML files. Usually, these are inputs to the
Web Clipping Application Builder program that is used to make Web clippings.These
may have associated graphic files. Some chapters have files with a .pl extension.These
are Perl source files and are designed to be installed as CGI scripts on your Web
server. Chapter 8 contains files with .php extensions; these are Web pages with
embedded scripts that get executed by the PHP interpreter on a Web server.
Chapters 10 and 11 each contain programs written in C for Palm OS.The
examples in Chapter 10 were all produced with CodeWarrior for Palm OS, Release 7.
These are small enough to work with the demo version of CodeWarrior for Palm
OS that is included on this CD-ROM.The programs in Chapter 11 were written
using PRC Tools, the port of the GNU C compiler to Palm OS.These also come
with CodeWarrior projects. Most of the programs in Chapter 11 can be built with
the demo edition of CodeWarrior, but the final program is too large to work with
the included demo.
Also contained on this CD-ROM are full versions of several useful Web server
programs, all built for Microsoft Windows. Included are the latest versions (at the
time of publication) of PHP, Apache Server, and ActivePerl.To install the ZIP files,
you need some sort of unzip utility, such as WinZip (www.winzip.com).To install the
.msi files, you need the Windows Installer.This package is built into Windows 2000,

Using Clipper to Get Access to Web Information 13
Summary 14
Solutions Fast Track 14
Frequently Asked Questions 16
Chapter 2 Building a Simple
Web Clipping Application 17
Introduction 18
Writing Simple Web Pages 18
Running the Web Clipping Application Builder 19
Load Web Clipping
Applications on Your
Device
New Web clipping
applications can be added
to Palm VII devices in the
same fashion that Palm OS
applications are installed.
Web clipping applications
can be added to a Palm
VII by using the Install Tool
application on a desktop
computer and performing
a HotSync operation with
the device.
139_palm_TOC 6/11/01 12:41 PM Page xiii
xiv Contents
Picking Your HTML Files 20
Setting Options in the Build PQA Dialog Box 21
Setting Small and Large Icons 24
Building a Multiple Document PQA 25

Small Headers: <H4>, <H5>, and <H6> 49
Horizontal Rule: <HR> 50
Learn How to Install
Icons in the
Application Launcher
Learn What HTML Tags
Are Available and How
to Use Them
The most common body
tags available in the HTML
3.2 specification are
available in the Web
clipping HTML definition.
Content with these tags
applied may render
differently to fit the small
Palm OS device screen.
139_palm_TOC 6/11/01 12:41 PM Page xiv
Contents xv
Images: <IMG> 50
Ordered and Unordered List: <OL>
and <UL> 53
Structured Information: <TABLE> 55
Text Markup 58
Physical Markup: Bold, Italics, and
Underlining 58
Font Markup: <FONT> 60
Logical Markup: Strong and
Emphasized Text 60
Hyperlinks: <A> 61

Color Name Hex
Black #000000
Silver #C0C0C0
Gray #808080
White #FFFFFF
139_palm_TOC 6/11/01 12:41 PM Page xv
xvi Contents
Solutions Fast Track 104
Frequently Asked Questions 106
Chapter 5 Interacting with Forms 107
Introduction 108
Using Standard HTML Forms 108
Accepting User Input 110
Handling Textual Input 112
Retrieving Sensitive Passwords 114
Making a Choice Using a Checkbox 116
Selecting from Several Items with
Radio Buttons 121
Storing State in Hidden Fields 124
Submitting Completed Forms 126
Starting with a Clean Slate 127
Selecting from Many Choices 128
Handling Large Amounts of Input Text 132
Tracking Widget Inventory Example 134
Processing Forms on the Server 137
Placing a Widget Order Example 143
Enhancing Forms for Clipper 145
Using the Timepicker Type 146
Using the Datepicker Type 148
Setting Delivery Date for Widget Orders Example 150

know what they are
actually scribbling.
Without that feedback,
you could easily enter
wrong data. Palm’s
compromise is to show
this password input for
only the brief time that the
user is entering the text.
139_palm_TOC 6/11/01 12:41 PM Page xvi
Contents xvii
Starting with a Desktop-Oriented Page 162
Redesigning the Page for Both Desktop
and Handheld 167
Using Tables for Page Layout 175
Specifying History Text 184
Using the HistoryListText META Tag 184
Using Date and Time Variables with the
History Text 185
Using MAILTO Links to Send E-Mail 187
Using Other Mail Handlers with
Palm OS 4.0 189
Summary 190
Solutions Fast Track 190
Frequently Asked Questions 192
Chapter 7 Debugging Web Clipping
Applications 195
Introduction 196
Emulating Web Clipping by Using the Palm OS
Emulator 196

such as the steps
required to produce
the problem, date and
time of the first
occurrence (including
time zone), and so on.
Q:
What can I do to stay
abreast of the latest
developments in WCA
debugging
technology?
A:
A good first step is to
join the Web Clipping
Announcement list and
Web Clipping Forum
using the forms at
www.palmos.com/dev/
tech/support/forums.
139_palm_TOC 6/11/01 12:41 PM Page xvii
xviii Contents
Caching 205
Secure Sockets Layer Encryption 205
Detecting Proxy Problems 206
Using Valid Development Proxy Servers
and HTTP Port Numbers 207
Having a Valid Security Certificate 208
Failing Due to Invalid HTML 208
Diagnosing Image Problems 209

Cookies let you store
data on the device
that can be retrieved
at a later time.

Cookies are supported
only in Web clipping
on Palm OS 4.0 and
later devices.

Although cookies can
be used to make the
user’s life much easier,
by storing preferences
or login information,
they can also be used
to secretly track which
sites a user visits.
139_palm_TOC 6/11/01 12:41 PM Page xviii
Contents xix
Building Device Identifiers on the Kyocera
QCP-6035 Smartphone 231
Identifying Sessions Using URL Rewriting 232
Encoding a Session ID in a URL 233
Managing Sessions with PHP 4 235
Understanding PHP Syntax 236
Configuring PHP for URL Rewriting 238
Starting a Session 239
Saving System State in a Session 239
Using Automatic URL Rewriting 240

convert %ZIPCODE to
other position qualifiers
(State and County, for
example), a new Palm-
specific variable has been
created within Palm OS
4.0. Named %LOCATION,
it provides a robust
mechanism for obtaining
additional qualifiers for
the current base station.
139_palm_TOC 6/11/01 12:41 PM Page xix
xx Contents
Locating the Closest Widget Outlet Example 285
Using Enhanced %LOCATION Information in
Palm OS 4.0 296
Summary 299
Solutions Fast Track 299
Frequently Asked Questions 302
Chapter 10 Integrating Web Clipping
with Palm OS Applications 303
Introduction 304
Launching and Sublaunching Applications 305
Using SysUIAppSwitch to Launch a New
Program 305
Using SysAppLaunch to Call into Another
Program 306
Launching Nonapplication Databases 307
Calling Clipper from Palm OS Applications 308
Determining if Clipper Can Be Called 309

4 Add memo pad
entry
5 Add expense
record
139_palm_TOC 6/11/01 12:41 PM Page xx
Contents xxi
Designing the Query String 329
Building a Test PQA 330
Parsing the Query String 331
Pulling Numbers from the
Parameter List 332
Extracting Strings from the
Parameter List 333
Parsing the Parameter List as a Whole 335
Drawing the Bar Chart 338
Cleaning Up Before Returning to Clipper 342
Testing the Plug-In without Clipper 343
Applying iKnapsack to Add PIM Data 346
Understanding iKnapsack’s Architecture 346
Using the iKnapsack User Interface 346
Setting Your Default Programs 347
Managing the iKnapsack Plug-Ins 348
Managing Your Web Clipping
Applications 350
Using the Add Palm Data Plug-In 351
Adding a Date Book Entry 352
Adding an Address Book Entry 354
Adding a To Do List Entry 355
Adding a Memo Pad Entry 356
Adding an Expense Entry 356

Moving to an Event-Driven Model 390
A Quick Introduction to the Palm OS
Event Model 390
INetLib Events 392
URLFetch:An Improvement on Hello World 393
Understanding the URLFetch Example 394
Palm OS Device Databases 394
User Interface: Lists and Fields 394
Browsing the Documentation 395
Accessing a Server-Side Application 395
How Server-Side Applications Differ from
Web Clipping 395
Using POST Operations 396
Opening the Socket 396
Associating the Socket with an HTTP
Request 397
Preparing HTTP Data 398
Sending Request Data 401
Choosing between GET and POST 402
Passing Data via GET 404
W
ARNING
If you forget to include
“https://” as part of the
resNameP, you may find
that your HTTPS
transaction was
degraded to HTTP even
if you specified the
inetSchemeHTTPS

Data Format 432
Proprietary Format 432
XML 432
Transport Format 434
No Compression 434
Using the Proxy’s Built-In LZ77
Compression 434
End-to-End Compressed Data 437
An Unwired Widgets Mail Reader Example 438
Requirements for UWMail 438
Design of UWMail 439
A Brief Discussion on Mail Format,
Storage, IMAP4, and POP3 439
139_palm_TOC 6/11/01 12:41 PM Page xxiii
xxiv Contents
Server Architecture 442
Client Architecture 446
Enhancing UWMail 454
Securing Data 455
Obscurity Does Not Constitute Security 455
Securing Server Access 455
Securing HTTP Transactions 456
Testing for Proxy Issues and Known Bugs 457
OmniSky Servers 457
Unwanted Characters in Server
Response 457
The Omnisky INetLib Implementation
and ctpWireless 459
Summary 461
Solutions Fast Track 462


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status