Skip to content
Browse files

Merge pull request #19 from mdwoolley/master

Please commit new application
  • Loading branch information...
2 parents 861bea3 + 80cb982 commit b9d7118c8725c4ec37cfd90698ac23a2667cd3a6 @timwindsor timwindsor committed Aug 15, 2012
Showing with 3,057 additions and 0 deletions.
  1. +7 −0 NFC/TouchTicTacToe/.classpath
  2. +29 −0 NFC/TouchTicTacToe/.project
  3. +3 −0 NFC/TouchTicTacToe/.settings/net.rim.browser.tools.debug.widget.prefs
  4. +12 −0 NFC/TouchTicTacToe/.settings/org.eclipse.jdt.core.prefs
  5. +23 −0 NFC/TouchTicTacToe/BlackBerry_App_Descriptor.xml
  6. +43 −0 NFC/TouchTicTacToe/README.md
  7. BIN NFC/TouchTicTacToe/bin/img/blank_clicked_160x120.png
  8. BIN NFC/TouchTicTacToe/bin/img/blank_clicked_213x160.png
  9. BIN NFC/TouchTicTacToe/bin/img/blank_focus_160x120.png
  10. BIN NFC/TouchTicTacToe/bin/img/blank_focus_213x160.png
  11. BIN NFC/TouchTicTacToe/bin/img/blank_unfocus_160x120.png
  12. BIN NFC/TouchTicTacToe/bin/img/blank_unfocus_213x160.png
  13. BIN NFC/TouchTicTacToe/bin/img/board_480x360.png
  14. BIN NFC/TouchTicTacToe/bin/img/board_640x480.png
  15. BIN NFC/TouchTicTacToe/bin/img/cross_clicked_160x120.png
  16. BIN NFC/TouchTicTacToe/bin/img/cross_clicked_213x160.png
  17. BIN NFC/TouchTicTacToe/bin/img/cross_focus_160x120.png
  18. BIN NFC/TouchTicTacToe/bin/img/cross_focus_213x160.png
  19. BIN NFC/TouchTicTacToe/bin/img/cross_unfocus_160x120.png
  20. BIN NFC/TouchTicTacToe/bin/img/cross_unfocus_213x160.png
  21. BIN NFC/TouchTicTacToe/bin/img/icon.png
  22. BIN NFC/TouchTicTacToe/bin/img/icon2.png
  23. BIN NFC/TouchTicTacToe/bin/img/icon3.png
  24. BIN NFC/TouchTicTacToe/bin/img/icon4.png
  25. BIN NFC/TouchTicTacToe/bin/img/new_game_480x360.png
  26. BIN NFC/TouchTicTacToe/bin/img/new_game_640x480.png
  27. BIN NFC/TouchTicTacToe/bin/img/nought_clicked_160x120.png
  28. BIN NFC/TouchTicTacToe/bin/img/nought_clicked_213x160.png
  29. BIN NFC/TouchTicTacToe/bin/img/nought_focus_160x120.png
  30. BIN NFC/TouchTicTacToe/bin/img/nought_focus_213x160.png
  31. BIN NFC/TouchTicTacToe/bin/img/nought_unfocus_160x120.png
  32. BIN NFC/TouchTicTacToe/bin/img/nought_unfocus_213x160.png
  33. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/Constants.class
  34. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/TouchTicTacToe.class
  35. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/Utilities.class
  36. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/ChooseCrossCommand.class
  37. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/ChooseNoughtCommand.class
  38. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/SelectTileCommand.class
  39. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/game/GameState.class
  40. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/game/GameStateChangeListener.class
  41. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/NfcReceiver.class
  42. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/NfcSender.class
  43. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/SnepCallBack.class
  44. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/GameMessageProcessor.class
  45. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/GameProtocol.class
  46. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessage.class
  47. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageMasterBid.class
  48. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageResetBidState.class
  49. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageTurnOver.class
  50. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MsbConfig.class
  51. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MsbState.class
  52. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MultiStateButtonField.class
  53. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/BitmapFactory.class
  54. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$1.class
  55. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$2.class
  56. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$3.class
  57. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen.class
  58. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/StartGameScreen$1.class
  59. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/StartGameScreen.class
  60. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/SymbolSelectionScreen$1.class
  61. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/SymbolSelectionScreen.class
  62. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TileChangedListener.class
  63. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$1.class
  64. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$2.class
  65. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$3.class
  66. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField.class
  67. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig.class
  68. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig480x360.class
  69. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig640x480.class
  70. BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfigFactory.class
  71. BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe-1.debug
  72. BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.cod
  73. +1 −0 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.csl
  74. +5 −0 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.cso
  75. BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.debug
  76. +19 −0 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.jad
  77. BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.jar
  78. +10 −0 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.rapc
  79. +31 −0 NFC/TouchTicTacToe/deliverables/Standard/TouchTicTacToe.alx
  80. BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe-1.cod
  81. BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe-1.debug
  82. BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.cod
  83. +1 −0 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.csl
  84. +5 −0 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.cso
  85. BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.debug
  86. +19 −0 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.jad
  87. BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.jar
  88. +10 −0 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.rapc
  89. BIN NFC/TouchTicTacToe/res/img/blank_clicked_160x120.png
  90. BIN NFC/TouchTicTacToe/res/img/blank_clicked_213x160.png
  91. BIN NFC/TouchTicTacToe/res/img/blank_focus_160x120.png
  92. BIN NFC/TouchTicTacToe/res/img/blank_focus_213x160.png
  93. BIN NFC/TouchTicTacToe/res/img/blank_unfocus_160x120.png
  94. BIN NFC/TouchTicTacToe/res/img/blank_unfocus_213x160.png
  95. BIN NFC/TouchTicTacToe/res/img/board_480x360.png
  96. BIN NFC/TouchTicTacToe/res/img/board_640x480.png
  97. BIN NFC/TouchTicTacToe/res/img/cross_clicked_160x120.png
  98. BIN NFC/TouchTicTacToe/res/img/cross_clicked_213x160.png
  99. BIN NFC/TouchTicTacToe/res/img/cross_focus_160x120.png
  100. BIN NFC/TouchTicTacToe/res/img/cross_focus_213x160.png
  101. BIN NFC/TouchTicTacToe/res/img/cross_unfocus_160x120.png
  102. BIN NFC/TouchTicTacToe/res/img/cross_unfocus_213x160.png
  103. BIN NFC/TouchTicTacToe/res/img/icon.png
  104. BIN NFC/TouchTicTacToe/res/img/icon2.png
  105. BIN NFC/TouchTicTacToe/res/img/icon3.png
  106. BIN NFC/TouchTicTacToe/res/img/icon4.png
  107. BIN NFC/TouchTicTacToe/res/img/new_game_480x360.png
  108. BIN NFC/TouchTicTacToe/res/img/new_game_640x480.png
  109. BIN NFC/TouchTicTacToe/res/img/nought_clicked_160x120.png
  110. BIN NFC/TouchTicTacToe/res/img/nought_clicked_213x160.png
  111. BIN NFC/TouchTicTacToe/res/img/nought_focus_160x120.png
  112. BIN NFC/TouchTicTacToe/res/img/nought_focus_213x160.png
  113. BIN NFC/TouchTicTacToe/res/img/nought_unfocus_160x120.png
  114. BIN NFC/TouchTicTacToe/res/img/nought_unfocus_213x160.png
  115. +55 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/Constants.java
  116. +35 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/TouchTicTacToe.java
  117. +62 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/Utilities.java
  118. +49 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/ChooseCrossCommand.java
  119. +48 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/ChooseNoughtCommand.java
  120. +45 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/SelectTileCommand.java
  121. +352 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/game/GameState.java
  122. +21 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/game/GameStateChangeListener.java
  123. +46 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/NfcReceiver.java
  124. +64 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/NfcSender.java
  125. +59 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/SnepCallBack.java
  126. +26 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/GameMessageProcessor.java
  127. +125 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/GameProtocol.java
  128. +61 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessage.java
  129. +64 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageMasterBid.java
  130. +47 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageResetBidState.java
  131. +72 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageTurnOver.java
  132. +33 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/tiles/MsbConfig.java
  133. +103 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/tiles/MsbState.java
  134. +169 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/tiles/MultiStateButtonField.java
  135. +87 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/BitmapFactory.java
  136. +564 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/GameScreen.java
  137. +133 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/StartGameScreen.java
  138. +140 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/SymbolSelectionScreen.java
  139. +20 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/TileChangedListener.java
  140. +102 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/TimedLabelField.java
  141. +38 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/UiConfig.java
  142. +94 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/UiConfig480x360.java
  143. +93 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/UiConfig640x480.java
  144. +32 −0 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/UiConfigFactory.java
