From: Danny Jeongseok Seo Date: Tue, 21 Aug 2012 09:13:01 +0000 (+0900) Subject: Release Tizen 2.0 beta X-Git-Tag: 2.0_alpha^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;p=framework%2Fconnectivity%2Fnet-config.git Release Tizen 2.0 beta --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a365b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 51be390..4d89a09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,20 @@ SET(LIBDIR "${PREFIX}/lib") 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 "") @@ -27,11 +31,10 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(pkgs REQUIRED - dbus-1 glib-2.0 dbus-glib-1 - vconf dlog + vconf wifi-direct syspopup-caller) @@ -66,6 +69,12 @@ ADD_CUSTOM_TARGET(netconfig-iface-network-state-glue.h ${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 @@ -74,6 +83,7 @@ ADD_CUSTOM_TARGET(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}) diff --git a/LICENSE b/LICENSE index 38d434f..181359e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,203 +1,203 @@ -Copyright (c) 2000 - 2011 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. +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. diff --git a/debian/changelog b/debian/changelog index fde9244..2473bca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,160 @@ +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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 Tue, 05 Jun 2012 10:41:42 +0900 @@ -9,7 +162,7 @@ net-config (0.1.85-2) unstable; urgency=low 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 Fri, 01 Jun 2012 15:12:49 +0900 @@ -17,7 +170,7 @@ net-config (0.1.85-1) unstable; urgency=low 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 Wed, 30 May 2012 13:34:17 +0900 @@ -25,7 +178,7 @@ net-config (0.1.84-1) unstable; urgency=low 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 Thu, 17 May 2012 17:55:47 +0900 @@ -33,7 +186,7 @@ net-config (0.1.83) unstable; urgency=low 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 Thu, 17 May 2012 16:20:17 +0900 @@ -41,7 +194,7 @@ net-config (0.1.82) unstable; urgency=low 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 Tue, 15 May 2012 13:54:28 +0900 @@ -49,7 +202,7 @@ net-config (0.1.81) unstable; urgency=low 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 Wed, 09 May 2012 15:13:52 +0900 @@ -58,7 +211,7 @@ net-config (0.1.79) unstable; urgency=low * 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 Wed, 09 May 2012 11:41:09 +0900 @@ -66,7 +219,7 @@ net-config (0.1.79) unstable; urgency=low 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 Tue, 08 May 2012 15:55:04 +0900 @@ -75,7 +228,7 @@ net-config (0.1.77) unstable; urgency=low * 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 Tue, 24 Apr 2012 23:08:11 +0900 @@ -83,7 +236,7 @@ net-config (0.1.77) unstable; urgency=low 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 Tue, 17 Apr 2012 10:28:08 +0900 @@ -92,7 +245,7 @@ net-config (0.1.75) unstable; urgency=low * 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 Fri, 13 Apr 2012 16:37:55 +0900 @@ -100,7 +253,7 @@ net-config (0.1.75) unstable; urgency=low 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 Thu, 12 Apr 2012 22:06:27 +0900 @@ -108,7 +261,7 @@ net-config (0.1.74) unstable; urgency=low 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 Mon, 02 Apr 2012 17:27:06 +0900 @@ -116,7 +269,7 @@ net-config (0.1.73) unstable; urgency=low 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 Thu, 29 Mar 2012 10:45:15 +0900 @@ -124,7 +277,7 @@ net-config (0.1.72) unstable; urgency=low 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 Tue, 27 Mar 2012 14:01:40 +0900 @@ -132,15 +285,15 @@ net-config (0.1.71) unstable; urgency=low 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 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 Fri, 16 Mar 2012 10:21:53 +0900 @@ -148,7 +301,7 @@ net-config (0.1.69) unstable; urgency=low 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 Thu, 15 Mar 2012 13:33:17 +0900 @@ -156,7 +309,7 @@ net-config (0.1.68) unstable; urgency=low 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 Wed, 14 Mar 2012 21:31:57 +0900 @@ -164,7 +317,7 @@ net-config (0.1.67) unstable; urgency=low 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 Wed, 14 Mar 2012 19:00:26 +0900 @@ -172,7 +325,7 @@ net-config (0.1.66) unstable; urgency=low 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 Thu, 08 Mar 2012 22:17:24 +0900 @@ -180,7 +333,7 @@ net-config (0.1.65) unstable; urgency=low 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 Tue, 06 Mar 2012 21:11:08 +0900 diff --git a/include/emulator.h b/include/emulator.h index e652232..3bff8b2 100644 --- a/include/emulator.h +++ b/include/emulator.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/log.h b/include/log.h index 8f72a1d..9aca9e5 100644 --- a/include/log.h +++ b/include/log.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/mdm-private.h b/include/mdm-private.h new file mode 100644 index 0000000..8a44f93 --- /dev/null +++ b/include/mdm-private.h @@ -0,0 +1,35 @@ +/* + * 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 + +gboolean netconfig_is_wifi_allowed(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MDM_PRIVATE_H_ */ diff --git a/include/netconfig.h b/include/netconfig.h index 8d06770..7626ef8 100644 --- a/include/netconfig.h +++ b/include/netconfig.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/dbus.h b/include/netdbus.h similarity index 67% rename from include/dbus.h rename to include/netdbus.h index 505f48d..b3f1fb7 100644 --- a/include/dbus.h +++ b/include/netdbus.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -19,8 +17,8 @@ * */ -#ifndef __NETCONFIG_DBUS_H__ -#define __NETCONFIG_DBUS_H__ +#ifndef __NETCONFIG_NETDBUS_H__ +#define __NETCONFIG_NETDBUS_H__ #ifdef __cplusplus extern "C" { @@ -33,11 +31,6 @@ extern "C" { #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" @@ -46,6 +39,9 @@ extern "C" { #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 @@ -54,19 +50,9 @@ typedef enum { 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[]); +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); @@ -77,4 +63,4 @@ DBusGConnection *netconfig_setup_dbus(void); } #endif -#endif /* __NETCONFIG_DBUS_H__ */ +#endif /* __NETCONFIG_NETDBUS_H__ */ diff --git a/include/neterror.h b/include/neterror.h index 9c6af38..512872e 100644 --- a/include/neterror.h +++ b/include/neterror.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/netsupplicant.h b/include/netsupplicant.h new file mode 100644 index 0000000..4538a00 --- /dev/null +++ b/include/netsupplicant.h @@ -0,0 +1,52 @@ +/* + * 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 +#include +#include + +#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__ */ diff --git a/include/network-state.h b/include/network-state.h index 04970b1..d52ba9a 100644 --- a/include/network-state.h +++ b/include/network-state.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/network-statistics.h b/include/network-statistics.h new file mode 100644 index 0000000..2af172f --- /dev/null +++ b/include/network-statistics.h @@ -0,0 +1,73 @@ +/* + * 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 +#include + +#include + +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_ */ diff --git a/include/signal-handler.h b/include/signal-handler.h index 311b5e7..0864452 100644 --- a/include/signal-handler.h +++ b/include/signal-handler.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/util.h b/include/util.h index d4a0638..32a6526 100644 --- a/include/util.h +++ b/include/util.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/include/wifi-background-scan.h b/include/wifi-background-scan.h index 52781a3..97fc1f6 100644 --- a/include/wifi-background-scan.h +++ b/include/wifi-background-scan.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -26,6 +24,8 @@ extern "C" { #endif +#include "wifi.h" + void netconfig_wifi_bgscan_start(void); void netconfig_wifi_bgscan_stop(void); diff --git a/include/wifi-indicator.h b/include/wifi-indicator.h index 686a5a1..755f4a4 100644 --- a/include/wifi-indicator.h +++ b/include/wifi-indicator.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -26,6 +24,8 @@ extern "C" { #endif +int netconfig_wifi_get_rssi(void); + void netconfig_wifi_indicator_start(void); void netconfig_wifi_indicator_stop(void); diff --git a/include/wifi-ssid-scan.h b/include/wifi-ssid-scan.h new file mode 100644 index 0000000..41dc843 --- /dev/null +++ b/include/wifi-ssid-scan.h @@ -0,0 +1,49 @@ +/* + * 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__ */ diff --git a/include/wifi-state.h b/include/wifi-state.h index 641bd5d..a5694e6 100644 --- a/include/wifi-state.h +++ b/include/wifi-state.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -26,6 +24,8 @@ extern "C" { #endif +#include + enum netconfig_wifi_service_state { NETCONFIG_WIFI_UNKNOWN = 0x00, NETCONFIG_WIFI_IDLE = 0x01, @@ -33,15 +33,32 @@ enum netconfig_wifi_service_state { 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 diff --git a/include/wifi.h b/include/wifi.h index 0961601..9134fdc 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/interfaces/netconfig-iface-network-statistics.xml b/interfaces/netconfig-iface-network-statistics.xml new file mode 100644 index 0000000..d436a61 --- /dev/null +++ b/interfaces/netconfig-iface-network-statistics.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/interfaces/netconfig-iface-wifi.xml b/interfaces/netconfig-iface-wifi.xml index 00297ee..4f2aae0 100644 --- a/interfaces/netconfig-iface-wifi.xml +++ b/interfaces/netconfig-iface-wifi.xml @@ -10,6 +10,9 @@ + + + diff --git a/packaging/net-config.changes b/packaging/net-config.changes deleted file mode 100644 index 0b82cf7..0000000 --- a/packaging/net-config.changes +++ /dev/null @@ -1,8 +0,0 @@ -* Thu Jul 19 2012 Danny JS Seo - 0.1.85_2 -- Upgrade net-config according to the ConnMan 0.78 - -* Thu Jul 12 09:37:03 CST 2012 Arron - 0.1.74 -- Add systemd support - -* Fri Jun 15 2012 Chris Leech - 0.1.74 -- move dbus files from /usr/etc/dbus-1 to /etc/dbus-1 diff --git a/packaging/net-config.manifest b/packaging/net-config.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/net-config.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/net-config.service b/packaging/net-config.service deleted file mode 100644 index 5a564b6..0000000 --- a/packaging/net-config.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=net config service -After=syslog.target - -[Service] -Type=forking -ExecStart=/usr/sbin/net-config - -[Install] -WantedBy=multi-user.target diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 0e86bed..993f809 100644 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,28 +1,20 @@ -#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 @@ -32,7 +24,6 @@ TIZEN Network Configuration Module %setup -q %build -cp %{SOURCE1001} . cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} make %{?jobs:-j%jobs} @@ -42,8 +33,8 @@ rm -rf %{buildroot} 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 @@ -53,11 +44,6 @@ ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc3.d/S60net-config 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 @@ -92,25 +78,15 @@ vconftool set -t int file/private/wifi/last_power_state "0" #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 diff --git a/resources/etc/rc.d/init.d/net-config b/resources/etc/rc.d/init.d/net-config index c9be073..91d0d33 100755 --- a/resources/etc/rc.d/init.d/net-config +++ b/resources/etc/rc.d/init.d/net-config @@ -1,13 +1,10 @@ #!/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 diff --git a/src/dbus.c b/src/dbus.c deleted file mode 100644 index 64b08d5..0000000 --- a/src/dbus.c +++ /dev/null @@ -1,828 +0,0 @@ -/* - * Network Configuration Module - * - * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Danny JS Seo - * - * 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 -#include -#include - -#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; -} diff --git a/src/dbus/netdbus.c b/src/dbus/netdbus.c new file mode 100644 index 0000000..8be22c1 --- /dev/null +++ b/src/dbus/netdbus.c @@ -0,0 +1,457 @@ +/* + * 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 +#include +#include + +#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; +} diff --git a/src/dbus/netsupplicant.c b/src/dbus/netsupplicant.c new file mode 100644 index 0000000..15249c7 --- /dev/null +++ b/src/dbus/netsupplicant.c @@ -0,0 +1,273 @@ +/* + * 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; +} diff --git a/src/main.c b/src/main.c index bedaed1..8c6ecfd 100644 --- a/src/main.c +++ b/src/main.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -22,10 +20,11 @@ #include #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; @@ -55,11 +54,15 @@ int main(int argc, char* argv[]) 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; diff --git a/src/neterror.c b/src/neterror.c index ba3cb45..ac5cc5d 100644 --- a/src/neterror.c +++ b/src/neterror.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/src/network-state.c b/src/network-state.c index 4a81a5d..add6492 100644 --- a/src/network-state.c +++ b/src/network-state.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -143,6 +141,7 @@ static void __netconfig_pop_3g_alert_syspoppup(void) 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"); diff --git a/src/network-statistics.c b/src/network-statistics.c new file mode 100644 index 0000000..731f4eb --- /dev/null +++ b/src/network-statistics.c @@ -0,0 +1,451 @@ +/* + * 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 +#include + +#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; +} diff --git a/src/signal-handler.c b/src/signal-handler.c index 66e5453..4f39cb1 100644 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -27,18 +25,26 @@ #include #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; @@ -126,7 +132,6 @@ static void __netconfig_wifi_technology_state_signal_handler( 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); @@ -144,7 +149,6 @@ static void netconfig_wifi_set_essid(const char *active_profile) { int err; char *essid_name = NULL; - DBusConnection *connection = NULL; DBusMessage *message = NULL; int MessageType = 0; @@ -153,18 +157,11 @@ static void netconfig_wifi_set_essid(const char *active_profile) 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; } @@ -193,8 +190,6 @@ static void netconfig_wifi_set_essid(const char *active_profile) done: dbus_message_unref(message); - - dbus_connection_unref(connection); } static void netconfig_wifi_unset_essid(void) @@ -218,7 +213,8 @@ static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg, cons 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"); @@ -234,16 +230,17 @@ static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg, cons 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); @@ -252,7 +249,8 @@ static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg, cons 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 @@ -275,6 +273,51 @@ static DBusHandlerResult __netconfig_signal_filter_handler( 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; @@ -287,14 +330,17 @@ static DBusHandlerResult __netconfig_signal_filter_handler( 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) @@ -306,12 +352,20 @@ static DBusHandlerResult __netconfig_signal_filter_handler( 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; } @@ -362,8 +416,16 @@ void netconfig_register_signal(void) 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; } @@ -378,8 +440,8 @@ void netconfig_deregister_signal(void) 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); diff --git a/src/emulator.c b/src/utils/emulator.c similarity index 98% rename from src/emulator.c rename to src/utils/emulator.c index 1dda48b..d220d62 100644 --- a/src/emulator.c +++ b/src/utils/emulator.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 diff --git a/src/utils/mdm-private.c b/src/utils/mdm-private.c new file mode 100644 index 0000000..26c569b --- /dev/null +++ b/src/utils/mdm-private.c @@ -0,0 +1,25 @@ +/* + * 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; +} diff --git a/src/util.c b/src/utils/util.c similarity index 77% rename from src/util.c rename to src/utils/util.c index 7287f22..f6ac1bf 100644 --- a/src/util.c +++ b/src/utils/util.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -101,73 +99,28 @@ void netconfig_stop_timer(guint *timer_id) } } -static gboolean __netconfig_wifi_state_device_picker_trials(gboolean is_clear_mode) +static gboolean __netconfig_test_device_picker() { - 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; - } + char *favorite_wifi_service = NULL; - if (*wifi_state == NETCONFIG_WIFI_CONNECTED) + favorite_wifi_service = netconfig_wifi_get_favorite_service(); + if (favorite_wifi_service != NULL) { + g_free(favorite_wifi_service); return FALSE; + } return TRUE; } -static gboolean __netconfig_pop_device_picker(void) +static void __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; + return; b = bundle_create(); @@ -175,25 +128,12 @@ static gboolean __netconfig_pop_device_picker(void) 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(); + if (__netconfig_test_device_picker() == TRUE) + __netconfig_pop_device_picker(); return FALSE; } @@ -238,7 +178,6 @@ void netconfig_wifi_device_picker_service_start(void) 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); } @@ -255,7 +194,6 @@ void netconfig_wifi_device_picker_service_stop(void) 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) diff --git a/src/wifi-background-scan.c b/src/wifi-background-scan.c index 2fd5e55..07be1b9 100644 --- a/src/wifi-background-scan.c +++ b/src/wifi-background-scan.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -24,9 +22,9 @@ #include #include "log.h" -#include "dbus.h" #include "util.h" #include "wifi.h" +#include "netdbus.h" #include "wifi-state.h" #include "wifi-background-scan.h" @@ -81,34 +79,23 @@ static guint __netconfig_wifi_bgscan_get_mode(void) 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; } diff --git a/src/wifi-indicator.c b/src/wifi-indicator.c index 621c94a..0db76ed 100644 --- a/src/wifi-indicator.c +++ b/src/wifi-indicator.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -29,72 +27,45 @@ #include #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); @@ -102,127 +73,66 @@ static int __netconfig_wifi_get_interface(const char **path) 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); @@ -232,15 +142,9 @@ static int __netconfig_wifi_set_rssi_level(gboolean is_start, const char *ifname 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); @@ -248,200 +152,96 @@ static int __netconfig_wifi_set_rssi_level(gboolean is_start, const char *ifname 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) diff --git a/src/wifi-power.c b/src/wifi-power.c index 5dd06ad..7a5a6c5 100644 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -27,21 +25,22 @@ #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 @@ -161,23 +160,16 @@ static gboolean __netconfig_wifi_enable_technology(void) { 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; } @@ -190,23 +182,16 @@ static gboolean __netconfig_wifi_disable_technology(void) { 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; } @@ -295,6 +280,9 @@ static gboolean __netconfig_wifi_try_to_load_driver(void) 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; */ @@ -318,7 +306,6 @@ static gboolean __netconfig_wifi_try_to_load_driver(void) __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"); @@ -330,11 +317,13 @@ static gboolean __netconfig_wifi_try_to_load_driver(void) 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; } @@ -350,11 +339,12 @@ static gboolean __netconfig_wifi_try_to_remove_driver(void) 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"); @@ -363,10 +353,13 @@ static gboolean __netconfig_wifi_try_to_remove_driver(void) 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) { @@ -472,6 +465,40 @@ static void __netconfig_wifi_power_configuration(void) } } +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; @@ -498,12 +525,19 @@ gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error) 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; } @@ -519,5 +553,6 @@ gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error) return FALSE; } + __netconfig_wifi_notify_power_completed(FALSE); return TRUE; } diff --git a/src/wifi-ssid-scan.c b/src/wifi-ssid-scan.c new file mode 100644 index 0000000..dd1cba3 --- /dev/null +++ b/src/wifi-ssid-scan.c @@ -0,0 +1,467 @@ +/* + * 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); +} diff --git a/src/wifi-state.c b/src/wifi-state.c index e46ab9e..1a67115 100644 --- a/src/wifi-state.c +++ b/src/wifi-state.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Danny JS Seo - * * 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 @@ -21,21 +19,65 @@ #include #include +#include #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) @@ -83,104 +125,19 @@ 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 */ @@ -189,58 +146,99 @@ __netconfig_wifi_state_get_connman_service_state(void) 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; } @@ -284,7 +282,6 @@ next_dict: } dbus_message_unref(message); - dbus_connection_unref(connection); if (wifi_tech_enabled) return g_strdup("EnabledTechnologies"); @@ -315,11 +312,15 @@ void netconfig_wifi_update_power_state(gboolean powered) 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); @@ -328,3 +329,88 @@ void netconfig_wifi_update_power_state(gboolean powered) } } } + +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); +}