/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
#ifndef __NETWORK_CM_ERROR_H__
#define __NETWORK_CM_ERROR_H__
-
#ifdef __cplusplus
extern "C" {
#endif
/*
==================================================================================================
- INCLUDE FILES
-==================================================================================================
-*/
-
-/*
-==================================================================================================
CONSTANTS
==================================================================================================
*/
#endif
#endif
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifndef __NETWORK_CM_INTF_H__ /* To prevent inclusion of a header file twice */
+#ifndef __NETWORK_CM_INTF_H__
#define __NETWORK_CM_INTF_H__
+#include "network-pm-intf.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__((deprecated))
+#endif
+
/**
* @file network-cm-intf.h
* @brief This file defines the interface of Connection Manager with the application.
*/
/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <sys/un.h>
-#include <errno.h>
-
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <pthread.h>
-#include <signal.h>
-
-#include <sys/poll.h>
-
-#include <semaphore.h>
-#include <linux/unistd.h>
-
-#include "network-pm-intf.h"
-#include "network-cm-error.h"
-
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
-#endif
-
-/*==================================================================================================
CONSTANTS
==================================================================================================*/
/*****************************************************************************************/
/* Callback function prototype
- * typedef void (*net_event_cb_t ) ( const net_event_info_t* net_event, void* user_data);
+ * typedef void (*net_event_cb_t)(const net_event_info_t* net_event, void* user_data);
*/
/**
*
*/
-typedef void (*net_event_cb_t ) ( const net_event_info_t* net_event, void* user_data);
+typedef void (*net_event_cb_t)(const net_event_info_t* net_event, void* user_data);
/*==================================================================================================
FUNCTION PROTOTYPES
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
#ifndef __NETWORK_PM_CONFIG_H__
#define __NETWORK_PM_CONFIG_H__
+#include <netinet/in.h>
+
+#include "network-cm-error.h"
#ifdef __cplusplus
extern "C"
*/
/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-
-#include <netinet/in.h>
-
-#include "network-cm-error.h"
-
-/*==================================================================================================
CONSTANTS
==================================================================================================*/
#endif /* __cplusplus */
#endif
-
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
#ifndef __NETWORK_PM_INTF_H__
#define __NETWORK_PM_INTF_H__
+#include "network-pm-wlan.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__((deprecated))
+#endif
+
/**
* @file network-pm-intf.h
* @brief This file defines the interface of Profile Manager with the application/Connection Manager.
* \{
*/
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
-#endif
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-
-#include "network-pm-wlan.h"
-
/*==================================================================================================
CONSTANTS
==================================================================================================*/
* \par Example of how this function would be called:
*
* net_profile_info_t prof_info;\n
- * int result; \n
- * result = net_add_profile( NET_SERVICE_MMS, &prof_info ); \n
+ * int result;\n
+ * result = net_add_profile(NET_SERVICE_MMS, &prof_info);\n
* if(result == NET_ERR_NONE)
*
******************************************************************************************/
#endif /* __cplusplus */
#endif
-
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
#ifndef __NETWORK_PM_WLAN_H__
#define __NETWORK_PM_WLAN_H__
+#include "network-pm-config.h"
#ifdef __cplusplus
extern "C"
/*
==================================================================================================
- INCLUDE FILES
-==================================================================================================
-*/
-
-#include "network-pm-config.h"
-
-/*
-==================================================================================================
CONSTANTS
==================================================================================================
*/
/** Length of essid */
#define NET_WLAN_ESSID_LEN 128
-
/**
* Length of WPS PIN code
* WPS PIN code should be 4 or 8 digits
*/
#define NETPM_WLAN_MAX_WEP_KEY_LEN 26
-
/**
* These lengths depends on authentication server being used,
* In case of freeradius server Max allowed length for username/password is 255
* Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
*/
#define NETPM_WLAN_USERNAME_LEN 50
+
/**
* These lengths depends on authentication server being used,
* In case of freeradius server Max allowed length for username/password is 255
* Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
*/
#define NETPM_WLAN_CA_CERT_FILENAME_LEN 50
+
/**
* length of Client Cert file name
* Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
*/
#define NETPM_WLAN_CLIENT_CERT_FILENAME_LEN 50
+
/**
* length of private key file name
* Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
*/
#define NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN 50
+
/**
* length of Private key password
* Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
char essid[NET_WLAN_ESSID_LEN+1];
} net_essid_t;
-
/**
* Below structure is used by WPA-PSK or WPA2-PSK
* @remark To see the maximum length of PSK passphrase key.
char pskKey[NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
} wlan_psk_info_t;
-
/**
* Below structure is used by WEP
* @remark To see the maximum length of WEP key.
char wepKey[NETPM_WLAN_MAX_WEP_KEY_LEN + 1];
} wlan_wep_info_t;
-
/**
* Below structure is used by EAP
* @see wlan_auth_info_t
/**
* For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
*/
- char ca_cert_filename[NETPM_WLAN_CA_CERT_FILENAME_LEN+1]; /* Used to authenticate server */
+ /* Used to authenticate server */
+ char ca_cert_filename[NETPM_WLAN_CA_CERT_FILENAME_LEN+1];
/** client certificate file name */
char client_cert_filename[NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1];
/** private key file name */
wlan_eap_auth_type_t eap_auth;
} wlan_eap_info_t;
-
/**
* At any point of time only one security mechanism is supported
* @see wlan_security_info_t
wlan_eap_info_t eap;
} wlan_auth_info_t;
-
/**
* This is main security information structure
* @see net_pm_wlan_profile_info_t
char wps_support;
} wlan_security_info_t;
-
/**
* AP Profile information
*/
#endif /* __cplusplus */
#endif /* __NETPM_WLAN_H__ */
-
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
+#ifndef __NETWORK_WIFI_INTF_H__
+#define __NETWORK_WIFI_INTF_H__
-#ifndef __NETWORK_WIFI_INTF_H_
-#define __NETWORK_WIFI_INTF_H_
+#include "network-cm-intf.h"
#ifdef __cplusplus
extern "C" {
* \addtogroup wifi_specific
* \{
*/
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-
-#include "network-pm-wlan.h"
-#include "network-cm-intf.h"
/*****************************************************************************
* Macros and Typedefs
WIFI_CONNECTED,
/** Trying to disconnect(connected, but disconnecting process is on going) */
WIFI_DISCONNECTING,
-} net_wifi_state_t;
+} net_wifi_state_t;
/**
*@enum net_wifi_background_scan_mode_t
/*****************************************************************************
* Global Structures
*****************************************************************************/
-
/**
* This is the structure to connect with WPS network.
*/
* ConnMan Wi-Fi Client Interface Synchronous API Declaration
*****************************************************************************/
-
/**
* @fn int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name)
*
int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name);
-
/**
* @fn int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
*
int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info);
-
/**
* @fn int net_scan_wifi(void)
*
int net_scan_wifi(void);
-
/**
* @fn int net_wifi_power_on(void)
*
int net_wifi_power_on(void);
-
/**
* @fn int net_wifi_power_off(void)
*
int net_wifi_power_off(void);
-
/**
* @fn int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
*
int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info);
-
/**
* \}
*/
}
#endif
-#endif /** __NETWORK_WIFI_INTF_H_ */
+#endif /** __NETWORK_WIFI_INTF_H__ */
Name: libnet-client
Summary: Network Client library (Shared library)
-Version: 0.1.77_20
+Version: 0.1.77_21
Release: 1
Group: System/Network
License: Flora License
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
+#ifndef __NETWORK_DBUS_REQUEST_H__
+#define __NETWORK_DBUS_REQUEST_H__
-#ifndef __NETWORK_DBUS_REQUEST_H_
-#define __NETWORK_DBUS_REQUEST_H_
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <dbus/dbus.h>
-
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-
+#include "network-internal.h"
+#include "network-wifi-intf.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
/*****************************************************************************
* Macros and Typedefs
char *private_key_password;
} net_wifi_connect_service_info_t;
-
/*****************************************************************************
* Global Functions
*****************************************************************************/
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);
DBusMessage *_net_invoke_dbus_method(const char* dest, const char* path,
- char* interface_name, char* method, char *param_array[], int *dbus_error);
+ char* interface_name, char* method,
+ char* param_array[], int* dbus_error);
int _net_invoke_dbus_method_nonblock(const char* dest, const char* path,
- char* interface_name, char* method, DBusPendingCallNotifyFunction notify_func);
+ char* interface_name, char* method,
+ DBusPendingCallNotifyFunction notify_func);
int _net_dbus_load_wifi_driver(void);
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_specific_scan_request(const char *ssid);
int _net_dbus_set_default(const char* profile_name);
-#endif /** __NETWORK_SIGNAL_HANDLER_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_SIGNAL_HANDLER_H__ */
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
+#ifndef __NETWORK_INTERNAL_H__
+#define __NETWORK_INTERNAL_H__
-#ifndef __NETWORK_INTERNAL_H_
-#define __NETWORK_INTERNAL_H_
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
#include <glib.h>
+#include <stdlib.h>
+#include <dbus/dbus.h>
-#include <dbus/dbus.h>
-
-#include <net/if.h> /** for IFNAMSIZ and co... */
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-#include "network-pm-intf.h"
#include "network-cm-intf.h"
#include "network-wifi-intf.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*****************************************************************************
* Macros and Typedefs
*****************************************************************************/
#define NET_MEMFREE(x) {if(x != NULL) free(x); x = NULL;}
-/** ConnMan Daemon Management interface */
+/** ConnMan interfaces */
#define CONNMAN_SERVICE "net.connman"
-
#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
#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 NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
#define NETCONFIG_STATISTICS_PATH "/net/netconfig/network_statistics"
-#define TELEPHONY_SERVCE "com.tcore.ps"
-#define TELEPHONY_MASTER_INTERFACE TELEPHONY_SERVCE ".master"
-#define TELEPHONY_NETWORK_INTERFACE TELEPHONY_SERVCE ".network"
-#define TELEPHONY_PROFILE_INTERFACE TELEPHONY_SERVCE ".context"
-#define TELEPHONY_MASTER_PATH "/"
-
-/** Network related Daemon Signal Filters */
-#define NETCONFIG_WIFI_FILTER "type='signal',interface='net.netconfig.wifi'"
+#define TELEPHONY_SERVICE "com.tcore.ps"
+#define TELEPHONY_MASTER_INTERFACE TELEPHONY_SERVICE ".master"
+#define TELEPHONY_NETWORK_INTERFACE TELEPHONY_SERVICE ".network"
+#define TELEPHONY_PROFILE_INTERFACE TELEPHONY_SERVICE ".context"
-/** Network related Daemon Signals */
-#define NETCONFIG_SIGNAL_POWERON_COMPLETED "PowerOnCompleted"
-#define NETCONFIG_SIGNAL_POWEROFF_COMPLETED "PowerOffCompleted"
-#define NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE "SpecificScanCompleted"
+#define TELEPHONY_MASTER_PATH "/"
-/** ConnMan Daemon Signal Filters */
+/** Signal Filters */
#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
#define CONNMAN_TECHNOLOGY_SIGNAL_FILTER "type='signal',interface='net.connman.Technology'"
#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
#define CONNMAN_PROFILE_SIGNAL_FILTER "type='signal',interface='net.connman.Profile'"
-#define CONNMAN_NETWORK_COUNTER_FILTER "type='signal',interface='net.connman.Counter'"
-
-/** ConnMan Daemon Signals */
-#define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+#define NETCONFIG_WIFI_FILTER "type='signal',interface='net.netconfig.wifi'"
-/* Newly added manager interface signals */
-#define CONNMAN_SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded"
-#define CONNMAN_SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
-#define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
+/** Signals */
+#define SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+#define SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded"
+#define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
+#define SIGNAL_SERVICES_CHANGED "ServicesChanged"
/** ConnMan technology and profile prefixes for ConnMan */
#define CONNMAN_CELLULAR_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/cellular"
#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"
#ifdef VITA_FEATURE
#include <dlog.h>
#endif /** VITA_FEATURE */
-
/*****************************************************************************
* Global Enums
*****************************************************************************/
NETWORK_REQUEST_TYPE_MAX
} network_async_request_type_t;
-
typedef struct
{
- int flag; /** TRUE/FALSE */
+ int flag;
char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
} network_request_table_t;
typedef struct
{
- char technology[NET_TECH_LENGTH_MAX]; /** wifi, ethernet, cellular - strings */
+ char technology[NET_TECH_LENGTH_MAX];
char AvailableTechnology;
char EnabledTechnology;
char ConnectedTechnology;
char DefaultTechnology;
- /* Connman 1.3 */
+ /* Connman 1.x */
char Connected;
char Powered;
} network_tech_state_info_t;
net_wifi_state_t _net_get_wifi_state(void);
void _net_clear_request_table(void);
-#endif /** __NETWORK_INTERNAL_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_INTERNAL_H__*/
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
+#ifndef __NETWORK_SIGNAL_HANDLER_H__
+#define __NETWORK_SIGNAL_HANDLER_H__
-#ifndef __NETWORK_SIGNAL_HANDLER_H_
-#define __NETWORK_SIGNAL_HANDLER_H_
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <dbus/dbus.h>
-
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
/*****************************************************************************
* Macros and Typedefs
int _net_register_signal(void);
int _net_init_service_state_table(void);
+#ifdef __cplusplus
+}
+#endif
-#endif /** __NETWORK_SIGNAL_HANDLER_H_ */
-
+#endif /** __NETWORK_SIGNAL_HANDLER_H__ */
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <dbus/dbus.h>
-
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-
-#include "network-internal.h"
-#include "network-signal-handler.h"
#include "network-dbus-request.h"
-
-/*****************************************************************************
- * Macros and Typedefs
- *****************************************************************************/
+#include "network-signal-handler.h"
/*****************************************************************************
* Local Functions Declaration
net_err_t Error = NET_ERR_NONE;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (param == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! _net_get_default_profile_info() failed. Error [%s]\n",
+ "_net_get_default_profile_info() failed. Error [%s]\n",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
NETCONFIG_NETWORK_INTERFACE, "AddRoute", param_array, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to Add route\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to add route\n");
goto done;
}
NETCONFIG_NETWORK_INTERFACE, "RemoveRoute", param_array, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to Remove route\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to remove route\n");
goto done;
}
net_err_t Error = NET_ERR_NONE;
if (event_cb == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Invalid EventCb parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (NetworkInfo.ClientEventCb != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application Already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application Already registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_ALREADY_REGISTERED;
}
{
net_err_t Error = NET_ERR_NONE;
- if (event_cb == NULL || (client_type != NET_DEVICE_DEFAULT && client_type != NET_DEVICE_WIFI)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Invalid EventCb parameter\n");
+ if (event_cb == NULL ||
+ (client_type != NET_DEVICE_DEFAULT &&
+ client_type != NET_DEVICE_WIFI)) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid EventCb parameter\n");
return NET_ERR_INVALID_PARAM;
}
switch (client_type) {
case NET_DEVICE_DEFAULT:
if (NetworkInfo.ClientEventCb_conn != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Connection CAPI Already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection CAPI Already registered\n");
return NET_ERR_APP_ALREADY_REGISTERED;
}
break;
case NET_DEVICE_WIFI:
if (NetworkInfo.ClientEventCb_wifi != NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Wi-Fi CAPI Already registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI Already registered\n");
return NET_ERR_APP_ALREADY_REGISTERED;
}
default:
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0 ||
NetworkInfo.ClientEventCb == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application was not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
int net_deregister_client_ext(net_device_t client_type)
{
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application was not registered\n");
return NET_ERR_APP_NOT_REGISTERED;
}
switch (client_type) {
case NET_DEVICE_DEFAULT:
if (NetworkInfo.ClientEventCb_conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Connection CAPI was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection CAPI was not registered\n");
return NET_ERR_APP_NOT_REGISTERED;
}
NetworkInfo.ClientEventCb_conn = NULL;
break;
case NET_DEVICE_WIFI:
if (NetworkInfo.ClientEventCb_wifi == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Wi-Fi CAPI was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi CAPI was not registered\n");
return NET_ERR_APP_NOT_REGISTERED;
}
NetworkInfo.ClientEventCb_wifi = NULL;
NetworkInfo.user_data_wifi = NULL;
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid client_type parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid client_type parameter\n");
return NET_ERR_INVALID_PARAM;
}
}
if (active_profile_info.profile_type == NET_DEVICE_CELLULAR) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Active(default) network is cellular type.\n");
+ NETWORK_LOG(NETWORK_ERROR, "Active network is cellular type.\n");
Error = NET_ERR_NO_SERVICE;
} else if (active_profile_info.profile_type == NET_DEVICE_ETHERNET) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Active(default) network is ethernet type.\n");
+ NETWORK_LOG(NETWORK_ERROR, "Active network is ethernet type.\n");
Error = NET_ERR_NO_SERVICE;
} else if (active_profile_info.profile_type == NET_DEVICE_WIFI) {
wlan_info = &active_profile_info.ProfileInfo.Wlan;
*/
EXPORT_API int net_is_connected(void)
{
- char state[CONNMAN_STATE_STRLEN] = ""; /** Possible value are "online", "offline" and "connected" */
+ char state[CONNMAN_STATE_STRLEN] = "";
net_err_t Error = NET_ERR_NONE;
__NETWORK_FUNC_ENTER__;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if ((Error = _net_dbus_get_state(state)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to get state. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get state. Error [%s]\n",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return FALSE;
}
- if ((strcmp(state, "online") == 0) || (strcmp(state, "connected") == 0)) {
+ if ((g_strcmp0(state, "online") == 0) || (g_strcmp0(state, "connected") == 0)) {
NETWORK_LOG(NETWORK_HIGH, "State [%s]\n", state);
+
__NETWORK_FUNC_EXIT__;
- return TRUE;
+ return TRUE;
}
- __NETWORK_FUNC_EXIT__;
+ __NETWORK_FUNC_EXIT__;
return FALSE;
}
-
/**
* @fn EXPORT_API int net_get_network_status(net_service_type_t network_type, net_cm_network_status_t* pNetworkStatus)
*
__NETWORK_FUNC_ENTER__;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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, "Error!!! failed to get network status. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get network status. Error [%s]\n",
_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,
- "Error!!! Failed to get statistics info. error : [%s]\n",
- _net_print_error(Error));
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get statistics. error: [%s]\n",
+ _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,
- "Error!!! Failed to set statistics info. error : [%s]\n",
- _net_print_error(Error));
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set statistics. error: [%s]\n",
+ _net_print_error(Error));
return Error;
}
net_err_t Error = NET_ERR_NONE;
if (ip_addr == NULL || strlen(ip_addr) < 7 || interface == NULL || strlen(interface) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_add_route(ip_addr, interface);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to add route. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to add route. Error [%s]\n",
_net_print_error(Error));
+
return Error;
}
net_err_t Error = NET_ERR_NONE;
if (ip_addr == NULL || strlen(ip_addr) < 7 || interface == NULL || strlen(interface) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
Error = __net_remove_route(ip_addr, interface);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to remove route. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to remove route. Error [%s]\n",
_net_print_error(Error));
+
return Error;
}
* ConnMan Wi-Fi Client Interface Async Function Definition
*****************************************************************************/
-
/**
* @fn EXPORT_API int net_open_connection_with_profile(const char *profile_name)
*
* @param[in] char *ProfileName - Profile Name to be connected
* @param[out] none
*/
-
EXPORT_API int net_open_connection_with_profile(const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
-
+
NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__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, "Pending call in progress\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
- snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- if ((Error = _net_dbus_open_connection(profile_name)) != NET_ERR_NONE) {
+ Error = _net_dbus_open_connection(profile_name);
+ if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!! Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]\n",
_net_print_error(Error));
- if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
- 0, sizeof(network_request_table_t));
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+ 0, sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n", profile_name);
- __NETWORK_FUNC_EXIT__;
+ NETWORK_LOG(NETWORK_HIGH, "Successfully request to connect %s\n",
+ profile_name);
+
+ __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, "Error!!! Invalid Service Type passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Service Type\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__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, "pending call in progress\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
Error = _net_get_service_profile(service_type, &profile_name);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Failed to find service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to find service\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
- snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name.ProfileName);
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ profile_name.ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
- if ((Error = _net_dbus_open_connection(profile_name.ProfileName)) != NET_ERR_NONE) {
+ Error = _net_dbus_open_connection(profile_name.ProfileName);
+ if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!! Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]\n",
_net_print_error(Error));
- if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
- 0, sizeof(network_request_table_t));
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+ 0, sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
return Error;
NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n",
profile_name.ProfileName);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-int net_open_connection_with_preference_ext(net_service_type_t service_type, net_profile_name_t *prof_name)
+int net_open_connection_with_preference_ext(net_service_type_t service_type,
+ net_profile_name_t *prof_name)
{
+ __NETWORK_FUNC_ENTER__;
+
net_err_t Error = NET_ERR_NONE;
net_profile_name_t profile_name;
memset(&profile_name, 0, sizeof(net_profile_name_t));
if (_net_is_valid_service_type(service_type) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Service Type passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid service type\n");
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (prof_name == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid profile name passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
+ __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, "pending call in progress\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
Error = _net_get_service_profile(service_type, &profile_name);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Failed to find service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to find service\n");
+ __NETWORK_FUNC_EXIT__;
return Error;
}
request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
- snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name.ProfileName);
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ profile_name.ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
- if ((Error = _net_dbus_open_connection(profile_name.ProfileName)) != NET_ERR_NONE) {
+ Error = _net_dbus_open_connection(profile_name.ProfileName);
+ if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!! Failed to request open connection, Error [%s]\n",
+ "Failed to request open connection, Error [%s]\n",
_net_print_error(Error));
- if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
- 0, sizeof(network_request_table_t));
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+ 0, sizeof(network_request_table_t));
+ __NETWORK_FUNC_EXIT__;
return Error;
}
profile_name.ProfileName);
memcpy(prof_name, &profile_name, sizeof(net_profile_name_t));
+
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
EXPORT_API int net_close_connection(const char *profile_name)
{
__NETWORK_FUNC_ENTER__;
-
+
net_err_t Error = NET_ERR_NONE;
NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Invalid ProfileName parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
}
request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
- snprintf(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- if ((Error = _net_dbus_close_connection(profile_name)) != NET_ERR_NONE) {
+ Error = _net_dbus_close_connection(profile_name);
+ if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!! Failed to request close connection, Error [%s]\n",
+ "Failed to request close connection, Error [%s]\n",
_net_print_error(Error));
-
- if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
- 0, sizeof(network_request_table_t));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
+ 0, sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
return Error;
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <vconf.h>
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
+#include <arpa/inet.h>
+#include <netinet/in.h>
#include "network-internal.h"
#include "network-dbus-request.h"
/*****************************************************************************
* Macros and Typedefs
*****************************************************************************/
-
#define DBUS_REPLY_TIMEOUT (120 * 1000)
/*****************************************************************************
- * Local Functions Declaration
- *****************************************************************************/
-
-static int __net_error_string_to_enum(const char* error);
-static int __net_netconfig_error_string_to_enum(const char* error);
-static int _net_get_error_from_message(DBusMessage *message);
-static int _net_get_error_from_netconfig_message(DBusMessage *message);
-static void __net_open_connection_reply(DBusPendingCall *call, void *user_data);
-static void __net_close_connection_reply(DBusPendingCall *call, void *user_data);
-static void __net_wifi_power_reply(DBusPendingCall *call, void *user_data);
-
-/*****************************************************************************
* Global Functions
*****************************************************************************/
-
/*****************************************************************************
* Global Variables
*****************************************************************************/
-
struct dbus_pending_call_data {
DBusPendingCall *pcall;
dbus_bool_t is_used;
/*****************************************************************************
* Extern Variables
*****************************************************************************/
-
extern network_info_t NetworkInfo;
extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
-
/*****************************************************************************
* Extern Functions
*****************************************************************************/
/*****************************************************************************
* Local Functions Definition
*****************************************************************************/
-
static int __net_error_string_to_enum(const char* error)
{
NETWORK_LOG(NETWORK_HIGH, "Passed error value [%s]\n", error);
MessageType = dbus_message_get_type(message);
if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char* ptr = dbus_message_get_error_name(message);
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Error message received [%s]\n", ptr);
+ const char* str = dbus_message_get_error_name(message);
+
+ NETWORK_LOG(NETWORK_ERROR, "message %s\n", str);
__NETWORK_FUNC_EXIT__;
- return __net_error_string_to_enum(ptr);
+ return __net_error_string_to_enum(str);
}
__NETWORK_FUNC_EXIT__;
MessageType = dbus_message_get_type(message);
if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
- const char* ptr = dbus_message_get_error_name(message);
+ const char* str = dbus_message_get_error_name(message);
const char* err_msg = _net_get_string(message);
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Error message received [%s] [%s]\n", ptr, err_msg);
+
+ NETWORK_LOG(NETWORK_ERROR, "message %s %s\n", str, err_msg);
__NETWORK_FUNC_EXIT__;
return __net_netconfig_error_string_to_enum(err_msg);
}
int callback_flag = FALSE;
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];
+ 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];
DBusMessage *reply = dbus_pending_call_steal_reply(call);
net_err_t Error = _net_get_error_from_message(reply);
if (Error == NET_ERR_NONE)
goto done;
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Connection open failed. Error code : [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Connection open failed. Error [%d]\n", Error);
if (open_info->flag == TRUE) {
- net_device_t device_type = _net_get_tech_type_from_path(open_info->ProfileName);
+ net_device_t device_type =
+ _net_get_tech_type_from_path(open_info->ProfileName);
- if (Error == NET_ERR_IN_PROGRESS &&
- device_type == NET_DEVICE_CELLULAR)
+ if (Error == NET_ERR_IN_PROGRESS && device_type == NET_DEVICE_CELLULAR)
goto done;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX + 1, "%s",
- open_info->ProfileName);
-
+ g_strlcpy(event_data.ProfileName, open_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
memset(open_info, 0, sizeof(network_request_table_t));
event_data.Error = Error;
event_data.Error = NET_ERR_NONE;
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! net_get_profile_info() failed [%s]\n",
- _net_print_error(Error));
+ NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info [%s]\n",
+ _net_print_error(Error));
+
event_data.Datalength = 0;
event_data.Data = NULL;
} else {
callback_flag = TRUE;
} else if (wps_info->flag == TRUE) {
-
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX + 1, "%s",
- wps_info->ProfileName);
-
+ g_strlcpy(event_data.ProfileName, wps_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
memset(wps_info, 0, sizeof(network_request_table_t));
event_data.Error = Error;
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,
- "Error!!! net_get_profile_info() failed [%s]\n",
- _net_print_error(Error));
+ NETWORK_LOG(NETWORK_ERROR, "Fail to get profile info [%s]\n",
+ _net_print_error(Error));
+
event_data.Datalength = 0;
event_data.Data = NULL;
} else {
int callback_flag = FALSE;
net_event_info_t event_data = {0,};
- network_request_table_t *close_info = &request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
+ network_request_table_t *close_info =
+ &request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
DBusMessage *reply = dbus_pending_call_steal_reply(call);
net_err_t Error = _net_get_error_from_message(reply);
if (Error == NET_ERR_NONE)
goto done;
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Connection close failed. Error code : [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Connection close failed. Error [%d]\n", Error);
if (close_info->flag == TRUE) {
- net_device_t device_type = _net_get_tech_type_from_path(close_info->ProfileName);
+ 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)
Error = NET_ERR_NONE;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX + 1, "%s",
- close_info->ProfileName);
-
+ g_strlcpy(event_data.ProfileName, close_info->ProfileName,
+ NET_PROFILE_NAME_LEN_MAX + 1);
memset(close_info, 0, sizeof(network_request_table_t));
event_data.Error = Error;
event_data.Datalength = 0;
event_data.Data = NULL;
event_data.Event = NET_EVENT_CLOSE_RSP;
+
NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP Error = %s\n",
_net_print_error(event_data.Error));
net_event_info_t event_data = {0,};
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Wifi Power on/off failed. Error code : [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR,
+ "Wi-Fi power operation failed. Error [%d]\n", Error);
if (Error != NET_ERR_WIFI_DRIVER_LOAD_INPROGRESS) {
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
0, sizeof(network_request_table_t));
event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_WIFI_POWER_RSP wifi state : %d Error = %d\n",
- NetworkInfo.wifi_state, Error);
+ "Sending NET_EVENT_WIFI_POWER_RSP Wi-Fi: %d Error = %d\n",
+ NetworkInfo.wifi_state, Error);
event_data.Datalength = sizeof(net_wifi_state_t);
event_data.Data = &(NetworkInfo.wifi_state);
net_event_info_t event_data = {0,};
if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Find hidden AP failed. Error code : [%d]\n", Error);
+ NETWORK_LOG(NETWORK_ERROR, "Find hidden AP failed. Error [%d]\n", Error);
else
- NETWORK_LOG(NETWORK_LOW, "Hidden AP response received for AP.\n");
+ NETWORK_LOG(NETWORK_LOW, "Hidden AP found\n");
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
if (NET_ERR_NONE != Error) {
- /* An error occured. So lets reset specific scan request entry in the request table */
+ /* An error occurred.
+ * So lets reset specific scan request entry in the request table */
memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN],
0, sizeof(network_request_table_t));
}
event_data.Event = NET_EVENT_SPECIFIC_SCAN_RSP;
+
NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_SPECIFIC_SCAN_RSP wifi state : %d Error = %d\n",
- NetworkInfo.wifi_state, Error);
+ "Sending NET_EVENT_SPECIFIC_SCAN_RSP Wi-Fi: %d Error = %d\n",
+ NetworkInfo.wifi_state, Error);
event_data.Datalength = sizeof(net_wifi_state_t);
event_data.Data = &(NetworkInfo.wifi_state);
static char *__net_make_group_name(const char *ssid, const char *net_mode, const char *sec)
{
- char *buf;
+ char *buf = NULL;
+ char *pbuf = NULL;
const char *hidden_str = "hidden";
const char *g_sec;
char buf_tmp[32] = {0,};
return NULL;
if (NULL != ssid) {
+ pbuf = buf;
for (i = 0; i < ssid_len; i++) {
- snprintf(buf_tmp, 3, "%02x", ssid[i]);
- strcat(buf, buf_tmp);
+ g_snprintf(pbuf, 3, "%02x", ssid[i]);
+ pbuf += 2;
}
- } else {
- strcat(buf, hidden_str);
- }
+ } else
+ g_strlcat(buf, hidden_str,
+ actual_len + strlen(net_mode) + strlen(sec) + 3);
- snprintf(buf_tmp, 32, "_%s_%s", net_mode, g_sec);
- strcat(buf, buf_tmp);
+ g_snprintf(buf_tmp, 32, "_%s_%s", net_mode, g_sec);
+ g_strlcat(buf, buf_tmp,
+ actual_len + strlen(net_mode) + strlen(sec) + 3);
NETWORK_LOG(NETWORK_HIGH, "Group name : %s\n", buf);
ch = strchr(args, ':');
if (ch == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter[\"%s\"]\n", args);
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter[\"%s\"]\n", args);
return NET_ERR_INVALID_PARAM;
}
*ch = 0; ch++;
- if (strcmp(args, CONNMAN_CLIENT_DBUS_TYPE_STRING) == 0) {
+ if (strcmp(args, CONNMAN_CLIENT_DBUS_TYPE_STRING) == 0)
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ch);
- } else if (strcmp(args, CONNMAN_CLIENT_DBUS_TYPE_UINT32) == 0) {
+ else if (strcmp(args, CONNMAN_CLIENT_DBUS_TYPE_UINT32) == 0) {
uint32 = strtoul(ch, NULL, 0);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &uint32);
} else if (strcmp(args, CONNMAN_CLIENT_DBUS_TYPE_VARIANT) == 0) {
args = ch;
ch = strchr(args, ':');
if (ch == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid data format[\"%s\"]\n", args);
+ NETWORK_LOG(NETWORK_ERROR, "Invalid data format[\"%s\"]\n", args);
return NET_ERR_INVALID_PARAM;
}
*ch = 0; ch++;
dbus_message_iter_append_basic(&container_iter, DBUS_TYPE_STRING, &ch);
dbus_message_iter_close_container(&iter, &container_iter);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Not supported data format[\"%s\"]\n", args);
+ NETWORK_LOG(NETWORK_ERROR, "Not supported data format[\"%s\"]\n", args);
return NET_ERR_INVALID_PARAM;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Not supported data format[\"%s\"]\n", args);
+ NETWORK_LOG(NETWORK_ERROR, "Not supported data format[\"%s\"]\n", args);
return NET_ERR_INVALID_PARAM;
}
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &value);
dbus_message_iter_close_container(dict, &entry);
}
+
/*****************************************************************************
* Global Functions Definition
*****************************************************************************/
-
DBusMessage *_net_invoke_dbus_method(const char* dest, const char* path,
- char* interface_name, char* method, char *param_array[], int *dbus_error)
+ char* interface_name, char* method,
+ char* param_array[], int* dbus_error)
{
__NETWORK_FUNC_ENTER__;
*dbus_error = NET_ERR_NONE;
- NETWORK_LOG(NETWORK_HIGH, "[DBUS Sync] %s.%s, %s\n", interface_name, method, path);
+ NETWORK_LOG(NETWORK_HIGH, "[DBUS Sync] %s.%s, %s\n",
+ interface_name, method, path);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
+
*dbus_error = NET_ERR_UNKNOWN;
+
__NETWORK_FUNC_EXIT__;
return NULL;
}
message = dbus_message_new_method_call(dest, path, interface_name, method);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
+
dbus_connection_unref(conn);
*dbus_error = NET_ERR_UNKNOWN;
+
__NETWORK_FUNC_EXIT__;
return NULL;
}
if (__net_append_param(message, param_array) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_param() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "__net_append_param() failed\n");
+
dbus_message_unref(message);
dbus_connection_unref(conn);
+
*dbus_error = NET_ERR_INVALID_PARAM;
+
__NETWORK_FUNC_EXIT__;
return NULL;
}
dbus_error_init(&error);
- reply = dbus_connection_send_with_reply_and_block(conn, message, DBUS_REPLY_TIMEOUT, &error);
+ reply = dbus_connection_send_with_reply_and_block(conn, message,
+ DBUS_REPLY_TIMEOUT, &error);
if (reply == NULL) {
if (dbus_error_is_set(&error) == TRUE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed. dbus error [%s: %s]\n",
- error.name, error.message);
+ "dbus_connection_send_with_reply_and_block() failed."
+ "error [%s: %s]\n", error.name, error.message);
+
*dbus_error = __net_error_string_to_enum(error.name);
dbus_error_free(&error);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_send_with_reply_and_block() failed\n");
+ NETWORK_LOG(NETWORK_ERROR,
+ "dbus_connection_send_with_reply_and_block() failed\n");
+
*dbus_error = NET_ERR_UNKNOWN;
}
dbus_message_unref(message);
dbus_connection_unref(conn);
+
__NETWORK_FUNC_EXIT__;
return NULL;
}
}
int _net_invoke_dbus_method_nonblock(const char* dest, const char* path,
- char* interface_name, char* method, DBusPendingCallNotifyFunction notify_func)
+ char* interface_name, char* method,
+ DBusPendingCallNotifyFunction notify_func)
{
__NETWORK_FUNC_ENTER__;
- DBusConnection* conn = NULL;
+ DBusConnection *conn = NULL;
DBusMessage *message = NULL;
DBusPendingCall *call;
dbus_bool_t result;
- NETWORK_LOG(NETWORK_HIGH, "[DBUS Async] %s.%s, %s\n", interface_name, method, path);
+ NETWORK_LOG(NETWORK_HIGH, "[DBUS Async] %s.%s, %s\n",
+ interface_name, method, path);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
message = dbus_message_new_method_call(dest, path, interface_name, method);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() Failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() Failed\n");
+
dbus_connection_unref(conn);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- result = dbus_connection_send_with_reply(conn, message, &call, DBUS_REPLY_TIMEOUT);
-
+ result = dbus_connection_send_with_reply(conn, message, &call,
+ DBUS_REPLY_TIMEOUT);
if (result == FALSE || call == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_send_with_reply() Failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_connection_send_with_reply() Failed\n");
+
dbus_message_unref(message);
dbus_connection_unref(conn);
+
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
- network_dbus_pending_call_data.pcall = call;
- network_dbus_pending_call_data.is_used = TRUE;
+ if (notify_func == NULL)
+ dbus_pending_call_cancel(call);
+ else {
+ dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
+
+ network_dbus_pending_call_data.pcall = call;
+ network_dbus_pending_call_data.is_used = TRUE;
+ }
dbus_message_unref(message);
dbus_connection_unref(conn);
if (Error == NET_ERR_IN_PROGRESS)
Error = NET_ERR_NONE;
- if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_invoke_dbus_method_nonblock failed\n");
-
__NETWORK_FUNC_EXIT__;
return Error;
}
net_err_t Error = NET_ERR_NONE;
- Error = _net_invoke_dbus_method_nonblock(TELEPHONY_SERVCE,
+ Error = _net_invoke_dbus_method_nonblock(TELEPHONY_SERVICE,
profile_name, TELEPHONY_PROFILE_INTERFACE,
"SetDefaultConnection", __net_set_default_reply);
NETCONFIG_WIFI_INTERFACE, "SetBgscan", param_array, &Error);
if (Error != NET_ERR_NONE)
- NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_invoke_dbus_method failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
if (message)
dbus_message_unref(message);
DBusMessage *message = NULL;
if ((tech_state == NULL) || (strlen(tech_state->technology) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- if (strcmp(tech_state->technology, "wifi") == 0) {
- int hotspot_state = 0;
- vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
-
- if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
- goto done;
- }
-
message = _net_invoke_dbus_method(CONNMAN_SERVICE,
CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
"GetTechnologies", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to get technology info\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get technology info\n");
goto done;
}
network_tech_state_info_t tech_state = {{0,},};
if (device_type == NET_DEVICE_WIFI)
- snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "wifi");
+ g_strlcpy(tech_state.technology, "wifi", NET_TECH_LENGTH_MAX);
else if (device_type == NET_DEVICE_CELLULAR)
- snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "cellular");
+ g_strlcpy(tech_state.technology, "cellular", NET_TECH_LENGTH_MAX);
else if (device_type == NET_DEVICE_ETHERNET)
- snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "ethernet");
+ g_strlcpy(tech_state.technology, "ethernet", NET_TECH_LENGTH_MAX);
else if (device_type == NET_DEVICE_BLUETOOTH)
- snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "bluetooth");
+ g_strlcpy(tech_state.technology, "bluetooth", NET_TECH_LENGTH_MAX);
else {
Error = NET_ERR_INVALID_PARAM;
goto done;
Error = _net_dbus_get_technology_state(&tech_state);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! _net_dbus_get_technology_state() failed. Error [%s]\n",
+ "_net_dbus_get_technology_state() failed. Error [%s]\n",
_net_print_error(Error));
goto done;
}
method = "GetWifiTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
return NET_ERR_INVALID_PARAM;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
return NET_ERR_INVALID_PARAM;
}
NETCONFIG_SERVICE, NETCONFIG_STATISTICS_PATH,
NETCONFIG_STATISTICS_INTERFACE, method, NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to get service properties\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties\n");
return Error;
}
method = "ResetCellularTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
return NET_ERR_INVALID_PARAM;
}
} else if (device_type == NET_DEVICE_WIFI) {
method = "ResetWifiTotalTxBytes";
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
return NET_ERR_INVALID_PARAM;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
return NET_ERR_INVALID_PARAM;
}
NETCONFIG_SERVICE, NETCONFIG_STATISTICS_PATH,
NETCONFIG_STATISTICS_INTERFACE, method, NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to get service properties\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service properties\n");
return Error;
}
}
net_state = _net_get_string(message);
- snprintf(state, CONNMAN_STATE_STRLEN, "%s", net_state);
+ g_strlcpy(state, net_state, CONNMAN_STATE_STRLEN);
- NETWORK_LOG( NETWORK_HIGH, "State: %s\n", state);
+ NETWORK_LOG(NETWORK_HIGH, "State: %s\n", state);
dbus_message_unref(message);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (NULL == conn) {
- NETWORK_LOG(NETWORK_ERROR, "Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
"CreateConfig");
if (NULL == message) {
- NETWORK_LOG( NETWORK_ERROR, "dbus_message_new_method_call() "
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() "
"failed\n");
dbus_connection_unref(conn);
__NETWORK_FUNC_EXIT__;
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (NULL == conn) {
- NETWORK_LOG(NETWORK_ERROR, "Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
NETCONFIG_WIFI_PATH, CONNMAN_AGENT_INTERFACE,
"SetField");
if (NULL == message) {
- NETWORK_LOG( NETWORK_ERROR, "dbus_message_new_method_call() "
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() "
"failed\n");
dbus_connection_unref(conn);
__NETWORK_FUNC_EXIT__;
wifi_connection_info->mode,
wifi_connection_info->security);
if (NULL == grp_name) {
- NETWORK_LOG(NETWORK_ERROR, "Error! can't make a group name\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to make a group name\n");
NET_MEMFREE(hidden_grp_name);
return NET_ERR_UNKNOWN;
}
- Error = _net_get_profile_list(NET_DEVICE_WIFI, &profile_info,
- &profile_count);
+ 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_print_error(Error));
+
goto done;
} else {
for (i = 0; i < profile_count; i++) {
/* Caching the group_name which has 'ssid' in hex, as the connection
* response contains the profile with 'ssid' */
- snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", grp_name);
+ g_strlcpy(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+ grp_name, NET_PROFILE_NAME_LEN_MAX+1);
Error = _net_dbus_open_connection(profile_info[i].ProfileName);
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR,
- "_net_dbus_open_connection fail, Error [%s]\n",
+ "Failed to request open connection, Error [%s]\n",
_net_print_error(Error));
- if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
- 0, sizeof(network_request_table_t));
-
- goto done;
- }
-
- NETWORK_LOG(NETWORK_HIGH, "Sent Connect request\n");
+ 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);
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- DBusError error;
+ DBusError error;
+
const char *manual_method = "manual";
const char *dhcp_method = "dhcp";
const char *off_method = "off";
DBusConnection* conn = NULL;
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- snprintf(ip_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
- inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4));
+ g_strlcpy(ip_buffer,
+ inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4),
+ NETPM_IPV4_STR_LEN_MAX + 1);
- snprintf(netmask_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
- inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4));
+ g_strlcpy(netmask_buffer,
+ inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4),
+ NETPM_IPV4_STR_LEN_MAX + 1);
- snprintf(gateway_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
- inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4));
+ g_strlcpy(gateway_buffer,
+ inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4),
+ NETPM_IPV4_STR_LEN_MAX + 1);
- NETWORK_LOG(NETWORK_HIGH, "ipaddress : %s, netmask : %s, gateway : %s\n",
+ NETWORK_LOG(NETWORK_HIGH, "ipaddress: %s, netmask: %s, gateway: %s\n",
ipaddress, netmask, gateway);
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
message = dbus_message_new_method_call(CONNMAN_SERVICE,
profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
if (message == NULL) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
dbus_connection_unref(conn);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", CONNMAN_SERVICE,
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2: %s %s %s %s\n", CONNMAN_SERVICE,
profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
dbus_message_iter_init_append(message, &itr);
dbus_message_iter_close_container(&entry, &sub_variant);
dbus_message_iter_close_container(&dict, &entry);
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s %s\n", prop_method, dhcp_method);
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2: %s %s\n", prop_method, dhcp_method);
} else if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_OFF) {
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
dbus_message_iter_close_container(&entry, &sub_variant);
dbus_message_iter_close_container(&dict, &entry);
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s %s\n", prop_method, off_method);
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2: %s %s\n", prop_method, off_method);
} else if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
dbus_message_iter_close_container(&dict, &entry);
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s %s %s %s %s %s %s %s\n",
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2: %s %s %s %s %s %s %s %s\n",
prop_method, manual_method, prop_address, ipaddress,
prop_netmask, netmask, prop_gateway, gateway);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (reply == NULL) {
if (dbus_error_is_set (&error) == TRUE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
- error.name,
- error.message);
+ "dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+ error.name, error.message);
Error = __net_error_string_to_enum(error.name);
- dbus_error_free(&error);
+ dbus_error_free(&error);
dbus_message_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- DBusError error;
+ DBusError error;
const char *prop_nameserver_configuration = "Nameservers.Configuration";
char dns_buffer[NET_DNS_ADDR_MAX][NETPM_IPV4_STR_LEN_MAX+1];
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0) ||
(prof_info->ProfileInfo.Wlan.net_info.DnsCount > NET_DNS_ADDR_MAX)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
dns_address[i] = NULL;
if (prof_info->ProfileInfo.Wlan.net_info.DnsAddr[i].Data.Ipv4.s_addr != 0)
- snprintf(dns_buffer[i], NETPM_IPV4_STR_LEN_MAX + 1, "%s",
- inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.DnsAddr[i].Data.Ipv4));
+ g_strlcpy(dns_buffer[i],
+ inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.DnsAddr[i].Data.Ipv4),
+ NETPM_IPV4_STR_LEN_MAX + 1);
dns_address[i] = dns_buffer[i];
}
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
if (message == NULL) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_message_new_method_call() failed\n");
+ "dbus_message_new_method_call() failed\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
if (reply == NULL) {
if (dbus_error_is_set (&error) == TRUE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
- error.name,
- error.message);
+ "dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+ error.name, error.message);
Error = __net_error_string_to_enum(error.name);
dbus_error_free(&error);
dbus_message_unref(message);
net_err_t Error = NET_ERR_NONE;
DBusError error;
- const char *direct_method = "direct"; /* not method[] as gcc screws it with dbus */
- const char *auto_method = "auto"; /* not method[] as gcc screws it with dbus */
- const char *manual_method = "manual"; /* not method[] as gcc screws it with dbus */
+ const char *direct_method = "direct";
+ const char *auto_method = "auto";
+ const char *manual_method = "manual";
const char *prop_proxy_configuration = "Proxy.Configuration";
const char *prop_method = "Method";
DBusConnection* conn = NULL;
if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- snprintf(proxy_buffer, NET_PROXY_LEN_MAX + 1, "%s", prof_info->ProfileInfo.Wlan.net_info.ProxyAddr);
+ g_strlcpy(proxy_buffer,
+ prof_info->ProfileInfo.Wlan.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);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
message = dbus_message_new_method_call(CONNMAN_SERVICE, profile_name,
CONNMAN_SERVICE_INTERFACE, "SetProperty");
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
if (reply == NULL) {
if (dbus_error_is_set(&error) == TRUE) {
- NETWORK_LOG( NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
- error.name,
- error.message);
+ NETWORK_LOG(NETWORK_ERROR,
+ "dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+ error.name, error.message);
Error = __net_error_string_to_enum(error.name);
- dbus_error_free(&error);
+ dbus_error_free(&error);
dbus_message_unref(message);
__NETWORK_FUNC_EXIT__;
return Error;
dbus_message_unref(reply);
dbus_message_unref(message);
- NETWORK_LOG( NETWORK_HIGH, "Successfully configured Proxy.Configuration\n");
+ NETWORK_LOG(NETWORK_HIGH, "Successfully configured Proxy.Configuration\n");
dbus_connection_unref(conn);
DBusConnection* conn = NULL;
if (prof_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
/** Create message */
- message = dbus_message_new_method_call(TELEPHONY_SERVCE,
+ message = dbus_message_new_method_call(TELEPHONY_SERVICE,
TELEPHONY_MASTER_PATH, TELEPHONY_MASTER_INTERFACE, "AddProfile");
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
dbus_connection_unref(conn);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVCE,
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVICE,
TELEPHONY_MASTER_PATH, TELEPHONY_MASTER_INTERFACE, ".AddProfile");
dbus_message_iter_init_append(message, &iter);
DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
&dict);
- snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
+ 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",
}
if (prof_info->ProfileInfo.Pdp.AuthInfo.AuthType >= NET_PDP_AUTH_NONE &&
- prof_info->ProfileInfo.Pdp.AuthInfo.AuthType <= NET_PDP_AUTH_CHAP) {
- snprintf(buff_auth_type, 10, "%d", prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
+ prof_info->ProfileInfo.Pdp.AuthInfo.AuthType <= NET_PDP_AUTH_CHAP) {
+ g_snprintf(buff_auth_type, 10, "%d",
+ prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
+
temp_ptr = buff_auth_type;
NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
if (reply == NULL) {
if (dbus_error_is_set (&error) == TRUE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
- error.name,
- error.message);
+ "dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+ error.name, error.message);
Error = __net_error_string_to_enum(error.name);
dbus_error_free(&error);
dbus_message_unref(message);
DBusConnection* conn = NULL;
if ((prof_info == NULL) || (profile_name == NULL)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid argument\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid argument\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
/** Create message */
- message = dbus_message_new_method_call(TELEPHONY_SERVCE,
+ message = dbus_message_new_method_call(TELEPHONY_SERVICE,
profile_name, TELEPHONY_PROFILE_INTERFACE, "ModifyProfile");
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
dbus_connection_unref(conn);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVCE,
+ NETWORK_LOG(NETWORK_HIGH, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVICE,
profile_name, TELEPHONY_PROFILE_INTERFACE, ".ModifyProfile");
dbus_message_iter_init_append(message, &iter);
DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
&dict);
- snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
+ 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",
if (prof_info->ProfileInfo.Pdp.AuthInfo.AuthType >= NET_PDP_AUTH_NONE &&
prof_info->ProfileInfo.Pdp.AuthInfo.AuthType <= NET_PDP_AUTH_CHAP) {
- snprintf(buff_auth_type, 10, "%d", prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
+ g_snprintf(buff_auth_type, 10, "%d",
+ prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
temp_ptr = buff_auth_type;
NETWORK_LOG(NETWORK_HIGH, "DBus Message 2/2 : %s : %s\n",
if (reply == NULL) {
if (dbus_error_is_set (&error) == TRUE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
- error.name,
- error.message);
+ "dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+ error.name, error.message);
Error = __net_error_string_to_enum(error.name);
dbus_error_free(&error);
dbus_message_unref(message);
return Error;
}
-
int _net_dbus_load_wifi_driver(void)
{
__NETWORK_FUNC_ENTER__;
{
if (_net_dbus_is_pending_call_used()) {
dbus_pending_call_cancel(_net_dbus_get_pending_call());
+
_net_dbus_set_pending_call(NULL);
_net_dbus_set_pending_call_used(FALSE);
}
return FALSE;
}
- snprintf(event_data.ProfileName, NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+ 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;
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get a system bus\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
- message = dbus_message_new_method_call(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE, "RequestSpecificScan");
+ message = dbus_message_new_method_call(NETCONFIG_SERVICE,
+ NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+ "RequestSpecificScan");
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_message_new_method_call() failed\n");
+
dbus_connection_unref(conn);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
dbus_message_append_args(message, DBUS_TYPE_STRING, &ssid, NULL);
- result = dbus_connection_send_with_reply(conn, message, &call, 6 * DBUS_REPLY_TIMEOUT);
+ result = dbus_connection_send_with_reply(conn, message, &call,
+ 6 * DBUS_REPLY_TIMEOUT);
if (result == FALSE || call == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_send_with_reply() Failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_connection_send_with_reply() failed\n");
+
dbus_message_unref(message);
dbus_connection_unref(conn);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <dbus/dbus.h>
-
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <linux/if_ether.h>
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-
#include "network-internal.h"
#include "network-dbus-request.h"
*****************************************************************************/
/** set all request to FALSE (0) */
-network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = {{0, }, };
+network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = {{0,},};
struct {
pthread_mutex_t callback_mutex;
net_device_t device_type = NET_DEVICE_UNKNOWN;
- if (g_str_has_prefix(profile_name, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
+ if (g_str_has_prefix(profile_name,
+ CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
device_type = NET_DEVICE_WIFI;
- else if (g_str_has_prefix(profile_name, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
+ else if (g_str_has_prefix(profile_name,
+ CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
device_type = NET_DEVICE_CELLULAR;
- else if (g_str_has_prefix(profile_name, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
+ else if (g_str_has_prefix(profile_name,
+ CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
device_type = NET_DEVICE_ETHERNET;
- else if (g_str_has_prefix(profile_name, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
+ else if (g_str_has_prefix(profile_name,
+ CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
device_type = NET_DEVICE_BLUETOOTH;
__NETWORK_FUNC_EXIT__;
if (dbus_message_iter_get_arg_type(&value1) ==
DBUS_TYPE_BOOLEAN) {
dbus_message_iter_get_basic(&value1, &data);
- NETWORK_LOG(NETWORK_LOW, "key-[%s]-[%s]", key, data ? "True" : "False");
+ NETWORK_LOG(NETWORK_LOW, "key-[%s]-[%s]",
+ key, data ? "True" : "False");
- if (strcmp(key, "Powered") == 0) {
+ if (g_strcmp0(key, "Powered") == 0) {
if (data)
tech_state->Powered = TRUE;
else
tech_state->Powered = FALSE;
- } else if (strcmp(key, "Connected") == 0) {
+ } else if (g_strcmp0(key, "Connected") == 0) {
if (data)
tech_state->Connected = TRUE;
else
tech_state->Connected = FALSE;
- } else if (strcmp(key, "Tethering") == 0) {
+ } else if (g_strcmp0(key, "Tethering") == 0) {
/* For further use */
}
} else if (dbus_message_iter_get_arg_type(&value1) ==
case WLAN_SEC_MODE_WEP:
wifi_connection_info.security = g_strdup("wep");
- wifi_connection_info.passphrase = g_strdup(wifi_info->security_info.authentication.wep.wepKey);
+ wifi_connection_info.passphrase =
+ g_strdup(wifi_info->security_info.authentication.wep.wepKey);
break;
/** 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.passphrase = g_strdup(wifi_info->security_info.authentication.psk.pskKey);
+ wifi_connection_info.passphrase =
+ g_strdup(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.passphrase = g_strdup(wifi_info->security_info.authentication.psk.pskKey);
+ wifi_connection_info.passphrase =
+ g_strdup(wifi_info->security_info.authentication.psk.pskKey);
break;
case WLAN_SEC_MODE_IEEE8021X:
wifi_connection_info.security = g_strdup("ieee8021x");
wifi_connection_info.eap_type = g_strdup(
- __convert_eap_type_to_string(wifi_info->security_info.authentication.eap.eap_type));
+ __convert_eap_type_to_string(
+ wifi_info->security_info.authentication.eap.eap_type));
wifi_connection_info.eap_auth = g_strdup(
- __convert_eap_auth_to_string(wifi_info->security_info.authentication.eap.eap_auth));
+ __convert_eap_auth_to_string(
+ 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);
+ wifi_connection_info.identity =
+ g_strdup(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);
+ wifi_connection_info.password =
+ g_strdup(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);
+ wifi_connection_info.ca_cert_file =
+ g_strdup(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);
+ wifi_connection_info.client_cert_file =
+ g_strdup(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);
+ wifi_connection_info.private_key_file =
+ g_strdup(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);
+ wifi_connection_info.private_key_password =
+ g_strdup(wifi_info->security_info.authentication.eap.private_key_passwd);
break;
default:
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid security type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid security type\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
wifi_connection_info.private_key_file, wifi_connection_info.private_key_password);
}
- if ((Error = _net_dbus_connect_service(&wifi_connection_info)) != NET_ERR_NONE)
+ 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",
_net_print_error(Error));
else
network_tech_state_info_t tech_state = {{0,},};
net_wifi_state_t wifi_state = WIFI_UNKNOWN;
- snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "wifi");
+ 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,
- "Error!!! _net_dbus_get_technology_state() failed. Error [%s]\n",
+ "_net_dbus_get_technology_state() failed. Error [%s]\n",
_net_print_error(Error));
goto state_done;
}
memset(&request_table[i], 0, sizeof(network_request_table_t));
__NETWORK_FUNC_EXIT__;
-}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+}
\ No newline at end of file
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
+#include <ctype.h>
#include "network-internal.h"
#include "network-dbus-request.h"
profile_type != NET_DEVICE_CELLULAR &&
profile_type != NET_DEVICE_ETHERNET &&
profile_type != NET_DEVICE_BLUETOOTH)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
return NET_ERR_INVALID_PARAM;
}
__NETWORK_FUNC_ENTER__;
if (ProfInfo == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
DBusMessageIter iter, array;
if (ProfileName == NULL || ProfileInfo == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter!\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- result = _net_invoke_dbus_method(TELEPHONY_SERVCE, ProfileName->ProfileName,
+ result = _net_invoke_dbus_method(TELEPHONY_SERVICE, ProfileName->ProfileName,
TELEPHONY_PROFILE_INTERFACE, "GetProfile", NULL, &Error);
if (result == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_invoke_dbus_method failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
DBusMessageIter iter, array;
int count = 0;
- result = _net_invoke_dbus_method(TELEPHONY_SERVCE, TELEPHONY_MASTER_PATH,
+ result = _net_invoke_dbus_method(TELEPHONY_SERVICE, TELEPHONY_MASTER_PATH,
TELEPHONY_MASTER_INTERFACE, "GetProfileList", NULL, &Error);
if (result == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_invoke_dbus_method failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
}
if (profileList == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to allocate memory\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory\n");
*ProfileCount = 0;
dbus_message_unref(result);
__NETWORK_FUNC_EXIT__;
/* Get pdp profile list from telephony service */
Error = __net_telephony_get_profile_list(&ProfileList, &ProfileCount);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to get profile list from telephony service\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list from telephony service\n");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return Error;
}
if (ProfileList == NULL || ProfileCount <= 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! There is no PDP profiles\n");
+ NETWORK_LOG(NETWORK_ERROR, "There is no PDP profiles\n");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NO_SERVICE;
}
if (i >= ProfileCount) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! There is no matching PDP profiles\n");
+ NETWORK_LOG(NETWORK_ERROR, "There is no matching PDP profiles\n");
NET_MEMFREE(ProfileList);
__NETWORK_FUNC_EXIT__;
return NET_ERR_NO_SERVICE;
}
if (g_str_has_prefix(obj, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) {
- if (g_strrstr(obj + strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX), "hidden") != NULL)
+ if (g_strrstr(obj + strlen(CONNMAN_WIFI_SERVICE_PROFILE_PREFIX),
+ "hidden") != NULL)
goto get_next;
service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
count++;
}
+
get_next:
dbus_message_iter_next(array);
}
__NETWORK_FUNC_ENTER__;
if (message == NULL || array == NULL || service_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter \n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter \n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
if (network_type == NET_SERVICE_UNKNOWN)
found = TRUE;
- else if (network_type == NET_SERVICE_INTERNET && strcmp(suffix, net_suffix) == 0)
+ else if (network_type == NET_SERVICE_INTERNET &&
+ strcmp(suffix, net_suffix) == 0)
found = TRUE;
- else if (network_type == NET_SERVICE_MMS && strcmp(suffix, mms_suffix) == 0)
+ else if (network_type == NET_SERVICE_MMS &&
+ strcmp(suffix, mms_suffix) == 0)
found = TRUE;
- else if (network_type == NET_SERVICE_PREPAID_INTERNET && strcmp(suffix, pre_net_suffix) == 0)
+ else if (network_type == NET_SERVICE_PREPAID_INTERNET &&
+ strcmp(suffix, pre_net_suffix) == 0)
found = TRUE;
- else if (network_type == NET_SERVICE_PREPAID_MMS && strcmp(suffix, pre_mms_suffix) == 0)
+ else if (network_type == NET_SERVICE_PREPAID_MMS &&
+ strcmp(suffix, pre_mms_suffix) == 0)
found = TRUE;
- else if (network_type == NET_SERVICE_TETHERING && strcmp(suffix, tethering_suffix) == 0)
+ else if (network_type == NET_SERVICE_TETHERING &&
+ strcmp(suffix, tethering_suffix) == 0)
found = TRUE;
if (found == TRUE) {
- service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
+ 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");
return NET_ERR_UNKNOWN;
}
- g_strlcpy(service_info->ProfileName[count], obj, NET_PROFILE_NAME_LEN_MAX+1);
+ g_strlcpy(service_info->ProfileName[count], obj,
+ NET_PROFILE_NAME_LEN_MAX+1);
count++;
}
}
if (g_str_has_prefix(obj, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE) {
- service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
+ 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");
}
if (g_str_has_prefix(obj, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE) {
- service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
+ 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");
Error = __net_extract_wifi_services(message, &dict, &service_info);
break;
case NET_DEVICE_CELLULAR :
- Error = __net_extract_mobile_services(message, &dict, &service_info, NET_SERVICE_UNKNOWN);
+ Error = __net_extract_mobile_services(message, &dict, &service_info,
+ NET_SERVICE_UNKNOWN);
break;
case NET_DEVICE_ETHERNET :
Error = __net_extract_ethernet_services(message, &dict, &service_info);
}
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't extract services from received message\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to extract services from received message\n");
*profile_count = 0;
*profile_info = NULL;
__NETWORK_FUNC_EXIT__;
ProfilePtr = (net_profile_info_t*)malloc(service_info.num_of_services * sizeof(net_profile_info_t));
if (ProfilePtr == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to allocate memory\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to allocate memory\n");
for (i = 0; i < service_info.num_of_services; i++)
NET_MEMFREE(service_info.ProfileName[i]);
Error = __net_get_profile_info(service_info.ProfileName[i], &ProfileInfo);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to get service(profile) information. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service(profile) information. Error [%s]\n",
_net_print_error(Error));
NETWORK_LOG(NETWORK_HIGH, "Continuing with next profile\n");
net_info = &(ProfInfo->ProfileInfo.Bluetooth.net_info);
} else {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Invalid Profile type. [%d]\n", ProfInfo->profile_type);
+ "Invalid Profile type. [%d]\n", ProfInfo->profile_type);
return NET_ERR_INVALID_PARAM;
}
}
__NETWORK_FUNC_EXIT__;
-
return Error;
}
if (profileType == NET_DEVICE_WIFI) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_WIFI, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
} else if (profileType == NET_DEVICE_CELLULAR) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_CELLULAR, ProfInfo)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_mobile_info(&array, 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, "Error!!! Can't init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_ethernet_info(&array, 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, "Error!!! Can't init profile\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_extract_bluetooth_info(&array, ProfInfo);
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Not supported profile type\n");
+ NETWORK_LOG(NETWORK_ERROR, "Not supported profile type\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NOT_SUPPORTED;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Can't extract service information from received message\n");
+ "Failed to extract service information from received message\n");
+
__NETWORK_FUNC_EXIT__;
return Error;
}
__NETWORK_FUNC_EXIT__;
-
- return Error;
+ return Error;
}
-static int __net_get_profile_info(const char* ProfileName, net_profile_info_t* ProfInfo)
+static int __net_get_profile_info(
+ const char* ProfileName, net_profile_info_t* ProfInfo)
{
__NETWORK_FUNC_ENTER__;
return Error;
}
- message = _net_invoke_dbus_method(TELEPHONY_SERVCE, telephony_profile.ProfileName,
+ message = _net_invoke_dbus_method(TELEPHONY_SERVICE, telephony_profile.ProfileName,
TELEPHONY_PROFILE_INTERFACE, "SetDefaultConnection", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to set default cellular service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set default cellular service(profile)\n");
goto done;
}
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);
- snprintf(profilePath, NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+ g_strlcpy(profilePath, ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
/* Compare and Set 'Passphrase' */
if (ex_security_info->sec_mode == WLAN_SEC_MODE_WEP) {
if (strcmp(security_info->authentication.wep.wepKey,
- ex_security_info->authentication.wep.wepKey) != 0) {
+ ex_security_info->authentication.wep.wepKey) != 0) {
Error = _net_dbus_set_agent_fields(NULL,
- security_info->authentication.wep.wepKey);
+ security_info->authentication.wep.wepKey);
+
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field\n");
if (strcmp(security_info->authentication.psk.pskKey,
ex_security_info->authentication.psk.pskKey) != 0) {
Error = _net_dbus_set_agent_fields(NULL,
- security_info->authentication.psk.pskKey);
+ security_info->authentication.psk.pskKey);
+
if (NET_ERR_NONE != Error) {
NETWORK_LOG(NETWORK_ERROR, "Failed to set agent field\n");
/* 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 != ex_net_info->IpAddr.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 != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
-
+ (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 ||
+ 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, "Error!!! Can't set IPv4\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set IPv4\n");
__NETWORK_FUNC_EXIT__;
return Error;
Error = _net_dbus_set_profile_dns(ProfInfo, profilePath);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't set dns\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set DNS\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to Remove service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)\n");
goto done;
}
char connman_profile[NET_PROFILE_NAME_LEN_MAX+1] = "";
if (_net_is_valid_service_type(exProfInfo->ProfileInfo.Pdp.ServiceType) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
net_err_t Error = NET_ERR_NONE;
DBusMessage *message = NULL;
- message = _net_invoke_dbus_method(TELEPHONY_SERVCE, PdpProfName->ProfileName,
+ message = _net_invoke_dbus_method(TELEPHONY_SERVICE, PdpProfName->ProfileName,
TELEPHONY_PROFILE_INTERFACE, "RemoveProfile", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to Remove service(profile)\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to Remove service(profile)\n");
goto done;
}
__NETWORK_FUNC_ENTER__;
if (array == NULL || profile_name == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter \n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter \n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
continue;
}
- if (g_str_has_prefix(objPath, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
+ if (g_str_has_prefix(objPath,
+ CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
suffix = strrchr(objPath, '_');
if (strcmp(suffix, net_suffix) == 0)
int stringLen = 0;
if (ProfileName == NULL || strlen(ProfileName) <= strlen(profileHeader)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
__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, "Error!!! Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Profile name is invalid\n");
+ NETWORK_LOG(NETWORK_ERROR, "Profile name is invalid\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
return NET_ERR_NONE;
}
-int _net_get_profile_list(net_device_t device_type, net_profile_info_t** profile_info, int* profile_count)
+int _net_get_profile_list(net_device_t device_type,
+ net_profile_info_t** profile_info, int* profile_count)
{
__NETWORK_FUNC_ENTER__;
message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
if (message == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to get service(profile) list\n");
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get service(profile) list\n");
+
__NETWORK_FUNC_EXIT__;
return Error;
}
case NET_DEVICE_BLUETOOTH:
Error = __net_extract_services(message, device_type, profile_info, profile_count);
break;
+
default :
Error = NET_ERR_UNKNOWN;
break;
__NETWORK_FUNC_ENTER__;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
__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, "Error!!! failed to add service(profile). Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR, "Failed to add service(profile). Error [%s]\n",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
net_profile_info_t prof_info;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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, "Invalid Parameter\n");
__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,
- "Error!!! failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]\n",
_net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
prof_info.ProfileInfo.Wlan.security_info.sec_mode);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to delete service(profile). Error [%s]\n",
+ "Failed to delete service(profile). Error [%s]\n",
_net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_telephony_search_pdp_profile(wifi_prof_name.ProfileName, &pdp_prof_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]\n",
_net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
Error = __net_telephony_delete_profile(&pdp_prof_name);
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to delete service(profile). Error [%s]\n",
+ "Failed to delete service(profile). Error [%s]\n",
_net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
} else {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
- __NETWORK_FUNC_EXIT__;
+ __NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
EXPORT_API int net_get_profile_info(const char *profile_name, net_profile_info_t *prof_info)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
- if (_net_check_profile_name(profile_name) != NET_ERR_NONE || prof_info == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ if (prof_info == NULL ||
+ _net_check_profile_name(profile_name) != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+
__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,
- "Error!!! failed to get service(profile) information. Error [%s]\n",
- _net_print_error(Error));
-
+ "Failed to get service(profile) information. Error [%s]\n",
+ _net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
-
EXPORT_API int net_modify_profile(const char* profile_name, net_profile_info_t* prof_info)
{
__NETWORK_FUNC_ENTER__;
net_profile_info_t exProfInfo;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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,
- "Error!!! failed to get service(profile) information. Error [%s]\n",
+ "Failed to get service(profile) information. Error [%s]\n",
_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)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to modify service(profile) information. Error [%s]\n",
+ "Failed to modify service(profile) information. Error [%s]\n",
_net_print_error(Error));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
__NETWORK_FUNC_EXIT__;
-
return NET_ERR_NONE;
}
-
EXPORT_API int net_get_profile_list(net_device_t device_type, net_profile_info_t **profile_list, int *count)
{
__NETWORK_FUNC_ENTER__;
net_profile_info_t* profile_info = NULL;
if (count == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
device_type != NET_DEVICE_WIFI &&
device_type != NET_DEVICE_ETHERNET &&
device_type != NET_DEVICE_BLUETOOTH) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Not Supported\n");
+ NETWORK_LOG(NETWORK_ERROR, "Not Supported\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NOT_SUPPORTED;
}
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to get service(profile) list. Error [%s]\n",
+ "Failed to get service(profile) list. Error [%s]\n",
_net_print_error(Error));
NET_MEMFREE(profile_info);
net_err_t Error = NET_ERR_NONE;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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, "Invalid Parameter\n");
__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,
- "Error!!! failed to set default cellular service(profile). Error [%s]\n",
+ "Failed to set default cellular service(profile). Error [%s]\n",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
return NET_ERR_NONE;
}
+/*****************************************************************************
+ * ConnMan Wi-Fi Client Interface Async Function Definition
+ *****************************************************************************/
+
EXPORT_API int net_set_default_cellular_service_profile_async(const char *profile_name)
{
net_err_t Error = NET_ERR_NONE;
return NET_ERR_NONE;
}
-
-/*****************************************************************************
- * ConnMan Wi-Fi Client Interface Async Function Definition
- *****************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
#include <vconf.h>
+
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
-
#include "network-internal.h"
-#include "network-signal-handler.h"
#include "network-dbus-request.h"
-
-/*****************************************************************************
- * Macros and Typedefs
- *****************************************************************************/
-
-
-/*****************************************************************************
- * Local Functions Declaration
- *****************************************************************************/
-static DBusHandlerResult __net_signal_filter
- (DBusConnection *conn, DBusMessage *msg, void *user_data);
-
-static int __net_get_state(DBusMessage *msg, char *state, char *error);
-static int __net_handle_wifi_power_rsp(int value);
-static int __net_svc_error_string_to_enum(const char *error);
-static void __net_handle_svc_failure_ind(const char *profile_name, const char *svc_error);
-static void __net_handle_state_ind(const char* profile_name, net_state_type_t profile_state);
-static void __net_init_dbus_thread();
-
-/*****************************************************************************
- * Global Functions
- *****************************************************************************/
-
+#include "network-signal-handler.h"
/*****************************************************************************
* Extern Global Variables
extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
/*****************************************************************************
- * Extern Functions Declarations
- *****************************************************************************/
-
-/*****************************************************************************
* Global Variables
*****************************************************************************/
DBusConnection* signal_conn = NULL;
static net_state_type_t service_state_table[NET_DEVICE_MAX] = {NET_STATE_TYPE_UNKNOWN,};
+static int net_service_error = NET_ERR_NONE;
+
/*****************************************************************************
* Local Functions Definition
*****************************************************************************/
-static int __net_get_state(DBusMessage *msg, char *state, char *error)
+static int __net_get_dbus_property_changed_basic(DBusMessage *message,
+ char **key, int type, void *value)
{
- __NETWORK_FUNC_ENTER__;
+ int Error = NET_ERR_UNKNOWN_METHOD;
+ DBusMessageIter iter, iter_variant;
- char *key_name = NULL;
- char *svc_state = NULL;
- char *svc_error = NULL;
- DBusMessageIter iter, sub_iter;
- int Error = NET_ERR_UNKNOWN;
-
- /* Get state */
- dbus_message_iter_init(msg, &iter);
- int ArgType = dbus_message_iter_get_arg_type(&iter);
-
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
-
- dbus_message_iter_get_basic(&iter, &key_name);
- if (strcmp(key_name, "State") != 0)
- goto done;
-
- dbus_message_iter_next(&iter);
- ArgType = dbus_message_iter_get_arg_type(&iter);
- if (ArgType != DBUS_TYPE_VARIANT)
- goto done;
-
- dbus_message_iter_recurse(&iter, &sub_iter);
- ArgType = dbus_message_iter_get_arg_type(&sub_iter);
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
-
- dbus_message_iter_get_basic(&sub_iter, &svc_state);
- snprintf(state, strlen(svc_state) + 1, "%s", svc_state);
- Error = NET_ERR_NONE;
-
- /* Get error */
- dbus_message_iter_next(&iter);
- ArgType = dbus_message_iter_get_arg_type(&iter);
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
+ dbus_message_iter_init(message, &iter);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return Error;
- dbus_message_iter_get_basic(&iter, &key_name);
- if (strcmp(key_name, "Error") != 0)
- goto done;
+ dbus_message_iter_get_basic(&iter, key);
dbus_message_iter_next(&iter);
- ArgType = dbus_message_iter_get_arg_type(&iter);
- if (ArgType != DBUS_TYPE_VARIANT)
- goto done;
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+ return Error;
- dbus_message_iter_recurse(&iter, &sub_iter);
- ArgType = dbus_message_iter_get_arg_type(&sub_iter);
- if (ArgType != DBUS_TYPE_STRING)
- goto done;
+ dbus_message_iter_recurse(&iter, &iter_variant);
+ if (dbus_message_iter_get_arg_type(&iter_variant) != type)
+ return Error;
- dbus_message_iter_get_basic(&sub_iter, &svc_error);
- snprintf(error, strlen(svc_error) + 1, "%s", svc_error);
+ dbus_message_iter_get_basic(&iter_variant, value);
-done:
- __NETWORK_FUNC_EXIT__;
- return Error;
+ return NET_ERR_NONE;
}
static int __net_handle_services_changed_signal(DBusMessage* msg)
{
__NETWORK_FUNC_ENTER__;
+
net_event_info_t event_data = { 0, };
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)
{
__NETWORK_FUNC_ENTER__;
- int wifi_state_flag = 0;
net_event_info_t event_data = {0,};
- int hotspot_state = 0;
-
- vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
- if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
- }
- if (value == FALSE && NetworkInfo.wifi_state != WIFI_OFF) {
+ if (value == TRUE) {
+ NetworkInfo.wifi_state = WIFI_ON;
+ event_data.Error = NET_ERR_NONE;
+ } else {
NetworkInfo.wifi_state = WIFI_OFF;
- wifi_state_flag = 1;
event_data.Error = NET_ERR_NONE;
- if(request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
0, sizeof(network_request_table_t));
-
- } else if (value == TRUE && NetworkInfo.wifi_state != WIFI_ON) {
- NetworkInfo.wifi_state = WIFI_ON;
- wifi_state_flag = 1;
- event_data.Error = NET_ERR_NONE;
}
- if (wifi_state_flag != 0) {
- if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
- 0, sizeof(network_request_table_t));
+ if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+ 0, sizeof(network_request_table_t));
- event_data.Event = NET_EVENT_WIFI_POWER_RSP;
- NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_WIFI_POWER_RSP wifi state : %d\n",
- NetworkInfo.wifi_state);
- _net_dbus_clear_pending_call();
- } else {
- event_data.Event = NET_EVENT_WIFI_POWER_IND;
- NETWORK_LOG(NETWORK_LOW,
- "Sending NET_EVENT_WIFI_POWER_IND wifi state : %d\n",
- NetworkInfo.wifi_state);
- }
+ event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+ NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_RSP wifi state: %d\n",
+ NetworkInfo.wifi_state);
- event_data.Datalength = sizeof(net_wifi_state_t);
- event_data.Data = &(NetworkInfo.wifi_state);
- _net_client_callback(&event_data);
+ _net_dbus_clear_pending_call();
+ } else {
+ event_data.Event = NET_EVENT_WIFI_POWER_IND;
+ NETWORK_LOG(NETWORK_LOW, "NET_EVENT_WIFI_POWER_IND wifi state: %d\n",
+ 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__;
return NET_ERR_NONE;
}
+static wlan_security_mode_type_t __net_get_wlan_sec_mode(int security)
+{
+ switch (security) {
+ default:
+ return WLAN_SEC_MODE_NONE;
+ case 2:
+ return WLAN_SEC_MODE_WEP;
+ case 3:
+ return WLAN_SEC_MODE_WPA_PSK;
+ case 4:
+ return WLAN_SEC_MODE_IEEE8021X;
+ }
+}
+
static int __net_handle_specific_scan_resp(GSList *bss_info_list)
{
__NETWORK_FUNC_ENTER__;
NETWORK_LOG(NETWORK_LOW, "bss_info_list : 0x%x\n", bss_info_list);
event_data.Data = bss_info_list;
+
_net_client_callback(&event_data);
}
return NET_ERR_NONE;
}
-static int __net_svc_error_string_to_enum(const char *error)
+static int __net_handle_wifi_specific_scan_rsp(DBusMessage *msg)
{
- if (strcmp(error, "out-of-range") == 0)
- return NET_ERR_CONNECTION_OUT_OF_RANGE;
- else if (strcmp(error, "pin-missing") == 0)
- return NET_ERR_CONNECTION_PIN_MISSING;
- else if (strcmp(error, "dhcp-failed") == 0)
- return NET_ERR_CONNECTION_DHCP_FAILED;
- else if (strcmp(error, "connect-failed") == 0)
- return NET_ERR_CONNECTION_CONNECT_FAILED;
- else if (strcmp(error, "login-failed") == 0)
- return NET_ERR_CONNECTION_LOGIN_FAILED;
- else if (strcmp(error, "auth-failed") == 0)
- return NET_ERR_CONNECTION_AUTH_FAILED;
- else if (strcmp(error, "invalid-key") == 0)
- return NET_ERR_CONNECTION_INVALID_KEY;
+ net_err_t Error = NET_ERR_UNKNOWN_METHOD;
+ DBusMessageIter iter, array;
- return NET_ERR_UNKNOWN;
+ dbus_message_iter_init(msg, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ GSList *bss_info_list = NULL;
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, dict;
+ const char *key = NULL;
+ const char *ssid = NULL;
+ const int security = 0;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (g_strcmp0(key, "ssid"))
+ return Error;
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
+ dbus_message_iter_get_basic(&dict, &ssid);
+ NETWORK_LOG(NETWORK_LOW, "Got an ssid: %s", ssid);
+
+ dbus_message_iter_next(&array);
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_DICT_ENTRY)
+ return Error;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+ if (g_strcmp0(key, "security"))
+ return Error;
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
+ dbus_message_iter_get_basic(&dict, (void *)&security);
+ NETWORK_LOG(NETWORK_LOW, "with security: %d", security);
+
+ 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);
+
+ dbus_message_iter_next(&array);
+ }
+
+ NETWORK_LOG(NETWORK_LOW,
+ "Received the signal: %s with total bss count = %d(Error = %d)",
+ NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE,
+ g_slist_length(bss_info_list), Error);
+
+ __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);
+
+ return NET_ERR_NONE;
}
-static void __net_handle_svc_failure_ind(const char *profile_name, const char *svc_error)
+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,};
- char event_string[64] = {0,};
- char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+ event_data.Error = NET_ERR_NONE;
+ event_data.Event = NET_EVENT_NET_STATE_IND;
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
- strstr(profile_name, svc_name1) != NULL) {
+ 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",
+ profile_state, event_data.ProfileName);
+
+ _net_client_callback(&event_data);
+
+ __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_handle_failure_ind(const char *profile_name)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_event_info_t event_data = { 0, };
+
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ strstr(profile_name, svc_name1) != NULL) {
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_clear_pending_call();
} else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- strcmp(profile_name, svc_name2) == 0) {
-
+ strcmp(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_clear_pending_call();
} else {
__net_handle_state_ind(profile_name, NET_STATE_TYPE_FAILURE);
+
__NETWORK_FUNC_EXIT__;
return;
}
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+ g_strlcpy(event_data.ProfileName,
+ profile_name, NET_PROFILE_NAME_LEN_MAX+1);
- event_data.Error = __net_svc_error_string_to_enum(svc_error);
+ event_data.Error = net_service_error;
event_data.Datalength = 0;
event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "%s, Error : %d\n", event_string, event_data.Error);
+ net_service_error = NET_ERR_NONE;
+
+ NETWORK_LOG(NETWORK_ERROR, "State failure %d\n", event_data.Error);
_net_client_callback(&event_data);
__NETWORK_FUNC_EXIT__;
}
-static void __net_handle_state_ind(const char* profile_name, net_state_type_t profile_state)
+static int string2state(const char *state)
{
- __NETWORK_FUNC_ENTER__;
-
- 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));
-
- 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",
- profile_state, event_data.ProfileName);
-
- _net_client_callback(&event_data);
-
- __NETWORK_FUNC_EXIT__;
+ if (g_strcmp0(state, "idle") == 0)
+ return NET_STATE_TYPE_IDLE;
+ else if (g_strcmp0(state, "association") == 0)
+ return NET_STATE_TYPE_ASSOCIATION;
+ else if (g_strcmp0(state, "configuration") == 0)
+ return NET_STATE_TYPE_CONFIGURATION;
+ else if (g_strcmp0(state, "ready") == 0)
+ return NET_STATE_TYPE_READY;
+ else if (g_strcmp0(state, "online") == 0)
+ return NET_STATE_TYPE_ONLINE;
+ else if (g_strcmp0(state, "disconnect") == 0)
+ return NET_STATE_TYPE_DISCONNECT;
+ else if (g_strcmp0(state, "failure") == 0)
+ return NET_STATE_TYPE_FAILURE;
+
+ return NET_STATE_TYPE_UNKNOWN;
}
-static wlan_security_mode_type_t __net_get_wlan_sec_mode(int security)
+static int __net_handle_service_state_changed(DBusMessage *message,
+ const char *key, const char *state)
{
- switch (security) {
- default:
- return WLAN_SEC_MODE_NONE;
- case 2:
- return WLAN_SEC_MODE_WEP;
- case 3:
- return WLAN_SEC_MODE_WPA_PSK;
- case 4:
- return WLAN_SEC_MODE_IEEE8021X;
+ net_err_t Error = NET_ERR_NONE;
+ const char *sig_path = NULL;
+ net_state_type_t old_state, new_state;
+
+ net_event_info_t event_data = { 0, };
+ net_device_t device_type = NET_DEVICE_UNKNOWN;
+
+ sig_path = dbus_message_get_path(message);
+
+ device_type = _net_get_tech_type_from_path(sig_path);
+ if (device_type == NET_DEVICE_UNKNOWN)
+ return Error;
+
+ NETWORK_LOG(NETWORK_LOW, "[%s] %s\n", state, sig_path);
+
+ if (device_type == NET_DEVICE_WIFI && NetworkInfo.wifi_state == WIFI_OFF) {
+ NETWORK_LOG(NETWORK_LOW, "Wi-Fi is off\n");
+ return Error;
}
-}
-static DBusHandlerResult
-__net_signal_filter (DBusConnection* conn, DBusMessage* msg, void* user_data)
-{
- __NETWORK_FUNC_ENTER__;
+ old_state = service_state_table[device_type];
+ new_state = string2state(state);
- static char svc_state[CONNMAN_MAX_BUFLEN] = "";
- static char svc_error[CONNMAN_MAX_BUFLEN] = "";
- static char ProfileName[NET_PROFILE_NAME_LEN_MAX + 1] = "";
+ if (old_state == new_state)
+ return Error;
- static int open_connection_rsp_sent = FALSE;
+ service_state_table[device_type] = new_state;
- const char* sig_path = NULL;
- const char* svc_name1 = NULL;
- const char* svc_name2 = NULL;
- const char* svc_name3 = NULL;
+ switch (new_state) {
+ case NET_STATE_TYPE_IDLE:
+ case NET_STATE_TYPE_ASSOCIATION:
+ case NET_STATE_TYPE_CONFIGURATION:
+ __net_handle_state_ind(sig_path, new_state);
+ break;
- char* property = NULL;
- net_event_info_t event_data = {0,};
- net_err_t Error = NET_ERR_NONE;
- net_device_t device_type = NET_DEVICE_UNKNOWN;
+ case NET_STATE_TYPE_READY:
+ case NET_STATE_TYPE_ONLINE:
+ {
+ if (old_state != NET_STATE_TYPE_READY &&
+ old_state != NET_STATE_TYPE_ONLINE) {
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
- if (msg == NULL) {
- NETWORK_LOG(NETWORK_LOW, "Invalid Message. Ignore\n");
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+ strstr(sig_path, svc_name1) != NULL) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+ sizeof(network_request_table_t));
- if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- property = _net_get_string(msg);
- if(property == NULL) {
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- NETWORK_LOG(NETWORK_LOW, "[Manager : PropertyChanged] Property - [%s]\n", property);
+ event_data.Event = NET_EVENT_OPEN_RSP;
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_TECHNOLOGY_ADDED)) {
- NETWORK_LOG(NETWORK_LOW, "[Manager : TechnologyAdded]\n");
- } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_TECHNOLOGY_REMOVED)) {
- NETWORK_LOG(NETWORK_LOW, "[Manager : TechnologyRemoved]\n");
- } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
- CONNMAN_SIGNAL_SERVICES_CHANGED)) {
- NETWORK_LOG(NETWORK_LOW, "[Manager : ServicesChanged]\n");
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
- __net_handle_services_changed_signal(msg);
+ _net_dbus_clear_pending_call();
+ } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+ g_strcmp0(sig_path, svc_name2) == 0) {
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_t));
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE, NETCONFIG_SIGNAL_POWERON_COMPLETED)) {
- __net_handle_wifi_power_rsp(TRUE);
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE, NETCONFIG_SIGNAL_POWEROFF_COMPLETED)) {
- __net_handle_wifi_power_rsp(FALSE);
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE, NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE)) {
- DBusMessageIter iter, array;
- dbus_message_iter_init(msg, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- GSList *bss_info_list = NULL;
-
- /* The dbus message will be packed in this format: {{"ssid", <ssid name>}{"security", <security mode>}....}*/
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, dict;
- const char *key = NULL;
- const char *ssid = NULL;
- const int security = 0;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- if (g_strcmp0(key, "ssid")) {
- Error = NET_ERR_UNKNOWN;
- break;
- }
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &dict);
- dbus_message_iter_get_basic(&dict, &ssid);
- NETWORK_LOG(NETWORK_LOW, "Got an ssid: %s", ssid);
-
- dbus_message_iter_next(&array);
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_DICT_ENTRY) {
- Error = NET_ERR_UNKNOWN;
- break;
- }
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
- if (g_strcmp0(key, "security")) {
- Error = NET_ERR_UNKNOWN;
- break;
+ _net_dbus_clear_pending_call();
+ } else {
+ event_data.Event = NET_EVENT_OPEN_IND;
+
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_IND\n");
}
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &dict);
- dbus_message_iter_get_basic(&dict, (void *)&security);
- NETWORK_LOG(NETWORK_LOW, "with security: %d", security);
- 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);
+ 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",
+ _net_print_error(Error));
- dbus_message_iter_next(&array);
- }
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+ } else {
+ event_data.Datalength = sizeof(net_profile_info_t);
+ event_data.Data = &prof_info;
+ }
- NETWORK_LOG(NETWORK_LOW, "Received the signal: %s with total bss count = %d(Error = %d)", NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE, g_slist_length(bss_info_list), Error);
+ event_data.Error = Error;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
- __net_handle_specific_scan_resp(bss_info_list);
+ _net_client_callback(&event_data);
+ } else
+ __net_handle_state_ind(sig_path, new_state);
- /* Specific Scan response handled. Release/Destroy the list */
- g_slist_free_full(bss_info_list, g_free);
+ break;
+ }
+ case NET_STATE_TYPE_DISCONNECT:
+ {
+ const char *svc_name1 =
+ request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+ const char *svc_name2 =
+ request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+ const char *svc_name3 =
+ request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+ 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,
+ sizeof(network_request_table_t));
+
+ /** Send Open Resp */
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Event = NET_EVENT_OPEN_RSP;
+ 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_OPEN_RSP\n");
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE,
- CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
-#if 0
- char* prop_value = NULL;
- int value = FALSE;
-
- property = __net_get_property(msg, &prop_value, &value);
- if (property == NULL) {
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ _net_dbus_clear_pending_call();
- memset(ProfileName, 0, sizeof(ProfileName));
- _net_get_path(msg, ProfileName);
+ _net_client_callback(&event_data);
+ } else 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));
- NETWORK_LOG(NETWORK_LOW,
- "[Technology : PropertyChanged]"
- "Property-[%s] path [%s] state [%s]\n",
- property, ProfileName, prop_value);
-#endif
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
- property = _net_get_string(msg);
- if (property == NULL) {
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ /** Send WPS Resp */
+ event_data.Error = NET_ERR_OPERATION_ABORTED;
+ event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
- if(strcmp(property, "Strength") != 0) /** Ignore Strength signal */
- NETWORK_LOG(NETWORK_LOW, "[Service : PropertyChanged]"
- "Got Signal with value [%s]\n", property);
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
- if (strcmp(property, "State") == 0) {
- memset(ProfileName, 0, sizeof(ProfileName));
- _net_get_path(msg, ProfileName);
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
- device_type = _net_get_tech_type_from_path(ProfileName);
+ _net_dbus_clear_pending_call();
- if (device_type == NET_DEVICE_UNKNOWN) {
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ _net_client_callback(&event_data);
+ } else 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));
- sig_path = ProfileName;
+ /** Send Close Resp */
+ event_data.Error = Error;
+ event_data.Event = NET_EVENT_CLOSE_RSP;
+ g_strlcpy(event_data.ProfileName, sig_path, NET_PROFILE_NAME_LEN_MAX+1);
- memset(svc_state, 0, sizeof(svc_state));
- memset(svc_error, 0, sizeof(svc_error));
- __net_get_state(msg, svc_state, svc_error);
- NETWORK_LOG(NETWORK_LOW, "Current ConnMan svc_state [%s] and svc_error [%s] for ProfileName [%s]\n",
- svc_state, svc_error, ProfileName);
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
- if (device_type == NET_DEVICE_WIFI &&
- NetworkInfo.wifi_state == WIFI_OFF) {
- NETWORK_LOG(NETWORK_LOW, "Warning!! Wi-Fi is already off!!\n");
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;;
- }
+ NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP\n");
- if (strcmp(svc_state, "idle") == 0) {
- service_state_table[device_type] = NET_STATE_TYPE_IDLE;
- __net_handle_state_ind(ProfileName, NET_STATE_TYPE_IDLE);
- } else if (strcmp(svc_state, "association") == 0) {
- service_state_table[device_type] = NET_STATE_TYPE_ASSOCIATION;
- __net_handle_state_ind(ProfileName, NET_STATE_TYPE_ASSOCIATION);
- } else if (strcmp(svc_state, "configuration") == 0) {
- service_state_table[device_type] = NET_STATE_TYPE_CONFIGURATION;
- __net_handle_state_ind(ProfileName, NET_STATE_TYPE_CONFIGURATION);
- } else if (strcmp(svc_state, "ready") == 0 ||
- strcmp(svc_state, "online") == 0) {
- if (service_state_table[device_type] != NET_STATE_TYPE_READY &&
- service_state_table[device_type] != NET_STATE_TYPE_ONLINE) {
- svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
-
- if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
- strstr(sig_path, svc_name1) != NULL) {
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
- sizeof(network_request_table_t));
-
- event_data.Event = NET_EVENT_OPEN_RSP;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
- _net_dbus_clear_pending_call();
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- strcmp(sig_path, 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;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
- _net_dbus_clear_pending_call();
- } else {
- event_data.Event = NET_EVENT_OPEN_IND;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_IND\n");
- }
-
- net_profile_info_t prof_info;
- if ((Error = net_get_profile_info(ProfileName, &prof_info)) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! net_get_profile_info() failed [%s]\n",
- _net_print_error(Error));
- event_data.Datalength = 0;
- event_data.Data = NULL;
- } else {
- event_data.Datalength = sizeof(net_profile_info_t);
- event_data.Data = &prof_info;
- }
-
- event_data.Error = Error;
- snprintf(event_data.ProfileName, NET_PROFILE_NAME_LEN_MAX + 1, "%s", ProfileName);
- open_connection_rsp_sent = TRUE;
- _net_client_callback(&event_data);
- } else {
- if (strcmp(svc_state, "ready") == 0)
- __net_handle_state_ind(ProfileName, NET_STATE_TYPE_READY);
- else
- __net_handle_state_ind(ProfileName, NET_STATE_TYPE_ONLINE);
- }
-
- if (strcmp(svc_state, "ready") == 0)
- service_state_table[device_type] = NET_STATE_TYPE_READY;
- else
- service_state_table[device_type] = NET_STATE_TYPE_ONLINE;
- } else if (strcmp(svc_state, "disconnect") == 0) {
- svc_name1 = request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
- svc_name2 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
- svc_name3 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
-
- 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,
- sizeof(network_request_table_t));
-
- /** Send Open Resp */
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Event = NET_EVENT_OPEN_RSP;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
-
- event_data.Datalength = 0;
- event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
- _net_dbus_clear_pending_call();
- _net_client_callback(&event_data);
- } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
- strcmp(sig_path, svc_name3) == 0) {
- memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
- sizeof(network_request_table_t));
-
- /** Send WPS Resp */
- event_data.Error = NET_ERR_OPERATION_ABORTED;
- event_data.Event = NET_EVENT_WIFI_WPS_RSP;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
-
- event_data.Datalength = 0;
- event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
- _net_dbus_clear_pending_call();
- _net_client_callback(&event_data);
- } else if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
- strcmp(sig_path, svc_name1) == 0) {
- memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0,
- sizeof(network_request_table_t));
-
- /** Send Close Resp */
- event_data.Error = Error;
- event_data.Event = NET_EVENT_CLOSE_RSP;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
-
- event_data.Datalength = 0;
- event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP\n");
- _net_dbus_clear_pending_call();
- _net_client_callback(&event_data);
- } else {
- /** Send Close Ind */
- event_data.Error = Error;
- event_data.Event = NET_EVENT_CLOSE_IND;
- snprintf(event_data.ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
-
- event_data.Datalength = 0;
- event_data.Data = NULL;
- NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_IND\n");
- _net_client_callback(&event_data);
- }
-
- service_state_table[device_type] = NET_STATE_TYPE_DISCONNECT;
- } else if (strcmp(svc_state, "failure") == 0) {
- __net_handle_svc_failure_ind(sig_path, (char*)svc_error);
- service_state_table[device_type] = NET_STATE_TYPE_FAILURE;
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- } else if (strcmp(property, "Nameservers") == 0) {
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
- } else if (strcmp(property, "IPv4") == 0) {
- /** Ignore - compared for future use */
- } else if (strcmp(property, "Ethernet") == 0) {
- /** Ignore - compared for future use */
- } else if (strcmp(property, "Domains") == 0) {
- /** Ignore - compared for future use */
- } else if (strcmp(property, "IPv4.Configuration") == 0) {
- /** Ignore - compared for future use */
+ _net_dbus_clear_pending_call();
+
+ _net_client_callback(&event_data);
} else {
- /** Ignore - compared for future use */
+ /** 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);
}
- /* We have handled this message, don't pass it on */
- __NETWORK_FUNC_EXIT__;
- return DBUS_HANDLER_RESULT_HANDLED;
+ break;
}
+ case NET_STATE_TYPE_FAILURE:
+ __net_handle_failure_ind(sig_path);
+ break;
- if (dbus_message_is_signal(msg, CONNMAN_COUNTER_INTERFACE, "Usage")) {
- NETWORK_LOG(NETWORK_LOW, "Received [COUNTER_USAGE_SIGNAL] signal\n");
- } else if (dbus_message_is_signal(msg, CONNMAN_COUNTER_INTERFACE, "Release")) {
- NETWORK_LOG(NETWORK_LOW, "Received [COUNTER_RELEASE_SIGNAL] signal\n");
+ default:
+ Error = NET_ERR_UNKNOWN_METHOD;
+ break;
+ }
+
+ return Error;
+}
+
+static int string2error(const char *error)
+{
+ if (g_strcmp0(error, "out-of-range") == 0)
+ return NET_ERR_CONNECTION_OUT_OF_RANGE;
+ else if (g_strcmp0(error, "pin-missing") == 0)
+ return NET_ERR_CONNECTION_PIN_MISSING;
+ else if (g_strcmp0(error, "dhcp-failed") == 0)
+ return NET_ERR_CONNECTION_DHCP_FAILED;
+ else if (g_strcmp0(error, "connect-failed") == 0)
+ return NET_ERR_CONNECTION_CONNECT_FAILED;
+ else if (g_strcmp0(error, "login-failed") == 0)
+ return NET_ERR_CONNECTION_LOGIN_FAILED;
+ else if (g_strcmp0(error, "auth-failed") == 0)
+ return NET_ERR_CONNECTION_AUTH_FAILED;
+ else if (g_strcmp0(error, "invalid-key") == 0)
+ return NET_ERR_CONNECTION_INVALID_KEY;
+
+ return NET_ERR_UNKNOWN;
+}
+
+static int __net_handle_service_set_error(DBusMessage *message,
+ const char *key, const char *error)
+{
+ NETWORK_LOG(NETWORK_LOW, "[%s] %s\n", key, error);
+
+ net_service_error = string2error(error);
+
+ return NET_ERR_NONE;
+}
+
+static int __net_handle_service_property_changed(DBusMessage *message)
+{
+ int Error = NET_ERR_NONE;
+ char *key = NULL;
+ char *value = NULL;
+
+ Error = __net_get_dbus_property_changed_basic(message,
+ &key, DBUS_TYPE_STRING, &value);
+ if (Error != NET_ERR_NONE)
+ return Error;
+
+ if (g_strcmp0(key, "State") == 0) {
+ Error = __net_handle_service_state_changed(message, key, value);
+ } else if (g_strcmp0(key, "Error") == 0) {
+ Error = __net_handle_service_set_error(message, key, value);
+ } else if (g_strcmp0(key, "Nameservers") == 0) {
+ /** Ignore - compared for future use */
+ } else if (g_strcmp0(key, "IPv4") == 0) {
+ /** Ignore - compared for future use */
+ } else if (g_strcmp0(key, "Ethernet") == 0) {
+ /** Ignore - compared for future use */
+ } else if (g_strcmp0(key, "Domains") == 0) {
+ /** Ignore - compared for future use */
+ } else if (g_strcmp0(key, "IPv4.Configuration") == 0) {
+ /** Ignore - compared for future use */
+ } else {
+ /** Ignore - compared for future use */
+ }
+
+ return Error;
+}
+
+static DBusHandlerResult
+__net_signal_filter(DBusConnection* conn, DBusMessage* msg, void* user_data)
+{
+ if (msg == NULL)
+ return DBUS_HANDLER_RESULT_HANDLED;
+
+ if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED)) {
+ __net_handle_service_property_changed(msg);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE,
+ NETCONFIG_SIGNAL_POWERON_COMPLETED)) {
+ __net_handle_wifi_power_rsp(TRUE);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE,
+ NETCONFIG_SIGNAL_POWEROFF_COMPLETED)) {
+ __net_handle_wifi_power_rsp(FALSE);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ SIGNAL_PROPERTY_CHANGED)) {
+ /* reserved */
+ } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ SIGNAL_TECHNOLOGY_ADDED)) {
+ /* reserved */
+ } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ SIGNAL_TECHNOLOGY_REMOVED)) {
+ /* reserved */
+ } else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ SIGNAL_SERVICES_CHANGED)) {
+ __net_handle_services_changed_signal(msg);
+ /* reserved */
+ } else if (dbus_message_is_signal(msg, NETCONFIG_WIFI_INTERFACE,
+ NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE)) {
+ __net_handle_wifi_specific_scan_rsp(msg);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
- NETWORK_LOG(NETWORK_LOW, "Useless signal. Ignored !!!\n");
- __NETWORK_FUNC_EXIT__;
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static void __net_init_dbus_thread()
{
static dbus_bool_t init_required = TRUE;
+
if (init_required) {
dbus_g_thread_init();
init_required = FALSE;
/*****************************************************************************
* Global Functions
*****************************************************************************/
-
int _net_deregister_signal(void)
{
__NETWORK_FUNC_ENTER__;
dbus_error_init(&err);
if (signal_conn == NULL) {
- NETWORK_LOG(NETWORK_HIGH, "Already de-registered. Nothing to be done\n");
+ NETWORK_LOG(NETWORK_HIGH, "Already de-registered\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
dbus_bus_remove_match(signal_conn, CONNMAN_MANAGER_SIGNAL_FILTER, &err);
dbus_connection_flush(signal_conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Remove Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Remove Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_remove_match(signal_conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err);
dbus_connection_flush(signal_conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Remove Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Remove Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_remove_match(signal_conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
dbus_connection_flush(signal_conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Remove Match Error (%s)\n", err.message);
- dbus_error_free(&err);
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
- }
-
- dbus_bus_remove_match(signal_conn, CONNMAN_NETWORK_COUNTER_FILTER, &err);
- dbus_connection_flush(signal_conn);
- if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Remove Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Remove Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_remove_match(signal_conn, NETCONFIG_WIFI_FILTER, &err);
dbus_connection_flush(signal_conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Remove Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Remove Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_connection_remove_filter(signal_conn, __net_signal_filter, NULL);
NETWORK_LOG(NETWORK_HIGH, "dbus_connection_remove_filter() successful\n");
- NETWORK_LOG(NETWORK_LOW, "Successfully removed signal filter rules\n");
+ NETWORK_LOG(NETWORK_LOW, "Successfully remove signal filters\n");
/* If DBusPendingCall remains, it should be released */
- if (_net_dbus_is_pending_call_used() == TRUE) {
- _net_dbus_clear_pending_call();
- NETWORK_LOG(NETWORK_HIGH, "DBus pending call successfully removed\n");
- }
+ _net_dbus_clear_pending_call();
dbus_connection_unref(signal_conn);
signal_conn = NULL;
__net_init_dbus_thread();
dbus_error_init(&err);
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (conn == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to connect to the D-BUS daemon: [%s]\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR,
+ "Failed to connect to the D-BUS daemon: [%s]\n", err.message);
dbus_error_free(&err);
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
/** listening to messages from all objects as no path is specified */
/** see signals from the given interface */
- dbus_bus_add_match(conn, CONNMAN_MANAGER_SIGNAL_FILTER, &err);
+ dbus_bus_add_match(conn, CONNMAN_MANAGER_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Add Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Add Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_add_match(conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Add Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Add Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_add_match(conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Add Match Error (%s)\n", err.message);
- dbus_error_free(&err);
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_UNKNOWN;
- }
-
- dbus_bus_add_match(conn, CONNMAN_NETWORK_COUNTER_FILTER, &err);
- dbus_connection_flush(conn);
- if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Add Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Add Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
dbus_bus_add_match(conn, NETCONFIG_WIFI_FILTER, &err);
dbus_connection_flush(conn);
if (dbus_error_is_set(&err)) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Add Match Error (%s)\n", err.message);
+ NETWORK_LOG(NETWORK_ERROR, "Add Match Error (%s)\n", err.message);
dbus_error_free(&err);
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
if (dbus_connection_add_filter(conn, __net_signal_filter, NULL, NULL) == FALSE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_add_filter() failed\n");
+ NETWORK_LOG(NETWORK_ERROR, "dbus_connection_add_filter() failed\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_UNKNOWN;
}
-
- NETWORK_LOG(NETWORK_LOW, "Successfully set signal filter rules\n");
+
+ NETWORK_LOG(NETWORK_LOW, "Successfully register signal filters\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/*****************************************************************************
- * Standard headers
- *****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
#include <vconf.h>
-#include <dbus/dbus.h>
-
-/*****************************************************************************
- * Platform headers
- *****************************************************************************/
#include "network-internal.h"
-#include "network-signal-handler.h"
#include "network-dbus-request.h"
+#include "network-signal-handler.h"
/*****************************************************************************
* Macros and Typedefs
* Global Functions
*****************************************************************************/
-
/*****************************************************************************
* Extern Variables
*****************************************************************************/
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! failed to get service(profile) list. Error [%s]\n",
+ "Failed to get service(profile) list. Error [%s]\n",
_net_print_error(Error));
NET_MEMFREE(profile_info);
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Async API Definition
*****************************************************************************/
-
EXPORT_API int net_specific_scan_wifi(const char *ssid)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if (ssid == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Find hidden AP request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Find hidden AP request in progress\n");
__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");
+ if (_net_get_wifi_state() != WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+ 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_SPECIFIC_SCAN].flag = TRUE;
+
Error = _net_dbus_specific_scan_request(ssid);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_dbus_specific_scan_request() failed. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR,
+ "_net_dbus_specific_scan_request() failed. Error [%s]\n",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0, sizeof(network_request_table_t));
+ memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0,
+ sizeof(network_request_table_t));
}
__NETWORK_FUNC_EXIT__;
return Error;
}
-
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, "Error!!! Invalid parameter\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Connection open request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Connection open request in progress\n");
__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");
+ if (_net_get_wifi_state() != WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+ 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_OPEN_CONNECTION].flag = TRUE;
+
Error = _net_open_connection_with_wifi_info(wifi_info);
if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! net_open_connection_with_wifi_info() failed. Error [%s]\n",
+ NETWORK_LOG(NETWORK_ERROR,
+ "net_open_connection_with_wifi_info() failed. Error [%s]\n",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, sizeof(network_request_table_t));
+ 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)
{
__NETWORK_FUNC_ENTER__;
int hotspot_state = 0;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__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, "Error!!! Wi-Fi hotspot is enabled!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi hotspot is enabled!\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
if (NetworkInfo.wifi_state != WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! wifi is powered on already!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered on already!\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__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_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
Error = _net_dbus_load_wifi_driver();
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Failed to request wifi power on/off. Error [%s]\n",
+ "Failed to request Wi-Fi power on/off. Error [%s]\n",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, sizeof(network_request_table_t));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0,
+ sizeof(network_request_table_t));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
return NET_ERR_NONE;
}
-
EXPORT_API int net_wifi_power_off(void)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if(g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if(NetworkInfo.wifi_state == WIFI_OFF) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! wifi is powered off already!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off already!\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
- if (_net_dbus_is_pending_call_used() == TRUE &&
- request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! pending call already in progress\n");
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
- } else {
- _net_dbus_clear_pending_call();
- memset(request_table, 0, sizeof(request_table));
- }
+ _net_dbus_clear_pending_call();
+ memset(request_table, 0, sizeof(request_table));
request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
Error = _net_dbus_remove_wifi_driver();
if (Error != NET_ERR_NONE ) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Failed to request wifi power on/off. Error [%s]\n",
+ "Failed to request Wi-Fi power on/off. Error [%s]\n",
_net_print_error(Error));
+
memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, sizeof(network_request_table_t));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
return NET_ERR_NONE;
}
-
EXPORT_API int net_scan_wifi(void)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
- if(g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\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_SCAN].flag == TRUE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!! Request already in progress\n");
- __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");
+ if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_IN_PROGRESS;
}
if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi powered off!\n");
__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 {
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_OPERATION;
+ }
+ }
+
request_table[NETWORK_REQUEST_TYPE_SCAN].flag = TRUE;
- if ((Error = _net_dbus_scan_request()) != NET_ERR_NONE ) {
- NETWORK_LOG(NETWORK_ERROR,
- "Error!!! Failed to request scan. Error [%s]\n",
+ Error = _net_dbus_scan_request();
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to request scan. Error [%s]\n",
_net_print_error(Error));
- memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, sizeof(network_request_table_t));
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0,
+ sizeof(network_request_table_t));
+
__NETWORK_FUNC_EXIT__;
- return Error;;
+ return Error;
}
- NETWORK_LOG(NETWORK_HIGH, "Scan request was sent successfully to connman.\n");
+ NETWORK_LOG(NETWORK_HIGH, "Wi-Fi scan requested successfully\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
EXPORT_API int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+ NETWORK_LOG(NETWORK_ERROR, "Invalid profile name\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ 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, "Error!! Request already in progress\n");
+ NETWORK_LOG(NETWORK_ERROR, "Request in progress\n");
__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");
+ if (_net_get_wifi_state() != WIFI_ON) {
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
__NETWORK_FUNC_EXIT__;
- return NET_ERR_IN_PROGRESS;
+ return NET_ERR_INVALID_OPERATION;
}
- if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+ 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;
- snprintf(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
- NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+ 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) {
+ if (wps_info->type == WIFI_WPS_PBC) {
Error = _net_dbus_open_connection(profile_name);
- if(Error != NET_ERR_NONE)
- {
+ if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
- "Error!! Failed to request open connection, Error [%s]\n",
+ "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));
-
+
+ memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+ sizeof(network_request_table_t));
+
__NETWORK_FUNC_EXIT__;
return Error;
}
- }
- else if(wps_info->type == WIFI_WPS_PIN) {
+ } else if(wps_info->type == WIFI_WPS_PIN) {
// TODO: handle wps pin
- }
- else {
+ } else {
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
-
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-
/*****************************************************************************
* ConnMan Wi-Fi Client Interface Sync Function Definition
*****************************************************************************/
-
-
EXPORT_API int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name)
{
__NETWORK_FUNC_ENTER__;
net_wifi_state_t wifi_state;
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (profile_name == NULL) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! profile_name is NULL\n");
+ NETWORK_LOG(NETWORK_ERROR, "profile_name is NULL\n");
return NET_ERR_INVALID_PARAM;
}
return NET_ERR_NONE;
}
-
EXPORT_API int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
{
__NETWORK_FUNC_ENTER__;
net_err_t Error = NET_ERR_NONE;
-
+
if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
- NETWORK_LOG(NETWORK_ERROR, "Error!!! Application not registered\n");
+ NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_APP_NOT_REGISTERED;
}
if (_net_get_wifi_state() != WIFI_ON) {
- NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+ NETWORK_LOG(NETWORK_ERROR, "Wi-Fi is powered off!\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_OPERATION;
}
- NETWORK_LOG(NETWORK_HIGH, "BGScan Mode [%d]\n", scan_mode);
+ 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,
- "Error!!! Failed to set bgscan mode. Error [%s]\n",
+ "Failed to set bgscan mode. Error [%s]\n",
_net_print_error(Error));
__NETWORK_FUNC_EXIT__;
return Error;
}
-
- NETWORK_LOG(NETWORK_HIGH, "Set BGScan mode Request to connman is successfull\n");
-
- __NETWORK_FUNC_EXIT__;
- return NET_ERR_NONE;
-}
-#ifdef __cplusplus
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
}
-#endif /* __cplusplus */
-
/*
- * Network Client Library
+ * Network Client Library
*
* Copyright 2011-2013 Samsung Electronics Co., Ltd
-
+ *
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-
+ *
* http://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.
*
*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <dbus/dbus.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
-#include <network-pm-config.h>
+#include <glib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dbus/dbus.h>
#include <network-cm-intf.h>
#include <network-pm-intf.h>
#include <network-wifi-intf.h>
+#include <network-pm-config.h>
#define debug_print(format, args...) printf("[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
gwaddr = (unsigned char *)&bt_info->net_info.GatewayAddr.Data.Ipv4.s_addr;
net_info = &(bt_info->net_info);
} else {
- debug_print("Error!!! Invalid profile type\n");
+ debug_print("Invalid profile type\n");
return ;
}
Error = net_get_profile_list(NET_DEVICE_WIFI, &Profiles, &num_of_profile);
if (Error != NET_ERR_NONE) {
- debug_print("Error!!! failed to get service(profile) list. Error [%d]\n",
+ debug_print("Failed to get service(profile) list. Error [%d]\n",
Error);
} else {
- debug_print("network_dbus_get_scan_result() successfull\n");
+ debug_print("network_dbus_get_scan_result() successfully\n");
debug_print("........................Scan Table.......................\n");
__print_profile_list(num_of_profile, Profiles, PROFILE_BASIC_INFO);
debug_print(".........................................................\n");
debug_print("Activation Failed!\n");
break;
default:
- debug_print("Unknown Error!\n");
+ debug_print("Unknown Error\n");
break;
}
debug_print("Deactivation Failed!\n");
break;
default:
- debug_print("Unknown Error!\n");
+ debug_print("Unknown Error\n");
break;
}
break;
default :
- debug_print("Error! Unknown Event\n\n");
+ debug_print("Unknown Event\n\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_wifi_power_on() != NET_ERR_NONE) {
- debug_print("Error!! net_wifi_power_on() failed.\n");
+ debug_print("net_wifi_power_on() failed.\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_wifi_power_off() != NET_ERR_NONE ) {
- debug_print("Error!! net_wifi_power_off() failed.\n");
+ debug_print("net_wifi_power_off() failed.\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_scan_wifi() != NET_ERR_NONE ) {
- debug_print("Error!! net_scan_wifi() failed.\n");
+ debug_print("net_scan_wifi() failed.\n");
break;
}
if (net_wifi_set_background_scan_mode(input_int) != NET_ERR_NONE) {
debug_print(
- "Error!! network_wifi_set_scan_interval() failed.\n");
+ "network_wifi_set_scan_interval() failed.\n");
break;
}
break;
case '4':
- debug_print( "Enter Service Type(1:Internet, 2:MMS): \n");
+ debug_print("Enter Service Type(1:Internet, 2:MMS): \n");
scanf("%d", &input_int);
net_service_type_t service_type = NET_SERVICE_UNKNOWN;
if (service_type != NET_SERVICE_UNKNOWN) {
net_error = net_open_connection_with_preference(service_type);
if (net_error != NET_ERR_NONE) {
- debug_print(
- "Error!! net_open_connection_with_profile() failed.\n");
+ debug_print("net_open_connection_with_profile() failed.\n");
break;
}
}
if (net_open_connection_with_profile(ProfileName) != NET_ERR_NONE) {
debug_print(
- "Error!! net_open_connection_with_profile() failed.\n");
+ "net_open_connection_with_profile() failed.\n");
break;
}
if (net_close_connection(ProfileName) != NET_ERR_NONE) {
debug_print(
- "Error!! net_close_connection() failed.\n");
+ "net_close_connection() failed.\n");
break;
}
net_profile_name_t profile_name;
if (net_get_wifi_state(&wlanstate, &profile_name) != NET_ERR_NONE) {
- debug_print("Error!! net_get_wifi_state() failed.\n");
+ debug_print("net_get_wifi_state() failed.\n");
break;
}
break;
default :
debug_print("wlanstate : Unknown\n");
+ break;
}
break;
start_time = Convert_time2double(timevar);
if (net_get_network_status(device_type, &NetworkStatus) != NET_ERR_NONE) {
- debug_print("Error!!! net_get_network_status() failed\n");
+ debug_print("net_get_network_status() failed\n");
break;
}
switch (input_int) {
case 1:
if (net_get_active_net_info(&profile_info) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_net_info() failed\n");
+ debug_print("net_get_active_net_info() failed\n");
else
__network_print_profile(&profile_info, PROFILE_FULL_INFO);
break;
case 2:
if (net_get_active_ipaddress(&ip_address) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_ipaddress() failed\n");
+ debug_print("net_get_active_ipaddress() failed\n");
else
__network_print_ipaddress(&ip_address);
break;
case 3:
if (net_get_active_netmask(&ip_address) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_netmask() failed\n");
+ debug_print("net_get_active_netmask() failed\n");
else
__network_print_ipaddress(&ip_address);
break;
case 4:
if (net_get_active_gateway(&ip_address) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_gateway() failed\n");
+ debug_print("net_get_active_gateway() failed\n");
else
__network_print_ipaddress(&ip_address);
break;
case 5:
if (net_get_active_dns(&ip_address) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_dns() failed\n");
+ debug_print("net_get_active_dns() failed\n");
else
__network_print_ipaddress(&ip_address);
break;
case 6:
if (net_get_active_essid(&essid) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_essid() failed\n");
+ debug_print("net_get_active_essid() failed\n");
else
debug_print("Profile ESSID = [%s]\n", essid.essid);
break;
case 7:
if (net_get_active_proxy(&proxy) != NET_ERR_NONE)
- debug_print("Error!!! net_get_active_proxy() failed\n");
+ debug_print("net_get_active_proxy() failed\n");
else
debug_print("Profile Proxy = [%s]\n", proxy.proxy_addr);
break;
&profList, &profListCount);
if (net_error != NET_ERR_NONE) {
- debug_print("Error!!! net_get_profile_list() failed\n");
+ debug_print("net_get_profile_list() failed\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_get_profile_info(ProfileName, &profile_info) != NET_ERR_NONE) {
- debug_print("Error!!! net_get_profile_info() failed\n");
+ debug_print("net_get_profile_info() failed\n");
break;
}
net_error = net_get_profile_info(ProfileName, &profile_info);
if (net_error != NET_ERR_NONE) {
- debug_print("Error!!! net_get_profile_info() failed\n");
+ debug_print("net_get_profile_info() failed\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_modify_profile(ProfileName, &profile_info) != NET_ERR_NONE) {
- debug_print("Error!!! net_modify_profile() failed\n");
+ debug_print("net_modify_profile() failed\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_delete_profile(ProfileName) != NET_ERR_NONE) {
- debug_print("Error!!! net_delete_profile() failed\n");
+ debug_print("net_delete_profile() failed\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_add_profile(network_type, &profile_info) != NET_ERR_NONE) {
- debug_print("Error!!! net_add_profile() failed\n");
+ debug_print("net_add_profile() failed\n");
break;
}
net_error = net_open_connection_with_wifi_info(&wifi_info);
if (net_error != NET_ERR_NONE) {
- debug_print("Error!!! "
- "net_open_connection_with_wifi_info() failed.\n");
+ debug_print("net_open_connection_with_wifi_info() failed.\n");
break;
}
wps_info.type = WIFI_WPS_PBC;
if (net_wifi_enroll_wps(ProfileName, &wps_info) != NET_ERR_NONE) {
- debug_print("Error!! net_wifi_enroll_wps() failed.\n");
+ debug_print("net_wifi_enroll_wps() failed.\n");
break;
}
if (user_sel == 1) {
if (net_set_default_cellular_service_profile(ProfileName) != NET_ERR_NONE) {
- debug_print("Error!! net_set_default_cellular_service_profile() failed.\n");
+ debug_print("net_set_default_cellular_service_profile() failed.\n");
break;
}
} else {
if (net_set_default_cellular_service_profile_async(ProfileName) != NET_ERR_NONE) {
- debug_print("Error!! net_set_default_cellular_service_profile_async() failed.\n");
+ debug_print("net_set_default_cellular_service_profile_async() failed.\n");
break;
}
}
start_time = Convert_time2double(timevar);
if (net_add_route(ip_addr, if_name) != NET_ERR_NONE) {
- debug_print("Error!! net_add_route() failed.\n");
+ debug_print("net_add_route() failed.\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_remove_route(ip_addr, if_name) != NET_ERR_NONE) {
- debug_print("Error!! net_remove_route() failed.\n");
+ debug_print("net_remove_route() failed.\n");
break;
}
start_time = Convert_time2double(timevar);
if (net_specific_scan_wifi(essid) != NET_ERR_NONE) {
- debug_print("Error!! net_specific_scan_wifi() failed.\n");
+ debug_print("net_specific_scan_wifi() failed.\n");
break;
}
break;
case 'z':
- debug_print( "Exiting...!!!\n");
+ debug_print("Exiting...!!!\n");
if (net_deregister_client () != NET_ERR_NONE)
- debug_print("Error!! net_deregister_client() failed.\n");
+ debug_print("net_deregister_client() failed.\n");
else
- debug_print( "net_deregister_client() success\n");
+ debug_print("net_deregister_client() success\n");
exit(1);
default:
- debug_print( "default...!!!\n");
+ debug_print("default...!!!\n");
+ break;
}
return TRUE;
}
-
int main(int argc, char *argv[])
{
GMainLoop* mainloop = NULL;
if (net_register_client ((net_event_cb_t)__network_evt_cb, NULL) != NET_ERR_NONE) {
- debug_print("Error!! net_register_client() failed.\n");
+ debug_print("net_register_client() failed.\n");
return 0;
}
- debug_print( "net_register_client() successfull\n");
+ debug_print("net_register_client() successfull\n");
g_idle_add(network_main_gthread, NULL);
return 0;
}
-