View
7 NFC/TouchTicTacToe/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="res"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/net.rim.ejde.BlackBerryVMInstallType/BlackBerry JRE 7.1.0"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
29 NFC/TouchTicTacToe/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TouchTicTacToe</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>net.rim.ejde.internal.builder.BlackBerryPreprocessBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.rim.ejde.internal.builder.BlackBerryResourcesBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>net.rim.ejde.BlackBerryPreProcessNature</nature>
+ <nature>net.rim.ejde.BlackBerryProjectCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
3 NFC/TouchTicTacToe/.settings/net.rim.browser.tools.debug.widget.prefs
@@ -0,0 +1,3 @@
+#Tue Jul 03 14:17:25 BST 2012
+eclipse.preferences.version=1
+outputfolder=build
View
12 NFC/TouchTicTacToe/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Tue Jul 03 14:15:38 BST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.source=1.3
View
23 NFC/TouchTicTacToe/BlackBerry_App_Descriptor.xml
@@ -0,0 +1,23 @@
+<!-- This file has been generated by the BlackBerry Plugin for Eclipse v3.6.1. -->
+
+<Properties ModelVersion="1.1.2">
+ <General Title="" Version="1.0.0" Vendor="BlackBerry Developer" Description=""/>
+ <Application Type="BlackBerry Application" MainMIDletName="" MainArgs="" HomeScreenPosition="0" StartupTier="7" IsSystemModule="false" IsAutostartup="false"/>
+ <Resources hasTitleResource="false" TitleResourceBundleName="" TitleResourceBundleRelativePath="" TitleResourceBundleClassName="" TitleResourceBundleKey="" DescriptionId="">
+ <Icons>
+ <Icon CanonicalFileName="res/img/icon4.png" IsFocus="false"/>
+ </Icons>
+ </Resources>
+ <KeywordResources KeywordResourceBundleName="" KeywordResourceBundleRelativePath="" KeywordResourceBundleClassName="" KeywordResourceBundleKey=""/>
+ <Compile OutputCompilerMessages="false" ConvertImages="true" CreateWarningForNoExportedRoutine="true" CompressResources="false" AliasList="">
+ <PreprocessorDefines/>
+ </Compile>
+ <Packaging PreBuildStep="" PostBuildStep="" CleanStep="" OutputFileName="TouchTicTacToe" OutputFolder="deliverables" GenerateALXFile="true">
+ <AlxFiles/>
+ </Packaging>
+ <HiddenProperties>
+ <ClassProtection/>
+ <PackageProtection/>
+ </HiddenProperties>
+ <AlternateEntryPoints/>
+</Properties>
View
43 NFC/TouchTicTacToe/README.md
@@ -0,0 +1,43 @@
+# TouchTicTacToe
+
+
+The purpose of this application is to demonstrate "Proximity Gaming". Proximity Gaming is a term coined by Martin Woolley of Research In Motion for the use
+of Near Field Communications in multi-player games. See http://devblog.blackberry.com/ for a blog post on this subject.
+
+The sample code for this application is Open Source under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
+
+**Applies To**
+
+* [BlackBerry Java SDK for Smartphones](http://us.blackberry.com/developers/javaappdev/)
+
+
+**Author**
+
+* [Martin Woolley](https://github.com/mdwoolley)
+
+
+**Dependencies**
+
+1. BlackBerry Device Software 7.1 and above.
+
+
+**Known Issues**
+
+None
+
+**To contribute code to this repository you must be [signed up as an official contributor](http://blackberry.github.com/howToContribute.html).**
+
+
+## Contributing Changes
+
+Please see the [README](https://github.com/blackberry/BlackBerry-Java) of the BlackBerry-Java repository for instructions on how to add new Samples or make modifications to existing Samples.
+
+
+## Bug Reporting and Feature Requests
+
+If you find a bug in a Sample, or have an enhancement request, simply file an [Issue](https://github.com/blackberry/BlackBerry-Java/issues) for the Sample and send a message (via github messages) to the Sample Author(s) to let them know that you have filed an [Issue](https://github.com/blackberry/BlackBerry-Java/issues).
+
+
+## Disclaimer
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
BIN NFC/TouchTicTacToe/bin/img/blank_clicked_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/blank_clicked_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/blank_focus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/blank_focus_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/blank_unfocus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/blank_unfocus_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/board_480x360.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/board_640x480.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_clicked_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_clicked_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_focus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_focus_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_unfocus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/cross_unfocus_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/icon2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/icon3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/icon4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/new_game_480x360.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/new_game_640x480.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_clicked_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_clicked_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_focus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_focus_213x160.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_unfocus_160x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN NFC/TouchTicTacToe/bin/img/nought_unfocus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/Constants.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/TouchTicTacToe.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/Utilities.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/ChooseCrossCommand.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/ChooseNoughtCommand.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/commands/SelectTileCommand.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/game/GameState.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/game/GameStateChangeListener.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/NfcReceiver.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/NfcSender.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/nfc/SnepCallBack.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/GameMessageProcessor.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/GameProtocol.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessage.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageMasterBid.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageResetBidState.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/protocol/ProtocolMessageTurnOver.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MsbConfig.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MsbState.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/tiles/MultiStateButtonField.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/BitmapFactory.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$1.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$2.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen$3.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/GameScreen.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/StartGameScreen$1.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/StartGameScreen.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/SymbolSelectionScreen$1.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/SymbolSelectionScreen.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TileChangedListener.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$1.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$2.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField$3.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/TimedLabelField.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig480x360.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfig640x480.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/bin/nfc/sample/tictactoe/ui/UiConfigFactory.class
Binary file not shown.
View
BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe-1.debug
Binary file not shown.
View
BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.cod
Binary file not shown.
View
1 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.csl
@@ -0,0 +1 @@
+52525400=RIM Runtime API
View
5 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.cso
@@ -0,0 +1,5 @@
+33000000=RIMAPPSA2
+52424200=RIM Blackberry Apps API
+52434900=RIM Crypto API - Internal
+52435200=RIM Crypto API - RIM
+4e464352=NFCRoutingAPI
View
BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.debug
Binary file not shown.
View
19 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.jad
@@ -0,0 +1,19 @@
+MIDlet-Name: TouchTicTacToe
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: TouchTicTacToe.jar
+MIDlet-Jar-Size: 247594
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon4.png,
+RIM-MIDlet-Flags-1: 0
+Manifest-Version: 1.0
+RIM-COD-URL: TouchTicTacToe.cod
+RIM-COD-Size: 61640
+RIM-COD-Creation-Time: 1345031668
+RIM-COD-Module-Name: TouchTicTacToe
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_nfc
+RIM-COD-SHA1: 45 d2 72 b1 bb 88 15 da 61 ec 96 29 3f b0 41 ea a5 a7 ab f9
+RIM-COD-URL-1: TouchTicTacToe-1.cod
+RIM-COD-Size-1: 23668
+RIM-COD-SHA1-1: ea 05 58 83 38 07 b6 4f 85 f5 ee 48 ac 5d e6 0f 04 5f ee e9
View
BIN NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.jar
Binary file not shown.
View
10 NFC/TouchTicTacToe/deliverables/Standard/7.1.0/TouchTicTacToe.rapc
@@ -0,0 +1,10 @@
+MIDlet-Name: TouchTicTacToe
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: TouchTicTacToe.jar
+MIDlet-Jar-Size: 0
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon4.png,
+RIM-MIDlet-Flags-1: 0
+
View
31 NFC/TouchTicTacToe/deliverables/Standard/TouchTicTacToe.alx
@@ -0,0 +1,31 @@
+<loader version="1.0">
+ <application id="TouchTicTacToe">
+ <name >
+
+ </name>
+ <description >
+
+ </description>
+ <version >
+ 1.0.0
+ </version>
+ <vendor >
+ BlackBerry Developer
+ </vendor>
+ <copyright >
+ Copyright (c) 2012 BlackBerry Developer
+ </copyright>
+ <fileset Java="1.54" _blackberryVersion="[7.1.0)">
+ <directory >
+ 7.1.0
+ </directory>
+ <files >
+ TouchTicTacToe.cod
+
+ </files>
+
+ </fileset>
+
+ </application>
+
+</loader>
View
BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe-1.cod
Binary file not shown.
View
BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe-1.debug
Binary file not shown.
View
BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.cod
Binary file not shown.
View
1 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.csl
@@ -0,0 +1 @@
+52525400=RIM Runtime API
View
5 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.cso
@@ -0,0 +1,5 @@
+33000000=RIMAPPSA2
+52424200=RIM Blackberry Apps API
+52434900=RIM Crypto API - Internal
+52435200=RIM Crypto API - RIM
+4e464352=NFCRoutingAPI
View
BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.debug
Binary file not shown.
View
19 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.jad
@@ -0,0 +1,19 @@
+MIDlet-Name: TouchTicTacToe
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: TouchTicTacToe.jar
+MIDlet-Jar-Size: 247594
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon4.png,
+RIM-MIDlet-Flags-1: 0
+Manifest-Version: 1.0
+RIM-COD-URL: TouchTicTacToe.cod
+RIM-COD-Size: 61640
+RIM-COD-Creation-Time: 1345031668
+RIM-COD-Module-Name: TouchTicTacToe
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_nfc
+RIM-COD-SHA1: 45 d2 72 b1 bb 88 15 da 61 ec 96 29 3f b0 41 ea a5 a7 ab f9
+RIM-COD-URL-1: TouchTicTacToe-1.cod
+RIM-COD-Size-1: 23668
+RIM-COD-SHA1-1: ea 05 58 83 38 07 b6 4f 85 f5 ee 48 ac 5d e6 0f 04 5f ee e9
View
BIN NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.jar
Binary file not shown.
View
10 NFC/TouchTicTacToe/deliverables/Web/7.1.0/TouchTicTacToe.rapc
@@ -0,0 +1,10 @@
+MIDlet-Name: TouchTicTacToe
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: TouchTicTacToe.jar
+MIDlet-Jar-Size: 0
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon4.png,
+RIM-MIDlet-Flags-1: 0
+
View
BIN NFC/TouchTicTacToe/res/img/blank_clicked_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/blank_clicked_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/blank_focus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/blank_focus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/blank_unfocus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/blank_unfocus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/board_480x360.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/board_640x480.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_clicked_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_clicked_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_focus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_focus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_unfocus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/cross_unfocus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/icon.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/icon2.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/icon3.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/icon4.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/new_game_480x360.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/new_game_640x480.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_clicked_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_clicked_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_focus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_focus_213x160.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_unfocus_160x120.png
Diff not rendered.
View
BIN NFC/TouchTicTacToe/res/img/nought_unfocus_213x160.png
Diff not rendered.
View
55 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/Constants.java
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe;
+import net.rim.device.api.ui.Color;
+
+public interface Constants {
+
+ public static final String MYAPP_VERSION = "1.0.1";
+ public static final String MYAPP_NAME = "Touch Tic Tac Toe";
+
+ public static final String [] WINNER_MESSAGE = {"YOU HAVE WON!!","Touch devices to start new game"};
+ public static final String [] STALE_MATE_MESSAGE = {"Stale mate! No more moves.","Touch devices to start new game"};
+
+ public static final int BOARD_STATE_OPEN=0;
+ public static final int BOARD_STATE_LOCKED=1;
+ public static final int NO_PREV_TURN=-1;
+ public static final int TILE_STATE_BLANK=0;
+ public static final int TILE_STATE_NOUGHT=1;
+ public static final int TILE_STATE_CROSS=2;
+ public static final int SELECT_STATE_NOUGHT=0;
+ public static final int SELECT_STATE_CROSS=0;
+ public static final int STATUS_COLOUR = Color.RED;
+ public static final int FOCUSED_COLOUR = Color.GOLD;
+ public static final int CLICKED_COLOUR = Color.RED;
+ public static final int WIN_LINE_COLOUR = Color.DARKORANGE;
+ public static final int STALE_MATE_TILE_COLOUR = Color.BLUE;
+ public static final int TRANSPARENCY = 30;
+ public static final int PLAYER_1 = 1;
+ public static final int PLAYER_2 = 2;
+ public static final int PLAYER_SYMBOL_NOUGHT = 1;
+ public static final int PLAYER_SYMBOL_CROSS = 2;
+ public static final long MESSAGE_TIME = 5000;
+ public static final int INITIAL_TILE = 4;
+
+ // protocol
+ public static final int PROTOCOL_MASTER_BID=1;
+ public static final int PROTOCOL_TURN_OVER=2;
+ public static final int PROTOCOL_RESET_BID_STATE=3;
+ public static final String SNEP_DOMAIN = "com.blackberry.nfc.sample";
+ public static final String SNEP_TYPE = "G1"; // Game #1
+
+}
View
35 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/TouchTicTacToe.java
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe;
+
+import net.rim.device.api.ui.UiApplication;
+import nfc.sample.tictactoe.ui.StartGameScreen;
+
+public class TouchTicTacToe extends UiApplication {
+
+ public static void main(String[] args) {
+ Utilities.initLogging();
+ Utilities.log("XXXX "+Constants.MYAPP_NAME+" v"+Constants.MYAPP_VERSION);
+ TouchTicTacToe app = new TouchTicTacToe();
+ app.enterEventDispatcher();
+ }
+
+ private TouchTicTacToe() {
+ StartGameScreen start_screen = new StartGameScreen();
+ pushScreen(start_screen);
+ }
+
+}
View
62 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/Utilities.java
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe;
+import net.rim.device.api.system.EventLogger;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.Dialog;
+
+public class Utilities {
+
+ private static final long MYAPP_ID = 0x4c38c8a7798397d1L;
+
+ public static void log(String logMessage) {
+ boolean ok = EventLogger.logEvent(MYAPP_ID, logMessage.getBytes(), EventLogger.INFORMATION);
+ }
+
+ public static void initLogging() {
+ EventLogger.register(MYAPP_ID, "TouchTicTacToe", EventLogger.VIEWER_STRING);
+ }
+
+ public static boolean isOdd(int number) {
+ int remainder = number % 2;
+ return remainder == 1;
+ }
+
+ public static byte[] toBytes(int value) {
+ byte [] bytes = new byte[4];
+ bytes [0] = (byte) ((value >>> 24) & 0xFF);
+ bytes [1] = (byte) ((value >>> 16) & 0xFF);
+ bytes [2] = (byte) ((value >>> 8) & 0xFF);
+ bytes [3] = (byte) ( value & 0xFF);
+ return bytes;
+ }
+
+ public static int toInt(byte[] bytes, int start) {
+ if((bytes.length - start) < 3) {
+ Utilities.log("XXXX toInt method received invalid length start position; insifficient bytes:" + bytes.length + "," + start);
+ return 0;
+ }
+ int i = ((bytes[start] & 0xFF) << 24) + ((bytes[start + 1] & 0xFF) << 16) + ((bytes[start + 2] & 0xFF) << 8) + (bytes[start + 3] & 0xFF);
+ return i;
+ }
+
+ public static void popupMessage(String message) {
+ synchronized(UiApplication.getEventLock()) {
+ Dialog.inform(message);
+ }
+ }
+
+}
View
49 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/ChooseCrossCommand.java
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.commands;
+import net.rim.device.api.command.AlwaysExecutableCommand;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
+import net.rim.device.api.ui.UiApplication;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.ui.GameScreen;
+import nfc.sample.tictactoe.ui.SymbolSelectionScreen;
+
+public class ChooseCrossCommand extends AlwaysExecutableCommand {
+
+
+ private SymbolSelectionScreen current_screen;
+
+ public ChooseCrossCommand(SymbolSelectionScreen ss_screen) {
+ current_screen = ss_screen;
+ }
+
+ public void execute(ReadOnlyCommandMetadata metadata, Object context) {
+
+ Utilities.log("XXXX ChooseCrossCommand - execute");
+
+ // only ever called by player 1 from the symbol selection screen
+ GameScreen screen = GameScreen.getInstance(Constants.PLAYER_1,Constants.PLAYER_SYMBOL_CROSS);
+
+ synchronized(UiApplication.getUiApplication().getEventLock()) {
+ synchronized (UiApplication.getEventLock()) {
+ UiApplication.getUiApplication().popScreen(current_screen);
+ UiApplication.getUiApplication().pushScreen(screen);
+ }
+ }
+ }
+
+}
View
48 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/ChooseNoughtCommand.java
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.commands;
+import net.rim.device.api.command.AlwaysExecutableCommand;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
+import net.rim.device.api.ui.UiApplication;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.ui.GameScreen;
+import nfc.sample.tictactoe.ui.SymbolSelectionScreen;
+
+public class ChooseNoughtCommand extends AlwaysExecutableCommand {
+
+ private SymbolSelectionScreen current_screen;
+
+ public ChooseNoughtCommand(SymbolSelectionScreen ss_screen) {
+ current_screen = ss_screen;
+ }
+
+ public void execute(ReadOnlyCommandMetadata metadata, Object context) {
+
+ Utilities.log("XXXX ChooseNoughtCommand - execute");
+
+ // only ever called by player 1 from the symbol selection screen
+ GameScreen screen = GameScreen.getInstance(Constants.PLAYER_1,Constants.PLAYER_SYMBOL_NOUGHT);
+
+ synchronized(UiApplication.getUiApplication().getEventLock()) {
+ synchronized (UiApplication.getEventLock()) {
+ UiApplication.getUiApplication().popScreen(current_screen);
+ UiApplication.getUiApplication().pushScreen(screen);
+ }
+ }
+ }
+
+}
View
45 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/commands/SelectTileCommand.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.commands;
+import net.rim.device.api.command.AlwaysExecutableCommand;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
+import nfc.sample.tictactoe.game.GameState;
+import nfc.sample.tictactoe.tiles.MultiStateButtonField;
+
+public class SelectTileCommand extends AlwaysExecutableCommand {
+
+ private int _symbol;
+
+ public void execute(ReadOnlyCommandMetadata metadata, Object context) {
+ GameState game_state = GameState.getInstance();
+ if (game_state.isBoardLocked()) {
+ return;
+ }
+ if (context instanceof MultiStateButtonField) {
+ int current_tile = game_state.getCurrent_tile();
+ game_state.updateTileThisPlayer(current_tile,_symbol);
+ }
+ }
+
+ public int get_symbol() {
+ return _symbol;
+ }
+
+ public void set_symbol(int _symbol) {
+ this._symbol = _symbol;
+ }
+
+}
View
352 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/game/GameState.java
@@ -0,0 +1,352 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.game;
+
+import net.rim.device.api.ui.UiApplication;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.protocol.ProtocolMessageMasterBid;
+import nfc.sample.tictactoe.tiles.MultiStateButtonField;
+import nfc.sample.tictactoe.ui.TileChangedListener;
+
+public class GameState {
+
+ public static final int GAME_STATE_CHANGE_MY_TURN_NOW=1;
+ public static final int GAME_STATE_CHANGE_THEIR_TURN_NOW=2;
+ public static final int GAME_STATE_CHANGE_GAME_OVER_WON=3;
+ public static final int GAME_STATE_CHANGE_GAME_OVER_STALE_MATE=4;
+ public static final int GAME_STATE_CHANGE_NEW_GAME_STARTED=5;
+
+ private static GameState _game_state;
+
+ private GameStateChangeListener game_state_change_listener;
+ private int current_game_state;
+
+ private int current_tile = -1;
+ private MultiStateButtonField[] _tiles;
+
+ private int tile_count_this_turn=0;
+
+ // indicates whether a tile is 0=unoccupied,1=nought,2=cross
+ private int[] tile_states = new int[9];
+ private boolean[] locked = new boolean[9];
+
+ private boolean board_locked;
+
+ private boolean game_over = false;
+ private boolean bid_sent = false;
+
+ private ProtocolMessageMasterBid my_bid_sent;
+ private ProtocolMessageMasterBid other_bid_received;
+
+ // tracks the last tile updated during a turn so if the player changes their mind we can undo this update
+ private int last_turn;
+
+ private TileChangedListener _listener;
+
+ private GameState() {
+ last_turn = Constants.NO_PREV_TURN;
+ }
+
+ public synchronized static GameState getInstance() {
+ if(_game_state == null) {
+ _game_state = new GameState();
+ }
+ return _game_state;
+ }
+
+ public void setGameStateChangeListener(GameStateChangeListener game_state_change_listener) {
+ this.game_state_change_listener = game_state_change_listener;
+ }
+
+ public void initialiseGameState() {
+ for(int i = 0; i < 9; i++) {
+ tile_states[i] = Constants.TILE_STATE_BLANK;
+ locked[i] = false;
+ setUiState(i, Constants.TILE_STATE_BLANK, false);
+ }
+ current_tile = Constants.INITIAL_TILE;;
+ last_turn = Constants.NO_PREV_TURN;
+ game_over = false;
+ current_game_state=GAME_STATE_CHANGE_NEW_GAME_STARTED;
+ if (game_state_change_listener != null) {
+ game_state_change_listener.onGameStateChange(GAME_STATE_CHANGE_NEW_GAME_STARTED);
+ }
+ }
+
+ public void setTileUiObjects(MultiStateButtonField[] tiles) {
+ _tiles = tiles;
+ }
+
+ public void setTileChangedListener(TileChangedListener listener) {
+ _listener = listener;
+ }
+
+ public void updateTileThisPlayer(int tile, int players_symbol) {
+ Utilities.log("XXXX updateTileThisPlayer(tile=" + tile + ",symbol=" + players_symbol + ",current tile state=" + tile_states[tile] + ",last_turn=" + last_turn);
+ boolean tile_set = false;
+ if(tile_states[tile] == Constants.TILE_STATE_BLANK) {
+ Utilities.log("XXXX updateTileThisPlayer setting tile to players symbol:" + players_symbol);
+ tile_states[tile] = players_symbol;
+ setUiState(tile, players_symbol, true);
+ tile_count_this_turn++;
+ _listener.tileChanged(tile);
+ tile_set = true;
+ if (hasWon(players_symbol)) {
+ current_game_state=GAME_STATE_CHANGE_GAME_OVER_WON;
+ game_over = true;
+ if (game_state_change_listener != null) {
+ game_state_change_listener.onGameStateChange(GAME_STATE_CHANGE_GAME_OVER_WON);
+ }
+ } else {
+ if (isBoardFull()) {
+ current_game_state=GAME_STATE_CHANGE_GAME_OVER_STALE_MATE;
+ game_over = true;
+ if (game_state_change_listener != null) {
+ game_state_change_listener.onGameStateChange(GAME_STATE_CHANGE_GAME_OVER_STALE_MATE);
+ }
+ }
+ }
+ } else {
+ if(tile_states[tile] == players_symbol && !locked[tile]) {
+ Utilities.log("XXXX updateTileThisPlayer setting tile to blank square");
+ tile_states[tile] = Constants.TILE_STATE_BLANK;
+ setUiState(tile, Constants.TILE_STATE_BLANK, true);
+ tile_set = false;
+ } else {
+ Utilities.log("XXXX updateTileThisPlayer ignoring request as tile contains other player's symbol or is locked from previous turn");
+ tile_set = false;
+ }
+ }
+ if(tile_set && last_turn != Constants.NO_PREV_TURN && last_turn != tile && !locked[tile]) {
+ Utilities.log("XXXX updateTileThisPlayer setting last turn's tile [" + last_turn + "] to BLANK");
+ tile_states[last_turn] = Constants.TILE_STATE_BLANK;
+ setUiState(last_turn, Constants.TILE_STATE_BLANK, false);
+ }
+ if(tile_set) {
+ last_turn = tile;
+ }
+ }
+
+ public void updateTileOtherPlayer(int tile, int players_symbol) {
+ Utilities.log("XXXX updateTileOtherPlayer(tile=" + tile + ",symbol=" + players_symbol + ",current tile state=" + tile_states[tile]);
+ // assume this was a valid move!
+ Utilities.log("XXXX updateTileOtherPlayer setting tile to players symbol:" + players_symbol);
+ tile_states[tile] = players_symbol;
+ locked[tile] = true;
+ setUiState(tile, players_symbol, true);
+ last_turn = Constants.NO_PREV_TURN;
+ current_game_state=GAME_STATE_CHANGE_MY_TURN_NOW;
+ if (game_state_change_listener != null) {
+ game_state_change_listener.onGameStateChange(GAME_STATE_CHANGE_MY_TURN_NOW);
+ }
+ }
+
+ public void setGameState(int new_state) {
+ current_game_state = new_state;
+ if (game_state_change_listener != null) {
+ game_state_change_listener.onGameStateChange(new_state);
+ }
+ }
+
+ private void setUiState(int tile, int symbol, boolean give_focus) {
+ _tiles[tile].setMsbState(symbol);
+ synchronized(UiApplication.getEventLock()) {
+ if(give_focus) {
+ _tiles[tile].setFocus();
+ _tiles[tile].setFocusedImage();
+ } else {
+ _tiles[tile].updateImage(false);
+ }
+ }
+ }
+
+ public int getTileState(int tile) {
+ return tile_states[tile];
+ }
+
+ public void setStartOfTurn() {
+ last_turn = Constants.NO_PREV_TURN;
+ }
+
+ public boolean isBoardLocked() {
+ return board_locked;
+ }
+
+ public void setBoardLocked(boolean locked) {
+ board_locked = locked;
+ }
+
+ public boolean isBoardFull() {
+ for(int i = 0; i < 9; i++) {
+ if(tile_states[i] == Constants.TILE_STATE_BLANK) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean hasWon(int symbol) {
+ // horizontal lines
+ if(tile_states[0] == symbol && tile_states[1] == symbol && tile_states[2] == symbol) {
+ return true;
+ }
+ if(tile_states[3] == symbol && tile_states[4] == symbol && tile_states[5] == symbol) {
+ return true;
+ }
+ if(tile_states[6] == symbol && tile_states[7] == symbol && tile_states[8] == symbol) {
+ return true;
+ }
+
+ // vertical lines
+ if(tile_states[0] == symbol && tile_states[3] == symbol && tile_states[6] == symbol) {
+ return true;
+ }
+ if(tile_states[1] == symbol && tile_states[4] == symbol && tile_states[7] == symbol) {
+ return true;
+ }
+ if(tile_states[2] == symbol && tile_states[5] == symbol && tile_states[8] == symbol) {
+ return true;
+ }
+
+ // diagonal lines
+ if(tile_states[0] == symbol && tile_states[4] == symbol && tile_states[8] == symbol) {
+ return true;
+ }
+
+ if(tile_states[2] == symbol && tile_states[4] == symbol && tile_states[6] == symbol) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public int[] getWinningLine(int symbol) {
+
+ int[] line = { -1, -1, -1 };
+
+ // horizontal lines
+ if(tile_states[0] == symbol && tile_states[1] == symbol && tile_states[2] == symbol) {
+ line[0] = 0;
+ line[1] = 1;
+ line[2] = 2;
+ }
+ if(tile_states[3] == symbol && tile_states[4] == symbol && tile_states[5] == symbol) {
+ line[0] = 3;
+ line[1] = 4;
+ line[2] = 5;
+ }
+ if(tile_states[6] == symbol && tile_states[7] == symbol && tile_states[8] == symbol) {
+ line[0] = 6;
+ line[1] = 7;
+ line[2] = 8;
+ }
+
+ // vertical lines
+ if(tile_states[0] == symbol && tile_states[3] == symbol && tile_states[6] == symbol) {
+ line[0] = 0;
+ line[1] = 3;
+ line[2] = 6;
+ }
+ if(tile_states[1] == symbol && tile_states[4] == symbol && tile_states[7] == symbol) {
+ line[0] = 1;
+ line[1] = 4;
+ line[2] = 7;
+ }
+ if(tile_states[2] == symbol && tile_states[5] == symbol && tile_states[8] == symbol) {
+ line[0] = 2;
+ line[1] = 5;
+ line[2] = 8;
+ }
+
+ // diagonal lines
+ if(tile_states[0] == symbol && tile_states[4] == symbol && tile_states[8] == symbol) {
+ line[0] = 0;
+ line[1] = 4;
+ line[2] = 8;
+ }
+
+ if(tile_states[2] == symbol && tile_states[4] == symbol && tile_states[6] == symbol) {
+ line[0] = 2;
+ line[1] = 4;
+ line[2] = 6;
+ }
+
+ return line;
+ }
+
+ public int getCurrent_tile() {
+ return current_tile;
+ }
+
+ public void setCurrent_tile(int current_tile) {
+ Utilities.log("XXXX GameState.setCurrent_tile:" + current_tile);
+ this.current_tile = current_tile;
+ }
+
+ public void lockBoard() {
+ setBoardLocked(true);
+ for(int i = 0; i < 9; i++) {
+ if(tile_states[i] != Constants.TILE_STATE_BLANK) {
+ locked[i] = true;
+ } else {
+ locked[i] = false;
+ }
+ }
+ last_turn = Constants.NO_PREV_TURN;
+ }
+
+ public boolean isGame_over() {
+ return game_over;
+ }
+
+ public void setGame_over(boolean game_over) {
+ this.game_over = game_over;
+ }
+
+ public int getTile_count_this_turn() {
+ return tile_count_this_turn;
+ }
+
+ public void setTile_count_this_turn(int tile_count_this_turn) {
+ this.tile_count_this_turn = tile_count_this_turn;
+ }
+
+ public boolean isBid_sent() {
+ return bid_sent;
+ }
+
+ public void setBid_sent(boolean bid_sent) {
+ this.bid_sent = bid_sent;
+ }
+
+ public ProtocolMessageMasterBid getMy_bid_sent() {
+ return my_bid_sent;
+ }
+
+ public void setMy_bid_sent(ProtocolMessageMasterBid my_bid_sent) {
+ this.my_bid_sent = my_bid_sent;
+ }
+
+ public ProtocolMessageMasterBid getOther_bid_received() {
+ return other_bid_received;
+ }
+
+ public void setOther_bid_received(ProtocolMessageMasterBid other_bid_received) {
+ this.other_bid_received = other_bid_received;
+ }
+
+}
View
21 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/game/GameStateChangeListener.java
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.game;
+
+public interface GameStateChangeListener {
+
+ public void onGameStateChange(int new_game_state);
+}
View
46 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/NfcReceiver.java
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.nfc;
+
+
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+import net.rim.device.api.io.nfc.ndef.NDEFMessageListener;
+import net.rim.device.api.io.nfc.ndef.NDEFRecord;
+import net.rim.device.api.util.ByteArrayUtilities;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.protocol.GameMessageProcessor;
+import nfc.sample.tictactoe.protocol.ProtocolMessage;
+
+public class NfcReceiver implements NDEFMessageListener {
+
+ GameMessageProcessor _processor;
+
+ public NfcReceiver(GameMessageProcessor processor) {
+ _processor = processor;
+ }
+
+ public void onNDEFMessageDetected(NDEFMessage msg) {
+ NDEFRecord[] records = msg.getRecords();
+ if (records.length > 0) {
+ byte[] payload = records[0].getPayload();
+ Utilities.log("XXXX NfcReceiver payload=" + ByteArrayUtilities.byteArrayToHex(payload));
+ ProtocolMessage pmsg = ProtocolMessage.makeMessage(payload);
+ _processor.gameMessage(pmsg);
+ }
+
+ }
+
+}
View
64 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/NfcSender.java
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.nfc;
+
+import net.rim.device.api.io.nfc.NFCException;
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+import net.rim.device.api.io.nfc.ndef.NDEFMessageUtils;
+import net.rim.device.api.io.nfc.push.NDEFMessageBuilder;
+import net.rim.device.api.util.ByteArrayUtilities;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.protocol.ProtocolMessage;
+
+public class NfcSender implements NDEFMessageBuilder {
+
+ private ProtocolMessage _message;
+
+ public NfcSender(ProtocolMessage message) {
+ _message = message;
+ }
+
+ public NDEFMessage[] buildNDEFMessages() {
+
+ Utilities.log("XXXX NfcSender sending ProtocolMessage:" + _message);
+
+ NDEFMessage[] ndef_messages = null;
+ NDEFMessage game_message;
+
+ try {
+
+ byte[] payload = _message.marshall();
+ Utilities.log("XXXX NfcSender sending payload 0x" + ByteArrayUtilities.byteArrayToHex(payload));
+ game_message = NDEFMessageUtils.createExternalTypeMessage(Constants.SNEP_DOMAIN, Constants.SNEP_TYPE, payload);
+
+ ndef_messages = new NDEFMessage[] { game_message };
+
+ } catch(NFCException e) {
+ Utilities.log("XXXX NfcSender:" + e.getClass().getName() + ":" + e.getMessage());
+ }
+ return ndef_messages;
+ }
+
+ public ProtocolMessage get_message() {
+ return _message;
+ }
+
+ public void set_message(ProtocolMessage _message) {
+ this._message = _message;
+ }
+
+}
View
59 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/nfc/SnepCallBack.java
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.nfc;
+
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+import net.rim.device.api.io.nfc.push.NDEFPushStatusCallback;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.protocol.GameMessageProcessor;
+
+public class SnepCallBack implements NDEFPushStatusCallback {
+
+ GameMessageProcessor _processor;
+
+ public SnepCallBack(GameMessageProcessor processor) {
+ _processor = processor;
+ }
+
+ public void onNDEFPushStatusUpdate(NDEFMessage message, int status) {
+
+ String status_text;
+
+ switch(status) {
+
+ case NDEFPushStatusCallback.SUCCESS:
+ status_text = "Ready";
+ break;
+ case NDEFPushStatusCallback.REJECTED:
+ status_text = "REJECTED";
+ break;
+ case NDEFPushStatusCallback.PUSH_ERROR:
+ status_text = "PUSH_ERROR";
+ break;
+ case NDEFPushStatusCallback.INVALID_DATA:
+ status_text = "INVALID_DATA";
+ break;
+ case NDEFPushStatusCallback.DATA_TOO_LARGE:
+ status_text = "DATA_TOO_LARGE";
+ break;
+ default:
+ status_text = "UNDEFINED";
+ break;
+ }
+ Utilities.log("XXXX SNEP message status:"+status_text);
+ _processor.sentMessagestatusUpdate(message, status, status_text);
+ }
+}
View
26 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/GameMessageProcessor.java
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+
+public interface GameMessageProcessor {
+
+ public void gameMessage(ProtocolMessage message);
+
+ public void sentMessagestatusUpdate(NDEFMessage ndefMessage, int status, String status_text);
+
+}
View
125 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/GameProtocol.java
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import net.rim.device.api.io.nfc.NFCException;
+import net.rim.device.api.io.nfc.ndef.NDEFRecord;
+import net.rim.device.api.io.nfc.push.NDEFPushManager;
+import net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+import nfc.sample.tictactoe.nfc.NfcReceiver;
+import nfc.sample.tictactoe.nfc.NfcSender;
+import nfc.sample.tictactoe.nfc.SnepCallBack;
+
+public class GameProtocol {
+
+ private GameMessageProcessor game_message_processor;
+ private ReaderWriterManager nfc_manager;
+ private NDEFPushManager ndef_push_manager;
+ private SnepCallBack status_monitor;
+ private NfcSender sender;
+ private NfcReceiver receiver;
+ private int push_id;
+ private boolean listening = false;
+ private byte last_message_type_sent;
+
+ public GameProtocol(GameMessageProcessor game_message_processor) throws NFCException {
+ this.game_message_processor = game_message_processor;
+ receiver = new NfcReceiver(game_message_processor);
+ ndef_push_manager = NDEFPushManager.getInstance();
+ nfc_manager = ReaderWriterManager.getInstance();
+ }
+
+ public void sendMasterBid(ProtocolMessageMasterBid my_bid) throws NFCException {
+ Utilities.log("XXXX sending master bid:" + my_bid.toString());
+ sender = new NfcSender(my_bid);
+ status_monitor = new SnepCallBack(game_message_processor);
+ push_id = ndef_push_manager.pushNDEF(sender, status_monitor);
+ last_message_type_sent = Constants.PROTOCOL_MASTER_BID;
+ Utilities.log("XXXX push_id=" + push_id);
+ }
+
+ public void prepareTurnOver(ProtocolMessageTurnOver turn_over) throws NFCException {
+ Utilities.log("XXXX prepareTurnOver:" + turn_over.toString());
+ nfc_manager.removeNDEFMessageListener(NDEFRecord.TNF_EXTERNAL, Constants.SNEP_DOMAIN + ":" + Constants.SNEP_TYPE);
+ listening = false;
+ sender = new NfcSender(turn_over);
+ status_monitor = new SnepCallBack(game_message_processor);
+ push_id = ndef_push_manager.pushNDEF(sender, status_monitor);
+ last_message_type_sent = Constants.PROTOCOL_TURN_OVER;
+ }
+
+ public void resetBidState(ProtocolMessageResetBidState reset) throws NFCException {
+ Utilities.log("XXXX sending reset bid state message:" + reset.toString());
+ sender = new NfcSender(reset);
+ status_monitor = new SnepCallBack(game_message_processor);
+ push_id = ndef_push_manager.pushNDEF(sender, status_monitor);
+ last_message_type_sent = Constants.PROTOCOL_RESET_BID_STATE;
+ Utilities.log("XXXX push_id=" + push_id);
+ }
+
+ public void disableMessaging() throws NFCException {
+ Utilities.log("XXXX disabling NFC messaging");
+ nfc_manager.removeNDEFMessageListener(NDEFRecord.TNF_EXTERNAL, Constants.SNEP_DOMAIN + ":" + Constants.SNEP_TYPE);
+ ndef_push_manager.cancelNDEFPush(push_id);
+ listening = false;
+ }
+
+ public void cancelPushRegistration() throws NFCException {
+ Utilities.log("XXXX canceling push registration");
+ ndef_push_manager.cancelNDEFPush(push_id);
+ }
+
+ public void listenForMessages() {
+ Utilities.log("XXXX listenForMessages");
+ try {
+ if(!listening) {
+ nfc_manager.addNDEFMessageListener(receiver, NDEFRecord.TNF_EXTERNAL, Constants.SNEP_DOMAIN + ":" + Constants.SNEP_TYPE);
+ listening = true;
+ }
+ } catch(NFCException e) {
+ Utilities.log("XXXX listenForMessages:" + e.getClass().getName() + ":" + e.getMessage());
+ }
+ }
+
+ public void stopListeningForMessages() {
+ Utilities.log("XXXX stopListeningForMessages");
+ try {
+ nfc_manager.removeNDEFMessageListener(NDEFRecord.TNF_EXTERNAL, Constants.SNEP_DOMAIN + ":" + Constants.SNEP_TYPE);
+ listening = false;
+ } catch(NFCException e) {
+ Utilities.log("XXXX stopListeningForMessages:" + e.getClass().getName() + ":" + e.getMessage());
+ }
+ }
+
+ public boolean isListening() {
+ return listening;
+ }
+
+ public void setListening(boolean listening) {
+ this.listening = listening;
+ }
+
+ public byte getLast_message_type() {
+ return last_message_type_sent;
+ }
+
+ public void setLast_message_type(byte last_message_type) {
+ this.last_message_type_sent = last_message_type;
+ }
+
+}
View
61 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessage.java
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+
+abstract public class ProtocolMessage {
+
+ byte message_id;
+
+ public static ProtocolMessage makeMessage(byte [] data) {
+ if(data.length >= 4) {
+ byte messageid = data[0];
+ switch(messageid) {
+ case Constants.PROTOCOL_MASTER_BID:
+ ProtocolMessageMasterBid pmsg_mb = new ProtocolMessageMasterBid();
+ pmsg_mb.demarshall(data);
+ Utilities.log("XXXX rcvd:"+pmsg_mb.toString());
+ return pmsg_mb;
+ case Constants.PROTOCOL_TURN_OVER:
+ ProtocolMessageTurnOver pmsg_to = new ProtocolMessageTurnOver();
+ pmsg_to.demarshall(data);
+ Utilities.log("XXXX rcvd:"+pmsg_to.toString());
+ return pmsg_to;
+ }
+ }
+ return null;
+
+ }
+
+
+ abstract public byte [] marshall();
+
+ abstract public void demarshall(byte [] bytes);
+
+ public byte getMessage_id() {
+ return message_id;
+ }
+ public void setMessage_id(byte message_id) {
+ this.message_id = message_id;
+ }
+
+ public String toString() {
+ return "message_id="+message_id;
+ }
+
+}
View
64 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageMasterBid.java
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import java.util.Random;
+
+import net.rim.device.api.util.ByteArrayUtilities;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+
+public class ProtocolMessageMasterBid extends ProtocolMessage {
+
+ private int bid;
+
+ public ProtocolMessageMasterBid() {
+ message_id = Constants.PROTOCOL_MASTER_BID;
+ Random rand = new Random(System.currentTimeMillis());
+ bid = rand.nextInt(1000000);
+ }
+
+ public byte[] marshall() {
+ byte [] bid_bytes = Utilities.toBytes(bid);
+ byte [] bytes = new byte[1+bid_bytes.length];
+ bytes [0] = message_id;
+ System.arraycopy(bid_bytes, 0, bytes, 1, bid_bytes.length);
+ return bytes;
+ }
+
+ public void demarshall(byte[] bytes) {
+ Utilities.log("XXXX demarshalling:"+ByteArrayUtilities.byteArrayToHex(bytes));
+ if (bytes.length != 5) {
+ Utilities.log("XXXX invalid parameter length passed to ProtocolMessageMasterBid demarshall:"+ bytes.length);
+ return;
+ }
+ message_id = bytes[0];
+ bid = Utilities.toInt(bytes,1);
+ }
+
+ public int getBid() {
+ return bid;
+ }
+
+ public void setBid(int bid) {
+ this.bid = bid;
+ }
+
+ public String toString() {
+ String string = super.toString() + ",ProtocolMessageMasterBid" + ",bid="+bid;
+ return string;
+ }
+}
View
47 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageResetBidState.java
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import net.rim.device.api.util.ByteArrayUtilities;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+
+public class ProtocolMessageResetBidState extends ProtocolMessage {
+
+ public ProtocolMessageResetBidState() {
+ message_id = Constants.PROTOCOL_RESET_BID_STATE;
+ }
+
+ public byte[] marshall() {
+ byte [] bytes = new byte[1];
+ bytes [0] = message_id;
+ return bytes;
+ }
+
+ public void demarshall(byte[] bytes) {
+ Utilities.log("XXXX demarshalling:"+ByteArrayUtilities.byteArrayToHex(bytes));
+ if (bytes.length != 1) {
+ Utilities.log("XXXX invalid parameter length passed to ProtocolMessageResetBidState demarshall:"+ bytes.length);
+ return;
+ }
+ message_id = bytes[0];
+ }
+
+ public String toString() {
+ String string = super.toString() + ",ProtocolMessageResetBidState";
+ return string;
+ }
+}
View
72 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/protocol/ProtocolMessageTurnOver.java
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.protocol;
+
+import net.rim.device.api.util.ByteArrayUtilities;
+import nfc.sample.tictactoe.Constants;
+import nfc.sample.tictactoe.Utilities;
+
+public class ProtocolMessageTurnOver extends ProtocolMessage {
+
+ private int _tile_changed;
+ private int _symbol_played;
+
+ public ProtocolMessageTurnOver() {
+ message_id = Constants.PROTOCOL_TURN_OVER;
+ }
+
+ public byte[] marshall() {
+ byte [] tile_changed_bytes = Utilities.toBytes(_tile_changed);
+ byte [] symbol_played_bytes = Utilities.toBytes(_symbol_played);
+ byte [] bytes = new byte[9];
+ bytes [0] = message_id;
+ System.arraycopy(tile_changed_bytes, 0, bytes, 1, 4);
+ System.arraycopy(symbol_played_bytes, 0, bytes, 5, 4);
+ return bytes;
+ }
+
+ public void demarshall(byte[] bytes) {
+ Utilities.log("XXXX demarshalling:"+ByteArrayUtilities.byteArrayToHex(bytes));
+ if (bytes.length != 9) {
+ Utilities.log("XXXX invalid parameter length passed to ProtocolTurnOver demarshall:"+ bytes.length);
+ return;
+ }
+ message_id = bytes[0];
+ _tile_changed = Utilities.toInt(bytes,1);
+ _symbol_played = Utilities.toInt(bytes,5);
+ }
+
+ public String toString() {
+ String string = super.toString() + ",ProtocolMessageTurnOver" + ",tile_changed="+_tile_changed+",symbol_changed="+_symbol_played;
+ return string;
+ }
+
+ public int get_tile_changed() {
+ return _tile_changed;
+ }
+
+ public void set_tile_changed(int _tile_changed) {
+ this._tile_changed = _tile_changed;
+ }
+
+ public int get_symbol_played() {
+ return _symbol_played;
+ }
+
+ public void set_symbol_played(int _symbol_played) {
+ this._symbol_played = _symbol_played;
+ }
+}
View
33 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/tiles/MsbConfig.java
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2012 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.
+*/
+package nfc.sample.tictactoe.tiles;
+import java.util.Hashtable;
+
+public class MsbConfig {
+