Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:36 +0000 (00:48 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:48:36 +0000 (00:48 +0900)
117 files changed:
AUTHORS [new file with mode: 0644]
LICENSE [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
TC/_export_env.sh [new file with mode: 0644]
TC/_export_target_env.sh [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/excute.sh [new file with mode: 0755]
TC/making_new_tet_scen.py [new file with mode: 0755]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/unit/Makefile [new file with mode: 0644]
TC/unit/stc_gps_nmea.c [new file with mode: 0644]
TC/unit/stc_gps_position.c [new file with mode: 0644]
TC/unit/stc_gps_satellite.c [new file with mode: 0644]
TC/unit/stc_gps_velocity.c [new file with mode: 0644]
TC/unit/stc_gps_zone.c [new file with mode: 0644]
TC/unit/tslist [new file with mode: 0644]
TC/unit/utc_location_free.c [new file with mode: 0644]
TC/unit/utc_location_get_address.c [new file with mode: 0644]
TC/unit/utc_location_get_address_from_position.c [new file with mode: 0644]
TC/unit/utc_location_get_position.c [new file with mode: 0644]
TC/unit/utc_location_get_position_from_address.c [new file with mode: 0644]
TC/unit/utc_location_get_position_from_freeformed_address.c [new file with mode: 0644]
TC/unit/utc_location_get_velocity.c [new file with mode: 0644]
TC/unit/utc_location_init.c [new file with mode: 0644]
TC/unit/utc_location_new.c [new file with mode: 0644]
TC/unit/utc_location_start.c [new file with mode: 0644]
TC/unit/utc_location_stop.c [new file with mode: 0644]
TC/unit/utc_properties_boundary.c [new file with mode: 0644]
TC/unit/utc_properties_last_position.c [new file with mode: 0644]
TC/unit/utc_properties_method.c [new file with mode: 0644]
TC/unit/utc_signals_service_disabled.c [new file with mode: 0644]
TC/unit/utc_signals_service_enabled.c [new file with mode: 0644]
TC/unit/utc_signals_service_updated.c [new file with mode: 0644]
TC/unit/utc_signals_zone_in.c [new file with mode: 0644]
TC/unit/utc_signals_zone_out.c [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/libslp-location-dev.install [new file with mode: 0644]
debian/libslp-location.install [new file with mode: 0644]
debian/libslp-location.postinst [new file with mode: 0755]
debian/rules [new file with mode: 0755]
image/SLP_Location_PG.h [new file with mode: 0755]
image/location_image001.png [new file with mode: 0644]
image/location_image002.png [new file with mode: 0644]
location.pc.in [new file with mode: 0644]
location/Makefile.am [new file with mode: 0644]
location/location-accuracy.c [new file with mode: 0644]
location/location-accuracy.h [new file with mode: 0644]
location/location-address.c [new file with mode: 0644]
location/location-address.h [new file with mode: 0644]
location/location-boundary.c [new file with mode: 0644]
location/location-boundary.h [new file with mode: 0644]
location/location-common-util.c [new file with mode: 0644]
location/location-common-util.h [new file with mode: 0644]
location/location-cps.c [new file with mode: 0644]
location/location-cps.h [new file with mode: 0644]
location/location-geocode.c [new file with mode: 0644]
location/location-geocode.h [new file with mode: 0644]
location/location-gps.c [new file with mode: 0644]
location/location-gps.h [new file with mode: 0644]
location/location-hybrid.c [new file with mode: 0644]
location/location-hybrid.h [new file with mode: 0644]
location/location-ielement.c [new file with mode: 0644]
location/location-ielement.h [new file with mode: 0644]
location/location-ips.c [new file with mode: 0644]
location/location-ips.h [new file with mode: 0644]
location/location-log.h [new file with mode: 0644]
location/location-marshal.list [new file with mode: 0644]
location/location-module-internal.c [new file with mode: 0644]
location/location-module-internal.h [new file with mode: 0644]
location/location-module.h [new file with mode: 0644]
location/location-poi-info.c [new file with mode: 0644]
location/location-poi-info.h [new file with mode: 0644]
location/location-poi.c [new file with mode: 0644]
location/location-poi.h [new file with mode: 0644]
location/location-position.c [new file with mode: 0644]
location/location-position.h [new file with mode: 0644]
location/location-satellite.c [new file with mode: 0644]
location/location-satellite.h [new file with mode: 0644]
location/location-setting.c [new file with mode: 0644]
location/location-setting.h [new file with mode: 0644]
location/location-signaling-util.c [new file with mode: 0644]
location/location-signaling-util.h [new file with mode: 0644]
location/location-sps.c [new file with mode: 0644]
location/location-sps.h [new file with mode: 0644]
location/location-types.h [new file with mode: 0644]
location/location-velocity.c [new file with mode: 0644]
location/location-velocity.h [new file with mode: 0644]
location/location-wps.c [new file with mode: 0644]
location/location-wps.h [new file with mode: 0644]
location/location.c [new file with mode: 0644]
location/location.h [new file with mode: 0644]
packaging/libslp-location.spec [new file with mode: 0644]
tests/Makefile.am [new file with mode: 0644]
tests/address-sample.c [new file with mode: 0644]
tests/cps-test.c [new file with mode: 0644]
tests/gps-test.c [new file with mode: 0644]
tests/hybrid-test.c [new file with mode: 0644]
tests/ips-test.c [new file with mode: 0644]
tests/location-api-test-util.c [new file with mode: 0644]
tests/location-api-test-util.h [new file with mode: 0644]
tests/location-api-test.c [new file with mode: 0644]
tests/location-api-test.json [new file with mode: 0644]
tests/nmea-sample.c [new file with mode: 0644]
tests/position-sample-gps.c [new file with mode: 0644]
tests/property-sample.c [new file with mode: 0644]
tests/satellite-sample.c [new file with mode: 0644]
tests/sps-test.c [new file with mode: 0644]
tests/velocity-sample.c [new file with mode: 0644]
tests/wps-test.c [new file with mode: 0644]
tests/zone-sample.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..a4570bb
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Youngae Kang <youngae.kang@samsung.com>
+Yunhan Kim <yhan.kim@samsung.com>
+Minjune Kim <sena06.kim@samsung.com>
+Genie Kim <daejins.kim@samsung.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+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
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..847e20c
--- /dev/null
@@ -0,0 +1,6 @@
+ACLOCAL_AMFLAGS=-I m4
+
+SUBDIRS=location tests
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = location.pc
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100644 (file)
index 0000000..7a7b2ae
--- /dev/null
@@ -0,0 +1,14 @@
+export ARCH=target
+
+export TET_INSTALL_PATH=~/opensrc/tet3.7  # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH  # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100644 (file)
index 0000000..323bb38
--- /dev/null
@@ -0,0 +1,14 @@
+export ARCH=target
+
+export TET_INSTALL_PATH=/opt/home/root/TETware  # path to mount
+export TET_TARGET_PATH=$TET_INSTALL_PATH
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..b6c54b9
--- /dev/null
@@ -0,0 +1,17 @@
+. ./_export_env.sh                              # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+tcc -b -j $JOURNAL_RESULT -p ./            # executing tcc to build test cases (-b)
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT  # reporting the result
diff --git a/TC/excute.sh b/TC/excute.sh
new file mode 100755 (executable)
index 0000000..2c6167e
--- /dev/null
@@ -0,0 +1,16 @@
+. ./_export_target_env.sh                    # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./             # executing tcc, with â€“e option
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py
new file mode 100755 (executable)
index 0000000..6c5b845
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+#############################################
+# tet_scen  auto generator
+#
+# ** argv[1] = TC root
+#############################################
+
+import sys,string,os
+
+
+write_file = open("tet_scen", 'w')
+
+#
+# making new tet_scen
+#
+def making_tet_scen (filename):
+       #tmp_list = filename.strip().split('/')
+       n_filename = filename.replace(' ', '\\ ')
+       #print n_filename
+       #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6]
+       new_path = "/"+n_filename[:-6]
+       #print new_path
+       file = open(filename, 'r')
+       lines = file.readlines()
+       for line in lines:
+               if len(line.strip()) > 1:
+                       list = line.strip().split('/')
+                       #print new_path + list[-1]
+                       write_file.write("\t"+new_path+list[-1]+"\n")
+
+#
+# usage()
+#
+def usage():
+       print(" ")
+       print("./making_new_tet_scen.py tc_root")
+       print("Put the Test Case's root directory.")
+       print("Do not include '/' at the end")
+       print(" ")
+
+#
+# main()
+#
+def main():
+       if len(sys.argv) < 2:
+               usage()
+               sys.exit(0)
+               
+       os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt')
+       
+       #write_file = open("tetscen", w)
+       write_file.write("# auto generated tet_scen\n")
+       write_file.write("all\n")
+       write_file.write("\t\"Starting Full Test Suite\"\n")
+       
+       for file in open("tslist.txt", 'r'):
+               #print file.strip()
+               making_tet_scen(file.strip())
+                       
+       write_file.write("\t\"Completed Full Test Suite\"\n")
+       write_file.write("# EOF\n")
+       write_file.close()
+       print(" ")
+       print("==============================")
+       print("New tet_scen file is made~~~~")
+       print("==============================")
+       print(" ")
+main()
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100644 (file)
index 0000000..305a021
--- /dev/null
@@ -0,0 +1,29 @@
+# auto generated tet_scen
+all
+       "Starting Full Test Suite"
+       /unit/utc_location_init
+    /unit/utc_location_new
+    /unit/utc_location_free
+    /unit/utc_location_start
+    /unit/utc_location_stop
+       /unit/utc_location_get_position
+    /unit/utc_location_get_velocity
+       /unit/utc_location_get_address
+    /unit/utc_location_get_address_from_position
+    /unit/utc_location_get_position_from_address
+    /unit/utc_location_get_position_from_freeformed_address
+    /unit/utc_signals_service_disabled
+    /unit/utc_signals_service_enabled
+    /unit/utc_signals_service_updated
+    /unit/utc_signals_zone_in
+       /unit/utc_signals_zone_out
+    /unit/utc_properties_method
+    /unit/utc_properties_boundary
+    /unit/utc_properties_last_position
+    /unit/stc_gps_position
+    /unit/stc_gps_velocity
+    /unit/stc_gps_satellite
+       /unit/stc_gps_nmea
+    /unit/stc_gps_zone
+       "Completed Full Test Suite"
+# EOF
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..f7eda55
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..02d7030
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..ef3e452
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/TC/unit/Makefile b/TC/unit/Makefile
new file mode 100644 (file)
index 0000000..58743b6
--- /dev/null
@@ -0,0 +1,56 @@
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TC1 = stc_gps_position
+TC2 = stc_gps_velocity 
+TC3 = stc_gps_satellite 
+TC4 = stc_gps_nmea 
+TC5 = stc_gps_zone  
+TC6 = utc_location_init
+TC7 = utc_location_new
+TC8 = utc_location_start 
+TC9 = utc_location_stop 
+TC10 = utc_location_free 
+TC11 = utc_location_get_position 
+TC12 = utc_location_get_velocity         
+TC13 = utc_properties_last_position 
+TC14 = utc_properties_method 
+TC16 = utc_properties_boundary 
+TC17 = utc_signals_service_disabled 
+TC18 = utc_signals_service_enabled 
+TC19 = utc_signals_service_updated 
+TC20 = utc_signals_zone_in
+TC21 = utc_signals_zone_out
+TC22 = utc_location_get_address
+TC23 = utc_location_get_address_from_position
+TC24 = utc_location_get_position_from_address
+TC25 = utc_location_get_position_from_freeformed_address
+
+#
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS= location gconf-2.0
+
+LDLIBS = `pkg-config --libs $(PKGS)` 
+LDLIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
+LDLIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDLIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CC = gcc
+INCS  =  -I. `pkg-config --cflags $(PKGS)`
+INCS  += -I$(TET_ROOT)/inc/tet3 
+CFLAGS = $(INCS)
+CFLAGS += -Wall -D_TETWARE_MODE
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# 
+TCLIST = $(TC1) $(TC2) $(TC3) $(TC4) $(TC5) $(TC6) $(TC7) $(TC8) $(TC9) $(TC10) $(TC11) $(TC12) $(TC13) $(TC14) $(TC16) $(TC17) $(TC18) $(TC19) $(TC20) $(TC21) $(TC22) $(TC23) $(TC24) $(TC25)
diff --git a/TC/unit/stc_gps_nmea.c b/TC/unit/stc_gps_nmea.c
new file mode 100644 (file)
index 0000000..1b0578e
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+static void utc_location_new();
+static void utc_location_start();
+static void utc_get_method();
+static void utc_get_devname();
+static void utc_location_get_nmea();
+static void utc_location_svc_disabled();
+static void utc_location_free();
+
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {utc_location_new,1},
+       {utc_location_start,1},
+       {utc_get_method,1},
+       {utc_get_devname,1},
+       {utc_location_get_nmea,1},
+       {utc_location_svc_disabled,1},
+       {utc_location_free,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_new()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if (loc) tet_result(TET_PASS);
+       else  tet_result(TET_FAIL);
+}
+
+static void
+utc_location_start()
+{
+       ret = location_start(loc);
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+       if (LOCATION_METHOD_HYBRID <= method && method<= LOCATION_METHOD_WPS)  tet_result(TET_PASS);
+       else tet_result(TET_FAIL);      
+}
+
+static void
+utc_get_devname()
+{
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if(devname){
+               tet_result(TET_PASS);
+               g_free(devname);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+_get_nmea (GObject *self,
+       guint _status,
+       gpointer userdata)
+{
+       char* nmea_data;
+       g_object_get(loc, "nmea", &nmea_data, NULL);
+       if (nmea_data) {
+               tet_result(TET_PASS);
+               g_free(nmea_data);
+       } else tet_result(TET_FAIL);    
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_nmea()
+{
+       loop = g_main_loop_new (NULL, TRUE);    
+       g_signal_connect (loc, "service-updated", G_CALLBACK(_get_nmea), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+_cb_disabled (GObject *self,
+       guint _status,
+       gpointer userdata)
+{
+       if( LOCATION_STATUS_NO_FIX <= _status && _status <= LOCATION_STATUS_3D_FIX)     tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+gboolean
+_stop_location()
+{
+       location_stop(loc);
+       return FALSE;
+}
+
+static void
+utc_location_svc_disabled()
+{
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(_cb_disabled), loc);
+       g_timeout_add_seconds(1, _stop_location, NULL); 
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+
+}
+
+static void
+utc_location_free()
+{
+       ret = location_free(loc);
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/stc_gps_position.c b/TC/unit/stc_gps_position.c
new file mode 100644 (file)
index 0000000..bb91dfe
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+static void utc_location_new();
+static void utc_location_start();
+static void utc_get_method();
+static void utc_get_devname();
+static void utc_location_get_position();
+static void utc_location_svc_updated();
+static void utc_location_stop();
+static void utc_get_lastpostion();
+static void utc_location_free();
+
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {utc_location_new,1},
+       {utc_location_start,1},
+       {utc_get_method,1},
+       {utc_get_devname,1},
+       {utc_location_get_position,1},
+       {utc_location_svc_updated,1},
+       {utc_location_stop,1},
+       {utc_get_lastpostion,1},
+       {utc_location_free,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+
+static void startup()
+{      
+       tet_printf("\n TC startup");    
+       loop = g_main_loop_new (NULL, TRUE);    
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_new()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if (loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_start()
+{
+       ret = location_start(loc);      
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+
+       if(LOCATION_METHOD_HYBRID <= method && method<= LOCATION_METHOD_WPS) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_devname()
+{
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+
+       if (devname) {
+               tet_result(TET_PASS);
+               g_free(devname);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_lastpostion()
+{
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL); 
+
+       if (pos) {
+               tet_result(TET_PASS);
+               location_position_free (pos);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+_get_position (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationObject *loc = (LocationObject*)userdata;        
+
+       ret = location_get_position (loc, &pos, &acc);
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_position()
+{
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_position), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_stop()
+{
+       ret = location_stop(loc);
+       
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+_cb_updated (GObject *self,
+                    guint type,
+                    gpointer data,
+                    gpointer accuracy,
+                    gpointer userdata)
+{
+       if ( POSITION_UPDATED <= type && type <= REVERSEGEOCODE_UPDATED) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_svc_updated()
+{
+       g_signal_connect (loc, "service-updated", G_CALLBACK(_cb_updated), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_free()
+{
+       ret = location_free(loc);
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/stc_gps_satellite.c b/TC/unit/stc_gps_satellite.c
new file mode 100644 (file)
index 0000000..86c6240
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+static void utc_location_new();
+static void utc_location_start();
+static void utc_get_method();
+static void utc_get_devname();
+static void utc_location_get_satellite();
+static void utc_location_svc_disabled();
+static void utc_location_free();
+
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {utc_location_new,1},
+       {utc_location_start,1},
+       {utc_get_method,1},
+       {utc_get_devname,1},
+       {utc_location_get_satellite,1},
+       {utc_location_svc_disabled,1},
+       {utc_location_free,1},
+       {NULL,0},
+};     
+
+
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_new()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if(loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_start()
+{
+       ret = location_start(loc);      
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+       if (LOCATION_METHOD_HYBRID <= method && method<= LOCATION_METHOD_WPS) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_devname()
+{
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if (devname) {
+               tet_result(TET_PASS);
+               g_free(devname);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+_get_satellite (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       LocationSatellite *sat = NULL;
+       g_object_get (loc, "satellite", &sat, NULL);
+       if (sat) {
+               tet_result(TET_PASS);
+               location_satellite_free (sat);
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_satellite()
+{
+       loop = g_main_loop_new (NULL, TRUE);    
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_satellite), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+_cb_disabled (GObject *self,
+                               guint _status,
+                               gpointer userdata)
+{
+       if( LOCATION_STATUS_NO_FIX <= _status && _status <= LOCATION_STATUS_3D_FIX) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+gboolean
+_stop_location()
+{
+       location_stop(loc);
+       return FALSE;
+}
+
+static void
+utc_location_svc_disabled()
+{
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(_cb_disabled), loc);
+       g_timeout_add_seconds(1, _stop_location, NULL); 
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop);
+}
+
+static void
+utc_location_free()
+{
+       ret = location_free(loc);
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/stc_gps_velocity.c b/TC/unit/stc_gps_velocity.c
new file mode 100644 (file)
index 0000000..0f175d9
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+static void utc_location_new();
+static void utc_location_start();
+static void utc_get_method();
+static void utc_get_devname();
+static void utc_location_get_velocity();
+static void utc_location_stop();
+static void utc_location_svc_updated();
+static void utc_location_free();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {utc_location_new,1},
+       {utc_location_start,1},
+       {utc_get_method,1},
+       {utc_get_devname,1},
+       {utc_location_get_velocity,1},
+       {utc_location_svc_updated,1},
+       {utc_location_stop,1},  
+       {utc_location_free,1},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_new()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if (loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_start()
+{
+       ret = location_start(loc);
+       
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+
+       if (LOCATION_METHOD_HYBRID <= method && method<= LOCATION_METHOD_WPS) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_devname()
+{
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+
+       if(devname){
+               tet_result(TET_PASS);
+               g_free(devname);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+_get_velocity (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       LocationVelocity *vel = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationObject *loc = (LocationObject*)userdata;        
+
+       ret = location_get_velocity (loc, &vel, &acc);
+       if (ret == LOCATION_ERROR_NONE) {
+               location_velocity_free (vel);
+               location_accuracy_free (acc);
+               tet_result(TET_PASS);
+       }
+       else tet_result(TET_FAIL);      
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_velocity()
+{
+       loop = g_main_loop_new (NULL, TRUE);
+       
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_velocity), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_stop()
+{
+       ret = location_stop(loc);
+       
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+_cb_updated (GObject *self,
+                    guint type,
+                    gpointer data,
+                    gpointer accuracy,
+                    gpointer userdata)
+{
+       if ( POSITION_UPDATED <= type && type <= REVERSEGEOCODE_UPDATED) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_svc_updated()
+{
+       g_signal_connect (loc, "service-updated", G_CALLBACK(_cb_updated), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_free()
+{
+       ret = location_free(loc);
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/stc_gps_zone.c b/TC/unit/stc_gps_zone.c
new file mode 100644 (file)
index 0000000..3cfbb85
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+static void utc_location_new();
+static void utc_location_start();
+static void utc_get_method();
+static void utc_get_devname();
+static void utc_location_svc_enabled();
+static void utc_set_boundary_in_suwonHQ();
+static void utc_get_boundary_in_suwonHQ();
+static void utc_zone_in();
+static void utc_set_boundary_in_Santorini();
+static void utc_get_boundary_in_Santorini();
+static void utc_zone_out();
+static void utc_location_stop();
+static void utc_location_free();
+
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {utc_location_new,1},
+       {utc_location_start,1},
+       {utc_get_method,1},
+       {utc_get_devname,1},
+       {utc_location_svc_enabled,1},
+       {utc_set_boundary_in_suwonHQ,1},
+       {utc_get_boundary_in_suwonHQ,1},
+       {utc_zone_in,1},
+       {utc_set_boundary_in_Santorini,1},
+       {utc_get_boundary_in_Santorini,1},
+       {utc_zone_out,1},
+       {utc_location_stop,1},
+       {utc_location_free,1},
+       {NULL,0},
+};     
+
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       tet_printf("\n TC startup");
+       loop = g_main_loop_new (NULL, TRUE);    
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_new()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if(loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_start()
+{
+       ret = location_start(loc);
+       
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+
+       if(LOCATION_METHOD_HYBRID <= method && method<= LOCATION_METHOD_WPS) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_devname()
+{
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+
+       if(devname){
+               tet_result(TET_PASS);
+               g_free(devname);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+_cb_svc_enabled (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       if(LOCATION_STATUS_NO_FIX <= _status && _status <= LOCATION_STATUS_3D_FIX) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit(loop);
+}
+
+
+static void
+utc_location_svc_enabled()
+{
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_cb_svc_enabled), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_set_boundary_in_suwonHQ()
+{
+       LocationPosition *rb = location_position_new(0, 37.253, 127.058, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.261, 127.052, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary *bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       g_object_set(loc, "boundary", bound, NULL);     
+       if (loc) {              
+               tet_result(TET_PASS);
+               location_boundary_free (bound);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_boundary_in_suwonHQ()
+{
+       LocationBoundary* bound = NULL; 
+       
+       g_object_get(loc, "boundary", &bound, NULL);
+       if ( bound && 
+               bound->type ==LOCATION_BOUNDARY_RECT &&
+               bound->rect.right_bottom->latitude == 37.253 &&
+               bound->rect.right_bottom->longitude == 127.058 &&
+               bound->rect.left_top->latitude == 37.261 &&
+               bound->rect.left_top->longitude == 127.052 ){           
+               tet_result(TET_PASS);
+               location_boundary_free (bound);
+       }
+       else
+               tet_result(TET_FAIL);
+}
+
+static void
+_cb_zone_in(LocationObject *self,
+            guint type,
+            gpointer position,
+            gpointer accuracy)
+{
+       LocationPosition *pos = (LocationPosition*) position;
+       if( (37.253 <= pos->latitude && pos->latitude <= 37.261) &&
+               (127.052 <= pos->longitude && pos->longitude <= 127.058) ) {
+               tet_result(TET_PASS);   // I am in Suwon HQ
+       } else tet_result(TET_FAIL);
+
+       g_main_loop_quit(loop);
+}
+
+static void
+utc_zone_in()
+{
+       g_signal_connect (loc, "zone-in", G_CALLBACK(_cb_zone_in), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_set_boundary_in_Santorini()
+{
+       LocationPosition *rb = location_position_new(0, 36.395, 25.41, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 36.413, 25.388, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       g_object_set(loc, "boundary", bound, NULL);             
+
+       if (loc) {
+               tet_result(TET_PASS);
+               location_boundary_free (bound);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_boundary_in_Santorini()
+{
+       LocationBoundary* bound = NULL; 
+       g_object_get(loc, "boundary", &bound, NULL);
+
+       if ( bound && 
+               bound->type ==LOCATION_BOUNDARY_RECT &&
+               bound->rect.right_bottom->latitude == 36.395 &&
+               bound->rect.right_bottom->longitude == 25.41 &&
+               bound->rect.left_top->latitude == 36.413 &&
+               bound->rect.left_top->longitude == 25.388 ){
+               tet_result(TET_PASS);
+               location_boundary_free (bound);
+       } else tet_result(TET_FAIL);            
+               
+}
+
+static void
+_cb_zone_out(LocationObject *self,
+            guint type,
+            gpointer position,
+            gpointer accuracy)
+{
+       LocationPosition *pos = (LocationPosition*) position;
+
+       if( (37.253 <= pos->latitude && pos->latitude <= 37.261) &&
+               (27.052 <= pos->longitude && pos->longitude <= 127.058) ) {
+               tet_result(TET_PASS);   // I am in Suwon HQ
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit(loop);
+}
+
+
+static void
+utc_zone_out()
+{
+       g_signal_connect (loc, "zone-out", G_CALLBACK(_cb_zone_out), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_stop()
+{
+       ret = location_stop(loc);
+       
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_free()
+{
+       ret = location_free(loc);
+       if(ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/tslist b/TC/unit/tslist
new file mode 100644 (file)
index 0000000..7d73612
--- /dev/null
@@ -0,0 +1,24 @@
+stc_gps_nmea
+stc_gps_position
+stc_gps_satellite
+stc_gps_velocity
+stc_gps_zone
+utc_location_free
+utc_location_get_address
+utc_location_get_address_from_position
+utc_location_get_position_from_address
+utc_location_get_position_from_freeformed_address
+utc_location_get_position
+utc_location_get_velocity
+utc_location_init
+utc_location_new
+utc_location_start
+utc_location_stop
+utc_properties_boundary
+utc_properties_last_position
+utc_properties_method
+utc_signals_service_disabled
+utc_signals_service_enabled
+utc_signals_service_updated
+utc_signals_zone_in
+utc_signals_zone_out
diff --git a/TC/unit/utc_location_free.c b/TC/unit/utc_location_free.c
new file mode 100644 (file)
index 0000000..e107106
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_free_01();
+static void utc_location_free_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_free_01,1},
+       {utc_location_free_02,2},
+       {NULL,0},
+};
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{      
+       ret = location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{              
+       if(loc)
+               location_free(loc);
+       
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_free_01()
+{
+       ret = location_free(loc);
+
+       tet_printf("Returned value: %d", ret);  
+       if(ret == LOCATION_ERROR_NONE){
+               tet_result(TET_PASS);
+               loc = NULL;
+       }
+       else{
+               tet_result(TET_FAIL);
+       }
+}
+
+static void
+utc_location_free_02()
+{
+       ret = location_free(NULL);
+
+       tet_printf("Returned value: %d", ret);
+       if(ret == LOCATION_ERROR_PARAMETER){
+               tet_result(TET_PASS);
+       }
+       else{
+               tet_result(TET_FAIL);
+       }
+}
+
diff --git a/TC/unit/utc_location_get_address.c b/TC/unit/utc_location_get_address.c
new file mode 100644 (file)
index 0000000..3561da4
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_address_01();
+static void utc_location_get_address_02();
+static void utc_location_get_address_03();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_address_01,1},
+       {utc_location_get_address_02,2},
+       {utc_location_get_address_03,3},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+LocationObject* loc = NULL;
+int ret = LOCATION_ERROR_NONE;
+int isNetStarted = 0;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       return FALSE;
+}
+
+static gboolean
+exit_loop_fail (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+
+       loop = g_main_loop_new(NULL,FALSE);
+       g_main_loop_run (loop);
+       
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+_get_address (GObject *self,
+       guint _status,
+       gpointer userdata)
+{
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+
+       ret = location_get_address(loc, &addr, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_NONE ||
+               ret == LOCATION_ERROR_CONFIGURATION) {
+               location_address_free(addr);
+               location_accuracy_free(acc);
+               tet_result(TET_PASS);
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_address_01()
+{              
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_address), loc);
+       location_start(loc);
+       g_timeout_add_seconds(60, exit_loop_fail, NULL);
+       g_main_loop_run (loop); 
+}
+
+       static void
+utc_location_get_address_02()
+{
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+
+       ret = location_get_address(NULL, &addr, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+       static void
+utc_location_get_address_03()
+{
+       LocationAccuracy *acc = NULL;
+       ret = location_get_address(loc, NULL, &acc);
+       tet_printf("Returned value: %d", ret);
+       if(ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_get_address_from_position.c b/TC/unit/utc_location_get_address_from_position.c
new file mode 100644 (file)
index 0000000..fc52ece
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_address_from_position_01();
+static void utc_location_get_address_from_position_02();
+static void utc_location_get_address_from_position_03();
+static void utc_location_get_address_from_position_04();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_address_from_position_01,1},
+       {utc_location_get_address_from_position_02,2},
+       {utc_location_get_address_from_position_03,3},
+       {utc_location_get_address_from_position_04,4},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+LocationObject* loc;
+int ret;
+int isNetStarted = 0;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+
+       loop = g_main_loop_new(NULL,FALSE);             
+       g_main_loop_run (loop);
+
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_get_address_from_position_01()
+{      
+       LocationPosition *pos = location_position_new(0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+       ret = location_get_address_from_position(loc, pos, &addr, &acc);
+       location_position_free(pos);
+       tet_printf("Returned value: %d", ret);  
+       if (ret == LOCATION_ERROR_NONE ||
+               ret == LOCATION_ERROR_CONFIGURATION) {
+               location_address_free(addr);
+               location_accuracy_free(acc);
+               tet_result(TET_PASS);           
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_address_from_position_02()
+{
+       LocationPosition *pos = location_position_new(0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+       
+       ret = location_get_address_from_position(NULL, pos, &addr, &acc);
+       location_position_free(pos);
+       location_address_free(addr);
+       location_accuracy_free(acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+       static void
+utc_location_get_address_from_position_03()
+{
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+       ret = location_get_address_from_position(loc, NULL, &addr, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+       static void
+utc_location_get_address_from_position_04()
+{
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = location_position_new(0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+
+       ret = location_get_address_from_position(loc, pos, NULL, &acc);
+       location_position_free(pos);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_get_position.c b/TC/unit/utc_location_get_position.c
new file mode 100644 (file)
index 0000000..3590fff
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_position_01();
+static void utc_location_get_position_02();
+static void utc_location_get_position_03();
+static void utc_location_get_position_04();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_position_01,1},
+       {utc_location_get_position_02,2},
+       {utc_location_get_position_03,3},
+       {utc_location_get_position_04,4},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);    
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+_get_position (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationObject *loc = (LocationObject*)userdata;        
+
+       ret = location_get_position (loc, &pos, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_NONE) {
+               location_position_free (pos);
+               location_accuracy_free (acc);
+               tet_result(TET_PASS);
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_position_01()
+{      
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_position), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+static void
+utc_location_get_position_02()
+{
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+
+       ret = location_get_position (NULL, &pos, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_03()
+{
+       LocationAccuracy *acc = NULL;
+       ret = location_get_position (loc, NULL, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_04()
+{
+       LocationPosition *pos = NULL;
+       ret = location_get_position (loc, &pos, NULL);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_get_position_from_address.c b/TC/unit/utc_location_get_position_from_address.c
new file mode 100644 (file)
index 0000000..558a7e3
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_position_from_address_01();
+static void utc_location_get_position_from_address_02();
+static void utc_location_get_position_from_address_03();
+static void utc_location_get_position_from_address_04();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_position_from_address_01,1},
+       {utc_location_get_position_from_address_02,2},
+       {utc_location_get_position_from_address_03,3},
+       {utc_location_get_position_from_address_04,4},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+LocationObject* loc;
+int ret;
+int isNetStarted = 0;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+
+       loop = g_main_loop_new(NULL,FALSE);             
+       g_main_loop_run (loop);
+
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_get_position_from_address_01()
+{      
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = location_address_new ("1",  "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       ret = location_get_position_from_address (loc, addr, &pos, &acc);
+       location_address_free(addr);
+       tet_printf("Returned value: %d", ret);
+       if( (ret == LOCATION_ERROR_NONE && 
+               37.325276 <= pos->latitude &&  pos->latitude <= 37.345276 &&
+               -121.900059 <= pos->longitude && pos->longitude<= -121.880059) ||
+               ret == LOCATION_ERROR_CONFIGURATION ) {
+               location_position_free(pos);
+               location_accuracy_free(acc);
+               tet_result(TET_PASS);
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_from_address_02()
+{
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = location_address_new ("1",  "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       ret = location_get_position_from_address (NULL, addr, &pos, &acc);
+       location_address_free(addr);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_from_address_03()
+{
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       ret = location_get_position_from_address(loc, NULL, &pos, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_from_address_04()
+{
+       LocationAddress *addr = location_address_new ("1",  "Post Street", NULL, "san jose", "ca", NULL, "95113");;
+       LocationAccuracy *acc = NULL;
+       ret = location_get_position_from_address(loc, addr, NULL, &acc);
+       location_address_free (addr);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_get_position_from_freeformed_address.c b/TC/unit/utc_location_get_position_from_freeformed_address.c
new file mode 100644 (file)
index 0000000..d33b750
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_position_from_freeformed_address_01();
+static void utc_location_get_position_from_freeformed_address_02();
+static void utc_location_get_position_from_freeformed_address_03();
+static void utc_location_get_position_from_freeformed_address_04();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_position_from_freeformed_address_01,1},
+       {utc_location_get_position_from_freeformed_address_02,2},
+       {utc_location_get_position_from_freeformed_address_03,3},
+       {utc_location_get_position_from_freeformed_address_04,4},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+LocationObject* loc;
+int ret;
+int isNetStarted = 0;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+
+       loop = g_main_loop_new(NULL,FALSE);             
+       g_main_loop_run (loop);
+
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_get_position_from_freeformed_address_01()
+{      
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       char* addr_str = g_strdup("4 N 2nd Street 95113");
+       ret = location_get_position_from_freeformed_address(loc, addr_str, &pos, &acc);
+       g_free(addr_str);
+       tet_printf("Returned value: %d", ret);
+       if( (ret == LOCATION_ERROR_NONE && 
+               37.325276 <= pos->latitude &&  pos->latitude <= 37.345276 &&
+               -121.900059 <= pos->longitude && pos->longitude<= -121.880059) ||
+               ret == LOCATION_ERROR_CONFIGURATION ) {
+               location_position_free (pos);
+               location_accuracy_free (acc);
+               tet_result(TET_PASS);
+       }
+       else
+               tet_result(TET_FAIL);
+       
+}
+
+static void
+utc_location_get_position_from_freeformed_address_02()
+{
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       char* addr_str = g_strdup("4 N 2nd Street 95113");
+       ret = location_get_position_from_freeformed_address(NULL, addr_str, &pos, &acc);
+       g_free(addr_str);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_from_freeformed_address_03()
+{
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       ret = location_get_position_from_freeformed_address(loc, NULL, &pos, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_position_from_freeformed_address_04()
+{
+       LocationAccuracy *acc = NULL;
+       char* addr_str = g_strdup("4 N 2nd Street 95113");
+       ret = location_get_position_from_freeformed_address(loc, addr_str, NULL, &acc);
+       g_free (addr_str);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
diff --git a/TC/unit/utc_location_get_velocity.c b/TC/unit/utc_location_get_velocity.c
new file mode 100644 (file)
index 0000000..cd4c803
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_get_velocity_01();
+static void utc_location_get_velocity_02();
+static void utc_location_get_velocity_03();
+static void utc_location_get_velocity_04();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_get_velocity_01,1},
+       {utc_location_get_velocity_02,2},
+       {utc_location_get_velocity_03,3},
+       {utc_location_get_velocity_04,4},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);    
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+
+static void
+_get_velocity (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       LocationVelocity *vel = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationObject *loc = (LocationObject*)userdata;
+       ret = location_get_velocity (loc, &vel, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_NONE) {
+               location_velocity_free (vel);
+               location_accuracy_free (acc);
+               tet_result(TET_PASS);
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_get_velocity_01()
+{
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_velocity), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
+
+
+static void
+utc_location_get_velocity_02()
+{
+       LocationVelocity *vel = NULL;
+       LocationAccuracy *acc = NULL;
+       ret = location_get_velocity (NULL, &vel, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_velocity_03()
+{
+       LocationAccuracy *acc = NULL;
+       ret = location_get_velocity (loc, NULL, &acc);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_get_velocity_04()
+{
+       LocationVelocity *vel = NULL;
+       ret = location_get_velocity (loc, &vel, NULL);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_init.c b/TC/unit/utc_location_init.c
new file mode 100644 (file)
index 0000000..a0efe5a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_init();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_init,1},
+       {NULL,0},
+};     
+
+int ret;
+
+static void startup()
+{      
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       tet_printf("\n TC End");                
+}
+
+static void
+utc_location_init()
+{
+       ret = location_init();
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_location_new.c b/TC/unit/utc_location_new.c
new file mode 100644 (file)
index 0000000..ee33c6b
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_new_01();
+static void utc_location_new_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_new_01,1},
+       {utc_location_new_02,1},
+       {NULL,0},
+};     
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{              
+       ret = location_init();  
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       if (loc) location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_new_01()
+{
+       loc = location_new(LOCATION_METHOD_GPS);
+       if (loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       location_free(loc);
+}
+
+static void
+utc_location_new_02()
+{
+       loc = location_new(-1);
+       if (!loc) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
diff --git a/TC/unit/utc_location_start.c b/TC/unit/utc_location_start.c
new file mode 100644 (file)
index 0000000..a4bf54c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_start_01();
+static void utc_location_start_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_start_01,1},
+       {utc_location_start_02,2},
+       {NULL,0},
+};     
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{              
+       ret = location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{              
+       if( loc )
+               location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_start_01()
+{
+       ret = location_start(loc);
+
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       location_stop(loc);
+}
+
+static void
+utc_location_start_02()
+{
+       ret = location_start(NULL);
+
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
diff --git a/TC/unit/utc_location_stop.c b/TC/unit/utc_location_stop.c
new file mode 100644 (file)
index 0000000..d879480
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_stop_01();
+static void utc_location_stop_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_stop_01,1},
+       {utc_location_stop_02,2},
+       {NULL,0},
+};
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{              
+       ret = location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       ret = location_start(loc);      
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       if( loc ){
+               location_stop(loc);
+               location_free(loc);
+       }
+       tet_printf("\n TC End");
+}
+
+static void
+utc_location_stop_01()
+{
+       ret = location_stop(loc);
+
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_NONE) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
+static void
+utc_location_stop_02()
+{
+       location_start(loc);
+       ret = location_stop(NULL);
+       tet_printf("Returned value: %d", ret);
+       if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
+
diff --git a/TC/unit/utc_properties_boundary.c b/TC/unit/utc_properties_boundary.c
new file mode 100644 (file)
index 0000000..8cc0845
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_set_boundary_in_suwonHQ();
+static void utc_get_boundary_in_suwonHQ();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_set_boundary_in_suwonHQ,1},
+       {utc_get_boundary_in_suwonHQ,2},
+       {NULL,0},
+};     
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+utc_set_boundary_in_suwonHQ()
+{
+       LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
+       g_object_set(loc, "boundary", bound, NULL);
+       location_position_free (rb);
+       location_position_free (lt);
+       location_boundary_free(bound);
+       if (loc) {
+               tet_result(TET_PASS);           
+       } else tet_result(TET_FAIL);
+}
+
+static void
+utc_get_boundary_in_suwonHQ()
+{
+       LocationBoundary* bound = NULL; 
+       g_object_get(loc, "boundary", &bound, NULL);
+       if ( bound && 
+               bound->type == LOCATION_BOUNDARY_RECT &&
+               bound->rect.right_bottom->latitude == 37.258 &&
+               bound->rect.right_bottom->longitude == 127.056 &&
+               bound->rect.left_top->latitude == 37.260 &&
+               bound->rect.left_top->longitude == 127.054 ){           
+               tet_result(TET_PASS);
+               location_boundary_free (bound);
+       } else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_properties_last_position.c b/TC/unit/utc_properties_last_position.c
new file mode 100644 (file)
index 0000000..03c08cf
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_get_lastpostion();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_get_lastpostion,1},
+       {NULL,0},
+};     
+
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+static gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+cb_updated (GObject *self,
+                    guint type,
+                    gpointer data,
+                    gpointer accuracy,
+                    gpointer userdata)
+{
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               location_position_free (pos);
+               tet_result(TET_PASS);           
+       } else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_get_lastpostion()
+{
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_updated), loc); 
+       g_timeout_add_seconds (60, exit_loop, NULL);
+       g_main_loop_run (loop);
+}
diff --git a/TC/unit/utc_properties_method.c b/TC/unit/utc_properties_method.c
new file mode 100644 (file)
index 0000000..bdb3430
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_get_method();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_get_method,1},
+       {NULL,0},
+};     
+
+int ret;
+LocationObject* loc;
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);        
+       tet_printf("\n TC startup");    
+}
+
+static void cleanup()
+{              
+       location_free(loc);     
+       tet_printf("\n TC End");
+}
+
+static void
+utc_get_method()
+{
+       LocationMethod method;  
+       g_object_get(loc, "method", &method, NULL);
+       if (method == LOCATION_METHOD_GPS) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_signals_service_disabled.c b/TC/unit/utc_signals_service_disabled.c
new file mode 100644 (file)
index 0000000..e8a44b1
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_svc_disabled();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_svc_disabled,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+cb_enabled (GObject *self,
+                               guint _status,
+                               gpointer userdata)
+{
+       location_stop(loc);
+}
+
+static void
+cb_disabled (GObject *self,
+                               guint _status,
+                               gpointer userdata)
+{
+       if( LOCATION_STATUS_NO_FIX <= _status && _status <= LOCATION_STATUS_3D_FIX) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_svc_disabled()
+{
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_disabled), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+
+}
diff --git a/TC/unit/utc_signals_service_enabled.c b/TC/unit/utc_signals_service_enabled.c
new file mode 100644 (file)
index 0000000..02cea2a
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_svc_enabled();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_svc_enabled,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+_cb_svc_enabled (GObject *self,
+                               guint _status,
+                    gpointer userdata)
+{
+       if (LOCATION_STATUS_NO_FIX  <= _status && _status <= LOCATION_STATUS_3D_FIX) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit(loop);
+}
+
+static void
+utc_location_svc_enabled()
+{
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(_cb_svc_enabled), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
diff --git a/TC/unit/utc_signals_service_updated.c b/TC/unit/utc_signals_service_updated.c
new file mode 100644 (file)
index 0000000..737fd11
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_location_svc_updated();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_location_svc_updated,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+cb_updated (GObject *self,
+                    guint type,
+                    gpointer data,
+                    gpointer accuracy,
+                    gpointer userdata)
+{
+       if ( POSITION_UPDATED <= type && type <= REVERSEGEOCODE_UPDATED) tet_result(TET_PASS);
+       else tet_result(TET_FAIL);
+       g_main_loop_quit (loop);
+}
+
+static void
+utc_location_svc_updated()
+{
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_updated), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
diff --git a/TC/unit/utc_signals_zone_in.c b/TC/unit/utc_signals_zone_in.c
new file mode 100644 (file)
index 0000000..c0d42c9
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_zone_in();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_zone_in,1},
+       {NULL,0},
+};     
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+
+       LocationPosition *rb = location_position_new(0, 37.254, 127.057, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.261, 127.050, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       g_object_set(loc, "boundary", bound, NULL);     
+       location_boundary_free (bound); 
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+cb_zone_in(LocationObject *self,
+            guint type,
+            gpointer position,
+            gpointer accuracy)
+{
+       LocationPosition *pos = (LocationPosition*) position;
+
+       if( (37.255 <= pos->latitude && pos->latitude <= 37.265) &&
+               (127.052 <= pos->longitude && pos->longitude <= 127.058)) tet_result(TET_PASS); // I am in Suwon HQ
+       else tet_result(TET_FAIL);
+       g_main_loop_quit(loop);
+}
+
+static void
+utc_zone_in()
+{
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
diff --git a/TC/unit/utc_signals_zone_out.c b/TC/unit/utc_signals_zone_out.c
new file mode 100644 (file)
index 0000000..5070a66
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_zone_out();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_zone_out,1},
+       {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+       g_main_loop_quit (loop);
+       tet_result(TET_FAIL);
+       return FALSE;
+}
+
+static void startup()
+{      
+       location_init();
+       loc = location_new(LOCATION_METHOD_GPS);
+       location_start(loc);
+       loop = g_main_loop_new(NULL,FALSE);     
+
+       LocationPosition *rb = location_position_new(0, 36.395, 25.41, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 36.413, 25.388, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       g_object_set(loc, "boundary", bound, NULL);
+       location_boundary_free (bound);
+       tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{      
+       location_stop(loc);
+       location_free(loc);
+       tet_printf("\n TC End");
+}
+
+static void
+_cb_zone_out(LocationObject *self,
+            guint type,
+            gpointer position,
+            gpointer accuracy)
+{
+       LocationPosition *pos = (LocationPosition*) position;
+
+       if( (37.255 <= pos->latitude && pos->latitude <= 37.265) &&
+               (27.052 <= pos->longitude && pos->longitude <= 127.060) ) tet_result(TET_PASS); // I am in Suwon HQ
+       else tet_result(TET_FAIL);
+       g_main_loop_quit(loop);
+}
+
+
+static void
+utc_zone_out()
+{
+       g_signal_connect (loc, "zone-out", G_CALLBACK(_cb_zone_out), loc);
+       g_timeout_add_seconds(60, exit_loop, NULL);
+       g_main_loop_run (loop); 
+}
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..e6f3a78
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+rm -f config.cache
+rm -f acconfig.h
+
+echo "- libtoolize..."
+libtoolize --force || exit $?
+
+echo "- aclocal..."
+aclocal --force -I m4 || exit $?
+
+echo "- autoheader..."
+autoheader --force || exit $?
+
+echo "- automake..."
+automake --add-missing --force-missing || exit $?
+
+echo "- autoconf..."
+autoconf --force || exit $?
+
+echo "- ready!"
+exit
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..f574b41
--- /dev/null
@@ -0,0 +1,87 @@
+# Initialize
+AC_PREREQ(2.61)
+AC_INIT(Location, 0.1, [sena06.kim@samsung.com])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_SRCDIR([location/location.c])
+AM_INIT_AUTOMAKE([1.10.2 foreign -Wall -Werror])
+
+# Check programs for making executable
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+
+# Check programs for making libraries.
+AM_PROG_LIBTOOL
+AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+
+# Add default build options to CFLAGS, LDFLAGS
+if test "x$GCC" = "xyes"; then
+       CFLAGS="$CFLAGS -Wall" # -Werror
+       LDFLAGS="$LDFLAGS -Wl,-z,defs -Wl,--as-needed -Wl,--hash-style=both"
+fi
+
+# Add -g option to CFLAGS
+AC_ARG_ENABLE([debug],
+        [AC_HELP_STRING([--enable-debug],[turn on debugging [default=no]])],
+        [case "${enableval}" in
+         yes) enable_dbg=yes ;;
+         no) enable_dbg=no ;;
+         *) AC_MSG_ERROR([Bad value ${enableval} for --enable-debug]) ;;
+       esac],[enable_dbg=no])
+if ([test "x$enable_dbg" = xyes]); then
+       CFLAGS="$CFLAGS -g"
+fi
+
+# Check GCC EFL visibility
+AC_MSG_CHECKING(for ELF visibility)
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[
+               __attribute__((visibility("default")))
+               int var=10;
+       ]])],
+       [has_visibility=yes
+       AC_DEFINE([EXPORT_API], [__attribute__((visibility("default")))], [Symbol visibility prefix])
+       CFLAGS="$CFLAGS -fvisibility=hidden"],
+       [has_visibility=no
+       AC_DEFINE([EXPORT_API], [], [Symbol visibility prefix]) ]
+)
+AC_MSG_RESULT($has_visibility)
+
+# Check dependencies
+PKG_CHECK_MODULES(LOCATION, [glib-2.0 gobject-2.0 gmodule-2.0 vconf])
+AC_SUBST(LOCATION_LIBS)
+AC_SUBST(LOCATION_CFLAGS)
+
+PKG_CHECK_MODULES(TEST, [glib-2.0 gconf-2.0 json-glib-1.0])
+AC_SUBST(TEST_LIBS)
+AC_SUBST(TEST_CFLAGS)
+
+# Check dlog libraries
+AC_ARG_ENABLE([dlog],
+        [AC_HELP_STRING([--enable-dlog],[show dlog message [default=no]])],
+        [case "${enableval}" in
+         yes) enable_dlog=yes ;;
+         no) enable_dlog=no ;;
+         *) AC_MSG_ERROR([Bad value ${enableval} for --enable-dlog]) ;;
+       esac],[enable_dlog=no])
+if ([test "x$enable_dlog" = xyes]); then
+       PKG_CHECK_MODULES(DLOG, [dlog], have_dlog="yes", have_dlog="no")
+       AC_SUBST(DLOG_LIBS)
+       AC_SUBST(DLOG_CFLAGS)
+       if test "x$have_dlog" = "xyes"; then
+               LOCATION_CFLAGS="$LOCATION_CFLAGS -DLOCATION_DLOG_DEBUG $DLOG_CFLAGS"
+               LOCATION_LIBS="$LOCATION_LIBS $DLOG_LIBS"
+       fi
+fi
+
+# Generate files
+AC_CONFIG_FILES([
+location.pc
+Makefile
+location/Makefile
+tests/Makefile
+])
+
+AC_OUTPUT
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..37124e8
--- /dev/null
@@ -0,0 +1,439 @@
+libslp-location (0.3.31-3) unstable; urgency=low
+
+  * Change PKG name to "org.tizen" in test codes.
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.31-3
+
+ -- Yunhan Kim <yhan.kim@samsung.com>  Fri, 23 Dec 2011 20:04:55 +0900
+
+libslp-location (0.3.31-2) unstable; urgency=low
+
+  * check a method before creating its object.
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.31-2
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Mon, 19 Dec 2011 21:34:46 +0900
+
+libslp-location (0.3.31-1) unstable; urgency=low
+
+  * change default value of location serverce from 'On' to 'Off'
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.31-1
+
+ -- Genie Kim <daejins.kim@samsung.com>  Thu, 08 Dec 2011 20:08:49 +0900
+
+libslp-location (0.3.30-1) unstable; urgency=low
+
+  * add an empty body of location_send_command & support exception case
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.30-1
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Tue, 06 Dec 2011 17:05:16 +0900
+
+libslp-location (0.3.29-1) unstable; urgency=low
+
+  * Support multi boundaries & add new API, location_is_enabled_gps
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.29-1
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Thu, 03 Nov 2011 22:16:21 +0900
+
+libslp-location (0.3.28-1) unstable; urgency=low
+
+  * fix the bug that the last value of logitude was truncated.
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.28-1
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Wed, 02 Nov 2011 14:42:03 +0900
+
+libslp-location (0.3.27-1) unstable; urgency=low
+
+  * fix the bug that libslp-location returns 0,0 instead of error when a last postion(VCONF) is null
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.27-1
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Mon, 31 Oct 2011 11:17:21 +0900
+
+libslp-location (0.3.26-1) unstable; urgency=low
+
+  * vconf key is changed and use time_t for timestamp
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.26-1
+
+ -- Genie Kim <daejins.kim@samsung.com>  Mon, 17 Oct 2011 13:29:19 +0900
+
+libslp-location (0.3.25-1) unstable; urgency=low
+
+  * add location_is_supported_method, location_send_command & update_interval
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.25-1
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Wed, 12 Oct 2011 12:36:45 +0900
+
+libslp-location (0.3.24-1) unstable; urgency=low
+
+  * add location_get_last_known_position & fix prevent defect
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.24-1
+
+ -- Genie Kim <daejins.kim@samsung.com>  Thu, 29 Sep 2011 21:37:27 +0900
+
+libslp-location (0.3.23-2) unstable; urgency=low
+
+  * change maintainer in boilerplate
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.23-2
+
+ -- Genie Kim <daejins.kim@samsung.com>  Wed, 20 Jul 2011 17:56:38 +0900
+
+libslp-location (0.3.23-1) unstable; urgency=low
+
+  * Vconfkey value is changed by new UI guide
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.23-1
+
+ -- Genie Kim <daejins.kim@samsung.com>  Fri, 01 Jul 2011 17:42:34 +0900
+
+libslp-location (0.3.22-1) unstable; urgency=low
+
+  * Release New Location APIs
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.3.22-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Wed, 20 Apr 2011 11:07:38 +0900
+
+libslp-location (0.2.22-1) unstable; urgency=low
+
+  * Bug fix when hybrid exit
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.22-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Thu, 10 Mar 2011 19:44:07 +0900
+
+libslp-location (0.2.21-1) unstable; urgency=low
+
+  * Always update GPS data to PDR in hybrid mode & change some names
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.21-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Thu, 10 Mar 2011 14:52:09 +0900
+
+libslp-location (0.2.20-1) unstable; urgency=low
+
+  * Location eanbled by UX guide
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.20-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Mon, 07 Mar 2011 21:01:50 +0900
+
+libslp-location (0.2.19-2) unstable; urgency=low
+
+  * Release again for sbox i386 build
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.19-2
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Mon, 07 Mar 2011 09:19:06 +0900
+
+libslp-location (0.2.19-1) unstable; urgency=low
+
+  * Apply prevent
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.19-1
+
+ -- sangho park <sangho.g.park@samsung.com>  Tue, 22 Feb 2011 13:57:22 +0900
+
+libslp-location (0.2.18-2) unstable; urgency=low
+
+  * Fix depends for Sbox1
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.18-2
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Thu, 17 Feb 2011 20:07:52 +0900
+
+libslp-location (0.2.18-1) unstable; urgency=low
+
+  * Add SPS object/module
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.18-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Wed, 16 Feb 2011 16:52:43 +0900
+
+libslp-location (0.2.17-1) unstable; urgency=low
+
+  * Apply prevent & Fix PG
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.17-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Tue, 08 Feb 2011 13:04:34 +0900
+
+libslp-location (0.2.16-2) unstable; urgency=low
+
+  * Add prevent & Fix accuracy
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.16-2
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Tue, 25 Jan 2011 17:12:01 +0900
+
+libslp-location (0.2.16-1) unstable; urgency=low
+
+  * Add CPS/IPS & Async address API & Appy vconf security
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.16-1
+
+ -- Tae-Hwan Kim <the81.kim@samsung.com>  Wed, 19 Jan 2011 11:39:22 +0900
+
+libslp-location (0.2.15-1) unstable; urgency=low
+
+  * Apply TC recomm. & change default setting value to 0
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.15-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Thu, 06 Jan 2011 10:21:04 +0900
+
+libslp-location (0.2.14-1) unstable; urgency=low
+
+  * Change plugin & guide & Fix TC
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.14-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 20 Dec 2010 17:27:55 +0900
+
+libslp-location (0.2.13-0) unstable; urgency=low
+
+  * Fix build dependency
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.13-0
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 13 Dec 2010 13:03:30 +0900
+
+libslp-location (0.2.12-0) unstable; urgency=low
+
+  * Fix plugin & guide & add setting feature
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.12-0
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 13 Dec 2010 09:40:53 +0900
+
+libslp-location (0.2.11-0) unstable; urgency=low
+
+  * Add hybri mode & Fix some bugs
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.11-0
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 29 Nov 2010 10:57:57 +0900
+
+libslp-location (0.2.10-0) unstable; urgency=low
+
+  * Fix minor bugs
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.10-0
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Wed, 24 Nov 2010 23:26:37 +0900
+
+libslp-location (0.2.9-1) unstable; urgency=low
+
+  * Remove caching
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.9-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 23 Nov 2010 14:29:20 +0900
+
+libslp-location (0.2.8-1) unstable; urgency=low
+
+  * Fix plugin priority & Fix sample code bug
+  * git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.8-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Wed, 10 Nov 2010 21:46:03 +0900
+
+libslp-location (0.2.7-1) unstable; urgency=low
+
+  * Add geocode object & Enable wps object
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.2.7-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 08 Nov 2010 23:03:50 +0900
+
+libslp-location (0.1.7-1) unstable; urgency=low
+
+  * Remove unnecessary dependencies(geoclue-skyhook,gpsd ..)
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.7-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 01 Nov 2010 13:53:11 +0900
+
+libslp-location (0.1.6-1) unstable; urgency=low
+
+  * Fix dependency
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.6-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Sun, 31 Oct 2010 16:59:48 +0900
+
+libslp-location (0.1.5-1) unstable; urgency=low
+
+  * Fix for limo
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.5-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 29 Oct 2010 16:26:43 +0900
+
+libslp-location (0.1.4-2) unstable; urgency=low
+
+  * Remove version field for limo
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.4-2
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 29 Oct 2010 14:50:42 +0900
+
+libslp-location (0.1.4-1) unstable; urgency=low
+
+  * Add version field in control
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.4-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 29 Oct 2010 14:18:01 +0900
+
+libslp-location (0.1.3-1) unstable; urgency=low
+
+  * Fix PG & sample, Change signal emission
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.3-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 29 Oct 2010 13:49:11 +0900
+
+libslp-location (0.1.2-1) unstable; urgency=low
+
+  * Add more bolier plate
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.2-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 26 Oct 2010 16:40:31 +0900
+
+libslp-location (0.1.1-1) unstable; urgency=low
+
+  * Fix for PG & Doxygen & Limo Contrib.
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.1-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 26 Oct 2010 12:22:16 +0900
+
+libslp-location (0.1.0-15) unstable; urgency=low
+
+  * Update programming guide & test case for address APIs
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-15
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Sat, 16 Oct 2010 20:53:38 +0900
+
+libslp-location (0.1.0-14) unstable; urgency=low
+
+  * Adapt to libdecarta
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-14
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 11 Oct 2010 22:33:14 +0900
+
+libslp-location (0.1.0-13) unstable; urgency=low
+
+  * Add input parameter error handling & Change TC
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-13
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 27 Sep 2010 20:03:09 +0900
+
+libslp-location (0.1.0-12) unstable; urgency=low
+
+  * Fix in zone in/out & Add more test case
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-12
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 17 Sep 2010 16:56:35 +0900
+
+libslp-location (0.1.0-11) unstable; urgency=low
+
+  * Add glib-genmarshal & Remove marshal source/header
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-11
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 14 Sep 2010 10:18:37 +0900
+
+libslp-location (0.1.0-10) unstable; urgency=low
+
+  * Change programming guide & doxygen comments
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-10
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Fri, 10 Sep 2010 14:52:24 +0900
+
+libslp-location (0.1.0-9) unstable; urgency=low
+
+  * Change programming guilde & Add sample codes
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-9
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Thu, 09 Sep 2010 17:50:27 +0900
+
+libslp-location (0.1.0-8) unstable; urgency=low
+
+  * Add zone in/out & boundary feature
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-8
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 06 Sep 2010 10:57:08 +0900
+
+libslp-location (0.1.0-7) unstable; urgency=low
+
+  * Adapt to geoclue change
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-7
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Sat, 04 Sep 2010 19:40:16 +0900
+
+libslp-location (0.1.0-6) unstable; urgency=low
+
+  * Change programming guide & test application
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-6
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Wed, 01 Sep 2010 20:07:34 +0900
+
+libslp-location (0.1.0-5) unstable; urgency=low
+
+  * Change fw name in doxygen & release again
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-5
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 31 Aug 2010 23:28:12 +0900
+
+libslp-location (0.1.0-4) unstable; urgency=low
+
+  * Add doxygen & change API return value to integer
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-4
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Tue, 31 Aug 2010 22:09:35 +0900
+
+libslp-location (0.1.0-3) unstable; urgency=low
+
+  * Change header dependency for relase
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-3
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 30 Aug 2010 20:58:04 +0900
+
+libslp-location (0.1.0-2) unstable; urgency=low
+
+  * Fix header include & Release again
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-2
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 30 Aug 2010 17:51:44 +0900
+
+libslp-location (0.1.0-1) unstable; urgency=low
+
+  * Initial version
+  * Git: pkgs/l/libslp-location
+  * Tag: libslp-location_0.1.0-1
+
+ -- Tae-hwan Kim <the81.kim@samsung.com>  Mon, 30 Aug 2010 12:01:05 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..89f9108
--- /dev/null
@@ -0,0 +1,31 @@
+Source: libslp-location
+Section: libs
+Priority: extra
+Maintainer: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>, Genie kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
+Uploaders: Genie Kim <daejins.kim@samsung.com>
+Build-Depends: debhelper (>= 5), libglib2.0-dev, dlog-dev, libvconf-dev, libvconf-keys-dev, libjson-glib-dev
+Standards-Version: 3.7.2
+Homepage: N/A
+
+Package: libslp-location
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libglib2.0-0, libdlog-0, libvconf-0
+Description: Location Based Service (Shared Object)
+ Location Based Service Libraries
+
+Package: libslp-location-dev
+Section: libdevel
+Architecture: any
+XB-Generate-Docs: yes
+XB-Public-Package: yes
+Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-location (= ${binary:Version}), libglib2.0-dev, dlog-dev, libvconf-dev
+Description: Location Based Service (Development files)
+ Location Based Service Development Package
+
+Package: libslp-location-dbg
+Section: debug
+Architecture: any
+Depends: ${misc:Depends}, libslp-location (= ${binary:Version})
+Description: Location Based Service (Unstripped Object)
+ Location Based Service Library Debug Package
diff --git a/debian/libslp-location-dev.install b/debian/libslp-location-dev.install
new file mode 100644 (file)
index 0000000..a2f6b8c
--- /dev/null
@@ -0,0 +1,4 @@
+usr/include/*
+usr/lib/pkgconfig/*
+usr/lib/*.{la,a}
+usr/lib/*.so
diff --git a/debian/libslp-location.install b/debian/libslp-location.install
new file mode 100644 (file)
index 0000000..093956b
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/*.so.*
diff --git a/debian/libslp-location.postinst b/debian/libslp-location.postinst
new file mode 100755 (executable)
index 0000000..eb04949
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#setting 
+if [ "${USER}" = "root" ]
+then
+vconftool set -t int db/location/position/Timestamp "0" -f
+vconftool set -t string db/location/position/LastPosition "" -f
+vconftool set -t int db/location/position/LastAccuracy "0" -f
+vconftool set -t int db/location/setting/GpsEnabled "0" -g 6514 -f
+vconftool set -t int db/location/setting/AgpsEnabled "0" -g 6514 -f
+vconftool set -t int db/location/setting/NetworkEnabled "0" -g 6514 -f
+vconftool set -t int db/location/setting/SensorEnabled "0" -g 6514 -f
+else
+vconftool set -t int db/location/position/Timestamp "0" -f
+vconftool set -t string db/location/position/LastPosition "" -f
+vconftool set -t int db/location/position/LastAccuracy "0" -f
+vconftool set -t int db/location/setting/GpsEnabled "0" -g -f
+vconftool set -t int db/location/setting/AgpsEnabled "0" -f
+vconftool set -t int db/location/setting/NetworkEnabled "0" -f
+vconftool set -t int db/location/setting/SensorEnabled "0" -f
+fi
+
+sync
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..4f12d83
--- /dev/null
@@ -0,0 +1,117 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+       CXXFLAGS += -O0
+else
+       CFLAGS += -O2
+       CXXFLAGS += -O2
+endif
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       ./autogen.sh
+       # Add here commands to configure the package.
+       ./configure --prefix=$(PREFIX) --enable-dlog --enable-debug
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       - $(MAKE) clean
+
+       rm -rf CMakeCache.txt
+       rm -rf CMakeFiles
+       rm -rf cmake_install.cmake
+       rm -rf Makefile
+       rm -rf install_manifest.txt
+       rm -rf *.so
+       rm -f pkgconfig/lbs-location.pc
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs
+#      dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+#      dh_strip
+       dh_strip --dbg-package=libslp-location-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/image/SLP_Location_PG.h b/image/SLP_Location_PG.h
new file mode 100755 (executable)
index 0000000..aeada25
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
diff --git a/image/location_image001.png b/image/location_image001.png
new file mode 100644 (file)
index 0000000..bbddf7b
Binary files /dev/null and b/image/location_image001.png differ
diff --git a/image/location_image002.png b/image/location_image002.png
new file mode 100644 (file)
index 0000000..7400407
Binary files /dev/null and b/image/location_image002.png differ
diff --git a/location.pc.in b/location.pc.in
new file mode 100644 (file)
index 0000000..bf901e0
--- /dev/null
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+datarootdir = @datarootdir@
+datadir=@datadir@
+
+Name: location
+Description: SLP Location FW
+Requires: glib-2.0 gobject-2.0 gmodule-2.0 vconf
+Version: @VERSION@
+Libs: -L${libdir} -lSLP-location
+Cflags: -I${includedir} -I${includedir}/location
diff --git a/location/Makefile.am b/location/Makefile.am
new file mode 100644 (file)
index 0000000..799e4c8
--- /dev/null
@@ -0,0 +1,77 @@
+lib_LTLIBRARIES = libSLP-location.la
+
+libSLP_location_la_SOURCES = \
+                                                        location-marshal.c   \
+                                                        location-marshal.h   \
+                                                        location-ielement.c  \
+                                                        location-ielement.h  \
+                                                        location-setting.c  \
+                                                        location-setting.h  \
+                                                        location-module.h \
+                                                        location-module-internal.c\
+                                                        location-module-internal.h\
+                                                        location.c           \
+                                                        location.h           \
+                                                        location-position.c  \
+                                                        location-position.h  \
+                                                        location-velocity.c  \
+                                                        location-velocity.h  \
+                                                        location-accuracy.c  \
+                                                        location-accuracy.h  \
+                                                        location-address.c  \
+                                                        location-address.h  \
+                                                        location-boundary.c  \
+                                                        location-boundary.h  \
+                                                        location-satellite.c  \
+                                                        location-satellite.h  \
+                                                        location-poi-info.c  \
+                                                        location-poi-info.h  \
+                                                        location-signaling-util.c \
+                                                        location-signaling-util.h \
+                                                        location-common-util.c \
+                                                        location-common-util.h \
+                                                        location-gps.c       \
+                                                        location-gps.h       \
+                                                        location-wps.c       \
+                                                        location-wps.h       \
+                                                        location-ips.c       \
+                                                        location-ips.h       \
+                                                        location-cps.c       \
+                                                        location-cps.h       \
+                                                        location-sps.c       \
+                                                        location-sps.h       \
+                                                        location-hybrid.c \
+                                                        location-hybrid.h \
+                                                        location-geocode.c \
+                                                        location-geocode.h \
+                                                        location-poi.c   \
+                                                        location-poi.h
+
+libSLP_location_la_CFLAGS = \
+                                                       -fPIC\
+                                                       $(LOCATION_CFLAGS)
+
+libSLP_location_la_LIBADD = \
+                                                       -lm\
+                                                       $(LOCATION_LIBS)
+
+EXTRA_DIST = \
+                        location-marshal.list
+
+location-marshal.h: location-marshal.list $(GLIB_GENMARSHAL)
+       $(GLIB_GENMARSHAL) $< --header --prefix=location > $@
+location-marshal.c: location-marshal.list location-marshal.h $(GLIB_GENMARSHAL)
+       echo "#include \"location-marshal.h\"" > $@ && $(GLIB_GENMARSHAL) location-marshal.list --body --prefix=location >> $@
+
+libSLP_location_includedir = $(includedir)/location
+libSLP_location_include_HEADERS = \
+                                                                 location.h     \
+                                                                 location-types.h \
+                                                                 location-position.h  \
+                                                                 location-velocity.h  \
+                                                                 location-accuracy.h  \
+                                                                 location-address.h  \
+                                                                 location-boundary.h  \
+                                                                 location-satellite.h  \
+                                                                 location-poi-info.h \
+                                                                 location-module.h
diff --git a/location/location-accuracy.c b/location/location-accuracy.c
new file mode 100644 (file)
index 0000000..4681e37
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-accuracy.h"
+#include "location/location-log.h"
+
+GType
+location_accuracy_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationAccuracy"),
+                       (GBoxedCopyFunc) location_accuracy_copy,
+                       (GBoxedFreeFunc) location_accuracy_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+EXPORT_API LocationAccuracy*
+location_accuracy_new (LocationAccuracyLevel level,
+       gdouble horizontal_accuracy,
+       gdouble vertical_accuracy)
+{
+       LocationAccuracy* accuracy = g_slice_new0 (LocationAccuracy);
+       accuracy->level = level;
+       accuracy->horizontal_accuracy = horizontal_accuracy;
+       accuracy->vertical_accuracy = vertical_accuracy;
+
+       return accuracy;
+}
+
+EXPORT_API void
+location_accuracy_free (LocationAccuracy* accuracy)
+{
+       g_return_if_fail (accuracy);
+       g_slice_free (LocationAccuracy, accuracy);
+}
+
+static int
+comp_int(int a, int b){
+       if (a < b) return -1;
+       if (a == b) return 0;
+       return 1;
+}
+
+static int
+comp_double_reverse(double a, double b) {
+        if (a > b) return -1;
+        else if (a == b) return 0;
+        return 1;
+}
+
+int
+location_accuracy_level_compare(const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2)
+{
+       g_return_val_if_fail(accuracy1, -1);
+       g_return_val_if_fail(accuracy2, 1);
+
+       return comp_int(accuracy1->level, accuracy2->level);
+}
+
+EXPORT_API int
+location_accuracy_compare (const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2)
+{
+       int ret = 0;
+       ret = location_accuracy_level_compare(accuracy1, accuracy2);
+       if(!ret){
+               ret = comp_double_reverse(accuracy1->horizontal_accuracy, accuracy2->horizontal_accuracy);
+               if(!ret) return comp_double_reverse(accuracy1->vertical_accuracy, accuracy2->vertical_accuracy);
+       }
+       return ret;
+}
+
+EXPORT_API LocationAccuracy*
+location_accuracy_copy (const LocationAccuracy *accuracy)
+{
+       g_return_val_if_fail(accuracy, NULL);
+       return location_accuracy_new(accuracy->level,
+                                                               accuracy->horizontal_accuracy,
+                                                               accuracy->vertical_accuracy);
+}
diff --git a/location/location-accuracy.h b/location/location-accuracy.h
new file mode 100644 (file)
index 0000000..38f21a6
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_ACCURACY_H_
+#define __LOCATION_ACCURACY_H_
+
+#include <location/location-types.h>
+
+G_BEGIN_DECLS
+
+/**
+ * @file location-accuracy.h
+ * @brief This file contains the definitions, structures, and functions related to accuracy information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+/**
+ * @brief This represents the approximate accuracy level of given information.
+ */
+typedef enum {
+       LOCATION_ACCURACY_LEVEL_NONE = 0,    ///< Invalid data.
+       LOCATION_ACCURACY_LEVEL_COUNTRY,     ///< Country accuracy level->
+       LOCATION_ACCURACY_LEVEL_REGION,      ///< Regional accuracy level->
+       LOCATION_ACCURACY_LEVEL_LOCALITY,    ///< Local accuracy level->
+       LOCATION_ACCURACY_LEVEL_POSTALCODE,  ///< Postal accuracy level->
+       LOCATION_ACCURACY_LEVEL_STREET,      ///< Street accuracy level->
+       LOCATION_ACCURACY_LEVEL_DETAILED,    ///< Detailed accuracy level->
+} LocationAccuracyLevel;
+
+/**
+ * @brief This represents location accuracy information such as accuracy level, horizontal and vertical accuracy.
+ */
+struct _LocationAccuracy
+{
+       LocationAccuracyLevel level;        ///< The accuracy level of the location information.
+       gdouble horizontal_accuracy;        ///< The horizontal position uncertainty  of the location in meters.
+       gdouble vertical_accuracy;          ///< The vertical position unvertainty of the location in meters.
+};
+
+GType location_accuracy_get_type(void);
+#define LOCATION_TYPE_ACCURACY (location_accuracy_get_type())
+
+/**
+ * @brief   Create a new #LocationAccuracy with  given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  level - The accuracy level of the location information.
+ * @param [in]  horizontal_accuracy - The horizontal position uncertainty  of the location in meters.
+ * @param [in]  vertical_accuracy - The vertical position unvertainty of the location in meters.
+ * @return a new #LocationAccuracy
+ * @retval NULL if error occured
+ */
+LocationAccuracy *location_accuracy_new (LocationAccuracyLevel level, gdouble horizontal_accuracy, gdouble vertical_accuracy);
+
+/**
+ * @brief   Free a #LocationAccuracy.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] accuracy - a #LocationAccuracy.
+ * @return None.
+ */
+void location_accuracy_free (LocationAccuracy *accuracy);
+
+/**
+ * @brief   Compare for two accuracys.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  accuracy1 - a #LocationAccuracy
+ * @param [in]  accuracy2 - another #LocationAccuracy
+ * @return integer
+ * @retval\n
+ * 0 - if the accuracy match\n
+ * positive value - if accuracy of accuracy1 is better than accuracy of accuracy2\n
+ * negative value - if accuracy of accuracy1 is worse than accuracy of accuracy2
+ */
+int location_accuracy_compare (const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2);
+
+/**
+ * @brief   Compare for two accuracys' level.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  accuracy1 - a #LocationAccuracy
+ * @param [in]  accuracy2 - another #LocationAccuracy
+ * @return integer
+ * @retval\n
+ * 0 - if the accuracy match\n
+ * positive value - if accuracy1's level is better than accuracy2's level\n
+ * negative value - if accuracy1's level is worse than accuracy2's level
+ */
+int location_accuracy_level_compare(const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2);
+
+/**
+ * @brief   Makes a copy of #LocationAccuracy
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  accuracy - a #LocationAccuracy
+ * @return a new #LocationAccuracy
+ * @retval NULL if error occured
+ */
+LocationAccuracy *location_accuracy_copy (const LocationAccuracy *accuracy);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-address.c b/location/location-address.c
new file mode 100644 (file)
index 0000000..61bf429
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-address.h"
+#include "location/location-log.h"
+
+GType
+location_address_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationAddress"),
+                       (GBoxedCopyFunc) location_address_copy,
+                       (GBoxedFreeFunc) location_address_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+EXPORT_API LocationAddress*
+location_address_new (const gchar *building_number,
+       const gchar *street,
+       const gchar *district,
+       const gchar *city,
+       const gchar *state,
+       const gchar *country_code,
+       const gchar *postal_code)
+{
+       LocationAddress* address = g_slice_new0(LocationAddress);
+
+       address->building_number = g_strdup(building_number);
+       address->street = g_strdup(street);
+       address->district = g_strdup(district);
+       address->city = g_strdup(city);
+       address->state = g_strdup(state);
+       address->country_code = g_strdup(country_code);
+       address->postal_code = g_strdup(postal_code);
+
+       return address;
+}
+
+EXPORT_API void
+location_address_free (LocationAddress* address)
+{
+       g_return_if_fail(address);
+       g_free(address->building_number);
+       g_free(address->street);
+       g_free(address->district);
+       g_free(address->city);
+       g_free(address->state);
+       g_free(address->country_code);
+       g_free(address->postal_code);
+       g_slice_free(LocationAddress, address);
+}
+
+EXPORT_API LocationAddress*
+location_address_copy (const LocationAddress *address)
+{
+       g_return_val_if_fail(address, NULL);
+       return location_address_new(address->building_number,
+                                                               address->street,
+                                                               address->district,
+                                                               address->city,
+                                                               address->state,
+                                                               address->country_code,
+                                                               address->postal_code);
+}
diff --git a/location/location-address.h b/location/location-address.h
new file mode 100644 (file)
index 0000000..45747a1
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_ADDRESS_H_
+#define __LOCATION_ADDRESS_H_
+
+#include <location/location-types.h>
+
+G_BEGIN_DECLS
+
+/**
+ * @file location-address.h
+ * @brief This file contains the definitions, structures, and functions related to address information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+/**
+ * @brief This represents address information such as building number, street name, etc.
+ */
+struct _LocationAddress
+{
+       gchar *building_number;  ///< Building number.
+       gchar *street;           ///< Full street name.
+       gchar *district;         ///< Municipal district name.
+       gchar *city;             ///< City name.
+       gchar *state;            ///< State or provinc region of a nation.
+       gchar *country_code;     ///< Country name.
+       gchar *postal_code;      ///< Postal delivery code.
+};
+
+GType location_address_get_type(void);
+#define LOCATION_TYPE_ADDRESS (location_address_get_type())
+
+/**
+ * @brief   Create a new #LocationAddress with  given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  building_number - Building number
+ * @param [in]  street - Full street name.
+ * @param [in]  district - Municipal district name.
+ * @param [in]  city - City name.
+ * @param [in]  state - State or provinc region of a nation.
+ * @param [in]  country_code - Country name.
+ * @param [in]  postal_code - Postal delivery code.
+ * @return a new #LocationAddress
+ * @retval NULL if error occured
+ */
+LocationAddress *location_address_new (const gchar *building_number, const gchar *street, const gchar *district, const gchar *city, const gchar *state, const gchar *country_code, const gchar *postal_code);
+
+/**
+ * @brief   Free a #LocationAddress.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] address - a #LocationAddress.
+ * @return None.
+ */
+void location_address_free (LocationAddress *address);
+
+/**
+ * @brief   Makes a copy of #LocationAddress
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  address - a #LocationAddress
+ * @return a new #LocationAddress
+ * @retval NULL if error occured
+ */
+LocationAddress *location_address_copy (const LocationAddress *address);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-boundary.c b/location/location-boundary.c
new file mode 100644 (file)
index 0000000..5c06a17
--- /dev/null
@@ -0,0 +1,354 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+/*
+ * location_boundary_if_inside(LocationBoundary* boundary,
+ *                     LocationPosition* position)
+ * code from
+ *
+ * Copyright (c) 1970-2003, Wm. Randolph Franklin
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * 1.Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimers.
+ * 2.Redistributions in binary form must reproduce the above copyright notice
+ * in the documentation and/or other materials provided with the distribution.
+ * 3.The name of W. Randolph Franklin may not be used to endorse or promote
+ * products derived from this Software without specific prior written permission.
+ *
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+#include "location/location-boundary.h"
+#include "location/location-log.h"
+
+GType
+location_boundary_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationBoundary"),
+                       (GBoxedCopyFunc) location_boundary_copy,
+                       (GBoxedFreeFunc) location_boundary_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+static void _append_polygon_position(gpointer data, gpointer user_data)
+{
+       g_return_if_fail(data);
+       g_return_if_fail(user_data);
+
+       LocationBoundary* boundary = (LocationBoundary*)user_data;
+       LocationPosition* position = (LocationPosition *)data;
+       LocationPosition* new_position = location_position_copy(position);
+
+       boundary->polygon.position_list = g_list_append(boundary->polygon.position_list, new_position);
+}
+
+static void _free_polygon_position(gpointer data)
+{
+       g_return_if_fail(data);
+
+       LocationPosition* position = (LocationPosition *)data;
+       location_position_free(position);
+}
+
+
+EXPORT_API LocationBoundary *
+location_boundary_new_for_rect (LocationPosition* left_top,
+       LocationPosition* right_bottom)
+{
+       g_return_val_if_fail(left_top, NULL);
+       g_return_val_if_fail(right_bottom, NULL);
+
+       gdouble lon_interval = right_bottom->longitude - left_top->longitude;
+
+       if(lon_interval < 180 && lon_interval > -180) {
+               if(right_bottom->longitude <= left_top->longitude || right_bottom->latitude >= left_top->latitude)
+                       return NULL;
+       }
+       else {
+               if(right_bottom->longitude >= left_top->longitude || right_bottom->latitude >= left_top->latitude)
+                       return NULL;
+       }
+
+       LocationBoundary* boundary = g_slice_new0 (LocationBoundary);
+       boundary->type = LOCATION_BOUNDARY_RECT;
+       boundary->rect.left_top = location_position_copy(left_top);
+       boundary->rect.right_bottom = location_position_copy(right_bottom);
+       return boundary;
+}
+
+EXPORT_API LocationBoundary *
+location_boundary_new_for_circle (LocationPosition* center,
+       gdouble radius)
+{
+       g_return_val_if_fail(center, NULL);
+       g_return_val_if_fail(radius > 0, NULL);
+       LocationBoundary* boundary = g_slice_new0 (LocationBoundary);
+       boundary->type = LOCATION_BOUNDARY_CIRCLE;
+       boundary->circle.center = location_position_copy(center);
+       boundary->circle.radius = radius;
+       return boundary;
+}
+
+EXPORT_API LocationBoundary *
+location_boundary_new_for_polygon(GList *position_list)
+{
+       g_return_val_if_fail(position_list, NULL);
+       g_return_val_if_fail(g_list_length(position_list) > 2, NULL);
+
+       LocationBoundary *boundary = g_slice_new0 (LocationBoundary);
+
+       g_list_foreach(position_list, (GFunc)_append_polygon_position, boundary);
+       boundary->type = LOCATION_BOUNDARY_POLYGON;
+       boundary->polygon.position_list = g_list_first(boundary->polygon.position_list);
+
+       return boundary;
+}
+
+EXPORT_API void
+location_boundary_free (LocationBoundary* boundary)
+{
+       g_return_if_fail(boundary);
+
+       if (boundary->type == LOCATION_BOUNDARY_RECT) {
+               location_position_free(boundary->rect.left_top);
+               location_position_free(boundary->rect.right_bottom);
+       } else if (boundary->type == LOCATION_BOUNDARY_CIRCLE) {
+               location_position_free(boundary->circle.center);
+       } else if (boundary->type == LOCATION_BOUNDARY_POLYGON) {
+               g_list_free_full(boundary->polygon.position_list, (GDestroyNotify)_free_polygon_position);
+       }
+       g_slice_free(LocationBoundary, boundary);
+}
+
+EXPORT_API LocationBoundary*
+location_boundary_copy (const LocationBoundary* boundary)
+{
+       g_return_val_if_fail(boundary, NULL);
+       if (boundary->type == LOCATION_BOUNDARY_RECT) {
+               return location_boundary_new_for_rect(boundary->rect.left_top, boundary->rect.right_bottom);
+       } else if (boundary->type == LOCATION_BOUNDARY_CIRCLE) {
+               return location_boundary_new_for_circle(boundary->circle.center, boundary->circle.radius);
+       } else if (boundary->type == LOCATION_BOUNDARY_POLYGON) {
+               return location_boundary_new_for_polygon(boundary->polygon.position_list);
+       }
+       return NULL;
+}
+
+
+EXPORT_API gboolean
+location_boundary_if_inside (LocationBoundary* boundary,
+       LocationPosition* position)
+{
+       g_return_val_if_fail(boundary, FALSE);
+       g_return_val_if_fail(position, FALSE);
+
+       gboolean is_inside = FALSE;
+
+       switch(boundary->type) {
+
+               case LOCATION_BOUNDARY_RECT: {
+                       gdouble y = position->latitude;
+                       gdouble x = position->longitude;
+
+                       gdouble lt_y = boundary->rect.left_top->latitude;
+                       gdouble lt_x = boundary->rect.left_top->longitude;
+                       gdouble rb_y = boundary->rect.right_bottom->latitude;
+                       gdouble rb_x = boundary->rect.right_bottom->longitude;
+
+                       if (lt_x - rb_x < 180 && lt_x - rb_x > -180) {
+                               if ((rb_y < y && y < lt_y) && ( lt_x < x && x < rb_x)) {
+                                       LOCATION_LOGD("\tInside of Rectangular boundary");
+                                       is_inside = TRUE;
+                               }
+                       }
+                       else {
+                               if ((rb_y < y && y < lt_y) && ( lt_x < x || x < rb_x)) {
+                                       LOCATION_LOGD("\tInside of Rectangular boundary near 180th meridian");
+                                       is_inside = TRUE;
+                               }
+                       }
+                       break;
+               }
+               case LOCATION_BOUNDARY_CIRCLE: {
+
+                       LocationPosition center;
+                       gulong distance = 0;
+
+                       center.latitude = boundary->circle.center->latitude;
+                       center.longitude = boundary->circle.center->longitude;
+
+                       location_get_distance(&center, position, &distance);
+                       if (distance  < boundary->circle.radius){
+                               LOCATION_LOGD("\tInside Circle boundary");
+                               is_inside = TRUE;
+                       }
+                       break;
+               }
+               case LOCATION_BOUNDARY_POLYGON: {
+
+                       int i, j;
+                       double interval_x = 0.0, interval_y = 0.0;
+                       double x0, y0;
+                       gboolean edge_area;
+                       int crossing_num = 0;
+                       GList *position_list = boundary->polygon.position_list;
+                       int count = g_list_length(position_list);
+                       GList *pos1_list = NULL;
+                       GList *pos2_list = NULL;
+                       LocationPosition* pos1 = NULL;
+                       LocationPosition* pos2 = NULL;
+
+                       i = 0;
+                       j = count - 1;
+                       pos1_list = g_list_first(position_list);
+                       pos2_list = g_list_last(position_list);
+                       while(pos1_list = g_list_next(pos1_list)) {
+                               edge_area = FALSE;
+                               pos1 = pos1_list->data;
+                               pos2 = pos2_list->data;
+                               interval_y = pos1->longitude - pos2->longitude;
+                               interval_x = pos1->latitude - pos2->latitude;
+                       /**
+                        * Case 1. -180 < longitude2 - longitude1 < 180         : normal case
+                        * Case 2. longitude2 - longitude1 < -180               : interval_y = longitude2 - longitude1 + 360
+                        * Case 3. longitude2 - longitude1 > 180                : intreval_y = longitude2 - longitude1 - 360
+                        */
+                               if (interval_y > 180) {
+                                       interval_y = interval_y - 360;
+                                       edge_area = TRUE;
+                               }
+                               else if (interval_y < -180) {
+                                       interval_y = interval_y + 360;
+                                       edge_area = TRUE;
+                               }
+
+                               if (edge_area && (pos1->longitude > position->longitude) == (pos2->longitude > position->longitude)){
+                                       if (pos2->longitude * position->longitude > 0) {
+                                               x0 = pos2->latitude;
+                                               y0 = pos2->longitude;
+                                       }
+                                       else {
+                                               x0 = pos1->latitude;
+                                               y0 = pos1->longitude;
+                                       }
+
+                                       if (position->latitude < ((interval_x/interval_y)*(position->longitude - y0) + x0)) {
+
+                                               LOCATION_LOGD("Reverse");
+                                               crossing_num++;
+                                       }
+                               }
+                               else if (!edge_area && (pos1->longitude > position->longitude) != (pos2->longitude > position->longitude)) {
+                                       x0 = pos2->latitude;
+                                       y0 = pos2->longitude;
+                                       if (position->latitude < ((interval_x/interval_y)*(position->longitude - y0) + x0)) {
+                                               LOCATION_LOGD("Common");
+                                               crossing_num++;
+                                       }
+                               }
+                               else LOCATION_LOGD("It is not crossed.");
+
+                               pos2_list = pos1_list;
+                       }
+                       LOCATION_LOGW("num[%d]", crossing_num);
+                       is_inside = crossing_num & 1; // Odd : inside, Even : outside
+
+                       break;
+               }
+               default: {
+                       LOCATION_LOGW("\tboundary type is undefined.[%d]", boundary->type);
+                       break;
+               }
+       }
+
+       return is_inside;
+}
+
+EXPORT_API int
+location_boundary_add(const LocationObject *obj, const LocationBoundary *boundary)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (boundary, LOCATION_ERROR_PARAMETER);
+
+       GList *boundary_list = NULL;
+
+       boundary_list = g_list_append(boundary_list, (gpointer) boundary);
+
+       g_object_set(G_OBJECT(obj), "boundary", boundary_list, NULL);
+
+
+       return LOCATION_ERROR_NONE;
+}
+
+EXPORT_API int
+location_boundary_remove(const LocationObject *obj, const LocationBoundary *boundary)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (boundary, LOCATION_ERROR_PARAMETER);
+
+       g_object_set(G_OBJECT(obj), "removal-boundary", boundary, NULL);
+
+       return LOCATION_ERROR_NONE;
+}
+
+EXPORT_API int
+location_boundary_foreach(const LocationObject *obj, LocationBoundaryFunc func, gpointer user_data)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (func, LOCATION_ERROR_PARAMETER);
+
+       GList * boundary_list = NULL;
+
+       g_object_get(G_OBJECT(obj), "boundary", &boundary_list, NULL);
+
+       if (boundary_list == NULL) {
+               LOCATION_LOGD("There is no boundary.");
+               return LOCATION_ERROR_UNKNOWN;
+       }
+       g_list_foreach(boundary_list, (GFunc)func, user_data);
+
+       return LOCATION_ERROR_NONE;
+}
diff --git a/location/location-boundary.h b/location/location-boundary.h
new file mode 100644 (file)
index 0000000..e6b70bc
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_BOUNDARY_H_
+#define __LOCATION_BOUNDARY_H_
+
+#include <location/location-types.h>
+#include <location/location-position.h>
+
+/**
+ * @file location-boundary.h
+ * @brief This file contains the definitions, structures, and functions related to boundary information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+G_BEGIN_DECLS
+
+/**
+ * @brief
+ * The type of the @location_boundary_foreach function of #LocationObject
+ */
+typedef void (*LocationBoundaryFunc) (LocationBoundary *boundary, gpointer user_data);
+
+/**
+ * @brief This represents used geographical type, and supports rectangle or circle area.
+ */
+typedef enum {
+       LOCATION_BOUNDARY_NONE = 0,  ///< Undefined geographical area type.
+       LOCATION_BOUNDARY_RECT,      ///< Rectangular geographical area type.
+       LOCATION_BOUNDARY_CIRCLE,     ///< Circle geographical area type.
+       LOCATION_BOUNDARY_POLYGON               ///< Polygon geographical area type.
+} LocationBoundaryType;
+
+/**
+ * @brief This represents a rectangular geographical area.
+ */
+typedef struct {
+       LocationPosition* left_top;       ///< The left top position of rectangle.
+       LocationPosition* right_bottom;   ///< The right bottom position of rectangle.
+} LocationRect;
+
+/**
+ * @brief This represents a circle geographical area with center geographic position and radius.
+ */
+typedef struct {
+       LocationPosition* center;      ///< The center position of a circle.
+       gdouble radius;               ///< The radius of a circle.
+} LocationCircle;
+
+/**
+ * @brief This represents a polygon geographical area.
+ */
+typedef struct {
+       GList *position_list;   ///< The collection of positions
+} LocationPolygon;
+
+/**
+ * @brief This represents boundary information such as rectagular or circle area.
+ */
+struct _LocationBoundary{
+       LocationBoundaryType type;   ///< The boundary type of this information.
+       union {
+               LocationRect rect;           ///< The geographical information of a rectagle.
+               LocationCircle circle;       ///< The geographical information of a circle.
+               LocationPolygon polygon;                ///< The geographical information of a polygon.
+       };
+};
+
+GType location_boundary_get_type (void);
+#define LOCATION_TYPE_BOUNDARY (location_boundary_get_type ())
+
+/**
+ * @brief   Create a rectagular type of new #LocationBoundary with given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  left_top - left top position.
+ * @param [in]  right_bottom - right bottom position.
+ * @return a new #LocationBoundary
+ * @retval NULL if error occured
+ */
+LocationBoundary *location_boundary_new_for_rect (LocationPosition *left_top, LocationPosition *right_bottom);
+
+/**
+ * @brief   Create a circle type of new #LocationBoundary with  given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  center - center position.
+ * @param [in]  radius - radius.
+ * @return a new #LocationBoundary
+ * @retval NULL if error occured
+ */
+LocationBoundary *location_boundary_new_for_circle (LocationPosition *center, gdouble radius);
+
+/**
+ * @brief   Create a polygon type of new #LocationBoundary with  given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  position_list - the list of positions.
+ * @return a new #LocationBoundary
+ * @retval NULL if error occured
+ */
+LocationBoundary *location_boundary_new_for_polygon(GList *position_list);
+
+/**
+ * @brief   Free a #LocationBoundary.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] boundary - a #LocationBoundary.
+ * @return None.
+ */
+void location_boundary_free (LocationBoundary *boundary);
+
+/**
+ * @brief   Makes a copy of #LocationBoundary
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  boundary - a #LocationBoundary
+ * @return a new #LocationBoundary
+ * @retval NULL if error occured
+ */
+LocationBoundary *location_boundary_copy (const LocationBoundary* boundary);
+
+/**
+ * @brief
+ * Add Boundary on LocationFW.
+ * You should call this fuction when you want to receive a corssing signal(zone-in/zone-out) from #LocationBoundary.
+ * @remarks It suppoorts multi-boundaries. \n
+    However a duplicated boundary would not be allowed.
+ * @pre
+ * #location_new should be called before.\n
+ * @post None.
+ * @param [in]  obj - a #LocationObject
+ * @param [in]  boundary - a #LocationBoundary
+ * @return int
+ * @retval 0                              Success
+ * Please refer #LocationError for more information.
+ * @par Example
+ * @code
+#include <location.h>
+
+static void cb_zone_in (GObject *self, guint type, gpointer position, gpointer accuracy)
+{
+       g_printf ("[zone-in] position - lat: %f, long: %f", position->latitude, position->longitude);
+}
+
+static void cb_zone_out (GObject *self, guint type, gpointer position, gpointer accuracy)
+{
+       g_printf ("[zone-out] position - lat: %f, long: %f", position->latitude, position->longitude);
+}
+
+void location_test_boundary_add(LocationObject *loc)
+{
+       LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
+
+       LoationBoundary *boundary = location_boundary_new_for_rect (lt, rb);
+
+       ret = location_boundary_add(loc, boundary);
+
+       g_signal_connect(loc, "zone-in", G_CALLBACK(cb_zone_in), NULL);
+       g_siganl_connect(loc, "zone-out", G_CALLBACK(cb_zone_out), NULL);
+
+       location_position_free(rb);
+       location_position_free(lt);
+}
+ * @endcode
+ */
+int location_boundary_add(const LocationObject *obj, const LocationBoundary *boundary);
+
+/**
+ * @brief
+ * Remove Boundary on LocationFW.
+ * You should call this function when you don't want to receive a corssing signal(zone-in/zone-out) from #LocationBoundary any more.
+ * @remarks It suppoorts multi-boundaries.
+ * @pre
+ * #location_init should be called before.\n
+ * @post None.
+ * @param [in]  obj - a #LocationObject
+ * @param [in]  boundary - a #LocationBoundary
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @par Example
+ * @code
+#include <location.h>
+
+void location_test_boundary_remove(LocationObject *loc)
+{
+       int ret = 0;
+       LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
+
+       LoationBoundary *boundary = location_boundary_new_for_rect (lt, rb);
+
+       ret = location_boundary_remove(loc, boundary);
+
+       location_position_free(rb);
+       location_position_free(lt);
+
+}
+ * @endcode
+ */
+int location_boundary_remove(const LocationObject *obj, const LocationBoundary *boundary);
+
+/**
+ * @brief
+ * Call a function for each element of a Boundary list.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.\n
+ * @post None.
+ * @param [in]  obj - a #LocationObject
+ * @param [in]  func - a #LocationBoundaryFunc
+ * @param [in]  user_data - a #void
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @par Example
+ * @code
+#include <location.h>
+
+static void remove_boundary(LocationBoundary *boundary, void *user_data)
+{
+       LocationBoundary *loc = (LocationBoundary *) user_data;
+       if (loc == NULL || boundary == NULL) return;
+
+       location_boundary_remove(loc, boundary);
+}
+
+void location_test_boundary_foreach(LocationObject *loc)
+{
+       int ret = location_boundary_foreach(loc, remove_boundary, loc);
+}
+ * @endcode
+ */
+int location_boundary_foreach(const LocationObject *obj, LocationBoundaryFunc func, gpointer user_data);
+
+
+/**
+ * @brief   Check if #LocationPosition is inside #LocationBoundary.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.* @param [in]  boundary - a #LocationBoundary
+ * @param [in]  position - a #LocationPosition
+ * @return gboolean
+ * @retval\n
+ * TRUE - if inside\n
+ * FALSE - if outside\n
+ * @par Example
+ * @code
+#include <location.h>
+
+void location_test_boundary_if_inside(LocationObject *loc, LocationBoundary *boundary)
+{
+       gboolean is_inside = FALSE;
+       LocationPosition* position = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
+       is_inside = location_boundary_if_inside(boundary, position);
+       if (is_inside == TRUE) g_printf("The position is inside of the boundary\n");
+       else g_printf("The position is outside of the boundary\n");
+
+}
+ * @endcode
+
+ */
+gboolean location_boundary_if_inside (LocationBoundary *boundary, LocationPosition *position);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-common-util.c b/location/location-common-util.c
new file mode 100644 (file)
index 0000000..900bf30
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include "location.h"
+#include "location-common-util.h"
+#include "location-log.h"
+
+static gint compare_position (gconstpointer a, gconstpointer b)
+{
+       g_return_val_if_fail(a, 1);
+       g_return_val_if_fail(b, -1);
+
+       if(location_position_equal((LocationPosition*) a, (LocationPosition *)b) == TRUE) {
+               return 0;
+       }
+
+       return -1;
+}
+
+static int
+boundary_compare (gconstpointer comp1, gconstpointer comp2)
+{
+       g_return_val_if_fail(comp1, 1);
+       g_return_val_if_fail(comp2, -1);
+
+       int ret = -1;
+
+       LocationBoundary *boundary1 = (LocationBoundary *)comp1;
+       LocationBoundary *boundary2 = (LocationBoundary *)comp2;
+
+       if (boundary1->type == boundary2->type) {
+               switch (boundary1->type) {
+                       case LOCATION_BOUNDARY_CIRCLE: {
+                               if (location_position_equal(boundary1->circle.center, boundary2->circle.center)
+                                       && boundary1->circle.radius == boundary2->circle.radius) {
+                                       ret = 0;
+                               }
+                               break;
+                       }
+                       case LOCATION_BOUNDARY_RECT: {
+                               if (location_position_equal(boundary1->rect.left_top, boundary2->rect.left_top)
+                                       && location_position_equal(boundary1->rect.right_bottom, boundary2->rect.right_bottom)) {
+                                       ret = 0;
+                               }
+                               break;
+                       }
+                       case LOCATION_BOUNDARY_POLYGON: {
+
+                               GList *boundary1_next = NULL;
+                               GList *boundary2_start = NULL, *boundary2_prev = NULL, *boundary2_next = NULL;
+                               if (g_list_length(boundary1->polygon.position_list) != g_list_length(boundary2->polygon.position_list)) {
+                                       return -1;
+                               }
+
+                               // Find a matching index of Boundary2 with Boundary1's 1st postion.
+                               boundary2_start = g_list_find_custom(boundary2->polygon.position_list, g_list_nth_data(boundary1->polygon.position_list, 0), (GCompareFunc) compare_position);
+                               if (boundary2_start == NULL) return -1;
+
+                               boundary2_prev = g_list_previous(boundary2_start);
+                               boundary2_next = g_list_next(boundary2_start);
+                               if (boundary2_prev == NULL) boundary2_prev = g_list_last(boundary2->polygon.position_list);
+                               if (boundary2_next == NULL) boundary2_next = g_list_first(boundary2->polygon.position_list);
+
+                               boundary1_next = g_list_next(boundary1->polygon.position_list);
+                               if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_prev->data) == TRUE){
+                                       boundary1_next = g_list_next(boundary1_next);
+                                       while (boundary1_next) {
+                                               boundary2_prev = g_list_previous(boundary2_prev);
+                                               if (boundary2_prev == NULL) boundary2_prev = g_list_last(boundary2->polygon.position_list);
+                                               if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*) boundary2_prev->data) == FALSE){
+                                                       return -1;
+                                               }
+                                               boundary1_next = g_list_next(boundary1_next);
+                                       }
+                                       ret = 0;
+                               }
+                               else if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_next->data) == TRUE) {
+                                       boundary1_next = g_list_next(boundary1_next);
+                                       while(boundary1_next) {
+                                               boundary2_next = g_list_next(boundary2_next);
+                                               if (boundary2_next == NULL) boundary2_next = g_list_first(boundary2->polygon.position_list);
+                                               if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*) boundary2_next->data) == FALSE){
+                                                       return -1;
+                                               }
+                                               boundary1_next = g_list_next(boundary1_next);
+                                       }
+                                       ret = 0;
+                               }
+                               else {
+                                       return -1;
+                               }
+                               break;
+                       }
+                       default:{
+                                ret = -1;
+                                break;
+                       }
+
+               }
+       }
+
+       return ret;
+}
+
+int set_prop_boundary(GList **prev_boundary_list, GList *new_boundary_list)
+{
+       g_return_val_if_fail(new_boundary_list, LOCATION_ERROR_PARAMETER);
+
+       int index;
+       GList *check_list = NULL;
+
+       LocationBoundary *new_boundary = NULL;
+       LocationBoundary *copy_boundary = NULL;
+
+       index = 0;
+       while((new_boundary = (LocationBoundary*) g_list_nth_data(new_boundary_list, index)) != NULL) {
+
+               check_list = g_list_find_custom(*prev_boundary_list, new_boundary, (GCompareFunc)boundary_compare);
+               if (check_list == NULL) {
+                       LOCATION_LOGD("Set Prop >> boundary type: [%d]", new_boundary->type);
+                       copy_boundary = location_boundary_copy(new_boundary);
+                       *prev_boundary_list = g_list_append(*prev_boundary_list, copy_boundary);
+               }
+               index++;
+       }
+       *prev_boundary_list = g_list_first(*prev_boundary_list);
+
+       return LOCATION_ERROR_NONE;
+}
+
+
+
+int set_prop_removal_boundary(GList **prev_boundary_list, LocationBoundary* boundary)
+{
+       g_return_val_if_fail(*prev_boundary_list, LOCATION_ERROR_PARAMETER);
+
+       GList *check_list = NULL;
+
+       check_list = g_list_find_custom (*prev_boundary_list, boundary, (GCompareFunc) boundary_compare);
+       if (check_list) {
+               LOCATION_LOGD("Found");
+               *prev_boundary_list = g_list_delete_link(*prev_boundary_list, check_list);
+       }
+
+       if (g_list_length(*prev_boundary_list) == 0 ) {
+               LOCATION_LOGD("Boundary List is empty");
+               g_list_free(*prev_boundary_list);
+               *prev_boundary_list = NULL;
+       }
+
+       return LOCATION_ERROR_NONE;
+}
+
+
diff --git a/location/location-common-util.h b/location/location-common-util.h
new file mode 100644 (file)
index 0000000..8918b39
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_COMMON_UTIL_H__
+#define __LOCATION_COMMON_UTIL_H__
+
+#include <location/location.h>
+#include <location/location-ielement.h>
+
+/**
+ * @file location-common-util.h
+ * @brief This file contains the common utils for LocationObject.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+int set_prop_boundary(GList **prev_boundary_list, GList *new_boundary_list);
+int set_prop_removal_boundary(GList **prev_boundary_list, LocationBoundary *boundary);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-cps.c b/location/location-cps.c
new file mode 100644 (file)
index 0000000..c0c404a
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-cps.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+
+typedef struct _LocationCpsPrivate {
+       LocationCpsMod *mod;
+       LocationPosition *pos;
+       LocationAccuracy *acc;
+} LocationCpsPrivate;
+
+enum {
+       PROP_0,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION
+};
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_CPS, LocationCpsPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationCps, location_cps, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+static void
+location_cps_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_cps_dispose");
+       G_OBJECT_CLASS (location_cps_parent_class)->dispose (gobject);
+}
+
+static void
+location_cps_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_cps_finalize");
+       LocationCpsPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "cps");
+       priv->mod = NULL;
+
+       G_OBJECT_CLASS (location_cps_parent_class)->finalize (gobject);
+}
+
+static void
+location_cps_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationCpsPrivate *priv = GET_PRIVATE (object);
+
+       switch (property_id){
+               case PROP_METHOD_TYPE:
+                       g_value_set_int(value, LOCATION_METHOD_CPS);
+                       break;
+               case PROP_LAST_POSITION:{
+                       g_value_set_boxed (value, priv->pos);
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static int
+location_cps_get_position (LocationCps *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_cps_get_position");
+
+       LocationCpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(NETWORK_ENABLED);
+
+       LocModCpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
+       int ret = ops.get_position(priv->mod->handler, position, accuracy);
+       if(priv->pos) location_position_free(priv->pos);
+       if(priv->acc) location_accuracy_free(priv->acc);
+       priv->pos = location_position_copy(*position);
+       priv->acc = location_accuracy_copy(*accuracy);
+       return ret;
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->get_position = (TYPE_GET_POSITION)location_cps_get_position;
+}
+
+static void
+location_cps_init (LocationCps *self)
+{
+       LOCATION_LOGD("location_cps_init");
+       LocationCpsPrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationCpsMod*)module_new("cps");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+
+       priv->pos = NULL;
+       priv->acc = NULL;
+}
+
+static void
+location_cps_class_init (LocationCpsClass *klass)
+{
+       LOCATION_LOGD("location_cps_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GParamSpec *pspec;
+
+       gobject_class->get_property = location_cps_get_property;
+
+       gobject_class->dispose = location_cps_dispose;
+       gobject_class->finalize = location_cps_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationCpsPrivate));
+
+       pspec = g_param_spec_int ("method",
+                                "method type",
+                                "location method type name",
+                                LOCATION_METHOD_CPS,
+                                LOCATION_METHOD_CPS,
+                                LOCATION_METHOD_CPS,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_METHOD_TYPE,
+                                   pspec);
+
+       pspec = g_param_spec_boxed ("last-position",
+                                "cps last position prop",
+                                "cps last position data",
+                                LOCATION_TYPE_POSITION,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_LAST_POSITION,
+                                   pspec);
+}
+
diff --git a/location/location-cps.h b/location/location-cps.h
new file mode 100644 (file)
index 0000000..5effdf4
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_CPS_H__
+#define __LOCATION_CPS_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-cps.h
+ * @brief This file contains the internal definitions and structures related to CPS.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_CPS                  (location_cps_get_type ())
+#define LOCATION_CPS(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_CPS, LocationCps))
+#define LOCATION_IS_CPS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_CPS))
+#define LOCATION_CPS_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_CPS, LocationCpsClass))
+#define LOCATION_IS_CPS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_CPS))
+#define LOCATION_CPS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_CPS, LocationCpsClass))
+
+typedef struct _LocationCps        LocationCps;
+typedef struct _LocationCpsClass   LocationCpsClass;
+
+struct _LocationCps
+{
+       GObject parent_instance;
+};
+
+struct _LocationCpsClass
+{
+       GObjectClass parent_class;
+};
+
+GType location_cps_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-geocode.c b/location/location-geocode.c
new file mode 100644 (file)
index 0000000..666af95
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-geocode.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+
+typedef struct _LocationGeocodePrivate {
+       LocationGeoMod* mod;
+} LocationGeocodePrivate;
+
+enum {
+       PROP_0,
+       PROP_SERVICE_NAME
+};
+
+#define DEFAULT_SERVICE "decarta"
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_GEOCODE, LocationGeocodePrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationGeocode, location_geocode, G_TYPE_OBJECT,
+       G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
+
+
+static void
+location_geocode_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_geocode_dispose");
+
+       G_OBJECT_CLASS (location_geocode_parent_class)->dispose (gobject);
+}
+
+static void
+location_geocode_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_geocode_finalize");
+       LocationGeocodePrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "geocode");
+       priv->mod = NULL;
+       G_OBJECT_CLASS (location_geocode_parent_class)->finalize (gobject);
+}
+
+static void
+location_geocode_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationGeocodePrivate *priv = GET_PRIVATE (object);
+
+       g_return_if_fail(priv->mod);
+       g_return_if_fail(priv->mod->handler);
+       switch (property_id){
+       case PROP_SERVICE_NAME:{
+               char* service_name = NULL;
+               if(priv->mod->ops.get_service_name){
+                       if( LOCATION_ERROR_NONE != priv->mod->ops.get_service_name(priv->mod->handler, &service_name) ){
+                               service_name = NULL;
+                       }
+               }
+               LOCATION_LOGD("Get prop>> Service name: %s", service_name);
+               g_value_set_string(value, service_name);
+               g_free(service_name);
+               break;
+       }
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static int
+location_geocode_get_geocode (LocationGeocode *self,
+       const LocationAddress *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_geocode_get_geocode");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_geocode)(priv->mod->handler, address, position, accuracy);
+}
+
+static int
+location_geocode_get_geocode_freeform (LocationGeocode *self,
+       const gchar  *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_geocode_get_geocode_freeform");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_geocode_freetext, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_geocode_freetext)(priv->mod->handler, address, position, accuracy);
+}
+
+static int
+location_geocode_get_reversegeocode (LocationGeocode *self,
+       const LocationPosition *position,
+       LocationAddress **address,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_geocode_get_reversegeocode");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_reverse_geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_reverse_geocode)(priv->mod->handler, position, address, accuracy);
+}
+
+static int
+location_geocode_get_geocode_async (LocationGeocode *self,
+       LocationAddress *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_geocode_get_geocode_async");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_geocode_async)(priv->mod->handler, address, callback, userdata);
+}
+
+static int
+location_geocode_get_geocode_freeform_async (LocationGeocode *self,
+       const gchar *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_geocode_get_geocode_freeform_async");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_geocode_freetext_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_geocode_freetext_async)(priv->mod->handler, address, callback, userdata);
+}
+
+static int
+location_geocode_get_reversegeocode_async (LocationGeocode *self,
+       const LocationPosition *position,
+       LocationAddressCB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_geocode_get_reversegeocode_async");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_reverse_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_reverse_geocode_async)(priv->mod->handler, position, callback, userdata);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->get_geocode = (TYPE_GET_GEOCODE)location_geocode_get_geocode;
+       iface->get_geocode_freeform = (TYPE_GET_GEOCODE_FREEFORM)location_geocode_get_geocode_freeform;
+       iface->get_reversegeocode = (TYPE_GET_REVERSEGEOCODE)location_geocode_get_reversegeocode;
+       iface->get_geocode_async = (TYPE_GET_GEOCODE_ASYNC)location_geocode_get_geocode_async;
+       iface->get_geocode_freeform_async = (TYPE_GET_GEOCODE_FREEFORM_ASYNC)location_geocode_get_geocode_freeform_async;
+       iface->get_reversegeocode_async = (TYPE_GET_REVERSEGEOCODE_ASYNC)location_geocode_get_reversegeocode_async;
+}
+
+static void
+location_geocode_init (LocationGeocode *self)
+{
+       LOCATION_LOGD("location_geocode_init");
+       LocationGeocodePrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationGeoMod*)module_new("geocode");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+}
+
+static void
+location_geocode_class_init (LocationGeocodeClass *klass)
+{
+       LOCATION_LOGD("location_geocode_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GParamSpec *pspec;
+
+       gobject_class->get_property = location_geocode_get_property;
+
+       gobject_class->dispose = location_geocode_dispose;
+       gobject_class->finalize = location_geocode_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationGeocodePrivate));
+
+       pspec = g_param_spec_string ("service provider",
+                                "geocode service provider name prop",
+                                "geocode service provider name",
+                                DEFAULT_SERVICE,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_SERVICE_NAME,
+                                   pspec);
+}
diff --git a/location/location-geocode.h b/location/location-geocode.h
new file mode 100644 (file)
index 0000000..efb4ac1
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_GEOCODE_H__
+#define __LOCATION_GEOCODE_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-geocode.h
+ * @brief This file contains the internal definitions and structures related to geocode.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_GEOCODE                  (location_geocode_get_type ())
+#define LOCATION_GEOCODE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_GEOCODE, LocationGeocode))
+#define LOCATION_IS_GEOCODE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_GEOCODE))
+#define LOCATION_GEOCODE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_GEOCODE, LocationGeocodeClass))
+#define LOCATION_IS_GEOCODE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_GEOCODE))
+#define LOCATION_GEOCODE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_GEOCODE, LocationGeocodeClass))
+
+typedef struct _LocationGeocode        LocationGeocode;
+typedef struct _LocationGeocodeClass   LocationGeocodeClass;
+
+struct _LocationGeocode
+{
+       GObject parent_instance;
+};
+
+struct _LocationGeocodeClass
+{
+       GObjectClass parent_class;
+};
+
+GType location_geocode_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-gps.c b/location/location-gps.c
new file mode 100644 (file)
index 0000000..9ab8a76
--- /dev/null
@@ -0,0 +1,491 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-gps.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+#include "location/location-signaling-util.h"
+#include "location/location-common-util.h"
+
+
+typedef struct _LocationGpsPrivate {
+       LocationGpsMod*         mod;
+       gboolean                is_started;
+       gboolean                enabled;
+       guint                   interval;
+       LocationPosition*       pos;
+       LocationVelocity*       vel;
+       LocationAccuracy*       acc;
+       GList*                  boundary_list;
+       ZoneStatus              zone_status;
+} LocationGpsPrivate;
+
+enum {
+       PROP_0,
+       PROP_DEV_NAME,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION,
+       PROP_UPDATE_INTERVAL,
+       PROP_BOUNDARY,
+       PROP_REMOVAL_BOUNDARY,
+       PROP_NMEA,
+       PROP_SATELLITE,
+       PROP_MAX
+};
+
+static guint32 signals[LAST_SIGNAL] = {0, };
+static GParamSpec *properties[PROP_MAX] = {NULL, };
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_GPS, LocationGpsPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationGps, location_gps, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+static void
+gps_status_cb (gboolean enabled,
+       LocationStatus status,
+       gpointer self)
+{
+       LOCATION_LOGD("gps_status_cb");
+       g_return_if_fail(self);
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, status);
+}
+
+static void
+gps_position_cb (gboolean enabled,
+       LocationPosition *pos,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("gps_position_cb");
+       g_return_if_fail(self);
+       g_return_if_fail(pos);
+       g_return_if_fail(acc);
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, pos->status);
+       position_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->pos), &(priv->acc), priv->boundary_list, &(priv->zone_status), enabled, pos, acc);
+}
+
+static void
+gps_velocity_cb (gboolean enabled,
+       LocationVelocity *vel,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("gps_velocity_cb");
+       g_return_if_fail(self);
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       velocity_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->vel), enabled, vel, acc);
+}
+
+static void
+location_setting_gps_cb (keynode_t *key,
+       gpointer self)
+{
+       LOCATION_LOGD("location_setting_gps_cb");
+       g_return_if_fail(key);
+       g_return_if_fail(self);
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       if (0 == location_setting_get_key_val(key) && priv->mod->ops.stop) {
+               LOCATION_LOGD("location stopped by setting");
+               priv->mod->ops.stop(priv->mod->handler);
+       }
+       else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start) {
+               LOCATION_LOGD("location resumed by setting");
+               priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_position_cb, gps_velocity_cb, self);
+       }
+}
+
+static int
+location_gps_start (LocationGps *self)
+{
+       LOCATION_LOGD("location_gps_start");
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail (GPS_ENABLED);
+       if (priv->is_started == TRUE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_position_cb, gps_velocity_cb, self);
+       if (ret == LOCATION_ERROR_NONE) {
+               priv->is_started = TRUE;
+               location_setting_add_notify (GPS_ENABLED, location_setting_gps_cb, self);
+       }
+       return ret;
+}
+
+static int
+location_gps_stop (LocationGps *self)
+{
+       LOCATION_LOGD("location_gps_stop");
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
+       if (priv->is_started == FALSE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.stop (priv->mod->handler);
+       if (ret == LOCATION_ERROR_NONE) {
+               priv->is_started = FALSE;
+               location_setting_ignore_notify (GPS_ENABLED, location_setting_gps_cb);
+       }
+       return ret;
+}
+
+static void
+location_gps_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_gps_dispose");
+       G_OBJECT_CLASS (location_gps_parent_class)->dispose (gobject);
+}
+
+static void
+location_gps_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_gps_finalize");
+       LocationGpsPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "gps");
+       priv->mod = NULL;
+       G_OBJECT_CLASS (location_gps_parent_class)->finalize (gobject);
+}
+
+static void
+location_gps_set_property (GObject *object,
+       guint property_id,
+       const GValue *value,
+       GParamSpec *pspec)
+{
+       LocationGpsPrivate* priv = GET_PRIVATE(object);
+
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       LocModGpsOps ops = priv->mod->ops;
+
+       int ret = 0;
+       switch (property_id){
+               case PROP_DEV_NAME: {
+                       char* devname = g_value_dup_string(value);
+                       LOCATION_LOGD("Set prop>> device_name: %s", devname);
+                       if(ops.set_devname)
+                               ops.set_devname(priv->mod->handler, devname);
+                       g_free(devname);
+                       break;
+               }
+               case PROP_BOUNDARY: {
+                       GList *boundary_list = g_list_copy(g_value_get_pointer(value));
+                       ret = set_prop_boundary(&priv->boundary_list, boundary_list);
+                       if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_REMOVAL_BOUNDARY: {
+                       LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value);
+                       ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
+                       if(ret != 0) LOCATION_LOGD("Removal boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_UPDATE_INTERVAL: {
+                       guint interval = g_value_get_uint(value);
+                       LOCATION_LOGD("Set prop>> update-interval: %u", interval);
+                       if(interval > 0) {
+                               if(interval < LOCATION_UPDATE_INTERVAL_MAX)
+                                       priv->interval = interval;
+                               else
+                                       priv->interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
+                       }
+                       else
+                               priv->interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static void
+location_gps_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationGpsPrivate *priv = GET_PRIVATE (object);
+
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       LocModGpsOps ops = priv->mod->ops;
+       switch (property_id) {
+               case PROP_DEV_NAME: {
+                       char* devname = NULL;
+                       if(ops.get_devname)
+                               ops.get_devname(priv->mod->handler, &devname);
+                       LOCATION_LOGD ("Get prop>> device_name: %s", devname);
+                       g_value_set_string (value, devname);
+                       g_free(devname);
+                       break;
+               }
+               case PROP_METHOD_TYPE:
+                       g_value_set_int(value, LOCATION_METHOD_GPS);
+                       break;
+               case PROP_LAST_POSITION:
+                       g_value_set_boxed (value, priv->pos);
+                       break;
+               case PROP_UPDATE_INTERVAL:
+                       g_value_set_uint(value, priv->interval);
+                       break;
+               case PROP_BOUNDARY:
+                       g_value_set_pointer(value, g_list_first(priv->boundary_list));
+                       break;
+               case PROP_NMEA: {
+                       char *nmea_data = NULL;
+                       if (ops.get_nmea &&  LOCATION_ERROR_NONE == ops.get_nmea(priv->mod->handler, &nmea_data) && nmea_data) {
+                               LOCATION_LOGD("Get prop>> Lastest nmea: \n%s", nmea_data);
+                               g_value_set_string(value, nmea_data);
+                               g_free(nmea_data);
+                       } else {
+                               LOCATION_LOGW("Get prop>> Lastest nmea: failed");
+                               g_value_set_string(value, NULL);
+                       }
+                       break;
+               }
+               case PROP_SATELLITE: {
+                       LocationSatellite *satellite = NULL;
+                       if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite){
+                               LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
+                               g_value_set_boxed (value, satellite);
+                               location_satellite_free(satellite);
+                       } else {
+                               LOCATION_LOGW("Get prop>> Last sat: failed");
+                               g_value_set_boxed (value, NULL);
+                       }
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static int
+location_gps_get_position (LocationGps *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_gps_get_position");
+
+       LocationGpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+
+       LocModGpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_position(priv->mod->handler, position, accuracy);
+}
+
+static int
+location_gps_get_velocity (LocationGps *self,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_gps_get_velocity");
+
+       LocationGpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+
+       LocModGpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_velocity(priv->mod->handler, velocity, accuracy);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->start = (TYPE_START_FUNC)location_gps_start;
+       iface->stop = (TYPE_STOP_FUNC)location_gps_stop;
+       iface->get_position = (TYPE_GET_POSITION)location_gps_get_position;
+       iface->get_velocity = (TYPE_GET_VELOCITY)location_gps_get_velocity;
+}
+
+static void
+location_gps_init (LocationGps *self)
+{
+       LOCATION_LOGD("location_gps_init");
+       LocationGpsPrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationGpsMod*)module_new("gps");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+
+       priv->is_started = FALSE;
+       priv->enabled= FALSE;
+       priv->interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+
+       priv->pos = NULL;
+       priv->vel = NULL;
+       priv->acc = NULL;
+       priv->zone_status = ZONE_STATUS_NONE;
+       priv->boundary_list = NULL;
+}
+
+static void
+location_gps_class_init (LocationGpsClass *klass)
+{
+       LOCATION_LOGD("location_gps_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+       gobject_class->set_property = location_gps_set_property;
+       gobject_class->get_property = location_gps_get_property;
+
+       gobject_class->dispose = location_gps_dispose;
+       gobject_class->finalize = location_gps_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationGpsPrivate));
+
+       signals[SERVICE_ENABLED] = g_signal_new ("service-enabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationGpsClass, enabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_DISABLED] = g_signal_new ("service-disabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationGpsClass, disabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_UPDATED] = g_signal_new ("service-updated",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationGpsClass, updated),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_IN] = g_signal_new ("zone-in",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationGpsClass, zone_in),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_OUT] = g_signal_new ("zone-out",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationGpsClass, zone_out),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       properties[PROP_DEV_NAME] = g_param_spec_string ("dev-name",
+                       "gps device name prop",
+                       "gps device name",
+                       "/dev/rfcomm0",
+                       G_PARAM_READWRITE);
+
+       properties[PROP_METHOD_TYPE] = g_param_spec_int ("method",
+                       "method type",
+                       "location method type name",
+                       LOCATION_METHOD_GPS,
+                       LOCATION_METHOD_GPS,
+                       LOCATION_METHOD_GPS,
+                       G_PARAM_READABLE);
+
+       properties[PROP_LAST_POSITION]  = g_param_spec_boxed ("last-position",
+                       "gps last position prop",
+                       "gps last position data",
+                       LOCATION_TYPE_POSITION,
+                       G_PARAM_READABLE);
+
+       properties[PROP_UPDATE_INTERVAL] = g_param_spec_uint ("update-interval",
+                       "gps update interval prop",
+                       "gps update interval data",
+                       LOCATION_UPDATE_INTERVAL_MIN,
+                       LOCATION_UPDATE_INTERVAL_MAX,
+                       LOCATION_UPDATE_INTERVAL_DEFAULT,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary",
+                       "gps boundary prop",
+                       "gps boundary data",
+                       G_PARAM_READWRITE);
+
+       properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary",
+                       "gps removal boundary prop",
+                       "gps removal boundary data",
+                       LOCATION_TYPE_BOUNDARY,
+                       G_PARAM_READWRITE);
+
+
+       properties[PROP_NMEA] = g_param_spec_string ("nmea",
+                       "gps NMEA name prop",
+                       "gps NMEA",
+                       NULL,
+                       G_PARAM_READABLE);
+
+       properties[PROP_SATELLITE] = g_param_spec_boxed ("satellite",
+                       "gps satellite prop",
+                       "gps satellite data",
+                       LOCATION_TYPE_SATELLITE,
+                       G_PARAM_READABLE);
+
+       g_object_class_install_properties (gobject_class,
+                       PROP_MAX,
+                       properties);
+
+}
diff --git a/location/location-gps.h b/location/location-gps.h
new file mode 100644 (file)
index 0000000..418bcf1
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_GPS_H__
+#define __LOCATION_GPS_H__
+
+#include <glib-object.h>
+
+
+/**
+ * @file location-gps.h
+ * @brief This file contains the internal definitions and structures related to GPS.
+ * @defgroup LocationInternal Location Internal
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_GPS                  (location_gps_get_type ())
+#define LOCATION_GPS(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_GPS, LocationGps))
+#define LOCATION_IS_GPS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_GPS))
+#define LOCATION_GPS_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_GPS, LocationGpsClass))
+#define LOCATION_IS_GPS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_GPS))
+#define LOCATION_GPS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_GPS, LocationGpsClass))
+
+typedef struct _LocationGps        LocationGps;
+typedef struct _LocationGpsClass   LocationGpsClass;
+
+struct _LocationGps
+{
+       GObject parent_instance;
+};
+
+struct _LocationGpsClass
+{
+       GObjectClass parent_class;
+
+       void (* enabled) (guint type);
+       void (* disabled) (guint type);
+       void (* updated) (guint type, gpointer data, gpointer accuracy);
+       void (* zone_in) (guint type, gpointer position, gpointer boundary);
+       void (* zone_out) (guint type, gpointer position, gpointer boundary);
+};
+
+GType location_gps_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-hybrid.c b/location/location-hybrid.c
new file mode 100644 (file)
index 0000000..db054a7
--- /dev/null
@@ -0,0 +1,567 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-hybrid.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+#include "location/location-signaling-util.h"
+#include "location/location-common-util.h"
+
+#include "location/location-gps.h"
+#include "location/location-wps.h"
+#include "location/location-sps.h"
+
+typedef struct _LocationHybridPrivate {
+       gboolean is_started;
+       gboolean gps_enabled;
+       gboolean wps_enabled;
+       gboolean sps_enabled;
+       guint interval;
+       LocationObject *gps;
+       LocationObject *wps;
+       LocationObject *sps;
+       gboolean enabled;
+       LocationMethod current_method;
+       LocationPosition *pos;
+       LocationVelocity *vel;
+       LocationAccuracy *acc;
+       GList* boundary_list;
+       ZoneStatus zone_status;
+
+} LocationHybridPrivate;
+
+enum {
+       PROP_0,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION,
+       PROP_UPDATE_INTERVAL,
+       PROP_BOUNDARY,
+       PROP_REMOVAL_BOUNDARY,
+       PROP_MAX
+};
+
+static guint32 signals[LAST_SIGNAL] = {0, };
+static GParamSpec *properties[PROP_MAX] = {NULL, };
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_HYBRID, LocationHybridPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationHybrid, location_hybrid, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+
+static LocationObject*
+hybrid_get_update_method_obj (LocationHybridPrivate* priv)
+{
+       if(!priv->sps && !priv->gps && !priv->wps) return NULL;
+
+       LocationObject* obj = NULL;
+       if (priv->sps_enabled) {
+               LOCATION_LOGW("Current method is SPS");
+               priv->current_method = LOCATION_METHOD_SPS;
+               obj = priv->sps;
+       } else if (priv->gps_enabled) {
+               LOCATION_LOGW("Current method is GPS");
+               priv->current_method = LOCATION_METHOD_GPS;
+               obj = priv->gps;
+       } else if (priv->wps_enabled) {
+               LOCATION_LOGW("Current method is WPS");
+               priv->current_method = LOCATION_METHOD_WPS;
+               obj = priv->wps;
+       } else {
+               LOCATION_LOGW("No current method available");
+               priv->current_method = LOCATION_METHOD_HYBRID;
+               obj = NULL;
+       }
+       return obj;
+}
+
+static gboolean
+hyrid_is_equal_g_type_method(GType g_type, LocationMethod method)
+{
+       if (g_type == LOCATION_TYPE_SPS && method == LOCATION_METHOD_SPS) return TRUE;
+       if (g_type == LOCATION_TYPE_GPS && method == LOCATION_METHOD_GPS) return TRUE;
+       if (g_type == LOCATION_TYPE_WPS && method == LOCATION_METHOD_WPS) return TRUE;
+       return FALSE;
+}
+
+static void
+hybrid_update_sps(LocationHybrid* self,
+       guint type,
+       gpointer data,
+       gpointer accuracy)
+{
+       LocationHybridPrivate* priv = GET_PRIVATE(self);
+       if (!priv->sps) return;
+       LOCATION_LOGD ("hybrid_update_sps");
+
+       switch (type) {
+               case POSITION_UPDATED: {
+                       if (data) g_object_set(priv->sps, "position-base", data, NULL);
+                       if (priv->gps) {
+                               LocationSatellite* sat = NULL;
+                               g_object_get(priv->gps, "satellite", &sat, NULL);
+                               if (sat) {
+                                       g_object_set(priv->sps, "satellite-info", sat, NULL);
+                                       location_satellite_free (sat);
+                               }
+                       }
+                       if (accuracy) g_object_set(priv->sps, "accuracy-info", accuracy, NULL);
+                       break;
+               }
+               case VELOCITY_UPDATED:
+                       if (data) g_object_set(priv->sps, "velocity-base", data, NULL);
+                       if (accuracy) g_object_set(priv->sps, "accuracy-info", accuracy, NULL);
+                       break;
+       }
+}
+
+static void
+hybrid_service_updated (GObject *obj,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer self)
+{
+       LOCATION_LOGD ("hybrid_service_updated");
+       LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
+       GType g_type = G_TYPE_FROM_INSTANCE(obj);
+       if (g_type == LOCATION_TYPE_GPS) hybrid_update_sps((LocationHybrid*)self, type, data, accuracy);
+       if (hyrid_is_equal_g_type_method(g_type, priv->current_method)) {
+               LocationAccuracy *acc = (LocationAccuracy*)accuracy;
+               if (type == POSITION_UPDATED) {
+                       LocationPosition *pos = (LocationPosition*)data;
+                       position_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->pos), &(priv->acc), priv->boundary_list, &(priv->zone_status), TRUE, pos, acc);
+               } else if (type == VELOCITY_UPDATED) {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       velocity_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->vel), TRUE, vel, acc);
+               } else LOCATION_LOGW ("Undefined GType updated");
+       }
+
+}
+
+static void
+hybrid_service_enabled (GObject *obj,
+       guint status,
+       gpointer self)
+{
+       LOCATION_LOGD ("hybrid_service_enabled");
+       LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
+       GType g_type = G_TYPE_FROM_INSTANCE(obj);
+       if (g_type == LOCATION_TYPE_SPS)     priv->sps_enabled = TRUE;
+       else if(g_type == LOCATION_TYPE_GPS) priv->gps_enabled = TRUE;
+       else if(g_type == LOCATION_TYPE_WPS) priv->wps_enabled = TRUE;
+       else {
+               LOCATION_LOGW("Undefined GType enabled");
+               return;
+       }
+       hybrid_get_update_method_obj(priv);
+       if(priv->sps_enabled || priv->gps_enabled || priv->wps_enabled)
+               enable_signaling(self, signals, &(priv->enabled), TRUE, status);
+}
+
+static void
+hybrid_service_disabled (GObject *obj,
+       guint status,
+       gpointer self)
+{
+       LOCATION_LOGD ("hybrid_service_disabled");
+       LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
+       GType g_type = G_TYPE_FROM_INSTANCE(obj);
+       if (g_type == LOCATION_TYPE_SPS)     priv->sps_enabled = FALSE;
+       else if(g_type == LOCATION_TYPE_GPS) priv->gps_enabled = FALSE;
+       else if(g_type == LOCATION_TYPE_WPS) priv->wps_enabled = FALSE;
+       else {
+               LOCATION_LOGW("Undefined GType disabled");
+               return;
+       }
+       hybrid_get_update_method_obj(priv);
+       if(!priv->sps_enabled && !priv->gps_enabled && !priv->wps_enabled)
+               enable_signaling(self, signals, &(priv->enabled), FALSE, status);
+}
+
+static int
+location_hybrid_start (LocationHybrid *self)
+{
+       LOCATION_LOGD("location_hybrid_start");
+       setting_retval_if_fail(GPS_ENABLED);
+
+       int ret_gps = LOCATION_ERROR_NONE;
+       int ret_wps = LOCATION_ERROR_NONE;
+       int ret_sps = LOCATION_ERROR_NONE;
+
+       LocationHybridPrivate* priv = GET_PRIVATE(self);
+       if (priv->is_started == TRUE)
+               return LOCATION_ERROR_NONE;
+
+       if(priv->gps) ret_gps = location_start(priv->gps);
+       if(priv->wps) ret_wps = location_start(priv->wps);
+       if(priv->sps) ret_sps = location_start(priv->sps);
+
+       if (ret_gps != LOCATION_ERROR_NONE &&
+               ret_wps != LOCATION_ERROR_NONE &&
+               ret_sps != LOCATION_ERROR_NONE)
+               return LOCATION_ERROR_NOT_AVAILABLE;
+
+       priv->is_started = TRUE;
+       return LOCATION_ERROR_NONE;
+}
+
+static int
+location_hybrid_stop (LocationHybrid *self)
+{
+       LOCATION_LOGD("location_hybrid_stop");
+
+       LocationHybridPrivate* priv = GET_PRIVATE(self);
+       if( priv->is_started == FALSE)
+               return LOCATION_ERROR_NONE;
+
+       int ret_gps = LOCATION_ERROR_NONE;
+       int ret_wps = LOCATION_ERROR_NONE;
+       int ret_sps = LOCATION_ERROR_NONE;
+
+       if(priv->gps) ret_gps = location_stop(priv->gps);
+       if(priv->wps) ret_wps = location_stop(priv->wps);
+       if(priv->sps) ret_sps = location_stop(priv->sps);
+
+       if (ret_gps != LOCATION_ERROR_NONE &&
+               ret_wps != LOCATION_ERROR_NONE &&
+               ret_sps != LOCATION_ERROR_NONE)
+               return LOCATION_ERROR_NOT_AVAILABLE;
+
+       priv->is_started = FALSE;
+       return LOCATION_ERROR_NONE;
+}
+
+static void
+location_hybrid_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_hybrid_dispose");
+       G_OBJECT_CLASS (location_hybrid_parent_class)->dispose (gobject);
+}
+
+static void
+location_hybrid_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_hybrid_finalize");
+       LocationHybridPrivate* priv = GET_PRIVATE(gobject);
+
+       if (priv->gps) {
+               g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_enabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_disabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_updated), gobject);
+               location_free(priv->gps);
+       }
+       if (priv->wps) {
+               g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_enabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_disabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_updated), gobject);
+               location_free(priv->wps);
+       }
+       if (priv->sps) {
+               g_signal_handlers_disconnect_by_func(priv->sps, G_CALLBACK (hybrid_service_enabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->sps, G_CALLBACK (hybrid_service_disabled), gobject);
+               g_signal_handlers_disconnect_by_func(priv->sps, G_CALLBACK (hybrid_service_updated), gobject);
+               location_free(priv->sps);
+       }
+
+       G_OBJECT_CLASS (location_hybrid_parent_class)->finalize (gobject);
+}
+
+static void
+location_hybrid_set_property (GObject *object,
+       guint property_id,
+       const GValue *value,
+       GParamSpec *pspec)
+{
+       LocationHybridPrivate* priv = GET_PRIVATE(object);
+       if (!priv->gps && !priv->wps && !priv->sps) {
+               LOCATION_LOGW("Set property is not available now");
+               return;
+       }
+
+       int ret = 0;
+       switch (property_id){
+               case PROP_BOUNDARY:{
+                       GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value));
+                       ret = set_prop_boundary(&priv->boundary_list, boundary_list);
+                       if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret);
+                  break;
+               }
+               case PROP_REMOVAL_BOUNDARY: {
+                       LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value);
+                       ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
+                       if(ret != 0) LOCATION_LOGD("Removal boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_UPDATE_INTERVAL: {
+                       guint interval = g_value_get_uint(value);
+                       if(interval > 0) {
+                               if(interval < LOCATION_UPDATE_INTERVAL_MAX)
+                                       priv->interval = interval;
+                               else
+                                       priv->interval = (guint) LOCATION_UPDATE_INTERVAL_MAX;
+
+                       }
+                       else
+                               priv->interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static void
+location_hybrid_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationHybridPrivate *priv = GET_PRIVATE (object);
+       if(!priv->gps && !priv->wps && !priv->sps){
+               LOCATION_LOGW("Get property is not available now");
+               return;
+       }
+
+       LOCATION_LOGW("Get Propery ID[%d]", property_id);
+
+       switch (property_id){
+       case PROP_METHOD_TYPE:
+               g_value_set_int(value, priv->current_method);
+               break;
+       case PROP_LAST_POSITION:
+               g_value_set_boxed(value, priv->pos);
+               break;
+       case PROP_BOUNDARY:
+               g_value_set_pointer(value, g_list_first(priv->boundary_list));
+               break;
+       case PROP_UPDATE_INTERVAL:
+               g_value_set_uint(value, priv->interval);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static int
+location_hybrid_get_position (LocationHybrid *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_hybrid_get_position");
+       setting_retval_if_fail(GPS_ENABLED);
+
+       LocationHybridPrivate *priv = GET_PRIVATE (self);
+       LocationObject *obj = hybrid_get_update_method_obj(priv);
+       if(!obj) return LOCATION_ERROR_NOT_AVAILABLE;
+       return location_get_position (obj, position, accuracy);
+}
+
+static int
+location_hybrid_get_velocity (LocationHybrid *self,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_hybrid_get_velocity");
+       setting_retval_if_fail(GPS_ENABLED);
+
+       LocationHybridPrivate *priv = GET_PRIVATE (self);
+       LocationObject *obj = hybrid_get_update_method_obj(priv);
+       if(!obj) return LOCATION_ERROR_NOT_AVAILABLE;
+       return location_get_velocity (obj, velocity, accuracy);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->start = (TYPE_START_FUNC)location_hybrid_start;
+       iface->stop = (TYPE_STOP_FUNC)location_hybrid_stop;
+       iface->get_position = (TYPE_GET_POSITION)location_hybrid_get_position;
+       iface->get_velocity = (TYPE_GET_VELOCITY)location_hybrid_get_velocity;
+}
+
+static void
+location_hybrid_init (LocationHybrid *self)
+{
+       LOCATION_LOGD("location_hybrid_init");
+       LocationHybridPrivate* priv = GET_PRIVATE(self);
+
+       priv->is_started = FALSE;
+       priv->interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+       priv->gps_enabled = FALSE;
+       priv->wps_enabled = FALSE;
+       priv->sps_enabled = FALSE;
+       priv->gps = NULL;
+       priv->wps = NULL;
+       priv->sps = NULL;
+
+       if(location_is_supported_method(LOCATION_METHOD_GPS)) priv->gps = location_new (LOCATION_METHOD_GPS);
+       if(location_is_supported_method(LOCATION_METHOD_WPS)) priv->wps = location_new (LOCATION_METHOD_WPS);
+       if(location_is_supported_method(LOCATION_METHOD_SPS)) priv->sps = location_new (LOCATION_METHOD_SPS);
+
+       if(priv->gps){
+               g_signal_connect (priv->gps, "service-enabled", G_CALLBACK(hybrid_service_enabled), self);
+               g_signal_connect (priv->gps, "service-disabled", G_CALLBACK(hybrid_service_disabled), self);
+               g_signal_connect (priv->gps, "service-updated", G_CALLBACK(hybrid_service_updated), self);
+       }
+       if(priv->wps){
+               g_signal_connect (priv->wps, "service-enabled", G_CALLBACK(hybrid_service_enabled), self);
+               g_signal_connect (priv->wps, "service-disabled", G_CALLBACK(hybrid_service_disabled), self);
+               g_signal_connect (priv->wps, "service-updated", G_CALLBACK(hybrid_service_updated), self);
+       }
+       if(priv->sps){
+               g_signal_connect (priv->sps, "service-enabled", G_CALLBACK(hybrid_service_enabled), self);
+               g_signal_connect (priv->sps, "service-disabled", G_CALLBACK(hybrid_service_disabled), self);
+               g_signal_connect (priv->sps, "service-updated", G_CALLBACK(hybrid_service_updated), self);
+       }
+
+       priv->current_method = LOCATION_METHOD_HYBRID;
+       priv->enabled= FALSE;
+
+       priv->pos = NULL;
+       priv->vel = NULL;
+       priv->acc = NULL;
+       priv->zone_status = ZONE_STATUS_NONE;
+       priv->boundary_list = NULL;
+}
+
+static void
+location_hybrid_class_init (LocationHybridClass *klass)
+{
+       LOCATION_LOGD("location_hybrid_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+       gobject_class->set_property = location_hybrid_set_property;
+       gobject_class->get_property = location_hybrid_get_property;
+
+       gobject_class->dispose = location_hybrid_dispose;
+       gobject_class->finalize = location_hybrid_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationHybridPrivate));
+
+       signals[SERVICE_ENABLED] = g_signal_new ("service-enabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationHybridClass, enabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_DISABLED] = g_signal_new ("service-disabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationHybridClass, disabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_UPDATED] = g_signal_new ("service-updated",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationHybridClass, updated),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_IN] = g_signal_new ("zone-in",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationHybridClass, zone_in),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_OUT] = g_signal_new ("zone-out",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationHybridClass, zone_out),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       properties[PROP_METHOD_TYPE] = g_param_spec_int ("method",
+                       "method type",
+                       "location method type name",
+                       LOCATION_METHOD_HYBRID,
+                       LOCATION_METHOD_HYBRID,
+                       LOCATION_METHOD_HYBRID,
+                       G_PARAM_READABLE);
+
+       properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position",
+                       "hybrid last position prop",
+                       "hybrid last position data",
+                       LOCATION_TYPE_POSITION,
+                       G_PARAM_READABLE);
+
+       properties[PROP_UPDATE_INTERVAL] = g_param_spec_uint ("update-interval",
+                       "update interval prop",
+                       "update interval data",
+                       LOCATION_UPDATE_INTERVAL_MIN,
+                       LOCATION_UPDATE_INTERVAL_MAX,
+                       LOCATION_UPDATE_INTERVAL_DEFAULT,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_BOUNDARY]  = g_param_spec_pointer ("boundary",
+                       "hybrid boundary prop",
+                       "hybrid boundary data",
+                       G_PARAM_READWRITE);
+
+       properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary",
+                       "hybrid removal boundary prop",
+                       "hybrid removal boundary data",
+                       LOCATION_TYPE_BOUNDARY,
+                       G_PARAM_READWRITE);
+
+       g_object_class_install_properties (gobject_class,
+                       PROP_MAX,
+                       properties);
+
+}
diff --git a/location/location-hybrid.h b/location/location-hybrid.h
new file mode 100644 (file)
index 0000000..b7434c3
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_HYBRID_H__
+#define __LOCATION_HYBRID_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-hybrid.h
+ * @brief This file contains the internal definitions and structures related to Hybrid method.
+ * @addtogroup LocationInternal
+ * @{
+ *@}
+ */
+
+G_BEGIN_DECLS
+
+typedef struct _LocationHybrid        LocationHybrid;
+typedef struct _LocationHybridClass   LocationHybridClass;
+
+#define LOCATION_TYPE_HYBRID               (location_hybrid_get_type ())
+#define LOCATION_HYBRID(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_HYBRID, LocationHybrid))
+#define LOCATION_IS_HYBRID(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_HYBRID))
+#define LOCATION_HYBRID_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_HYBRID, LocationHybridClass))
+#define LOCATION_IS_HYBRID_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_HYBRID))
+#define LOCATION_HYBRID_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_HYBRID, LocationHybridClass))
+
+struct _LocationHybrid
+{
+       GObject parent_instance;
+};
+
+struct _LocationHybridClass
+{
+       GObjectClass parent_class;
+
+       void (* enabled) (guint type);
+       void (* disabled) (guint type);
+       void (* updated) (guint type, gpointer data, gpointer accuracy);
+       void (* zone_in) (guint type, gpointer position, gpointer boundary);
+       void (* zone_out) (guint type, gpointer position, gpointer boundary);
+};
+
+GType location_hybrid_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-ielement.c b/location/location-ielement.c
new file mode 100644 (file)
index 0000000..ea62ae8
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-log.h"
+#include "location/location-ielement.h"
+
+static void
+location_ielement_base_init (gpointer g_class)
+{
+       static gboolean is_initialized = FALSE;
+
+       if (is_initialized){
+               /* add properties and signals to the interface here */
+
+               is_initialized = TRUE;
+       }
+}
+
+GType
+location_ielement_get_type (void)
+{
+       static GType iface_type = 0;
+
+       if (iface_type == 0) {
+               static const GTypeInfo info = {
+                       sizeof (LocationIElementInterface),
+                       location_ielement_base_init, /* base_init */
+                       NULL /* base_finalize */
+               };
+
+               iface_type = g_type_register_static (G_TYPE_INTERFACE, "LocationIElement",
+                                            &info, 0);
+       }
+
+       return iface_type;
+}
+
+int
+location_ielement_start (LocationIElement *self)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->start, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->start (self);
+}
+
+int
+location_ielement_stop (LocationIElement *self)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->stop, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->stop (self);
+}
+
+int
+location_ielement_get_position (LocationIElement *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_position, LOCATION_ERROR_NOT_AVAILABLE);
+
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_position (self, position, accuracy);
+}
+
+int
+location_ielement_get_velocity (LocationIElement *self,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity (self, velocity, accuracy);
+}
+
+int
+location_ielement_get_geocode (LocationIElement *self,
+       const LocationAddress *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode (self, address, position, accuracy);
+}
+
+int
+location_ielement_get_geocode_freeform (LocationIElement *self,
+       const gchar *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform (self, address, position, accuracy);
+}
+
+int
+location_ielement_get_reversegeocode (LocationIElement *self,
+       const LocationPosition *position,
+       LocationAddress **address,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode (self, position, address, accuracy);
+}
+
+int
+location_ielement_get_geocode_async (LocationIElement *self,
+       const LocationAddress *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async (self, address, callback, userdata);
+}
+
+int
+location_ielement_get_geocode_freeform_async (LocationIElement *self,
+       const gchar *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async (self, address, callback, userdata);
+}
+
+int
+location_ielement_get_reversegeocode_async (LocationIElement *self,
+       const LocationPosition *position,
+       LocationAddressCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async (self, position, callback, userdata);
+}
+
+int
+location_ielement_get_poi (LocationIElement *self,
+       gdouble radius,
+       const gchar* keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi(self, radius, keyword, poi_info);
+}
+
+int
+location_ielement_get_poi_from_address (LocationIElement *self,
+       const LocationAddress* address,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address(self, address, radius, keyword, poi_info);
+}
+
+int
+location_ielement_get_poi_from_position (LocationIElement *self,
+       const LocationPosition *position,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position(self, position, radius, keyword, poi_info);
+}
+
+int
+location_ielement_get_poi_async (LocationIElement *self,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_async (self, radius, keyword, callback, userdata);
+}
+
+int
+location_ielement_get_poi_from_address_async (LocationIElement *self,
+       const LocationAddress *address,
+       gdouble radius,
+       const gchar* keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address_async (self, address, radius, keyword, callback, userdata);
+}
+
+
+
+int location_ielement_get_poi_from_position_async (LocationIElement *self,
+       const LocationPosition* position,
+       gdouble radius,
+       const gchar* keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position_async (self, position, radius, keyword, callback, userdata);
+}
diff --git a/location/location-ielement.h b/location/location-ielement.h
new file mode 100644 (file)
index 0000000..39a4815
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_IELEMENT_H__
+#define __LOCATION_IELEMENT_H__
+
+#include <glib-object.h>
+#include <location/location-types.h>
+#include <location/location-position.h>
+#include <location/location-velocity.h>
+#include <location/location-accuracy.h>
+#include <location/location-address.h>
+#include <location/location-boundary.h>
+#include <location/location-satellite.h>
+#include <location/location-poi-info.h>
+
+/**
+ * @file location-ielement.h
+ * @brief This file contains the internal definitions and structures related to location interface.
+ * @addtogroup LocationInternal
+ * @{
+ *@}
+ */
+
+G_BEGIN_DECLS
+
+enum {
+       SERVICE_ENABLED,
+       SERVICE_DISABLED,
+       SERVICE_UPDATED,
+       ZONE_IN,
+       ZONE_OUT,
+       LAST_SIGNAL
+};
+
+#define LOCATION_TYPE_IELEMENT                  (location_ielement_get_type ())
+#define LOCATION_IELEMENT(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_IELEMENT, LocationIElement))
+#define LOCATION_IS_IELEMENT(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_IELEMENT))
+#define LOCATION_IELEMENT_GET_INTERFACE(obj)    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), LOCATION_TYPE_IELEMENT, LocationIElementInterface))
+
+typedef struct _LocationIElement          LocationIElement;
+typedef struct _LocationIElementInterface LocationIElementInterface;
+
+typedef int (*TYPE_START_FUNC)(LocationIElement *self);
+typedef int (*TYPE_STOP_FUNC) (LocationIElement *self);
+typedef int (*TYPE_GET_POSITION)(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy);
+typedef int (*TYPE_GET_VELOCITY)(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy);
+typedef int (*TYPE_GET_GEOCODE)(LocationIElement *self, const LocationAddress *address, LocationPosition **position, LocationAccuracy **accuracy);
+typedef int (*TYPE_GET_GEOCODE_FREEFORM)(LocationIElement *self, const gchar *address, LocationPosition **position, LocationAccuracy **accuracy);
+typedef int (*TYPE_GET_REVERSEGEOCODE)(LocationIElement *self, const LocationPosition *position, LocationAddress **address, LocationAccuracy **accuracy);
+typedef int (*TYPE_GET_GEOCODE_ASYNC)(LocationIElement *self, const LocationAddress *address, LocationPositionCB callback, gpointer userdata);
+typedef int (*TYPE_GET_GEOCODE_FREEFORM_ASYNC)(LocationIElement *self, const gchar *address,  LocationPositionCB callback, gpointer userdata);
+typedef int (*TYPE_GET_REVERSEGEOCODE_ASYNC)(LocationIElement *self, const LocationPosition *position, LocationAddressCB callback, gpointer userdata);
+typedef int (*TYPE_GET_POI)(LocationIElement *self, gdouble radius, const gchar* keyword, LocationPOIInfo** poi);
+typedef int (*TYPE_GET_POI_ASYNC)(LocationIElement *self, gdouble radius, const gchar* keyword, LocationPOICB callback, gpointer userdata);
+typedef int (*TYPE_GET_POI_FROM_ADDRESS)(LocationIElement *self, const LocationAddress* address, gdouble radius, const gchar* keyword, LocationPOIInfo** poi);
+typedef int (*TYPE_GET_POI_FROM_POSITION)(LocationIElement *self, const LocationPosition* position, gdouble radius, const gchar* keyword, LocationPOIInfo** poi);
+typedef int (*TYPE_GET_POI_FROM_ADDRESS_ASYNC)(LocationIElement *self, const LocationAddress* address, gdouble radius, const gchar* keyword, LocationPOICB callback, gpointer userdata);
+typedef int (*TYPE_GET_POI_FROM_POSITION_ASYNC)(LocationIElement *self, const LocationPosition* position, gdouble radius, const gchar* keyword, LocationPOICB callback, gpointer userdata);
+
+struct _LocationIElementInterface
+{
+       GTypeInterface parent_iface;
+
+       TYPE_START_FUNC start;
+       TYPE_STOP_FUNC stop;
+       TYPE_GET_POSITION get_position;
+       TYPE_GET_VELOCITY get_velocity;
+       TYPE_GET_GEOCODE get_geocode;
+       TYPE_GET_GEOCODE_FREEFORM get_geocode_freeform;
+       TYPE_GET_REVERSEGEOCODE get_reversegeocode;
+       TYPE_GET_GEOCODE_ASYNC get_geocode_async;
+       TYPE_GET_GEOCODE_FREEFORM_ASYNC get_geocode_freeform_async;
+       TYPE_GET_REVERSEGEOCODE_ASYNC get_reversegeocode_async;
+       TYPE_GET_POI get_poi;
+       TYPE_GET_POI_FROM_ADDRESS get_poi_from_address;
+       TYPE_GET_POI_FROM_POSITION get_poi_from_position;
+       TYPE_GET_POI_ASYNC get_poi_async;
+       TYPE_GET_POI_FROM_ADDRESS_ASYNC get_poi_from_address_async;
+       TYPE_GET_POI_FROM_POSITION_ASYNC get_poi_from_position_async;
+};
+
+GType location_ielement_get_type (void);
+
+int location_ielement_start (LocationIElement *self);
+int location_ielement_stop(LocationIElement *self);
+int location_ielement_get_position (LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy);
+int location_ielement_get_velocity (LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy);
+int location_ielement_get_geocode (LocationIElement *self, const LocationAddress *address, LocationPosition **position, LocationAccuracy **accuracy);
+int location_ielement_get_geocode_freeform (LocationIElement *self, const gchar *address, LocationPosition **position, LocationAccuracy **accuracy);
+int location_ielement_get_reversegeocode (LocationIElement *self, const LocationPosition *position, LocationAddress **address, LocationAccuracy **accuracy);
+int location_ielement_get_geocode_async (LocationIElement *self, const LocationAddress *address, LocationPositionCB callback, gpointer userdata);
+int location_ielement_get_geocode_freeform_async (LocationIElement *self, const gchar *address, LocationPositionCB callback, gpointer userdata);
+int location_ielement_get_reversegeocode_async (LocationIElement *self, const LocationPosition *position, LocationAddressCB callback, gpointer userdata);
+int location_ielement_get_poi(LocationIElement *self, gdouble radius, const gchar *keyword, LocationPOIInfo **poi);
+int location_ielement_get_poi_from_address(LocationIElement *self, const LocationAddress *address, gdouble radius, const gchar *keyword, LocationPOIInfo **poi);
+int location_ielement_get_poi_from_position (LocationIElement *self, const LocationPosition *position, gdouble radius, const gchar *keyword, LocationPOIInfo **poi);
+int location_ielement_get_poi_async(LocationIElement *self, gdouble radius, const gchar *keyword, LocationPOICB callback, gpointer userdata);
+int location_ielement_get_poi_from_address_async(LocationIElement *self, const LocationAddress *address, gdouble radius, const gchar *keyword, LocationPOICB callback, gpointer userdata);
+int location_ielement_get_poi_from_position_async (LocationIElement *self, const LocationPosition *position, gdouble radius, const gchar *keyword, LocationPOICB callback, gpointer userdata);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-ips.c b/location/location-ips.c
new file mode 100644 (file)
index 0000000..0412c01
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-ips.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+
+typedef struct _LocationIpsPrivate {
+       LocationIpsMod *mod;
+       LocationPosition *pos;
+       LocationAccuracy *acc;
+} LocationIpsPrivate;
+
+enum {
+       PROP_0,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION
+};
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_IPS, LocationIpsPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationIps, location_ips, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+static void
+location_ips_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_ips_dispose");
+       G_OBJECT_CLASS (location_ips_parent_class)->dispose (gobject);
+}
+
+static void
+location_ips_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_ips_finalize");
+       LocationIpsPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "ips");
+       priv->mod = NULL;
+
+       G_OBJECT_CLASS (location_ips_parent_class)->finalize (gobject);
+}
+
+static void
+location_ips_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationIpsPrivate *priv = GET_PRIVATE (object);
+
+       switch (property_id){
+               case PROP_METHOD_TYPE:
+                       g_value_set_int(value, LOCATION_METHOD_IPS);
+                       break;
+               case PROP_LAST_POSITION:{
+                       g_value_set_boxed (value, priv->pos);
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static int
+location_ips_get_position (LocationIps *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_ips_get_position");
+
+       LocationIpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(NETWORK_ENABLED);
+
+       LocModIpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
+       int ret = ops.get_position(priv->mod->handler, position, accuracy);
+       if (priv->pos) location_position_free(priv->pos);
+       if (priv->acc) location_accuracy_free(priv->acc);
+       priv->pos = location_position_copy(*position);
+       priv->acc = location_accuracy_copy(*accuracy);
+       return ret;
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->get_position = (TYPE_GET_POSITION)location_ips_get_position;
+}
+
+static void
+location_ips_init (LocationIps *self)
+{
+       LOCATION_LOGD("location_ips_init");
+       LocationIpsPrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationIpsMod*)module_new("ips");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+
+       priv->pos = NULL;
+       priv->acc = NULL;
+}
+
+static void
+location_ips_class_init (LocationIpsClass *klass)
+{
+       LOCATION_LOGD("location_ips_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GParamSpec *pspec;
+
+       gobject_class->get_property = location_ips_get_property;
+
+       gobject_class->dispose = location_ips_dispose;
+       gobject_class->finalize = location_ips_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationIpsPrivate));
+
+       pspec = g_param_spec_int ("method",
+                                "method type",
+                                "location method type name",
+                                LOCATION_METHOD_IPS,
+                                LOCATION_METHOD_IPS,
+                                LOCATION_METHOD_IPS,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_METHOD_TYPE,
+                                   pspec);
+
+       pspec = g_param_spec_boxed ("last-position",
+                                "ips last position prop",
+                                "ips last position data",
+                                LOCATION_TYPE_POSITION,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_LAST_POSITION,
+                                   pspec);
+}
+
diff --git a/location/location-ips.h b/location/location-ips.h
new file mode 100644 (file)
index 0000000..b2523b6
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_IPS_H__
+#define __LOCATION_IPS_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-ips.h
+ * @brief This file contains the internal definitions and structures related to IPS.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_IPS                  (location_ips_get_type ())
+#define LOCATION_IPS(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_IPS, LocationIps))
+#define LOCATION_IS_IPS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_IPS))
+#define LOCATION_IPS_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_IPS, LocationIpsClass))
+#define LOCATION_IS_IPS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_IPS))
+#define LOCATION_IPS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_IPS, LocationIpsClass))
+
+typedef struct _LocationIps        LocationIps;
+typedef struct _LocationIpsClass   LocationIpsClass;
+
+struct _LocationIps
+{
+       GObject parent_instance;
+};
+
+struct _LocationIpsClass
+{
+       GObjectClass parent_class;
+};
+
+GType location_ips_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-log.h b/location/location-log.h
new file mode 100644 (file)
index 0000000..0f9f58a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_LOG_H__
+#define __LOCATION_LOG_H__
+
+/**
+ * @file location-log.h
+ * @brief This file contains macro functions for logging.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+#define TAG_LOCATION           "location"
+
+#ifdef LOCATION_DLOG_DEBUG        // if debug mode, show filename & line number
+#include <dlog.h>
+#define LOCATION_LOGD(fmt,args...)  SLOG(LOG_DEBUG, TAG_LOCATION, "[%-15s:%-4d:%-27s]"fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##args)
+#define LOCATION_LOGW(fmt,args...)  SLOG(LOG_WARN,  TAG_LOCATION, "[%-15s:%-4d:%-27s]"fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##args)
+#define LOCATION_LOGI(fmt,args...)  SLOG(LOG_INFO,  TAG_LOCATION, "[%-15s:%-4d:%-27s]"fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##args)
+#define LOCATION_LOGE(fmt,args...)  SLOG(LOG_ERROR, TAG_LOCATION, "[%-15s:%-4d:%-27s]"fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##args)
+#elif LOCATION_DLOG_RELEASE      // if release mode, do not show filename & line number
+#include <dlog.h>
+#define LOCATION_LOGD(fmt,args...)  SLOG(LOG_DEBUG, TAG_LOCATION, fmt"\n", ##args)
+#define LOCATION_LOGW(fmt,args...)  SLOG(LOG_WARN,  TAG_LOCATION, fmt"\n", ##args)
+#define LOCATION_LOGI(fmt,args...)  SLOG(LOG_INFO,  TAG_LOCATION, fmt"\n", ##args)
+#define LOCATION_LOGE(fmt,args...)  SLOG(LOG_ERROR, TAG_LOCATION, fmt"\n", ##args)
+#else                       // if do not use dlog
+#define LOCATION_LOGD(...)  g_debug(__VA_ARGS__);
+#define LOCATION_LOGW(...)  g_warning(__VA_ARGS__);
+#define LOCATION_LOGI(...)  g_message(__VA_ARGS__);
+#define LOCATION_LOGE(...)  g_error(__VA_ARGS__);
+#endif
+
+#endif
diff --git a/location/location-marshal.list b/location/location-marshal.list
new file mode 100644 (file)
index 0000000..069387a
--- /dev/null
@@ -0,0 +1,2 @@
+VOID:UINT,POINTER,POINTER
+VOID:UINT
diff --git a/location/location-module-internal.c b/location/location-module-internal.c
new file mode 100644 (file)
index 0000000..1c9a19b
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h> 
+#include "location/location-module-internal.h"
+#include "location/location-log.h"
+
+#define MAX_MODULE_INDEX 10
+const char* MODULE_PATH_PREFIX = "/usr/lib/location/module";
+
+static GMod*
+gmod_new (const char* module_name, gboolean is_resident)
+{
+       if(!module_name)
+               return NULL;
+
+       GMod* gmod = g_new0(GMod, 1);
+       gmod->name = g_strdup(module_name);
+       if(!gmod->name) {
+               g_free(gmod);
+               return NULL;
+       }
+       gmod->path = g_module_build_path (MODULE_PATH_PREFIX, gmod->name);
+       if(!gmod->path){
+               g_free(gmod->name);
+               g_free(gmod);
+               gmod->name = NULL;
+               return NULL;
+       }
+       gmod->module = g_module_open(gmod->path, G_MODULE_BIND_LAZY);
+       if(!gmod->module){
+               g_free(gmod->name);
+               g_free(gmod->path);
+               g_free(gmod);
+               gmod->name = NULL;
+               gmod->path = NULL;
+
+               return NULL;
+       }
+       if(is_resident)
+               g_module_make_resident(gmod->module);
+
+       return gmod;
+}
+
+static void
+gmod_free (GMod* gmod)
+{      
+       if(gmod->name)
+               g_free(gmod->name);
+       if(gmod->path)
+               g_free(gmod->path);     
+       if(gmod->module)
+               g_module_close(gmod->module);
+       g_free(gmod);
+}
+
+static gboolean
+gmod_find_sym (GMod* gmod,
+       gpointer* init_func, gpointer* shutdown_func)
+{
+       char sym[256];
+       g_stpcpy(sym, "init");
+       if ( !g_module_symbol (gmod->module, sym, init_func) ){
+               LOCATION_LOGW("symbol not found: %s", sym);
+               return FALSE;   
+       }
+       g_stpcpy(sym, "shutdown");
+       if ( !g_module_symbol (gmod->module, sym, shutdown_func) ){
+               LOCATION_LOGW("symbol not found: %s", sym);
+               return FALSE;
+       }
+       return TRUE;
+}
+
+static gpointer
+mod_new (const char* module_name)
+{
+       gpointer ret_mod = NULL;        
+       if(!module_name)
+               return NULL;
+
+       GMod* gmod = NULL;
+       gpointer init = NULL;
+       gpointer shutdown = NULL;
+       gmod = gmod_new(module_name, TRUE);
+       if(!gmod){
+               LOCATION_LOGW("module(%s) new failed", module_name);
+               return NULL;
+       }       
+       if( !gmod_find_sym(gmod, &init, &shutdown) ){
+               LOCATION_LOGW("symbol (init, shutdown) finding failed");
+               gmod_free(gmod);
+               return NULL;
+       }
+       if(!init || !shutdown){
+               LOCATION_LOGW("init, shutdown symbol is NULL"); 
+               gmod_free(gmod);
+               return NULL;
+       }       
+       if(g_str_has_prefix(module_name, "geocode")){
+               LocationGeoMod* _mod = g_new0(LocationGeoMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "gps")){
+               LocationGpsMod* _mod = g_new0(LocationGpsMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "wps")){
+               LocationWpsMod* _mod = g_new0(LocationWpsMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "cps")){
+               LocationCpsMod* _mod = g_new0(LocationCpsMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;
+               _mod->handler= _mod->init(&(_mod->ops));
+               if(!_mod->handler){
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "ips")){
+               LocationIpsMod* _mod = g_new0(LocationIpsMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "sps")){
+               LocationSpsMod* _mod = g_new0(LocationSpsMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else if(g_str_has_prefix(module_name, "poi")){
+               LocationPoiMod* _mod = g_new0(LocationPoiMod, 1);
+               _mod->gmod = gmod;
+               _mod->init = init;
+               _mod->shutdown= shutdown;       
+               _mod->handler= _mod->init(&(_mod->ops));        
+               if(!_mod->handler){     
+                       LOCATION_LOGW("module init failed");
+                       gmod_free(_mod->gmod);
+                       ret_mod = NULL;
+               }else
+                       ret_mod = (gpointer)_mod;
+       }else{
+               LOCATION_LOGW("module name (%s) is wrong", module_name); 
+               ret_mod = NULL;
+       }       
+       return ret_mod;
+}
+
+               
+static void
+mod_free (gpointer mod,
+       const char* module_name)        
+{
+       if(!mod || !module_name)
+               return;
+       
+       if(0 == g_strcmp0(module_name, "geocode")){
+               LocationGeoMod* _mod = (LocationGeoMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "gps")){
+               LocationGpsMod* _mod = (LocationGpsMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "wps")){
+               LocationWpsMod* _mod = (LocationWpsMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }               
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "cps")){
+               LocationCpsMod* _mod = (LocationCpsMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }               
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "ips")){
+               LocationIpsMod* _mod = (LocationIpsMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }               
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "sps")){
+               LocationSpsMod* _mod = (LocationSpsMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }               
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else if(0 == g_strcmp0(module_name, "poi")){
+               LocationPoiMod* _mod = (LocationPoiMod*)mod;
+               if(_mod->shutdown && _mod->handler){
+                       _mod->shutdown(_mod->handler);                  
+               }
+               _mod->handler = NULL;
+               _mod->init = NULL;
+               _mod->shutdown= NULL;
+               gmod_free(_mod->gmod);
+               _mod->gmod = NULL;
+       }else
+               LOCATION_LOGW("module name (%s) is wrong", module_name); 
+
+       g_free(mod);
+}
+
+static gboolean
+mod_is_supported(const char *module_name)
+{
+       GMod * gmod = NULL;
+       gmod = gmod_new(module_name, FALSE);
+       if(!gmod) {
+               return FALSE;
+       }
+       gmod_free(gmod);
+
+       return TRUE;
+}
+
+gboolean module_init (void)
+{
+       if (!g_module_supported()) { 
+               LOCATION_LOGW("module is not supported"); 
+               return FALSE;
+       }
+       return TRUE;
+}
+
+void
+module_free (gpointer mod,
+       const char* module_name)
+{
+       if(!mod || !module_name)
+               return;
+       mod_free(mod, module_name);
+}
+
+gpointer
+module_new (const char* module_name)
+{
+       if(!module_name)
+               return NULL;
+       int index = 0;
+       char name[256];
+
+       gpointer mod = NULL;
+       for(index = -1 ; index < MAX_MODULE_INDEX ; index++){
+               if(index >= 0){
+                       if( 0 >= g_snprintf(name, 256, "%s%d", module_name, index)){
+                               LOCATION_LOGW("module name(%s) is wrong", name);
+                               continue;
+                       }
+               }else{
+                       if( 0 >= g_snprintf(name, 256, "%s", module_name)){                             
+                               LOCATION_LOGW("module name(%s) is wrong", name);
+                               continue;
+                       }               
+               }
+               mod = mod_new(name);
+               if(mod){
+                       LOCATION_LOGW("module (%s) open success", name);
+                       break;
+               }
+               LOCATION_LOGW("module (%s) open failed", name);
+       }
+       return mod;
+}
+
+gboolean
+module_is_supported(const char *module_name)
+{
+       if(!module_name)
+               return FALSE;
+
+       int index = 0;
+       gboolean ret = FALSE;
+       gboolean found = FALSE;
+
+       char name[256] = {0, };
+
+       for(index = -1 ; index < MAX_MODULE_INDEX ; index++){
+               if(index >= 0){
+                       g_snprintf(name, 256, "%s%d", module_name, index);
+               }else{
+                       g_snprintf(name, 256, "%s", module_name);
+               }
+
+               ret = mod_is_supported(name);
+               if(ret == TRUE) {
+                       found = TRUE;
+                       LOCATION_LOGW("module name(%s) is found", name);
+                       break;
+               }
+       }
+
+       return found;
+}
diff --git a/location/location-module-internal.h b/location/location-module-internal.h
new file mode 100644 (file)
index 0000000..406a48f
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_MODULE_INTERNAL_H__
+#define __LOCATION_MODULE_INTERNAL_H__
+
+#include <gmodule.h>
+#include "location/location-module.h"
+
+/**
+ * @file location-module-internal.h
+ * @brief This file contains the internal definitions and structures related to module.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+typedef struct{
+       GModule* module;
+       char* name;
+       char* path;     
+} GMod;
+
+typedef struct{
+       GMod* gmod;
+       gpointer handler;
+       gpointer (*init)(LocModGeoOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModGeoOps ops;
+} LocationGeoMod;
+
+typedef struct{
+       GMod* gmod;
+       gpointer handler;
+       gpointer (*init)(LocModPoiOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModPoiOps ops;
+} LocationPoiMod;
+
+typedef struct{
+       GMod* gmod;     
+       gpointer handler;
+       gpointer (*init)(LocModGpsOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModGpsOps ops;
+} LocationGpsMod;
+
+typedef struct{
+       GMod* gmod;     
+       gpointer handler;
+       gpointer (*init)(LocModWpsOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModWpsOps ops;
+} LocationWpsMod;
+
+typedef struct{
+       GMod* gmod;     
+       gpointer handler;
+       gpointer (*init)(LocModCpsOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModCpsOps ops;
+} LocationCpsMod;
+
+typedef struct{
+       GMod* gmod;
+       gpointer handler;
+       gpointer (*init)(LocModIpsOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModIpsOps ops;
+} LocationIpsMod;
+
+typedef struct{
+       GMod* gmod;
+       gpointer handler;
+       gpointer (*init)(LocModSpsOps* ops);
+       void (*shutdown)(gpointer handle);
+       LocModSpsOps ops;
+} LocationSpsMod;
+
+G_BEGIN_DECLS
+
+gboolean module_init(void);
+gpointer module_new(const char* module_name);
+void module_free(gpointer mod, const char* module_name);
+       
+G_END_DECLS
+
+#endif
diff --git a/location/location-module.h b/location/location-module.h
new file mode 100644 (file)
index 0000000..7c8d7d1
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_MODULE_H__
+#define __LOCATION_MODULE_H__
+
+#include <gmodule.h>
+#include <location/location-types.h>
+#include <location/location-position.h>
+#include <location/location-velocity.h>
+#include <location/location-accuracy.h>
+#include <location/location-address.h>
+#include <location/location-satellite.h>
+#include <location/location-poi-info.h>
+
+G_BEGIN_DECLS
+
+/**
+ * @file location-module.h
+ * @brief This file contains the structure and enumeration for location plug-in development.
+ */
+
+/**
+ * @addtogroup LocationFW
+ * @{
+ * @defgroup LocationModules Location Moduels
+ * @brief  This sub module provides the definitions and structrues for 3rd party plugin modules.
+ * @addtogroup LocationModules
+ * @{
+ */
+
+/**
+ * @brief This represents APIs declared in a geocode plug-in for location geocode modules.
+ */
+typedef struct{
+       int (*get_service_name)(gpointer handle, gchar **servicename);                                                                         ///< This is used for getting a service name from a plug-in.
+       int (*get_geocode)(gpointer handle, const LocationAddress *address, LocationPosition **position, LocationAccuracy **accuracy);         ///< This is used for getting a geocode from a plug-in.
+       int (*get_geocode_freetext)(gpointer handle, const gchar *address, LocationPosition **position, LocationAccuracy **accuracy);          ///< This is used for getting a geocode by using a free-fromed address from a plug-in.
+       int (*get_reverse_geocode)(gpointer handle, const LocationPosition *position, LocationAddress **address, LocationAccuracy **accuracy); ///< This is used for getting a reverse geocode from a plug-in.
+       int (*get_geocode_async)(gpointer handle, const LocationAddress *address, LocationPositionCB callback, gpointer userdata);             ///< This is used for getting a geocode from a plug-in asynchronously.
+       int (*get_geocode_freetext_async)(gpointer handle, const gchar *address, LocationPositionCB callback, gpointer userdata);              ///< This is used for getting a geocode by using a free-fromed address from a plug-in asynchronously.
+       int (*get_reverse_geocode_async)(gpointer handle, const LocationPosition *position, LocationAddressCB callback, gpointer userdata);    ///< This is used for getting a reverse geocode from a plug-in asynchronously.   
+} LocModGeoOps;
+
+/**
+ * @brief This represents APIs declared in a POI plug-in for location POI modules.
+ */
+typedef struct{
+       int (*get_service_name)(gpointer handle, gchar** servicename);                                                                                                            ///< This is used for getting a service name from a plug-in.
+       int (*get_poi)(gpointer handle, gdouble radius, const gchar* keyword, LocationPOIInfo **poi);                                                                             ///< This is used for getting a POI from a plug-in.
+       int (*get_poi_from_address)(gpointer handle, const LocationAddress *address, gdouble radius, const gchar* keyword, LocationPOIInfo **poi);                                ///< This is used for getting a POI by using a address from a plug-in.
+       int (*get_poi_from_position)(gpointer handle, const LocationPosition *position, gdouble radius, const gchar* keyword, LocationPOIInfo **poi);                             ///< This is used for getting a POI by using a position from a plug-in.
+       int (*get_poi_async)(gpointer handle, gdouble radius, const gchar* keyword, LocationPOICB callback, gpointer userdata);                                                   ///< This is used for getting a POI from a plug-in asynchronously.
+       int (*get_poi_from_address_async)(gpointer handle, const LocationAddress *address, gdouble radius, const gchar* keyword, LocationPOICB callback, gpointer userdata);      ///< This is used for getting a POI by using a address from a plug-in asynchronously.
+       int (*get_poi_from_position_async)(gpointer handle, const LocationPosition *position, gdouble radius, const gchar* keyword,  LocationPOICB callback, gpointer userdata);  ///< This is used for getting a POI by using a position from a plug-in asynchronously.
+} LocModPoiOps;
+
+/**
+* @brief This represents a enabled/disabled callback function for a plug-in.
+*/
+typedef void (*LocModStatusCB)(gboolean enabled, LocationStatus status, gpointer userdata);
+
+/**
+ * @brief This represents a position callback function for a plug-in.
+ */
+typedef void (*LocModPositionCB) (gboolean enabled, LocationPosition *position, LocationAccuracy *accuracy, gpointer userdata);
+
+/**
+ * @brief This represents a velocity callback function for a plug-in.
+ */
+typedef void (*LocModVelocityCB) (gboolean enabled, LocationVelocity *velocity, LocationAccuracy *accuracy, gpointer userdata);
+
+/**
+ * @brief This represents APIs declared in a GPS plug-in for location GPS modules.
+ */
+typedef struct{
+       int (*start)(gpointer handle, LocModStatusCB status_cb, LocModPositionCB pos_cb, LocModVelocityCB vel_cb, gpointer userdata);  ///< This is used for starting a GPS device from a plug-in. #LocModStatusCB, #LocModPositionCB, and #LocModVelocityCB are given from a location framework to a plug-in for asynchronous signaling.
+       int (*stop)(gpointer handle);                                                                                                  ///< This is used for stopping a GPS device name from a plug-in.
+       int (*get_position)(gpointer handle, LocationPosition **position, LocationAccuracy **accuracy);                                ///< This is used for getting a position from a plug-in.
+       int (*get_velocity)(gpointer handle, LocationVelocity **velocity, LocationAccuracy **accuracy);                                ///< This is used for getting a velocity from a plug-in.
+       int (*get_nmea)(gpointer handle, gchar** nmea_data);                                                                           ///< This is used for getting a nmea string from a plug-in.
+       int (*get_satellite)(gpointer handle, LocationSatellite **satellite);                                                          ///< This is used for getting a satellite information from a plug-in.
+       int (*set_devname)(gpointer handle, const gchar *devname);                                                                     ///< This is used for setting a device name from a plug-in.
+       int (*get_devname)(gpointer handle, gchar **devname);                                                                          ///< This is used for getting a device name from a plug-in.
+} LocModGpsOps;
+
+/**
+ * @brief This represents APIs declared in a WPS plug-in for location WPS modules.
+ */
+typedef struct{
+       int (*start)(gpointer handle, LocModStatusCB status_cb, LocModPositionCB pos_cb, LocModVelocityCB vel_cb, gpointer userdata);   ///< This is used for starting a WPS service from a plug-in. #LocModStatusCB, #LocModPositionCB, and #LocModVelocityCB are given from a location framework to a plug-in for asynchronous signaling.
+       int (*stop)(gpointer handle);                                                                                                   ///< This is used for stopping a WPS service from a plug-in.
+       int (*get_position)(gpointer handle, LocationPosition **position, LocationAccuracy **accuracy);                                 ///< This is used for getting a position from a plug-in.
+       int (*get_velocity)(gpointer handle, LocationVelocity **velocity, LocationAccuracy **accuracy);                                 ///< This is used for getting a velocity from a plug-in.
+} LocModWpsOps;
+
+/**
+ * @brief This represents APIs declared in a SPS plug-in for location SPS modules.
+ */
+typedef struct{
+       int (*start)(gpointer handle, LocModStatusCB status_cb, LocModPositionCB pos_cb, LocModVelocityCB vel_cb, gpointer userdata);                                                   ///< This is used for starting a SPS service from a plug-in. #LocModStatusCB, #LocModPositionCB and #LocModVelocityCB are given from a location framework to a plug-in for asynchronous signaling.
+       int (*stop)(gpointer handle);                                                                                                                                                   ///< This is used for stopping a SPS service from a plug-in.
+       int (*get_position)(gpointer handle, LocationPosition **position, LocationAccuracy **accuracy);                                                                                 ///< This is used for getting a position from a plug-in.
+       int (*get_velocity)(gpointer handle, LocationVelocity **velocity, LocationAccuracy **accuracy);                                                                                 ///< This is used for getting a velocity from a plug-in.
+       int (*update_data)(gpointer handle, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy, const LocationSatellite *satellite);  ///< This is used for updating compensated position/velocity data for a plug-in.
+} LocModSpsOps;
+
+/**
+ * @brief This represents APIs declared in a IPS plug-in for location IPS modules.
+ */
+typedef struct{
+       int (*get_position)(gpointer handle, LocationPosition **position, LocationAccuracy **accuracy);          ///< This is used for getting a position from a plug-in.
+} LocModIpsOps;
+
+/**
+ * @brief This represents APIs declared in a CPS plug-in for location CPS modules.
+ */
+typedef struct{
+       int (*get_position)(gpointer handle, LocationPosition **position, LocationAccuracy **accuracy);          ///< This is used for getting a position from a plug-in.
+} LocModCpsOps;
+
+/**
+ * @brief This is used for exported APIs in a plug-in for a location framework.
+ */
+#define LOCATION_MODULE_API __attribute__((visibility("default"))) G_MODULE_EXPORT 
+
+/**
+ * @} @}
+ */
+G_END_DECLS
+
+#endif
diff --git a/location/location-poi-info.c b/location/location-poi-info.c
new file mode 100644 (file)
index 0000000..9429f5f
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-poi-info.h"
+#include "location/location-log.h"
+
+GType
+location_poiinfo_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationPOIInfo"),
+                       (GBoxedCopyFunc) location_poiinfo_copy,
+                       (GBoxedFreeFunc) location_poiinfo_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+GHashTable*
+location_poiinfo_detail_properties_new (void)
+{
+       return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+}
+
+void
+location_poiinfo_detail_properties_free (GHashTable* properties)
+{
+       g_return_if_fail(properties);
+       g_hash_table_destroy(properties);
+}
+
+gboolean
+location_poiinfo_detail_properties_insert (GHashTable* properties,
+       const gchar* key,
+       const gchar* value)
+{
+       g_return_val_if_fail(properties, FALSE);
+       g_hash_table_insert (properties, g_strdup(key), g_strdup(value));
+       return TRUE;
+}
+
+static void
+copy_poiinfo_detail_properties (gchar *key,
+       gchar *value,
+       GHashTable *properties)
+{
+       location_poiinfo_detail_properties_insert(properties, key, value);
+}
+
+GHashTable *
+location_poiinfo_detail_properties_copy (const GHashTable *properties)
+{
+       g_return_val_if_fail(properties, NULL);
+
+       GHashTable *dup = location_poiinfo_detail_properties_new ();
+       g_hash_table_foreach (properties,
+                                               (GHFunc)copy_poiinfo_detail_properties,
+                                               dup);
+       return dup;
+}
+
+LocationPOIInfo *
+location_poiinfo_new (int num_of_poi)
+{
+       LocationPOIInfo* poi_info = g_slice_new0(LocationPOIInfo);
+       poi_info->num_of_poi = num_of_poi;
+       poi_info->poi_detail = g_new0(LocationPOIDetail, poi_info->num_of_poi);
+       return poi_info;
+}
+
+void
+location_poiinfo_free (LocationPOIInfo* poi_info)
+{
+       g_return_if_fail(poi_info);
+       if(poi_info->poi_detail){
+               int i = 0;
+               for (i = 0 ; i < poi_info->num_of_poi ; i++) {
+                       g_free(poi_info->poi_detail[i].name);
+                       g_free(poi_info->poi_detail[i].type);
+                       location_address_free(poi_info->poi_detail[i].address);
+                       location_position_free(poi_info->poi_detail[i].position);
+                       g_free(poi_info->poi_detail[i].phone_number);
+                       location_poiinfo_detail_properties_free(poi_info->poi_detail[i].properties);
+               }
+       }
+       g_free(poi_info->poi_detail);
+       g_slice_free(LocationPOIInfo, poi_info);
+}
+
+LocationPOIInfo *
+location_poiinfo_copy (const LocationPOIInfo* poi_info)
+{
+       LocationPOIInfo* poi_info_dup = location_poiinfo_new(poi_info->num_of_poi);
+       int i = 0;
+       for (i = 0 ; i < poi_info_dup->num_of_poi ; i++)
+               location_poiinfo_set_poi_detail (poi_info_dup, i,
+                                                                               poi_info->poi_detail[i].name,
+                                                                               poi_info->poi_detail[i].type,
+                                                                               poi_info->poi_detail[i].address,
+                                                                               poi_info->poi_detail[i].position,
+                                                                               poi_info->poi_detail[i].phone_number,
+                                                                               poi_info->poi_detail[i].properties);
+
+       return poi_info_dup;
+}
+
+gboolean
+location_poiinfo_get_poi_detail (LocationPOIInfo *poi_info,
+       guint index,
+       gchar** name,
+       gchar** type,
+       LocationAddress** address,
+       LocationPosition** position,
+       gchar** phone_number,
+       GHashTable** properties)
+{
+       LOCATION_LOGD("location_poiinfo_get_poi_detail");
+       g_return_val_if_fail(name, FALSE);
+       g_return_val_if_fail(type, FALSE);
+       g_return_val_if_fail(address, FALSE);
+       g_return_val_if_fail(position, FALSE);
+       g_return_val_if_fail(phone_number, FALSE);
+       g_return_val_if_fail(properties, FALSE);
+       g_return_val_if_fail(index < poi_info->num_of_poi, FALSE);
+
+       *name = g_strdup(poi_info->poi_detail[index].name);
+       *type = g_strdup(poi_info->poi_detail[index].type);
+       *address = location_address_copy(poi_info->poi_detail[index].address);
+       *position = location_position_copy(poi_info->poi_detail[index].position);
+       *phone_number = g_strdup(poi_info->poi_detail[index].phone_number);
+       *properties = location_poiinfo_detail_properties_copy(poi_info->poi_detail[index].properties);
+
+       return TRUE;
+}
+
+gboolean
+location_poiinfo_set_poi_detail (LocationPOIInfo *poi_info,
+       guint index,
+       const gchar* name,
+       const gchar* type,
+       const LocationAddress* address,
+       const LocationPosition* position,
+       const gchar* phone_number,
+       const GHashTable* properties)
+{
+       LOCATION_LOGD("location_poiinfo_set_poi_detail");
+       g_return_val_if_fail(name, FALSE);
+       g_return_val_if_fail(type, FALSE);
+       g_return_val_if_fail(address, FALSE);
+       g_return_val_if_fail(position, FALSE);
+       g_return_val_if_fail(phone_number, FALSE);
+       g_return_val_if_fail( index < poi_info->num_of_poi, FALSE);
+
+       g_free(poi_info->poi_detail[index].name);
+       g_free(poi_info->poi_detail[index].type);
+       location_address_free(poi_info->poi_detail[index].address);
+       location_position_free(poi_info->poi_detail[index].position);
+       g_free(poi_info->poi_detail[index].phone_number);
+       location_poiinfo_detail_properties_free(poi_info->poi_detail[index].properties);
+
+       poi_info->poi_detail[index].name = g_strdup(name);
+       poi_info->poi_detail[index].type = g_strdup(type);
+       poi_info->poi_detail[index].address = location_address_copy(address);
+       poi_info->poi_detail[index].position = location_position_copy(position);
+       poi_info->poi_detail[index].phone_number = g_strdup(phone_number);
+       poi_info->poi_detail[index].properties = location_poiinfo_detail_properties_copy(properties);
+
+       return TRUE;
+}
diff --git a/location/location-poi-info.h b/location/location-poi-info.h
new file mode 100644 (file)
index 0000000..6488907
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_POI_INFO_H__
+#define __LOCATION_POI_INFO_H__
+
+#include <location/location-types.h>
+#include <location/location-position.h>
+#include <location/location-address.h>
+
+/**
+ * @file location-poi-info.h
+ * @brief This file contains the internal definitions and structures related to POI information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+G_BEGIN_DECLS
+
+/**
+ * @brief This represents one POI information such as name, type of POI, etc.
+ */
+typedef struct _LocationPOIDetail {
+       gchar *name;                   // Name of a POI
+       gchar *type;                   // Type of a POI (e.g. cafe)
+       LocationAddress *address;      // Address of a POI
+       LocationPosition *position;    // Position of a POI
+       gchar *phone_number;           // Phone number of a POI
+       GHashTable *properties;        // GHashTable with detailed characteristics of a POI.
+} LocationPOIDetail;
+
+/**
+ * @brief This represents a number of POI informations.
+ */
+struct _LocationPOIInfo
+{
+       guint num_of_poi;
+       LocationPOIDetail *poi_detail;
+};
+
+GType location_poiinfo_get_type (void);
+#define LOCATION_TYPE_POIINFO (location_poiinfo_get_type ())
+
+/**
+ * @brief   Create a new GHashTable for properties in a #LocationPOIDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param   None.
+ * @return  a new GHashTable.
+ * @retval  NULL if error occured
+ */
+GHashTable *location_poiinfo_detail_properties_new (void);
+
+/**
+ * @brief   Free a GHashTable for properties in a #LocationPOIDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] properties - a #GHashTable.
+ * @return None.
+ */
+void location_poiinfo_detail_properties_free (GHashTable* properties);
+
+/**
+ * @brief   Insert a new key and value into a GHashTable for properties in a #LocationPOIDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  properties - a #GHashTable in a #LocationPOIDetail.
+ * @param [in]  key - a key to insert (e.g. URL)
+ * @param [in]  value - the value to associate with the key. (e.g. http://www.samsung.com)
+ * @return gboolean
+ * @retval\n
+ * TRUE - if success\n
+ * FALSE - if error occured\n
+ */
+gboolean location_poiinfo_detail_properties_insert (GHashTable* properties, const gchar* key, const gchar* value);
+
+/**
+ * @brief   Makes a copy of GHashTable for properties in a #LocationPOIDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  properties - a #GHashTable
+ * @return a new #GHashTable
+ * @retval NULL if error occured
+ */
+GHashTable *location_poiinfo_detail_properties_copy (const GHashTable *properties);
+
+/**
+ * @brief   Create a new #LocationPOIInfo with given number of #LocationPOIDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  num_of_poi - number of #LocationPOIDetail.
+ * @return a new #LocationPOIInfo
+ * @retval NULL if error occured
+ */
+LocationPOIInfo* location_poiinfo_new (int num_of_poi);
+
+/**
+ * @brief   Free a #LocationPOIInfo.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] poi_info - a #LocationPOIInfo.
+ * @return None.
+ */
+void location_poiinfo_free(LocationPOIInfo* poi_info);
+
+/**
+ * @brief   Makes a copy of #LocationPOIInfo
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  poi_info - a #LocationPOIInfo
+ * @return a new #LocationPOIInfo
+ * @retval NULL if error occured
+ */
+LocationPOIInfo *location_poiinfo_copy (const LocationPOIInfo* poi_info);
+
+/**
+ * @brief   Get elements of #LocationPOIDetail with given index in #LocationPOIInfo.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]   poi_info - a #LocationPOIInfo
+ * @param [in]   index - index of #LocationPOIDetail in #LocationPOIInfo
+ * @param [out]  name - a name of a #LocationPOIDetail
+ * @param [out]  type - a type of a #LocationPOIDetail
+ * @param [out]  address - a address of a #LocationPOIDetail
+ * @param [out]  position - a position of a#LocationPOIDetail
+ * @param [out]  phone_number - a phone number of #LocationPOIDetail
+ * @param [out]  properties - a GHashTable with properties of #LocationPOIDetail
+ * @return gboolean
+ * @retval\n
+ * TRUE - if success\n
+ * FALSE - if error occured\n
+ */
+gboolean location_poiinfo_get_poi_detail(LocationPOIInfo *poi_info, guint index, gchar** name, gchar** type, LocationAddress** address, LocationPosition** position, gchar** phone_number, GHashTable** properties);
+
+/**
+ * @brief   Set elements of #LocationPOIDetail with given index in #LocationPOIInfo.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  poi_info - a #LocationPOIInfo
+ * @param [in]  index - index of #LocationPOIDetail in #LocationPOIInfo
+ * @param [in]  name - a name of a #LocationPOIDetail
+ * @param [in]  type - a type of a #LocationPOIDetail
+ * @param [in]  address - a address of a #LocationPOIDetail
+ * @param [in]  position - a position of a #LocationPOIDetail
+ * @param [in]  phone_number - a phone number of a #LocationPOIDetail
+ * @param [in]  properties - a GHashTable with properties of a #LocationPOIDetail, can be NULL if a POI have no additional properties
+ * @return gboolean
+ * @retval\n
+ * TRUE - if success\n
+ * FALSE - if error occured\n
+ */
+gboolean location_poiinfo_set_poi_detail(LocationPOIInfo *poi_info, guint index, const gchar* name, const gchar* type, const LocationAddress* address, const LocationPosition* position, const gchar* phone_number, const GHashTable* properties);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-poi.c b/location/location-poi.c
new file mode 100644 (file)
index 0000000..20084bb
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-poi.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+
+typedef struct _LocationPoiPrivate {
+       LocationPoiMod* mod;
+} LocationPoiPrivate;
+
+enum {
+       PROP_0,
+       PROP_SERVICE_NAME
+};
+
+#define DEFAULT_SERVICE "decarta"
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_POI, LocationPoiPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationPoi, location_poi, G_TYPE_OBJECT,
+       G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
+
+
+static void
+location_poi_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_poi_dispose");
+
+       G_OBJECT_CLASS (location_poi_parent_class)->dispose (gobject);
+}
+
+static void
+location_poi_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_poi_finalize");
+       LocationPoiPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "poi");
+       priv->mod = NULL;
+       G_OBJECT_CLASS (location_poi_parent_class)->finalize (gobject);
+}
+
+static void
+location_poi_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationPoiPrivate *priv = GET_PRIVATE (object);
+
+       g_return_if_fail(priv->mod);
+       g_return_if_fail(priv->mod->handler);
+       switch (property_id){
+       case PROP_SERVICE_NAME:{
+               char* service_name = NULL;
+               if(priv->mod->ops.get_service_name){
+                       if( LOCATION_ERROR_NONE != priv->mod->ops.get_service_name(priv->mod->handler, &service_name) ){
+                               service_name = NULL;
+                       }
+               }
+               LOCATION_LOGD("Get prop>> Service name: %s", service_name);
+               g_value_set_string(value, service_name);
+               g_free(service_name);
+               break;
+       }
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+               break;
+       }
+}
+
+static int
+location_poi_get_poi (LocationPoi *poi,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       LOCATION_LOGD("location_poi_get_poi");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi)(priv->mod->handler, radius, keyword, poi_info);
+}
+
+static int
+location_poi_get_poi_from_address (LocationPoi *poi,
+       const LocationAddress *address,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       LOCATION_LOGD("location_poi_get_poi_from_address");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi_from_address, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi_from_address)(priv->mod->handler, address, radius, keyword, poi_info);
+}
+
+static int
+location_poi_get_poi_from_position (LocationPoi *poi,
+       const LocationPosition *position,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       LOCATION_LOGD("location_poi_get_poi_from_position");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi_from_position, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi_from_position)(priv->mod->handler, position, radius, keyword, poi_info);
+}
+
+static int
+location_poi_get_poi_async (LocationPoi *poi,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_poi_get_poi_async");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi_async)(priv->mod->handler, radius, keyword, callback, userdata);
+}
+
+static int
+location_poi_get_poi_from_address_async (LocationPoi *poi,
+       const LocationAddress *address,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_poi_get_poi_from_address_async");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi_from_address_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi_from_address_async)(priv->mod->handler, address, radius, keyword, callback, userdata);
+}
+
+static int
+location_poi_get_poi_from_position_async (LocationPoi *poi,
+       const LocationPosition *position,
+       gdouble radius,
+       const gchar* keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       LOCATION_LOGD("location_poi_get_poi_from_position_async");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.get_poi_from_position_async, LOCATION_ERROR_NOT_AVAILABLE);
+       return (priv->mod->ops.get_poi_from_position_async)(priv->mod->handler, position, radius, keyword, callback, userdata);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->get_poi = (TYPE_GET_POI)location_poi_get_poi;
+       iface->get_poi_from_address = (TYPE_GET_POI_FROM_ADDRESS)location_poi_get_poi_from_address;
+       iface->get_poi_from_position = (TYPE_GET_POI_FROM_POSITION)location_poi_get_poi_from_position;
+       iface->get_poi_async = (TYPE_GET_POI_ASYNC)location_poi_get_poi_async;
+       iface->get_poi_from_address_async = (TYPE_GET_POI_FROM_ADDRESS_ASYNC)location_poi_get_poi_from_address_async;
+       iface->get_poi_from_position_async = (TYPE_GET_POI_FROM_POSITION_ASYNC)location_poi_get_poi_from_position_async;
+}
+
+static void
+location_poi_init (LocationPoi *poi)
+{
+       LOCATION_LOGD("location_poi_init");
+       LocationPoiPrivate* priv = GET_PRIVATE(poi);
+
+       priv->mod = (LocationPoiMod*)module_new("poi");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+}
+
+static void
+location_poi_class_init (LocationPoiClass *klass)
+{
+       LOCATION_LOGD("location_poi_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GParamSpec *pspec;
+
+       gobject_class->get_property = location_poi_get_property;
+
+       gobject_class->dispose = location_poi_dispose;
+       gobject_class->finalize = location_poi_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationPoiPrivate));
+
+       pspec = g_param_spec_string ("service provider",
+                                "poi service provider name prop",
+                                "poi service provider name",
+                                DEFAULT_SERVICE,
+                                G_PARAM_READABLE);
+       g_object_class_install_property (gobject_class,
+                                   PROP_SERVICE_NAME,
+                                   pspec);
+}
diff --git a/location/location-poi.h b/location/location-poi.h
new file mode 100644 (file)
index 0000000..03dbf55
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_POI_H__
+#define __LOCATION_POI_H__
+
+#include <glib-object.h>
+
+/**
+ * @addtogroup Location
+ * @{
+ * @file location-poi.h
+ * @brief This file contains the internal definitions and structures related to POI.
+ *@}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_POI                  (location_poi_get_type ())
+#define LOCATION_POI(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_POI, LocationPoi))
+#define LOCATION_IS_POI(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_POI))
+#define LOCATION_POI_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_POI, LocationPoiClass))
+#define LOCATION_IS_POI_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_POI))
+#define LOCATION_POI_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_POI, LocationPoiClass))
+
+typedef struct _LocationPoi        LocationPoi;
+typedef struct _LocationPoiClass   LocationPoiClass;
+
+struct _LocationPoi
+{
+       GObject parent_instance;
+};
+
+struct _LocationPoiClass
+{
+       GObjectClass parent_class;
+};
+
+GType location_poi_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-position.c b/location/location-position.c
new file mode 100644 (file)
index 0000000..dd3b387
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "location/location-position.h"
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#define                DEG2RAD(x)      ((x) * M_PI / 180)
+
+GType
+location_position_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationPosition"),
+                       (GBoxedCopyFunc) location_position_copy,
+                       (GBoxedFreeFunc) location_position_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+EXPORT_API LocationPosition *
+location_position_new (guint timestamp,
+       gdouble latitude,
+       gdouble longitude,
+       gdouble altitude,
+       LocationStatus status)
+{
+       LocationPosition* position = g_slice_new0(LocationPosition);
+       position->timestamp = timestamp;
+       position->latitude = latitude;
+       position->longitude = longitude;
+       position->altitude = altitude;
+       position->status = status;
+       return position;
+}
+
+EXPORT_API void
+location_position_free (LocationPosition* position)
+{
+       g_return_if_fail(position);
+       g_slice_free(LocationPosition, position);
+}
+
+EXPORT_API gboolean
+location_position_equal (const LocationPosition *position1, const LocationPosition *position2)
+{
+       g_return_val_if_fail(position1, FALSE);
+       g_return_val_if_fail(position2, FALSE);
+
+       if (position1->latitude == position2->latitude &&
+               position1->longitude == position2->longitude &&
+               position1->altitude == position2->altitude)
+               return TRUE;
+       return FALSE;
+}
+
+EXPORT_API LocationPosition*
+location_position_copy (const LocationPosition *position)
+{
+       g_return_val_if_fail(position, NULL);
+
+       LocationPosition *new_position = NULL;
+
+       new_position = location_position_new (position->timestamp,
+                                                               position->latitude,
+                                                               position->longitude,
+                                                               position->altitude,
+                                                               position->status);
+
+       if(new_position) new_position->updated_timestamp = position->updated_timestamp;
+
+       return new_position;
+
+}
+
+/* Vincenty formula. WGS-84 */
+EXPORT_API     int
+location_get_distance(const LocationPosition *pos1, const LocationPosition *pos2, gulong *distance)
+{
+       g_return_val_if_fail(pos1, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(pos2, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(distance, LOCATION_ERROR_PARAMETER);
+
+       *distance = 0;
+
+       const double a = 6378137.0, b = 6356752.314245,  f = 1/298.257223563;
+       double delta_lon = DEG2RAD(pos2->longitude-pos1->longitude);
+       double u_1 = atan((1-f) * tan(DEG2RAD(pos1->latitude)));
+       double u_2 = atan((1-f) * tan(DEG2RAD(pos2->latitude)));
+
+       double lambdaP, iter_limit = 100.0;
+       double lambda = delta_lon;
+
+       double sin_sigma, sin_alpha, cos_sigma, sigma,  sq_cos_alpha, cos_2sigma, C;
+       double sq_u, cal1, cal2, delta_sigma, cal_dist;
+       double sin_lambda, cos_lambda;
+
+       double sin_u1 = sin(u_1);
+       double cos_u1 = cos(u_1);
+       double sin_u2 = sin(u_2);
+       double cos_u2 = cos(u_2);
+
+       do {
+               sin_lambda = sin(lambda);
+               cos_lambda = cos(lambda);
+
+               sin_sigma = sqrt((cos_u2*sin_lambda)*(cos_u2*sin_lambda) + \
+                       (cos_u1*sin_u2-sin_u1*cos_u2*cos_lambda) * \
+                       (cos_u1*sin_u2-sin_u1*cos_u2*cos_lambda));
+
+               if (sin_sigma ==0)
+                       return LOCATION_ERROR_NONE;  // co-incident points
+
+               cos_sigma = sin_u1*sin_u2 + cos_u1*cos_u2*cos_lambda;
+               sigma = atan2(sin_sigma, cos_sigma);
+
+               sin_alpha = cos_u1 * cos_u2 * sin_lambda / sin_sigma;
+               sq_cos_alpha = 1.0 - sin_alpha*sin_alpha;
+               cos_2sigma = cos_sigma - 2.0*sin_u1*sin_u2/sq_cos_alpha;
+
+               if (isnan(cos_2sigma))
+                       cos_2sigma = 0;
+
+               C = f/16.0*sq_cos_alpha*(4.0+f*(4.0-3.0*sq_cos_alpha));
+
+               lambdaP = lambda;
+               lambda = delta_lon + (1.0-C) * f * sin_alpha * \
+                        (sigma + C*sin_sigma*(cos_2sigma+C*cos_sigma*(-1.0+2.0*cos_2sigma*cos_2sigma)));
+
+       } while (abs(lambda-lambdaP) > 1e-12 && --iter_limit>0);
+
+       if (iter_limit==0) return LOCATION_ERROR_UNKNOWN;
+
+       sq_u = sq_cos_alpha * (a*a - b*b) / (b*b);
+
+       cal1 = 1.0 + sq_u/16384.0*(4096.0+sq_u*(-768.0+sq_u*(320.0-175.0*sq_u)));
+       cal2 = sq_u/1024.0 * (256.0+sq_u*(-128.0+sq_u*(74.0-47.0*sq_u)));
+
+       delta_sigma = cal2*sin_sigma*(cos_2sigma+cal2/4.0*(cos_sigma*(-1.0+2.0*cos_2sigma*cos_2sigma)- \
+                               cal2/6.0*cos_2sigma*(-3.0+4.0*sin_sigma*sin_sigma)*(-3.0+4.0*cos_2sigma*cos_2sigma)));
+       cal_dist = b*cal1*(sigma-delta_sigma);
+
+       *distance = (gulong) cal_dist;
+
+       return LOCATION_ERROR_NONE;
+
+}
+
+EXPORT_API void
+location_last_position_a2i(char *position, int *lat, int *lon)
+{
+       char *d_lat, *d_lon;
+       char latitude[HALF_KEY_LENGTH];
+       char longitude[HALF_KEY_LENGTH];
+
+       memcpy(latitude, position + 1, HALF_KEY_LENGTH - 1);
+       memcpy(longitude, position + HALF_KEY_LENGTH + 1, HALF_KEY_LENGTH - 1);
+       latitude[HALF_KEY_LENGTH - 1] = '\0';
+       longitude[HALF_KEY_LENGTH - 1] = '\0';
+       d_lat = position;
+       d_lon = position + HALF_KEY_LENGTH;
+
+       *lat = atoi(latitude);
+       *lon = atoi(longitude);
+
+       if (*d_lat == 'S') {
+               *lat = *lat * -1;
+       }
+       if (*d_lon == 'W') {
+               *lon = *lon * -1;
+       }
+}
diff --git a/location/location-position.h b/location/location-position.h
new file mode 100644 (file)
index 0000000..585cbe0
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_POSITION_H_
+#define __LOCATION_POSITION_H_
+
+#include <location/location-types.h>
+
+#define MAX_KEY_LENGTH                 16
+#define HALF_KEY_LENGTH        8
+
+/**
+ * @file location-position.h
+ * @brief This file contains the internal definitions and structures related to position information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+G_BEGIN_DECLS
+
+/**
+ * @brief This represents the various fix states.
+ */
+typedef enum
+{
+       LOCATION_STATUS_NO_FIX = 0,     ///< No fix status.
+       LOCATION_STATUS_2D_FIX,         ///< 2D fix status (latitude/longitude/speed/direction).
+       LOCATION_STATUS_3D_FIX          ///< 3D fix status (altitude/climb as well).
+} LocationStatus;
+
+/**
+ * @brief This represents position information such as latitude-longitude-altitude values and timestamp.
+ */
+struct _LocationPosition
+{
+       guint timestamp;        ///< Time stamp.
+       guint updated_timestamp;        ///< lastest updated time stamp.
+       gdouble latitude;       ///< Latitude data.
+       gdouble longitude;      ///< Longitude data.
+       gdouble altitude;       ///< Altitude data.
+       LocationStatus status;  ///< Fix states.
+};
+
+/**
+ * @brief This represents last known position information such as latitude-longitude values and accuracy.
+ */
+struct _LocationLastPosition
+{
+       guint timestamp;        ///< Time stamp.
+       gdouble latitude;       ///< Latitude data.
+       gdouble longitude;      ///< Longitude data.
+       gdouble accuracy;       ///< Accuracy data.
+};
+
+GType location_position_get_type (void);
+#define LOCATION_TYPE_POSITION (location_position_get_type ())
+
+/**
+ * @brief   Create a new #LocationPosition with given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  timestamp - Time stamp.
+ * @param [in]  latitude - Latitude data.
+ * @param [in]  longitude - Longitude data.
+ * @param [in]  altitude - Altitude data.
+ * @param [in]  status - a #LocationStatus.
+ * @return a new #LocationPosition
+ * @retval NULL if error occured
+ */
+LocationPosition *location_position_new (guint timestamp, gdouble latitude, gdouble longitude, gdouble altitude, LocationStatus status);
+
+/**
+ * @brief   Free a #LocationPosition.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] position - a #LocationPosition.
+ * @return None.
+ */
+void location_position_free (LocationPosition *position);
+
+/**
+ * @brief   Compares two positoins for equality, returning TRUE if they are equal.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  position1 - a #LocationPosition
+ * @param [in]  position2 - a #LocationPosition
+ * @return gboolean
+ * @retval\n
+ * TRUE - if equal\n
+ * FALSE - if not equal\n
+ */
+gboolean location_position_equal (const LocationPosition *position1, const LocationPosition *position2);
+
+/**
+ * @brief   Makes a copy of #LocationPosition
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  position - a #LocationPosition
+ * @return a new #LocationPosition
+ * @retval NULL if error occured
+ */
+LocationPosition *location_position_copy (const LocationPosition *position);
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+/* Vincenty Inverse Solution of Geodesics on the Ellipsoid (c) Chris Veness 2002-2010             */
+/*                                                                                                */
+/* from: Vincenty inverse formula - T Vincenty, "Direct and Inverse Solutions of Geodesics on the */
+/*       Ellipsoid with application of nested equations", Survey Review, vol XXII no 176, 1975    */
+/*       http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf                                             */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+
+/**
+ * @brief   Gets the approximate distance between two points. A distance is defined using the WGS84 ellipsoid.
+ * @remarks Uses meters as a unit of measurement for a distance.
+ * @pre     None.
+ * @post    None.
+ * @param [in]  pos1 - a #LocationPosition (decimal degree)
+ * @param [in]  pos2 - a #LocationPosition (decimal degree)
+ * @param [out]  distance - a #gulong (meters)
+ * @return int
+ * @retval 0                              Success.
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_distance(const LocationPosition *pos1, const LocationPosition *pos2, gulong *distance);
+
+/**
+ * @brief   Change position string to latitude and longitude integer.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  position - string of last position.
+ * @param [in]  lat - latitude.
+ * @param [in]  lon - longitude.
+ * @return None.
+ */
+void location_last_position_a2i(char *position, int *lat, int *lon);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-satellite.c b/location/location-satellite.c
new file mode 100644 (file)
index 0000000..6c19ed4
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-satellite.h"
+#include "location/location-log.h"
+
+GType
+location_satellite_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationSatellite"),
+                       (GBoxedCopyFunc) location_satellite_copy,
+                       (GBoxedFreeFunc) location_satellite_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+static void
+update_num_of_used (LocationSatellite *satellite)
+{
+       g_return_if_fail(satellite);
+       satellite->num_of_sat_used = 0;
+       if (satellite->num_of_sat_inview > 0 && satellite->sat_inview) {
+               int i = 0;
+               for (i = 0 ; i < satellite->num_of_sat_inview ; i++)
+                       if(satellite->sat_inview[i].used) (satellite->num_of_sat_used)++;
+       }
+}
+
+EXPORT_API LocationSatellite*
+location_satellite_new (int num_of_sat_inview)
+{
+       LocationSatellite* satellite = g_slice_new0(LocationSatellite);
+       satellite->num_of_sat_inview = num_of_sat_inview;
+       satellite->num_of_sat_used = 0;
+       satellite->sat_inview = g_new0(LocationSatelliteDetail, satellite->num_of_sat_inview);
+       return satellite;
+}
+
+EXPORT_API void
+location_satellite_free (LocationSatellite* satellite)
+{
+       g_return_if_fail(satellite);
+       g_free(satellite->sat_inview);
+       g_slice_free(LocationSatellite, satellite);
+}
+
+EXPORT_API LocationSatellite*
+location_satellite_copy (const LocationSatellite *satellite)
+{
+       g_return_val_if_fail(satellite, NULL);
+       LocationSatellite* satellite_dup = location_satellite_new(satellite->num_of_sat_inview);
+       satellite_dup->num_of_sat_used = satellite->num_of_sat_used;
+       int i = 0;
+       for (i = 0 ; i < satellite_dup->num_of_sat_inview ; i++)
+               location_satellite_set_satellite_details(satellite_dup, i,
+                                                                                               satellite->sat_inview[i].prn,
+                                                                                               satellite->sat_inview[i].used,
+                                                                                               satellite->sat_inview[i].elevation,
+                                                                                               satellite->sat_inview[i].azimuth,
+                                                                                               satellite->sat_inview[i].snr);
+       return satellite_dup;
+}
+
+EXPORT_API gboolean
+location_satellite_get_satellite_details (const LocationSatellite *satellite,
+       guint index,
+       guint* prn,
+       gboolean* used,
+       guint* elevation,
+       guint* azimuth,
+       gint* snr)
+{
+       g_return_val_if_fail(satellite, FALSE);
+       g_return_val_if_fail(prn, FALSE);
+       g_return_val_if_fail(used, FALSE);
+       g_return_val_if_fail(elevation, FALSE);
+       g_return_val_if_fail(azimuth, FALSE);
+       g_return_val_if_fail(snr, FALSE);
+       g_return_val_if_fail(satellite->sat_inview, FALSE);
+       g_return_val_if_fail(index < satellite->num_of_sat_inview, FALSE);
+
+       *prn = satellite->sat_inview[index].prn;
+       *used = satellite->sat_inview[index].used;
+       *elevation = satellite->sat_inview[index].elevation;
+       *azimuth = satellite->sat_inview[index].azimuth;
+       *snr = satellite->sat_inview[index].snr;
+
+       return TRUE;
+}
+
+EXPORT_API gboolean
+location_satellite_set_satellite_details (LocationSatellite *satellite,
+       guint index,
+       guint prn,
+       gboolean used,
+       guint elevation,
+       guint azimuth,
+       gint snr)
+{
+       g_return_val_if_fail(satellite, FALSE);
+       g_return_val_if_fail(satellite->sat_inview, FALSE);
+       g_return_val_if_fail(index < satellite->num_of_sat_inview, FALSE);
+
+       satellite->sat_inview[index].prn= prn;
+       satellite->sat_inview[index].used= used;
+       satellite->sat_inview[index].elevation= elevation;
+       satellite->sat_inview[index].azimuth= azimuth;
+       satellite->sat_inview[index].snr= snr;
+       update_num_of_used (satellite);
+
+       return TRUE;
+}
diff --git a/location/location-satellite.h b/location/location-satellite.h
new file mode 100644 (file)
index 0000000..a7a38ce
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_SATELLITE_H_
+#define __LOCATION_SATELLITE_H_
+
+#include <location/location-types.h>
+
+/**
+ * @file location-satellite.h
+ * @brief This file contains the internal definitions and structures related to satellite information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+G_BEGIN_DECLS
+
+/**
+ * @brief This represents one satellite information in view.
+ */
+typedef struct {
+       guint prn;       ///< The PRNs(Pseudo-Random Noise code) of a satellite.
+       gboolean used;   ///< TRUE if currently used satellite.
+       guint elevation; ///< The elevation of a satellite.
+       guint azimuth;   ///< The degress from true north 000 to 359 of a satellite.
+       gint snr;        ///< The signal-to-noise ratio, dB of a satellite.
+} LocationSatelliteDetail;
+
+/**
+ * @brief This represents position information such as number of satelltes in used or in view.
+ */
+struct _LocationSatellite
+{
+       guint num_of_sat_inview;                   ///< The number of satellites in view.
+       guint num_of_sat_used;                     ///< The number of satellites in used.
+       LocationSatelliteDetail* sat_inview;       ///< The information of satellites in view .
+};
+
+GType location_satellite_get_type (void);
+#define LOCATION_TYPE_SATELLITE (location_satellite_get_type ())
+
+/**
+ * @brief   Create a new #LocationSatellite with given number of #LocationSatelliteDetail.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  num_of_sat_inview - number of #LocationSatelliteDetail.
+ * @return a new #LocationSatellite
+ * @retval NULL if error occured
+ */
+LocationSatellite *location_satellite_new (int num_of_sat_inview);
+
+/**
+ * @brief   Free a #LocationSatellite.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] satellite - a #LocationSatellite.
+ * @return None.
+ */
+void location_satellite_free (LocationSatellite *satellite);
+
+/**
+ * @brief   Makes a copy of #LocationSatellite
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  satellite - a #LocationSatellite
+ * @return a new #LocationSatellite
+ * @retval NULL if error occured
+ */
+LocationSatellite *location_satellite_copy (const LocationSatellite *satellite);
+
+/**
+ * @brief   Get elements of #LocationSatelliteDetail with given index in #LocationSatellite.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]   satellite - a #LocationSatellite
+ * @param [in]   index - index of #LocationSatelliteDetail in #LocationSatellite
+ * @param [out]  prn - The PRNs(Pseudo-Random Noise code) of a #LocationSatellite
+ * @param [out]  used - TRUE if a #LocationSatellite in used.
+ * @param [out]  elevation - The elevation of a #LocationSatellite
+ * @param [out]  azimuth - The degress from true north 000 to 359 of a#LocationSatellite
+ * @param [out]  snr - The signal-to-noise ratio, dB of #LocationSatellite
+ * @return gboolean
+ * @retval\n
+ * TRUE - if success\n
+ * FALSE - if error occured\n
+ */
+gboolean location_satellite_get_satellite_details (const LocationSatellite *satellite, guint index, guint *prn, gboolean *used, guint *elevation, guint *azimuth, gint *snr);
+
+/**
+ * @brief   Set elements of #LocationSatelliteDetail with given index in #LocationSatellite.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  satellite - a #LocationSatellite
+ * @param [in]  index - index of #LocationSatelliteDetail in #LocationSatellite
+ * @param [in]  prn - The PRNs(Pseudo-Random Noise code) of a #LocationSatellite
+ * @param [in]  used - TRUE if a #LocationSatellite in used.
+ * @param [in]  elevation - The elevation of a #LocationSatellite
+ * @param [in]  azimuth - The degress from true north 000 to 359 of a#LocationSatellite
+ * @param [in]  snr - The signal-to-noise ratio, dB of #LocationSatellite
+ * @return gboolean
+ * @retval\n
+ * TRUE - if success\n
+ * FALSE - if error occured\n
+ */
+gboolean location_satellite_set_satellite_details( LocationSatellite *satellite, guint index, guint prn,       gboolean used, guint elevation, guint azimuth, gint snr);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-setting.c b/location/location-setting.c
new file mode 100644 (file)
index 0000000..d380855
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include "location/location-log.h"
+#include "location/location-setting.h"
+
+
+gint location_setting_get_key_val(keynode_t *key)
+{
+       g_return_val_if_fail(key, -1);
+       int val = -1;
+       switch(vconf_keynode_get_type(key))
+       {
+               case VCONF_TYPE_INT:
+                       val = vconf_keynode_get_int(key);
+                       LOCATION_LOGD("Setting changed [%s]:[%d]", vconf_keynode_get_name(key), val);
+                       break;
+               default:
+                       LOCATION_LOGW("Unused type(%d)", vconf_keynode_get_type(key));
+                       break;
+       }
+       return val;
+}
+
+gint location_setting_get_int(const gchar* path)
+{
+       g_return_val_if_fail(path, -1);
+       int val = -1;
+       if( vconf_get_int(path, &val)){
+               LOCATION_LOGW("vconf_get_int: failed [%s]", path);
+               val = -1;
+       } else if (val == 0)
+               LOCATION_LOGD("vconf_get_int: [%s]:[%d]", path, val);
+       return val;
+}
+
+gboolean location_setting_get_bool(const gchar* path)
+{
+       g_return_val_if_fail(path, -1);
+       gboolean val = FALSE;
+       if( vconf_get_bool(path, &val)){
+               LOCATION_LOGW("vconf_get_int: failed [%s]", path);
+               val = FALSE;
+       }
+       return val;
+}
+
+gchar *location_setting_get_string(const gchar* path)
+{
+       g_return_val_if_fail(path, -1);
+       return vconf_get_str(path);
+}
+
+gint location_setting_add_notify(const gchar* path, SettingCB setting_cb, gpointer self)
+{
+       g_return_val_if_fail(path, -1);
+       g_return_val_if_fail(self, -1);
+
+       if( vconf_notify_key_changed(path, setting_cb, self)){
+               LOCATION_LOGW("vconf notify add failed [%s]", path);
+               return -1;
+       }
+       LOCATION_LOGD("vconf notify added [%s]", path);
+       return 0;
+}
+
+gint location_setting_ignore_notify(const gchar* path, SettingCB setting_cb)
+{
+       g_return_val_if_fail(path, -1);
+       g_return_val_if_fail(setting_cb, -1);
+
+       if( vconf_ignore_key_changed(path, setting_cb)){
+               LOCATION_LOGW("vconf notify remove failed [%s]", path);
+               return -1;
+       }
+       LOCATION_LOGD("vconf notify removed [%s]", path);
+       return -1;
+}
diff --git a/location/location-setting.h b/location/location-setting.h
new file mode 100644 (file)
index 0000000..fbb1a19
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_SETTING_H__
+#define __LOCATION_SETTING_H__
+
+#include <glib.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+/**
+ * @file location-setting.h
+ * @brief This file contains the defintions and functions for setting.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+#define VCONF_LOCATION_PATH            "db/location"
+
+#define LOCATION_POSITION_PATH                 VCONF_LOCATION_PATH"/position"
+#define LAST_TIMESTAMP                 LOCATION_POSITION_PATH"/Timestamp"
+#define LAST_POSITION                  LOCATION_POSITION_PATH"/LastPosition"
+#define LAST_ACCURACY                  LOCATION_POSITION_PATH"/LastAccuracy"
+
+#define GPS_ENABLED                    VCONFKEY_LOCATION_ENABLED
+#define LOCATION_SETTING_PATH          VCONF_LOCATION_PATH"/setting"
+#define AGPS_ENABLED                   LOCATION_SETTING_PATH"/AgpsEnabled"
+#define NETWORK_ENABLED                        LOCATION_SETTING_PATH"/NetworkEnabled"
+#define SENSOR_ENABLED                         LOCATION_SETTING_PATH"/SensorEnabled"
+
+#define LOCATION_UPDATE_INTERVAL_MIN           1
+#define LOCATION_UPDATE_INTERVAL_MAX           120
+#define LOCATION_UPDATE_INTERVAL_DEFAULT       LOCATION_UPDATE_INTERVAL_MIN
+
+typedef void (*SettingCB)(keynode_t *key, gpointer data);
+
+gint location_setting_get_key_val(keynode_t *key);
+gint location_setting_get_int(const gchar* path);
+gchar *location_setting_get_string(const gchar* path);
+gint location_setting_add_notify(const gchar* path, SettingCB setting_cb, gpointer self);
+gint location_setting_ignore_notify(const gchar* path, SettingCB setting_cb);
+
+#define setting_retval_if_fail(path) {\
+       if(!location_setting_get_int(path)){\
+               return LOCATION_ERROR_NOT_ALLOWED;\
+       }\
+}
+
+#define setting_ret_if_fail(path) {\
+       if(!location_setting_get_int(path)){\
+               return;\
+       }\
+}
+
+
+#endif
diff --git a/location/location-signaling-util.c b/location/location-signaling-util.c
new file mode 100644 (file)
index 0000000..eb2af00
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-signaling-util.h"
+#include "location/location-log.h"
+
+#define POS_EXPIRATION_TIME            9       /* sec */
+
+void
+enable_signaling (LocationObject *obj,
+       guint32 signals[LAST_SIGNAL],
+       gboolean *prev_enabled,
+       gboolean enabled,
+       LocationStatus status)
+{
+       g_return_if_fail(obj);
+       g_return_if_fail(signals);
+       g_return_if_fail(prev_enabled);
+       if (*prev_enabled == TRUE && enabled == FALSE) {
+               *prev_enabled = FALSE;
+               LOCATION_LOGD("Signal emit: SERVICE_DISABLED");
+               g_signal_emit (obj, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX);
+       } else if (*prev_enabled == FALSE && enabled == TRUE){
+               *prev_enabled = TRUE;
+               LOCATION_LOGD("Signal emit: SERVICE_ENABLED");
+               g_signal_emit (obj, signals[SERVICE_ENABLED], 0, status);
+       }
+}
+
+void
+position_signaling (LocationObject *obj,
+       guint32 signals[LAST_SIGNAL],
+       gboolean *prev_enabled,
+       guint interval,
+       LocationPosition **prev_pos,
+       LocationAccuracy **prev_acc,
+       GList *prev_bound,
+       ZoneStatus *zone_status,
+       gboolean enabled,
+       const LocationPosition *pos,
+       const LocationAccuracy *acc)
+{
+       g_return_if_fail(zone_status);
+       g_return_if_fail(pos);
+       g_return_if_fail(acc);
+       g_return_if_fail(obj);
+       g_return_if_fail(signals);
+
+       int index = 0;
+       gboolean is_inside = FALSE;
+       guint updated_timestamp = 0;
+       GList *boundary_list = prev_bound;
+       LocationBoundary *boundary = NULL;
+
+       if (prev_enabled == FALSE) enable_signaling(obj, signals, prev_enabled, enabled, pos->status);
+
+       if(*prev_pos || !*prev_acc || location_accuracy_level_compare(*prev_acc, acc) != -1 ||
+                       (pos->timestamp - (*prev_pos)->timestamp) > POS_EXPIRATION_TIME) {
+
+               if(*prev_pos) {
+                       updated_timestamp = (*prev_pos)->updated_timestamp;
+                       location_position_free(*prev_pos);
+               }
+               if(*prev_acc) location_accuracy_free(*prev_acc);
+
+               if(!updated_timestamp || pos->timestamp - updated_timestamp >= interval) {
+                       LOCATION_LOGD("Signal emit: POSITION SERVICE_UPDATED");
+                       g_signal_emit(obj, signals[SERVICE_UPDATED], 0, POSITION_UPDATED, pos, acc);
+                       updated_timestamp = pos->timestamp;
+               }
+
+               if(boundary_list) {
+                       while((boundary = (LocationBoundary *)g_list_nth_data(boundary_list, index))!= NULL) {
+
+                               is_inside = location_boundary_if_inside(boundary, pos);
+                               if(is_inside) {
+                                       break;
+                               }
+                               index++;
+                       }
+
+                       if(is_inside) {
+                               if(*zone_status != ZONE_STATUS_IN) {
+                                       LOCATION_LOGD("Signal emit: ZONE IN");
+                                       g_signal_emit(obj, signals[ZONE_IN], 0, NULL, pos, acc);
+                                       *zone_status = ZONE_STATUS_IN;
+                               }
+                       }
+                       else {
+                               if (*zone_status != ZONE_STATUS_OUT) {
+                                       LOCATION_LOGD("Signal emit : ZONE_OUT");
+                                       g_signal_emit(obj, signals[ZONE_OUT], 0, NULL, pos, acc);
+                                       *zone_status = ZONE_STATUS_OUT;
+                               }
+                       }
+
+               }
+       }
+
+       *prev_pos = location_position_copy(pos);
+       *prev_acc = location_accuracy_copy(acc);
+       (*prev_pos)->updated_timestamp = updated_timestamp;
+}
+
+void
+velocity_signaling (LocationObject *obj,
+       guint32 signals[LAST_SIGNAL],
+       gboolean *prev_enabled,
+       guint interval,
+       LocationVelocity **prev_vel,
+       gboolean enabled,
+       const LocationVelocity *vel,
+       const LocationAccuracy *acc)
+{
+       g_return_if_fail(obj);
+       g_return_if_fail(signals);
+       g_return_if_fail(vel);
+
+       guint updated_timestamp = 0;
+
+       if (prev_enabled == FALSE) enable_signaling(obj, signals, prev_enabled, enabled, LOCATION_STATUS_NO_FIX);
+
+       if(*prev_vel) {
+               updated_timestamp = (*prev_vel)->updated_timestamp;
+               if(!location_velocity_equal(*prev_vel, vel)) {
+                       location_velocity_free (*prev_vel);
+               }
+       }
+
+       *prev_vel = location_velocity_copy (vel);
+
+       if(!updated_timestamp || vel->timestamp - updated_timestamp >= interval) {
+
+               LOCATION_LOGD ("Signal emit: VELOCITY SERVICE_UPDATED");
+               LocationVelocity *temp_vel = location_velocity_copy (*prev_vel);
+               LocationAccuracy *temp_acc = location_accuracy_copy(acc);
+
+               g_signal_emit (obj, signals[SERVICE_UPDATED], 0, VELOCITY_UPDATED, temp_vel, temp_acc);
+
+               (*prev_vel)->updated_timestamp = vel->timestamp;
+
+               location_velocity_free(temp_vel);
+               location_accuracy_free(temp_acc);
+       }
+       else {
+               (*prev_vel)->updated_timestamp = updated_timestamp;
+       }
+
+}
diff --git a/location/location-signaling-util.h b/location/location-signaling-util.h
new file mode 100644 (file)
index 0000000..c2474bf
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_SIGNALING_UTIL_H__
+#define __LOCATION_SIGNALING_UTIL_H__
+
+#include <location/location.h>
+#include <location/location-ielement.h>
+
+/**
+ * @file location-signaling.h
+ * @brief This file contains the signaling utils for LocationObject.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+typedef enum {
+       ZONE_STATUS_NONE = 0,
+       ZONE_STATUS_IN,
+       ZONE_STATUS_OUT,
+} ZoneStatus;
+
+void enable_signaling (LocationObject *obj,    guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, gboolean enabled, LocationStatus status);
+
+void position_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, guint interval, LocationPosition **prev_pos, LocationAccuracy **prev_acc, GList *prev_bound, ZoneStatus *zone_status, gboolean enabled, const LocationPosition *pos, const LocationAccuracy *acc);
+
+void velocity_signaling (LocationObject* obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, guint interval, LocationVelocity **prev_vel, gboolean enabled, const LocationVelocity *vel, const LocationAccuracy *acc);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-sps.c b/location/location-sps.c
new file mode 100644 (file)
index 0000000..106053b
--- /dev/null
@@ -0,0 +1,509 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-sps.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+#include "location/location-signaling-util.h"
+#include "location/location-common-util.h"
+
+typedef struct _LocationSpsPrivate {
+       LocationSpsMod* mod;
+       gboolean is_started;
+       gboolean enabled;
+       guint    interval;
+       LocationPosition *pos;
+       LocationVelocity *vel;
+       LocationAccuracy *acc;
+       GList *boundary_list;
+       ZoneStatus zone_status;
+       LocationPosition *pos_base;
+       LocationVelocity *vel_base;
+       LocationAccuracy *acc_info;
+       LocationSatellite *sat_info;
+} LocationSpsPrivate;
+
+enum {
+       PROP_0,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION,
+       PROP_UPDATE_INTERVAL,
+       PROP_BOUNDARY,
+       PROP_REMOVAL_BOUNDARY,
+       PROP_POSITION_BASE,
+       PROP_VELOCITY_BASE,
+       PROP_ACCURACY_INFO,
+       PROP_SATELLITE_INFO,
+       PROP_MAX
+};
+
+static guint32 signals[LAST_SIGNAL] = {0, };
+static GParamSpec *properties[PROP_MAX] = {NULL, };
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_SPS, LocationSpsPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationSps, location_sps, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+static void
+sps_status_cb (gboolean enabled,
+       LocationStatus status,
+       gpointer self)
+{
+       LOCATION_LOGD("sps_status_cb");
+       g_return_if_fail(self);
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, status);
+}
+
+static void
+sps_position_cb (gboolean enabled,
+       LocationPosition *pos,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("sps_position_cb");
+       g_return_if_fail(self);
+       g_return_if_fail(pos);
+       g_return_if_fail(acc);
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, pos->status);
+
+       position_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->pos), &(priv->acc), priv->boundary_list, &(priv->zone_status), enabled, pos, acc);
+}
+
+static void
+sps_velocity_cb (gboolean enabled,
+       LocationVelocity *vel,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("sps_velocity_cb");
+       g_return_if_fail(self);
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       velocity_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->vel), enabled, vel, acc);
+}
+
+static void
+location_setting_sps_cb(keynode_t *key,
+       gpointer self)
+{
+       LOCATION_LOGD("location_setting_sps_cb");
+       g_return_if_fail(key);
+       g_return_if_fail(self);
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       if (0 == location_setting_get_key_val(key) && priv->mod->ops.stop) {
+               LOCATION_LOGD("location stopped by setting");
+               priv->mod->ops.stop(priv->mod->handler);
+       }
+       else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start) {
+               LOCATION_LOGD("location resumed by setting");
+               priv->mod->ops.start (priv->mod->handler, sps_status_cb, sps_position_cb, sps_velocity_cb, self);
+       }
+}
+
+static int
+location_sps_start (LocationSps *self)
+{
+       LOCATION_LOGD("location_sps_start");
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.update_data, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(SENSOR_ENABLED);
+       if( priv->is_started == TRUE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.start(priv->mod->handler, sps_status_cb, sps_position_cb, sps_velocity_cb, self);
+       if(ret == LOCATION_ERROR_NONE){
+               priv->is_started = TRUE;
+               location_setting_add_notify (GPS_ENABLED, location_setting_sps_cb, self);
+               location_setting_add_notify (SENSOR_ENABLED, location_setting_sps_cb, self);
+               priv->mod->ops.update_data(priv->mod->handler, priv->pos_base, priv->vel_base, priv->acc_info, priv->sat_info);
+       }
+       return ret;
+}
+
+static int
+location_sps_stop (LocationSps *self)
+{
+       LOCATION_LOGD("location_sps_stop");
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
+       if (priv->is_started == FALSE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.stop (priv->mod->handler);
+       if (ret == LOCATION_ERROR_NONE){
+               priv->is_started = FALSE;
+               location_setting_ignore_notify (GPS_ENABLED, location_setting_sps_cb);
+               location_setting_ignore_notify (SENSOR_ENABLED, location_setting_sps_cb);
+       }
+       return ret;
+}
+
+static void
+location_sps_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_sps_dispose");
+       G_OBJECT_CLASS (location_sps_parent_class)->dispose (gobject);
+}
+
+static void
+location_sps_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_sps_finalize");
+       LocationSpsPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "sps");
+       priv->mod = NULL;
+       G_OBJECT_CLASS (location_sps_parent_class)->finalize (gobject);
+}
+
+static void
+location_sps_set_property (GObject *object,
+       guint property_id,
+       const GValue *value,
+       GParamSpec *pspec)
+{
+       LocationSpsPrivate* priv = GET_PRIVATE(object);
+
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       LocModSpsOps ops = priv->mod->ops;
+       g_return_if_fail (ops.update_data);
+
+       int ret = 0;
+       switch (property_id){
+               case PROP_BOUNDARY:{
+                       GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value));
+                       ret = set_prop_boundary(&priv->boundary_list, boundary_list);
+                       if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret);
+         break;
+               }
+               case PROP_REMOVAL_BOUNDARY: {
+                       LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value);
+                       ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
+                       if(ret != 0) LOCATION_LOGD("Removal boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_POSITION_BASE:{
+                       if(priv->pos_base) location_position_free(priv->pos_base);
+                       priv->pos_base = (LocationPosition*) g_value_dup_boxed (value);
+                       LOCATION_LOGD("Set prop>> base position: \t%lf, %lf, %lf, time: %d", priv->pos_base->latitude, priv->pos_base->longitude, priv->pos_base->altitude, priv->pos_base->timestamp);
+                       if (priv->is_started) ops.update_data (priv->mod->handler, priv->pos_base, priv->vel_base, priv->acc_info, priv->sat_info);
+                       break;
+               }
+               case PROP_VELOCITY_BASE:{
+                       if(priv->vel_base) location_velocity_free(priv->vel_base);
+                       priv->vel_base = (LocationVelocity*) g_value_dup_boxed (value);
+                       LOCATION_LOGD("Set prop>> base velocity: \t%lf, %lf, %lf, time: %d", priv->vel_base->speed, priv->vel_base->direction, priv->vel_base->climb, priv->vel_base->timestamp);
+                       if(priv->is_started) ops.update_data (priv->mod->handler, priv->pos_base, priv->vel_base, priv->acc_info, priv->sat_info);
+                       break;
+               }
+               case PROP_ACCURACY_INFO:{
+                       if(priv->acc_info) location_accuracy_free(priv->acc_info);
+                       priv->acc_info = (LocationAccuracy*) g_value_dup_boxed (value);
+                       LOCATION_LOGD("Set prop>> accuracy information: \t%d, %lf, %lf", priv->acc_info->level, priv->acc_info->horizontal_accuracy, priv->acc_info->vertical_accuracy);
+                       if(priv->is_started) ops.update_data (priv->mod->handler, priv->pos_base, priv->vel_base, priv->acc_info, priv->sat_info);
+                       break;
+               }
+               case PROP_SATELLITE_INFO:{
+                       if(priv->sat_info) location_satellite_free(priv->sat_info);
+                       priv->sat_info = (LocationSatellite*) g_value_dup_boxed (value);
+                       LOCATION_LOGD("Set prop>> satellite information: \tNofView:%d, NofUsed:%d", priv->sat_info->num_of_sat_inview, priv->sat_info->num_of_sat_used);
+                       if(priv->is_started) ops.update_data (priv->mod->handler, priv->pos_base, priv->vel_base, priv->acc_info, priv->sat_info);
+                       break;
+               }
+               case PROP_UPDATE_INTERVAL: {
+                       guint interval = g_value_get_uint(value);
+                       if(interval > 0) {
+                               if(interval < LOCATION_UPDATE_INTERVAL_MAX)
+                                       priv->interval = interval;
+                               else
+                                       priv->interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
+
+                       }
+                       else
+                               priv->interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static void
+location_sps_get_property (GObject *object,
+                           guint property_id,
+                           GValue *value,
+                           GParamSpec *pspec)
+{
+       LocationSpsPrivate *priv = GET_PRIVATE (object);
+
+       switch (property_id){
+               case PROP_METHOD_TYPE:
+                       g_value_set_int(value, LOCATION_METHOD_SPS);
+                       break;
+               case PROP_LAST_POSITION:
+                       g_value_set_boxed (value, priv->pos);
+                       break;
+               case PROP_BOUNDARY:
+                       g_value_set_pointer(value, g_list_first(priv->boundary_list));
+                       break;
+               case PROP_POSITION_BASE:
+                       g_value_set_boxed (value, priv->pos_base);
+                       break;
+               case PROP_VELOCITY_BASE:
+                       g_value_set_boxed (value, priv->vel_base);
+                       break;
+               case PROP_ACCURACY_INFO:
+                       g_value_set_boxed (value, priv->acc_info);
+                       break;
+               case PROP_SATELLITE_INFO:
+                       g_value_set_boxed (value, priv->sat_info);
+                       break;
+               case PROP_UPDATE_INTERVAL:
+                       g_value_set_uint(value, priv->interval);
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static int
+location_sps_get_position (LocationSps *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_sps_get_position");
+
+       LocationSpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(SENSOR_ENABLED);
+
+       LocModSpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_position(priv->mod->handler, position, accuracy);
+}
+
+static int
+location_sps_get_velocity (LocationSps *self,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_sps_get_velocity");
+
+       LocationSpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(SENSOR_ENABLED);
+
+       LocModSpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_velocity(priv->mod->handler, velocity, accuracy);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->start = (TYPE_START_FUNC)location_sps_start;
+       iface->stop = (TYPE_STOP_FUNC)location_sps_stop;
+       iface->get_position = (TYPE_GET_POSITION)location_sps_get_position;
+       iface->get_velocity = (TYPE_GET_VELOCITY)location_sps_get_velocity;
+}
+
+static void
+location_sps_init (LocationSps *self)
+{
+       LOCATION_LOGD("location_sps_init");
+       LocationSpsPrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationSpsMod*)module_new("sps");
+       if(!priv->mod)
+               LOCATION_LOGW("module loading failed");
+
+       priv->is_started = FALSE;
+       priv->enabled= FALSE;
+       priv->interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+       priv->pos = NULL;
+       priv->vel = NULL;
+       priv->acc = NULL;
+       priv->zone_status = ZONE_STATUS_NONE;
+       priv->boundary_list = NULL;
+
+       priv->pos_base = NULL;
+       priv->vel_base = NULL;
+       priv->acc_info = NULL;
+       priv->sat_info = NULL;
+}
+
+static void
+location_sps_class_init (LocationSpsClass *klass)
+{
+       LOCATION_LOGD("location_sps_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+       gobject_class->set_property = location_sps_set_property;
+       gobject_class->get_property = location_sps_get_property;
+
+       gobject_class->dispose = location_sps_dispose;
+       gobject_class->finalize = location_sps_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationSpsPrivate));
+
+       signals[SERVICE_ENABLED] = g_signal_new ("service-enabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationSpsClass, enabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_DISABLED] = g_signal_new ("service-disabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationSpsClass, disabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_UPDATED] = g_signal_new ("service-updated",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationSpsClass, updated),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_IN] = g_signal_new ("zone-in",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationSpsClass, zone_in),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_OUT] = g_signal_new ("zone-out",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationSpsClass, zone_out),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       properties[PROP_METHOD_TYPE]  = g_param_spec_int ("method",
+                       "method type",
+                       "location method type name",
+                       LOCATION_METHOD_SPS,
+                       LOCATION_METHOD_SPS,
+                       LOCATION_METHOD_SPS,
+                       G_PARAM_READABLE);
+
+       properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position",
+                       "sps last position prop",
+                       "sps last position data",
+                       LOCATION_TYPE_POSITION,
+                       G_PARAM_READABLE);
+
+       properties[PROP_UPDATE_INTERVAL] = g_param_spec_uint ("update-interval",
+                       "sps update interval prop",
+                       "sps update interval data",
+                       LOCATION_UPDATE_INTERVAL_MIN,
+                       LOCATION_UPDATE_INTERVAL_MAX,
+                       LOCATION_UPDATE_INTERVAL_DEFAULT,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary",
+                       "sps boundary prop",
+                       "sps boundary data",
+                       G_PARAM_READWRITE);
+
+       properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary",
+                       "sps removal boundary prop",
+                       "sps removal boundary data",
+                       LOCATION_TYPE_BOUNDARY,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_POSITION_BASE] = g_param_spec_boxed ("position-base",
+                       "sps position base prop",
+                       "sps position base data",
+                       LOCATION_TYPE_POSITION,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_VELOCITY_BASE] = g_param_spec_boxed ("velocity-base",
+                       "sps velocity base prop",
+                       "sps velocity base data",
+                       LOCATION_TYPE_VELOCITY,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_ACCURACY_INFO] = g_param_spec_boxed ("accuracy-info",
+                       "sps accuracy information prop",
+                       "sps accuracy information data",
+                       LOCATION_TYPE_ACCURACY,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_SATELLITE_INFO] = g_param_spec_boxed ("satellite-info",
+                       "sps satellite information prop",
+                       "sps satellite information data",
+                       LOCATION_TYPE_SATELLITE,
+                       G_PARAM_READWRITE);
+
+       g_object_class_install_properties (gobject_class,
+                       PROP_MAX,
+                       properties);
+}
diff --git a/location/location-sps.h b/location/location-sps.h
new file mode 100644 (file)
index 0000000..5d82a9a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_SPS_H__
+#define __LOCATION_SPS_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-sps.h
+ * @brief This file contains the internal definitions and structures related to SPS.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_SPS                  (location_sps_get_type ())
+#define LOCATION_SPS(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_SPS, LocationSps))
+#define LOCATION_IS_SPS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_SPS))
+#define LOCATION_SPS_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_SPS, LocationSpsClass))
+#define LOCATION_IS_SPS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_SPS))
+#define LOCATION_SPS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_SPS, LocationSpsClass))
+
+typedef struct _LocationSps        LocationSps;
+typedef struct _LocationSpsClass   LocationSpsClass;
+
+struct _LocationSps
+{
+       GObject parent_instance;
+};
+
+struct _LocationSpsClass
+{
+       GObjectClass parent_class;
+
+       void (* enabled) (guint type);
+       void (* disabled) (guint type);
+       void (* updated) (guint type, gpointer data);
+       void (* zone_in) (guint type, gpointer position, gpointer boundary);
+       void (* zone_out) (guint type, gpointer position, gpointer boundary);
+};
+
+GType location_sps_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-types.h b/location/location-types.h
new file mode 100644 (file)
index 0000000..fb74707
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_TYPE_H__
+#define __LOCATION_TYPE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ * @file location-types.h
+ * @brief This file contains the Location related structure, enumeration, and asynchronous function definitions.
+ * @addtogroup LocationFW
+ * @{
+ * @defgroup LocationTypes Location Types
+ * @brief This sub module provides structure, enumeration, and asynchronous function definitions.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+/**
+ * @brief This represents the returned error code of used functions.
+ */
+typedef enum {
+       LOCATION_ERROR_NONE = 0,       ///< Success.
+       LOCATION_ERROR_NOT_ALLOWED,    ///< Location servie is not allowed.
+       LOCATION_ERROR_NOT_AVAILABLE,  ///< Location service is not available.
+       LOCATION_ERROR_NETWORK_FAILED, ///< Network is not available.
+       LOCATION_ERROR_NETWORK_NOT_CONNECTED, ///< Network is not connected.
+       LOCATION_ERROR_CONFIGURATION,  ///< Configuration setting is not correct.
+       LOCATION_ERROR_PARAMETER,      ///< Input parameter is not correct.
+       LOCATION_ERROR_UNKNOWN,        ///< Unknown error.
+} LocationError;
+
+/**
+ * @brief This represents location method to be used.
+ */
+typedef enum
+{
+       LOCATION_METHOD_NONE = -1,   ///< Undefined method.
+       LOCATION_METHOD_HYBRID = 0,  ///< This method selects best method.
+       LOCATION_METHOD_GPS,         ///< This method uses Global Positioning System.
+       LOCATION_METHOD_WPS,         ///< This method uses Wifi Positioning System.
+       LOCATION_METHOD_CPS,         ///< This method uses cell ID of base station.
+       LOCATION_METHOD_IPS,         ///< This method uses IP address.
+       LOCATION_METHOD_SPS          ///< This method uses sensor.
+} LocationMethod;
+
+/**
+ * @brief This represents the update type given by signal callback.
+ */
+typedef enum {
+       UPDATE_TYPE_NONE = -1,  ///< Undefined update type.
+       POSITION_UPDATED = 0,   ///< This type is used when position information is updated.
+       VELOCITY_UPDATED,       ///< This type is used when velocity information is updated.
+       ADDRESS_UPDATED,        ///< This type is used when address information is updated. This is not implemented yet.
+       GEOCODE_UPDATED,        ///< This type is used when geocode information is updated. This is not implemented yet.
+       REVERSEGEOCODE_UPDATED  ///< This type is used when reverse geocode information is updated. This is not implemented yet.
+} LocationUpdateType;
+
+/**
+ * @brief Location object redefined by GObject.
+ */
+typedef GObject LocationObject;
+
+/**
+ * @brief This represents position information such as latitude-longitude-altitude values and timestamp.
+ */
+typedef struct _LocationPosition   LocationPosition;
+
+/**
+ * @brief This represents last known position information such as latitude-longitud values and accuracy.
+ */
+typedef struct _LocationLastPosition   LocationLastPosition;
+
+/**
+ * @brief This represents velocity information such as as speed, direction, climb.
+ */
+typedef struct _LocationVelocity   LocationVelocity;
+
+/**
+ * @brief This represents location accuracy information such as accuracy level, horizontal and vertical accuracy.
+ */
+typedef struct _LocationAccuracy   LocationAccuracy;
+
+/**
+ * @brief This represents address information such as building number, street name, etc.
+ */
+typedef struct _LocationAddress    LocationAddress;
+
+/**
+ * @brief This represents boundary information such as rectagular or circle area.
+ */
+typedef struct _LocationBoundary   LocationBoundary;
+
+/**
+ * @brief This represents position information such as number of satelltes in used or in view.
+ */
+typedef struct _LocationSatellite  LocationSatellite;
+
+/**
+ * @brief This represents a number of POI informations.
+ */
+typedef struct _LocationPOIInfo    LocationPOIInfo;
+
+/**
+ * @brief This represents callback function which will be called to give postiion information.
+ */
+typedef void (*LocationPositionCB)(LocationError error, LocationPosition *position, LocationAccuracy *acc, gpointer userdata);
+
+/**
+ * @brief This represents callback function which will be called to give address information.
+ */
+typedef void (*LocationAddressCB)(LocationError error, LocationAddress *address, LocationAccuracy *acc, gpointer userdata);
+
+/**
+ * @brief This represents callback function which will be called to give POI information.
+ */
+typedef void (*LocationPOICB)(LocationError error, LocationPOIInfo *poi, gpointer userdata);
+
+/**
+ * @}@}
+ */
+
+G_END_DECLS
+
+#endif /* __LOCATION_TYPE_H__ */
diff --git a/location/location-velocity.c b/location/location-velocity.c
new file mode 100644 (file)
index 0000000..fd7b523
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-velocity.h"
+#include "location/location-log.h"
+
+GType
+location_velocity_get_type (void)
+{
+       static volatile gsize type_volatile = 0;
+       if(g_once_init_enter(&type_volatile)) {
+               GType type = g_boxed_type_register_static (
+                       g_intern_static_string ("LocationVelocity"),
+                       (GBoxedCopyFunc) location_velocity_copy,
+                       (GBoxedFreeFunc) location_velocity_free);
+               g_once_init_leave(&type_volatile, type);
+       }
+       return type_volatile;
+}
+
+EXPORT_API LocationVelocity*
+location_velocity_new (guint timestamp,
+       gdouble speed,
+       gdouble direction,
+       gdouble climb)
+{
+       LocationVelocity* velocity = g_slice_new0(LocationVelocity);
+       velocity->timestamp = timestamp;
+       velocity->speed = speed;
+       velocity->direction = direction;
+       velocity->climb = climb;
+       return velocity;
+}
+
+EXPORT_API void
+location_velocity_free (LocationVelocity* velocity)
+{
+       g_return_if_fail(velocity);
+       g_slice_free(LocationVelocity, velocity);
+}
+
+EXPORT_API gboolean
+location_velocity_equal (const LocationVelocity *velocity1, const LocationVelocity *velocity2)
+{
+       g_return_val_if_fail(velocity1, FALSE);
+       g_return_val_if_fail(velocity2, FALSE);
+
+       if (velocity1->timestamp == velocity2->timestamp &&
+               velocity1->speed == velocity2->speed &&
+               velocity1->direction == velocity2->direction &&
+               velocity1->climb == velocity2->climb)
+               return TRUE;
+       return FALSE;
+}
+
+EXPORT_API LocationVelocity*
+location_velocity_copy (const LocationVelocity *velocity)
+{
+       g_return_val_if_fail(velocity, NULL);
+
+       LocationVelocity *new_velocity = NULL;
+
+       new_velocity = location_velocity_new(velocity->timestamp,
+                                                               velocity->speed,
+                                                               velocity->direction,
+                                                               velocity->climb);
+       if(new_velocity) new_velocity->updated_timestamp = velocity->updated_timestamp;
+
+       return new_velocity;
+}
diff --git a/location/location-velocity.h b/location/location-velocity.h
new file mode 100644 (file)
index 0000000..5dc1c81
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_VELOCITY_H_
+#define __LOCATION_VELOCITY_H_
+
+#include <location/location-types.h>
+
+/**
+ * @file location-velocity.h
+ * @brief This file contains the internal definitions and structures related to velocity information.
+ * @addtogroup LocationTypes
+ * @{
+ */
+
+G_BEGIN_DECLS
+
+/**
+ * @brief This represents velocity information such as as speed, direction, climb.
+ */
+struct _LocationVelocity
+{
+       guint timestamp;                ///< Time stamp.
+       guint updated_timestamp;        ///< The latest updated time stamp.
+       gdouble speed;                  ///< The speed over ground. (km/h)
+       gdouble direction;              ///< The course made in degrees relative to true north. The value is always in the range [0.0, 360.0] degree.
+       gdouble climb;                  ///< The vertical speed. (km/h)
+};
+
+GType location_velocity_get_type (void);
+#define LOCATION_TYPE_VELOCITY                 (location_velocity_get_type ())
+
+/**
+ * @brief   Create a new #LocationVelocity with given information.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  timestamp - Time stamp.
+ * @param [in]  speed - The speed over ground. (km/h)
+ * @param [in]  direction - The course made in degrees relative to true north. The value is always in the range [0.0, 360.0] degree.
+ * @param [in]  climb - The vertical speed. (km/h)
+ * @return a new #LocationVelocity
+ * @retval NULL if error occured
+ */
+LocationVelocity *location_velocity_new (guint timestamp, gdouble speed, gdouble direction,    gdouble climb);
+
+/**
+ * @brief   Free a #LocationVelocity.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in] velocity - a #LocationVelocity.
+ * @return None.
+ */
+void location_velocity_free (LocationVelocity *velocity);
+
+/**
+ * @brief   Compares two velocities for equality, returning TRUE if they are equal.
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  velocity1 - a #LocationVelocity
+ * @param [in]  velocity2 - a #LocationVelocity
+ * @return gboolean
+ * @retval\n
+ * TRUE - if equal\n
+ * FALSE - if not equal\n
+ */
+gboolean location_velocity_equal (const LocationVelocity *velocity1, const LocationVelocity *velocity2);
+
+/**
+ * @brief   Makes a copy of #LocationVelocity
+ * @remarks None.
+ * @pre     #location_init should be called before.\n
+ * @post    None.
+ * @param [in]  velocity - a #LocationVelocity
+ * @return a new #LocationVelocity
+ * @retval NULL if error occured
+ */
+LocationVelocity *location_velocity_copy (const LocationVelocity *velocity);
+
+/**
+ * @}
+ */
+
+G_END_DECLS
+
+#endif
diff --git a/location/location-wps.c b/location/location-wps.c
new file mode 100644 (file)
index 0000000..5b69e7d
--- /dev/null
@@ -0,0 +1,426 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "location/location-setting.h"
+#include "location/location-log.h"
+
+#include "location/location-module-internal.h"
+
+#include "location/location-wps.h"
+#include "location/location-marshal.h"
+#include "location/location-ielement.h"
+#include "location/location-signaling-util.h"
+#include "location/location-common-util.h"
+/*
+ * forward definitions
+ */
+
+typedef struct _LocationWpsPrivate {
+       LocationWpsMod* mod;
+       gboolean is_started;
+       gboolean enabled;
+       guint    interval;
+       LocationPosition *pos;
+       LocationVelocity *vel;
+       LocationAccuracy *acc;
+       GList *boundary_list;
+       ZoneStatus zone_status;
+} LocationWpsPrivate;
+
+enum {
+       PROP_0,
+       PROP_METHOD_TYPE,
+       PROP_LAST_POSITION,
+       PROP_UPDATE_INTERVAL,
+       PROP_BOUNDARY,
+       PROP_REMOVAL_BOUNDARY,
+       PROP_MAX
+};
+
+static guint32 signals[LAST_SIGNAL] = {0, };
+static GParamSpec *properties[PROP_MAX] = {NULL, };
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_WPS, LocationWpsPrivate))
+
+static void location_ielement_interface_init (LocationIElementInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (LocationWps, location_wps, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
+                         location_ielement_interface_init));
+
+static void
+wps_status_cb (gboolean enabled,
+       LocationStatus status,
+       gpointer self)
+{
+       LOCATION_LOGD("wps_status_cb");
+       g_return_if_fail(self);
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, status);
+}
+
+static void
+wps_position_cb (gboolean enabled,
+       LocationPosition *pos,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("wps_position_cb");
+       g_return_if_fail(self);
+       g_return_if_fail(pos);
+       g_return_if_fail(acc);
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       enable_signaling(self, signals, &(priv->enabled), enabled, pos->status);
+       position_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->pos), &(priv->acc), priv->boundary_list, &(priv->zone_status), enabled, pos, acc);
+}
+
+static void
+wps_velocity_cb(gboolean enabled,
+       LocationVelocity *vel,
+       LocationAccuracy *acc,
+       gpointer self)
+{
+       LOCATION_LOGD("wps_velocity_cb");
+       g_return_if_fail(self);
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       velocity_signaling(self, signals, &(priv->enabled), priv->interval, &(priv->vel), enabled, vel, acc);
+}
+
+static void
+location_setting_wps_cb(keynode_t *key,
+       gpointer self)
+{
+       LOCATION_LOGD("location_setting_wps_cb");
+       g_return_if_fail(key);
+       g_return_if_fail(self);
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       g_return_if_fail (priv->mod);
+       g_return_if_fail (priv->mod->handler);
+       if (0 == location_setting_get_key_val(key) && priv->mod->ops.stop) {
+               LOCATION_LOGD("location stopped by setting");
+               priv->mod->ops.stop(priv->mod->handler);
+       }
+       else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start) {
+               LOCATION_LOGD("location resumed by setting");
+               priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_position_cb, wps_velocity_cb, self);
+       }
+}
+
+static int
+location_wps_start (LocationWps *self)
+{
+       LOCATION_LOGD("location_wps_start");
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail (GPS_ENABLED);
+       setting_retval_if_fail (NETWORK_ENABLED);
+       if (priv->is_started == TRUE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_position_cb, wps_velocity_cb, self);
+       if (ret == LOCATION_ERROR_NONE) {
+               priv->is_started = TRUE;
+               location_setting_add_notify (GPS_ENABLED, location_setting_wps_cb, self);
+               location_setting_add_notify (NETWORK_ENABLED, location_setting_wps_cb, self);
+       }
+       return ret;
+}
+
+static int
+location_wps_stop (LocationWps *self)
+{
+       LOCATION_LOGD("location_wps_stop");
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
+       if( priv->is_started == FALSE) return LOCATION_ERROR_NONE;
+
+       int ret = priv->mod->ops.stop (priv->mod->handler);
+       if (ret == LOCATION_ERROR_NONE) {
+               priv->is_started = FALSE;
+               location_setting_ignore_notify (GPS_ENABLED, location_setting_wps_cb);
+               location_setting_ignore_notify (NETWORK_ENABLED, location_setting_wps_cb);
+       }
+       return ret;
+}
+
+static void
+location_wps_dispose (GObject *gobject)
+{
+       LOCATION_LOGD("location_wps_dispose");
+       G_OBJECT_CLASS (location_wps_parent_class)->dispose (gobject);
+}
+
+static void
+location_wps_finalize (GObject *gobject)
+{
+       LOCATION_LOGD("location_wps_finalize");
+       LocationWpsPrivate* priv = GET_PRIVATE(gobject);
+       module_free(priv->mod, "wps");
+       G_OBJECT_CLASS (location_wps_parent_class)->finalize (gobject);
+}
+
+static void
+location_wps_set_property (GObject *object,
+       guint property_id,
+       const GValue *value,
+       GParamSpec *pspec)
+{
+       LocationWpsPrivate* priv = GET_PRIVATE(object);
+       int ret = 0;
+
+       switch (property_id){
+               case PROP_BOUNDARY:{
+                       GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value));
+                       ret = set_prop_boundary(&priv->boundary_list, boundary_list);
+                       if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_REMOVAL_BOUNDARY: {
+                       LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value);
+                       ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
+                       if(ret != 0) LOCATION_LOGD("Set removal boundary. Error[%d]", ret);
+                       break;
+               }
+               case PROP_UPDATE_INTERVAL: {
+                       guint interval = g_value_get_uint(value);
+                       if(interval > 0) {
+                               if(interval < LOCATION_UPDATE_INTERVAL_MAX)
+                                       priv->interval = interval;
+                               else
+                                       priv->interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
+                       }
+                       else
+                               priv->interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
+                       break;
+               }
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static void
+location_wps_get_property (GObject *object,
+       guint property_id,
+       GValue *value,
+       GParamSpec *pspec)
+{
+       LocationWpsPrivate *priv = GET_PRIVATE (object);
+
+       switch (property_id){
+               case PROP_METHOD_TYPE:
+                       g_value_set_int(value, LOCATION_METHOD_WPS);
+                       break;
+               case PROP_LAST_POSITION:
+                       g_value_set_boxed (value, priv->pos);
+                       break;
+               case PROP_BOUNDARY:
+                       g_value_set_pointer(value, g_list_first(priv->boundary_list));
+                       break;
+               case PROP_UPDATE_INTERVAL:
+                       g_value_set_uint(value, priv->interval);
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static int
+location_wps_get_position (LocationWps *self,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_wps_get_position");
+
+       LocationWpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(NETWORK_ENABLED);
+
+       LocModWpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_position(priv->mod->handler, position, accuracy);
+}
+
+static int
+location_wps_get_velocity (LocationWps *self,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       LOCATION_LOGD("location_wps_get_velocity");
+
+       LocationWpsPrivate *priv = GET_PRIVATE (self);
+       g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(GPS_ENABLED);
+       setting_retval_if_fail(NETWORK_ENABLED);
+
+       LocModWpsOps ops = priv->mod->ops;
+       g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (ops.get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
+       return ops.get_velocity(priv->mod->handler, velocity, accuracy);
+}
+
+static void
+location_ielement_interface_init (LocationIElementInterface *iface)
+{
+       iface->start = (TYPE_START_FUNC)location_wps_start;
+       iface->stop = (TYPE_STOP_FUNC)location_wps_stop;
+       iface->get_position = (TYPE_GET_POSITION)location_wps_get_position;
+       iface->get_velocity = (TYPE_GET_VELOCITY)location_wps_get_velocity;
+}
+
+static void
+location_wps_init (LocationWps *self)
+{
+       LOCATION_LOGD("location_wps_init");
+       LocationWpsPrivate* priv = GET_PRIVATE(self);
+
+       priv->mod = (LocationWpsMod*)module_new("wps");
+       if(!priv->mod) LOCATION_LOGW("module loading failed");
+
+       priv->is_started = FALSE;
+       priv->enabled= FALSE;
+       priv->interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+
+       priv->pos = NULL;
+       priv->vel = NULL;
+       priv->acc = NULL;
+       priv->zone_status = ZONE_STATUS_NONE;
+       priv->boundary_list = NULL;
+}
+
+static void
+location_wps_class_init (LocationWpsClass *klass)
+{
+       LOCATION_LOGD("location_wps_class_init");
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+       gobject_class->set_property = location_wps_set_property;
+       gobject_class->get_property = location_wps_get_property;
+
+       gobject_class->dispose = location_wps_dispose;
+       gobject_class->finalize = location_wps_finalize;
+
+       g_type_class_add_private (klass, sizeof (LocationWpsPrivate));
+
+       signals[SERVICE_ENABLED] = g_signal_new ("service-enabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationWpsClass, enabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_DISABLED] = g_signal_new ("service-disabled",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationWpsClass, disabled),
+                       NULL, NULL,
+                       location_VOID__UINT,
+                       G_TYPE_NONE, 1,
+                       G_TYPE_UINT);
+
+       signals[SERVICE_UPDATED] = g_signal_new ("service-updated",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationWpsClass, updated),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_IN] = g_signal_new ("zone-in",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationWpsClass, zone_in),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       signals[ZONE_OUT] = g_signal_new ("zone-out",
+                       G_TYPE_FROM_CLASS (klass),
+                       G_SIGNAL_RUN_FIRST |
+                       G_SIGNAL_NO_RECURSE,
+                       G_STRUCT_OFFSET (LocationWpsClass, zone_out),
+                       NULL, NULL,
+                       location_VOID__UINT_POINTER_POINTER,
+                       G_TYPE_NONE, 3,
+                       G_TYPE_UINT,
+                       G_TYPE_POINTER,
+                       G_TYPE_POINTER);
+
+       properties[PROP_METHOD_TYPE] = g_param_spec_int ("method",
+                       "method type",
+                       "location method type name",
+                       LOCATION_METHOD_WPS,
+                       LOCATION_METHOD_WPS,
+                       LOCATION_METHOD_WPS,
+                       G_PARAM_READABLE);
+
+       properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position",
+                       "wps last position prop",
+                       "wps last position data",
+                       LOCATION_TYPE_POSITION,
+                       G_PARAM_READABLE);
+
+       properties[PROP_UPDATE_INTERVAL] = g_param_spec_uint ("update-interval",
+                       "wps update interval prop",
+                       "wps update interval data",
+                       LOCATION_UPDATE_INTERVAL_MIN,
+                       LOCATION_UPDATE_INTERVAL_MAX,
+                       LOCATION_UPDATE_INTERVAL_DEFAULT,
+                       G_PARAM_READWRITE);
+
+       properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary",
+                       "wps boundary prop",
+                       "wps boundary data",
+                       G_PARAM_READWRITE);
+
+       properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary",
+                       "wps removal boundary prop",
+                       "wps removal boundary data",
+                       LOCATION_TYPE_BOUNDARY,
+                       G_PARAM_READWRITE);
+
+       g_object_class_install_properties (gobject_class,
+                       PROP_MAX,
+                       properties);
+}
+
diff --git a/location/location-wps.h b/location/location-wps.h
new file mode 100644 (file)
index 0000000..77ec679
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifndef __LOCATION_WPS_H__
+#define __LOCATION_WPS_H__
+
+#include <glib-object.h>
+
+/**
+ * @file location-wps.h
+ * @brief This file contains the internal definitions and structures related to WPS.
+ * @addtogroup LocationInternal
+ * @{
+ * @}
+ */
+
+G_BEGIN_DECLS
+
+#define LOCATION_TYPE_WPS                  (location_wps_get_type ())
+#define LOCATION_WPS(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_WPS, LocationWps))
+#define LOCATION_IS_WPS(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_WPS))
+#define LOCATION_WPS_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_WPS, LocationWpsClass))
+#define LOCATION_IS_WPS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_WPS))
+#define LOCATION_WPS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_WPS, LocationWpsClass))
+
+typedef struct _LocationWps        LocationWps;
+typedef struct _LocationWpsClass   LocationWpsClass;
+
+struct _LocationWps
+{
+       GObject parent_instance;
+};
+
+struct _LocationWpsClass
+{
+       GObjectClass parent_class;
+
+       void (* enabled) (guint type);
+       void (* disabled) (guint type);
+       void (* updated) (guint type, gpointer data);
+       void (* zone_in) (guint type, gpointer position, gpointer boundary);
+       void (* zone_out) (guint type, gpointer position, gpointer boundary);
+};
+
+GType location_wps_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/location/location.c b/location/location.c
new file mode 100644 (file)
index 0000000..5afe973
--- /dev/null
@@ -0,0 +1,418 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "location/location.h"
+#include "location/location-log.h"
+#include "location/location-setting.h"
+#include "location/location-module-internal.h"
+#include "location/location-ielement.h"
+#include "location/location-hybrid.h"
+#include "location/location-gps.h"
+#include "location/location-wps.h"
+#include "location/location-ips.h"
+#include "location/location-cps.h"
+#include "location/location-sps.h"
+#include "location/location-geocode.h"
+#include "location/location-poi.h"
+#include "location/location-position.h"
+
+static LocationObject *geocode = NULL;
+static LocationObject *poi = NULL;
+
+static gboolean
+is_connected_network()
+{
+       gboolean is_connected = TRUE;
+       int net_state = 0;
+
+       net_state = location_setting_get_int(VCONFKEY_NETWORK_STATUS);
+
+       LOCATION_LOGW("net_state[%d]", net_state);
+       if(net_state == VCONFKEY_NETWORK_OFF) {
+               is_connected = FALSE;
+       }
+
+       return is_connected;
+
+}
+
+EXPORT_API int location_init (void)
+{
+       LOCATION_LOGD("location_init");
+       g_type_init ();
+       if( FALSE == module_init() )
+               return LOCATION_ERROR_NOT_AVAILABLE;
+
+       return LOCATION_ERROR_NONE;
+}
+
+EXPORT_API LocationObject*
+location_new (LocationMethod method)
+{
+       LocationObject *self = NULL;
+
+       if (!geocode)
+               geocode = g_object_new (LOCATION_TYPE_GEOCODE, NULL);
+
+       /*if (!poi)
+               poi = g_object_new (LOCATION_TYPE_POI, NULL);*/
+
+       switch (method) {
+       case LOCATION_METHOD_HYBRID:
+               self = g_object_new (LOCATION_TYPE_HYBRID, NULL);
+               break;
+       case LOCATION_METHOD_GPS:
+               self = g_object_new (LOCATION_TYPE_GPS, NULL);
+               break;
+       case LOCATION_METHOD_WPS:
+               self = g_object_new (LOCATION_TYPE_WPS, NULL);
+               break;
+       case LOCATION_METHOD_CPS:
+               self = g_object_new (LOCATION_TYPE_CPS, NULL);
+               break;
+       case LOCATION_METHOD_IPS:
+               self = g_object_new (LOCATION_TYPE_IPS, NULL);
+               break;
+       case LOCATION_METHOD_SPS:
+               self = g_object_new (LOCATION_TYPE_SPS, NULL);
+               break;
+       default:
+               break;
+       }
+       return self;
+}
+
+EXPORT_API int
+location_free (LocationObject *obj)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+
+       //location_ielement_stop(LOCATION_IELEMENT(obj));
+       if (geocode) {
+               g_object_unref (geocode);
+               geocode = NULL;
+       }
+       /*if (poi) {
+               g_object_unref (poi);
+               poi = NULL;
+       }*/
+       g_object_unref (obj);
+       return LOCATION_ERROR_NONE;
+}
+
+EXPORT_API int
+location_start (LocationObject *obj)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       return location_ielement_start (LOCATION_IELEMENT(obj));
+}
+
+EXPORT_API int
+location_stop (LocationObject *obj)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       return location_ielement_stop (LOCATION_IELEMENT(obj));
+}
+
+EXPORT_API gboolean
+location_is_supported_method(LocationMethod method)
+{
+       gboolean is_supported = FALSE;
+
+       switch(method) {
+       case LOCATION_METHOD_HYBRID:
+               if(module_is_supported("gps") || module_is_supported("wps") || module_is_supported("sps"))
+                       is_supported = TRUE;
+               break;
+       case LOCATION_METHOD_GPS:
+               is_supported = module_is_supported("gps");
+               break;
+       case LOCATION_METHOD_WPS:
+               is_supported = module_is_supported("wps");
+               break;
+       case LOCATION_METHOD_SPS:
+               is_supported = module_is_supported("sps");
+               break;
+       case LOCATION_METHOD_CPS:
+       case LOCATION_METHOD_IPS:
+       default:
+               break;
+       }
+
+       return is_supported;
+}
+
+EXPORT_API gboolean
+location_is_enabled_gps(LocationObject *obj)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+
+       return (gboolean) location_setting_get_int(GPS_ENABLED);
+}
+
+EXPORT_API int
+location_get_position (LocationObject *obj,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       return location_ielement_get_position (LOCATION_IELEMENT(obj), position, accuracy);
+}
+
+EXPORT_API int
+location_get_last_known_position (LocationObject *obj,
+       LocationLastPosition *last_position)
+{
+       g_return_val_if_fail (last_position, LOCATION_ERROR_PARAMETER);
+
+       int ret = -1;
+       int lat, lon, acc;
+       char position[MAX_KEY_LENGTH + 1] = {0,};
+
+       snprintf(position, MAX_KEY_LENGTH + 1, "%s", location_setting_get_string(LAST_POSITION));
+       if (position[0] != '\0') {
+               location_last_position_a2i(position, &lat, &lon);
+               LOCATION_LOGD("location_last_position_a2i [%s][%d/%d]", position, lat, lon);
+               acc = location_setting_get_int(LAST_ACCURACY);
+
+               last_position->latitude = lat * 0.0001;
+               last_position->longitude = lon * 0.0001;
+               last_position->accuracy = acc * 0.0001;
+               LOCATION_LOGD("last_position [%f/%f]", last_position->latitude, last_position->longitude);
+               ret = LOCATION_ERROR_NONE;
+       } else {
+               LOCATION_LOGD("location_last_position is empty");
+               ret = LOCATION_ERROR_UNKNOWN;
+       }
+
+       return ret;
+}
+
+EXPORT_API int
+location_get_position_from_address (LocationObject *obj,
+       const LocationAddress *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_geocode (LOCATION_IELEMENT(geocode), address, position, accuracy);
+}
+
+EXPORT_API int
+location_get_position_from_freeformed_address (LocationObject *obj,
+       const gchar *address,
+       LocationPosition **position,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_geocode_freeform (LOCATION_IELEMENT(geocode), address, position, accuracy);
+}
+
+EXPORT_API int
+location_get_velocity (LocationObject *obj,
+       LocationVelocity **velocity,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       return location_ielement_get_velocity (LOCATION_IELEMENT(obj), velocity, accuracy);
+}
+
+EXPORT_API int
+location_get_address (LocationObject *obj,
+       LocationAddress **address,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+
+       LocationPosition *position = NULL;
+       int ret = location_ielement_get_position(LOCATION_IELEMENT (obj), &position, accuracy);
+       if (LOCATION_ERROR_NONE != ret) return ret;
+       ret = location_ielement_get_reversegeocode (LOCATION_IELEMENT(geocode), position, address, accuracy);
+       location_position_free (position);
+       return ret;
+}
+
+EXPORT_API int
+location_get_address_from_position (LocationObject *obj,
+       const LocationPosition *position,
+       LocationAddress **address,
+       LocationAccuracy **accuracy)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_reversegeocode (LOCATION_IELEMENT(geocode), position, address, accuracy);
+}
+
+EXPORT_API int
+location_get_position_from_address_async (LocationObject *obj,
+       const LocationAddress *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_geocode_async (LOCATION_IELEMENT(geocode), address, callback, userdata);
+}
+
+
+EXPORT_API int
+location_get_position_from_freeformed_address_async (LocationObject *obj,
+       const gchar *address,
+       LocationPositionCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_geocode_freeform_async (LOCATION_IELEMENT(geocode), address, callback, userdata);
+}
+
+EXPORT_API int
+location_get_address_async (LocationObject *obj,
+       LocationAddressCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+
+       LocationPosition *position = NULL;
+       LocationAccuracy *acc = NULL;
+       int ret = location_ielement_get_position(LOCATION_IELEMENT(obj), &position, &acc);
+       if (LOCATION_ERROR_NONE != ret) return ret;
+       ret = location_ielement_get_reversegeocode_async (LOCATION_IELEMENT(geocode), position, callback, userdata);
+       location_position_free (position);
+       return ret;
+}
+
+EXPORT_API int
+location_get_address_from_position_async (LocationObject *obj,
+       const LocationPosition *position,
+       LocationAddressCB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (geocode, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_reversegeocode_async (LOCATION_IELEMENT(geocode), position, callback, userdata);
+}
+
+EXPORT_API int
+location_get_poi (LocationObject *obj,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi(LOCATION_IELEMENT(poi), radius, keyword, poi_info);
+}
+
+EXPORT_API int
+location_get_poi_from_address(LocationObject *obj,
+       const LocationAddress *address,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi_from_address(LOCATION_IELEMENT(poi), address, radius, keyword, poi_info);
+}
+
+EXPORT_API int
+location_get_poi_from_position(LocationObject *obj,
+       const LocationPosition *position,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOIInfo **poi_info)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi_from_position(LOCATION_IELEMENT(poi), position, radius, keyword, poi_info);
+}
+
+EXPORT_API int
+location_get_poi_async (LocationObject *obj,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi_async(LOCATION_IELEMENT(poi), radius, keyword, callback, userdata);
+}
+
+EXPORT_API int
+location_get_poi_from_address_async (LocationObject *obj,
+       const LocationAddress *address,
+       gdouble radius,
+       const gchar *keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi_from_address_async(LOCATION_IELEMENT(poi), address, radius, keyword, callback, userdata);
+}
+
+EXPORT_API int
+location_get_poi_from_position_async (LocationObject *obj,
+       const LocationPosition *position,
+       gdouble radius,
+       const gchar*keyword,
+       LocationPOICB callback,
+       gpointer userdata)
+{
+       g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail (poi, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail (is_connected_network(), LOCATION_ERROR_NETWORK_NOT_CONNECTED);
+       return location_ielement_get_poi_from_position_async(LOCATION_IELEMENT(poi), position, radius, keyword, callback, userdata);
+}
+
+EXPORT_API int
+location_send_command(const char *cmd)
+{
+       g_return_val_if_fail (cmd, LOCATION_ERROR_PARAMETER);
+
+       return LOCATION_ERROR_NONE;
+}
+
diff --git a/location/location.h b/location/location.h
new file mode 100644 (file)
index 0000000..62888e1
--- /dev/null
@@ -0,0 +1,1105 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+
+#ifndef __LOCATION_H__
+#define __LOCATION_H__
+
+
+#include <glib.h>
+#include <location/location-types.h>
+#include <location/location-position.h>
+#include <location/location-velocity.h>
+#include <location/location-accuracy.h>
+#include <location/location-address.h>
+#include <location/location-boundary.h>
+#include <location/location-satellite.h>
+#include <location/location-poi-info.h>
+
+G_BEGIN_DECLS
+
+/**
+ * @file location.h
+ * @brief This file contains the Location API and related structure and enumeration.
+ */
+/**
+ * @defgroup LocationFW LocationFW
+ * @brief This is a Locatoin Framework for providing location based services.
+ * @addtogroup LocationFW
+ * @{
+ * @defgroup LocationAPI Location API
+ * @brief This sub module provides the Location API.
+ * @addtogroup LocationAPI
+ * @{
+ */
+
+/**
+ * @brief
+ * Initialize location sub module.
+ * @remarks None.
+ * This API should be called before any other Location APIs.
+ * @pre None.
+ * @post None.
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see None.
+ * @par Example
+ * @code
+#include <location.h>
+int main (int argc, char *argv[])
+{
+    location_init();
+    // Now you can use any other Location APIs.
+    return 0;
+}
+ * @endcode
+ */
+int location_init (void);
+
+/**
+ * @brief
+ * Create a new #LocationObject by using given #LocationMethod.
+ * @remarks
+ * Returned object is necessary for other APIs.
+ * @pre
+ * #location_init should be called before.
+ * @post None.
+ * @param [in]
+ * method - Location method to be used.
+ * @return a new #LocationObject
+ * @retval NULL              if error occured
+ * @see location_free
+ * @par Example
+ * @code
+#include <location.h>
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       location_init ();
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc)
+               return -1;
+       // You can use new location object now.
+       return 0;
+}
+ * @endcode
+ */
+LocationObject *location_new (LocationMethod method);
+
+/**
+ * @brief
+ * Free memory of given #LocationObject.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new.
+ * @return int
+ * @retval 0                              Success.
+ *
+ * Please refer #LocationError for more information.
+ * @see location_new
+ * @par Example
+ * @code
+#include <location.h>
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       location_init ();
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc)
+               return -1;
+
+       location_free (loc);
+       // You can not use location object anymore.
+       return 0;
+}
+ * @endcode
+ */
+int location_free (LocationObject *obj);
+
+/**
+ * @brief
+ * Start the location service by using given #LocationObject.
+ * @remarks
+ * If you want to recieve signals, you should use this API.
+ * @pre
+ * #location_init should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @return int
+ * @retval 0                              Success.
+ *
+ * Please refer #LocationError for more information.
+ * @see location_stop
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       int interval = 6;       //seconds
+       location_init ();
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc)
+               return -1;
+
+       g_object_set(loc, "update-interval", interval, NULL);
+
+       location_start(loc);
+       loop = g_main_loop_new (NULL, TRUE);
+       g_main_loop_run (loop);  // GMainLoop is needed for receiving signals.
+
+       // ...
+       return 0;
+}
+ * @endcode
+ */
+int location_start (LocationObject *obj);
+
+/**
+ * @brief
+ * Stop the location service by using given #LocationObject.
+ * @remarks
+ * After call this API, you can not recieve signals.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see location_start
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       location_init ();
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc)
+               return -1;
+
+       location_start(loc);
+       loop = g_main_loop_new (NULL, TRUE);
+       g_main_loop_run (loop);
+
+       // ....
+
+       location_stop (loc);
+       // you can not receive signals anymore.
+       return 0;
+}
+ * @endcode
+ */
+int location_stop (LocationObject *obj);
+
+/**
+ * @brief
+ * Check wheither a method is available.
+ * @remarks
+ * @pre
+ * #location_init should be called before.\n
+ * @post None.
+ * @param [in] method - a #LocationMethod
+ * @return int
+ * @retval True                Supported
+ *        False        Not supported
+ * @par Example
+ #include <location.h>
+static GMainLoop *loop = NULL;
+
+int main (int argc, char *argv[])
+{
+       gboolean is_supported = FALSE;
+
+       // ....
+
+       is_supported = location_is_supported_method(LOCATION_METHOD_HYBRID);
+       if(is_supported == TRUE)
+               g_printf("Hybrid Method is supported.\n");
+       else
+               g_printf("Hybrid Method is not supported.\n");
+
+       return 0;
+}* @code
+ * @endcode
+ */
+gboolean location_is_supported_method(LocationMethod method);
+
+/**
+ * @brief
+ * Check wheither GPS is turned on or off.
+ * @remarks
+ * @pre
+ * #location_init should be called before.\n
+ * @post None.
+ * @param [in] method - a #LocationMethod
+ * @return int
+ * @retval True                Turned on
+ *        False        Turned off
+ * @par Example
+ #include <location.h>
+static GMainLoop *loop = NULL;
+
+int main (int argc, char *argv[])
+{
+       gboolean is_enabled = FALSE;
+
+       // ....
+
+       is_enabled = location_is_enabled_gps(loc);
+       if(is_enable == TRUE)
+               g_printf("GPS is turned on.\n");
+       else
+               g_printf("GPS is turned off.\n");
+
+       return 0;
+}* @code
+ * @endcode
+ */
+gboolean location_is_enabled_gps(LocationObject *obj);
+
+/**
+ * @brief
+ * Get current position information with estimate of the accuracy.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [out]
+ * position - a new #LocationPosition
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see location_get_velocity
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+static void cb_service_enabled (GObject *self, guint status, gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+
+       // This function works properly after service is enabled.
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+}
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       gulong handler_id = 0;
+
+       location_init ();
+       loop = g_main_loop_new (NULL, TRUE);
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       location_start (loc);
+       g_main_loop_run (loop);
+
+       g_signal_handler_disconnect(loc, handler_id);
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
+ * @endcode
+ */
+int location_get_position (LocationObject *obj, LocationPosition **position,   LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get last known position information with estimate of the accuracy.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * last_position - a #LocationLastPosition
+ * @return int
+ * @retval 0                              Success
+ *
+ * @par Example
+ * @code
+#include <location.h>
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       LocationLastPosition last_pos;
+       location_init ();
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       location_get_last_known_position(loc, &last_pos);
+       g_debug ("Last known position > lat: %f, long: %f, acc: %f", last_pos.latitude, last_pos.longitude, last_pos.accuracy);
+
+       location_free (loc);
+       return 0;
+}
+ * @endcode
+ */
+int location_get_last_known_position (LocationObject *obj, LocationLastPosition *last_position);
+
+
+/**
+ * @brief
+ * Get current position information with estimate of the accuracy by using given address information.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * address - a #LocationAddress
+ * @param [out]
+ * position - a new #LocationPosition
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success.
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_position_from_address_async\n
+ * @par Example
+ * @code
+#include <location.h>
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       int ret = LOCATION_ERROR_NONE;
+
+       location_init ();
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+
+       addr = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       if (LOCATION_ERROR_NONE == location_get_position_from_address(loc, addr, &pos, &acc)) {
+               g_debug ("SYNC>> position from address> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free (pos);
+               location_accuracy_free (acc);
+       } else g_warning ("SYNC>> position from address> failed");
+       location_address_free (addr);
+
+       location_free (loc);
+       return 0;
+}
+ * @endcode
+ */
+int location_get_position_from_address (LocationObject *obj, const LocationAddress *address, LocationPosition **position, LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get current position information asynchronously with estimate of the accuracy by using given address information.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * address - a #LocationAddress
+ * @param [in]
+ * callback - A pointer of function which will be called after position is gained or when an error occurs.
+ * @param [in]
+ * userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success.
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_position_from_address\n
+ * @par Example
+ * @code
+#include <location.h>
+
+static void
+cb_position_from_address (LocationError error, LocationPosition *pos, LocationAccuracy *acc, gpointer userdata)
+{
+       g_debug ("ASYNC>> location_get_position_from_address_async> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+void get_position_from_address(LocationObject* loc)
+{
+       LocationAddress *addr = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_position_from_address_async(loc, addr, cb_position_from_address, loc))
+               g_debug("location_get_position_from_address_async() success");
+       else g_warning ("location_get_position_from_address_async() failed");
+       location_address_free (addr);
+}
+ * @endcode
+ */
+int location_get_position_from_address_async (LocationObject *obj, const LocationAddress *address, LocationPositionCB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Get current position information with estimate of the accuracy by using given free-formed address string.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * address - Free-formed address string to be used
+ * @param [out]
+ * position - a new #LocationPosition
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_position_from_freeformed_address_async\n
+ * @par Example
+ * @code
+#include <location.h>
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       int ret = LOCATION_ERROR_NONE;
+
+       location_init ();
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       char* addr_str = g_strdup("4 N 2nd Street 95113");
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_position_from_freeformed_address(loc, addr_str, &pos, &acc)) {
+               g_debug ("SYNC>> position from freeformed address> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free (pos);
+               location_accuracy_free (acc);
+       } else g_warning ("SYNC>> position from freeformed address> failed");
+       g_free(addr_str);
+
+
+       location_free (loc);
+       return 0;
+}
+ * @endcode
+ */
+int location_get_position_from_freeformed_address (LocationObject *obj, const gchar *address, LocationPosition **position, LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get current position information asynchronously with estimate of the accuracy by using given free-formed address string.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * address - Free-formed address string to be used
+ * @param [in]
+ * callback - A pointer of function which will be called after position is gained or when an error occurs.
+ * @param [in]
+ * userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_position_from_freeformed_address\n
+ * @par Example
+ * @code
+#include <location.h>
+
+static void
+cb_position_from_freeformed_address (LocationError error, LocationPosition *pos, LocationAccuracy *acc, gpointer userdata)
+{
+       g_debug ("ASYNC>> location_get_position_from_freeformed_address_async> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+void get_position_from_address(LocationObject* loc)
+{
+       gchar *addr_str = g_strdup("4 N 2nd Street 95113");
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_position_from_freeformed_address_async(loc, addr_str, cb_position_from_freeformed_address, loc))
+               g_debug("location_get_position_from_freeformed_address_async() success");
+       else g_warning ("location_get_position_from_freeformed_address_async() failed");
+       g_free(addr_str);
+
+}
+ * @endcode
+ */
+int location_get_position_from_freeformed_address_async (LocationObject *obj, const gchar *address, LocationPositionCB callback,       gpointer userdata);
+
+/**
+ * @brief
+ * Get current velocity information with estimate of the accuracy.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [out]
+ * velocity - a new #LocationVelocity
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see location_get_position
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+static void cb_service_enabled (GObject *self, guint status, gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationVelocity *vel = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+}
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       gulong hander_id = 0;
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       location_start (loc);
+       g_main_loop_run (loop);
+
+       g_signal_handler_disconnect(loc, handler_id);
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
+
+ * @endcode
+ */
+int location_get_velocity (LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get current address information with estimate of the accuracy by using current position.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [out]
+ * address - a new #LocationAddress
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_address_async\n
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+static void cb_service_enabled (GObject *self, guint status, gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationAddress *addr = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationObject *loc = (LocationObject*)userdata;
+
+       // This function works properly after service is enabled.
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+}
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       gulong handler_id = 0;
+       int ret = LOCATION_ERROR_NONE;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       location_start (loc);
+       g_main_loop_run (loop);
+
+       g_signal_handler_disconnect(loc, handler_id);
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
+ * @endcode
+ */
+int location_get_address (LocationObject *obj, LocationAddress **address, LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get current address information asynchronously with estimate of the accuracy by using current position.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * callback - A pointer of function which will be called after address is gained or when an error occurs.
+ * @param [in]
+ * userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_address\n
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+static void
+cb_address (LocationError error, LocationAddress *addr, LocationAccuracy *acc, gpointer userdata)
+{
+       g_debug ("ASYNC>> location_get_address_async> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void cb_service_enabled (GObject *self, guint status, gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       // This function works properly after service is enabled.
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_address_async(loc, cb_address, loc))
+               g_debug("location_get_address_async() success");
+       else g_warning ("location_get_address_async() failed");
+}
+
+
+int main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       gulong handler_id = 0;
+       int ret = LOCATION_ERROR_NONE;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       location_start (loc);
+       g_main_loop_run (loop);
+
+       g_signal_handler_disconnect(loc, handler_id);
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
+ * @endcode
+ */
+int location_get_address_async (LocationObject *obj, LocationAddressCB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Get current address information with estimate of the accuracy by using given position information.
+ * @remarks Out parameters are should be freed.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * position - a #LocationPosition
+ * @param [out]
+ * address - a new #LocationAddress
+ * @param [out]
+ * accuracy - a new #LocationAccuracy
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_address_from_position_async\n
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       int ret = LOCATION_ERROR_NONE;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if(!loc){
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+
+       //Calling application must have an active data connection before using this function.
+       pos = location_position_new (0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+       if (LOCATION_ERROR_NONE == location_get_address_from_position(loc, pos, &addr, &acc)) {
+               g_debug ("SYNC>> address from position> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> address from position> failed");
+       location_position_free (pos);
+}
+ * @endcode
+ */
+int location_get_address_from_position (LocationObject *obj, const LocationPosition *position, LocationAddress **address, LocationAccuracy **accuracy);
+
+/**
+ * @brief
+ * Get current address information asynchronously with estimate of the accuracy by using given position information.
+ * @remarks None.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]
+ * obj - a #LocationObject created by #location_new
+ * @param [in]
+ * position - a #LocationPosition
+ * @param [in]
+ * callback - A pointer of function which will be called after address is gained or when an error occurs.
+ * @param [in]
+ * userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ * @see
+ * location_get_address_from_position\n
+ * @par Example
+ * @code
+#include <location.h>
+static GMainLoop *loop = NULL;
+
+static void
+cb_address_from_position (LocationError error, LocationAddress *addr, LocationAccuracy *acc, gpointer userdata)
+{
+       g_debug ("ASYNC>> location_get_address_from_position_async> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+void get_address_from_position(LocationObject* loc)
+{
+       LocationPosition *pos = location_position_new (0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+       //Calling application must have an active data connection before using this function.
+       if (LOCATION_ERROR_NONE == location_get_address_from_position_async(loc, pos, cb_address_from_position, loc))
+               g_debug("location_get_address_from_position_async() success");
+       else g_warning ("location_get_address_from_position_async() failed");
+       location_position_free (pos);
+}
+ * @endcode
+ */
+int location_get_address_from_position_async (LocationObject *obj, const LocationPosition *position,   LocationAddressCB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Get information of point of interests by using current position within a given radius.
+ * @remarks Out parameters are should be freed.
+ * \n This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  radius - radius of a circle
+ * @param [in]  keyword - keyword for POI
+ * @param [out] poi_info - a new #LocationPOIInfo
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi (LocationObject *obj, gdouble radius, const gchar *keyword, LocationPOIInfo **poi_info);
+
+/**
+ * @brief
+ * Get information of point of interests asynchronously by using current position within a given radius.
+ * @remarks This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * #location_start should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  radius - radius of a circle
+ * @param [in]  callback - function to call
+ * @param [in]  userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi_async (LocationObject *obj, gdouble radius, const gchar *keyword, LocationPOICB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Get information of point of interests by using given address within a given radius.
+ * @remarks Out parameters are should be freed.
+ * \n This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  address - a #LocationAddress
+ * @param [in]  radius - radius of a circle
+ * @param [in]  keyword - keyword for POI
+ * @param [out] poi_info - a new #LocationPOIInfo
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi_from_address(LocationObject *obj, const LocationAddress *address, gdouble radius, const gchar *keyword,   LocationPOIInfo **poi_info);
+
+/**
+ * @brief
+ * Get information of point of interests asynchronously by using given address within a given radius.
+ * @remarks This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  address - a #LocationAddress
+ * @param [in]  radius - radius of a circle
+ * @param [in]  callback - function to call
+ * @param [in]  userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi_from_address_async (LocationObject *obj, const LocationAddress *address, gdouble radius, const gchar *keyword, LocationPOICB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Get information of point of interests by using given position within a given radius.
+ * @remarks Out parameters are should be freed.
+ * \n This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  position - a #LocationPosition
+ * @param [in]  radius - radius of a circle
+ * @param [in]  keyword - keyword for POI
+ * @param [out] poi_info - a new #LocationPOIInfo
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi_from_position(LocationObject *obj, const LocationPosition *position, gdouble radius,      const gchar *keyword, LocationPOIInfo **poi_info);
+
+/**
+ * @brief
+ * Get information of point of interests asynchronously by using given position within a given radius.
+ * @remarks This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  obj - a #LocationObject created by #location_new
+ * @param [in]  position - a #LocationPosition
+ * @param [in]  radius - radius of a circle
+ * @param [in]  callback - function to call
+ * @param [in]  userdata - data to pass to function
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_get_poi_from_position_async (LocationObject *obj, const LocationPosition *position, gdouble radius,       const gchar*keyword, LocationPOICB callback, gpointer userdata);
+
+/**
+ * @brief
+ * Send command to the server.
+ * @remarks This functions is not implemneted yet.
+ * @pre
+ * #location_init should be called before.\n
+ * Calling application must have glib or ecore main loop.\n
+ * Calling application must have an active data connection.
+ * @post None.
+ * @param [in]  cmd - a #char
+ * @return int
+ * @retval 0                              Success
+ *
+ * Please refer #LocationError for more information.
+ */
+int location_send_command(const char *cmd);
+
+/**
+ * @} @}
+ */
+
+G_END_DECLS
+
+#endif /* __LOCATION_H__ */
diff --git a/packaging/libslp-location.spec b/packaging/libslp-location.spec
new file mode 100644 (file)
index 0000000..cc04c6d
--- /dev/null
@@ -0,0 +1,73 @@
+
+Name:       libslp-location
+Summary:    Location Based Service
+Version:    0.3.23
+Release:    2
+Group:      System/Libraries
+License:    TBD
+Source0:    %{name}-%{version}.tar.bz2
+Requires(post):  /sbin/ldconfig
+Requires(post):  /usr/bin/vconftool
+Requires(postun):  /sbin/ldconfig
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gconf-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(vconf)
+
+BuildRoot:  %{_tmppath}/%{name}-%{version}-build
+
+%description
+Location Based Service Libraries
+
+
+%package devel
+Summary:    Location Based Service (Development files)
+Group:      System/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Location Based Service Development Package
+
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+
+%build
+
+./autogen.sh
+./configure --prefix=%{_prefix} --enable-dlog --enable-debug
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%clean
+rm -rf %{buildroot}
+
+
+
+%post 
+/sbin/ldconfig
+vconftool set -t int db/location/LocationEnabled "1" -g 6514 -f
+vconftool set -t int db/location/NetworkEnabled "0" -g 6514  -f
+vconftool set -t int db/location/AgpsEnabled "0" -g 6514 -f
+vconftool set -t int db/location/SensorEnabled "0" -g 6514 -f
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/lib*.so.*
+
+
+%files devel
+%{_includedir}/location/*.h
+%{_libdir}/lib*.so
+%{_libdir}/pkgconfig/*.pc
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..51837cd
--- /dev/null
@@ -0,0 +1,34 @@
+dir_location = $(top_srcdir)/location
+noinst_PROGRAMS = location-api-test gps-test wps-test hybrid-test ips-test cps-test sps-test\
+                                 position-sample-gps velocity-sample nmea-sample satellite-sample property-sample zone-sample address-sample
+
+gps_test_SOURCES =  gps-test.c
+wps_test_SOURCES =  wps-test.c
+hybrid_test_SOURCES =  hybrid-test.c
+ips_test_SOURCES =  ips-test.c
+cps_test_SOURCES =  cps-test.c
+position_sample_gps_SOURCES =   position-sample-gps.c
+velocity_sample_SOURCES = velocity-sample.c
+nmea_sample_SOURCES = nmea-sample.c
+satellite_sample_SOURCES = satellite-sample.c
+property_sample_SOURCES = property-sample.c
+zone_sample_SOURCES = zone-sample.c
+address_sample_SOURCES = address-sample.c
+location_api_test_SOURCES = location-api-test.c location-api-test-util.c
+
+LDADD = \
+               $(dir_location)/libSLP-location.la\
+               $(TEST_LIBS)
+AM_CFLAGS = \
+                       -I$(dir_location)\
+                       $(TEST_CFLAGS)
+
+dir_tests = $(top_srcdir)/tests
+dir_tests_exec = $(top_srcdir)/tests/.libs
+
+install-exec-hook:
+       cp $(dir_tests)/location-api-test.json $(dir_tests_exec)/location-api-test.json
+       chmod 644 $(dir_tests_exec)/location-api-test.json
+
+uninstall-hook:
+       rm -f $(dir_tests_exec)/location-api-test.json
diff --git a/tests/address-sample.c b/tests/address-sample.c
new file mode 100644 (file)
index 0000000..64f1273
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <gconf/gconf-client.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_address (LocationError error,
+       LocationAddress *addr,
+       LocationAccuracy *acc,
+       gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_debug("cb_address failed: error=%d\n", error);
+               return;
+       }
+       g_debug ("ASYNC>> location_get_address_async> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_position_from_address (LocationError error, LocationPosition *pos, LocationAccuracy *acc, gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_debug("cb_position_from_address failed: error=%d\n", error);
+               return;
+       }
+       g_debug ("ASYNC>> location_get_position_from_address_async> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_position_from_freeformed_address (LocationError error, LocationPosition *pos, LocationAccuracy *acc, gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_debug("cb_position_from_freeformed_address failed: error=%d\n", error);
+               return;
+       }
+       g_debug ("ASYNC>> location_get_position_from_freeformed_address_async> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_address_from_position (LocationError error, LocationAddress *addr, LocationAccuracy *acc, gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_debug("cb_address_from_position failed: error=%d\n", error);
+               return;
+       }
+       g_debug ("ASYNC>> location_get_address_from_position_async> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationAddress *addr = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationObject *loc = (LocationObject*)userdata;
+
+       LocationError err = location_get_address(loc, &addr, &acc);
+       if (LOCATION_ERROR_NONE == err) {
+               g_debug ("SYNC>> location_get_address() success> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> location_get_address() failed> error code:%d", err);
+
+       err = location_get_address_async(loc, cb_address, loc);
+       if (LOCATION_ERROR_NONE == err) g_debug("location_get_address_async() success");
+       else g_warning ("location_get_address_async() failed> error code:%d", err);
+}
+
+static gboolean
+async_request (gpointer loc)
+{
+       LocationAddress *addr = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       LocationError err = location_get_position_from_address_async(loc, addr, cb_position_from_address, loc);
+       if (LOCATION_ERROR_NONE == err)
+               g_debug("location_get_position_from_address_async() success");
+       else g_warning ("location_get_position_from_address_async() failed> error code:%d", err);
+       location_address_free (addr);
+
+       gchar *addr_str = g_strdup("4 N 2nd Street 95113");
+       err = location_get_position_from_freeformed_address_async(loc, addr_str, cb_position_from_freeformed_address, loc);
+       if (LOCATION_ERROR_NONE == err)
+               g_debug("location_get_position_from_freeformed_address_async() success");
+       else g_warning ("location_get_position_from_freeformed_address_async() failed> error code:%d", err);
+       g_free(addr_str);
+
+       LocationPosition *pos = location_position_new (0, 37.3322, -121.8720, 0, LOCATION_STATUS_2D_FIX);
+       err = location_get_address_from_position_async(loc, pos, cb_address_from_position, loc);
+       if (LOCATION_ERROR_NONE == err)
+               g_debug("location_get_address_from_position_async() success");
+       else g_warning ("location_get_address_from_position_async() failed> error code:%d", err);
+       location_position_free (pos);
+       return FALSE;
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.address-sample", 1);
+
+       g_type_init();
+       location_init ();
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_warning("location_new failed");
+               return -1;
+       }
+       LocationPosition *pos = NULL;
+       LocationAccuracy *acc = NULL;
+       LocationAddress *addr = NULL;
+
+       addr = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+       LocationError err = location_get_position_from_address(loc, addr, &pos, &acc);
+       if (LOCATION_ERROR_NONE == err) {
+               g_debug ("SYNC>> location_get_position_from_address() success> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free (pos);
+               location_accuracy_free (acc);
+       } else g_warning ("SYNC>>>location_get_position_from_address() failed> error code:%d", err);
+       location_address_free (addr);
+
+       char* addr_str = g_strdup("4 N 2nd Street 95113");
+       err = location_get_position_from_freeformed_address(loc, addr_str, &pos, &acc);
+       if (LOCATION_ERROR_NONE == err) {
+               g_debug ("SYNC>> location_get_position_from_freeformed_address() success> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free (pos);
+               location_accuracy_free (acc);
+       } else g_warning ("SYNC>> location_get_position_from_freeformed_address() failed> error code:%d", err);
+       g_free(addr_str);
+
+       pos = location_position_new (0, 37.3322, -121.8720, 0, LOCATION_STATUS_2D_FIX);
+       err = location_get_address_from_position(loc, pos, &addr, &acc);
+       if (LOCATION_ERROR_NONE == err) {
+               g_debug ("SYNC>> location_get_address_from_position() success> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> location_get_address_from_position() failed> error code:%d", err);
+       location_position_free (pos);
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+
+       g_timeout_add_seconds (3, async_request, loc);
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds (60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/cps-test.c b/tests/cps-test.c
new file mode 100644 (file)
index 0000000..de3a28e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.cps-test", 1);
+
+       location_init ();
+
+       loc  = location_new (LOCATION_METHOD_CPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationAddress *addr = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+       return 0;
+}
+
diff --git a/tests/gps-test.c b/tests/gps-test.c
new file mode 100644 (file)
index 0000000..b989b44
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       default:
+               g_warning ("ASYNC>> Undefined update type");
+               break;
+       }
+}
+
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationVelocity *vel = NULL;
+       LocationAddress *addr = NULL;
+       LocationSatellite *sat = NULL;
+       gchar *nmea_data = NULL;
+       int idx = 0;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+
+       g_object_get (loc, "satellite", &sat, NULL);
+       if (sat) {
+               g_debug ("SYNC>> Current Sattelite> satellite in view = %d, satellite in used = %d", sat->num_of_sat_inview, sat->num_of_sat_used);
+               g_debug ("\tinview satellite information = ");
+               for (idx=0; idx<sat->num_of_sat_inview; idx++) {
+                       guint prn;
+                       gboolean used;
+                       guint elevation;
+                       guint azimuth;
+                       gint snr;
+                       location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr);
+                       g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d",
+                               idx, used, prn, elevation, azimuth, snr);
+               }
+               location_satellite_free (sat);
+       } else g_warning ("SYNC>> Current Sattelite> failed");
+
+       g_object_get(loc, "nmea", &nmea_data, NULL);
+       if (nmea_data) {
+               g_debug("SYNC>> Currnet NMEA> nmea_data:\n%s\n", nmea_data);
+               g_free(nmea_data);
+       } else g_warning("SYNC>> Current NMEA> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.gps-test", 1);
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if (devname) {
+               g_debug("Get property>> dev-name: %s", devname);
+       } else g_warning("failed to get property> dev-name");
+
+       devname = NULL;
+       g_object_set(loc, "dev-name", "/dev/test", NULL);
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if (devname) {
+               g_debug("Get property>> dev-name: %s", devname);
+               g_free(devname);
+       } else g_warning("failed to set property> dev-name");
+
+       LocationBoundary *bound = NULL;
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Get property>> boundary> type: %d", bound->type);
+       } else g_warning("failed to get property> boundary");
+
+       bound = NULL;
+       LocationPosition *rb = location_position_new(0, 37.255, 127.056, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.050, 0, LOCATION_STATUS_2D_FIX);
+       bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       if (bound) {
+               g_object_set(loc, "boundary", bound, NULL);
+       } else g_warning("failed to location_boundary_new_for_rect()");
+
+       bound = NULL;
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)",
+                       bound->type,
+                       bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
+                       bound->rect.left_top->latitude, bound->rect.left_top->longitude);
+               location_boundary_free (bound);
+       } else  g_warning("failed to set property> boundary");
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/hybrid-test.c b/tests/hybrid-test.c
new file mode 100644 (file)
index 0000000..03d36e3
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       default:
+               g_warning ("ASYNC>> Undefined update type");
+               break;
+       }
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationVelocity *vel = NULL;
+       LocationAddress *addr = NULL;
+       LocationMethod method;
+
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+       }
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.hybrid-test", 1);
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_HYBRID);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       LocationBoundary *bound = NULL;
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Get property>> boundary> type: %d", bound->type);
+               location_boundary_free (bound);
+       } else g_warning("failed to get property> boundary");
+
+       LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
+       bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       if (bound) {
+               g_object_set(loc, "boundary", bound, NULL);
+               location_boundary_free(bound);
+       } else g_warning("failed to location_boundary_new_for_rect()");
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)",
+                       bound->type,
+                       bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
+                       bound->rect.left_top->latitude, bound->rect.left_top->longitude);
+               location_boundary_free (bound);
+       } else  g_warning("failed to set property> boundary");
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
+
+       if (LOCATION_ERROR_NONE != location_start (loc)) {
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/ips-test.c b/tests/ips-test.c
new file mode 100644 (file)
index 0000000..a70895f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.ips-test", 1);
+
+       location_init ();
+
+       loc  = location_new (LOCATION_METHOD_IPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationAddress *addr = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/location-api-test-util.c b/tests/location-api-test-util.c
new file mode 100644 (file)
index 0000000..7131c42
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */\r
+\r
+#include <glib.h>\r
+#include <json-glib.h>\r
+#include "location.h"\r
+\r
+JsonParser *parser;\r
+JsonNode *root;\r
+\r
+static int _get_polygon_position_count(int polygon_index)\r
+{\r
+       if (parser == NULL || root == NULL) return 0;\r
+\r
+       JsonObject* polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       if (polygon_obj == NULL) return 0;\r
+\r
+       JsonArray * positions = json_object_get_array_member (polygon_obj, "positions");\r
+       if (positions == NULL) return 0;\r
+\r
+       return json_array_get_length(positions);\r
+}\r
+\r
+static LocationPosition* _get_position_from_polygon(int polygon_index, int pos_index)\r
+{\r
+       double latitude = 0.0;\r
+       double longitude = 0.0;\r
+       LocationPosition *position = NULL;\r
+       if (parser == NULL || root == NULL) return NULL;\r
+\r
+       JsonObject *polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       JsonArray * pos_array = json_object_get_array_member(polygon_obj, "positions");\r
+       JsonObject* pos = json_array_get_object_element(pos_array, pos_index);\r
+\r
+       latitude = json_object_get_double_member(pos, "latitude");\r
+       longitude = json_object_get_double_member(pos, "longitude");\r
+\r
+       if (latitude == 0.0 || longitude == 0.0) return NULL;\r
+\r
+       position = location_position_new(0, latitude, longitude, 0.0, LOCATION_STATUS_2D_FIX);\r
+\r
+       return position;\r
+}\r
+\r
+static LocationPosition* _get_marker_position_from_polygon(int polygon_index, int pos_index)\r
+{\r
+       double latitude = 0.0;\r
+       double longitude = 0.0;\r
+       LocationPosition *position = NULL;\r
+       if (parser == NULL || root == NULL) return NULL;\r
+\r
+       JsonObject *polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       JsonArray * pos_array = json_object_get_array_member(polygon_obj, "marker_position");\r
+       JsonObject* pos = json_array_get_object_element(pos_array, pos_index);\r
+\r
+       latitude = json_object_get_double_member(pos, "latitude");\r
+       longitude = json_object_get_double_member(pos, "longitude");\r
+\r
+       if (latitude == 0.0 || longitude == 0.0) return NULL;\r
+\r
+       position = location_position_new(0, latitude, longitude, 0.0, LOCATION_STATUS_2D_FIX);\r
+\r
+       return position;\r
+}\r
+\r
+static void _free_position_list(gpointer data)\r
+{\r
+       if (data == NULL) return;\r
+\r
+       LocationPosition *position = (LocationPosition*) data;\r
+\r
+       location_position_free(position);\r
+}\r
+\r
+\r
+LocationBoundary* json_util_get_polygon_boundary(int polygon_index)\r
+{\r
+       if (parser == NULL || root == NULL) {\r
+               g_printf("invalid param parser[%d], root[%d]\n", parser, root);\r
+               return NULL;\r
+       }\r
+       GList* position_list = NULL;\r
+       LocationBoundary *boundary = NULL;\r
+       int index = 0;\r
+       int pos_count = _get_polygon_position_count(polygon_index);\r
+       if (pos_count == 0) return NULL;\r
+\r
+       for(index = 0; index < pos_count; index++) {\r
+               position_list = g_list_append(position_list, _get_position_from_polygon(polygon_index, index));\r
+       }\r
+\r
+       boundary = location_boundary_new_for_polygon(position_list);\r
+\r
+       g_list_free_full(position_list, (GDestroyNotify)_free_position_list);\r
+\r
+       return boundary;\r
+}\r
+\r
+\r
+/* Polygon boundary */\r
+int json_util_get_polygon_count(void)\r
+{\r
+       JsonArray * array = json_node_get_array(root);\r
+\r
+       return json_array_get_length(array);\r
+}\r
+\r
+char *json_util_get_polygon_name(int polygon_index)\r
+{\r
+       char *name = NULL;\r
+       JsonObject *polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+\r
+       name = (char *)json_object_get_string_member(polygon_obj, "name");\r
+       if (name == NULL)  return NULL;\r
+\r
+       return g_strdup(name);\r
+}\r
+\r
+/* Test Marker */\r
+char * json_util_get_marker_name(int polygon_index, int pos_index)\r
+{\r
+       char *result = NULL;\r
+       if (parser == NULL || root == NULL) return NULL;\r
+\r
+       JsonObject *polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       JsonArray * pos_array = json_object_get_array_member(polygon_obj, "marker_position");\r
+       JsonObject* pos = json_array_get_object_element(pos_array, pos_index);\r
+\r
+       result = (char *)json_object_get_string_member(pos, "where");\r
+       if (result == NULL) return NULL;\r
+\r
+       return g_strdup(result);\r
+}\r
+\r
+int json_util_get_marker_position_count(int polygon_index)\r
+{\r
+       if (parser == NULL || root == NULL) return 0;\r
+\r
+       JsonObject* polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       JsonArray * marker_position = json_object_get_array_member (polygon_obj, "marker_position");\r
+\r
+       return json_array_get_length(marker_position);\r
+}\r
+\r
+LocationPosition *json_util_get_marker_position(int polygon_index, int marker_index)\r
+{\r
+       if (parser == NULL || root == NULL) return NULL;\r
+\r
+       LocationPosition* position = NULL;\r
+       position = _get_marker_position_from_polygon(polygon_index, marker_index);\r
+\r
+       return position;\r
+}\r
+\r
+char* json_util_result_zone_test(int polygon_index, int marker_index)\r
+{\r
+       if (parser == NULL || root == NULL) return NULL;\r
+\r
+       char *result = NULL;\r
+       JsonObject *polygon_obj = json_array_get_object_element(json_node_get_array(root), polygon_index);\r
+       JsonArray * pos_array = json_object_get_array_member(polygon_obj, "marker_position");\r
+       JsonObject* pos = json_array_get_object_element(pos_array, marker_index);\r
+\r
+       result = (char *)json_object_get_string_member(pos, "result");\r
+       if (result == NULL) return NULL;\r
+\r
+       return g_strdup(result);\r
+}\r
+\r
+void json_util_init(const char * file_name)\r
+{\r
+       g_print("Enter init_json_parser");\r
+       GError *error;\r
+       gboolean ret = FALSE;\r
+       if (parser != NULL) return;\r
+\r
+       parser = json_parser_new();\r
+\r
+       error = NULL;\r
+       ret = json_parser_load_from_file(parser, file_name, &error);\r
+       if (ret == FALSE) {\r
+               g_print("Unable to parser[%s]:[%s]\n", file_name, error->message);\r
+               return ;\r
+       }\r
+\r
+       root = json_parser_get_root(parser);\r
+}\r
diff --git a/tests/location-api-test-util.h b/tests/location-api-test-util.h
new file mode 100644 (file)
index 0000000..47948a9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+
+#ifndef __LOCATION_API_TEST_UTIL_H__
+#define __LOCATION_API_TEST_UTIL_H__
+
+#include "location.h"
+
+G_BEGIN_DECLS
+
+void json_util_init(const char *file_file);
+char* json_util_result_zone_test(int polygon_index, int marker_index);
+int* json_util_get_marker_name(int polygon_index, int marker_index);
+int json_util_get_marker_position_count(int polygon_index);
+LocationPosition *json_util_get_marker_position(int polygon_index, int marker_index);
+
+int json_util_get_polygon_count(void);
+char* json_util_get_polygon_name(int polygon_index);
+LocationBoundary* json_util_get_polygon_boundary(int polygon_index);
+
+G_END_DECLS
+
+#endif /* __LOCATION_H__ */
diff --git a/tests/location-api-test.c b/tests/location-api-test.c
new file mode 100644 (file)
index 0000000..0d3241e
--- /dev/null
@@ -0,0 +1,1037 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <gconf/gconf-client.h>
+#include <location/location.h>
+#include "location-api-test-util.h"
+
+#define STR_MAX        128
+LocationObject* location_obj = NULL;
+static GMainLoop *g_mainloop = NULL;
+
+#define GCONF_PROXY_MODE            "/system/proxy/mode"
+#define GCONF_HTTP_PROXY_HOST       "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT       "/system/http_proxy/port"
+#define ENV_HTTP_PROXY              "http_proxy"
+
+#define LOCATION_API_TEST_JSON_FILE "/opt/data/location-api-test.json"
+
+static gpointer GmainThread(gpointer data)
+{
+       g_mainloop = g_main_loop_new (NULL, FALSE);
+       g_printf("\n...Entering GMain Loop to Receive Notifications....\n");
+       g_main_loop_run (g_mainloop);
+       g_main_loop_unref (g_mainloop);
+       g_mainloop = NULL;
+       return NULL;
+}
+
+
+static void GetLocationError(char str[STR_MAX], int ret)
+{
+       switch(ret)
+       {
+               case LOCATION_ERROR_NONE:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_NONE", STR_MAX);
+                       break;
+               case LOCATION_ERROR_NOT_ALLOWED:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_NOT_ALLOWED", STR_MAX);
+                       break;
+               case LOCATION_ERROR_NOT_AVAILABLE:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_NOT_AVAILABLE", STR_MAX);
+                       break;
+               case LOCATION_ERROR_NETWORK_FAILED:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_NETWORK_FAILED", STR_MAX);
+                       break;
+               case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_NETWORK_NOT_CONNECTED", STR_MAX);
+                       break;
+               case LOCATION_ERROR_CONFIGURATION:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_CONFIGURATION", STR_MAX);
+                       break;
+               case LOCATION_ERROR_PARAMETER:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_PARAMETER", STR_MAX);
+                       break;
+               case LOCATION_ERROR_UNKNOWN:
+                       g_utf8_strncpy(str, "LOCATION_ERROR_UNKNOWN", STR_MAX);
+                       break;
+               default:
+                       g_utf8_strncpy(str, "Error: undefined error code", STR_MAX);
+       }
+}
+
+static void GetStatus(char str[STR_MAX], LocationStatus acc_level)
+{
+       switch(acc_level)
+       {
+               case LOCATION_STATUS_NO_FIX:
+                       g_utf8_strncpy(str, "LOCATION_STATUS_NO_FIX", STR_MAX);
+                       break;
+               case LOCATION_STATUS_2D_FIX:
+                       g_utf8_strncpy(str, "LOCATION_STATUS_2D_FIX", STR_MAX);
+                       break;
+               case LOCATION_STATUS_3D_FIX:
+                       g_utf8_strncpy(str, "LOCATION_STATUS_3D_FIX", STR_MAX);
+                       break;
+               default:
+                       g_utf8_strncpy(str, "Error: undefined status code", STR_MAX);
+       }
+}
+
+static void GetMethod(char str[STR_MAX], LocationMethod acc_level)
+{
+       switch(acc_level)
+       {
+               case LOCATION_METHOD_HYBRID:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_HYBRID", STR_MAX);
+                       break;
+               case LOCATION_METHOD_GPS:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_GPS", STR_MAX);
+                       break;
+               case LOCATION_METHOD_CPS:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_CPS", STR_MAX);
+                       break;
+               case LOCATION_METHOD_IPS:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_IPS", STR_MAX);
+                       break;
+               case LOCATION_METHOD_WPS:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_WPS", STR_MAX);
+                       break;
+               case LOCATION_METHOD_SPS:
+                       g_utf8_strncpy(str, "LOCATION_METHOD_SPS", STR_MAX);
+                       break;
+               default:
+                       g_utf8_strncpy(str, "Error: undefined method", STR_MAX);
+       }
+}
+
+static void GetAccuracyLevel(char str[STR_MAX], LocationAccuracyLevel acc_level)
+{
+       switch(acc_level)
+       {
+               case LOCATION_ACCURACY_LEVEL_NONE:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_NONE", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_COUNTRY:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_COUNTRY", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_REGION:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_REGION", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_LOCALITY:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_LOCALITY", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_POSTALCODE:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_POSTALCODE", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_STREET:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_STREET", STR_MAX);
+                       break;
+               case LOCATION_ACCURACY_LEVEL_DETAILED:
+                       g_utf8_strncpy(str, "LOCATION_ACCURACY_LEVEL_DETAILED", STR_MAX);
+                       break;
+               default:
+                       g_utf8_strncpy(str, "Error: undefined accuracy level", STR_MAX);
+       }
+}
+
+
+static void SelectOpt(char* buf)
+{
+       int iLen = 0;
+       fgets(buf, 255, stdin);
+       iLen = g_utf8_strlen(buf, -1);
+       buf[iLen-1] = '\0';
+}
+
+static int PromptInt()
+{
+       char buf[255];
+       int ret;
+       fgets(buf, 255, stdin);
+       buf[strlen(buf)-1]='\0';
+       ret = g_ascii_strtoll(buf, NULL, 10);
+       return ret;
+}
+
+static double PromptDB()
+{
+       char buf[255];
+       double ret;
+       fgets(buf, 255, stdin);
+       buf[strlen(buf)-1]='\0';
+       ret = g_ascii_strtod(buf, NULL);
+       return ret;
+}
+
+gulong g_sig_enable = 0;
+gulong g_sig_disable = 0;
+gulong g_sig_update = 0;
+gulong g_sig_zonein = 0;
+gulong g_sig_zoneout = 0;
+
+static void PrintPolygonPosition(gpointer data, gpointer user_data)
+{
+       LocationPosition *position = (LocationPosition*) data;
+       g_printf("[%lf %lf %lf] ", position->latitude, position->longitude, position->altitude);
+}
+
+static void PrintBoundary(LocationBoundary *boundary, void *user_data)
+{
+       if(boundary == NULL) return;
+       if (boundary->type == LOCATION_BOUNDARY_CIRCLE) {
+               g_printf("\n\tCIRCLE: center[%lf %lf %lf] radius[%lf]",
+                               boundary->circle.center->latitude, boundary->circle.center->longitude, boundary->circle.center->altitude, boundary->circle.radius);
+       } else if (boundary->type == LOCATION_BOUNDARY_RECT) {
+               g_printf("\n\tRECT: left_top[%lf %lf %lf] right_bottom[%lf %lf %lf]",
+                               boundary->rect.left_top->latitude, boundary->rect.left_top->longitude, boundary->rect.left_top->altitude,
+                               boundary->rect.right_bottom->latitude, boundary->rect.right_bottom->longitude, boundary->rect.right_bottom->altitude);
+       } else if (boundary->type == LOCATION_BOUNDARY_POLYGON) {
+               g_printf("\n\tPOLYGON: ");
+
+               GList *list = boundary->polygon.position_list;
+
+               g_list_foreach(list, PrintPolygonPosition, NULL);
+       }
+}
+
+static void RemoveBoundary(LocationBoundary *boundary, void *user_data)
+{
+       LocationObject * obj = (LocationObject *)user_data;
+       if(obj == NULL || boundary == NULL) return;
+
+       location_boundary_remove(obj, boundary);
+}
+
+static void PrintProperty (LocationObject* loc)
+{
+       if (!loc) return;
+       LocationMethod method = LOCATION_METHOD_NONE;
+       LocationPosition *pos = NULL;
+       guint interval = 0;
+       gchar method_str[STR_MAX] = {0, };
+       gchar status_str[STR_MAX] = {0, };
+
+       gchar* devname = NULL;
+
+       g_object_get(loc, "method", &method, NULL);
+       GetMethod(method_str, method);
+       g_printf("method[%s] ", method_str);
+
+       if (LOCATION_METHOD_GPS == method) {
+               g_object_get(loc, "dev-name", &devname, NULL);
+               if (devname) {
+                       g_printf("dev-name[%s] ", devname);
+                       g_free(devname);
+               }
+       }
+
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               GetStatus(status_str, pos->status);
+               g_printf("\nLast position [time(%d) lat(%f) long(%f) alt(%f) status(%s)]",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, status_str);
+               location_position_free (pos);
+       }
+
+       g_object_get(loc, "update-interval", &interval, NULL);
+       g_printf("Update interval : [%u]", interval);
+
+       if (LOCATION_METHOD_CPS == method ||  LOCATION_METHOD_IPS == method) return;
+
+       g_printf("\nSignals: ");
+       if (g_sig_enable)  g_printf("[service-enabled], ");
+       if (g_sig_disable) g_printf("[service-disabled], ");
+       if (g_sig_update)  g_printf("[service-updated], ");
+       if (g_sig_zonein)  g_printf("[zone-in], ");
+       if (g_sig_zoneout) g_printf("[zone-out]");
+}
+
+static void cb_service_enabled (GObject *self,         guint status, gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationVelocity *vel = NULL;
+       LocationAddress *addr = NULL;
+       LocationMethod method;
+
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       default:
+               g_warning ("ASYNC>> Undefined update type");
+               break;
+       }
+}
+
+static void cb_position (LocationError error,
+       LocationPosition *position,
+       LocationAccuracy *acc,
+       gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_printf("cb_position failed: error=%d\n", error);
+               return;
+       }
+       char str[STR_MAX];
+       g_printf("userdata[0x%x] time: [%d], latitude: [%f], longitude: [%f], altitude: [%f]\n", (unsigned int)userdata, position->timestamp, position->latitude, position->longitude, position->altitude);
+       GetAccuracyLevel(str, acc->level);
+       g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void cb_address(LocationError error, LocationAddress *addr, LocationAccuracy *acc, gpointer userdata)
+{
+       if (error != LOCATION_ERROR_NONE) {
+               g_printf("cb_address failed: error=%d\n", error);
+               return;
+       }
+       char str[STR_MAX];
+       g_printf("userdata[0x%x] building number: [%s], street: [%s], state: [%s], country code: [%s], city: [%s], district: [%s], postal code: [%s]\n",
+               (unsigned int)userdata, addr->building_number, addr->street, addr->state, addr->country_code, addr->city, addr->district, addr->postal_code);
+       GetAccuracyLevel(str, acc->level);
+       g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+typedef struct {
+       LocationObject *obj;
+       LocationPosition *pos;
+       LocationAddress *addr;
+       gchar *str_addr;
+       LocationPositionCB pos_cb;
+       LocationAddressCB addr_cb;
+       gpointer user_data;
+} IdleData;
+
+static gboolean idle_position_from_address_async(gpointer data)
+{
+       IdleData* idle_data = (IdleData*)data;
+       char str[STR_MAX];
+       int ret = location_get_position_from_address_async(idle_data->obj, idle_data->addr, idle_data->pos_cb, idle_data->user_data);
+       GetLocationError(str, ret);
+       g_printf("location_get_position_from_address_async: returned value [%s]\n", str);
+       location_address_free(idle_data->addr);
+       g_free(idle_data);
+       return FALSE;
+}
+
+static gboolean idle_position_from_freefromed_address_async(gpointer data)
+{
+       IdleData* idle_data = (IdleData*)data;
+       char str[STR_MAX];
+       int ret = location_get_position_from_freeformed_address_async(idle_data->obj, idle_data->str_addr, idle_data->pos_cb, idle_data->user_data);
+       GetLocationError(str, ret);
+       g_printf("location_get_position_from_freeformed_address_async: returned value [%s]\n", str);
+       g_free(idle_data->str_addr);
+       g_free(idle_data);
+       return FALSE;
+}
+
+static gboolean idle_address_async(gpointer data)
+{
+       IdleData* idle_data = (IdleData*)data;
+       char str[STR_MAX];
+       int ret = location_get_address_async(idle_data->obj, idle_data->addr_cb, idle_data->user_data);
+       GetLocationError(str, ret);
+       g_printf("location_get_address_async: returned value [%s]\n", str);
+       g_free(idle_data);
+       return FALSE;
+}
+
+static gboolean idle_address_from_position_async(gpointer data)
+{
+       IdleData* idle_data = (IdleData*)data;
+       char str[STR_MAX];
+       int ret = location_get_address_from_position_async(idle_data->obj, idle_data->pos, idle_data->addr_cb, idle_data->user_data);
+       GetLocationError(str, ret);
+       g_printf("location_get_address_from_position_async: returned value [%s]\n", str);
+       location_position_free(idle_data->pos);
+       g_free(idle_data);
+       return FALSE;
+}
+
+static void print_menu()
+{
+       g_printf("\n================================= Location API Test =================================\n");
+       g_printf("q.   Exit\n");
+       g_printf("1.   location_init\n");
+       g_printf("2.   location_new\n");
+       g_printf("3.   location_free\n");
+       g_printf("4.   location_start\n");
+       g_printf("5.   location_stop\n");
+       g_printf("6.   location_get_position\n");
+       g_printf("6a.  location_get_last_known_position\n");
+       g_printf("7.   location_get_position_from_address\n");
+       g_printf("7a.  location_get_position_from_address_async\n");
+       g_printf("8.   location_get_position_from_freeformed_address\n");
+       g_printf("8a.  location_get_position_from_freeformed_address_async\n");
+       g_printf("9.   location_get_velocity\n");
+       g_printf("10.  location_get_address\n");
+       g_printf("10a. location_get_address_async\n");
+       g_printf("11.  location_get_address_from_position\n");
+       g_printf("11a. location_get_address_from_position_async\n");
+       g_printf("12.  location_get_distance\n");
+       g_printf("13.  location_is_supported_method\n");
+       g_printf("14.  location_is_enabled_gps\n");
+       g_printf("99.  location_send_command\n");
+       g_printf("a?.  signals:(1)'service-enabled',(2)'service-disabled',(3)'service-updated',(4)'zone-in',(5)'zone-out'\n");
+       g_printf("b?.  disconnect signals:(1)'service-enabled',(2)'service-disabled',(3)'service-updated',(4)'zone-in',(5)'zone-out'\n");
+       g_printf("c?. (1)Set boundary, (2)Get boundary, (3) Remove boundary, (4) Remove all boundaries, (5)Set device name, (6)Set update interval\n");
+       g_printf("==================================== Property ====================================\n");
+       PrintProperty(location_obj);
+       g_printf("\n==================================================================================\n");
+}
+
+int main(int argc, char** argv)
+{
+       char strOpt[255];
+       int ret;
+       char str[STR_MAX];
+       GError *gerr = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.location-api-test", 1);
+
+       g_type_init();
+       if( !g_thread_supported() )
+       {
+               g_thread_init(NULL);
+       }
+
+       GThread *g_main;
+       g_main = g_thread_create(GmainThread, NULL, TRUE, &gerr);
+       if (!g_main) {
+               g_debug("Error create gmain thread: Err domain[%d] Err code[%d] Err msg[%s]",
+                       gerr->domain, gerr->code, gerr->message);
+               g_error_free(gerr);
+               return 0;
+       }
+
+       json_util_init(LOCATION_API_TEST_JSON_FILE);
+       g_printf("--- Start LBS Test App ---\n");
+       while(1)
+       {
+               print_menu();
+               g_printf("Select option: ");
+               SelectOpt(strOpt);
+               g_printf("======================================================================================\n");
+               if (0 == g_strcmp0 ("x", strOpt)) {
+
+               }
+               else if (0 == g_strcmp0("1",strOpt)) {
+                       ret = location_init();
+                       GetLocationError(str, ret);
+                       g_printf("location_init: returned value [%s]\n", str);
+               } else if (0 == g_strcmp0("2",strOpt)) {
+                       if (location_obj) {
+                               g_printf("Location object already existed: [0x%x]", (unsigned int)location_obj);
+                               continue;
+                       }
+                       g_printf("LOCATION_METHOD_HYBRID[0] LOCATION_METHOD_GPS[1] LOCATION_METHOD_WPS[2] LOCATION_METHOD_CPS[3] LOCATION_METHOD_IPS[4] LOCATION_METHOD_SPS[5]\n");
+                       g_printf("Select Location Method: ");
+                       LocationMethod method = PromptInt();
+                       location_obj = location_new(method);
+                       if(location_obj) g_printf("Success\n");
+                       else             g_printf("Failed\n");
+               } else if (0 == g_strcmp0("3",strOpt)) {
+                       ret = location_free (location_obj);
+                       location_obj = NULL;
+                       g_sig_enable = 0;
+                       g_sig_disable = 0;
+                       g_sig_update = 0;
+                       g_sig_zonein = 0;
+                       g_sig_zoneout = 0;
+                       GetLocationError(str, ret);
+                       g_printf("location_free: returned value [%s]\n", str);
+               } else if (0 == g_strcmp0("4",strOpt)) {
+                       ret = location_start(location_obj);
+                       GetLocationError(str, ret);
+                       g_printf("location_start: returned value [%s]\n", str);
+               } else if (0 == g_strcmp0("5",strOpt)) {
+                       ret = location_stop(location_obj);
+                       GetLocationError(str, ret);
+                       g_printf("location_stop: returned value [%s]\n", str);
+               } else if (0 == g_strcmp0("6",strOpt)) {
+                       LocationPosition *pos = NULL;
+                       LocationAccuracy *acc = NULL;
+                       ret = location_get_position(location_obj, &pos, &acc);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_position: returned value [%s]\n", str);
+                       if (ret == LOCATION_ERROR_NONE) {
+                               g_printf("time: [%d], latitude: [%f], longitude: [%f], altitude: [%f], status: [%d]\n", pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                               GetAccuracyLevel(str, acc->level);
+                               g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
+                       }
+                       if(pos) location_position_free(pos);
+                       if(acc) location_accuracy_free(acc);
+               } else if (0 == g_strcmp0("6a",strOpt)) {
+                       LocationLastPosition last_pos;
+                       ret = location_get_last_known_position(location_obj, &last_pos);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_last_known_position: returned value [%s]\n", str);
+                       if (ret == LOCATION_ERROR_NONE) {
+                               g_printf("last position latitude: [%f], longitude: [%f], accuracy: [%f]\n", last_pos.latitude, last_pos.longitude, last_pos.accuracy);
+                       }
+               } else if (0 == g_strcmp0("7",strOpt)) {
+                       LocationAddress *add = NULL;
+                       LocationPosition *pos = NULL;
+                       LocationAccuracy *acc = NULL;
+
+                       g_printf("[0].San jose [1].¼ö¿ø»ï¼º [2].Suwon HQ [*].Custom\n");
+                       g_printf("Select Address: ");
+                       int opt = PromptInt();
+                       if (opt == 0)      add = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+                       else if (opt == 1) add = location_address_new (NULL, "»ï¼º·Î", "¸Åź3µ¿", "¼ö¿ø½Ã Â¿ÂµÃ…뱸", "°æ±âµµ", NULL, NULL);
+                       else if (opt == 2) add = location_address_new (NULL, "Samsung Electro-Mechanics Co. LTD", "Maetan 3-dong", "Suwon Si Yeongtong-gu", "Gyeonggi-do", NULL, NULL);
+                       else {
+                               char building_number[255], street[255], state[255], country_code[255], city[255], district[255], postal_code[255];
+                               g_printf("Input building number: ");
+                               fgets(building_number, 255, stdin);
+                               building_number[strlen(building_number)-1]='\0';
+                               g_printf("Input street: ");
+                               fgets(street, 255, stdin);
+                               street[strlen(street)-1]='\0';
+                               g_printf("Input state: ");
+                               fgets(state, 255, stdin);
+                               state[strlen(state)-1]='\0';
+                               g_printf("Input country code: ");
+                               fgets(country_code, 255, stdin);
+                               country_code[strlen(country_code)-1]='\0';
+                               g_printf("Input city: ");
+                               fgets(city, 255, stdin);
+                               city[strlen(city)-1]='\0';
+                               g_printf("Input district: ");
+                               fgets(district, 255, stdin);
+                               district[strlen(district)-1]='\0';
+                               g_printf("Input postal code: ");
+                               fgets(postal_code, 255, stdin);
+                               postal_code[strlen(postal_code)-1]='\0';
+                               add = location_address_new(building_number, street, district, city, state, country_code, postal_code);
+                       }
+                       ret = location_get_position_from_address (location_obj, add, &pos, &acc);
+                       if(add) location_address_free (add);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_position_from_adress: returned value [%s]\n", str);
+                       if (ret == LOCATION_ERROR_NONE)
+                               g_printf("time: [%d], latitude: [%f], longitude: [%f], altitude: [%f]\n", pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+                       if(pos) location_position_free(pos);
+                       if(acc) location_accuracy_free(acc);
+               } else if (0 == g_strcmp0("7a",strOpt)) {
+                       IdleData* data = g_new0(IdleData, 1);
+                       data->obj = location_obj;
+                       data->pos_cb = cb_position;
+                       data->user_data = location_obj;
+
+                       g_printf("[0].San jose [1].¼ö¿ø»ï¼º [2].Suwon HQ [*].Custom\n");
+                       g_printf("Select Address: ");
+                       int opt = PromptInt();
+                       if (opt == 0)      data->addr = location_address_new ("1", "Post Street", NULL, "san jose", "ca", NULL, "95113");
+                       else if (opt == 1) data->addr = location_address_new (NULL, "»ï¼º·Î", "¸Åź3µ¿", "¼ö¿ø½Ã Â¿ÂµÃ…뱸", "°æ±âµµ", NULL, NULL);
+                       else if (opt == 2) data->addr = location_address_new (NULL, "Samsung Electro-Mechanics Co. LTD", "Maetan 3-dong", "Suwon Si Yeongtong-gu", "Gyeonggi-do", NULL, NULL);
+                       else {
+                               char building_number[255], street[255], state[255], country_code[255], city[255], district[255], postal_code[255];
+                               g_printf("Input building number: ");
+                               fgets(building_number, 255, stdin);
+                               building_number[strlen(building_number)-1]='\0';
+                               g_printf("Input street: ");
+                               fgets(street, 255, stdin);
+                               street[strlen(street)-1]='\0';
+                               g_printf("Input state: ");
+                               fgets(state, 255, stdin);
+                               state[strlen(state)-1]='\0';
+                               g_printf("Input country code: ");
+                               fgets(country_code, 255, stdin);
+                               country_code[strlen(country_code)-1]='\0';
+                               g_printf("Input city: ");
+                               fgets(city, 255, stdin);
+                               city[strlen(city)-1]='\0';
+                               g_printf("Input district: ");
+                               fgets(district, 255, stdin);
+                               district[strlen(district)-1]='\0';
+                               g_printf("Input postal code: ");
+                               fgets(postal_code, 255, stdin);
+                               postal_code[strlen(postal_code)-1]='\0';
+                               data->addr = location_address_new(building_number, street, district, city, state, country_code, postal_code);
+                       }
+                       g_idle_add((GSourceFunc)idle_position_from_address_async, data);
+               }else if (0 == g_strcmp0("8",strOpt)) {
+                       gchar* addr = NULL;
+                       LocationPosition *pos = NULL;
+                       LocationAccuracy *acc = NULL;
+
+                       g_printf("[0].San jose [1].¼ö¿ø»ï¼º [2].Suwon HQ [*].Custom\n");
+                       g_printf("Select Address: ");
+                       int opt = PromptInt();
+                       if(opt == 0){
+                               addr = g_strdup("4 N 2nd Street 95113");
+                       }else if(opt == 1){
+                               addr = g_strdup("´ëÇѹα¹ Â°Ã¦Â±Ã¢ÂµÂµ Â¼Ã¶Â¿Ã¸Â½Ãƒ Â¿ÂµÃ…뱸 Â¸Ã…źµ¿ 436-52");
+                       }else if(opt == 2){
+                               addr = g_strdup("Samsung Electronics Co. LTD Maetan 3-dong, Suwon Si Yeongtong-gu, Gyeonggi-Do (Seoul 443-742 Korea), Rep of KOREA");
+                       }else{
+                               char buf[255];
+                               g_printf("Input freeform address: ");
+                               fgets(buf, 255, stdin);
+                               buf[strlen(buf)-1]='\0';
+                               addr = g_strdup(buf);
+                       }
+                       ret = location_get_position_from_freeformed_address(location_obj, addr, &pos, &acc);
+                       g_free(addr);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_position_from_freeformed_adress: returned value [%s]\n", str);
+                       if(ret == LOCATION_ERROR_NONE){
+                               g_printf("time: [%d], latitude: [%f], longitude: [%f], altitude: [%f]\n", pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+                       }
+                       if(pos) location_position_free(pos);
+                       if(acc) location_accuracy_free(acc);
+               }else if(0 == g_strcmp0("8a",strOpt) ){
+                       IdleData* data = g_new0(IdleData, 1);
+                       data->obj = location_obj;
+                       data->pos_cb = cb_position;
+                       data->user_data = location_obj;
+                       g_printf("[0].San jose [1].¼ö¿ø»ï¼º [2].Suwon HQ [*].Custom\n");
+                       g_printf("Select Address: ");
+                       int opt = PromptInt();
+                       if(opt == 0){
+                               data->str_addr = g_strdup("4 N 2nd Street 95113");
+                       }else if(opt == 1){
+                               data->str_addr = g_strdup("´ëÇѹα¹ Â°Ã¦Â±Ã¢ÂµÂµ Â¼Ã¶Â¿Ã¸Â½Ãƒ Â¿ÂµÃ…뱸 Â¸Ã…źµ¿ 436-52");
+                       }else if(opt == 2){
+                               data->str_addr = g_strdup("Samsung Electronics Co. LTD Maetan 3-dong, Suwon Si Yeongtong-gu, Gyeonggi-Do (Seoul 443-742 Korea), Rep of KOREA");
+                       }else{
+                               char buf[255];
+                               g_printf("Input freeform address: ");
+                               fgets(buf, 255, stdin);
+                               buf[strlen(buf)-1]='\0';
+                               data->str_addr = g_strdup(buf);
+                       }
+                       g_idle_add((GSourceFunc)idle_position_from_freefromed_address_async, data);
+
+               }else if(0 == g_strcmp0("9",strOpt) ){
+                       LocationVelocity *vel = NULL;
+                       LocationAccuracy *acc = NULL;
+                       ret = location_get_velocity(location_obj, &vel, &acc);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_velocity: returned value [%s]\n", str);
+                       if (ret == LOCATION_ERROR_NONE) {
+                               g_printf("time: [%d], speed: [%f], direction: [%f], climb: [%f]\n", vel->timestamp, vel->speed, vel->direction, vel->climb);
+                               GetAccuracyLevel(str, acc->level);
+                               g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
+                       }
+                       if(vel) location_velocity_free(vel);
+                       if(acc) location_accuracy_free(acc);
+               } else if(0 == g_strcmp0("10",strOpt) ){
+                       LocationAddress *addr = NULL;
+                       LocationAccuracy *acc = NULL;
+                       ret = location_get_address(location_obj, &addr, &acc);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_address: returned value [%s]\n", str);
+                       if(ret == LOCATION_ERROR_NONE){
+                               g_printf("building number: [%s], street: [%s], state: [%s], country code: [%s], city: [%s], district: [%s], postal code: [%s]\n",
+                                       addr->building_number, addr->street, addr->state, addr->country_code, addr->city, addr->district, addr->postal_code);
+                               GetAccuracyLevel(str, acc->level);
+                               g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
+                       }
+               }else if(0 == g_strcmp0("10a",strOpt) ){
+                       IdleData* data = g_new0(IdleData, 1);
+                       data->obj = location_obj;
+                       data->addr_cb = cb_address;
+                       data->user_data = location_obj;
+                       g_idle_add((GSourceFunc)idle_address_async, data);
+               }else if(0 == g_strcmp0("11",strOpt) ){
+                       LocationPosition *pos = NULL;
+                       LocationAddress *addr = NULL;
+                       LocationAccuracy *acc = NULL;
+                       g_printf("[0].San jose [1].Suwon HQ [*].Custom\n");
+                       g_printf("Select Position: ");
+                       int opt = PromptInt();
+                       if(opt == 0)      pos = location_position_new(0, 37.335276, -121.890059, 0, LOCATION_STATUS_2D_FIX);
+                       else if(opt == 1) pos = location_position_new(0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+                       else{
+                               g_printf("Input latitude: ");
+                               gdouble lat = PromptDB();
+                               g_printf("Input longitude: ");
+                               gdouble lon = PromptDB();
+                               pos = location_position_new(0, lat, lon, 0, LOCATION_STATUS_2D_FIX);
+                       }
+                       ret = location_get_address_from_position(location_obj, pos, &addr, &acc);
+                       GetLocationError(str, ret);
+                       g_printf("location_get_address_from_position: returned value [%s]\n", str);
+                       if(ret == LOCATION_ERROR_NONE){
+                               g_printf("building number: [%s], street: [%s], state: [%s], country code: [%s], city: [%s], district: [%s], postal code: [%s]\n",
+                                       addr->building_number, addr->street, addr->state, addr->country_code, addr->city, addr->district, addr->postal_code);
+                       }
+                       if(addr) location_address_free(addr);
+                       if(acc) location_accuracy_free(acc);
+               }else if(0 == g_strcmp0("11a",strOpt) ){
+                       IdleData* data = g_new0(IdleData, 1);
+                       data->obj = location_obj;
+                       data->addr_cb = cb_address;
+                       data->user_data = location_obj;
+
+                       g_printf("[0].San jose [1].Suwon HQ [*].Custom\n");
+                       g_printf("Select Position: ");
+                       int opt = PromptInt();
+                       if(opt == 0)       data->pos = location_position_new(0, 37.335276, -121.890059, 0, LOCATION_STATUS_2D_FIX);
+                       else if (opt == 1) data->pos = location_position_new(0, 37.257809, 127.056383, 0, LOCATION_STATUS_2D_FIX);
+                       else {
+                               g_printf("Input latitude: ");
+                               gdouble lat = PromptDB();
+                               g_printf("Input longitude: ");
+                               gdouble lon = PromptDB();
+                               data->pos = location_position_new(0, lat, lon, 0, LOCATION_STATUS_2D_FIX);
+                       }
+                       g_idle_add((GSourceFunc)idle_address_from_position_async, data);
+               }else if(0 == g_strcmp0("12",strOpt) ) {
+
+                       gulong distance;
+                       int ret = 0;
+                       char str[STR_MAX];
+                       LocationPosition pos1, pos2;
+
+                       pos1.latitude = 50.0663222;
+                       pos1.longitude = -5.71475;
+
+                       pos2.latitude = 58.6441;
+                       pos2.longitude = -3.070094;
+
+                       ret = location_get_distance(&pos1, &pos2, &distance);
+                       GetLocationError(str, ret);
+                       if(ret != LOCATION_ERROR_NONE) {
+                                       g_printf("Fail to get position. Error[%s]\n", str);
+                       }
+                       else {
+                                       g_printf("The approximate distance is [%lu]\n", distance);
+                                       g_printf("cf.) It is approximately 969954.114 meter\n");
+                       }
+               }else if(0 == g_strcmp0("13", strOpt)) {
+                       int method;
+                       char method_str[STR_MAX] = {0, };
+                       char input[8] = {0, };
+                       gboolean is_supported = FALSE;
+
+                       g_printf("0.Hybrid 1.GPS 2.WPS 3.CPS(X) 4.IPS(X) 5.SPS\n");
+                       g_printf("Select Method :");
+                       fgets(input, 8, stdin);
+                       method = atoi(input);
+                       switch(method) {
+                               case LOCATION_METHOD_HYBRID:
+                                       is_supported = location_is_supported_method(LOCATION_METHOD_HYBRID);
+                                       break;
+
+                               case LOCATION_METHOD_GPS:
+                                       is_supported = location_is_supported_method(LOCATION_METHOD_GPS);
+                                       break;
+
+                               case LOCATION_METHOD_WPS:
+                                       is_supported = location_is_supported_method(LOCATION_METHOD_WPS);
+                                       break;
+
+                               case LOCATION_METHOD_SPS:
+                                       is_supported = location_is_supported_method(LOCATION_METHOD_SPS);
+                                       break;
+
+                               case LOCATION_METHOD_CPS:
+                               case LOCATION_METHOD_IPS:
+                               default:
+                                       break;
+
+                       }
+                       GetMethod(method_str, method);
+
+                       g_printf("Method[%s] is %s.", method_str, is_supported ? "supported" : "not supported");
+
+               }else if(0 == g_strcmp0("14", strOpt)) {
+                       gboolean is_enabled = FALSE;
+                       is_enabled = location_is_enabled_gps(location_obj);
+                       if(is_enabled == TRUE) g_printf("GPS is turned on");
+                       else g_printf("GPS is turned off");
+               }else if(0 == g_strcmp0("99", strOpt)) {
+                       int ret = 0;
+                       const *str = "command";
+                       ret = location_send_command(str);
+                       if(ret == 0)
+                               g_printf("Success to send command[%s]", str);
+               }else if(0 == g_strcmp0("a1",strOpt)){
+                       if(location_obj && !g_sig_enable) {
+                               g_sig_enable = g_signal_connect (location_obj, "service-enabled", G_CALLBACK(cb_service_enabled), location_obj);
+                       }
+               }else if(0 == g_strcmp0("a2",strOpt)){
+                       if(location_obj && !g_sig_disable){
+                               g_sig_disable = g_signal_connect (location_obj, "service-disabled", G_CALLBACK(cb_service_disabled), location_obj);
+                       }
+               }else if(0 == g_strcmp0("a3",strOpt)){
+                       if(location_obj && !g_sig_update){
+                               g_sig_update = g_signal_connect (location_obj, "service-updated", G_CALLBACK(cb_service_updated), location_obj);
+                       }
+               }else if(0 == g_strcmp0("a4",strOpt)){
+                       if(location_obj && !g_sig_zonein){
+                               g_sig_zonein = g_signal_connect (location_obj, "zone-in", G_CALLBACK(cb_zone_in), location_obj);
+                       }
+               }else if(0 == g_strcmp0("a5",strOpt)){
+                       if(location_obj && !g_sig_zoneout){
+                               g_sig_zoneout = g_signal_connect (location_obj, "zone-out", G_CALLBACK(cb_zone_out), location_obj);
+                       }
+               }else if(0 == g_strcmp0("b1",strOpt)){
+                       if(location_obj && g_sig_enable) {
+                               g_signal_handler_disconnect (location_obj, g_sig_enable);
+                               g_sig_enable = 0;
+                       }
+               }else if(0 == g_strcmp0("b2",strOpt)){
+                       if(location_obj && g_sig_disable){
+                               g_signal_handler_disconnect (location_obj, g_sig_disable);
+                               g_sig_disable = 0;
+                       }
+               }else if(0 == g_strcmp0("b3",strOpt)){
+                       if(location_obj && g_sig_update){
+                               g_signal_handler_disconnect (location_obj, g_sig_update);
+                               g_sig_update = 0;
+                       }
+               }else if(0 == g_strcmp0("b4",strOpt)){
+                       if(location_obj && g_sig_zonein){
+                               g_signal_handler_disconnect (location_obj, g_sig_zonein);
+                               g_sig_zonein = 0;
+                       }
+               }else if(0 == g_strcmp0("b5",strOpt)){
+                       if(location_obj && g_sig_zoneout){
+                               g_signal_handler_disconnect (location_obj, g_sig_zoneout);
+                               g_sig_zoneout = 0;
+                       }
+               }else if(0 == g_strcmp0("c1",strOpt)){
+                       LocationBoundary* bound = NULL;
+                       int i = 0;
+                       int polygon_count = json_util_get_polygon_count();
+
+                       g_printf("[0].San jose(Rect) [1].Suwon HQ(Rect) [2].Seoul City(circle) ");
+                       for(i = 0; i < polygon_count; i++)
+                               g_printf("[%d].%s ", i + 3, json_util_get_polygon_name(i));
+
+                       g_printf("\nSelect Boundary: ");
+                       int opt = PromptInt();
+                       if (opt == 0) {
+                               LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
+                               LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
+                               bound = location_boundary_new_for_rect (lt, rb);
+                               location_position_free(rb);
+                               location_position_free(lt);
+
+                               location_boundary_add(location_obj, bound);
+
+                       } else if(opt == 1) {
+                               LocationPosition* rb = location_position_new (0, 37.255, 127.058, 0, LOCATION_STATUS_2D_FIX);
+                               LocationPosition* lt = location_position_new (0, 37.260, 127.045, 0, LOCATION_STATUS_2D_FIX);
+                               bound = location_boundary_new_for_rect (lt, rb);
+                               location_position_free(rb);
+                               location_position_free(lt);
+
+                               location_boundary_add(location_obj, bound);
+                       } else if(opt == 2) {
+                               LocationPosition *center = location_position_new(0, 37.566535, 126.977969, 0.0, LOCATION_STATUS_2D_FIX);
+                               double radius = 10.0;
+                               bound = location_boundary_new_for_circle(center, radius);
+
+                               location_boundary_add(location_obj, bound);
+                       } else if (opt > 2 && opt < 3 + polygon_count) {
+                               int index;
+                               int polygon_index = opt - 3;
+                               bound = json_util_get_polygon_boundary(polygon_index);
+                               location_boundary_add(location_obj, bound);
+
+                               LocationPosition * check_pos = NULL;
+                               gboolean ret = FALSE;
+                               int count = json_util_get_marker_position_count(polygon_index);
+                               for(index = 0; index < count; index++) {
+                                       check_pos = json_util_get_marker_position(polygon_index, index);
+
+                                       ret = location_boundary_if_inside(bound, check_pos);
+                                       g_printf("[%s] is [%s] and the test result is [%s]\n", json_util_get_marker_name(polygon_index, index), json_util_result_zone_test(polygon_index, index), ret == TRUE? "inside": "outside");
+                                       location_position_free(check_pos);
+                               }
+                       } else {
+                               g_printf("boundary is not set\n");
+                       }
+                       location_boundary_free(bound);
+
+               }else if(0 == g_strcmp0("c2",strOpt)){
+                       g_printf("Get Boundary\n");
+                       location_boundary_foreach(location_obj, PrintBoundary, NULL);
+
+               }else if(0 == g_strcmp0("c3",strOpt)){
+                       g_printf("Remove Boundary\n");
+                       LocationBoundary* bound = NULL;
+
+                       int i = 0;
+                       int polygon_count = json_util_get_polygon_count();
+
+                       g_printf("[0].San jose(Rect) [1].Suwon HQ(Rect) [2].Seoul City(circle) ");
+                       for(i = 0; i < polygon_count; i++)
+                               g_printf("[%d].%s ", i + 3, json_util_get_polygon_name(i));
+
+                       g_printf("\nSelect Boundary: ");
+                       int opt = PromptInt();
+                       if (opt == 0) {
+                               LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
+                               LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
+                               bound = location_boundary_new_for_rect (lt, rb);
+                               location_position_free(rb);
+                               location_position_free(lt);
+
+                       } else if(opt == 1) {
+                               LocationPosition* rb = location_position_new (0, 37.255, 127.058, 0, LOCATION_STATUS_2D_FIX);
+                               LocationPosition* lt = location_position_new (0, 37.260, 127.045, 0, LOCATION_STATUS_2D_FIX);
+                               bound = location_boundary_new_for_rect (lt, rb);
+                               location_position_free(rb);
+                               location_position_free(lt);
+
+                       } else if(opt == 2) {
+                               LocationPosition *center = location_position_new(0, 37.566535, 126.977969, 0.0, LOCATION_STATUS_2D_FIX);
+                               double radius = 10.0;
+                               bound = location_boundary_new_for_circle(center, radius);
+                               location_position_free(center);
+
+                       } else if (opt > 2 && opt < 3 + polygon_count) {
+                               int polygon_index = opt - 3;
+                               bound = json_util_get_polygon_boundary(polygon_index);
+                       } else {
+                               g_printf("Invalid value\n");
+                       }
+
+                       if(bound != NULL) location_boundary_remove(location_obj, bound);
+
+               }else if(0 == g_strcmp0("c4",strOpt)){
+                       location_boundary_foreach(location_obj, RemoveBoundary, location_obj);
+               }else if(0 == g_strcmp0("c5",strOpt)){
+                       char buf[255];
+                       g_printf("Input device name: ");
+                       fgets(buf, 255, stdin);
+                       buf[strlen(buf)-1]='\0';
+                       g_object_set(location_obj, "dev-name", buf, NULL);
+               } else if (0 == g_strcmp0("c6", strOpt)) {
+                       guint interval = 1;
+                       g_printf("Input interval[1~120]:");
+                       scanf("%u", &interval);
+                       g_printf("changed interval to [%u]\n", interval);
+                       g_object_set(location_obj, "update-interval", interval, NULL);
+               }else if(0 == g_strcmp0("q",strOpt) ){
+                       g_main_loop_quit(g_mainloop);
+                       break;
+               }
+       }
+       g_thread_join(g_main);
+       g_printf("\n--- Exit LBS Test App ---\n");
+       return 1;
+}
diff --git a/tests/location-api-test.json b/tests/location-api-test.json
new file mode 100644 (file)
index 0000000..7d3cf9c
--- /dev/null
@@ -0,0 +1,220 @@
+[\r
+       {\r
+               "name": "Seoul city hall(poly)",\r
+               "positions": [\r
+               {\r
+                       "latitude": 37.285217,\r
+                       "longitude": 127.015343\r
+               },\r
+               {\r
+                       "latitude": 37.230975,\r
+                       "longitude": 126.988735\r
+               },\r
+               {\r
+                       "latitude": 37.21799,\r
+                       "longitude": 127.087955\r
+               },\r
+               {\r
+                       "latitude": 37.2859,\r
+                       "longitude": 127.099457\r
+               }\r
+               ],\r
+               "marker_position": [\r
+               {\r
+                       "where": "Youngtong ku office",\r
+                       "latitude": 37.259246,\r
+                       "longitude": 127.046948,\r
+                       "result": "inside"\r
+               },\r
+               {\r
+                       "where": "Yongin",\r
+                       "latitude": 37.271576,\r
+                       "longitude": 127.328796,\r
+                       "result": "outside"\r
+               }\r
+               ]\r
+       },\r
+       {\r
+               "name" : "Suwon city hall(4pos)",\r
+               "positions": [\r
+               {\r
+                       "latitude": 43.068888,\r
+                       "longitude": 158.378906\r
+               },\r
+               {\r
+                       "latitude": -43.834527,\r
+                       "longitude": 156.445313\r
+               },\r
+               {\r
+                       "latitude": -53.852527,\r
+                       "longitude": -101.953125\r
+               },\r
+               {\r
+                       "latitude": 41.24472,\r
+                       "longitude": -134.648437\r
+               }\r
+               ],\r
+               "marker_position": [\r
+               {\r
+                       "where": "pos1",\r
+                       "latitude": 21.289374,\r
+                       "longitude": 78.398438,\r
+                       "result": "outside"\r
+               },\r
+               {\r
+                       "where": "pos2",\r
+                       "latitude": 20.303418,\r
+                       "longitude": -159.609375,\r
+                       "result": "inside"\r
+               }\r
+               ]\r
+       },\r
+       {\r
+               "name" : "Suwon city hall(4pos_other_seq)",\r
+               "positions": [\r
+               {\r
+                       "latitude": -53.852527,\r
+                       "longitude": -101.953125\r
+               },\r
+               {\r
+                       "latitude": 41.24472,\r
+                       "longitude": -134.648437\r
+               },\r
+               {\r
+                       "latitude": 43.068888,\r
+                       "longitude": 158.378906\r
+               },\r
+               {\r
+                       "latitude": -43.834527,\r
+                       "longitude": 156.445313\r
+               }\r
+\r
+               ],\r
+               "marker_position": [\r
+               {\r
+                       "where": "pos1",\r
+                       "latitude": 21.289374,\r
+                       "longitude": 78.398438,\r
+                       "result": "outside"\r
+               },\r
+               {\r
+                       "where": "pos2",\r
+                       "latitude": 20.303418,\r
+                       "longitude": -159.609375,\r
+                       "result": "inside"\r
+               }\r
+               ]\r
+\r
+       },\r
+       {\r
+               "name" : "India(7pos)",\r
+               "positions": [\r
+               {\r
+                       "latitude": 14.43468,\r
+                       "longitude": 32.519531\r
+               },\r
+               {\r
+                       "latitude": 22.593726,\r
+                       "longitude": 40.078125\r
+               },\r
+               {\r
+                       "latitude": 33.870416,\r
+                       "longitude": 55.898438\r
+               },\r
+               {\r
+                       "latitude": 32.249974,\r
+                       "longitude": 82.96875\r
+               },\r
+               {\r
+                       "latitude": 9.275622,\r
+                       "longitude": 116.894531\r
+               },\r
+               {\r
+                       "latitude": -9.622414,\r
+                       "longitude": 85.957031\r
+               },\r
+               {\r
+                       "latitude": 2.460181,\r
+                       "longitude": 42.363281\r
+               }\r
+               ],\r
+               "marker_position": [\r
+               {\r
+                       "where": "pos1",\r
+                       "latitude": 12.039321,\r
+                       "longitude": 58.535156,\r
+                       "result": "inside"\r
+               },\r
+               {\r
+                       "where": "pos2",\r
+                       "latitude": 8.233237,\r
+                       "longitude": 71.542969,\r
+                       "result": "inside"\r
+               },\r
+               {\r
+                       "where": "pos3",\r
+                       "latitude": 12.039321,\r
+                       "longitude": 96.679688,\r
+                       "result": "inside"\r
+               },\r
+               {\r
+                       "where": "pos4",\r
+                       "latitude": 2.284551,\r
+                       "longitude": 173.320313,\r
+                       "result": "outside"\r
+               },\r
+               {\r
+                       "where": "pos5",\r
+                       "latitude": 20.0,\r
+                       "longitude": -10.0,\r
+                       "result": "outside"\r
+               }\r
+               ]\r
+\r
+       },\r
+       {\r
+               "name" : "Sydney(6pos)",\r
+               "positions": [\r
+               {\r
+                       "latitude": -34.0214,\r
+                       "longitude": 151.009054\r
+               },\r
+               {\r
+                       "latitude": -34.01987,\r
+                       "longitude": 151.013389\r
+               },\r
+               {\r
+                       "latitude": -34.021435,\r
+                       "longitude": 151.0218\r
+               },\r
+               {\r
+                       "latitude": -34.02581,\r
+                       "longitude": 151.018109\r
+               },\r
+               {\r
+                       "latitude": -34.028158,\r
+                       "longitude": 151.010599\r
+               },\r
+               {\r
+                       "latitude": -34.02421,\r
+                       "longitude": 151.00811\r
+               }\r
+               ],\r
+               "marker_position": [\r
+               {\r
+                       "where": "pos1",\r
+                       "latitude": -34.023747,\r
+                       "longitude": 151.017294,\r
+                       "result": "inside"\r
+               },\r
+               {\r
+                       "where": "pos2",\r
+                       "latitude": -34.028798,\r
+                       "longitude": 71.542969,\r
+                       "result": "outside"\r
+               }\r
+               ]\r
+\r
+       }\r
+\r
+]\r
diff --git a/tests/nmea-sample.c b/tests/nmea-sample.c
new file mode 100644 (file)
index 0000000..7491589
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+GSource* nmea_src = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       gchar *nmea_data = NULL;
+       g_object_get(self, "nmea", &nmea_data, NULL);
+       if (nmea_data) {
+               g_debug("SYNC>> Currnet NMEA> nmea_data:\n%s\n", nmea_data);
+               g_free(nmea_data);
+       } else g_warning("SYNC>> Current NMEA> failed");
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds(60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/position-sample-gps.c b/tests/position-sample-gps.c
new file mode 100644 (file)
index 0000000..60432f3
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+       }
+}
+
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds(60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/property-sample.c b/tests/property-sample.c
new file mode 100644 (file)
index 0000000..b11844e
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       char* devname = NULL;
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if (devname) {
+               g_debug("Get property>> dev-name: %s", devname);
+               g_free(devname);
+       } else g_warning("failed to get property> dev-name");
+
+       g_object_set(loc, "dev-name", "/dev/test", NULL);
+       g_object_get(loc, "dev-name", &devname, NULL);
+       if (devname) {
+               g_debug("Get property>> dev-name: %s", devname);
+               g_free(devname);
+       } else g_warning("failed to set property> dev-name");
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds (60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/satellite-sample.c b/tests/satellite-sample.c
new file mode 100644 (file)
index 0000000..50fac0a
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+GSource* sat_src = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationSatellite *sat = NULL;
+       int idx = 0;
+
+       g_object_get (loc, "satellite", &sat, NULL);
+       if (sat) {
+               g_debug ("SYNC>> Current Sattelite> satellite in view = %d, satellite in used = %d", sat->num_of_sat_inview, sat->num_of_sat_used);
+               g_debug ("\tinview satellite information = ");
+               for (idx=0; idx<sat->num_of_sat_inview; idx++) {
+                       guint prn;
+                       gboolean used;
+                       guint elevation;
+                       guint azimuth;
+                       gint snr;
+                       location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr);
+                       g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d",
+                               idx, used, prn, elevation, azimuth, snr);
+               }
+               location_satellite_free (sat);
+       } else g_warning ("SYNC>> Current Sattelite> failed");
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds(60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/sps-test.c b/tests/sps-test.c
new file mode 100644 (file)
index 0000000..7764341
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static void
+update_gps(LocationObject* loc)
+{
+       g_debug("update gps");
+       double ran = g_random_double()/200;
+       LocationPosition* pos = location_position_new (time(NULL), 37.257809 + ran, 127.056383 + ran, 150.199997 + ran, LOCATION_STATUS_3D_FIX);
+       g_object_set(loc, "position-base", pos, NULL);
+       location_position_free (pos);
+
+       LocationVelocity* vel = location_velocity_new (pos->timestamp, 0, 0, 0);
+       g_object_set(loc, "velocity-base", vel, NULL);
+       location_velocity_free (vel);
+
+       LocationAccuracy* acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, 0, 0);
+       g_object_set(loc, "accuracy-info", acc, NULL);
+       location_accuracy_free (acc);
+
+       LocationSatellite* sat = location_satellite_new (9);
+       location_satellite_set_satellite_details(sat, 0, 5, 1, 0, 0, 41);
+       location_satellite_set_satellite_details(sat, 1, 9, 1, 0, 0, 46);
+       location_satellite_set_satellite_details(sat, 2, 15, 1, 0, 0, 45);
+       location_satellite_set_satellite_details(sat, 3, 18, 1, 0, 0, 41);
+       location_satellite_set_satellite_details(sat, 4, 21, 1, 0, 0, 34);
+       location_satellite_set_satellite_details(sat, 5, 22, 0, 0, 0, 41);
+       location_satellite_set_satellite_details(sat, 6, 26, 0, 0, 0, 46);
+       location_satellite_set_satellite_details(sat, 7, 27, 0, 0, 0, 31);
+       location_satellite_set_satellite_details(sat, 8, 28, 0, 0, 0, 33);
+       g_object_set(loc, "satellite-info", sat, NULL);
+       location_satellite_free (sat);
+}
+
+static gboolean
+update_timer(gpointer data)
+{
+       update_gps(data);
+       return TRUE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       default:
+               g_warning ("ASYNC>> Undefined update type");
+               break;
+       }
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationVelocity *vel = NULL;
+       LocationAddress *addr = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.sps-test", 1);
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_SPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       LocationBoundary *bound = NULL;
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Get property>> boundary> type: %d", bound->type);
+               location_boundary_free (bound);
+       } else g_warning("failed to get property> boundary");
+
+       LocationPosition *rb = location_position_new(0, 37.255, 127.060, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.055, 0, LOCATION_STATUS_2D_FIX);
+       bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       if (bound) {
+               g_object_set(loc, "boundary", bound, NULL);
+               location_boundary_free(bound);
+       } else g_warning("failed to location_boundary_new_for_rect()");
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)",
+                       bound->type,
+                       bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
+                       bound->rect.left_top->latitude, bound->rect.left_top->longitude);
+               location_boundary_free (bound);
+       } else  g_warning("failed to set property> boundary");
+
+       update_gps(loc);
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds(1, update_timer, loc);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/velocity-sample.c b/tests/velocity-sample.c
new file mode 100644 (file)
index 0000000..18cffdf
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+       }
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationVelocity *vel = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds(60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}
+
diff --git a/tests/wps-test.c b/tests/wps-test.c
new file mode 100644 (file)
index 0000000..308ee9d
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static void
+cb_service_updated (GObject *self,
+       guint type,
+       gpointer data,
+       gpointer accuracy,
+       gpointer userdata)
+{
+       g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
+
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+       switch (type) {
+       case POSITION_UPDATED: {
+                       LocationPosition *pos = (LocationPosition*) data;
+                       g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                               pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       case VELOCITY_UPDATED: {
+                       LocationVelocity *vel = (LocationVelocity*) data;
+                       g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                               vel->timestamp, vel->speed, vel->direction, vel->climb);
+                       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               }
+               break;
+       default:
+               g_warning ("ASYNC>> Undefined update type");
+               break;
+       }
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+
+       LocationObject *loc = (LocationObject*)userdata;
+       LocationAccuracy *acc = NULL;
+       LocationPosition *pos = NULL;
+       LocationVelocity *vel = NULL;
+       LocationAddress *addr = NULL;
+
+       if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) {
+               g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_position_free(pos);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current position> failed");
+       if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
+               g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
+                       vel->timestamp, vel->speed, vel->direction, vel->climb);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+                       acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_velocity_free(vel);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current velocity> failed");
+       if (LOCATION_ERROR_NONE == location_get_address(loc, &addr, &acc)) {
+               g_debug ("SYNC>> Current address> %s %s %s %s %s %s %s",
+                       addr->building_number, addr->street, addr->district, addr->city, addr->state, addr->postal_code, addr->country_code);
+               g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+               location_address_free(addr);
+               location_accuracy_free(acc);
+       } else g_warning ("SYNC>> Current address> failed");
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+
+       // If application is executed by AUL, this is not needed.
+       g_setenv("PKG_NAME", "org.tizen.wps-test", 1);
+
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_WPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationMethod method = LOCATION_METHOD_NONE;
+       g_object_get(loc, "method", &method, NULL);
+       g_debug("Get property>> method:%d", method);
+
+       LocationBoundary *bound = NULL;
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Get property>> boundary> type: %d", bound->type);
+               location_boundary_free (bound);
+       } else g_warning("failed to get property> boundary");
+
+       LocationPosition *rb = location_position_new(0, 37.255, 127.056, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.050, 0, LOCATION_STATUS_2D_FIX);
+       bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       if (bound) {
+               g_object_set(loc, "boundary", bound, NULL);
+               location_boundary_free(bound);
+       } else g_warning("failed to location_boundary_new_for_rect()");
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)",
+                       bound->type,
+                       bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
+                       bound->rect.left_top->latitude, bound->rect.left_top->longitude);
+               location_boundary_free (bound);
+       } else  g_warning("failed to set property> boundary");
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
+
+       if (LOCATION_ERROR_NONE != location_start (loc)) {
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+
+       LocationPosition *pos = NULL;
+       g_object_get(loc, "last-position", &pos, NULL);
+       if (pos) {
+               g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
+                       pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
+               location_position_free(pos);
+       } else  g_warning("failed to get property> last-position");
+
+       location_free (loc);
+
+       return 0;
+}
diff --git a/tests/zone-sample.c b/tests/zone-sample.c
new file mode 100644 (file)
index 0000000..28b2c76
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@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.
+ */
+
+#include <glib.h>
+#include <location/location.h>
+
+static GMainLoop *loop = NULL;
+
+static gboolean
+exit_program (gpointer data)
+{
+       g_main_loop_quit (loop);
+       g_debug ("Quit g_main_loop");
+       return FALSE;
+}
+
+static void
+cb_service_enabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
+}
+
+static void
+cb_service_disabled (GObject *self,
+       guint status,
+       gpointer userdata)
+{
+       g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);      
+}
+
+static void
+cb_zone_in (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{      
+       g_debug("cb_zone_in: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f", 
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", 
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+static void
+cb_zone_out (GObject *self,
+       guint type,
+       gpointer position,
+       gpointer accuracy)
+{
+       g_debug("cb_zone_out: type(%d)", type);
+       LocationPosition *pos = (LocationPosition*) position;
+       LocationAccuracy *acc = (LocationAccuracy*) accuracy;
+
+       g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f", 
+               pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
+       g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", 
+               acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
+}
+
+int
+main (int argc, char *argv[])
+{
+       LocationObject *loc = NULL;
+       
+       location_init ();
+
+       loop = g_main_loop_new (NULL, TRUE);
+
+       loc  = location_new (LOCATION_METHOD_GPS);
+       if (!loc) {
+               g_debug("location_new failed");
+               return -1;
+       }
+
+       LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
+       LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
+       LocationBoundary *bound = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+       if (bound) {
+               g_object_set(loc, "boundary", bound, NULL);
+               location_boundary_free(bound);
+       } else g_warning("failed to location_boundary_new_for_rect()"); 
+       g_object_get(loc, "boundary", &bound, NULL);
+       if (bound) {
+               g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)", 
+                       bound->type,
+                       bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
+                       bound->rect.left_top->latitude, bound->rect.left_top->longitude);
+               location_boundary_free (bound);
+       } else  g_warning("failed to set property> boundary");
+
+       g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
+       g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
+       g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
+       g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
+       
+       if( LOCATION_ERROR_NONE != location_start (loc) ){
+               g_debug("location_start failed");
+               return -1;
+       }
+
+       g_timeout_add_seconds (60, exit_program, NULL);
+       g_main_loop_run (loop);
+
+       location_stop (loc);
+       location_free (loc);
+
+       return 0;
+}