Académique Documents
Professionnel Documents
Culture Documents
iii
Contents
BREW Basics, 26
The BREW solution, 26
BREW advantages, 26
The BREW environment, 28
BREW module/interface structure, 30
Using an interface, 30
Becoming an authenticated BREW application developer, 30
iv
Contents
v
Contents
Index, 152
vi
Introducing the BREW SDK
User’s Guide
BREW SDK Overview Provides an overview of BREW SDK concepts and components,
including a description of how the SDK is organized.
BREW Basics Provides an overview of BREW and describes how the BREW
Application Execution Environment (AEE) allows you to efficiently
develop applications that can be ported to virtually any handheld
device. This section also includes a brief introduction to the BREW
APIs. See the BREW API Reference for detailed descriptions of each
of the BREW API functions, including parameter types and return
values.
BREW Programming Concepts Explains basic and advanced concepts of the BREW SDK, including
modules, applets, and interfaces.
BREW Sample Applications Provides several sample applications developed using the SDK and
guides you through the steps involved in developing an application.
Using Dialogs and Controls Describes and explains how to use dialogs and controls in your
BREW applications.
Using the BREW Emulator Describes how to start and use the Emulator to load and test your
applications. This section also explains how the Emulator can help
you learn about the BREW environment.
Extending BREW APIs Provides information on customizing BREW APIs with extensions.
Using Visual Studio Add-Ins Describes add-ins to Microsoft Visual Studio, provided with the
BREW SDK, that can make your development efforts more efficient.
Appendix A: SDK Software Describes SDK software compatibility issues you may need to be
Backward Compatibility aware of if you have downloaded multiple versions of the SDK
software.
7
Introducing the BREW SDK User’s Guide
Appendix B: Event Codes and Lists event codes and key codes supported by BREW.
Key Codes
Appendix C: Problems and Lists possible problems or messages you may encounter while using
Warning Messages BREW, and provides resolution suggestions.
BREW documentation
This guide is part of an information set that includes the following documents:
BREW SDK User’s Guide Introduces the components of the BREW Software
Development Kit (BREW SDK™) and their relationship to one
another. The document also contains general instructions for
developing BREW applications and for using the Emulator.
BREW API Reference Provides information about BREW functions and data
structures needed to develop applications for BREW-enabled
mobile platforms.
BREW Device Configurator Guide Describes how to use the BREW Device Configurator to
create effective wireless devices for emulation by the BREW
Emulator.
BREW Resource Editor Guide Describes how to use the BREW Resource Editor to create the
text strings, images, and dialogs used by BREW applications.
BREW MIF Editor Guide Describes how to use the BREW MIF Editor to create and
modify Module Information Files (MIF)—a special type of
BREW resource file that contains information about the
classes and applets supported by particular BREW modules.
BREW SDK Utilities Guide Describes how to use the utilities, such as the PureVoice
Converter, included with the BREW SDK.
BREW Compressed Image Describes how to use the BREW Compressed Image
Authoring Guide Authoring Tool to create files for displaying and animating
images in your applications.
8
Introducing the BREW SDK User’s Guide
Documentation conventions
Several of the conventions used throughout the BREW documentation are illustrated in the
following example:
Italic text following a numbered step identifies what happens after you have
performed the step, such as: The BREW Emulator window opens and BREW
automatically runs the BREW Application Manager.
NOTE: As you can see in step 1 in the previous example, the BREW documentation describes
the use of menu options as the means for navigating through the BREW software. In many
instances, you can perform the same action using a number of methods, such as choosing a
menu option, clicking a toolbar button, pressing shortcut keys on the keyboard, and right-
clicking to open a shortcut menu. You will, no doubt, discover ways of getting around that are
the most comfortable to you. But rather than document ALL of the ways you can perform each
task, the BREW manuals generally describe only one way.
The BREW online manuals are available for viewing and printing using the Adobe Acrobat
Reader. This subsection describes several suggestions that will help you get the most out of
this documentation.
9
Introducing the BREW SDK User’s Guide
Links
Links appear in the BREW online manuals as blue text; for example, Introducing the BREW
SDK User’s Guide. Point your mouse at the blue link and notice that the cursor changes.
Clicking on the link takes you to a different location in the document. If you want to return to
your starting place, choose Document > Go to Previous View.
The table of contents at the start of each manual and the index at the end of each manual
perform the same function as other links. Simply browse the contents or index until you find
the entry that you want to view, and click the entry.
Printing
Printing pages from an online manual, or printing the entire online manual, is much the same
as printing in any word processing program. Simply choose File > Print, select a range of
pages, and click Print. The page number at the bottom of the Acrobat Reader (for example,
5 of 100) corresponds to the page number in the BREW manual.
The Acrobat Reader allows you to search for a word or a string of words in the currently
opened manual.
3. Type the word or string of words you want to find and click Find.
The first instance of the selected word or string of words is highlighted in the
manual.
4. To find the next instance of the word or string of words, click Find Again.
10
Introducing the BREW SDK User’s Guide
NOTE: This Search feature is not a full-text search. That is, if you type How do I
configure an applet to play sound?, the system will not search for
individual words in the string; it will search for the exact string of words you typed.
So it is usually a good idea to type as few words as needed to find the information
you seek.
5. Click to highlight the book you want to open, and click View.
The selected book opens and the first instance of the word or words is highlighted.
6. To find the next instance of the word or words, choose Edit > Search > Next.
The Adobe Acrobat Reader includes a comprehensive online help system. To learn how to
perform a particular action, simply choose Help > Reader Help and search the online help for
the desired topic.
Active device A set of files consisting of a resource file (.qsc extension) and device image
files (.bmp extension), interpreted by the Emulator to emulate the device. The
Device Configurator creates the resource file.
Applet A class that supports the base IApplet interface. This interface is used by the
BREW AEE to load an applet, dispatch events, and terminate an applet. In this
document, it is also used synonymously with the word “application.”
11
Introducing the BREW SDK User’s Guide
BAR BREW Applet Resource. The binary output file from the Resource Editor.
BCI BREW Compressed Image. A BCI file consists of a series of graphic images
compressed and combined, using the BREW Compressed Image Authoring
Tool, to add animation to a BREW application.
BMP Bitmap
Bounding rectangle Each device object, regardless of its shape, is bounded by a rectangle, as
represented in Windows pixel coordinates.
BREW AEE BREW Application Execution Environment. The BREW AEE is the
environment that allows BREW applets to be loaded and run.
BREW SDK BREW Software Development Kit. This allows application developers to
quickly write and test applets and modules in a familiar Windows desktop
environment.
BREW test plan The BREW test plan is a set of testing guidelines that help application
developers test their applications thoroughly.
Class A template (file) that defines the generic characteristics of an object or module
in the system.
ClassID 32-bit IDs for identifying BREW classes and applets. These IDs are assigned
at the site www.qualcomm.com/brew/sdk/classid . BREW ClassIDs are
available to authenticated developers only.
Device attributes The attributes pertaining to the wireless device, such as model and pushed
image file.
12
Introducing the BREW SDK User’s Guide
Image file A file containing an image of the device. It is created by a third party, for
example, a carrier or application developer.
Interface An abstract class providing a set of methods for a specific service. For
example, the IDisplay interface provides a set of methods for basic display
services. Each interface has a unique class identifier (AEECLSID), and the
name of each interface begins with the letter “I.” In BREW, all the interfaces
are derived from a base level class interface called IBase. IBase consists of
two standard methods for incrementing and decrementing the reference
count of an object. This reference count mechanism allows an object to be
shared by multiple users.
IP Internet Protocol
Key object attributes Attributes pertaining to the screen object, such as key symbols, key action,
and overload codes.
Large font The Emulator uses this device attribute to show text on the screen. The large
font maps to AEE_FONT_LARGE. Its bold version is not used.
Logical screen size The size of the device screen measured in Windows pixels.
Method An entry point into an object that allows it to interact with other objects or
applets.
MIF Module Information File. The MIF Editor generates this binary file, which
contains information regarding the list of classes and applets supported by the
modules.
Module In the BREW model, a library or dynamically loaded code block that exposes
one or more interfaces. As each interface is associated with an ID, the module
can expose these interfaces in a generic manner. This eliminates the need for
explicit entry points in modules for each exported interface.
Normal font The Emulator uses this device attribute to show text on the screen. The
normal font maps to AEE_FONT_NORMAL, and its bold version maps to
AEE_FONT_BOLD.
13
Introducing the BREW SDK User’s Guide
Physical screen size The size of the device screen measured in inches or centimeters.
Primary code A code that uniquely identifies the primary functionality of a device object.
Each device object has only one associated primary code. It is assigned from
a pool of available virtual codes. Key and screen objects have their own pools
of virtual codes.
Pushed bitmap file An optional file containing an image of a device skin with all buttons pushed.
The Emulator uses this image to animate button push action. If it is not
present, the Emulator emulates button push action by inverting the color. A
third party, such as a carrier or applications developer, creates this file.
QCP PureVoice files supported by the Emulator and BREW applications. For more
information, see the BREW SDK Utilities Guide.
Resource file A file containing active resource information. The Emulator and Device
Configurator interpret this file, in conjunction with image files.
Resources Elements used in applications and/or libraries. In BREW, three types are
supported: string, image, and dialog.
Screen object Attributes pertaining to a screen object, such as pixels per row, pixels per
attributes column, and physical width and height.
WAV Waveform
Wide string A character string composed of 16-bit characters. Wide strings are used for
character encodings, such as Unicode that require more than 8 bits per
character.
14
Introducing the BREW SDK User’s Guide
15
BREW SDK Overview
The BREW SDK comprises a suite of tools and services that allow application developers to
quickly, efficiently, and cost-effectively develop and deploy new applications for a wide variety
of handheld devices.
The minimum system requirement for installing the BREW SDK is Microsoft Windows NT 4.0
SP3 or higher, or Windows 2000 SP2 or higher. To develop applications using the BREW SDK,
you also need Microsoft Visual C++ 6.0 or higher.
NOTE: Do not install the BREW SDK in a directory whose name contains dots (for example,
<BREW.1.1.>). The BREW SDK emulates file systems on mobile devices, and these file
systems do not recognize a dot as a valid character in a directory name.
16
BREW SDK Overview
Resource Editor Use the BREW Resource EditorTM, subsequently referred to as the
Resource Editor, to create resources for applications. You can use the
same resource files in Windows and in the device. For more information
about using the Resource Editor, see the BREW Resource Editor Guide.
MIF Editor The BREW MIF EditorTM, subsequently referred to as the MIF Editor,
generates Module Information Files (MIF) which contain module- and
applet-specific information required to load the applet. For more
information about using the MIF Editor, see the BREW MIF Editor Guide.
BREW DLLs BREW contains several dynamic-link libraries (DLL) that expose the core
supported BREW classes in the Microsoft Windows environment.
Because the DLLs use the identical code developed for BREW, there is
little difference between application behavior in the Windows-based
BREW Emulator and on a live device.
Win-OEM DLLs Win-OEM DLLs provide the underlying layers required to emulate device
behavior on a Windows platform.
BREW header files BREW header files contain the BREW interface definitions, and are used
to develop applets. Each BREW interface has an associated header file,
and each applet must contain the header file of each interface used by
that applet.
Visual Studio add-ins Free add-ins to Microsoft Visual Studio automate some of the time-
consuming tasks you perform in Visual Studio to develop BREW
applications.
17
BREW SDK Overview
BREW utilities Utilities, included with the BREW SDK, provide added functionality to your
BREW applications.
Sample applications Sample application DLLs and their source code provided with the SDK
include the following:
• Calculator
• Calendar
• Clock applications (stopwatch, countdown, alarm clock)
• Games
• Memo Pad
• MIDI-MP3 Player
• Usage applications (to illustrate how BREW interfaces can be used)
Documentation The entire BREW documentation set is available from within the BREW
development environment.
The diagram that follows shows you the main elements of the BREW SDK (MIF Editor,
Resource Editor, C++ IDE, Device Configurator, and Emulator) and how they interact with one
another.
18
BREW SDK Overview
fooapp
BREW MIF Editor
Reference:
ClassIDs: Input BREW MIF
Request from Editor Guide
QUALCOMM Supported classes and applets
website Applet titles, icons, thumbnails
Exported classes
Dependancies
Notifications
BREW privileges
Output Preferred Location
fooapp.mif BREW MIF Directory
For example: BREW\Examples\
MIF\Apps\256colors
NOTE: As indicated in the diagram, each of the elements in the BREW SDK are described in
the other manuals included with the SDK, with the exception of the Emulator. For more
information on the Emulator, see Using the BREW Emulator in this guide.
19
BREW SDK Overview
Directory Contents
Bin BREW SDK binaries and data files. The <Bin\DataFiles> directory
contains the tone database and beep types for the Emulator. For
details, see the ISound interface description in the BREW API
Reference.
Bitmaps Images used in the sample applications. They are stored in the Mono,
4Grey, and 256color directories. For more information, see Bitmaps
directory on page 23.
Devices Predefined sample device files that you can load in the Emulator. For
more information, see Device files below.
Inc BREW AEE header files that can be used in BREW modules.
Device files
A set of predefined sample device files is provided with the BREW SDK. Each sample device
file can be loaded in the Emulator to show a different device skin, as illustrated below. See
Using the BREW Emulator on page 97 for information on loading device files in the Emulator.
20
BREW SDK Overview
NOTE: The BREW SDK provides the ability to create new devices via the Configurator. See
the BREW Device Configurator Guide for detailed instructions on creating new devices.
Examples directory
The Examples directory contains sample applications, application resources, BAR files (used
by the Resource Editor to load images into an application’s DLL), shared files, and MIFs. The
Emulator uses components of the Examples directory to load and run applications.
21
BREW SDK Overview
Sample applications
The BREW SDK is shipped with a set of sample applications. These applications are found in
the <BREW\Examples> directory. Sample applications are of two types:
Usage applications These applications demonstrate how to use BREW interfaces and
APIs. The names of most of these applications begin with an I. For
example, IMenuCtl application shows you how to use the BREW
IMenuCtl interface to manage menus in a BREW application.
For descriptions of demonstration and usage sample applications included in the BREW SDK,
see BREW Sample Applications on page 54.
NOTE: The usage applications included with the BREW SDK demonstrate how to use BREW
interfaces and APIs; however, they do not represent examples of TRUE BREW ™ tested code.
The <BREW\Examples\en> directory is the default resource directory for the English
language. It contains system and application resources for color depths of 1-bit, 2-bit, and 8-
bit under the Mono, 4Grey, and 256color directories. See Resource directories on page 24 for
details.
Shared files
The <BREW\Examples\shared> directory contains images, MIDI files, QCP files, and MP3
files used by the Application Manager within the Emulator. This directory also contains a text
file called appinfo.txt. Whenever a change is made in the Application Manager, such as when
a new image is assigned to an application, the change is written to this file. When the Emulator
is started the next time, the system reads this file, along with the specified MIF directory, and
loads the correct configuration into the Application Manager. See Using the Application
Manager on page 108 for more information.
22
BREW SDK Overview
Bitmaps directory
The <BREW\bitmaps> directory contains images used in the sample applications. They are
stored in the Mono, 4Grey, and 256color directories. You can add files to this directory to use
new images in your applications.
Applet directory
The default applet directory is <BREW\Examples>. You can change the default by selecting a
different directory in the Brew Emulator Settings dialog box (Tools > Settings).
The applet directory represents the root directory under which application directories are
stored. Each application has its own directory with the same name as its MIF and the
application executable must reside in the application directory. For example, the MIDI.MIF file
must have a corresponding subdirectory called MIDI under the applet directory
<BREW\Examples>. Inside this subdirectory is the DLL corresponding to the module. The
MIDI subdirectory contains the file MIDI.DLL. This subdirectory may also contain resource files
and other data files associated with all the applications within that module.
MIF directory
All MIFs reside in the directory <BREW\Examples\MIF>, which is organized as follows:
BREW\Examples\MIF\Apps\
Mono\
RoadWarrior.mif
ClockApps.mif
HelloWorld.mif
...
4Grey\
RoadWarrior.mif
ClockApps.mif
HelloWorld.mif
23
BREW SDK Overview
...
256Color\
RoadWarrior.mif
ClockApps.mif
HelloWorld.mif
...
BREW\Examples\MIF\Usage\
Mono\
iimage.mif
idialog.mif
igraphics.mif
...
4Grey\
iimage.mif
idialog.mif
igraphics.mif
...
256Color\
iimage.mif
idialog.mif
igraphics.mif
...
NOTE: On the target device, the MIF directory is the same as the applet directory. The ability
to have a MIF directory that is different from the applet directory is supported in the SDK on
Windows only. On the device, MIFs must always be present in the same directory as the applet
directory.
Resource directories
The resource directory, a subdirectory under the applet directory, contains system resources
for a particular language type and various color depths. By default, the BREW SDK uses
English. The default resource directory is <BREW\Examples\en>.
Within the <BREW\Examples\en> directory, system resources (and application resources) are
stored for color depths of 1-bit, 2-bit, and 8-bit under the Mono, 4Grey, and 256color
directories.
After the BREW SDK is installed, the following resource directories are created:
BREW\Examples\en\
Mono\
AEEControls.bar
RoadWarrior.bar
...
4Grey\
24
BREW SDK Overview
AEEControls.bar
RoadWarrior.bar
...
256Color\
AEEControls.bar
RoadWarrior.bar
...
When you are entering paths in BREW SDK applications running on a PC, such as the path
to the initial Applet directory in the Emulator Settings dialog box, you can enter a maximum of
256 characters for the path and filename. However, when you are ready to test your own
BREW applications on an actual device, significantly fewer characters are allowed for the path
and filename. Check with the device OEM for specific path length information.
Case sensitivity is also important when entering paths and filenames. On the PC, you can mix
uppercase and lowercase characters in the same path. On the device, however, all characters
used in paths must be lowercase.
25
BREW Basics
Today’s mobile communications users expect more features from their mobile devices, which
range from very high-end integrated mobile personal digital assistants (PDA) to mass-market
mobile phones that focus on low cost and easy operation. While there has been much
enthusiasm surrounding the possibility of leveraging high-speed ASIC technology to bring new
application functionality even to low-cost devices, the actual task has been complicated by
cost and size factors related to integrating the high-end operating systems seemingly required
to host such applications. Mass-market devices are often characterized by proprietary
solutions that support unique sets of services and interfaces. Although most of these devices
share the same underlying environment, proprietary layers above the ASIC have discouraged
the development of generic applications that can be leveraged across offerings from device
manufacturers.
BREW advantages
Some advantages of BREW’s AEE include the following:
• BREW makes efficient use of both RAM and persistent memory. Objects used by
BREW are loaded and unloaded on an as-needed basis.
26
BREW Basics
• All text is managed as Unicode while stored in the most efficient manner supported
for the language selected. BREW also provides support for OEM-specific native
formats for text.
• Developers need not be concerned with low-level platform data structures and
device drivers because all interactions between the application and the device
platform occur through well-defined classes.
• Modules can be integrated at the object code level, simplifying the task of adding
modules to the BREW platform.
• BREW provides core classes to interface with the device platform. Device resources
that applets can manage and control with these classes include:
- Shell services
- Time/timers (obtaining current date and time; starting and stopping timers and
alarms)
- Notifications
- Memory management
- File management
- Database management
- HTTP
• Dialogs
• Date controls
• Menu controls
• Text controls
27
BREW Basics
• Time controls
- Display
- Graphics
In future releases, core classes will be extended to offer services such as Bluetooth, Global
Positioning System (GPS), and telephony.
BREW supports applications (applets) and shared modules. Applets and modules are
developed as standalone DLLs and are loaded into the Emulator at runtime. Shared modules
include functionality, such as enhanced game APIs that can be used by several applets.
BREW applets and modules are developed in an emulated environment under Windows. To
help you get started, QUALCOMM has provided a number of sample applications, one of
which is presented as a step-by-step tutorial in the BREW Sample Applications section.
28
BREW Basics
BREW exposes a sophisticated set of object technologies that provide the following benefits
to developers:
• Core services to support access to files, network services, memory, and the screen
The following figure shows how BREW provides a thin layer that supports access to OEM and
ASIC software in support of applets and modules.
29
BREW Basics
BREW’s AEE offers a number of distinct categories of services, including several AEE
interfaces such as IShell, IDisplay, and IMenuCtl. Each interface encapsulates a set of
resources and contains methods that allow those resources to be managed. See the BREW
API Reference for a detailed description of the functions within each of these interfaces.
BREW modules can contain one or more applets or classes. Classes are exposed by the
module at runtime and are loaded or unloaded on an as-needed basis.
Using an interface
Interfaces are identified by a 32-bit interface ID. Public interfaces must be reserved via the
QUALCOMM BREW Interface Registry. The Interface Registry does not place any restriction
on the assignment of interface IDs; it is maintained as a service to BREW developers to avoid
interface ID conflicts.
Before using an interface, you must create an instance of it by invoking the CreateInstance()
method of the IShell interface (see note below). A globally unique identifier corresponding to
an interface is passed to the ISHELL_CreateInstance function to retrieve a pointer to the
interface. (Store a pointer to the interface instance within your applet for subsequent use.)
Interfaces are returned by CreateInstance with a positive reference count. Be sure to release
the interface when the applet no longer needs it.
NOTE: For many interfaces, the ISHELL_CreateInstance() method of IShell interface is the
means to create an instance of the interface. However, for certain interfaces, other methods
are used. For example, to create an instance of IImage using a bitmap file, call
ISHELL_LoadImage(). This returns a pointer to the IImage interface.
Before your application can be tested and approved for distribution, you must provide certain
information that will allow you to become an authenticated BREW application developer. After
you register as an authenticated developer, each of your applications is electronically signed
with your unique identifier, ensuring the integrity of your code. When the code is signed, you
can submit your application to proceed to the application commercialization steps which may
include BREW certification. For more information, see the BREW AppSigner User Guide.
30
BREW Basics
You may apply for authentication at any point in the BREW development process; however,
you cannot obtain ClassIDs for your application until you are authenticated. For more
information, see the BREW MIF Editor Guide, or visit www.qualcomm.com/brew/developer for
more information about the authentication and certification processes.
31
BREW Programming Concepts
This section discusses BREW programming concepts, including applets and modules, BREW
ClassIDs, short message service (SMS) support, TAPI support, shell services, floating point
operations, and the Embedded File System (EFS).
A module can read data from BREW resource files, making strings, images, and dialogs
available to the applications. Storing language- and device-specific data in resource files
makes it possible to create versions of your application for different countries and devices. To
develop resources for applets, use the Resource Editor to generate binary resource files and
corresponding resource header files. See the BREW Resource Editor Guide for details on
creating new resource files.
A BREW applet is developed so that it can be compiled and run on both the Emulator and the
target device. Source and header files that build the foundation of an application are provided
with the SDK. Some files that implement DLL-specific functionality are also provided with the
SDK, allowing you to generate application and resource files. The formats of the resources
and binary resource files used by the application in the BREW environment on the device and
in the Emulator are identical.
32
BREW Programming Concepts
• Applet resources and resource headers (optional) created using the Resource
Editor
About MIFs
The MIF for the module must be created in the MIF Editor before the applet can be loaded into
the Emulator. Each MIF contains information about the classes and applets supported by a
particular BREW module. The MIF is also required to be shipped as part of the applet bundle.
At system startup on the device or in the Emulator, the Application Manager processes each
MIF to obtain the list of all applications whose information is present within that MIF. Using the
information obtained from the MIF, the Application Manager shows the list of applications
(along with their icons and titles) on the device screen. The information gathered from the MIF
enumeration is stored by BREW for use when classes are requested, and support various
IShell functions, such as those that provide the ability to enumerate the supported applets.
In the sample application called Hello World App, HelloWorld contains a description of the
HelloWorld module. The main information in HelloWorld is summarized as follows:
• Supported classes.
• Supported applets.
• Applet title: Hello World. It appears on the device screen when the applet icon is
selected.
33
BREW Programming Concepts
BREW ClassIDs
Each class or applet in BREW must have a unique ClassID. The BREW model uses 32-bit IDs
for public classes and applets. These IDs are assigned at the BREW Developer extranet site
www.qualcomm.com/brew/sdk/classid.
NOTE: BREW ClassIDs are available to authenticated developers only. If you are developing
a BREW application and have not yet been authenticated, use dummy IDs until you complete
the authentication process, at which point you need to insert BREW ClassIDs into your
application.
If you are manually assigning ClassIDs to your applets or classes, you must ensure that they
are unique. If two or more classes have the same ID, the class or applet will not run. For
example, consider the following directory structure:
sample/bar.dll
sample/foo.mif
sample/foo/foo.dll
If bar.mif and foo.mif refer to the same ClassID, the applet will not run because BREW
enumerates the MIFs in the order that they are presented in the directory. For the given
ClassID, BREW first loads bar.mif. So when you try to run the applet, BREW looks for the
directory called bar and cannot find it.
The two types of BREW ClassIDs, interface and applet, are described in the following
subsections.
Interface ClassIDs
Each public BREW interface has an ID that uniquely identifies it. These IDs are reserved and
cannot be used by another interface or applet. When an applet requests an interface pointer
in a call to the CreateInstance function of the shell, it uses this interface ID to identify the
requested interface.
The following interface identifiers are supported in Release 1.0.2 of the BREW AEE.
34
BREW Programming Concepts
35
BREW Programming Concepts
The values these IDs take are predefined in the AEEClassIDs.h header file that comes with
the SDK.
Applet ClassIDs
Each BREW applet that runs on the AEE platform must also have a unique identifier that is
passed to the AEE shell when an applet is loaded. The shell uses this ID to subsequently load
and manage the applet. Accordingly, no two applets can have the same ID.
In the example code shown in BREW Sample Applications on page 54, two local ClassIDs are
defined: AEECLSID_HELLOWORLD and AEECLSID_RESOURCEAPP. These local
definitions are for illustration purposes only. Before submitting your applet for certification, you
must reserve a unique ClassID.
Creating instances
BREW supports applet and module creation through the ISHELL_CreateInstance function,
one of the most powerful APIs supported in BREW. When this function is called, BREW
searches for the specified 32-bit registered ClassID in the list of supported classes. This list
contains entries supported by the core BREW API, and all of the classes and applets added
to the system and detected at system startup through the MIF enumeration process.
Typically, BREW calls no functions other than AddRef and Release on a class created using
the ISHELL_CreateInstance function. If an instance of the class is successfully created, an
interface pointer to the instance is returned. When the requestor is finished using the class,
the Release method for the class must be called.
36
BREW Programming Concepts
It is critical that any objects owned by a module increment the reference count of the IModule
when they are created, and decrement the reference count of the IModule when they are
freed. This process allows BREW to unload the module when necessary.
See BREW Sample Applications on page 54 for information about creating instances of
BREW interfaces, including IModule and IApplet.
Creating applets
Under the BREW model, applets are classes that support the functions in the IApplet interface,
allowing BREW to manage all applets using the same simple interface. The IApplet interface
supports only the HandleEvent function in addition to the standard AddRef and Release
methods.
• In response to registered notifications and alarms. In this case, the applet is created
and immediately receives an event specific to the notification.
Events are sent to applets through the ISHELL_SendEvent function, either synchronously or
asynchronously. Events sent to applets include keypad, dialog, and control change events.
Here is a sample sequence of events sent to an applet:
EVT_APP_START
...
Other App Events (EVT_KEY, etc.)
...
EVT_APP_SUSPEND (optional)
EVT_APP_RESUME (optional)
...
Other App Events (EVT_KEY, etc.)
...
EVT_APP_STOP
37
BREW Programming Concepts
Typically, applets only need to process a few events. These can include EVT_APP_START,
EVT_APP_STOP, EVT_KEY, and EVT_COMMAND. If an applet does not process an event,
its HandleEvent method must return FALSE. This allows BREW to do any necessary special
processing for that event.
When BREW suspends an applet, it sends the EVT_APP_SUSPEND event to the applet. If
the applet returns TRUE to this event, it indicates to BREW that the applet has processed the
suspend. If the applet does not want to process the Suspend event, it can return FALSE. When
this occurs, BREW stops the applet by sending an EVT_APP_STOP event.
If memory is allocated in the AEEClsCreateInstance() function (that is, when the instance of
the applet is created), it is extremely dangerous to free this memory inside EVT_APP_STOP.
Therefore, any memory allocated inside EVT_APP_START must be cleaned up in
EVT_APP_STOP, and any memory allocated inside AEEClsCreateInstance() must be freed
inside the APPFreeData() function.
In the Emulator, you can simulate the sending of the EVT_APP_SUSPEND event by first
running the applet in the AppManager, and then choosing an option from one of the menus in
the Emulator menu bar (Tools > Settings for example). BREW immediately sends an
EVT_APP_SUSPEND event to the applet. When you click Cancel in the Settings dialog box,
BREW sends the EVT_APP_RESUME event.
• If the applet does not handle suspend, BREW sends EVT_APP_STOP to stop the
applet. Then, instead of resuming the applet, it sends an EVT_APP_START event
to restart the applet.
38
BREW Programming Concepts
• The application is registered to receive specific IS-637 messages based upon the
teleservice ID of the message.
• The application is registered to receive all IS-637 CMT-95 (4099) text messages.
• The application is a BREW application to which a CMT-95 text message has been
directed.
The remainder of this subsection describes the format of the application-directed CMT-95 text
messages, as well as the mechanisms used to support their delivery.
Where:
• Class ID is the hex representation of the AEECLSID (BREW AEE ClassID) used
to identify the target application for the message.
• Text Payload is the ASCII text payload of the message. BREW does not interpret
the text payload.
NOTE: If the SMS messages received do not use this format, they cannot launch BREW
applications. They can, however, be viewed using an SMS messaging application.
39
BREW Programming Concepts
Upon receipt of an SMS message, BREW decodes and analyzes the content of the message
to determine whether it is of interest to BREW. If so, BREW schedules the message for
dispatch/delivery to the target applications.
In the case of an application-directed message, BREW decodes the Class ID to determine the
applicable application. It then passes the message to the application through the
EVT_APP_MESSAGE event. The Text Payload of the message is provided as the argument
to this event notification.
When the application receives the EVT_APP_MESSAGE event, it may or may not be active,
and it does not automatically start. If the application is to be activated as a result of receiving
the message, it can do so using the standard ISHELL_StartApplet API. Also, the application is
not responsible for the memory used to store the message data.
The following sample code illustrates how an incoming application-directed message can be
processed:
static void MyHandler(MyAppType * pme, AEEEvent evt, uint16 wp, uint32 dwp)
{
switch(evt)
{
case EVT_APP_START:
MyApp_Start(pme);
return(TRUE);
case EVT_APP_STOP:
return(TRUE);
case EVT_APP_MESSAGE:
{
const char * url = (const char *)dwp;
if(url && !STRNICMP(url,”http”,4))
ISHELL_BrowseURL(pme->a.m_pIShell, url);
}
return(TRUE);
}
}
40
BREW Programming Concepts
The BREW environment uses a set of system resource files that are required for successful
operation of BREW. These resource files are specific to the languages supported by the
device. For example, the IDateCtl and ITimeCtl interfaces use a resource file called
AEEControls.bar, which contains definitions of all resources used by these interfaces.
In the device environment, all language-specific resource files are placed in a directory specific
to that language. The name of the directory assigned to each language is derived from the ISO
639 code for that language. For example, the ISO 639 code for the English language is the
string “en.” All system resources specific to English must be placed inside a directory called
en, which must be placed within the applet directory. Therefore, if the applet directory is set to
<BREW\apps>, the English-specific resource files must be placed in the directory
<BREW\apps\en>.
The concept explained above is also supported in the SDK, so be sure to place the BREW
system resources in the language-specific directory. The BREW SDK installation ensures that
this is done when BREW is installed. This mechanism continues to work as long as you do not
change the applet directory. If, however, you change the applet directory to another directory
(for example, <C:\MyApps>), you must do the following to ensure that BREW works
successfully:
2. Copy the entire contents of the en subdirectory from the BREW installation
location, <C:\ProgramFiles\Brew\examples\en>, to the directory <C:\MyApps\en>.
Repeat these steps whenever you change the applet directory to a different location. If you do
not follow these steps, BREW interfaces will not be able to find the required resource files and
some of the interfaces, such as IDateCtl and ITimeCtl, may not function properly.
Floating-point operations
The BREW platform does not support floating-point operations. If you write an application with
a floating-point operation and test it in the BREW SDK, it works as expected because the
underlying platform is the Windows operating system. However, floating-point operations are
not supported on the device platform and must not be used in BREW applications.
41
BREW Programming Concepts
#===================================================================
# Name:
# helloworld.MAK
#
# Description:
# Makefile to build the helloworld downloadable module.
#
# The following nmake targets are available in this makefile:
#
# all - make .elf and .mod image files (default)
# clean - delete object directory and image files
# filename.o - make object file
#
# The above targets can be made with the following command:
#
# nmake /f helloworld.mak [target]
#
# Assumptions:
# 1. The ARM ADS 1.0.1 tools are installed in the c:\ads directory.
# 2. This Makefile can be used with the ARM ADS 1.0.1 Compiler only.
#
# Notes:
# 1. While building the application using this make file, the
# following warnings may be
# received. They can be safely ignored:
# "Warning: C2067I: option -zas will not be supported in future
# releases of the compiler
# "Warning: C2071W: option -za will not be supported in future
# releases of the compiler
# "Warning: L6305W: Image does not have an entry point. (Not
# specified or not set due to
# multiple choices).
#
#
# Copyright © 2000-2001 QUALCOMM Incorporated.
# All Rights Reserved.
# QUALCOMM Proprietary/GTDR
#
#-------------------------------------------------------------------
#===================================================================
#-------------------------------------------------------------------
# Target file name and type definitions
#-------------------------------------------------------------------
42
BREW Programming Concepts
SUPPORT_DIR = ..\..\src
SUPPORT_INCDIR = ..\..\inc
SUPPORT_APPIDDIR = ..
#-------------------------------------------------------------------
# Target compile time symbol definitions
#-------------------------------------------------------------------
DYNAPP = -DDYNAMIC_APP
#-------------------------------------------------------------------
# Software tool and environment definitions
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Processor architecture options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# ARM Procedure Call Standard (APCS) options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Additional compile time error checking options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Compiler output options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Compiler/assembler debug options
43
BREW Programming Concepts
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Compiler optimization options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Compiler code generation options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Include file search path options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Compiler pragma emulation options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Linker options
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# HEXTOOL options
#-------------------------------------------------------------------
BINFORMAT = -bin
#-------------------------------------------------------------------
# Compiler flag definitions
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Linker flag definitions
44
BREW Programming Concepts
#-------------------------------------------------------------------
LFLAGS = $(ROPILINK)
#-------------------------------------------------------------------
# Default target
#-------------------------------------------------------------------
all : $(TARGET).$(MODULE)
#-------------------------------------------------------------------
# Clean target
#-------------------------------------------------------------------
# The object subdirectory, target image file, and target hex file are
deleted.
clean :
@echo ------------------------------------------------------
@echo CLEAN
-del /f AEEAppGen.o
-del /f AEEModGen.o
-del /f $(TARGET).o
-del /f $(TARGET).$(EXETYPE)
-del /f $(TARGET).$(MODULE)
@echo ------------------------------------------------------
#===================================================================
# DEFAULT SUFFIX RULES
#===================================================================
# The following are the default suffix rules used to compile all objects
# that are not specifically included in one of the module specific rules
# defined in the next section.
# The following macros are used to specify the output object file,
MSG_FILE
# symbol definition and input source file on the compile line in the
rules
# defined below.
.SUFFIXES :
.SUFFIXES : .o .dep .c
#-------------------------------------------------------------------
# C code inference rules
#-------------------------------------------------------------------
.c.o:
@echo ------------------------------------------------------
@echo OBJECT $(@F)
$(ARMCC) $(CFLAGS) $(INC) $(OBJ_FILE) $(SRC_FILE)
@echo ------------------------------------------------------
{$(SUPPORT_DIR)}.c.o:
@echo ------------------------------------------------------
@echo OBJECT $(@F)
$(ARMCC) $(CFLAGS) $(INC) $(OBJ_FILE) $(SUPPORT_DIR)\$(SRC_FILE)
@echo ------------------------------------------------------
45
BREW Programming Concepts
#===================================================================
# MODULE SPECIFIC RULES
#===================================================================
APP_OBJS = AEEAppGen.o \
AEEModGen.o \
$(TARGET).o
#-------------------------------------------------------------------
# Lib file targets
#-------------------------------------------------------------------
$(TARGET).$(MODULE) : $(TARGET).$(EXETYPE)
@echo ------------------------------------------------------
@echo TARGET $@
$(HEXTOOL) $(TARGET).$(EXETYPE) $(BINFORMAT)
$(TARGET).$(MODULE)
$(TARGET).$(EXETYPE) : $(APP_OBJS)
@echo ------------------------------------------------------
@echo TARGET $@
$(LD) $(LINK_CMD) $(TARGET).$(EXETYPE) $(LFLAGS) $(APP_OBJS)
$(LINK_ORDER)
# ------------------------------
# DO NOT EDIT BELOW THIS LINE
AEEAppGen.o : $(SUPPORT_DIR)\AEEAppGen.c
AEEAppGen.o : $(SUPPORT_INCDIR)\AEEAppGen.h
AEEModGen.o : $(SUPPORT_DIR)\AEEModGen.c
AEEModGen.o : $(SUPPORT_INCDIR)\AEEModGen.h
$(TARGET).o : $(TARGET).c
#$(TARGET).o : $(TARGET).h
$(TARGET).o : $(SUPPORT_INCDIR)\AEEAppGen.h
$(TARGET).o : $(SUPPORT_INCDIR)\AEEModGen.h
To build BREW applications for ARM Development Suite 1.1, you need to convert the ARM
Development Suite 1.0.1 makefile for ARM Development Suite 1.1.
NOTE: The minimum requirements for the conversion are build 717 or higher of the ADS 1.1
compiler.
46
BREW Programming Concepts
To
The ARM BREW Builder includes the Compiler, Linker, and Assembler components of the
ARM Developer Suite. The BREW Code Generation Tools (CGT) package is available to
authenticated BREW developers for $1,500. A free, 45-day evaluation unit of the full ARM
compiler is also available at http://www.arm.com.
To purchase the BREW Code Generation Tools, or for more details, please visit the BREW
web site at http://www.qualcomm.com/brew/developer.
ARM BREW Builder makefiles are the same as those produced with ARM Development
Suite 1.1.
The following are the differences between ARM BREW Builder and ARM Development
Suite 1.1. The ARM BREW Builder:
• includes only .PDF documentation, and does not include ARM's DynaText tool.
47
BREW Programming Concepts
NOTE: The fact that the ARM BREW Builder cannot create libraries is not a limitation because
BREW application developers are not supposed to write static applications, but BREW
extensions, which can be built with the ARM BREW Builder.
IShell interface
The IShell interface provides a number of services to applets for accessing device operating
system functionality. Major IShell features allow you to:
• Manage timers
• Post alarms
See the BREW API Reference for detailed descriptions of IShell’s features.
48
BREW Programming Concepts
IBase interface
The IBase interface class defines the base structure incorporated into all AEE class objects.
Each AEE interface class/structure contains the IBase functions as the first two interfaces
defined in the public class definition.
Since AEE objects can be dynamically allocated, a mechanism must be used independently
of the specific memory manager to free or release the objects. The IBase interface provides
two basic functions: AddRef and Release, which allow you to:
All BREW classes must implement the functions in the IBase interface.
IModule and IApplet are fundamentally different from all other interfaces in that they implement
services provided by an application, as opposed to services used by an application. They
provide a mechanism to the shell for loading, managing, and passing events to an application.
The BREW SDK provides you with a default implementation of the IModule and IApplet
interfaces.
IModule interfaces
The basis for the BREW model is a mechanism whereby the module (IModule) is linked to or
loaded by the core device shell (IShell). These modules export a single defined entry point that
is called to retrieve the interface known as the IModule. The IModule provides only two
functions. The first and most critical function allows BREW to request a specific class instance
from the module. The second function allows BREW to request that the module free any
unwanted system resources.
BREW supports both static and dynamic modules. Static modules are built into the device by
the manufacturers; therefore, only device manufacturers can develop static modules. Dynamic
modules can be downloaded and run on the device. The SDK supports dynamic modules only.
49
BREW Programming Concepts
Both static and dynamic modules export a single entry point, which is the very first function to
be called or run in the module. In the case of statically linked modules, this entry point serves
to retrieve a list of supported classes and applets. The entry point also returns a pointer to the
module’s main Load function. BREW calls the Load function to ask the module to create
classes supported by the module. The entry point must have a unique name, which allows the
entry point to be added to a static module table managed by the device integrator.
Dynamically loaded modules only export the Load function. This is accomplished by placing it
as the first function in the first object linked to the relocatable code image for the module. The
module can be loaded by BREW on an as-needed basis. Although not discussed in detail in
this document, digital signing of applications is required for them to be loaded dynamically onto
target devices.
IApplet interface
The IApplet interface implements services provided by an applet. The main service of the
IApplet interface is providing a mechanism to the shell to pass events to an applet.
The BREW application model is based on an event-driven engine. After an applet is loaded, it
receives all input through events, which are received by the HandleEvent function of the
applet. Since it is an event-driven environment, BREW demands that events be handled in a
timely manner. This means that an applet is expected to quickly handle the event and return.
Under BREW, substantial delays in processing events may result in the applet being shut
down to safeguard the device.
When BREW passes an event to an applet, the applet indicates whether it handled the event
by returning TRUE (handled) or FALSE (not handled). When an applet must pass the event to
other event handlers (such as controls), it can simply return the result of that call.
Applets receive three event-related inputs, which are passed in the second, third, and fourth
parameters of the HandleEvent function. Below is an example signature of the event handler
function.
50
BREW Programming Concepts
The second parameter is of type AEEEvent, and it specifies the main event received by the
applet. Examples of events that the applets receive are Start, Stop, Suspend, Resume, and
Alarm. A detailed list of events that an applet can receive is provided in Appendix B: Event
Codes and Key Codes.
The third and fourth parameters are the short data and long data corresponding to the event
received. These values are context-specific and are defined in accordance with the definition
of the event.
• Some events contain event-specific data in both the short data and long data fields.
Examples of such events are EVT_KEY_UP, EVT_DEY_DOWN,
EVT_DIALOG_START, EVT_COMMAND, and EVT_CTL_SET_TITLE.
• Some events contain data in either the short data field or the long data field only. An
example of an event that has data in only the short data field is EVT_ALARM.
Examples of events that have data only in the long data field are
EVT_NET_STATUS and EVT_CTL_CHANGING.
• Some events contain no data in either the short or long data fields. Examples of such
events are EVT_START, EVT_STOP, EVT_SUSPEND, and EVT_RESUME.
The event table in Appendix A gives more details on which event is accompanied with which
data field, and what each field contains.
Some events are not sent to the applet unless it specifically indicates that it wants such
notifications. Critical events received by the applet cannot be ignored, regardless of the state
of the applet. EVT_STOP and EVT_SUSPEND are examples of critical events that impact the
applet in any state. Be careful when receiving all the critical events in any given state of the
applet. You may have to save data/context in processing a received event.
Keypress events are sent to the applet as EVT_KEY events. The short data field contains the
primary key code. The long data field values are OEM specific. The key codes passed to an
applet are in Unicode values. The values of key codes and their symbols are defined in
Appendix B: Event Codes and Key Codes.
51
BREW Programming Concepts
For example, if key 2 is pressed, the short data field contains the Unicode value corresponding
to key symbol 2. This feature allows you to handle a key press in the context of an applet.
Using the Configurator, you can alter which of the primary key codes is passed to an applet.
The device OEM determines the primary key code on the target device.
When a key is pressed or released, ISHELL sends asynchronous events to the active applet.
Following is a list of key events an applet can receive, and a brief description of each key
event.
EVT_KEY Sent either when a key is pressed or when a key is released, or both,
depending on the device manufacturer’s choice. Applications are
expected to do the key handling when this event is received.
Because each handset ships with a particular key handling setting,
you must write your applications within this specification. The
Configurator supports an attribute called Key Action, which can be set
to one of the following:
• DOWN: the event is sent when a key is pressed. This is default
behavior.
• UP: the event is sent when a key is released.
• UPDOWN: the event is sent when a key is pressed and when it
is released; that is, two EVT_KEY events are sent.
Parameters include the following:
• wParam: primary code
• dwParam: OEM-specific
NOTE: For a particular device, primary code, key action, and key
symbols are configured for each key in the Configurator.
52
BREW Programming Concepts
The device contains an Embedded File System (EFS). There are several differences in the
behavior of the EFS versus a file system on a desktop (for example, Windows NT).
Applications must adhere to the following guidelines while trying to access files or APIs that
involve the file system (Databases, SoundPlayer, and so forth).
• When specifying the path for a file, do not include the drive letter. For example, the
following call is invalid:
IFILEMGR_OpenFile(pIFileMgr, "C:\\Test.dat",_OFM_CREATE);
There is no concept of drives on the EFS; therefore, they are not supported on the
Emulator.
• When specifying the path for a file, the paths “.\” and “..\” are not supported. For
example, the following calls are invalid:
IFILEMGR_OpenFile(pIFileMgr, ".\\Test.dat",_OFM_CREATE);
IFILEMGR_OpenFile(pIFileMgr, "..\\Test.dat",_OFM_CREATE);
• A filename cannot contain two periods (dots) within it. For example, the name
test.log.dat is invalid.
• When a filename is specified, BREW always tries to open that file in the directory of
the current module. For each module, the directory in which that module exists acts
as the root. Accordingly, when a file path is specified as <test\foo.dat>, the test
directory is searched within the directory of the module that has made this API call.
IFILEMGR_OpenFile(pIFileMgr, "Test1\\Test2\\Test.dat",_OFM_CREATE);
This call creates the subdirectories Test1\Test2, and then creates the file Test.dat
within Test2. These subdirectories and file are created within the applet's directory.
You will see similar behavior when dealing with databases because BREW
databases are stored in BREW files, and the name of the database is simply the
name of its file.
53
BREW Sample Applications
This BREW SDK includes an Examples directory with a wide variety of sample applications
you can use to learn to write BREW applications, or as the basis for creating your own
applications. Application source code for a few of the applications are shown in this section.
Reading the line-by-line explanations of these sample applications can help prepare you for
creating your own applications.
NOTE: Although the sample applications included in the BREW SDK have been thoroughly
tested, it is important that you employ reasonable user interface design and usability principles
in the creation of your own applications.
The sample applications included with the BREW SDK are of two types, demonstration and
usage.
• Usage applications demonstrate how to use BREW interfaces and APIs. In most
cases, the application file names begin with an "I," such as IMenuCtl. See Sample
usage applications on page 59 for a list of the usage applications included with the
BREW SDK.
The sample applications can be run and viewed on the Emulator. See Running sample
applications on page 105 for details.
NOTE: The sample source code provided with the BREW SDK has been written to
demonstrate the usage of BREW data structures and functions. Despite the extensive testing
that each sample application undergoes in our test labs, the source code was not intended to
pass the rigid requirements of TRUE BREW Certification because many of the sample
applications are not fully-featured. A notable exception is Road Warrior, version 1.1. This is a
TRUE BREW tested application. The source code and instructions are included in the BREW
SDK 1.1 release.
54
BREW Sample Applications
NOTE: The Test Signature (SIG) file listed in the last column, obtained from the BREW
Developers Extranet, enables your application to run on a particular handset. For more
information, see the BREW Developers Extranet web site.
55
BREW Sample Applications
Hello World IApplet A very simple (probably your first) BREW helloworld.mif
IDisplay application that shows Hello World on the helloworld.mod
IModule device screen. helloworld.sig
IShell This sample application demonstrates:
• BREW application structure,
including fundamental BREW
interfaces: IShell, IDisplay,
IModule, and IApplet.
• How to define and show a string
using the IDisplay interface.
• Minimum components required to
build a BREW application.
56
BREW Sample Applications
57
BREW Sample Applications
58
BREW Sample Applications
NOTE: For details on the interfaces, see the BREW API Reference.
NOTE: The Test Signature (SIG) file listed in the last column, obtained from the BREW
Developers Extranet, enables your application to run on a particular handset. For more
information, see the BREW Developers Extranet web site.
59
BREW Sample Applications
Extension Class IDisplay The BREW Extension Module. The sample extension.mif
Application IModule application uses the Exported Class in the extension.mod
IShell Extension Module. extension.sig
This sample application demonstrates:
• The BREW Extension Module
(ExtMod).
• How to write an ExtMod that contains
one or more exported Classes.
• A sample MIFfor the ExtMod.
• A BREW application using ExtMod.
• How to create an instance of an
exported Class in the Extension
application, and how to use that Class.
• A sample MIF for the application that
shows dependency on an exported
Class in the Extension application.
Extension Usage IApplet This applet is used to invoke the Extension extuse.mif
Application IDisplay Class application. extuse.mod
IExtensionCls This sample application demonstrates: extuse.sig
IModule
• Loading a dynamic class module and
IShell
calling functions from it.
60
BREW Sample Applications
I411 Viewer I411 Viewer A viewer application that implements a new b.411
IApplet Viewer interface which overrides the BREW I411Viewer.bar
IAStream IImage interface. I411Viewer.mif
IDisplay This sample application demonstrates: I411Viewer.mod
IImage I411Viewer.sig
• Creation and implementation of the
IMenuCtl
IShell new Viewer interface that overrides
the corresponding BREW interface.
• Registering and de-registering of the
Viewer interface with the BREW Shell
Registry using
ISHELL_RegisterHandler().
• Using the new interface functionality.
IDialog IApplet Allows the user to create and manage user dialog.bar
IDateCtl interface dialogs. idialog.mif
IDialog This sample application demonstrates: idialogusage.mod
IDisplay idialogusage.sig
• Usage of the IDialog interface.
IMenuCtl
IModule
IShell
61
BREW Sample Applications
IHTMLViewer IApplet Allows the user to specify a URL and load ihtmlviewer.mif
IDisplay and view an HTML file on the device. ihtmlviewer.mod
IFileMgr This sample application demonstrates: ihtmlviewer.sig
IHtmlViewer
• Usage of the IHtmlViewer interface.
IModule
IShell
62
BREW Sample Applications
63
BREW Sample Applications
IShell IApplet Allows the user to create and operate on the ishellusage.bar
IDisplay IShell object. IShell objects are used to ishell.mif
IMenuCtl invoke system level functionality. ishellusage.mod
IModule This sample application demonstrates: ishellusage.sig
IShell
• Usage of the IShell interface.
ISound IApplet Allows the user to create and operate on the isound.mif
IDisplay ISound object. The ISound interface offers isoundusage.mod
IMenuCtl basic sound services. isoundusage.sig
IModule This sample application demonstrates:
IShell
• Usage of the ISound interface.
ISound
64
BREW Sample Applications
IStatic IApplet Allows the user to display static text controls, static.bar
IDisplay consisting of a text message and title. istatic.mif
IImage This sample application demonstrates: istaticusage.mod
IMenuCtl istaticusage.sig
• Usage of the IStatic interface.
IModule
IShell
IStatic
65
BREW Sample Applications
NOTE: For details on the interfaces, see the BREW API Reference.
66
BREW Sample Applications
NOTE: The phone skins displayed in this Guide are for illustration purposes only. The actual
phone skins shown may or may not by available with the BREW SDK at this time.
To develop an application, you need to create an application source code file. A sample source
file follows. Because each code segment of the file is explained in the table at the end of the
description of each sample application, few comments are added to the sample source code
listings.
67
BREW Sample Applications
68
BREW Sample Applications
The sample Hello World application uses a simple applet stub source file provided with the
BREW SDK. This file is compiled and linked with the applet and provides the necessary
interface required supporting the IModule and IApplet interfaces. This allows the application
developer to simply focus on handling a few of the BREW events passed to its HandleEvent
method. The application developer has the option of implementing all IModule and IApplet
interfaces directly that meet their needs more effectively.
In this example, the Hello World message is shown when the EVT_APP_START event is
received by the applet. This event is received by the application’s HandleEvent function when
the BREW AEE starts the applet. In this example the applet clears the screen, displays the
"Hello World" message, and instructs the display interface to update the screen.
This sample outlines just how easy it is to develop an applet under BREW. BREW isolates you
from all device-specific event processing. Although applets can elect to handle many events,
doing so is not a requirement of the AEE. This leaves you to concentrate on the functions
required by your application, rather than focusing on any device-specific requirements.
The following table provides a detailed description of the Hello World application source code.
1-3 The first four lines include files needed by the Hello World application.
• AEEModGen.h and AEEAppGen.h define the Module and Applet
functions.
• The AEEDisp.h file includes the definitions of the IDisplay interface.
4 Line 4 includes the helloworld.bid file. This file contains the definition of the
unique AEECLSID_HELLOWORLD ClassID of the applet. You have to use a
value not used by another application. As stated previously, this value is
reserved using the QUALCOMM BREW Interface Registry.
6-7 These lines are for forward declaration of the HandleEvent function prototype.
69
BREW Sample Applications
10-25 These lines define the standard load function that must be provided by all
modules.
The Hello World applet is loaded into the Emulator as a DLL. This follows the
dynamic loading model also used on the target device. To support this
mechanism, the applet must export a single entry point into the module. Under
the Emulator, this entry point is exported as a DLL entry point. Under the
Device BREW environment, this function must be exported as follows:
• For statically linked modules (.LIB), the entry point must be given a
unique name that can be added by the device integrator into the module
table.
• For dynamically loaded modules (.MOD), the entry point must be
located at the start of the first file linked.
The purpose of the AEEClsCreateInstance() function is to create an instance
of the AEEApplet data structure for each applet or class supported by the
module. The AEEApplet data structure is created by invoking the
AEEApplet_New() function with the address of the applet specific handle
event function. The first parameter is the size of the applet data structure.
Because there is no data this applet needs to store, the AEEApplet data
structure is used (see the resource application example for an applet-specific
data structure use).
In the Hello World module, only one applet is supported. At line 17, the
AEEApplet_New() function is invoked to create the AEEApplet data structure
of the Hello World module.
Upon successful loading of the applet, AEE_SUCCESS is returned.
70
BREW Sample Applications
28-52 The HelloWorld_HandleEvent() function processes all the events the applet
receives. The event type, subevent type, and event data are passed in the
eCode, wParam, and dwParam parameters, respectively.
• The switch statement at line 35 looks at the main event received by the
applet.
• If the event is EVT_APP_START, the applet has received a START
event.
• The IDISPLAY_ClearScreen () function erases the whole screen.
• The IDISPLAY_DrawText () function is used to display the text string
"Hello World" in the middle of the screen. The flags
IDF_ALIGN_CENTER and IDF_ALIGH_MIDDLE are used to place the
text string in the center of the screen along the horizontal and vertical
axis, respectively.
• Finally, the IDISPLAY_Update () function is used to update the screen.
This application supports only two events, EVT_APP_START and
EVT_APP_STOP. When the user presses the device’s END key, the applet
receives the EVT_APP_STOP event. When this event is received by the
applet, it needs to do applet-specific cleanup such as saving files, releasing
memory allocated by applet, etc. Because the Hello World applet does not
allocate any resources, there is no cleanup needed when the
EVT_APP_STOP event is received.
When this applet starts, it prints two lines of text in the top half of the screen, with a 2-pixel-
wide horizontal line dividing the screen in the middle. In the following illustration, the two lines
of text read:
• to move cursor
71
BREW Sample Applications
You can move the cursor using the left, right, up, and down arrow keys, or using the navigation
button on the emulated device, if applicable.
72
BREW Sample Applications
73
BREW Sample Applications
74
BREW Sample Applications
118. pMe->m_nCursorY);
119.
120. IDISPLAY_Update(pMe->a.m_pIDisplay);
121. return (TRUE);
122. case EVT_KEY: // process key-down event
123. switch (wParam)
124. {
125. case AVK_LEFT:
126. case AVK_RIGHT:
127. CresApp_Move(pMe,(wParam == AVK_RIGHT ? 1 : -1), 0);
128. break;
129. case AVK_UP:
130. case AVK_DOWN:
131. CresApp_Move(pMe,0,(wParam == AVK_UP ? -1 : 1));
132. break;
133. default:
134. return(FALSE);
135. }
136. return(TRUE);
137. case EVT_APP_STOP:
138. return TRUE;
139. default:
140. break;
141. }
142.
143. return FALSE;
144. }
145.
146. // Helper function to move bitmap on the screen
147. static void CresApp_Move(CResApp * pMe, int xc, int yc)
148. {
149. AEEImageInfo iInfo;
150. int min, max;
151. int x = pMe->m_nCursorX;
152. int y = pMe->m_nCursorY;
153.
154. IIMAGE_GetInfo (pMe->m_pIImage, &iInfo); // Get image info
155.
156. // Erase previously displayed bitmap from the screen
157. IDISPLAY_EraseRgn (pMe->a.m_pIDisplay, x, y, iInfo.cx, iInfo.cy);
158.
159. x += xc;
160. y += yc;
161.
162. // Delimit the x & y coordinates to lower half of the screen
163. min = 0;
164. max = pMe->m_cxWidth - iInfo.cx;
165. x = ((x < min) ? (min) : (x > max) ? max : (x));
166.
167. min = pMe->m_cyHeight/2;
168. max = pMe->m_cyHeight - iInfo.cy;
169. y = ((y < min) ? (min) : (y > max) ? max : (y));
170.
171. IIMAGE_Draw (pMe->m_pIImage, x, y); // Display bitmap image
75
BREW Sample Applications
172.
173. pMe->m_nCursorX = x; // Store new x coordinates
174. pMe->m_nCursorY = y; // Store new y coordinate
175.
176. IDISPLAY_Update(pMe->a.m_pIDisplay); // Update screen
177. }
The data structure of sample application #2 is applet-specific. It needs to declare as its first
data member an instance of the AEEApplet class. This is a strict requirement that gives the
BREW AEE the ability to load applets dynamically. You need to add the applet-specific data
member following the AEEApplet instance.
1-8 A new header file, resapp_res.h, is included to get the resource IDs for the
new applet.
• AEEStdlib.h is included to access standard conversion routines.
• AEEImage.h is added to include image processing functions.
10 A resource filename is defined. This resource file contains all the resources
used in this example.
13-21 An applet-specific data structure is defined here to store all the applet data
that needs to be remembered through the life of the application. The major
requirement this data structure has is that its first data member needs to be an
instance of type AEEApplet. This requirement is related to an applet being
dynamically downloaded.
30-47 These lines define the standard load function each module needs to supply.
• AEEApplet_New function is invoked to load the applet. Here the first
parameter to this function is the size of the applet data structure.
NOTE: Unlike the Hello World applet, the applet data structure size is
passed instead of AEEApplet size.
• When an applet is loaded successfully, the InitAppData function is
invoked at line 40 to initialize applet-specific data.
76
BREW Sample Applications
50-74 This section defines the InitAppData function, used to initialize applet-specific
data.
• Use the ISHELL_GetDeviceInfo function to get the device screen width
and height and store them in the applet data structure.
• Initialize the location coordinates of the cursor on the screen. The device
screen width and height are used so that the cursor image is located
halfway along the x-axis and 2/3 of the way along the y-axis.
• Load the resource image from the resource file and store a pointer to it
in the m_pIImage data member.
77-85 This section defines the FreeAppData function, which frees the image object
stored in the applet data structure.
77
BREW Sample Applications
78
BREW Sample Applications
147-177 These lines define a helper function, which takes an applet data structure
pointer and two integer variables corresponding to incremental movement of
the cursor in the x and y directions.
• Two local variables (x and y) are initialized with the present cursor
location coordinates.
• The IIMAGE_GetInfo function gets the image information.
• The IDISPLAY_EraseRgn function erases the region where the cursor
was previously displayed.
• The local x and y variables are updated with the new position of the
cursor.
163-169 These lines use algorithms to evaluate if the new cursor coordinates are within
the boundaries of the bottom half of the screen, delimiting the cursor to the
bottom half of the screen.
• The IIMAGE_Draw function is used to display the cursor at the new
coordinates.
• The new coordinates are stored in the applet data structure members,
and the device screen is updated using the IDISPLAY_Update function.
79
BREW Sample Applications
12.
13. static void TimerApp_FreeAppData(IApplet* pMe) {}
14. static void AlarmApp_FreeAppData(IApplet* pMe) {}
15.
16. int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell,
17. IModule* po, void** ppObj)
18. {
19. *ppObj = NULL;
20.
21. if(ClsId == AEECLSID_TIMERAPP)
22. {
23. if(AEEApplet_New(sizeof(AEEApplet), ClsId, pIShell,po,
24. (IApplet**)ppObj, (AEEHANDLER)TimerApp_HandleEvent,
25. (PFNFREEAPPDATA)TimerApp_FreeAppData) == TRUE)
26. {
27. return(AEE_SUCCESS);
28. }
29. }
30. else if(ClsId == AEECLSID_ALARMAPP)
31. {
32. if(AEEApplet_New(sizeof(AEEApplet), ClsId, pIShell,po,
33. (IApplet**)ppObj, (AEEHANDLER)AlarmApp_HandleEvent,
34. (PFNFREEAPPDATA)TimerApp_FreeAppData) == TRUE)
35. {
36. return(AEE_SUCCESS);
37. }
38. }
39. return (EFAILED);
40. }
41.
42. // Timer Callback Function
43. void TimerCB(void *pv)
44. {
45. AEEApplet * pMe = (AEEApplet *) pv;
46.
47. // Process timer expiration here
48.
49. }
50.
51. static boolean TimerApp_HandleEvent(IApplet *pi, AEEEvent eCode,
52. uint16 wParam,uint32 dwParam)
53. {
54. AEEApplet * pMe = (AEEApplet *)pi;
55. int timerValue = 10000; // 10000 milliseconds
56. uint16 nCode = 10;
57. uint32 numMinutes = 10; // Alarm activate time: 10 minutes
58.
59. switch (eCode)
60. {
61. // Handle app startup
62. case EVT_APP_START: // Process Start event
63.
64. // Set timer
65. ISHELL_SetTimer (pMe->m_pIShell, timerValue,
80
BREW Sample Applications
81
BREW Sample Applications
1-3 The first three lines include files needed by the timer/alarm application.
• AEEModGen.h and AEEAppGen.h define the module and applet
functions.
• AEEShell.h includes all the definitions that an application needs to work
with the IShell interface.
5-6 Defines the ClassIDs of the two applets in this application. The timer applet
(AEECLSID_TIMERAPP) sets an alarm and a timer. When the alarm is
activated, the alarm applet (AEECLSID_ALARMAPP) receives the
EVT_ALARM event, at which time the applet is loaded to process it.
8-14 Forward declarations of the HandleEvent and FreeAppData functions for each
applet are presented here. Because neither applet has any data that needs to
be freed upon termination, both their FreeAppData functions are empty.
16-40 These lines define the standard load function that must be provided by all
modules. In this application, the function can load either the timer or alarm
applet, based on the ClassID that is passed to it. The timer applet is loaded
when the device user requests execution of the applet, while the alarm applet
is loaded to process the EVT_ALARM that is generated when the alarm is
activated.
42-49 TimerCB is the callback function for the timer that is set when the timer applet
is started. When setting a timer, you specify the address of the timer’s callback
function and a 32-bit variable that is the single parameter of this function. In
this example, a pointer to the timer applet’s AEEApplet structure is passed to
TimerCB. When the timer expires, this function is invoked. The callback
function is empty in this example, but it usually contains any processing that
must be performed upon expiration of the timer.
82
BREW Sample Applications
51-88 These lines contain the HandleEvent function of the timer applet. This applet
supports the EVT_APP_START and EVT_APP_STOP events.
When it receives the EVT_APP_START event, the timer applet first starts a
timer, specifying the expiration time (10,000 milliseconds, or 10 seconds), and
the address (TimerCB) and parameter (pMe, the timer applet’s AEEApplet
structure) of the callback function. The applet then sets an alarm, providing the
ClassID (AEECLSID_ALARMAPP) of the alarm applet, a 16-bit code
identifying the alarm (this code allows multiple alarms destined for the same
class to be active at once), and the number of minutes (10 in this case) until
the alarm is activated.
This applet also processes the EVT_APP_STOP event, which would be
generated if the device user chose to terminate the applet before the timer
and/or alarm have been activated. In this case, the applet cancels the timer if
it is still running, and then cancels the alarm.
90-105 These lines contain the HandleEvent function of the alarm applet. This applet
processes only the EVT_ALARM event. When it receives this event, the
wParam parameter of the HandleEvent function contains the 16-bit code that
was supplied by the timer applet when it sets the alarm. Here the applet can
perform any processing associated with the alarm activation (no processing is
shown in this example). Note that once it completes processing of the alarm,
the alarm applet is terminated. If an applet that is loaded just to process an
alarm event needs to interact with the device user, it can send itself an
EVT_APP_START by calling its own HandleEvent function. This allows the
applet to write to the device display and receive keypad input from the user.
This example demonstrates the use of the IFileMgr and IFile interfaces to open a file and read
data from it. The code author has assumed that the interface pointers in this example are used
by several parts of the program; therefore, they are part of the applet data structure.
The declaration of the applet data structure and the HandleEvent function of the example are
shown in the following sample source code. Other portions of the program have been omitted.
83
BREW Sample Applications
84
BREW Sample Applications
53. }
54. return FALSE;
55. }
1-8 The declaration of the applet data structure includes the mandatory AEEApplet
structure as its first member, followed by the applet-specific IFileMgr and IFile
instance pointers. Declaring the pointers here makes them available to other parts
of the program by passing them a pointer to the applet data structure. For
example, an instance of IFileMgr is created when the applet is started (see below),
and this instance can be used by any other applet function that needs it. This
instance could be freed in the applet’s FreeAppData function (not shown).
11-20 This is the beginning of the applet’s HandleEvent function. Some variables that
are used as parameters in the function calls in the body of HandleEvent are
declared and initialized here.
22-30 The applet tries to read the file when it receives the start event. It first attempts to
create an instance of the IFileMgr interface. If this succeeds, the instance pointer
returned by ISHELL_CreateInstance has a nonzero value.
31-35 If an instance of IFileMgr was created successfully, the applet next tries to open
the specified file for reading. If this succeeds, IFILEMGR_OpenFile returns a
pointer to an IFile interface, which can be used to perform read operations on the
opened file.
36-45 If IFILEMGR_OpenFile returns a non-NULL file pointer, the applet can then call
IFILE_Read to read the specified number of bytes from the start of the file into the
buffer. IFILE_Read returns the number of bytes read, so if it returns 0 (zero), the
IFile instance is released and an indication of applet startup failure is returned.
46-49 If this point is reached, you can assume that the read was successful. The IFile
instance (which closes the file opened in lines 34-35) is then released and
success is returned. The instance of IFileMgr created in lines 28-29 has not been
released because other parts of the program need it. (It can be released with the
applet’s FreeAppData function.)
85
BREW Sample Applications
As in the previous example, only the event handling function is listed. The
AEEClsCreateInstance function is similar to the one found in the first three examples. The
InitAppData function initializes the three database-related pointers and the FreeAppData
releases them.
86
BREW Sample Applications
35. }
36. }
37. return FALSE;
38. case EVT_APP_STOP:
39. return TRUE;
40. default:
41. break;
42. }
43.
44. return FALSE;
45. }
The previous example creates a database record with one field to hold the last name of a
person. A detailed description of the Handle-Event function of the example follows.
14-17 Datafill the database field instance with the field type, name, data length, and a
pointer to the data.
26-27 If the database manager was created successfully, create a database of the given
name using the IDBMGR_OpenDatabase function. The final parameter of this
function indicates whether a new database is to be be created when the specified
database file does not exist: When set to TRUE, a new database is created; when
set to FALSE, no new database is created.
87
BREW Sample Applications
4. When the Connect callback is called, perform a read operation on the socket using
the ISOCKET_Read() function.
When the socket is ready to be read, this callback is invoked. Inside the callback,
the data can be read using ISOCKET_Read(). The AEE Sockets always operate
in the asynchronous mode.
6. Repeat the previous steps until the required number of bytes have been read.
8. When the INetMgr interface is no longer needed, release the INetMgr by invoking
the INETMGR_Release() function.
For the complete source code, see the sample applications in the Examples directory of the
BREW SDK.
88
Using Dialogs and Controls
A dialog is a frame that contains controls. BREW controls are graphical and textual interfaces
that provide input and output functions for BREW. The following types of controls are
supported:
• Clock
• Countdown
• Date
• Date Pick
• Icon View
• List
• Menu
• Soft Key
• Stopwatch
• Text
Creating dialogs
There are two ways to create a dialog:
You must create a dialog resource before you can use the Resource Editor to create dialog
objects.
89
Using Dialogs and Controls
90
Using Dialogs and Controls
With the Resource Editor, you can specify the coordinates, size, and types of
controls to be placed on a dialog. The following example shows the Menu control.
For detailed instructions on creating BREW dialogs and controls with the Resource
Editor, see the BREW Resource Editor Guide.
After the appropriate resource files are generated, you must call the ISHELL_CreateDialog
function using the following parameters:
If you prefer, you can construct a dialog object without first creating a BREW dialog resource.
In this case, you need to provide the DialogInfo structure defined in the AEEShell.h file. To
construct a DialogInfo object, you must also create DialogItem objects and DListItem objects
(also defined in AEEShell.h). The DialogItem structure defines dialog controls, while the
DListItem structure defines list items, which are the choices presented in the controls.
After you have created the appropriate structures, call the ISHELL_CreateDialog function
using the following parameters:
• EBADCLASS indicates that the pointer to the IShell object was invalid.
• EBADPARM indicates that one or more parameters passed into the function is
invalid.
91
Using Dialogs and Controls
Dialog events
The following three events can be handled by any applet that uses BREW dialogs:
EVT_DIALOG_INIT This event is sent to the applet after the BREW dialog object verified
the passed in parameters and is initialized correctly. No event-specific
parameter is passed in with this event.
EVT_DIALOG_START This event is sent to the applet after all the dialog Controls and List
Items are loaded and the screen is refreshed to show the dialog. The
following parameters are passed in with the event:
• dParam: The first event parameter contains the ID of the dialog.
• dwParam: The second event parameter contains the pointer to
the dialog.
EVT_DIALOG_END This event is sent to the applet after the dialog is destroyed. The
following parameters are passed in with the event:
• dParam: The first event parameter contains the ID of the dialog.
• dwParam: The second event parameter contains the pointer to
the dialog.
The applet is not required to do any specific processing in response to these events in the
applet event handler; however, it is recommended that appropriate initialization or cleanup be
performed.
In addition to these three events, the applet can also handle those events of type
EVT_COMMAND specified in the dialog control and list items.
Dialog controls
To retrieve an interface pointer to a control in a newly created dialog, use the
ISHELL_GetControl function. To use this function, you must provide the ID of the control (the
same ID you used to create the control). The signature of the function looks like this:
where pIDialog is the pointer to the dialog object, and int16 wID is the ID of the control.
The return value is the pointer to the control object. If the control ID isn’t valid, the return value
is set to NULL. After this pointer is obtained, you can manipulate the control objects by calling
each control’s interface functions.
92
Using Dialogs and Controls
The IDIALOG_SetFocus function lets you specify which control in a multicontrol dialog has the
focus. This control receives key input from the device user.
where pIDialog is the pointer to the dialog object, and int16 wID is the ID of the control.
The return value is the ID of the control that had the active focus just prior to the function call.
For descriptions of each control, see the BREW Resource Editor Guide. For functions
associated with each control, see the BREW API Reference.
Terminating dialogs
When a dialog object is no longer needed, terminate it through the ISHELL_EndDialog
function must be called with the Pointer to the IShell object parameter.
The ISHELL_EndDialog function terminates the active dialog in the event that more than one
dialog object is open. The return value of this function varies based on the success of the
dialog termination. Possible return values are as follows:
• SUCCESS indicates that the function has properly terminated the active dialog
object.
• EBADCLASS is an error code, which is returned when the pointer to the IShell
object is not valid.
After the termination is complete, the EVT_DIALOG_END dialog event is sent to the applet.
When the event is received, the applet takes appropriate actions to ensure that all references
to the old active dialog are also removed.
In the following procedure, you will create an example application with a dialog using the
Resource Editor. The dialog includes a menu from which the user to choose a favorite color
from a list of five choices.
93
Using Dialogs and Controls
2. Using the Resource Editor, create String resources, entering the text strings shown
below:
94
Using Dialogs and Controls
The menu control has list Items representing the color choices.
See the source code for the SampleDialog applet and IDialog usage applet shipped with the
BREW SDK.
95
Using Dialogs and Controls
The new application’s initial dialog looks like the device on the left, and each selection presents
a selection confirmation message box like the one shown on the right.
96
Using the BREW Emulator
The Emulator emulates a selected handheld device, allowing you to load and test applets and
classes developed in the BREW environment. The wireless devices emulated can have
different screens, keypads, amounts of available memory, and supported languages. During
emulation, the Emulator opens an image of the device on a PC monitor. By clicking the
portions of the image that correspond to the device’s keys, you provide key input to the applet
being emulated, and the screen output produced by the applet appears in the screen portion
of the device image.You have the option of viewing your applications at the device’s actual
screen size or specifying a screen size in the configuration file in the Configurator. See the
BREW Device Configurator Guide for more information. The BREW SDK also includes several
sample applets that you can load into the Emulator and explore.
When you choose an applet from the list, the Emulator loads the applet’s DLL and executes
the applet, showing its initial screen on the device screen. You can click the device keys to
provide input to the applet and observe its behavior, including its output to the screen.
Before beginning to develop applications with BREW, try running devices on the Emulator.
You’ll discover this is an invaluable tool for learning about programming in the BREW
environment. See Running sample applications on page 105 for information.
There are two methods for running the Emulator, from the Windows Start menu and from the
command line.
The BREW Emulator window opens. BREW automatically starts the Application
Manager, which shows a menu of icons and an applet name on the device screen.
97
Using the BREW Emulator
Applets
Select
key
End
key
Clear
key
NOTE: The phone skins displayed in this Guide are for illustration purposes only.
The actual phone skins shown may or may not by available with the BREW SDK
at this time.
98
Using the BREW Emulator
2. Depending on the selected device, you can use your keyboard arrow keys to move
between applet icons, or you can click on the navigation buttons on the emulated
device. In the device shown above, the Select button allows you to move left, right,
up, and down.
• For Windows 2000, choose Start > Programs > Accessories > Command
Prompt.
• For Windows NT, choose Start > Programs > Command Prompt.
where:
NOTE: If any of the paths contain spaces, you must enclose the path with quotation
marks. For example, if you type the <MifDir> path C:\Program Files\BREW
\Examples\MIF\Apps\256Color\, all characters in the path after the word Program
would be ignored. The correct way to type the path is: “C:\Program
Files\BREW\Examples\MIF\Apps\256Color\.”
The Emulator has four menus (File, View, Tools, and Help), which are described on the
following pages.
99
Using the BREW Emulator
File menu
Load Device... Opens the Select Device dialog box which, by default, lists
preconfigured device files in the <BREW\Devices> directory. These
device configuration files were created with the Configurator. For
more details on device files, see BREW SDK directory structure.
Change Applet Dir... Opens the Select Applet Directory dialog box so that you can change
the applet directory where the Application Manager searches for
applets. For more information about the applet directory, see BREW
SDK directory structure.
100
Using the BREW Emulator
Change MIF Dir... Opens the Select MIF Directory dialog box so that you can change the
MIF directory where the Application Manager searches for MIFs of the
applets. For more details on the MIF directory, see BREW SDK
directory structure.
101
Using the BREW Emulator
View menu
Real Size Screen Toggles between the device's actual screen size and the Emulator's
default screen size. When you create a device configuration file using
the Configurator, you have the option of specifying the width and
height of the device screen. Then, when the device is loaded into the
Emulator, choosing Real Size Screen from the View menu lets you
match the Emulator's display size with the size of the actual device
screen to obtain a more accurate emulation of device output behavior.
This feature of the Emulator is available only if you entered the
physical dimensions of the device screen when you created the
device configuration file.
Output Window Displays messages that can be valuable for debugging your software
when it is displayed using the Emulator. Any code marked for tracing
within the software can cause messages to be shown in this window.
Tools menu
Settings... Opens the Settings dialog box, which allows you to select the initial
device file, initial applet directory, and initial MIF directory. The
Emulator saves the settings in a data file and uses the saved settings
when the Emulator is restarted. Changes made to the settings take
effect immediately.
102
Using the BREW Emulator
Click Select Device File... to open the Select Device dialog box.
Click Select App Dir... to open the Select Applet Directory dialog box
in order to enter the initial applet directory.
Click Select MIF Dir... to open the Select MIF Directory dialog box in
order to enter the initial MIF directory.
TAPI Emulation Allows you to emulate incoming or outgoing calls, or send SMS
messages to BREW. This allows you to test the effect of incoming
calls when applications you have written are running. For more
information, see Using TAPI emulation on page 114.
Enable Key Beep Allows you to emulate the Dual Tone Multi-Frequency (DTMF) tones
for the selected device. The device’s key pad has been mapped to
generate the DTMF tones corresponding to those on the actual
device. This menu option toggles on and off.
103
Using the BREW Emulator
Help menu
About BREW Emulator Opens a window that shows the BREW version and copyright
information.
Backlight toggle
Clicking the right mouse button anywhere on the Emulator screen opens a menu that contains
an option to toggle the backlight of the screen between dark and light. This feature is available
for monochrome devices only. It is not supported by color devices.
The Emulator supports 1-monochrome, 4-grayscale, 16-color, and 256-color. The color depth
information is obtained from the BREW device file for any given device. To use the color
feature of the Emulator, you must use the Configurator to create a BREW device file with
corresponding color depth. A list of color depths and their associated colors follows.
Color depth of 2:
Color depth of 4:
104
Using the BREW Emulator
Color depth of 8: BREW supports 216 (6x6x6) colors uniformly distributed in the RGB color
cube, in which each axis, corresponding to R, G, or B, is from 0 to 255.
For your convenience, this release of the SDK includes sample BREW device files supporting
different color depths for various devices.
Usage applications These applications demonstrate how to use BREW interfaces and
APIs. The names of most of these applications begin with an I. For
example, IMenuCtl application shows you how to use the BREW
IMenuCtl interface to manage menus in a BREW application.
105
Using the BREW Emulator
The Emulator opens with a list of the sample applications shown in the emulated
device’s window.
You can choose applications using the keyboard left and right arrow keys. If the
selected device includes left and right arrow keys, you can also use those to scroll
through the applications.
BREW loads the MIDI applet (that is, the MIDI applet DLL) and starts the
application. The MIDI application shows a screen similar to the following:
106
Using the BREW Emulator
4. Using the arrow keys, choose a music file and click Select.
7. Now try the same application on a different device by selecting a device file using
File > Load Device.
NOTE: You are advised to make a copy of the entire Examples directory before making any
change to the sample sources.
107
Using the BREW Emulator
NOTE: This release of the BREW SDK supports only the Microsoft Visual C++
development environment.
2. Make a small change to HelloWorld.c (for example, type a different text message)
and rebuild the application using the Build menu in your compiler.
3. Run the Emulator, choose the “Hello World App” applet, and run it to verify that your
change has taken effect.
When the Emulator is started, the Application Manager (AppManager) builds a main menu of
applets (with icons and titles of applets) and runs selected applets.
The Application Manager is a BREW application that serves as a starting point for browsing
and running the BREW applications available on the device. It has a simple GUI that shows
all the BREW applications present on the device. Using this GUI, you can navigate through
the different applications and run any of them.
NOTE: The <BREW\Examples\shared> directory contains images, MIDI files, and MP3 files
used by the Application Manager. You can add files to the shared directory to make them
available to the Application Manager.
108
Using the BREW Emulator
The AppManager presents a set of small icons (soft key menu items) at the bottom of the
device screen, each corresponding to a BREW application. When the cursor (focus) is on the
soft key item, the large image for the corresponding application is shown on the main device
screen.
The last soft key menu is called Configure. This menu allows you to do the following:
• Control the sequence in which applications are shown by the Application Manager.
By default, the applications are shown in the order that their corresponding MIFs are
read by BREW. However, you can change the sequence as needed. For example,
if you always want Scheduler to be the first application, you can do it using the
Configure Menu.
• Associate image files with each application. When the cursor is on the soft key menu
item for an application, an image appears in the main screen. This image
supersedes the image (if any) contained within the MIF.
• Associate sound files (MIDI and MP3) with each application. When the cursor is on
the soft key menu item for an application, the corresponding sound file is played (if
the device supports sound files).
The Configure information is stored in a data file called appinfo.txt in the shared directory. The
AppManager reads these settings when the Emulator is restarted.
NOTE: The Application Manager included with the Emulator is not necessarily the same
Application Manager program used on each handset. OEMs may have their own customized
programs for managing applications.
3. Use the left-arrow key until the Configure applet is highlighted, and click Select.
109
Using the BREW Emulator
4. Use the down-arrow key until the applet you want to configure is highlighted, and
click Select. For this example, choose Scheduler.
5. To change the image shown in this screen, press the right-arrow key until Image is
highlighted, and click Select.
You are presented with a list of images from which you can choose a new image.
6. Use the down-arrow key until the image you want to use is highlighted, and click
Select.
110
Using the BREW Emulator
2. Use the down-arrow key until the sound you want to use is highlighted, and click
Select.
3. When you are done configuring the applets, use the left-arrow key until Done is
highlighted, and click Select.
4. Use the right-arrow key until Done is highlighted, and click Select.
111
Using the BREW Emulator
The BREW SDK includes several device files already configured for speed emulation. These
are the devices in the <BREW/Devices> directory with SpeedEmu in the filename (for
example, LGE_CX-300L_SpeedEmu.qsc).
If needed, you can configure other devices for speed emulation. This process involves the
following steps:
• Download the SpeedTune application from the BREW SDK to the device. Be sure
to include the MIF, MOD, BAR, SIG (device signature file), and testfile.rd files. The
MIF files for devices of various color depths are stored in the
<BREW/Examples/MIF/Apps> directory.
• Run the SpeedTune application on the device to generate a configuration file. This
file contains information about the device’s speed and is used to calculate the
device’s emulation speed.
• Upload the configuration file (brew_emu.dst) from the device to your PC. After
uploading the file, rename the file to something more meaningful.
NOTE: For information on downloading and uploading data to and from the device, see
the BREW AppLoader User Guide. This guide is included with the AppLoader
application that you can download from the BREW developer extranet site.
• Using the Configurator, configure the device so that it can be enabled for speed
emulation, and associate the uploaded configuration file with the device. See the
BREW Device Configurator Guide for more information.
• You can now enable the device for speed emulation in the Emulator.
112
Using the BREW Emulator
• Optionally, you can perform the following two steps to ensure that the emulation
speed approximates the speed that your applications runs on the actual device.
- Load the device in the Emulator and tune the device’s speed parameters for
speed emulation. This process calculates the speed of emulation based on the
speed of your computer and the device.
- After the parameters have been tuned, you can enable the device for speed
emulation.
NOTE: For information on tuning speed parameters and enabling the device for speed
emulation in the Emulator, see Tuning speed emulation parameters and enabling the device
below.
To tune speed parameters for a device and enable it for speed emulation
1. Load the device you configured for speed emulation into the Emulator.
2. Make sure the device is not enabled for speed emulation by clicking Tools > Speed
Emulation. The Enable menu option must not have a check mark in front of it. If it
does, click Enable to disable speed emulation.
113
Using the BREW Emulator
The DispSpeedTune application runs and generates the configuration file (.dst)
that contains the PC’s speed values.
5. After the Tune Parameters dialog box closes, you can enable speed emulation for
the device by clicking Tools > Speed Emulation > Enable.
At runtime in the Emulator, the speed value from the device is subtracted from the
speed of your PC processor to determine the emulation speed for the device.
114
Using the BREW Emulator
A Privacy Alert message appears, asking if you want to receive the call.
• Applications that have registered to receive specific IS-637 messages based upon
the teleservice ID of the message
• Applications that have registered to receive all IS-637 CMT 95 (4099) text
messages
• Any BREW applications to which a CMT 95 text message has been “directed.”
For more information on incoming SMS messages, see Monitoring incoming SMS messages
on page 39.
115
Using the BREW Emulator
3. Type the applet’s hex ClassID number and a text message you want sent to the
device.
4. Click Send.
The SMS dialog box closes and EVT_APP_MESSAGE with dwParam pointing to
the user character string causes the message to appear in the device’s screen.
NOTE: In order for the message to be passed, the application must be in the
current applet directory and in the MIF path.
116
Using the BREW Emulator
You can emulate an outgoing call initiated by the active BREW application using the ITapi
Usage applet. For your applications to have this capability, they must use the
ITAPI_MakeVoiceCall function. For more information, see the BREW API Reference.
NOTE: If you do not see this applet, choose Tools > Settings, and change the MIF
directory to Examples\MIF\Usage\256Color\.
2. Use the down-arrow key until 4. Make Voice Call is highlighted, then click Select.
117
Using the BREW Emulator
A Privacy Alert message appears, asking if you want to allow the application to
make the call.
118
Extending BREW APIs
You can customize BREW API by providing BREW API Extensions that contain common
functionalities for use by many applications. For example, you can write an animation and
graphics extension for a set of games, or a sorting algorithm extension for a set of data
intensive applications.
Implementing the extensions is not much different than writing a BREW application. The
difference is that the extensions must expose their virtual function tables to the other external
classes.
NOTE: The examples in the following subsections are based on the Extension sample
application distributed with the BREW SDK.
QINTERFACE(IExtensionCls)
{
DECLARE_IBASE(IExtensionCls)
int (*DrawSmiley)(IExtensionCls * po, AEEPoint ptCenter, int nRadius);
int (*DrawHello)(IExtensionCls * po, AEEPoint ptXYOffset);
};
The previous code declares an interface of IExtensionCls through the macro QINTERFACE(),
and lists its member functions: DrawSmiley() and DrawHello(). These functions are accessed
through the following virtual table access macros:
#define IEXTCLS_AddRef(p) \
GET_PVTBL(p,IExtensionCls)->AddRef(p)
#define IEXTCLS_Release(p) \
GET_PVTBL(p,IExtensionCls)->Release(p)
#define IEXTCLS_DrawSmiley(p,ptC,nR) \
GET_PVTBL(p,IExtensionCls)->DrawSmiley(p,ptC,nR)
#define IEXTCLS_DrawHello(p,ptC) \
GET_PVTBL(p,IExtensionCls)->DrawHello(p,ptC)
119
Extending BREW APIs
Two extra member functions are exposed: AddRef() and Release(). They are derived from the
top-most parent class IBASE through the macro DECLARE_IBASE().
The AddRef() function needs to increment the internal reference count of the interface by one.
Following BREW policy, each module or class must perform its own reference count to
conserve memory. The Release() function must decrement the internal reference count by one
and check whether it has reached zero (0); if so, the function needs to free all the resources
allocated for the extension as well as for itself.
An additional macro, GET_PVTBL(), is used in the previous example to access the interface
functions through virtual function table pointers.
The C++ equivalent of the previous class declaration is shown in this example:
NOTE: This C++ illustration is for explanatory purposes only. You cannot use C++ yet since
there are issues with the ARM Compiler. We are looking into these issues and will soon make
this feature available.
120
Extending BREW APIs
Inside the class, the macro DECLARE_VTBL() inserts the virtual table into the class definition.
NOTE: This virtual table declaration must be the first line inside the class.
After the virtual table declaration, you can enumerate all of the member variables in any order.
A mandatory member variable is m_rRefs, which keeps count of all the modules that have
references to the extensions. This variable makes possible the functions AddRef() and
Release(), which were discussed in the previous section.
The functions AddRef() and Release() are responsible for module reference counting and
cleaning up the modules as described earlier. DrawSmiley() and DrawHello() perform the
intended functionality of the extension.
The AEEClsCreateInstance() function must perform several tasks that regular BREW modules
usually don’t perform. Instead of calling AEEApplet_New() to create, it must call its own new-
operator. In this example, we’ll call it ExtensionCls_New() with the following signature:
121
Extending BREW APIs
Memory allocation Memory must be allocated for the class, including all of the member
variable instances, and the virtual function table, as shown in the following
example:
VTBL(IExtensionCls) * modFuncs;
if(!ppMod || !pIShell || !pIModule)
return EFAILED;
*ppMod = NULL;
Virtual Function Table After the memory block for the class and virtual function table is allocated,
Initialization the virtual function table must be initialized to point to the right functions,
as shown in the following example:
NOTE: This step first initializes each individual entry in the virtual function
table, and then it initializes the table itself.
Class Member After the virtual function table has been initialized, the next step is to
Initialization initialize each class member, as shown in the following example:
122
Extending BREW APIs
Other initialization Finally, any other initialization codes must come next before returning
from the function, as shown in the following example:
NOTE: In all cases, the function must increment the ISHELL and
IMODULE reference counts by one. This is reversed in the Release
function where ISHELL_Release() and IMODULE_Release() are called
to bring the reference counts back to the original number.
The C++ equivalent of the above class implementation is:
NOTE: This C++ illustration is for explanatory purposes only. You cannot
use C++ yet since there are issues with the ARM Compiler. We are
looking into these issues and will soon make this feature available.
123
Extending BREW APIs
Extension Usage
After all the work is done, another application can create an instance of the extension through
the ISHELL_CreateInstance() call. After this call is successfully completed, each function is
accessible through the macros defined in the header file. It is very important that the extension
be cleaned up by calling the Release function. The following example shows an extension
being called and released:
Macros
IEXTCLS_AddRef
Applet IEXTCLS_Release
IEXTCLS_DrawSmiley
ExtensionCls_AddRef()
{ IEXTCLS_DrawHello
…
}
IExtensionCls VTBL
ExtensionCls_AddRef()
{
AddRef
…
}
Release
ExtensionCls_AddRef()
{ DrawSmiley
…
} DrawHello
ExtensionCls_AddRef()
{
…
}
124
Using Visual Studio Add-Ins
Microsoft Visual Studio, also known as the Integrated Development Environment (IDE), is a
system requirement that must already be loaded on your PC before you can install the BREW
SDK. If you install the SDK before installing Visual Studio, you must reload the SDK for these
add-in to take effect.
The SDK includes free add-ins that automate some of the tasks you must perform in Visual
Studio to develop BREW applications.
In addition to saving you time and effort, the files you create using the AppWizard are highly
mobile. You can move your project from one location on your computer to another without
having to modify the project file (DSP) or the paths to the project’s INCLUDE statements.
125
Using Visual Studio Add-Ins
b. In Location, enter a new path to the directory where you want to store the files
for the project.
4. Click OK.
126
Using Visual Studio Add-Ins
5. Check the interfaces you want to include in your application. When the project file
is generated, the header files for the selected interfaces are included in your
project’s main source file.
6. Click Next.
127
Using Visual Studio Add-Ins
a. To create the MIF for your project at a later time, proceed to step 8.
b. To create a MIF for the project right now, click MIF Editor. See the BREW MIF
Editor Guide for instructions on creating the MIF.
When you have finished creating the MIF, close the MIF Editor window.
128
Using Visual Studio Add-Ins
9. When you have finished viewing the new project information, click OK.
The Microsoft Visual C++ window reopens with your new BREW application project
loaded in the workspace.
129
Using Visual Studio Add-Ins
10. You can now compile your project. However, if you have not already acquired a
BREW ClassID (BID) from the BREW web site and used it to create a MIF for the
project, one warning and one error will be generated. These disappear after you
create the MIF. See Sample 1: "Hello World" on page 66 for information on
including the BID.
NOTE: The ARM compiling add-in causes three new buttons (Generate ARM Makefile, BREW
MIF Editor, and BREW Resource Editor) to appear on the Visual Studio toolbar. Clicking these
buttons opens the associated applications. If these toolbar buttons are not on the toolbar when
you open Visual Studio, follow the procedure in step 2 below.
130
Using Visual Studio Add-Ins
2. If the new toolbar buttons do not appear on the Visual Studio toolbar), do the
following:
c. Select ARMMakeBREWApp.DSAddIn.1.
d. Click Close.
3. Click the Generate ARM Makefile toolbar button to generate the makefile.
A message box appears informing you that the makefile has been generated.
The output window opens and shows the files created from the compilation.
NOTE: If you choose arm make without having first created a makefile, the output
window displays: Fatal Error: Makefile Not Found. See the previous
procedure, To create a makefile for your application, for instructions.
To clean a makefile
1. If you have not done so already, load your application in a Visual Studio workspace.
Old object files are removed from the makefile, and the message panel shows the
files that were removed, such as the following:
131
Using Visual Studio Add-Ins
CLEAN
del /f AEEAppGen.o AEEModGen.o helloworld.o
del /f helloworld.elf
del /f helloworld.mod.
NOTE: If you choose arm clean without having first created a makefile, the output
window shows: Fatal Error: Makefile Not Found. See To create a makefile
for your application for instructions.
As shown below, a small, blue line to the left of the code points to the line of code
at which the error occurred.
2. If other errors are shown in the output window, repeat this process until all errors
have been corrected, and perform the compile again.
132
Appendix A: SDK Software
Backward Compatibility
This appendix describes SDK software compatibility issues you may need to be aware of if you
have downloaded multiple versions of the SDK software.
NOTE: For more information and late-breaking issues that may have arisen since this
document was updated, click Start > Programs > BREW > BREW ReadMe.
BREW Backward
Release Compatible With Comments
1.0.2.x 1.0.1.x Possible compilation errors can occur for applications written
in the 1.0.1 release that use the AEEClsCreateInstance()
function with IApplet** as the last parameter, instead of
void**. See the ReadMe file for details and a procedure for
fixing this problem.
133
Appendix A: SDK Software Backward Compatibility
BREW Backward
Release Compatible With Comments
134
Appendix B: Event Codes and
Key Codes
The following tables list the event codes and key codes supported by BREW.
Event codes
135
Appendix B: Event Codes and Key Codes
EVT_KEY_HELD Key held event. The hold time is wParam = key code (see Key
device-specific. Not supported codes table), dwParam = OEM-
in Emulator. specific.
136
Appendix B: Event Codes and Key Codes
Key codes
Key code Value Description
137
Appendix B: Event Codes and Key Codes
138
Appendix C: Problems and
Warning Messages
This appendix describes problems and error messages you might encounter while working in
the BREW SDK, along with probable causes and suggestions for solving the problems. The
appendix is divided into subsections, each describing troubleshooting for the various
components of the SDK, as shown in the following table.
139
Appendix C: Problems and Warning Messages
Emulator problems
The following problems are specific to the Emulator.
The device image is shown, but The MIF directory is wrong. From Tools > Settings or from
the device screen is blank. File > Change MIF Dir, change
the MIF directory.
The Emulator window is blank Device file is wrong. Possible From Tools > Settings or from
after startup or after changing causes for a wrong device file File > Load Device, change
settings or changing device. include: the device file.
• The screen object doesn't
exist.
• The screen is too small or
too big.
• The color depth is not one
of 1, 2, 4, 8.
While trying to play a MIDI or Possible causes include: First, make sure the file is
MP3 file, the file fails to run. • The file is not present. present and is of MIDI or MP3
format.
• The file is not MIDI or
MP3 format. Next, make sure the operating
• The operating system system is at least Windows NT
version is lower than 4.0-Service Pack 3 or Windows
Windows NT 4.0-Service 2000-Service Pack 2.
Pack 3 or Windows 2000- Finally, make sure the
Service Pack 2. computer has hardware and
• Multimedia capabilities software multimedia
are not present on the capabilities. To verify this,
computer. download and install Windows
• Multimedia software Media Player (version 6.4 and
components are not above for NT, or version 7.0
present in the operating and above for Windows 2000)
system. from the Microsoft web site,
then open and play Sample.mid
and Sample.mp3 under the
<BREW\Bin\DataFiles>
directory.
140
Appendix C: Problems and Warning Messages
Emulator messages
The following messages are Emulator-specific.
Failed to initialize The heap size specified in the Edit the device file using the
BREW. The heap size ... device file is smaller than what Configurator. Click Details in
(displayed when loading a BREW requires. Attribute View. The Device
device in the Emulator) Attributes dialog box opens.
Increase the heap size, click
OK, save the device, and
reopen in the Emulator.
Failed to initialize Device resource file (.qsc file) is First, make sure the device file
the device either corrupt or contains is in the same directory as the
(displayed when loading a invalid data. device resource file. If it is,
device in the Emulator) open the device resource file
using the Configurator. The
Configurator then fails to read
the file and returns an error
number.
Failed to write to the The BREW_Emu.dat file may Make sure the BREW_Emu.dat
settings file. be read-only. file is not read-only. The
(displayed in Emulator after BREW_Emu.dat file is under
clicking OK in Settings dialog Brew\Bin directory.
box)
There is no real size Either the screen width or Edit the device file using the
screen info height is 0 (zero). Configurator. Select the screen
(displayed when you choose and update the screen
View > Real Size Screen in the dimension, and then save the
Emulator) device and reopen it in the
Emulator.
Windows has not enough The heap size specified in the Change to another device that
memory... device file is bigger than what has a smaller heap size,
(displayed when loading a Windows can allocate. decrease heap size using the
device in the Emulator) Configurator, or close some
Windows applications.
141
Appendix C: Problems and Warning Messages
Applet-specific messages
The following messages are BREW applet-specific. These messages are displayed by IShell
on the device screen.
Digital service is The device does not have Ensure that the device is in a
required to use this digital service. digital coverage area.
feature.
Insufficient Memory There was not sufficient On the SDK, increase the
memory to load and execute memory size from the device
the application. configuration file.
On the device, restart the
phone.
Module failed to free The application did not free all Ensure the application does not
all memory. the memory it allocated during have memory leaks. You can
execution. run the application through a
standard tool such as "Purify" to
catch the exact locations of
memory leaks. Before running
"Purify," make sure to change
the device configuration to use
"Windows Heap."
This application has The applet subdirectory or the On the SDK, ensure that the
been unloaded to save applet module (.mod on the applet subdirectory exists and
memory. You must device and .DLL on the SDK) has the same name as the MIF.
download a new version. could not be found. Also, ensure that the applet
subdirectory contains the
applet DLL.
On the device, either download
the application again, or ensure
that the applet subdirectory and
applet module exist.
142
Appendix C: Problems and Warning Messages
This application has The allowed duration of use for Download the application to the
expired. the application has expired. device again.
Unable to start The application load procedure Debug the application to check
application. failed due to initialization errors. which of the initialization
or This can occur if one or more operations (mainly in
operations failed using the CreateInstance() and handling
Unknown Error
AEEClsCreateInstance() the APP_START event) failed.
function or during APP_START
event processing.
Configurator problems
When you select an object There are no more free virtual Make sure there are enough
Type of Screen or Key, you codes available. You have virtual codes available for the
are informed that the device created more objects than the created objects. Locate and delete
object cannot be created. total number of free virtual UNDEFINED objects in the
codes available. Created Device Objects list. See
the BREW Device Configurator
Guide for details.
In the device pane, the device The Windows Color Palette or Choose Control Panel > Display
image appears as black and the Number Of Colors field is > Settings. Set the Color Palette
white. set to less than or equal to 256 or Number Of Colors to more than
colors. 256 colors.
The device pane is blank and The main image file is blank, See if the image file is blank.
you cannot proceed further. or you did not specify an Specify the correct image file
image file when creating a when choosing a new file.
new project.
You cannot save the device There is a sharing violation or Check if the device file is used by
(or resource) file. other file permission some other application. Also
problems. check for its file permissions.
While you are creating an The object you are trying to Create objects that are within the
object in the device pane, the create intersects or overlaps device boundary and that are not
rectangle disappears. another object’s boundary intersecting or overlapping with
rectangle. any other objects.
143
Appendix C: Problems and Warning Messages
Configurator messages
Coordinates out of You entered a value in the In the device pane, select the
device boundary or Coordinates fields and one of object rectangle and use the
intersecting/over- the following problems exists: sizing handles to adjust it. If you
lapping with other need to add a value manually,
• The coordinates of the
objects. . . adjust the Coordinates fields in
object rectangle are
beyond the device the attribute pane.
boundary. The
coordinates of a device
object must always lie
within the device
boundary.
• The device object
intersects or overlaps
with some other device
object.
Error adding primary You tried to assign the primary Always make sure that there
code code for a key object and there are enough virtual codes
are no more free virtual codes available for the created
available. You have created objects. Locate UNDEFINED
more objects than the total objects (use the Created
number of free virtual codes Device Objects list) and delete
available. them. See the BREW Device
Configurator Guide for details.
Error adding virtual You tried to add an overload Do not assign more than five
code code for a key object when overload codes per key object.
there may be too many
overload codes. The
Configurator allows only five
overload codes per key object.
Fatal: Language type You tried to open the Device There is a problem with the
load error Attributes dialog box. binary. Contact BREW
technical support.
144
Appendix C: Problems and Warning Messages
Pushed Image file not You entered a pushed image Enter the correct image
found, wrong format or file that does not exist, is filename, or leave the field
same as Main Image file corrupted, or is the same as the blank (the pushed image file is
main image file. optional).
NOTE: The Configurator reads
and validates the pushed
image file.
Resource File read You tried to open a .qsc file or Make sure the main image file
error: <cause> load a new image file and one is in the same directory as the
of the following problems resource, and that it is a valid
exists: image.
• Configurator cannot find For all other errors, please
the main image file. contact BREW technical
• Main image file is invalid. support.
• One or more device We recommend that you
objects are out of the modify the device file using the
main image boundary. Configurator, not an editor.
• Configurator encountered
a fatal Windows GDI
resource allocation error.
• Configurator could not
open the device (or
resource) file.
• Configurator found an
invalid keyword in the
device file.
• Configurator found an
entry with insufficient
parameters in the device
file.
• Error setting locale.
• Unknown error.
The font that you have You selected the system font in Select another font; the system
selected is System the Font dialog box. font does not appear properly in
Font. It does not have the Emulator.
distinct Normal and
Bold characteristics.
Both Normal and Bold
will appear similar. Do
you want to continue
with this font?
145
Appendix C: Problems and Warning Messages
A required field is You left one or more required Enter a number in the required
empty. Please enter a fields empty. fields.
32-bit hexadecimal
number.
A required field was You left one or more required Enter text in the required fields.
left empty. Please text fields empty.
enter a string.
Are you sure you want to You attempted to use Local Use local ClassIDs for testing
generate a ClassID ClassIDs when submitting an only. Applications submitted
locally? application for BREW using a local ClassID will not
certification. pass BREW certification.
Checking "Show on In the Advanced Applet dialog If you choose Show on Config
Config Menu" and/or box, you selected Show on Menu or Show on Hidden
"Show on Hidden Config Config Menu or Show on Config Menu, specify a Menu
Menu" requires a Menu Hidden Config Menu, without String.
String. specifying a Menu String.
"Menu String" needs to In the Advanced Applet dialog If you enter a menu string, you
be associated with box, you entered a menu string, must choose Show on Config
"Show on Config Menu" but did not choose Show on Menu and/or Show on Hidden
and/or "Show on Hidden Config Menu and/or Show on Config Menu.
Config Menu". Please Hidden Config Menu.
check the applicable.
The file <name> does not The filename you entered Verify that the file exists and
exist. cannot be found. that you spelled the name
correctly.
The MIF file you Version incompatibility. See Appendix A: SDK Software
attempted to open was Backward Compatibility on
produced by an page 133 for a list of backward-
incompatible version of compatible versions and
the MIF Editor and issues.
cannot be opened.
The value cannot be You entered zero in a field that Enter a value, other than 0
zero. Please enter a must be non-zero. (zero).
non-zero 32-bit
hexadecimal number.
146
Appendix C: Problems and Warning Messages
You must either specify You added a new notification Specify either a custom or
a system class or a without specifying a custom or system class notification when
custom class system class notification. adding a new notification.
notification type.
You must have at least A MIF must contain at least one Specify at least one applet or
one class or applet applet to be saved. class in the MIF and try saving
defined. it again.
An error occurred while This error can occur if the BRI open error:
trying to save the Resource Editor was unable to • If the BRI file is corrupt,
resource file .... open a BRI file, or if the re-create the file.
Resource Editor could not save
• Make sure the file is not
a resource file for one or more
read-only.
of the following reasons:
• Ensure that your PC has
• The file is read-only. sufficient disk space.
• Not enough disk space is • Check the file’s
available to create the permission and sharing
file. settings.
• There is a sharing
Save error:
problem or other file
permission problems. • Make sure the file is in a
• An unknown error format recognized by the
Resource Editor.
occurred.
• Check the file’s
permission and sharing
settings.
For all other errors, please
contact BREW technical
support.
Could not open the "..." The file could not be opened. If the file is read-only, remove
file. Make sure it is that attribute so that it can be
not marked as Read- opened successfully.
Only.
147
Appendix C: Problems and Warning Messages
The control ID in which You are attempting to set initial Make sure that the specified
you wish to set initial focus to a control in a dialog control ID is shown in the
focus is not valid for that does not exist in that Dialog Controls list.
this dialog. Please dialog.
choose a control ID that
exists within this
dialog box.
The control resource ID The ID you specified for the Choose a unique ID. By default
you specified is resource type already exists. the Resource Editor
already used by another automatically generates the ID.
control. Please choose
a unique control
resource ID.
The dialog resource ID The ID you specified for the Choose a unique ID. By default
you specified is resource type already exists. the Resource Editor
already used by another automatically generates the ID.
dialog. Please choose a
unique dialog resource
ID.
The file does not The extension is missing on the Make sure the image file has
contain any extension image file. The image type the correct extension. For
and hence the Image Type cannot be determined, because example, a bitmap file should
(MIME Type) cannot be the image type (MIME type) is have a .bmp extension.
determined. based on the extension.
The image resource ID The ID you specified for the Choose a unique ID. By default
you specified is resource type already exists. the Resource Editor
already used by another automatically generates the ID.
image. Please choose a
unique image resource
ID.
148
Appendix C: Problems and Warning Messages
The image you have This warning describes the Change the size of the selected
selected is 80 pixels details of the selected image image or select another image
wide, 80 pixels tall, and identifies the dimensions of that is within the size restriction.
and has 8 bits/pixel. a typical image resource.
Typically, image
resources are less than If an image size is larger that
150 pixels wide, 150 the screen size on the phone,
pixels tall, and have 1 the image is clipped.
bit(s)/pixel.
The list item resource The ID you specified for the Choose a unique ID. By default
ID you specified is resource type already exists. the Resource Editor
already used by another automatically generates the ID.
list item. Please
choose a unique list
item resource ID.
The resource file that BREW version incompatibility. See Appendix A: SDK Software
you are opening is from Backward Compatibility on
a previous version of page 133 for version
the application. The compatibility issues.
file will automatically
be upgraded to the
format of the current
version when it is
saved. If you do not
wish to upgrade the
format of the file then
select File->Save As
and save the file as a
different filename.
The resource name you The ID you specified for the Choose a unique ID. By default
specified is already resource type already exists. the Resource Editor
used by another automatically generates the ID.
resource. Please
choose a unique
resource name.
The string resource ID The ID you specified for the Choose a unique ID. By default
you specified is resource type already exists. the Resource Editor
already used by another automatically generates the ID.
string. Please choose a
unique string resource
ID.
149
Appendix C: Problems and Warning Messages
The version of the file BREW version incompatibility. See Appendix A: SDK Software
you are opening was Backward Compatibility on
created with a version page 133 for version
of the application that compatibility issues.
is not compatible with
this version. You will
need to obtain an
updated version of this
application in order to
open this file.
You must enter a You have not entered a Enter a valid resource name.
resource name for this resource name for the dialog
dialog. resource.
You must enter a You have not entered a Enter the requested resource
resource name for this resource name for the image name.
image. resource.
You must enter a You have not entered a Enter the requested resource
resource name for this resource name for the list item name.
list item. resource.
You must enter a You have not entered a Enter the requested resource
resource name for this resource name for the string name.
string. resource.
You must enter a string You have not entered a string Enter a valid string.
for this resource ID. for this string resource
You must enter an ID for You have not entered an ID Enter a valid ID number.
this dialog resource. number for the dialog resource.
You must enter an ID for You have not entered an ID for Enter the requested ID number.
this image resource. the image resource.
You must enter an ID for You have not entered an ID for Enter the requested ID number.
this string resource. the string resource.
150
Appendix C: Problems and Warning Messages
You must have at least There are no string resources You must specify at least one
one string resource for in your resource file. string per dialog.
your dialog box(es)
You must specify a You entered an invalid path or Enter a valid path and filename.
path\filename of a filename for the image file.
valid image.
151
Index
A C
Acronyms used in this manual, 11 Case sensitivity of paths on PC and device, 25
Add-ins Changing
Application Wizard, 125 applet directory, 100
automated ARM compiling, 130 application source code, 107
Visual Studio, 125 MIF directory, 101
AEE Class
headers, 33 creating, 36
IBase class, 49 defining, 120
model, 29 methods of defining, 121
API ClassIDs
extensions, 119 applet, 36
interfaces, 30 assigning to applets or classes, 34
Applets interface, 34
changing directory, 100 Cleaning a make file, 131
ClassIDs for, 36 Color support in the BREW Emulator, 104
configuring in the Emulator, 109 Compilation errors, finding and fixing, 132
creating, 37 Controls
directory on SDK, 23 dialog, 92
events passed to, 50 using, 89
overview, 32 Conventions, documentation, 9
processing events for, 37 Creating
resuming, 38 applets, 37
suspending, 38 applications, 40
Application classes, 36
certifying, 30 dialogs, 89, 91
creating new, 40 instances, 36
developing with BREW, 28 make file for application, 131
source code, viewing and editing, 107
Application Manager, configuring applets
with, 108
D
Application Wizard add-in Database management sample application, 85
description of, 125 Defining
files created with, 130 class methods, 121
Authentication, developer, 30 classes, 120
Automated ARM compiling, 130 Device
configuring for speed emulation, 112
directory, 20
B files, 20
Backward compatibility of SDK software, 133 selecting, 100
Bin directory, 20 Device Attributes dialog box, error on
Bitmaps directory, 20 opening, 144
Device Configurator, description of, 17
Device file
cannot save, 143
error on opening, 145
152
Index
153
Index
P System
requirements, 16
Paths, entering on PC and device, 25 resources, language-specific, 41
Primary code, error assigning a code, 144 startup, 33
Printing in online manuals, 10
Processing applet events, 37
Programming concepts, 32 T
Project, creating with Application Wizard, 125 TAPI emulation
Pushed image file, error when loading, 145 calls outgoing from a BREW application, 117
description, 103
R incoming calls to BREW, 114
incoming SMS messages, 115
Readme directory, 20 Terminating dialogs, 93
Requesting new BREW features, 15 Timers and alarms sample application, 79
Resource directory, 24 Tuning speed emulation parameters, 103, 113
Resource Editor, description of, 17
Resuming an applet, 38
U
S Usage applications, defined, 22, 105
Sample application
code for general applications, 54 V
code for incoming SMS messages, 40 Virtual code, error when selecting, 144
Hello World, 66 Virtual function table initialization, 122
resource management, 71 Visual Studio add-ins
running, 105 Application Wizard, 125
shipped with SDK, 22 automated ARM compiling, 130
using databases, 85
using files, 83
using sockets, 88
W
using timers and alarms, 79 Web site, BREW, 15
Screen object
error when creating, 143, 144
rectangle disappears, 143
Screen size, setting in Emulator, 102
Searching within online manuals, 10
Selecting a device, 100
Shared modules, 28
Shell services, 48
SMS messages
directed, 39
monitoring, 39, 115
sample code, 40
Socket sample application, 88
Software, backward compatibility, 133
Sound files, 109
Speed emulation
configuring devices for, 112
enabling, 103
SpeedTune, downloading and running, 112
Src directory, 20
Starting the BREW Emulator, 97
Static modules, 49
Suspending an applet, 38
154