callbackMap[key].callback = callback;
int ret = vconf_notify_key_changed(key.c_str(), vconfChangedCallback, &callbackMap[key]);
- if (VCONF_OK != ret) {
- ERR("vconf_notify_key_changed(%s) Fail(%s)", key.c_str(), get_error_message(ret));
+ if (0 != ret) {
+ ERR("vconf_notify_key_changed(%s) Fail(%d)", key.c_str(), ret);
return MODES_ERROR_SYSTEM;
}
callbackMap.erase(found);
int ret = vconf_ignore_key_changed(key.c_str(), vconfChangedCallback);
- if (VCONF_OK != ret) {
- ERR("vconf_ignore_key_changed(%s) Fail(%s)", key.c_str(), get_error_message(ret));
+ if (0 != ret) {
+ ERR("vconf_ignore_key_changed(%s) Fail(%d)", key.c_str(), ret);
return MODES_ERROR_SYSTEM;
}
callbackMap.erase(found);
int ret = vconf_ignore_key_changed(key.c_str(), vconfChangedCallback);
- if (VCONF_OK != ret) {
- ERR("vconf_ignore_key_changed(%s) Fail(%s)", key.c_str(), get_error_message(ret));
+ if (0 != ret) {
+ ERR("vconf_ignore_key_changed(%s) Fail(%d)", key.c_str(), ret);
return MODES_ERROR_SYSTEM;
}
}
callbackMap.erase(found);
int ret = vconf_ignore_key_changed(node->keyname, vconfChangedCallback);
- if (VCONF_OK != ret)
- ERR("vconf_ignore_key_changed(%s) Fail(%s)", node->keyname, get_error_message(ret));
+ if (0 != ret)
+ ERR("vconf_ignore_key_changed(%s) Fail(%d)", node->keyname, ret);
}
INCLUDE_DIRECTORIES(${wifi_pkgs_INCLUDE_DIRS})
LINK_DIRECTORIES(${wifi_pkgs_LIBRARY_DIRS})
-# ==== WifiErrorMessage Header genertor ====
-#ADD_CUSTOM_TARGET(
-# genWifiErrorMessage
-# COMMAND echo "Run WifiErrorMessage Generator"
-# COMMAND tool/WifiErrorMessageGenerator.sh
-#)
-#ADD_DEPENDENCIES(${WIFI_PLUGIN} genWifiErrorMessage)
-
ADD_LIBRARY(${WIFI_PLUGIN} SHARED ${WIFI_SRCS})
TARGET_LINK_LIBRARIES(${WIFI_PLUGIN} ${wifi_pkgs_LIBRARIES})
SET_TARGET_PROPERTIES(${WIFI_PLUGIN} PROPERTIES NO_SONAME 1 )
: PluginAction(name), handle(NULL)
{
int ret = wifi_manager_initialize(&handle);
- if (ret != WIFI_MANAGER_ERROR_NONE)
- ERR("wifi_manager_initialize() Fail(%d)", ret);
+ if (WIFI_MANAGER_ERROR_NONE != ret)
+ ERR("wifi_manager_initialize() Fail(%s)", get_error_message(ret));
}
WifiAction::~WifiAction()
{
wifi_manager_deinitialize(handle);
}
-
-const std::string& WifiAction::strErr(int err)
-{
- return wifiErrorMessage.get(err);
-}
#include <string>
#include <wifi-manager.h>
#include <PluginAction.h>
-#include "WifiErrorMessage.h"
+#include "plugin-def.h"
MODES_NAMESPACE_BEGIN
virtual int set(bool val) = 0;
protected:
- const std::string& strErr(int err);
- WifiErrorMessage wifiErrorMessage;
wifi_manager_h handle;
};
if (val) {
int ret = wifi_manager_activate(handle, activateCB, this);
if (WIFI_MANAGER_ERROR_NONE != ret) {
- ERR("wifi_manager_activate() Fail(%d, %s)", ret, strErr(ret).c_str());
+ ERR("wifi_manager_activate() Fail(%s)", get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
} else {
int ret = wifi_manager_deactivate(handle, deactivateCB, this);
if (WIFI_MANAGER_ERROR_NONE != ret) {
- ERR("wifi_manager_deactivate() Fail(%d, %s)", ret, strErr(ret).c_str());
+ ERR("wifi_manager_deactivate() Fail(%s)", get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
}
int ret = wifi_manager_set_device_state_changed_cb(handle, wifiStateChangedCB, this);
if (WIFI_MANAGER_ERROR_NONE != ret) {
- ERR("wifi_manager_set_device_state_changed_cb() Fail(%s)", strErr(ret).c_str());
+ ERR("wifi_manager_set_device_state_changed_cb() Fail(%s)", get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
int ret = wifi_manager_unset_device_state_changed_cb(handle);
if (WIFI_MANAGER_ERROR_NONE != ret) {
- ERR("wifi_manager_unset_device_state_changed_cb() Fail(%s)", strErr(ret).c_str());
+ ERR("wifi_manager_unset_device_state_changed_cb() Fail(%s)", get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
{
INFO("wifi Activated");
if (WIFI_MANAGER_ERROR_NONE != result) {
- const std::string &errStr = ((WifiActionPower*)user_data)->strErr(result);
- ERR("activateCB() Fail(%d, %s)", result, errStr.c_str());
+ ERR("activateCB() Fail(%s)", get_error_message(result));
}
}
{
INFO("wifi Deactivated");
if (WIFI_MANAGER_ERROR_NONE != result) {
- const std::string &errStr = ((WifiActionPower*)user_data)->strErr(result);
- ERR("deactivateCB() Fail(%d, %s)", result, errStr.c_str());
+ ERR("deactivateCB() Fail(%s)", get_error_message(result));
}
}
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-#include <map>
-#include <utility>
-#include <stdexcept>
-#include <wifi-manager.h>
-#include "plugin-def.h"
-
-MODES_NAMESPACE_BEGIN
-
-#define WIFI_ERROR_PAIR(err) std::pair<int, std::string>(WIFI_MANAGER_ERROR_##err, #err)
-#define CREATE_WIFI_ERROR_MESSAGE_MAP() \
- do { \
- wifiErrorMessageMap.clear(); \
- wifiErrorMessageMap.insert(std::pair<int, std::string>(WIFI_MANAGER_ERROR_NONE, "Success")); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(INVALID_PARAMETER)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(OUT_OF_MEMORY)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(INVALID_OPERATION)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(ADDRESS_FAMILY_NOT_SUPPORTED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(OPERATION_FAILED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(NO_CONNECTION)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(NOW_IN_PROGRESS)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(ALREADY_EXISTS)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(OPERATION_ABORTED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(DHCP_FAILED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(INVALID_KEY)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(NO_REPLY)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(SECURITY_RESTRICTED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(ALREADY_INITIALIZED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(OUT_OF_RANGE)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(CONNECT_FAILED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(LOGIN_FAILED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(AUTHENTICATION_FAILED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(PIN_MISSING)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(WPS_OVERLAP)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(WPS_TIMEOUT)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(WPS_WEP_PROHIBITED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(PERMISSION_DENIED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(OFFLINE)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(INVALID_GATEWAY)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(NOT_SUPPORTED)); \
- wifiErrorMessageMap.insert(WIFI_ERROR_PAIR(NOT_INITIALIZED)); \
- } while (0)
-
-class WifiErrorMessage {
-public:
- WifiErrorMessage()
- {
- CREATE_WIFI_ERROR_MESSAGE_MAP();
- }
- ~WifiErrorMessage()
- {
- }
-
- const std::string& get(int key)
- {
- try {
- return wifiErrorMessageMap.at(key);
- }
- catch (const std::out_of_range& oor) {
- static const std::string empty = "";
- return empty;
- }
- }
-private:
- std::map<int, std::string> wifiErrorMessageMap;
-};
-MODES_NAMESPACE_END
+++ /dev/null
-#!/bin/sh
-
-sourceFileName="/usr/include/network/wifi-manager.h"
-targetFileName="WifiErrorMessage.h"
-
-main() {
-
- if [ ! -f $sourceFileName ]
- then
- echo "wifi-manager.h not found!"
- exit 1
- fi
-cat > $targetFileName << EOL
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <string>
-#include <map>
-#include <utility>
-#include <wifi-manager.h>
-#include "common/definitions.h"
-
-MODES_NAMESPACE_BEGIN
-
-#define WIFI_ERROR_PAIR(err) std::pair<int, std::string>(WIFI_MANAGER_ERROR_##err, #err)
-EOL
-
-echo "#define CREATE_WIFI_ERROR_MESSAGE_MAP() \\
- do { \\
- wifiErrorMessageMap.clear(); \\
- wifiErrorMessageMap.insert(std::pair<int, std::string>(WIFI_MANAGER_ERROR_NONE, \"Success\")); \\" >> $targetFileName
-
-cat $sourceFileName | grep -P "^\tWIFI_MANAGER_ERROR_" | grep -v "WIFI_MANAGER_ERROR_NONE" | sed 's/WIFI_MANAGER_ERROR_//g' | awk '{ print "\t\twifiErrorMessageMap.insert(WIFI_ERROR_PAIR(" $1 ")); \\" }' >> $targetFileName
-
-cat >> $targetFileName << EOL
- } while (0)
-
-class WifiErrorMessage {
-public:
- WifiErrorMessage(){
- CREATE_WIFI_ERROR_MESSAGE_MAP();
- }
- ~WifiErrorMessage(){
- }
-
- std::string get( int key ){
- if( wifiErrorMessageMap.count(key) <= 0 )
- return std::string();
-
- return wifiErrorMessageMap[key];
- }
-private:
- std::map<int, std::string> wifiErrorMessageMap;
-};
-MODES_NAMESPACE_END
-EOL
-
- echo "$targetFileName generate complete!"
-}
-
-
-main $@
#include <wifi-manager.h>
#include <Plugin.h>
#include "plugin-log.h"
-#include "WifiErrorMessage.h"
#include "WifiFactory.h"
MODES_NAMESPACE_USE;