+++ /dev/null
-Jeik Jaehyun Kim <jeik01.kim@samsung.com>
-Danny Jeongseok Seo <s.seo@samsung.com>
--- /dev/null
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+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.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+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
+solely as incorporated into a Tizen Certified Platform, 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 solely
+as incorporated into a Tizen Certified Platform 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 pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works
+ a copy of this License; and
+ 2. You must cause any modified files to carry prominent notices stating
+ that You changed the files; and
+ 3. 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
+ 4. 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
+ and your own copyright statement or terms and conditions do not conflict
+ the conditions stated in the License including section 3.
+
+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 Flora License to your work
+
+To apply the Flora 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 Flora License, Version 1.1 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://floralicense.org/license/
+
+ 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.
+
+++ /dev/null
-Flora License
-
-Version 1.1, April, 2013
-
-http://floralicense.org/license/
-
-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.
-
-"Tizen Certified Platform" shall mean a software platform that complies
-with the standards set forth in the Tizen Compliance Specification
-and passes the Tizen Compliance Tests as defined from time to time
-by the Tizen Technical Steering Group and certified by the Tizen
-Association or its designated agent.
-
-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
-solely as incorporated into a Tizen Certified Platform, 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 solely
-as incorporated into a Tizen Certified Platform 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 pursuant to the copyright license
-above, in any medium, with or without modifications, and in Source or
-Object form, provided that You meet the following conditions:
-
- 1. You must give any other recipients of the Work or Derivative Works
- a copy of this License; and
- 2. You must cause any modified files to carry prominent notices stating
- that You changed the files; and
- 3. 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
- 4. 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
- and your own copyright statement or terms and conditions do not conflict
- the conditions stated in the License including section 3.
-
-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 Flora License to your work
-
-To apply the Flora 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 Flora License, Version 1.1 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://floralicense.org/license/
-
- 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.
-
-CPPFLAGS = $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(DLOG_CFLAGS) $(VCONF_CFLAGS)
-CPPFLAGS += -Wall
+CPPFLAGS = $(GIO_CFLAGS) $(GLIB_CFLAGS) $(DLOG_CFLAGS) $(VCONF_CFLAGS) $(WAPI_CFLAGS) $(DUALSIM_CFLAGS) $(WEARABLE_CFLAGS) $(TIZEN_TV_CFLAGS)
+CPPFLAGS += -Wall -Werror -fvisibility=hidden
ACLOCAL_AMFLAGS = -I m4
libnetwork_la_CFLAGS += $(CPPFLAGS)
libnetwork_la_LIBADD = \
- $(DBUS_LIBS) $(GLIB_LIBS) $(VCONF_LIBS) \
+ $(GIO_LIBS) $(GLIB_LIBS) $(VCONF_LIBS) \
$(GTHREAD_LIBS) $(DLOG_LIBS) -lpthread -lrt
includelibnetworkdir = $(includedir)/network
+++ /dev/null
-Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
-Except as noted, this software is licensed under Flora License, Version 1.1.
-Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions.
-
--- /dev/null
+aclocal
+libtoolize
+autoheader
+autoconf
+automake --add-missing --copy --foreign
LT_INIT
-# Checks for moduels.
+# Checks for modules.
PKG_CHECK_MODULES(DLOG, dlog)
AC_SUBST(DLOG_CFLAGS)
AC_SUBST(DLOG_LIBS)
AC_SUBST(VCONF_CFLAGS)
AC_SUBST(VCONF_LIBS)
+PKG_CHECK_MODULES(GIO, gio-2.0)
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+
PKG_CHECK_MODULES(GLIB, glib-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
-AC_SUBST(GTHREAD_CFLAS)
+AC_SUBST(GTHREAD_CFLAGS)
AC_SUBST(GTHREAD_LIBS)
-PKG_CHECK_MODULES(DBUS, dbus-glib-1)
-AC_SUBST(DBUS_CFLAS)
-AC_SUBST(DBUS_LIBS)
-
-PKG_CHECK_MODULES(GIO, gio-2.0)
-AC_SUBST(GIO_CFLAS)
-AC_SUBST(GIO_LIBS)
-
if (!test $ARCH = "arm"); then
AM_CONDITIONAL(ARM_BUILD, false)
else
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
/** Close Connection Response Event*/
NET_EVENT_CLOSE_RSP,
-
+
/** Open connection Indication (auto join) */
NET_EVENT_OPEN_IND,
/** Profile modify indication Event\n
* This is deprecated Event and maintained only for compatibility */
NET_EVENT_PROFILE_MODIFY_IND,
-
+
/** Network configuration changed Event\n
* This is deprecated Event and maintained only for compatibility */
NET_EVENT_NET_CONFIGURE_RSP,
/** Wi-Fi interface Scan Response Event */
NET_EVENT_WIFI_SCAN_RSP,
-
+
/** Wi-Fi interface Scan Indication Event(BG scan) */
NET_EVENT_WIFI_SCAN_IND,
/** Wi-Fi interface MAC changed Event\n
* This is deprecated Event and maintained only for compatibility */
NET_EVENT_WIFI_MAC_ID_IND,
-
+
/** Wi-Fi interface Power On/Off Response Event */
NET_EVENT_WIFI_POWER_RSP,
*/
typedef enum
{
- NET_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0, /**< Last received data */
- NET_STATISTICS_TYPE_LAST_SENT_DATA = 1, /**< Last sent data */
- NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2, /**< Total received data */
- NET_STATISTICS_TYPE_TOTAL_SENT_DATA = 3, /**< Total sent data */
+ NET_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0, /**< Last received data */
+ NET_STATISTICS_TYPE_LAST_SENT_DATA = 1, /**< Last sent data */
+ NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2, /**< Total received data */
+ NET_STATISTICS_TYPE_TOTAL_SENT_DATA = 3, /**< Total sent data */
} net_statistics_type_e;
/**
* - If the connection open successfully, application can get the connected profile information \n
* If the connection is failed to establish, net_profile_info_t also contains NULL value
*
+ * - NET_EVENT_SPECIFIC_SCAN_IND \n
+ * Response event for net_specific_scan_wifi() to notify the BSSs which are found.
+ * - net_event->ProfileName : NULL (not used in this event)
+ * - net_event->Error : Its value will be NET_ERR_NONE in case of success and error cause in case of failure
+ * - net_event->Data : Pointer to GSList of struct ssid_scan_bss_info_t
+ * - net_event->Datalength : The number of BSSs which are found
+ * - Do not delete and modify Data and Datalength and they are destroyed automatically
+ *
*/
typedef void (*net_event_cb_t)(const net_event_info_t* net_event, void* user_data);
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*/
typedef enum
{
-
/** IPV4 Address type */
NET_ADDR_IPV4 = 0x0,
*/
typedef enum
{
-
/** No authentication */
NET_PDP_AUTH_NONE = 0x0,
/** Don't use any method */
NET_IP_CONFIG_TYPE_OFF,
+
} net_ip_config_type_t;
/*==================================================================================================
net_addr_t IpAddr6;
/** Prefix Length for the connection link */
- int PrefixLen6;
+ int PrefixLen6;
/** Whether gateway address present or not */
char BDefGateway6;
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
NET_STATE_TYPE_DISCONNECT,
} net_state_type_t;
+/**
+ * @enum net_state_error_type_t
+ * This enumeration defines the service error state type.
+ */
+typedef enum
+{
+ NET_STATE_ERROR_NONE = 0x00,
+ NET_STATE_ERROR_OUT_OF_RANGE = 0x01,
+ NET_STATE_ERROR_PIN_MISSING = 0x02,
+ NET_STATE_ERROR_DHCP_FAILED = 0x03,
+ NET_STATE_ERROR_CONNECT_FAILED = 0x04,
+ NET_STATE_ERROR_LOGIN_FAILED = 0x05,
+ NET_STATE_ERROR_AUTH_FAILED = 0x06,
+ NET_STATE_ERROR_INVALID_KEY = 0x07,
+} net_error_state_type_t;
/*==================================================================================================
STRUCTURES AND OTHER TYPEDEFS
typedef struct
{
/** Specifies a protocol type */
- net_pdp_type_t ProtocolType;
+ net_pdp_type_t ProtocolType;
/** Specifies a service type(Internet, MMS, WAP, etc...) */
net_service_type_t ServiceType;
/** Network Access Point Name */
- char Apn[NET_PDP_APN_LEN_MAX+1];
+ char Apn[NET_PDP_APN_LEN_MAX+1];
/** Authentication info of the PDP profile */
- net_auth_info_t AuthInfo;
+ net_auth_info_t AuthInfo;
/** Browser Home URL or MMS server URL */
- char HomeURL[NET_HOME_URL_LEN_MAX+1];
+ char HomeURL[NET_HOME_URL_LEN_MAX+1];
/** Sim Info Mcc */
char Mcc[NET_SIM_INFO_LEN+1];
/** Sim Info Mnc */
char DefaultConn;
/** Modem object path for PS cellular profile */
- char PSModemPath[NET_PROFILE_NAME_LEN_MAX + 1];
+ char PSModemPath[NET_PROFILE_NAME_LEN_MAX + 1];
/** network information */
net_dev_info_t net_info;
} net_pdp_profile_info_t;
-
/**
* Profile data structures: Ethernet Interface
*/
typedef union
{
/** PDP Profile Information */
- net_pdp_profile_info_t Pdp;
+ net_pdp_profile_info_t Pdp;
/** Wifi Profile Information */
- net_wifi_profile_info_t Wlan;
+ net_wifi_profile_info_t Wlan;
/** Ethernet Profile Information */
- net_eth_profile_info_t Ethernet;
+ net_eth_profile_info_t Ethernet;
/** Bluetooth Profile Information */
- net_bt_profile_info_t Bluetooth;
+ net_bt_profile_info_t Bluetooth;
} net_specific_profile_info_t;
/**
typedef struct
{
/** Device Type of the profile */
- net_device_t profile_type;
+ net_device_t profile_type;
/** Profile name */
- char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
/** Specific profile information */
- net_specific_profile_info_t ProfileInfo;
+ net_specific_profile_info_t ProfileInfo;
/** Service state */
- net_state_type_t ProfileState;
+ net_state_type_t ProfileState;
+ /** Service error state */
+ net_error_state_type_t ProfileErrorState;
/** Favourite flag */
- char Favourite;
+ char Favourite;
} net_profile_info_t;
/*
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#ifndef __NETWORK_PM_WLAN_H__
#define __NETWORK_PM_WLAN_H__
-#include "network-pm-config.h"
#include <glib.h>
+#include "network-pm-config.h"
+
#ifdef __cplusplus
extern "C"
{
/** Length of essid */
#define NET_WLAN_ESSID_LEN 128
+/** Length of bssid */
+#define NET_WLAN_BSSID_LEN 17
+
/**
* Length of WPS PIN code
* WPS PIN code should be 4 or 8 digits
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* This enum indicates wifi state
*/
typedef enum {
- /** Unknown state */
- WIFI_UNKNOWN = 0x00,
- /** Wi-Fi is Off */
- WIFI_OFF,
- /** Wi-Fi is On(idle/failure) */
- WIFI_ON,
- /** Trying to connect(association/configuration) */
- WIFI_CONNECTING,
- /** Wi-Fi is connected to an AP(ready/online) */
- WIFI_CONNECTED,
- /** Trying to disconnect(connected, but disconnecting process is on going) */
- WIFI_DISCONNECTING,
+ WIFI_UNKNOWN = 0x00, /** Unknown state */
+ WIFI_OFF = 0x01, /** Wi-Fi is Off */
+ WIFI_ON = 0x02, /** Wi-Fi is On(idle/failure) */
+ WIFI_ASSOCIATION = 0x03, /** Trying association */
+ WIFI_CONFIGURATION = 0x04, /** Trying configuration */
+ WIFI_CONNECTED = 0x05, /** Wi-Fi is connected */
+ WIFI_DISCONNECTING = 0x06, /** Trying to disconnect */
} net_wifi_state_t;
/**
char wps;
};
+struct wps_scan_bss_info_t {
+ unsigned char ssid[NET_WLAN_ESSID_LEN + 1];
+ char bssid[NET_WLAN_BSSID_LEN + 1];
+ int rssi;
+ int mode;
+};
+
/*****************************************************************************
* Typedefs
*****************************************************************************/
* @param[in] none
* @param[out] current_state Current wifi state
* @param[out] profile_name Profile name of current Wi-Fi state\n
- * (valid for WIFI_CONNECTING, WIFI_CONNECTED, WIFI_DISCONNECTING state only)
- *
+ * (valid for WIFI_ASSOCIATION, WIFI_CONFIGURATION,\n
+ * WIFI_CONNECTED, WIFI_DISCONNECTING state only)
* @return NET_ERR_NONE on success, negative values for errors
*/
int net_specific_scan_wifi(const char *ssid);
+/**
+ * @fn int net_wps_scan_wifi(void)
+ *
+ * This function sends scan request to NetConfig daemon,
+ *
+ * \par Sync (or) Async:
+ * This is Asynchronous API.
+ *
+ * @param[out] none
+ *
+ * @return NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_wps_scan_wifi(void);
+
/**
* @fn int net_wifi_get_passpoint(int *enable)
*
int net_wifi_set_passpoint(int enable);
+#if defined TIZEN_TV
+/**
+* @fn int net_wifi_cancel_wps(void)
+*
+* This function stops ongoing WPS Provisioning / disconnects
+* connected access point.
+*
+* \par Sync (or) Async:
+* This is an Sync API.
+*
+* @param[in] none
+* @param[out] none
+*
+* @return NET_ERR_NONE on success, negative values for errors
+*/
+
+int net_wifi_cancel_wps(void);
+
+#endif
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Asynchronous Function Declaration
*****************************************************************************/
* @return NET_ERR_NONE on success, negative values for errors
*/
+
int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info);
/**
int net_scan_wifi(void);
/**
- * @fn int net_wifi_power_on(void)
+ * @fn int net_wifi_power_on(gboolean wifi_picker_test)
*
* This function requests wifi power on.
*
* \par Sync (or) Async:
* This is an Asynchronous API.
*
- * @param[in] none
+ * @param[in] wifi_picker_test whether wifi list popup(picker) display or not
* @param[out] none
*
* \par Async Response Message:
* @return NET_ERR_NONE on success, negative values for errors
*/
-int net_wifi_power_on(void);
+int net_wifi_power_on(gboolean wifi_picker_test);
/**
* @fn int net_wifi_power_off(void)
int net_check_profile_privilege();
+#if defined TIZEN_TV
+/**
+ * @fn int net_wifi_enroll_wps_without_ssid()
+ *
+ * This function sends enroll wps request to NetConfig daemon,
+ * with wps information.
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in] wps_info wps type
+ * @param[out] none
+ *
+ * \par Async Response Message:
+ * NET_EVENT_WIFI_WPS_RSP : enroll wps response will be sent asynchronously to the App in the callback function registered.\n
+ * refer to net_event_cb_t()
+ *
+ * @return NET_ERR_NONE on success, negative values for errors
+ */
+int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_t *wps_info);
+
+#endif
/**
* \}
*/
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
-prefix=@prefix@\r
-exec_prefix=@prefix@\r
-libdir=@libdir@\r
-includedir=@prefix@/include\r
-\r
-Name: network\r
-Description: ConnMan Client Library\r
-Requires: dlog glib-2.0 gthread-2.0 dbus-glib-1 gio-2.0
-Version: @VERSION@\r
-Libs: -L${libdir} -lnetwork -lgio-2.0\r
-Cflags: -I${includedir} -I${includedir}/network\r
+prefix=@prefix@
+exec_prefix=@prefix@
+libdir=@libdir@
+includedir=@prefix@/include
+
+Name: network
+Description: ConnMan Client Library
+Requires: dlog gio-2.0 glib-2.0 gthread-2.0
+Version: @VERSION@
+Libs: -L${libdir} -lnetwork
+Cflags: -I${includedir} -I${includedir}/network
+++ /dev/null
-* Sun May 26 2013 Rusty Lynch <rusty.lynch@intel.com> accepted/tizen/20130520.215057@b416fd1
-- Fix build on 64bit platforms
-
-* Sat May 18 2013 Rusty Lynch <rusty.lynch@intel.com> submit/tizen/20130517.044905@78dc8c1
-- Fix rpmlint errors
-- Fix breakage caused by unused variables
-- Remove use of deprecated g_type_init()
-
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
-Name: libnet-client
-Summary: Network Client library (Shared library)
-Version: 0.1.77_61
-Release: 0
-Group: System/Network
-License: Flora License
-Source0: %{name}-%{version}.tar.gz
-Source1001: libnet-client.manifest
-URL: https://review.tizen.org/git/?p=framework/connectivity/libnet-client.git;a=summary
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gio-2.0)
+Name: libnet-client
+Summary: Network Client library (Shared library)
+Version: 1.1.40
+Release: 1
+Group: System/Network
+License: Flora-1.1
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gthread-2.0)
-BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: model-build-features
%description
Network Client library (Shared library)
%package devel
-Summary: Network Client library (Development)
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
+Summary: Network Client library (Development)
+Group: Development/Library
+Requires: %{name} = %{version}-%{release}
%description devel
Network Client library (Development)
%prep
%setup -q
-cp %{SOURCE1001} .
+
%build
-mkdir -p m4
-%reconfigure
-%__make %{?_smp_mflags}
+%if 0%{?model_build_feature_network_dsds} == 1
+export DUALSIM_CFLAGS+=" -DTIZEN_DUALSIM_ENABLE"
+%endif
+
+%if "%{?tizen_profile_name}" == "wearable"
+export WEARABLE_CFLAGS+=" -DTIZEN_WEARABLE"
+%endif
+
+%if "%{?tizen_profile_name}" == "tv"
+ export TIZEN_TV_CFLAGS+=" -DTIZEN_TV"
+%endif
+
+./autogen.sh
+./configure --prefix=/usr --libdir=%{_libdir}
+
+make %{?_smp_mflags}
+
%install
%make_install
#License
mkdir -p %{buildroot}%{_datadir}/license
-cp LICENSE.Flora %{buildroot}%{_datadir}/license/libnet-client
+cp LICENSE %{buildroot}%{_datadir}/license/libnet-client
-#Make test app
cd test
-mkdir ./lib
-cp -rf %{buildroot}%{_libdir}/* ./lib/
+cp -rf %{buildroot}%{_libdir}/ ./
./build.sh
cd ..
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
%files
-%manifest %{name}.manifest
+%manifest libnet-client.manifest
%{_libdir}/libnetwork.so
%{_libdir}/libnetwork.so.0
%attr(644,-,-) %{_libdir}/libnetwork.so.0.0.0
%{_datadir}/license/libnet-client
%files devel
-%manifest %{name}.manifest
%{_includedir}/network/*.h
%{_libdir}/pkgconfig/network.pc
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
/*****************************************************************************
* Macros and Typedefs
*****************************************************************************/
-#define CONNMAN_CLIENT_DBUS_TYPE_STRING "string"
-#define CONNMAN_CLIENT_DBUS_TYPE_INT16 "int16"
-#define CONNMAN_CLIENT_DBUS_TYPE_UINT16 "uint16"
-#define CONNMAN_CLIENT_DBUS_TYPE_INT32 "int32"
-#define CONNMAN_CLIENT_DBUS_TYPE_UINT32 "uint32"
-#define CONNMAN_CLIENT_DBUS_TYPE_INT64 "int64"
-#define CONNMAN_CLIENT_DBUS_TYPE_UINT64 "uint64"
-#define CONNMAN_CLIENT_DBUS_TYPE_DOUBLE "double"
-#define CONNMAN_CLIENT_DBUS_TYPE_BYTE "byte"
-#define CONNMAN_CLIENT_DBUS_TYPE_BOOLEAN "boolean"
+
+#define CONNMAN_CLIENT_DBUS_TYPE_STRING "string"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT16 "int16"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT16 "uint16"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT32 "int32"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT32 "uint32"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT64 "int64"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT64 "uint64"
+#define CONNMAN_CLIENT_DBUS_TYPE_DOUBLE "double"
+#define CONNMAN_CLIENT_DBUS_TYPE_BYTE "byte"
+#define CONNMAN_CLIENT_DBUS_TYPE_BOOLEAN "boolean"
#define CONNMAN_CLIENT_DBUS_TYPE_OBJECT_PATH "objpath"
-#define CONNMAN_CLIENT_DBUS_TYPE_VARIANT "variant"
-#define CONNMAN_CLIENT_DBUS_TYPE_ARRAY "array"
-#define CONNMAN_CLIENT_DBUS_TYPE_DICT_ENTRY "dict"
+#define CONNMAN_CLIENT_DBUS_TYPE_VARIANT "variant"
+#define CONNMAN_CLIENT_DBUS_TYPE_ARRAY "array"
+#define CONNMAN_CLIENT_DBUS_TYPE_DICT_ENTRY "dict"
#define NETCONFIG_AGENT_FIELD_SSID "SSID"
-#define NETCONFIG_AGENT_FIELD_PASSPHRASE "Passphrase"
-#define NETCONFIG_AGENT_FIELD_WPS_PBC "WPS_PBC"
-#define NETCONFIG_AGENT_FIELD_WPS_PIN "WPS_PIN"
-
-#define CONNMAN_CONFIG_FIELD_TYPE "Type"
-#define CONNMAN_CONFIG_FIELD_NAME "Name"
-#define CONNMAN_CONFIG_FIELD_SSID "SSID"
-#define CONNMAN_CONFIG_FIELD_EAP_METHOD "EAP"
-#define CONNMAN_CONFIG_FIELD_IDENTITY "Identity"
-#define CONNMAN_CONFIG_FIELD_PASSPHRASE "Passphrase"
-#define CONNMAN_CONFIG_FIELD_PHASE2 "Phase2"
-#define CONNMAN_CONFIG_FIELD_CA_CERT_FILE "CACertFile"
-#define CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE "ClientCertFile"
-#define CONNMAN_CONFIG_FIELD_PVT_KEY_FILE "PrivateKeyFile"
-#define CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE "PrivateKeyPassphrase"
+#define NETCONFIG_AGENT_FIELD_PASSPHRASE "Passphrase"
+#define NETCONFIG_AGENT_FIELD_WPS_PBC "WPS_PBC"
+#define NETCONFIG_AGENT_FIELD_WPS_PIN "WPS_PIN"
+
+#define CONNMAN_CONFIG_FIELD_TYPE "Type"
+#define CONNMAN_CONFIG_FIELD_NAME "Name"
+#define CONNMAN_CONFIG_FIELD_SSID "SSID"
+#define CONNMAN_CONFIG_FIELD_EAP_METHOD "EAP"
+#define CONNMAN_CONFIG_FIELD_IDENTITY "Identity"
+#define CONNMAN_CONFIG_FIELD_PASSPHRASE "Passphrase"
+#define CONNMAN_CONFIG_FIELD_PHASE2 "Phase2"
+#define CONNMAN_CONFIG_FIELD_CA_CERT_FILE "CACertFile"
+#define CONNMAN_CONFIG_FIELD_CLIENT_CERT_FILE "ClientCertFile"
+#define CONNMAN_CONFIG_FIELD_PVT_KEY_FILE "PrivateKeyFile"
+#define CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE "PrivateKeyPassphrase"
/*****************************************************************************
* Global Structures
int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_t mode);
int _net_dbus_get_state(char* state);
int _net_dbus_get_ethernet_cable_state(int *state);
-int _net_dbus_set_agent_passphrase(const char *passphrase);
-int _net_dbus_set_agent_wps_pbc(void);
-int _net_dbus_set_agent_wps_pin(const char *wps_pin);
+int _net_dbus_set_agent_passphrase_and_connect(
+ const char *passphrase, const char *profilename);
+int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename);
+int _net_dbus_set_agent_wps_pin_and_connect(
+ const char *wps_pin, const char *profilename);
int _net_dbus_open_connection(const char* profile_name);
int _net_dbus_close_connection(const char* profile_name);
int _net_dbus_get_network_status(net_device_t device_type, net_cm_network_status_t* network_status);
int _net_dbus_set_profile_dns(net_profile_info_t* prof_info, char* profile_name);
int _net_dbus_set_proxy(net_profile_info_t* prof_info, char* profile_name);
int _net_dbus_get_technology_state(network_tech_state_info_t* tech_state);
-GVariant *_net_invoke_dbus_method(const char* dest, const char* path,
- char* interface_name, char* method,
- GVariant *params, int* dbus_error);
+GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int *dbus_error);
int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
const char *interface_name, const char *method,
- GVariant *params,
+ GVariant *params, int timeout,
GAsyncReadyCallback notify_func);
-int _net_dbus_load_wifi_driver(void);
+int _net_dbus_load_wifi_driver(gboolean wifi_picker_test);
int _net_dbus_remove_wifi_driver(void);
int _net_dbus_get_statistics(net_device_t device_type, net_statistics_type_e statistics_type, unsigned long long *size);
int _net_dbus_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type);
int _net_dbus_add_pdp_profile(net_profile_info_t *prof_info);
int _net_dbus_reset_pdp_profile(int type, const char * modem_path);
int _net_dbus_modify_pdp_profile(net_profile_info_t *prof_info, const char *profile_name);
-gboolean __net_dbus_abort_open_request(const char *profile_name);
int _net_dbus_specific_scan_request(const char *ssid);
+int _net_dbus_wps_scan_request(void);
int _net_dbus_set_default(const char* profile_name);
int _net_dbus_get_passpoint(int *enabled);
int _net_dbus_set_passpoint(int enable);
+#if defined TIZEN_TV
+int _net_dbus_cancel_wps(void);
+#endif
+
+#if defined TIZEN_TV
+int _net_dbus_open_connection_without_ssid();
+int _net_dbus_open_pin_connection_without_ssid(const char *pin);
+int _net_dbus_set_agent_wps_pbc(void);
+int _net_dbus_set_agent_wps_pin(const char *wps_pin);
+
+#endif
+
#ifdef __cplusplus
}
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#ifndef __NETWORK_INTERNAL_H__
#define __NETWORK_INTERNAL_H__
+#include <dlog.h>
#include <glib.h>
-#include <glib-object.h>
-#include <gio/gio.h>
#include <stdlib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
#include "network-cm-intf.h"
#include "network-wifi-intf.h"
#define CONNMAN_STATE_STRLEN 16
-#define NET_MEMFREE(x) do { g_free(x); x=NULL; } while(0)
+#define NET_MEMFREE(x) {if(x != NULL) free(x); x = NULL;}
-/** ConnMan interfaces */
-#define CONNMAN_SERVICE "net.connman"
+#define CONNMAN_SERVICE "net.connman"
#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
-#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
+#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter"
#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent"
#define CONNMAN_MANAGER_PATH "/"
-#define CONNMAN_PATH "/net/connman"
+#define CONNMAN_PATH "/net/connman"
#define CONNMAN_TECHNOLOGY_PATH "/net/connman/technology"
-/** Network related Daemon interfaces */
-#define NETCONFIG_SERVICE "net.netconfig"
+#define NETCONFIG_SERVICE "net.netconfig"
#define NETCONFIG_NETWORK_INTERFACE NETCONFIG_SERVICE ".network"
#define NETCONFIG_WIFI_INTERFACE NETCONFIG_SERVICE ".wifi"
-#define NETCONFIG_STATISTICS_INTERFACE NETCONFIG_SERVICE ".network_statistics"
+#define NETCONFIG_STATISTICS_INTERFACE NETCONFIG_SERVICE ".network_statistics"
#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
-#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
#define NETCONFIG_STATISTICS_PATH "/net/netconfig/network_statistics"
-#define TELEPHONY_SERVICE "com.tcore.ps"
+#if defined TIZEN_TV
+#define NETCONFIG_TV_PROFILE_INTERFACE NETCONFIG_SERVICE ".tv_profile"
+#endif
+
+#define TELEPHONY_SERVICE "com.tcore.ps"
#define TELEPHONY_MASTER_INTERFACE TELEPHONY_SERVICE ".master"
#define TELEPHONY_MODEM_INTERFACE TELEPHONY_SERVICE ".modem"
#define TELEPHONY_NETWORK_INTERFACE TELEPHONY_SERVICE ".network"
#define TELEPHONY_MASTER_PATH "/"
#define TELEPHONY_MODEM_PATH "/qmimodem0"
-#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
-#define SUPPLICANT_SERVICE_INTERFACE SUPPLICANT_SERVICE ".Interface"
-
-/** Signal Filters */
-#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
-#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
-#define NETCONFIG_WIFI_FILTER "type='signal',interface='net.netconfig.wifi'"
-#define SUPPLICANT_INTERFACE_SIGNAL_FILTER "type='signal',interface='fi.w1.wpa_supplicant1.Interface'"
-
-/** Signals */
-#define SIGNAL_PROPERTY_CHANGED "PropertyChanged"
-#define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
-#define SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded"
-#define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
-#define SIGNAL_SERVICES_CHANGED "ServicesChanged"
+#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_IFACE_INTERFACE SUPPLICANT_INTERFACE ".Interface"
+#define SUPPLICANT_IFACE_BSS SUPPLICANT_INTERFACE ".BSS"
+#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
+
+#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+
+#define CONNMAN_MANAGER_SIGNAL_FILTER \
+ "type='signal',interface='net.connman.Manager'"
+#define CONNMAN_SERVICE_SIGNAL_FILTER \
+ "type='signal',interface='net.connman.Service'"
+#define NETCONFIG_WIFI_FILTER \
+ "type='signal',interface='net.netconfig.wifi'"
+#define SUPPLICANT_INTERFACE_SIGNAL_FILTER \
+ "type='signal',interface='fi.w1.wpa_supplicant1.Interface'"
+
+#define SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+#define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
+#define SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded"
+#define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
+#define SIGNAL_SERVICES_CHANGED "ServicesChanged"
#define SIGNAL_SCAN_DONE "ScanDone"
-/** ConnMan technology and profile prefixes for ConnMan */
-#define CONNMAN_CELLULAR_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/cellular"
-#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
-#define CONNMAN_ETHERNET_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/ethernet"
-#define CONNMAN_BLUETOOTH_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/bluetooth"
-
-#define CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/cellular_"
-#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/wifi_"
-#define CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/ethernet_"
-#define CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/bluetooth_"
-#define CONNMAN_SERVICE_PROFILE_PREFIX CONNMAN_PATH "/service/"
+#define CONNMAN_CELLULAR_TECHNOLOGY_PREFIX \
+ CONNMAN_PATH "/technology/cellular"
+#define CONNMAN_WIFI_TECHNOLOGY_PREFIX \
+ CONNMAN_PATH "/technology/wifi"
+#define CONNMAN_ETHERNET_TECHNOLOGY_PREFIX \
+ CONNMAN_PATH "/technology/ethernet"
+#define CONNMAN_BLUETOOTH_TECHNOLOGY_PREFIX \
+ CONNMAN_PATH "/technology/bluetooth"
+
+#define CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX \
+ CONNMAN_PATH "/service/cellular_"
+#define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX \
+ CONNMAN_PATH "/service/wifi_"
+#define CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX \
+ CONNMAN_PATH "/service/ethernet_"
+#define CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX \
+ CONNMAN_PATH "/service/bluetooth_"
/** Network related Daemon Signals */
#define NETCONFIG_SIGNAL_POWERON_COMPLETED "PowerOnCompleted"
#define NETCONFIG_SIGNAL_POWEROFF_COMPLETED "PowerOffCompleted"
#define NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE "SpecificScanCompleted"
+#define NETCONFIG_SIGNAL_WPS_SCAN_DONE "WpsScanCompleted"
#define NETCONFIG_SIGNAL_ETHERNET_CABLE_STATE "EthernetCableState"
-#ifdef VITA_FEATURE
-#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "NET_CLIENT"
-#undef LOG_TAG
-#define LOG_TAG "NET_CLIENT"
-
-#define NETWORK_LOW 1
-#define NETWORK_HIGH 2
-#define NETWORK_ERROR 3
+#define NETWORK_LOW 1
+#define NETWORK_HIGH 2
+#define NETWORK_ERROR 3
#define NETWORK_LOG(log_level, format, args...) \
do { \
switch (log_level) { \
case NETWORK_ERROR: \
- LOGE(format, ## args); \
+ SLOGE(format, ##args); \
+ break; \
+ case NETWORK_HIGH: \
+ SLOGI(format, ##args); \
break; \
default: \
- LOGI(format, ## args); \
+ SLOGD(format, ##args); \
} \
} while(0)
-#define __NETWORK_FUNC_ENTER__ /* NETWORK_LOG(NETWORK_HIGH, "Entering %s()\n", __func__) */
-#define __NETWORK_FUNC_EXIT__ /* NETWORK_LOG(NETWORK_HIGH, "Quit: %s()\n", __func__) */
-
-#else /** VITA_FEATURE */
-
-#define NETWORK_LOG(log_level, format, args...) printf("[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
-#define __NETWORK_FUNC_ENTER__ /* printf("Entering: %s:%d:%s()\n", __FILE__, __LINE__,__func__) */
-#define __NETWORK_FUNC_EXIT__ /* printf("Quit: %s:%d:%s()\n", __FILE__, __LINE__,__func__) */
+#define SECURE_NETWORK_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case NETWORK_ERROR: \
+ SECURE_SLOGE(format, ##args); \
+ break; \
+ case NETWORK_HIGH: \
+ SECURE_SLOGI(format, ##args); \
+ break; \
+ default: \
+ SECURE_SLOGD(format, ##args); \
+ } \
+ } while(0)
-#endif /** VITA_FEATURE */
+#define __NETWORK_FUNC_ENTER__ /* NETWORK_LOG(NETWORK_LOW, "Entering (%s)", __func__)*/
+#define __NETWORK_FUNC_EXIT__ /* NETWORK_LOG(NETWORK_LOW, "Quit (%s)", __func__)*/
/*****************************************************************************
* Global Enums
net_event_cb_t ClientEventCb_wifi;
void* user_data_wifi;
int ref_count;
+ guint handler_id;
} network_info_t;
typedef struct
/* Connman 1.x */
char Connected;
char Powered;
- /* Tethering */
- char Tethering;
} network_tech_state_info_t;
/**
} net_telephony_profile_info_t;
/*****************************************************************************
- * Global Functions
+ * Global Functions
*****************************************************************************/
net_device_t _net_get_tech_type_from_path(const char *profile_name);
int _net_get_tech_state(GVariant *iter, network_tech_state_info_t* tech_state);
void _net_client_callback(net_event_info_t *event_data);
int _net_get_service_profile(net_service_type_t service_type, net_profile_name_t *profile_name);
int _net_get_default_profile_info(net_profile_info_t *profile_info);
-net_wifi_state_t _net_get_wifi_state(void);
+net_wifi_state_t _net_get_wifi_state(net_err_t *net_error);
void _net_clear_request_table(void);
+guint _net_client_callback_add(GSourceFunc func, gpointer user_data);
+void _net_client_callback_cleanup(void);
+
gboolean _net_dbus_is_pending_call_used(void);
void _net_dbus_pending_call_ref(void);
void _net_dbus_pending_call_unref(void);
}
#endif
-#endif /** __NETWORK_INTERNAL_H__*/
+#endif /* __NETWORK_INTERNAL_H__ */
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* Global Functions
*****************************************************************************/
int _net_deregister_signal(void);
-int network_register_and_recieve_signal(void);
int _net_register_signal(void);
+int _net_subscribe_signal_wifi(void);
int _net_init_service_state_table(void);
#ifdef __cplusplus
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*
*/
+#include "network-internal.h"
#include "network-dbus-request.h"
#include "network-signal-handler.h"
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (param == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_get_default_profile_info() failed. Error [%s]\n",
+ "_net_get_default_profile_info() failed. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
+static gboolean __net_is_connecting(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name1) == 0) {
+ __NETWORK_FUNC_EXIT__;
+ return TRUE;
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name2) == 0) {
+ __NETWORK_FUNC_EXIT__;
+ return TRUE;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return FALSE;
+}
+
+static void __net_abort_open_connection(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_event_info_t event_data;
+ char event_string[64];
+
+ char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name1) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_t));
+
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ g_strlcpy(event_string, "Sending NET_EVENT_OPEN_RSP", 64);
+
+ _net_dbus_pending_call_unref();
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(profile_name, svc_name2) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_t));
+
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ g_strlcpy(event_string, "Sending NET_EVENT_WIFI_WPS_RSP", 64);
+
+ _net_dbus_pending_call_unref();
+ } else {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ NETWORK_LOG(NETWORK_LOW, "%s, Error: %d", event_string, event_data.Error);
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
/*****************************************************************************
* ConnMan Client Common Interface API Definition
*****************************************************************************/
* @return int - NET_ERR_NONE on success, negative values for errors
* @param[in] net_event_cb_t event_cb - Pointer to callback function
* void* user_data - Pointer to user data
- * @param[out] none
+ * @param[out] none
*/
EXPORT_API int net_register_client(net_event_cb_t event_cb, void *user_data)
{
net_err_t Error = NET_ERR_NONE;
if (event_cb == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ClientEventCb != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Application already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application already registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_ALREADY_REGISTERED;
}
if (NetworkInfo.ref_count < 1) {
Error = _net_register_signal();
if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
-
- NetworkInfo.wifi_state = _net_get_wifi_state();
- _net_init_service_state_table();
}
- __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
+ if (NetworkInfo.ClientEventCb_wifi == NULL)
+ _net_subscribe_signal_wifi();
NetworkInfo.ClientEventCb = event_cb;
NetworkInfo.user_data = user_data;
- NETWORK_LOG(NETWORK_HIGH, "Client register successfully(%d)\n",
- NetworkInfo.ref_count);
+ if (NetworkInfo.ref_count < 1)
+ _net_init_service_state_table();
+
+ __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
if (event_cb == NULL ||
(client_type != NET_DEVICE_DEFAULT &&
client_type != NET_DEVICE_WIFI)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- switch (client_type) {
- case NET_DEVICE_DEFAULT:
+ if (client_type == NET_DEVICE_DEFAULT) {
if (NetworkInfo.ClientEventCb_conn != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Connection CAPI Already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection CAPI Already registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_ALREADY_REGISTERED;
}
- break;
- case NET_DEVICE_WIFI:
+ } else if (client_type == NET_DEVICE_WIFI) {
if (NetworkInfo.ClientEventCb_wifi != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI Already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI Already registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_ALREADY_REGISTERED;
}
- default:
- break;
}
if (NetworkInfo.ref_count < 1) {
Error = _net_register_signal();
if (Error != NET_ERR_NONE && Error != NET_ERR_APP_ALREADY_REGISTERED) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to register DBus signal [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
-
- NetworkInfo.wifi_state = _net_get_wifi_state();
- _net_init_service_state_table();
}
- __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
+ if (NetworkInfo.ref_count < 1) {
+ Error = _net_init_service_state_table();
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init service state table [%s]",
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ }
- switch (client_type) {
- case NET_DEVICE_DEFAULT:
+ if (client_type == NET_DEVICE_DEFAULT) {
NetworkInfo.ClientEventCb_conn = event_cb;
NetworkInfo.user_data_conn = user_data;
- break;
- case NET_DEVICE_WIFI:
+ } else if (client_type == NET_DEVICE_WIFI) {
+ _net_subscribe_signal_wifi();
NetworkInfo.ClientEventCb_wifi = event_cb;
NetworkInfo.user_data_wifi = user_data;
- default:
- break;
}
- NETWORK_LOG(NETWORK_HIGH, "Client register successfully(%d)\n",
- NetworkInfo.ref_count);
+ __sync_fetch_and_add(&NetworkInfo.ref_count, 1);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
if (NetworkInfo.ref_count < 1 ||
NetworkInfo.ClientEventCb == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
_net_deregister_signal();
_net_clear_request_table();
+ _net_client_callback_cleanup();
}
NetworkInfo.ClientEventCb = NULL;
NetworkInfo.user_data = NULL;
- NETWORK_LOG(NETWORK_HIGH, "Client de-register successfully(%d)\n",
- NetworkInfo.ref_count);
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
__NETWORK_FUNC_ENTER__;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
switch (client_type) {
case NET_DEVICE_DEFAULT:
if (NetworkInfo.ClientEventCb_conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Connection CAPI was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection CAPI was not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
break;
case NET_DEVICE_WIFI:
if (NetworkInfo.ClientEventCb_wifi == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI was not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
NetworkInfo.user_data_wifi = NULL;
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Invalid client_type parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid client_type parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (__sync_sub_and_fetch(&NetworkInfo.ref_count, 1) < 1) {
_net_deregister_signal();
_net_clear_request_table();
+ _net_client_callback_cleanup();
}
- NETWORK_LOG(NETWORK_HIGH, "Client de-register successfully(%d)\n",
- NetworkInfo.ref_count);
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
}
if (active_profile_info.profile_type == NET_DEVICE_CELLULAR) {
- NETWORK_LOG(NETWORK_ERROR, "Active network is cellular type.\n");
+ NETWORK_LOG(NETWORK_ERROR, "Active network is cellular type");
Error = NET_ERR_NO_SERVICE;
} else if (active_profile_info.profile_type == NET_DEVICE_ETHERNET) {
- NETWORK_LOG(NETWORK_ERROR, "Active network is ethernet type.\n");
+ NETWORK_LOG(NETWORK_ERROR, "Active network is ethernet type");
Error = NET_ERR_NO_SERVICE;
} else if (active_profile_info.profile_type == NET_DEVICE_WIFI) {
wlan_info = &active_profile_info.ProfileInfo.Wlan;
__NETWORK_FUNC_ENTER__;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if ((Error = _net_dbus_get_state(state)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get state. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get state. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return FALSE;
if ((g_strcmp0(state, "online") == 0) ||
(g_strcmp0(state, "connected") == 0)) {
- NETWORK_LOG(NETWORK_HIGH, "State [%s]\n", state);
+ NETWORK_LOG(NETWORK_LOW, "State [%s]", state);
__NETWORK_FUNC_EXIT__;
return TRUE;
__NETWORK_FUNC_ENTER__;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if ((Error = _net_dbus_get_network_status(device_type, network_status)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get network status. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get network status. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
__NETWORK_FUNC_ENTER__;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if ((Error = _net_dbus_get_tech_status(tech_type, tech_info)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get technology status. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get technology status. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
if ((Error = _net_dbus_get_statistics(device_type, statistics_type, size)) != NET_ERR_NONE )
- NETWORK_LOG(NETWORK_ERROR, "Failed to get statistics. error: %s\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get statistics. error: %s",
_net_print_error(Error));
return Error;
net_err_t Error = NET_ERR_NONE;
if ((Error = _net_dbus_set_statistics(device_type, statistics_type)) != NET_ERR_NONE )
- NETWORK_LOG(NETWORK_ERROR, "Failed to set statistics. error: %s\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set statistics. error: %s",
_net_print_error(Error));
return Error;
net_err_t Error = NET_ERR_NONE;
- NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
+ NETWORK_LOG(NETWORK_LOW, "Open: %s", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_dbus_open_connection(profile_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully request to connect %s\n",
- profile_name);
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
* @param[in] net_service_type_t service_type - Service type to be connected
* @param[out] none
*/
-EXPORT_API int net_open_connection_with_preference(net_service_type_t service_type)
+EXPORT_API int net_open_connection_with_preference(
+ net_service_type_t service_type)
{
__NETWORK_FUNC_ENTER__;
memset(&profile_name, 0, sizeof(net_profile_name_t));
if (_net_is_valid_service_type(service_type) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Service Type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Service Type");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_get_service_profile(service_type, &profile_name);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to find service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to find service");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = _net_dbus_open_connection(profile_name.ProfileName);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n",
- profile_name.ProfileName);
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
memset(&profile_name, 0, sizeof(net_profile_name_t));
if (_net_is_valid_service_type(service_type) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid service type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid service type");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (prof_name == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_get_service_profile(service_type, &profile_name);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to find service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to find service");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = _net_dbus_open_connection(profile_name.ProfileName);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n",
- profile_name.ProfileName);
-
memcpy(prof_name, &profile_name, sizeof(net_profile_name_t));
__NETWORK_FUNC_EXIT__;
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
+ gboolean is_connecting = FALSE;
- NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
+ NETWORK_LOG(NETWORK_LOW, "ProfileName [%s] passed", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_dbus_is_pending_call_used() == TRUE &&
- __net_dbus_abort_open_request(profile_name) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ is_connecting = __net_is_connecting(profile_name);
+ if (is_connecting == FALSE) {
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_IN_PROGRESS;
+ }
}
request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
Error = _net_dbus_close_connection(profile_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request close connection, Error [%s]\n",
+ "Failed to request close connection, Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
__NETWORK_FUNC_EXIT__;
return Error;
}
-
- __NETWORK_FUNC_EXIT__;
+
+ if (is_connecting == TRUE)
+ __net_abort_open_connection(profile_name);
+
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
static int __net_error_string_to_enum(const char *error)
{
- NETWORK_LOG(NETWORK_ERROR, "Passed error value [%s]", error);
+ NETWORK_LOG(NETWORK_LOW, "Passed error value [%s]", error);
if (NULL != strstr(error, "NoReply"))
return NET_ERR_TIME_OUT;
return NET_ERR_UNKNOWN;
}
-
static int __net_netconfig_error_string_to_enum(const char* error)
{
- NETWORK_LOG(NETWORK_HIGH, "Passed error value [%s]\n", error);
+ NETWORK_LOG(NETWORK_ERROR, "Passed error value [%s]", error);
if (error == NULL)
return NET_ERR_UNKNOWN;
if (NULL != strstr(error, ".WifiDriverFailed"))
return NET_ERR_WIFI_DRIVER_FAILURE;
- else if (NULL != strstr(error, ".SecurityRestricted"))
+ else if (NULL != strstr(error, ".PermissionDenied"))
return NET_ERR_SECURITY_RESTRICTED;
- else if (NULL != strstr(error, ".WifiLoadInprogress"))
+ else if (NULL != strstr(error, ".InProgress"))
return NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS;
return NET_ERR_UNKNOWN;
}
{
__NETWORK_FUNC_ENTER__;
- NETWORK_LOG(NETWORK_LOW, "__net_open_connection_reply() called\n");
-
- int callback_flag = FALSE;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
net_profile_info_t prof_info;
network_request_table_t *open_info =
&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
network_request_table_t *wps_info =
&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
-
GDBusConnection *conn = NULL;
GError *error = NULL;
- GVariant *dbus_result = NULL;
net_err_t Error = NET_ERR_NONE;
- conn = G_DBUS_CONNECTION (source_object);
- dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+ NETWORK_LOG(NETWORK_LOW, "__net_open_connection_reply() called");
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- NETWORK_LOG(NETWORK_LOW, "error msg - [%s]\n", error->message);
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
- } else
- NETWORK_LOG(NETWORK_LOW, "error msg is NULL\n");
-
- if (dbus_result)
- g_variant_unref(dbus_result);
+ }
if (Error == NET_ERR_NONE)
goto done;
- NETWORK_LOG(NETWORK_ERROR, "Connection open failed. Error [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Connection open failed[%d]", Error);
if (open_info->flag == TRUE) {
net_device_t device_type =
event_data.Error = NET_ERR_NONE;
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info[%s]",
_net_print_error(Error));
event_data.Datalength = 0;
}
event_data.Event = NET_EVENT_OPEN_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP Error = %s\n",
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP Error[%s]",
_net_print_error(event_data.Error));
-
- callback_flag = TRUE;
} else if (wps_info->flag == TRUE) {
g_strlcpy(event_data.ProfileName, wps_info->ProfileName,
NET_PROFILE_NAME_LEN_MAX + 1);
if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
Error = net_get_profile_info(event_data.ProfileName, &prof_info);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info[%s]",
_net_print_error(Error));
event_data.Datalength = 0;
event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s\n",
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP Error[%s]",
_net_print_error(event_data.Error));
+ } else {
+ _net_dbus_pending_call_unref();
- callback_flag = TRUE;
+ __NETWORK_FUNC_EXIT__;
+ return;
}
done:
_net_dbus_pending_call_unref();
- if (callback_flag)
- _net_client_callback(&event_data);
+ _net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
}
{
__NETWORK_FUNC_ENTER__;
- NETWORK_LOG(NETWORK_LOW, "__net_close_connection_reply() called\n");
+ NETWORK_LOG(NETWORK_LOW, "__net_close_connection_reply() called");
- int callback_flag = FALSE;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
network_request_table_t *close_info =
&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
GDBusConnection *conn = NULL;
GError *error = NULL;
- GVariant *dbus_result = NULL;
net_err_t Error = NET_ERR_NONE;
- conn = G_DBUS_CONNECTION (source_object);
- dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
Error = __net_error_string_to_enum(error->message);
g_error_free(error);
}
- if (dbus_result)
- g_variant_unref(dbus_result);
-
if (Error == NET_ERR_NONE)
goto done;
- NETWORK_LOG(NETWORK_ERROR, "Connection close failed. Error [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Connection close failed[%d]", Error);
if (close_info->flag == TRUE) {
net_device_t device_type =
_net_get_tech_type_from_path(close_info->ProfileName);
if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS &&
- device_type == NET_DEVICE_CELLULAR)
+ device_type == NET_DEVICE_CELLULAR)
Error = NET_ERR_NONE;
g_strlcpy(event_data.ProfileName, close_info->ProfileName,
event_data.Data = NULL;
event_data.Event = NET_EVENT_CLOSE_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP Error = %s\n",
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP Error[%s]",
_net_print_error(event_data.Error));
+ } else {
+ _net_dbus_pending_call_unref();
- callback_flag = TRUE;
+ __NETWORK_FUNC_EXIT__;
+ return;
}
done:
_net_dbus_pending_call_unref();
- if (callback_flag)
- _net_client_callback(&event_data);
+ _net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
}
{
__NETWORK_FUNC_ENTER__;
- NETWORK_LOG(NETWORK_LOW, "__net_wifi_power_reply() called\n");
-
- int callback_flag = FALSE;
GDBusConnection *conn = NULL;
GError *error = NULL;
- GVariant *dbus_result = NULL;
net_err_t Error = NET_ERR_NONE;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
- conn = G_DBUS_CONNECTION (source_object);
- dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+ NETWORK_LOG(NETWORK_LOW, "__net_wifi_power_reply() called");
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
Error = __net_netconfig_error_string_to_enum(error->message);
g_error_free(error);
}
- if (dbus_result)
- g_variant_unref(dbus_result);
-
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Wi-Fi power operation failed. Error [%d]\n", Error);
+ "Wi-Fi power operation failed. Error [%d]", Error);
if (Error != NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS) {
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
event_data.Event = NET_EVENT_WIFI_POWER_RSP;
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_WIFI_POWER_RSP Wi-Fi: %d Error = %d\n",
+ "Sending NET_EVENT_WIFI_POWER_RSP Wi-Fi: %d Error = %d",
NetworkInfo.wifi_state, Error);
event_data.Datalength = sizeof(net_wifi_state_t);
event_data.Error = Error;
}
}
+ } else {
+ _net_dbus_pending_call_unref();
- callback_flag = TRUE;
+ __NETWORK_FUNC_EXIT__;
+ return;
}
_net_dbus_pending_call_unref();
- if (callback_flag)
- _net_client_callback(&event_data);
+ _net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
}
conn = G_DBUS_CONNECTION (source_object);
dbus_result = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- Error = __net_netconfig_error_string_to_enum(error->message);
+ Error = __net_error_string_to_enum(error->message);
g_error_free(error);
NETWORK_LOG(NETWORK_ERROR, "Error code: [%d]", Error);
{
__NETWORK_FUNC_ENTER__;
- int callback_flag = FALSE;
GDBusConnection *conn = NULL;
GError *error = NULL;
- GVariant *dbus_result = NULL;
net_err_t Error = NET_ERR_NONE;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
- conn = G_DBUS_CONNECTION (source_object);
- dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
Error = __net_netconfig_error_string_to_enum(error->message);
g_error_free(error);
}
- if (dbus_result)
- g_variant_unref(dbus_result);
-
if (Error != NET_ERR_NONE)
NETWORK_LOG(NETWORK_ERROR, "Find specific AP failed[%d]", Error);
else
event_data.Event = NET_EVENT_SPECIFIC_SCAN_RSP;
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_SPECIFIC_SCAN_RSP Wi-Fi: %d Error = %d\n",
+ "Sending NET_EVENT_SPECIFIC_SCAN_RSP Wi-Fi: %d Error[%d]",
NetworkInfo.wifi_state, Error);
event_data.Datalength = sizeof(net_wifi_state_t);
event_data.Data = &(NetworkInfo.wifi_state);
event_data.Error = Error;
+ } else {
+ _net_dbus_pending_call_unref();
- callback_flag = TRUE;
+ __NETWORK_FUNC_EXIT__;
+ return;
}
_net_dbus_pending_call_unref();
- if (callback_flag)
- _net_client_callback(&event_data);
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_wps_scan_wifi_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ net_err_t Error = NET_ERR_NONE;
+ net_event_info_t event_data = { 0, };
+
+ conn = G_DBUS_CONNECTION(source_object);
+ g_dbus_connection_call_finish(conn, res, &error);
+ if (error != NULL) {
+ Error = __net_netconfig_error_string_to_enum(error->message);
+ g_error_free(error);
+ }
+
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "WPS scan failed[%d]", Error);
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_t));
+
+ event_data.Event = NET_EVENT_WPS_SCAN_IND;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ event_data.Error = Error;
+
+ _net_dbus_pending_call_unref();
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+ } else
+ NETWORK_LOG(NETWORK_LOW, "WPS scan succeed");
+
+ _net_dbus_pending_call_unref();
__NETWORK_FUNC_EXIT__;
}
GError *error = NULL;
net_err_t Error = NET_ERR_NONE;
- conn = G_DBUS_CONNECTION (source_object);
+ conn = G_DBUS_CONNECTION(source_object);
g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
Error = __net_netconfig_error_string_to_enum(error->message);
}
if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "set passpoint failed. Error [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "set passpoint failed[%d]", Error);
else
- NETWORK_LOG(NETWORK_LOW, "set passpoint succeed\n");
+ NETWORK_LOG(NETWORK_LOW, "set passpoint succeeded");
_net_dbus_pending_call_unref();
{
__NETWORK_FUNC_ENTER__;
- NETWORK_LOG(NETWORK_LOW, "__net_set_default_reply() called\n");
-
- int callback_flag = FALSE;
- net_event_info_t event_data = {0,};
int rv;
-
+ net_event_info_t event_data = { 0, };
GDBusConnection *conn = NULL;
+ GVariant *dbus_result;
GError *error = NULL;
- GVariant *dbus_result = NULL;
net_err_t Error = NET_ERR_NONE;
- conn = G_DBUS_CONNECTION (source_object);
+ NETWORK_LOG(NETWORK_LOW, "__net_set_default_reply() called");
+
+ conn = G_DBUS_CONNECTION(source_object);
dbus_result = g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
- Error = __net_netconfig_error_string_to_enum(error->message);
+ Error = __net_error_string_to_enum(error->message);
g_error_free(error);
- }
- NETWORK_LOG(NETWORK_ERROR, "Error code : [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Error code[%d]", Error);
+ }
if (request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT],
if (Error == NET_ERR_NONE) {
g_variant_get(dbus_result, "(b)", &rv);
- NETWORK_LOG(NETWORK_LOW, "Reply : [%s]\n", rv ? "TRUE" : "FALSE");
+ NETWORK_LOG(NETWORK_LOW, "Reply: %s", rv ? "TRUE" : "FALSE");
if (rv)
event_data.Error = NET_ERR_NONE;
} else
event_data.Error = Error;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CELLULAR_SET_DEFAULT_RSP Error = %s\n",
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CELLULAR_SET_DEFAULT_RSP Error[%s]",
_net_print_error(event_data.Error));
+ } else {
+ _net_dbus_pending_call_unref();
- callback_flag = TRUE;
+ __NETWORK_FUNC_EXIT__;
+ return;
}
_net_dbus_pending_call_unref();
- if (dbus_result)
- g_variant_unref(dbus_result);
-
- if (callback_flag)
- _net_client_callback(&event_data);
+ _net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
}
-static char *__net_make_group_name(const char *ssid, const char *net_mode, const char *sec)
+static char *__net_make_group_name(const char *ssid,
+ const char *net_mode, const char *sec)
{
char *buf = NULL;
char *pbuf = NULL;
const char *hidden_str = "hidden";
const char *g_sec;
- char buf_tmp[32] = {0,};
+ char buf_tmp[32] = { 0, };
int i;
int ssid_len = 0;
int actual_len = 0;
g_strlcat(buf, buf_tmp,
actual_len + strlen(net_mode) + strlen(sec) + 3);
- NETWORK_LOG(NETWORK_HIGH, "Group name : %s\n", buf);
+ NETWORK_LOG(NETWORK_LOW, "Group name: %s", buf);
return buf;
}
-static int __net_dbus_set_agent_field(const char *key, const char *value)
+static int __net_dbus_set_agent_field_and_connect(
+ const char *key, const char *value, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
- GError *error = NULL;
- GVariant *reply = NULL;
+ net_err_t Error = NET_ERR_NONE;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
- builder = g_variant_builder_new(G_VARIANT_TYPE ("a{ss}"));
- g_variant_builder_add(builder, "{ss}", key, value);
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add(builder, "{sv}", key, g_variant_new_string(value));
- params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
+ params = g_variant_new("(o@a{sv})",
+ profilename, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- reply = g_dbus_connection_call_sync(connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- CONNMAN_AGENT_INTERFACE,
- "SetField",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- }
-
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
- }
-
- g_variant_unref(reply);
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH,
+ CONNMAN_AGENT_INTERFACE, "SetField", params,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
/*****************************************************************************
* Global Functions Definition
*****************************************************************************/
-GVariant *_net_invoke_dbus_method(const char* dest, const char* path,
- char* interface_name, char* method,
- GVariant *params, int* dbus_error)
+GVariant *_net_invoke_dbus_method(const char *dest, const char *path,
+ const char *interface_name, const char *method,
+ GVariant *params, int *dbus_error)
{
__NETWORK_FUNC_ENTER__;
connection = _net_dbus_get_gdbus_conn();
if (connection == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "GDBusconnection is NULL\n");
+ NETWORK_LOG(NETWORK_ERROR, "GDBusconnection is NULL");
*dbus_error = NET_ERR_APP_NOT_REGISTERED;
return reply;
}
- NETWORK_LOG(NETWORK_HIGH, "[DBUS Sync] %s.%s, %s\n",
- interface_name, method, path);
-
reply = g_dbus_connection_call_sync(connection,
- dest,
- path,
- interface_name,
- method,
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
+ dest,
+ path,
+ interface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ _net_dbus_get_gdbus_cancellable(),
+ &error);
if (reply == NULL) {
if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
+ SECURE_NETWORK_LOG(NETWORK_ERROR,
+ "g_dbus_connection_call_sync() failed"
+ "error [%d: %s]", error->code, error->message);
*dbus_error = __net_error_string_to_enum(error->message);
g_error_free(error);
} else {
NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
+ "g_dbus_connection_call_sync() failed");
+ *dbus_error = NET_ERR_UNKNOWN;
}
- *dbus_error = NET_ERR_UNKNOWN;
-
__NETWORK_FUNC_EXIT__;
return NULL;
}
}
int _net_invoke_dbus_method_nonblock(const char *dest, const char *path,
- const char *interface_name, const char *method, GVariant *params,
+ const char *interface_name, const char *method,
+ GVariant *params, int timeout,
GAsyncReadyCallback notify_func)
{
__NETWORK_FUNC_ENTER__;
params,
NULL,
G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
+ timeout,
_net_dbus_get_gdbus_cancellable(),
(GAsyncReadyCallback) notify_func,
NULL);
return NET_ERR_NONE;
}
-
int _net_dbus_open_connection(const char* profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
+ /* use DBus signal than reply pending because of performance reason */
Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "Connect", NULL, __net_open_connection_reply);
+ CONNMAN_SERVICE_INTERFACE, "Connect", NULL,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
+ /* use DBus signal than reply pending because of performance reason */
Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, profile_name,
- CONNMAN_SERVICE_INTERFACE, "Disconnect", NULL, __net_close_connection_reply);
+ CONNMAN_SERVICE_INTERFACE, "Disconnect", NULL,
+ DBUS_REPLY_TIMEOUT, __net_close_connection_reply);
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
+ /* use DBus signal than reply pending because of performance reason */
Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
CONNMAN_WIFI_TECHNOLOGY_PREFIX,
- CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL, NULL);
+ CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
+ DBUS_REPLY_TIMEOUT, NULL);
if (Error == NET_ERR_IN_PROGRESS)
Error = NET_ERR_NONE;
Error = _net_invoke_dbus_method_nonblock(TELEPHONY_SERVICE,
profile_name, TELEPHONY_PROFILE_INTERFACE,
- "SetDefaultConnection", NULL, __net_set_default_reply);
+ "SetDefaultConnection", NULL, DBUS_REPLY_TIMEOUT,
+ __net_set_default_reply);
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
GVariant *message = NULL;
- GVariant *params = NULL;
+ GVariant *params;
char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
NETCONFIG_WIFI_INTERFACE, "SetBgscan", params, &Error);
if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed");
if (message != NULL)
g_variant_unref(message);
GVariant *message = NULL;
if ((tech_state == NULL) || (strlen(tech_state->technology) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
message = _net_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
"GetTechnologies", NULL, &Error);
-
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get technology info\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get technology info");
goto done;
}
Error = _net_get_tech_state(message, tech_state);
- NETWORK_LOG(NETWORK_HIGH,
- "Technology-[%s] Powered-[%d] Connected-[%d] Tethering-[%d]",
- tech_state->technology,
- tech_state->Powered,
- tech_state->Connected,
- tech_state->Tethering);
-
g_variant_unref(message);
done:
Error = _net_dbus_get_technology_state(&tech_state);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_get_technology_state() failed. Error [%s]\n",
+ "_net_dbus_get_technology_state() failed. Error [%s]",
_net_print_error(Error));
goto done;
}
Error = _net_dbus_get_technology_state(&tech_state);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_get_technology_state() failed. Error [%s]\n",
+ "_net_dbus_get_technology_state() failed. Error [%s]",
_net_print_error(Error));
goto done;
}
method = "GetWifiTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
return NET_ERR_INVALID_PARAM;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
return NET_ERR_INVALID_PARAM;
}
NETCONFIG_SERVICE, NETCONFIG_STATISTICS_PATH,
NETCONFIG_STATISTICS_INTERFACE, method, NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties");
return Error;
}
g_variant_get(message, "(t)", size);
- NETWORK_LOG(NETWORK_HIGH, "success [%s] statistics size : [%llu]\n", method, *size);
+ NETWORK_LOG(NETWORK_LOW, "success [%s] statistics size: [%llu]", method, *size);
g_variant_unref(message);
return Error;
method = "ResetCellularTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
return NET_ERR_INVALID_PARAM;
}
} else if (device_type == NET_DEVICE_WIFI) {
method = "ResetWifiTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
return NET_ERR_INVALID_PARAM;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
return NET_ERR_INVALID_PARAM;
}
NETCONFIG_SERVICE, NETCONFIG_STATISTICS_PATH,
NETCONFIG_STATISTICS_INTERFACE, method, NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties");
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "reset [%s] statistics success\n", method);
+ NETWORK_LOG(NETWORK_LOW, "reset [%s] statistics success", method);
g_variant_unref(message);
return Error;
CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetProperties", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties");
__NETWORK_FUNC_EXIT__;
return Error;
if (g_strcmp0(key, "State") == 0) {
net_state = g_variant_get_string(value, NULL);
g_strlcpy(state, net_state, CONNMAN_STATE_STRLEN);
-
g_variant_unref(value);
g_free(key);
break;
}
}
- NETWORK_LOG(NETWORK_HIGH, "State: %s\n", state);
+ NETWORK_LOG(NETWORK_LOW, "State: %s", state);
g_variant_iter_free(iter);
g_variant_unref(message);
return Error;
}
-static void __net_create_config_reply(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
-{
- __NETWORK_FUNC_ENTER__;
-
- NETWORK_LOG(NETWORK_LOW, "__net_create_config_reply() called\n");
-
- GDBusConnection *conn = NULL;
- GVariant *dbus_result =NULL;
- GError *error = NULL;
-
- conn = G_DBUS_CONNECTION (source_object);
- dbus_result = g_dbus_connection_call_finish(conn, res, &error);
-
- if (error != NULL) {
- NETWORK_LOG(NETWORK_LOW, "error msg - [%s]\n", error->message);
- g_error_free(error);
- } else
- NETWORK_LOG(NETWORK_LOW, "error msg is NULL\n");
-
- if (dbus_result)
- g_variant_unref(dbus_result);
-
- _net_dbus_pending_call_unref();
-
- __NETWORK_FUNC_EXIT__;
-}
-
-int _net_dbus_set_eap_config_fields(
- const net_wifi_connect_service_info_t *wifi_info)
+int _net_dbus_set_eap_config_fields_and_connect(
+ const net_wifi_connect_service_info_t *wifi_info,
+ const char *profilename)
{
__NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
builder = g_variant_builder_new(G_VARIANT_TYPE ("a{ss}"));
-
g_variant_builder_add(builder, "{ss}", CONNMAN_CONFIG_FIELD_TYPE, "wifi");
if (wifi_info->ssid)
CONNMAN_CONFIG_FIELD_PVT_KEY_PASSPHRASE,
wifi_info->private_key_password);
- params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
+ params = g_variant_new("(o@a{ss})",
+ profilename, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- g_dbus_connection_call(connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE,
- "CreateConfig",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- (GAsyncReadyCallback)__net_create_config_reply,
- NULL);
-
- NETWORK_LOG(NETWORK_HIGH, "Successfully sent eap config fields\n");
-
- _net_dbus_pending_call_ref();
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "CreateConfig", params,
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
-int _net_dbus_set_agent_passphrase(const char *passphrase)
+int _net_dbus_set_agent_passphrase_and_connect(
+ const char *passphrase, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
- int ret_val;
+ net_err_t Error = NET_ERR_NONE;
- if (NULL == passphrase || strlen(passphrase) <= 0) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid param \n");
+ if (NULL == passphrase || strlen(passphrase) <= 0 || NULL == profilename) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
return NET_ERR_INVALID_PARAM;
}
- ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_PASSPHRASE, passphrase);
- if (NET_ERR_NONE != ret_val) {
- NETWORK_LOG(NETWORK_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
- return ret_val;
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_PASSPHRASE,
+ passphrase,
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ NETWORK_LOG(NETWORK_ERROR, "Configuration failed(%d)", Error);
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully sent passphrase\n");
-
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
int _net_dbus_set_agent_fields_and_connect(const char *ssid,
Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
NETCONFIG_WIFI_PATH,
CONNMAN_AGENT_INTERFACE, "SetField", params,
- __net_open_connection_reply);
+ DBUS_REPLY_TIMEOUT, __net_open_connection_reply);
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR, "Configuration failed(%d)", Error);
return Error;
return Error;
}
-int _net_dbus_set_agent_wps_pbc(void)
+int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename)
{
__NETWORK_FUNC_ENTER__;
- int ret_val;
+ net_err_t Error = NET_ERR_NONE;
- ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PBC, "enable");
- if (NET_ERR_NONE != ret_val) {
- NETWORK_LOG(NETWORK_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
- return ret_val;
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_WPS_PBC,
+ "enable",
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ NETWORK_LOG(NETWORK_ERROR, "PBC configuration failed(%d)", Error);
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully sent wps pbc\n");
-
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
-int _net_dbus_set_agent_wps_pin(const char *wps_pin)
+int _net_dbus_set_agent_wps_pin_and_connect(
+ const char *wps_pin, const char *profilename)
{
__NETWORK_FUNC_ENTER__;
- int ret_val;
+ net_err_t Error = NET_ERR_NONE;
if (NULL == wps_pin || strlen(wps_pin) <= 0) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid param \n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid param ");
return NET_ERR_INVALID_PARAM;
}
- ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PIN, wps_pin);
- if (NET_ERR_NONE != ret_val) {
- NETWORK_LOG(NETWORK_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
- return ret_val;
+ Error = __net_dbus_set_agent_field_and_connect(
+ NETCONFIG_AGENT_FIELD_WPS_PIN,
+ wps_pin,
+ profilename);
+ if (NET_ERR_NONE != Error) {
+ NETWORK_LOG(NETWORK_ERROR, "PIN configuration failed(%d)", Error);
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully sent wps pin\n");
-
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
int _net_dbus_connect_service(const net_wifi_connect_service_info_t *wifi_connection_info)
wifi_connection_info->mode,
wifi_connection_info->security);
if (NULL == grp_name) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to make a group name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to make a group name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
Error = _net_get_profile_list(NET_DEVICE_WIFI, &profile_info, &profile_count);
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_get_profile_list fail. Error [%s]\n",
+ "_net_get_profile_list fail. Error [%s]",
_net_print_error(Error));
- goto done;
+ goto error;
}
for (i = 0; i < profile_count; i++) {
if (g_strstr_len(profile_info[i].ProfileName,
NET_PROFILE_NAME_LEN_MAX+1, grp_name) != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Found profile %s\n",
+ NETWORK_LOG(NETWORK_ERROR, "Found profile %s",
profile_info[i].ProfileName);
+ if (profile_info[i].ProfileState == NET_STATE_TYPE_READY ||
+ profile_info[i].ProfileState == NET_STATE_TYPE_ONLINE) {
+ NETWORK_LOG(NETWORK_ERROR, "Already profile is connected");
+ Error = NET_ERR_ACTIVE_CONNECTION_EXISTS;
+
+ goto error;
+ }
+
break;
}
}
if (i >= profile_count) {
- NETWORK_LOG(NETWORK_ERROR, "No matching profile found\n");
+ NETWORK_LOG(NETWORK_ERROR, "No matching profile found");
Error = NET_ERR_NO_SERVICE;
- goto done;
+ goto error;
}
if (wifi_connection_info->is_hidden == TRUE) {
if (g_strcmp0(wifi_connection_info->security, "ieee8021x") == 0) {
/* Create the EAP config file */
- Error = _net_dbus_set_eap_config_fields(wifi_connection_info);
+ Error = _net_dbus_set_eap_config_fields_and_connect(
+ wifi_connection_info, profile_info[i].ProfileName);
if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR, "Fail to create eap_config\n");
+ NETWORK_LOG(NETWORK_ERROR, "Fail to create eap_config");
- goto done;
+ goto error;
}
} else if (wifi_connection_info->is_hidden == TRUE) {
Error = _net_dbus_set_agent_fields_and_connect(
wifi_connection_info->passphrase,
profile_info[i].ProfileName);
} else if (g_strcmp0(wifi_connection_info->security, "none") != 0) {
- Error = _net_dbus_set_agent_passphrase(wifi_connection_info->passphrase);
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ wifi_connection_info->passphrase, profile_info[i].ProfileName);
if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR, "Fail to set agent_passphrase\n");
+ NETWORK_LOG(NETWORK_ERROR, "Fail to set agent_passphrase");
- goto done;
+ goto error;
}
- }
+ } else
+ Error = _net_dbus_open_connection(profile_info[i].ProfileName);
- Error = _net_dbus_open_connection(profile_info[i].ProfileName);
+error:
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
0, sizeof(network_request_table_t));
- } else
- NETWORK_LOG(NETWORK_HIGH, "Sent Connect request\n");
+ }
-done:
NET_MEMFREE(profile_info);
g_free(grp_name);
{
__NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
const char *manual_method = "manual";
const char *dhcp_method = "dhcp";
char *netmask = netmask_buffer;
char *gateway = gateway_buffer;
- GError *error = NULL;
- GVariant *reply = NULL;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
net_dev_info_t *profile_net_info = NULL;
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ GVariant *message = NULL;
+
+ NETWORK_LOG(NETWORK_HIGH, "profile_name: [%s]",profile_name);
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
return NET_ERR_INVALID_PARAM;
}
-
g_strlcpy(ip_buffer,
inet_ntoa(profile_net_info->IpAddr.Data.Ipv4),
NETPM_IPV4_STR_LEN_MAX + 1);
inet_ntoa(profile_net_info->GatewayAddr.Data.Ipv4),
NETPM_IPV4_STR_LEN_MAX + 1);
-
- NETWORK_LOG(NETWORK_HIGH, "ipaddress: %s, netmask: %s, gateway: %s\n",
+ SECURE_NETWORK_LOG(NETWORK_LOW, "ip: %s, netmask: %s, gateway: %s",
ipaddress, netmask, gateway);
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2: %s %s %s %s\n", CONNMAN_SERVICE,
- profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
-
builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC ||
return NET_ERR_INVALID_PARAM;
}
-
- params = g_variant_new("(sv)", prop_ipv4_configuration, g_variant_builder_end(builder));
+ params = g_variant_new("(sv)",
+ prop_ipv4_configuration, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- reply = g_dbus_connection_call_sync(connection,
- CONNMAN_SERVICE,
- profile_name,
- CONNMAN_SERVICE_INTERFACE,
- "SetProperty",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- }
-
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if(message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set IPv4 Property");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
+ return Error;
}
+ g_variant_unref(message);
NETWORK_LOG(NETWORK_HIGH, "Successfully configured IPv4.Configuration\n");
- g_variant_unref(reply);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
int _net_dbus_set_profile_ipv6(net_profile_info_t* prof_info, char* profile_name)
char *gw6_ptr = gwaddr6;
char *prlen_ptr = prefixlen;
- GError *error = NULL;
- GVariant *reply = NULL;
+ net_err_t Error = NET_ERR_NONE;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
+ GVariant *message = NULL;
net_dev_info_t *profile_net_info = NULL;
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
-
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
__NETWORK_FUNC_EXIT__;
g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- reply = g_dbus_connection_call_sync(connection,
- CONNMAN_SERVICE,
- profile_name,
- CONNMAN_SERVICE_INTERFACE,
- "SetProperty",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync()"
- " failed. error [%d: %s]\n",
- error->code, error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- }
-
- if (params)
- g_variant_unref(params);
-
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name,
+ CONNMAN_SERVICE_INTERFACE, "SetProperty", params,
+ &Error);
+ if(message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set IPv6 Property");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
+ return Error;
}
+ g_variant_unref(message);
NETWORK_LOG(NETWORK_HIGH, "Successfully configured IPv6.Configuration\n");
- g_variant_unref(reply);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
int _net_dbus_set_profile_dns(net_profile_info_t* prof_info, char* profile_name)
const char *prop_nameserver_configuration = "Nameservers.Configuration";
char dns_buffer[NET_DNS_ADDR_MAX][NETPM_IPV4_STR_LEN_MAX+1];
char *dns_address[NET_DNS_ADDR_MAX];
-
+ net_err_t Error = NET_ERR_NONE;
GVariant *params = NULL;
GVariantBuilder *builder;
int i = 0;
- GDBusConnection *connection;
- net_err_t Error = NET_ERR_NONE;
net_dev_info_t *profile_net_info = NULL;
GVariant *message = NULL;
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if(prof_info->profile_type == NET_DEVICE_WIFI)
+ if (prof_info->profile_type == NET_DEVICE_WIFI)
profile_net_info = &(prof_info->ProfileInfo.Wlan.net_info);
- else if(prof_info->profile_type == NET_DEVICE_ETHERNET)
+ else if (prof_info->profile_type == NET_DEVICE_ETHERNET)
profile_net_info = &(prof_info->ProfileInfo.Ethernet.net_info);
else {
NETWORK_LOG(NETWORK_ERROR, "Invalid Profile Type\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
-
if(profile_net_info->DnsCount > NET_DNS_ADDR_MAX ) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_PARAM;
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
}
for (i = 0; i < profile_net_info->DnsCount; i++) {
dns_address[i] = dns_buffer[i];
}
- if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC ||
- profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC) {
+ if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
builder = g_variant_builder_new(G_VARIANT_TYPE ("as"));
for (i = 0; i < profile_net_info->DnsCount; i++) {
NETWORK_LOG(NETWORK_HIGH, "Successfully configured Nameservers.Configuration\n");
g_variant_unref(message);
}
+
__NETWORK_FUNC_EXIT__;
return Error;
}
{
__NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
+
const char *direct_method = "direct";
const char *auto_method = "auto";
const char *manual_method = "manual";
GVariant *params = NULL;
GVariantBuilder *builder;
GVariantBuilder *builder_sub;
+ net_dev_info_t *profile_net_info = NULL;
GVariant *message = NULL;
- net_dev_info_t *profile_net_info = NULL;
- net_err_t Error = NET_ERR_NONE;
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
-
if (prof_info->profile_type == NET_DEVICE_WIFI)
profile_net_info = &(prof_info->ProfileInfo.Wlan.net_info);
else if (prof_info->profile_type == NET_DEVICE_ETHERNET)
g_strlcpy(proxy_buffer,
profile_net_info->ProxyAddr, NET_PROXY_LEN_MAX+1);
- NETWORK_LOG(NETWORK_HIGH, "Method : %d, proxy address : %s\n",
- prof_info->ProfileInfo.Wlan.net_info.ProxyMethod, proxy_address);
+ SECURE_NETWORK_LOG(NETWORK_LOW, "method: %d, proxy address: %s, Profile Name %s",
+ profile_net_info->ProxyMethod, proxy_address,profile_net_info->ProfileName);
builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
-
switch (profile_net_info->ProxyMethod) {
case NET_PROXY_TYPE_AUTO:
g_variant_builder_add(builder, "{sv}", prop_method, g_variant_new_string(auto_method));
g_variant_builder_unref(builder_sub);
}
-
params = g_variant_new("(sv)", prop_proxy_configuration, g_variant_builder_end(builder));
g_variant_builder_unref(builder);
const char *auth_type = "auth_type";
const char *auth_id = "auth_id";
const char *apn = "apn";
- const char *keyword = "keyword";
+ const char *keyword = "profile_name";
char buff_svc_type[10] = "";
char buff_auth_type[10] = "";
char *temp_ptr = NULL;
- GError *error = NULL;
- GVariant *reply = NULL;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ GVariant *message = NULL;
if (prof_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVICE,
- TELEPHONY_MASTER_PATH, TELEPHONY_MASTER_INTERFACE, ".AddProfile");
+#if defined TIZEN_DUALSIM_ENABLE
+ if (prof_info->ProfileInfo.Pdp.PSModemPath[0] != '/' ||
+ (g_str_has_suffix(prof_info->ProfileInfo.Pdp.PSModemPath, "0") != TRUE &&
+ g_str_has_suffix(prof_info->ProfileInfo.Pdp.PSModemPath, "1") != TRUE)) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid modem path: %s",
+ prof_info->ProfileInfo.Pdp.PSModemPath);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+#endif
builder = g_variant_builder_new(G_VARIANT_TYPE ("a{ss}"));
g_snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
temp_ptr = buff_svc_type;
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- service_type, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", service_type, temp_ptr);
if (strlen(prof_info->ProfileInfo.Pdp.HomeURL) > 0) {
temp_ptr = prof_info->ProfileInfo.Pdp.HomeURL;
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- home_url, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", home_url, temp_ptr);
}
if (strlen(prof_info->ProfileInfo.Pdp.net_info.ProxyAddr) > 0) {
temp_ptr = prof_info->ProfileInfo.Pdp.net_info.ProxyAddr;
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- proxy_addr, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", proxy_addr, temp_ptr);
}
params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- reply = g_dbus_connection_call_sync(connection,
- TELEPHONY_SERVICE,
- TELEPHONY_MASTER_PATH,
- TELEPHONY_MASTER_INTERFACE,
- "AddProfile",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
- Error = __net_error_string_to_enum(error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- }
+ message = _net_invoke_dbus_method(TELEPHONY_SERVICE,
+ prof_info->ProfileInfo.Pdp.PSModemPath,
+ TELEPHONY_MODEM_INTERFACE, "AddProfile", params,
+ &Error);
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Add Profile");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully requested : Add PDP profile\n");
-
/** Check Reply */
int add_result = 0;
- g_variant_get(reply, "(b)", &add_result);
- NETWORK_LOG(NETWORK_HIGH, "Profile add result : %d\n", add_result);
-
+ g_variant_get(message, "(b)", &add_result);
if (add_result)
Error = NET_ERR_NONE;
else
Error = NET_ERR_UNKNOWN;
- g_variant_unref(reply);
+ g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
if (modem_path) {
Error = _net_invoke_dbus_method_nonblock(TELEPHONY_SERVICE,
- modem_path,
- TELEPHONY_MODEM_INTERFACE,
- "ResetProfile",
- params,
- __net_reset_cellular_reply);
+ modem_path,
+ TELEPHONY_MODEM_INTERFACE,
+ "ResetProfile",
+ params,
+ DBUS_REPLY_TIMEOUT,
+ __net_reset_cellular_reply);
} else {
Error = _net_invoke_dbus_method_nonblock(TELEPHONY_SERVICE,
- TELEPHONY_MASTER_PATH,
- TELEPHONY_MODEM_INTERFACE,
- "ResetProfile",
- params,
- __net_reset_cellular_reply);
+ TELEPHONY_MASTER_PATH,
+ TELEPHONY_MODEM_INTERFACE,
+ "ResetProfile",
+ params,
+ DBUS_REPLY_TIMEOUT,
+ __net_reset_cellular_reply);
}
__NETWORK_FUNC_EXIT__;
char buff_auth_type[10] = "";
char *temp_ptr = NULL;
- GError *error = NULL;
- GVariant *reply = NULL;
GVariant *params = NULL;
GVariantBuilder *builder;
- GDBusConnection *connection;
-
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ GVariant *message = NULL;
if ((prof_info == NULL) || (profile_name == NULL)) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVICE,
- profile_name, TELEPHONY_PROFILE_INTERFACE, ".ModifyProfile");
-
builder = g_variant_builder_new(G_VARIANT_TYPE ("a{ss}"));
g_snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
temp_ptr = buff_svc_type;
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- service_type, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", service_type, temp_ptr);
if (strlen(prof_info->ProfileInfo.Pdp.HomeURL) > 0) {
temp_ptr = prof_info->ProfileInfo.Pdp.net_info.ProxyAddr;
g_variant_builder_add(builder, "{ss}", proxy_addr, temp_ptr);
- }
+ } else
+ g_variant_builder_add(builder, "{ss}", proxy_addr, "");
if (strlen(prof_info->ProfileInfo.Pdp.AuthInfo.Password) > 0) {
temp_ptr = prof_info->ProfileInfo.Pdp.AuthInfo.Password;
else
temp_ptr = "FALSE";
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- hidden, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", hidden, temp_ptr);
if (prof_info->ProfileInfo.Pdp.Editable)
else
temp_ptr = "FALSE";
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- editable, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", editable, temp_ptr);
if (prof_info->ProfileInfo.Pdp.DefaultConn)
else
temp_ptr = "FALSE";
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
- default_conn, temp_ptr);
-
g_variant_builder_add(builder, "{ss}", default_conn, temp_ptr);
params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
- reply = g_dbus_connection_call_sync(connection,
- TELEPHONY_SERVICE,
- profile_name,
- TELEPHONY_PROFILE_INTERFACE,
- "ModifyProfile",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
- Error = __net_error_string_to_enum(error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- }
-
+ message = _net_invoke_dbus_method(TELEPHONY_SERVICE, profile_name,
+ TELEPHONY_PROFILE_INTERFACE, "ModifyProfile", params,
+ &Error);
+ if(message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Modify Profile");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Successfully requested : Modify PDP profile\n");
-
/** Check Reply */
int add_result = 0;
- g_variant_get(reply, "(b)", &add_result);
- NETWORK_LOG(NETWORK_HIGH, "Profile modify result : %d\n", add_result);
+ g_variant_get(message, "(b)", &add_result);
+ NETWORK_LOG(NETWORK_HIGH, "Profile modify result: %d", add_result);
if (add_result)
Error = NET_ERR_NONE;
else
Error = NET_ERR_UNKNOWN;
- g_variant_unref(reply);
+ g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_dbus_load_wifi_driver(void)
+int _net_dbus_load_wifi_driver(gboolean wifi_picker_test)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
+ GVariant *params;
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "LoadDriver", NULL, __net_wifi_power_reply);
+ params = g_variant_new("(b)", wifi_picker_test);
+
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "LoadDriver", params, DBUS_REPLY_TIMEOUT,
+ __net_wifi_power_reply);
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
- Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE, "RemoveDriver", NULL, __net_wifi_power_reply);
+ /* use DBus signal than reply pending because of performance reason */
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RemoveDriver", NULL, DBUS_REPLY_TIMEOUT,
+ __net_wifi_power_reply);
__NETWORK_FUNC_EXIT__;
return Error;
}
-gboolean __net_dbus_abort_open_request(const char *profile_name)
+int _net_dbus_specific_scan_request(const char *ssid)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_t event_data;
- char event_string[64];
+ GVariant *params = NULL;
+ net_err_t Error = NET_ERR_NONE;
- char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ params = g_variant_new("(s)", ssid);
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
- strstr(profile_name, svc_name1) != NULL) {
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RequestSpecificScan", params, 6 * DBUS_REPLY_TIMEOUT,
+ __net_specific_scan_wifi_reply);
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
- sizeof(network_request_table_t));
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
- event_data.Event = NET_EVENT_OPEN_RSP;
- g_strlcpy(event_string, "Sending NET_EVENT_OPEN_RSP", 64);
- _net_dbus_pending_call_unref();
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- strcmp(profile_name, svc_name2) == 0) {
+int _net_dbus_wps_scan_request(void)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
- sizeof(network_request_table_t));
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RequestWpsScan", NULL, 6 * DBUS_REPLY_TIMEOUT,
+ __net_wps_scan_wifi_reply);
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- g_strlcpy(event_string, "Sending NET_EVENT_WIFI_WPS_RSP", 64);
- _net_dbus_pending_call_unref();
- } else {
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_passpoint(int *enabled)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *message = NULL;
+ net_err_t Error = NET_ERR_NONE;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "GetPasspoint", NULL, &Error);
+ if(message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Get Passpoint");
__NETWORK_FUNC_EXIT__;
- return FALSE;
+ return Error;
}
- g_strlcpy(event_data.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Datalength = 0;
- event_data.Data = NULL;
+ /** Check Reply */
+ int result = 0;
+ g_variant_get(message, "(i)", &result);
+ *enabled = result;
- NETWORK_LOG(NETWORK_LOW, "%s, Error : %d\n", event_string, event_data.Error);
- _net_client_callback(&event_data);
+ NETWORK_LOG(NETWORK_HIGH, "Get passpoint result: %d", result);
+
+ g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
- return TRUE;
+ return Error;
}
-int _net_dbus_specific_scan_request(const char *ssid)
+int _net_dbus_set_passpoint(int enable)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GVariant *params;
+ net_err_t Error = NET_ERR_NONE;
+
+ params = g_variant_new("(i)", enable);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "SetPasspoint", params, 6 * DBUS_REPLY_TIMEOUT,
+ __net_set_passpoint_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+#if defined TIZEN_TV
+static void __net_wps_cancel_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ NETWORK_LOG(NETWORK_LOW, "__net_wps_cancel_wifi_reply() called\n");
+
+ GDBusConnection *conn = NULL;
+ GVariant *dbus_result =NULL;
+ GError *error = NULL;
+
+ conn = G_DBUS_CONNECTION (source_object);
+ dbus_result = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "error msg - [%s]\n", error->message);
+ g_error_free(error);
+ }
+
+ if (dbus_result)
+ g_variant_unref(dbus_result);
+
+ _net_dbus_pending_call_unref();
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+
+int _net_dbus_cancel_wps(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsCancel", NULL, DBUS_REPLY_TIMEOUT,
+ __net_wps_cancel_reply);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+
+}
+
+static int __net_dbus_set_agent_field(const char *key, const char *value)
{
__NETWORK_FUNC_ENTER__;
GVariant *params = NULL;
- GDBusConnection *connection;
+ GVariantBuilder *builder;
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *message = NULL;
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
- params = g_variant_new("(s)", ssid);
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("a{ss}"));
+ g_variant_builder_add(builder, "{ss}", key, value);
- g_dbus_connection_call(connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE,
- "RequestSpecificScan",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- 6 * DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- (GAsyncReadyCallback) __net_specific_scan_wifi_reply,
- NULL);
+ params = g_variant_new("(@a{ss})", g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
- NETWORK_LOG(NETWORK_HIGH, "Successfully configured\n");
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+ CONNMAN_AGENT_INTERFACE, "SetField", params, &Error);
- _net_dbus_pending_call_ref();
+ if (Error != NET_ERR_NONE)
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed");
+
+ if (message != NULL)
+ g_variant_unref(message);
+ else
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-int _net_dbus_get_passpoint(int *enabled)
+static void __net_wps_connect_wifi_reply(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
{
__NETWORK_FUNC_ENTER__;
- GDBusConnection *connection;
+ int callback_flag = FALSE;
+ GDBusConnection *conn = NULL;
GError *error = NULL;
- GVariant *reply = NULL;
+ GVariant *dbus_result = NULL;
+ net_event_info_t event_data;
net_err_t Error = NET_ERR_NONE;
+ network_request_table_t *wps_info =
+ &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+ memset(&event_data, 0, sizeof(event_data));
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ conn = G_DBUS_CONNECTION (source_object);
+ dbus_result = g_dbus_connection_call_finish(conn, res, &error);
- reply = g_dbus_connection_call_sync(connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE,
- "GetPasspoint",
- NULL,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- &error);
- if (reply == NULL) {
- if (error != NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed."
- "error [%d: %s]\n", error->code, error->message);
- Error = __net_error_string_to_enum(error->message);
- g_error_free(error);
- } else {
- NETWORK_LOG(NETWORK_ERROR,
- "g_dbus_connection_call_sync() failed.\n");
- Error = NET_ERR_UNKNOWN;
- }
+ if (error != NULL) {
+ NETWORK_LOG(NETWORK_HIGH, "error msg - [%s]\n", error->message);
+ Error = __net_error_string_to_enum(error->message);
+ g_error_free(error);
+ } else
+ NETWORK_LOG(NETWORK_LOW, "error msg is NULL\n");
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
+ if (dbus_result)
+ g_variant_unref(dbus_result);
- /** Check Reply */
- int result = 0;
- g_variant_get(reply, "(i)", &result);
- *enabled = result;
+ if (Error == NET_ERR_NONE)
+ goto done;
+
+ NETWORK_LOG(NETWORK_ERROR, "Connection open failed. Error [%d]\n", Error);
+
+ memset(wps_info, 0, sizeof(network_request_table_t));
- NETWORK_LOG(NETWORK_HIGH, "Get passpoint result: %d\n", result);
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- g_variant_unref(reply);
+ NETWORK_LOG(NETWORK_HIGH, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s\n",
+ _net_print_error(event_data.Error));
+
+ callback_flag = TRUE;
+
+done:
+ _net_dbus_pending_call_unref();
+
+ if (callback_flag)
+ _net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
}
-int _net_dbus_set_passpoint(int enable)
+int _net_dbus_open_connection_without_ssid()
{
__NETWORK_FUNC_ENTER__;
- GDBusConnection *connection;
- GVariant *params;
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *params = NULL;
- connection = _net_dbus_get_gdbus_conn();
- if (connection == NULL)
- return NET_ERR_APP_NOT_REGISTERED;
+ params = g_variant_new("(s)", "PBC");
+ NETWORK_LOG(NETWORK_ERROR, "Invoke wps connection without ssid");
- params = g_variant_new("(i)", enable);
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsConnect", params,DBUS_REPLY_TIMEOUT,
+ __net_wps_connect_wifi_reply);
- g_dbus_connection_call(connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_PATH,
- NETCONFIG_WIFI_INTERFACE,
- "SetPasspoint",
- params,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- 6 * DBUS_REPLY_TIMEOUT,
- _net_dbus_get_gdbus_cancellable(),
- (GAsyncReadyCallback) __net_set_passpoint_reply,
- NULL);
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+
+int _net_dbus_open_pin_connection_without_ssid(const char *pin){
+
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
- NETWORK_LOG(NETWORK_HIGH, "Successfully configured\n");
+ GVariant *params = NULL;
+ params = g_variant_new("(s)", pin);
+
+ Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_TV_PROFILE_INTERFACE,
+ "RequestWpsConnect", params,DBUS_REPLY_TIMEOUT,
+ __net_wps_connect_wifi_reply);
+
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_agent_wps_pbc(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int ret_val;
+
+ ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PBC, "enable");
+ if (NET_ERR_NONE != ret_val) {
+ NETWORK_LOG(NETWORK_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
+ return ret_val;
+ }
- _net_dbus_pending_call_ref();
+ NETWORK_LOG(NETWORK_HIGH, "Successfully sent wps pbc\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
+int _net_dbus_set_agent_wps_pin(const char *wps_pin)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int ret_val;
+
+ if (NULL == wps_pin || strlen(wps_pin) <= 0) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid param \n");
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ ret_val = __net_dbus_set_agent_field(NETCONFIG_AGENT_FIELD_WPS_PIN, wps_pin);
+ if (NET_ERR_NONE != ret_val) {
+ NETWORK_LOG(NETWORK_ERROR, "__net_dbus_set_agent_field failed. Error = %d \n", ret_val);
+ return ret_val;
+ }
+
+ NETWORK_LOG(NETWORK_HIGH, "Successfully sent wps pin\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+#endif
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
void *handle_libnetwork;
};
+struct managed_idle_data {
+ GSourceFunc func;
+ gpointer user_data;
+ guint id;
+};
+
/*****************************************************************************
* Extern Global Variables
*****************************************************************************/
__thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = { { 0, }, };
static __thread struct gdbus_connection_data gdbus_conn = { NULL, 0, NULL, NULL };
+static __thread GSList *managed_idler_list = NULL;
static char *__convert_eap_type_to_string(gchar eap_type)
{
gchar *tech_prefix;
gchar *path = NULL;
gchar *key = NULL;
- gboolean data = FALSE;
+ gboolean data;
if (g_str_equal(tech_state->technology, "wifi") == TRUE)
tech_prefix = CONNMAN_WIFI_TECHNOLOGY_PREFIX;
else if (g_str_equal(tech_state->technology, "bluetooth") == TRUE)
tech_prefix = CONNMAN_BLUETOOTH_TECHNOLOGY_PREFIX;
else {
- NETWORK_LOG(NETWORK_LOW, "Invalid technology type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid technology type");
Error = NET_ERR_INVALID_PARAM;
goto done;
}
if (path == NULL || g_str_equal(path, tech_prefix) != TRUE)
continue;
- NETWORK_LOG(NETWORK_LOW, "Path - [%s]", path);
-
while (g_variant_iter_loop(var, "{sv}", &key, &value)) {
if (g_strcmp0(key, "Powered") == 0) {
data = g_variant_get_boolean(value);
tech_state->Powered = TRUE;
else
tech_state->Powered = FALSE;
-
- NETWORK_LOG(NETWORK_ERROR, "key-[%s]-[%d]", key, tech_state->Powered);
} else if (g_strcmp0(key, "Connected") == 0) {
data = g_variant_get_boolean(value);
tech_state->Connected = TRUE;
else
tech_state->Connected = FALSE;
-
- NETWORK_LOG(NETWORK_ERROR, "key-[%s]-[%d]", key, tech_state->Connected);
} else if (g_strcmp0(key, "Tethering") == 0) {
- data = g_variant_get_boolean(value);
- if (data)
- tech_state->Tethering = TRUE;
- else
- tech_state->Tethering = FALSE;
- NETWORK_LOG(NETWORK_ERROR, "key-[%s]-[%d]", key, tech_state->Tethering);
+ /* For further use */
}
}
}
net_wifi_connect_service_info_t wifi_connection_info;
memset(&wifi_connection_info, 0, sizeof(net_wifi_connect_service_info_t));
- wifi_connection_info.type = g_strdup("wifi");
+ wifi_connection_info.type = "wifi";
if (wifi_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)
- wifi_connection_info.mode = g_strdup("adhoc");
+ wifi_connection_info.mode = "adhoc";
else
- wifi_connection_info.mode = g_strdup("managed");
+ wifi_connection_info.mode = "managed";
- wifi_connection_info.ssid = g_strdup(wifi_info->essid);
+ wifi_connection_info.ssid = (char *)wifi_info->essid;
wifi_connection_info.is_hidden = wifi_info->is_hidden;
switch (wifi_info->security_info.sec_mode) {
case WLAN_SEC_MODE_NONE:
- wifi_connection_info.security = g_strdup("none");
+ wifi_connection_info.security = "none";
break;
case WLAN_SEC_MODE_WEP:
- wifi_connection_info.security = g_strdup("wep");
+ wifi_connection_info.security = "wep";
wifi_connection_info.passphrase =
- g_strdup(wifi_info->security_info.authentication.wep.wepKey);
+ (char *)wifi_info->security_info.authentication.wep.wepKey;
break;
- /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
+ /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
case WLAN_SEC_MODE_WPA_PSK:
- wifi_connection_info.security = g_strdup("psk");
+ wifi_connection_info.security = "psk";
wifi_connection_info.passphrase =
- g_strdup(wifi_info->security_info.authentication.psk.pskKey);
+ (char *)wifi_info->security_info.authentication.psk.pskKey;
break;
/** WPA2-PSK */
/** WPA-PSK / WPA2-PSK supported */
case WLAN_SEC_MODE_WPA2_PSK:
- wifi_connection_info.security = g_strdup("rsn");
+ wifi_connection_info.security = "rsn";
wifi_connection_info.passphrase =
- g_strdup(wifi_info->security_info.authentication.psk.pskKey);
+ (char *)wifi_info->security_info.authentication.psk.pskKey;
break;
case WLAN_SEC_MODE_IEEE8021X:
- wifi_connection_info.security = g_strdup("ieee8021x");
+ wifi_connection_info.security = "ieee8021x";
- wifi_connection_info.eap_type = g_strdup(
+ wifi_connection_info.eap_type =
__convert_eap_type_to_string(
- wifi_info->security_info.authentication.eap.eap_type));
- wifi_connection_info.eap_auth = g_strdup(
+ wifi_info->security_info.authentication.eap.eap_type);
+ wifi_connection_info.eap_auth =
__convert_eap_auth_to_string(
- wifi_info->security_info.authentication.eap.eap_auth));
+ wifi_info->security_info.authentication.eap.eap_auth);
if (wifi_info->security_info.authentication.eap.username[0] != '\0')
wifi_connection_info.identity =
- g_strdup(wifi_info->security_info.authentication.eap.username);
+ (char *)wifi_info->security_info.authentication.eap.username;
if (wifi_info->security_info.authentication.eap.password[0] != '\0')
wifi_connection_info.password =
- g_strdup(wifi_info->security_info.authentication.eap.password);
+ (char *)wifi_info->security_info.authentication.eap.password;
if (wifi_info->security_info.authentication.eap.ca_cert_filename[0] != '\0')
wifi_connection_info.ca_cert_file =
- g_strdup(wifi_info->security_info.authentication.eap.ca_cert_filename);
+ (char *)wifi_info->security_info.authentication.eap.ca_cert_filename;
if (wifi_info->security_info.authentication.eap.client_cert_filename[0] != '\0')
wifi_connection_info.client_cert_file =
- g_strdup(wifi_info->security_info.authentication.eap.client_cert_filename);
+ (char *)wifi_info->security_info.authentication.eap.client_cert_filename;
if (wifi_info->security_info.authentication.eap.private_key_filename[0] != '\0')
wifi_connection_info.private_key_file =
- g_strdup(wifi_info->security_info.authentication.eap.private_key_filename);
+ (char *)wifi_info->security_info.authentication.eap.private_key_filename;
if (wifi_info->security_info.authentication.eap.private_key_passwd[0] != '\0')
wifi_connection_info.private_key_password =
- g_strdup(wifi_info->security_info.authentication.eap.private_key_passwd);
-
+ (char *)wifi_info->security_info.authentication.eap.private_key_passwd;
break;
+
default:
- NETWORK_LOG(NETWORK_ERROR, "Invalid security type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid security type");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
Error = _net_dbus_connect_service(&wifi_connection_info);
if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "Failed to request connect service. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to request connect service. Error [%s]",
_net_print_error(Error));
- else
- NETWORK_LOG(NETWORK_HIGH, "Successfully requested to connect service\n");
-
- g_free(wifi_connection_info.type);
- g_free(wifi_connection_info.mode);
- g_free(wifi_connection_info.ssid);
- g_free(wifi_connection_info.security);
- g_free(wifi_connection_info.passphrase);
- g_free(wifi_connection_info.eap_type);
- g_free(wifi_connection_info.eap_auth);
- g_free(wifi_connection_info.identity);
- g_free(wifi_connection_info.password);
- g_free(wifi_connection_info.ca_cert_file);
- g_free(wifi_connection_info.client_cert_file);
- g_free(wifi_connection_info.private_key_file);
- g_free(wifi_connection_info.private_key_password);
__NETWORK_FUNC_EXIT__;
return Error;
}
-void _net_client_callback(net_event_info_t *event_data)
+static gboolean __net_client_cb_idle(gpointer data)
{
- __NETWORK_FUNC_ENTER__;
+ GSList *bss_info_list = NULL;
+ net_event_info_t *event_data = (net_event_info_t *)data;
+
+ if (event_data->Event == NET_EVENT_SPECIFIC_SCAN_IND ||
+ event_data->Event == NET_EVENT_WPS_SCAN_IND) {
+ bss_info_list = (GSList *)event_data->Data;
+ }
if (NetworkInfo.ClientEventCb != NULL)
NetworkInfo.ClientEventCb(event_data, NetworkInfo.user_data);
+ /* BSS list should be released in a delayed manner */
+ if (bss_info_list != NULL)
+ g_slist_free_full(bss_info_list, g_free);
+ else if (event_data->Datalength > 0)
+ g_free(event_data->Data);
+
+ g_free(event_data);
+
+ return FALSE;
+}
+
+static gboolean __net_client_cb_conn_idle(gpointer data)
+{
+ net_event_info_t *event_data = (net_event_info_t *)data;
+
+ if (event_data->Event == NET_EVENT_SPECIFIC_SCAN_IND) {
+ /* ClientEventCb only handles NET_EVENT_SPECIFIC_SCAN_IND */
+ g_free(event_data);
+ return FALSE;
+ }
+
if (NetworkInfo.ClientEventCb_conn != NULL)
NetworkInfo.ClientEventCb_conn(event_data, NetworkInfo.user_data_conn);
+ if (event_data->Datalength > 0)
+ g_free(event_data->Data);
+
+ g_free(event_data);
+
+ return FALSE;
+}
+
+static gboolean __net_client_cb_wifi_idle(gpointer data)
+{
+ net_event_info_t *event_data = (net_event_info_t *)data;
+
if (NetworkInfo.ClientEventCb_wifi != NULL)
NetworkInfo.ClientEventCb_wifi(event_data, NetworkInfo.user_data_wifi);
+ if (event_data->Datalength > 0)
+ g_free(event_data->Data);
+
+ g_free(event_data);
+
+ return FALSE;
+}
+
+void _net_client_callback(net_event_info_t *event_data)
+{
+ guint id;
+
+ __NETWORK_FUNC_ENTER__;
+
+ if (NetworkInfo.ref_count < 1) {
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered. "
+ "If multi-threaded, thread integrity be broken.");
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ if (NetworkInfo.ClientEventCb != NULL) {
+ GSList *bss_info_list = NULL;
+ net_event_info_t *client = g_try_new0(net_event_info_t, 1);
+ if (client == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client, event_data, sizeof(net_event_info_t));
+
+ if (event_data->Event == NET_EVENT_SPECIFIC_SCAN_IND ||
+ event_data->Event == NET_EVENT_WPS_SCAN_IND) {
+ /* To enhance performance,
+ * BSS list should be delivered directly */
+ bss_info_list = (GSList *)event_data->Data;
+ } else if (event_data->Datalength > 0) {
+ client->Data = g_try_malloc0(event_data->Datalength);
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, event_data->Datalength);
+ } else {
+ client->Datalength = 0;
+ client->Data = NULL;
+ }
+
+ id = _net_client_callback_add(__net_client_cb_idle, (gpointer)client);
+ if (!id) {
+ if (bss_info_list != NULL)
+ g_slist_free_full(bss_info_list, g_free);
+ else if (client->Datalength > 0)
+ g_free(client->Data);
+
+ g_free(client);
+ }
+ }
+
+ if (NetworkInfo.ClientEventCb_conn != NULL &&
+ event_data->Event != NET_EVENT_SPECIFIC_SCAN_IND &&
+ event_data->Event != NET_EVENT_WPS_SCAN_IND) {
+ net_event_info_t *client = g_try_new0(net_event_info_t, 1);
+ if (client == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client, event_data, sizeof(net_event_info_t));
+
+ if (event_data->Datalength > 0) {
+ client->Data = g_try_malloc0(event_data->Datalength);
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, event_data->Datalength);
+ } else {
+ client->Datalength = 0;
+ client->Data = NULL;
+ }
+
+ id = _net_client_callback_add(__net_client_cb_conn_idle, (gpointer)client);
+ if (!id) {
+ if (client->Datalength > 0)
+ g_free(client->Data);
+
+ g_free(client);
+ }
+ }
+
+ if (NetworkInfo.ClientEventCb_wifi != NULL) {
+ net_event_info_t *client = g_try_new0(net_event_info_t, 1);
+ if (client == NULL) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client, event_data, sizeof(net_event_info_t));
+ if (event_data->Datalength > 0) {
+ if (event_data->Event == NET_EVENT_SPECIFIC_SCAN_IND ||
+ event_data->Event == NET_EVENT_WPS_SCAN_IND) {
+ client->Data = g_try_malloc0(sizeof(GSList));
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, sizeof(GSList));
+ }
+ else {
+ client->Data = g_try_malloc0(event_data->Datalength);
+ if (client->Data == NULL) {
+ g_free(client);
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ memcpy(client->Data, event_data->Data, event_data->Datalength);
+ }
+ } else {
+ client->Datalength = 0;
+ client->Data = NULL;
+ }
+
+ id = _net_client_callback_add(__net_client_cb_wifi_idle, (gpointer)client);
+ if (!id) {
+ if (client->Datalength > 0)
+ g_free(client->Data);
+
+ g_free(client);
+ }
+ }
+
__NETWORK_FUNC_EXIT__;
}
-net_wifi_state_t _net_get_wifi_state(void)
+net_wifi_state_t _net_get_wifi_state(net_err_t *net_error)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- network_tech_state_info_t tech_state = {{0,},};
+ network_tech_state_info_t tech_state = { { 0, }, };
net_wifi_state_t wifi_state = WIFI_UNKNOWN;
g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
Error = _net_dbus_get_technology_state(&tech_state);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_get_technology_state() failed. Error [%s]\n",
+ "_net_dbus_get_technology_state() failed. Error [%s]",
_net_print_error(Error));
+ *net_error = Error;
goto state_done;
}
- if (tech_state.Powered == TRUE
- && tech_state.Tethering != TRUE)
+ if (tech_state.Powered == TRUE)
wifi_state = WIFI_ON;
else
wifi_state = WIFI_OFF;
return wifi_state;
}
+static void __net_client_idle_destroy_cb(gpointer data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return;
+ }
+
+ managed_idler_list = g_slist_remove(managed_idler_list, data);
+ g_free(data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static gboolean __net_client_idle_cb(gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ struct managed_idle_data *data = (struct managed_idle_data *)user_data;
+
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return FALSE;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return data->func(data->user_data);
+}
+
+guint _net_client_callback_add(GSourceFunc func, gpointer user_data)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ guint id;
+ struct managed_idle_data *data;
+
+ if (!func) {
+ __NETWORK_FUNC_EXIT__;
+ return 0;
+ }
+
+ data = g_try_new0(struct managed_idle_data, 1);
+ if (!data) {
+ __NETWORK_FUNC_EXIT__;
+ return 0;
+ }
+
+ data->func = func;
+ data->user_data = user_data;
+
+ id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __net_client_idle_cb, data,
+ __net_client_idle_destroy_cb);
+ if (!id) {
+ g_free(data);
+ __NETWORK_FUNC_EXIT__;
+ return id;
+ }
+
+ data->id = id;
+
+ managed_idler_list = g_slist_append(managed_idler_list, data);
+
+ __NETWORK_FUNC_EXIT__;
+ return id;
+}
+
+void _net_client_callback_cleanup(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ GSList *cur = managed_idler_list;
+ GSource *src;
+ struct managed_idle_data *data;
+
+ while (cur) {
+ GSList *next = cur->next;
+ data = (struct managed_idle_data *)cur->data;
+
+ src = g_main_context_find_source_by_id(g_main_context_default(), data->id);
+ if (src) {
+ g_source_destroy(src);
+ cur = managed_idler_list;
+ } else
+ cur = next;
+ }
+
+ g_slist_free(managed_idler_list);
+ managed_idler_list = NULL;
+
+ __NETWORK_FUNC_EXIT__;
+}
+
void _net_clear_request_table(void)
{
__NETWORK_FUNC_ENTER__;
- int i = 0;
+ int i;
- for (i = 0;i < NETWORK_REQUEST_TYPE_MAX;i++)
+ for (i = 0; i < NETWORK_REQUEST_TYPE_MAX; i++)
memset(&request_table[i], 0, sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
if (__sync_sub_and_fetch(&gdbus_conn.conn_ref_count, 1) < 1 &&
gdbus_conn.handle_libnetwork != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL\n");
+ NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL");
gdbus_conn.connection = NULL;
}
int _net_dbus_create_gdbus_call(void)
{
GError *error = NULL;
- gchar *addr;
if (gdbus_conn.connection != NULL) {
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_ALREADY_REGISTERED;
}
- addr = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (!addr) {
- NETWORK_LOG(NETWORK_ERROR,
- "Failed to get D-BUS : [%s]\n", error->message);
- g_error_free(error);
- return NET_ERR_UNKNOWN;
- }
+#if !GLIB_CHECK_VERSION(2,36,0)
+ g_type_init();
+#endif
- gdbus_conn.connection = g_dbus_connection_new_for_address_sync(addr,
- G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
- G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
- NULL, NULL, &error);
- g_free(addr);
+ gdbus_conn.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (gdbus_conn.connection == NULL) {
- NETWORK_LOG(NETWORK_ERROR,
- "Failed to connect to the D-BUS daemon: [%s]\n", error->message);
- g_error_free(error);
+ if (error != NULL) {
+ NETWORK_LOG(NETWORK_ERROR,
+ "Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
return NET_ERR_UNKNOWN;
}
if (gdbus_conn.handle_libnetwork != NULL) {
NETWORK_LOG(NETWORK_ERROR,
- "A handle of libnetwork is not NULL and should be released\n");
+ "A handle of libnetwork is not NULL and should be released");
dlclose(gdbus_conn.handle_libnetwork);
gdbus_conn.handle_libnetwork = NULL;
g_object_unref(gdbus_conn.cancellable);
gdbus_conn.cancellable = NULL;
- if (g_dbus_connection_close_sync(gdbus_conn.connection, NULL, NULL) == FALSE) {
- NETWORK_LOG(NETWORK_HIGH, "Failed to close GDBus\n");
- return NET_ERR_UNKNOWN;
- }
-
if (gdbus_conn.conn_ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "There is no pending call\n");
+ NETWORK_LOG(NETWORK_ERROR, "There is no pending call");
g_object_unref(gdbus_conn.connection);
gdbus_conn.connection = NULL;
} else {
NETWORK_LOG(NETWORK_ERROR,
- "There are %d pending calls, waiting to be cleared\n",
+ "There are %d pending calls, waiting to be cleared",
gdbus_conn.conn_ref_count);
if (gdbus_conn.handle_libnetwork != NULL)
- NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL\n");
+ NETWORK_LOG(NETWORK_ERROR, "A handle of libnetwork is not NULL");
gdbus_conn.handle_libnetwork =
dlopen("/usr/lib/libnetwork.so", RTLD_LAZY);
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*/
#include <ctype.h>
+#include <stdio.h>
#include <arpa/inet.h>
#include "network-internal.h"
#include "network-dbus-request.h"
+#define DBUS_OBJECT_PATH_MAX 150
+
/*****************************************************************************
* Local Functions Declaration
*****************************************************************************/
static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_t* ProfInfo);
-static int __net_get_profile_info(const char* ProfileName, net_profile_info_t* ProfInfo);
static int __net_extract_service_info(const char* ProfileName,
GVariant *message, net_profile_info_t* ProfInfo);
-static int __net_pm_init_profile_info(net_device_t profile_type, net_profile_info_t* ProfInfo);
-static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfInfo);
-static int __net_telephony_get_profile_info(net_profile_name_t* ProfileName,
- net_telephony_profile_info_t *ProfileInfo);
-static int __net_telephony_get_profile_list(net_profile_name_t** ProfileName, int* ProfileCount);
static int __net_extract_services(GVariantIter *message, net_device_t device_type,
net_profile_info_t** profile_info, int* profile_count);
static int __net_extract_ip(const gchar *value, net_addr_t *ipAddr);
static int __net_extract_mobile_info(GVariantIter *array, net_profile_info_t* ProfInfo);
static int __net_extract_ethernet_info(GVariantIter *array, net_profile_info_t* ProfInfo);
static int __net_extract_bluetooth_info(GVariantIter *array, net_profile_info_t* ProfInfo);
-static int __net_telephony_search_pdp_profile(char* ProfileName, net_profile_name_t* PdpProfName);
-static int __net_telephony_modify_profile(const char* ProfileName,
- net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo);
-static int __net_modify_wlan_profile_info(const char* ProfileName,
- net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo);
-static int __net_telephony_delete_profile(net_profile_name_t* PdpProfName);
-static int __net_wifi_delete_profile(net_profile_name_t* WifiProfName,
- wlan_security_mode_type_t sec_mode, gboolean passpoint);
-static int __net_telephony_add_profile(net_profile_info_t *ProfInfo, net_service_type_t network_type);
-static int __net_set_default_cellular_service_profile_sync(const char* ProfileName);
-static int __net_set_default_cellular_service_profile_async(const char* ProfileName);
-static int __net_modify_ethernet_profile(const char* ProfileName,
- net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo);
/*****************************************************************************
* Extern Variables
/*****************************************************************************
* Local Functions Definition
*****************************************************************************/
-static int __net_pm_init_profile_info(net_device_t profile_type, net_profile_info_t* ProfInfo)
+static int __net_pm_init_profile_info(net_device_t profile_type, net_profile_info_t *ProfInfo)
{
- __NETWORK_FUNC_ENTER__;
-
int i = 0;
- net_dev_info_t* net_info = NULL;
+ net_dev_info_t *net_info = NULL;
if (ProfInfo == NULL ||
(profile_type != NET_DEVICE_WIFI &&
}
memset(ProfInfo, 0, sizeof(net_profile_info_t));
- ProfInfo->Favourite = FALSE;
+ ProfInfo->Favourite = (char)FALSE;
if (profile_type == NET_DEVICE_WIFI) {
ProfInfo->profile_type = NET_DEVICE_WIFI;
ProfInfo->ProfileInfo.Wlan.security_info.wps_support = FALSE;
net_info = &(ProfInfo->ProfileInfo.Wlan.net_info);
- } else if(profile_type == NET_DEVICE_CELLULAR) {
+ } else if (profile_type == NET_DEVICE_CELLULAR) {
ProfInfo->profile_type = NET_DEVICE_CELLULAR;
ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_NONE;
ProfInfo->ProfileInfo.Pdp.ServiceType = NET_SERVICE_UNKNOWN;
ProfInfo->ProfileInfo.Pdp.DefaultConn = FALSE;
net_info = &(ProfInfo->ProfileInfo.Pdp.net_info);
- } else if(profile_type == NET_DEVICE_ETHERNET) {
+ } else if (profile_type == NET_DEVICE_ETHERNET) {
net_info = &(ProfInfo->ProfileInfo.Ethernet.net_info);
- } else if(profile_type == NET_DEVICE_BLUETOOTH) {
+ } else if (profile_type == NET_DEVICE_BLUETOOTH) {
net_info = &(ProfInfo->ProfileInfo.Bluetooth.net_info);
}
net_info->BDefGateway6 = FALSE;
net_info->GatewayAddr6.Type = NET_ADDR_IPV6;
inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
-
+
net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
- __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfInfo)
{
- __NETWORK_FUNC_ENTER__;
-
if (ProfInfo == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
ProfInfo->Editable = TRUE;
ProfInfo->DefaultConn = FALSE;
- __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-static int __net_get_service_type(gchar *obj_path)
-{
- if (g_str_has_prefix(obj_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
- return NET_DEVICE_WIFI;
- else if (g_str_has_prefix(obj_path, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
- return NET_DEVICE_CELLULAR;
- else if (g_str_has_prefix(obj_path, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
- return NET_DEVICE_ETHERNET;
- else if (g_str_has_prefix(obj_path, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
- return NET_DEVICE_BLUETOOTH;
- else
- return NET_DEVICE_UNKNOWN;
-}
-
static int __net_telephony_get_profile_info(net_profile_name_t* ProfileName, net_telephony_profile_info_t *ProfileInfo)
{
__NETWORK_FUNC_ENTER__;
const gchar *value = NULL;
if (ProfileName == NULL || ProfileInfo == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter!");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
result = _net_invoke_dbus_method(TELEPHONY_SERVICE, ProfileName->ProfileName,
TELEPHONY_PROFILE_INTERFACE, "GetProfile", NULL, &Error);
if (result == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
return Error;
}
-static int __net_telephony_get_profile_list(net_profile_name_t** ProfileName, int* ProfileCount)
+static int __net_telephony_get_profile_list(net_profile_name_t **ProfileName,
+ int *ProfileCount)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
+ int count = 0, i = 0;
+ const char *str = NULL;
GVariant *result;
- GVariantIter *iter;
- const char *str;
- int count = 0, i;
- GSList *profiles = NULL, *list;
- net_profile_name_t* profileList = NULL;
+ GVariantIter *iter = NULL;
+ GSList *profiles = NULL, *list = NULL;
+ net_profile_name_t *profileList = NULL;
- result = _net_invoke_dbus_method(TELEPHONY_SERVICE, TELEPHONY_MASTER_PATH,
- TELEPHONY_MASTER_INTERFACE, "GetProfileList", NULL, &Error);
- if (result == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
+ GSList *ModemPathList = NULL;
+ const char *path = NULL;
+
+ Error = __net_telephony_get_modem_object_path(&ModemPathList);
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get modems path list");
+
+ g_slist_free_full(ModemPathList, g_free);
__NETWORK_FUNC_EXIT__;
return Error;
}
- g_variant_get(result, "(as)", &iter);
- while (g_variant_iter_loop(iter, "s", &str))
- profiles = g_slist_append(profiles, g_strdup(str));
+ for (list = ModemPathList; list != NULL; list = list->next) {
+ path = (const char *)list->data;
+
+ NETWORK_LOG(NETWORK_LOW, "path: %s", path);
+ result = _net_invoke_dbus_method(TELEPHONY_SERVICE, path,
+ TELEPHONY_MODEM_INTERFACE, "GetProfileList", NULL, &Error);
+ if (result == NULL) {
+ NETWORK_LOG(NETWORK_LOW, "Failed to get profiles: %s", path);
+ continue;
+ }
+
+ g_variant_get(result, "(as)", &iter);
+ while (g_variant_iter_loop(iter, "s", &str))
+ profiles = g_slist_append(profiles, g_strdup(str));
+
+ g_variant_iter_free(iter);
+ g_variant_unref(result);
+ }
+
+ g_slist_free_full(ModemPathList, g_free);
count = g_slist_length(profiles);
- if (count > 0)
- profileList =
- (net_profile_name_t*)malloc(sizeof(net_profile_name_t) * count);
- else {
+ if (count > 0) {
+ profileList = (net_profile_name_t*)malloc(sizeof(net_profile_name_t) * count);
+ Error = NET_ERR_NONE;
+ } else {
*ProfileCount = 0;
goto out;
}
if (profileList == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory");
*ProfileCount = 0;
Error = NET_ERR_UNKNOWN;
goto out;
out:
g_slist_free_full(profiles, g_free);
- g_variant_iter_free(iter);
- g_variant_unref(result);
__NETWORK_FUNC_EXIT__;
return Error;
/* Get pdp profile list from telephony service */
Error = __net_telephony_get_profile_list(&ProfileList, &ProfileCount);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list from telephony service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list from telephony service");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return Error;
}
if (ProfileList == NULL || ProfileCount <= 0) {
- NETWORK_LOG(NETWORK_ERROR, "There is no PDP profiles\n");
+ NETWORK_LOG(NETWORK_ERROR, "There is no PDP profiles");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NO_SERVICE;
ProfileList[i].ProfileName, NET_PROFILE_NAME_LEN_MAX);
NETWORK_LOG(NETWORK_HIGH,
- "PDP profile name found in cellular profile: %s\n",
+ "PDP profile name found in cellular profile: %s",
PdpProfName->ProfileName);
break;
}
}
if (i >= ProfileCount) {
- NETWORK_LOG(NETWORK_ERROR, "There is no matching PDP profiles\n");
+ NETWORK_LOG(NETWORK_ERROR, "There is no matching PDP profiles");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NO_SERVICE;
__NETWORK_FUNC_ENTER__;
if (iter == NULL || service_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
if (NET_SERVICE_INTERNET <= network_type &&
network_type <= NET_SERVICE_TETHERING) {
- NETWORK_LOG(NETWORK_ERROR, "Service type %d\n", network_type);
+ NETWORK_LOG(NETWORK_ERROR, "Service type %d", network_type);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Invalid service type %d\n", network_type);
+ NETWORK_LOG(NETWORK_ERROR, "Invalid service type %d", network_type);
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
service_info->ProfileName[count] =
(char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
if (service_info->ProfileName[count] == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory");
for (i = 0; i < count; i++)
NET_MEMFREE(service_info->ProfileName[i]);
g_variant_iter_free(value);
g_free(obj);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
int *prof_count, net_profile_info_t **ProfilePtr)
{
int count = 0;
- net_profile_info_t ProfInfo = {0, };
+ net_profile_info_t ProfInfo = { 0, };
net_err_t Error = NET_ERR_NONE;
gchar *obj;
GVariantIter *next = NULL;
__NETWORK_FUNC_ENTER__;
if (array == NULL || service_prefix == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter \n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
continue;
if (g_str_has_prefix(obj, service_prefix) == TRUE) {
- net_device_t local_device_type = __net_get_service_type(obj);
-
- if (local_device_type == NET_DEVICE_UNKNOWN)
- continue;
-
- if (local_device_type == NET_DEVICE_WIFI &&
- g_strrstr(obj + strlen(service_prefix), "hidden") != NULL)
- continue;
-
memset(&ProfInfo, 0, sizeof(net_profile_info_t));
- if ((Error = __net_pm_init_profile_info(local_device_type, &ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+
+ if ((Error = __net_pm_init_profile_info(device_type, &ProfInfo)) != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
NET_MEMFREE(*ProfilePtr);
*prof_count = 0;
g_strrstr(obj + strlen(service_prefix), "hidden") != NULL)
ProfInfo.ProfileInfo.Wlan.is_hidden = TRUE;
- ProfInfo.profile_type = local_device_type;
+ ProfInfo.profile_type = device_type;
g_strlcpy(ProfInfo.ProfileName, obj, NET_PROFILE_NAME_LEN_MAX);
- switch(local_device_type) {
+ switch(device_type) {
case NET_DEVICE_WIFI:
g_strlcpy(ProfInfo.ProfileInfo.Wlan.net_info.ProfileName,
obj, NET_PROFILE_NAME_LEN_MAX);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to extract service info\n");
+ "Failed to extract service info");
NET_MEMFREE(*ProfilePtr);
*prof_count = 0;
*ProfilePtr = (net_profile_info_t *)realloc(*ProfilePtr,
(count + 1) * sizeof(net_profile_info_t));
if (*ProfilePtr == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory");
*prof_count = 0;
Error = NET_ERR_UNKNOWN;
error:
if (next)
g_variant_iter_free(next);
-
if (obj)
g_free(obj);
*profile_count = 0;
switch (device_type) {
- case NET_DEVICE_WIFI :
+ case NET_DEVICE_WIFI:
service_prefix = CONNMAN_WIFI_SERVICE_PROFILE_PREFIX;
break;
- case NET_DEVICE_CELLULAR :
+ case NET_DEVICE_CELLULAR:
service_prefix = CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX;
break;
- case NET_DEVICE_ETHERNET :
+ case NET_DEVICE_ETHERNET:
service_prefix = CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX;
break;
- case NET_DEVICE_BLUETOOTH :
+ case NET_DEVICE_BLUETOOTH:
service_prefix = CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX;
break;
- case NET_DEVICE_MAX :
- service_prefix = CONNMAN_SERVICE_PROFILE_PREFIX;
- break;
- default :
+ default:
*profile_count = 0;
*profile_info = NULL;
__NETWORK_FUNC_EXIT__;
Error = __net_extract_all_services(message, device_type, service_prefix,
&prof_cnt, &ProfilePtr);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to extract services from received message\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to extract services from received message");
*profile_count = 0;
*profile_info = NULL;
__NETWORK_FUNC_EXIT__;
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Total Num. of Profiles [%d]\n", prof_cnt);
-
*profile_count = prof_cnt;
*profile_info = ProfilePtr;
__NETWORK_FUNC_EXIT__;
-
return Error;
}
ipValue = (unsigned char *)&(ipAddr->Data.Ipv4.s_addr);
- if(value != NULL) {
+ if (value != NULL) {
g_strlcpy(ipString, value, NETPM_IPV4_STR_LEN_MAX+1);
ipToken[0] = strtok_r(ipString, ".", &saveptr);
- if(ipToken[0] != NULL) {
+ if (ipToken[0] != NULL) {
ipToken[1] = strtok_r(NULL, ".", &saveptr);
- if(ipToken[1] != NULL) {
+ if (ipToken[1] != NULL) {
ipToken[2] = strtok_r(NULL, ".", &saveptr);
- if(ipToken[2] != NULL) {
+ if (ipToken[2] != NULL) {
ipToken[3] = strtok_r(NULL, ".", &saveptr);
- if(ipToken[3] != NULL) {
+ if (ipToken[3] != NULL) {
ipValue[0] = (unsigned char)atoi(ipToken[0]);
ipValue[1] = (unsigned char)atoi(ipToken[1]);
ipValue[2] = (unsigned char)atoi(ipToken[2]);
static int __net_extract_common_info(const char *key, GVariant *variant, net_profile_info_t* ProfInfo)
{
- __NETWORK_FUNC_ENTER__;
-
net_err_t Error = NET_ERR_NONE;
const gchar *subKey = NULL;
const gchar *value = NULL;
net_info = &(ProfInfo->ProfileInfo.Bluetooth.net_info);
} else {
NETWORK_LOG(NETWORK_ERROR,
- "Invalid Profile type. [%d]\n", ProfInfo->profile_type);
+ "Invalid Profile type. [%d]", ProfInfo->profile_type);
return NET_ERR_INVALID_PARAM;
}
ProfInfo->ProfileState = NET_STATE_TYPE_ONLINE;
else
ProfInfo->ProfileState = NET_STATE_TYPE_UNKNOWN;
+ } else if (g_strcmp0(key, "Error") == 0) {
+ value = g_variant_get_string(variant, NULL);
+
+ if (g_strcmp0(value, "invalid-key") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_INVALID_KEY;
+ else if (g_strcmp0(value, "connect-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_CONNECT_FAILED;
+ else if (g_strcmp0(value, "auth-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_AUTH_FAILED;
+ else if (g_strcmp0(value, "login-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_LOGIN_FAILED;
+ else if (g_strcmp0(value, "dhcp-failed") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_DHCP_FAILED;
+ else if (g_strcmp0(value, "out-of-range") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_OUT_OF_RANGE;
+ else if (g_strcmp0(value, "pin-missing") == 0)
+ ProfInfo->ProfileErrorState = NET_STATE_ERROR_PIN_MISSING;
} else if (g_strcmp0(key, "Favorite") == 0) {
gboolean val = g_variant_get_boolean(variant);
- if(val)
- ProfInfo->Favourite = TRUE;
+ if (val)
+ ProfInfo->Favourite = (char)TRUE;
else
- ProfInfo->Favourite = FALSE;
+ ProfInfo->Favourite = (char)FALSE;
} else if (g_strcmp0(key, "Ethernet") == 0) {
g_variant_get(variant, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
if (g_strcmp0(subKey, "Method") == 0) {
value = g_variant_get_string(var, NULL);
- if(g_strcmp0(value, "dhcp") == 0)
+ if (g_strcmp0(value, "dhcp") == 0)
net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
- else if(g_strcmp0(value, "manual") == 0)
+ else if (g_strcmp0(value, "manual") == 0)
net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
else if (g_strcmp0(value, "fixed") == 0)
net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
- else if(g_strcmp0(value, "off") == 0)
+ else if (g_strcmp0(value, "off") == 0)
net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
} else if (g_strcmp0(subKey, "Address") == 0 &&
while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
if (g_strcmp0(subKey, "Method") == 0) {
value = g_variant_get_string(var, NULL);
-
+
if (g_strcmp0(value, "manual") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
else if (g_strcmp0(value, "off") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
else if (g_strcmp0(value, "auto") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
-
+
} else if (g_strcmp0(subKey, "Address") == 0) {
value = g_variant_get_string(var, NULL);
-
+
inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
} else if (g_strcmp0(subKey, "PrefixLength") == 0) {
net_info->PrefixLen6 = g_variant_get_byte(var);
} else if (g_strcmp0(subKey, "Gateway") == 0) {
value = g_variant_get_string(var, NULL);
-
+
inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
net_info->BDefGateway6 = TRUE;
} else if (g_strcmp0(subKey, "Privacy") == 0) {
value = g_variant_get_string(var, NULL);
-
+
if (value != NULL)
g_strlcpy(net_info->Privacy6, value, NETPM_IPV6_MAX_PRIVACY_LEN);
}
while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
if (g_strcmp0(subKey, "Method") == 0) {
value = g_variant_get_string(var, NULL);
-
+
if (g_strcmp0(value, "manual") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_STATIC;
else if (g_strcmp0(value, "off") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_OFF;
else if (g_strcmp0(value, "auto") == 0)
net_info->IpConfigType6 = NET_IP_CONFIG_TYPE_AUTO_IP;
-
+
} else if (g_strcmp0(subKey, "Address") == 0) {
value = g_variant_get_string(var, NULL);
-
+
inet_pton(AF_INET6, value, &net_info->IpAddr6.Data.Ipv6);
} else if (g_strcmp0(subKey, "PrefixLength") == 0) {
net_info->PrefixLen6 = g_variant_get_byte(var);
} else if (g_strcmp0(subKey, "Gateway") == 0) {
value = g_variant_get_string(var, NULL);
-
+
inet_pton(AF_INET6, value, &net_info->GatewayAddr6.Data.Ipv6);
net_info->BDefGateway6 = TRUE;
} else if (g_strcmp0(subKey, "Privacy") == 0) {
value = g_variant_get_string(var, NULL);
-
+
if (value != NULL)
g_strlcpy(net_info->Privacy6, value, NETPM_IPV6_MAX_PRIVACY_LEN);
}
dnsCount++;
if (dnsCount >= NET_DNS_ADDR_MAX) {
- g_free((gchar*)value);
+ if (NULL != value)
+ g_free((gchar*)value);
break;
}
}
dnsCount++;
if (dnsCount >= NET_DNS_ADDR_MAX) {
- g_free((gchar*)value);
+ if (NULL != value)
+ g_free((gchar*)value);
break;
}
}
GVariantIter *iter_sub = NULL;
g_variant_get(var, "as", &iter_sub);
-
- if (g_variant_iter_loop(iter_sub, "s", &servers) == FALSE)
- servers = NULL;
-
+ g_variant_iter_loop(iter_sub, "s", &servers);
g_variant_iter_free(iter_sub);
}
}
if (servers)
g_free(servers);
} else if (g_strcmp0(key, "Proxy.Configuration") == 0 &&
- net_info->ProxyMethod != NET_PROXY_TYPE_AUTO &&
- net_info->ProxyMethod != NET_PROXY_TYPE_MANUAL) {
+ net_info->ProxyMethod != NET_PROXY_TYPE_AUTO &&
+ net_info->ProxyMethod != NET_PROXY_TYPE_MANUAL) {
const gchar *url = NULL;
gchar *servers = NULL;
GVariantIter *iter_sub = NULL;
g_variant_get(var, "as", &iter_sub);
-
- if (g_variant_iter_loop(iter_sub, "s", &servers) == FALSE)
- servers = NULL;
-
+ g_variant_iter_loop(iter_sub, "s", &servers);
g_variant_iter_free(iter_sub);
}
}
if (servers)
g_free(servers);
- } else if(g_strcmp0(key, "Provider") == 0) {
+ } else if (g_strcmp0(key, "Provider") == 0) {
+ /* Do noting */
}
- __NETWORK_FUNC_EXIT__;
return Error;
}
return WLAN_SEC_EAP_AUTH_NONE;
}
+static int __net_update_connected_wifi_info(net_profile_info_t* ProfInfo)
+{
+ static char ifname[NET_MAX_DEVICE_NAME_LEN+1] = { '\0', };
+ static char interface_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
+ char current_bss_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *params = NULL;
+ GVariant *reply = NULL;
+ GVariant *value = NULL;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ const char *path = NULL;
+
+ /* Get proper interface */
+ if (g_strcmp0(ProfInfo->ProfileInfo.Wlan.net_info.DevName, ifname) != 0) {
+ g_strlcpy(ifname, ProfInfo->ProfileInfo.Wlan.net_info.DevName,
+ NET_MAX_DEVICE_NAME_LEN+1);
+
+ params = g_variant_new("(s)", ifname);
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE, "GetInterface", params, &Error);
+ if (reply == NULL) {
+ ifname[0] = '\0';
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get Wi-Fi interface");
+ return Error;
+ }
+ g_variant_get(reply, "(o)", &path);
+ g_strlcpy(interface_path, path, DBUS_OBJECT_PATH_MAX);
+
+ g_variant_unref(reply);
+ }
+
+ /* Get CurrentBSS object path */
+ params = g_variant_new("(ss)", SUPPLICANT_IFACE_INTERFACE, "CurrentBSS");
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, interface_path,
+ DBUS_PROPERTIES_INTERFACE, "Get", params, &Error);
+ if (reply == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get CurrentBSS");
+ return Error;
+ }
+ g_variant_get(reply, "(v)", &value);
+ path = g_variant_get_string(value, NULL);
+ g_strlcpy(current_bss_path, path, DBUS_OBJECT_PATH_MAX);
+
+ g_variant_unref(value);
+ g_variant_unref(reply);
+
+ /* Get Wi-Fi information */
+ params = g_variant_new("(s)", SUPPLICANT_IFACE_BSS);
+ reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, current_bss_path,
+ DBUS_PROPERTIES_INTERFACE, "GetAll", params, &Error);
+ if (reply == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get Wi-Fi information");
+ return Error;
+ }
+ g_variant_get(reply, "(a{sv})", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "BSSID") == 0) {
+ gsize bssid_len = 0;
+ const gchar *bssid = NULL;
+
+ bssid =
+ g_variant_get_fixed_array(value, &bssid_len, sizeof(guchar));
+ if (bssid_len == 6)
+ snprintf(ProfInfo->ProfileInfo.Wlan.bssid, 18,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ bssid[0], bssid[1], bssid[2],
+ bssid[3], bssid[4], bssid[5]);
+
+ } else if (g_strcmp0(key, "Signal") == 0) {
+ ProfInfo->ProfileInfo.Wlan.Strength =
+ (unsigned char)(120 + g_variant_get_int16(value));
+
+ if (ProfInfo->ProfileInfo.Wlan.Strength > 100)
+ ProfInfo->ProfileInfo.Wlan.Strength = 100;
+
+ } else if (g_strcmp0(key, "Frequency") == 0) {
+ ProfInfo->ProfileInfo.Wlan.frequency =
+ (unsigned int)g_variant_get_uint16(value);
+
+ } else if (g_strcmp0(key, "Rates") == 0) {
+ GVariantIter *iter_sub = NULL;
+ guint32 value_sub;
+
+ g_variant_get(value, "au", &iter_sub);
+ while (g_variant_iter_loop(iter_sub, "u", &value_sub)) {
+ ProfInfo->ProfileInfo.Wlan.max_rate = (unsigned int)value_sub;
+ break;
+ }
+
+ g_variant_iter_free(iter_sub);
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(reply);
+
+ return Error;
+}
+
static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_t* ProfInfo)
{
net_err_t Error = NET_ERR_NONE;
g_variant_get(var, "as", &iter_sub);
while (g_variant_iter_loop(iter_sub, "s", &value)) {
if (g_strcmp0(value, "none") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_NONE)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_NONE;
else if (g_strcmp0(value, "wep") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_WEP)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_WEP)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_WEP;
else if (g_strcmp0(value, "psk") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
else if (g_strcmp0(value, "ieee8021x") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
else if (g_strcmp0(value, "wpa") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
else if (g_strcmp0(value, "rsn") == 0 &&
- Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+ Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
else if (g_strcmp0(value, "wps") == 0)
Wlan->security_info.wps_support = TRUE;
else if (Wlan->security_info.sec_mode < WLAN_SEC_MODE_NONE)
Wlan->security_info.sec_mode = WLAN_SEC_MODE_NONE;
}
+ g_variant_iter_free(iter_sub);
} else if (g_strcmp0(key, "EncryptionMode") == 0) {
value = g_variant_get_string(var, NULL);
g_strlcpy(security_info->authentication.wep.wepKey,
value, NETPM_WLAN_MAX_WEP_KEY_LEN+1);
else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
- security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
- value != NULL)
+ security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
+ value != NULL)
g_strlcpy(security_info->authentication.psk.pskKey,
value, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
-
} else if (g_strcmp0(key, "PassphraseRequired") == 0) {
gboolean val;
val = g_variant_get_boolean(var);
- if(val)
+ if (val)
Wlan->PassphraseRequired = TRUE;
else
Wlan->PassphraseRequired = FALSE;
g_strlcpy(Wlan->bssid, value, NET_MAX_MAC_ADDR_LEN);
} else if (g_strcmp0(key, "MaxRate") == 0) {
- Wlan->max_rate = g_variant_get_uint32(var);
+ Wlan->max_rate = (unsigned int)g_variant_get_uint32(var);
} else if (g_strcmp0(key, "Frequency") == 0) {
- unsigned short frequency;
- frequency = g_variant_get_uint16(var);
-
- Wlan->frequency = (unsigned int)frequency;
+ Wlan->frequency = (unsigned int)g_variant_get_uint16(var);
} else if (g_str_equal(key, "EAP") == TRUE) {
value = g_variant_get_string(var, NULL);
Error = __net_extract_common_info(key, var, ProfInfo);
}
+ /* If there are multiple Wi-Fi networks which have the same SSID,
+ * and one of them is connected, we need to get the connected one
+ * rather than ConnMan grouped properties.
+ */
+ if (ProfInfo->ProfileState == NET_STATE_TYPE_READY ||
+ ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE)
+ Error = __net_update_connected_wifi_info(ProfInfo);
+
__NETWORK_FUNC_EXIT__;
return Error;
}
ProfInfo->ProfileInfo.Pdp.SetupRequired = TRUE;
else
ProfInfo->ProfileInfo.Pdp.SetupRequired = FALSE;
+#if defined TIZEN_DUALSIM_ENABLE
+ } else if (g_strcmp0(key, "Name") == 0) {
+ value = g_variant_get_string(var, NULL);
+ if (value != NULL) {
+ gchar **list = g_strsplit(value, "/context", 0);
+
+ if (*list) {
+ g_strlcpy(ProfInfo->ProfileInfo.Pdp.PSModemPath,
+ list[0], NET_PROFILE_NAME_LEN_MAX);
+ NETWORK_LOG(NETWORK_LOW, "Modem path: %s",
+ ProfInfo->ProfileInfo.Pdp.PSModemPath);
+ g_strfreev(list);
+ } else
+ NETWORK_LOG(NETWORK_ERROR, "Invalid modem path: %s", value);
+ } else
+ NETWORK_LOG(NETWORK_ERROR, "Null modem path");
+#endif
} else
Error = __net_extract_common_info(key, var, ProfInfo);
}
if (profileType == NET_DEVICE_WIFI) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_WIFI, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_wifi_info(iter, ProfInfo);
} else if (profileType == NET_DEVICE_CELLULAR) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_CELLULAR, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_mobile_info(iter, ProfInfo);
} else if (profileType == NET_DEVICE_ETHERNET) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_ETHERNET, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_ethernet_info(iter, ProfInfo);
} else if (profileType == NET_DEVICE_BLUETOOTH) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_BLUETOOTH, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_bluetooth_info(iter, ProfInfo);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Not supported profile type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Not supported profile type");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NOT_SUPPORTED;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to extract service information from received message\n");
+ "Failed to extract service information from received message");
__NETWORK_FUNC_EXIT__;
return Error;
}
-
g_variant_iter_free(iter);
__NETWORK_FUNC_EXIT__;
message = _net_invoke_dbus_method(CONNMAN_SERVICE, ProfileName,
CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get profile");
goto done;
}
Error = __net_telephony_search_pdp_profile((char*)connman_profile, &telephony_profile);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "__net_telephony_search_pdp_profile() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "__net_telephony_search_pdp_profile() failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
message = _net_invoke_dbus_method(TELEPHONY_SERVICE, telephony_profile.ProfileName,
TELEPHONY_PROFILE_INTERFACE, "SetDefaultConnection", NULL, &Error);
-
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to set default cellular service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set default cellular service(profile)");
goto done;
}
gboolean result = FALSE;
g_variant_get(message, "(b)", &result);
- NETWORK_LOG(NETWORK_HIGH, "Set default cellular profile result : %d\n", result);
+ NETWORK_LOG(NETWORK_HIGH, "Set default cellular profile result: %d", result);
if (result)
Error = NET_ERR_NONE;
Error = __net_telephony_search_pdp_profile((char*)connman_profile, &telephony_profile);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "__net_telephony_search_pdp_profile() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "__net_telephony_search_pdp_profile() failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
int i = 0;
char profilePath[NET_PROFILE_NAME_LEN_MAX+1] = "";
- wlan_security_info_t *security_info = &(ProfInfo->ProfileInfo.Wlan.security_info);
- wlan_security_info_t *ex_security_info = &(exProfInfo->ProfileInfo.Wlan.security_info);
+ wlan_security_info_t *security_info =
+ &(ProfInfo->ProfileInfo.Wlan.security_info);
+ wlan_security_info_t *ex_security_info =
+ &(exProfInfo->ProfileInfo.Wlan.security_info);
net_dev_info_t *net_info = &(ProfInfo->ProfileInfo.Wlan.net_info);
net_dev_info_t *ex_net_info = &(exProfInfo->ProfileInfo.Wlan.net_info);
if (ex_security_info->sec_mode == WLAN_SEC_MODE_WEP) {
if (g_strcmp0(security_info->authentication.wep.wepKey,
ex_security_info->authentication.wep.wepKey) != 0) {
- Error = _net_dbus_set_agent_passphrase(security_info->authentication.wep.wepKey);
+ /* ConnMan does not support modification of passphrase only,
+ * you need to make a connection to update passphrase.
+ */
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ security_info->authentication.wep.wepKey, ProfileName);
if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field");
__NETWORK_FUNC_EXIT__;
return Error;
} else if (ex_security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
ex_security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) {
if (g_strcmp0(security_info->authentication.psk.pskKey,
- ex_security_info->authentication.psk.pskKey) != 0) {
- Error = _net_dbus_set_agent_passphrase(security_info->authentication.psk.pskKey);
+ ex_security_info->authentication.psk.pskKey) != 0) {
+ /* ConnMan does not support modification of passphrase only,
+ * you need to make a connection to update passphrase.
+ */
+ Error = _net_dbus_set_agent_passphrase_and_connect(
+ security_info->authentication.psk.pskKey, ProfileName);
if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field");
__NETWORK_FUNC_EXIT__;
return Error;
/* Compare and Set 'IPv4 addresses' */
if ((ex_net_info->IpConfigType != net_info->IpConfigType) ||
- (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC &&
- (net_info->IpAddr.Data.Ipv4.s_addr !=
+ (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC &&
+ (net_info->IpAddr.Data.Ipv4.s_addr !=
ex_net_info->IpAddr.Data.Ipv4.s_addr ||
- net_info->SubnetMask.Data.Ipv4.s_addr !=
+ net_info->SubnetMask.Data.Ipv4.s_addr !=
ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
- net_info->GatewayAddr.Data.Ipv4.s_addr !=
+ net_info->GatewayAddr.Data.Ipv4.s_addr !=
ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
Error = _net_dbus_set_profile_ipv4(ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to set IPv4\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set IPv4");
__NETWORK_FUNC_EXIT__;
return Error;
}
if (net_info->DnsAddr[i].Data.Ipv4.s_addr !=
- ex_net_info->DnsAddr[i].Data.Ipv4.s_addr)
+ ex_net_info->DnsAddr[i].Data.Ipv4.s_addr)
break;
}
net_err_t Error = NET_ERR_NONE;
GVariant *message = NULL;
char param0[NET_PROFILE_NAME_LEN_MAX + 8] = "";
- GVariant *params = NULL;
+ GVariant *params;
if (passpoint == TRUE && WLAN_SEC_MODE_IEEE8021X == sec_mode) {
message = _net_invoke_dbus_method(CONNMAN_SERVICE,
WifiProfName->ProfileName,
CONNMAN_SERVICE_INTERFACE, "Remove", NULL,
&Error);
+
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)");
+ g_variant_unref(message);
+ goto done;
+ }
+
g_variant_unref(message);
g_snprintf(param0, NET_PROFILE_NAME_LEN_MAX + 8, "string:%s",
}
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)");
goto done;
}
Error = _net_dbus_add_pdp_profile(ProfInfo);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "_net_dbus_add_pdp_profile() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_dbus_add_pdp_profile() failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
char connman_profile[NET_PROFILE_NAME_LEN_MAX+1] = "";
if (_net_is_valid_service_type(exProfInfo->ProfileInfo.Pdp.ServiceType) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_telephony_search_pdp_profile((char*)connman_profile, &telephony_profile);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "__net_telephony_search_pdp_profile() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "__net_telephony_search_pdp_profile() failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = _net_dbus_modify_pdp_profile(ProfInfo, (char*)telephony_profile.ProfileName);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "_net_dbus_modify_pdp_profile() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_dbus_modify_pdp_profile() failed");
__NETWORK_FUNC_EXIT__;
return Error;
}
if ((ex_net_info->IpConfigType != net_info->IpConfigType) ||
(net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC &&
(net_info->IpAddr.Data.Ipv4.s_addr
- != ex_net_info->IpAddr.Data.Ipv4.s_addr ||
+ != ex_net_info->IpAddr.Data.Ipv4.s_addr ||
net_info->SubnetMask.Data.Ipv4.s_addr
- != ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
+ != ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
net_info->GatewayAddr.Data.Ipv4.s_addr
- != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
+ != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
Error = _net_dbus_set_profile_ipv4(ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
return Error;
}
}
-
- /* Compare and Set 'IPv6 addresses' */
- if ((ex_net_info->IpConfigType6 != net_info->IpConfigType6) ||
- (net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_STATIC &&
- (net_info->IpAddr6.Data.Ipv6.s6_addr != ex_net_info->IpAddr6.Data.Ipv6.s6_addr ||
- net_info->PrefixLen6 != ex_net_info->PrefixLen6 ||
- net_info->GatewayAddr6.Data.Ipv6.s6_addr != ex_net_info->GatewayAddr6.Data.Ipv6.s6_addr))) {
-
- Error = _net_dbus_set_profile_ipv6(ProfInfo, profilePath);
-
- if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't set IPv6\n");
-
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
- }
/* Compare and Set 'DNS addresses' */
for (i = 0; i < net_info->DnsCount; i++) {
if (i >= NET_DNS_ADDR_MAX) {
return NET_ERR_NONE;
}
-
static int __net_telephony_delete_profile(net_profile_name_t* PdpProfName)
{
__NETWORK_FUNC_ENTER__;
message = _net_invoke_dbus_method(TELEPHONY_SERVICE, PdpProfName->ProfileName,
TELEPHONY_PROFILE_INTERFACE, "RemoveProfile", NULL, &Error);
-
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)");
goto done;
}
gboolean remove_result = FALSE;
g_variant_get(message, "(b)", &remove_result);
- NETWORK_LOG(NETWORK_HIGH, "Profile remove result : %d\n", remove_result);
+ NETWORK_LOG(NETWORK_HIGH, "Profile remove result: %d", remove_result);
if (remove_result)
Error = NET_ERR_NONE;
__NETWORK_FUNC_ENTER__;
if (array == NULL || ProfilePtr == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
else if (g_str_has_prefix(key, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
device_type = NET_DEVICE_BLUETOOTH;
else {
- g_variant_iter_free(value);
- g_free(key);
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_NO_SERVICE;
+ Error = NET_ERR_NO_SERVICE;
+ goto error;
}
Error = __net_pm_init_profile_info(device_type, ProfilePtr);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
- g_variant_iter_free(value);
- g_free(key);
- __NETWORK_FUNC_EXIT__;
- return Error;
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile");
+ goto error;
}
ProfilePtr->profile_type = device_type;
key, NET_PROFILE_NAME_LEN_MAX);
Error = __net_extract_mobile_info(value, ProfilePtr);
-
break;
} else if (device_type == NET_DEVICE_WIFI) {
g_strlcpy(ProfilePtr->ProfileInfo.Wlan.net_info.ProfileName,
key, NET_PROFILE_NAME_LEN_MAX);
Error = __net_extract_wifi_info(value, ProfilePtr);
-
break;
} else if (device_type == NET_DEVICE_ETHERNET) {
g_strlcpy(ProfilePtr->ProfileInfo.Ethernet.net_info.ProfileName,
key, NET_PROFILE_NAME_LEN_MAX);
Error = __net_extract_ethernet_info(value, ProfilePtr);
-
break;
} else if (device_type == NET_DEVICE_BLUETOOTH) {
g_strlcpy(ProfilePtr->ProfileInfo.Bluetooth.net_info.ProfileName,
key, NET_PROFILE_NAME_LEN_MAX);
Error = __net_extract_bluetooth_info(value, ProfilePtr);
-
break;
}
}
ProfilePtr->ProfileState == NET_STATE_TYPE_ONLINE))
goto found;
- NETWORK_LOG(NETWORK_ERROR, "Fail to find default service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Fail to find default service");
Error = NET_ERR_NO_SERVICE;
+error:
if (value)
g_variant_iter_free(value);
if (key)
return Error;
found:
- NETWORK_LOG(NETWORK_HIGH, "Default: %s\n", ProfilePtr->ProfileName);
+ NETWORK_LOG(NETWORK_HIGH, "Default: %s", ProfilePtr->ProfileName);
if (value)
g_variant_iter_free(value);
int stringLen = 0;
if (ProfileName == NULL || strlen(ProfileName) <= strlen(profileHeader)) {
- NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (strncmp(profileHeader, ProfileName, strlen(profileHeader)) == 0) {
for (i = 0;i < stringLen;i++) {
if (isgraph(ProfileName[i]) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- GVariant *message = NULL;
- GVariantIter *iter = NULL;
+ GVariant *message;
+ GVariantIter *iter;
message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get service(profile) list\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service(profile) list");
__NETWORK_FUNC_EXIT__;
return Error;
}
case NET_DEVICE_WIFI:
case NET_DEVICE_ETHERNET:
case NET_DEVICE_BLUETOOTH:
- case NET_DEVICE_MAX:
g_variant_get(message, "(a(oa{sv}))", &iter);
Error = __net_extract_services(iter, device_type, profile_info, profile_count);
g_variant_iter_free(iter);
break;
- default :
+ default:
Error = NET_ERR_UNKNOWN;
break;
}
- NETWORK_LOG(NETWORK_HIGH, "Error = %d\n", Error);
g_variant_unref(message);
__NETWORK_FUNC_EXIT__;
net_err_t Error = NET_ERR_NONE;
GVariant *message = NULL;
GVariantIter *iter = NULL;
- network_services_list_t service_info = {0,};
+ network_services_list_t service_info = { 0, };
int i = 0;
message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list");
__NETWORK_FUNC_EXIT__;
return Error;
message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NO_SERVICE;
+ return Error;
}
g_variant_get(message, "(a(oa{sv}))", &iter);
net_err_t Error = NET_ERR_NONE;
-#if defined TIZEN_WEARABLE
- Error = _net_dbus_reset_pdp_profile(type, NULL);
- if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_HIGH, "_net_dbus_reset_pdp_profile() failed");
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
-#else
char subscriber_id[3];
GSList *ModemPathList = NULL;
const char *path = NULL;
}
g_slist_free_full(ModemPathList, g_free);
-#endif
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
+
EXPORT_API int net_reset_profile(int type, int sim_id)
{
net_err_t Error = NET_ERR_NONE;
return Error;
}
+
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Sync API Definition
*****************************************************************************/
__NETWORK_FUNC_ENTER__;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (prof_info == NULL || _net_is_valid_service_type(network_type) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_telephony_add_profile(prof_info, network_type);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to add service(profile). Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to add service(profile). Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
net_profile_info_t prof_info;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
+ NETWORK_LOG(NETWORK_ERROR, "Delete Profile [%s]", profile_name);
+
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_get_profile_info(profile_name, &prof_info);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
prof_info.ProfileInfo.Wlan.passpoint);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to delete service(profile). Error [%s]\n",
+ "Failed to delete service(profile). Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
Error = __net_telephony_search_pdp_profile(wifi_prof_name.ProfileName, &pdp_prof_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
Error = __net_telephony_delete_profile(&pdp_prof_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to delete service(profile). Error [%s]\n",
+ "Failed to delete service(profile). Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (prof_info == NULL ||
_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
Error = __net_get_profile_info(profile_name, prof_info);
if (Error != NET_ERR_NONE)
NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
net_profile_info_t exProfInfo;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
Error = net_get_profile_info(profile_name, &exProfInfo);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
+
if (prof_info == NULL ||
(exProfInfo.profile_type != NET_DEVICE_WIFI &&
exProfInfo.profile_type != NET_DEVICE_CELLULAR &&
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to modify service(profile) information. Error [%s]\n",
+ "Failed to modify service(profile) information. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
net_profile_info_t* profile_info = NULL;
if (count == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (device_type != NET_DEVICE_CELLULAR &&
device_type != NET_DEVICE_WIFI &&
device_type != NET_DEVICE_ETHERNET &&
- device_type != NET_DEVICE_BLUETOOTH &&
- device_type != NET_DEVICE_MAX) {
- NETWORK_LOG(NETWORK_ERROR, "Not Supported\n");
+ device_type != NET_DEVICE_BLUETOOTH) {
+ NETWORK_LOG(NETWORK_ERROR, "Not Supported");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NOT_SUPPORTED;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) list. Error [%s]\n",
+ "Failed to get service(profile) list. Error [%s]",
_net_print_error(Error));
NET_MEMFREE(profile_info);
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_set_default_cellular_service_profile_sync(profile_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to set default cellular service(profile). Error [%s]\n",
+ "Failed to set default cellular service(profile). Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Error!!! Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
Error = __net_set_default_cellular_service_profile_async(profile_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to set default cellular service(profile). Error [%s]\n",
+ "Error!!! failed to set default cellular service(profile). Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT],
0, sizeof(network_request_table_t));
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
extern __thread network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
static __thread net_state_type_t service_state_table[NET_DEVICE_MAX] =
- { NET_STATE_TYPE_UNKNOWN, };
+ { NET_STATE_TYPE_UNKNOWN, };
static __thread int net_service_error = NET_ERR_NONE;
-static __thread guint gdbus_conn_subscribe_id_connman_svc = 0;
static __thread guint gdbus_conn_subscribe_id_connman_state = 0;
static __thread guint gdbus_conn_subscribe_id_connman_error = 0;
static __thread guint gdbus_conn_subscribe_id_supplicant = 0;
{
__NETWORK_FUNC_ENTER__;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
if (value == TRUE) {
NetworkInfo.wifi_state = WIFI_ON;
0, sizeof(network_request_table_t));
event_data.Event = NET_EVENT_WIFI_POWER_RSP;
- NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_RSP wifi state: %d\n",
+ NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_RSP wifi state: %d",
NetworkInfo.wifi_state);
_net_dbus_pending_call_unref();
} else {
event_data.Event = NET_EVENT_WIFI_POWER_IND;
- NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_IND wifi state: %d\n",
+ NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_IND wifi state: %d",
NetworkInfo.wifi_state);
}
event_data.Datalength = sizeof(net_wifi_state_t);
event_data.Data = &(NetworkInfo.wifi_state);
+
_net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
{
__NETWORK_FUNC_ENTER__;
- net_event_info_t event_data = {0,};
+ int count = 0;;
+ net_event_info_t event_data = { 0, };
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
_net_dbus_pending_call_unref();
+ count = (int)g_slist_length(bss_info_list);
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_SPECIFIC_SCAN_IND"
- "wifi state: %d\n", NetworkInfo.wifi_state);
- NETWORK_LOG(NETWORK_LOW, "bss_info_list: 0x%x\n",
- bss_info_list);
+ "Received the signal: %s with total bss count = %d",
+ NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE,
+ count);
event_data.Event = NET_EVENT_SPECIFIC_SCAN_IND;
+ event_data.Datalength = count;
event_data.Data = bss_info_list;
_net_client_callback(&event_data);
- }
+ } else
+ g_slist_free_full(bss_info_list, g_free);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
{
GVariantIter *iter = NULL;
GVariant *value = NULL;
- const char *key = NULL;
+ gchar *key = NULL;
const gchar *ssid = NULL;
gint32 security = 0;
+ gboolean wps = FALSE;
GSList *bss_info_list = NULL;
gboolean ssid_found = FALSE;
gboolean sec_found = FALSE;
+ gboolean wps_found = FALSE;
g_variant_get(param, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
if (g_strcmp0(key, "ssid") == 0 && ssid_found == FALSE) {
ssid = g_variant_get_string(value, NULL);
- NETWORK_LOG(NETWORK_LOW, "Got an ssid: %s", ssid);
+ NETWORK_LOG(NETWORK_LOW, "SSID: %s", ssid);
ssid_found = TRUE;
}
if (g_strcmp0(key, "security") == 0 && sec_found == FALSE) {
- security = g_variant_get_int16(value);
+ security = g_variant_get_int32(value);
NETWORK_LOG(NETWORK_LOW, "with security: %d", security);
sec_found = TRUE;
}
+ if (g_strcmp0(key, "wps") == 0 && wps_found == FALSE) {
+ wps = g_variant_get_boolean(value);
+ NETWORK_LOG(NETWORK_LOW, "wps supported: %d", wps);
+ wps_found = TRUE;
+ }
+
+ if (ssid_found == TRUE && sec_found == TRUE && wps_found == TRUE) {
+ struct ssid_scan_bss_info_t *bss = NULL;
+ bss = g_try_new0(struct ssid_scan_bss_info_t, 1);
+ if (bss == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Memory allocation error");
+
+ g_slist_free_full(bss_info_list, g_free);
+ g_variant_unref(value);
+ g_free(key);
+ return NET_ERR_UNKNOWN;
+ }
- if (ssid_found == TRUE && sec_found == TRUE) {
- net_wifi_connection_info_t *resp_data = g_try_new0(
- net_wifi_connection_info_t, 1);
- g_strlcpy(resp_data->essid, ssid, NET_WLAN_ESSID_LEN);
- resp_data->security_info.sec_mode = __net_get_wlan_sec_mode(security);
- bss_info_list = g_slist_append(bss_info_list, resp_data);
+ g_strlcpy(bss->ssid, ssid, NET_WLAN_ESSID_LEN);
+ bss->security = __net_get_wlan_sec_mode(security);
+ bss->wps = (char)wps;
+ bss_info_list = g_slist_append(bss_info_list, bss);
- ssid_found = FALSE;
- sec_found = FALSE;
+ ssid_found = sec_found = wps_found = FALSE;
}
}
g_variant_iter_free(iter);
- NETWORK_LOG(NETWORK_LOW,
- "Received the signal: %s with total bss count = %d",
- NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE,
- g_slist_length(bss_info_list));
-
__net_handle_specific_scan_resp(bss_info_list);
- /* Specific Scan response handled. Release/Destroy the list */
- g_slist_free_full(bss_info_list, g_free);
+ /* To enhance performance,
+ * BSS list should be release in a delayed manner in _net_client_callback */
+
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wps_scan_resp(GSList *bss_info_list)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ int count = 0;;
+ net_event_info_t event_data = { 0, };
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_t));
+
+ _net_dbus_pending_call_unref();
+
+ count = (int)g_slist_length(bss_info_list);
+ NETWORK_LOG(NETWORK_LOW,
+ "Received the signal: %s with total bss count = %d",
+ NETCONFIG_SIGNAL_WPS_SCAN_DONE,
+ count);
+
+ event_data.Event = NET_EVENT_WPS_SCAN_IND;
+ event_data.Datalength = count;
+ event_data.Data = bss_info_list;
+
+ _net_client_callback(&event_data);
+ } else
+ g_slist_free_full(bss_info_list, g_free);
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_wps_scan_rsp(GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ gchar *key = NULL;
+ GSList *bss_info_list = NULL;
+ const gchar *ssid = NULL;
+ const gchar *bssid = NULL;
+ gsize ssid_len;
+ int rssi = -89;
+ int mode = 0;
+ gboolean ssid_found = FALSE;
+ gboolean bssid_found = FALSE;
+ gboolean rssi_found = FALSE;
+ gboolean mode_found = FALSE;
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "ssid") == 0) {
+ ssid = g_variant_get_fixed_array(value, &ssid_len, sizeof(guchar));
+ ssid_found = TRUE;
+ } else if (g_strcmp0(key, "bssid") == 0) {
+ bssid = g_variant_get_string(value, NULL);
+ bssid_found = TRUE;
+ } else if (g_strcmp0(key, "rssi") == 0) {
+ rssi = g_variant_get_int32(value);
+ rssi_found = TRUE;
+ } else if (g_strcmp0(key, "mode") == 0) {
+ mode = g_variant_get_int32(value);
+ mode_found = TRUE;
+ }
+
+ if (ssid_found == TRUE && bssid_found == TRUE &&
+ rssi_found == TRUE && mode_found == TRUE) {
+ struct wps_scan_bss_info_t *bss = NULL;
+ bss = g_try_new0(struct wps_scan_bss_info_t, 1);
+ if (bss == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Memory allocation error");
+
+ g_slist_free_full(bss_info_list, g_free);
+ g_variant_unref(value);
+ g_free(key);
+ return NET_ERR_UNKNOWN;
+ }
+
+ memcpy(bss->ssid, ssid, ssid_len);
+ g_strlcpy(bss->bssid, bssid, NET_WLAN_BSSID_LEN+1);
+ bss->rssi = rssi;
+ bss->mode = mode;
+ bss_info_list = g_slist_append(bss_info_list, bss);
+
+ ssid_found = bssid_found = FALSE;
+ rssi_found = mode_found = FALSE;
+ }
+ }
+ g_variant_iter_free(iter);
+
+ __net_handle_wps_scan_resp(bss_info_list);
return NET_ERR_NONE;
}
-static void __net_handle_state_ind(const char* profile_name,
+static void __net_handle_state_ind(const char *profile_name,
net_state_type_t profile_state)
{
__NETWORK_FUNC_ENTER__;
- net_event_info_t event_data = {0,};
+ net_event_info_t event_data = { 0, };
event_data.Error = NET_ERR_NONE;
event_data.Event = NET_EVENT_NET_STATE_IND;
- g_strlcpy(event_data.ProfileName, profile_name,
- sizeof(event_data.ProfileName));
+ g_strlcpy(event_data.ProfileName, profile_name, sizeof(event_data.ProfileName));
event_data.Datalength = sizeof(net_state_type_t);
event_data.Data = &profile_state;
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_NET_STATE_IND, state: %d, profile name: %s\n",
+ "Sending NET_EVENT_NET_STATE_IND, state: %d, profile name: %s",
profile_state, event_data.ProfileName);
_net_client_callback(&event_data);
event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
+ sizeof(network_request_table_t));
+
_net_dbus_pending_call_unref();
} else if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
g_strcmp0(profile_name, svc_name3) == 0) {
net_service_error = NET_ERR_NONE;
- NETWORK_LOG(NETWORK_ERROR, "State failure %d\n", event_data.Error);
+ NETWORK_LOG(NETWORK_ERROR, "State failure %d", event_data.Error);
_net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
if (device_type == NET_DEVICE_UNKNOWN)
return Error;
- NETWORK_LOG(NETWORK_LOW, "[%s] %s\n", state, sig_path);
+ NETWORK_LOG(NETWORK_LOW, "[%s] %s", state, sig_path);
if (device_type == NET_DEVICE_WIFI && NetworkInfo.wifi_state == WIFI_OFF) {
- NETWORK_LOG(NETWORK_LOW, "Wi-Fi is off\n");
+ NETWORK_LOG(NETWORK_LOW, "Wi-Fi is off");
return Error;
}
event_data.Event = NET_EVENT_OPEN_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP");
_net_dbus_pending_call_unref();
} else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP");
_net_dbus_pending_call_unref();
} else {
event_data.Event = NET_EVENT_OPEN_IND;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_IND\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_IND");
}
net_profile_info_t prof_info;
if ((Error = net_get_profile_info(sig_path, &prof_info)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "net_get_profile_info() failed [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "net_get_profile_info() failed [%s]",
_net_print_error(Error));
event_data.Datalength = 0;
const char *svc_name3 =
request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != TRUE &&
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag != TRUE &&
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag != TRUE)
+ {
+ /** Send Close Ind */
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_CLOSE_IND;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
+
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_IND");
+
+ _net_client_callback(&event_data);
+ }
+
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
strstr(sig_path, svc_name2) != NULL) {
memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
event_data.Datalength = 0;
event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP");
_net_dbus_pending_call_unref();
_net_client_callback(&event_data);
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
g_strcmp0(sig_path, svc_name3) == 0) {
memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
sizeof(network_request_table_t));
event_data.Datalength = 0;
event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP");
_net_dbus_pending_call_unref();
_net_client_callback(&event_data);
- } else if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
g_strcmp0(sig_path, svc_name1) == 0) {
memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
sizeof(network_request_table_t));
event_data.Datalength = 0;
event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP");
_net_dbus_pending_call_unref();
- _net_client_callback(&event_data);
- } else {
- /** Send Close Ind */
- event_data.Error = Error;
- event_data.Event = NET_EVENT_CLOSE_IND;
- g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
-
- event_data.Datalength = 0;
- event_data.Data = NULL;
-
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_IND\n");
-
_net_client_callback(&event_data);
}
-
break;
}
case NET_STATE_TYPE_FAILURE:
if (error == NULL || *error == '\0')
return NET_ERR_NONE;
- NETWORK_LOG(NETWORK_LOW, "[%s] %s\n", key, error);
+ NETWORK_LOG(NETWORK_ERROR, "[%s] %s", key, error);
net_service_error = string2error(error);
static int __net_handle_scan_done(GVariant *param)
{
- __NETWORK_FUNC_ENTER__;
-
net_event_info_t event_data = { 0, };
- if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_LOW, "Flag for specific scan is TRUE, so ignore this signal\n");
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
return NET_ERR_NONE;
- } else if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ else if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0,
sizeof(network_request_table_t));
event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
_net_dbus_pending_call_unref();
-
- NETWORK_LOG(NETWORK_LOW, "response ScanDone\n");
} else {
event_data.Event = NET_EVENT_WIFI_SCAN_IND;
-
- NETWORK_LOG(NETWORK_LOW, "indicate ScanDone\n");
}
event_data.Error = NET_ERR_NONE;
_net_client_callback(&event_data);
- __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
__net_handle_service_set_error(key, value);
}
+
+ g_free((gchar *)value);
+ g_free((gchar *)key);
+ if (NULL != var)
+ g_variant_unref(var);
}
}
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
- if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0) {
- NETWORK_LOG(NETWORK_HIGH, "ScanDone signal from wpasupplicant\n");
+ if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0)
__net_handle_scan_done(param);
- }
}
static void __net_netconfig_signal_filter(GDBusConnection *conn,
__net_handle_wifi_power_rsp(FALSE);
else if (g_strcmp0(sig, NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE) == 0)
__net_handle_wifi_specific_scan_rsp(param);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WPS_SCAN_DONE) == 0)
+ __net_handle_wifi_wps_scan_rsp(param);
}
static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
connection = _net_dbus_get_gdbus_conn();
if (connection == NULL) {
- NETWORK_LOG(NETWORK_HIGH, "Already de-registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Already de-registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_connman_svc);
+ gdbus_conn_subscribe_id_connman_state);
g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_supplicant);
+ gdbus_conn_subscribe_id_connman_error);
g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_netconfig_wifi);
+ gdbus_conn_subscribe_id_supplicant);
g_dbus_connection_signal_unsubscribe(connection,
- gdbus_conn_subscribe_id_netconfig);
+ gdbus_conn_subscribe_id_netconfig_wifi);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_netconfig);
Error = _net_dbus_close_gdbus_call();
if (Error != NET_ERR_NONE) {
return Error;
}
- NETWORK_LOG(NETWORK_LOW, "Successfully remove signals\n");
-
__NETWORK_FUNC_EXIT__;
return Error;
}
return NET_ERR_UNKNOWN;
}
+ /* Create supplicant service connection */
+ gdbus_conn_subscribe_id_supplicant = g_dbus_connection_signal_subscribe(
+ connection,
+ SUPPLICANT_SERVICE,
+ SUPPLICANT_IFACE_INTERFACE,
+ "ScanDone",
+ NULL,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_supplicant_signal_filter,
+ NULL,
+ NULL);
+
/* Create net-config service connection */
gdbus_conn_subscribe_id_netconfig_wifi = g_dbus_connection_signal_subscribe(
- connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_INTERFACE,
- NULL,
- NETCONFIG_WIFI_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __net_netconfig_signal_filter,
- NULL,
- NULL);
+ connection,
+ NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_INTERFACE,
+ NULL,
+ NETCONFIG_WIFI_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_netconfig_signal_filter,
+ NULL,
+ NULL);
+
+ if (gdbus_conn_subscribe_id_supplicant == 0 ||
+ gdbus_conn_subscribe_id_netconfig_wifi == 0) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed register signals "
+ "supplicant(%d), netconfig_wifi(%d)",
+ gdbus_conn_subscribe_id_supplicant,
+ gdbus_conn_subscribe_id_netconfig_wifi);
+ Error = NET_ERR_NOT_SUPPORTED;
+ }
__NETWORK_FUNC_EXIT__;
return Error;
return NET_ERR_UNKNOWN;
}
- /* Create connman service connection */
- gdbus_conn_subscribe_id_connman_svc = g_dbus_connection_signal_subscribe(
- connection,
- CONNMAN_SERVICE,
- CONNMAN_SERVICE_INTERFACE,
- NULL,
- NULL,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __net_connman_service_signal_filter,
- NULL,
- NULL);
-
- /* Create supplicant service connection */
- gdbus_conn_subscribe_id_supplicant = g_dbus_connection_signal_subscribe(
- connection,
- SUPPLICANT_SERVICE,
- SUPPLICANT_SERVICE_INTERFACE,
- NULL,
- NULL,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __net_supplicant_signal_filter,
- NULL,
- NULL);
-
- /* Create net-config service connection */
- gdbus_conn_subscribe_id_netconfig = g_dbus_connection_signal_subscribe(
- connection,
- NETCONFIG_SERVICE,
- NETCONFIG_WIFI_INTERFACE,
- NULL,
- NETCONFIG_WIFI_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __net_netconfig_signal_filter,
- NULL,
- NULL);
+ /* Create connman service state connection */
+ gdbus_conn_subscribe_id_connman_state = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_SERVICE_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED,
+ NULL,
+ "State",
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_connman_service_signal_filter,
+ NULL,
+ NULL);
+
+ /* Create connman service error connection */
+ gdbus_conn_subscribe_id_connman_error = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_SERVICE_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED,
+ NULL,
+ "Error",
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_connman_service_signal_filter,
+ NULL,
+ NULL);
/* Create net-config service connection for network */
gdbus_conn_subscribe_id_netconfig = g_dbus_connection_signal_subscribe(
- connection,
- NETCONFIG_SERVICE,
- NETCONFIG_NETWORK_INTERFACE,
- NULL,
- NETCONFIG_NETWORK_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __net_netconfig_network_signal_filter,
- NULL,
- NULL);
+ connection,
+ NETCONFIG_SERVICE,
+ NETCONFIG_NETWORK_INTERFACE,
+ NULL,
+ NETCONFIG_NETWORK_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_netconfig_network_signal_filter,
+ NULL,
+ NULL);
+
+ if (gdbus_conn_subscribe_id_connman_state == 0 ||
+ gdbus_conn_subscribe_id_connman_error == 0 ||
+ gdbus_conn_subscribe_id_netconfig == 0) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed register signals "
+ "connman_state(%d), connman_error(%d), netconfig(%d)",
+ gdbus_conn_subscribe_id_connman_state,
+ gdbus_conn_subscribe_id_connman_error,
+ gdbus_conn_subscribe_id_netconfig);
+ Error = NET_ERR_NOT_SUPPORTED;
+ }
__NETWORK_FUNC_EXIT__;
return Error;
}
-int _net_init_service_state_table(void)
+
+static int __net_get_all_tech_states(GVariant *msg, net_state_type_t *state_table)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- net_cm_network_status_t network_status;
-
- Error = _net_dbus_get_network_status(NET_DEVICE_WIFI, &network_status);
- if (Error != NET_ERR_NONE) {
- __NETWORK_FUNC_EXIT__;
- return Error;
+ GVariantIter *iter_main = NULL;
+ GVariantIter *var = NULL;
+ GVariant *value = NULL;
+ gchar *path = NULL;
+ gchar *key = NULL;
+ gboolean data;
+
+ g_variant_get(msg, "(a(oa{sv}))", &iter_main);
+ while (g_variant_iter_loop(iter_main, "(oa{sv})", &path, &var)) {
+
+ if (path == NULL)
+ continue;
+
+ while (g_variant_iter_loop(var, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "Connected") == 0) {
+ data = g_variant_get_boolean(value);
+ if (!data)
+ continue;
+
+ if (g_str_equal(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
+ *(state_table + NET_DEVICE_WIFI) = NET_STATE_TYPE_READY;
+ NetworkInfo.wifi_state = WIFI_CONNECTED;
+ } else if (g_str_equal(path, CONNMAN_CELLULAR_TECHNOLOGY_PREFIX)
+ == TRUE)
+ *(state_table + NET_DEVICE_CELLULAR) = NET_STATE_TYPE_READY;
+ else if (g_str_equal(path, CONNMAN_ETHERNET_TECHNOLOGY_PREFIX)
+ == TRUE)
+ *(state_table + NET_DEVICE_ETHERNET) = NET_STATE_TYPE_READY;
+ else if (g_str_equal(path, CONNMAN_BLUETOOTH_TECHNOLOGY_PREFIX)
+ == TRUE)
+ *(state_table + NET_DEVICE_BLUETOOTH) = NET_STATE_TYPE_READY;
+ else
+ NETWORK_LOG(NETWORK_ERROR, "Invalid technology type");
+ } else if (g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == 0 &&
+ g_strcmp0(key, "Powered") == 0) {
+ data = g_variant_get_boolean(value);
+ if (data == FALSE)
+ NetworkInfo.wifi_state = WIFI_OFF;
+ else if (data == TRUE && NetworkInfo.wifi_state < WIFI_ON)
+ NetworkInfo.wifi_state = WIFI_ON;
+ }
+ }
}
+ g_variant_iter_free(iter_main);
- if (network_status == NET_STATUS_AVAILABLE)
- service_state_table[NET_DEVICE_WIFI] = NET_STATE_TYPE_READY;
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
- Error = _net_dbus_get_network_status(NET_DEVICE_CELLULAR, &network_status);
- if (Error != NET_ERR_NONE) {
- __NETWORK_FUNC_EXIT__;
- return Error;
+static int __net_dbus_get_all_technology_states(net_state_type_t *state_table)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetTechnologies", NULL, &Error);
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get technology info");
+ goto done;
}
- if (network_status == NET_STATUS_AVAILABLE)
- service_state_table[NET_DEVICE_CELLULAR] = NET_STATE_TYPE_READY;
+ Error = __net_get_all_tech_states(message, state_table);
- Error = _net_dbus_get_network_status(NET_DEVICE_ETHERNET, &network_status);
- if (Error != NET_ERR_NONE) {
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
+ g_variant_unref(message);
- if (network_status == NET_STATUS_AVAILABLE)
- service_state_table[NET_DEVICE_ETHERNET] = NET_STATE_TYPE_READY;
+done:
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_init_service_state_table(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
- Error = _net_dbus_get_network_status(NET_DEVICE_BLUETOOTH, &network_status);
+ Error = __net_dbus_get_all_technology_states(&service_state_table[0]);
if (Error != NET_ERR_NONE) {
__NETWORK_FUNC_EXIT__;
return Error;
}
- if (network_status == NET_STATUS_AVAILABLE)
- service_state_table[NET_DEVICE_BLUETOOTH] = NET_STATE_TYPE_READY;
-
NETWORK_LOG(NETWORK_HIGH, "init service state table. "
- "wifi:%d, cellular:%d, ethernet:%d, bluetooth:%d\n",
+ "wifi:%d, cellular:%d, ethernet:%d, bluetooth:%d",
service_state_table[NET_DEVICE_WIFI],
service_state_table[NET_DEVICE_CELLULAR],
service_state_table[NET_DEVICE_ETHERNET],
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*/
#include <vconf.h>
+#include <vconf-keys.h>
#include "network-internal.h"
#include "network-dbus-request.h"
/*****************************************************************************
* Local Functions Definition
*****************************************************************************/
-static net_wifi_state_t __net_get_wifi_service_state(char *profile_name)
+static net_wifi_state_t __net_get_wifi_service_state(char *profile_name, net_err_t *net_error)
{
- __NETWORK_FUNC_ENTER__;
-
+ int i = 0, profile_count = 0;
net_err_t Error = NET_ERR_NONE;
net_wifi_state_t wifi_state = NetworkInfo.wifi_state;
- int profile_count = 0;
- int i = 0;
- net_profile_info_t* profile_info = NULL;
+ net_profile_info_t *temp = NULL, *profile_info = NULL;
+ __NETWORK_FUNC_ENTER__;
Error = _net_get_profile_list(NET_DEVICE_WIFI, &profile_info, &profile_count);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR,
- "Failed to get service(profile) list. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service list[%s]",
_net_print_error(Error));
NET_MEMFREE(profile_info);
+ *net_error = Error;
+
+ __NETWORK_FUNC_EXIT__;
+ return wifi_state;
+ }
+
+ if (profile_count == 0) {
+ wifi_state = WIFI_ON;
+ NET_MEMFREE(profile_info);
+ *net_error = Error;
__NETWORK_FUNC_EXIT__;
return wifi_state;
}
- for (i = 0;i < profile_count;i++) {
- switch (profile_info[i].ProfileState) {
- case NET_STATE_TYPE_ASSOCIATION :
- case NET_STATE_TYPE_CONFIGURATION :
- wifi_state = WIFI_CONNECTING;
- g_strlcpy(profile_name, profile_info[i].ProfileName,
- sizeof(profile_info[i].ProfileName));
+ /* Assign 'profile_info' to 'temp' to free memory at the end */
+ temp = profile_info;
+ for (i = 0; i < profile_count; i++) {
+ switch (profile_info->ProfileState) {
+ case NET_STATE_TYPE_ASSOCIATION:
+ wifi_state = WIFI_ASSOCIATION;
+ g_strlcpy(profile_name, profile_info->ProfileName,
+ sizeof(profile_info->ProfileName));
+ break;
+ case NET_STATE_TYPE_CONFIGURATION:
+ wifi_state = WIFI_CONFIGURATION;
+ g_strlcpy(profile_name, profile_info->ProfileName,
+ sizeof(profile_info->ProfileName));
break;
- case NET_STATE_TYPE_READY :
- case NET_STATE_TYPE_ONLINE :
+ case NET_STATE_TYPE_READY:
+ case NET_STATE_TYPE_ONLINE:
wifi_state = WIFI_CONNECTED;
- g_strlcpy(profile_name, profile_info[i].ProfileName,
- sizeof(profile_info[i].ProfileName));
+ g_strlcpy(profile_name, profile_info->ProfileName,
+ sizeof(profile_info->ProfileName));
break;
- case NET_STATE_TYPE_UNKNOWN :
- case NET_STATE_TYPE_IDLE :
- case NET_STATE_TYPE_FAILURE :
- case NET_STATE_TYPE_DISCONNECT :
+ case NET_STATE_TYPE_UNKNOWN:
+ case NET_STATE_TYPE_IDLE:
+ case NET_STATE_TYPE_FAILURE:
+ case NET_STATE_TYPE_DISCONNECT:
break;
}
+ profile_info++;
}
if (wifi_state == WIFI_CONNECTED &&
request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
wifi_state = WIFI_DISCONNECTING;
- NET_MEMFREE(profile_info);
+ NET_MEMFREE(temp);
+ *net_error = Error;
__NETWORK_FUNC_EXIT__;
return wifi_state;
}
-static gboolean __net_check_wifi_pending(void)
-{
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag) {
- char *name = (char*)request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
-
- if (g_str_has_prefix(name, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
- return TRUE;
- else
- return FALSE;
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag) {
- char *name = (char*)request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
-
- if (g_str_has_prefix(name, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
- return TRUE;
- else
- return FALSE;
- }
-
- if (request_table[NETWORK_REQUEST_TYPE_SET_DEFAULT].flag)
- return FALSE;
-
- return TRUE;
-}
-
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Async API Definition
*****************************************************************************/
net_err_t Error = NET_ERR_NONE;
if (ssid == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Find hidden AP request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Find hidden AP request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_dbus_specific_scan_request(ssid);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_specific_scan_request() failed. Error [%s]\n",
+ "_net_dbus_specific_scan_request() failed. Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0,
return Error;
}
+EXPORT_API int net_wps_scan_wifi(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+
+ if (NetworkInfo.ref_count < 1) {
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag = TRUE;
+
+ Error = _net_dbus_wps_scan_request();
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR,
+ "_net_dbus_wps_scan_request() failed. Error [%s]",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN], 0,
+ sizeof(network_request_table_t));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
EXPORT_API int net_wifi_get_passpoint(int *enabled)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state()) == WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_dbus_get_passpoint(enabled);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_get_passpoint() failed. Error [%s]\n",
+ "_net_dbus_get_passpoint() failed. Error [%s]",
_net_print_error(Error));
}
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (NetworkInfo.wifi_state == WIFI_OFF) {
- if ((NetworkInfo.wifi_state = _net_get_wifi_state()) == WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_dbus_set_passpoint(enable);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_set_passpoint() failed. Error [%s]\n",
+ "_net_dbus_set_passpoint() failed. Error [%s]",
_net_print_error(Error));
}
return Error;
}
+/*****************************************************************************
+ * ConnMan Wi-Fi Client Interface Async API Definition
+ *****************************************************************************/
EXPORT_API int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if (wifi_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Connection open request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection open request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_open_connection_with_wifi_info(wifi_info);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "net_open_connection_with_wifi_info() failed. Error [%s]\n",
+ "net_open_connection_with_wifi_info() failed. Error [%s]",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
- sizeof(network_request_table_t));
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag != 0)
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
return Error;
return NET_ERR_NONE;
}
-EXPORT_API int net_wifi_power_on(void)
+EXPORT_API int net_wifi_power_on(gboolean wifi_picker_test)
{
__NETWORK_FUNC_ENTER__;
int hotspot_state = 0;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi hotspot is enabled!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi hotspot is enabled!");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
if (NetworkInfo.wifi_state != WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered on already!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_ALREADY_EXISTS;
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered on already!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_ALREADY_EXISTS;
+ }
+ else if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get Wi-Fi state");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
}
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
+ _net_dbus_pending_call_unref();
+ memset(request_table, 0, sizeof(request_table));
request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
- Error = _net_dbus_load_wifi_driver();
+ Error = _net_dbus_load_wifi_driver(wifi_picker_test);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request Wi-Fi power on/off. Error [%s]\n",
+ "Failed to request Wi-Fi power on/off. Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0,
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Sent driver load request successfully\n");
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
- if(NetworkInfo.wifi_state == WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off already!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_ALREADY_EXISTS;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off already!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_ALREADY_EXISTS;
+ }
}
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- if (__net_check_wifi_pending() == TRUE) {
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
_net_dbus_pending_call_unref();
- memset(request_table, 0, sizeof(request_table));
- } else {
- NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress\n");
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_WPS_SCAN].flag == TRUE) {
+ _net_dbus_pending_call_unref();
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WPS_SCAN],
+ 0, sizeof(network_request_table_t));
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
Error = _net_dbus_remove_wifi_driver();
if (Error != NET_ERR_NONE ) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request Wi-Fi power on/off. Error [%s]\n",
+ "Failed to request Wi-Fi power on/off. Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, sizeof(network_request_table_t));
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Sent driver remove request successfully\n");
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
}
if (_net_dbus_is_pending_call_used() == TRUE) {
if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Pending call already in progress\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
} else {
Error = _net_dbus_scan_request();
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to request scan. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to request scan. Error [%s]",
_net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0,
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Wi-Fi scan requested successfully\n");
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
net_err_t Error = NET_ERR_NONE;
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
}
if (_net_dbus_is_pending_call_used() == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
g_strlcpy(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- if (wps_info->type == WIFI_WPS_PBC) {
- Error = _net_dbus_set_agent_wps_pbc();
- if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_set_agent_wps_pbc() failed\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
- } else if(wps_info->type == WIFI_WPS_PIN) {
- Error = _net_dbus_set_agent_wps_pin(wps_info->pin);
- if (NET_ERR_NONE != Error) {
- NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_set_agent_wps_pin() failed\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
- }
- } else {
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_PARAM;
- }
+ if (wps_info->type == WIFI_WPS_PBC)
+ Error = _net_dbus_set_agent_wps_pbc_and_connect(profile_name);
+ else if (wps_info->type == WIFI_WPS_PIN)
+ Error = _net_dbus_set_agent_wps_pin_and_connect(wps_info->pin, profile_name);
+ else
+ Error = NET_ERR_INVALID_PARAM;
- Error = _net_dbus_open_connection(profile_name);
- if (Error != NET_ERR_NONE) {
+ if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to request open connection, Error [%s]\n",
- _net_print_error(Error));
+ "WPS configuration failed(%s)", _net_print_error(Error));
memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
sizeof(network_request_table_t));
return Error;
}
+#if defined TIZEN_TV
+EXPORT_API int net_wifi_cancel_wps(void)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+ NETWORK_LOG(NETWORK_ERROR, "net_wifi_wps_cancel called\n");
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == FALSE) {
+ NETWORK_LOG(NETWORK_ERROR, "No pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_get_wifi_state(&Error) != WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName[0] != '\0') {
+ net_delete_profile(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName);
+ }
+
+ Error = _net_dbus_cancel_wps();
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR,
+ "Failed to request cancel WPS, Error [%s]\n",
+ _net_print_error(Error));
+ }
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_t));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+#endif
+
+
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Sync Function Definition
*****************************************************************************/
__NETWORK_FUNC_ENTER__;
net_wifi_state_t wifi_state;
+ net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (profile_name == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "profile_name is NULL\n");
+ NETWORK_LOG(NETWORK_ERROR, "profile_name is NULL");
return NET_ERR_INVALID_PARAM;
}
memset(profile_name, 0, sizeof(net_profile_name_t));
- wifi_state = _net_get_wifi_state();
+ wifi_state = _net_get_wifi_state(&Error);
if (wifi_state == WIFI_OFF) {
*current_state = WIFI_OFF;
return NET_ERR_NONE;
}
- *current_state = __net_get_wifi_service_state(profile_name->ProfileName);
-
- NETWORK_LOG(NETWORK_HIGH, "current state : %d, profile name : %s\n",
- *current_state, profile_name->ProfileName);
+ *current_state = __net_get_wifi_service_state(profile_name->ProfileName, &Error);
__NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
+ return Error;
}
EXPORT_API int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
net_err_t Error = NET_ERR_NONE;
if (NetworkInfo.ref_count < 1) {
- NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
-
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_INVALID_OPERATION;
+ if (NetworkInfo.wifi_state == WIFI_OFF) {
+ if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
}
- NETWORK_LOG(NETWORK_HIGH, "BGScan Mode [%d]\n", scan_mode);
-
if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Failed to set bgscan mode. Error [%s]\n",
+ "Failed to set bgscan mode. Error [%s]",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
+#if defined TIZEN_TV
+EXPORT_API int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_t *wps_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+
+ if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_APP_NOT_REGISTERED;
+ }
+
+ if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_IN_PROGRESS;
+ }
+
+ if (_net_get_wifi_state(&Error) != WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ if (_net_dbus_is_pending_call_used() == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "pending call in progress\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+
+ if (wps_info->type == WIFI_WPS_PBC) {
+ /* Look How to change the use of Connman agent */
+ Error = _net_dbus_set_agent_wps_pbc();
+ if (NET_ERR_NONE != Error) {
+ NETWORK_LOG(NETWORK_ERROR,
+ "_net_dbus_set_agent_wps_pbc() failed\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ } else if (wps_info->type == WIFI_WPS_PIN) {
+ Error = _net_dbus_set_agent_wps_pin(wps_info->pin);
+ if (NET_ERR_NONE != Error){
+ NETWORK_LOG(NETWORK_ERROR,
+ "_net_dbus_set_agent_wps_pin() failed\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }else {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if(wps_info->type == WIFI_WPS_PBC) {
+ Error = _net_dbus_open_connection_without_ssid();
+ } else if(wps_info->type == WIFI_WPS_PIN) {
+ Error = _net_dbus_open_pin_connection_without_ssid(wps_info->pin);
+ }else{
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR,
+ "Failed to request open connection, Error [%s]\n",
+ _net_print_error(Error));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_t));
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+#endif
#!/bin/sh
+# How to build this test app
+# 1. insert below contents in end of spec file (install)
+# cd test
+# cp -rf %{buildroot}/usr/lib/ ./
+# ./build.sh
+# cd ..
+# 2. find network_client in your build repository in build system
-rm -f network_client
-gcc -Wall -g -O2 -o ./network_client ./main.c `pkg-config glib-2.0 dbus-glib-1 gthread-2.0 --cflags --libs` -I../include/common -I../include/profile -I../include/wifi -L./lib/ -lnetwork
+#rm -f network_client
+#gcc -Wall -g -O2 -o ./network_client ./main.c `pkg-config gio-2.0 glib-2.0 gthread-2.0 --cflags --libs` -I../include/common -I../include/profile -I../include/wifi -L./lib/ -lnetwork
/*
* Network Client Library
*
- * Copyright 2011-2013 Samsung Electronics Co., Ltd
+ * Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://www.tizenopensource.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/time.h>
#include <arpa/inet.h>
-#include <unistd.h>
#include <network-cm-intf.h>
#include <network-pm-intf.h>
gwaddr6, INET6_ADDRSTRLEN);
prefixlen = wlan_info->net_info.PrefixLen6;
privacy = wlan_info->net_info.Privacy6;
-
+
net_info = &(wlan_info->net_info);
} else if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
ipaddr = (unsigned char *)&pdp_info->net_info.IpAddr.Data.Ipv4.s_addr;
netmaskaddr = (unsigned char *)&pdp_info->net_info.SubnetMask.Data.Ipv4.s_addr;
gwaddr = (unsigned char *)&pdp_info->net_info.GatewayAddr.Data.Ipv4.s_addr;
-
+
inet_ntop(AF_INET6, &pdp_info->net_info.IpAddr6.Data.Ipv6,
ipaddr6, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &pdp_info->net_info.GatewayAddr6.Data.Ipv6,
gwaddr6, INET6_ADDRSTRLEN);
prefixlen = pdp_info->net_info.PrefixLen6;
privacy = pdp_info->net_info.Privacy6;
-
+
net_info = &(pdp_info->net_info);
} else if (ProfInfo->profile_type == NET_DEVICE_ETHERNET) {
ipaddr = (unsigned char *)ð_info->net_info.IpAddr.Data.Ipv4.s_addr;
gwaddr6, INET6_ADDRSTRLEN);
prefixlen = eth_info->net_info.PrefixLen6;
privacy = eth_info->net_info.Privacy6;
-
+
net_info = &(eth_info->net_info);
} else if (ProfInfo->profile_type == NET_DEVICE_BLUETOOTH) {
ipaddr = (unsigned char *)&bt_info->net_info.IpAddr.Data.Ipv4.s_addr;
}
debug_print("Profile Name = [%s]\n", ProfInfo->ProfileName);
-
+
if (ProfInfo->ProfileState == NET_STATE_TYPE_IDLE)
debug_print("Profile State = [idle]\n");
else if (ProfInfo->ProfileState == NET_STATE_TYPE_FAILURE)
}
} else if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
debug_print("Profile Type = [cellular]\n");
-
+
if (print_type == PROFILE_PARTIAL_INFO ||
print_type == PROFILE_FULL_INFO) {
}
if (print_type == PROFILE_FULL_INFO) {
- unsigned char *dns = NULL;
+ unsigned char *dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr;
debug_print("Profile Favourite = [%d]\n", (int)ProfInfo->Favourite);
debug_print("Profile Device Name = [%s]\n", net_info->DevName);
debug_print("Profile DNS Count = [%d]\n", net_info->DnsCount);
- for (di = 0;di < net_info->DnsCount;di++) {
- dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr;
+ for (di = 0;di < net_info->DnsCount;di++)
debug_print("Profile DNS Address %d = [%d.%d.%d.%d]\n",
di+1, dns[0], dns[1], dns[2], dns[3]);
- }
if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC)
debug_print("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_DYNAMIC]\n");
netmaskaddr[0], netmaskaddr[1], netmaskaddr[2], netmaskaddr[3]);
debug_print("Profile Gateway = [%d.%d.%d.%d]\n",
gwaddr[0], gwaddr[1], gwaddr[2], gwaddr[3]);
-
+
if (net_info->IpConfigType6 == NET_IP_CONFIG_TYPE_STATIC)
debug_print("Profile IPv6 Method = "
"[NET_IP_CONFIG_TYPE_STATIC]\n");
debug_print("Profile IPv6 GateWay = [%s]\n", gwaddr6);
debug_print("Profile IPv6 Privacy = [%s]\n", privacy);
-
if (net_info->ProxyMethod == NET_PROXY_TYPE_DIRECT)
debug_print("Proxy Method = [direct]\n");
else if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO)
case NET_EVENT_SPECIFIC_SCAN_IND:
debug_print("Got Specific scan Ind : %d\n", event_cb->Error);
- GSList *bss_info_list = event_cb->Data;
+ GSList *bss_info_list = (GSList *)event_cb->Data;
if (bss_info_list)
- for (; bss_info_list; bss_info_list = bss_info_list->next){
- net_wifi_connection_info_t *resp_data = bss_info_list->data;
+ for (; bss_info_list != NULL; bss_info_list = bss_info_list->next) {
+ struct ssid_scan_bss_info_t *resp_data = bss_info_list->data;
if (resp_data)
- debug_print("essid:%s, sec type:%d\n",
- resp_data->essid,
- resp_data->security_info.sec_mode);
+ debug_print("essid:%s, security:%d, wps:%d",
+ resp_data->ssid, resp_data->security, resp_data->wps);
}
else
debug_print("No AP\n");
break;
+ case NET_EVENT_WPS_SCAN_IND:
+ debug_print("Got WPS scan Ind : %d\n", event_cb->Error);
+ GSList *wps_bss_info_list = (GSList *)event_cb->Data;
+
+ if (event_cb->Error == NET_ERR_NONE) {
+ if (wps_bss_info_list) {
+ for (; wps_bss_info_list != NULL; wps_bss_info_list = wps_bss_info_list->next) {
+ struct wps_scan_bss_info_t *resp_data = wps_bss_info_list->data;
+ if (resp_data)
+ debug_print("ESSID %s, BSSID %s, RSSI %d, MODE %d\n",
+ resp_data->ssid, resp_data->bssid, resp_data->rssi, resp_data->mode);
+ }
+ } else
+ debug_print("No AP\n");
+ } else {
+ debug_print("Failed WPS scan\n");
+ }
+ break;
case NET_EVENT_CELLULAR_SET_DEFAULT_RSP:
debug_print("Got Set cellular default profile Rsp : %d\n", event_cb->Error);
break;
wlan_security_info_t *security_info2 =
&profile_info->ProfileInfo.Wlan.security_info;
net_pdp_profile_info_t *pdp_info = &profile_info->ProfileInfo.Pdp;
- char input_str[FORMAT_SIZE] = {0,};
+ char input_str[100] = {0,};
int ei = 0;
if (profile_info->profile_type == NET_DEVICE_WIFI) {
- debug_print("\nInput Passphrase('s' for skip) :\n");
+ debug_print("\nInput Passphrase(Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str) - 1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(security_info2->authentication.psk.pskKey,
input_str, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1);
debug_print("\nInput Proxy Type(1:direct, 2:auto, 3:manual - current:%d)"
- " - ('s' for skip) :\n", net_info2->ProxyMethod);
+ " - (Enter for skip) :\n", net_info2->ProxyMethod);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's') {
+ input_str[strlen(input_str) - 1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
int proxyType = 0;
proxyType = atoi(input_str);
"(Enter for DHCP/WPAD auto-discover) :\n");
else
debug_print("\nInput manual Proxy address - "
- "('s' for skip) :\n");
+ "(Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' &&
+ *input_str != '\n' &&
+ *input_str != '\r') {
+ input_str[strlen(input_str)-1] = '\0';
g_strlcpy(net_info2->ProxyAddr,
input_str, NET_PROXY_LEN_MAX + 1);
- else
+ } else {
net_info2->ProxyAddr[0] = '\0';
+ }
}
}
- debug_print("\nInput IPv4 Address Type dhcp/manual ('s' for skip) :\n");
+ debug_print("\nInput IPv4 Address Type dhcp/manual (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's') {
+ input_str[strlen(input_str) - 1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
if (strcmp(input_str, "dhcp") == 0) {
net_info2->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
} else if (strcmp(input_str, "manual") == 0) {
net_info2->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
- debug_print("\nInput IP Address ('s' for skip) :\n");
+ debug_print("\nInput IP Address (Enter for skip) :\n");
+
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
+ input_str[strlen(input_str) - 1] = '\0';
+ net_info2->IpAddr.Data.Ipv4.s_addr = 0;
+
+ if ((input_str[0] != '\0' &&
+ *input_str != '\n' &&
+ *input_str != '\r') &&
+ strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+ inet_aton(input_str, &(net_info2->IpAddr.Data.Ipv4));
}
- if (input_str[0] != 's' &&
- strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN)
- if (inet_aton(input_str, &(net_info2->IpAddr.Data.Ipv4)) == 0)
- net_info2->IpAddr.Data.Ipv4.s_addr = 0;;
+ debug_print("\nInput Netmask (Enter for skip) :\n");
- debug_print("\nInput Netmask ('s' for skip) :\n");
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ input_str[strlen(input_str) - 1] = '\0';
+ net_info2->SubnetMask.Data.Ipv4.s_addr = 0;
- if (input_str[0] != 's' &&
- strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN)
- if (inet_aton(input_str, &(net_info2->SubnetMask.Data.Ipv4)) == 0)
- net_info2->SubnetMask.Data.Ipv4.s_addr = 0;;
+ if ((input_str[0] != '\0' &&
+ *input_str != '\n' &&
+ *input_str != '\r') &&
+ strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+ inet_aton(input_str, &(net_info2->SubnetMask.Data.Ipv4));
+ }
debug_print("\nInput Gateway (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
+ net_info2->GatewayAddr.Data.Ipv4.s_addr = 0;
- if ((input_str[0] != 's') &&
- strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN)
- if (inet_aton(input_str, &(net_info2->GatewayAddr.Data.Ipv4)) == 0)
- net_info2->GatewayAddr.Data.Ipv4.s_addr = 0;
+ if ((input_str[0] != '\0' &&
+ *input_str != '\n' &&
+ *input_str != '\r') &&
+ strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+ inet_aton(input_str, &(net_info2->GatewayAddr.Data.Ipv4));
+ }
}
}
for (ei = 0;ei < NET_DNS_ADDR_MAX;ei++) {
- debug_print("\nInput DNS %d Address('s' for skip) :\n", ei);
+ debug_print("\nInput DNS %d Address(Enter for skip) :\n", ei);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's') {
- if (inet_aton(input_str, &(net_info2->DnsAddr[ei].Data.Ipv4)) == 0)
- net_info2->DnsAddr[ei].Data.Ipv4.s_addr = 0;;
+ input_str[strlen(input_str)-1] = '\0';
+ net_info2->DnsAddr[ei].Data.Ipv4.s_addr = 0;
+ if (input_str[0] != '\0' &&
+ *input_str != '\n' &&
+ *input_str != '\r') {
+ inet_aton(input_str, &(net_info2->DnsAddr[ei].Data.Ipv4));
net_info2->DnsCount = ei+1;
}
}
&net_info2->GatewayAddr6.Data.Ipv6);
}
} else if (profile_info->profile_type == NET_DEVICE_CELLULAR) {
- debug_print("\nInput Apn(current:%s) - ('s' for skip) :\n", pdp_info->Apn);
+ debug_print("\nInput Apn(current:%s) - (Enter for skip) :\n", pdp_info->Apn);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->Apn, input_str, NET_PDP_APN_LEN_MAX+1);
- debug_print("\nInput Proxy(current:%s) - ('s' for skip) :\n",
+ debug_print("\nInput Proxy(current:%s) - (Enter for skip) :\n",
pdp_info->net_info.ProxyAddr);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ input_str[strlen(input_str)-1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->net_info.ProxyAddr, input_str, NET_PROXY_LEN_MAX+1);
- debug_print("\nInput HomeURL(current:%s) - ('s' for skip) :\n",
+ debug_print("\nInput HomeURL(current:%s) - (Enter for skip) :\n",
pdp_info->HomeURL);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->HomeURL, input_str, NET_HOME_URL_LEN_MAX+1);
debug_print("\nInput AuthType(0:None, 1:PAP, 2:CHAP - current:%d)"
- " - ('s' for skip) :\n", pdp_info->AuthInfo.AuthType);
+ " - (Enter for skip) :\n", pdp_info->AuthInfo.AuthType);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's') {
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
int typeValue = 0;
typeValue = atoi(input_str);
- if(typeValue == NET_PDP_AUTH_PAP)
+ if (typeValue == NET_PDP_AUTH_PAP)
pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_PAP;
- else if(typeValue == NET_PDP_AUTH_CHAP)
+ else if (typeValue == NET_PDP_AUTH_CHAP)
pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
else
pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_NONE;
if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_PAP ||
pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_CHAP) {
- debug_print("\nInput AuthId(current:%s) - ('s' for skip) :\n",
+ debug_print("\nInput AuthId(current:%s) - (Enter for skip) :\n",
pdp_info->AuthInfo.UserName);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ input_str[strlen(input_str)-1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->AuthInfo.UserName,
input_str, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
- debug_print("\nInput AuthPwd(current:%s) - ('s' for skip) :\n",
+ debug_print("\nInput AuthPwd(current:%s) - (Enter for skip) :\n",
pdp_info->AuthInfo.Password);
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ input_str[strlen(input_str)-1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->AuthInfo.Password,
input_str, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
}
int __network_add_profile_info(net_profile_info_t *profile_info)
{
net_pdp_profile_info_t *pdp_info = &profile_info->ProfileInfo.Pdp;
- char input_str[FORMAT_SIZE] = {0,};
+ char input_str[100] = {0,};
- debug_print("\nInput Keyword(Profile name) - ('s' for skip) :\n");
+ debug_print("\nInput Keyword(Profile name) - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->Keyword, input_str, NET_PDP_APN_LEN_MAX+1);
else
pdp_info->Keyword[0] = '\0';
- debug_print("\nInput Apn - ('s' for skip) :\n");
+ debug_print("\nInput Apn - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->Apn, input_str, NET_PDP_APN_LEN_MAX+1);
else
pdp_info->Apn[0] = '\0';
- debug_print("\nInput Proxy - ('s' for skip) :\n");
+ debug_print("\nInput Proxy - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ input_str[strlen(input_str)-1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->net_info.ProxyAddr, input_str, NET_PROXY_LEN_MAX+1);
else
pdp_info->net_info.ProxyAddr[0] = '\0';
- debug_print("\nInput HomeURL - ('s' for skip) :\n");
+ debug_print("\nInput HomeURL - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->HomeURL, input_str, NET_HOME_URL_LEN_MAX+1);
else
pdp_info->HomeURL[0] = '\0';
- debug_print("\nInput AuthType(0:NONE 1:PAP 2:CHAP) - ('s' for skip) :\n");
+ debug_print("\nInput AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's') {
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
int typeValue = 0;
typeValue = atoi(input_str);
if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_PAP ||
pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_CHAP) {
- debug_print("\nInput AuthId - ('s' for skip) :\n");
+ debug_print("\nInput AuthId - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
+
+ input_str[strlen(input_str)-1] = '\0';
- if (input_str[0] != 's')
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->AuthInfo.UserName,
input_str, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
else
pdp_info->AuthInfo.UserName[0] = '\0';
- debug_print("\nInput AuthPwd - ('s' for skip) :\n");
+ debug_print("\nInput AuthPwd - (Enter for skip) :\n");
- if (__network_get_user_string(input_str, FORMAT_SIZE) == FALSE) {
- debug_print("Fail to get input string\n");
- return FALSE;
- }
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
- if (input_str[0] != 's')
+ input_str[strlen(input_str)-1] = '\0';
+
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
g_strlcpy(pdp_info->AuthInfo.Password,
input_str, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
else
static gboolean network_main_gthread(gpointer data)
{
- char ProfileName[PROFILE_NAME_LEN] = {0,};
+ char ProfileName[NET_PROFILE_NAME_LEN_MAX+1] = {0,};
int input_int = 0;
int net_error = 0;
+ char input_str[100] = { 0, };
+
net_profile_info_t profile_info;
fd_set rfds;
debug_print("n - Add route\n");
debug_print("o - Remove route\n");
debug_print("p - Reqeust specific scan\n");
- debug_print("q - Get technology state\n");
- debug_print("r - Set passpoint on/off\n");
- debug_print("s - Get passpoint state\n");
- debug_print("t - Add IPv6 route\n");
- debug_print("u - Remove IPv6 route\n");
+ debug_print("q - Request wps scan\n");
+ debug_print("r - Get technology state\n");
+ debug_print("s - Set passpoint on/off\n");
+ debug_print("t - Get passpoint state\n");
+ debug_print("u - Add IPv6 route\n");
+ debug_print("v - Remove IPv6 route\n");
debug_print("z - Exit \n");
debug_print("ENTER - Show options menu.......\n");
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
- if (net_wifi_power_on() != NET_ERR_NONE) {
+ if (net_wifi_power_on(FALSE) != NET_ERR_NONE) {
debug_print("net_wifi_power_on() failed.\n");
break;
}
break;
case '3':
- debug_print("Enter BG Scan Mode(0:default, 1:periodic, 2:exponential):\n");
+ debug_print("Enter BG Scan Mode(0:default, 1:periodic, 2:exponential):");
scanf("%d", &input_int);
gettimeofday(&timevar, NULL);
if (service_type != NET_SERVICE_UNKNOWN) {
net_error = net_open_connection_with_preference(service_type);
if (net_error != NET_ERR_NONE) {
- debug_print("net_open_connection_with_profile() failed.\n");
+ debug_print("net_open_connection_with_profile() failed[%d]\n", net_error);
break;
}
}
case '5':
debug_print("Enter Profile Name: \n");
-
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ scanf("%s", ProfileName);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
case '6':
debug_print("Enter Profile Name: \n");
-
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ scanf("%s", ProfileName);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
case WIFI_ON:
debug_print("wlanstate : WIFI_ON\n");
break;
- case WIFI_CONNECTING:
- debug_print("wlanstate : WIFI_CONNECTING, profile name : %s\n",
+ case WIFI_ASSOCIATION:
+ debug_print("wlanstate : WIFI_ASSOCIATION, profile name : %s\n",
+ profile_name.ProfileName);
+ break;
+ case WIFI_CONFIGURATION:
+ debug_print("wlanstate : WIFI_CONFIGURATION, profile name : %s\n",
profile_name.ProfileName);
break;
case WIFI_CONNECTED:
break;
case 'b':
- debug_print("Enter network type - 1:wifi, 2:mobile, 3:ethernet 4:bluetooth : \n");
- scanf("%d", &input_int);
+ debug_print("Enter network type (wifi/cellular/eth/bt): \n");
+ scanf("%s", input_str);
net_device_t device_type = NET_DEVICE_UNKNOWN;
net_cm_network_status_t NetworkStatus;
- switch (input_int) {
- case 1:
+ if (strcmp(input_str, "wifi") == 0)
device_type = NET_DEVICE_WIFI;
- break;
- case 2:
+ else if (strcmp(input_str, "cellular") == 0)
device_type = NET_DEVICE_CELLULAR;
- break;
- case 3:
+ else if (strcmp(input_str, "eth") == 0)
device_type = NET_DEVICE_ETHERNET;
- break;
- case 4:
+ else if (strcmp(input_str, "bt") == 0)
device_type = NET_DEVICE_BLUETOOTH;
- }
-
- if (device_type == NET_DEVICE_UNKNOWN)
+ else {
+ debug_print("Invalid string\n");
break;
+ }
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
break;
case 'd':
- debug_print("Input profile type - 1:wifi, 2:mobile 3:ethernet 4:bluetooth 5:all : \n");
- scanf("%d", &input_int);
+ debug_print("\nInput profile type - 1:wifi, 2:mobile 3:ethernet 4:bluetooth (Enter for skip):\n");
+ memset(input_str, 0, 100);
+ read(0, input_str, 100);
net_device_t deviceType = NET_DEVICE_UNKNOWN;
int profListCount = 0;
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
- switch (input_int) {
- case 1:
- deviceType = NET_DEVICE_WIFI;
- break;
- case 2:
- deviceType = NET_DEVICE_CELLULAR;
- break;
- case 3:
- deviceType = NET_DEVICE_ETHERNET;
- break;
- case 4:
- deviceType = NET_DEVICE_BLUETOOTH;
- break;
- case 5:
- deviceType = NET_DEVICE_MAX;
- break;
- default:
- deviceType = NET_DEVICE_UNKNOWN;
- }
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+ input_str[strlen(input_str)-1] = '\0';
- if (deviceType == NET_DEVICE_UNKNOWN)
- break;
+ if (strcmp(input_str, "1") == 0)
+ deviceType = NET_DEVICE_WIFI;
+ else if (strcmp(input_str, "2") == 0)
+ deviceType = NET_DEVICE_CELLULAR;
+ else if (strcmp(input_str, "3") == 0)
+ deviceType = NET_DEVICE_ETHERNET;
+ else if (strcmp(input_str, "4") == 0)
+ deviceType = NET_DEVICE_BLUETOOTH;
- net_error = net_get_profile_list(deviceType,
- &profList, &profListCount);
+ net_error = net_get_profile_list(deviceType,
+ &profList, &profListCount);
+ if (net_error != NET_ERR_NONE) {
+ debug_print("net_get_profile_list() failed[%d]\n", net_error);
+ break;
+ }
- if (net_error != NET_ERR_NONE) {
- debug_print("net_get_profile_list() failed\n");
- break;
+ __print_profile_list(profListCount, profList, PROFILE_BASIC_INFO);
+ MAIN_MEMFREE(profList);
}
- __print_profile_list(profListCount, profList, PROFILE_BASIC_INFO);
- MAIN_MEMFREE(profList);
-
gettimeofday(&timevar, NULL);
finish_time = Convert_time2double(timevar);
debug_print("Total time taken = [%f]\n", finish_time - start_time);
break;
case 'e':
- debug_print("Input profile Name : \n");
+ debug_print("\nInput profile Name((Enter for skip) :\n");
+ memset(ProfileName, 0, NET_PROFILE_NAME_LEN_MAX);
+ read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ if (ProfileName[0] == '\0' || *ProfileName == '\n' || *ProfileName == '\r')
+ debug_print("\nCanceled!\n\n");
+
+ ProfileName[strlen(ProfileName)-1] = '\0';
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
- if (net_get_profile_info(ProfileName, &profile_info) != NET_ERR_NONE) {
- debug_print("net_get_profile_info() failed\n");
+ net_error = net_get_profile_info(ProfileName, &profile_info);
+ if (net_error != NET_ERR_NONE) {
+ debug_print("net_get_profile_info() failed[%d]\n", net_error);
break;
}
break;
case 'f':
- debug_print("Input profile Name : \n");
-
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ debug_print("\nInput profile Name(Enter for skip) :\n");
+ memset(ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX);
+ read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
- net_error = net_get_profile_info(ProfileName, &profile_info);
+ if (ProfileName[0] != '\0' &&
+ *ProfileName != '\n' &&
+ *ProfileName != '\r') {
+ ProfileName[strlen(ProfileName) - 1] = '\0';
- if (net_error != NET_ERR_NONE) {
- debug_print("net_get_profile_info() failed\n");
+ net_error = net_get_profile_info(ProfileName, &profile_info);
+ if (net_error != NET_ERR_NONE) {
+ debug_print("net_get_profile_info() failed[%d]\n", net_error);
+ break;
+ }
+ } else {
+ debug_print("\nCanceled!\n\n");
break;
}
break;
case 'g':
- debug_print("Input profile Name : \n");
+ debug_print("\nInput profile Name(Enter for skip) :\n");
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ memset(ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX);
+ read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
+ if (ProfileName[0] == '\0' || *ProfileName == '\n' || *ProfileName == '\r')
+ debug_print("\nCanceled!\n\n");
+
+ ProfileName[strlen(ProfileName)-1] = '\0';
+
if (net_delete_profile(ProfileName) != NET_ERR_NONE) {
debug_print("net_delete_profile() failed\n");
break;
break;
case 'h':
- debug_print("Input Network Type (Internet:1, MMS:2, Prepaid_internet:3, "
- "Prepaid MMS:4, Tethering:5, Application:6) :\n");
+ debug_print("\nInput Network Type(Internet:1, MMS:2, Prepaid_internet:3, "
+ "Prepaid MMS:4, Tethering:5, Application:6)"
+ " - (Enter for skip) :\n");
- scanf("%d", &input_int);
+ memset(input_str, '\0', 100);
+ read(0, input_str, 100);
net_service_type_t network_type = NET_SERVICE_INTERNET;
memset(&profile_info, 0, sizeof(net_profile_info_t));
- if (input_int > NET_SERVICE_UNKNOWN && input_int <= NET_SERVICE_APPLICATION)
- network_type = input_int;
- else
+ if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+ int typeValue = 0;
+ typeValue = atoi(input_str);
+
+ if (typeValue > NET_SERVICE_UNKNOWN &&
+ typeValue <= NET_SERVICE_APPLICATION)
+ network_type = typeValue;
+ else
+ return TRUE;
+ } else {
return TRUE;
+ }
__network_add_profile_info(&profile_info);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
- if (net_add_profile(network_type, &profile_info) != NET_ERR_NONE) {
- debug_print("net_add_profile() failed\n");
+ net_error = net_add_profile(network_type, &profile_info);
+ if (net_error != NET_ERR_NONE) {
+ debug_print("net_add_profile() failed[%d]\n", net_error);
break;
}
case 'i': {
net_wifi_connection_info_t wifi_info = {{0,}, };
- debug_print("Enter essid : \n");
-
- if (__network_get_user_string(wifi_info.essid, sizeof(wifi_info.essid)) == FALSE)
- break;
-
- debug_print("Enter psk key : \n");
-
- if (__network_get_user_string(wifi_info.security_info.authentication.psk.pskKey,
- sizeof(wifi_info.security_info.authentication.psk.pskKey)) == FALSE)
- break;
+ debug_print("Enter essid:\n");
+ scanf("%s", wifi_info.essid);
wifi_info.wlan_mode = NETPM_WLAN_CONNMODE_INFRA;
wifi_info.security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+ debug_print("Enter psk key:\n");
+ scanf("%s", wifi_info.security_info.authentication.psk.pskKey);
+
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
net_error = net_open_connection_with_wifi_info(&wifi_info);
if (net_error != NET_ERR_NONE) {
- debug_print("net_open_connection_with_wifi_info() failed.\n");
+ debug_print("net_open_connection_with_wifi_info() failed[%d]\n", net_error);
break;
}
break;
case 'k': {
- debug_print("Input profile Name : \n");
-
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ debug_print("Enter Profile Name: \n");
+ scanf("%s", ProfileName);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
info.security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
debug_print("Enter essid:\n");
-
- if (__network_get_user_string(info.essid, sizeof(info.essid)) == FALSE)
- break;
+ scanf("%s", info.essid);
debug_print("Enter EAP type PEAP 1, TLS 2, TTLS 3, SIM 4, AKA 5:\n");
scanf("%d", &eap_type);
info.security_info.authentication.eap.eap_auth = (wlan_eap_auth_type_t) eap_auth;
debug_print("Enter user name:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.username,
- sizeof(info.security_info.authentication.eap.username)) == FALSE)
- break;
+ scanf("%s", info.security_info.authentication.eap.username);
debug_print("Enter password:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.password,
- sizeof(info.security_info.authentication.eap.password)) == FALSE)
+ scanf("%s", info.security_info.authentication.eap.password);
debug_print("Enter CA Cert filename:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.ca_cert_filename,
- sizeof(info.security_info.authentication.eap.ca_cert_filename)) == FALSE)
+ scanf("%s", info.security_info.authentication.eap.ca_cert_filename);
debug_print("Enter Client Cert filename:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.client_cert_filename,
- sizeof(info.security_info.authentication.eap.client_cert_filename)) == FALSE)
+ scanf("%s", info.security_info.authentication.eap.client_cert_filename);
debug_print("Enter private key filename:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.private_key_filename,
- sizeof(info.security_info.authentication.eap.private_key_filename)) == FALSE)
+ scanf("%s", info.security_info.authentication.eap.private_key_filename);
debug_print("Enter private key password:\n");
-
- if (__network_get_user_string(info.security_info.authentication.eap.private_key_passwd,
- sizeof(info.security_info.authentication.eap.private_key_passwd)) == FALSE)
+ scanf("%s", info.security_info.authentication.eap.private_key_passwd);
net_open_connection_with_wifi_info(&info);
}
case 'm': {
int user_sel;
- debug_print( "Enter API type(1:sync, 2:async) : \n");
+ debug_print("Enter API type(1:sync, 2:async) : \n");
scanf("%d", &user_sel);
if (user_sel != 1 && user_sel != 2) {
break;
}
- debug_print("Input profile Name : \n");
-
- if (__network_get_user_string(ProfileName, PROFILE_NAME_LEN) == FALSE)
- break;
+ debug_print("Enter Profile Name: \n");
+ scanf("%s", ProfileName);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
if (user_sel == 1) {
if (net_set_default_cellular_service_profile(ProfileName) != NET_ERR_NONE) {
- debug_print("net_set_default_cellular_service_profile() failed.\n");
+ debug_print("Error!! net_set_default_cellular_service_profile() failed.\n");
break;
}
} else {
if (net_set_default_cellular_service_profile_async(ProfileName) != NET_ERR_NONE) {
- debug_print("net_set_default_cellular_service_profile_async() failed.\n");
+ debug_print("Error!! net_set_default_cellular_service_profile_async() failed.\n");
break;
}
}
case 'p': {
char essid[40];
- debug_print( "Enter essid to scan : \n");
-
- if (__network_get_user_string(essid, 40) == FALSE)
- break;
+ debug_print("Enter essid to scan : \n");
+ scanf("%39s", essid);
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
if (net_specific_scan_wifi(essid) != NET_ERR_NONE) {
- debug_print("net_specific_scan_wifi() failed.\n");
+ debug_print("Error!! net_specific_scan_wifi() failed.\n");
break;
}
break;
case 'q': {
- char user_str[20];
- debug_print("Enter network type (wifi/cellular/eth/bt): \n");
+ gettimeofday(&timevar, NULL);
+ start_time = Convert_time2double(timevar);
- if (__network_get_user_string(user_str, 20) == FALSE)
+ if (net_wps_scan_wifi() != NET_ERR_NONE) {
+ debug_print("Error!! net_wps_scan_wifi() failed.\n");
break;
+ }
+
+ gettimeofday(&timevar, NULL);
+ finish_time = Convert_time2double(timevar);
+ debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+ debug_print("net_wps_scan_wifi() success\n");
+ }
+ break;
+
+ case 'r': {
+ char user_str[20];
+ debug_print("Enter network type (wifi/cellular/eth/bt): \n");
+ scanf("%19s", user_str);
net_device_t device_type;
net_tech_info_t tech_info;
}
break;
- case 'r': {
+ case 's': {
int enable;
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
- debug_print( "Enter passpoint on/off(0:off, 1:on) : \n");
+ debug_print("Enter passpoint on/off(0:off, 1:on) : \n");
scanf("%d", &enable);
if (net_wifi_set_passpoint(enable) != NET_ERR_NONE) {
}
break;
- case 's': {
+ case 't': {
int enabled;
gettimeofday(&timevar, NULL);
start_time = Convert_time2double(timevar);
}
break;
- case 't': {
+ case 'u': {
char ip_addr[40] = {0};
char if_name[40] = {0};
char gateway[40] = {0};
}
break;
- case 'u': {
+ case 'v': {
char ip_addr[40] = {0};
char if_name[40] = {0};
char gateway[40] = {0};