Application and Window Management
Total Page:16
File Type:pdf, Size:1020Kb
QNX® SDK for Apps and Media 1.0 QNX® SDK for Apps and Media 1.0 Application and Window Management ©2014, QNX Software Systems Limited, a subsidiary of BlackBerry Limited. All rights reserved. QNX Software Systems Limited 1001 Farrar Road Ottawa, Ontario K2K 0B3 Canada Voice: +1 613 591-0931 Fax: +1 613 591-3579 Email: [email protected] Web: http://www.qnx.com/ QNX, QNX CAR, Momentics, Neutrino, and Aviage are trademarks of BlackBerry Limited, which are registered and/or used in certain jurisdictions, and used under license by QNX Software Systems Limited. All other trademarks belong to their respective owners. Electronic edition published: Wednesday, September 24, 2014 Application and Window Management Table of Contents About This Guide .......................................................................................................................5 Typographical conventions .................................................................................................6 Technical support .............................................................................................................8 Chapter 1: Packaging, Installing, and Launching Apps ...................................................................9 Packaging an HTML5 app for installation ..........................................................................10 Packaging a native C/C++ app for installation ....................................................................11 Installing a packaged app on the target .............................................................................12 Launching an app on the target ........................................................................................13 Stopping all apps on the target ........................................................................................14 Uninstalling Apps ...........................................................................................................15 Chapter 2: Application Launcher (launcher) ................................................................................17 Chapter 3: Authorization Manager (authman) ..............................................................................19 Chapter 4: Creating Your Own Application Window Manager .........................................................23 Application management .................................................................................................24 Launcher control object (/pps/services/launcher/control) ............................................24 Interacting with the /pps/services/launcher/control object ..........................................26 Starting an application ..........................................................................................28 Stopping an application .........................................................................................29 Window management ......................................................................................................30 Set up Screen ......................................................................................................30 Handle Screen events ............................................................................................33 An example of a simple application window manager .........................................................37 struct.h ................................................................................................................37 main.c .................................................................................................................39 screen.c ...............................................................................................................41 launcher.c ............................................................................................................54 pps.c ...................................................................................................................55 core.c ...................................................................................................................59 Table of Contents About This Guide Application and Window Management describes the process of starting/stopping applications and explains how windows interact with the HMI. The guide also explains how to write your own window manager. This guide is intended for developers who will be creating and deploying apps for embedded devices running QNX Neutrino. The following table may help you find information quickly: To find out about: Go to: Packaging an HTML5 app Packaging an HTML5 app for installation (p. 10) Packaging a native C/C++ app Packaging a native C/C++ app for installation (p. 11) Installing an app on your target Installing a packaged app on the target (p. 12) Launching an app Launching an app on the target (p. 13) Stopping apps Stopping all apps on the target (p. 14) Removing apps from your target Uninstalling Apps (p. 15) The launcher service Application Launcher (p. 17) Access control Authorization Manager (p. 19) How to manage your applications Creating Your Own Application Window Manager (p. 23) For instructions on how to create apps, see the following: • HTML5 Developer's Guide • IDE User's Guide © 2014, QNX Software Systems Limited 5 About This Guide Typographical conventions Throughout this manual, we use certain typographical conventions to distinguish technical terms. In general, the conventions we use conform to those found in IEEE POSIX publications. The following table summarizes our conventions: Reference Example Code examples if( stream == NULL) Command options -lR Commands make Constants NULL Data types unsigned short Environment variables PATH File and pathnames /dev/null Function names exit() Keyboard chords Ctrl–Alt–Delete Keyboard input Username Keyboard keys Enter Program output login: Variable names stdin Parameters parm1 User-interface components Navigator Window title Options We use an arrow in directions for accessing menu items, like this: You'll find the Other... menu item under Perspective ➝ Show View. We use notes, cautions, and warnings to highlight important messages: Notes point out something important or useful. Cautions tell you about commands or procedures that may have unwanted or undesirable side effects. 6 © 2014, QNX Software Systems Limited Typographical conventions Warnings tell you about commands or procedures that could be dangerous to your files, your hardware, or even yourself. Note to Windows users In our documentation, we typically use a forward slash (/) as a delimiter in pathnames, including those pointing to Windows files. We also generally follow POSIX/UNIX filesystem conventions. © 2014, QNX Software Systems Limited 7 About This Guide Technical support Technical assistance is available for all supported products. To obtain technical support for any QNX product, visit the Support area on our website (www.qnx.com). You'll find a wide range of support options, including community forums. 8 © 2014, QNX Software Systems Limited Chapter 1 Packaging, Installing, and Launching Apps Before you can install an app on your target, you must first package it. Packaging is the process of creating a compressed archive of all the files that comprise your app. The tools you use will differ, depending on the type of app you're packaging. For any type of app, you need to specify: • the app's resources • the services the app needs to access on the target You then run the approprate packaging tool, which produces the final BAR (BlackBerry ARchive) file (.bar) that you'll install on your target. Note that the format of a BAR file is essentially RAR, so you can use an extractor tool such as WinRAR to view the contents of any .bar file. When your app is packaged as a .bar file, you copy it to your target, where you can install and launch it. © 2014, QNX Software Systems Limited 9 Packaging, Installing, and Launching Apps Packaging an HTML5 app for installation To create a .bar file for an HTML5 app, you run the Cordova build script that was included in your app when you ran create. Because you don't need to sign your .bar file, you can run the build script in debug mode. To create a .bar file that can be deployed to your target: 1. Navigate to the directory that contains your app's files. This is the directory you specified when you ran the create command. 2. Ensure that all the resources and permissions your application needs are specified in the config.xml file. The create command produces a basic config.xml file that defines the properties of the app and specifies the features and functionality the app can access. Depending on the features you add to your app, you may need to edit this file. 3. Change to the cordova directory. 4. Run the build command: build --debug After you run the build command, you'll fiel the .bar file for your app in these two directories: • /build/device • build/simulator For instructions on creating a simple HTML5 app using Cordova, see “Creating an HTML5 app” in the HTML5 Developer's Guide. For instructions on installing the app on your target, see “Installing a packaged app on the target (p. 12)”. 10 © 2014, QNX Software Systems Limited Packaging a native C/C++ app for installation Packaging a native C/C++ app for installation To create a .bar file for a native C/C++ app, you run the blackberry-nativepackager. The blackberry-nativepackager creates a .bar file that includes all of your app's resources as well as the following key components: • app descriptor file, which includes capabilities specified in <action> elements (bar-descriptor.xml).