--- /dev/null
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
+*.[oa]
+*~
+build-stamp
+cmake_build_tmp
+configure-stamp
+debian/files
+debian/net-config-dbg.debhelper.log
+debian/net-config-dbg.substvars
+debian/net-config-dbg
+debian/net-config.debhelper.log
+debian/net-config.install
+debian/net-config.substvars
+debian/net-config
+debian/net.netconfig.service
+debian/tmp
+netconfig-iface*-glue.h
+.project
+.cproject
SET(SRCS
src/main.c
- src/dbus.c
- src/util.c
src/neterror.c
- src/emulator.c
src/wifi-power.c
src/wifi-state.c
src/network-state.c
+ src/network-statistics.c
src/wifi-indicator.c
src/signal-handler.c
+ src/wifi-ssid-scan.c
src/wifi-background-scan.c
+ src/dbus/netdbus.c
+ src/dbus/netsupplicant.c
+ src/utils/util.c
+ src/utils/emulator.c
+ src/utils/mdm-private.c
)
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(pkgs REQUIRED
- dbus-1
glib-2.0
dbus-glib-1
- vconf
dlog
+ vconf
wifi-direct
syspopup-caller)
${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
)
+ADD_CUSTOM_TARGET(netconfig-iface-network-statistics-glue.h
+ COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_network_statistics
+ --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-network-statistics-glue.h
+ ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-statistics.xml
+ DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-statistics.xml
+)
ADD_CUSTOM_TARGET(netconfig-iface-wifi-glue.h
COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_wifi
--output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-wifi-glue.h
)
ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-network-state-glue.h)
+ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-network-statistics-glue.h)
ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-wifi-glue.h)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
-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
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+net-config (0.1.88-5) unstable; urgency=low
+
+ * wifi-state notifier
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.88-5
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 17 Aug 2012 00:24:16 +0900
+
+net-config (0.1.88-4) unstable; urgency=low
+
+ * Re-factor wifi-state, statistics
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.88-4
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 16 Aug 2012 16:52:47 +0900
+
+net-config (0.1.88-3) unstable; urgency=low
+
+ * Fix build break
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.88-3
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 14 Aug 2012 13:30:07 +0900
+
+net-config (0.1.88-2) unstable; urgency=low
+
+ * Implement SSID scan for Finding Hidden Network
+ * First draft from Sanghoon Cho, Praveen C
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.88-2
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 11 Aug 2012 16:30:06 +0900
+
+net-config (0.1.88-1) unstable; urgency=low
+
+ * Revise functions for dbus method call to avoid GPL license issue
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.88-1
+
+ -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 10 Aug 2012 19:22:42 +0900
+
+net-config (0.1.87-3) unstable; urgency=low
+
+ * Revise test_device_picker to refer service favorite
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.87-3
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 06 Aug 2012 19:43:16 +0900
+
+net-config (0.1.87-2) unstable; urgency=low
+
+ * Revise codes to make public source release
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.87-2
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 03 Aug 2012 18:07:18 +0900
+
+net-config (0.1.87-1) unstable; urgency=low
+
+ * Wi-Fi ANT BAR update (updated)
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.87-1
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 18 Jul 2012 14:44:47 +0900
+
+net-config (0.1.86-7) unstable; urgency=low
+
+ * Add power on/off completed signal
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-7
+
+ -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 17 Jul 2012 16:40:10 +0900
+
+net-config (0.1.86-6) unstable; urgency=low
+
+ * Implement to delete Wi-Fi found notification when Wi-Fi is turned off
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-6
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Mon, 16 Jul 2012 16:40:40 +0900
+
+net-config (0.1.86-5) unstable; urgency=low
+
+ * Fix not showing 3G alert popup
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-5
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 13 Jul 2012 21:03:36 +0900
+
+net-config (0.1.86-4) unstable; urgency=low
+
+ * No update RSSI when LCD off
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-4
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 11 Jul 2012 23:19:51 +0900
+
+net-config (0.1.86-3) unstable; urgency=low
+
+ * Fix Wi-Fi state update during Wi-Fi power off
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-3
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 07 Jul 2012 20:53:21 +0900
+
+net-config (0.1.86-2) unstable; urgency=low
+
+ * No device picker during connecting
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-2
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 07 Jul 2012 16:45:40 +0900
+
+net-config (0.1.86-1) unstable; urgency=low
+
+ * Implement to set/get network statistics
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.86-1
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 06 Jul 2012 19:47:02 +0900
+
+net-config (0.1.85-6) unstable; urgency=low
+
+ * Fix wifi indicator update bug
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.85-6
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 06 Jul 2012 16:36:04 +0900
+
+net-config (0.1.85-5) unstable; urgency=low
+
+ * Implement Wi-Fi found notification
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.85-5
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Tue, 03 Jul 2012 14:07:28 +0900
+
+net-config (0.1.85-4) unstable; urgency=low
+
+ * Re-factor Wi-Fi indicator
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.85-4
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 05 Jun 2012 16:28:12 +0900
+
+net-config (0.1.85-3) unstable; urgency=low
+
+ * Remove logging of libnet-client and net-config
+ * Git: magnolia/framework/connectivity/net-config
+ * Tag: net-config_0.1.85-3
+
+ -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 19:57:12 +0900
+
net-config (0.1.85-2) unstable; urgency=low
* Clean up the useless
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.85-2
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 05 Jun 2012 10:41:42 +0900
net-config (0.1.85-1) unstable; urgency=low
* Fix Wi-Fi BG Scan bug for default value
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.85-1
-- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 01 Jun 2012 15:12:49 +0900
net-config (0.1.84-1) unstable; urgency=low
* Fix Wi-Fi power state update
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.84-1
-- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 30 May 2012 13:34:17 +0900
net-config (0.1.83) unstable; urgency=low
* Revise emulator support
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.83
-- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 17 May 2012 17:55:47 +0900
net-config (0.1.82) unstable; urgency=low
* Check NULL: Wi-Fi technology state
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.82
-- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 17 May 2012 16:20:17 +0900
net-config (0.1.81) unstable; urgency=low
* Revise private vconf key name
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.81
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 15 May 2012 13:54:28 +0900
net-config (0.1.80) unstable; urgency=low
* Revise unnecessary funtions
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.80
-- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 09 May 2012 15:13:52 +0900
* Revise net-config signal filter handler
* Revise Wi-Fi state management
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.79
-- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 09 May 2012 11:41:09 +0900
net-config (0.1.78) unstable; urgency=low
* Revise ConnMan profile prefix to fit ConnMan 0.78
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.78
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 08 May 2012 15:55:04 +0900
* Revise net-config to fit Android supplicant
* Revise net-config log
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.77
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 24 Apr 2012 23:08:11 +0900
net-config (0.1.76) unstable; urgency=low
* Add a vconf key for local MAC address of Wi-Fi device
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.76
-- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 17 Apr 2012 10:28:08 +0900
* Modify background scan policy
* disallow to request bg scan in case the state is connected and rssi is below level 2
- * Git: slp/pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.75
-- Sanghoon Cho <sanghoon80.cho@samsung.com> Fri, 13 Apr 2012 16:37:55 +0900
net-config (0.1.74) unstable; urgency=low
* Fix Wi-Fi power bug when Wi-Fi direct is on
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.74
-- Sanghoon Cho <sanghoon80.cho@samsung.com> Thu, 12 Apr 2012 22:06:27 +0900
net-config (0.1.73) unstable; urgency=low
* Fix Wi-Fi tethering state bugs
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.73
-- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 02 Apr 2012 17:27:06 +0900
net-config (0.1.72) unstable; urgency=low
* Fix emulator proxy setting
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.72
-- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 29 Mar 2012 10:45:15 +0900
net-config (0.1.71) unstable; urgency=low
* Enable DBus auto-activation
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.71
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 27 Mar 2012 14:01:40 +0900
net-config (0.1.70) unstable; urgency=low
* Implement Wi-Fi device picker service
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.70
-- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 23 Mar 2012 19:28:01 +0900
net-config (0.1.69) unstable; urgency=low
- * Change alert popup name to "net-popup"
- * Git: pkgs/n/net-config
+ * Change alert popup name to net-popup
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.69
-- Sunkey Lee <yuvjjang.lee@samsung.com> Fri, 16 Mar 2012 10:21:53 +0900
net-config (0.1.68) unstable; urgency=low
* Revise Network State update DBus interface name (object path)
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.68
-- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 15 Mar 2012 13:33:17 +0900
net-config (0.1.67) unstable; urgency=low
* Write update default connection information
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.67
-- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 21:31:57 +0900
net-config (0.1.66) unstable; urgency=low
* Write initial Network Configuration Module based on exist sonet
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.66
-- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 19:00:26 +0900
net-config (0.1.65) unstable; urgency=low
* Fix network status update
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.65
-- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 08 Mar 2012 22:17:24 +0900
net-config (0.1.64) unstable; urgency=low
* Fix vconf memory backend to be installed
- * Git: pkgs/n/net-config
+ * Git: magnolia/framework/connectivity/net-config
* Tag: net-config_0.1.64
-- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 06 Mar 2012 21:11:08 +0900
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Danny JS Seo <S.Seo@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 __NETCONFIG_DBUS_H__
-#define __NETCONFIG_DBUS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-
-#define CONNMAN_SERVICE "net.connman"
-#define CONNMAN_PATH "/net/connman"
-
-#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
-#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
-#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
-#define SUPPLICANT_GLOBAL_INTERFACE "org.freedesktop.DBus.Properties"
-
-#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
-#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
-#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
-#define CONNMAN_MANAGER_PATH "/"
-
-#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
-#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
-
-#define DBUS_PATH_MAX_BUFLEN 512
-#define DBUS_STATE_MAX_BUFLEN 64
-
-typedef enum {
- NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE,
- NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY,
-} netconfig_dbus_result_type;
-
-struct dbus_input_arguments {
- int type;
- void *data;
-};
-
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message);
-DBusMessage *netconfig_invoke_dbus_method(const char *dest, DBusConnection *connection,
- const char *path, const char *interface_name, const char *method);
-DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
- DBusConnection *connection,
- const char *path, const char *interface_name,
- const char *method, GList *args);
-DBusMessage *netconfig_dbus_send_request(const char *destination, char *param_array[]);
-void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
- netconfig_dbus_result_type result_type, void *data);
-char *netconfig_dbus_get_string(DBusMessage *msg);
-
-DBusGConnection *netconfig_setup_dbus(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NETCONFIG_DBUS_H__ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 MDM_PRIVATE_H_
+#define MDM_PRIVATE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+gboolean netconfig_is_wifi_allowed(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDM_PRIVATE_H_ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __NETCONFIG_NETDBUS_H__
+#define __NETCONFIG_NETDBUS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
+#define CONNMAN_SERVICE "net.connman"
+#define CONNMAN_PATH "/net/connman"
+
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
+#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
+#define CONNMAN_MANAGER_PATH "/"
+
+#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
+#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
+
+#define NETCONFIG_WIFI_INTERFACE "net.netconfig.wifi"
+#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+
+#define DBUS_PATH_MAX_BUFLEN 512
+#define DBUS_STATE_MAX_BUFLEN 64
+
+typedef enum {
+ NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE,
+ NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY,
+} netconfig_dbus_result_type;
+
+char *netconfig_wifi_get_connected_service_name(DBusMessage *message);
+DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method, char *param_array[]);
+void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
+ netconfig_dbus_result_type result_type, void *data);
+char *netconfig_dbus_get_string(DBusMessage *msg);
+
+DBusGConnection *netconfig_setup_dbus(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETDBUS_H__ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __NETCONFIG_NETSUPPLICANT_H__
+#define __NETCONFIG_NETSUPPLICANT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
+#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
+#define SUPPLICANT_GLOBAL_INTERFACE "org.freedesktop.DBus.Properties"
+
+struct dbus_input_arguments {
+ int type;
+ void *data;
+};
+
+gboolean netconfig_wifi_get_ifname(char **ifname);
+gboolean netconfig_wifi_get_supplicant_interface(char **path);
+DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
+ DBusConnection *connection,
+ const char *path, const char *interface_name,
+ const char *method, GList *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETSUPPLICANT_H__ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 NETWORK_STATISTICS_H_
+#define NETWORK_STATISTICS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+#include <wifi-state.h>
+
+G_BEGIN_DECLS
+
+typedef struct NetconfigNetworkStatistics NetconfigNetworkStatistics;
+typedef struct NetconfigNetworkStatisticsClass NetconfigNetworkStatisticsClass;
+
+#define NETCONFIG_TYPE_NETWORK_STATISTICS ( netconfig_network_statistics_get_type() )
+#define NETCONFIG_NETWORK_STATISTICS(obj) ( G_TYPE_CHECK_INSTANCE_CAST( (obj),NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatistics ) )
+#define NETCONFIG_IS_NETWORK_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE( (obj), NETCONFIG_TYPE_NETWORK_STATISTICS) )
+
+#define NETCONFIG_NETWORK_STATISTICS_CLASS(klass) ( G_TYPE_CHECK_CLASS_CAST( (klass), NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatisticsClass) )
+#define NETCONFIG_IS_NETWORK_STATISTICS_CLASS(klass) ( G_TYPE_CHECK_CLASS_TYPE( (klass), NETCONFIG_TYPE_NETWORK_STATISTICS) )
+#define NETCONFIG_NETWORK_STATISTICS_GET_CLASS(obj) ( G_TYPE_INSTANCE_GET_CLASS( (obj), NETCONFIG_TYPE_NETWORK_STATISTICS, NetconfigNetworkStatisticsClass ) )
+
+GType netconfig_network_statistics_get_type(void);
+
+gpointer netconfig_network_statistics_create_and_init(DBusGConnection *conn);
+
+
+gboolean netconfig_iface_network_statistics_get_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error);
+gboolean netconfig_iface_network_statistics_get_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error);
+gboolean netconfig_iface_network_statistics_get_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error);
+gboolean netconfig_iface_network_statistics_get_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error);
+
+gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+
+gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error);
+
+void netconfig_wifi_statistics_update_powered_off(void);
+
+G_END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NETWORK_STATISTICS_H_ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
extern "C" {
#endif
+#include "wifi.h"
+
void netconfig_wifi_bgscan_start(void);
void netconfig_wifi_bgscan_stop(void);
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
extern "C" {
#endif
+int netconfig_wifi_get_rssi(void);
+
void netconfig_wifi_indicator_start(void);
void netconfig_wifi_indicator_stop(void);
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __NETCONFIG_WIFI_SSID_SCAN_H__
+#define __NETCONFIG_WIFI_SSID_SCAN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+enum netconfig_wifi_security {
+ WIFI_SECURITY_UNKNOWN = 0x00,
+ WIFI_SECURITY_NONE = 0x01,
+ WIFI_SECURITY_WEP = 0x02,
+ WIFI_SECURITY_PSK = 0x03,
+ WIFI_SECURITY_IEEE8021X = 0x04,
+};
+
+gboolean netconfig_wifi_get_ssid_scan_state(void);
+
+void netconfig_wifi_notify_ssid_scan_done(DBusMessage *message);
+void netconfig_wifi_bss_added(DBusMessage *message);
+
+gboolean netconfig_iface_wifi_request_specific_scan(NetconfigWifi *wifi,
+ gchar *ssid, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_SSID_SCAN_H__ */
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
extern "C" {
#endif
+#include <glib.h>
+
enum netconfig_wifi_service_state {
NETCONFIG_WIFI_UNKNOWN = 0x00,
NETCONFIG_WIFI_IDLE = 0x01,
NETCONFIG_WIFI_CONNECTED = 0x03,
};
+struct netconfig_wifi_state_notifier {
+ void (*netconfig_wifi_state_changed)
+ (enum netconfig_wifi_service_state, void *user_data);
+ void *user_data;
+};
+
void netconfig_wifi_state_set_service_state(
enum netconfig_wifi_service_state state);
enum netconfig_wifi_service_state
- netconfig_wifi_state_get_service_state(void);
+ netconfig_wifi_state_get_service_state(void);
gchar *netconfig_wifi_get_technology_state(void);
void netconfig_wifi_update_power_state(gboolean powered);
+char *netconfig_wifi_get_favorite_service(void);
+
+void netconfig_wifi_check_network_notification(void);
+
+
+void netconfig_wifi_state_notifier_cleanup(void);
+void netconfig_wifi_state_notifier_register(
+ struct netconfig_wifi_state_notifier *notifier);
+void netconfig_wifi_state_notifier_unregister(
+ struct netconfig_wifi_state_notifier *notifier);
+
#ifdef __cplusplus
}
#endif
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/net/netconfig/network_statistics">
+ <interface name="net.netconfig.network_statistics">
+ <method name="GetWifiTotalTxBytes">
+ <arg type="t" name="total_bytes" direction="out" />
+ </method>
+ <method name="GetWifiTotalRxBytes">
+ <arg type="t" name="total_bytes" direction="out" />
+ </method>
+ <method name="GetWifiLastTxBytes">
+ <arg type="t" name="last_bytes" direction="out" />
+ </method>
+ <method name="GetWifiLastRxBytes">
+ <arg type="t" name="last_bytes" direction="out" />
+ </method>
+ <method name="ResetCellularTotalTxBytes">
+ </method>
+ <method name="ResetCellularTotalRxBytes">
+ </method>
+ <method name="ResetCellularLastTxBytes">
+ </method>
+ <method name="ResetCellularLastRxBytes">
+ </method>
+ <method name="ResetWifiTotalTxBytes">
+ </method>
+ <method name="ResetWifiTotalRxBytes">
+ </method>
+ <method name="ResetWifiLastTxBytes">
+ </method>
+ <method name="ResetWifiLastRxBytes">
+ </method>
+ </interface>
+</node>
<method name="SetBgscan">
<arg type="u" name="ScanMode" direction="in"/>
</method>
+ <method name="RequestSpecificScan">
+ <arg type="s" name="SSID" direction="in"/>
+ </method>
<signal name="DriverLoaded">
<arg name="mac" type="s"/>
</signal>
+++ /dev/null
-* Thu Jul 19 2012 Danny JS Seo <S.Seo@samsung.com> - 0.1.85_2
-- Upgrade net-config according to the ConnMan 0.78
-
-* Thu Jul 12 09:37:03 CST 2012 Arron <arron.wang@intel.com> - 0.1.74
-- Add systemd support
-
-* Fri Jun 15 2012 Chris Leech <christopher.leech@linux.intel.com> - 0.1.74
-- move dbus files from /usr/etc/dbus-1 to /etc/dbus-1
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
+++ /dev/null
-[Unit]
-Description=net config service
-After=syslog.target
-
-[Service]
-Type=forking
-ExecStart=/usr/sbin/net-config
-
-[Install]
-WantedBy=multi-user.target
-#sbs-git:pkgs/n/net-config
+#sbs-git:magnolia/framework/connectivity/net-config
Name: net-config
Summary: TIZEN Network Configuration Module
-Version: 0.1.85_2
+Version: 0.1.88_5
Release: 1
Group: System/Network
License: Apache License Version 2.0
Source0: %{name}-%{version}.tar.gz
-Source1: net-config.service
-Source1001: packaging/net-config.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(tapi)
-BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(wifi-direct)
BuildRequires: pkgconfig(syspopup-caller)
-Requires: systemd
-Requires(post): systemd
-Requires(preun): systemd
-Requires(postun): systemd
%description
TIZEN Network Configuration Module
%setup -q
%build
-cp %{SOURCE1001} .
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
make %{?jobs:-j%jobs}
mkdir -p %{buildroot}/usr/share/dbus-1/services
cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}/usr/share/dbus-1/services/net.netconfig.service
-mkdir -p %{buildroot}/%{_sysconfdir}/dbus-1/system.d
-cp resources/usr/etc/dbus-1/system.d/net-config.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/net-config.conf
+mkdir -p %{buildroot}/usr/etc/dbus-1/system.d
+cp resources/usr/etc/dbus-1/system.d/net-config.conf %{buildroot}/usr/etc/dbus-1/system.d/net-config.conf
mkdir -p %{buildroot}/opt/etc
cp resources/opt/etc/resolv.conf %{buildroot}/opt/etc/resolv.conf
mkdir -p %{buildroot}/etc/rc.d/init.d
mkdir -p %{buildroot}/etc/rc.d/rc5.d
ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc5.d/S60net-config
-# Systemd service file
-install -d %{buildroot}%{_libdir}/systemd/system/
-install -m 644 %{S:1} %{buildroot}%{_libdir}/systemd/system/net-config.service
-install -d %{buildroot}%{_libdir}/systemd/system/network.target.wants/
-ln -s ../net-config.service %{buildroot}%{_libdir}/systemd/system/network.target.wants/net-config.service
%post
#Resource
chmod 644 /opt/etc/resolv.conf
-systemctl daemon-reload
-systemctl restart net-config.service
-
-%preun
-systemctl stop net-config.service
-
%postun
-systemctl daemon-reload
%files
-%manifest net-config.manifest
%defattr(-,root,root,-)
%{_sbindir}/*
%{_datadir}/dbus-1/services/*
/opt/etc/resolv.conf
-%{_sysconfdir}/dbus-1/system.d/*
+%{_prefix}/etc/dbus-1/system.d/*
%{_sysconfdir}/rc.d/init.d/net-config
%{_sysconfdir}/rc.d/rc3.d/S60net-config
%{_sysconfdir}/rc.d/rc5.d/S60net-config
-%{_libdir}/systemd/system/net-config.service
-%{_libdir}/systemd/system/network.target.wants/net-config.service
#!/bin/sh
-dlogutil -v threadtime -f /var/log/libnetwork.log -r 1000 -n 10 network &
-dlogutil -v threadtime -f /var/log/net-config.log -r 1000 -n 10 net-config &
-
/usr/sbin/net-config &
bssid="$(vconftool -t string get db/wifi/bssid_address | sed -n "/\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]/p")"
if [ "$bssid" = "" ]; then
if [ -f /opt/etc/.mac.info ]; then
- cat /opt/etc/.mac.info | sed -n "/^\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]$/p" | xargs vconftool set -t string db/wifi/bssid_address
+ cat /opt/etc/.mac.info | sed -n "/^\([0-9A-F][0-9A-F]:\)\{5\}[0-9A-F][0-9A-F]$/p" | xargs vconftool set -t string db/wifi/bssid_address -f
fi
-fi
\ No newline at end of file
+fi
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Danny JS Seo <S.Seo@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 <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "dbus.h"
-#include "log.h"
-#include "netconfig.h"
-
-#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
-
-#define DBUS_PARAM_TYPE_STRING "string"
-#define DBUS_PARAM_TYPE_INT16 "int16"
-#define DBUS_PARAM_TYPE_UINT16 "uint16"
-#define DBUS_PARAM_TYPE_INT32 "int32"
-#define DBUS_PARAM_TYPE_UINT32 "uint32"
-#define DBUS_PARAM_TYPE_INT64 "int64"
-#define DBUS_PARAM_TYPE_UINT64 "uint64"
-#define DBUS_PARAM_TYPE_DOUBLE "double"
-#define DBUS_PARAM_TYPE_BYTE "byte"
-#define DBUS_PARAM_TYPE_BOOLEAN "boolean"
-#define DBUS_PARAM_TYPE_OBJECT_PATH "objpath"
-
-static int __neconfig_dbus_datatype_from_stringname(const char *Args)
-{
- int ArgType = 0;
-
- if (!strcmp(Args, DBUS_PARAM_TYPE_STRING))
- ArgType = DBUS_TYPE_STRING;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_INT16))
- ArgType = DBUS_TYPE_INT16;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT16))
- ArgType = DBUS_TYPE_UINT16;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_INT32))
- ArgType = DBUS_TYPE_INT32;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT32))
- ArgType = DBUS_TYPE_UINT32;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_INT64))
- ArgType = DBUS_TYPE_INT64;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT64))
- ArgType = DBUS_TYPE_UINT64;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_DOUBLE))
- ArgType = DBUS_TYPE_DOUBLE;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_BYTE))
- ArgType = DBUS_TYPE_BYTE;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_BOOLEAN))
- ArgType = DBUS_TYPE_BOOLEAN;
- else if (!strcmp(Args, DBUS_PARAM_TYPE_OBJECT_PATH))
- ArgType = DBUS_TYPE_OBJECT_PATH;
- else {
- ERR("Error!!! Unknown Argument Type \"%s\"", Args);
-
- return -1;
- }
-
- return ArgType;
-}
-
-static int __netconfig_dbus_append_argument(DBusMessageIter *iter, int ArgType,
- const char *Value)
-{
- double Double = 0;
- unsigned char ByteValue = 0;
- dbus_bool_t booleanvalue = 0;
- dbus_uint16_t Uint16 = 0;
- dbus_int16_t Int16 = 0;
- dbus_uint32_t Uint32 = 0;
- dbus_int32_t Int32 = 0;
-
- switch (ArgType) {
- case DBUS_TYPE_BYTE:
- ByteValue = strtoul(Value, NULL, 0);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &ByteValue);
- break;
-
- case DBUS_TYPE_DOUBLE:
- Double = strtod(Value, NULL);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_DOUBLE, &Double);
- break;
-
- case DBUS_TYPE_INT16:
- Int16 = strtol(Value, NULL, 0);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_INT16, &Int16);
- break;
-
- case DBUS_TYPE_UINT16:
- Uint16 = strtoul(Value, NULL, 0);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &Uint16);
- break;
-
- case DBUS_TYPE_INT32:
- Int32 = strtol(Value, NULL, 0);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &Int32);
- break;
-
- case DBUS_TYPE_UINT32:
- Uint32 = strtoul(Value, NULL, 0);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &Uint32);
- break;
-
- case DBUS_TYPE_STRING:
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &Value);
- break;
-
- case DBUS_TYPE_OBJECT_PATH:
- dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &Value);
- break;
-
- case DBUS_TYPE_BOOLEAN:
- if (strcmp(Value, "true") == 0) {
- booleanvalue = TRUE;
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &booleanvalue);
- } else if (strcmp(Value, "false") == 0) {
- booleanvalue = FALSE;
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &booleanvalue);
- } else {
- ERR("Error!!! Expected \"true\" or \"false\" instead of \"%s\"", Value);
-
- return -1;
- }
- break;
-
- default:
- ERR("Error!!! Unsupported data ArgType %c", (char)ArgType);
-
- return -1;
- }
-
- return 0;
-}
-
-static int __netconfig_dbus_append_array(DBusMessageIter *iter, int ArgType,
- const char *Value)
-{
- const char *Val = NULL;
- char *DupValue = strdup(Value);
- Val = strtok(DupValue, ",");
-
- while (Val != NULL) {
- if (__netconfig_dbus_append_argument(iter, ArgType, Val) != 0) {
- g_free(DupValue);
- DupValue = NULL;
-
- return -1;
- }
-
- Val = strtok(NULL, ",");
- }
-
- g_free(DupValue);
- DupValue = NULL;
- return 0;
-}
-
-static int __netconfig_dbus_append_dict(DBusMessageIter *iter, int KeyType,
- int ValueType, const char *Value)
-{
- const char *Val = NULL;
- char *DupValue = strdup(Value);
- Val = strtok(DupValue, ",");
-
- while (Val != NULL) {
- DBusMessageIter SubIter;
- dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY,
- NULL, &SubIter);
-
- if (__netconfig_dbus_append_argument(&SubIter, KeyType, Val) != 0) {
- ERR("Error!!! network_append_argument() failed");
- g_free(DupValue);
- DupValue = NULL;
- return -1;
- }
-
- Val = strtok(NULL, ",");
- if (Val == NULL) {
- ERR("Error!!! Mal-formed dictionary data");
- g_free(DupValue);
- DupValue = NULL;
- return -1;
- }
-
- if (__netconfig_dbus_append_argument(&SubIter, ValueType, Val) != 0) {
- ERR("Error!!! network_append_argument() failed");
- g_free(DupValue);
- DupValue = NULL;
- return -1;
- }
-
- dbus_message_iter_close_container(iter, &SubIter);
-
- Val = strtok(NULL, ",");
- }
-
- g_free(DupValue);
- DupValue = NULL;
- return 0;
-}
-
-char *netconfig_dbus_get_string(DBusMessage * msg)
-{
- DBusMessageIter args;
- char *sigvalue = NULL;
-
- /** read these parameters */
- if (!dbus_message_iter_init(msg, &args))
- DBG("Message does not have parameters");
- else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args))
- DBG("Argument is not string");
- else
- dbus_message_iter_get_basic(&args, &sigvalue);
-
- return sigvalue;
-}
-
-DBusMessage *netconfig_dbus_send_request(const char *destination, char *param_array[])
-{
- DBusConnection *connection = NULL;
- DBusError error;
- DBusMessage *message = NULL;
- char *RequestMethod = NULL;
- int i = 0;
- const char *path = NULL;
- const char *name = NULL;
- int param_count = 0;
- DBusMessageIter iter;
- DBusMessage *reply = NULL;
-
- DBG("Send DBus request to %s", destination);
-
- for (param_count = 0; param_array[param_count] != NULL;
- param_count++)
- DBG("[%s]", param_array[param_count]);
-
- DBG("Total Arguments [%d]", param_count);
- path = param_array[i++];
-
- /** 0th is path */
- name = param_array[i++];/** 1st is request name */
- if ((strlen(path) == 0) || (strlen(name) == 0)) {
- ERR("Error!!! Invalid parameters passed path [%s], request name [%s]",
- path, name);
-
- goto end_error;
- }
-
- dbus_error_init(&error);
-
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- ERR("Error!!! Failed to get system DBus, error [%s]",
- error.message);
- dbus_error_free(&error);
-
- goto end_error;
- }
-
- RequestMethod = strrchr(name, '.');
- if (RequestMethod == NULL) {
- ERR("Error!!! Invalid method in \"%s\"", name);
-
- goto end_error;
- }
-
- *RequestMethod = '\0';
- message = dbus_message_new_method_call(NULL, path, name,
- RequestMethod + 1);
- if (message == NULL) {
- ERR("Error!!! dbus_message_new_method_call() failed");
-
- goto end_error;
- }
-
- if (destination && !dbus_message_set_destination(message, destination)) {
- ERR("Error!!! dbus_message_set_destination() failed");
-
- goto end_error;
- }
-
- dbus_message_iter_init_append(message, &iter);
-
- /** Two args name and path already extracted, so i == 2 */
- while (i < param_count) {
- char *Args = NULL;
- char *Ch = NULL;
- int ArgType = 0;
- int SecondaryType = 0;
- int ContainerType = 0;
- DBusMessageIter *TargetIter = NULL;
- DBusMessageIter ContainerIter;
- ArgType = DBUS_TYPE_INVALID;
-
- Args = param_array[i++];
- Ch = strchr(Args, ':');
- if (Ch == NULL) {
- ERR("Error!!! Invalid data format[\"%s\"]", Args);
-
- goto end_error;
- }
-
- *(Ch++) = 0;
- if (strcmp(Args, "variant") == 0)
- ContainerType = DBUS_TYPE_VARIANT;
- else if (strcmp(Args, "array") == 0)
- ContainerType = DBUS_TYPE_ARRAY;
- else if (strcmp(Args, "dict") == 0)
- ContainerType = DBUS_TYPE_DICT_ENTRY;
- else
- ContainerType = DBUS_TYPE_INVALID;
-
- if (ContainerType != DBUS_TYPE_INVALID) {
- Args = Ch;
- Ch = strchr(Args, ':');
- if (Ch == NULL) {
- ERR("Error!!! Invalid data format[\"%s\"]", Args);
-
- goto end_error;
- }
-
- *(Ch++) = 0;
- }
-
- if (Args[0] == 0)
- ArgType = DBUS_TYPE_STRING;
- else {
- ArgType = __neconfig_dbus_datatype_from_stringname(Args);
-
- if (ArgType == -1) {
- ERR("Error!!! Unknown data type");
-
- goto end_error;
- }
- }
-
- if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
- char Signature[5] = "";
- Args = Ch;
- Ch = strchr(Ch, ':');
- if (Ch == NULL) {
- ERR("Error!!! Invalid data format[\"%s\"]", Args);
-
- goto end_error;
- }
-
- *(Ch++) = 0;
- SecondaryType = __neconfig_dbus_datatype_from_stringname(Args);
- if (SecondaryType == -1) {
- ERR("Error!!! Unknown data type");
-
- goto end_error;
- }
-
- Signature[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
- Signature[1] = ArgType;
- Signature[2] = SecondaryType;
- Signature[3] = DBUS_DICT_ENTRY_END_CHAR;
- Signature[4] = '\0';
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- Signature, &ContainerIter);
-
- TargetIter = &ContainerIter;
- } else if (ContainerType != DBUS_TYPE_INVALID) {
- char Signature[2] = "";
- Signature[0] = ArgType;
- Signature[1] = '\0';
-
- dbus_message_iter_open_container(&iter, ContainerType,
- Signature, &ContainerIter);
-
- TargetIter = &ContainerIter;
- } else
- TargetIter = &iter;
-
- if (ContainerType == DBUS_TYPE_ARRAY) {
- if (__netconfig_dbus_append_array(TargetIter, ArgType, Ch) != 0) {
- ERR("Error!!! network_append_array() failed");
-
- goto end_error;
- }
- } else if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
- if (__netconfig_dbus_append_dict(TargetIter, ArgType, SecondaryType, Ch) != 0) {
- ERR("Error!!! network_append_dict() failed");
-
- goto end_error;
- }
- } else {
- if (__netconfig_dbus_append_argument(TargetIter, ArgType, Ch) != 0) {
- ERR("Error!!! network_append_array() failed");
-
- goto end_error;
- }
- }
-
- if (ContainerType != DBUS_TYPE_INVALID) {
- dbus_message_iter_close_container(&iter, &ContainerIter);
- }
- }
-
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
-
- if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]",
- error.name, error.message);
-
- dbus_error_free(&error);
-
- goto end_error;
- }
- }
-
- dbus_message_unref(message);
- dbus_connection_unref(connection);
-
- return reply;
-
-end_error:
-
- if (message != NULL)
- dbus_message_unref(message);
- if (connection != NULL)
- dbus_connection_unref(connection);
-
- return NULL;
-}
-
-DBusMessage *netconfig_invoke_dbus_method(const char *dest, DBusConnection *connection,
- const char *path, const char *interface_name, const char *method)
-{
- DBusError error;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
-
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Error!!! Failed to GetProperties");
- return NULL;
- }
-
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
-
- if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
- error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Error!!! Failed to get properties");
-
- dbus_message_unref(message);
-
- return NULL;
- }
-
- dbus_message_unref(message);
-
- return reply;
-}
-
-void setup_dbus(gpointer data, gpointer user_data)
-{
- struct dbus_input_arguments *args;
- DBusMessageIter *iter;
-
- if (data != NULL && user_data != NULL) {
- args = (struct dbus_input_arguments *)data;
- iter = (DBusMessageIter *) user_data;
-
- dbus_message_iter_append_basic(iter, args->type,
- &(args->data));
- }
-}
-
-DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
- DBusConnection *connection,
- const char *path, const char *interface_name,
- const char *method, GList *args)
-{
- DBusError error;
- DBusMessageIter iter;
- DBusMessage *reply = NULL;
- DBusMessage *message = NULL;
-
- message = dbus_message_new_method_call(dest, path, interface_name, method);
- if (message == NULL) {
- ERR("Error!!! DBus method call fail");
- return NULL;
- }
-
- dbus_message_iter_init_append(message, &iter);
-
- if (args != NULL)
- g_list_foreach(args, setup_dbus, (gpointer) &iter);
-
- dbus_error_init(&error);
-
- reply = dbus_connection_send_with_reply_and_block(connection, message,
- NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
-
- if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
- ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
- error.name, error.message);
-
- dbus_error_free(&error);
- } else
- ERR("Error!!! Failed to get properties");
-
- dbus_message_unref(message);
-
- return NULL;
- }
-
- dbus_message_unref(message);
-
- return reply;
-}
-
-char *netconfig_wifi_get_connected_service_name(DBusMessage *message)
-{
- int is_connected = 0;
- char *essid_name = NULL;
- DBusMessageIter iter, array;
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, string;
- const char *key = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- if (g_str_equal(key, "State") == TRUE && is_connected == 0) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
-
- if (g_str_equal(key, "ready") == TRUE || g_str_equal(key, "online") == TRUE)
- is_connected = 1;
- }
- } else if (g_str_equal(key, "Name") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &string);
-
- if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string, &key);
-
- essid_name = (char *)g_strdup(key);
- }
- }
-
- dbus_message_iter_next(&array);
- }
-
- if (is_connected == 1 && essid_name != NULL)
- return essid_name;
-
- if (essid_name != NULL)
- g_free(essid_name);
-
- return NULL;
-}
-
-void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
- netconfig_dbus_result_type result_type, void *data)
-{
- unsigned char *bgscan_mode = NULL;
- static dbus_bool_t default_tech_flag = FALSE;
- char *default_tech = NULL;
-
- if (result_type == NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE)
- bgscan_mode = (unsigned char *)data;
- else if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY)
- default_tech = (char *)data;
-
- do {
- int ArgType = dbus_message_iter_get_arg_type(iter);
-
- if (ArgType == DBUS_TYPE_INVALID)
- break;
-
- switch (ArgType) {
- case DBUS_TYPE_BYTE:
- {
- unsigned char Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
-
- *bgscan_mode = Value;
- INFO("BG scan mode: %d, %d", *bgscan_mode, Value);
- break;
- }
-
- case DBUS_TYPE_STRING:
- {
- char *Value = NULL;
-
- dbus_message_iter_get_basic(iter, &Value);
-
- INFO("result type: %d, string: %s", result_type, Value);
- if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY) {
- if (strcmp(Value, "DefaultTechnology") == 0) {
- default_tech_flag = TRUE;
- } else {
- if (default_tech_flag == TRUE) {
- sprintf(default_tech, "%s", Value);
- INFO("default technology: %s", default_tech);
- default_tech_flag = FALSE;
- }
- }
- }
- break;
- }
-
- case DBUS_TYPE_SIGNATURE:
- {
- char *Value = NULL;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_OBJECT_PATH:
- {
- char *Value = NULL;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_INT16:
- {
- dbus_int16_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_UINT16:
- {
- dbus_uint16_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_INT32:
- {
- dbus_int32_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_UINT32:
- {
- dbus_uint32_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_INT64:
- {
- dbus_int64_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_UINT64:
- {
- dbus_uint64_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_DOUBLE:
- {
- double Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_BOOLEAN:
- {
- dbus_bool_t Value = 0;
-
- dbus_message_iter_get_basic(iter, &Value);
- break;
- }
-
- case DBUS_TYPE_VARIANT:
- {
- DBusMessageIter SubIter;
-
- dbus_message_iter_recurse(iter, &SubIter);
- netconfig_dbus_parse_recursive(&SubIter,
- result_type, data);
- break;
- }
-
- case DBUS_TYPE_ARRAY:
- {
- int CurrentType = 0;
- DBusMessageIter SubIter;
-
- dbus_message_iter_recurse(iter, &SubIter);
- CurrentType = dbus_message_iter_get_arg_type(&SubIter);
-
- while (CurrentType != DBUS_TYPE_INVALID) {
- netconfig_dbus_parse_recursive(&SubIter,
- result_type, data);
-
- dbus_message_iter_next(&SubIter);
- CurrentType = dbus_message_iter_get_arg_type(&SubIter);
- }
- break;
- }
-
- case DBUS_TYPE_DICT_ENTRY:
- {
- DBusMessageIter SubIter;
-
- dbus_message_iter_recurse(iter, &SubIter);
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
-
- dbus_message_iter_next(&SubIter);
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
- break;
- }
-
- case DBUS_TYPE_STRUCT:
- {
- int CurrentType = 0;
- DBusMessageIter SubIter;
-
- dbus_message_iter_recurse(iter, &SubIter);
-
- while ((CurrentType = dbus_message_iter_get_arg_type(&SubIter))
- != DBUS_TYPE_INVALID) {
- netconfig_dbus_parse_recursive(&SubIter, result_type, data);
-
- dbus_message_iter_next(&SubIter);
- }
- break;
- }
-
- default:
- ERR("Error!!! Invalid Argument Type [%c]", ArgType);
- }
- } while (dbus_message_iter_next(iter));
-}
-
-DBusGConnection *netconfig_setup_dbus(void)
-{
- DBusGConnection* connection = NULL;
- GError *error = NULL;
- DBusGProxy *proxy;
- guint rv = 0;
-
- connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- ERR("Fail to get DBus(%s)", error->message);
- return connection;
- }
-
- INFO("Successfully get system DBus connection(%p)", connection);
-
- proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call(proxy, "RequestName", &error,
- G_TYPE_STRING, NETCONFIG_SERVICE, G_TYPE_UINT, 0,
- G_TYPE_INVALID, G_TYPE_UINT, &rv,
- G_TYPE_INVALID)) {
- ERR("Failed to acquire service(%s) error(%s)",
- NETCONFIG_SERVICE, error->message);
-
- dbus_g_connection_unref(connection);
-
- return NULL;
- }
-
- if (rv != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- ERR("Service name is already in use");
-
- dbus_g_connection_unref(connection);
-
- return NULL;
- }
-
- return connection;
-}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "log.h"
+#include "netdbus.h"
+#include "netconfig.h"
+
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+
+#define DBUS_PARAM_TYPE_STRING "string"
+#define DBUS_PARAM_TYPE_INT16 "int16"
+#define DBUS_PARAM_TYPE_UINT16 "uint16"
+#define DBUS_PARAM_TYPE_INT32 "int32"
+#define DBUS_PARAM_TYPE_UINT32 "uint32"
+#define DBUS_PARAM_TYPE_INT64 "int64"
+#define DBUS_PARAM_TYPE_UINT64 "uint64"
+#define DBUS_PARAM_TYPE_DOUBLE "double"
+#define DBUS_PARAM_TYPE_BYTE "byte"
+#define DBUS_PARAM_TYPE_BOOLEAN "boolean"
+#define DBUS_PARAM_TYPE_OBJECT_PATH "objpath"
+#define DBUS_PARAM_TYPE_VARIANT "variant"
+
+
+static int __netconfig_dbus_append_param(DBusMessage *message, char *param_array[])
+{
+ int count = 0;
+ dbus_uint32_t uint32 = 0;
+ DBusMessageIter iter;
+ DBusMessageIter container_iter;
+ char *args = NULL;
+ char *ch = NULL;
+
+ if (param_array == NULL)
+ return TRUE;
+
+ dbus_message_iter_init_append(message, &iter);
+
+ while (param_array[count] != NULL) {
+ args = param_array[count];
+ DBG("parameter %d - [%s]", count, param_array[count]);
+
+ ch = strchr(args, ':');
+ if (ch == NULL) {
+ ERR("Error!!! Invalid parameter[\"%s\"]\n", args);
+ return FALSE;
+ }
+ *ch = 0; ch++;
+
+ if (strcmp(args, DBUS_PARAM_TYPE_STRING) == 0) {
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ch);
+ } else if (strcmp(args, DBUS_PARAM_TYPE_UINT32) == 0) {
+ uint32 = strtoul(ch, NULL, 0);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &uint32);
+ } else if (strcmp(args, DBUS_PARAM_TYPE_VARIANT) == 0) {
+ args = ch;
+ ch = strchr(args, ':');
+ if (ch == NULL) {
+ ERR("Error!!! Invalid data format[\"%s\"]\n", args);
+ return FALSE;
+ }
+ *ch = 0; ch++;
+
+ if (strcmp(args, DBUS_PARAM_TYPE_STRING) == 0) {
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_STRING_AS_STRING, &container_iter);
+ dbus_message_iter_append_basic(&container_iter, DBUS_TYPE_STRING, &ch);
+ dbus_message_iter_close_container(&iter, &container_iter);
+ } else {
+ ERR("Error!!! Not supported data format[\"%s\"]\n", args);
+ return FALSE;
+ }
+ } else {
+ ERR("Error!!! Not supported data format[\"%s\"]\n", args);
+ return FALSE;
+ }
+
+ count++;
+ }
+
+ return TRUE;
+}
+
+char *netconfig_dbus_get_string(DBusMessage * msg)
+{
+ DBusMessageIter args;
+ char *sigvalue = NULL;
+
+ /** read these parameters */
+ if (!dbus_message_iter_init(msg, &args))
+ DBG("Message does not have parameters");
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args))
+ DBG("Argument is not string");
+ else
+ dbus_message_iter_get_basic(&args, &sigvalue);
+
+ return sigvalue;
+}
+
+DBusMessage *netconfig_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method, char *param_array[])
+{
+ DBusError error;
+ DBusConnection *conn = NULL;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+
+ DBG("[DBUS Sync] %s %s %s", interface_name, method, path);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Failed to get system bus");
+ return NULL;
+ }
+
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Error!!! Failed to GetProperties");
+ dbus_connection_unref(conn);
+ return NULL;
+ }
+
+ if (__netconfig_dbus_append_param(message, param_array) == FALSE) {
+ ERR("Error!!! __netconfig_dbus_append_param() failed\n");
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+ return NULL;
+ }
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
+ error.name, error.message);
+
+ dbus_error_free(&error);
+ } else
+ ERR("Error!!! Failed to get properties");
+
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+
+ return NULL;
+ }
+
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+
+ return reply;
+}
+
+char *netconfig_wifi_get_connected_service_name(DBusMessage *message)
+{
+ int is_connected = 0;
+ char *essid_name = NULL;
+ DBusMessageIter iter, array;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, string;
+ const char *key = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (g_str_equal(key, "State") == TRUE && is_connected == 0) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &string);
+
+ if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string, &key);
+
+ if (g_str_equal(key, "ready") == TRUE || g_str_equal(key, "online") == TRUE)
+ is_connected = 1;
+ }
+ } else if (g_str_equal(key, "Name") == TRUE) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &string);
+
+ if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string, &key);
+
+ essid_name = (char *)g_strdup(key);
+ }
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ if (is_connected == 1 && essid_name != NULL)
+ return essid_name;
+
+ if (essid_name != NULL)
+ g_free(essid_name);
+
+ return NULL;
+}
+
+void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
+ netconfig_dbus_result_type result_type, void *data)
+{
+ unsigned char *bgscan_mode = NULL;
+ static dbus_bool_t default_tech_flag = FALSE;
+ char *default_tech = NULL;
+
+ if (result_type == NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE)
+ bgscan_mode = (unsigned char *)data;
+ else if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY)
+ default_tech = (char *)data;
+
+ do {
+ int ArgType = dbus_message_iter_get_arg_type(iter);
+
+ if (ArgType == DBUS_TYPE_INVALID)
+ break;
+
+ switch (ArgType) {
+ case DBUS_TYPE_BYTE:
+ {
+ unsigned char Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+
+ *bgscan_mode = Value;
+ INFO("BG scan mode: %d, %d", *bgscan_mode, Value);
+ break;
+ }
+
+ case DBUS_TYPE_STRING:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+
+ INFO("result type: %d, string: %s", result_type, Value);
+ if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY) {
+ if (strcmp(Value, "DefaultTechnology") == 0) {
+ default_tech_flag = TRUE;
+ } else {
+ if (default_tech_flag == TRUE) {
+ sprintf(default_tech, "%s", Value);
+ INFO("default technology: %s", default_tech);
+ default_tech_flag = FALSE;
+ }
+ }
+ }
+ break;
+ }
+
+ case DBUS_TYPE_SIGNATURE:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_OBJECT_PATH:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT16:
+ {
+ dbus_int16_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT16:
+ {
+ dbus_uint16_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT32:
+ {
+ dbus_int32_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT32:
+ {
+ dbus_uint32_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT64:
+ {
+ dbus_int64_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_DOUBLE:
+ {
+ double Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_BOOLEAN:
+ {
+ dbus_bool_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_VARIANT:
+ {
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ netconfig_dbus_parse_recursive(&SubIter,
+ result_type, data);
+ break;
+ }
+
+ case DBUS_TYPE_ARRAY:
+ {
+ int CurrentType = 0;
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ CurrentType = dbus_message_iter_get_arg_type(&SubIter);
+
+ while (CurrentType != DBUS_TYPE_INVALID) {
+ netconfig_dbus_parse_recursive(&SubIter,
+ result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ CurrentType = dbus_message_iter_get_arg_type(&SubIter);
+ }
+ break;
+ }
+
+ case DBUS_TYPE_DICT_ENTRY:
+ {
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+ break;
+ }
+
+ case DBUS_TYPE_STRUCT:
+ {
+ int CurrentType = 0;
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+
+ while ((CurrentType = dbus_message_iter_get_arg_type(&SubIter))
+ != DBUS_TYPE_INVALID) {
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ }
+ break;
+ }
+
+ default:
+ ERR("Error!!! Invalid Argument Type [%c]", ArgType);
+ }
+ } while (dbus_message_iter_next(iter));
+}
+
+DBusGConnection *netconfig_setup_dbus(void)
+{
+ DBusGConnection* connection = NULL;
+ GError *error = NULL;
+ DBusGProxy *proxy;
+ guint rv = 0;
+
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Fail to get DBus(%s)", error->message);
+ return connection;
+ }
+
+ INFO("Successfully get system DBus connection(%p)", connection);
+
+ proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ if (!dbus_g_proxy_call(proxy, "RequestName", &error,
+ G_TYPE_STRING, NETCONFIG_SERVICE, G_TYPE_UINT, 0,
+ G_TYPE_INVALID, G_TYPE_UINT, &rv,
+ G_TYPE_INVALID)) {
+ ERR("Failed to acquire service(%s) error(%s)",
+ NETCONFIG_SERVICE, error->message);
+
+ dbus_g_connection_unref(connection);
+
+ return NULL;
+ }
+
+ if (rv != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ ERR("Service name is already in use");
+
+ dbus_g_connection_unref(connection);
+
+ return NULL;
+ }
+
+ return connection;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 "log.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+
+static void setup_dbus_args(gpointer data, gpointer user_data)
+{
+ struct dbus_input_arguments *args;
+ DBusMessageIter *iter;
+
+ if (data != NULL && user_data != NULL) {
+ args = (struct dbus_input_arguments *)data;
+ iter = (DBusMessageIter *) user_data;
+
+ dbus_message_iter_append_basic(iter, args->type,
+ &(args->data));
+ }
+}
+
+static GList *setup_input_args(GList *list,
+ struct dbus_input_arguments *items)
+{
+ struct dbus_input_arguments *iter = items;
+
+ if (iter == NULL)
+ return NULL;
+
+ while (iter->data) {
+ list = g_list_append(list, iter);
+ iter++;
+ }
+
+ return list;
+}
+
+gboolean netconfig_wifi_get_ifname(char **ifname)
+{
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter;
+ int MessageType = 0;
+ char *ptr = (char *)*ifname;
+ const char *temp = NULL;
+
+ char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
+ char *path_ptr = &object_path[0];
+
+ GList *input_args = NULL;
+ struct dbus_input_arguments args[] = {
+ {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE ".Interface"},
+ {DBUS_TYPE_STRING, "Ifname"},
+ {0, NULL}
+ };
+
+ if (ptr == NULL)
+ return FALSE;
+
+ if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return FALSE;
+ }
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Error!!! Fail to get system DBus");
+ return FALSE;
+ }
+
+ input_args = setup_input_args(input_args, args);
+
+ message = netconfig_supplicant_invoke_dbus_method(
+ SUPPLICANT_SERVICE, connection,
+ path_ptr,
+ SUPPLICANT_GLOBAL_INTERFACE, "Get",
+ input_args);
+
+ g_list_free(input_args);
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto error;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_ptr = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received %s", err_ptr);
+ goto error;
+ }
+
+ dbus_message_iter_init(message, &iter);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter))
+ == DBUS_TYPE_VARIANT) {
+ DBusMessageIter string_type;
+ dbus_message_iter_recurse(&iter, &string_type);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&string_type))
+ == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string_type, &temp);
+ } else
+ goto error;
+ } else
+ goto error;
+
+ g_strlcpy(ptr, temp, 16);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return TRUE;
+
+error:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (connection != NULL)
+ dbus_connection_unref(connection);
+
+ return FALSE;
+}
+
+gboolean netconfig_wifi_get_supplicant_interface(char **path)
+{
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter;
+ int MessageType = 0;
+ char *ptr = (char *)*path;
+ const char *temp = NULL;
+
+ GList *input_args = NULL;
+ struct dbus_input_arguments args[] = {
+ {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE},
+ {DBUS_TYPE_STRING, "Interfaces"},
+ {0, NULL}
+ };
+
+ if (ptr == NULL)
+ return FALSE;
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Error!!! Fail to get system DBus");
+ return FALSE;
+ }
+
+ input_args = setup_input_args(input_args, args);
+
+ message = netconfig_supplicant_invoke_dbus_method(
+ SUPPLICANT_SERVICE, connection,
+ SUPPLICANT_PATH,
+ SUPPLICANT_GLOBAL_INTERFACE, "Get",
+ input_args);
+
+ g_list_free(input_args);
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto error;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_msg = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received %s", err_msg);
+ goto error;
+ }
+
+ dbus_message_iter_init(message, &iter);
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter))
+ == DBUS_TYPE_VARIANT) {
+ DBusMessageIter array;
+ dbus_message_iter_recurse(&iter, &array);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&array))
+ == DBUS_TYPE_ARRAY) {
+ DBusMessageIter object_path;
+ dbus_message_iter_recurse(&array, &object_path);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&object_path))
+ == DBUS_TYPE_OBJECT_PATH)
+ dbus_message_iter_get_basic(&object_path, &temp);
+ else
+ goto error;
+ } else
+ goto error;
+ } else
+ goto error;
+
+ g_strlcpy(ptr, temp, DBUS_PATH_MAX_BUFLEN);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return TRUE;
+
+error:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (connection != NULL)
+ dbus_connection_unref(connection);
+
+ return FALSE;
+}
+
+DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
+ DBusConnection *connection,
+ const char *path, const char *interface_name,
+ const char *method, GList *args)
+{
+ DBusError error;
+ DBusMessageIter iter;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Error!!! DBus method call fail");
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(message, &iter);
+
+ if (args != NULL)
+ g_list_foreach(args, setup_dbus_args, (gpointer) &iter);
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
+ error.name, error.message);
+
+ dbus_error_free(&error);
+ } else
+ ERR("Error!!! Failed to get properties");
+
+ dbus_message_unref(message);
+
+ return NULL;
+ }
+
+ dbus_message_unref(message);
+
+ return reply;
+}
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Danny JS Seo <S.Seo@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 <stdlib.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <sys/utsname.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include "log.h"
-#include "emulator.h"
-
-static gboolean netconfig_is_emulated = FALSE;
-
-static gboolean __netconfig_emulator_test_emulation_env(void)
-{
- struct utsname buf;
- const char *EMUL_UTSNAME_MACHINE_SUFFIX = "emulated";
-
- DBG("Test emulation environment");
-
- uname(&buf);
-
- if (buf.machine != NULL &&
- g_str_has_suffix(buf.machine, EMUL_UTSNAME_MACHINE_SUFFIX) == TRUE)
- return TRUE;
-
- return FALSE;
-}
-
-static void __netconfig_emulator_set_ip(void)
-{
- const int BUF_LEN_MAX = 255;
- const char EMUL_IFNAME[] = "eth0";
- char ip[BUF_LEN_MAX];
- int sockfd = 0;
- struct ifreq ifr;
-
- if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
- ERR("Failed to open socket");
- return;
- }
-
- memset(&ifr, 0, sizeof(struct ifreq));
- g_strlcpy((char*)&ifr.ifr_name, EMUL_IFNAME, sizeof(EMUL_IFNAME));
-
- if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) {
- ERR("Error getting IP address");
-
- close(sockfd);
- return;
- }
-
- g_strlcpy(ip, (char*)inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr), BUF_LEN_MAX);
-
- vconf_set_str(VCONFKEY_NETWORK_IP, ip);
-
- close(sockfd);
-}
-
-static void __netconfig_emulator_set_proxy(void)
-{
- const char HTTP_PROXY[] = "http_proxy";
- char *proxy = NULL;
-
- proxy = getenv(HTTP_PROXY);
- DBG("Get system proxy: %s", proxy);
-
- if(proxy != NULL)
- vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy);
-}
-
-static void __netconfig_emulator_set_network_state(void)
-{
- vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
- vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
- vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_NORMAL_CONNECTED);
-}
-
-static void __netconfig_emulator_config_emul_env(void)
-{
- __netconfig_emulator_set_ip();
- __netconfig_emulator_set_proxy();
- __netconfig_emulator_set_network_state();
-}
-
-gboolean netconfig_emulator_is_emulated(void)
-{
- return netconfig_is_emulated;
-}
-
-void netconfig_emulator_test_and_start(void)
-{
- netconfig_is_emulated = __netconfig_emulator_test_emulation_env();
-
- DBG("Emulation environment tested: %s", netconfig_is_emulated ? "It's emulated" : "Not emulated");
-
- if (netconfig_is_emulated == TRUE)
- __netconfig_emulator_config_emul_env();
-}
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include <unistd.h>
#include "log.h"
-#include "dbus.h"
#include "wifi.h"
#include "emulator.h"
+#include "netdbus.h"
#include "network-state.h"
+#include "network-statistics.h"
#include "signal-handler.h"
static GMainLoop *main_loop = NULL;
if (netconfig_wifi_create_and_init(connection) == NULL)
return -1;
+ if (netconfig_network_statistics_create_and_init(connection) == NULL)
+ return -1;
+
/* If its environment uses Emulator, network configuration is set by emulator default */
netconfig_emulator_test_and_start();
g_main_loop_run(main_loop);
+ netconfig_wifi_state_notifier_cleanup();
netconfig_deregister_signal();
return 0;
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
b = bundle_create();
bundle_add(b, "_SYSPOPUP_TITLE_", "Cellular connection popup");
+ bundle_add(b, "_SYSPOPUP_TYPE_", "notification");
bundle_add(b, "_SYSPOPUP_CONTENT_", "connected");
DBG("Launch 3G alert network popup");
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netsupplicant.h"
+#include "wifi-indicator.h"
+#include "network-statistics.h"
+
+#include "netconfig-iface-network-statistics-glue.h"
+
+#define NETCONFIG_NETWORK_STATISTICS_PATH "/net/netconfig/network_statistics"
+
+#define NETCONFIG_PROCDEVFILE "/proc/net/dev"
+
+#define PROP_DEFAULT FALSE
+#define PROP_DEFAULT_STR NULL
+
+enum {
+ PROP_O,
+ PROP_NETWORK_STATISTICS_CONN,
+ PROP_NETWORK_STATISTICS_PATH,
+};
+
+struct NetconfigNetworkStatisticsClass {
+ GObjectClass parent;
+};
+
+struct NetconfigNetworkStatistics {
+ GObject parent;
+
+ DBusGConnection *conn;
+ gchar *path;
+};
+
+G_DEFINE_TYPE(NetconfigNetworkStatistics, netconfig_network_statistics, G_TYPE_OBJECT);
+
+static void __netconfig_network_statistics_gobject_get_property(GObject *object,
+ guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ return;
+}
+
+static void __netconfig_network_statistics_gobject_set_property(GObject *object,
+ guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ NetconfigNetworkStatistics *network_statistics = NETCONFIG_NETWORK_STATISTICS(object);
+
+ switch (prop_id) {
+ case PROP_NETWORK_STATISTICS_CONN:
+ {
+ network_statistics->conn = g_value_get_boxed(value);
+ INFO("network_statistics(%p) set conn(%p)", network_statistics, network_statistics->conn);
+ break;
+ }
+
+ case PROP_NETWORK_STATISTICS_PATH:
+ {
+ if (network_statistics->path)
+ g_free(network_statistics->path);
+
+ network_statistics->path = g_value_dup_string(value);
+ INFO("network_statistics(%p) path(%s)", network_statistics, network_statistics->path);
+
+ break;
+ }
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void netconfig_network_statistics_init(NetconfigNetworkStatistics *network_statistics)
+{
+ DBG("network_statistics initialize");
+
+ network_statistics->conn = NULL;
+ network_statistics->path = g_strdup(PROP_DEFAULT_STR);
+}
+
+static void netconfig_network_statistics_class_init(NetconfigNetworkStatisticsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ DBG("class initialize");
+
+ object_class->get_property = __netconfig_network_statistics_gobject_get_property;
+ object_class->set_property = __netconfig_network_statistics_gobject_set_property;
+
+ /* DBus register */
+ dbus_g_object_type_install_info(NETCONFIG_TYPE_NETWORK_STATISTICS,
+ &dbus_glib_netconfig_iface_network_statistics_object_info);
+
+ /* property */
+ g_object_class_install_property(object_class, PROP_NETWORK_STATISTICS_CONN,
+ g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
+ DBUS_TYPE_G_CONNECTION,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property(object_class, PROP_NETWORK_STATISTICS_PATH,
+ g_param_spec_string("path", "Path", "Object path",
+ PROP_DEFAULT_STR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+
+static gboolean __netconfig_wifi_get_bytes_statistics(guint64 *tx, guint64 *rx)
+{
+ gboolean ret = FALSE;
+ FILE *fp;
+ gchar buf[1024];
+ gchar ifname[16] = { 0, };
+ gchar *p_ifname = NULL, *p_entry = NULL;
+ gchar *ifname_ptr = &ifname[0];
+
+ *tx = 0;
+ *rx = 0;
+
+ if (netconfig_wifi_get_ifname(&ifname_ptr) != TRUE) {
+ DBG("Fail to get Wi-Fi ifname from wpa_supplicant: %s", ifname_ptr);
+ return FALSE;
+ }
+
+ fp = fopen(NETCONFIG_PROCDEVFILE, "r");
+ if (fp == NULL) {
+ ERR("Failed to open file %s", NETCONFIG_PROCDEVFILE);
+ return FALSE;
+ }
+
+ /* skip the first and second line */
+ if (fgets(buf, sizeof(buf), fp) == NULL ||
+ fgets(buf, sizeof(buf), fp) == NULL)
+ goto endline;
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ guint64 llval;
+ gulong lval;
+
+ p_ifname = buf;
+ while (*p_ifname == ' ') p_ifname++;
+ p_entry = strchr(p_ifname, ':');
+ *p_entry++ = '\0';
+
+ if (g_str_equal(p_ifname, ifname) != TRUE)
+ continue;
+
+ /* read interface statistics */
+ sscanf(p_entry,
+ "%llu %llu %lu %lu %lu %lu %lu %lu "
+ "%llu %llu %lu %lu %lu %lu %lu %lu",
+ rx, /* rx bytes */
+ &llval, /* rx packet */
+ &lval, /* rx errors */
+ &lval, /* rx dropped */
+ &lval, /* rx fifo errors */
+ &lval, /* rx frame errors */
+ &lval, /* rx compressed */
+ &lval, /* rx multicast */
+
+ tx, /* tx bytes */
+ &llval, /* tx packet */
+ &lval, /* tx errors */
+ &lval, /* tx dropped */
+ &lval, /* tx fifo errors */
+ &lval, /* collisions */
+ &lval, /* tx carrier errors */
+ &lval /* tx compressed */
+ );
+
+ ret = TRUE;
+ break;
+ }
+
+endline:
+ fclose(fp);
+ return ret;
+}
+
+gboolean netconfig_iface_network_statistics_get_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+ guint64 tx_bytes = 0;
+ int val = 0;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, &val);
+ tx_bytes = (guint64)val;
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *total_bytes = (guint64)tx + (guint64)tx_bytes;
+ else
+ *total_bytes = (guint64)tx_bytes;
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_get_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *total_bytes, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+ guint64 rx_bytes = 0;
+ int val = 0;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, &val);
+ rx_bytes = (guint64)val;
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *total_bytes = (guint64)rx + (guint64)rx_bytes;
+ else
+ *total_bytes = (guint64)rx_bytes;
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_get_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+ guint64 tx_bytes = 0;
+ int val = 0;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, &val);
+ tx_bytes = (guint64)val;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ *last_bytes = (guint64)tx_bytes;
+ return TRUE;
+ }
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *last_bytes = (((guint64)tx - (guint64)tx_bytes) > (guint64)0) ?
+ ((guint64)tx - (guint64)tx_bytes) : (guint64)0;
+ else
+ *last_bytes = (guint64)tx_bytes;
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_get_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, guint64 *last_bytes, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+ guint64 rx_bytes = 0;
+ int val = 0;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, &val);
+ rx_bytes = (guint64)val;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ *last_bytes = (guint64)rx_bytes;
+ return TRUE;
+ }
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ *last_bytes = (((guint64)rx - (guint64)rx_bytes) > (guint64)0) ?
+ ((guint64)rx - (guint64)rx_bytes) : (guint64)0;
+ else
+ *last_bytes = (guint64)rx_bytes;
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_cellular_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, 0);
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_cellular_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, 0);
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_cellular_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, 0);
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_cellular_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, 0);
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_wifi_total_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, -(int)tx);
+ else
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, 0);
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_wifi_total_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, -(int)rx);
+ else
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, 0);
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_wifi_last_tx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ return TRUE;
+ }
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)tx);
+ else
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_network_statistics_reset_wifi_last_rx_bytes(NetconfigNetworkStatistics *network_statistics, GError **error)
+{
+ guint64 tx = 0, rx = 0;
+
+ if (netconfig_wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+ return TRUE;
+ }
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) == TRUE)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)rx);
+ else
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+
+ return TRUE;
+}
+
+void netconfig_wifi_statistics_update_powered_off(void)
+{
+ guint64 cur_tx = 0, cur_rx = 0;
+ guint64 prev_tx = 0, prev_rx = 0;
+ guint64 total_tx = 0, total_rx = 0;
+ int val = 0;
+
+ if (__netconfig_wifi_get_bytes_statistics(&cur_tx, &cur_rx) != TRUE)
+ return;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, &val);
+ prev_tx = (guint64)val;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, &val);
+ prev_rx = (guint64)val;
+
+ total_tx = prev_tx + cur_tx;
+ total_rx = prev_rx + cur_rx;
+
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_SNT, (int)total_tx);
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_TOTAL_RCV, (int)total_rx);
+}
+
+static void netconfig_wifi_statistics_update_state(
+ enum netconfig_wifi_service_state state, void *user_data)
+{
+ guint64 tx = 0, rx = 0;
+ guint64 last_tx = 0, last_rx = 0;
+ int val = 0;
+ static enum netconfig_wifi_service_state prev_state = NETCONFIG_WIFI_UNKNOWN;
+
+ if (prev_state == NETCONFIG_WIFI_UNKNOWN) {
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, 0);
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, 0);
+
+ prev_state = NETCONFIG_WIFI_IDLE;
+ return;
+ }
+
+ if (__netconfig_wifi_get_bytes_statistics(&tx, &rx) != TRUE)
+ return;
+
+ if (state == NETCONFIG_WIFI_CONNECTED) {
+ last_tx = tx;
+ last_rx = rx;
+ } else {
+ if (prev_state != NETCONFIG_WIFI_CONNECTED)
+ return;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, &val);
+ last_tx = (guint64)val;
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, &val);
+ last_rx = (guint64)val;
+
+ last_tx = (((guint64)tx - (guint64)last_tx) > (guint64)0) ?
+ ((guint64)tx - (guint64)last_tx) : (guint64)0;
+ last_rx = (((guint64)rx - (guint64)last_rx) > (guint64)0) ?
+ ((guint64)rx - (guint64)last_rx) : (guint64)0;
+ }
+
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_SNT, (int)last_tx);
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_PKT_LAST_RCV, (int)last_rx);
+
+ prev_state = state;
+}
+
+static struct netconfig_wifi_state_notifier state_notifier = {
+ .netconfig_wifi_state_changed = netconfig_wifi_statistics_update_state,
+ .user_data = NULL,
+};
+
+gpointer netconfig_network_statistics_create_and_init(DBusGConnection *conn)
+{
+ GObject *object;
+
+ g_return_val_if_fail(conn != NULL, NULL);
+
+ object = g_object_new(NETCONFIG_TYPE_NETWORK_STATISTICS, "conn", conn, "path",
+ NETCONFIG_NETWORK_STATISTICS_PATH, NULL);
+
+ INFO("create network_statistics(%p)", object);
+
+ dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATISTICS_PATH, object);
+
+ INFO("network_statistics(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATISTICS_PATH);
+
+ netconfig_wifi_statistics_update_state(NETCONFIG_WIFI_IDLE, NULL);
+ netconfig_wifi_state_notifier_register(&state_notifier);
+
+ return object;
+}
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include <vconf-keys.h>
#include "log.h"
-#include "dbus.h"
#include "util.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
#include "wifi-state.h"
#include "wifi-indicator.h"
+#include "wifi-ssid-scan.h"
#include "wifi-background-scan.h"
#include "neterror.h"
+#define SIGNAL_SCAN_DONE "ScanDone"
+#define SIGNAL_BSS_ADDED "BSSAdded"
+
+#define CONNMAN_SIGNAL_SCAN_COMPLETED "ScanCompleted"
#define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
#define CONNMAN_TECHNOLOGY_SIGNAL_FILTER "type='signal',interface='net.connman.Technology'"
#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
+#define SUPPLICANT_INTERFACE_SIGNAL_FILTER "type='signal',interface='fi.w1.wpa_supplicant1.Interface'"
+
static DBusConnection *signal_connection = NULL;
gchar *wifi_tech_state = NULL;
wifi_tech_state = netconfig_wifi_get_technology_state();
- INFO("Wi-Fi technology state: %s", wifi_tech_state);
if (wifi_tech_state == NULL)
netconfig_wifi_update_power_state(FALSE);
{
int err;
char *essid_name = NULL;
- DBusConnection *connection = NULL;
DBusMessage *message = NULL;
int MessageType = 0;
return;
}
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Failed to get system bus");
- return;
- }
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection, active_profile,
- CONNMAN_SERVICE_INTERFACE, "GetProperties");
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, active_profile,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
if (message == NULL) {
ERR("Failed to get service properties");
- dbus_connection_unref(connection);
return;
}
done:
dbus_message_unref(message);
-
- dbus_connection_unref(connection);
}
static void netconfig_wifi_unset_essid(void)
vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
DBG("Current Wi-Fi state: %d", wifi_state);
- if (g_str_equal(state, "ready") == TRUE || g_str_equal(state, "online") == TRUE) {
+ if (g_str_equal(state, "ready") == TRUE ||
+ g_str_equal(state, "online") == TRUE) {
if (wifi_state > VCONFKEY_WIFI_OFF && wifi_state != VCONFKEY_WIFI_CONNECTED) {
INFO("Wifi connected");
g_strlcpy(current_profile, profile, sizeof(current_profile));
}
- } else if (g_str_equal(state, "failure") == TRUE || g_str_equal(state, "disconnect") == TRUE || g_str_equal(state, "idle") == TRUE) {
- if (wifi_state > VCONFKEY_WIFI_UNCONNECTED) {
+ } else if (g_str_equal(state, "failure") == TRUE ||
+ g_str_equal(state, "disconnect") == TRUE ||
+ g_str_equal(state, "idle") == TRUE) {
+ if ((g_str_equal(profile, current_profile)) != TRUE)
+ return;
- INFO("Wifi [%s] Disconnected", profile);
- DBG("Current profile is %s", current_profile);
+ INFO("Wifi disconnected: %s", profile);
- if ((g_str_equal(profile, current_profile)) == TRUE)
- if ((vconf_set_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED)) < 0)
- ERR("Error!!! vconf_set_int failed");
- }
+ if (wifi_state > VCONFKEY_WIFI_UNCONNECTED)
+ if ((vconf_set_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED)) < 0)
+ ERR("Error!!! vconf_set_int failed");
netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
netconfig_wifi_indicator_stop();
memset(current_profile, 0, sizeof(current_profile));
- } else if (g_str_equal(state, "association") == TRUE || g_str_equal(state, "configuration") == TRUE) {
+ } else if (g_str_equal(state, "association") == TRUE ||
+ g_str_equal(state, "configuration") == TRUE) {
netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTING);
}
} else
CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
/* We have handled this message, don't pass it on */
return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ CONNMAN_SIGNAL_SCAN_COMPLETED)) {
+ DBusMessageIter args;
+ dbus_bool_t val = FALSE;
+ int qs_enable = 0;
+ int wifi_state = 0;
+ int ug_state = 0;
+
+ if (vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &qs_enable) < 0) {
+ DBG("failed to get vconf");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (qs_enable) {
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) < 0) {
+ DBG("failed to get vconf");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (wifi_state == VCONFKEY_WIFI_CONNECTED) {
+ DBG("Wi-Fi is Connected");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &ug_state) < 0) {
+ DBG("failed to get vconf");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND) {
+ DBG("Wi-Fi UG is running on foreground");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (!dbus_message_iter_init(msg, &args)) {
+ DBG("Message does not have parameters");
+ } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN) {
+ DBG("Argument is not boolean");
+ } else {
+ dbus_message_iter_get_basic(&args, &val);
+ if (val)
+ netconfig_wifi_check_network_notification();
+ }
+ }
+ return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE,
CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
char *property = NULL;
technology_path = (char *)dbus_message_get_path(msg);
INFO("technology object path: %s", technology_path);
- if (g_str_has_prefix(technology_path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
- __netconfig_wifi_technology_state_signal_handler((const char *)sigvalue, (const char *)property);
+ if (g_str_has_prefix(technology_path,
+ CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
+ __netconfig_wifi_technology_state_signal_handler(
+ (const char *)sigvalue, (const char *)property);
return DBUS_HANDLER_RESULT_HANDLED;
}
/* We have handled this message, don't pass it on */
return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
+ } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE,
+ CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
sigvalue = netconfig_dbus_get_string(msg);
if (sigvalue == NULL)
service_profile = (char *)dbus_message_get_path(msg);
INFO("service profile: %s", service_profile);
- if (g_str_has_prefix(service_profile, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
- __netconfig_wifi_service_state_signal_handler(msg, service_profile);
+ if (g_str_has_prefix(service_profile,
+ CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
+ __netconfig_wifi_service_state_signal_handler(
+ msg, service_profile);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
}
- }
+ } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
+ SIGNAL_BSS_ADDED)) {
+ if (netconfig_wifi_get_ssid_scan_state() == TRUE)
+ netconfig_wifi_bss_added(msg);
+ } else if (dbus_message_is_signal(msg, SUPPLICANT_INTERFACE ".Interface",
+ SIGNAL_SCAN_DONE))
+ netconfig_wifi_notify_ssid_scan_done(msg);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
return;
}
- if (dbus_connection_add_filter(conn, __netconfig_signal_filter_handler, NULL, NULL)
- == FALSE) {
+ dbus_bus_add_match(conn, SUPPLICANT_INTERFACE_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Error! Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ if (dbus_connection_add_filter(conn,
+ __netconfig_signal_filter_handler, NULL, NULL) == FALSE) {
ERR("Error! dbus_connection_add_filter() failed");
return;
}
return;
}
- dbus_connection_remove_filter(signal_connection, __netconfig_signal_filter_handler,
- NULL);
+ dbus_connection_remove_filter(signal_connection,
+ __netconfig_signal_filter_handler, NULL);
INFO("Successfully remove DBus signal filters");
dbus_connection_unref(signal_connection);
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Danny JS Seo <S.Seo@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 <unistd.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <wifi-direct.h>
-#include <syspopup_caller.h>
-
-#include "log.h"
-#include "util.h"
-#include "neterror.h"
-#include "wifi-state.h"
-
-void netconfig_start_timer_seconds(int secs,
- gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
-{
- guint t_id = 0;
-
- INFO("Register timer with callback pointer (%p)", callback);
-
- if (callback == NULL) {
- ERR("callback function is NULL");
- return;
- }
-
- if ((timer_id != NULL && *timer_id != 0)) {
- ERR("timer already is registered");
- return;
- }
-
- t_id = g_timeout_add_seconds(secs, callback, user_data);
-
- if (t_id == 0) {
- ERR("Can't add timer");
- return;
- }
-
- if (timer_id != NULL)
- *timer_id = t_id;
-}
-
-void netconfig_start_timer(int msecs,
- gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
-{
- guint t_id = 0;
-
- INFO("Register timer with callback pointer (%p)", callback);
-
- if (callback == NULL) {
- ERR("callback function is NULL");
- return;
- }
-
- if ((timer_id != NULL && *timer_id != 0)) {
- ERR("timer already is registered");
- return;
- }
-
- t_id = g_timeout_add(msecs, callback, user_data);
-
- if (t_id == 0) {
- ERR("Can't add timer");
- return;
- }
-
- if (timer_id != NULL)
- *timer_id = t_id;
-}
-
-void netconfig_stop_timer(guint *timer_id)
-{
- if (timer_id == NULL) {
- ERR("timer is NULL");
- return;
- }
-
- if (*timer_id != 0) {
- g_source_remove(*timer_id);
- *timer_id = 0;
- }
-}
-
-static gboolean __netconfig_wifi_state_device_picker_trials(gboolean is_clear_mode)
-{
- static int netconfig_device_picker_trials = 0;
- const int MAX_DEVICE_PICKER_TRIALS = 20;
-
- if (is_clear_mode != TRUE) {
- netconfig_device_picker_trials++;
-
- if (netconfig_device_picker_trials > MAX_DEVICE_PICKER_TRIALS)
- return TRUE;
- else
- return FALSE;
- }
-
- netconfig_device_picker_trials = 0;
-
- return FALSE;
-}
-
-static gboolean __netconfig_wifi_state_inc_and_test_trials(void)
-{
- return __netconfig_wifi_state_device_picker_trials(FALSE);
-}
-
-static void __netconfig_wifi_state_clear_trials(void)
-{
- __netconfig_wifi_state_device_picker_trials(TRUE);
-}
-
-static gboolean __netconfig_test_device_picker(enum netconfig_wifi_service_state *wifi_state)
-{
- *wifi_state = netconfig_wifi_state_get_service_state();
-
- DBG("Current Wi-Fi state: %d", *wifi_state);
-
- if (*wifi_state == NETCONFIG_WIFI_CONNECTING ||
- *wifi_state == NETCONFIG_WIFI_UNKNOWN) {
- if (__netconfig_wifi_state_inc_and_test_trials() == FALSE)
- return FALSE;
- }
-
- if (*wifi_state == NETCONFIG_WIFI_CONNECTED)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean __netconfig_pop_device_picker(void)
-{
- int rv = 0;
- bundle *b = NULL;
- int wifi_ug_state = 0;
- enum netconfig_wifi_service_state wifi_state;
-
- /* It's double checked,
- * because ConnMan state stops by IDLE in a short time.
- */
- if (__netconfig_test_device_picker(&wifi_state) != TRUE) {
- if (wifi_state == NETCONFIG_WIFI_CONNECTED)
- return TRUE;
-
- return FALSE;
- }
-
- vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
- if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
- return TRUE;
-
- b = bundle_create();
-
- DBG("Launch Wi-Fi device picker");
- rv = syspopup_launch("wifi-qs", b);
-
- bundle_free(b);
-
- return TRUE;
-}
-
-static gboolean __netconfig_wifi_try_device_picker(gpointer data)
-{
- enum netconfig_wifi_service_state wifi_state;
-
- if (__netconfig_test_device_picker(&wifi_state) != TRUE) {
- if (wifi_state == NETCONFIG_WIFI_CONNECTED)
- return FALSE;
-
- return TRUE;
- }
-
- if (__netconfig_pop_device_picker() != TRUE)
- return TRUE;
-
- __netconfig_wifi_state_clear_trials();
-
- return FALSE;
-}
-
-static guint __netconfig_wifi_device_picker_timer_id(gboolean is_set_method,
- guint timer_id)
-{
- static guint netconfig_wifi_device_picker_service_timer = 0;
-
- if (is_set_method != TRUE)
- return netconfig_wifi_device_picker_service_timer;
-
- if (netconfig_wifi_device_picker_service_timer != timer_id)
- netconfig_wifi_device_picker_service_timer = timer_id;
-
- return netconfig_wifi_device_picker_service_timer;
-}
-
-static void __netconfig_wifi_device_picker_set_timer_id(guint timer_id)
-{
- __netconfig_wifi_device_picker_timer_id(TRUE, timer_id);
-}
-
-static guint __netconfig_wifi_device_picker_get_timer_id(void)
-{
- return __netconfig_wifi_device_picker_timer_id(FALSE, -1);
-}
-
-void netconfig_wifi_device_picker_service_start(void)
-{
- int wifi_ug_state;
- const int NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL = 700;
- guint timer_id = 0;
-
- vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
- if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
- return;
-
- DBG("Register device picker timer with %d milliseconds",
- NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL);
-
- netconfig_start_timer(NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL,
- __netconfig_wifi_try_device_picker, NULL, &timer_id);
-
- __netconfig_wifi_state_clear_trials();
- __netconfig_wifi_device_picker_set_timer_id(timer_id);
-}
-
-void netconfig_wifi_device_picker_service_stop(void)
-{
- guint timer_id = 0;
-
- timer_id = __netconfig_wifi_device_picker_get_timer_id();
- if (timer_id == 0)
- return;
-
- DBG("Clear device picker timer with timer_id %d", timer_id);
-
- netconfig_stop_timer(&timer_id);
-
- __netconfig_wifi_device_picker_set_timer_id(timer_id);
- __netconfig_wifi_state_clear_trials();
-}
-
-gboolean netconfig_is_wifi_direct_on(void)
-{
- int wifi_direct_state = 0;
-
- vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state);
-
- DBG("Wi-Fi direct mode %d", wifi_direct_state);
- return (wifi_direct_state != 0) ? TRUE : FALSE;
-}
-
-gboolean netconfig_is_wifi_tethering_on(void)
-{
- int wifi_tethering_state = 0;
-
- vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state);
-
- DBG("Wi-Ti tethering mode %d", wifi_tethering_state);
- if (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
- return TRUE;
-
- return FALSE;
-}
-
-gboolean netconfig_execute_file(const char *file_path,
- char *const args[], char *const env[])
-{
- pid_t pid = 0;
- int rv = 0;
- errno = 0;
-
- if (!(pid = fork())) {
- register unsigned int index = 0;
- INFO("pid(%d), ppid (%d)", getpid(), getppid());
- INFO("Inside child, exec (%s) command", file_path);
-
- index = 0;
- while (args[index] != NULL) {
- INFO(" %s", args[index]);
- index++;
- }
-
- errno = 0;
- if (execve(file_path, args, env) == -1) {
- DBG("Fail to execute command...(%s)",
- strerror(errno));
- return FALSE;
- }
- } else if (pid > 0) {
- if (waitpid(pid, &rv, 0) == -1) {
- DBG("wait pid (%u) rv (%d)", pid, rv);
-
- if (WIFEXITED(rv)) {
- DBG("exited, rv=%d", WEXITSTATUS(rv));
- } else if (WIFSIGNALED(rv)) {
- DBG("killed by signal %d", WTERMSIG(rv));
- } else if (WIFSTOPPED(rv)) {
- DBG("stopped by signal %d", WSTOPSIG(rv));
- } else if (WIFCONTINUED(rv)) {
- DBG("continued");
- }
- }
- return TRUE;
- }
-
- DBG("failed to fork()...(%s)", strerror(errno));
- return FALSE;
-}
-
-gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
-{
- gboolean ret = TRUE;
-
- DBG("Launch Wi-Fi direct daemon");
-
- const char *path = "/usr/bin/wifi-direct-server.sh";
- char *const args[] = { "wifi-direct-server.sh", "start" };
- char *const env[] = { NULL };
-
- ret = netconfig_execute_file(path, args, env);
-
- if (ret != TRUE) {
- INFO("Failed to launch Wi-Fi direct daemon");
-
- netconfig_error_wifi_direct_failed(error);
- }
-
- return ret;
-}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <sys/utsname.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "emulator.h"
+
+static gboolean netconfig_is_emulated = FALSE;
+
+static gboolean __netconfig_emulator_test_emulation_env(void)
+{
+ struct utsname buf;
+ const char *EMUL_UTSNAME_MACHINE_SUFFIX = "emulated";
+
+ DBG("Test emulation environment");
+
+ uname(&buf);
+
+ if (buf.machine != NULL &&
+ g_str_has_suffix(buf.machine, EMUL_UTSNAME_MACHINE_SUFFIX) == TRUE)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void __netconfig_emulator_set_ip(void)
+{
+ const int BUF_LEN_MAX = 255;
+ const char EMUL_IFNAME[] = "eth0";
+ char ip[BUF_LEN_MAX];
+ int sockfd = 0;
+ struct ifreq ifr;
+
+ if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
+ ERR("Failed to open socket");
+ return;
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ g_strlcpy((char*)&ifr.ifr_name, EMUL_IFNAME, sizeof(EMUL_IFNAME));
+
+ if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) {
+ ERR("Error getting IP address");
+
+ close(sockfd);
+ return;
+ }
+
+ g_strlcpy(ip, (char*)inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr), BUF_LEN_MAX);
+
+ vconf_set_str(VCONFKEY_NETWORK_IP, ip);
+
+ close(sockfd);
+}
+
+static void __netconfig_emulator_set_proxy(void)
+{
+ const char HTTP_PROXY[] = "http_proxy";
+ char *proxy = NULL;
+
+ proxy = getenv(HTTP_PROXY);
+ DBG("Get system proxy: %s", proxy);
+
+ if(proxy != NULL)
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy);
+}
+
+static void __netconfig_emulator_set_network_state(void)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+ vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_NORMAL_CONNECTED);
+}
+
+static void __netconfig_emulator_config_emul_env(void)
+{
+ __netconfig_emulator_set_ip();
+ __netconfig_emulator_set_proxy();
+ __netconfig_emulator_set_network_state();
+}
+
+gboolean netconfig_emulator_is_emulated(void)
+{
+ return netconfig_is_emulated;
+}
+
+void netconfig_emulator_test_and_start(void)
+{
+ netconfig_is_emulated = __netconfig_emulator_test_emulation_env();
+
+ DBG("Emulation environment tested: %s", netconfig_is_emulated ? "It's emulated" : "Not emulated");
+
+ if (netconfig_is_emulated == TRUE)
+ __netconfig_emulator_config_emul_env();
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 "mdm-private.h"
+
+gboolean netconfig_is_wifi_allowed(void)
+{
+ return TRUE;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <wifi-direct.h>
+#include <syspopup_caller.h>
+
+#include "log.h"
+#include "util.h"
+#include "neterror.h"
+#include "wifi-state.h"
+
+void netconfig_start_timer_seconds(int secs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
+{
+ guint t_id = 0;
+
+ INFO("Register timer with callback pointer (%p)", callback);
+
+ if (callback == NULL) {
+ ERR("callback function is NULL");
+ return;
+ }
+
+ if ((timer_id != NULL && *timer_id != 0)) {
+ ERR("timer already is registered");
+ return;
+ }
+
+ t_id = g_timeout_add_seconds(secs, callback, user_data);
+
+ if (t_id == 0) {
+ ERR("Can't add timer");
+ return;
+ }
+
+ if (timer_id != NULL)
+ *timer_id = t_id;
+}
+
+void netconfig_start_timer(int msecs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
+{
+ guint t_id = 0;
+
+ INFO("Register timer with callback pointer (%p)", callback);
+
+ if (callback == NULL) {
+ ERR("callback function is NULL");
+ return;
+ }
+
+ if ((timer_id != NULL && *timer_id != 0)) {
+ ERR("timer already is registered");
+ return;
+ }
+
+ t_id = g_timeout_add(msecs, callback, user_data);
+
+ if (t_id == 0) {
+ ERR("Can't add timer");
+ return;
+ }
+
+ if (timer_id != NULL)
+ *timer_id = t_id;
+}
+
+void netconfig_stop_timer(guint *timer_id)
+{
+ if (timer_id == NULL) {
+ ERR("timer is NULL");
+ return;
+ }
+
+ if (*timer_id != 0) {
+ g_source_remove(*timer_id);
+ *timer_id = 0;
+ }
+}
+
+static gboolean __netconfig_test_device_picker()
+{
+ char *favorite_wifi_service = NULL;
+
+ favorite_wifi_service = netconfig_wifi_get_favorite_service();
+ if (favorite_wifi_service != NULL) {
+ g_free(favorite_wifi_service);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void __netconfig_pop_device_picker(void)
+{
+ int rv = 0;
+ bundle *b = NULL;
+ int wifi_ug_state = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return;
+
+ b = bundle_create();
+
+ DBG("Launch Wi-Fi device picker");
+ rv = syspopup_launch("wifi-qs", b);
+
+ bundle_free(b);
+}
+
+static gboolean __netconfig_wifi_try_device_picker(gpointer data)
+{
+ if (__netconfig_test_device_picker() == TRUE)
+ __netconfig_pop_device_picker();
+
+ return FALSE;
+}
+
+static guint __netconfig_wifi_device_picker_timer_id(gboolean is_set_method,
+ guint timer_id)
+{
+ static guint netconfig_wifi_device_picker_service_timer = 0;
+
+ if (is_set_method != TRUE)
+ return netconfig_wifi_device_picker_service_timer;
+
+ if (netconfig_wifi_device_picker_service_timer != timer_id)
+ netconfig_wifi_device_picker_service_timer = timer_id;
+
+ return netconfig_wifi_device_picker_service_timer;
+}
+
+static void __netconfig_wifi_device_picker_set_timer_id(guint timer_id)
+{
+ __netconfig_wifi_device_picker_timer_id(TRUE, timer_id);
+}
+
+static guint __netconfig_wifi_device_picker_get_timer_id(void)
+{
+ return __netconfig_wifi_device_picker_timer_id(FALSE, -1);
+}
+
+void netconfig_wifi_device_picker_service_start(void)
+{
+ int wifi_ug_state;
+ const int NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL = 700;
+ guint timer_id = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return;
+
+ DBG("Register device picker timer with %d milliseconds",
+ NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL);
+
+ netconfig_start_timer(NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL,
+ __netconfig_wifi_try_device_picker, NULL, &timer_id);
+
+ __netconfig_wifi_device_picker_set_timer_id(timer_id);
+}
+
+void netconfig_wifi_device_picker_service_stop(void)
+{
+ guint timer_id = 0;
+
+ timer_id = __netconfig_wifi_device_picker_get_timer_id();
+ if (timer_id == 0)
+ return;
+
+ DBG("Clear device picker timer with timer_id %d", timer_id);
+
+ netconfig_stop_timer(&timer_id);
+
+ __netconfig_wifi_device_picker_set_timer_id(timer_id);
+}
+
+gboolean netconfig_is_wifi_direct_on(void)
+{
+ int wifi_direct_state = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state);
+
+ DBG("Wi-Fi direct mode %d", wifi_direct_state);
+ return (wifi_direct_state != 0) ? TRUE : FALSE;
+}
+
+gboolean netconfig_is_wifi_tethering_on(void)
+{
+ int wifi_tethering_state = 0;
+
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state);
+
+ DBG("Wi-Ti tethering mode %d", wifi_tethering_state);
+ if (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
+ return TRUE;
+
+ return FALSE;
+}
+
+gboolean netconfig_execute_file(const char *file_path,
+ char *const args[], char *const env[])
+{
+ pid_t pid = 0;
+ int rv = 0;
+ errno = 0;
+
+ if (!(pid = fork())) {
+ register unsigned int index = 0;
+ INFO("pid(%d), ppid (%d)", getpid(), getppid());
+ INFO("Inside child, exec (%s) command", file_path);
+
+ index = 0;
+ while (args[index] != NULL) {
+ INFO(" %s", args[index]);
+ index++;
+ }
+
+ errno = 0;
+ if (execve(file_path, args, env) == -1) {
+ DBG("Fail to execute command...(%s)",
+ strerror(errno));
+ return FALSE;
+ }
+ } else if (pid > 0) {
+ if (waitpid(pid, &rv, 0) == -1) {
+ DBG("wait pid (%u) rv (%d)", pid, rv);
+
+ if (WIFEXITED(rv)) {
+ DBG("exited, rv=%d", WEXITSTATUS(rv));
+ } else if (WIFSIGNALED(rv)) {
+ DBG("killed by signal %d", WTERMSIG(rv));
+ } else if (WIFSTOPPED(rv)) {
+ DBG("stopped by signal %d", WSTOPSIG(rv));
+ } else if (WIFCONTINUED(rv)) {
+ DBG("continued");
+ }
+ }
+ return TRUE;
+ }
+
+ DBG("failed to fork()...(%s)", strerror(errno));
+ return FALSE;
+}
+
+gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
+{
+ gboolean ret = TRUE;
+
+ DBG("Launch Wi-Fi direct daemon");
+
+ const char *path = "/usr/bin/wifi-direct-server.sh";
+ char *const args[] = { "wifi-direct-server.sh", "start" };
+ char *const env[] = { NULL };
+
+ ret = netconfig_execute_file(path, args, env);
+
+ if (ret != TRUE) {
+ INFO("Failed to launch Wi-Fi direct daemon");
+
+ netconfig_error_wifi_direct_failed(error);
+ }
+
+ return ret;
+}
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include <vconf-keys.h>
#include "log.h"
-#include "dbus.h"
#include "util.h"
#include "wifi.h"
+#include "netdbus.h"
#include "wifi-state.h"
#include "wifi-background-scan.h"
static gboolean __netconfig_wifi_bgscan_request_connman_scan(void)
{
DBusMessage *reply = NULL;
- /** dbus-send --system --print-reply --dest=net.connman / net.connman.Manager.SetProperty string:ScanMode variant:uint16:0/1/2/3 */
- char request[] = CONNMAN_MANAGER_INTERFACE ".RequestScan";
char param1[] = "string:wifi";
- char path[] = CONNMAN_MANAGER_PATH;
- char *param_array[] = {
- NULL,
- NULL,
- NULL,
- NULL
- };
+ char *param_array[] = {NULL, NULL};
if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTED)
if (__netconfig_wifi_bgscan_get_mode() == WIFI_BGSCAN_MODE_EXPONENTIAL)
- return FALSE;
+ return FALSE;
if (netconfig_wifi_state_get_service_state() == NETCONFIG_WIFI_CONNECTING)
return FALSE;
- param_array[0] = path;
- param_array[1] = request;
- param_array[2] = param1;
+ param_array[0] = param1;
- DBG("Requesting [%s %s %s]", param_array[0], param_array[1], param_array[2]);
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "RequestScan", param_array);
- reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
if (reply == NULL) {
ERR("Error! Request failed");
-
return FALSE;
}
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include <vconf-keys.h>
#include "log.h"
-#include "dbus.h"
#include "util.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
#include "wifi-indicator.h"
-#define NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL 3
+#define VCONFKEY_WIFI_SNR_MIN -89
-#define VCONFKEY_WIFI_SNR_MIN -85
-#define VCONFKEY_WIFI_SNR_MAX -55
+#define NETCONFIG_WIFI_INDICATOR_INTERVAL 3
static guint netconfig_wifi_indicator_timer = 0;
-static GList *__netconfig_wifi_supplicant_setup(GList * list,
- struct dbus_input_arguments *items)
-{
- struct dbus_input_arguments *iter = items;
-
- if (iter == NULL)
- return NULL;
-
- while (iter->data) {
- list = g_list_append(list, iter);
- iter++;
- }
-
- return list;
-}
-
-static int __netconfig_wifi_get_interface(const char **path)
+#if defined NL80211
+static int __netconfig_wifi_get_signal(const char *object_path)
{
- char *ptr = (char *)*path;
- DBusConnection *conn = NULL;
+ DBusConnection *connection = NULL;
DBusMessage *message = NULL;
DBusMessageIter iter;
+ int rssi_dbm = 0;
int MessageType = 0;
- const char *temp = NULL;
-
- GList *input_args = NULL;
- struct dbus_input_arguments inserted_items[] = {
- {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE},
- {DBUS_TYPE_STRING, "Interfaces"},
- {0, NULL}
- };
- if (ptr == NULL) {
+ if (object_path == NULL) {
ERR("Error!!! path is NULL");
- return -1;
+ goto error;
}
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL) {
- ERR("Error!!! Can't get on system bus");
- return -1;
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Error!!! Failed to get system DBus");
+ goto error;
}
- input_args = __netconfig_wifi_supplicant_setup(input_args, inserted_items);
-
- message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn,
- SUPPLICANT_PATH,
- SUPPLICANT_GLOBAL_INTERFACE, "Get",
- input_args);
-
- g_list_free(input_args);
+ message = netconfig_supplicant_invoke_dbus_method(
+ SUPPLICANT_SERVICE, connection, object_path,
+ SUPPLICANT_INTERFACE ".Interface", "GetLinkSignal",
+ NULL);
if (message == NULL) {
ERR("Error!!! Failed to get service properties");
- goto err;
+ goto error;
}
MessageType = dbus_message_get_type(message);
if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
const char *err_msg = dbus_message_get_error_name(message);
ERR("Error!!! Error message received [%s]", err_msg);
- goto err;
+ goto error;
}
dbus_message_iter_init(message, &iter);
- if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_VARIANT) {
- DBusMessageIter array;
- dbus_message_iter_recurse(&iter, &array);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&array)) == DBUS_TYPE_ARRAY) {
- DBusMessageIter object_path;
- dbus_message_iter_recurse(&array, &object_path);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&object_path)) == DBUS_TYPE_OBJECT_PATH)
- dbus_message_iter_get_basic(&object_path, &temp);
- else
- goto err;
-
- } else
- goto err;
-
- } else
- goto err;
- INFO("interface %s, path pointer %p", temp, *path);
- g_strlcpy(ptr, temp, DBUS_PATH_MAX_BUFLEN);
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_INT32)
+ dbus_message_iter_get_basic(&iter, &rssi_dbm);
+ else
+ goto error;
dbus_message_unref(message);
- dbus_connection_unref(conn);
+ dbus_connection_unref(connection);
- return 0;
+ return rssi_dbm;
-err:
+error:
if (message != NULL)
dbus_message_unref(message);
- if (conn != NULL)
- dbus_connection_unref(conn);
+ if (connection != NULL)
+ dbus_connection_unref(connection);
- return -1;
+ return VCONFKEY_WIFI_SNR_MIN;
}
-#ifdef NL80211
-static int __netconfig_wifi_get_signal(const char *path, int *sig)
+static int __netconfig_wifi_get_rssi_from_supplicant(void)
{
- DBusConnection *conn = NULL;
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- int MessageType = 0;
-
- if (path == NULL || sig == NULL) {
- ERR("Error!!! path is NULL");
- return -1;
- }
-
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL) {
- ERR("Error!!! Can't get on system bus");
- return -1;
- }
-
- INFO("supplicant path is [%s]", path);
-
- message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn,
- path,
- SUPPLICANT_INTERFACE".Interface", "GetLinkSignal",
- NULL);
-
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto err;
- }
-
- MessageType = dbus_message_get_type(message);
-
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_msg = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", err_msg);
- goto err;
- }
+ int rssi_dbm =0;
- dbus_message_iter_init(message, &iter);
+ char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
+ char *path_ptr = &object_path[0];
- if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_INT32) {
- dbus_message_iter_get_basic(&iter, sig);
- INFO("signal value is [%d]", *sig);
- } else {
- ERR("message type is %d", MessageType);
- goto err;
+ if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return VCONFKEY_WIFI_SNR_MIN;
}
- dbus_message_unref(message);
-
- dbus_connection_unref(conn);
-
- return 0;
-
-err:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (conn != NULL)
- dbus_connection_unref(conn);
+ rssi_dbm = __netconfig_wifi_get_signal((const char *)path_ptr);
- return -1;
+ return rssi_dbm;
}
-#endif
+#endif /* #if defined NL80211 */
-static int __netconfig_wifi_set_rssi_level(gboolean is_start, const char *ifname)
+#if !defined NL80211
+static int __netconfig_wifi_get_rssi_from_system(void)
{
int rssi_dbm = 0;
- static int last_snr = 0;
- int snr_level_interval = 0;
- int snr_level = 0;
+ char ifname[16] = { 0, };
+ char *ifname_ptr = &ifname[0];
-#ifndef NL80211
int fd = -1;
struct iwreq wifi_req;
struct iw_statistics stats;
-
unsigned int iw_stats_len = sizeof(struct iw_statistics);
+ if (netconfig_wifi_get_ifname(&ifname_ptr) != TRUE) {
+ DBG("Fail to get Wi-Fi ifname from wpa_supplicant: %s", ifname_ptr);
+ return VCONFKEY_WIFI_SNR_MIN;
+ }
+
/* Set device name */
memset(wifi_req.ifr_name, 0, sizeof(wifi_req.ifr_name));
strncpy(wifi_req.ifr_name, ifname, sizeof(wifi_req.ifr_name) - 1);
wifi_req.u.data.length = iw_stats_len;
wifi_req.u.data.flags = 1; /* Clear updated flag */
- if (is_start == TRUE) {
- last_snr = VCONFKEY_WIFI_STRENGTH_MAX;
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, last_snr);
- return 0;
- }
-
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
DBG("Fail to open socket to get rssi");
- return -1;
+ return VCONFKEY_WIFI_SNR_MIN;
}
memset(&stats, 0, iw_stats_len);
if (ioctl(fd, SIOCGIWSTATS, &wifi_req) < 0) {
DBG("Fail to execute ioctl for SIOCGIWSTATS");
close(fd);
- return -1;
+
+ return VCONFKEY_WIFI_SNR_MIN;
}
close(fd);
rssi_dbm = stats.qual.level - 255; /** signed integer, so 255 */
-#else
- if (is_start == TRUE) {
- last_snr = VCONFKEY_WIFI_STRENGTH_MAX;
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, last_snr);
- return 0;
- }
- __netconfig_wifi_get_signal(ifname, &rssi_dbm);
-#endif
-
- snr_level_interval =
- (VCONFKEY_WIFI_SNR_MAX -
- VCONFKEY_WIFI_SNR_MIN) / (VCONFKEY_WIFI_STRENGTH_MAX - 2);
-
- snr_level =
- ((rssi_dbm - VCONFKEY_WIFI_SNR_MIN) / snr_level_interval) + 2;
-
- if (rssi_dbm <= VCONFKEY_WIFI_SNR_MIN)
- snr_level = VCONFKEY_WIFI_STRENGTH_MIN + 1;
- else if (rssi_dbm >= VCONFKEY_WIFI_SNR_MAX)
- snr_level = VCONFKEY_WIFI_STRENGTH_MAX;
-
- if (snr_level != last_snr) {
- INFO("rssi (%d)", rssi_dbm);
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, snr_level);
- last_snr = snr_level;
- }
- return 0;
+ return rssi_dbm;
}
+#endif /* #if !defined NL80211 */
-#ifndef NL80211
-static int __netconfig_wifi_get_ifname(const char *supp_inf, const char **ifname)
+int netconfig_wifi_get_rssi(void)
{
- char *ptr = (char *)*ifname;
- DBusConnection *conn = NULL;
- DBusMessage *message = NULL;
- DBusMessageIter iter;
- int MessageType = 0;
- const char *temp = NULL;
-
- GList *input_args = NULL;
-
- struct dbus_input_arguments inserted_items[] = {
- { DBUS_TYPE_STRING, SUPPLICANT_INTERFACE ".Interface" },
- { DBUS_TYPE_STRING, "Ifname" },
- { 0, NULL }
- };
-
- if (ptr == NULL) {
- ERR("Error!!! Path is NULL");
- return -1;
- }
-
- if (supp_inf == NULL) {
- ERR("Error!!! Supplicant DBus interface is NULL");
- return -1;
- }
-
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-
- if (conn == NULL) {
- ERR("Fail to get DBus *p", conn);
- return -1;
- }
-
- input_args = __netconfig_wifi_supplicant_setup(input_args, inserted_items);
-
- message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn, (char *)supp_inf,
- SUPPLICANT_GLOBAL_INTERFACE, "Get",
- input_args);
+ int rssi_dbm = 0;
- g_list_free(input_args);
+ /* There are two ways to get Wi-Fi RSSI:
+ * - WEXT interface, get DBus path of wpa_supplicant,
+ * and get Wi-Fi interface name e.g. wlan0 from wpa_supplicant.
+ * IOCTL with ifname will return RSSI dB.
+ * - NL80211 interface, get DBus path of wpa_supplicant,
+ * and get RSSI from wpa_supplicant directly.
+ * However, in this case wpa_supplicant needs some modification
+ * to get RSSI from DBus interface. */
+
+#if defined NL80211
+ rssi_dbm = __netconfig_wifi_get_rssi_from_supplicant();
+#else
+ rssi_dbm = __netconfig_wifi_get_rssi_from_system();
+#endif
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto err;
- }
+ return rssi_dbm;
+}
- if (message == NULL) {
- ERR("Error!!! Failed to get service properties");
- goto err;
- }
+static void __netconfig_wifi_set_rssi_level(int rssi_dbm)
+{
+ int snr_level = 0;
+ static int last_snr_level = 0;
+
+ /* Wi-Fi Signal Strength Display
+ *
+ * Excellent : -63 ~
+ * Good: -74 ~ -64
+ * Weak: -82 ~ -75
+ * Very weak: ~ -83
+ */
+ if (rssi_dbm >= -63)
+ snr_level = 4;
+ else if (rssi_dbm >= -74)
+ snr_level = 3;
+ else if (rssi_dbm >= -82)
+ snr_level = 2;
+ else
+ snr_level = 1;
+
+ if (snr_level != last_snr_level) {
+ INFO("Wi-Fi RSSI: %d dB, %d level", rssi_dbm, snr_level);
- MessageType = dbus_message_get_type(message);
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, snr_level);
- if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char *err_ptr = dbus_message_get_error_name(message);
- ERR("Error!!! Error message received [%s]", err_ptr);
- goto err;
+ last_snr_level = snr_level;
}
-
- dbus_message_iter_init(message, &iter);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_VARIANT) {
- DBusMessageIter string_type;
- dbus_message_iter_recurse(&iter, &string_type);
-
- if ((MessageType = dbus_message_iter_get_arg_type(&string_type)) ==
- DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&string_type, &temp);
- } else
- goto err;
-
- } else
- goto err;
-
- INFO("interface %s, ifname pointer %p", temp, *ifname);
-
- g_strlcpy(ptr, temp, IFNAMSIZ);
-
- dbus_message_unref(message);
- dbus_connection_unref(conn);
-
- return 0;
-
-err:
- if (message != NULL)
- dbus_message_unref(message);
-
- if (conn != NULL)
- dbus_connection_unref(conn);
-
- return -1;
}
-#endif
-static gboolean __netconfig_wifi_monitor_rssi(gpointer data)
+static gboolean __netconfig_wifi_indicator_monitor(gpointer data)
{
- int rssi_result = 0;
+ int rssi_dbm = 0;
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
- if (data == NULL)
- return FALSE;
+ vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+ if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
+ return TRUE;
- rssi_result = __netconfig_wifi_set_rssi_level(FALSE, (char *)data);
+ rssi_dbm = netconfig_wifi_get_rssi();
- if (rssi_result == -1)
- vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MIN);
+ __netconfig_wifi_set_rssi_level(rssi_dbm);
return TRUE;
}
void netconfig_wifi_indicator_start(void)
{
- char *path_ptr = NULL;
- static char path[DBUS_PATH_MAX_BUFLEN] = { 0 };
-#ifndef NL80211
- char *ifname_ptr = NULL;
- static char ifname[IFNAMSIZ] = { 0 };
-#endif
-
INFO("Start Wi-Fi indicator");
- netconfig_stop_timer(&netconfig_wifi_indicator_timer);
-
-#ifndef NL80211
- memset(ifname, 0, sizeof(ifname));
- ifname_ptr = &ifname[0];
-#endif
- path_ptr = &path[0];
-
- if (__netconfig_wifi_get_interface((const char **)(&path_ptr)) == 0) {
-#ifndef NL80211
- INFO("Success to get DBus interface %s", path_ptr);
-
- if (__netconfig_wifi_get_ifname(path_ptr, (const char **)(&ifname_ptr)) == 0) {
- INFO("Success to get wifi ifname %s", ifname_ptr);
-
- __netconfig_wifi_set_rssi_level(TRUE, (const char *)ifname);
-
- DBG("Register Wi-Fi indicator timer with %d seconds",
- NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL);
- netconfig_start_timer_seconds(NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL,
- __netconfig_wifi_monitor_rssi, ifname, &netconfig_wifi_indicator_timer);
- }
-
- return;
-#else
- INFO("interface is [%s]", path_ptr);
-
- __netconfig_wifi_set_rssi_level(TRUE, (const char *)path_ptr);
-
- DBG("Register Wi-Fi indicator timer with %d seconds",
- NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL);
- netconfig_start_timer_seconds(NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL,
- __netconfig_wifi_monitor_rssi, path_ptr, &netconfig_wifi_indicator_timer);
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
- return;
-#endif
- }
+ netconfig_start_timer_seconds(
+ NETCONFIG_WIFI_INDICATOR_INTERVAL,
+ __netconfig_wifi_indicator_monitor,
+ NULL,
+ &netconfig_wifi_indicator_timer);
}
void netconfig_wifi_indicator_stop(void)
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include "log.h"
#include "wifi.h"
-#include "dbus.h"
#include "util.h"
+#include "netdbus.h"
#include "neterror.h"
#include "netconfig.h"
#include "emulator.h"
+#include "network-statistics.h"
#include "wifi-state.h"
+#include "wifi-ssid-scan.h"
#include "wifi-background-scan.h"
+#include "mdm-private.h"
gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error);
gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error);
#include "netconfig-iface-wifi-glue.h"
-#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
-
#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
#define PROP_DEFAULT FALSE
{
DBusMessage *reply = NULL;
char path[DBUS_PATH_MAX_BUFLEN] = "/";
- char request[] = CONNMAN_MANAGER_INTERFACE ".EnableTechnology";
char param1[] = "string:wifi";
- char *param_array[] = {
- NULL,
- NULL,
- NULL,
- NULL
- };
-
- param_array[0] = path;
- param_array[1] = request;
- param_array[2] = param1;
-
- reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
+ char *param_array[] = {NULL, NULL};
+
+ param_array[0] = param1;
+
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
+ CONNMAN_MANAGER_INTERFACE, "EnableTechnology", param_array);
+
if (reply == NULL) {
ERR("Error! Request failed");
-
return FALSE;
}
{
DBusMessage *reply = NULL;
char path[DBUS_PATH_MAX_BUFLEN] = "/";
- char request[] = CONNMAN_MANAGER_INTERFACE ".DisableTechnology";
char param1[] = "string:wifi";
- char *param_array[] = {
- NULL,
- NULL,
- NULL,
- NULL
- };
-
- param_array[0] = path;
- param_array[1] = request;
- param_array[2] = param1;
-
- reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
+ char *param_array[] = {NULL, NULL};
+
+ param_array[0] = param1;
+
+ reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, path,
+ CONNMAN_MANAGER_INTERFACE, "DisableTechnology", param_array);
+
if (reply == NULL) {
ERR("Error! Request failed");
-
return FALSE;
}
int count = 0;
gchar *wifi_tech_state = NULL;
+ if (netconfig_is_wifi_allowed() != TRUE)
+ return FALSE;
+
if (netconfig_is_wifi_tethering_on() == TRUE) {
/* TODO: Wi-Fi tethering turns off here */
/* return TRUE; */
__netconfig_wifi_enable_technology();
wifi_tech_state = netconfig_wifi_get_technology_state();
- INFO("Wi-Fi technology state: %s", wifi_tech_state);
if (wifi_tech_state == NULL) {
DBG("Failed to get Wi-Fi technology state");
netconfig_wifi_device_picker_service_start();
+ g_free(wifi_tech_state);
+ wifi_tech_state = NULL;
+
return TRUE;
}
g_free(wifi_tech_state);
-
wifi_tech_state = NULL;
}
netconfig_wifi_device_picker_service_stop();
+ netconfig_wifi_statistics_update_powered_off();
+
for (count = 0; count < 3; count++) {
__netconfig_wifi_disable_technology();
wifi_tech_state = netconfig_wifi_get_technology_state();
- INFO("Wi-Fi technology state: %s", wifi_tech_state);
if (wifi_tech_state == NULL) {
DBG("Failed to get Wi-Fi technology state");
if (g_str_equal(wifi_tech_state, "EnabledTechnologies") != TRUE) {
g_free(wifi_tech_state);
+ wifi_tech_state = NULL;
+
break;
}
g_free(wifi_tech_state);
+ wifi_tech_state = NULL;
}
if (__netconfig_wifi_remove_driver() == TRUE) {
}
}
+static void __netconfig_wifi_notify_power_completed(gboolean power_on)
+{
+ DBusMessage *signal;
+ DBusConnection *connection = NULL;
+ DBusError error;
+ char *sig_name = NULL;
+
+ if (power_on)
+ sig_name = "PowerOnCompleted";
+ else
+ sig_name = "PowerOffCompleted";
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Error!!! Failed to get system DBus, error [%s]", error.message);
+ dbus_error_free(&error);
+ return;
+ }
+
+ signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, sig_name);
+ if (signal == NULL)
+ return;
+
+ dbus_connection_send(connection, signal, NULL);
+
+ dbus_message_unref(signal);
+ dbus_connection_unref(connection);
+
+ INFO("(%s)", sig_name);
+}
+
gpointer netconfig_wifi_create_and_init(DBusGConnection *conn)
{
GObject *object;
g_return_val_if_fail(wifi != NULL, FALSE);
+ if (netconfig_is_wifi_allowed() != TRUE) {
+ netconfig_error_security_restricted(error);
+
+ return FALSE;
+ }
+
if (__netconfig_wifi_try_to_load_driver() != TRUE) {
netconfig_error_wifi_driver_failed(error);
return FALSE;
}
+ __netconfig_wifi_notify_power_completed(TRUE);
return TRUE;
}
return FALSE;
}
+ __netconfig_wifi_notify_power_completed(FALSE);
return TRUE;
}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 "log.h"
+#include "neterror.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+#include "wifi-ssid-scan.h"
+
+struct bss_info_t {
+ unsigned char ssid[32];
+ enum netconfig_wifi_security security;
+ dbus_bool_t privacy;
+ dbus_bool_t wps;
+};
+
+static gboolean wifi_ssid_scan_state = FALSE;
+static GSList *wifi_bss_info_list = NULL;
+
+static void __netconfig_wifi_ssid_scan_start(void)
+{
+ wifi_ssid_scan_state = TRUE;
+}
+
+static void __netconfig_wifi_ssid_scan_stop(void)
+{
+ wifi_ssid_scan_state = FALSE;
+}
+
+static gboolean __netconfig_wifi_invoke_ssid_scan(
+ const char *object_path, const char *ssid)
+{
+ /* TODO: Revise following code */
+
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ DBusMessage *reply = NULL;
+ DBusMessageIter iter, dict, entry;
+ DBusMessageIter value, array, array2;
+ DBusError error;
+ int MessageType = 0;
+ const char *key1 = "Type";
+ const char *val1 = "active";
+ const char *key2 = "SSIDs";
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Error!!! Failed to get system DBus");
+ goto error;
+ }
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
+ object_path, SUPPLICANT_INTERFACE ".Interface", "Scan");
+ if (message == NULL) {
+ ERR("Error!!! DBus method call fail");
+ goto error;
+ }
+
+ dbus_message_iter_init_append(message, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ dbus_message_iter_open_container(&dict,
+ DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key1);
+
+ dbus_message_iter_open_container(&entry,
+ DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &val1);
+
+ dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_close_container(&dict, &entry);
+
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key2);
+
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_BYTE_AS_STRING,
+ &value);
+ dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_BYTE_AS_STRING,
+ &array);
+ dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &array2);
+
+ dbus_message_iter_append_fixed_array(&array2, DBUS_TYPE_BYTE, &ssid, strlen(ssid));
+
+ dbus_message_iter_close_container(&array, &array2);
+ dbus_message_iter_close_container(&value, &array);
+ dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_close_container(&dict, &entry);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. "
+ "DBus error [%s: %s]", error.name, error.message);
+
+ dbus_error_free(&error);
+ return FALSE;
+ } else
+ ERR("Error!!! Failed to get properties");
+
+ goto error;
+ }
+
+ MessageType = dbus_message_get_type(reply);
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_msg = dbus_message_get_error_name(reply);
+ ERR("Error!!! Error message received %s", err_msg);
+ goto error;
+ }
+
+ INFO("Message type :%d", MessageType);
+
+ dbus_message_unref(message);
+ dbus_message_unref(reply);
+ dbus_connection_unref(connection);
+
+ return TRUE;
+
+error:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (reply != NULL)
+ dbus_message_unref(reply);
+
+ if (connection != NULL)
+ dbus_connection_unref(connection);
+
+ return FALSE;
+}
+
+static void __netconfig_wifi_notify_ssid_scan_done(void)
+{
+ DBusMessage *signal;
+ DBusConnection *connection = NULL;
+ DBusMessageIter dict, type, array, value;
+ DBusError error;
+ char *prop_ssid = "ssid";
+ char *prop_security = "security";
+ const char *sig_name = "SpecificScanCompleted";
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ /* TODO: If this occurs then UG should be informed abt SCAN fail. CHECK THIS. */
+ ERR("Error!!! Failed to get system DBus, error [%s]", error.message);
+ dbus_error_free(&error);
+
+ g_slist_free_full(wifi_bss_info_list, g_free);
+ wifi_bss_info_list = NULL;
+
+ return;
+ }
+
+ signal = dbus_message_new_signal(NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE, sig_name);
+ if (signal == NULL) {
+ /* TODO: If this occurs then UG should be informed abt SCAN fail. CHECK THIS. */
+ dbus_connection_unref(connection);
+
+ g_slist_free_full(wifi_bss_info_list, g_free);
+ wifi_bss_info_list = NULL;
+
+ return;
+ }
+
+ dbus_message_iter_init_append(signal, &array);
+ dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, "{sv}", &dict);
+ GSList* list = wifi_bss_info_list;
+ while(list) {
+ struct bss_info_t *bss_info = (struct bss_info_t *)g_slist_nth_data(list, 0);
+
+ if (bss_info) {
+ char *ssid = (char *)&(bss_info->ssid[0]);
+ dbus_int16_t security = bss_info->security;
+ DBG("Bss found. SSID: %s; Sec mode: %d;", ssid, security);
+
+ /* Lets pack the SSID */
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_ssid);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &ssid);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+
+ /* Lets pack the Security */
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &type);
+ dbus_message_iter_append_basic(&type, DBUS_TYPE_STRING, &prop_security);
+ dbus_message_iter_open_container(&type, DBUS_TYPE_VARIANT, DBUS_TYPE_INT16_AS_STRING, &value);
+
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_INT16, &security);
+ dbus_message_iter_close_container(&type, &value);
+ dbus_message_iter_close_container(&dict, &type);
+ }
+ list = g_slist_next(list);
+ }
+
+ dbus_message_iter_close_container(&array, &dict);
+
+ dbus_error_init(&error);
+ dbus_connection_send(connection, signal, NULL);
+
+ dbus_message_unref(signal);
+ dbus_connection_unref(connection);
+
+ g_slist_free_full(wifi_bss_info_list, g_free);
+ wifi_bss_info_list = NULL;
+
+ INFO("(%s)", sig_name);
+}
+
+static gboolean __netconfig_wifi_ssid_scan(const char *ssid)
+{
+ char object_path[DBUS_PATH_MAX_BUFLEN] = { 0, };
+ char *path_ptr = &object_path[0];
+
+ if (ssid == NULL)
+ return FALSE;
+
+ DBG("Start SSID Scan with %s", ssid);
+
+ if (wifi_bss_info_list) {
+ g_slist_free_full(wifi_bss_info_list, g_free);
+ wifi_bss_info_list = NULL;
+ }
+
+ if (netconfig_wifi_get_supplicant_interface(&path_ptr) != TRUE) {
+ DBG("Fail to get wpa_supplicant DBus path");
+ return FALSE;
+ }
+
+ if (__netconfig_wifi_invoke_ssid_scan(
+ (const char *)object_path, ssid) == TRUE) {
+ __netconfig_wifi_ssid_scan_start();
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void __netconfig_wifi_check_security(const char *str_keymgmt, struct bss_info_t *bss_data)
+{
+ INFO("keymgmt : %s", str_keymgmt);
+
+ if (strcmp(str_keymgmt, "ieee8021x") == 0) {
+ bss_data->security = WIFI_SECURITY_IEEE8021X;
+ } else if (strcmp(str_keymgmt, "wpa-psk") == 0) {
+ bss_data->security = WIFI_SECURITY_PSK;
+ } else if (strcmp(str_keymgmt, "wpa-psk-sha256") == 0) {
+ bss_data->security = WIFI_SECURITY_PSK;
+ } else if (strcmp(str_keymgmt, "wpa-ft-psk") == 0) {
+ bss_data->security = WIFI_SECURITY_PSK;
+ } else if (strcmp(str_keymgmt, "wpa-ft-eap") == 0) {
+ bss_data->security = WIFI_SECURITY_IEEE8021X;
+ } else if (strcmp(str_keymgmt, "wpa-eap") == 0) {
+ bss_data->security = WIFI_SECURITY_IEEE8021X;
+ } else if (strcmp(str_keymgmt, "wpa-eap-sha256") == 0) {
+ bss_data->security = WIFI_SECURITY_IEEE8021X;
+ } else if (strcmp(str_keymgmt, "wps") == 0) {
+ bss_data->wps = TRUE;
+ }
+}
+
+static void __netconfig_wifi_parse_keymgmt_message(DBusMessageIter *iter, struct bss_info_t *bss_data)
+{
+ DBusMessageIter dict, entry, array, value;
+ const char *key;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return;
+
+ dbus_message_iter_recurse(iter, &dict);
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ dbus_message_iter_recurse(&dict, &entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
+ return;
+
+ dbus_message_iter_get_basic(&entry, &key);
+ if (g_strcmp0(key, "KeyMgmt") == 0) {
+ dbus_message_iter_next(&entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+ return;
+
+ dbus_message_iter_recurse(&entry, &array);
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+ return;
+
+ dbus_message_iter_recurse(&array, &value);
+ while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
+ const char *str = NULL;
+
+ dbus_message_iter_get_basic(&value, &str);
+ if (str == NULL)
+ return;
+
+ __netconfig_wifi_check_security(str, bss_data);
+ dbus_message_iter_next(&value);
+ }
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+}
+
+gboolean netconfig_wifi_get_ssid_scan_state(void)
+{
+ return wifi_ssid_scan_state;
+}
+
+void netconfig_wifi_notify_ssid_scan_done(DBusMessage *message)
+{
+ DBusMessageIter args;
+ dbus_bool_t val = FALSE;
+
+ if (netconfig_wifi_get_ssid_scan_state() != TRUE)
+ return;
+
+ __netconfig_wifi_ssid_scan_stop();
+
+ INFO("SSID scan finishes");
+
+ if (!dbus_message_iter_init(message, &args))
+ DBG("Message does not have parameters");
+ else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN)
+ DBG("Argument is not boolean");
+ else {
+ dbus_message_iter_get_basic(&args, &val);
+ DBG("!!!!!!! SpecificScanDone : %d", val);
+
+ __netconfig_wifi_notify_ssid_scan_done();
+ }
+}
+
+void netconfig_wifi_bss_added(DBusMessage *message)
+{
+ DBusMessageIter iter, dict, entry;
+ DBusMessageIter value, array;
+ const char *key;
+ struct bss_info_t *bss_info;
+
+ if (netconfig_wifi_get_ssid_scan_state() != TRUE)
+ return;
+
+ INFO("NEW BSS added");
+
+ if (!dbus_message_iter_init(message, &iter)) {
+ DBG("Message does not have parameters");
+ return;
+ }
+
+ dbus_message_iter_next(&iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
+ DBG("Invalid message type");
+ return;
+ }
+
+ bss_info = g_try_new0(struct bss_info_t, 1);
+
+ dbus_message_iter_recurse(&iter, &dict);
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ dbus_message_iter_recurse(&dict, &entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
+ return;
+
+ dbus_message_iter_get_basic(&entry, &key);
+ if (key == NULL)
+ return;
+
+ dbus_message_iter_next(&entry);
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+ return;
+
+ dbus_message_iter_recurse(&entry, &value);
+
+ if (g_strcmp0(key, "SSID") == 0) {
+ unsigned char *ssid;
+ int ssid_len;
+
+ dbus_message_iter_recurse(&value, &array);
+ dbus_message_iter_get_fixed_array(&array, &ssid, &ssid_len);
+
+ if (ssid_len > 0 && ssid_len < 33)
+ memcpy(bss_info->ssid, ssid, ssid_len);
+ else
+ memset(bss_info->ssid, 0, sizeof(bss_info->ssid));
+ } else if (g_strcmp0(key, "Privacy") == 0) {
+ dbus_bool_t privacy = FALSE;
+
+ dbus_message_iter_get_basic(&value, &privacy);
+ bss_info->privacy = privacy;
+ } else if ((g_strcmp0(key, "RSN") == 0) || (g_strcmp0(key, "WPA") == 0)) {
+
+ __netconfig_wifi_parse_keymgmt_message(&value, bss_info);
+ } else if (g_strcmp0(key, "IEs") == 0) {
+ unsigned char *ie;
+ int ie_len;
+
+ dbus_message_iter_recurse(&value, &array);
+ dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+ if (bss_info->ssid == NULL) {
+ g_free(bss_info);
+ return;
+ }
+
+ if (bss_info->security == WIFI_SECURITY_UNKNOWN) {
+ if (bss_info->privacy == TRUE)
+ bss_info->security = WIFI_SECURITY_WEP;
+ else
+ bss_info->security = WIFI_SECURITY_NONE;
+ }
+
+ wifi_bss_info_list = g_slist_append(wifi_bss_info_list, bss_info);
+}
+
+gboolean netconfig_iface_wifi_request_specific_scan(NetconfigWifi *wifi,
+ gchar *ssid, GError **error)
+{
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ /* TODO: If already scan with SSID, make error in-progress */
+ /* if (netconfig_wifi_get_ssid_scan_state() != TRUE)
+ * netconfig_error_ssid_scan_in_progress();
+ */
+
+ return __netconfig_wifi_ssid_scan((const char *)ssid);
+}
*
* Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Danny JS Seo <S.Seo@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
#include <vconf.h>
#include <vconf-keys.h>
+#include <syspopup_caller.h>
#include "log.h"
-#include "dbus.h"
#include "util.h"
+#include "netdbus.h"
+#include "network-statistics.h"
#include "wifi-state.h"
#include "wifi-background-scan.h"
+static int profiles_count = 0;
+
static enum netconfig_wifi_service_state
wifi_service_state = NETCONFIG_WIFI_UNKNOWN;
-void netconfig_wifi_state_set_service_state(
- enum netconfig_wifi_service_state state)
+static GSList *notifier_list = NULL;
+
+
+static gboolean __netconfig_wifi_add_network_notification(void)
+{
+ int rv = 0;
+ bundle *b = NULL;
+
+ b = bundle_create();
+ bundle_add(b, "_SYSPOPUP_TYPE_", "wifi_notification");
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "add");
+
+ DBG("Register Wi-Fi network notification");
+ rv = syspopup_launch("net-popup", b);
+
+ bundle_free(b);
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_del_network_notification(void)
+{
+ int rv = 0;
+ bundle *b = NULL;
+
+ b = bundle_create();
+ bundle_add(b, "_SYSPOPUP_TYPE_", "wifi_notification");
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "delete");
+
+ DBG("Delete Wi-Fi network notification");
+ rv = syspopup_launch("net-popup", b);
+
+ bundle_free(b);
+
+ return TRUE;
+}
+
+static void __netconfig_wifi_set_profiles_count(const int count)
{
- if (wifi_service_state != state)
- wifi_service_state = state;
+ profiles_count = count;
+}
+
+static int __netconfig_wifi_get_profiles_count(void)
+{
+ return profiles_count;
}
static GSList *__netconfig_wifi_state_get_service_profiles(DBusMessage *message)
return service_profiles;
}
-static enum netconfig_wifi_service_state
-__netconfig_wifi_state_get_state_from_service(DBusMessage *message)
+static char *__netconfig_wifi_get_connman_favorite_service(void)
{
- enum netconfig_wifi_service_state wifi_state = NETCONFIG_WIFI_UNKNOWN;
- DBusMessageIter iter, array;
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, dict;
- const char *key = NULL;
- const char *temp = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- if (g_str_equal(key, "Type") == TRUE) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &dict);
- dbus_message_iter_get_basic(&dict, &temp);
-
- if (g_str_equal(temp, "wifi") == TRUE)
- break;
- else
- return wifi_state;
- }
-
- dbus_message_iter_next(&array);
- }
-
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, variant;
- const char *key = NULL;
- const char *value = NULL;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &variant);
-
- if (g_str_equal(key, "State") != TRUE) {
- dbus_message_iter_next(&array);
- continue;
- }
-
- dbus_message_iter_get_basic(&variant, &value);
-
- if (g_str_equal(value, "idle") == TRUE)
- wifi_state = NETCONFIG_WIFI_IDLE;
- else if (g_str_equal(value, "failure") == TRUE)
- wifi_state = NETCONFIG_WIFI_IDLE;
- else if (g_str_equal(value, "association") == TRUE)
- wifi_state = NETCONFIG_WIFI_CONNECTING;
- else if (g_str_equal(value, "configuration") == TRUE)
- wifi_state = NETCONFIG_WIFI_CONNECTING;
- else if (g_str_equal(value, "ready") == TRUE)
- wifi_state = NETCONFIG_WIFI_CONNECTED;
- else if (g_str_equal(value, "disconnect") == TRUE)
- wifi_state = NETCONFIG_WIFI_IDLE;
- else if (g_str_equal(value, "online") == TRUE)
- wifi_state = NETCONFIG_WIFI_CONNECTED;
- else
- wifi_state = NETCONFIG_WIFI_UNKNOWN;
-
- break;
- }
-
- return wifi_state;
-}
-
-static enum netconfig_wifi_service_state
-__netconfig_wifi_state_get_connman_service_state(void)
-{
- enum netconfig_wifi_service_state wifi_state = NETCONFIG_WIFI_UNKNOWN;
- DBusConnection *connection = NULL;
+ char *favorite_service = NULL;
DBusMessage *message = NULL;
GSList *service_profiles = NULL;
GSList *list = NULL;
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Failed to get system bus");
-
- return wifi_state;
- }
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties");
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL);
if (message == NULL) {
ERR("Failed to get service list");
- dbus_connection_unref(connection);
- return wifi_state;
+ return NULL;
}
/* Get service profiles from ConnMan Manager */
for (list = service_profiles; list != NULL; list = list->next) {
char *profile_path = list->data;
- enum netconfig_wifi_service_state wifi_service_state = wifi_state;
+ DBusMessageIter iter, array;
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection,
- profile_path, CONNMAN_SERVICE_INTERFACE, "GetProperties");
+ if (favorite_service != NULL)
+ break;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ profile_path, CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
if (message == NULL) {
ERR("Failed to get service information of %s", profile_path);
continue;
}
- /* Get service information from ConnMan Service */
- wifi_service_state = __netconfig_wifi_state_get_state_from_service(message);
- if (wifi_state < wifi_service_state)
- wifi_state = wifi_service_state;
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, variant;
+ const char *key = NULL;
+ dbus_bool_t value;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+
+ if (g_str_equal(key, "Favorite") != TRUE) {
+ dbus_message_iter_next(&array);
+ continue;
+ }
+
+ dbus_message_iter_get_basic(&variant, &value);
+
+ if (value)
+ favorite_service = g_strdup(profile_path);
+
+ break;
+ }
dbus_message_unref(message);
}
g_slist_free(service_profiles);
- dbus_connection_unref(connection);
- return wifi_state;
+ return favorite_service;
}
-enum netconfig_wifi_service_state
-netconfig_wifi_state_get_service_state(void)
+static void __netconfig_wifi_state_changed(
+ enum netconfig_wifi_service_state state)
+{
+ GSList *list;
+
+ for (list = notifier_list; list; list = list->next) {
+ struct netconfig_wifi_state_notifier *notifier = list->data;
+
+ if (notifier->netconfig_wifi_state_changed != NULL)
+ notifier->netconfig_wifi_state_changed(state, notifier->user_data);
+ }
+}
+
+void netconfig_wifi_state_set_service_state(
+ enum netconfig_wifi_service_state state)
{
+ if (wifi_service_state == state)
+ return;
+
+ wifi_service_state = state;
+ DBG("Wi-Fi state %d", state);
+
if (wifi_service_state == NETCONFIG_WIFI_CONNECTED)
- return NETCONFIG_WIFI_CONNECTED;
+ __netconfig_wifi_del_network_notification();
+
+ __netconfig_wifi_state_changed(state);
+}
- return __netconfig_wifi_state_get_connman_service_state();
+enum netconfig_wifi_service_state
+netconfig_wifi_state_get_service_state(void)
+{
+ return wifi_service_state;
}
gchar *netconfig_wifi_get_technology_state(void)
{
- DBusConnection *connection = NULL;
DBusMessage *message = NULL;
DBusMessageIter args, dict;
gboolean wifi_tech_available = FALSE;
gboolean wifi_tech_enabled = FALSE;
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (connection == NULL) {
- ERR("Failed to get system bus");
- return NULL;
- }
-
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection,
- CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties");
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL);
if (message == NULL) {
ERR("Failed to get Wi-Fi technology state");
- dbus_connection_unref(connection);
return NULL;
}
}
dbus_message_unref(message);
- dbus_connection_unref(connection);
if (wifi_tech_enabled)
return g_strdup("EnabledTechnologies");
netconfig_wifi_bgscan_start();
}
} else {
- netconfig_wifi_bgscan_stop();
-
if (wifi_state != VCONFKEY_WIFI_OFF) {
DBG("Wi-Fi successfully turned off");
+ __netconfig_wifi_del_network_notification();
+
+ netconfig_wifi_bgscan_stop();
+
+ __netconfig_wifi_set_profiles_count(0);
+
vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_OFF);
vconf_set_int(VCONF_WIFI_LAST_POWER_STATE, WIFI_POWER_OFF);
}
}
}
+
+char *netconfig_wifi_get_favorite_service(void)
+{
+ return __netconfig_wifi_get_connman_favorite_service();
+}
+
+void netconfig_wifi_check_network_notification(void)
+{
+ DBusMessage *message = NULL;
+ DBusMessageIter iter, dict;
+ int profiles_count = 0;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service list");
+ return;
+ }
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter keyValue, array, value;
+ const char *key = NULL;
+ const char *object_path = NULL;
+
+ dbus_message_iter_recurse(&dict, &keyValue);
+ dbus_message_iter_get_basic(&keyValue, &key);
+
+ if (g_str_equal(key, "Services") != TRUE) {
+ dbus_message_iter_next(&dict);
+ continue;
+ }
+
+ dbus_message_iter_next(&keyValue);
+ dbus_message_iter_recurse(&keyValue, &array);
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+ continue;
+
+ dbus_message_iter_recurse(&array, &value);
+ while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
+ dbus_message_iter_get_basic(&value, &object_path);
+
+ if (g_str_has_prefix(object_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
+ profiles_count++;
+
+ dbus_message_iter_next(&value);
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+ dbus_message_unref(message);
+
+ if (__netconfig_wifi_get_profiles_count() < profiles_count) {
+ DBG("profiles prev_count (%d) - profiles count (%d)",
+ __netconfig_wifi_get_profiles_count(), profiles_count);
+
+ __netconfig_wifi_add_network_notification();
+ }
+
+ __netconfig_wifi_set_profiles_count(profiles_count);
+}
+
+void netconfig_wifi_state_notifier_cleanup(void)
+{
+ g_slist_free_full(notifier_list, NULL);
+}
+
+void netconfig_wifi_state_notifier_register(
+ struct netconfig_wifi_state_notifier *notifier)
+{
+ DBG("register notifier");
+
+ notifier_list = g_slist_append(notifier_list, notifier);
+}
+
+void netconfig_wifi_state_notifier_unregister(
+ struct netconfig_wifi_state_notifier *notifier)
+{
+ DBG("un-register notifier");
+
+ notifier_list = g_slist_remove_all(notifier_list, notifier);
+}