Initialize
authorSungho Park <chywoo.park@samsung.com>
Mon, 27 Feb 2012 12:19:43 +0000 (21:19 +0900)
committerSungho Park <chywoo.park@samsung.com>
Mon, 27 Feb 2012 12:19:43 +0000 (21:19 +0900)
187 files changed:
AUTHORS [new file with mode: 0644]
LICENSE [new file with mode: 0644]
NOTICE [new file with mode: 0644]
build.sh [new file with mode: 0755]
builder/build.properties.clean [new file with mode: 0644]
builder/customTargets.xml [new file with mode: 0644]
builder/metadata/data/IDE/plugins/org.tizen.telephony.call_1.3.20.201202101837.jar [new file with mode: 0644]
builder/metadata/data/IDE/plugins/org.tizen.telephony.sms_1.3.20.201202101837.jar [new file with mode: 0644]
builder/metadata/pkginfo.manifest [new file with mode: 0644]
builder/metadata/web/pkginfo.manifest [new file with mode: 0644]
org.tizen.device/.classpath [new file with mode: 0644]
org.tizen.device/.project [new file with mode: 0644]
org.tizen.device/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.device/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.device/build.properties [new file with mode: 0644]
org.tizen.device/plugin.xml [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/battery/Battery.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/battery/page/BatteryConstants.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/battery/page/BatteryPage.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/earjack/Earjack.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/earjack/page/EarjackConstants.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/earjack/page/EarjackPage.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/rssi/Rssi.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/rssi/page/RssiPage.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/usb/Usb.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/usb/page/UsbConstants.java [new file with mode: 0644]
org.tizen.device/src/org/tizen/device/usb/page/UsbPage.java [new file with mode: 0644]
org.tizen.eventinjector.feature/.project [new file with mode: 0644]
org.tizen.eventinjector.feature/build.properties [new file with mode: 0644]
org.tizen.eventinjector.feature/feature.properties [new file with mode: 0644]
org.tizen.eventinjector.feature/feature.xml [new file with mode: 0644]
org.tizen.injector/.classpath [new file with mode: 0644]
org.tizen.injector/.project [new file with mode: 0644]
org.tizen.injector/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.tizen.injector/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.injector/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.injector/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.injector/build.properties [new file with mode: 0644]
org.tizen.injector/icons/connect.png [new file with mode: 0644]
org.tizen.injector/icons/disconnect.png [new file with mode: 0644]
org.tizen.injector/icons/injector_view.png [new file with mode: 0644]
org.tizen.injector/plugin.xml [new file with mode: 0644]
org.tizen.injector/schema/injectorItemProvider.exsd [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/DebugLog.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/Injector.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/AbstractGA.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/AbstractItem.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/ByteArrayItem.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/IntItem.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/InvalidTypeException.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/ItemType.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/StructureGA.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/sensor/AbstractSenserMessage.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/protocol/sensor/TestSensorMessage.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorItem.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorPage.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/receiver/AbstractInjectorReceiver.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/socket/LocationSocket.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/socket/SensorTCPSocket.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/socket/SensorUDPSocket.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/socket/TelephonySocket.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/sourceProvider/InjectorStateProvider.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/util/ByteUtil.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/util/FormPageUtil.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/util/StringUtil.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/view/InjectorView.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/view/Messages.java [new file with mode: 0644]
org.tizen.injector/src/org/tizen/injector/view/messages.properties [new file with mode: 0644]
org.tizen.location.core/.classpath [new file with mode: 0644]
org.tizen.location.core/.project [new file with mode: 0644]
org.tizen.location.core/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.tizen.location.core/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.location.core/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.location.core/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.location.core/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.location.core/build.properties [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/injector/DebugLog.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/injector/LocationInjector.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/model/GeoLocationVO.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/AbstractNMEA0183.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/GeoLocation.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/IdentifiersConstants.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/Messages.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGGA.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSA.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSV.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPRMC.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/SatelliteInfo.java [new file with mode: 0644]
org.tizen.location.core/src/org/tizen/location/core/protocol/messages.properties [new file with mode: 0644]
org.tizen.location.log/.classpath [new file with mode: 0644]
org.tizen.location.log/.project [new file with mode: 0644]
org.tizen.location.log/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.tizen.location.log/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.location.log/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.location.log/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.location.log/build.properties [new file with mode: 0644]
org.tizen.location.log/plugin.xml [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/Log.java [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/Messages.java [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/messages.properties [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/page/LogFile.java [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/page/Messages.java [new file with mode: 0644]
org.tizen.location.log/src/org/tizen/location/log/page/messages.properties [new file with mode: 0644]
org.tizen.location.manual/.classpath [new file with mode: 0644]
org.tizen.location.manual/.project [new file with mode: 0644]
org.tizen.location.manual/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.tizen.location.manual/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.location.manual/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.location.manual/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.location.manual/build.properties [new file with mode: 0644]
org.tizen.location.manual/plugin.xml [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/Manual.java [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/Messages.java [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/messages.properties [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/page/Coordinate.java [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/page/Messages.java [new file with mode: 0644]
org.tizen.location.manual/src/org/tizen/location/manual/page/messages.properties [new file with mode: 0644]
org.tizen.location.map/.classpath [new file with mode: 0644]
org.tizen.location.map/.project [new file with mode: 0644]
org.tizen.location.map/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.tizen.location.map/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.location.map/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.location.map/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.location.map/build.properties [new file with mode: 0644]
org.tizen.location.map/html/googleMap.html [new file with mode: 0644]
org.tizen.location.map/plugin.xml [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/Map.java [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/Messages.java [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/messages.properties [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/page/MapImage.java [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/page/Messages.java [new file with mode: 0644]
org.tizen.location.map/src/org/tizen/location/map/page/messages.properties [new file with mode: 0644]
org.tizen.nfc/.classpath [new file with mode: 0644]
org.tizen.nfc/.project [new file with mode: 0644]
org.tizen.nfc/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.nfc/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.nfc/build.properties [new file with mode: 0644]
org.tizen.nfc/plugin.xml [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/Nfc.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NDEFRecord.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NfcCommand.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NfcDialog.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NfcMimeType.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NfcPage.java [new file with mode: 0644]
org.tizen.nfc/src/org/tizen/nfc/page/NfcStringResource.java [new file with mode: 0644]
org.tizen.sensor.accelerometer/.classpath [new file with mode: 0644]
org.tizen.sensor.accelerometer/.project [new file with mode: 0644]
org.tizen.sensor.accelerometer/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.tizen.sensor.accelerometer/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.sensor.accelerometer/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.sensor.accelerometer/build.properties [new file with mode: 0644]
org.tizen.sensor.accelerometer/plugin.xml [new file with mode: 0644]
org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/Sensor.java [new file with mode: 0644]
org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Accelerometer.java [new file with mode: 0644]
org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/MobilePanel.java [new file with mode: 0644]
org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Vector.java [new file with mode: 0644]
org.tizen.sensor.accelerometer/src/org/tizen/sensor/magnetic/Magnetic.java [new file with mode: 0644]
org.tizen.sensor.light/.classpath [new file with mode: 0644]
org.tizen.sensor.light/.project [new file with mode: 0644]
org.tizen.sensor.light/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.sensor.light/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.sensor.light/build.properties [new file with mode: 0644]
org.tizen.sensor.light/plugin.xml [new file with mode: 0644]
org.tizen.sensor.light/src/org/tizen/sensor/light/Light.java [new file with mode: 0644]
org.tizen.sensor.light/src/org/tizen/sensor/light/page/LightPage.java [new file with mode: 0644]
org.tizen.sensor.motion/.classpath [new file with mode: 0644]
org.tizen.sensor.motion/.project [new file with mode: 0644]
org.tizen.sensor.motion/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.sensor.motion/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.sensor.motion/build.properties [new file with mode: 0644]
org.tizen.sensor.motion/plugin.xml [new file with mode: 0644]
org.tizen.sensor.motion/src/org/tizen/sensor/motion/Motion.java [new file with mode: 0644]
org.tizen.sensor.motion/src/org/tizen/sensor/motion/page/MotionPage.java [new file with mode: 0644]
org.tizen.sensor.proximity/.classpath [new file with mode: 0644]
org.tizen.sensor.proximity/.project [new file with mode: 0644]
org.tizen.sensor.proximity/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.tizen.sensor.proximity/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.sensor.proximity/build.properties [new file with mode: 0644]
org.tizen.sensor.proximity/plugin.xml [new file with mode: 0644]
org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/Proximity.java [new file with mode: 0644]
org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityConstants.java [new file with mode: 0644]
org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityPage.java [new file with mode: 0644]
package/build.linux [new file with mode: 0755]
package/build.windows [new file with mode: 0755]
package/pkginfo.manifest [new file with mode: 0644]
packaging_eventinjector.sh [new file with mode: 0755]
packaging_eventinjector_wac.sh [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..fe14544
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,13 @@
+YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+DongKyun Yun <dk77.yun@samsung.com>
+DoHyung Hong <don.hong@samsung.com>
+SeokYeon Hwang <syeon.hwang@samsung.com>
+Hyunjun Son <hj79.son@samsung.com>
+SangJin Kim <sangjin3.kim@samsung.com>
+KiTae Kim <kt920.kim@samsung.com>
+JinHyung Jo <jinhyung.jo@samsung.com>
+SungMin Ha <sungmin82.ha@samsung.com>
+MunKyu Im <munkyu.im@samsung.com>
+JiHye Kim <jihye1128.kim@samsung.com>
+GiWoong Kim <giwoong.kim@samsung.com>
+HyunGoo Kang <hyungoo1.kang@samsung.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..bbe9d02
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..f085dc6
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..5bea2e6
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,159 @@
+#!/bin/bash
+start_path=`pwd`
+
+###############################################################
+##
+## Please modify parameter value.
+##
+###############################################################
+build_type=N
+build_id=eventinjector_build
+build_path="`pwd`/../build_result"
+
+###############################################################
+##
+## Do not touch here.
+##
+###############################################################
+build_result_directory=${build_type}.${build_id}
+builder_path="$start_path/builder"
+equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar`
+pde_build=`echo org.eclipse.pde.build_*`
+metadata_path=$start_path/builder
+
+if [ "x$1" = "x" ]
+then
+       echo "
+Usage : build_ide.sh PLATFORM_NAME TARGET_ECLIPSE_PATH
+
+   PLATFORM_NAME               You can set \"linux\" or \"windows\"
+   TARGET_ECLIPSE_PATH         Set target eclipse path.
+                               For example, $HOME/git/fresh-ide-pde
+"
+       exit 1
+fi
+
+if [ "x$2" = "x" ]
+then
+       echo "
+Usage : build_ide.sh $1 TARGET_ECLIPSE_PATH
+   TARGET_ECLIPSE_PATH Set target eclipse path.
+                       For example, $HOME/git/fresh-ide-pde
+"
+       exit 1
+fi
+
+build_result_path="$build_path/$build_result_directory"
+platform=$1
+based_eclipse_path=$2
+fresh_ide_path=$3
+parent_path_of_based_eclipse=${based_eclipse_path}/..
+architecture=x86
+
+case ${platform} in
+       linux)
+               archive_platform_name=linux
+               windowing=gtk
+               ;;
+       windows)
+               archive_platform_name=win32
+               windowing=win32
+               ;;
+       *)
+               echo "${platform} is not support yet."
+               exit 1
+               ;;
+esac
+
+result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip
+
+if [ -d $build_path ]
+then
+       echo "Build result directory : [$build_path]"
+else
+       echo "Make build result directory [$build_path]"
+       mkdir -p $build_path
+fi
+
+echo "Remove legacy build files..."
+if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ]
+then
+       rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}
+fi
+if [ -e ${build_result_path}/${result_archive_file} ]
+then
+       rm -rf ${build_result_path}/${result_archive_file}
+fi
+
+if [ -d $build_path/plugins ]
+then
+       echo "plugins directory recreate..."
+        rm -rf $build_path/plugins
+       mkdir $build_path/plugins
+else
+       echo "Make plugins directory..."
+       mkdir $build_path/plugins
+fi
+if [ -d $build_path/features/ ]
+then
+       echo "features directory recreate..."
+        rm -rf $build_path/features
+       mkdir $build_path/features
+else
+       echo "Make features directory..."
+       mkdir $build_path/features
+fi
+
+echo "Copy features from $start_path to $build_path/features"
+cp -r $start_path/*.feature $build_path/features
+
+echo "Copy plugins from $start_path to $build_path/plugins"
+cp -r $start_path/* $build_path/plugins
+rm -rf $build_path/plugins/*.feature
+
+echo "Copy fresh ide plugins..."
+if [ -d ${fresh_ide_path} ]
+then
+       cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/features/* ${build_path}/features
+       cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/plugins/* ${build_path}/plugins
+else
+       echo "ERROR : Fresh IDE does not exist..."
+       exit 1
+fi
+
+echo "Make build.properties file..."
+if [ ! -e $builder_path/build.properties.clean ] ; then
+       echo "ERROR : \"build.properties.clean\" file does not exist..."
+       exit 1
+fi
+cp $builder_path/build.properties.clean $build_path
+cp $builder_path/customTargets.xml $build_path
+
+if [ -d $based_eclipse_path ] 
+then
+       sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" -e "s;\(^baseLocation=\).*;\1${based_eclipse_path};g" -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" -e "s;\(^buildType=\).*;\1${build_type};g" -e "s;\(^buildId=\).*;\1${build_id};g" < $build_path/build.properties.clean > $build_path/build.properties
+else
+       echo "ERROR : target eclipse is not exist."
+       exit 1
+fi
+
+echo "Execute Product Ant Builder..."
+java -server -XX:+UseParNewGC -jar ${based_eclipse_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${based_eclipse_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path 2>&1
+
+if [ $? != 0 ];
+then
+       echo "Build failed..."
+       exit 1
+fi
+
+echo "unzip to $build_result_path"
+unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture}
+
+#echo "Delete temp files..."
+#rm -rf $build_path/features
+#rm -rf $build_path/plugins
+#rm $build_path/*.xml
+#rm $build_path/*.properties
+#rm $build_path/*.properties.clean
+
+echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"."
diff --git a/builder/build.properties.clean b/builder/build.properties.clean
new file mode 100644 (file)
index 0000000..1e101ef
--- /dev/null
@@ -0,0 +1,259 @@
+###############################################################################
+# Copyright (c) 2003, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+#####################
+# Parameters describing how and where to execute the build.
+# Typical users need only update the following properties:
+#    baseLocation - where things you are building against are installed
+#    bootclasspath - The base jars to compile against (typicaly rt.jar)
+#    configs - the list of {os, ws, arch} configurations to build.  
+#
+# Of course any of the settings here can be overridden by spec'ing 
+# them on the command line (e.g., -DbaseLocation=d:/eclipse
+
+#The type of the top level element we are building,  generally "feature"
+topLevelElementType=feature
+#The id of the top level element we are building
+topLevelElementId=org.tizen.eventinjector.feature
+
+############# PRODUCT/PACKAGING CONTROL #############
+#runPackager=true
+
+#Set the name of the archive that will result from the product build.
+#archiveNamePrefix=
+
+# The prefix that will be used in the generated archive.
+archivePrefix=eventinjector
+
+# The location underwhich all of the build output will be collected.
+collectingFolder=${archivePrefix}
+
+# The list of {os, ws, arch} configurations to build.  This 
+# value is a '&' separated list of ',' separate triples.  For example, 
+#     configs=win32,win32,x86 & linux,motif,x86
+# By default the value is *,*,*
+configs="Do not touch here."
+#configs=win32, win32, x86 & \
+#      win32,win32,x86_64 & \
+#      win32,win32,wpf & \
+#      linux, gtk, ppc & \
+#      linux, gtk, x86 & \
+#      linux, gtk, x86_64 & \
+#      linux, motif, x86 & \
+#      solaris, motif, sparc & \
+#      solaris, gtk, sparc & \
+#      aix, motif, ppc & \
+#      hpux, motif, ia64_32 & \
+#      macosx, carbon, ppc & \
+#      macosx, carbon, x86 & \
+#      macosx, cocoa, ppc & \
+#      macosx, cocoa, x86 & \
+#      macosx, cocoa, x86_64
+
+# By default PDE creates one archive (result) per entry listed in the configs property.
+# Setting this value to true will cause PDE to only create one output containing all 
+# artifacts for all the platforms listed in the configs property.
+# To control the output format for the group, add a "group, group, group - <format>" entry to the
+# archivesFormat. 
+#groupConfigurations=true
+
+#The format of the archive. By default a zip is created using antZip.
+#The list can only contain the configuration for which the desired format is different than zip.
+#archivesFormat=win32, win32, x86 - antZip& \
+#      linux, gtk, ppc - antZip &\
+#    linux, gtk, x86 - antZip& \
+#      linux, gtk, x86_64 - antZip& \
+# linux, motif, x86 - antZip& \
+#      solaris, motif, sparc - antZip& \
+#      solaris, gtk, sparc - antZip& \
+#      aix, motif, ppc - antZip& \
+#      hpux, motif, PA_RISC - antZip& \
+#      macosx, carbon, ppc - antZip
+
+#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
+allowBinaryCycles=true
+
+#Sort bundles depenedencies across all features instead of just within a given feature.
+#flattenDependencies = true
+
+#Parallel compilation, requires flattenedDependencies=true
+#parallelCompilation=true
+#parallelThreadCount=
+#parallelThreadsPerProcessor=
+       
+#Set to true if you want the output to be ready for an update jar (no site.xml generated)
+#outputUpdateJars = false
+
+#Set to true for Jnlp generation
+#codebase should be a URL that will be used as the root of all relative URLs in the output.
+#generateJnlp=false
+#jnlp.codebase=<codebase url>
+#jnlp.j2se=<j2se version>
+#jnlp.locale=<a locale>
+#jnlp.generateOfflineAllowed=true or false generate <offlineAllowed/> attribute in the generated features
+#jnlp.configs=${configs}                       #uncomment to filter the content of the generated jnlp files based on the configuration being built
+
+#Set to true if you want to sign jars
+#signJars=false
+#sign.alias=<alias>
+#sign.keystore=<keystore location>
+#sign.storepass=<keystore password>
+#sign.keypass=<key password>
+
+#Arguments to send to the zip executable
+#zipargs=
+
+#Arguments to send to the tar executable
+#tarargs=
+
+#Control the creation of a file containing the version included in each configuration - on by default 
+#generateVersionsLists=false
+
+############## BUILD NAMING CONTROL ################
+# The directory into which the build elements are fetched and where
+# the build takes place.
+buildDirectory="Do not touch here"
+
+# Type of build.  Used in naming the build output.  Typically this value is
+# one of I, N, M, S, ...
+buildType="Do not touch here"
+
+# ID of the build.  Used in naming the build output.
+buildId="Do not touch here"
+
+# Label for the build.  Used in naming the build output
+buildLabel=${buildType}.${buildId}
+
+# Timestamp for the build.  Used in naming the build output
+timestamp=007
+
+#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
+#The value will only be applied to plugin or features indicating build.properties, qualifier = context 
+#forceContextQualifier=<the value for the qualifier>
+
+#Enable / disable the generation of a suffix for the features that use .qualifier. 
+#The generated suffix is computed according to the content of the feature   
+#generateFeatureVersionSuffix=true
+
+############# BASE CONTROL #############
+# Settings for the base Eclipse components and Java class libraries 
+# against which you are building.
+# Base location for anything the build needs to compile against.  For example,
+# in most RCP app or a plug-in,  the baseLocation should be the location of a previously
+# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
+
+base="Do not touch here"
+baseLocation="Do not touch here"
+
+
+#Folder containing repositories whose content is needed to compile against
+#repoBaseLocation=${base}/repos
+#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against
+#transformedRepoLocation=${base}/transformedRepos
+
+#Os/Ws/Arch/nl of the eclipse specified by baseLocation
+baseos=linux
+basews=gtk
+basearch=x86
+
+#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
+filteredDependencyCheck=false
+
+#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
+resolution.devMode=false
+
+#pluginPath is a list of locations in which to find plugins and features.  This list is separated by the platform file separator (; or :)
+#a location is one of:  
+#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
+#- a directory that contains a /plugins or /features subdirectory
+#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
+#pluginPath=
+
+skipBase=true
+eclipseURL=<url for eclipse download site>
+eclipseBuildId=<Id of Eclipse build to get>
+eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
+
+
+############# MAP FILE CONTROL ################
+# This section defines CVS tags to use when fetching the map files from the repository.
+# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
+
+skipMaps=true
+mapsRepo=:pserver:anonymous@example.com/path/to/repo
+mapsRoot=path/to/maps
+mapsCheckoutTag=HEAD
+
+#tagMaps=true
+mapsTagTag=v${buildId}
+
+
+############ REPOSITORY CONTROL ###############
+# This section defines properties parameterizing the repositories where plugins, fragments
+# bundles and features are being obtained from. 
+
+# The tags to use when fetching elements to build.
+# By default thebuilder will use whatever is in the maps.  
+# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the 
+# overriding value
+# For example fetchTag=CVS=HEAD, SVN=v20050101
+# fetchTag=HEAD
+skipFetch=true
+
+
+############# P2 OPTIONS ##############
+#p2.gathering = true
+#p2.compress=true
+
+############# JAVA COMPILER OPTIONS ##############
+# The location of the Java jars to compile against.  Typically the rt.jar for your JDK/JRE
+#bootclasspath=${java.home}/lib/rt.jar
+
+# specific JRE locations to compile against. These values are used to compile bundles specifying a 
+# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
+#CDC-1.0/Foundation-1.0= /path/to/rt.jar
+#CDC-1.1/Foundation-1.1=
+#OSGi/Minimum-1.0=
+#OSGi/Minimum-1.1=
+#JRE-1.1=
+#J2SE-1.2=
+#J2SE-1.3=
+#J2SE-1.4=
+#J2SE-1.5=
+#JavaSE-1.6=
+#PersonalJava-1.1=
+#PersonalJava-1.2=
+#CDC-1.0/PersonalBasis-1.0=
+#CDC-1.0/PersonalJava-1.0=
+#CDC-1.1/PersonalBasis-1.1=
+#CDC-1.1/PersonalJava-1.1=
+
+# Specify the output format of the compiler log when eclipse jdt is used
+logExtension=.log
+
+# Whether or not to include debug info in the output jars
+javacDebugInfo=false 
+
+# Whether or not to fail the build if there are compiler errors
+javacFailOnError=true
+
+# Enable or disable verbose mode of the compiler
+javacVerbose=true
+
+# Extra arguments for the compiler. These are specific to the java compiler being used.
+#compilerArg=
+
+# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
+javacSource=1.6
+
+# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
+javacTarget=1.6
+
+
diff --git a/builder/customTargets.xml b/builder/customTargets.xml
new file mode 100644 (file)
index 0000000..6a42e92
--- /dev/null
@@ -0,0 +1,187 @@
+<project name="Build specific targets and properties" default="noDefault">
+
+       <!-- ===================================================================== -->
+       <!-- Run a given ${target} on all elements being built -->
+       <!-- Add on <ant> task for each top level element being built. -->
+       <!-- ===================================================================== -->
+       <available property="allElementsFile" file="${builder}/allElements.xml" value="${builder}/allElements.xml"/>
+       <property name="allElementsFile" location="${eclipse.pdebuild.templates}/headless-build/allElements.xml"/>
+
+       <import file="${allElementsFile}" />
+       <target name="allElements">
+               <ant antfile="${genericTargets}" target="${target}">
+                       <property name="type" value="${topLevelElementType}"/>
+                       <property name="id" value="${topLevelElementId}"/>
+               </ant>
+       </target>
+
+       <target
+               name="assemble.${topLevelElementId}.linux.gtk.x86">
+               <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+       </target>
+       <target
+               name="assemble.${topLevelElementId}.win32.win32.x86">
+               <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/>
+       </target>
+       
+       <!-- ===================================================================== -->
+       <!-- ===================================================================== -->
+       <target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
+               <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" />
+               <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" />
+       </target>
+
+       <target name="checkLocalBase">
+               <available file="${base}" property="skipBase" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Check out map files from correct repository -->
+       <!-- Replace values for mapsCheckoutTag as desired. -->
+       <!-- ===================================================================== -->
+       <target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps">
+               <property name="mapsCheckoutTag" value="HEAD" />
+               <cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" />
+       </target>
+
+       <target name="checkLocalMaps">
+               <available property="skipMaps" file="${buildDirectory}/maps" />
+       </target>
+
+       <target name="tagMapFiles" if="tagMaps">
+               <cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" />
+       </target>
+
+       <!-- ===================================================================== -->
+
+       <target name="clean" unless="noclean">
+               <antcall target="allElements">
+                       <param name="target" value="cleanElement" />
+               </antcall>
+       </target>
+
+       <target name="gatherLogs">
+               <mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" />
+               <antcall target="allElements">
+                       <param name="target" value="gatherLogs" />
+               </antcall>
+               <unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true">
+                       <fileset dir="${buildDirectory}/features">
+                               <include name="**/*.log.zip" />
+                       </fileset>
+               </unzip>
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before setup -->
+       <!-- ===================================================================== -->
+       <target name="preSetup">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after setup but before starting the build proper -->
+       <!-- ===================================================================== -->
+       <target name="postSetup">
+               <antcall target="getBaseComponents" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before fetching the build elements -->
+       <!-- ===================================================================== -->
+       <target name="preFetch">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after fetching the build elements -->
+       <!-- ===================================================================== -->
+       <target name="postFetch">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before the repositories are being processed -->
+       <!-- ===================================================================== -->
+       <target name="preProcessRepos">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after the repositories have been processed -->
+       <!-- ===================================================================== -->
+       <target name="postProcessRepos">
+       </target>
+       
+       <!-- ===================================================================== -->
+       <!-- Steps to do before generating the build scripts. -->
+       <!-- ===================================================================== -->
+       <target name="preGenerate">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after generating the build scripts. -->
+       <!-- ===================================================================== -->
+       <target name="postGenerate">
+               <antcall target="clean" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running the build.xmls for the elements being built. -->
+       <!-- ===================================================================== -->
+       <target name="preProcess">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after running the build.xmls for the elements being built. -->
+       <!-- ===================================================================== -->
+       <target name="postProcess">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running assemble. -->
+       <!-- ===================================================================== -->
+       <target name="preAssemble">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after  running assemble. -->
+       <!-- ===================================================================== -->
+       <target name="postAssemble">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do before running package. -->
+       <!-- ===================================================================== -->
+       <target name="prePackage">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after  running package. -->
+       <!-- ===================================================================== -->
+       <target name="postPackage">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do after the build is done. -->
+       <!-- ===================================================================== -->
+       <target name="postBuild">
+               <antcall target="gatherLogs" />
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do to test the build results -->
+       <!-- ===================================================================== -->
+       <target name="test">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Steps to do to publish the build results -->
+       <!-- ===================================================================== -->
+       <target name="publish">
+       </target>
+
+       <!-- ===================================================================== -->
+       <!-- Default target                                                        -->
+       <!-- ===================================================================== -->
+       <target name="noDefault">
+               <echo message="You must specify a target when invoking this file" />
+       </target>
+
+</project>
diff --git a/builder/metadata/data/IDE/plugins/org.tizen.telephony.call_1.3.20.201202101837.jar b/builder/metadata/data/IDE/plugins/org.tizen.telephony.call_1.3.20.201202101837.jar
new file mode 100644 (file)
index 0000000..971ecc5
Binary files /dev/null and b/builder/metadata/data/IDE/plugins/org.tizen.telephony.call_1.3.20.201202101837.jar differ
diff --git a/builder/metadata/data/IDE/plugins/org.tizen.telephony.sms_1.3.20.201202101837.jar b/builder/metadata/data/IDE/plugins/org.tizen.telephony.sms_1.3.20.201202101837.jar
new file mode 100644 (file)
index 0000000..447f518
Binary files /dev/null and b/builder/metadata/data/IDE/plugins/org.tizen.telephony.sms_1.3.20.201202101837.jar differ
diff --git a/builder/metadata/pkginfo.manifest b/builder/metadata/pkginfo.manifest
new file mode 100644 (file)
index 0000000..8bbc440
--- /dev/null
@@ -0,0 +1,9 @@
+Package:EventInjector
+Version:1.1
+Architecture:i386
+Maintainer:juyung Kim <j0.kim@samsung.com>, jaewon lim <jaewon81.lim@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
+Description:EventInjector for emulator
+Install-script:
+Remove-script:
+Category:IDE/SLP IDE/Plugins/EventInjector
+Depends:
diff --git a/builder/metadata/web/pkginfo.manifest b/builder/metadata/web/pkginfo.manifest
new file mode 100644 (file)
index 0000000..9fa75b9
--- /dev/null
@@ -0,0 +1,8 @@
+Package:EventInjector_Web
+Version:1.1
+Architecture:i386
+Maintainer:dongkyun Yun <dk77.yun@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
+Description:EventInjector for emulator
+Install-script:
+Remove-script:
+Category:IDE/WEB IDE/Plugins/EventInjector
diff --git a/org.tizen.device/.classpath b/org.tizen.device/.classpath
new file mode 100644 (file)
index 0000000..121e527
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.device/.project b/org.tizen.device/.project
new file mode 100644 (file)
index 0000000..d1e624e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.device</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.device/.settings/org.eclipse.jdt.core.prefs b/org.tizen.device/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..71c4657
--- /dev/null
@@ -0,0 +1,8 @@
+#Tue Oct 04 17:29:44 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.device/META-INF/MANIFEST.MF b/org.tizen.device/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..6480f6d
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Device
+Bundle-SymbolicName: org.tizen.device;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.tizen.injector,
+ org.eclipse.swt;bundle-version="3.6.2",
+ org.tizen.common,
+ org.tizen.common.connection,
+ org.eclipse.core.runtime;bundle-version="3.7.0"
+Import-Package: org.tizen.sdblib,
+ org.eclipse.ui.plugin
diff --git a/org.tizen.device/build.properties b/org.tizen.device/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.device/plugin.xml b/org.tizen.device/plugin.xml
new file mode 100644 (file)
index 0000000..67f0909
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Device"
+            class="org.tizen.device.battery.Battery"
+            id="org.tizen.device.battery"
+            name="Battery">
+      </itemType>
+   </extension>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Device"
+            class="org.tizen.device.earjack.Earjack"
+            id="org.tizen.device.earjack"
+            name="EarJack">
+      </itemType>
+   </extension>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Device"
+            class="org.tizen.device.usb.Usb"
+            id="org.tizen.device.usb"
+            name="USB">
+      </itemType>
+   </extension>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Device"
+            class="org.tizen.device.rssi.Rssi"
+            id="org.tizen.device.rssi"
+            name="RSSI">
+      </itemType>
+   </extension>
+
+</plugin>
diff --git a/org.tizen.device/src/org/tizen/device/battery/Battery.java b/org.tizen.device/src/org/tizen/device/battery/Battery.java
new file mode 100644 (file)
index 0000000..0dfad4d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * org.tizen.device.battery
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.battery;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.device.battery.page.BatteryPage;
+
+public class Battery extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new BatteryPage(this, "Battery"));
+       }
+
+}
diff --git a/org.tizen.device/src/org/tizen/device/battery/page/BatteryConstants.java b/org.tizen.device/src/org/tizen/device/battery/page/BatteryConstants.java
new file mode 100644 (file)
index 0000000..e7ee27d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * org.tizen.device.battery
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.battery.page;
+
+public class BatteryConstants {
+       public static final String Connect = "Connect";
+       public static final String Disconnect = "Disconnect";
+}
diff --git a/org.tizen.device/src/org/tizen/device/battery/page/BatteryPage.java b/org.tizen.device/src/org/tizen/device/battery/page/BatteryPage.java
new file mode 100644 (file)
index 0000000..e4ac294
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * org.tizen.device.battery
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.battery.page;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Text;
+
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+
+public class BatteryPage extends AbstractInjectorPage implements ISelectionListener {  
+       private Text sliderText;
+       private Slider slider;
+       private final String levelNumber = "8\n";
+       private final String batteryLevel = "Level    : ";
+       private final String batteryCharger = "Charger : ";
+       private int sendData = 100;
+       private Button radioButton[];
+       private int sensorOn;
+       private IDevice currentDevice;
+       
+       public BatteryPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents() {
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               sensorOn = 0;
+               
+               Composite mainComposite = formUtil.createComposite(parent, 3);
+               formUtil.createLabel(mainComposite, batteryLevel);
+               slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
+               slider.setValues(100, 1, 101, 1, 1, 1);
+               slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+               sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
+               sliderText.setEditable(false);
+               GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
+               gd.widthHint = 24;
+               sliderText.setLayoutData(gd);
+               sendData = slider.getSelection();
+               slider.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendData = slider.getSelection();
+                               sliderText.setText(Integer.toString(sendData));
+                               sendMessage(sendData, sensorOn);
+                       }
+               });
+               
+               Composite secondComposite = formUtil.createComposite(parent, 5);
+               formUtil.createLabel(secondComposite, batteryCharger);
+               radioButton = new Button[2];
+               radioButton[0] = formUtil.createButton(secondComposite, BatteryConstants.Connect, SWT.RADIO);
+               radioButton[1] = formUtil.createButton(secondComposite, BatteryConstants.Disconnect, SWT.RADIO);
+               radioButton[1].setSelection(true);
+               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                       if(radioButton[i].getSelection()) {
+                               if( i == 0 ) { // On
+                                       sensorOn = 1;
+                               }
+                               else {  // Off
+                                       sensorOn = 0;
+                               }
+                       }
+               }
+               
+               radioButton[0].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                                       if(radioButton[i].getSelection()) {
+                                               if( i == 0 ) { // On
+                                                       sensorOn = 1;
+                                               }
+                                               else {  // Off
+                                                       sensorOn = 0;
+                                               }
+                                       }
+                               super.widgetSelected(e);
+                               sendMessage(sendData, sensorOn);
+                               }
+                       }
+               });
+
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+       
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       public void sendMessage(int level, int charger) {
+                       TestSensorMessage msg = new TestSensorMessage(level, charger);
+                       try {
+                       //      sensorSocket.send(levelNumber + msg.getMessage());
+                               injectorSocket.sendSensor(levelNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+       }
+
+//     @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               sendMessage(sendData, sensorOn);
+       }
+}
diff --git a/org.tizen.device/src/org/tizen/device/earjack/Earjack.java b/org.tizen.device/src/org/tizen/device/earjack/Earjack.java
new file mode 100644 (file)
index 0000000..4fd26e9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * org.tizen.device.earjack
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.earjack;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.device.earjack.page.EarjackPage;
+
+public class Earjack extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new EarjackPage(this, "Earjack"));
+               
+       }
+
+}
diff --git a/org.tizen.device/src/org/tizen/device/earjack/page/EarjackConstants.java b/org.tizen.device/src/org/tizen/device/earjack/page/EarjackConstants.java
new file mode 100644 (file)
index 0000000..ed16665
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * org.tizen.device.earjack
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.earjack.page;
+
+public class EarjackConstants {
+       public static final String wire3= "3 Wire";
+       public static final String wire4 = "4 Wire";
+       public static final String disconnect = "Disconnect";
+}
diff --git a/org.tizen.device/src/org/tizen/device/earjack/page/EarjackPage.java b/org.tizen.device/src/org/tizen/device/earjack/page/EarjackPage.java
new file mode 100644 (file)
index 0000000..52c0268
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * org.tizen.device.earjack
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.earjack.page;
+
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.SWT;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class EarjackPage extends AbstractInjectorPage implements ISelectionListener {
+
+       private Button radioButton[];
+       private final String sensorNumber = "9\n";
+       private int earjack_status, tmp_status = -1;
+       private IDevice currentDevice;
+       
+       public EarjackPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       protected void createContents() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               
+               Composite mainComposite = formUtil.createComposite(parent, 6);
+               radioButton = new Button[3];
+               radioButton[0] = formUtil.createButton(mainComposite, EarjackConstants.wire3, SWT.RADIO);
+               radioButton[1] = formUtil.createButton(mainComposite, EarjackConstants.wire4, SWT.RADIO);
+               radioButton[2] = formUtil.createButton(mainComposite, EarjackConstants.disconnect, SWT.RADIO);
+               radioButton[2].setSelection(true);
+               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                       if(radioButton[i].getSelection()) {
+                               if( i == 0 )    // 3wire
+                                       earjack_status = 1;
+                               else if(i == 1)  // 4wire
+                                       earjack_status = 3;
+                               else
+                                       earjack_status = 0;
+                       }
+               }
+               
+               radioButton[0].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                                       if(radioButton[i].getSelection()) {
+                                               if( i == 0 )    // 3wire
+                                                       earjack_status = 1;
+                                               else if(i == 1)  // 4wire
+                                                       earjack_status = 3;
+                                               else
+                                                       earjack_status = 0;
+                                       }
+                               super.widgetSelected(e);
+                               sendMessage(earjack_status);
+                               }
+                       }
+               });
+               
+               radioButton[1].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                                       if(radioButton[i].getSelection()) {
+                                               if( i == 0 )    // 3wire
+                                                       earjack_status = 1;
+                                               else if(i == 1)  // 4wire
+                                                       earjack_status = 3;
+                                               else
+                                                       earjack_status = 0;
+                                       }
+                               super.widgetSelected(e);
+                               sendMessage(earjack_status);
+                               }
+                       }
+               });
+               
+               radioButton[2].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                                       if(radioButton[i].getSelection()) {
+                                               if( i == 0 )    // 3wire
+                                                       earjack_status = 1;
+                                               else if(i == 1)  // 4wire
+                                                       earjack_status = 3;
+                                               else
+                                                       earjack_status = 0;
+                                       }
+                               super.widgetSelected(e);
+                               sendMessage(earjack_status);
+                               }
+                       }
+               });
+
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+       
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public void sendMessage(int status) {
+               if(tmp_status != status)
+               {
+                       TestSensorMessage msg = new TestSensorMessage(status);
+                       try {
+                       //      sensorSocket.send(sensorNumber + msg.getMessage());
+                               injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+                       tmp_status = status;
+               }
+       }
+
+//     @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               sendMessage(earjack_status);
+       }
+}
diff --git a/org.tizen.device/src/org/tizen/device/rssi/Rssi.java b/org.tizen.device/src/org/tizen/device/rssi/Rssi.java
new file mode 100644 (file)
index 0000000..eaae186
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * org.tizen.device.rssi
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.rssi;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.device.rssi.page.RssiPage;
+
+public class Rssi extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new RssiPage(this, "Rssi"));
+       }
+
+}
diff --git a/org.tizen.device/src/org/tizen/device/rssi/page/RssiPage.java b/org.tizen.device/src/org/tizen/device/rssi/page/RssiPage.java
new file mode 100644 (file)
index 0000000..884f486
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * org.tizen.device.rssi
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.rssi.page;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Text;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class RssiPage extends AbstractInjectorPage implements ISelectionListener {     
+       private Text sliderText;
+       private Slider slider;
+       private final String levelNumber = "11\n";
+       private final String rssiLevel = "Level    : ";
+       private int sendData = -1; // initial level
+       private IDevice currentDevice;
+       
+       public RssiPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               
+               Composite mainComposite = formUtil.createComposite(parent, 3);
+               formUtil.createLabel(mainComposite, rssiLevel);
+               slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
+               slider.setValues(6, 0, 7, 1, 1, 1);
+               slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+               sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
+               sliderText.setEditable(false);
+               GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
+               gd.widthHint = 10;
+               sliderText.setLayoutData(gd);
+               sendData = slider.getSelection();
+               slider.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendData = slider.getSelection();
+                               sliderText.setText(Integer.toString(sendData));
+                               sendLevelMessage(sendData);
+                       }
+               });
+               
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+       
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       public void sendLevelMessage(int level) {
+                       TestSensorMessage msg = new TestSensorMessage(level);
+                       try {
+                       //      sensorSocket.send(levelNumber + msg.getMessage());
+                               injectorSocket.sendSensor(levelNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+       }
+
+//     @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               sendLevelMessage(sendData);
+       }
+}
diff --git a/org.tizen.device/src/org/tizen/device/usb/Usb.java b/org.tizen.device/src/org/tizen/device/usb/Usb.java
new file mode 100644 (file)
index 0000000..a84881a
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * org.tizen.device.usb
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.usb;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.device.usb.page.UsbPage;
+
+public class Usb extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new UsbPage(this, "Usb"));
+               
+       }
+
+}
diff --git a/org.tizen.device/src/org/tizen/device/usb/page/UsbConstants.java b/org.tizen.device/src/org/tizen/device/usb/page/UsbConstants.java
new file mode 100644 (file)
index 0000000..da0d6fb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * org.tizen.device.usb
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.usb.page;
+
+public class UsbConstants {
+       public static final String inject = "Connect";
+       public static final String remove = "Disconnect";
+}
diff --git a/org.tizen.device/src/org/tizen/device/usb/page/UsbPage.java b/org.tizen.device/src/org/tizen/device/usb/page/UsbPage.java
new file mode 100644 (file)
index 0000000..2869dc7
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * org.tizen.device.usb
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.device.usb.page;
+
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.SWT;
+
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class UsbPage extends AbstractInjectorPage implements ISelectionListener {
+
+       private Button radioButton[];
+       private final String sensorNumber = "10\n";
+       private boolean sensorOn;
+       private IDevice currentDevice;
+       
+       public UsbPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       protected void createContents() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               sensorOn = false;
+       
+               Composite mainComposite = formUtil.createComposite(parent, 5);
+               radioButton = new Button[2];
+               radioButton[0] = formUtil.createButton(mainComposite, UsbConstants.inject, SWT.RADIO);
+               radioButton[1] = formUtil.createButton(mainComposite, UsbConstants.remove, SWT.RADIO);
+               radioButton[1].setSelection(true);
+               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                       if(radioButton[i].getSelection()) {
+                               if( i == 0 )  // On
+                                       sensorOn = true;
+                               else            // Off
+                                       sensorOn = false;
+                       }
+               }
+
+               radioButton[0].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               for( int i = 0 ; i < radioButton.length ; i++ ) {
+                                       if(radioButton[i].getSelection()) {
+                                               if( i == 0 ) { // On
+                                                       sensorOn = true;
+                                               }
+                                               else {  // Off
+                                                       sensorOn = false;
+                                               }
+                                       }
+                               super.widgetSelected(e);
+                               if( sensorOn ) { // On
+                                       sendMessage(1);
+                               }
+                               else {  // Off
+                                       sendMessage(0);
+                               }
+                               }
+                       }
+               });
+               
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+       
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public void sendMessage(int status) {
+                       TestSensorMessage msg = new TestSensorMessage(status);
+                       try {
+                       //      sensorSocket.send(sensorNumber + msg.getMessage());
+                               injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+       }
+
+//     @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               if( sensorOn ) // On
+                       sendMessage(1);
+               else                             // Off
+                       sendMessage(0);
+       }
+}
diff --git a/org.tizen.eventinjector.feature/.project b/org.tizen.eventinjector.feature/.project
new file mode 100644 (file)
index 0000000..bbf55d3
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.eventinjector.feature</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.FeatureBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.FeatureNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.eventinjector.feature/build.properties b/org.tizen.eventinjector.feature/build.properties
new file mode 100644 (file)
index 0000000..b3a611b
--- /dev/null
@@ -0,0 +1,2 @@
+bin.includes = feature.xml,\
+               feature.properties
diff --git a/org.tizen.eventinjector.feature/feature.properties b/org.tizen.eventinjector.feature/feature.properties
new file mode 100644 (file)
index 0000000..cc442a1
--- /dev/null
@@ -0,0 +1,52 @@
+###############################################################################
+# Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd.
+# All rights reserved. This program and the accompanying materials 
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#      S-Core Co., Ltd
+###############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=Tizen Event Injector
+
+# "providerName" property - name of the company that provides the feature
+providerName=Tizen
+
+# "updateSiteName" property - label for the update site
+updateSiteName=Tizen Event Injector Updates
+
+# "description" property - description of the feature
+description=Tizen SDK's Event Injector.
+
+# "copyright" property
+copyrightURL=https://developer.tizen.org
+copyright=Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd.\n\
+All rights reserved.\n
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Tizen SDK\n\
+\n\
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components.  All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.\n\
+ \n\
+The licenses governing the Open Source Software are available at: http://developer.tizen.org/download/tizen_sdk_opensource_license.html\n\
+ \n\
+Except for the Open Source Software contained in Tizen SDK, all other software portions contained in Tizen SDK are governed by the terms and conditions of the Tizen Software Development Kit License Agreement, available at: http://developer.tizen.org/download/samsung_sdk_license.html\n\
+ \n\
+You may access and download Tizen SDK Open Source Software at: http://developer.tizen.org/download/tizenopensdk.tar.gz\n\
+ \n\
+BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS AND THE TIZEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT. IF YOU DO NOT AGREE WITH THE OPEN SOURCE SOFTWARE LICENSE TERMS OR THE TIZEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT, YOU MAY NOT DOWNLOAD OR USE TIZEN SDK.\n
+########### end of license property ##########################################
diff --git a/org.tizen.eventinjector.feature/feature.xml b/org.tizen.eventinjector.feature/feature.xml
new file mode 100644 (file)
index 0000000..c375214
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.tizen.eventinjector.feature"
+      label="Tizen Event Injector"
+      version="1.1.0.qualifier"
+      provider-name="Tizen"
+      plugin="org.tizen.base.platform"
+      license-feature="org.tizen.base.feature">
+
+   <description>
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <license url="">
+      %license
+   </license>
+
+   <plugin
+         id="org.tizen.injector"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.location.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.device"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.location.log"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.location.manual"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.location.map"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.sensor.motion"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.sensor.accelerometer"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.sensor.light"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.sensor.proximity"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.tizen.nfc"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>
diff --git a/org.tizen.injector/.classpath b/org.tizen.injector/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.injector/.project b/org.tizen.injector/.project
new file mode 100644 (file)
index 0000000..f5cae62
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.injector</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.injector/.settings/org.eclipse.core.resources.prefs b/org.tizen.injector/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..1319378
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:07:09 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.tizen.injector/.settings/org.eclipse.core.runtime.prefs b/org.tizen.injector/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..25618a5
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:28:54 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.injector/META-INF/MANIFEST.MF b/org.tizen.injector/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..1d2a129
--- /dev/null
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Injector
+Bundle-SymbolicName: org.tizen.injector;singleton:=true
+Bundle-Version: 1.3.20.qualifier
+Bundle-Vendor: Tizen
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.ide,
+ org.eclipse.core.resources,
+ org.eclipse.core.filesystem,
+ org.tizen.common,
+ org.eclipse.ui.forms;bundle-version="3.3.103"
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.tizen.injector.Injector
+Export-Package: org.tizen.injector.protocol,
+ org.tizen.injector.protocol.sensor,
+ org.tizen.injector.provider,
+ org.tizen.injector.receiver,
+ org.tizen.injector.socket,
+ org.tizen.injector.util,
+ org.tizen.injector.view
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.tizen.common.connection,
+ org.tizen.common.util
diff --git a/org.tizen.injector/OSGI-INF/l10n/bundle.properties b/org.tizen.injector/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..f51d150
--- /dev/null
@@ -0,0 +1,5 @@
+#Properties file for org.tizen.injector
+view.name = Event Injector
+extension-point.name = InjectorItemProvider
+Bundle-Vendor = Tizen
+Bundle-Name = Tizen SDK Injector
\ No newline at end of file
diff --git a/org.tizen.injector/build.properties b/org.tizen.injector/build.properties
new file mode 100644 (file)
index 0000000..4fc24ed
--- /dev/null
@@ -0,0 +1,9 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               icons/,\\r
+               OSGI-INF/l10n/bundle.properties\r
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.tizen.injector/icons/connect.png b/org.tizen.injector/icons/connect.png
new file mode 100644 (file)
index 0000000..629a338
Binary files /dev/null and b/org.tizen.injector/icons/connect.png differ
diff --git a/org.tizen.injector/icons/disconnect.png b/org.tizen.injector/icons/disconnect.png
new file mode 100644 (file)
index 0000000..c75f909
Binary files /dev/null and b/org.tizen.injector/icons/disconnect.png differ
diff --git a/org.tizen.injector/icons/injector_view.png b/org.tizen.injector/icons/injector_view.png
new file mode 100644 (file)
index 0000000..d87e1cb
Binary files /dev/null and b/org.tizen.injector/icons/injector_view.png differ
diff --git a/org.tizen.injector/plugin.xml b/org.tizen.injector/plugin.xml
new file mode 100644 (file)
index 0000000..2f36167
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.2"?>\r
+<plugin>\r
+ <extension-point id="injectorItemProvider" \r
+       name="%extension-point.name" schema="schema/injectorItemProvider.exsd"/>\r
+   <extension point="org.eclipse.ui.perspectiveExtensions">
+     <perspectiveExtension targetID="org.tizen.nativeapp.perspective">\r
+         <view ratio="0.5" relative="org.eclipse.ui.views.ContentOutline"\r
+               relationship="stack" id="org.tizen.injector.view.InjectorView">\r
+         </view>\r
+         <viewShortcut\r
+               id="org.tizen.injector.view.InjectorView">\r
+         </viewShortcut>\r
+      </perspectiveExtension>\r
+   </extension> \r
+ <extension\r
+         point="org.eclipse.ui.views">\r
+               <category\r
+                       name="%view.name"\r
+                       id="org.tizen.injector.ViewCategory"/>\r
+      <view\r
+            category="org.tizen.nativeapp.viewCategory"\r
+            class="org.tizen.injector.view.InjectorView"    \r
+            id="org.tizen.injector.view.InjectorView"\r
+            name="%view.name"/>\r
+</extension>\r
+<extension\r
+               point="org.eclipse.ui.services">\r
+               <sourceProvider\r
+                       provider="org.tizen.injector.sourceProvider.InjectorStateProvider">\r
+                       <variable\r
+                               name="org.tizen.injector.sourceProvider.InjectorState"\r
+                               priorityLevel="workbench">\r
+                       </variable>\r
+               </sourceProvider>\r
+       </extension>     \r
+</plugin>\r
diff --git a/org.tizen.injector/schema/injectorItemProvider.exsd b/org.tizen.injector/schema/injectorItemProvider.exsd
new file mode 100644 (file)
index 0000000..bc5bc72
--- /dev/null
@@ -0,0 +1,115 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.tizen.injector" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.tizen.injector" id="injectorItemProvider" name="InjectorItemProvider"/>
+      </appInfo>
+      <documentation>
+         An extension point to provide category item to Function View.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="itemType" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="itemType">
+      <complexType>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="category">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+            <simpleType>
+               <restriction base="string">
+                  <enumeration value="Telephony">
+                  </enumeration>
+                  <enumeration value="Location">
+                  </enumeration>
+                  <enumeration value="Sensor">
+                  </enumeration>
+                  <enumeration value="Device">
+                  </enumeration>
+                 <enumeration value="Nfc">
+                  </enumeration>
+               </restriction>
+            </simpleType>
+         </attribute>
+         <attribute name="icon" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.tizen.injector.provider.AbstractInjectorItem:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+
+
+
+
+
+</schema>
diff --git a/org.tizen.injector/src/org/tizen/injector/DebugLog.java b/org.tizen.injector/src/org/tizen/injector/DebugLog.java
new file mode 100644 (file)
index 0000000..3356c77
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector;
+
+public class DebugLog {
+       
+       public static void log(Object msg) {
+               System.out.println("[INJECTOR] " + msg);
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/Injector.java b/org.tizen.injector/src/org/tizen/injector/Injector.java
new file mode 100644 (file)
index 0000000..c3b0497
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Injector extends AbstractUIPlugin {
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.tizen.injector"; //$NON-NLS-1$
+
+       // The shared instance
+       private static Injector plugin;
+       
+       /**
+        * The constructor
+        */
+       public Injector() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        *
+        * @return the shared instance
+        */
+       public static Injector getDefault() {
+               return plugin;
+       }
+       
+       public ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(PLUGIN_ID, path);
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/AbstractGA.java b/org.tizen.injector/src/org/tizen/injector/protocol/AbstractGA.java
new file mode 100644 (file)
index 0000000..1105db5
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+import java.nio.ByteBuffer;
+
+import org.tizen.injector.util.ByteUtil;
+import org.tizen.injector.util.StringUtil;
+
+abstract public class AbstractGA {
+
+       private static final int SINGLE_ROW_INDEX = 0;
+
+       private int groupId;
+       private int actionId;
+       private int length = 0;
+       private StructureGA header;
+       private StructureGA body;
+
+       public AbstractGA(int groupId, int actionId) {
+               this.groupId = groupId;
+               this.actionId = actionId;
+       }
+
+       abstract protected void makeBody();
+
+       abstract protected void makeHeader();
+
+       public void intialize() {
+               header = new StructureGA();
+               makeHeader();
+               body = new StructureGA();
+               makeBody();
+       }
+
+       public void intialize(byte[] packet) {
+               ByteBuffer byteBuffer = ByteUtil.getByteBuffer(packet);
+               AbstractItem item = null;
+               length = packet.length;
+
+               header = new StructureGA();
+               makeHeader();
+               for (int j = 0; j < header.getItemCount(); j++) {
+                       item = header.getItem(j);
+                       putBufferToItem(item, SINGLE_ROW_INDEX, byteBuffer);
+               }
+
+               body = new StructureGA();
+               makeBody();
+
+               int loopCount = getLoopCount();
+               body.setLoopCount(loopCount);
+
+               for (int i = 0; i < loopCount; i++) {
+                       for (int j = 0; j < body.getItemCount(); j++) {
+                               item = body.getItem(j);
+                               putBufferToItem(item, i, byteBuffer);
+                       }
+               }
+       }
+
+       private int getLoopCount() {
+               return (int) Math.ceil((double) (length - header.getByteLength())
+                               / body.getByteLength());
+       }
+
+       public byte[] makeStarterPacket() {
+               int byteLength = getSendLength();
+
+               ByteBuffer buffer = ByteUtil.getByteBuffer(4);
+
+               buffer.putShort((short) byteLength);
+               buffer.put(((Integer) groupId).byteValue());
+               buffer.put(((Integer) actionId).byteValue());
+               return buffer.array();
+       }
+
+       public byte[] makePacket() {
+               int byteLength = getSendLength();
+
+               ByteBuffer buffer = ByteUtil.getByteBuffer(byteLength);
+
+               AbstractItem item = null;
+               for (int j = 0; j < header.getItemCount(); j++) {
+                       item = header.getItem(j);
+                       putItemToBuffer(item, SINGLE_ROW_INDEX, buffer);
+               }
+
+               for (int i = 0; i < body.getLoopCount(); i++) {
+                       for (int j = 0; j < body.getItemCount(); j++) {
+                               item = body.getItem(j);
+                               putItemToBuffer(item, i, buffer);
+                       }
+               }
+
+               return buffer.array();
+       }
+
+       private void putItemToBuffer(AbstractItem item, int idx, ByteBuffer buffer) {
+               ItemType type = item.getType();
+               if (type == ItemType.BYTE) {
+                       buffer.put(getIntValue(item, idx).byteValue());
+               } else if (type == ItemType.SHORT) {
+                       buffer.putShort(getIntValue(item, idx).shortValue());
+               } else if (type == ItemType.INT) {
+                       buffer.putInt(getIntValue(item, idx));
+               } else if (type == ItemType.ByteArray) {
+                       byte[] buf = ((ByteArrayItem) item).getValue(idx);
+                       int length = item.getByteLength();
+                       int pos = buffer.position();
+
+                       if (buf.length > length) {
+                               buffer.put(buf, 0, length);
+                       } else {
+                               buffer.put(buf);
+                       }
+
+                       buffer.position(pos + length);
+               }
+       }
+
+       private Integer getIntValue(AbstractItem item, int idx) {
+               return ((IntItem) item).getValue(idx);
+       }
+
+       private void putBufferToItem(AbstractItem item, int idx, ByteBuffer buffer) {
+               ItemType type = item.getType();
+               try{
+               if (type == ItemType.BYTE) {
+                       ((IntItem) item).setValue(idx, buffer.get() & 0xff);
+               } else if (type == ItemType.SHORT) {
+                       ((IntItem) item).setValue(idx, buffer.getShort());
+               } else if (type == ItemType.INT) {
+                       ((IntItem) item).setValue(idx, buffer.getInt());
+               } else if (type == ItemType.ByteArray) {
+                       int length = item.getByteLength();
+                       int remain = buffer.remaining();
+
+                       byte[] buf = null;
+                       if (length > remain) {
+                               buf = new byte[remain];
+                       } else {
+                               if(item.getName() == "CALL_NUMBER")
+                                       buf = new byte[remain];
+                               else
+                                       buf = new byte[length];
+                       }
+
+                       buffer.get(buf, 0, buf.length);
+                       ((ByteArrayItem) item).setValue(idx, buf);
+               }
+               } catch(Exception e){
+                       e.printStackTrace();
+               }
+       }
+
+       public String getKey() {
+               return StringUtil.makeKey(groupId, actionId);
+       }
+
+       public int getSendLength() {
+               return header.getByteLength() + body.getByteLength()
+                               * body.getLoopCount();
+       }
+
+       public int getReceiveLength() {
+               return this.length;
+       }
+
+       public StructureGA getBody() {
+               return body;
+       }
+
+       public StructureGA getHeader() {
+               return header;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/AbstractItem.java b/org.tizen.injector/src/org/tizen/injector/protocol/AbstractItem.java
new file mode 100644 (file)
index 0000000..961a5e5
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+public class AbstractItem {
+       private ItemType type;
+       private int length;
+       private String name;
+       
+       
+       public AbstractItem(ItemType type, String name, int length){
+//             if(this.type!=ItemType.CHAR)
+//                     throw new InvalidTypeException("CHAR type should be created by the constructor,  IntItem(ItemType type, String name, int length)");
+               this.type = type;
+               this.name = name;
+               this.length = length;
+       }
+       
+       public ItemType getType() {
+               return type;
+       }
+       
+       public int getByteLength() {
+               return length;
+       }
+       
+       public String getName() {
+               return name;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/ByteArrayItem.java b/org.tizen.injector/src/org/tizen/injector/protocol/ByteArrayItem.java
new file mode 100644 (file)
index 0000000..7a402c0
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+import java.util.ArrayList;
+
+public class ByteArrayItem extends AbstractItem {
+       private ArrayList<byte[]> value;
+
+       public ByteArrayItem(ItemType type, String name, int length) {
+               super(type, name, length);
+               this.value = new ArrayList<byte[]>();
+       }
+
+       public void setValue(int idx, byte[] value) {
+               this.value.add(value);
+       }
+
+       public byte[] getValue(int idx) {
+               return this.value.get(idx);
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/IntItem.java b/org.tizen.injector/src/org/tizen/injector/protocol/IntItem.java
new file mode 100644 (file)
index 0000000..348b1a4
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+import java.util.ArrayList;
+
+public class IntItem extends AbstractItem {
+       private ArrayList<Integer> value;
+
+       public IntItem(ItemType type, String name, int length) {
+               super(type, name, length);
+               this.value = new ArrayList<Integer>();
+       }
+
+       public void setValue(int idx, int value) {
+               this.value.add(value);
+       }
+
+       public int getValue(int idx) {
+               return this.value.get(idx);
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/InvalidTypeException.java b/org.tizen.injector/src/org/tizen/injector/protocol/InvalidTypeException.java
new file mode 100644 (file)
index 0000000..5d22abf
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+@SuppressWarnings("serial")
+public class InvalidTypeException extends Exception {
+
+       public InvalidTypeException(String message) {
+               super(message);
+       }
+
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/ItemType.java b/org.tizen.injector/src/org/tizen/injector/protocol/ItemType.java
new file mode 100644 (file)
index 0000000..af9c7e9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+public enum ItemType {
+       BYTE, SHORT, INT, ByteArray
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/StructureGA.java b/org.tizen.injector/src/org/tizen/injector/protocol/StructureGA.java
new file mode 100644 (file)
index 0000000..1944f87
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol;
+
+import java.util.ArrayList;
+
+import org.tizen.injector.util.ByteUtil;
+
+public class StructureGA {
+       
+       public static final int SINGLE_ROW_INDEX = 0;
+       
+       private int loopCount = 1;
+       private ArrayList<AbstractItem> list;
+       
+       public StructureGA(){
+               list = new ArrayList<AbstractItem>();
+       }
+       
+       public void addShortItem(String name) {
+               list.add(new IntItem(ItemType.SHORT, name, ByteUtil.SHORT_LENGTH));
+       }
+       
+       public void addByteItem(String name) {
+               list.add(new IntItem(ItemType.BYTE, name, ByteUtil.BYTE_LENGTH));
+       }
+       
+       public void addIntItem(String name) {
+               list.add(new IntItem(ItemType.INT, name, ByteUtil.INT_LENGTH));
+       }
+
+       public void addByteArrayItem(String name, int length) {
+               list.add(new ByteArrayItem(ItemType.ByteArray, name, length));
+       }
+       
+       public int getByteLength(){
+               int sum = 0;
+               for(int i=0; i<list.size(); i++) {
+                       sum += list.get(i).getByteLength();
+               }
+               return sum;
+       }
+       
+       public void setByteArray(String name, byte[] value){
+               setByteArray(name, SINGLE_ROW_INDEX, value);
+       }
+
+       public void setByteArray(String name, int idx, byte[] value){
+               ByteArrayItem item = (ByteArrayItem)getItem(name);
+               if(item==null)
+                       return;
+               
+               item.setValue(idx, value);
+       }
+       
+       public void setInt(String name, int value){
+               setInt(name, SINGLE_ROW_INDEX, value);
+       };
+       
+       public void setInt(String name, int idx, int value){
+               IntItem item = (IntItem)getItem(name);
+               if(item==null)
+                       return;
+               
+               item.setValue(idx, value);
+       }
+       
+       public byte[] getByteArray(String name){
+               return getByteArray(name, SINGLE_ROW_INDEX);
+       }
+       
+       public byte[] getByteArray(String name, int idx){
+               ByteArrayItem item = (ByteArrayItem)getItem(name);
+               if(item==null)
+                       return null;
+               
+               return item.getValue(idx);
+       }
+       
+       public int getInt(String name){
+               return getInt(name, SINGLE_ROW_INDEX);
+       }
+       
+       public int getInt(String name, int idx){
+               IntItem item = (IntItem)getItem(name);
+               if(item==null)
+                       return 0;
+               
+               return item.getValue(idx);
+       }
+       
+       
+       private AbstractItem getItem(String name){
+               if(name==null)
+                       return null;
+               
+               AbstractItem result = null;
+               for(int i=0;i<list.size();i++){
+                       AbstractItem item = list.get(i);
+                       if(name.equals(item.getName())){
+                               result= item;
+                               break;
+                       }
+               }
+               
+               return result;
+       }
+       
+       public AbstractItem getItem(int idx){
+               return list.get(idx);
+       }
+       
+       public int getItemCount(){
+               return list.size();
+       }
+       
+       
+       public void setLoopCount(int loopCount){
+               this.loopCount = loopCount;
+       }
+       
+       public int getLoopCount(){
+               return this.loopCount;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/sensor/AbstractSenserMessage.java b/org.tizen.injector/src/org/tizen/injector/protocol/sensor/AbstractSenserMessage.java
new file mode 100644 (file)
index 0000000..3cf451f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol.sensor;
+
+public abstract class AbstractSenserMessage {
+       public String getMessage() {
+               return "TEST";
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/protocol/sensor/TestSensorMessage.java b/org.tizen.injector/src/org/tizen/injector/protocol/sensor/TestSensorMessage.java
new file mode 100644 (file)
index 0000000..5a502b4
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.protocol.sensor;
+
+public class TestSensorMessage extends AbstractSenserMessage {
+       private double param[];
+       private int paramCount;
+       
+       public TestSensorMessage(double x, double y, double z, double a, double b, double c, double d){
+               param = new double[7];
+               param[0] = x;
+               param[1] = y;
+               param[2] = z;
+               param[3] = a;
+               param[4] = b;
+               param[5] = c;
+               param[6] = d;
+               paramCount = 7;
+                       
+       }
+       public TestSensorMessage(double x, double y, double z) {
+               param = new double[3];
+               param[0] = x;
+               param[1] = y;
+               param[2] = z;
+               paramCount = 3;
+       }
+       public TestSensorMessage(int level) {
+               param = new double[1];
+               param[0] = level;
+               paramCount = 1;
+       }
+       public TestSensorMessage(int level, int charger) {
+               param = new double[2];
+               param[0] = level;
+               param[1] = charger;
+               paramCount = 2;
+       }
+       
+       public String getMessage() {
+               String message;
+               message = paramCount + "\n";
+               for( int i = 0 ; i < param.length ; i++) {
+                       message += (Double.toString(param[i]) + "\n");
+               }
+               return message;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorItem.java b/org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorItem.java
new file mode 100644 (file)
index 0000000..9f1af32
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.provider;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+import org.tizen.injector.util.FormPageUtil;
+import org.tizen.injector.view.InjectorView;
+
+public abstract class AbstractInjectorItem {
+       private InjectorView view;
+       
+       private ArrayList<AbstractInjectorPage> pageList = new ArrayList<AbstractInjectorPage>();
+       
+       public void createContents(Composite parent, FormPageUtil formUtil){
+               addPages();
+                       
+               TabFolder tabFolder = new TabFolder(parent, SWT.BORDER);
+               tabFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               tabFolder.addListener(SWT.MouseWheel, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               event.doit = false;
+                       }
+               });
+               
+               for(int i = 0; i < pageList.size(); i++){
+                       Composite composite = formUtil.createComposite(tabFolder);
+                       composite.setData(new GridData(GridData.FILL_HORIZONTAL));//new GridData(GridData.FILL, GridData.FILL, true, true));
+                       AbstractInjectorPage page = pageList.get(i);
+                       page.initialize(composite, formUtil);
+                       page.create();
+                       
+                       TabItem tab = new TabItem(tabFolder, SWT.NULL);
+                       tab.setText(page.getName());
+                       tab.setControl(composite);
+               }
+       }
+       
+       protected void addPage(AbstractInjectorPage page){
+               pageList.add(page);
+       }
+
+       public void setView(InjectorView view) {
+               this.view = view;
+       }
+       
+       public ArrayList<Composite> getCategoryItems(String category) {
+               return view.getCategoryCompositeList(category);         
+       }
+       
+       abstract protected void addPages();
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorPage.java b/org.tizen.injector/src/org/tizen/injector/provider/AbstractInjectorPage.java
new file mode 100644 (file)
index 0000000..d0b685a
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.provider;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.tizen.injector.receiver.AbstractInjectorReceiver;
+//import org.tizen.injector.socket.SensorTCPSocket;
+import org.tizen.injector.socket.SensorUDPSocket;
+import org.tizen.injector.socket.TelephonySocket;
+import org.tizen.injector.util.FormPageUtil;
+
+public abstract class AbstractInjectorPage {
+
+       public AbstractInjectorPage(AbstractInjectorItem item, String name) {
+               this.item = item;
+               this.name = name;
+       }
+
+       private String name;
+       private AbstractInjectorItem item;
+       protected FormPageUtil formUtil;
+       protected Composite parent;
+       protected TelephonySocket injectorSocket = TelephonySocket.getInstance();
+       protected SensorUDPSocket sensorSocket = SensorUDPSocket.getInstance();
+//     protected SensorTCPSocket sensorSocket = SensorTCPSocket.getInstance();
+       
+       private ArrayList<AbstractInjectorReceiver> receiverList = new ArrayList<AbstractInjectorReceiver>();
+
+       public void initialize(Composite parent, FormPageUtil formUtil) {
+               this.parent = parent;
+               this.formUtil = formUtil;
+       }
+
+       public void create() {
+               createContents();
+               registerReceivers();
+               this.injectorSocket.addInjectorReceiver(receiverList);
+       }
+
+       public String getName() {
+               return this.name;
+       }
+
+       public AbstractInjectorItem getParent() {
+               return this.item;
+       }
+
+       protected void registerReceiver(AbstractInjectorReceiver receiver) {
+               receiverList.add(receiver);
+       }
+
+       protected abstract void createContents();
+
+       protected abstract void registerReceivers();
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/receiver/AbstractInjectorReceiver.java b/org.tizen.injector/src/org/tizen/injector/receiver/AbstractInjectorReceiver.java
new file mode 100644 (file)
index 0000000..fa486ff
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.receiver;
+
+import org.tizen.injector.protocol.AbstractGA;
+
+abstract public class AbstractInjectorReceiver {
+       
+       private AbstractGA aga;
+       
+       public void analyzePacket(byte[] packet){
+               this.aga = createTransferObject();
+               this.aga.intialize(packet);
+       }
+       
+       public void analyzePacket(){
+               this.aga = createTransferObject();
+               this.aga.intialize();
+               this.aga.getHeader().setLoopCount(0);
+               this.aga.getBody().setLoopCount(0);
+       }
+       
+       public String getKey(){
+               if(this.aga==null)
+                       return createTransferObject().getKey();
+               else
+                       return this.aga.getKey();
+       }
+       
+       public AbstractGA getTransferObject(){
+               return this.aga;
+       }
+       
+       abstract public AbstractGA createTransferObject();
+       abstract public void run(AbstractGA aga);
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/socket/LocationSocket.java b/org.tizen.injector/src/org/tizen/injector/socket/LocationSocket.java
new file mode 100644 (file)
index 0000000..031fe66
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.socket;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetSocketAddress;
+
+//import org.tizen.injector.DebugLog;
+
+public class LocationSocket  {
+       private static LocationSocket locationSocket;
+
+       private static final int port = 3579;
+       private static final String ip = "127.0.0.1";
+
+       private DatagramSocket socket;
+       private boolean isConnected = false;
+
+       public static LocationSocket getInstance() {
+               if (locationSocket == null)
+                       locationSocket = new LocationSocket();
+       
+               return locationSocket;
+       }
+
+       public void connect() throws Exception {
+               if (isConnected())
+                       return;
+               else
+                       disconnect();
+
+               socket = new DatagramSocket();
+
+               try {
+                       socket.connect(new InetSocketAddress(ip, port));
+
+                       isConnected = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+
+       }
+
+       private boolean isConnected() {
+               return isConnected && socket != null && !socket.isClosed()
+                               && socket.isConnected();
+       }
+
+       public void disconnect() {
+               if (!isConnected)
+                       return;
+
+               isConnected = false;
+
+               if (socket != null) {
+                       socket.close();
+               }
+       }
+
+       public void sendDispose() throws Exception {
+               if (!isConnected())
+                       return;
+       }
+
+       public boolean send(String sentence) throws Exception {
+               if (!isConnected())
+                       connect();
+
+               boolean result = false;
+               try {
+                       byte[] bytes = sentence.getBytes();
+                       DatagramPacket packet = new DatagramPacket(bytes, bytes.length);
+                       socket.send(packet);
+//                     DebugLog.log(bytes);
+                       result = true;
+               } catch (Exception e) {
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/socket/SensorTCPSocket.java b/org.tizen.injector/src/org/tizen/injector/socket/SensorTCPSocket.java
new file mode 100644 (file)
index 0000000..5dfef23
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.socket;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+//import org.tizen.injector.DebugLog;
+import org.tizen.injector.protocol.sensor.AbstractSenserMessage;
+
+public class SensorTCPSocket {
+       private static SensorTCPSocket sensorSocket;
+
+       private static final int port = 3580;
+       private static final String ip = "127.0.0.1";
+
+       private Socket socket;
+       private BufferedOutputStream output;
+       private BufferedInputStream input;
+       private boolean isConnected = false;
+
+       public static SensorTCPSocket getInstance() {
+               if (sensorSocket == null)
+                       sensorSocket = new SensorTCPSocket();
+       
+               return sensorSocket;
+       }
+
+       public void connect() throws Exception {
+               if (isConnected())
+                       return;
+               else
+                       disconnect();
+
+               socket = new Socket();
+
+               try {
+                       socket.setKeepAlive(true);
+                       socket.connect(new InetSocketAddress(ip, port), 1000);
+
+                       this.output = new BufferedOutputStream(socket.getOutputStream());
+                       this.input = new BufferedInputStream(socket.getInputStream());
+
+                       isConnected = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+
+       }
+
+       private boolean isConnected() {
+               return isConnected && socket != null && !socket.isClosed()
+                               && socket.isConnected();
+       }
+
+       public void disconnect() {
+               if (!isConnected)
+                       return;
+
+               try {
+                       if (output != null)
+                               output.close();
+                       if (input != null)
+                               input.close();
+
+                       isConnected = false;
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } finally {
+                       if (socket != null) {
+                               try {
+                                       socket.close();
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+       }
+
+       public void sendDispose() throws Exception {
+               if (!isConnected())
+                       return;
+       }
+
+       public boolean send(AbstractSenserMessage sendObj) throws Exception {
+               boolean result = false;
+               
+               if (!isConnected())
+                       return result;
+               
+               try {
+                       String msg = sendObj.getMessage();
+                       byte[] bytes = msg.getBytes();
+
+//                     DebugLog.log(msg);
+                       output.write(bytes);
+                       
+                       output.flush();
+                       result = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/socket/SensorUDPSocket.java b/org.tizen.injector/src/org/tizen/injector/socket/SensorUDPSocket.java
new file mode 100644 (file)
index 0000000..bdbf697
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.socket;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetSocketAddress;
+
+//import org.tizen.injector.DebugLog;
+
+public class SensorUDPSocket {
+       private static SensorUDPSocket locationSocket;
+
+       private static final int port = 3580;
+       private static final String ip = "127.0.0.1";
+
+       private DatagramSocket socket;
+       private boolean isConnected = false;
+
+       public static SensorUDPSocket getInstance() {
+               if (locationSocket == null)
+                       locationSocket = new SensorUDPSocket();
+       
+               return locationSocket;
+       }
+
+       public void connect() throws Exception {
+               if (isConnected())
+                       return;
+               else
+                       disconnect();
+
+               socket = new DatagramSocket();
+
+               try {
+                       socket.connect(new InetSocketAddress(ip, port));
+
+                       isConnected = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+       }
+
+       private boolean isConnected() {
+               return isConnected && socket != null && !socket.isClosed()
+                               && socket.isConnected();
+       }
+
+       public void disconnect() {
+               if (!isConnected)
+                       return;
+
+               isConnected = false;
+
+               if (socket != null) {
+                       socket.close();
+               }
+       }
+
+       public void sendDispose() throws Exception {
+               if (!isConnected())
+                       return;
+       }
+
+       public boolean send(String sentence) throws Exception {
+               if (!isConnected()) {
+                       connect();
+               }
+
+               boolean result = false;
+               
+               try {
+                       byte[] bytes = sentence.getBytes();
+                       DatagramPacket packet = new DatagramPacket(bytes, bytes.length);
+                       socket.send(packet);
+//                     DebugLog.log(sentence);
+                       result = true;
+               } catch (Exception e) {
+                       disconnect();
+                       result = false;
+               }
+               return result;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/socket/TelephonySocket.java b/org.tizen.injector/src/org/tizen/injector/socket/TelephonySocket.java
new file mode 100644 (file)
index 0000000..08fba2e
--- /dev/null
@@ -0,0 +1,417 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.socket;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.sdblib.*;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.progress.UIJob;
+
+import org.tizen.injector.protocol.AbstractGA;
+import org.tizen.injector.receiver.AbstractInjectorReceiver;
+import org.tizen.injector.util.ByteUtil;
+import org.tizen.injector.util.StringUtil;
+import org.tizen.injector.view.InjectorView;
+
+public class TelephonySocket {
+       private static TelephonySocket telephonySocket;
+       
+       public static int port = 26103;                                 // default port but it will be changed when connection start
+       private static final String ip = "127.0.0.1"; //$NON-NLS-1$
+
+//     private static HashMap<String, AbstractInjectorReceiver> receiverMap = new HashMap<String, AbstractInjectorReceiver>();
+       private HashMap<String, AbstractInjectorReceiver> receiverMap = new HashMap<String, AbstractInjectorReceiver>();
+
+       private Socket socket;
+       private BufferedOutputStream output;
+       private BufferedInputStream input;
+       private boolean isConnected = false;
+       private Receiver receiverThread;
+       public boolean callWaiting = false;
+       private IDevice currentDevice = null;
+       
+       public void addInjectorReceiver(ArrayList<AbstractInjectorReceiver> list) {
+               if (list == null)
+                       return;
+               for (int i = 0; i < list.size(); i++) {
+                       AbstractInjectorReceiver receiver = list.get(i);
+                       receiverMap.put(receiver.getKey(), receiver);
+               }
+       }
+
+       public void removeInjectorReceiver() {
+               receiverMap.clear();
+       }
+
+       public static TelephonySocket getInstance() {
+               if (telephonySocket == null)
+                       telephonySocket = new TelephonySocket();
+               return telephonySocket;
+       }
+       
+       public void connect() throws Exception {
+               if (isConnected() && InjectorView.activated == true)
+                       return;
+               else
+                       disconnect();
+
+               socket = new Socket();
+
+               try {
+                       socket.setKeepAlive(true);
+                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+                       if(currentDevice == null)
+                               return;
+                       String str_localport = currentDevice.getSerialNumber();
+                       port = Integer.parseInt(str_localport.substring(9, str_localport.length())) + 3;
+                       socket.connect(new InetSocketAddress(ip, port), 1000);
+
+                       this.output = new BufferedOutputStream(socket.getOutputStream());
+                       this.input = new BufferedInputStream(socket.getInputStream());
+
+                       receiverThread = new Receiver();
+                       receiverThread.start();
+
+                       sendInitialize();
+                       isConnected = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw e;
+               }
+       }
+
+       private boolean isConnected() {
+               return isConnected && socket != null && !socket.isClosed()
+                               && socket.isConnected();
+       }
+
+       public void disconnect() {
+               if (!isConnected)
+                       return;
+
+               try {
+                       if (receiverThread != null)
+                               receiverThread.shutdown();
+                       if (output != null)
+                               output.close();
+                       if (input != null)
+                               input.close();                  
+                       isConnected = false;
+               } catch (Exception e) {
+                       e.printStackTrace();
+               } finally {
+                       if (socket != null) {
+                               try {
+                                       socket.close();
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+//             try {
+//                     connect();
+//             } catch (Exception e) {
+//                     // TODO Auto-generated catch block
+//                     e.printStackTrace();
+//             }
+       }
+
+       private void sendInitialize() throws IOException {
+               String str = "telephony\n";
+               output.write(str.getBytes(), 0, str.length());
+               output.flush();
+               
+               byte[] abuf = { 0x04, 0x00, 0x40, 0x41 };
+               output.write(abuf);
+               output.flush();
+
+               byte[] bbuf = { 0x16, 0x00, 0x00, 0x00 };
+               output.write(bbuf);
+               output.flush();
+               
+               output.write(str.getBytes(), 0, str.length());
+               output.flush();
+               
+               byte[] cbuf = { 0x00, 0x00, 0x40, 0x47 };
+               output.write(cbuf);
+               output.flush();
+
+               byte[] dbuf = { 0x00, 0x00, 0x40, 0x42 };
+               output.write(dbuf);
+               output.flush();
+       }
+
+       public void sendAskData() throws Exception {
+               if (!isConnected())
+                       connect();
+
+               String str = "telephony\n";
+               output.write(str.getBytes(), 0, str.length());
+               output.flush();
+               
+               byte[] buf = { 0x00, 0x00, 0x11, 0x5b };
+               output.write(buf);
+               output.flush();
+       }
+
+       public void sendDispose() throws Exception {
+               if (!isConnected())
+                       return;
+
+               String str = "telephony\n";
+               output.write(str.getBytes(), 0, str.length());
+               output.flush();
+               
+               byte[] abuf = { 0x00, 0x00, 0x10, 0x01 };
+               output.write(abuf);
+               output.flush();
+
+               byte[] bbuf = { 0x00, 0x00, 0x10, 0x02 };
+               output.write(bbuf);
+               output.flush();
+       }
+
+       public boolean send(AbstractGA sendObj) throws Exception {
+               if (!isConnected())
+                       connect();
+
+               boolean result = false;
+               try {
+                       String str = "telephony\n";
+                       output.write(str.getBytes(), 0, str.length());
+                       output.flush();
+                       
+                       byte[] starter = sendObj.makeStarterPacket();
+//                     ByteUtil.printHex(starter, "send head");
+                       output.write(starter, 0, starter.length);
+                       output.flush();
+                       
+                       byte[] main = sendObj.makePacket();
+                       if (main.length > 0) {
+//                             ByteUtil.printHex(main, "send body");
+                               output.write(main, 0, main.length);
+                       }
+                       output.flush();
+                       result = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+       
+       public boolean sendSensor(String sensorMsg) throws Exception {
+               if (!isConnected())
+                       connect();
+
+               boolean result = false;
+               try {
+                       String str = "sensor\n\n\n\n";
+                       if(output != null)
+                               output.flush();
+                       else
+                               return false;
+                       
+                       output.write(str.getBytes(), 0, str.length());
+                       output.flush();
+                       
+                       byte[] next_packet_length = { (byte)sensorMsg.getBytes().length, 0x00, 0x00, 0x00 };
+                       output.write(next_packet_length);
+                       output.flush();
+                       
+                       byte[] main = sensorMsg.getBytes();
+                       if (main.length > 0) {
+//                             ByteUtil.printHex(main, "send body");
+                               output.write(main, 0, main.length);
+                       }
+                       output.flush();
+                       result = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+       
+       public boolean sendLocation(String locationMsg) throws Exception {
+               if (!isConnected())
+                       return false;
+
+               boolean result = false;
+               try {
+                       String str = "location\n\n";
+                       output.write(str.getBytes(), 0, str.length());
+                       output.flush();
+                       
+                       byte[] next_packet_length = { (byte)locationMsg.getBytes().length, 0x00, 0x00, 0x00 };
+                       output.write(next_packet_length);
+                       output.flush();
+                       
+                       byte[] main = locationMsg.getBytes();
+                       if (main.length > 0) {
+//                             ByteUtil.printHex(main, "send body");
+                               output.write(main, 0, main.length);
+                       }
+                       output.flush();
+                       result = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+       
+       public boolean sendNfc(String nfcMsg) throws Exception {
+               if (!isConnected())
+                       connect();
+
+               boolean result = false;
+               try {
+                       String str = "nfc\n\n\n\n\n\n\n";
+                       output.write(str.getBytes(), 0, str.length());
+                       output.flush();
+
+                       String msgLen = Integer.toString(nfcMsg.getBytes().length);
+                       while(msgLen.length() < 5)
+                       {
+                               msgLen = msgLen + "\n";
+                       }
+                       output.write(msgLen.getBytes(), 0 , msgLen.length());
+                       output.flush();
+                       
+                       byte[] main = nfcMsg.getBytes();
+                       if (main.length > 0)
+                       {
+//                             ByteUtil.printHex(main, "send body");
+                               output.write(main, 0, main.length);
+                       }
+                       output.flush();
+                       result = true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       disconnect();
+                       throw e;
+               }
+               return result;
+       }
+
+       private class Receiver extends Thread {
+               private boolean hasActiveReceiver = true;
+                               
+               public void run() {
+                       try {                           
+                               byte[] buf = null;
+                               ByteBuffer byteBuffer = null;
+                               int length;
+                               int groupId;
+                               int actionId;
+                               while (hasActiveReceiver) {
+                                       buf = new byte[4];
+                                       input.read(buf, 0, buf.length);
+//                                     ByteUtil.printHex(buf, "receive head");
+                                       byteBuffer = ByteUtil.getByteBuffer(buf);
+                                       length = byteBuffer.getShort();                                 
+                                       groupId = byteBuffer.get() & 0xff;
+                                       actionId = byteBuffer.get() & 0xff;
+                                       
+                                       if (length != 0) {
+                                               buf = new byte[length];
+                                               input.read(buf, 0, buf.length);
+//                                             ByteUtil.printHex(buf, "receive body");
+                                       }
+
+                                       // groupid 3: GSM_SUPS, actionid 73: GSM_SUPS_SET_CW_REQ
+                                       if(groupId == 3 && actionId == 73)
+                                       {
+                                               for(int i = 0; i < buf.length; i++)
+                                               {
+                                                       if(buf[i] == -1)                                        // -1: class id 255
+                                                       {
+                                                               if(buf[i + 4] == 3)                     // 3: cw on
+                                                                       callWaiting = true;
+                                                               else if(buf[i + 4] == 4)                // 4: cw off
+                                                                       callWaiting = false;
+                                                       }
+                                               }
+                                       }
+
+                                       final AbstractInjectorReceiver receiver = getTelephonyReceiver(
+                                                       groupId, actionId);
+
+                                       if (receiver == null) {
+                                               continue;
+                                       }
+                                       
+                                       if (length == 0)
+                                               receiver.analyzePacket();
+                                       else
+                                               receiver.analyzePacket(buf);
+
+                                       UIJob job = new UIJob("Receive packet about [" + groupId
+                                                       + ":" + actionId + "]") { //$NON-NLS-1$ //$NON-NLS-2$
+                                               @Override
+                                               public IStatus runInUIThread(IProgressMonitor monitor) {
+                                                       receiver.run(receiver.getTransferObject());
+                                                       return Status.OK_STATUS;
+                                               }
+                                       };
+                                       job.schedule();
+                               }
+                       } catch (SocketException e) {
+                               return;
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               }
+
+               private void shutdown() {
+                       this.hasActiveReceiver = false;
+               }
+
+               private AbstractInjectorReceiver getTelephonyReceiver(int groupId,
+                               int actionId) {
+                       return receiverMap.get(StringUtil.makeKey(groupId, actionId));
+               }
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/sourceProvider/InjectorStateProvider.java b/org.tizen.injector/src/org/tizen/injector/sourceProvider/InjectorStateProvider.java
new file mode 100644 (file)
index 0000000..8c32707
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.sourceProvider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ui.AbstractSourceProvider;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.services.ISourceProviderService;
+
+public class InjectorStateProvider extends AbstractSourceProvider {
+
+       public final static String STATE_ID = "org.tizen.injector.sourceProvider.InjectorState"; //$NON-NLS-1$
+       public final static String STATE_ON = "ON"; //$NON-NLS-1$
+       public final static String STATE_OFF = "OFF"; //$NON-NLS-1$
+       private static String state = STATE_OFF;
+       
+       @Override
+       public void dispose() {
+
+       }
+
+       @Override
+       public Map<String,String> getCurrentState() {
+               Map<String,String> stateMap = new HashMap<String,String>();
+               stateMap.put(STATE_ID, state);
+               return stateMap;
+       }
+
+       @Override
+       public String[] getProvidedSourceNames() {
+               return new String[]{STATE_ID};
+       }
+       
+       public void setState(String newState){
+               if(state.equals(newState))
+                       return;
+               else
+                       state = newState;
+               
+               fireSourceChanged(ISources.WORKBENCH, STATE_ID, newState);
+       }
+       
+/*     public static boolean isConnected = false;
+       
+       private void setConnectionStatus(boolean isConnected){
+               InjectorStateProvider.isConnected = isConnected;
+       }*/
+       
+       public static void changeSyslogState(String state){
+               try {
+                       IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                       
+                       // In case of closing Eclipse
+                       if (window == null) {
+                               return;
+                       }
+                       
+                       ISourceProviderService service = (ISourceProviderService)window.getService(ISourceProviderService.class);
+                       InjectorStateProvider provider = (InjectorStateProvider)service.getSourceProvider(InjectorStateProvider.STATE_ID);
+                       provider.setState(state);
+//                     provider.setConnectionStatus(state.equals("ON")?true:false);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }       
+       
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/util/ByteUtil.java b/org.tizen.injector/src/org/tizen/injector/util/ByteUtil.java
new file mode 100644 (file)
index 0000000..61f6499
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.util;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class ByteUtil {
+       private static final ByteOrder BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;
+       public static final int BYTE_LENGTH = 1;
+       public static final int SHORT_LENGTH = 2;
+       public static final int INT_LENGTH = 4;
+
+       public static ByteBuffer getByteBuffer(byte[] buf) {
+               ByteBuffer byteBuffer = ByteBuffer.allocate(buf.length);
+               byteBuffer.order(BYTE_ORDER);
+               byteBuffer.put(buf);
+               byteBuffer.rewind();
+
+               return byteBuffer;
+       }
+
+       public static ByteBuffer getByteBuffer(int length) {
+               ByteBuffer byteBuffer = ByteBuffer.allocate(length);
+               byteBuffer.order(BYTE_ORDER);
+
+               return byteBuffer;
+       }
+
+       public static byte[] short2byte(short s) {
+               byte dest[] = new byte[2];
+               dest[1] = (byte) (s & 0xff);
+               dest[0] = (byte) (s >>> 8 & 0xff);
+               return dest;
+       }
+
+       public static byte[] int2byte(int i) {
+               byte dest[] = new byte[4];
+               dest[3] = (byte) (i & 0xff);
+               dest[2] = (byte) (i >>> 8 & 0xff);
+               dest[1] = (byte) (i >>> 16 & 0xff);
+               dest[0] = (byte) (i >>> 24 & 0xff);
+               return dest;
+       }
+
+       public static byte[] long2byte(long l) {
+               byte dest[] = new byte[8];
+               dest[7] = (byte) (int) (l & 255L);
+               dest[6] = (byte) (int) (l >>> 8 & 255L);
+               dest[5] = (byte) (int) (l >>> 16 & 255L);
+               dest[4] = (byte) (int) (l >>> 24 & 255L);
+               dest[3] = (byte) (int) (l >>> 32 & 255L);
+               dest[2] = (byte) (int) (l >>> 40 & 255L);
+               dest[1] = (byte) (int) (l >>> 48 & 255L);
+               dest[0] = (byte) (int) (l >>> 56 & 255L);
+               return dest;
+       }
+
+       public static short byte2short(byte src[]) {
+               return (short) ((src[0] & 0xff) << 8 | src[1] & 0xff);
+       }
+
+       public static int byte2int(byte src[]) {
+               return (src[0] & 0xff) << 24 | (src[1] & 0xff) << 16
+                               | (src[2] & 0xff) << 8 | src[3] & 0xff;
+       }
+
+       public static int byte2int(byte src[], int offset) {
+               return (src[offset] & 0xff) << 24 | (src[offset + 1] & 0xff) << 16
+                               | (src[offset + 2] & 0xff) << 8 | src[offset + 3] & 0xff;
+       }
+
+       public static long byte2long(byte src[]) {
+               return (long) byte2int(src) << 32 | (long) byte2int(src, 4)
+                               & 0xffffffffL;
+       }
+
+       public static String byte2hex(byte[] src) {
+               if (src == null)
+                       return null;
+
+               StringBuilder sb = new StringBuilder();
+               for (int i = 0; i < src.length; i++) {
+                       sb.append(Integer.toHexString(src[i] & 0xff));
+               }
+               return sb.toString();
+       }
+
+       public static byte[] hex2byte(String src) {
+               if (src == null)
+                       return null;
+
+               if (src.length() % 2 != 0)
+                       src = "0" + src; //$NON-NLS-1$
+
+               byte[] result = new byte[src.length() / 2];
+               for (int i = 0; i < result.length; i++) {
+                       result[i] = (byte) Integer.parseInt(
+                                       src.substring(2 * i, 2 * i + 2), 16);
+               }
+               return result;
+       }
+
+       // will be removed
+       public static void printHex(byte[] buf, String flag) {
+               System.out.print("\n### " + flag + " : "); //$NON-NLS-1$ //$NON-NLS-2$
+               for (int i = 0; i < buf.length; i++) {
+                       System.out.format("%02X ", buf[i]); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/util/FormPageUtil.java b/org.tizen.injector/src/org/tizen/injector/util/FormPageUtil.java
new file mode 100644 (file)
index 0000000..b387fa7
--- /dev/null
@@ -0,0 +1,378 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.util;
+
+import java.awt.TextArea;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+public class FormPageUtil {
+
+       private ScrolledForm form;
+       private FormToolkit toolkit;
+
+       private final int TEXT_LIMIT = 200;
+
+       public FormPageUtil(Composite parent) {
+               initialize(parent);
+       }
+
+       public void initialize(Composite parent) {
+               toolkit = new FormToolkit(parent.getDisplay());
+               form = toolkit.createScrolledForm(parent);
+               form.getBody().setLayout(new GridLayout());
+       }
+
+       public void setColspan(Control control, int colspan) {
+               GridData gd = (GridData) control.getLayoutData();
+               if (gd == null) {
+                       gd = new GridData();
+                       gd.horizontalSpan = colspan;
+                       control.setLayoutData(gd);
+               } else {
+                       gd.horizontalSpan = colspan;
+               }
+       }
+
+       public void setWidth(Control control, int width) {
+               GridData gd = (GridData) control.getLayoutData();
+               if (gd == null) {
+                       gd = new GridData();
+                       gd.widthHint = width;
+                       control.setLayoutData(gd);
+               } else {
+                       gd.widthHint = width;
+               }
+               gd.widthHint = width;
+       }
+
+       private Composite setLayout(Composite composite, int numColumns) {
+               GridLayout gl = new GridLayout(numColumns, false);
+               gl.marginWidth = 2;
+               gl.marginHeight = 2;
+               composite.setLayout(gl);
+               return composite;
+       }
+
+       public Combo createCombo(Composite parent) {
+               Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
+               combo.addListener(SWT.MouseWheel, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               event.doit = false;
+                       }
+               });
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+               combo.setLayoutData(gd);
+               return combo;
+       }
+
+       public Combo createEditableCombo(Composite parent) {
+               Combo combo = new Combo(parent, SWT.DROP_DOWN);
+               combo.addListener(SWT.MouseWheel, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               event.doit = false;
+                       }
+               });
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+               combo.setLayoutData(gd);
+               return combo;
+       }
+
+       public Combo createCombo(Composite parent, int colspan) {
+               Combo combo = createCombo(parent);
+               setColspan(combo, colspan);
+               return combo;
+       }
+
+       public Combo createEditableCombo(Composite parent, int colspan) {
+               Combo combo = createEditableCombo(parent);
+               setColspan(combo, colspan);
+               return combo;
+       }
+
+       public Label createLabel(Composite parent, String title) {
+               Label label = toolkit.createLabel(parent, title, SWT.NONE);
+               return label;
+       }
+
+       public Label createLabel(Composite parent, String title, int colspan) {
+               Label label = createLabel(parent, title);
+               setColspan(label, colspan);
+               return label;
+       }
+
+       public Text createText(Composite parent, String title) {
+               Text text = toolkit.createText(parent, title, SWT.BORDER);
+               text.setTextLimit(TEXT_LIMIT);
+               GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
+               text.setLayoutData(gd);
+               return text;
+       }
+       
+       public Text createTextArea(Composite parent, String title) {
+               Text text = toolkit.createText(parent, title, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.Expand | SWT.SCROLL_LINE);
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
+               text.setLayoutData(gd);
+               return text;
+       }
+
+       public Text createText(Composite parent, String title, int colspan) {
+               Text text = createText(parent, title);
+               setColspan(text, colspan);
+               return text;
+       }
+       
+       public Button createButton(Composite parent, String title, int style) {
+               return toolkit.createButton(parent, title, style);
+       }
+
+       public Button createButton(Composite parent, String title, int style,
+                       int colspan) {
+               Button button = toolkit.createButton(parent, title, style);
+               setColspan(button, colspan);
+               return button;
+       }
+
+       public Composite createSection(Composite parent, String title) {
+               Section section = toolkit.createSection(parent, Section.TWISTIE
+                               | Section.EXPANDED);
+               section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+               section.setText(title);
+               section.addExpansionListener(new ExpansionAdapter() {
+                       public void expansionStateChanged(ExpansionEvent e) {
+                               form.reflow(false);
+                       }
+               });
+               toolkit.createCompositeSeparator(section);
+
+               Composite client = toolkit.createComposite(section);
+               client.setLayout(new GridLayout());
+               section.setClient(client);
+               return client;
+       }
+
+       public Composite createComposite(Composite parent) {
+               Composite composite = toolkit.createComposite(parent);
+               composite.setLayout(new GridLayout());
+               composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+               return composite;
+       }
+
+       public Composite createComposite(Composite parent, int numColumns) {
+               return setLayout(createComposite(parent), numColumns);
+       }
+
+       public Composite createCategory(String title) {
+               Section section = toolkit.createSection(form.getBody(), Section.TWISTIE
+                               | Section.TITLE_BAR);
+               section.setText(title);
+               section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+               section.addExpansionListener(new ExpansionAdapter() {
+                       public void expansionStateChanged(ExpansionEvent e) {
+                               form.reflow(false);
+                       }
+               });
+
+               Composite client = toolkit.createComposite(section);
+               client.setLayout(new GridLayout());
+               section.setClient(client);
+               return client;
+       }
+
+       public Composite createExpandable(Composite parent, String title) {
+               ExpandableComposite expandable = toolkit.createExpandableComposite(
+                               parent, ExpandableComposite.TREE_NODE
+                                               | ExpandableComposite.EXPANDED
+                                               | ExpandableComposite.CLIENT_INDENT);
+               expandable.setText(title);
+               expandable.addExpansionListener(new ExpansionAdapter() {
+                       public void expansionStateChanged(ExpansionEvent e) {
+                               form.reflow(true);
+                       }
+               });
+               Composite client = toolkit.createComposite(expandable);
+               client.setLayout(new GridLayout());
+
+               expandable.setClient(client);
+               return client;
+       }
+
+       public Composite createExpandable(Composite parent, String title,
+                       int numColumns) {
+               return setLayout(createExpandable(parent, title), numColumns);
+       }
+
+       public void addComboItem(Combo combo, Object[] items) {
+               if (items == null || items.length == 0)
+                       return;
+
+               for (int i = 0; i < items.length; i++)
+                       combo.add(items[i].toString());
+
+               combo.select(0);
+       }
+
+       public void addComboItem(Combo combo, Object[] items, Object selection) {
+               if (items == null || items.length == 0)
+                       return;
+
+               int idx = 0;
+               for (int i = 0; i < items.length; i++) {
+                       combo.add(items[i].toString());
+                       if (items[i].equals(selection))
+                               idx = i;
+               }
+
+               combo.select(idx);
+       }
+
+       public void selectCombo(Combo combo, String selectedItem) {
+               String[] itemNames = combo.getItems();
+               for (int i = 0; i < itemNames.length; i++) {
+                       if (itemNames[i].equals(selectedItem)) {
+                               combo.select(i);
+                               return;
+                       }
+               }
+       }
+
+       public void selectButton(Button[] buttons, String[] options) {
+               for (int i = 0; i < buttons.length; i++) {
+                       boolean checked = false;
+                       String text = buttons[i].getText();
+                       if (options != null) {
+                               for (int j = 0; j < options.length; j++) {
+                                       if (text.equals(options[j]))
+                                               checked = true;
+                               }
+                       }
+                       buttons[i].setSelection(checked);
+               }
+       }
+
+       public void selectButton(Button[] buttons, String option, boolean isChecked) {
+               for (int i = 0; i < buttons.length; i++) {
+                       if (buttons[i].getText().contains(option)) {
+                               buttons[i].setSelection(isChecked);
+                               break;
+                       }
+               }
+       }
+
+       public ScrolledForm getForm() {
+               return form;
+       }
+
+       
+       public TableViewer createTableViewer(Composite parent, String[] columnNames) {
+               return createTableViewer(parent, columnNames, 1);
+       }
+
+       public TableViewer createTableViewer(Composite parent,
+                       String[] columnNames, int colspan) {
+               return createTableViewer(parent, columnNames, 1, SWT.BORDER | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
+       }
+       
+       public TableViewer createTableViewer(Composite parent, String[] columnNames, int colspan, int style) {
+               TableViewer viewer = new TableViewer(parent, style);
+
+               Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+               gd.heightHint = 120;
+               gd.horizontalSpan = colspan;
+               viewer.getTable().setLayoutData(gd);
+
+               TableColumn column = null;
+               for (int i = 0; i < columnNames.length; i++) {
+                       column = new TableColumn(table, SWT.NONE);
+                       column.setText(columnNames[i]);
+                       column.setWidth(100);
+               }
+               return viewer;
+       }
+       
+       public Browser createBrowser(Composite parent) {
+               return createBrowser(parent, 1);
+       }
+       
+       public Browser createBrowser(Composite parent, int colsapn) {
+               Browser browser = new Browser(parent, SWT.NONE);
+               
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
+               gd.minimumHeight = 200;
+               gd.minimumWidth = 250;
+               browser.setLayoutData(gd);
+               
+               return browser;
+       }
+       
+       public Slider createSlider(Composite parent) {
+               return createSlider(parent, SWT.HORIZONTAL);
+       }
+       
+       public Slider createSlider(Composite parent, int style) {
+               Slider slider = new Slider(parent, style);
+               
+               GridData gd;
+               if ((style & SWT.VERTICAL) == SWT.VERTICAL) {
+                       gd = new GridData(GridData.CENTER, GridData.FILL, true, true);
+               } else {
+                       gd = new GridData(GridData.FILL, GridData.CENTER, true, true);
+               }
+               slider.setLayoutData(gd);
+               
+               return slider;
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/util/StringUtil.java b/org.tizen.injector/src/org/tizen/injector/util/StringUtil.java
new file mode 100644 (file)
index 0000000..e84eaf3
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * org.tizen.injector\r
+ * \r
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Sungmin Ha <sungmin82.ha@samsung.com>\r
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
+ * DongKyun Yun <dk77.yun@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.injector.util;\r
+\r
+public class StringUtil {\r
+       public static String lpad(String strSource, int totalLength, String pad) {\r
+               if(totalLength <= strSource.length())\r
+                       return strSource;\r
+\r
+               StringBuilder sb = new StringBuilder(strSource);\r
+               for (int i = 0; i < totalLength-sb.length(); i++) {\r
+                       sb.insert(0, pad);\r
+               }\r
+\r
+               return sb.toString();\r
+       }\r
+\r
+       public static String rpad(String strSource, int totalLength, String pad) {\r
+               if(totalLength <= strSource.length())\r
+                       return strSource;\r
+\r
+               StringBuilder sb = new StringBuilder(strSource);\r
+               for (int i = 0; i < totalLength-sb.length(); i++) {\r
+                       sb.append(pad);\r
+               }\r
+               \r
+               return sb.toString();\r
+       }\r
+\r
+       public static String makeKey(int groupId, int actionId) {\r
+               return groupId + ":" + actionId; //$NON-NLS-1$\r
+       }\r
+}\r
diff --git a/org.tizen.injector/src/org/tizen/injector/view/InjectorView.java b/org.tizen.injector/src/org/tizen/injector/view/InjectorView.java
new file mode 100644 (file)
index 0000000..5e3dd17
--- /dev/null
@@ -0,0 +1,390 @@
+/*\r
+ * org.tizen.injector\r
+ * \r
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Sungmin Ha <sungmin82.ha@samsung.com>\r
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
+ * DongKyun Yun <dk77.yun@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.injector.view;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IConfigurationElement;\r
+import org.eclipse.core.runtime.IExtension;\r
+import org.eclipse.core.runtime.IExtensionPoint;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.FillLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.TabFolder;\r
+import org.eclipse.swt.widgets.TabItem;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.forms.widgets.Section;\r
+import org.eclipse.ui.part.ViewPart;\r
+import org.eclipse.ui.progress.UIJob;\r
+\r
+import org.tizen.injector.Injector;\r
+import org.tizen.injector.provider.AbstractInjectorItem;\r
+import org.tizen.injector.socket.LocationSocket;\r
+import org.tizen.injector.socket.SensorUDPSocket;\r
+import org.tizen.injector.socket.TelephonySocket;\r
+import org.tizen.injector.sourceProvider.InjectorStateProvider;\r
+import org.tizen.injector.util.FormPageUtil;\r
+import org.tizen.common.connection.ConnectionPlugin;\r
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;\r
+import org.tizen.common.util.DialogUtil;\r
+import org.tizen.sdblib.FileListingService.FileEntry;\r
+import org.tizen.sdblib.IDevice;\r
+\r
+public class InjectorView extends ViewPart implements\r
+ISelectionListener {\r
+\r
+       private final static String EXTENSION_POINT_INJECTOR_ITEM_PROVIDER = "injectorItemProvider";\r
+       private final static String TAG_ITEM_TYPE = "itemType";\r
+       private final static String ATTR_ID = "name";\r
+       private final static String ATTR_CATEGORY = "category";\r
+       private final static String ATTR_CLASS = "class";\r
+       private IDevice currentDevice = null;\r
+       static public boolean desposing = false;\r
+       static public boolean activated = false;\r
+       static public boolean disconnect_finished = true;\r
+\r
+       public final static String VIEW_ID = "org.tizen.injector.view.InjectorView";\r
+\r
+       private String errorMessage = Messages.InjectorView_6\r
+                       + System.getProperty("line.separator") //$NON-NLS-1$\r
+                       + Messages.InjectorView_8;\r
+\r
+       private ArrayList<String> categoryList = new ArrayList<String>();\r
+       private ArrayList<FormPageUtil> formUtilList = new ArrayList<FormPageUtil>();\r
+       private ArrayList<ArrayList<Composite>> compositeArrayList = new ArrayList<ArrayList<Composite>>();\r
+\r
+       @Override\r
+       public void createPartControl(Composite parent) {\r
+               getCategories();\r
+\r
+               TabFolder tabFolder = createTabFolder(parent);\r
+\r
+               for (int i = 0; i < categoryList.size(); i++) {\r
+                       compositeArrayList.add(new ArrayList<Composite>());\r
+                       TabItem tabItem = createTabItem(tabFolder, categoryList.get(i));\r
+                       formUtilList\r
+                                       .add(new FormPageUtil((Composite) tabItem.getControl()));\r
+                       getItems(i);\r
+               }\r
+\r
+               initialize();\r
+       }\r
+\r
+       private TabFolder createTabFolder(Composite parent) {\r
+               TabFolder tabFolder = new TabFolder(parent, SWT.NONE);\r
+               tabFolder.setLayout(new FillLayout());\r
+\r
+               return tabFolder;\r
+       }\r
+\r
+       private TabItem createTabItem(TabFolder parent, String text) {\r
+               TabItem tabItem = new TabItem(parent, SWT.NONE);\r
+               tabItem.setText(text);\r
+               tabItem.setControl(createTabItemComposite(parent));\r
+\r
+               return tabItem;\r
+       }\r
+\r
+       private Composite createTabItemComposite(Composite parent) {\r
+               Composite composite = new Composite(parent, SWT.NONE);\r
+               composite.setLayout(new FillLayout());\r
+\r
+               return composite;\r
+       }\r
+\r
+       private void initialize() {\r
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+               ConnectionPlugin.getDefault().addSelectionListener(this);\r
+               boolean connected = checkDeviceConnectedAlready();\r
+               if (connected == true) {\r
+                       connect();\r
+               }\r
+//             TargetConnectionControl.addTargetConnectionListener(this);\r
+//             TargetConnectionControl.addSimulatorStatusListener(this);\r
+//             connect();\r
+       }\r
+       \r
+       private boolean checkDeviceConnectedAlready() {\r
+               if (currentDevice == null)\r
+                       return false;\r
+               else\r
+                       return true;\r
+       }\r
+\r
+       @Override\r
+       public void dispose() {\r
+               desposing = true;\r
+               disconnect();\r
+\r
+               ConnectionPlugin.getDefault().removeSelectionListener(this);\r
+//             TargetConnectionControl.removeTargetConnectionListener(this);\r
+//             TargetConnectionControl.removeSimulatorStatusListener(this);\r
+               super.dispose();\r
+       }\r
+\r
+       private void getCategories() {\r
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()\r
+                               .getExtensionPoint(Injector.PLUGIN_ID,\r
+                                               EXTENSION_POINT_INJECTOR_ITEM_PROVIDER);\r
+\r
+               if (extensionPoint != null) {\r
+                       IExtension[] extensions = extensionPoint.getExtensions();\r
+                       for (IExtension ex : extensions) {\r
+                               IConfigurationElement[] configElements = ex\r
+                                               .getConfigurationElements();\r
+                               for (int i = 0; i < configElements.length; i++) {\r
+                                       if (configElements[i].getName().equals(TAG_ITEM_TYPE)) {\r
+                                               String category = configElements[i].getAttribute(ATTR_CATEGORY);\r
+                                               if (!categoryList.contains(category)) {\r
+                                                       categoryList.add(category);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       private void getItems(int index) {\r
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()\r
+                               .getExtensionPoint(Injector.PLUGIN_ID,\r
+                                               EXTENSION_POINT_INJECTOR_ITEM_PROVIDER);\r
+\r
+               String name = null;\r
+               AbstractInjectorItem executor = null;\r
+               if (extensionPoint != null) {\r
+                       IExtension[] extensions = extensionPoint.getExtensions();\r
+                       for (IExtension ex : extensions) {\r
+                               IConfigurationElement[] configElements = ex\r
+                                               .getConfigurationElements();\r
+                               for (int i = 0; i < configElements.length; i++) {\r
+                                       if (configElements[i].getName().equals(TAG_ITEM_TYPE)) {\r
+                                               if (configElements[i].getAttribute(ATTR_CATEGORY)\r
+                                                               .equals(categoryList.get(index))) {\r
+\r
+                                                       name = configElements[i].getAttribute(ATTR_ID);\r
+                                                       Composite client = formUtilList.get(index)\r
+                                                                       .createCategory(name);\r
+                                                       client.getParent().setEnabled(false);\r
+                                                       compositeArrayList.get(index).add(client);\r
+                                                       try {\r
+                                                               executor = (AbstractInjectorItem) (configElements[i]\r
+                                                                               .createExecutableExtension(ATTR_CLASS));\r
+                                                               executor.createContents(client, formUtilList\r
+                                                                               .get(index));\r
+                                                               executor.setView(this);\r
+                                                       } catch (CoreException e) {\r
+                                                               e.printStackTrace();\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       public void activate() {\r
+               for (int i = 0; i < compositeArrayList.size(); i++) {\r
+                       for (int j = 0; j < compositeArrayList.get(i).size(); j++) {\r
+                               Composite client = compositeArrayList.get(i).get(j);\r
+                               client.getParent().setEnabled(true);\r
+                       }\r
+               }\r
+               activated = true;\r
+       }\r
+\r
+       public void inactivateUI() {\r
+               for (int i = 0; i < compositeArrayList.size(); i++) {\r
+                       for (int j = 0; j < compositeArrayList.get(i).size(); j++) {\r
+                               Composite client = compositeArrayList.get(i).get(j);\r
+                               Section section = (Section) client.getParent();\r
+                               section.setExpanded(false);\r
+                               section.setEnabled(false);\r
+                       }\r
+               }\r
+               activated = false;\r
+       }\r
+\r
+       @Override\r
+       public void setFocus() {\r
+       }\r
+       \r
+       private void initSocket() {\r
+               UIJob job = new UIJob("Connect Vmodem") {\r
+                       @Override\r
+                       public IStatus runInUIThread(IProgressMonitor monitor) {\r
+                               try {\r
+                                       TelephonySocket.getInstance().connect();\r
+                                       TelephonySocket.getInstance().sendAskData();\r
+                                       \r
+//                                     SensorTCPSocket.getInstance().connect();                                \r
+//                                     SensorUDPSocket.getInstance().connect();\r
+//                                     LocationSocket.getInstance().connect();\r
+                                       \r
+                                       InjectorStateProvider\r
+                                                       .changeSyslogState(InjectorStateProvider.STATE_ON);\r
+                                       \r
+                                       InjectorView view = (InjectorView) PlatformUI.getWorkbench()\r
+                                       .getActiveWorkbenchWindow().getActivePage().findView(\r
+                                                       InjectorView.VIEW_ID);\r
+                                       if (view != null && currentDevice != null)\r
+                                               view.activate();\r
+                               } catch (Exception e) {\r
+                                       //initSocket();\r
+                                       //DialogUtil.openErrorDialog(errorMessage);\r
+                                       e.printStackTrace();\r
+                               }\r
+                               return Status.OK_STATUS;\r
+                       }\r
+               };\r
+               job.schedule();\r
+       }\r
+       \r
+//     @Override\r
+       public void connect() {\r
+               /*  createForward is executed by emulator */\r
+/*             String EMdPort = "3577";\r
+               try {\r
+                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       String str_localport = currentDevice.getSerialNumber();\r
+                       int localport = Integer.parseInt(str_localport.substring(9, str_localport.length())) + 3;\r
+                       TelephonySocket.port = localport;\r
+                       currentDevice.createForward(TelephonySocket.port, Integer.parseInt(EMdPort));\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+               }\r
+*/     \r
+                       initSocket();\r
+       }\r
+\r
+//     @Override\r
+       public void disconnect() {\r
+               try {\r
+                       TelephonySocket.getInstance().disconnect();\r
+//                     SensorUDPSocket.getInstance().disconnect();\r
+//                     SensorTCPSocket.getInstance().disconnect();\r
+//                     LocationSocket.getInstance().disconnect();\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+               }\r
+       \r
+               InjectorStateProvider.changeSyslogState(InjectorStateProvider.STATE_OFF);\r
+               if(PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench()\r
+                               .getActiveWorkbenchWindow() == null || PlatformUI.getWorkbench()\r
+                                               .getActiveWorkbenchWindow().getActivePage() == null)\r
+                       return;\r
+               \r
+               InjectorView view = (InjectorView) PlatformUI.getWorkbench()\r
+                               .getActiveWorkbenchWindow().getActivePage().findView(\r
+                                               InjectorView.VIEW_ID);\r
+               if (view != null)\r
+                       view.inactivateUI();\r
+/*             \r
+               UIJob job = new UIJob("Connect Vmodem") {\r
+                       @Override\r
+                       public IStatus runInUIThread(IProgressMonitor monitor) {\r
+                                       InjectorStateProvider\r
+                                                       .changeSyslogState(InjectorStateProvider.STATE_OFF);\r
+                                       InjectorView view = (InjectorView) PlatformUI.getWorkbench()\r
+                                                       .getActiveWorkbenchWindow().getActivePage().findView(\r
+                                                                       InjectorView.VIEW_ID);\r
+                                       if (view != null)\r
+                                               view.inactivateUI();\r
+\r
+                               return Status.OK_STATUS;\r
+                       }\r
+               };\r
+               if (desposing != true) {\r
+                       job.schedule();\r
+               }\r
+               */\r
+       }\r
+       \r
+       public ArrayList<String> getCategoryList() {\r
+               return this.categoryList;\r
+       }\r
+       \r
+       public ArrayList<Composite> getCategoryCompositeList(String category) { \r
+               int i = categoryList.indexOf(category);\r
+               \r
+               if(i > -1) {\r
+                       return compositeArrayList.get(i);\r
+               }\r
+               \r
+               return null;\r
+       }\r
+\r
+       // 1000 -> 1초\r
+       public void MatrixTime(int delayTime)\r
+       {\r
+           long saveTime = System.currentTimeMillis();\r
+           long currTime = 0;\r
+\r
+           while( currTime - saveTime < delayTime)\r
+           {\r
+               currTime = System.currentTimeMillis();\r
+           }\r
+       }\r
+                       \r
+       @Override\r
+       public void selectionChanged(FileEntry selectedEntry) {\r
+               if( selectedEntry == null)\r
+               {\r
+                       currentDevice = null;\r
+                       disconnect();\r
+                       return;\r
+               }\r
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())\r
+                       return;\r
+               \r
+               if(currentDevice == null && selectedEntry.getName() != null)\r
+               {\r
+                       connect();\r
+                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       return;\r
+               }\r
+\r
+               if (currentDevice.getSerialNumber() != selectedEntry.getName()) {\r
+                       disconnect_finished = false;\r
+                       disconnect();\r
+                       connect();\r
+                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       return;\r
+               }\r
+               else if(activated == false)\r
+               {\r
+                       connect();\r
+                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       return;\r
+               }\r
+       }\r
+}\r
diff --git a/org.tizen.injector/src/org/tizen/injector/view/Messages.java b/org.tizen.injector/src/org/tizen/injector/view/Messages.java
new file mode 100644 (file)
index 0000000..2a276ce
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * org.tizen.injector
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.injector.view;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.injector.view.messages"; //$NON-NLS-1$
+       public static String InjectorView_6;
+       public static String InjectorView_8;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.injector/src/org/tizen/injector/view/messages.properties b/org.tizen.injector/src/org/tizen/injector/view/messages.properties
new file mode 100644 (file)
index 0000000..69b248e
--- /dev/null
@@ -0,0 +1,2 @@
+InjectorView_6=To connect vmodem for emulator to interact it is failed.
+InjectorView_8=please retry after checking the status of simulator
diff --git a/org.tizen.location.core/.classpath b/org.tizen.location.core/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.location.core/.project b/org.tizen.location.core/.project
new file mode 100644 (file)
index 0000000..dc06ccd
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.location.core</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.location.core/.settings/org.eclipse.core.resources.prefs b/org.tizen.location.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..4ba9b9e
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:07:15 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.tizen.location.core/.settings/org.eclipse.core.runtime.prefs b/org.tizen.location.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..cef9197
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:29:26 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.location.core/.settings/org.eclipse.jdt.core.prefs b/org.tizen.location.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..556f96e
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed Oct 27 11:19:26 KST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.location.core/META-INF/MANIFEST.MF b/org.tizen.location.core/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..7d977c9
--- /dev/null
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Location Core
+Bundle-SymbolicName: org.tizen.location.core;singleton:=true
+Bundle-Version: 1.3.20.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.tizen.location.core.injector,
+ org.tizen.location.core.model,
+ org.tizen.location.core.protocol
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.tizen.common,
+ org.tizen.injector,
+ org.tizen.common.connection
+Import-Package: org.tizen.common.model
diff --git a/org.tizen.location.core/OSGI-INF/l10n/bundle.properties b/org.tizen.location.core/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..73c8421
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.tizen.location.core
+extension-point.name = Location Injector
+Bundle-Vendor = Tizen
+Bundle-Name = Tizen SDK Location Core
diff --git a/org.tizen.location.core/build.properties b/org.tizen.location.core/build.properties
new file mode 100644 (file)
index 0000000..b40fadf
--- /dev/null
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               OSGI-INF/l10n/bundle.properties
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.tizen.location.core/src/org/tizen/location/core/injector/DebugLog.java b/org.tizen.location.core/src/org/tizen/location/core/injector/DebugLog.java
new file mode 100644 (file)
index 0000000..de076b8
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+ * org.tizen.location.core\r
+ * \r
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Sungmin Ha <sungmin82.ha@samsung.com>\r
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
+ * DongKyun Yun <dk77.yun@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.location.core.injector;\r
+\r
+public class DebugLog {\r
+       public static void log(Object msg) {\r
+               System.out.println(msg);\r
+       }\r
+}\r
diff --git a/org.tizen.location.core/src/org/tizen/location/core/injector/LocationInjector.java b/org.tizen.location.core/src/org/tizen/location/core/injector/LocationInjector.java
new file mode 100644 (file)
index 0000000..189b35b
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.injector;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.common.model.ITableVO;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
+//import org.tizen.location.core.injector.DebugLog;
+import org.tizen.location.core.model.GeoLocationVO;
+import org.tizen.location.core.protocol.GeoLocation;
+
+public class LocationInjector implements ISelectionListener {
+       private IProgressMonitor monitor;
+
+       private final String remoteFilePath = "/opt/data/gps-manager/replay/nmea_replay.log";
+       private final String setStopMode        = "vconftool set -t int db/location/replay/ReplayMode 0"; // STOP MODE
+       private final String setLogMode         = "vconftool set -t int db/location/replay/ReplayMode 1"; // NMEA MODE(LOG MODE)
+       private final String setManualMode      = "vconftool set -t int db/location/replay/ReplayMode 2"; // MANUAL MODE
+
+       public LocationInjector() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+//             TargetConnectionControl.addTargetConnectionListener(this);
+       }
+
+       private void setStopMode() throws IOException {
+               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               currentDevice.executeShellCommand(setStopMode);
+       }
+
+       private void setLogMode() throws IOException {
+               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               currentDevice.executeShellCommand(setLogMode);
+       }
+       
+       private void setManualMode() throws IOException {
+               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               currentDevice.executeShellCommand(setManualMode);
+       }
+
+       private boolean injectLocation(double latitude, double longitude) throws IOException {
+               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               String latitudeCmd  = String.format("vconftool set -t double db/location/replay/ManualLatitude %f", latitude);
+               String longitudeCmd = String.format("vconftool set -t double db/location/replay/ManualLongitude %f", longitude);
+
+               currentDevice.executeShellCommand(latitudeCmd);
+               currentDevice.executeShellCommand(longitudeCmd);
+
+               return true;
+       }
+
+       public boolean inject(final File filename, IProgressMonitor monitor) throws IOException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+
+               setMonitor(monitor);
+
+               // PUSH FILE TO EMULATOR
+               SyncService sync = ConnectionPlugin.getDefault().getCurrentDevice().getSyncService();
+               if (sync != null) {
+                       SyncResult result = sync.pushFile(filename.getPath(), remoteFilePath, SyncService.getNullProgressMonitor());
+                   if (result.getCode() != SyncService.RESULT_OK) {
+                       // TODO
+                       return false;
+                   }
+               }
+
+               // SET LOG MODE
+               setLogMode();
+
+               while(true) {
+                       synchronized (monitor) {
+                               try {
+                                       monitor.wait(1000);
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+
+                       if (monitor.isCanceled()) {
+//                             DebugLog.log("[Injector] Canceled");
+                               // SET STOP MODE
+                               setStopMode();
+                               return true;
+                       }
+               }
+       }
+
+       public void inject(GeoLocation location, IProgressMonitor monitor) throws IOException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+
+               setMonitor(monitor);
+
+               // SET MANUAL MODE
+               setManualMode();
+
+               if (!injectLocation(location.getLatitude(), location.getLongitude())) {
+                       monitor.setCanceled(true);
+                       return ;
+               }
+
+               while(true) {
+                       synchronized (monitor) {
+                               try {
+                                       monitor.wait(1000);
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+
+                       if (monitor.isCanceled()) {
+//                             DebugLog.log("[Injector] Canceled");
+                               // SET STOP MODE
+                               setStopMode();
+                               return;
+                       }
+               }
+       }
+
+       public boolean inject(ITableVO[] locations, IProgressMonitor monitor) throws IOException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               
+               setMonitor(monitor);
+
+               // SET MANUAL MODE
+               setManualMode();
+
+               while(true) {
+                       for (int i = 0; i < locations.length; i++) {
+                               GeoLocationVO location = (GeoLocationVO) locations[i];
+                               if (!injectLocation(location.getLocation().getLatitude(), location.getLocation().getLongitude())) {
+                                       monitor.setCanceled(true);
+                                       return false;
+                               }
+
+                               synchronized (monitor) {
+                                       try {
+                                               monitor.wait(1000);
+                                       } catch (InterruptedException e) {
+                                               e.printStackTrace();
+                                       }
+                               }
+       
+                               if (monitor.isCanceled()) {
+//                                     DebugLog.log("[Injector] Canceled");
+                                       // SET STOP MODE
+                                       setStopMode();
+                                       return true;
+                               }
+                       }
+               }
+       }
+
+       public void setCancel(boolean canceled) {
+               this.monitor.setCanceled(canceled);
+       }
+       
+       public void setMonitor(IProgressMonitor monitor) {
+               this.monitor = monitor;
+       }
+       
+       //@Override
+       public void connect() { 
+       }
+       
+//     @Override
+       public void disconnect() {
+               setCancel(true);
+       }
+       
+       @Override
+       protected void finalize() throws Throwable {
+               ConnectionPlugin.getDefault().removeSelectionListener(this);
+//             TargetConnectionControl.removeTargetConnectionListener(this);
+               super.finalize();
+       }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               // TODO Auto-generated method stub
+               
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/model/GeoLocationVO.java b/org.tizen.location.core/src/org/tizen/location/core/model/GeoLocationVO.java
new file mode 100644 (file)
index 0000000..713c0bf
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.model;
+
+import org.tizen.common.model.AbstractTableVO;
+import org.tizen.location.core.protocol.GeoLocation;
+
+public class GeoLocationVO extends AbstractTableVO {
+       private int seq;
+       private GeoLocation location;
+       
+       public int getSeq() {
+               return this.seq;
+       }
+       
+       public void setSeq(int seq) {
+               this.seq = seq;
+       }
+       
+       public GeoLocation getLocation() {
+               return this.location;
+       }
+       
+       public void setLocation(GeoLocation location) {
+               this.location = location;
+       }
+       
+       private String getLatitudeString() {
+               return getLocation().getNorthSouth() + "," + Double.toString(Math.abs(getLocation().getLatitude())); //$NON-NLS-1$
+       }
+       
+       private String getLongitudeString() {
+               return getLocation().getEastWest() + "," + Double.toString(Math.abs(getLocation().getLongitude())); //$NON-NLS-1$
+       }
+
+       @Override
+       public String[] getColumnNames() {
+               return null;
+       }
+
+       @Override
+       public Object getColumnValue(int index) {
+               Object obj = null;
+               switch(index) {
+                       case 0:
+                               obj = getSeq();
+                               break;
+                       case 1:
+                               obj = getLatitudeString();
+                               break;
+                       case 2:
+                               obj = getLongitudeString();
+                               break;
+                       default:
+                               break;                  
+               }
+
+               return obj;
+       }
+
+       @Override
+       public void setColumnValue(int index, Object value) { 
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/AbstractNMEA0183.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/AbstractNMEA0183.java
new file mode 100644 (file)
index 0000000..7cc9b57
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import java.util.ArrayList;
+import java.util.Formatter;
+import java.util.List;
+import java.util.Locale;
+
+public abstract class AbstractNMEA0183 {
+       private static String PREFIX = "$"; //$NON-NLS-1$
+       private static String DELIMITER = ","; //$NON-NLS-1$
+       private static String CHECKSUM_PREFIX = "*"; //$NON-NLS-1$
+       
+       private String sentenceID;
+       private List<String> body;
+       private String fullSentence;
+       private int checksum = 0;
+       
+       protected static String NULL = ""; //$NON-NLS-1$
+       
+       public AbstractNMEA0183(String sentenceID) {
+               this.sentenceID = sentenceID;
+       }
+       
+       public String getSentence() {
+               StringBuilder sb = new StringBuilder();
+               Formatter hexFormatter = new Formatter(sb, Locale.US);
+               hexFormatter.format("%02x", checksum); //$NON-NLS-1$
+               
+               String sentence = PREFIX.concat(fullSentence);
+
+               sentence += CHECKSUM_PREFIX;
+               sentence += sb.toString().toUpperCase();
+                       
+               return sentence;
+       }
+       
+       protected List<String> getBody() {
+               return body;
+       }
+       
+       
+       protected void createSentence() {
+               body = new ArrayList<String>();
+               createBody();
+               createChecksum();
+       }
+       
+       private void createChecksum() {
+               fullSentence = sentenceID;
+               
+               for (int i = 0; i < body.size(); i++) {
+                       fullSentence += DELIMITER;
+                       fullSentence += body.get(i);
+               }
+                       
+               for (int i = 0; i < fullSentence.length(); i++) {
+                       checksum = checksum ^ fullSentence.charAt(i);
+               }
+       }
+       
+       abstract protected void createBody();
+       abstract protected boolean validate();
+       
+//     public enum Directions {
+//             NORTH, SOUTH, EAST, WEST
+//     }
+}
+
+
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/GeoLocation.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/GeoLocation.java
new file mode 100644 (file)
index 0000000..0daab6b
--- /dev/null
@@ -0,0 +1,115 @@
+/*\r
+ * org.tizen.location.core\r
+ * \r
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Sungmin Ha <sungmin82.ha@samsung.com>\r
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
+ * DongKyun Yun <dk77.yun@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ * \r
+ */\r
+\r
+package org.tizen.location.core.protocol;\r
+\r
+public class GeoLocation {\r
+       \r
+       public enum Directions {\r
+               NORTH, SOUTH, EAST, WEST\r
+       }\r
+       \r
+       private double latitude;\r
+       private double NMEAlatitude;\r
+       private Directions northSouth;\r
+       private double longitude;\r
+       private double NMEAlongitude;\r
+       private Directions eastWest;\r
+       \r
+       public GeoLocation(double latitude, double longitude) {\r
+               setLatitude(latitude);\r
+               setLongitude(longitude);\r
+       }\r
+       \r
+       public double getLatitude() {\r
+               return this.latitude;\r
+       }\r
+       \r
+       public double getLongitude() {\r
+               return this.longitude;\r
+       }\r
+       \r
+       public String getNorthSouth() {\r
+               return northSouth == Directions.NORTH ? "N" : "S"; //$NON-NLS-1$ //$NON-NLS-2$\r
+       }\r
+\r
+       public String getEastWest() {\r
+               return eastWest == Directions.EAST ? "E" : "W"; //$NON-NLS-1$ //$NON-NLS-2$\r
+       }\r
+\r
+       public double getNMEAlatitude() {\r
+               return NMEAlatitude;\r
+       }\r
+\r
+       public double getNMEAlongitude() {\r
+               return NMEAlongitude;\r
+       }\r
+\r
+       public void setLatitude(double latitude) {\r
+               this.latitude = latitude;\r
+               \r
+               if (latitude < 0) {\r
+                       setNorthSouth(Directions.SOUTH);\r
+               } else {\r
+                       setNorthSouth(Directions.NORTH);\r
+               }\r
+               setNMEAlatitude(Math.abs(latitude));\r
+       }\r
+\r
+       public void setLongitude(double longitude) {\r
+               this.longitude = longitude;\r
+               \r
+               if (longitude < 0) {\r
+                       setEastWest(Directions.WEST);\r
+               } else {\r
+                       setEastWest(Directions.EAST);\r
+               }\r
+               setNMEAlongitude(Math.abs(longitude));\r
+       }\r
+       \r
+       private void setNorthSouth(Directions northSouth) {\r
+               this.northSouth = northSouth;\r
+       }\r
+\r
+       private void setEastWest(Directions eastWest) {\r
+               this.eastWest = eastWest;\r
+       }\r
+\r
+       private void setNMEAlatitude(double latitude) {\r
+               int degree = (int) latitude;\r
+               double minutes = (double) ((latitude - degree) * 60);\r
+               \r
+               this.NMEAlatitude = (double) ((degree * 100) + minutes);\r
+       }\r
+\r
+       private void setNMEAlongitude(double longitude) {\r
+               int degree = (int) longitude;\r
+               double minutes = (double) ((longitude - degree) * 60);\r
+               \r
+               this.NMEAlongitude = (double) ((degree * 100) + minutes);\r
+       }\r
+}\r
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/IdentifiersConstants.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/IdentifiersConstants.java
new file mode 100644 (file)
index 0000000..c2f99f2
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+public class IdentifiersConstants {
+       
+       //             1 2 3 4 5 6 7     cn
+       //             | | | | | | |     |
+       //      $--GSV,x,x,x,x,x,x,x,...*hh
+       //      1) total number of messages
+       //      2) message number
+       //      3) satellites in view
+       //      4) satellite number
+       //      5) elevation in degrees
+       //      6) azimuth in degrees to true
+       //      7) SNR in dB
+       //      more satellite infos like 4)-7)
+       //      n) Checksum
+       public static String SATELITES_IN_VIEW = "GPGSV"; //$NON-NLS-1$
+       
+       //                                                           11
+       //             1         2       3 4        5 6 7  8   9  10 |  12 13  14   15
+       //             |         |       | |        | | |  |   |   | |   | |   |    |
+       //      $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh
+       //      1) Time (UTC)
+       //      2) Latitude
+       //      3) N or S (North or South)
+       //      4) Longitude
+       //      5) E or W (East or West)
+       //      6) GPS Quality Indicator,
+       //      0 - fix not available,
+       //      1 - GPS fix,
+       //      2 - Differential GPS fix
+       //      7) Number of satellites in view, 00 - 12
+       //      8) Horizontal Dilution of precision
+       //      9) Antenna Altitude above/below mean-sea-level (geoid)
+       //      10) Units of antenna altitude, meters
+       //      11) Geoidal separation, the difference between the WGS-84 earth
+       //      ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid
+       //      12) Units of geoidal separation, meters
+       //      13) Age of differential GPS data, time in seconds since last SC104
+       //      type 1 or 9 update, null field when DGPS is not used
+       //      14) Differential reference station ID, 0000-1023
+       //      15) Checksum
+       public static String GPS_FIX_DATA_TIME_POSITION_AND_FIX_RELATED_DATA = "GPGGA"; //$NON-NLS-1$
+       
+       //                                                              14      
+       //             1 2   3 4    5    6       7 8        9 10  11  12  13|
+       //             | |   | |    |    |       | |        | |   |   |   | |
+       //      $--RMB,A,x.x,a,c--c,c--c,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,A*hh
+       //      1) Status, V = Navigation receiver warning
+       //      2) Cross Track error - nautical miles
+       //      3) Direction to Steer, Left or Right
+       //      4) TO Waypoint ID
+       //      5) FROM Waypoint ID
+       //      6) Destination Waypoint Latitude
+       //      7) N or S
+       //      8) Destination Waypoint Longitude
+       //      9) E or W
+       //      10) Range to destination in nautical miles
+       //      11) Bearing to destination in degrees True
+       //      12) Destination closing velocity in knots
+       //      13) Arrival Status, A = Arrival Circle Entered
+       //      14) Checksum
+       public static String RECOMMENDED_MINIMUM_NAVIGATION_INFORMATION = "GPRMC"; //$NON-NLS-1$
+       
+       //             1 2 3                         14 15  16  17 18
+       //             | | |                         |  |   |   |  |
+       //      $--GSA,a,a,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x.x,x.x,x.x*hh
+       //      1) Selection mode
+       //      2) Mode
+       //      3) ID of 1st satellite used for fix
+       //      4) ID of 2nd satellite used for fix
+       //      ...
+       //      14) ID of 12th satellite used for fix
+       //      15) PDOP in meters
+       //      16) HDOP in meters
+       //      17) VDOP in meters
+       //      18) Checksum
+       public static String GPS_DOP_AND_ACTIVE_SATELITES = "GPGSA"; //$NON-NLS-1$
+       
+       
+       //             1   2 3   4 5   6 7   8 9
+       //             |   | |   | |   | |   | |
+       //      $--VTG,x.x,T,x.x,M,x.x,N,x.x,K*hh
+       //      1) Track Degrees
+       //      2) T = True
+       //      3) Track Degrees
+       //      4) M = Magnetic
+       //      5) Speed Knots
+       //      6) N = Knots
+       //      7) Speed Kilometers Per Hour
+       //      8) K = Kilometres Per Hour
+       //      9) Checksum
+       public static String TRACK_MODE_GOOD_AND_GROUND_SPEED = "GPVGT"; //$NON-NLS-1$
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/Messages.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/Messages.java
new file mode 100644 (file)
index 0000000..fad01d8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.core.protocol.messages"; //$NON-NLS-1$
+       public static String SatelliteInfo_0;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGGA.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGGA.java
new file mode 100644 (file)
index 0000000..707cf70
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class NMEA0183_GPGGA extends AbstractNMEA0183 {
+       
+       //                                                           11
+       //             1         2       3 4        5 6 7  8   9  10 |  12 13  14   15
+       //             |         |       | |        | | |  |   |   | |   | |   |    |
+       //      $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh
+       //      1) Time (UTC)
+       //      2) Latitude
+       //      3) N or S (North or South)
+       //      4) Longitude
+       //      5) E or W (East or West)
+       //      6) GPS Quality Indicator,
+       //      0 - fix not available,
+       //      1 - GPS fix,
+       //      2 - Differential GPS fix
+       //      7) Number of satellites in view, 00 - 12
+       //      8) Horizontal Dilution of precision
+       //      9) Antenna Altitude above/below mean-sea-level (geoid)
+       //      10) Units of antenna altitude, meters
+       //      11) Geoidal separation, the difference between the WGS-84 earth
+       //      ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid
+       //      12) Units of geoidal separation, meters
+       //      13) Age of differential GPS data, time in seconds since last SC104
+       //      type 1 or 9 update, null field when DGPS is not used
+       //      14) Differential reference station ID, 0000-1023
+       //      15) Checksum
+       private Date currentDate;
+       
+       private String date;
+       private GeoLocation location;
+       private String qualityIndicator = "1"; //$NON-NLS-1$
+       private int numOfSatellites = 5;
+       private double hdop = 0.0;
+       private double altitude = 0.0;
+       private String altitudeUnit = "M"; //$NON-NLS-1$
+       
+       public NMEA0183_GPGGA() {
+               this(0.0, 0.0);
+       }
+               
+       public NMEA0183_GPGGA(double latitude, double longitude) {
+               super("GPGGA"); //$NON-NLS-1$
+               
+               currentDate = new Date();
+               SimpleDateFormat format = new SimpleDateFormat("HHmmss.0"); //$NON-NLS-1$
+               date = format.format(currentDate);
+               
+               location = new GeoLocation(latitude, longitude);
+               
+               createSentence();
+       }
+
+       @Override
+       protected void createBody() {
+               DecimalFormat latitudeFormat = new DecimalFormat("0000.000000"); //$NON-NLS-1$
+               DecimalFormat longitudeFormat = new DecimalFormat("00000.000000"); //$NON-NLS-1$
+               DecimalFormat numOfSatellitesFormat = new DecimalFormat("00"); //$NON-NLS-1$
+               DecimalFormat hdopFormat = new DecimalFormat("0.0"); //$NON-NLS-1$
+               DecimalFormat altitudeFormat = new DecimalFormat("###0.0"); //$NON-NLS-1$
+               
+               getBody().add(date);
+               getBody().add(latitudeFormat.format(location.getNMEAlatitude()));
+               getBody().add(location.getNorthSouth());
+               getBody().add(longitudeFormat.format(location.getNMEAlongitude()));
+               getBody().add(location.getEastWest());
+               getBody().add(qualityIndicator);
+               getBody().add(numOfSatellitesFormat.format(numOfSatellites));
+               getBody().add(hdopFormat.format(hdop));
+               getBody().add(altitudeFormat.format(altitude));
+               getBody().add(altitudeUnit);
+               getBody().add(NULL);
+               getBody().add(NULL);
+               getBody().add(NULL);
+               getBody().add(NULL);
+       }
+
+       @Override
+       protected boolean validate() {
+               return true;
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSA.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSA.java
new file mode 100644 (file)
index 0000000..8e49930
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import java.text.DecimalFormat;
+
+public class NMEA0183_GPGSA extends AbstractNMEA0183 {
+       
+       //             1 2 3                         14 15  16  17 18
+       //             | | |                         |  |   |   |  |
+       //      $--GSA,a,a,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x.x,x.x,x.x*hh
+       //      1) Selection mode
+       //      2) Mode
+       //      3) ID of 1st satellite used for fix
+       //      4) ID of 2nd satellite used for fix
+       //      ...
+       //      14) ID of 12th satellite used for fix
+       //      15) PDOP in meters
+       //      16) HDOP in meters
+       //      17) VDOP in meters
+       //      18) Checksum    
+       private static String selectionMode = "A"; //$NON-NLS-1$
+       private static String mode = "3"; //$NON-NLS-1$
+       private int[] satellteIDs = { 1, 2, 3, 4, 5 };
+       private double pdop = 0.0;
+       private double hdop = 0.0;
+       private double vdop = 0.0;
+               
+       public NMEA0183_GPGSA() {
+               super("GPGSA"); //$NON-NLS-1$
+               
+               createSentence();
+       }
+
+       @Override
+       protected void createBody() {
+               DecimalFormat setelliteIDFormat = new DecimalFormat("00"); //$NON-NLS-1$
+               DecimalFormat dopFormat = new DecimalFormat("0.0"); //$NON-NLS-1$
+               
+               getBody().add(selectionMode);
+               getBody().add(mode);
+               for(int i = 0; i < 12; i++) {
+                       if (i >= satellteIDs.length) {
+                               getBody().add(NULL);
+                       } else {
+                               getBody().add(setelliteIDFormat.format(satellteIDs[i]));
+                       }
+               }
+               getBody().add(dopFormat.format(pdop));
+               getBody().add(dopFormat.format(hdop));
+               getBody().add(dopFormat.format(vdop));
+       }
+
+       @Override
+       protected boolean validate() {
+               return true;
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSV.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPGSV.java
new file mode 100644 (file)
index 0000000..d3a8896
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+public class NMEA0183_GPGSV extends AbstractNMEA0183 {
+       
+       //             1 2 3 4 5 6 7     cn
+       //             | | | | | | |     |
+       //      $--GSV,x,x,x,x,x,x,x,...*hh
+       //      1) total number of messages
+       //      2) message number
+       //      3) satellites in view
+       //      4) satellite number
+       //      5) elevation in degrees
+       //      6) azimuth in degrees to true
+       //      7) SNR in dB
+       //      more satellite infos like 4)-7)
+       //      n) Checksum
+       private int numTotalMessage = 3;
+       private int seq;
+       private int satellitesInView = 10;
+       private SatelliteInfo[] satellites;
+       
+       public NMEA0183_GPGSV(int seq) {
+               this(seq, createDefaultSatellites(seq));
+       }
+       
+       public NMEA0183_GPGSV(int seq, SatelliteInfo[] satellites) {
+               super("GPGSV"); //$NON-NLS-1$
+               
+               this.seq = seq;
+               this.satellites = satellites;
+               
+               createSentence();
+       }
+
+       @Override
+       protected void createBody() {
+               DecimalFormat numberFormat = new DecimalFormat("##0"); //$NON-NLS-1$
+               DecimalFormat satellitesIDFormat = new DecimalFormat("00"); //$NON-NLS-1$
+               
+               getBody().add(numberFormat.format(numTotalMessage));
+               getBody().add(numberFormat.format(seq));
+               getBody().add(numberFormat.format(satellitesInView));
+               
+               // TODO: limitation "number of satellites"
+               for (int i = 0; i < satellites.length; i++) {
+                       getBody().add(satellitesIDFormat.format(satellites[i].getId()));
+                       getBody().add(numberFormat.format(satellites[i].getElevation()));
+                       getBody().add(numberFormat.format(satellites[i].getAzimuth()));
+                       if (satellites[i].getSnr() == 0) {
+                               getBody().add(NULL);
+                       } else {
+                               getBody().add(numberFormat.format(satellites[i].getSnr()));
+                       }
+               }       
+       }
+
+       @Override
+       protected boolean validate() {
+               return true;
+       }
+       
+       private static SatelliteInfo[] createDefaultSatellites(int seq) {
+               List<SatelliteInfo> satellites = new ArrayList<SatelliteInfo>();
+               int numOfSatellites = 4;
+               
+               if (seq == 3) {
+                       numOfSatellites = 2;
+               }
+               
+               for (int i = 1; i <= numOfSatellites; i++) {
+                       satellites.add(new SatelliteInfo(((4 * (seq - 1)) + i), 45, 300, 0));
+               }
+               
+               return satellites.toArray(new SatelliteInfo[satellites.size()]);
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPRMC.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/NMEA0183_GPRMC.java
new file mode 100644 (file)
index 0000000..14fd88c
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class NMEA0183_GPRMC extends AbstractNMEA0183 {
+       
+       //                                                                 12
+       //             1         2 3       4 5        6 7   8   9    10  11|
+       //             |         | |       | |        | |   |   |    |   | |
+       //      $--RMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,xxxx,x.x,a*hh
+       //      1) Time (UTC)
+       //      2) Status, V = Navigation receiver warning
+       //      3) Latitude
+       //      4) N or S
+       //      5) Longitude
+       //      6) E or W
+       //      7) Speed over ground, knots
+       //      8) Track made good, degrees true
+       //      9) Date, ddmmyy
+       //      10) Magnetic Variation, degrees
+       //      11) E or W
+       //      12) Checksum
+       private Date currentDate;
+       
+       private String time;
+       private String status = "A"; //$NON-NLS-1$
+       private GeoLocation location;
+       private double speed = 0.0;
+       private double track = 0.0;
+       private String date;
+//     private double magneticVariation = 0.0;
+       private String magenticDirection = "A"; //$NON-NLS-1$
+       
+       public NMEA0183_GPRMC() {
+               this(0.0, 0.0);
+       }       
+               
+       public NMEA0183_GPRMC(double latitude, double longitude) {
+               super("GPRMC"); //$NON-NLS-1$
+               
+               currentDate = new Date();
+
+               SimpleDateFormat timeFormat = new SimpleDateFormat("HHmmss.0"); //$NON-NLS-1$
+               time = timeFormat.format(currentDate);
+               location = new GeoLocation(latitude, longitude);
+               SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyy"); //$NON-NLS-1$
+               date = dateFormat.format(currentDate);
+               
+               createSentence();
+       }
+
+       @Override
+       protected void createBody() {
+               DecimalFormat latitudeFormat = new DecimalFormat("0000.000000"); //$NON-NLS-1$
+               DecimalFormat longitudeFormat = new DecimalFormat("00000.000000"); //$NON-NLS-1$
+               DecimalFormat doubleFormat = new DecimalFormat("000.0"); //$NON-NLS-1$
+               
+               getBody().add(time);
+               getBody().add(status);
+               getBody().add(latitudeFormat.format(location.getNMEAlatitude()));
+               getBody().add(location.getNorthSouth());
+               getBody().add(longitudeFormat.format(location.getNMEAlongitude()));
+               getBody().add(location.getEastWest());
+               getBody().add(doubleFormat.format(speed));
+               getBody().add(doubleFormat.format(track));
+               getBody().add(date);
+//             getBody().add(doubleFormat.format(magneticVariation));
+               getBody().add(NULL);
+               getBody().add(NULL);
+               getBody().add(magenticDirection);
+       }
+
+       @Override
+       protected boolean validate() {
+               return true;
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/SatelliteInfo.java b/org.tizen.location.core/src/org/tizen/location/core/protocol/SatelliteInfo.java
new file mode 100644 (file)
index 0000000..61d0bb2
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * org.tizen.location.core
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.core.protocol;
+
+import javax.management.RuntimeErrorException;
+
+public class SatelliteInfo {
+       private int id;
+       private int elevation;
+       private int azimuth;
+       private int snr;
+       
+       public SatelliteInfo(int id, int elevation, int azimuth, int snr) {
+               this.setId(id);
+               this.setElevation(elevation);
+               this.setAzimuth(azimuth);
+               this.setSnr(snr);
+               
+               if (!validate()) {
+                       throw new RuntimeErrorException(null, Messages.SatelliteInfo_0);
+               }
+       }
+       
+       private boolean validate() {
+               if (id < 1 || id > 32) {
+                       return false;
+               }
+               
+               if (elevation < 0 || elevation > 90) {
+                       return false;
+               }
+               
+               if (azimuth < 0 || id > 359) {
+                       return false;
+               }
+               
+               if (snr < 0 || id > 99) {
+                       return false;
+               }
+               
+               return true;
+       }
+
+       public void setId(int id) {
+               this.id = id;
+       }
+
+       public int getId() {
+               return id;
+       }
+
+       public void setElevation(int elevation) {
+               this.elevation = elevation;
+       }
+
+       public int getElevation() {
+               return elevation;
+       }
+
+       public void setAzimuth(int azimuth) {
+               this.azimuth = azimuth;
+       }
+
+       public int getAzimuth() {
+               return azimuth;
+       }
+
+       public void setSnr(int snr) {
+               this.snr = snr;
+       }
+
+       public int getSnr() {
+               return snr;
+       }
+}
diff --git a/org.tizen.location.core/src/org/tizen/location/core/protocol/messages.properties b/org.tizen.location.core/src/org/tizen/location/core/protocol/messages.properties
new file mode 100644 (file)
index 0000000..f525d05
--- /dev/null
@@ -0,0 +1 @@
+SatelliteInfo_0=Invalid Satellite Info
diff --git a/org.tizen.location.log/.classpath b/org.tizen.location.log/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.location.log/.project b/org.tizen.location.log/.project
new file mode 100644 (file)
index 0000000..e673a10
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.location.log</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.location.log/.settings/org.eclipse.core.resources.prefs b/org.tizen.location.log/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..9bf4202
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:07:37 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.tizen.location.log/.settings/org.eclipse.core.runtime.prefs b/org.tizen.location.log/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..6d81787
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:29:37 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.location.log/META-INF/MANIFEST.MF b/org.tizen.location.log/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..956ee4e
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Location Log
+Bundle-SymbolicName: org.tizen.location.log;singleton:=true
+Bundle-Version: 1.3.20.qualifier
+Bundle-Vendor: Tizen
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.forms;bundle-version="3.3.103",
+ org.tizen.common,
+ org.tizen.injector;bundle-version="1.3.13",
+ org.tizen.location.core;bundle-version="1.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.tizen.location.log/OSGI-INF/l10n/bundle.properties b/org.tizen.location.log/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..c8f3cb8
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.tizen.location.log
+Bundle-Vendor = Tizen
+Bundle-Name = Tizen SDK Location Log
+Log = Log
\ No newline at end of file
diff --git a/org.tizen.location.log/build.properties b/org.tizen.location.log/build.properties
new file mode 100644 (file)
index 0000000..f9eefdc
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               OSGI-INF/l10n/bundle.properties\r
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.tizen.location.log/plugin.xml b/org.tizen.location.log/plugin.xml
new file mode 100644 (file)
index 0000000..1e04e25
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.2"?>\r
+<plugin>\r
+   <extension\r
+         point="org.tizen.injector.injectorItemProvider">\r
+      <itemType\r
+            category="Location"\r
+            class="org.tizen.location.log.Log"\r
+            id="org.tizen.location.log"\r
+            name="%Log">\r
+      </itemType>\r
+   </extension>\r
+</plugin>\r
diff --git a/org.tizen.location.log/src/org/tizen/location/log/Log.java b/org.tizen.location.log/src/org/tizen/location/log/Log.java
new file mode 100644 (file)
index 0000000..b8eb426
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * org.tizen.location.log
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.log;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.Section;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.location.log.page.LogFile;
+
+public class Log extends AbstractInjectorItem {
+       private static String LABEL = Messages.Log_0;
+
+       @Override
+       protected void addPages() {
+               addPage(new LogFile(this, Messages.Log_1));
+       }
+       
+       public void setSiblingsEnabled(boolean enabled) {
+               ArrayList<Composite> list = getCategoryItems("Location"); //$NON-NLS-1$
+               for (int i = 0; i < list.size(); i++) {
+                       Section parent = (Section) list.get(i).getParent();
+                       if (!parent.getText().equals(LABEL)) {
+                               if(!enabled) {
+                                       parent.setExpanded(enabled);
+                               }
+                               parent.setEnabled(enabled);     
+                       }
+               }
+       }
+}
diff --git a/org.tizen.location.log/src/org/tizen/location/log/Messages.java b/org.tizen.location.log/src/org/tizen/location/log/Messages.java
new file mode 100644 (file)
index 0000000..b826d39
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * org.tizen.location.log
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.log;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.log.messages"; //$NON-NLS-1$
+       public static String Log_0;
+       public static String Log_1;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.log/src/org/tizen/location/log/messages.properties b/org.tizen.location.log/src/org/tizen/location/log/messages.properties
new file mode 100644 (file)
index 0000000..6ee4eeb
--- /dev/null
@@ -0,0 +1,2 @@
+Log_0=Log
+Log_1=Log File
diff --git a/org.tizen.location.log/src/org/tizen/location/log/page/LogFile.java b/org.tizen.location.log/src/org/tizen/location/log/page/LogFile.java
new file mode 100644 (file)
index 0000000..f5db233
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * org.tizen.location.log
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.log.page;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+//import org.eclipse.ui.IWorkbenchWindow;
+//import org.eclipse.ui.PlatformUI;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+//import org.tizen.location.core.injector.AbstractLocationInjector;
+import org.tizen.location.core.injector.LocationInjector;
+import org.tizen.location.log.Log;
+
+public class LogFile extends AbstractInjectorPage {
+       
+       private static String FILE_CHECK_VALUE = "$GP"; //$NON-NLS-1$
+       
+       private Text filenameText;      
+       private Button injectButton;
+       private Button cancelButton;
+       
+       private LocationInjector injector;
+       
+       public LogFile(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents() {
+               createLogFileInjectComposite();         
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       
+       private Control createLogFileInjectComposite() {
+               Composite mainPage = formUtil.createComposite(parent, 2);
+               
+               filenameText = formUtil.createText(mainPage, ""); //$NON-NLS-1$
+
+               Button browserButton = formUtil.createButton(mainPage, Messages.LogFile_2, SWT.PUSH);
+               browserButton.addSelectionListener(new SelectionListener() {
+                       
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               String filename = ""; //$NON-NLS-1$
+                               FileDialog dialog = new FileDialog(new Shell());
+                               filename = dialog.open();
+                               
+                               if(filename == null)
+                                       return;
+                               
+                               filenameText.setText(filename);
+                               injectButton.setEnabled(validateFile());
+                       }
+                       
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                               
+                       }
+               });
+               
+               Composite buttonComposite = formUtil.createComposite(mainPage, 2);
+               
+               injectButton = formUtil.createButton(buttonComposite, Messages.LogFile_4, SWT.PUSH);
+               injectButton.addSelectionListener(new SelectionListener() {
+                       
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               final File file = new File(filenameText.getText());
+                               
+                               if (file.exists()) {
+                                       Job injectJob = new Job("Inject Job") {
+                                               
+                                               @Override
+                                               protected IStatus run(IProgressMonitor monitor) {
+                                                       try {
+                                                               injector = new LocationInjector();
+                                                               boolean ret = injector.inject(file, monitor);
+                                                               if(ret == false)
+                                                               {
+                                                                       injector.setCancel(true);
+                                                                       monitor.setCanceled(true);
+                                                               }
+                                                               
+                                                               if(monitor.isCanceled()) {
+                                                                       return Status.CANCEL_STATUS;
+                                                               }
+                                                       } catch (IOException e) {
+                                                               return Status.CANCEL_STATUS;
+                                                       }
+                                                       return Status.OK_STATUS;
+                                               }
+                                       };
+                                       
+                                       injectJob.addJobChangeListener(new JobChangeAdapter() {
+
+                                               @Override
+                                               public void scheduled(IJobChangeEvent event) {
+                                                       injectButton.setEnabled(false);
+                                                       cancelButton.setEnabled(true);
+                                                       ((Log) getParent()).setSiblingsEnabled(false);
+                                               }
+                                       });
+                                       injectJob.schedule();
+                               } else {
+                                       // Exception Error
+                               }
+                       }
+                       
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                               
+                       }
+               });
+               injectButton.setEnabled(false);
+               
+               cancelButton = formUtil.createButton(buttonComposite, Messages.LogFile_6, SWT.PUSH);
+               cancelButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               injector.setCancel(true);
+                               injectButton.setEnabled(true);
+                               cancelButton.setEnabled(false);
+                               ((Log) getParent()).setSiblingsEnabled(true);
+                       }
+               });
+               cancelButton.setEnabled(false);
+               
+               return mainPage;
+       }
+       
+       private boolean validateFile() {
+               File file = new File(filenameText.getText());
+               
+               if (!file.exists()) {
+                       return false;
+               }
+               
+               BufferedReader br;
+
+               try {
+                       br = new BufferedReader(new FileReader(file));
+                       
+                       String firstLine = br.readLine();
+                       if (!firstLine.startsWith(FILE_CHECK_VALUE)) {
+                               return false;
+                       }
+                       
+                       br.close();
+               } catch (IOException e) {
+                       return false;
+               }
+
+               return true;
+       }
+}
diff --git a/org.tizen.location.log/src/org/tizen/location/log/page/Messages.java b/org.tizen.location.log/src/org/tizen/location/log/page/Messages.java
new file mode 100644 (file)
index 0000000..bf28aaf
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * org.tizen.location.log
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.log.page;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.log.page.messages"; //$NON-NLS-1$
+       public static String LogFile_2;
+       public static String LogFile_4;
+       public static String LogFile_6;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.log/src/org/tizen/location/log/page/messages.properties b/org.tizen.location.log/src/org/tizen/location/log/page/messages.properties
new file mode 100644 (file)
index 0000000..b0849f0
--- /dev/null
@@ -0,0 +1,3 @@
+LogFile_2=Browse
+LogFile_4=Inject Log
+LogFile_6=Cancel
diff --git a/org.tizen.location.manual/.classpath b/org.tizen.location.manual/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.location.manual/.project b/org.tizen.location.manual/.project
new file mode 100644 (file)
index 0000000..cbb210f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.location.manual</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.location.manual/.settings/org.eclipse.core.resources.prefs b/org.tizen.location.manual/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..0f39f29
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:07:42 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.tizen.location.manual/.settings/org.eclipse.core.runtime.prefs b/org.tizen.location.manual/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..713b4d0
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:29:47 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.location.manual/META-INF/MANIFEST.MF b/org.tizen.location.manual/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..39be509
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Location Manual
+Bundle-SymbolicName: org.tizen.location.manual;singleton:=true
+Bundle-Version: 1.3.20.qualifier
+Bundle-Vendor: Tizen
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.ui.forms,
+ org.eclipse.core.runtime,
+ org.tizen.common,
+ org.tizen.injector,
+ org.tizen.location.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.tizen.location.manual/OSGI-INF/l10n/bundle.properties b/org.tizen.location.manual/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..ba59d98
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.tizen.location.manual
+Bundle-Vendor = Tizen
+Bundle-Name = Tizen SDK Location Manual
+Manual = Manual
\ No newline at end of file
diff --git a/org.tizen.location.manual/build.properties b/org.tizen.location.manual/build.properties
new file mode 100644 (file)
index 0000000..3605e25
--- /dev/null
@@ -0,0 +1,9 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               build.properties,\\r
+               OSGI-INF/l10n/bundle.properties\r
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.tizen.location.manual/plugin.xml b/org.tizen.location.manual/plugin.xml
new file mode 100644 (file)
index 0000000..b795162
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.2"?>\r
+<plugin>\r
+   <extension\r
+         point="org.tizen.injector.injectorItemProvider">\r
+      <itemType\r
+            category="Location"\r
+            class="org.tizen.location.manual.Manual"\r
+            id="org.tizen.location.manual"\r
+            name="%Manual">\r
+      </itemType>\r
+   </extension>\r
+</plugin>\r
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/Manual.java b/org.tizen.location.manual/src/org/tizen/location/manual/Manual.java
new file mode 100644 (file)
index 0000000..268a7ca
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * org.tizen.location.manual
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.manual;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.Section;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.location.manual.page.Coordinate;
+
+public class Manual extends AbstractInjectorItem {
+       private static String LABEL = Messages.Manual_0; 
+
+       @Override
+       protected void addPages() {
+               addPage(new Coordinate(this, Messages.Manual_1));
+       }
+       
+       public void setSiblingsEnabled(boolean enabled) {
+               ArrayList<Composite> list = getCategoryItems("Location"); //$NON-NLS-1$
+               for (int i = 0; i < list.size(); i++) {
+                       Section parent = (Section) list.get(i).getParent();
+                       if (!parent.getText().equals(LABEL)) {
+                               if(!enabled) {
+                                       parent.setExpanded(enabled);
+                               }
+                               parent.setEnabled(enabled);     
+                       }
+               }
+       }
+}
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/Messages.java b/org.tizen.location.manual/src/org/tizen/location/manual/Messages.java
new file mode 100644 (file)
index 0000000..556383f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * org.tizen.location.manual
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.manual;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.manual.messages"; //$NON-NLS-1$
+       public static String Manual_0;
+       public static String Manual_1;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/messages.properties b/org.tizen.location.manual/src/org/tizen/location/manual/messages.properties
new file mode 100644 (file)
index 0000000..0a748ca
--- /dev/null
@@ -0,0 +1,2 @@
+Manual_0=Manual
+Manual_1=Coordinate
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/page/Coordinate.java b/org.tizen.location.manual/src/org/tizen/location/manual/page/Coordinate.java
new file mode 100644 (file)
index 0000000..6576406
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * org.tizen.location.manual
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.manual.page;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+//import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+//import org.eclipse.ui.IWorkbenchWindow;
+//import org.eclipse.ui.PlatformUI;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+//import org.tizen.location.core.injector.AbstractLocationInjector;
+import org.tizen.location.core.injector.LocationInjector;
+import org.tizen.location.core.protocol.GeoLocation;
+//import org.tizen.location.core.protocol.AbstractNMEA0183;
+//import org.tizen.location.core.protocol.NMEA0183_GPGGA;
+//import org.tizen.location.core.protocol.NMEA0183_GPGSA;
+//import org.tizen.location.core.protocol.NMEA0183_GPGSV;
+//import org.tizen.location.core.protocol.NMEA0183_GPRMC;
+import org.tizen.location.manual.Manual;
+
+public class Coordinate extends AbstractInjectorPage {
+       
+       private Text latitudeText;
+       private Text longitudeText;
+       private Button injectButton;
+       private Button cancelButton;
+       
+       private LocationInjector injector;
+       
+       public Coordinate(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents() {
+               createCooridinateInputComposite();
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       
+       private Control createCooridinateInputComposite() {
+               Composite mainPage = formUtil.createComposite(parent, 2);
+               
+               formUtil.createLabel(mainPage, Messages.Coordinate_0);
+               latitudeText = formUtil.createText(mainPage, ""); //$NON-NLS-1$
+               latitudeText.addModifyListener(new ModifyListener() {
+                       
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               injectButton.setEnabled(validateValues());
+                       }
+               });
+               
+               formUtil.createLabel(mainPage, Messages.Coordinate_2);
+               longitudeText = formUtil.createText(mainPage, ""); //$NON-NLS-1$
+               longitudeText.addModifyListener(new ModifyListener() {
+                       
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               injectButton.setEnabled(validateValues());
+                       }
+               });
+               
+               injectButton = formUtil.createButton(mainPage, Messages.Coordinate_4, SWT.PUSH);
+               injectButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if(injector != null)
+                                       injector.setCancel(true);
+                               Double latitude = Double.parseDouble(latitudeText.getText().trim());
+                               Double longitude =  Double.parseDouble(longitudeText.getText().trim());
+                               final GeoLocation location = new GeoLocation(latitude, longitude);
+//                             final List<AbstractNMEA0183> NMEASentences = new ArrayList<AbstractNMEA0183>();
+                               
+//                             NMEASentences.add(new NMEA0183_GPGSV(1));
+//                             NMEASentences.add(new NMEA0183_GPGSV(2));
+//                             NMEASentences.add(new NMEA0183_GPGSV(3));
+//                             NMEASentences.add(new NMEA0183_GPGGA(Double.parseDouble(latitudeText.getText().trim()), Double.parseDouble(longitudeText.getText().trim())));
+//                             NMEASentences.add(new NMEA0183_GPRMC(Double.parseDouble(latitudeText.getText().trim()), Double.parseDouble(longitudeText.getText().trim())));
+//                             NMEASentences.add(new NMEA0183_GPGSA());
+                               
+                               Job injectJob = new Job("Inject Job") {
+                                       
+                                       @Override
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               try {
+                                                       injector = new LocationInjector();
+//                                                     injector.inject(NMEASentences.toArray(new AbstractNMEA0183[NMEASentences.size()]), monitor);
+                                                       injector.inject(location, monitor);
+                                                       if(monitor.isCanceled()) {
+                                                               return Status.CANCEL_STATUS;
+                                                       }
+                                               } catch (IOException e) {
+                                                       return Status.CANCEL_STATUS;
+                                               }
+                                               return Status.OK_STATUS;
+                                       }
+                               };
+                               
+                               injectJob.addJobChangeListener(new JobChangeAdapter() {
+
+                                       @Override
+                                       public void scheduled(IJobChangeEvent event) {
+                                               injectButton.setEnabled(false);
+                                               cancelButton.setEnabled(true);
+                                               ((Manual) getParent()).setSiblingsEnabled(false);
+                                       }
+                               });
+                               
+                               injectJob.schedule();
+                       }
+               });
+               
+               injectButton.setEnabled(false);
+               
+               cancelButton = formUtil.createButton(mainPage, Messages.Coordinate_6, SWT.PUSH);
+               cancelButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               injector.setCancel(true);
+                               injectButton.setEnabled(validateValues());
+                               cancelButton.setEnabled(false);
+                               ((Manual) getParent()).setSiblingsEnabled(true);
+                       }
+               });
+               cancelButton.setEnabled(false);
+               
+               return mainPage;
+       }
+       
+       boolean validateValues() {
+               double value;
+               
+               if (!latitudeText.getText().matches("[+|-]*[0-9]*[.]?[0-9]+")) { //$NON-NLS-1$
+                       injectButton.setEnabled(false);
+                       return false;
+               }
+               
+               value = Double.parseDouble(latitudeText.getText());
+               
+               if (value >= 90 || value <= -90) {
+                       return false;
+               }
+               
+               if (!longitudeText.getText().matches("[+|-]*[0-9]*[.]?[0-9]+")) { //$NON-NLS-1$
+                       return false;
+               }
+               
+               value = Double.parseDouble(longitudeText.getText());
+               
+               if (value >= 180 || value <= -180) {
+                       return false;
+               } 
+               
+               return true;
+       }
+}
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/page/Messages.java b/org.tizen.location.manual/src/org/tizen/location/manual/page/Messages.java
new file mode 100644 (file)
index 0000000..e6bd631
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * org.tizen.location.manual
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.manual.page;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.manual.page.messages"; //$NON-NLS-1$
+       public static String Coordinate_0;
+       public static String Coordinate_2;
+       public static String Coordinate_4;
+       public static String Coordinate_6;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.manual/src/org/tizen/location/manual/page/messages.properties b/org.tizen.location.manual/src/org/tizen/location/manual/page/messages.properties
new file mode 100644 (file)
index 0000000..004598d
--- /dev/null
@@ -0,0 +1,4 @@
+Coordinate_0=Latitude\u02DA
+Coordinate_2=Longitude\u02DA
+Coordinate_4=Inject Location
+Coordinate_6=Cancel
diff --git a/org.tizen.location.map/.classpath b/org.tizen.location.map/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.location.map/.project b/org.tizen.location.map/.project
new file mode 100644 (file)
index 0000000..51cdcb9
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.location.map</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.location.map/.settings/org.eclipse.core.resources.prefs b/org.tizen.location.map/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..0f1b4c1
--- /dev/null
@@ -0,0 +1,3 @@
+#Wed Dec 01 09:07:51 CET 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.tizen.location.map/.settings/org.eclipse.core.runtime.prefs b/org.tizen.location.map/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..cfb63fa
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:29:57 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.location.map/META-INF/MANIFEST.MF b/org.tizen.location.map/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..fcdb10a
--- /dev/null
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Location Map
+Bundle-SymbolicName: org.tizen.location.map;singleton:=true
+Bundle-Version: 1.3.20.qualifier
+Bundle-Vendor: Tizen
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.net;bundle-version="1.2.1",
+ org.eclipse.ui.forms;bundle-version="3.3.103",
+ org.tizen.common,
+ org.tizen.injector,
+ org.tizen.location.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.tizen.location.map/OSGI-INF/l10n/bundle.properties b/org.tizen.location.map/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..90b89c9
--- /dev/null
@@ -0,0 +1,4 @@
+#Properties file for org.tizen.location.map
+Bundle-Vendor = Tizen
+Bundle-Name = Tizen SDK Location Map
+Map = Map
\ No newline at end of file
diff --git a/org.tizen.location.map/build.properties b/org.tizen.location.map/build.properties
new file mode 100644 (file)
index 0000000..f9eefdc
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               OSGI-INF/l10n/bundle.properties\r
+javacSource = 1.6
+javacTarget = 1.6
diff --git a/org.tizen.location.map/html/googleMap.html b/org.tizen.location.map/html/googleMap.html
new file mode 100644 (file)
index 0000000..f15dcd6
--- /dev/null
@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1.0, user-scalable=no" /><meta http-equiv="content-type" content="text/html; charset=UTF-8"/><style type="text/css">html { height: 100% }body { height: 100%; margin: 0px; padding: 0px }#map_canvas { height: 100% }</style><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript">var map;var markersArray = [];function initialize() {var latlng = new google.maps.LatLng(37.259, 127.055);var myOptions = {zoom: 16,center: latlng,mapTypeId: google.maps.MapTypeId.ROADMAP};map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);google.maps.event.addListener(map, 'click', function(event) {placeMarker(event.latLng);});}function placeMarker(location) {var clickedLocation = new google.maps.LatLng(location);var marker = new google.maps.Marker({position: location,map: map});markersArray.push(marker);}function deleteMarkers() {if (markersArray) {for (i in markersArray) {markersArray[i].setMap(null);}markersArray.length = 0;}}</script></head><body onload="initialize()"><div id="map_canvas" style="width:100%; height:100%"></div></body></html>
diff --git a/org.tizen.location.map/plugin.xml b/org.tizen.location.map/plugin.xml
new file mode 100644 (file)
index 0000000..b52fd04
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.2"?>\r
+<plugin>\r
+   <extension\r
+         point="org.tizen.injector.injectorItemProvider">\r
+      <itemType\r
+            category="Location"\r
+            class="org.tizen.location.map.Map"\r
+            id="org.tizen.location.map"\r
+            name="%Map">\r
+      </itemType>\r
+   </extension>\r
+</plugin>\r
diff --git a/org.tizen.location.map/src/org/tizen/location/map/Map.java b/org.tizen.location.map/src/org/tizen/location/map/Map.java
new file mode 100644 (file)
index 0000000..82d88a2
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * org.tizen.location.map
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.map;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.internal.net.ProxyManager;
+import org.eclipse.core.net.proxy.IProxyData;
+import org.eclipse.core.net.proxy.IProxyService;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.Section;
+
+import org.tizen.common.model.DefaultTableModel;
+import org.tizen.injector.provider.AbstractInjectorItem;
+//import org.tizen.location.core.injector.DebugLog;
+import org.tizen.location.core.model.GeoLocationVO;
+import org.tizen.location.map.page.MapImage;
+
+@SuppressWarnings("restriction")
+public class Map extends AbstractInjectorItem {
+       private static String LABEL = Messages.Map_0;
+       
+       private DefaultTableModel model = new DefaultTableModel(new GeoLocationVO());
+       private ArrayList<TableViewer> viewerList = new ArrayList<TableViewer>();
+       public static String host = null;
+       public static int port = -1;
+       @Override
+       protected void addPages() {
+               init();
+               addPage(new MapImage(this, Messages.Map_1, model));
+       }
+       
+       private void init() {   
+               // Get Preferences - General - Network Connections
+               IProxyService proxyManager = ProxyManager.getProxyManager();
+
+               if (proxyManager.isProxiesEnabled()) {
+                       IProxyData proxyData = proxyManager.getProxyData(IProxyData.HTTP_PROXY_TYPE);
+                       host = proxyData.getHost();
+                       port = proxyData.getPort();
+
+                       if (host == null) { // no user-defined proxy
+                               if (proxyManager.hasSystemProxies() && proxyManager.isSystemProxiesEnabled()) {
+                                       // get system-wide proxy
+                                       host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
+                                       String portStr = System.getProperty("http.proxyPort"); //$NON-NLS-1$
+                                       port = ((portStr != null) ? Integer.parseInt(portStr) : -1);
+                               }
+                       }
+
+                       if (host != null) {
+                               System.setProperty("network.proxy_host", host); //$NON-NLS-1$
+                               if (port != -1) {
+                                       System.setProperty("network.proxy_port", "" + port); //$NON-NLS-1$ //$NON-NLS-2$
+                               }
+                       }
+               }
+
+//             DebugLog.log("[Activator] proxy initiate...." + System.getProperty("network.proxy_host") + " : " + //$NON-NLS-3$
+//                             System.getProperty("network.proxy_port")); //$NON-NLS-1$
+       }
+       
+       public void addViewer(TableViewer viewer){
+               viewerList.add(viewer);
+       }
+
+       public void refreshViewers() {
+               for (int i = 0; i < viewerList.size(); i++){
+                       viewerList.get(i).refresh();
+               }
+       }
+       
+       public void setSiblingsEnabled(boolean enabled) {
+               ArrayList<Composite> list = getCategoryItems("Location"); //$NON-NLS-1$
+               for (int i = 0; i < list.size(); i++) {
+                       Section parent = (Section) list.get(i).getParent();
+                       if (!parent.getText().equals(LABEL)) {
+                               if(!enabled) {
+                                       parent.setExpanded(enabled);
+                               }
+                               parent.setEnabled(enabled);     
+                       }
+               }
+       }
+}
diff --git a/org.tizen.location.map/src/org/tizen/location/map/Messages.java b/org.tizen.location.map/src/org/tizen/location/map/Messages.java
new file mode 100644 (file)
index 0000000..4b80c56
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * org.tizen.location.map
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.map;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.map.messages"; //$NON-NLS-1$
+       public static String Map_0;
+       public static String Map_1;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.map/src/org/tizen/location/map/messages.properties b/org.tizen.location.map/src/org/tizen/location/map/messages.properties
new file mode 100644 (file)
index 0000000..ecc07c8
--- /dev/null
@@ -0,0 +1,2 @@
+Map_0=Map
+Map_1=Map Image
diff --git a/org.tizen.location.map/src/org/tizen/location/map/page/MapImage.java b/org.tizen.location.map/src/org/tizen/location/map/page/MapImage.java
new file mode 100644 (file)
index 0000000..fa9328b
--- /dev/null
@@ -0,0 +1,400 @@
+/*
+ * org.tizen.location.map
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.map.page;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.UnknownHostException;
+//import java.util.ArrayList;
+//import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.tizen.common.control.TableViewContentProvider;
+import org.tizen.common.control.TableViewLabelProvider;
+import org.tizen.common.model.DefaultTableModel;
+import org.tizen.common.model.ITableVO;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+//import org.tizen.location.core.injector.AbstractLocationInjector;
+import org.tizen.location.core.injector.DebugLog;
+import org.tizen.location.core.injector.LocationInjector;
+import org.tizen.location.core.model.GeoLocationVO;
+import org.tizen.location.core.protocol.GeoLocation;
+//import org.tizen.location.core.protocol.AbstractNMEA0183;
+//import org.tizen.location.core.protocol.NMEA0183_GPGGA;
+//import org.tizen.location.core.protocol.NMEA0183_GPGSA;
+//import org.tizen.location.core.protocol.NMEA0183_GPGSV;
+//import org.tizen.location.core.protocol.NMEA0183_GPRMC;
+import org.tizen.location.map.Map;
+
+public class MapImage extends AbstractInjectorPage {
+
+       private Browser browser;
+       private String googleMapScript;
+       private TableViewer viewer;
+       private DefaultTableModel model;
+       private Button injectButton;
+       private Button resetButton;
+       private Button cancelButton;
+       
+       private LocationInjector injector;
+
+       public MapImage(AbstractInjectorItem item, String name,
+                       DefaultTableModel model) {
+               super(item, name);
+               this.model = model;
+               this.model.clear();
+       }
+
+       @Override
+       protected void createContents() {
+               createGoogleMapScript();
+               createMapComposite();
+               ((Map) getParent()).addViewer(viewer);
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+
+       }
+
+       private void createGoogleMapScript() {
+               if(Map.host == null && Map.port == -1)
+               {
+                       try {                         
+                               //make a URL to a known source                         
+                               URL url = new URL("http://www.google.com");                          
+                               
+                               //open a connection to that source
+                               HttpURLConnection urlConnect = (HttpURLConnection)url.openConnection();                          
+                               
+                               //trying to retrieve data from the source. If there                         
+                               //is no connection, this line will fail
+                               Object objData = urlConnect.getContent();
+                               urlConnect.disconnect();
+                       } catch (UnknownHostException e) {                         
+                               // TODO Auto-generated catch block                         
+                               e.printStackTrace();
+                               this.googleMapScript = "<html><head></head><body bgcolor=#dcdcdc oncontextmenu='return false'><br><br><br><br><center>Can't connect to network.</center></body></html>";
+                               return;
+                       }                 
+                       catch (IOException e) {                         
+                               // TODO Auto-generated catch block                         
+                               //e.printStackTrace();                         
+                       }
+               }
+               
+               this.googleMapScript = "<!DOCTYPE html>" //$NON-NLS-1$
+                               + "<html>" //$NON-NLS-1$
+                               + "<head>" //$NON-NLS-1$
+                               + "<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />" //$NON-NLS-1$
+                               + "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>" //$NON-NLS-1$
+                               + "<style type=\"text/css\">" //$NON-NLS-1$
+                               + "html { height: 100% }" //$NON-NLS-1$
+                               + "body { height: 100%; margin: 0px; padding: 0px }" //$NON-NLS-1$
+                               + "#map_canvas { height: 100% }" //$NON-NLS-1$
+                               + "</style>" //$NON-NLS-1$
+                               + "<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>" //$NON-NLS-1$
+                               + "<script type=\"text/javascript\">" //$NON-NLS-1$
+                               + "var map;" //$NON-NLS-1$
+                               + "var markersArray = [];" //$NON-NLS-1$
+                               + "function initialize() {" //$NON-NLS-1$
+                               + "var latlng = new google.maps.LatLng(37.259, 127.055);" //$NON-NLS-1$
+                               + "var myOptions = {" //$NON-NLS-1$
+                               + "zoom: 16," //$NON-NLS-1$
+                               + "center: latlng," //$NON-NLS-1$
+                               + "disableDoubleClickZoom: true," //$NON-NLS-1$
+                               + "keyboardShortcuts: false," //$NON-NLS-1$
+                               + "mapTypeId: google.maps.MapTypeId.ROADMAP" //$NON-NLS-1$
+                               + "};" //$NON-NLS-1$
+                               + "map = new google.maps.Map(document.getElementById(\"map_canvas\"), myOptions);" //$NON-NLS-1$
+                               + "google.maps.event.addListener(map, 'dblclick', function(event) {" //$NON-NLS-1$
+                               + "placeMarker(event.latLng);" //$NON-NLS-1$
+                               + "});" //$NON-NLS-1$
+                               + "}" //$NON-NLS-1$
+                               + "function placeMarker(location) {" //$NON-NLS-1$
+                               + "var clickedLocation = new google.maps.LatLng(location);" //$NON-NLS-1$
+                               + "var marker = new google.maps.Marker({" //$NON-NLS-1$
+                               + "position: location," //$NON-NLS-1$
+                               + "map: map" //$NON-NLS-1$
+                               + "});" //$NON-NLS-1$
+                               + "markersArray.push(marker);" //$NON-NLS-1$
+                               + "}" //$NON-NLS-1$
+                               + "function deleteMarkers() {" //$NON-NLS-1$
+                               + "if (markersArray) {" //$NON-NLS-1$
+                               + "for (i in markersArray) {" //$NON-NLS-1$
+                               + "markersArray[i].setMap(null);" //$NON-NLS-1$
+                               + "}" //$NON-NLS-1$
+                               + "markersArray.length = 0;" //$NON-NLS-1$
+                               + "}" //$NON-NLS-1$
+                               + "}" //$NON-NLS-1$
+                               + "</script>" //$NON-NLS-1$
+                               + "</head>" //$NON-NLS-1$
+                               + "<body oncontextmenu='return false' onload=\"initialize();\">" //$NON-NLS-1$
+                               + "<div id=\"map_canvas\" style=\"width:100%; height:100%\"></div>" //$NON-NLS-1$
+                               + "</body>" + "</html>"; //$NON-NLS-1$ //$NON-NLS-2$
+               
+       }
+
+       private Control createMapComposite() {
+               Composite mainPage = formUtil.createComposite(parent, 1);
+
+               browser = formUtil.createBrowser(mainPage);
+               browser.setJavascriptEnabled(true);
+               browser.addProgressListener(new ProgressListener() {
+
+                       @Override
+                       public void completed(ProgressEvent event) {
+//                             DebugLog.log("[Map] Map Loading: Compelete");
+                       }
+
+                       @Override
+                       public void changed(ProgressEvent event) {
+//                             DebugLog.log("[Map] Map Changed");
+                       }
+               });
+               browser.setText(googleMapScript);
+               browser.addMouseListener(new MouseAdapter() {
+                       @Override
+                       public void mouseDoubleClick(MouseEvent e) {
+                               Job markerJob = new Job("Add a Marker") {
+
+                                       @Override
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               IWorkbenchWindow window = PlatformUI.getWorkbench()
+                                                               .getActiveWorkbenchWindow();
+                                               if (window == null) {
+                                                       IWorkbenchWindow windows[] = PlatformUI
+                                                                       .getWorkbench().getWorkbenchWindows();
+                                                       window = windows[0];
+                                               }
+
+                                               final Shell shell = window.getShell();
+
+                                               shell.getDisplay().asyncExec(new Runnable() {
+
+                                                       @Override
+                                                       public void run() {
+                                                               try {
+                                                                       int markersCount = ((Double) browser.evaluate("return markersArray.length;")).intValue();
+                                                                       
+                                                                       // Number of markers is not changed
+                                                                       if (model.size() == markersCount) {
+                                                                               return;
+                                                                       // Number of markers is increased properly
+                                                                       } else if (model.size() == markersCount - 1) {
+                                                                               int lastIndex = markersCount - 1;
+                                                                               Double latitude = ((Double) browser.evaluate("return markersArray[" + lastIndex + "].getPosition().lat();")).doubleValue();
+                                                                               Double longitude = ((Double) browser.evaluate("return markersArray[" + lastIndex + "].getPosition().lng();")).doubleValue();
+                                                                               
+                                                                               GeoLocationVO locationVO = new GeoLocationVO();
+                                                                               
+                                                                               GeoLocation location = new GeoLocation(latitude, longitude);
+                                                                               locationVO.setSeq(markersCount);
+                                                                               locationVO.setLocation(location);
+       
+                                                                               model.add(locationVO);
+                                                                               ((Map) getParent()).refreshViewers();
+                                                                       // Number of markers is increased improperly
+                                                                       } else {
+                                                                               model.clear();
+                                                                               
+                                                                               for (int i = 0; i < markersCount; i++) {
+                                                                                       Double latitude = ((Double) browser.evaluate("return markersArray["     + i + "].getPosition().lat();")).doubleValue();
+                                                                                       Double longitude = ((Double) browser.evaluate("return markersArray[" + i+ "].getPosition().lng();")).doubleValue();
+                                                                                       
+                                                                                       GeoLocationVO locationVO = new GeoLocationVO();
+                                                                                       
+                                                                                       GeoLocation location = new GeoLocation(latitude, longitude);
+                                                                                       locationVO.setSeq(i + 1);
+                                                                                       locationVO.setLocation(location);
+                                                                                       
+                                                                                       model.add(locationVO);                                                                          
+                                                                               }
+                                                                               ((Map) getParent()).refreshViewers();
+                                                                       }
+                                                                       injectButton.setEnabled(validate());
+                                                                       resetButton.setEnabled(validate());
+                                                               } catch (SWTException ex) {
+                                                                       return;
+                                                               }
+                                                       }
+                                               });
+
+                                               return Status.OK_STATUS;
+                                       }
+                               };
+
+                               markerJob.schedule(100);
+                       }
+               });
+
+               Composite section = formUtil
+                               .createSection(mainPage, Messages.MapImage_62);
+
+               String[] columnNames = { Messages.MapImage_0, Messages.MapImage_1, Messages.MapImage_2 };
+
+               viewer = formUtil.createTableViewer(section, columnNames, 1, SWT.BORDER | SWT.H_SCROLL
+                               | SWT.V_SCROLL);
+               viewer.setContentProvider(new TableViewContentProvider());
+               viewer.setLabelProvider(new TableViewLabelProvider(viewer));
+               viewer.setInput(model);
+
+               Composite buttonComposite = formUtil.createComposite(mainPage, 3);
+               
+               injectButton = formUtil.createButton(buttonComposite, Messages.MapImage_66,
+                               SWT.PUSH);
+               injectButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+//                             final List<AbstractNMEA0183> NMEASentences = new ArrayList<AbstractNMEA0183>();
+                               final ITableVO[] dataList = (ITableVO[]) model.getDatas();
+                               
+//                             for (int i = 0; i < dataList.length; i++) {
+//                                     GeoLocationVO locationVO = (GeoLocationVO) dataList[i];
+//                                     NMEASentences.add(new NMEA0183_GPGSV(1));
+//                                     NMEASentences.add(new NMEA0183_GPGSV(2));
+//                                     NMEASentences.add(new NMEA0183_GPGSV(3));
+//                                     NMEASentences.add(new NMEA0183_GPGGA(locationVO.getLocation().getLatitude(), locationVO.getLocation().getLongitude()));
+//                                     NMEASentences.add(new NMEA0183_GPRMC(locationVO.getLocation().getLatitude(), locationVO.getLocation().getLongitude()));
+//                                     NMEASentences.add(new NMEA0183_GPGSA());
+//                             }
+                               
+                               Job injectJob = new Job("Inject Job") {
+                                       
+                                       @Override
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               try {
+                                                       injector = new LocationInjector();
+                                                       boolean ret = injector.inject(dataList, monitor);
+                                                       if(ret == false)
+                                                               this.cancel();
+                                                       
+                                                       if(monitor.isCanceled()) {
+                                                               return Status.CANCEL_STATUS;
+                                                       }
+                                               } catch (IOException e) {
+                                                       return Status.CANCEL_STATUS;
+                                               }
+                                               return Status.OK_STATUS;
+                                       }
+                               };
+                               
+                               injectJob.addJobChangeListener(new JobChangeAdapter() {
+
+                                       @Override
+                                       public void scheduled(IJobChangeEvent event) {
+                                               injectButton.setEnabled(false);
+                                               browser.setEnabled(false);
+                                               cancelButton.setEnabled(true);
+                                               resetButton.setEnabled(false);
+                                               ((Map) getParent()).setSiblingsEnabled(false);
+                                       }
+                               });
+                               
+                               injectJob.schedule();
+                       }                       
+               });
+               injectButton.setEnabled(validate());
+               
+               
+               resetButton = formUtil.createButton(buttonComposite, Messages.MapImage_68, SWT.PUSH);
+               resetButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               if (browser != null) {
+                                       try {
+                                               // Reload Google Map
+                                               browser.refresh();
+                                               boolean bResult = browser.setText(googleMapScript);
+
+                                               model.clear();
+                                               ((Map) getParent()).refreshViewers();
+                                               injectButton.setEnabled(validate());
+                                               resetButton.setEnabled(validate());
+                                               DebugLog.log("[Map] Browser reload : "
+                                                               + (bResult ? "Success" : "Fail"));
+                                       } catch (SWTException e) {
+                                               e.printStackTrace();
+                                       }
+                               } else {
+                                       DebugLog.log("Browser not created.");
+                               }
+                       }
+               });
+               resetButton.setEnabled(validate());
+               
+               cancelButton = formUtil.createButton(buttonComposite, Messages.MapImage_73, SWT.PUSH);
+               cancelButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               injector.setCancel(true);
+                               injectButton.setEnabled(true);
+                               browser.setEnabled(true);
+                               resetButton.setEnabled(true);
+                               cancelButton.setEnabled(false);
+                               ((Map) getParent()).setSiblingsEnabled(true);
+                       }
+               });
+               cancelButton.setEnabled(false);
+
+               return mainPage;
+       }
+       
+       private boolean validate() {
+               if (model.size() <= 0) {
+                       return false;
+               }
+
+               return true;
+       }
+}
diff --git a/org.tizen.location.map/src/org/tizen/location/map/page/Messages.java b/org.tizen.location.map/src/org/tizen/location/map/page/Messages.java
new file mode 100644 (file)
index 0000000..0d1c499
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * org.tizen.location.map
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.location.map.page;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.tizen.location.map.page.messages"; //$NON-NLS-1$
+       public static String MapImage_0;
+       public static String MapImage_1;
+       public static String MapImage_2;
+       public static String MapImage_62;
+       public static String MapImage_66;
+       public static String MapImage_68;
+       public static String MapImage_73;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.tizen.location.map/src/org/tizen/location/map/page/messages.properties b/org.tizen.location.map/src/org/tizen/location/map/page/messages.properties
new file mode 100644 (file)
index 0000000..6119859
--- /dev/null
@@ -0,0 +1,7 @@
+MapImage_0=Seq
+MapImage_1=Latitude
+MapImage_2=Longitude
+MapImage_62=Location Markers
+MapImage_66=Inject Markers
+MapImage_68=Reset Markers
+MapImage_73=Cancel
diff --git a/org.tizen.nfc/.classpath b/org.tizen.nfc/.classpath
new file mode 100644 (file)
index 0000000..121e527
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.nfc/.project b/org.tizen.nfc/.project
new file mode 100644 (file)
index 0000000..af6f26a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.nfc</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.nfc/.settings/org.eclipse.jdt.core.prefs b/org.tizen.nfc/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..71c4657
--- /dev/null
@@ -0,0 +1,8 @@
+#Tue Oct 04 17:29:44 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.nfc/META-INF/MANIFEST.MF b/org.tizen.nfc/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..1a440bc
--- /dev/null
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Nfc
+Bundle-SymbolicName: org.tizen.nfc;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.tizen.injector,
+ org.eclipse.swt;bundle-version="3.6.2",
+ org.tizen.common;bundle-version="1.3.20",
+ org.tizen.common.connection;bundle-version="1.0.0",
+ org.eclipse.core.runtime;bundle-version="3.7.0"
+Import-Package: org.tizen.sdblib,
+ org.eclipse.ui.plugin
diff --git a/org.tizen.nfc/build.properties b/org.tizen.nfc/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.nfc/plugin.xml b/org.tizen.nfc/plugin.xml
new file mode 100644 (file)
index 0000000..2b0e9c3
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Nfc"
+            class="org.tizen.nfc.Nfc"
+            id="org.tizen.nfc"
+            name="Nfc">
+      </itemType>
+   </extension>
+</plugin>
diff --git a/org.tizen.nfc/src/org/tizen/nfc/Nfc.java b/org.tizen.nfc/src/org/tizen/nfc/Nfc.java
new file mode 100644 (file)
index 0000000..64b7975
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * org.tizen.nfc.tag
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ * Jihye kim <jihye1128.kim@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.nfc;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.nfc.page.NfcPage;
+
+public class Nfc extends AbstractInjectorItem
+{
+       @Override
+       protected void addPages()
+       {
+               addPage(new NfcPage(this, "NFC"));
+       }
+}
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NDEFRecord.java b/org.tizen.nfc/src/org/tizen/nfc/page/NDEFRecord.java
new file mode 100644 (file)
index 0000000..29ee521
--- /dev/null
@@ -0,0 +1,61 @@
+package org.tizen.nfc.page;
+
+public class NDEFRecord
+{
+       private int     format          = 0;
+       private String  typename        = null;
+       private String  id                      = null;
+       private String  payload         = null;
+       
+       public NDEFRecord()
+       {
+       }
+
+       public NDEFRecord(int f, String n, String i, String p)
+       {
+               setFormat(f);
+               setTypeName(n);
+               setId(i);
+               setPayload(p);
+       }
+       
+       public int getFormat()
+       {
+               return format;
+       }
+
+       public void setFormat(int format)
+       {
+               this.format = format;
+       }
+
+       public String getTypeName()
+       {
+               return typename;
+       }
+
+       public void setTypeName(String name)
+       {
+               this.typename = name;
+       }
+
+       public String getId()
+       {
+               return id;
+       }
+
+       public void setId(String id)
+       {
+               this.id = id;
+       }
+
+       public String getPayload()
+       {
+               return payload;
+       }
+
+       public void setPayload(String payload)
+       {
+               this.payload = payload;
+       }
+}
\ No newline at end of file
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NfcCommand.java b/org.tizen.nfc/src/org/tizen/nfc/page/NfcCommand.java
new file mode 100644 (file)
index 0000000..56226a3
--- /dev/null
@@ -0,0 +1,10 @@
+package org.tizen.nfc.page;
+
+public class NfcCommand
+{
+       public static final Integer NFC_TAG_DISCOVERED  = 100;
+       public static final Integer NFC_TAG_DETACHED    = 101;
+       public static final Integer NFC_P2P_DISCOVERED  = 102;
+       public static final Integer NFC_P2P_DETACHED    = 103;
+       public static final Integer NFC_P2P_SEND                = 104;
+}
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NfcDialog.java b/org.tizen.nfc/src/org/tizen/nfc/page/NfcDialog.java
new file mode 100644 (file)
index 0000000..5bfc9e8
--- /dev/null
@@ -0,0 +1,72 @@
+package org.tizen.nfc.page;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class NfcDialog
+{
+    public static void openInfoDialog(String message) {
+       openInfoDialog(new Shell(), message);
+    }
+
+    public static void openInfoDialog(final Shell shell, final String message) {
+       Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       openInfoDialog(s, "Info", message);
+    }
+
+    public static void openInfoDialog(final Shell shell, final String title, final String message) {
+       final Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+  
+       Display.getDefault().syncExec(new Runnable() {
+            public void run() {
+                MessageBox dialog = new MessageBox(s, SWT.OK | SWT.MODELESS | SWT.ICON_INFORMATION);
+                dialog.setText(title);
+                dialog.setMessage(message);
+                dialog.open();
+            }
+        });
+    }
+
+    public static void openErrorDialog(String message) {
+        openErrorDialog(new Shell(), message);
+    }
+    
+    public static void openErrorDialog(final Shell shell, final String message) {
+       Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       openErrorDialog(s, "Error", message);
+    }
+
+    public static void openErrorDialog(final Shell shell, final String title, final String message) {
+       final Shell s;
+       if (shell == null) {
+               s = new Shell();
+       } else {
+               s = shell;
+       }
+       Display.getDefault().syncExec(new Runnable() {
+            public void run() {
+                MessageBox dialog = new MessageBox(s, SWT.OK | SWT.MODELESS | SWT.ICON_ERROR);
+                dialog.setText(title);
+                dialog.setMessage(message);
+                dialog.open();
+            }
+        });
+    }
+}
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NfcMimeType.java b/org.tizen.nfc/src/org/tizen/nfc/page/NfcMimeType.java
new file mode 100644 (file)
index 0000000..06f8ce4
--- /dev/null
@@ -0,0 +1,81 @@
+package org.tizen.nfc.page;
+
+import java.util.ArrayList;
+
+class MimeTypeList
+{
+       private static MimeTypeList typelist = new MimeTypeList();
+       private ArrayList<NfcMimeType> list;
+       
+       public static MimeTypeList getInstance()
+       {
+               return typelist;
+       }
+
+       private MimeTypeList()
+       {
+               list = new ArrayList<NfcMimeType>();
+               list.add(new NfcMimeType("vcf", "application/vcard"));
+               list.add(new NfcMimeType("jpeg", "image/jpeg"));
+               list.add(new NfcMimeType("mpeg", "image/mpeg"));
+               list.add(new NfcMimeType("png", "image/png"));
+               list.add(new NfcMimeType("gif", "image/gif"));
+               list.add(new NfcMimeType("bmp", "image/bmp"));
+               list.add(new NfcMimeType("jpg", "image/jpeg"));
+               list.add(new NfcMimeType("jpe", "image/jpeg"));
+               list.add(new NfcMimeType("mp3", "audio/mpeg"));
+               list.add(new NfcMimeType("mid", "audio/midi"));
+               list.add(new NfcMimeType("wav", "audio/x-wav"));
+               list.add(new NfcMimeType("mp4", "video/mp4"));
+               list.add(new NfcMimeType("mpe", "video/mpeg"));
+               list.add(new NfcMimeType("mpg", "video/mpeg"));
+               list.add(new NfcMimeType("mov", "video/quicktime"));
+               list.add(new NfcMimeType("flv", "video/x-flv"));
+               list.add(new NfcMimeType("asf", "video/x-ms-asf"));
+               list.add(new NfcMimeType("avi", "video/x-msvideo"));
+       }
+       
+       public String findMimeType(String ex)
+       {
+
+               for (NfcMimeType mimetype : list) {
+                       if (mimetype.getExtension().equals(ex)) {
+                               return mimetype.getMimetype();
+                       }
+               }
+
+               return null;
+       }
+}
+
+class NfcMimeType
+{
+       private String extension;
+       private String mimetype;
+       
+       public NfcMimeType(String ex, String type)
+       {
+               setExtension(ex);
+               setMimetype(type);
+       }
+
+       public String getExtension()
+       {
+               return extension;
+       }
+
+       public void setExtension(String extension)
+       {
+               this.extension = extension;
+       }
+
+       public String getMimetype()
+       {
+               return mimetype;
+       }
+
+       public void setMimetype(String mimetype)
+       {
+               this.mimetype = mimetype;
+       }
+}
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NfcPage.java b/org.tizen.nfc/src/org/tizen/nfc/page/NfcPage.java
new file mode 100644 (file)
index 0000000..4598a65
--- /dev/null
@@ -0,0 +1,954 @@
+/*
+ * org.tizen.nfc.tag.page
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye kim <jihye1128.kim@samsung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.nfc.page;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.SdbCommandRejectedException;
+import org.tizen.sdblib.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.TimeoutException;
+
+public class NfcPage extends AbstractInjectorPage implements ISelectionListener
+{
+       // add NDEFMessage
+       private String[] RecordFormatList       = RecordFormat.getInstance().getList();
+       private String[] TypeNameList           = TypeName.getInstance().getList();
+       private Combo cmbRecordFormat;
+       private Combo cmbRecordTypeName;
+       private Text txtRecordTypeName;
+       private Text txtRecordID;
+       private Text txtRecordPayload;
+       private Button butSelectMediaFile;
+
+       // check invalid characters
+       private NDEFRecord oldRecord = new NDEFRecord(0, "", "", "");
+       private boolean bCheckTypeNameText = true;
+       private boolean bCheckIDText = true;
+       private boolean bCheckPayloadText = true;
+
+       private Button butRecordAdd;
+       private Button butRecordEdit;
+       private Button butRecordRemove;
+
+       private Label lblRecords;
+       private int nTotalLength = 0;
+       private final int nMaxNDFEMessageLength = 4096;
+       private Combo cmbRecordList;
+       private ArrayList<NDEFRecord> RecordList = new ArrayList<NDEFRecord>();
+
+       // add Tag
+       private String[] TagTypeList = TagType.getInstance().getList();
+       private Combo cmbTagTypeList;
+       private Button butTagAttach;
+       private Button butTagDetach;
+
+       // add P2P
+       private Button butP2PDiscover;
+       private Button butP2PSend;
+       private Button butP2PDetach;
+
+       private IDevice currentDevice;
+       private Shell shell = null;
+
+       public NfcPage(AbstractInjectorItem item, String name)
+       {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents()
+       {
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+
+               shell = parent.getShell();
+
+               createNDEFMessageSection();
+               createTagSection();
+               createP2PSection();
+
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+
+       private void createNDEFMessageSection()
+       {
+               Composite client = formUtil.createSection(parent, "NDEF Message");
+               Composite messageComposite = formUtil.createComposite(client);
+
+               createRecordComposite(messageComposite);
+
+               Composite buttonComposite = formUtil.createComposite(messageComposite,
+                               3);
+               butRecordAdd = formUtil.createButton(buttonComposite, "Add", SWT.PUSH);
+               butRecordEdit = formUtil
+                               .createButton(buttonComposite, "Edit", SWT.PUSH);
+               butRecordRemove = formUtil.createButton(buttonComposite, "Remove",
+                               SWT.PUSH);
+
+               GridData gd1 = new GridData();
+               gd1.widthHint = 110;
+               butRecordAdd.setLayoutData(gd1);
+               butRecordEdit.setLayoutData(gd1);
+               butRecordRemove.setLayoutData(gd1);
+
+               butRecordAdd.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               addRecord();
+                       }
+               });
+               butRecordEdit.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               editRecord();
+                       }
+               });
+               butRecordRemove.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               removeRecord();
+                       }
+               });
+
+               Composite RecordComposite = formUtil.createComposite(messageComposite, 2);
+               GridData gd2 = new GridData();
+               gd2.widthHint = 160;
+               lblRecords = formUtil.createLabel(RecordComposite, String.format("Records [0/%d] ", nMaxNDFEMessageLength));
+               lblRecords.setLayoutData(gd2);
+
+               cmbRecordList = formUtil.createCombo(RecordComposite);
+               cmbRecordList.setLayoutData(gd2);
+               cmbRecordList.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               selectRecord();
+                       }
+               });
+       }
+
+       private void createRecordComposite(Composite parent)
+       {
+               GridData gd1 = new GridData();
+               gd1.widthHint = 200;
+
+               Composite messageComposite = formUtil.createComposite(parent, 2);
+
+               formUtil.createLabel(messageComposite, "Type Name Format ");
+               cmbRecordFormat = formUtil.createCombo(messageComposite);
+               cmbRecordFormat.setLayoutData(gd1);
+               formUtil.addComboItem(cmbRecordFormat, RecordFormatList);
+               cmbRecordFormat.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               Selected(e);
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               Selected(e);
+                       }
+
+                       private void Selected(SelectionEvent e) {
+                               int i = cmbRecordFormat.getSelectionIndex();
+                               if (i != -1) {
+                                       checkRecordFormat(i);
+                                       txtRecordTypeName.setText("");
+                                       cmbRecordTypeName.select(0);
+                                       txtRecordID.setText("");
+                                       txtRecordPayload.setText("");
+                               }
+                       }
+               });
+
+               formUtil.createLabel(messageComposite, "Type Name ");
+               txtRecordTypeName = formUtil.createText(messageComposite, "");
+               txtRecordTypeName.setEnabled(false);
+               txtRecordTypeName.setLayoutData(gd1);
+               txtRecordTypeName.setTextLimit(250);
+               txtRecordTypeName.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               if (bCheckTypeNameText == false) {
+                                       bCheckTypeNameText = true;
+                                       return;
+                               }
+                               if (checkInvalidCharaters(txtRecordTypeName.getText()) == false) {
+                                       txtRecordTypeName.setText(oldRecord.getTypeName());
+                                       return;
+                               }
+                               oldRecord.setTypeName(txtRecordTypeName.getText());
+                       }
+               });
+
+               formUtil.createLabel(messageComposite, "");
+               cmbRecordTypeName = formUtil.createCombo(messageComposite);
+               formUtil.addComboItem(cmbRecordTypeName, TypeNameList);
+               cmbRecordTypeName.setEnabled(false);
+               cmbRecordTypeName.setLayoutData(gd1);
+
+               formUtil.createLabel(messageComposite, "ID ");
+               txtRecordID = formUtil.createText(messageComposite, "");
+               txtRecordID.setEnabled(false);
+               txtRecordID.setLayoutData(gd1);
+               txtRecordID.setTextLimit(250);
+               txtRecordID.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               if (bCheckIDText == false) {
+                                       bCheckIDText = true;
+                                       return;
+                               }
+                               if (checkInvalidCharaters(txtRecordID.getText()) == false) {
+                                       txtRecordID.setText(oldRecord.getId());
+                                       return;
+                               }
+                               oldRecord.setId(txtRecordID.getText());
+                       }
+               });
+
+               formUtil.createLabel(messageComposite, "Payload ");
+               txtRecordPayload = formUtil.createText(messageComposite, "");
+               txtRecordPayload.setEnabled(false);
+               txtRecordPayload.setLayoutData(gd1);
+               txtRecordPayload.setTextLimit(1024);
+               txtRecordPayload.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               if (bCheckPayloadText == false) {
+                                       bCheckPayloadText = true;
+                                       return;
+                               }
+                               if (checkInvalidCharaters(txtRecordPayload.getText()) == false) {
+                                       txtRecordPayload.setText(oldRecord.getPayload());
+                                       return;
+                               }
+                               oldRecord.setPayload(txtRecordPayload.getText());
+                       }
+               });
+
+               formUtil.createLabel(messageComposite, "");
+               butSelectMediaFile = formUtil.createButton(messageComposite,
+                               "Select Media File", SWT.PUSH);
+               butSelectMediaFile.setEnabled(false);
+               butSelectMediaFile.setLayoutData(new GridData(GridData.END,
+                               GridData.END, false, false));
+               butSelectMediaFile.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               selectMediaFile();
+                       }
+               });
+       }
+
+       private void createTagSection()
+       {
+               Composite client = formUtil.createSection(parent, "NFC Tag");
+               Composite mainComposite = formUtil.createComposite(client, 3);
+
+               formUtil.createLabel(mainComposite, "Tag Type ");
+               cmbTagTypeList = formUtil.createCombo(mainComposite);
+               GridData gd1 = new GridData();
+               gd1.widthHint = 180;
+               cmbTagTypeList.setLayoutData(gd1);
+               formUtil.addComboItem(cmbTagTypeList, TagTypeList, TagTypeList[0]);
+
+               GridData gd2 = new GridData();
+               gd2.widthHint = 100;
+
+               butTagAttach = formUtil.createButton(mainComposite, "Tag Attach", SWT.PUSH);
+               butTagAttach.setLayoutData(gd2);
+
+               formUtil.createLabel(mainComposite, "");
+               formUtil.createLabel(mainComposite, "");
+               butTagDetach = formUtil.createButton(mainComposite, "Tag Detach", SWT.PUSH);
+               butTagDetach.setLayoutData(gd2);
+               butTagDetach.setEnabled(false);
+
+               butTagAttach.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               clickTagDiscovered();
+                       }
+               });
+
+               butTagDetach.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               clickTagDetached();
+                       }
+               });
+       }
+
+       private void createP2PSection()
+       {
+               Composite client = formUtil.createSection(parent, "Peer to Peer");
+               Composite mainComposite = formUtil.createComposite(client, 2);
+
+               butP2PDiscover = formUtil.createButton(mainComposite, "P2P Discovered", SWT.PUSH);
+               butP2PDetach = formUtil.createButton(mainComposite, "P2P Detached", SWT.PUSH);
+               butP2PSend = formUtil.createButton(mainComposite, "P2PSend", SWT.PUSH);
+               
+               // TODO
+               butP2PDiscover.setEnabled(true);
+               butP2PDetach.setEnabled(false);
+               butP2PSend.setEnabled(false);
+               //
+
+               GridData gd = new GridData();
+               gd.widthHint = 170;
+               butP2PDiscover.setLayoutData(gd);
+               butP2PDetach.setLayoutData(gd);
+               butP2PSend.setLayoutData(gd);
+
+               butP2PDiscover.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e)
+                       {
+                               clickP2PDiscovered();
+                       }
+               });
+
+               butP2PDetach.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e)
+                       {
+                               clickP2PDetached();
+                       }
+               });
+
+               butP2PSend.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e)
+                       {
+                               clickP2PSend();
+                       }
+               });
+       }
+
+       private void selectRecord() {
+               int i = cmbRecordList.getSelectionIndex();
+               if (i != -1) {
+                       NDEFRecord record = RecordList.get(i);
+                       checkRecordFormat(record.getFormat());
+                       cmbRecordFormat.select(record.getFormat());
+
+                       if (record.getFormat() == 1) {
+                               if (record.getTypeName().compareTo("U") == 0)
+                                       cmbRecordTypeName.select(0);
+                               else
+                                       cmbRecordTypeName.select(1);
+                               txtRecordTypeName.setText("");
+                       } else {
+                               cmbRecordTypeName.select(0);
+                               txtRecordTypeName.setText(record.getTypeName());
+                       }
+
+                       txtRecordID.setText(record.getId());
+                       txtRecordPayload.setText(record.getPayload());
+               }
+       }
+
+       private boolean checkInvalidCharaters(String text)
+       {
+               char[] textArray = new char[1000];
+               text.getChars(0, text.length(), textArray, 0);
+
+               for (int i = 0; i < text.length(); i++) {
+                       char c = textArray[i];
+                       if (c == '\n') {
+                               NfcDialog.openInfoDialog(shell, "Can not enter a newline character.");
+                               return false;
+                       }
+                       
+                       if (c == ',') {
+                               NfcDialog.openInfoDialog(shell, "Can not enter ',' character.\nThis character is used separater character.");
+                               return false;
+                       }
+
+                       if (c >= 0x80) {
+                               NfcDialog.openInfoDialog(shell, "Invalid characters are entered.\nOnly ASCII characters can be entered.\n");
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private void clickTagDiscovered() {
+               String msg = makeSendMessage(NfcCommand.NFC_TAG_DISCOVERED);
+               if (msg != null) {
+                       sendMessage(msg);
+                       {
+                               cmbRecordFormat.setEnabled(false);
+                               checkRecordFormat(0);
+
+                               cmbRecordList.setEnabled(false);
+                               butRecordAdd.setEnabled(false);
+                               butRecordEdit.setEnabled(false);
+                               butRecordRemove.setEnabled(false);
+
+                               cmbTagTypeList.setEnabled(false);
+                               butTagAttach.setEnabled(false);
+                               butTagDetach.setEnabled(true);
+                               
+                               butP2PDiscover.setEnabled(false);
+                               butP2PDetach.setEnabled(false);
+                               butP2PSend.setEnabled(false);
+                       }
+               }
+       }
+
+       private void clickTagDetached() {
+               String msg = makeSendMessage(NfcCommand.NFC_TAG_DETACHED);
+               if (msg != null) {
+                       sendMessage(msg);
+                       {
+                               cmbRecordFormat.setEnabled(true);
+
+                               checkRecordFormat(cmbRecordFormat.getSelectionIndex());
+                               txtRecordTypeName.setText("");
+                               cmbRecordTypeName.select(0);
+                               txtRecordID.setText("");
+                               txtRecordPayload.setText("");
+
+                               cmbRecordList.setEnabled(true);
+                               butRecordAdd.setEnabled(true);
+                               butRecordEdit.setEnabled(true);
+                               butRecordRemove.setEnabled(true);
+
+                               cmbTagTypeList.setEnabled(true);
+                               butTagAttach.setEnabled(true);
+                               butTagDetach.setEnabled(false);
+                               
+                               butP2PDiscover.setEnabled(true);
+                               butP2PDetach.setEnabled(false);
+                               butP2PSend.setEnabled(false);
+                       }
+               }
+       }
+
+       private void clickP2PDiscovered() {
+               String msg = makeSendMessage(NfcCommand.NFC_P2P_DISCOVERED);
+               if (msg != null) {
+                       sendMessage(msg);
+                       {
+                               cmbTagTypeList.setEnabled(false);
+                               butTagAttach.setEnabled(false);
+                               butTagDetach.setEnabled(false);
+                               
+                               butP2PDiscover.setEnabled(false);
+                               butP2PDetach.setEnabled(true);
+                               butP2PSend.setEnabled(true);
+                       }       
+               }
+               
+       }
+       
+       private void clickP2PDetached() {
+               String msg = makeSendMessage(NfcCommand.NFC_P2P_DETACHED);
+               if (msg != null) {
+                       sendMessage(msg);
+                       {
+                               cmbRecordFormat.setEnabled(true);
+
+                               checkRecordFormat(cmbRecordFormat.getSelectionIndex());
+                               txtRecordTypeName.setText("");
+                               cmbRecordTypeName.select(0);
+                               txtRecordID.setText("");
+                               txtRecordPayload.setText("");
+
+                               cmbRecordList.setEnabled(true);
+                               butRecordAdd.setEnabled(true);
+                               butRecordEdit.setEnabled(true);
+                               butRecordRemove.setEnabled(true);
+
+                               cmbTagTypeList.setEnabled(true);
+                               butTagAttach.setEnabled(true);
+                               butTagDetach.setEnabled(false);
+                               
+                               butP2PDiscover.setEnabled(true);
+                               butP2PDetach.setEnabled(false);
+                               butP2PSend.setEnabled(false);
+                       }
+               }
+       }
+
+       private void clickP2PSend() {
+               String msg = makeSendMessage(NfcCommand.NFC_P2P_SEND);
+               if (msg != null) {
+                       sendMessage(msg);
+                       cmbRecordFormat.setEnabled(false);
+                       checkRecordFormat(0);
+
+                       cmbRecordList.setEnabled(false);
+                       butRecordAdd.setEnabled(false);
+                       butRecordEdit.setEnabled(false);
+                       butRecordRemove.setEnabled(false);
+
+                       cmbTagTypeList.setEnabled(false);
+                       butTagAttach.setEnabled(false);
+                       butTagDetach.setEnabled(false);
+
+                       butP2PDiscover.setEnabled(false);
+                       butP2PDetach.setEnabled(true);
+                       butP2PSend.setEnabled(false);
+               }
+       }
+
+       private void checkRecordFormat(int format)
+       {
+               switch (format) {
+               case 0: // NDEF_TNF_EMPTY
+                       cmbRecordTypeName.setEnabled(false);
+                       txtRecordTypeName.setEnabled(false);
+                       txtRecordID.setEnabled(false);
+                       txtRecordPayload.setEnabled(false);
+                       butSelectMediaFile.setEnabled(false);
+                       break;
+               case 1: // NDEF_TNF_WELL_KNOWN
+                       cmbRecordTypeName.setEnabled(true);
+                       cmbRecordTypeName.select(0);
+                       txtRecordTypeName.setEnabled(false);
+                       txtRecordID.setEnabled(true);
+                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEditable(true);
+                       butSelectMediaFile.setEnabled(false);
+                       break;
+               case 2: // NDEF_TNF_MIME_MEDIA
+                       cmbRecordTypeName.setEnabled(false);
+                       txtRecordTypeName.setEnabled(true);
+                       txtRecordTypeName.setEditable(false);
+                       txtRecordID.setEnabled(true);
+                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEditable(false);
+                       butSelectMediaFile.setEnabled(true);
+                       break;
+               case 3: // NDEF_TNF_ABSOLUTE_URI
+               case 4: // NDEF_TNF_EXTERNAL
+                       cmbRecordTypeName.setEnabled(false);
+                       txtRecordTypeName.setEnabled(true);
+                       txtRecordTypeName.setEditable(true);
+                       txtRecordID.setEnabled(true);
+                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEditable(true);
+                       butSelectMediaFile.setEnabled(false);
+                       break;
+               case 5: // NDEF_TNF_UNKNOWN
+                       cmbRecordTypeName.setEnabled(false);
+                       txtRecordTypeName.setEnabled(false);
+                       txtRecordID.setEnabled(true);
+                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEditable(true);
+                       butSelectMediaFile.setEnabled(false);
+                       break;
+               }
+               bCheckTypeNameText = false;
+               bCheckIDText = false;
+               bCheckPayloadText = false;
+       }
+
+       private void addRecord()
+       {
+               if (RecordList.size() >= 5) {
+                       NfcDialog.openInfoDialog(shell, "The number of NDEF records has reached the maximum limit of 5.\n");
+                       return;
+               }
+
+               NDEFRecord record = new NDEFRecord();
+
+               /*
+               // check duplicate id !!
+               if (cmbRecordFormat.getSelectionIndex() != 0) {
+                       if (!checkRecordID(txtRecordID.getText() != null ? txtRecordID.getText() : "Null")) {
+                               return;
+                       }
+               }
+               */
+
+               setRecordValue(record);
+               RecordList.add(record);
+               if (!checkRecordlistMaxLength()) {
+                       RecordList.remove(record);
+                       return;
+               }
+
+               lblRecords.setText(String.format("Records [%4d/%d] ", nTotalLength, nMaxNDFEMessageLength));
+               cmbRecordList.add("record item" + RecordList.indexOf(record));
+               cmbRecordList.clearSelection();
+       }
+
+       private void editRecord()
+       {
+               int i = cmbRecordList.getSelectionIndex();
+               if (i != -1) {
+                       NDEFRecord record = RecordList.get(i);
+                       /*
+                       // check duplicate id !!
+                       if (record.getFormat() != 0) {
+                               if (!checkRecordID(txtRecordID.getText() != null ? txtRecordID.getText() : "Null", i)) {
+                                       return;
+                               }
+                       }
+                       */
+
+                       NDEFRecord copyRecord = record;
+                       setRecordValue(record);
+
+                       if (!checkRecordlistMaxLength()) {
+                               record = copyRecord;
+                               return;
+                       }
+
+                       lblRecords.setText(String.format("Records [%4d/%d] ",   nTotalLength, nMaxNDFEMessageLength));
+                       // cmbRecordFormat.select(record.getFormat());
+                       // checkFormat(record.getFormat());
+               }
+       }
+
+       private void removeRecord()
+       {
+               int index = cmbRecordList.getSelectionIndex();
+               if (index != -1) {
+                       RecordList.remove(index);
+                       cmbRecordList.removeAll();
+                       for (int i = 0; i < RecordList.size(); i++) {
+                               cmbRecordList.add("record item" + i);
+                       }
+                       cmbRecordList.clearSelection();
+               }
+
+               checkRecordlistMaxLength();
+               lblRecords.setText(String.format("Records [%4d/%d] ", nTotalLength, nMaxNDFEMessageLength));
+               txtRecordTypeName.setText("");
+               cmbRecordTypeName.select(0);
+               txtRecordID.setText("");
+               txtRecordPayload.setText("");
+       }
+
+       private void setRecordValue(NDEFRecord record)
+       {
+               record.setFormat(cmbRecordFormat.getSelectionIndex());
+
+               if (cmbRecordFormat.getSelectionIndex() == 1) {
+                       record.setTypeName(TypeNameList[cmbRecordTypeName.getSelectionIndex()]);
+               } else {
+                       if (txtRecordTypeName.getText().isEmpty() == true)
+                               record.setTypeName("Null");
+                       else
+                               record.setTypeName(txtRecordTypeName.getText());
+               }
+
+               if (txtRecordID.getText().isEmpty() == true)
+                       record.setId("Null");
+               else
+                       record.setId(txtRecordID.getText());
+
+               if (txtRecordPayload.getText().isEmpty() == true)
+                       record.setPayload("Null");
+               else
+                       record.setPayload(txtRecordPayload.getText());
+       }
+
+/*
+       private boolean checkRecordID(String id)
+       {
+               for (NDEFRecord record : RecordList) {
+                       if (id.equals(record.getId())) {
+                               NfcDialog.openInfoDialog(shell, "Duplicate ID is not allowed.\n");
+                               return false;
+                       }
+               }
+
+               return true;
+       }
+
+       private boolean checkRecordID(String id, int except)
+       {
+               NDEFRecord record;
+               for (int i = 0; i < RecordList.size(); i++) {
+                       if (i == except)
+                               continue;
+
+                       record = RecordList.get(i);
+                       if (id.equals(record.getId())) {
+                               NfcDialog.openInfoDialog(shell, "Duplicate ID is not allowed.\n");
+                               return false;
+                       }
+               }
+
+               return true;
+
+       }
+*/
+
+       private boolean checkRecordlistMaxLength()
+       {
+               int lenList = 0;
+
+               for (NDEFRecord record : RecordList) {
+                       lenList += 1 + record.getTypeName().length()
+                                   + record.getId().length() + record.getPayload().length() + 4;
+               }
+
+               if (lenList > nMaxNDFEMessageLength) {
+                       NfcDialog.openInfoDialog(shell, String.format("The length of the NDEF message has reached the maxium limit of %d bytes\n", nMaxNDFEMessageLength));
+                       return false;
+               }
+
+               nTotalLength = lenList;
+
+               return true;
+       }
+
+       private static String MediaFilePath = null;
+       private String shellCmd    = null;
+       private String shellResult = null;
+
+       private void selectMediaFile()
+       {
+               MediaFilePath = null;
+               if (shell != null) {
+                       shell.getDisplay().syncExec(new Runnable() {
+                               public void run() {
+                                       TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(
+                                                       shell, "Select a media file", currentDevice, false,
+                                                       "/opt/nfc");
+                                       if (dlg.open() == TizenRemoteFileDialogResult.OK) {
+                                               FileEntry fileEntry = dlg.getSelectedFileEntry();
+                                               MediaFilePath = fileEntry.getFullPath();
+                                       }
+                               }
+                       });
+               } else {
+                       NfcDialog.openErrorDialog("Can not open emulator's file dialog.\n");
+               }
+
+               if (MediaFilePath == null) {
+                       NfcDialog.openErrorDialog(shell, "Please choose media file.\n");
+               } else {
+                       String type = null;
+                       type = checkFileType(MediaFilePath);
+                       if (type == null) {
+                               NfcDialog.openErrorDialog(shell, "Type of selected file is not mime media type.\n");
+                               return;
+                       }
+                       if (checkFileSize(MediaFilePath) == false) {
+                               NfcDialog.openErrorDialog(shell, "Size of selected file is too big. Available file size is under of 10.\n");
+                               return;
+                       }
+                       txtRecordTypeName.setEnabled(true);
+                       txtRecordTypeName.setEditable(false);
+                       txtRecordPayload.setEnabled(true);
+                       txtRecordPayload.setEditable(false);
+                       txtRecordTypeName.setText(type);
+                       txtRecordPayload.setText(MediaFilePath);
+               }
+       }
+
+       private String checkFileType(String filePath) {
+               int index   = filePath.lastIndexOf('.');
+               String type = null;
+               if (index != -1) {
+                       String ex = filePath.substring(index + 1);
+                       MimeTypeList typelist = MimeTypeList.getInstance();
+
+                       type = typelist.findMimeType(ex);
+               }
+               return type;
+       }
+
+       private boolean checkFileSize(String filePath) {
+               boolean result = false;
+               shellCmd    = "du " + filePath;
+               try {
+                       currentDevice.executeShellCommand(shellCmd, new MultiLineReceiver() {
+                               @Override
+                               public void processNewLines(String[] lines) {
+                                       shellResult = lines[0];
+                               }
+                               
+                       });
+               } catch (TimeoutException e) {
+                       errorSelectMediaFile(e);
+                       return result;
+               } catch (SdbCommandRejectedException e) {
+                       errorSelectMediaFile(e);
+                       return result;
+               } catch (ShellCommandUnresponsiveException e) {
+                       errorSelectMediaFile(e);
+                       return result;
+               } catch (IOException e) {
+                       errorSelectMediaFile(e);
+                       return result;
+               }
+               if (shellResult != null) {
+                       int index = shellResult.indexOf('\t');
+                       if (index != -1) {
+                               shellResult = shellResult.substring(0, index);
+                               
+                               if (Integer.valueOf(shellResult) <= 10) {
+                                       result = true;
+                               }
+                       }
+               }
+               return result;
+       }
+
+       private void errorSelectMediaFile(Exception e) {
+               NfcDialog.openErrorDialog(shell, String.format("Throw exception while select media file : %s\n", e.getMessage()));
+       }
+
+       private String makeSendMessage(Integer type)
+       {
+               String msg = null;
+               switch (type) {
+               case 100: // NFC_TAG_DISCOVERED
+               {
+                       int tagtype = cmbTagTypeList.getSelectionIndex();
+                       if (tagtype != -1 && tagtype != 0) {
+                               String records = new String();
+                               records += "," + RecordList.size();
+                               for (NDEFRecord record : RecordList) {
+                                       records += "," + record.getFormat() + ","
+                                                       + record.getTypeName() + "," + record.getId() + ","
+                                                       + record.getPayload();
+                               }
+
+                               msg = NfcCommand.NFC_TAG_DISCOVERED.toString() + ":"
+                                               + String.valueOf(tagtype) + records + "\n";
+
+                       } else {
+                               NfcDialog.openErrorDialog(shell, "Select Tag Type\n");
+                               return null;
+                       }
+               }
+                       break;
+               case 101: // NFC_TAG_DETACHED
+                       msg = NfcCommand.NFC_TAG_DETACHED.toString() + ":" + "\n";
+                       break;
+               case 102: // NFC_P2P_DISCOVERED
+                       msg = NfcCommand.NFC_P2P_DISCOVERED.toString() + ":\n";
+                       break;
+               case 103: // NFC_P2P_DETACHED
+                       msg = NfcCommand.NFC_P2P_DETACHED.toString() + ":\n";
+                       break;
+               case 104: // NFC_P2P_SEND
+               {
+                       int tagtype = 5;        // for peer to peer
+                       String records = new String();
+                       records += "," + RecordList.size();
+                       for (NDEFRecord record : RecordList) {
+                               records += "," + record.getFormat() + ","
+                                               + record.getTypeName() + "," + record.getId() + ","
+                                               + record.getPayload();
+                       }
+
+                       msg = NfcCommand.NFC_P2P_SEND.toString() + ":"
+                               + String.valueOf(tagtype) + records + "\n";
+               }
+                       break;
+               }
+
+               return msg;
+       }
+
+       public boolean sendMessage(String msg)
+       {
+               boolean result = false;
+               try {
+                       // add for test
+                       //NfcDialog.openInfoDialog(shell, msg); 
+                       result = injectorSocket.sendNfc(msg);
+               } catch (Exception e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+               }
+
+               return result;
+       }
+
+       private boolean checkDeviceConnectedAlready()
+       {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+
+       @Override
+       protected void registerReceivers()
+       {
+               // TODO Auto-generated method stub
+
+       }
+
+       // @Override
+       public void connect()
+       {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+       // @Override
+       public void disconnect()
+       {
+               // TODO Auto-generated method stub
+       }
+
+       @Override
+       protected void finalize() throws Throwable
+       {
+               ConnectionPlugin.getDefault().removeSelectionListener(this);
+               // TargetConnectionControl.removeTargetConnectionListener(this);
+               super.finalize();
+       }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry)
+       {
+               if (selectedEntry == null) {
+                       disconnect();
+                       return;
+               } else if (!selectedEntry.getFileListingService().getDevice()
+                               .isEmulator())
+                       return;
+
+               if (currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if (currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.tizen.nfc/src/org/tizen/nfc/page/NfcStringResource.java b/org.tizen.nfc/src/org/tizen/nfc/page/NfcStringResource.java
new file mode 100644 (file)
index 0000000..c3cc808
--- /dev/null
@@ -0,0 +1,81 @@
+package org.tizen.nfc.page;
+
+import java.util.ArrayList;
+
+public class NfcStringResource
+{
+       private ArrayList<String> list;
+       
+       public NfcStringResource()
+       {
+               list = new ArrayList<String>();
+       }
+
+       public void add(int index, String element)
+       {
+               list.add(index, element);
+       }
+
+       public String[] getList()
+       {
+               return list.toArray(new String[size()]);
+       }
+       
+       public int size()
+       {
+               return list.size();
+       }
+}
+
+class TagType extends NfcStringResource
+{
+       private static TagType tagtype = new TagType();
+       public static TagType getInstance()
+       {
+               return tagtype;
+       }
+
+       private TagType()
+       {
+               add(0, "");
+               add(1, "Topaz Jewel (Type1)");
+               add(2, "Mifare UL (Type2)");
+               add(3, "Felica (Type3)");
+               add(4, "Mifare Desfire (Type4)");
+       }
+
+}
+
+class RecordFormat extends NfcStringResource
+{
+       private static RecordFormat format = new RecordFormat();
+       public static RecordFormat getInstance()
+       {
+               return format;
+       }
+
+       private RecordFormat()
+       {
+               add(0, "NDEF_TNF_EMPTY");
+               add(1, "NDEF_TNF_WELL_KNOWN");
+               add(2, "NDEF_TNF_MIME_MEDIA");
+               add(3, "NDEF_TNF_ABSOLUTE_URI");
+               add(4, "NDEF_TNF_EXTERNAL");
+               add(5, "NDEF_TNF_UNKNOWN");
+       }
+}
+
+class TypeName extends NfcStringResource
+{
+       private static TypeName typename = new TypeName();
+       public static TypeName getInstance()
+       {
+               return typename;
+       }
+
+       private TypeName()
+       {
+               add(0, "U");
+               add(1, "T");
+       }
+}
\ No newline at end of file
diff --git a/org.tizen.sensor.accelerometer/.classpath b/org.tizen.sensor.accelerometer/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.sensor.accelerometer/.project b/org.tizen.sensor.accelerometer/.project
new file mode 100644 (file)
index 0000000..8caeef0
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.sensor.accelerometer</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.sensor.accelerometer/.settings/org.eclipse.core.runtime.prefs b/org.tizen.sensor.accelerometer/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..2124634
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Dec 14 16:31:30 CET 2010
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.tizen.sensor.accelerometer/.settings/org.eclipse.jdt.core.prefs b/org.tizen.sensor.accelerometer/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..1ab6cd2
--- /dev/null
@@ -0,0 +1,8 @@
+#Thu Dec 02 13:13:49 KST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.sensor.accelerometer/META-INF/MANIFEST.MF b/org.tizen.sensor.accelerometer/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..9a4ba5f
--- /dev/null
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Sensor Accelerometer
+Bundle-SymbolicName: org.tizen.sensor.accelerometer;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.ui;bundle-version="3.5.2",
+ org.tizen.injector,
+ org.tizen.common,
+ org.tizen.common.connection,
+  org.eclipse.core.runtime;bundle-version="3.7.0"
diff --git a/org.tizen.sensor.accelerometer/build.properties b/org.tizen.sensor.accelerometer/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.sensor.accelerometer/plugin.xml b/org.tizen.sensor.accelerometer/plugin.xml
new file mode 100644 (file)
index 0000000..6190104
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Sensor"
+            class="org.tizen.sensor.accelerometer.Sensor"
+            id="org.tizen.sensor.accelerometer"
+            name="3-Axis Sensors">
+      </itemType>
+   </extension>
+
+</plugin>
diff --git a/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/Sensor.java b/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/Sensor.java
new file mode 100644 (file)
index 0000000..ae0cadb
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * org.tizen.sensor.accelerometer
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.accelerometer;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.sensor.accelerometer.page.Accelerometer;
+
+public class Sensor extends AbstractInjectorItem {
+
+       @Override
+       protected void addPages() {
+               addPage(new Accelerometer(this, "Accelerometer, Gyroscope, Geomagnetic"));
+       }
+}
diff --git a/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Accelerometer.java b/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Accelerometer.java
new file mode 100644 (file)
index 0000000..1913722
--- /dev/null
@@ -0,0 +1,688 @@
+/*
+ * org.tizen.sensor.accelerometer
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.accelerometer.page;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.DecimalFormat;
+
+import javax.swing.Timer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+import org.tizen.sensor.magnetic.Magnetic;
+//import org.tizen.sensor.accelerometer.DebugLog;
+
+public class Accelerometer extends AbstractInjectorPage {
+       Slider yawSlider, pitchSlider, rollSlider;
+       int yawValue, pitchValue, rollValue;
+       double xValue, yValue, zValue;
+       Mode mode;
+       MobilePanel panel;
+       Button checkboxAccelerometer;
+       Button checkboxGyro;
+    Button checkboxGeoMagnetic;
+    Button checkboxOrientation;
+    private Text dataText;
+    Timer dataOutputTimer;
+    
+    double north;
+    double east;
+    double vertical;
+    
+    static double tmp_accel_x = 0.1, tmp_accel_y = 0.1, tmp_accel_z = 0.1;
+    static double tmp_gyro_x = 0.1, tmp_gyro_y = 0.1, tmp_gyro_z = 0.1;
+    static double tmp_geo_x = 0.1, tmp_geo_y = 0.1, tmp_geo_z = 0.1, tmp_geo_a = 0.1, tmp_geo_b = 0.1, tmp_geo_c = 0.1, tmp_geo_d = 0.1;
+    static boolean changed_accel = false;
+    static boolean changed_gyro = false;
+    static boolean changed_geo = false;
+    
+    static String accelerometerData;
+       static String magneticData;
+       static String gyroData;
+       
+       static boolean orientation_active = true;
+    static boolean button_click = false;
+    
+       public Accelerometer(AbstractInjectorItem item, String name) {
+               super(item, name);
+               north = 22874.1;
+               east = 5939.5;
+               vertical = 43180.5;
+       }
+
+       private void init() {
+               yawValue = 0;
+               pitchValue = -90;
+               rollValue = 0;
+       }
+       
+       @Override
+       protected void createContents() {
+               init();
+               Composite mainComposite = formUtil.createComposite(parent, 2);
+               // Create Mobile Composite to draw virtual mobile phone
+               Composite mobileComposite = formUtil.createComposite(mainComposite);
+               
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, false, true);
+               gd.widthHint = 260;
+               mobileComposite.setLayoutData(gd);
+               
+               // Create panel composite to contain JPanel component
+               Composite panelComposite = new Composite(mobileComposite, SWT.EMBEDDED | SWT.BORDER);
+               
+               panel = new MobilePanel(this);
+               Frame frame = SWT_AWT.new_Frame(panelComposite);
+               frame.add(panel);
+               frame.pack();
+               gd = new GridData(GridData.CENTER, GridData.CENTER, false, true);
+               gd.widthHint = 200;
+               gd.heightHint = 200;
+               panelComposite.setLayoutData(gd);
+               
+               // Create composite containing moving type selection radio buttons
+               Composite radioComposite = formUtil.createComposite(mobileComposite, 3);
+               
+               Button button01 = formUtil.createButton(radioComposite, "Yaw/Pitch", SWT.RADIO);
+               button01.setSelection(true);
+               mode = Mode.YAW_PITCH;
+               button01.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               mode = Mode.YAW_PITCH;
+                               super.widgetSelected(e);
+                       }
+               });
+               Button button02 = formUtil.createButton(radioComposite, "Roll/Pitch", SWT.RADIO);
+               button02.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               mode = Mode.ROLL_PITCH;
+                               super.widgetSelected(e);
+                       }
+               });
+               Button button03 = formUtil.createButton(radioComposite, "Move", SWT.RADIO);
+               button03.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               mode = Mode.MOVE;
+                               super.widgetSelected(e);
+                       }
+               });
+               
+               // Create text (data output)
+               
+               dataText = new Text(mobileComposite, SWT.MULTI | SWT.BORDER );
+               gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
+               dataText.setLayoutData(gd);
+               
+               dataOutputTimer = new Timer(200, new ActionListener() {
+            public void actionPerformed(ActionEvent evt) {
+               if (PlatformUI.isWorkbenchRunning() == false){
+                       return;
+               }
+               if( PlatformUI.getWorkbench().isClosing() == true){
+                       return;
+               }
+        
+               PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){
+                                       @Override
+                                       public void run() {
+                                               DecimalFormat mf = new DecimalFormat("#0.00");
+                                               Magnetic magnetic = Magnetic.getInstance();
+                                               
+                                               if(changed_accel == true){
+                                                       if(checkboxAccelerometer.isDisposed())
+                                                               dataOutputTimer.stop();
+                                                       else if( checkboxAccelerometer.getSelection()){
+                                                               accelerometerData = "accelerometer : " + mf.format(panel.read_accelx) + ", "+ mf.format(panel.read_accely) +
+                                                               ", "+ mf.format(panel.read_accelz);
+                                                       }
+                                                       else {
+                                                               accelerometerData = "accelerometer : Disable";
+                                                       }
+                                                       changed_accel = false;
+                                               }
+                                               if(changed_geo == true){
+                                                       if(checkboxGeoMagnetic.isDisposed())
+                                                               dataOutputTimer.stop();
+                                                       else if( checkboxGeoMagnetic.getSelection()) {
+                                                               magneticData = "magnetic filed : " + mf.format(magnetic.getReadCompassX()) +
+                                                               ", " + mf.format(magnetic.getReadCompassY()) + ", " + mf.format(magnetic.getReadCompassZ()) + "\n" + "orientation : " + mf.format(magnetic.getAzimuth()) +
+                                                               ", " + mf.format(magnetic.getPitch()) + ", " + mf.format(magnetic.getRoll());
+                                                       }
+                                                       else {
+                                                               magneticData = "magnetic : Disable";
+                                                       }
+                                                       changed_geo = false;
+                                               }
+                                               if(changed_gyro == true){
+                                                       if(checkboxGyro.isDisposed())
+                                                               dataOutputTimer.stop();
+                                                       else if( checkboxGyro.getSelection()) {
+                                                               gyroData = "gyroscope : " + mf.format(panel.gyroPitch) + ", " + mf.format(panel.gyroRoll) + ", " + mf.format(panel.gyroYaw);
+                                                       }
+                                                       else {
+                                                               gyroData = "gyroscope : Disable";
+                                                       }
+                                                       changed_gyro = false;
+                                               }
+                                               if(dataText.isDisposed())
+                                                       dataOutputTimer.stop();
+                                               else
+                                                       dataText.setText(accelerometerData + "\n" + magneticData + "\n" + gyroData);
+                                       }
+               });
+            }
+        });
+               dataOutputTimer.setCoalesce(true);
+
+               // Create slider composite to add Yaw/Pitch/Roll sliders
+               Composite sliderComposite = formUtil.createComposite(mainComposite, 2);    
+           
+           formUtil.createLabel(sliderComposite, "Pitch");
+           pitchSlider = formUtil.createSlider(sliderComposite);
+           setDefaultSlider(pitchSlider);
+           pitchValue = (int) panel.pitchDegree;
+           pitchSlider.setSelection((int) panel.pitchDegree + 180);
+           pitchSlider.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               // TODO : Fix here
+                               pitchValue = pitchSlider.getSelection() - 180;
+                               panel.pitchDegree = pitchValue;
+                               panel.repaint();
+                               
+                               sendMessage(panel.read_accelx, panel.read_accely, panel.read_accelz);
+                               
+                               super.widgetSelected(e);
+                       }
+               });
+           pitchSlider.addMouseListener(new MouseAdapter(){
+                       public void mouseUp(MouseEvent e) {
+                               ((MobilePanel)panel).phone_pos_conv = true;
+                       }
+               });
+
+           formUtil.createLabel(sliderComposite, "Roll");    
+           rollSlider = formUtil.createSlider(sliderComposite);
+           setDefaultSlider(rollSlider);
+           rollValue = (int) panel.rollDegree;
+           rollSlider.setSelection((int) panel.rollDegree + 180);
+           rollSlider.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               // TODO : Fix here
+                               rollValue = rollSlider.getSelection() - 180;
+                               panel.rollDegree = rollValue;
+                               panel.repaint();
+                               
+                               sendMessage(panel.read_accelx, panel.read_accely, panel.read_accelz);
+                               
+                               super.widgetSelected(e);
+                       }
+               });
+           rollSlider.addMouseListener(new MouseAdapter(){
+                       public void mouseUp(MouseEvent e) {
+                               ((MobilePanel)panel).phone_pos_conv = true;
+                       }
+               });
+
+               formUtil.createLabel(sliderComposite, "Yaw");
+               yawSlider = formUtil.createSlider(sliderComposite);
+               setDefaultSlider(yawSlider);
+               yawValue = (int) panel.yawDegree;
+               yawSlider.setSelection((int) panel.yawDegree + 180);
+               yawSlider.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               // TODO : Fix here
+                               yawValue = yawSlider.getSelection() - 180;
+                               panel.yawDegree = yawValue;
+                               panel.repaint();
+                               sendMessage(panel.read_accelx, panel.read_accely, panel.read_accelz);
+                               super.widgetSelected(e);
+                       }
+               });
+               yawSlider.addMouseListener(new MouseAdapter(){
+                       public void mouseUp(MouseEvent e) {
+                               ((MobilePanel)panel).phone_pos_conv = true;
+                       }
+               });
+           
+           // Create rotation button
+           Composite rotationComposite = formUtil.createComposite(sliderComposite, 4);
+           gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+           gd.horizontalSpan = 2;
+           rotationComposite.setLayoutData(gd);
+           createRotationButton(rotationComposite);
+           
+           
+           // Create checkbox (Enable sensor)
+           Composite checkboxComposite = formUtil.createComposite(sliderComposite, 2);
+           GridData cbGd = new GridData(GridData.FILL, GridData.FILL, true, false);
+           cbGd.horizontalSpan = 2;
+           checkboxComposite.setLayoutData(cbGd);
+           checkboxAccelerometer = formUtil.createButton(checkboxComposite, "Accelerometer sensor", SWT.CHECK);
+           checkboxGeoMagnetic = formUtil.createButton(checkboxComposite, "Geomagnetic sensor", SWT.CHECK);
+           checkboxGyro = formUtil.createButton(checkboxComposite, "Gyroscope sensor", SWT.CHECK);
+           checkboxOrientation = formUtil.createButton(checkboxComposite, "Orientation sensor", SWT.CHECK);
+           checkboxAccelerometer.setSelection(true);
+           checkboxGeoMagnetic.setSelection(true);
+           checkboxGyro.setSelection(true);
+           checkboxOrientation.setSelection(true);
+           checkboxAccelerometer.addSelectionListener(new SelectionAdapter() {
+               public void widgetSelected(SelectionEvent e) {
+                               panel.accelerometerTimer(checkboxAccelerometer.getSelection());
+                               if(!checkboxAccelerometer.getSelection())
+                               {       
+                                       checkboxOrientation.setSelection(false);
+                                       orientation_active = false;
+                               }
+                               super.widgetSelected(e);
+                       }
+               
+           });
+           checkboxGeoMagnetic.addSelectionListener(new SelectionAdapter() {
+               public void widgetSelected(SelectionEvent e) {
+                               panel.geomagneticTimer(checkboxGeoMagnetic.getSelection());
+                               if(!checkboxGeoMagnetic.getSelection())
+                               {
+                                       checkboxOrientation.setSelection(false);
+                                       orientation_active = false;
+                               }
+                               super.widgetSelected(e);
+                       }
+           });
+           checkboxGyro.addSelectionListener(new SelectionAdapter() {
+               public void widgetSelected(SelectionEvent e) {
+                               panel.gyroTimer(checkboxGyro.getSelection());
+                               super.widgetSelected(e);
+                       }
+           });
+           checkboxOrientation.addSelectionListener(new SelectionAdapter() {
+               public void widgetSelected(SelectionEvent e) {
+                               if(checkboxOrientation.getSelection())
+                               {
+                                       checkboxAccelerometer.setSelection(true);
+                                       panel.accelerometerTimer(checkboxAccelerometer.getSelection());
+                                       checkboxGeoMagnetic.setSelection(true);
+                                       panel.geomagneticTimer(checkboxGeoMagnetic.getSelection());
+                                       orientation_active = true;
+                               }
+                               else
+                                       orientation_active = false;
+                               super.widgetSelected(e);
+                       }
+           });
+           
+           //panel.ConnectionChanged();
+           boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       panel.connect();
+               }
+       }
+       
+       private boolean checkDeviceConnectedAlready() {
+               if (panel.currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+
+       }
+       private void createRotationButton( Composite rotationComposite){
+               Button rotation0 = formUtil.createButton(rotationComposite, "Portrait", SWT.PUSH);
+           Button rotation90 = formUtil.createButton(rotationComposite, "Landscape", SWT.PUSH);
+           Button rotation180 = formUtil.createButton(rotationComposite, "Reverse Portrait", SWT.PUSH);
+           Button rotation270 = formUtil.createButton(rotationComposite, "Reverse Landscape", SWT.PUSH);
+           rotation0.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                               
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               button_click = true;
+                               double axisX[] = {1,0,0};
+                               double axisY[] = {0,0,1};
+                               double axisZ[] = {0,-1,0};
+                               panel.setGyroAxisX(axisX);
+                               panel.setGyroAxisY(axisY);
+                               panel.setGyroAxisZ(axisZ);
+                               panel.repaint();
+                       }
+           });
+           rotation90.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               button_click = true;
+                               double axisX[] = {0,0,1};
+                               double axisY[] = {-1,0,0};
+                               double axisZ[] = {0,-1,0};
+                               panel.setGyroAxisX(axisX);
+                               panel.setGyroAxisY(axisY);
+                               panel.setGyroAxisZ(axisZ);
+                               panel.repaint();
+                       }
+           });
+           rotation180.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                               
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               button_click = true;
+                               double axisX[] = {-1,0,0};
+                               double axisY[] = {0,0,-1};
+                               double axisZ[] = {0,-1,0};
+                               panel.setGyroAxisX(axisX);
+                               panel.setGyroAxisY(axisY);
+                               panel.setGyroAxisZ(axisZ);
+                               panel.repaint();
+                       }
+           });
+           rotation270.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                               
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               button_click = true;
+                               double axisX[] = {0,0,-1};
+                               double axisY[] = {1,0,0};
+                               double axisZ[] = {0,-1,0};
+                               panel.setGyroAxisX(axisX);
+                               panel.setGyroAxisY(axisY);
+                               panel.setGyroAxisZ(axisZ);
+                               panel.repaint();
+                       }
+           });
+       }
+       
+       private void createMagenticInput( Composite magneticSection){
+               Composite magneticComposite = formUtil.createComposite(magneticSection, 3);
+               formUtil.createLabel(magneticComposite, "North : ");
+               Text northText = formUtil.createText(magneticComposite, String.valueOf(north));
+               northText.setTextLimit(10);
+               formUtil.createLabel(magneticComposite, "nT");
+               formUtil.createLabel(magneticComposite, "East : ");
+               Text eastText = formUtil.createText(magneticComposite, String.valueOf(east));
+               eastText.setTextLimit(10);
+               formUtil.createLabel(magneticComposite, "nT");
+               formUtil.createLabel(magneticComposite, "Vertical : ");
+               Text verticalText = formUtil.createText(magneticComposite, String.valueOf(vertical));
+               verticalText.setTextLimit(10);
+               formUtil.createLabel(magneticComposite, "nT");
+               northText.addModifyListener(new ModifyListener(){
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               try{
+                                       north = Double.parseDouble(((Text)e.widget).getText());
+                               }
+                               catch (NumberFormatException nfe) {
+                                       int caret = ((Text)e.widget).getCaretPosition();
+                                       ((Text)e.widget).setText(String.valueOf(north));
+                                       ((Text)e.widget).setSelection(caret-1, caret-1);
+                               }
+                       }
+               });
+               eastText.addModifyListener(new ModifyListener(){
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               try{
+                                       east = Double.parseDouble(((Text)e.widget).getText());
+                               }
+                               catch (NumberFormatException nfe) {
+                                       int caret = ((Text)e.widget).getCaretPosition();
+                                       ((Text)e.widget).setText(String.valueOf(east));
+                                       ((Text)e.widget).setSelection(caret-1, caret-1);
+                                       System.out.println(caret);
+                               }
+                       }
+               });
+               verticalText.addModifyListener(new ModifyListener(){
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               try{
+                                       vertical = Double.parseDouble(((Text)e.widget).getText());
+                               }
+                               catch (NumberFormatException nfe) {
+                                       int caret = ((Text)e.widget).getCaretPosition();
+                                       ((Text)e.widget).setText(String.valueOf(vertical));
+                                       ((Text)e.widget).setSelection(caret-1, caret-1);
+                               }
+                       }
+               });
+       }
+       
+       private void setDefaultSlider(Slider slider) {
+           slider.setMinimum(0);
+           slider.setMaximum(361);
+           slider.setIncrement(1);
+           slider.setThumb(1);
+       }
+       
+       public int getYawSliderValue() {
+               return yawValue;
+       }
+       
+       public void setYawSliderValue(int value) {
+               yawValue = value;
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               
+               if (window == null) {
+                       IWorkbenchWindow windows[] = PlatformUI
+                                       .getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+               
+               final Shell shell = window.getShell();
+               
+               shell.getDisplay().asyncExec(new Runnable() {
+                       
+                       @Override
+                       public void run() {
+                               yawSlider.setSelection(yawValue + 180);
+                       }
+               });
+       }
+       
+       public int getPitchSliderValue() {
+               return pitchValue;
+       }
+       
+       public void setPitchSliderValue(int value) {
+               pitchValue = value;
+               
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               
+               if (window == null) {
+                       IWorkbenchWindow windows[] = PlatformUI
+                                       .getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+               
+               final Shell shell = window.getShell();
+               
+               shell.getDisplay().asyncExec(new Runnable() {
+                       
+                       @Override
+                       public void run() {
+                               pitchSlider.setSelection(pitchValue + 180);
+                       }
+               });
+       }
+       
+       public int getRollSliderValue() {
+               return rollValue;
+       }
+       
+       public void setRollSliderValue(int value) {
+               rollValue = value;
+               
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               
+               if (window == null) {
+                       IWorkbenchWindow windows[] = PlatformUI
+                                       .getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+               
+               final Shell shell = window.getShell();
+               
+               shell.getDisplay().asyncExec(new Runnable() {
+                       
+                       @Override
+                       public void run() {
+                               rollSlider.setSelection(rollValue + 180);
+                       }
+               });     
+       }
+       
+       public void sendMessage(double x, double y, double z) {
+               TestSensorMessage msg = new TestSensorMessage(x, y, z);
+               
+               try {
+               //      sensorSocket.send(msg.getMessage());
+                       injectorSocket.sendSensor(msg.getMessage());
+               } catch (Exception e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+               }
+       }
+       public void sendMessage(String sensorNumber, double x, double y, double z) {
+               if(sensorNumber == "1\n")       // accel
+               {
+                       if(button_click == true || tmp_accel_x != x || tmp_accel_y != y || tmp_accel_z != z)
+                       {
+                               TestSensorMessage msg = new TestSensorMessage(x, y, z);
+                               
+                               try {
+                               //      sensorSocket.send(sensorNumber + msg.getMessage());
+                                       injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                               } catch (Exception e1) {
+                                       // TODO Auto-generated catch block
+                                       e1.printStackTrace();
+                               }
+                               
+                               tmp_accel_x = x;
+                               tmp_accel_y = y;
+                               tmp_accel_z = z;
+                               button_click = false;
+                               changed_accel = true;
+                       }
+               }
+               else if(sensorNumber == "4\n")  // gyro
+               {
+                       if(tmp_gyro_x != x || tmp_gyro_y != y || tmp_gyro_z != z)
+                       {
+                               TestSensorMessage msg = new TestSensorMessage(x, y, z);
+                               
+                               try {
+                               //      sensorSocket.send(sensorNumber + msg.getMessage());
+                                       injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                               } catch (Exception e1) {
+                                       // TODO Auto-generated catch block
+                                       e1.printStackTrace();
+                               }
+                               
+                               tmp_gyro_x = x;
+                               tmp_gyro_y = y;
+                               tmp_gyro_z = z;
+                               changed_gyro = true;
+                       }
+               }
+       }
+       public void sendMessage(String sensorNumber, double x, double y, double z, double a, double b, double c, double d) {
+               if(sensorNumber == "5\n")
+               {
+                       if(tmp_geo_x != x || tmp_geo_y != y || tmp_geo_z != z || tmp_geo_a != a || tmp_geo_b != b || tmp_geo_c != c || tmp_geo_d != d)
+                       {
+                               TestSensorMessage msg = new TestSensorMessage(x, y, z, a, b, c, d);
+                               
+                               try {
+                               //      sensorSocket.send(sensorNumber + msg.getMessage());
+                                       injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                               } catch (Exception e1) {
+                                       // TODO Auto-generated catch block
+                                       e1.printStackTrace();
+                               }
+                               
+                               tmp_geo_x = x;  // azimuth
+                               tmp_geo_y = y; 
+                               tmp_geo_z = z;
+                               tmp_geo_a = a; // accuracy
+                               tmp_geo_b = b; // tesla x
+                               tmp_geo_c = c; // tesla y
+                               tmp_geo_d = d; // tesla z
+                               changed_geo = true;
+                       }
+               }
+       }
+       
+       public Mode getMode() {
+               return mode;
+       }
+       
+       public enum Mode {
+               YAW_PITCH, ROLL_PITCH, MOVE
+       };      
+}
diff --git a/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/MobilePanel.java b/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/MobilePanel.java
new file mode 100644 (file)
index 0000000..6c40abc
--- /dev/null
@@ -0,0 +1,925 @@
+package org.tizen.sensor.accelerometer.page;
+
+/* 
+ * Copyright (C) 2008 OpenIntents.org
+ *
+ * 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.
+ */
+
+/*
+ * 09/Apr/08 Dale Thatcher <openintents at dalethatcher dot com>
+ *           Added wii-mote data collection.
+ */
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import java.awt.geom.Line2D;
+
+import javax.swing.JPanel;
+import javax.swing.Timer;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sensor.accelerometer.page.Accelerometer.Mode;
+import org.tizen.sensor.magnetic.Magnetic;
+
+/**
+ * Displays a mobile phone in a panel and calculates sensor physics.
+ * 
+ * @author Peli
+ *
+ */
+@SuppressWarnings("serial")
+public class MobilePanel extends JPanel implements ISelectionListener {
+       
+       Accelerometer mPage;
+       /**
+        * Reference to SensorSimulator for accessing widgets.
+        */
+       
+       /** 
+        * Current read-out value of accelerometer x-component. 
+        * 
+        * This value is updated only at the desired 
+        * updateSensorRate().
+        */
+       double read_accelx;
+       /** Current read-out value of accelerometer y-component. */
+       double read_accely;
+       /** Current read-out value of accelerometer z-component. */
+       double read_accelz;
+
+       /** Current read-out value of orientation yaw. */
+       double read_yaw;
+       /** Current read-out value of orientation pitch. */
+       double read_pitch;
+       /** Current read-out value of orientation roll. */
+       double read_roll;
+       
+       /** Current read-out value of temperature. */
+       double read_temperature;
+       
+       /** Duration (in milliseconds) between two updates.
+        * This is the inverse of the update rate.
+        */
+       long accel_update_duration;
+       
+       /** Time of next update required.
+        * The time is compared to System.currentTimeMillis().
+        */
+       long accel_next_update;
+       
+       /** Duration (in milliseconds) between two updates.
+        * This is the inverse of the update rate.
+        */
+       long orientation_update_duration;
+       
+       /** Time of next update required.
+        * The time is compared to System.currentTimeMillis().
+        */
+       long orientation_next_update;
+       
+       /** Duration in milliseconds until user setting
+        * changes are read out.
+        */
+       long user_settings_duration;
+       
+       /** Time of next update for reading user settings from widgets.
+        * The time is compared to System.currentTimeMillis().
+        */
+       long user_settings_next_update;
+       
+       /** 
+        * Partial read-out value of accelerometer x-component. 
+        * 
+        * This partial value is used to calculate the
+        * sensor average.
+        */
+       double partial_accelx;
+       /** Partial read-out value of accelerometer y-component. */
+       double partial_accely;
+       /** Partial read-out value of accelerometer z-component. */
+       double partial_accelz;
+       /** Number of summands in partial sum for accelerometer. */
+       int partial_accel_n;
+       /** Whether to form the average over the last duration when reading out sensors. 
+        * Alternative is to just take the current value.
+        */
+       boolean average_accel;
+       
+       /** Partial read-out value of orientation yaw. */
+       double partial_yaw;
+       /** Partial read-out value of orientation pitch. */
+       double partial_pitch;
+       /** Partial read-out value of orientation roll. */
+       double partial_roll;
+       /** Number of summands in partial sum for orientation. */
+       int partial_orientation_n;
+       /** Whether to form the average over the last duration when reading out sensors. 
+        * Alternative is to just take the current value.
+        */
+       boolean average_orientation;
+       
+       /** Internal state value of accelerometer x-component.
+        * 
+        * This value is updated regularly by updateSensorPhysics().
+        */
+       double accelx;
+       /** Internal state value of accelerometer x-component. */
+       double accely;
+       /** Internal state value of accelerometer x-component. */
+       double accelz;
+       
+       // orientation (in degree)
+       double yaw;
+       double pitch;
+       double roll;
+       
+       // orientation sensor raw data (in degree)
+       double yawDegree;
+       double pitchDegree;
+       double rollDegree;
+       
+       /** Current position on screen. */
+       int movex;
+       /** Current position on screen. */
+       int movez;
+       
+       int oldx;
+       int oldz;
+       double vx; // velocity
+       double vz;
+       double oldvx;
+       double oldvz;
+       double ax; // acceleration
+       double az;
+       
+       double Fx; // force
+       double Fz; // force
+       double accx; // accelerometer position x on screen
+       double accz; // (DONT confuse with acceleration a!)
+       
+       /** Spring constant. */
+       double k; // spring constant
+       
+       /** Mass of accelerometer test particle.
+        * 
+        *  This is set to 1, as only the ratio
+        *  k/m enters the simulation. */
+       double m; // mass of accelerometer test particle
+       
+       /** Damping constant. */
+       double gamma; // damping of spring
+       
+       double dt; // time step size
+       
+       /** Inverse of screen pixel per meter */
+       double meterperpixel;
+       
+       /** Gravity constant. 
+        * 
+        * This takes the value 9.8 m/s^2.
+        * */
+       double g;
+       
+       /** 1/g (g-inverse) */
+       double ginverse;
+       
+       int mousedownx;
+       int mousedowny;
+       int mousedownyaw;
+       int mousedownpitch;
+       int mousedownroll;
+       int mousedownmovex;
+       int mousedownmovez;
+       
+       //gyro
+       boolean gyroStart;
+       Vector old_vector_yz;
+       Vector old_vector_xz;
+       double old_gyroYaw;
+       double old_gyroPitch;
+       double old_gyroRoll;
+       int gyroYawCount;
+       int gyroPitchCount;
+       int gyroRollCount;
+       
+       private double old_gyro_rollDegree = 0;
+       private double old_gyro_pitchDegree = 0;
+       private double old_gyro_yawDegree = 0;
+       private double[] gyro_axisX;
+       private double[] gyro_axisY;
+       private double[] gyro_axisZ;
+       
+       double gyroYaw;
+       double gyroPitch;
+       double gyroRoll;
+       
+       final String accelerometerSensorNumber = "1\n";
+       final String gyroSensorNumber = "4\n";
+       public boolean phone_pos_conv = false;
+       public IDevice currentDevice;
+       
+       /*
+        * http://code.google.com/android/reference/android/hardware/Sensors.html
+        * 
+        * With the device lying flat on a horizontal surface in front of the user, 
+        * oriented so the screen is readable by the user in the normal fashion, 
+        * the X axis goes from left to right, the Y axis goes from the user 
+        * toward the device, and the Z axis goes upwards perpendicular to the 
+        * surface. 
+        */
+       // Mobile size
+       final double sx = 15; // size x
+       final double sy = 40; // size y
+       final double sz = 5; // size z
+       
+       // Display size
+       final double dx = 12; // size x
+       final double dy1 = 33; // size y
+       final double dy2 = -15;
+       
+       /** Contains the grid model of the phone. */
+       double[][] phone = {
+                       // bottom shape
+                       { sx, sy, -sz}, {-sx, sy, -sz},
+                       {-sx, sy, -sz}, {-sx,-sy, -sz},
+                       {-sx,-sy, -sz}, { sx,-sy, -sz},
+                       { sx,-sy, -sz}, { sx, sy, -sz},
+                       // top shape
+                       { sx, sy, sz}, {-sx, sy, sz},
+                       {-sx, sy, sz}, {-sx,-sy, sz},
+                       {-sx,-sy, sz}, { sx,-sy, sz},
+                       { sx,-sy, sz}, { sx, sy, sz},
+                       // connectint top and bottom
+                       { sx, sy, -sz}, { sx, sy, sz},
+                       {-sx, sy, -sz}, {-sx, sy, sz},
+                       {-sx,-sy, -sz}, {-sx,-sy, sz},
+                       { sx,-sy, -sz}, { sx,-sy, sz},
+                       // display
+                       { dx, dy1, sz}, {-dx, dy1, sz},
+                       {-dx, dy1, sz}, {-dx, dy2, sz},
+                       {-dx, dy2, sz}, { dx, dy2, sz},
+                       { dx, dy2, sz}, { dx, dy1, sz},
+               };
+       private Timer timer;
+       private Timer geomagneticTimer;
+       private Timer gyroTimer;
+       private Timer orientationTimer;
+       private boolean connected = false;
+       
+       public MobilePanel(Accelerometer page) {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+//             TargetConnectionControl.addTargetConnectionListener(this);
+               
+               mPage = page;
+
+               yawDegree = 0;
+               pitchDegree = 0;
+               rollDegree = 0;
+               
+               gyroYawCount = 0;
+               gyroPitchCount = 0;
+               gyroRollCount = 0;
+               gyroStart = false;
+               
+               gyro_axisX = Vector.getAxisX().clone();
+               gyro_axisY = Vector.getAxisY().clone();
+               gyro_axisZ = Vector.getAxisZ().clone();
+
+               movex = 0;
+               movez = 0;
+               oldx = 0;
+               oldz = 0;
+               oldvx = 0;
+               oldvz = 0;
+               
+               Fx = 0;
+               Fz = 0;
+               accx = 0;
+               accz = 0;
+               k = 500; // spring constant
+               m = 1; // mass
+               gamma = 50; // damping 
+               
+               dt = 0.1;
+               meterperpixel = 1/3000.; // meter per pixel
+               g = 9.80665; // meter per second^2
+               ginverse = 1 / g;
+               
+               user_settings_duration = 500;  // Update every half second. This should be enough.
+               user_settings_next_update = System.currentTimeMillis(); // First update is now.
+               
+           addMouseListener(new MouseAdapter() {
+               public void mousePressed(MouseEvent e) {
+                       mousedownx = e.getX();
+                       mousedowny = e.getY();
+                       mousedownyaw = mPage.getYawSliderValue();
+                       mousedownpitch = mPage.getPitchSliderValue();
+                       mousedownroll = mPage.getRollSliderValue();
+                       mousedownmovex = movex;
+                       mousedownmovez = movez;
+               }
+               public void mouseReleased(MouseEvent e){
+                       phone_pos_conv = true;
+               }
+           });
+           
+
+       
+           addMouseMotionListener(new MouseMotionListener() {
+               public void mouseDragged(MouseEvent e) {
+                       if (mPage.getMode() == Mode.YAW_PITCH) {
+                               // Control yawDegree
+                               int newyaw = mousedownyaw - (e.getX() - mousedownx);
+                               while (newyaw > 180) {
+                                       newyaw -= 360;
+                                       gyroYawCount++;
+                               }
+                               while (newyaw < -180) {
+                                       newyaw += 360;
+                                       gyroYawCount--;
+                               }
+                               mPage.setYawSliderValue((int) newyaw);
+                               yawDegree = newyaw;
+                               
+                               // Control pitch
+                               int newpitch = mousedownpitch - (e.getY() - mousedowny);
+                               while (newpitch > 180) {
+                                       newpitch -= 360;
+                                       gyroPitchCount++;
+                               }
+                               while (newpitch < -180) {
+                                       newpitch += 360;
+                                       gyroPitchCount--;
+                               }
+                               mPage.setPitchSliderValue((int) newpitch);
+                               pitchDegree = newpitch;
+                       } else if (mPage.getMode() == Mode.ROLL_PITCH) {
+                               int newroll = mousedownroll + (e.getX() - mousedownx);
+                               while (newroll > 180) {
+                                       newroll -= 360;
+                                       gyroRollCount++;
+                               }
+                               while (newroll < -180) {
+                                       newroll += 360;
+                                       gyroRollCount--;
+                               }
+                               mPage.setRollSliderValue((int) newroll);
+                               rollDegree = newroll;
+                               
+                               // Control pitch
+                               int newpitch = mousedownpitch - (e.getY() - mousedowny);
+                               while (newpitch > 180) {
+                                       newpitch -= 360;
+                                       gyroPitchCount++;
+                               }
+                               while (newpitch < -180) {
+                                       newpitch += 360;
+                                       gyroPitchCount--;
+                               }
+                               mPage.setPitchSliderValue((int) newpitch);
+                               pitchDegree = newpitch;
+                       } else if (mPage.getMode() == Mode.MOVE) {
+                               // Control roll
+                               int newmovex = mousedownmovex + (e.getX() - mousedownx);
+                               movex = newmovex;
+                               
+                               // Control pitch
+                               int newmovez = mousedownmovez - (e.getY() - mousedowny);
+                               movez = newmovez;
+                       }
+
+                       repaint();
+               }
+
+            public void mouseMoved(MouseEvent evt) {
+                // NOOP
+            }
+           });
+           
+        int delay = 200;
+        timer = new Timer(delay, new ActionListener() {
+            public void actionPerformed(ActionEvent evt) {
+                updateSensorPhysics();
+                updateSensorReadoutValues();
+                updateUserSettings();
+                
+                mPage.sendMessage(accelerometerSensorNumber, read_accelx, read_accely, read_accelz);
+                
+            }
+        });
+        geomagneticTimer = new Timer(delay, new ActionListener(){
+                       public void actionPerformed(ActionEvent arg0) {
+                               Magnetic magnetic = Magnetic.getInstance();
+                               magnetic.setMagneticFiled(mPage.north, mPage.east, mPage.vertical);
+                               magnetic.updateSensorPhysics(rollDegree, pitchDegree, yawDegree);
+                               magnetic.updateSensorReadoutValues();
+                               magnetic.updateUserSettings();
+                               if(Accelerometer.orientation_active)
+                                       magnetic.setOrient(read_accelx, read_accely, read_accelz);
+                               
+                               mPage.sendMessage(Magnetic.sensorNumber, magnetic.getAzimuth(), magnetic.getPitch(), magnetic.getRoll() , 4, magnetic.getReadCompassX(), magnetic.getReadCompassY(), magnetic.getReadCompassZ());
+                       }
+        });
+        gyroTimer = new Timer(delay, new ActionListener(){
+               public void actionPerformed(ActionEvent arg0) {
+                       updateSensorGyro();
+                       mPage.sendMessage(gyroSensorNumber, gyroPitch, gyroRoll, gyroYaw);
+                       }
+        });
+
+        timer.setCoalesce(true);
+        geomagneticTimer.setCoalesce(true);
+        gyroTimer.setCoalesce(true);
+       }
+       
+private void updateSensorGyro(){
+               
+               if( gyroStart == false){
+                       old_gyroYaw = yawDegree;
+                       old_gyroPitch = pitchDegree;
+                       old_gyroRoll = rollDegree;
+                       gyroStart = true;
+                       return;
+               }
+               
+               gyroRoll = gyroRollCount * 360 + rollDegree - old_gyroRoll;
+               gyroPitch = gyroPitchCount * 360 + pitchDegree - old_gyroPitch;
+               gyroYaw = gyroYawCount * 360 + yawDegree - old_gyroYaw;
+               
+               gyroYawCount = 0;
+               gyroPitchCount = 0;
+               gyroRollCount = 0;
+               
+               old_gyroRoll = rollDegree;
+               old_gyroPitch = pitchDegree;
+               old_gyroYaw = yawDegree;
+               while( gyroRoll > 2000) gyroRoll-=360;
+               while( gyroRoll < -2000) gyroRoll+=360;
+               while( gyroPitch > 2000) gyroPitch-=360;
+               while( gyroPitch < -2000) gyroPitch+=360;
+               while( gyroYaw > 2000) gyroYaw-=360;
+               while( gyroYaw < -2000) gyroYaw+=360;
+       }
+       
+       /**
+        * Updates physical model of all sensors by minimum time-step.
+        * 
+        * This internal update provides the close-to-continuum
+        * description of the sensors.
+        * It does not yet provide the values that
+        * are read out by the Sensors class (which are
+        * obtained by further time-selection or averaging).
+        */
+       public void updateSensorPhysics() {
+               Vector vec;
+
+               dt = 0.001 * 10;
+               g = 9.80665;
+               if (g != 0) {
+                       ginverse = 1 / g;
+               }
+               k = 500;
+               gamma = 50;
+               
+               Fx = + k * (movex - accx);
+               Fz = + k * (movez - accz);
+               
+               ax = Fx / m;
+               az = Fz / m;
+               
+               vx += (ax) * dt;
+               vz += (az) * dt;
+
+               accx += vx * dt;
+               accz += vz * dt;
+               
+               // We put damping here: We don't want to damp for
+               // zero motion with respect to the background,
+               // but with respect to the mobile phone:
+               accx += gamma * (movex - accx) * dt;
+               accz += gamma * (movez - accz) * dt;
+                               
+               // Calculate acceleration by gravity:
+               // TODO: Make to be able to set by settings page
+               double gravityax = 0;
+               double gravityay = 0;
+               double gravityaz = -9.80665;
+               
+               ////
+               // Now calculate this into mobile phone acceleration:
+               // ! Mobile phone's acceleration is just opposite to 
+               // lab frame acceleration !
+               vec = new Vector(-ax * meterperpixel + gravityax, gravityay, -az * meterperpixel + gravityaz);
+                       
+               // we reverse roll, pitch, and yawDegree,
+               // as this is how the mobile phone sees the coordinate system.
+               vec.reverserollpitchyaw();
+               
+               // TODO: Add check condition to figure out selected sensors
+//             if (mSensorSimulator.mEnabledAccelerometer.isSelected()) {
+                       accelx = vec.x;
+                       accely = vec.y;
+                       accelz = vec.z;
+                               
+                       // Add accelerometer limit:
+                       double limit = g * 10;
+                       if (limit > 0) {
+                               // limit on each component separately, as each is
+                               // a separate sensor.
+                               if (accelx > limit) accelx = limit;
+                               if (accelx < -limit) accelx = -limit;
+                               if (accely > limit) accely = limit;
+                               if (accely < -limit) accely = -limit;
+                               if (accelz > limit) accelz = limit;
+                               if (accelz < -limit) accelz = -limit;
+                       }
+//             } else {
+//                     accelx = 0;
+//                     accely = 0;
+//                     accelz = 0;
+//             }
+                       
+               // Orientation is currently not affected:
+//             if (mSensorSimulator.mEnabledOrientation.isSelected()) {
+                       //yaw = Math.toRadians(yawDegree);
+                       //pitch = Math.toRadians(pitchDegree);
+                       //roll = Math.toRadians(rollDegree);
+                       // Since OpenGL uses degree as input,
+                       // and it seems also more user-friendly,
+                       // let us stick to degree.
+                       // (it seems, professional sensors also use
+                       //  degree output.)
+                       yaw = yawDegree;
+                       pitch = pitchDegree;
+                       roll = rollDegree;              
+//             } else {
+//                     yaw = 0;
+//                     pitch = 0;
+//                     roll = 0;
+//             }
+               
+               // TODO: Add check condition for showing acceleration bar 
+//             if (mSensorSimulator.mShowAcceleration.isSelected()) {
+                       // We only have to repaint if we show the acceleration,
+                       // otherwise the phone does not change as long as there is
+                       // no user interaction.
+                       repaint();
+//             };
+
+       }
+       
+       /**
+        * Updates sensor values in time intervals as specified by updateSensorRate().
+        */
+       public void updateSensorReadoutValues() {
+               long currentTime = System.currentTimeMillis();
+               
+               // From time to time we 
+               
+               if (average_accel) {
+                       // Form the average
+                       partial_accelx += accelx;
+                       partial_accely += accely;
+                       partial_accelz += accelz;
+                       partial_accel_n++;
+               }
+               
+               if (average_orientation) {
+                       // Form the average
+                       partial_yaw += yaw;
+                       partial_pitch += pitch;
+                       partial_roll += roll;
+                       partial_orientation_n++;
+               }
+                               
+               if (currentTime >= accel_next_update) {
+                       // Update
+                       accel_next_update += accel_update_duration;
+                       if (accel_next_update < currentTime) {
+                               // Don't lag too much behind.
+                               // If we are too slow, then we are too slow.
+                               accel_next_update = currentTime;
+                       }
+                       
+                       if (average_accel) {
+                               // form average
+                               read_accelx = partial_accelx / partial_accel_n;
+                               read_accely = partial_accely / partial_accel_n;
+                               read_accelz = partial_accelz / partial_accel_n;
+                               
+                               // reset average
+                               partial_accelx = 0;
+                               partial_accely = 0;
+                               partial_accelz = 0;
+                               partial_accel_n = 0;
+                               
+                       } else {
+                               // Only take current value
+                               read_accelx = accelx;
+                               read_accely = accely;
+                               read_accelz = accelz;
+                       }
+                       
+               }
+
+               if (currentTime >= orientation_next_update) {
+                       // Update
+                       orientation_next_update += orientation_update_duration;
+                       if (orientation_next_update < currentTime) {
+                               // Don't lag too much behind.
+                               // If we are too slow, then we are too slow.
+                               orientation_next_update = currentTime;
+                       }
+                       
+                       if (average_orientation) {
+                               // form average
+                               read_yaw = partial_yaw / partial_orientation_n;
+                               read_pitch = partial_pitch / partial_orientation_n;
+                               read_roll = partial_roll / partial_orientation_n;
+                               
+                               // reset average
+                               partial_yaw = 0;
+                               partial_pitch = 0;
+                               partial_roll = 0;
+                               partial_orientation_n = 0;
+                               
+                       } else {
+                               // Only take current value
+                               read_yaw = yaw;
+                               read_pitch = pitch;
+                               read_roll = roll;
+                       }
+                       
+                       // Normalize values:
+                       
+                       // Restrict pitch value to -90 to +90
+                       if (read_pitch < -90) {
+                               read_pitch = -180 - read_pitch;
+                               read_yaw += 180;
+                               read_roll += 180;
+                       } else if (read_pitch > 90) {
+                               read_pitch = 180 - read_pitch;
+                               read_yaw += 180;
+                               read_roll += 180;
+                               
+                       }
+                       
+                       // yaw from 0 to 360
+                       if (read_yaw < 0) {
+                               read_yaw = read_yaw + 360;
+                       }
+                       if (read_yaw >= 360) {
+                               read_yaw -= 360;
+                       }
+                       
+                       // roll from -180 to + 180
+                       if (read_roll >= 180) {
+                               read_roll -= 360;
+                       }
+                       
+               }
+       }
+               
+       /**
+        * Updates user settings by reading out the widgets.
+        * This is done after some duration 
+        * set by user_settings_duration.
+        */
+       public void updateUserSettings() {
+               long currentTime = System.currentTimeMillis();
+               double rate;
+               
+               // From time to time we get the user settings:
+               if (currentTime >= user_settings_next_update) {
+                       // Do update
+                       user_settings_next_update += user_settings_duration;
+                       if (user_settings_next_update < currentTime) {
+                               // Skip time if we are already behind:
+                               user_settings_next_update = System.currentTimeMillis();
+                       }
+                       
+                       average_accel = true;
+                       rate = 50;
+                       if (rate != 0) {
+                               accel_update_duration = (long) (1000. / rate);
+                       } else {
+                               accel_update_duration = 0;
+                       }
+                       
+                       average_orientation = true;
+                       rate = 50;
+                       if (rate != 0) {
+                               orientation_update_duration = (long) (1000. / rate);
+                       } else {
+                               orientation_update_duration = 0;
+                       }
+               }
+       }
+       
+    public Dimension getPreferredSize() {
+        return new Dimension(250,200);
+    }
+    
+    /**
+     *  yaws a vector (rotate around z-axis)
+     */
+    
+    /**
+     * Draws the phone.
+     */
+    protected void paintComponent(Graphics graphics) {
+        super.paintComponent(graphics);       
+        // g.drawString("This is my custom Panel!",(int)yawDegree,(int)pitch);
+        
+        Graphics2D g2 = (Graphics2D) graphics;
+        // draw Line2D.Double
+        
+        double centerx = 100;
+        double centery = 100;
+        double centerz = -150;
+        double draw_roll = old_gyro_rollDegree - rollDegree;
+        double draw_pitch = old_gyro_pitchDegree-pitchDegree;
+        double draw_yaw = old_gyro_yawDegree-yawDegree;
+        
+        for (int i=0; i<phone.length; i+=2) {
+               if (i==0) g2.setColor(Color.RED);
+               if (i==24) g2.setColor(Color.BLUE);
+               
+               Vector v1 = new Vector(phone[i]);
+               Vector v2 = new Vector(phone[i+1]);
+//             v1.rollpitchyaw(rollDegree, pitchDegree, yawDegree);
+//             v2.rollpitchyaw(rollDegree, pitchDegree, yawDegree);
+               if( i == 0 ) {
+                       v1.setAxisX(gyro_axisX);
+               v1.setAxisY(gyro_axisY);
+               v1.setAxisZ(gyro_axisZ);
+                       v1.rollpitchyaw(draw_roll, draw_pitch, draw_yaw);
+               }
+               //v2.rollpitchyaw(draw_roll, draw_pitch, draw_yaw);
+               v1.setPosition();
+               v2.setPosition();
+               
+               if (phone_pos_conv == true) {
+                       if( i == 30){
+                               phone_pos_conv = false;
+                               
+                               gyro_axisX = Vector.getAxisX().clone();
+                               gyro_axisY = Vector.getAxisY().clone();
+                               gyro_axisZ = Vector.getAxisZ().clone();
+                               
+                               old_gyro_rollDegree = rollDegree;
+                               old_gyro_pitchDegree = pitchDegree;
+                               old_gyro_yawDegree = yawDegree;
+                       }
+               }
+               
+            g2.draw(new Line2D.Double(
+                       centerx + (v1.x + movex) * centerz / (centerz - v1.y), 
+                       centery - (v1.z + movez) * centerz / (centerz - v1.y), 
+                       centerx + (v2.x + movex) * centerz / (centerz - v2.y), 
+                       centery - (v2.z + movez) * centerz / (centerz - v2.y)));
+        }
+        
+//      if (mSensorSimulator.mShowAcceleration.isSelected()) {
+        // Now we also draw the acceleration:
+               g2.setColor(Color.GREEN);
+               Vector v1 = new Vector(0,0,0);
+               Vector v2 = new Vector(accelx, accely, accelz);
+               v2.scale(20 * ginverse);
+               //Vector v2 = new Vector(1, 0, 0);
+//             v1.rollpitchyaw(rollDegree, pitchDegree, yawDegree);
+//             v2.rollpitchyaw(rollDegree, pitchDegree, yawDegree);
+               v1.setPosition();
+               v2.setPosition();
+               g2.draw(new Line2D.Double(
+                               centerx + (v1.x + movex) * centerz / (centerz - v1.y), 
+                               centery - (v1.z + movez) * centerz / (centerz - v1.y), 
+                               centerx + (v2.x + movex) * centerz / (centerz - v2.y), 
+                               centery - (v2.z + movez) * centerz / (centerz - v2.y)));
+               
+    }  
+    
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+    public void accelerometerTimer(boolean checked){
+       if( timer != null){
+               if( checked == true && connected == true){
+                       timer.start();
+               }
+               if( checked == false){
+                       timer.stop();
+               }
+       }
+    }
+    public void geomagneticTimer(boolean checked){
+       if( geomagneticTimer != null){
+               if( checked == true && connected == true){
+                       geomagneticTimer.start();
+               }
+               if( checked == false){
+                       geomagneticTimer.stop();
+               }
+       }
+    }
+    public void gyroTimer(boolean checked){
+       if( gyroTimer != null){
+               if( checked == true && connected == true){
+                       gyroTimer.start();
+               }
+               if( checked == false){
+                       gyroTimer.stop();
+               }
+       }
+    }
+    public void orientationTimer(boolean checked){
+       if( orientationTimer != null){
+               if( checked == true && connected == true){
+                       orientationTimer.start();
+               }
+               if( checked == false){
+                       orientationTimer.stop();
+               }
+       }
+    }
+    public void setGyroAxisX(double[] axis) {
+       gyro_axisX = axis.clone();
+    }
+    public void setGyroAxisY(double[] axis) {
+       gyro_axisY = axis.clone();
+    }
+    public void setGyroAxisZ(double[] axis) {
+       gyro_axisZ = axis.clone();
+    }
+//     @Override
+       public void connect() {
+               connected = true;
+               
+               accelerometerTimer(mPage.checkboxAccelerometer.getSelection());
+               geomagneticTimer(mPage.checkboxGeoMagnetic.getSelection());
+               gyroTimer(mPage.checkboxGyro.getSelection());
+               if( mPage.dataOutputTimer != null){
+                       mPage.dataOutputTimer.start();
+               }
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               connected = false;
+               
+               accelerometerTimer(false);
+               geomagneticTimer(false);
+               gyroTimer(false);
+               if( mPage.dataOutputTimer != null){
+                       mPage.dataOutputTimer.stop();
+               }
+
+       }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+       }
+}
diff --git a/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Vector.java b/org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/Vector.java
new file mode 100644 (file)
index 0000000..6fb8e63
--- /dev/null
@@ -0,0 +1,243 @@
+package org.tizen.sensor.accelerometer.page;
+
+/* 
+ * Copyright (C) 2008 OpenIntents.org
+ *
+ * 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.
+ */
+
+/**
+ * Rolls, pitches, and yaws a three-dimensional vector.
+ * 
+ * This tiny vector class is optimized for 
+ * rolling, pitching, and yawing of a three-vector.
+ * 
+ * @author Peli
+ *
+ */
+public class Vector {
+       public double x;
+       public double y;
+       public double z;
+       
+       private static double[] axisX = {1,0,0};
+       private static double[] axisY = {0,0,1};
+       private static double[] axisZ = {0,-1,0};
+       
+       
+       
+       public Vector() {
+               x = 0;
+               y = 0;
+               z = 0;
+       }
+       public Vector(Vector v) {
+               x = v.x;
+               y = v.y;
+               z = v.z;
+       }
+       public Vector(double x, double y, double z) {
+               this.x = x;
+               this.y = y;
+               this.z = z;
+       }
+       public Vector(double[] vec) {
+               x = vec[0];
+               y = vec[1];
+               z = vec[2];
+       }
+       
+       /**
+        * Scale the vector by a factor.
+        * 
+        * @param factor Common factor.
+        */
+       public void scale(double factor) {
+               x = factor * x;
+               y = factor * y;
+               z = factor * z;
+       }
+       
+       /**
+        * Yaw the vector (rotate around z-axis)
+        * 
+        * @param yaw yaw in Degree.
+        */
+       public void yaw(double yaw) {
+       Vector v = new Vector(this); // temporary vector
+       double yawRad = Math.toRadians(yaw);
+       double cos = Math.cos(yawRad);
+       double sin = Math.sin(yawRad);
+       x = cos * v.x + sin * v.y;
+       y = -sin * v.x + cos * v.y;
+       z = v.z;
+    }
+       
+       public void pitch(double pitch) {
+       Vector v = new Vector(this); // temporary vector
+       double pitchRad = Math.toRadians(pitch); // negative sign => positive as defined in SDK.
+       double cos = Math.cos(pitchRad);
+       double sin = Math.sin(pitchRad);
+       x = v.x;
+       y = cos * v.y + sin * v.z;
+       z = -sin * v.y + cos * v.z;
+    }
+       
+       public void roll(double roll) {
+       Vector v = new Vector(this); // temporary vector
+       double rollRad = Math.toRadians(roll);
+       double cos = Math.cos(rollRad);
+       double sin = Math.sin(rollRad);
+       x = cos * v.x + sin * v.z;
+       y = v.y;
+       z = -sin * v.x + cos * v.z;
+    }
+       
+       public static double[] getAxisX(){
+               return axisX;
+       }
+       public static double[] getAxisY(){
+               return axisY;
+       }
+       public static double[] getAxisZ(){
+               return axisZ;
+       }
+       public void setAxisX(double[] axis){
+               axisX[0] = axis[0];
+               axisX[1] = axis[1];
+               axisX[2] = axis[2];
+       }
+       public void setAxisY(double[] axis){
+               axisY[0] = axis[0];
+               axisY[1] = axis[1];
+               axisY[2] = axis[2];
+       }
+       public void setAxisZ(double[] axis){
+               axisZ[0] = axis[0];
+               axisZ[1] = axis[1];
+               axisZ[2] = axis[2];
+       }
+       
+       public double[][] getRotationMatrix(){
+               double ret_val[][] = 
+               { {axisX[0], axisX[1], axisX[2], 0},
+                 {axisY[0], axisY[1], axisY[2], 0},
+                 {axisZ[0], axisZ[1], axisZ[2], 0},
+                 {0, 0, 0, 1}
+               };
+               
+               return ret_val;
+       }
+       public double[][] getReverseMatrix(double[][] matrix){
+               double ret_val[][] = new double[4][4];
+               for( int i = 0 ; i < 4 ; i++){
+                       for( int j = 0 ; j < 4 ; j++){
+                               ret_val[i][j] = matrix[j][i];
+                       }
+               }
+
+               return ret_val;
+       }
+       
+       public void changeAxisRoll( double angle, double[] axisX, double[] axisZ){
+               double orignalMatrix[][] = getRotationMatrix();
+               double reverseMatrix[][] = getReverseMatrix(orignalMatrix);
+
+               double Rad = Math.toRadians(angle);
+               double cos = Math.cos(Rad);
+               double sin = Math.sin(Rad);
+               
+               axisX[0] = cos * 1 + sin * 0;
+       axisX[1] = 0;
+       axisX[2] = -sin * 1 + cos * 0;
+       trasnAxis(axisX, reverseMatrix);
+
+       axisZ[0] = cos * 0 + sin * 1;
+       axisZ[1] = 0;
+       axisZ[2] = -sin * 0 + cos * 1;
+       trasnAxis(axisZ, reverseMatrix);
+       }
+       public void changeAxisPitch( double angle, double[] axisY, double[] axisZ){
+               double orignalMatrix[][] = getRotationMatrix();
+               double reverseMatrix[][] = getReverseMatrix(orignalMatrix);
+
+               double Rad = Math.toRadians(angle);
+               double cos = Math.cos(Rad);
+               double sin = Math.sin(Rad);
+               
+               axisY[0] = 0;
+       axisY[1] = cos * 1 + sin * 0;
+       axisY[2] = -sin * 1 + cos * 0;
+       trasnAxis(axisY, reverseMatrix);
+
+       axisZ[0] = 0;
+       axisZ[1] = cos * 0 + sin * 1;
+       axisZ[2] = -sin * 0 + cos * 1;
+       trasnAxis(axisZ, reverseMatrix);
+       }
+       public void changeAxisYaw( double angle, double[] axisX, double[] axisY){
+               double orignalMatrix[][] = getRotationMatrix();
+               double reverseMatrix[][] = getReverseMatrix(orignalMatrix);
+
+               double Rad = Math.toRadians(angle);
+               double cos = Math.cos(Rad);
+               double sin = Math.sin(Rad);
+               
+               axisX[0] = cos * 1 + sin * 0;
+       axisX[1] = -sin * 1 + cos * 0;
+       axisX[2] = 0;
+       trasnAxis(axisX, reverseMatrix);
+       
+       axisY[0] = cos * 0 + sin * 1;
+       axisY[1] = -sin * 0 + cos * 1;
+       axisY[2] = 0;
+       trasnAxis(axisY, reverseMatrix);
+       }
+       public void trasnAxis( double[] axis, double[][] matrix){
+               double[] temp_pos = {0,0,0,0};
+               for( int i = 0 ; i < 4 ; i++){
+                       temp_pos[i] = matrix[i][0] * axis[0] + matrix[i][1] * axis[1] + matrix[i][2] * axis[2];
+               }
+                               
+               axis[0] = temp_pos[0];
+               axis[1] = temp_pos[1];
+               axis[2] = temp_pos[2];
+       }
+       public void transVector( double[][] matrix){
+               double[] temp_pos = {0,0,0,0};
+               for( int i = 0 ; i < 4 ; i++){
+                       temp_pos[i] = matrix[i][0] * x + matrix[i][1] * y + matrix[i][2] * z;
+               }
+                               
+               x = temp_pos[0];
+               y = temp_pos[1];
+               z = temp_pos[2];
+       }
+       public void setPosition(){
+               double[][] rotationMatrix = getRotationMatrix();
+               double[][] reverseMatrix = getReverseMatrix(rotationMatrix);
+               transVector(reverseMatrix);
+       }
+       
+       public void rollpitchyaw(double roll, double pitch, double yaw) {
+               changeAxisRoll(roll, axisX, axisZ);
+               changeAxisPitch(pitch, axisY, axisZ);
+               changeAxisYaw(yaw, axisX, axisY);
+       }
+       
+       
+       public void reverserollpitchyaw() {
+               double[][] rotationMatrix = getRotationMatrix();
+               transVector(rotationMatrix);
+       }
+}
diff --git a/org.tizen.sensor.accelerometer/src/org/tizen/sensor/magnetic/Magnetic.java b/org.tizen.sensor.accelerometer/src/org/tizen/sensor/magnetic/Magnetic.java
new file mode 100644 (file)
index 0000000..b0a30c9
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * org.tizen.sensor.accelerometer
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.magnetic;
+
+import java.util.Random;
+
+import org.tizen.sensor.accelerometer.page.Vector;
+
+public class Magnetic {
+       private static Magnetic instance;
+       private Random r;
+       private double compassx;
+       private double compassy;
+       private double compassz;
+       private int azimuth = 0;
+       private int pitch = -90;
+       private int roll = 0;
+//     private double magneticnorth = 22874.1;
+//     private double magneticeast = 5939.5;
+//     private double magneticvertical = 43180.5;
+       private double magneticnorth = 10000;
+       private double magneticeast = 1000;
+       private double magneticvertical = 0;
+       public static final String sensorNumber = "5\n";
+       
+       /** Current read-out value of compass x-component. */
+       private double read_compassx;
+       /** Current read-out value of compass y-component. */
+       private double read_compassy;
+       /** Current read-out value of compass z-component. */
+       private double read_compassz;
+       
+       /** Partial read-out value of compass x-component. */
+       private double partial_compassx;
+       /** Partial read-out value of compass y-component. */
+       private double partial_compassy;
+       /** Partial read-out value of compass z-component. */
+       private double partial_compassz;
+       /** Number of summands in partial sum for compass. */
+       private int partial_compass_n;
+       /** Duration (in milliseconds) between two updates.
+        * This is the inverse of the update rate.
+        */
+       private long compass_update_duration;
+       /** Time of next update required.
+        * The time is compared to System.currentTimeMillis().
+        */
+       private long compass_next_update;
+       /** Duration in milliseconds until user setting
+        * changes are read out.
+        */
+       private long user_settings_duration;
+       /** Time of next update for reading user settings from widgets.
+        * The time is compared to System.currentTimeMillis().
+        */
+       private long user_settings_next_update;
+       
+       private boolean average_compass;
+       
+       private Magnetic(){
+               r = new Random();
+               average_compass = true;
+               user_settings_duration = 500;  // Update every half second. This should be enough.
+               user_settings_next_update = System.currentTimeMillis(); // First update is now.
+               azimuth = 0;
+       }
+       
+       public static Magnetic getInstance(){
+               if( instance == null) {
+                       instance = new Magnetic();
+               }
+               return instance;
+       }
+       
+       public void setMagneticFiled(double north, double east, double vertical){
+//             magneticnorth = north;
+//             magneticeast = east;
+//             magneticvertical = vertical;
+       }
+       
+       public void updateSensorPhysics(double rollDegree, double pitchDegree, double yawDegree){
+               // user input
+               
+               double random = 0.0f;
+               
+               Vector vec;
+               
+
+
+               // Add random component:
+               if (random > 0) {
+                       magneticnorth += getRandom(random);
+                       magneticeast += getRandom(random);
+                       magneticvertical += getRandom(random);
+               }
+
+               // Magnetic vector in phone coordinates:
+               vec = new Vector(magneticeast, magneticnorth, -magneticvertical);
+               vec.scale(0.001); // convert from nT (nano-Tesla) to 占폯 (micro-Tesla)
+
+               // we reverse roll, pitch, and yawDegree,
+               // as this is how the mobile phone sees the coordinate system.
+               vec.reverserollpitchyaw();
+
+               compassx = vec.x;
+               compassy = vec.y;
+               compassz = vec.z;
+       }
+       
+       public void setOrient(double x, double y, double z){
+               /* orientation logic via accelerometer value */
+               int orient_yaw, orient_pitch, orient_roll;
+               orient_yaw = (int)(Math.round(Math.atan2(-x, -y) * (180.0/3.14) + 360) % 360);
+               orient_pitch = (int)(Math.atan2(-y, -z) * (180.0/3.14)) % 180;
+               orient_roll = (int)(Math.atan2(x, z) * (180.0/3.14)) % 180;
+               
+               if(orient_roll > 90)
+                       orient_roll = 180 - orient_roll;
+               else if(orient_roll < -90)
+                       orient_roll = -180 - orient_roll;
+               
+               azimuth = orient_yaw;
+               pitch = -orient_pitch;
+               roll = orient_roll;
+       }
+       
+       public int getAzimuth(){
+               return azimuth;
+       }
+       public int getPitch(){
+               return pitch;
+       }
+       public int getRoll(){
+               return roll;
+       }
+       public void updateSensorReadoutValues() {
+               long currentTime = System.currentTimeMillis();
+               if (average_compass) {
+                       // Form the average
+                       partial_compassx += compassx;
+                       partial_compassy += compassy;
+                       partial_compassz += compassz;
+                       partial_compass_n++;
+               }
+               if (currentTime >= compass_next_update) {
+                       // Update
+                       compass_next_update += compass_update_duration;
+                       if (compass_next_update < currentTime) {
+                               // Don't lag too much behind.
+                               // If we are too slow, then we are too slow.
+                               compass_next_update = currentTime;
+                       }
+
+                       if (average_compass) {
+                               // form average
+                               read_compassx = partial_compassx / partial_compass_n;
+                               read_compassy = partial_compassy / partial_compass_n;
+                               read_compassz = partial_compassz / partial_compass_n;
+
+                               // reset average
+                               partial_compassx = 0;
+                               partial_compassy = 0;
+                               partial_compassz = 0;
+                               partial_compass_n = 0;
+
+                       } else {
+                               // Only take current value
+                               read_compassx = compassx;
+                               read_compassy = compassy;
+                               read_compassz = compassz;
+                       }
+
+               }
+               
+       }
+       
+       public void updateUserSettings(){
+               long currentTime = System.currentTimeMillis();
+               double rate;
+               // From time to time we get the user settings:
+               if (currentTime >= user_settings_next_update) {
+                       // Do update
+                       user_settings_next_update += user_settings_duration;
+                       if (user_settings_next_update < currentTime) {
+                               // Skip time if we are already behind:
+                               user_settings_next_update = System.currentTimeMillis();
+                       }
+                       
+                       // user input
+                       average_compass = true;
+                       rate = 10;
+                       if (rate != 0) {
+                               compass_update_duration = (long) (1000. / rate);
+                       } else {
+                               compass_update_duration = 0;
+                       }
+               }
+       }
+       
+       public double getReadCompassX(){
+               return read_compassx;
+       }
+       public double getReadCompassY(){
+               return read_compassy;
+       }
+       public double getReadCompassZ(){
+               return read_compassz;
+       }
+       
+       
+       private double getRandom(double random) {
+               double val;
+               val = r.nextDouble();
+               return (2*val - 1) * random;
+       }
+}
diff --git a/org.tizen.sensor.light/.classpath b/org.tizen.sensor.light/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.sensor.light/.project b/org.tizen.sensor.light/.project
new file mode 100644 (file)
index 0000000..d5448fc
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.sensor.light</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.sensor.light/.settings/org.eclipse.jdt.core.prefs b/org.tizen.sensor.light/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..6022d0a
--- /dev/null
@@ -0,0 +1,8 @@
+#Thu May 12 13:46:39 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.sensor.light/META-INF/MANIFEST.MF b/org.tizen.sensor.light/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..3dd22cb
--- /dev/null
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Sensor Light
+Bundle-SymbolicName: org.tizen.sensor.light;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: 
+ org.eclipse.swt.widgets,
+ org.eclipse.ui.plugin,
+ org.tizen.common.connection,
+ org.tizen.common.util,
+ org.tizen.sdblib
+Require-Bundle: org.tizen.injector;bundle-version="1.3.20",
+ org.eclipse.swt;bundle-version="3.5.2",
+ org.eclipse.core.runtime;bundle-version="3.7.0"
diff --git a/org.tizen.sensor.light/build.properties b/org.tizen.sensor.light/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.sensor.light/plugin.xml b/org.tizen.sensor.light/plugin.xml
new file mode 100644 (file)
index 0000000..c83cad3
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Sensor"
+            class="org.tizen.sensor.light.Light"
+            id="org.tizen.sensor.light"
+            name="Light">
+      </itemType>
+   </extension>
+
+</plugin>
diff --git a/org.tizen.sensor.light/src/org/tizen/sensor/light/Light.java b/org.tizen.sensor.light/src/org/tizen/sensor/light/Light.java
new file mode 100644 (file)
index 0000000..78409aa
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * org.tizen.sensor.light
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.light;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.sensor.light.page.LightPage;
+
+public class Light extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new LightPage(this, "Light"));
+       }
+
+}
diff --git a/org.tizen.sensor.light/src/org/tizen/sensor/light/page/LightPage.java b/org.tizen.sensor.light/src/org/tizen/sensor/light/page/LightPage.java
new file mode 100644 (file)
index 0000000..f4a4b7b
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * org.tizen.sensor.light
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.light.page;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Text;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class LightPage extends AbstractInjectorPage implements ISelectionListener {
+       private Text sliderText;
+       private Text luxText;
+       private Button injectLux;
+       private Slider slider;
+       private final String sensorNumber = "3\n";
+       private final String lightLevel = "Level";
+       private int luxData = 65535, levelData;
+       private IDevice currentDevice;
+       
+       public LightPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       public static boolean checkNumberFormat(String noStr) {
+               Pattern luxPattern = Pattern.compile( "[^0-9]");
+               Matcher matcher = luxPattern.matcher(noStr);
+               return matcher.find();
+       }
+       
+       @Override
+       protected void createContents() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+               
+//             Composite mainComposite = formUtil.createComposite(parent, 3);                  
+//             formUtil.createLabel(mainComposite, lightLevel);
+//             slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
+//             slider.setValues(10, 1, 11, 1, 1, 1);
+//             slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+//             sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
+//             sliderText.setEditable(false);
+//             GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
+//             gd.widthHint = 20;
+//             sliderText.setLayoutData(gd);
+//             levelData = slider.getSelection();
+//             slider.addSelectionListener(new SelectionListener() {
+//                     @Override
+//                     public void widgetDefaultSelected(SelectionEvent e) {
+//                             // TODO Auto-generated method stub
+//                     }
+//                     @Override
+//                     public void widgetSelected(SelectionEvent e) {
+//                             levelData = slider.getSelection();
+//                             sliderText.setText(Integer.toString(levelData));
+//                             sendMessage(1, levelData);
+//                     }
+//             });
+               
+               Composite mainComposite2 = formUtil.createComposite(parent, 100);
+               formUtil.createLabel(mainComposite2, "Lux  ");
+               luxText = formUtil.createText(mainComposite2, "");
+               luxText.setTextLimit(5);
+
+               Composite buttonComposite = formUtil.createComposite(mainComposite2);
+               injectLux = formUtil.createButton(buttonComposite, "Inject", SWT.PUSH);
+               injectLux.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               String number = luxText.getText().trim();
+                               if(number==null||number.length()==0)
+                                       return;
+                               
+                               if(checkNumberFormat(number) || Double.parseDouble(number) <= 0 || Double.parseDouble(number) > 65535)
+                               {       
+                                               DialogUtil.openMessageDialog("Please enter the correct value.\nLux can be entered in the range of 1 to 65535.");
+                                               return;
+                               }
+                               luxData = Integer.parseInt(number);
+                               sendMessage(2, luxData);
+                       }
+               });
+               
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+       
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       
+       public void sendMessage(int label, int data) {
+                       TestSensorMessage msg = new TestSensorMessage(label, data);
+                       try {
+                       //      sensorSocket.send(sensorNumber + msg.getMessage());
+                               injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+       }
+
+//     @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               sendMessage(1, levelData);
+               sendMessage(2, luxData);
+       }
+}
diff --git a/org.tizen.sensor.motion/.classpath b/org.tizen.sensor.motion/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.sensor.motion/.project b/org.tizen.sensor.motion/.project
new file mode 100644 (file)
index 0000000..b4d9e48
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.sensor.motion</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.sensor.motion/.settings/org.eclipse.jdt.core.prefs b/org.tizen.sensor.motion/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..5f79cf8
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed Jun 29 14:18:42 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.sensor.motion/META-INF/MANIFEST.MF b/org.tizen.sensor.motion/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..a914a1a
--- /dev/null
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Sensor Motion
+Bundle-SymbolicName: org.tizen.sensor.motion;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.swt,
+ org.tizen.injector
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.tizen.injector.provider,
+ org.tizen.common.connection,
+ org.tizen.sdblib,
+ org.eclipse.swt,
+ org.eclipse.ui.plugin
diff --git a/org.tizen.sensor.motion/build.properties b/org.tizen.sensor.motion/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.sensor.motion/plugin.xml b/org.tizen.sensor.motion/plugin.xml
new file mode 100644 (file)
index 0000000..429250f
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Sensor"
+            class="org.tizen.sensor.motion.Motion"
+            id="org.tizen.sensor.motion"
+            name="Motion">
+      </itemType>
+   </extension>
+
+</plugin>
diff --git a/org.tizen.sensor.motion/src/org/tizen/sensor/motion/Motion.java b/org.tizen.sensor.motion/src/org/tizen/sensor/motion/Motion.java
new file mode 100644 (file)
index 0000000..49e4bcc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * org.tizen.sensor.motion
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.motion;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.sensor.motion.page.MotionPage;
+
+public class Motion extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new MotionPage(this, "Motion"));
+       }
+
+}
diff --git a/org.tizen.sensor.motion/src/org/tizen/sensor/motion/page/MotionPage.java b/org.tizen.sensor.motion/src/org/tizen/sensor/motion/page/MotionPage.java
new file mode 100644 (file)
index 0000000..44dda57
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * org.tizen.sensor.motion
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.motion.page;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class MotionPage extends AbstractInjectorPage implements ISelectionListener {
+       private final String sensorNumber = "6\n";
+
+       public MotionPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+       }
+
+       @Override
+       protected void createContents() {
+               Composite mainComposite = formUtil.createComposite(parent, 3);
+               
+               Button button_doubleTap = formUtil.createButton(mainComposite, "Double Tap", SWT.PUSH);
+               Button button_shakeStart = formUtil.createButton(mainComposite, "Shake Start", SWT.PUSH);
+               Button button_shakeEnd = formUtil.createButton(mainComposite, "Shake End", SWT.PUSH);
+               Button button_snapXp = formUtil.createButton(mainComposite, "Snap X+", SWT.PUSH);
+               Button button_snapYp = formUtil.createButton(mainComposite, "Snap Y+", SWT.PUSH);
+               Button button_snapZp = formUtil.createButton(mainComposite, "Snap Z+", SWT.PUSH);
+               Button button_snapXm = formUtil.createButton(mainComposite, "Snap X-", SWT.PUSH);
+               Button button_snapYm = formUtil.createButton(mainComposite, "Snap Y-", SWT.PUSH);
+               Button button_snapZm = formUtil.createButton(mainComposite, "Snap Z-", SWT.PUSH);
+               Button button_snapLeft = formUtil.createButton(mainComposite, "Snap Left", SWT.PUSH);
+               Button button_snapRight = formUtil.createButton(mainComposite, "Snap Right", SWT.PUSH);
+
+               GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
+
+               button_doubleTap.setLayoutData(gd);
+               button_shakeStart.setLayoutData(gd);
+               button_shakeEnd.setLayoutData(gd);
+               button_snapXp.setLayoutData(gd);
+               button_snapXm.setLayoutData(gd);
+               button_snapYp.setLayoutData(gd);
+               button_snapYm.setLayoutData(gd);
+               button_snapZp.setLayoutData(gd);
+               button_snapZm.setLayoutData(gd);
+               button_snapLeft.setLayoutData(gd);
+               button_snapRight.setLayoutData(gd);
+               
+               button_doubleTap.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(1);
+                       }
+           });
+               button_shakeStart.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(2);
+                       }
+           });
+               button_shakeEnd.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(3);
+                       }
+           });
+               button_snapXp.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(4);
+                       }
+           });
+               button_snapXm.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(5);
+                       }
+           });
+               button_snapYp.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(6);
+                       }
+           });
+               button_snapYm.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(7);
+                       }
+           });
+               button_snapZp.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(8);
+                       }
+           });
+               button_snapZm.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(9);
+                       }
+           });
+               button_snapLeft.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(10);
+                       }
+           });
+               button_snapRight.addSelectionListener(new SelectionListener(){
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendMessage(11);
+                       }
+           });
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+       public void sendMessage(int level) {
+               TestSensorMessage msg = new TestSensorMessage(level);
+               try {
+               //      sensorSocket.send(sensorNumber + msg.getMessage());
+                       injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+               } catch (Exception e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
+               }
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+//     DeviceLauncherManager.removeDeviceListener(this);
+//     TargetConnectionControl.removeTargetConnectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}
diff --git a/org.tizen.sensor.proximity/.classpath b/org.tizen.sensor.proximity/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.tizen.sensor.proximity/.project b/org.tizen.sensor.proximity/.project
new file mode 100644 (file)
index 0000000..58c1bbf
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.sensor.proximity</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.sensor.proximity/.settings/org.eclipse.jdt.core.prefs b/org.tizen.sensor.proximity/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..7f0584e
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed May 11 20:48:33 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.tizen.sensor.proximity/META-INF/MANIFEST.MF b/org.tizen.sensor.proximity/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..cd4b5d0
--- /dev/null
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tizen Event Injector Sensor Proximity
+Bundle-SymbolicName: org.tizen.sensor.proximity;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Tizen
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.tizen.injector,
+ org.eclipse.swt,
+ org.tizen.common,
+ org.eclipse.ui;bundle-version="3.7.0",
+ org.eclipse.core.runtime;bundle-version="3.7.0"
+Import-Package: 
+ org.eclipse.swt,
+ org.eclipse.swt.widgets,
+ org.tizen.common.connection,
+ org.tizen.sdblib
diff --git a/org.tizen.sensor.proximity/build.properties b/org.tizen.sensor.proximity/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.sensor.proximity/plugin.xml b/org.tizen.sensor.proximity/plugin.xml
new file mode 100644 (file)
index 0000000..222d6f4
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.tizen.injector.injectorItemProvider">
+      <itemType
+            category="Sensor"
+            class="org.tizen.sensor.proximity.Proximity"
+            id="org.tizen.sensor.proximity"
+            name="Proximity">
+      </itemType>
+   </extension>
+
+</plugin>
diff --git a/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/Proximity.java b/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/Proximity.java
new file mode 100644 (file)
index 0000000..a113635
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * org.tizen.sensor.proximity
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.proximity;
+
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.sensor.proximity.page.ProximityPage;
+
+public class Proximity extends AbstractInjectorItem{
+
+       @Override
+       protected void addPages() {
+               addPage(new ProximityPage(this, "Proximity"));
+               
+       }
+
+}
diff --git a/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityConstants.java b/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityConstants.java
new file mode 100644 (file)
index 0000000..da5203e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * org.tizen.sensor.proximity
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.proximity.page;
+
+public class ProximityConstants {
+       public static final String ON = "Near";
+       public static final String OFF = "Far";
+}
diff --git a/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityPage.java b/org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityPage.java
new file mode 100644 (file)
index 0000000..bf9912e
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * org.tizen.sensor.proximity
+ * 
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * 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.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.sensor.proximity.page;
+
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.SWT;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
+import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.IDevice;
+import org.tizen.injector.protocol.sensor.TestSensorMessage;
+import org.tizen.injector.provider.AbstractInjectorItem;
+import org.tizen.injector.provider.AbstractInjectorPage;
+
+public class ProximityPage extends AbstractInjectorPage implements ISelectionListener {
+       private Text sliderText;
+       private Slider slider;
+       private final String sensorNumber = "2\n";
+       private final String proxiDistance = "Distance";
+       private int sendData;
+       private IDevice currentDevice = null;
+       
+       public ProximityPage(AbstractInjectorItem item, String name) {
+               super(item, name);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       protected void createContents() {
+               ConnectionPlugin.getDefault().addSelectionListener(this);
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+
+               Composite mainComposite = formUtil.createComposite(parent, 3);
+               formUtil.createLabel(mainComposite, proxiDistance);
+               slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
+               slider.setValues(0, 0, 9, 1, 1, 1);
+               slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+               sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
+               sliderText.setEditable(false);
+               GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
+               gd.widthHint = 20;
+               sliderText.setLayoutData(gd);
+               sendData = slider.getSelection();
+               
+               slider.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // TODO Auto-generated method stub
+                       }
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               sendData = slider.getSelection();
+                               sliderText.setText(Integer.toString(sendData));
+                               sendMessage(sendData);
+                       }
+               });
+               
+               boolean connected = checkDeviceConnectedAlready();
+               if (connected == true) {
+                       connect();
+               }
+       }
+       
+       private boolean checkDeviceConnectedAlready() {
+               if (currentDevice == null)
+                       return false;
+               else
+                       return true;
+       }
+
+       @Override
+       protected void registerReceivers() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public void sendMessage(int distance) {
+                       TestSensorMessage msg = new TestSensorMessage(distance);
+                       try {
+                       //      sensorSocket.send(sensorNumber + msg.getMessage());
+                               injectorSocket.sendSensor(sensorNumber + msg.getMessage());
+                       } catch (Exception e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+       }
+
+       //      @Override
+       public void connect() {
+               // TODO Auto-generated method stub
+               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+       }
+
+//     @Override
+       public void disconnect() {
+               // TODO Auto-generated method stub
+       }
+       
+    @Override
+    protected void finalize() throws Throwable {
+       ConnectionPlugin.getDefault().removeSelectionListener(this);
+       super.finalize();
+    }
+
+       @Override
+       public void selectionChanged(FileEntry selectedEntry) {
+               if( selectedEntry == null)
+               {
+                       disconnect();
+                       return;
+               }
+               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
+                       return;
+               
+               if(currentDevice == null && selectedEntry.getName() != null)
+                       connect();
+               else if(currentDevice == null && selectedEntry.getName() == null)
+                       return;
+               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+                       disconnect();
+                       connect();
+               }
+               sendMessage(sendData);
+       }
+}
diff --git a/package/build.linux b/package/build.linux
new file mode 100755 (executable)
index 0000000..b6eaae3
--- /dev/null
@@ -0,0 +1,296 @@
+#!/bin/bash -x
+
+build_path=${SRCDIR}/build_result
+
+__set_parameter()
+{
+       build_id=${package_name}
+       build_type=N
+       build_result_directory=${build_type}.${build_id}
+       build_result_path="$build_path/$build_result_directory"
+       architecture=x86
+       ide_root_path_name=IDE
+
+       case ${platform} in
+               linux)
+                       archive_platform_name=linux
+                       windowing=gtk
+                       ;;
+               windows)
+                       archive_platform_name=win32
+                       windowing=win32
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       ;;
+       esac
+
+       result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip
+}
+
+__set_build_parameter()
+{
+       case ${platform} in
+               linux)
+                       reference_ide_path=${ROOTDIR}/indigo-pde/eclipse
+                       ;;
+               windows)
+                       reference_ide_path=${ROOTDIR}/indigo-winpde/eclipse
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       ;;
+       esac
+}
+
+__set_install_parameter()
+{
+       INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${platform}/data
+}
+
+__clean_build_environment()
+{
+       if [ -d $build_path ]
+       then
+               echo "Build result directory : [$build_path]"
+       else
+               echo "Make build result directory [$build_path]"
+               mkdir -p $build_path
+       fi
+
+       echo "Remove legacy build files..."
+       if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ]
+       then
+               rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}
+       fi
+       if [ -e ${build_result_path}/${result_archive_file} ]
+       then
+               rm -rf ${build_result_path}/${result_archive_file}
+       fi
+       if [ -d ${build_path}/tmp ]
+       then
+               rm -rf ${build_path}/tmp
+       fi
+
+       if [ -d ${build_path}/buildRepo ]
+       then
+               rm -rf ${build_path}/buildRepo
+       fi
+
+       rm -r ${build_path}/*.xml
+       rm -r ${build_path}/*.properties
+       rm -r ${build_path}/*.clean
+
+
+       if [ -d $build_path/plugins ]
+       then
+               echo "plugins directory recreate..."
+               rm -rf $build_path/plugins
+               mkdir $build_path/plugins
+       else
+               echo "Make plugins directory..."
+               mkdir $build_path/plugins
+       fi
+       if [ -d $build_path/features/ ]
+       then
+               echo "features directory recreate..."
+               rm -rf $build_path/features
+               mkdir $build_path/features
+       else
+               echo "Make features directory..."
+               mkdir $build_path/features
+       fi
+
+}
+
+__copy_build_sources()
+{
+       echo "Copy features from $SRCDIR to $build_path/features"
+       cp -r $SRCDIR/*.feature $build_path/features
+
+       echo "Copy plugins from $SRCDIR to $build_path/plugins"
+       cp -r $SRCDIR/* $build_path/plugins
+       rm -rf $build_path/plugins/*.feature
+}
+
+__copy_dependency_plugins()
+{
+       dependency_plugin_path=${ROOTDIR}/${ide_root_path_name}
+       if [ -d ${dependency_plugin_path} ]
+       then
+               cp -rf ${dependency_plugin_path}/features/* ${build_path}/features/
+               cp -rf ${dependency_plugin_path}/plugins/* ${build_path}/plugins/
+       fi
+}
+
+__make_ant_build_properties_file()
+{
+       builder_path="${SRCDIR}/builder"
+       parent_path_of_based_eclipse=${reference_ide_path}/..
+
+       echo "Make build.properties file..."
+       if [ ! -e $builder_path/build.properties.clean ] ; then
+               echo "ERROR : \"build.properties.clean\" file does not exist..."
+               exit 1
+       fi
+       cp $builder_path/build.properties.clean $build_path
+       cp $builder_path/customTargets.xml $build_path
+
+       if [ -d $reference_ide_path ] 
+       then
+               sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" \
+               -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" \
+               -e "s;\(^baseLocation=\).*;\1${reference_ide_path};g" \
+               -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" \
+               -e "s;\(^buildType=\).*;\1${build_type};g" \
+               -e "s;\(^buildId=\).*;\1${build_id};g" \
+               -e "s;\(^archivePrefix=\).*;\1${build_id};g" \
+               < $build_path/build.properties.clean > $build_path/build.properties
+
+       else
+               echo "ERROR : target eclipse is not exist."
+               exit 1
+       fi
+}
+
+__execute_pde_build()
+{
+       echo "Execute Product Ant Builder..."
+       equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar`
+       pde_build=`echo org.eclipse.pde.build_*`
+
+       java -XX:+UseParNewGC -jar ${reference_ide_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${reference_ide_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path -Dosgi.locking=none 2>&1
+
+       if [ $? != 0 ];
+       then
+               echo "Build failed..."
+               exit 1
+       fi
+}
+
+__unzip_plugin_pack()
+{
+       echo "unzip to $build_result_path"
+       unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture}
+}
+
+build_plugins()
+{
+       case ${platform} in
+               linux)
+                       echo "build plugin for ${platform}"
+                       ;;
+               windows)
+                       echo "build plugin for ${platform}"
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       exit 1
+                       ;;
+       esac
+
+       __set_parameter
+       __set_build_parameter
+       __clean_build_environment
+       __copy_build_sources
+       __copy_dependency_plugins
+       __make_ant_build_properties_file
+       __execute_pde_build
+       __unzip_plugin_pack
+
+       echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"."
+}
+
+__clean_packaging_environment()
+{
+
+       if [ -d ${INSTALL_DIR} ]
+       then
+               rm -rf ${INSTALL_DIR}
+       else
+               mkdir -p ${INSTALL_DIR}
+       fi
+}
+
+__copy_necessary_binaries()
+{
+       ## 패키징시 필요한 파일이 있으면 여기에 구현하시면 됩니다.
+       ## 파일을 복사할 위치는 ${INSTALL_DIR} 아래에 원하는 위치로 지정하시면 됩니다.
+       ## INSTALL_DIR의 값은 "${git repository 위치}/package/${package_name}.package.${platform}/data" 로 되어있습니다.
+       ## ex) cp -rf ~~~~/file.file ${INSTALL_DIR}/${ide_root_path_name}/
+       
+       echo "add necessary files."
+}
+
+packaging_plugins()
+{
+       __set_parameter
+       __set_install_parameter
+
+       __clean_packaging_environment
+       __copy_necessary_binaries
+
+       install_ide_path=${INSTALL_DIR}/${ide_root_path_name}
+       
+       if [ ! -d ${install_ide_path} ]
+       then
+               mkdir -p ${install_ide_path}
+       fi
+
+       cp -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}/${package_name}/* ${install_ide_path}/
+}
+
+# clean
+clean()
+{
+       echo "=========================================CLEAN============================================"
+       make clean
+       rm -rf ${SRCDIR}/*.zip
+       rm -rf ${SRCDIR}/*.tar.gz
+       rm -rf ${build_path}
+}
+
+# build
+build() 
+{
+       echo "=========================================BUILD============================================"
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+       
+               if [ "x${BUILD_TARGET_OS}" = "x${platform}" ]
+               then
+                       build_plugins
+               else
+                       echo ""
+               fi
+       done
+}
+
+# install
+install() 
+{
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               echo "=========================================INSTALL============================================"
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+
+               if [ "x${BUILD_TARGET_OS}" = "x${platform}" ]
+               then
+                       packaging_plugins
+               else
+                       echo ""
+               fi
+       done    
+}
+
+[ "$1" = "clean" ] && clean
+[ "$1" = "build" ] && build
+[ "$1" = "install" ] && install
+exit 0
diff --git a/package/build.windows b/package/build.windows
new file mode 100755 (executable)
index 0000000..b6eaae3
--- /dev/null
@@ -0,0 +1,296 @@
+#!/bin/bash -x
+
+build_path=${SRCDIR}/build_result
+
+__set_parameter()
+{
+       build_id=${package_name}
+       build_type=N
+       build_result_directory=${build_type}.${build_id}
+       build_result_path="$build_path/$build_result_directory"
+       architecture=x86
+       ide_root_path_name=IDE
+
+       case ${platform} in
+               linux)
+                       archive_platform_name=linux
+                       windowing=gtk
+                       ;;
+               windows)
+                       archive_platform_name=win32
+                       windowing=win32
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       ;;
+       esac
+
+       result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip
+}
+
+__set_build_parameter()
+{
+       case ${platform} in
+               linux)
+                       reference_ide_path=${ROOTDIR}/indigo-pde/eclipse
+                       ;;
+               windows)
+                       reference_ide_path=${ROOTDIR}/indigo-winpde/eclipse
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       ;;
+       esac
+}
+
+__set_install_parameter()
+{
+       INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${platform}/data
+}
+
+__clean_build_environment()
+{
+       if [ -d $build_path ]
+       then
+               echo "Build result directory : [$build_path]"
+       else
+               echo "Make build result directory [$build_path]"
+               mkdir -p $build_path
+       fi
+
+       echo "Remove legacy build files..."
+       if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ]
+       then
+               rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}
+       fi
+       if [ -e ${build_result_path}/${result_archive_file} ]
+       then
+               rm -rf ${build_result_path}/${result_archive_file}
+       fi
+       if [ -d ${build_path}/tmp ]
+       then
+               rm -rf ${build_path}/tmp
+       fi
+
+       if [ -d ${build_path}/buildRepo ]
+       then
+               rm -rf ${build_path}/buildRepo
+       fi
+
+       rm -r ${build_path}/*.xml
+       rm -r ${build_path}/*.properties
+       rm -r ${build_path}/*.clean
+
+
+       if [ -d $build_path/plugins ]
+       then
+               echo "plugins directory recreate..."
+               rm -rf $build_path/plugins
+               mkdir $build_path/plugins
+       else
+               echo "Make plugins directory..."
+               mkdir $build_path/plugins
+       fi
+       if [ -d $build_path/features/ ]
+       then
+               echo "features directory recreate..."
+               rm -rf $build_path/features
+               mkdir $build_path/features
+       else
+               echo "Make features directory..."
+               mkdir $build_path/features
+       fi
+
+}
+
+__copy_build_sources()
+{
+       echo "Copy features from $SRCDIR to $build_path/features"
+       cp -r $SRCDIR/*.feature $build_path/features
+
+       echo "Copy plugins from $SRCDIR to $build_path/plugins"
+       cp -r $SRCDIR/* $build_path/plugins
+       rm -rf $build_path/plugins/*.feature
+}
+
+__copy_dependency_plugins()
+{
+       dependency_plugin_path=${ROOTDIR}/${ide_root_path_name}
+       if [ -d ${dependency_plugin_path} ]
+       then
+               cp -rf ${dependency_plugin_path}/features/* ${build_path}/features/
+               cp -rf ${dependency_plugin_path}/plugins/* ${build_path}/plugins/
+       fi
+}
+
+__make_ant_build_properties_file()
+{
+       builder_path="${SRCDIR}/builder"
+       parent_path_of_based_eclipse=${reference_ide_path}/..
+
+       echo "Make build.properties file..."
+       if [ ! -e $builder_path/build.properties.clean ] ; then
+               echo "ERROR : \"build.properties.clean\" file does not exist..."
+               exit 1
+       fi
+       cp $builder_path/build.properties.clean $build_path
+       cp $builder_path/customTargets.xml $build_path
+
+       if [ -d $reference_ide_path ] 
+       then
+               sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" \
+               -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" \
+               -e "s;\(^baseLocation=\).*;\1${reference_ide_path};g" \
+               -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" \
+               -e "s;\(^buildType=\).*;\1${build_type};g" \
+               -e "s;\(^buildId=\).*;\1${build_id};g" \
+               -e "s;\(^archivePrefix=\).*;\1${build_id};g" \
+               < $build_path/build.properties.clean > $build_path/build.properties
+
+       else
+               echo "ERROR : target eclipse is not exist."
+               exit 1
+       fi
+}
+
+__execute_pde_build()
+{
+       echo "Execute Product Ant Builder..."
+       equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar`
+       pde_build=`echo org.eclipse.pde.build_*`
+
+       java -XX:+UseParNewGC -jar ${reference_ide_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${reference_ide_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path -Dosgi.locking=none 2>&1
+
+       if [ $? != 0 ];
+       then
+               echo "Build failed..."
+               exit 1
+       fi
+}
+
+__unzip_plugin_pack()
+{
+       echo "unzip to $build_result_path"
+       unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture}
+}
+
+build_plugins()
+{
+       case ${platform} in
+               linux)
+                       echo "build plugin for ${platform}"
+                       ;;
+               windows)
+                       echo "build plugin for ${platform}"
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       exit 1
+                       ;;
+       esac
+
+       __set_parameter
+       __set_build_parameter
+       __clean_build_environment
+       __copy_build_sources
+       __copy_dependency_plugins
+       __make_ant_build_properties_file
+       __execute_pde_build
+       __unzip_plugin_pack
+
+       echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"."
+}
+
+__clean_packaging_environment()
+{
+
+       if [ -d ${INSTALL_DIR} ]
+       then
+               rm -rf ${INSTALL_DIR}
+       else
+               mkdir -p ${INSTALL_DIR}
+       fi
+}
+
+__copy_necessary_binaries()
+{
+       ## 패키징시 필요한 파일이 있으면 여기에 구현하시면 됩니다.
+       ## 파일을 복사할 위치는 ${INSTALL_DIR} 아래에 원하는 위치로 지정하시면 됩니다.
+       ## INSTALL_DIR의 값은 "${git repository 위치}/package/${package_name}.package.${platform}/data" 로 되어있습니다.
+       ## ex) cp -rf ~~~~/file.file ${INSTALL_DIR}/${ide_root_path_name}/
+       
+       echo "add necessary files."
+}
+
+packaging_plugins()
+{
+       __set_parameter
+       __set_install_parameter
+
+       __clean_packaging_environment
+       __copy_necessary_binaries
+
+       install_ide_path=${INSTALL_DIR}/${ide_root_path_name}
+       
+       if [ ! -d ${install_ide_path} ]
+       then
+               mkdir -p ${install_ide_path}
+       fi
+
+       cp -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}/${package_name}/* ${install_ide_path}/
+}
+
+# clean
+clean()
+{
+       echo "=========================================CLEAN============================================"
+       make clean
+       rm -rf ${SRCDIR}/*.zip
+       rm -rf ${SRCDIR}/*.tar.gz
+       rm -rf ${build_path}
+}
+
+# build
+build() 
+{
+       echo "=========================================BUILD============================================"
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+       
+               if [ "x${BUILD_TARGET_OS}" = "x${platform}" ]
+               then
+                       build_plugins
+               else
+                       echo ""
+               fi
+       done
+}
+
+# install
+install() 
+{
+       pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'`
+       for pkgname_and_platform in ${pkgname_and_platform_list}
+       do
+               echo "=========================================INSTALL============================================"
+               pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '`
+               package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"`
+               platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"`
+
+               if [ "x${BUILD_TARGET_OS}" = "x${platform}" ]
+               then
+                       packaging_plugins
+               else
+                       echo ""
+               fi
+       done    
+}
+
+[ "$1" = "clean" ] && clean
+[ "$1" = "build" ] && build
+[ "$1" = "install" ] && install
+exit 0
diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest
new file mode 100644 (file)
index 0000000..6ea821b
--- /dev/null
@@ -0,0 +1,19 @@
+Package:eventinjector-eplugin
+Version:0.2.6
+OS:linux
+Build-host-os:linux
+Maintainer:yeongkyoon Lee <yeongkyoon.lee@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
+Description:EventInjector for emulator
+Build-dependency:indigo-pde[linux], common-eplugin[linux]
+Install-dependency:base-ide-product[linux]
+Source:eventinjector-eplugin
+
+Package:eventinjector-eplugin
+Version:0.2.6
+OS:windows
+Build-host-os:linux
+Maintainer:yeongkyoon Lee <yeongkyoon.lee@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
+Description:EventInjector for emulator
+Build-dependency:indigo-winpde[windows], common-eplugin[linux]
+Install-dependency:base-ide-product[windows]
+Source:eventinjector-eplugin
diff --git a/packaging_eventinjector.sh b/packaging_eventinjector.sh
new file mode 100755 (executable)
index 0000000..aaaf3fb
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/bash
+########################################################################################
+##
+## This script is packaging fresh ide.
+## If you have any question, please send e-mail to taeyoung2.son@samsung.com.
+##
+########################################################################################
+## You must setup parameter 
+set_build_result_path="`pwd`/.."
+
+############################################################################################################
+## Don't touch below!!!! If you want to touch this script, ask to Taeyoung Son(taeyoung2.son@samsung.com)
+############################################################################################################
+package()
+{
+       architecture=x86
+       case ${platform} in
+               linux)
+                       upload_platform_name=LINUX
+                       windowing=gtk
+                       ;;
+               windows)
+                       upload_platform_name=WINDOWS
+                       windowing=win32
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       exit 1
+                       ;;
+       esac
+
+       current_date=`date +%Y%m%d`
+       upload_server=172.21.17.46
+       case ${branch} in
+               master)
+                       upload_directory=/packages/PACKAGES_${upload_platform_name}
+                       ;;
+               release)
+                       upload_directory=/packages/${current_date}_PACKAGES_${upload_platform_name}
+                       ;;
+               *)
+                       echo "${branch} is not supported."
+                       exit 1
+                       ;;
+       esac
+
+       upload_user=core
+       upload_password=tmaxcore
+       
+       package_name=eventinjector
+       start_path=`pwd`
+       build_path="$set_build_result_path/build_result"
+
+       case ${platform} in
+               windows)
+                       build_result_directory=N.eventinjector_build/win32.${windowing}.${architecture}
+                       ;;
+               *)
+                       build_result_directory=N.eventinjector_build/${platform}.${windowing}.${architecture}
+                       ;;
+       esac
+
+       build_result_path="$build_path/$build_result_directory"
+       builder_path="$start_path/builder"
+       metadata_path=$start_path/builder/metadata
+       config_path=${start_path}/com.samsung.freshide/config.ini
+
+       package_version=`grep "Version" ${builder_path}/metadata/pkginfo.manifest`
+       ide_version=`echo $package_version | cut -f 2 -d":"`
+       sed -e "s;\(^Version:\).*;\1${ide_version};g" < $metadata_path/pkginfo.manifest > $metadata_path/pkginfo.manifest.new
+       mv ${metadata_path}/pkginfo.manifest ${metadata_path}/pkginfo.manifest.bak
+       mv ${metadata_path}/pkginfo.manifest.new ${metadata_path}/pkginfo.manifest
+       
+       package_file=${package_name}_${ide_version}.${BUILD_NUMBER}_${platform}.zip
+       
+       rm -rf $build_path/packaging
+       
+       echo "Create package for install manager..."
+       mkdir -p $build_path/packaging/data
+       cp -rf $build_result_path/eventinjector $build_path/packaging/data/
+       mv $build_path/packaging/data/eventinjector $build_path/packaging/data/NativeIDE
+       cp -rf $metadata_path/* $build_path/packaging
+       cd $build_path/packaging
+       
+       echo "Remove legacy package file..." 
+       rm -f $package_file
+       echo "Archive package for upload to server..."
+       if [ ${platform} = "linux" ]
+       then
+               zip -r $package_file pkginfo.manifest data 
+       elif [ ${platform} = "windows" ]
+       then
+               zip -r $package_file pkginfo.manifest data
+       fi
+
+       echo "Copy to Packaging directory"
+       mv $package_file ${build_path}/
+       echo "Package file's path : ${build_path}"
+       cd -
+       echo "Packaging SUCCESS"
+       
+       cd $build_path
+       echo "Delete legacy package from server...(download legacy package to \"$HOME/${package_name}_*_${platform}.zip\")"
+#      ncftpget -DD -u ${upload_user} -p ${upload_password} ${upload_server} ~/ ${upload_directory}/${package_name}_*_${platform}.zip
+       echo "Upload $package_file to server..."
+#      ncftpput -u ${upload_user} -p ${upload_password} ${upload_server} ${upload_directory} ${package_file}
+       cd -
+       echo "Upload SUCCESS"
+       
+       echo "Packaing and uploading complete."
+       echo "You can find package in \"${build_path}/${package_file}\""
+}
+
+if [ "x$1" = "x" ]
+then
+       echo "Usage : packaging_ide.sh PLATFORM_NAME"
+       exit 1
+fi
+
+platform=$1
+branch=$2
+package
diff --git a/packaging_eventinjector_wac.sh b/packaging_eventinjector_wac.sh
new file mode 100755 (executable)
index 0000000..c78f89d
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/bash
+########################################################################################
+##
+## This script is packaging fresh ide.
+## If you have any question, please send e-mail to taeyoung2.son@samsung.com.
+##
+########################################################################################
+## You must setup parameter 
+set_build_result_path="`pwd`/.."
+
+############################################################################################################
+## Don't touch below!!!! If you want to touch this script, ask to Taeyoung Son(taeyoung2.son@samsung.com)
+############################################################################################################
+package()
+{
+       architecture=x86
+       case ${platform} in
+               linux)
+                       upload_platform_name=LINUX
+                       windowing=gtk
+                       ;;
+               windows)
+                       upload_platform_name=WINDOWS
+                       windowing=win32
+                       ;;
+               *)
+                       echo "${platform} is not support yet."
+                       exit 1
+                       ;;
+       esac
+
+       current_date=`date +%Y%m%d`
+       upload_server=172.21.17.46
+       upload_directory=/packages/${current_date}_PACKAGES_${upload_platform_name}
+       case ${branch} in
+               master)
+                       upload_directory=/packages/PACKAGES_${upload_platform_name}
+                       ;;
+               release)
+                       upload_directory=/packages/${current_date}_PACKAGES_${upload_platform_name}
+                       ;;
+               *)
+                       echo "${branch} is not supported."
+                       exit 1
+                       ;;
+       esac
+
+       upload_user=core
+       upload_password=tmaxcore
+       
+       package_name=eventinjector_wac
+       start_path=`pwd`
+       build_path="$set_build_result_path/build_result"
+
+       case ${platform} in
+               windows)
+                       build_result_directory=N.eventinjector_build/win32.${windowing}.${architecture}
+                       ;;
+               *)
+                       build_result_directory=N.eventinjector_build/${platform}.${windowing}.${architecture}
+                       ;;
+       esac
+
+       build_result_path="$build_path/$build_result_directory"
+       builder_path="$start_path/builder"
+       metadata_path=$start_path/builder/metadata/wac
+       config_path=${start_path}/com.samsung.freshide/config.ini
+
+       package_version=`grep "Version" ${builder_path}/metadata/pkginfo.manifest`
+       ide_version=`echo $package_version | cut -f 2 -d":"`
+       sed -e "s;\(^Version:\).*;\1${ide_version};g" < $metadata_path/pkginfo.manifest > $metadata_path/pkginfo.manifest.new
+       mv ${metadata_path}/pkginfo.manifest ${metadata_path}/pkginfo.manifest.bak
+       mv ${metadata_path}/pkginfo.manifest.new ${metadata_path}/pkginfo.manifest
+       
+       package_file=${package_name}_${ide_version}.${BUILD_NUMBER}_${platform}.zip
+       
+       rm -rf $build_path/packaging
+       
+       echo "Create package for install manager..."
+       mkdir -p $build_path/packaging/data
+       cp -rf $build_result_path/eventinjector $build_path/packaging/data/
+       mv $build_path/packaging/data/eventinjector $build_path/packaging/data/WebIDE
+       cp -rf $metadata_path/* $build_path/packaging
+       cd $build_path/packaging
+       
+       echo "Remove legacy package file..." 
+       rm -f $package_file
+       echo "Archive package for upload to server..."
+       if [ ${platform} = "linux" ]
+       then
+               zip -r $package_file pkginfo.manifest data 
+       elif [ ${platform} = "windows" ]
+       then
+               zip -r $package_file pkginfo.manifest data
+       fi
+
+       echo "Copy to Packaging directory"
+       mv $package_file ${build_path}/
+       echo "Package file's path : ${build_path}"
+       cd -
+       echo "Packaging SUCCESS"
+       
+       cd $build_path
+       echo "Delete legacy package from server...(download legacy package to \"$HOME/${package_name}_*_${platform}.zip\")"
+#      ncftpget -DD -u ${upload_user} -p ${upload_password} ${upload_server} ~/ ${upload_directory}/${package_name}_*_${platform}.zip
+       echo "Upload $package_file to server..."
+#      ncftpput -u ${upload_user} -p ${upload_password} ${upload_server} ${upload_directory} ${package_file}
+       cd -
+       echo "Upload SUCCESS"
+       
+       echo "Packaing and uploading complete."
+       echo "You can find package in \"${build_path}/${package_file}\""
+}
+
+if [ "x$1" = "x" ]
+then
+       echo "Usage : packaging_ide.sh PLATFORM_NAME"
+       exit 1
+fi
+
+platform=$1
+branch=$2
+package