Browse files

update NDK-Samples next to NDK 2.0 Beta 3

  • Loading branch information...
1 parent 92d8ab4 commit bb08f0702196e2c702408aaa4ae99467ff953e9e @jhoffmannrim jhoffmannrim committed Jan 18, 2012
View
6 .gitignore
@@ -25,6 +25,9 @@ AudioControl/arm/o.le-v7-g/AudioControl
AudioControl/arm/o.le-v7/AudioControl
AudioControl/x86/o-g/AudioControl
AudioControl/x86/o/AudioControl
+Channels/arm/o.le-v7-g/Channels
+Channels/arm/o.le-v7/Channels
+Channels/x86/o-g/Channels
CubeRotate/arm/o.le-v7-g/CubeRotate
CubeRotate/arm/o.le-v7/CubeRotate
CubeRotate/x86/o-g/CubeRotate
@@ -97,3 +100,6 @@ VideoPlayback/arm/o.le-v7-g/VideoPlayback
VideoPlayback/arm/o.le-v7/VideoPlayback
VideoPlayback/x86/o-g/VideoPlayback
VideoPlayback/x86/o/VideoPlayback
+VideoWindow/arm/o.le-v7-g/VideoWindow
+VideoWindow/arm/o.le-v7/VideoWindow
+VideoWindow/x86/o-g/VideoWindow
View
92 AudioControl/main.c
@@ -109,7 +109,8 @@ main(int argc, char *argv[])
bps_initialize();
if (setup_screen() != EXIT_SUCCESS) {
- printf("Unable to set up the screen. Exiting.");
+ fprintf(stderr, "Unable to set up the screen. Exiting.");
+ bps_shutdown();
return 0;
}
@@ -119,50 +120,63 @@ main(int argc, char *argv[])
* Navigator service manages and delivers application life cycle and
* visibility events.
* For this sample, we request Navigator events so that we can track when
- * the system is terminating the application (NAVIGATOR_EXIT event) as well as
- * Audio Mixer events so we can be notified when audio values is updated
+ * the system is terminating the application (NAVIGATOR_EXIT event) as well
+ * as Dialog events so we can show a dialog and Audio Mixer events so we can
+ * be notified when audio values are updated.
*/
- navigator_request_events(0);
- audiomixer_request_events(0);
- dialog_request_events(0);
-
+ if (BPS_FAILURE == navigator_request_events(0)) {
+ fprintf(stderr, "Unable to request navigator events. Exiting.");
+ cleanup_screen();
+ bps_shutdown();
+ return 0;
+ }
+ if (BPS_FAILURE == dialog_request_events(0)) {
+ fprintf(stderr, "Unable to request dialog events. Exiting.");
+ cleanup_screen();
+ bps_shutdown();
+ return 0;
+ }
/*
* Create and display the dialog.
*/
create_dialog();
- /*
- * Retrieve and display the current audio mixer status
- */
- float headphone_volume;
- audiomixer_get_output_level(AUDIOMIXER_OUTPUT_HEADPHONE, &headphone_volume);
- float speaker_volume;
- audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &speaker_volume);
- float input_gain;
- audiomixer_get_input_level(AUDIOMIXER_INPUT, &input_gain);
-
- bool is_headphone_muted;
- audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_HEADPHONE, &is_headphone_muted);
- bool is_speaker_muted;
- audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_SPEAKER, &is_speaker_muted);
- bool is_input_muted;
- audiomixer_get_input_mute(AUDIOMIXER_INPUT, &is_input_muted);
-
- char tmp[MSG_SIZE];
- snprintf(msg, MSG_SIZE, "Audio Mixer Status\n");
- snprintf(tmp, MSG_SIZE, "Headphone Volume: %f\n", headphone_volume);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Speaker Volume: %f\n", speaker_volume);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Input Gain: %f\n", input_gain);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Headphone Muted: %s\n", bool_str(is_headphone_muted));
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Speaker Muted: %s\n", bool_str(is_speaker_muted));
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Input Muted: %s\n\n", bool_str(is_input_muted));
- strlcat(msg, tmp, MSG_SIZE);
- show_dialog_message(msg);
+ if (BPS_FAILURE == audiomixer_request_events(0)) {
+ show_dialog_message("Unable to request audio mixer events.");
+ } else {
+ /*
+ * Retrieve and display the current audio mixer status
+ */
+ float headphone_volume;
+ audiomixer_get_output_level(AUDIOMIXER_OUTPUT_HEADPHONE, &headphone_volume);
+ float speaker_volume;
+ audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &speaker_volume);
+ float input_gain;
+ audiomixer_get_input_level(AUDIOMIXER_INPUT, &input_gain);
+
+ bool is_headphone_muted;
+ audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_HEADPHONE, &is_headphone_muted);
+ bool is_speaker_muted;
+ audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_SPEAKER, &is_speaker_muted);
+ bool is_input_muted;
+ audiomixer_get_input_mute(AUDIOMIXER_INPUT, &is_input_muted);
+
+ char tmp[MSG_SIZE];
+ snprintf(msg, MSG_SIZE, "Audio Mixer Status\n");
+ snprintf(tmp, MSG_SIZE, "Headphone Volume: %f\n", headphone_volume);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Speaker Volume: %f\n", speaker_volume);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Input Gain: %f\n", input_gain);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Headphone Muted: %s\n", bool_str(is_headphone_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Speaker Muted: %s\n", bool_str(is_speaker_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Input Muted: %s\n\n", bool_str(is_input_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ show_dialog_message(msg);
+ }
/*
* Process Audio Mixer and Navigator events until we receive a NAVIGATOR_EXIT
View
179 Channels/.cproject
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="com.qnx.qcc.toolChain.2124598740">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.2124598740" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" id="com.qnx.qcc.toolChain.2124598740" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="com.qnx.qcc.toolChain.2124598740.352006086" name="/" resourcePath="">
+ <toolChain id="com.qnx.qcc.toolChain.297555076" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
+ <option id="com.qnx.qcc.option.os.76130292" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
+ <option id="com.qnx.qcc.option.cpu.1931122950" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
+ <option id="com.qnx.qcc.option.compiler.1326212100" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
+ <option id="com.qnx.qcc.option.runtime.726182661" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
+ <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1747223826" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
+ <builder id="com.qnx.qcc.toolChain.2124598740.1639495028" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="com.qnx.qcc.tool.compiler.1461970417" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
+ <option id="com.qnx.qcc.option.compiler.includePath.278798242" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
+ </option>
+ <inputType id="com.qnx.qcc.inputType.compiler.536915679" superClass="com.qnx.qcc.inputType.compiler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.assembler.1921399862" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
+ <inputType id="com.qnx.qcc.inputType.assembler.1321732829" superClass="com.qnx.qcc.inputType.assembler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.linker.351581766" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
+ <tool id="com.qnx.qcc.tool.archiver.869235712" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="com.qnx.qcc.toolChain.557690265">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.557690265" moduleId="org.eclipse.cdt.core.settings" name="Device-Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" id="com.qnx.qcc.toolChain.557690265" name="Device-Debug" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="com.qnx.qcc.toolChain.557690265.388570424" name="/" resourcePath="">
+ <toolChain id="com.qnx.qcc.toolChain.75998354" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
+ <option id="com.qnx.qcc.option.os.1874326858" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
+ <option id="com.qnx.qcc.option.cpu.1030458870" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
+ <option id="com.qnx.qcc.option.compiler.1030003814" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
+ <option id="com.qnx.qcc.option.runtime.1366270443" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
+ <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1559614187" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
+ <builder id="com.qnx.qcc.toolChain.557690265.1674217891" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="com.qnx.qcc.tool.compiler.1094930453" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
+ <option id="com.qnx.qcc.option.compiler.includePath.1932489235" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
+ </option>
+ <inputType id="com.qnx.qcc.inputType.compiler.1239363662" superClass="com.qnx.qcc.inputType.compiler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.assembler.2068988498" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
+ <inputType id="com.qnx.qcc.inputType.assembler.36475887" superClass="com.qnx.qcc.inputType.assembler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.linker.1208745666" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
+ <tool id="com.qnx.qcc.tool.archiver.1568287025" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="com.qnx.qcc.toolChain.922493807">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.922493807" moduleId="org.eclipse.cdt.core.settings" name="Device-Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" id="com.qnx.qcc.toolChain.922493807" name="Device-Release" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="com.qnx.qcc.toolChain.922493807.718680689" name="/" resourcePath="">
+ <toolChain id="com.qnx.qcc.toolChain.2117570715" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
+ <option id="com.qnx.qcc.option.os.1510141013" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
+ <option id="com.qnx.qcc.option.cpu.1576465665" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
+ <option id="com.qnx.qcc.option.compiler.1459101260" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
+ <option id="com.qnx.qcc.option.runtime.325341556" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
+ <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.512607580" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
+ <builder id="com.qnx.qcc.toolChain.922493807.1420686315" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="com.qnx.qcc.tool.compiler.581894373" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
+ <option id="com.qnx.qcc.option.compiler.includePath.854296484" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
+ </option>
+ <inputType id="com.qnx.qcc.inputType.compiler.902038706" superClass="com.qnx.qcc.inputType.compiler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.assembler.1156350308" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
+ <inputType id="com.qnx.qcc.inputType.assembler.626072260" superClass="com.qnx.qcc.inputType.assembler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.linker.765707219" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
+ <tool id="com.qnx.qcc.tool.archiver.1656052272" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="com.qnx.qcc.toolChain.2065693308">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.2065693308" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildProperties="" id="com.qnx.qcc.toolChain.2065693308" name="Simulator-Debug" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="com.qnx.qcc.toolChain.2065693308.2120762762" name="/" resourcePath="">
+ <toolChain id="com.qnx.qcc.toolChain.1099183171" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
+ <option id="com.qnx.qcc.option.os.1194097270" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
+ <option id="com.qnx.qcc.option.cpu.1544969817" name="Target CPU:" superClass="com.qnx.qcc.option.cpu"/>
+ <option id="com.qnx.qcc.option.compiler.553751577" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
+ <option id="com.qnx.qcc.option.runtime.1246873770" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
+ <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1284120619" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
+ <builder id="com.qnx.qcc.toolChain.2065693308.470583494" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+ <tool id="com.qnx.qcc.tool.compiler.1427699051" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
+ <option id="com.qnx.qcc.option.compiler.includePath.310709821" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
+ <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
+ </option>
+ <inputType id="com.qnx.qcc.inputType.compiler.1409512783" superClass="com.qnx.qcc.inputType.compiler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.assembler.1907699789" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
+ <inputType id="com.qnx.qcc.inputType.assembler.1764433086" superClass="com.qnx.qcc.inputType.assembler"/>
+ </tool>
+ <tool id="com.qnx.qcc.tool.linker.2142192344" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
+ <tool id="com.qnx.qcc.tool.archiver.1538049504" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="Channels.null.1533570678" name="Channels"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
+ <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.2124598740">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.557690265">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.922493807">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.2065693308">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="com.qnx.tools.ide.qde.core.QNXProjectProperties"/>
+ <storageModule moduleId="refreshScope"/>
+</cproject>
View
84 Channels/.project
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Channels</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
+ </natures>
+</projectDescription>
View
203 Channels/LICENSE
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
View
8 Channels/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)
View
5 Channels/NOTICE
@@ -0,0 +1,5 @@
+Channels
+Copyright (c) 2011 Research In Motion Limited.
+
+This product includes software developed at
+Research In Motion Limited (http://www.rim.com/).
View
8 Channels/arm/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)
View
1 Channels/arm/o.le-v7-g/Makefile
@@ -0,0 +1 @@
+include ../../common.mk
View
1 Channels/arm/o.le-v7/Makefile
@@ -0,0 +1 @@
+include ../../common.mk
View
101 Channels/bar-descriptor.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<qnx xmlns="http://www.qnx.com/schemas/application/1.0">
+
+<!-- BlackBerry Tablet OS application descriptor file.
+
+ Specifies parameters for identifying, installing, and launching native applications on BlackBerry Tablet OS.
+
+-->
+
+ <!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications.
+ Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
+ <id>com.example.Channels</id>
+
+ <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
+ May have multiple values for each language. See samples or xsd schema file. Optional. -->
+ <name>Channels</name>
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+ Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
+ An updated version of application must have a versionNumber value higher than the previous version. Required. -->
+ <versionNumber>1.0.0</versionNumber>
+
+ <!-- Fourth digit segment of the package version. First three segments are taken from the
+ <versionNumber> element. Must be an integer from 0 to 2^16-1 -->
+ <buildId>1</buildId>
+
+ <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
+ <!-- <versionLabel></versionLabel> -->
+
+ <!-- Description, displayed in the BlackBerry Tablet OS application installer.
+ May have multiple values for each language. See samples or xsd schema file. Optional. -->
+ <description>The Channels application</description>
+
+ <!-- Copyright information. Optional. -->
+ <!-- <copyright></copyright> -->
+
+ <!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
+ <author>Example Inc.</author>
+ <splashscreen>sample-splashscreen-landscape.png:sample-splashscreen-portrait.png</splashscreen>
+
+ <!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
+ <!-- <authorId>ABC1234YjsnUk235h</authorId> -->
+
+ <initialWindow>
+ <aspectRatio>landscape</aspectRatio>
+ <autoOrients>false</autoOrients>
+ <systemChrome>none</systemChrome>
+ <transparent>false</transparent>
+ </initialWindow>
+
+ <!-- The category where the application appears. Either core.games or core.media. -->
+ <category>core.games</category>
+ <asset path="icon.png">icon.png</asset>
+ <asset path="sample-splashscreen-landscape.png">sample-splashscreen-landscape.png</asset>
+ <asset path="sample-splashscreen-portrait.png">sample-splashscreen-portrait.png</asset>
+ <asset path="LICENSE">LICENSE</asset>
+ <asset path="NOTICE">NOTICE</asset>
+ <configuration id="com.qnx.qcc.toolChain.2124598740" name="Default">
+ <platformArchitecture>armle-v7</platformArchitecture>
+ <asset path="arm/o.le-v7-g/Channels" entry="true" type="Qnx/Elf">Channels</asset>
+ </configuration>
+ <configuration id="com.qnx.qcc.toolChain.557690265" name="Device-Debug">
+ <platformArchitecture>armle-v7</platformArchitecture>
+ <asset path="arm/o.le-v7-g/Channels" entry="true" type="Qnx/Elf">Channels</asset>
+ </configuration>
+ <configuration id="com.qnx.qcc.toolChain.922493807" name="Device-Release">
+ <platformArchitecture>armle-v7</platformArchitecture>
+ <asset path="arm/o.le-v7/Channels" entry="true" type="Qnx/Elf">Channels</asset>
+ </configuration>
+ <configuration id="com.qnx.qcc.toolChain.2065693308" name="Simulator-Debug">
+ <platformArchitecture>x86</platformArchitecture>
+ <asset path="x86/o-g/Channels" entry="true" type="Qnx/Elf">Channels</asset>
+ </configuration>
+
+ <!-- The icon for the application, which should be 86x86. -->
+ <icon>
+ <image>icon.png</image>
+ </icon>
+
+ <!-- The splash screen that will appear when your application is launching. Should be 1024x600. -->
+ <!-- <splashscreen></splashscreen> -->
+
+ <!-- Request permission to execute native code. Required for native applications. -->
+ <action system="true">run_native</action>
+ <action>read_geolocation</action>
+
+ <!-- The permissions requested by your application. -->
+ <!-- <action>access_shared</action> -->
+ <!-- <action>record_audio</action> -->
+ <!-- <action>read_geolocation</action> -->
+ <!-- <action>use_camera</action> -->
+ <!-- <action>access_internet</action> -->
+ <!-- <action>play_audio</action> -->
+ <!-- <action>post_notification</action> -->
+ <!-- <action>set_audio_volume</action> -->
+ <!-- <action>read_device_identifying_information</action> -->
+
+ <!-- Ensure that shared libraries in the package are found at run-time. -->
+ <env var="LD_LIBRARY_PATH" value="app/native/lib"/>
+
+</qnx>
View
36 Channels/common.mk
@@ -0,0 +1,36 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+USEFILE=
+
+include $(MKFILES_ROOT)/qmacros.mk
+
+# Suppress the _g suffix from the debug variant
+BUILDNAME=$(IMAGE_PREF_$(BUILD_TYPE))$(NAME)$(IMAGE_SUFF_$(BUILD_TYPE))
+
+# Extra include path libfreetype and for target overrides and patches
+EXTRA_INCVPATH+=$(QNX_TARGET)/usr/include/freetype2 \
+ $(QNX_TARGET)/../target-override/usr/include
+
+# Extra library search path for target overrides and patches
+EXTRA_LIBVPATH+=$(QNX_TARGET)/../target-override/$(CPUVARDIR)/lib \
+ $(QNX_TARGET)/../target-override/$(CPUVARDIR)/usr/lib
+
+# Compiler options for enhanced security
+CCFLAGS+=-fstack-protector-all -D_FORTIFY_SOURCE=2 \
+ $(if $(filter g so shared,$(VARIANTS)),,-fPIE)
+
+# Linker options for enhanced security
+LDFLAGS+=-Wl,-z,relro -Wl,-z,now $(if $(filter g so shared,$(VARIANTS)),,-pie)
+
+# Basic libraries required by most native applications
+LIBS+=bps pps screen
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+OPTIMIZE_TYPE_g=none
+OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS)))
+
+-include $(PROJECT_ROOT)/../samples.mk
View
187 Channels/dialogutil.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <screen/screen.h>
+#include <bps/bps.h>
+#include <bps/dialog.h>
+#include <bps/navigator.h>
+#include "dialogutil.h"
+
+static screen_context_t screen_ctx = 0;
+static screen_window_t screen_win = 0;
+static dialog_instance_t top_dialog = 0;
+static dialog_instance_t bottom_dialog = 0;
+
+
+/**
+ * Use the PID to set the window group id.
+ */
+static char *
+get_window_group_id()
+{
+ static char s_window_group_id[16] = "";
+
+ if (s_window_group_id[0] == '\0') {
+ snprintf(s_window_group_id, sizeof(s_window_group_id), "%d", getpid());
+ }
+
+ return s_window_group_id;
+}
+
+int
+setup_screen()
+{
+ if (screen_create_context(&screen_ctx, SCREEN_APPLICATION_CONTEXT) != 0) {
+ return EXIT_FAILURE;
+ }
+
+ //Signal BPS library that navigator orientation is to be locked
+ if (BPS_SUCCESS != navigator_rotation_lock(true)) {
+ screen_destroy_context(screen_ctx);
+ return EXIT_FAILURE;
+ }
+
+ if (screen_create_window(&screen_win, screen_ctx) != 0) {
+ screen_destroy_context(screen_ctx);
+ return EXIT_FAILURE;
+ }
+
+ int usage = SCREEN_USAGE_NATIVE;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
+
+ int size[2];
+ if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
+
+ screen_display_t screen_disp;
+ screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
+
+ screen_display_mode_t screen_mode;
+ if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
+
+ int buffer_size[2] = {size[0], size[1]};
+
+ int angle = atoi(getenv("ORIENTATION"));
+ if ((angle == 0) || (angle == 180)) {
+ if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
+ ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else if ((angle == 90) || (angle == 270)){
+ if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
+ ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else {
+ goto fail;
+ }
+
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+
+ if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
+
+ if (screen_create_window_group(screen_win, get_window_group_id()) != 0) goto fail;
+
+ screen_buffer_t buff;
+ if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void*)&buff) != 0) goto fail;
+
+ int attribs[1] = {SCREEN_BLIT_END};
+ if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
+
+ int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
+
+ return EXIT_SUCCESS;
+
+fail:
+ perror(NULL);
+ cleanup_screen();
+ return EXIT_FAILURE;
+}
+
+
+void cleanup_screen() {
+ screen_destroy_window(screen_win);
+ screen_destroy_context(screen_ctx);
+ screen_win = 0;
+ screen_ctx = 0;
+}
+
+
+
+void
+create_dialogs()
+{
+ if (bottom_dialog == NULL) {
+ dialog_create_alert(&bottom_dialog);
+ dialog_set_alert_message_text(bottom_dialog, "\n");
+ dialog_set_background_alpha(bottom_dialog, 0.0);
+ dialog_set_size(bottom_dialog, DIALOG_SIZE_SMALL);
+ dialog_set_position(bottom_dialog, DIALOG_POSITION_BOTTOM_CENTER);
+ dialog_set_group_id(bottom_dialog, get_window_group_id());
+ dialog_set_cancel_required(bottom_dialog, true);
+ dialog_show(bottom_dialog);
+ }
+
+ if (top_dialog == NULL) {
+ dialog_create_alert(&top_dialog);
+ dialog_set_alert_message_text(top_dialog, "\n");
+ dialog_set_background_alpha(top_dialog, 0.0);
+ dialog_set_size(top_dialog, DIALOG_SIZE_SMALL);
+ dialog_set_position(top_dialog, DIALOG_POSITION_TOP_CENTER);
+ dialog_set_group_id(top_dialog, get_window_group_id());
+ dialog_set_cancel_required(top_dialog, true);
+ dialog_show(top_dialog);
+ }
+
+}
+
+void
+destroy_dialogs() {
+ if (top_dialog) {
+ dialog_destroy(top_dialog);
+ }
+ top_dialog = 0;
+
+ if (bottom_dialog) {
+ dialog_destroy(bottom_dialog);
+ }
+ bottom_dialog = 0;
+
+}
+
+void
+show_top_dialog_message(const char * msg) {
+ dialog_set_alert_message_text(top_dialog, msg);
+ dialog_update(top_dialog);
+ fprintf(stderr, "%s\n", msg);
+}
+
+
+
+void
+show_bottom_dialog_message(const char * msg) {
+ dialog_set_alert_message_text(bottom_dialog, msg);
+ dialog_update(bottom_dialog);
+ fprintf(stderr, "%s\n", msg);
+
+}
View
62 Channels/dialogutil.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef DIALOGUTIL_H_
+#define DIALOGUTIL_H_
+
+/**
+ * Set up a basic screen, so that the navigator will send window state events
+ * when the window state changes.
+ *
+ * @return @c EXIT_SUCCESS or @c EXIT_FAILURE
+ */
+int setup_screen();
+
+/**
+ * Clean up all the resources that were allocated by setup_screen().
+ */
+void cleanup_screen();
+
+/**
+ * Show two alert dialogs that will output general data.
+ */
+void create_dialogs();
+
+/**
+ * Destroy dialogs that were created by create_dialogs.
+ */
+void destroy_dialogs();
+
+/**
+ * Displays a message to the top dialog created by create_dialogs() and
+ * outputs that message to stderr. This means it will get added
+ * to the log file in the sandbox and output to the console.
+ *
+ * @param msg the message to be displayed.
+ */
+void show_top_dialog_message(const char *msg);
+
+/**
+ * Displays a message to the bottom dialog created by create_dialogs() and
+ * outputs that message to stderr. This means it will get added
+ * to the log file in the sandbox and output to the console.
+ *
+ * @param msg the message to be displayed.
+ */
+void show_bottom_dialog_message(const char *msg);
+
+#endif /* DIALOGUTIL_H_ */
View
BIN Channels/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
356 Channels/main.c
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Sample showing how to use BlackBerry Native APIs for channels to
+ * allow different threads to handle events from different services.
+ *
+ * Note that the main purpose of this sample is to show channels working
+ * with services. Please see the Accelerometer sample and the Geolocation
+ * sample for a better understanding of how to use the accelerometer and
+ * geolocation services.
+ *
+ */
+
+#include <bps/bps.h>
+#include <bps/dialog.h>
+#include <bps/geolocation.h>
+#include <bps/navigator.h>
+#include <bps/sensor.h>
+#include <pthread.h>
+#include <screen/screen.h>
+#include <errno.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "dialogutil.h"
+
+#define MSG_SIZE 1024
+
+/**
+ * Microseconds between accelerometer reads.
+ */
+static const int ACCELEROMETER_RATE = 25000;
+
+/**
+ * Event code to tell the accelerometer thread to stop processing events.
+ */
+static const int STOP_REQUEST = 1;
+
+/**
+ * The channel ID for the channel that will handle accelerometer events.
+ */
+static int accel_chid = -1;
+
+/**
+ * A place to store the requested event domain
+ */
+static int local_event_domain;
+
+/**
+ * a buffer to store messages that will be passed to the dialog.
+ */
+static char msg[MSG_SIZE];
+
+pthread_mutex_t chidMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t chidCond = PTHREAD_COND_INITIALIZER;
+
+/**
+ * Print the Accelerometer reading.
+ *
+ * @param x The g-force along the x-axis.
+ * @param y The g-force along the y-axis.
+ * @param z The g-force along the z-axis.
+ */
+static void
+display_accelerometer_reading(float x, float y, float z)
+{
+ char accel_msg[MSG_SIZE];
+ /*
+ * Display the accelerometer values
+ */
+ snprintf(accel_msg, MSG_SIZE, "x: %f, y: %f, z: %f\n", x, y, z);
+ show_bottom_dialog_message(accel_msg);
+}
+
+/**
+ * Handle a navigator event.
+ *
+ * @return @c true if application should exit, else false.
+ */
+static bool
+handle_navigator_event(bps_event_t *event)
+{
+ bool should_exit = false;
+
+ switch (bps_event_get_code(event)) {
+ case NAVIGATOR_EXIT:
+ should_exit = true;
+ break;
+ }
+
+ return should_exit;
+}
+
+/**
+ * Handle a geolocation response.
+ *
+ * @param event The event containing geolocation data.
+ */
+static void
+handle_geolocation_response(bps_event_t *event)
+{
+ static int count = 0;
+
+ /*
+ * Double check that the event is valid.
+ */
+ if (event == NULL || bps_event_get_code(event) != GEOLOCATION_INFO) {
+ return;
+ }
+
+ double latitude = geolocation_event_get_latitude(event);
+ double longitude = geolocation_event_get_longitude(event);
+ double accuracy = geolocation_event_get_accuracy(event);
+
+ snprintf(msg, MSG_SIZE,
+ "Geolocation report #%d\n"
+ "\tlatitude: % 13.8f degrees\n"
+ "\tlongitude: % 13.8f degrees\n"
+ "\taccuracy: % 7.3f m\n",
+ count,
+ latitude, longitude, accuracy);
+
+ show_top_dialog_message(msg);
+ count++;
+}
+
+/**
+ * Thread that handles accelerometer events and
+ * sends relevant information to a dialog.
+ *
+ * @param p Unused.
+ */
+static void *
+accel_main (void *p) {
+ bool run = true;
+ bps_event_t *event;
+ float force_x, force_y, force_z;
+
+ bps_initialize();
+
+ /*
+ * Each thread that calls bps_initialize() will have its
+ * own unique channel ID. Protect it inside a mutex and
+ * condition variable to avoid race condition where main
+ * thread tries to use it before we assign it.
+ */
+ pthread_mutex_lock(&chidMutex);
+ accel_chid = bps_channel_get_active();
+ pthread_cond_signal(&chidCond);
+ pthread_mutex_unlock(&chidMutex);
+
+ if (BPS_SUCCESS != sensor_request_events(SENSOR_TYPE_ACCELEROMETER)) {
+ fprintf(stderr, "Error requesting sensor's accelerometer events: %s", strerror(errno));
+ bps_shutdown();
+ return NULL;
+ }
+
+ sensor_set_rate(SENSOR_TYPE_ACCELEROMETER, ACCELEROMETER_RATE);
+ sensor_set_skip_duplicates(SENSOR_TYPE_ACCELEROMETER, true);
+
+ while (run) {
+ /*
+ * Block, at the very least we'll get the "STOP" event
+ */
+ bps_get_event(&event, -1);
+ if (bps_event_get_domain(event) == local_event_domain) {
+ if (bps_event_get_code(event) == STOP_REQUEST) {
+ run = false;
+ }
+ }
+
+ if (bps_event_get_domain(event) == sensor_get_domain()) {
+ if (SENSOR_ACCELEROMETER_READING == bps_event_get_code(event)) {
+ sensor_event_get_xyz(event, &force_x, &force_y, &force_z);
+ display_accelerometer_reading(force_x, force_y, force_z);
+ }
+ }
+ }
+
+ sensor_stop_events(0);
+
+ bps_shutdown();
+
+ fprintf(stderr, "Exiting accelerometer thread\n");
+ return NULL;
+
+
+}
+
+/**
+ * The main entry point.
+ */
+int
+main(int argc, char *argv[])
+{
+ pthread_t accel_thread;
+
+ bool exit_application = false;
+ int rc;
+
+ /*
+ * Before we can listen for events from the BlackBerry Tablet OS platform
+ * services, we need to initialize the BPS infrastructure
+ */
+ bps_initialize();
+
+ /*
+ * Initialize the screen so that the window group Id is properly set,
+ * to allow the dialogs to be displayed.
+ */
+ if (setup_screen() != EXIT_SUCCESS) {
+ fprintf(stderr, "Unable to initialize screen.");
+ exit(-1);
+ }
+
+ /*
+ * Once the BPS infrastructure has been initialized we can register for
+ * events from the various BlackBerry Tablet OS platform services. The
+ * Navigator service manages and delivers application life cycle and
+ * visibility events.
+ *
+ * We register a custom event domain so that we can communicate with the
+ * the accelerometer thread. We will need to tell it to quit once we get
+ * the NAVIGATOR_EXIT.
+ *
+ * We request Navigator events so that we can track when the system is
+ * terminating the application (NAVIGATOR_EXIT event).
+ *
+ */
+ local_event_domain = bps_register_domain();
+ if (local_event_domain == -1) {
+ fprintf(stderr, "Error registering custom event domain: %s", strerror(errno));
+ exit(-1);
+ }
+ if (BPS_SUCCESS != navigator_request_events(0)) {
+ fprintf(stderr, "Error requesting navigator events: %s", strerror(errno));
+ exit(-1);
+ }
+ if (BPS_SUCCESS != dialog_request_events(0)) {
+ fprintf(stderr, "Error requesting dialog events: %s", strerror(errno));
+ exit(-1);
+ }
+ if (BPS_SUCCESS != geolocation_request_events(0)) {
+ fprintf(stderr, "Error requesting geolocation events: %s", strerror(errno));
+ exit(-1);
+ }
+
+ geolocation_set_period(1);
+
+ /*
+ * Create and display the dialogs that will show the data.
+ */
+ create_dialogs();
+ show_top_dialog_message("Geolocation getting first fix");
+ show_bottom_dialog_message("This is the Accelerometer Dialog");
+
+ /*
+ * Before initializing the accelerometer service we must ensure the device
+ * supports it.
+ */
+ if (!sensor_is_supported(SENSOR_TYPE_ACCELEROMETER)) {
+ /**
+ * If the device does not support accelerometer then notify the user,
+ * clean up and exit
+ */
+ snprintf(msg, MSG_SIZE, "Accelerometer not supported by device!");
+ show_top_dialog_message(msg);
+
+ /*
+ * Destroy the dialog, if it exists and cleanup screen resources.
+ */
+ destroy_dialogs();
+ cleanup_screen();
+ bps_shutdown();
+ return EXIT_FAILURE;
+ }
+
+ /*
+ * Create the accelerometer event thread.
+ */
+ rc = pthread_create(&accel_thread, NULL, accel_main, NULL);
+ if (rc != 0) {
+ fprintf(stderr, "Error in pthread_create: %s", strerror(errno));
+ exit(-1);
+ }
+
+ while (!exit_application) {
+ /*
+ * Using a negative timeout (-1) in the call to bps_get_event(...)
+ * ensures that we don't busy wait by blocking until an event is
+ * available.
+ */
+ bps_event_t *event = NULL;
+ bps_get_event(&event, -1);
+
+ if (event) {
+ if (bps_event_get_domain(event) == geolocation_get_domain()) {
+ handle_geolocation_response(event);
+ }
+ else if (bps_event_get_domain(event) == navigator_get_domain()) {
+ exit_application = handle_navigator_event(event);
+ }
+ }
+ }
+
+ geolocation_stop_events(0);
+
+ /*
+ * Avoid a possible race condition where accel_chid has not yet
+ * been assigned a valid channel ID.
+ */
+ pthread_mutex_lock(&chidMutex);
+ while (accel_chid == -1) {
+ pthread_cond_wait(&chidCond, &chidMutex);
+ }
+ pthread_mutex_unlock(&chidMutex);
+
+ bps_event_t *stop_request_event = NULL;
+
+ if (BPS_SUCCESS != bps_event_create(&stop_request_event, local_event_domain, STOP_REQUEST, NULL, NULL)) {
+ fprintf(stderr, "Unable to create event: %s", strerror(errno));
+ exit(-1);
+ }
+
+ if (BPS_SUCCESS != bps_channel_push_event(accel_chid, stop_request_event)) {
+ fprintf(stderr, "Unable to push event: %s", strerror(errno));
+ }
+
+ pthread_join(accel_thread, NULL);
+
+ /*
+ * Destroy the dialogs, if they exist.
+ */
+ destroy_dialogs();
+
+ bps_shutdown();
+ cleanup_screen();
+
+ return 0;
+}
View
58 Channels/manifest.properties
@@ -0,0 +1,58 @@
+#
+# Project template manifest file. This provides input to the New Project Wizard
+# to direct the creation of a project from a template.
+#
+# This file is a Java properties file. The properties supported are:
+#
+# template.name - [required] The succinct name of the project template shown in the wizard
+# template.description - [required] A brief description of the project template
+# project.name - [required] The name of the example project that is created
+# icon - [optional] The icon file to generate and list in the bar-descriptor.xml.
+# Should be named "icon.png"
+# splashscreen.landscape - [optional] The landscape splashscreen image.
+# splashscreen.portrait - [optional] The portrait splashscreen image.
+# actions - [optional] Space-delimited list of the permissions required (actions performed)
+# by the application. The "run_native" action is implicit.
+# open.file - [Optional] The file to open in an editor when the project creation
+# is finished. Usually the bar-descriptor.xml (which is not in the
+# example storage folder!)
+# libs - [required] The libraries to which to link the project binary. Space-separated list.
+# sources - [required] The source files to add to the project. Space-separated list.
+# resources - [optional] Other non-source files to add to the project. Space-separated list.
+# readmes - [optional] Read-me files to add to the project but not packaged in the BAR.
+# Space-separated list.
+#
+# For the 'sources' and 'resources' lists, additional properties may optionally be defined
+# that map the files to destination paths in the project. Depending on the kind of project
+# that is created, these may be relative to some directory or other within the project (e.g.,
+# a 'src/' directory.
+#
+# These properties consist of 'path.' appended by the source file name. For example:
+#
+# resources: some-file.xml other-file.xml
+# path.some-file.xml: resources/config/main.xml
+# path.other-file.xml: resources/misc/stuff.xml
+#
+
+template.name: BlackBerry Tablet OS Example Channels Project
+template.description: Combine elements of Geolocation and Accelerometer sample application to show how to use Channels.
+
+project.name: Channels
+
+icon: icon.png
+splashscreen.landscape: sample-splashscreen-landscape.png
+splashscreen.portrait: sample-splashscreen-portrait.png
+
+open.file: bar-descriptor.xml
+
+libs: bps pps screen
+
+sources: main.c dialogutil.c dialogutil.h
+
+resources: LICENSE NOTICE
+
+readmes: readme.txt
+
+orientation: landscape
+
+actions: read_geolocation
View
44 Channels/readme.txt
@@ -0,0 +1,44 @@
+Channels - Display current location data
+
+========================================================================
+Sample Description:
+
+ The Channels application demonstrates how to two different threads can
+ communicate by sending events through channels.
+
+ We retrieve and display geolocation specific information, such as
+ the latitude, longitude, altitude, and bearing of the tablet from
+ the default channel of the main thread. This thread also listens
+ for the navigator's event telling it to exit. Before joining on the
+ child thread, it sends a custom event to the child thread's channel
+ letting it know that it should exit.
+
+ We retrieve and display the x, y and z values of the accelerometer
+ device of the tablet from the default channel of the child thread.
+
+ When the application is executed, geolocation data is displayed in a
+ dialog and accelerometer data is displayed in another.
+
+ Feature summary
+ - Requesting events from different channels
+ - Multiple dialogs
+
+========================================================================
+Requirements:
+
+ - BlackBerry Native SDK for Tablet OS 2.0 or later
+ - One of the following:
+ - BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
+ - BlackBerry Tablet Simulator 2.0 or later
+
+========================================================================
+Importing a project into the Native SDK:
+
+ 1. From the the Sample apps page, download and extract the sample application.
+ 2. Launch the Native SDK.
+ 3. On the File menu, click Import.
+ 4. Expand General, and select Existing Projects into Workspace. Click Next.
+ 5. Browse to the location where you extracted the sample app, and click OK.
+ The sample project should display in the the Projects section.
+ 6. Click Finish to import the project into your workspace.
+
View
BIN Channels/sample-splashscreen-landscape.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Channels/sample-splashscreen-portrait.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 Channels/x86/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)
View
1 Channels/x86/o-g/Makefile
@@ -0,0 +1 @@
+include ../../common.mk
View
4 OpenGLES11Template/manifest.properties
@@ -50,8 +50,6 @@ libs: bps pps screen EGL GLESv1_CM freetype png
sources: bbutil.h bbutil.c main.c
-# these are not needed for a template
-#resources: LICENSE NOTICE
-#readmes: readme.txt
+readmes: readme.txt
#actions:
View
5 ScreenTemplate/manifest.properties
@@ -50,7 +50,6 @@ libs: bps pps screen m
sources: main.c
-# these are not needed for a template
-#resources: LICENSE NOTICE
-#readmes: readme.txt
+readmes: readme.txt
+
#actions:
View
2 VideoWindow/manifest.properties
@@ -45,7 +45,7 @@ splashscreen.portrait: sample-splashscreen-portrait.png
open.file: bar-descriptor.xml
-libs: bps screen mmrndclient strm
+libs: bps EGL GLESv1_CM screen mmrndclient strm
sources: src/main.c

0 comments on commit bb08f07

Please sign in to comment.