--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 3.9)
+PROJECT(modes-plugins)
+
+INCLUDE(FindPkgConfig)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11")
+
+ADD_DEFINITIONS("-DMDS_PLUGIN")
+
+IF(NOT DEFINED MODES_PLUGIN_DEFAULT_DIR)
+ MESSAGE("No MODES_PLUGIN_DEFAULT_DIR. Check build system")
+ SET(MODES_PLUGIN_DEFAULT_DIR "/usr/lib/modes-plugins/")
+ENDIF(NOT DEFINED MODES_PLUGIN_DEFAULT_DIR)
+
+ADD_SUBDIRECTORY(wifi)
+ADD_SUBDIRECTORY(vconf)
+ADD_SUBDIRECTORY(unittests)
--- /dev/null
+Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache license, version 2 terms and conditions.
--- /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 <modes_constants.h>
+
+#ifdef API
+#undef API
+#endif
+#define API __attribute__((visibility("default")))
+
+#define MDS_EQUAL 0
+
+#define MODES_NAMESPACE_BEGIN namespace ModeSupervisorNamespace {
+#define MODES_NAMESPACE_END }
+#define MODES_NAMESPACE_USE using namespace ModeSupervisorNamespace
--- /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
+
+#define MDS_LOG_RED "\033[31m"
+#define MDS_LOG_GREEN "\033[32m"
+#define MDS_LOG_BROWN "\033[33m"
+#define MDS_LOG_BLUE "\033[34m"
+#define MDS_LOG_END "\033[0m"
+
+#undef __DBG
+#undef __INFO
+#undef __WARN
+#undef __ERR
+
+#undef _DBG
+#undef _INFO
+#undef _WARN
+#undef _ERR
+
+#undef DBG
+#undef INFO
+#undef WARN
+#undef ERR
+
+#ifdef MDS_STDOUT
+#include <stdio.h>
+#include <string.h>
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#define __DBG(fmt, arg...) printf("[Modes]%s(%d):" fmt "\n", __FILENAME__, __LINE__, ##arg)
+#define __INFO(fmt, arg...) printf("[Modes]%s(%d):" fmt "\n", __FILENAME__, __LINE__, ##arg)
+#define __WARN(fmt, arg...) printf("[Modes]%s(%d):" fmt "\n", __FILENAME__, __LINE__, ##arg)
+#define __ERR(fmt, arg...) printf("[Modes]%s(%d):" fmt "\n", __FILENAME__, __LINE__, ##arg)
+#else
+#define LOG_TAG "MODES"
+#include <dlog.h>
+#define __DBG(fmt, arg...) SLOGD(fmt, ##arg)
+#define __INFO(fmt, arg...) SLOGI(fmt, ##arg)
+#define __WARN(fmt, arg...) SLOGW(fmt, ##arg)
+#define __ERR(fmt, arg...) SLOGE(fmt, ##arg)
+#endif /* MDS_STDOUT */
+
+
+#ifdef MDS_PLUGIN
+#define _DBG(fmt, arg...) __DBG(MDS_LOG_BROWN "<Plugin>" MDS_LOG_END fmt, ##arg)
+#define _INFO(fmt, arg...) __INFO(MDS_LOG_BLUE "<Plugin>" MDS_LOG_END fmt, ##arg)
+#define _WARN(fmt, arg...) __WARN(MDS_LOG_GREEN "<Plugin>" MDS_LOG_END fmt, ##arg)
+#define _ERR(fmt, arg...) __ERR(MDS_LOG_RED "<Plugin>" MDS_LOG_END fmt, ##arg)
+#elif defined(MDS_TEST)
+#define _DBG(fmt, arg...) __DBG(MDS_LOG_BROWN "<Plugin-Test>" MDS_LOG_END fmt, ##arg)
+#define _INFO(fmt, arg...) __INFO(MDS_LOG_BLUE "<Plugin-Test>" MDS_LOG_END fmt, ##arg)
+#define _WARN(fmt, arg...) __WARN(MDS_LOG_GREEN "<Plugin-Test>" MDS_LOG_END fmt, ##arg)
+#define _ERR(fmt, arg...) __ERR(MDS_LOG_RED "<Plugin-Test>" MDS_LOG_END fmt, ##arg)
+#else
+#define _DBG(fmt, arg...) __DBG(fmt, ##arg)
+#define _INFO(fmt, arg...) __INFO(fmt, ##arg)
+#define _WARN(fmt, arg...) __WARN(fmt, ##arg)
+#define _ERR(fmt, arg...) __ERR(fmt, ##arg)
+#endif /* MDS_PLUGIN */
+
+#define MDS_DEBUGGING
+
+#ifdef MDS_DEBUGGING
+#define API_CALL _DBG(">>>>>>>> API called")
+#define API_END _DBG(">>>>>>>> API ended")
+#define FN_CALL _DBG(">>>>>>>> called")
+#define FN_END _DBG("<<<<<<<< ended")
+#define DBG(fmt, arg...) _DBG(fmt, ##arg)
+#define WARN(fmt, arg...) _WARN(fmt, ##arg)
+#define ERR(fmt, arg...) _ERR(fmt, ##arg)
+#define INFO(fmt, arg...) _INFO(fmt, ##arg)
+#define SECURE_DBG(fmt, arg...) SECURE_SLOGI(fmt, ##arg)
+#define SECURE_ERR(fmt, arg...) SECURE_SLOGE(fmt, ##arg)
+
+#else /* MDS_DEBUGGING */
+#define API_CALL
+#define API_END
+#define FN_CALL
+#define FN_END
+#define DBG(fmt, arg...)
+#define WARN(fmt, arg...)
+#define ERR(fmt, arg...)
+#define INFO(fmt, arg...)
+#define SECURE_DBG(fmt, arg...)
+#define SECURE_ERR(fmt, arg...)
+
+#endif /* MDS_DEBUGGING */
+
+#define RET_IF(expr) \
+ do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return; \
+ } \
+ } while (0)
+
+#define RETV_IF(expr, val) \
+ do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return (val); \
+ } \
+ } while (0)
+
+#define RETM_IF(expr, fmt, arg...) \
+ do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return; \
+ } \
+ } while (0)
+
+#define RETVM_IF(expr, val, fmt, arg...) \
+ do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
+#define ERR_IF(expr) \
+ do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ } \
+ } while (0)
+
+#define WARN_IF(expr, fmt, arg...) \
+ do { \
+ if (expr) { \
+ WARN(fmt, ##arg); \
+ } \
+ } while (0)
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+Name: modes-plugins
+Version: 0.0.1
+Release: 0
+Summary: Plugin Libraries for Mode Supervisor
+
+Group: System/Management
+License: Apache-2.0
+URL : https://review.tizen.org/gerrit
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(modes)
+BuildRequires: modes-plugin-devel
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-network-wifi-manager)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(gmock)
+
+%description
+Plugin Libraries for Mode Supervisor
+
+%package unittests
+Summary: Test Programs for %{name}
+Group: System/Testing
+
+%description unittests
+The %{name}-unittests pacakge contains programs for checking quality the %{name}.
+
+%define modes_plugin_dir %{_libdir}/modes-plugins
+%define modes_test_dir %{_bindir}/%{name}
+
+%prep
+%setup -q
+chmod g-w %_sourcedir/*
+cp %{SOURCE1001} ./%{name}.manifest
+
+%build
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
+ -DCMAKE_VERBOSE_MAKEFILE=OFF \
+ -DTEST_INSTALL_DIR:PATH=%{modes_test_dir} \
+ -DMODES_PLUGIN_DEFAULT_DIR:PATH=%{modes_plugin_dir} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+ -DSTDOUT_LOG=%{?stdlog:1}%{!?stdlog:0}
+make %{?_smp_mflags}
+
+%install
+%make_install
+
+%check
+#TBD
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%{modes_plugin_dir}/*.so
+%license LICENSE.APLv2
+
+%files unittests
+%manifest %{name}.manifest
+%{modes_test_dir}/*
+%license LICENSE.APLv2
--- /dev/null
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
+ADD_DEFINITIONS("-DMDS_TEST")
+
+pkg_check_modules(test_pkgs REQUIRED modes dlog capi-network-wifi-manager gmock)
+INCLUDE_DIRECTORIES(${test_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${test_pkgs_LIBRARY_DIRS})
+
+SET(WIFI_SRC_DIR "${CMAKE_SOURCE_DIR}/wifi" )
+
+SET(WIFI_PLUGIN_TEST "modes-gtest-modemgr")
+SET(SRCS ${WIFI_SRC_DIR}/WifiAction.cpp "mdsp_wifi_main.cpp")
+
+ADD_EXECUTABLE(${WIFI_PLUGIN_TEST} ${SRCS})
+TARGET_LINK_LIBRARIES(${WIFI_PLUGIN_TEST} ${test_pkgs_LIBRARIES} dl)
+INSTALL(TARGETS ${WIFI_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR})
--- /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.
+ */
+#include <gtest/gtest.h>
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+SET(VCONF_PLUGIN "modes-plugin-vconf")
+
+FILE(GLOB VCONF_SRCS *.cpp)
+
+pkg_check_modules(vconf_pkgs REQUIRED modes dlog capi-base-common vconf)
+INCLUDE_DIRECTORIES(${vconf_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${vconf_pkgs_LIBRARY_DIRS})
+
+# ==== WifiErrorMessage Header genertor ====
+#ADD_CUSTOM_TARGET(
+# genWifiErrorMessage
+# COMMAND echo "Run WifiErrorMessage Generator"
+# COMMAND tool/WifiErrorMessageGenerator.sh
+#)
+#ADD_DEPENDENCIES(${VCONF_PLUGIN} genWifiErrorMessage)
+
+ADD_LIBRARY(${VCONF_PLUGIN} SHARED ${VCONF_SRCS})
+TARGET_LINK_LIBRARIES(${VCONF_PLUGIN} ${vconf_pkgs_LIBRARIES})
+SET_TARGET_PROPERTIES(${VCONF_PLUGIN} PROPERTIES NO_SONAME 1 )
+INSTALL(TARGETS ${VCONF_PLUGIN} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR})
--- /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.
+ */
+#include <vconf.h>
+#include <modes_errors.h>
+#include <string>
+#include <algorithm>
+#include <Plugin.h>
+#include "plugin-log.h"
+#include "plugin-def.h"
+
+
+MODES_NAMESPACE_USE;
+
+class VconfPlugin : public Plugin {
+private:
+
+public:
+ VconfPlugin();
+
+ int set(const std::string &key, int val) override;
+ int set(const std::string &key, double val) override;
+ int set(const std::string &key, bool val) override;
+ int set(const std::string &key, const std::string &val) override;
+
+ int getInt(const std::string &key) override;
+ double getDouble(const std::string &key) override;
+ bool getBool(const std::string &key) override;
+ std::string getString(const std::string &key) override;
+};
+
+extern "C" API Plugin *objectCreate(void)
+{
+ return new VconfPlugin;
+}
+
+extern "C" API void objectDelete(Plugin *plugin)
+{
+ delete plugin;
+}
+
+VconfPlugin::VconfPlugin()
+{
+ setName("vconf");
+}
+
+int VconfPlugin::set(const std::string &key, int val)
+{
+ DBG("set<int>(%s, %d)", key.c_str(), val);
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int ret = vconf_set_int(newKey.c_str(), val);
+ if (0 != ret) {
+ ERR("vconf_set_int(%s, %d) Fail(%d)", newKey.c_str(), val, ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return MODES_ERROR_NONE;
+}
+
+int VconfPlugin::set(const std::string &key, double val)
+{
+ DBG("set<double>(%s, %lf)", key.c_str(), val);
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int ret = vconf_set_dbl(newKey.c_str(), val);
+ if (0 != ret) {
+ ERR("vconf_set_int(%s, %lf) Fail(%d)", newKey.c_str(), val, ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return MODES_ERROR_NONE;
+}
+int VconfPlugin::set(const std::string &key, bool val)
+{
+ DBG("set<bool>(%s, %d)", key.c_str(), val);
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int ret = vconf_set_bool(newKey.c_str(), val);
+ if (0 != ret) {
+ ERR("vconf_set_bool(%s, %d) Fail(%d)", newKey.c_str(), val, ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return MODES_ERROR_NONE;
+}
+
+int VconfPlugin::set(const std::string &key, const std::string &val)
+{
+ DBG("set<string>(%s, %s)", key.c_str(), val.c_str());
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int ret = vconf_set_str(newKey.c_str(), val.c_str());
+ if (0 != ret) {
+ ERR("vconf_set_str(%s, %s) Fail(%d)", newKey.c_str(), val.c_str(), ret);
+ return MODES_ERROR_SYSTEM;
+ }
+
+ return MODES_ERROR_NONE;
+}
+
+int VconfPlugin::getInt(const std::string &key)
+{
+ DBG("getInt(%s)", key.c_str());
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int value = 0;
+ int ret = vconf_get_int(newKey.c_str(), &value);
+ if (0 != ret) {
+ ERR("vconf_get_int(%s) Fail(%d)", newKey.c_str(), ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return value;
+}
+
+double VconfPlugin::getDouble(const std::string &key)
+{
+ DBG("getDouble(%s)", key.c_str());
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ double value = 0.0;
+ int ret = vconf_get_dbl(newKey.c_str(), &value);
+ if (0 != ret) {
+ ERR("vconf_get_int(%s) Fail(%d)", newKey.c_str(), ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return value;
+}
+
+bool VconfPlugin::getBool(const std::string &key)
+{
+ DBG("getBool(%s)", key.c_str());
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ int value = 0;
+ int ret = vconf_get_bool(newKey.c_str(), &value);
+ if (0 != ret) {
+ ERR("vconf_get_bool(%s) Fail(%d)", newKey.c_str(), ret);
+ return MODES_ERROR_SYSTEM;
+ }
+ return (value) ? true : false;
+}
+
+std::string VconfPlugin::getString(const std::string &key)
+{
+ DBG("getString(%s)", key.c_str());
+
+ std::string newKey(key);
+ std::replace(newKey.begin(), newKey.end(), '.', '/');
+
+ char *value = NULL;
+ value = vconf_get_str(newKey.c_str());
+ if (NULL == value) {
+ ERR("vconf_get_str(%s) Fail()", newKey.c_str());
+ return std::string();
+ }
+ std::string retStr = value;
+ free(value);
+
+ return retStr;
+}
--- /dev/null
+SET(WIFI_PLUGIN "modes-plugin-wifi")
+
+FILE(GLOB WIFI_SRCS *.cpp)
+
+pkg_check_modules(wifi_pkgs REQUIRED modes dlog capi-base-common capi-network-wifi-manager)
+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 )
+INSTALL(TARGETS ${WIFI_PLUGIN} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR})
--- /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.
+ */
+#include "WifiAction.h"
+
+#include <modes_errors.h>
+#include "plugin-log.h"
+#include "plugin-def.h"
+
+MODES_NAMESPACE_USE;
+
+WifiAction::WifiAction()
+{
+ int ret = wifi_manager_initialize(&wifiManagerHandle);
+ if (ret != WIFI_MANAGER_ERROR_NONE) {
+ ERR("wifi_manager_initialize() Fail(%s)", wifiErrorMessage.get(ret).c_str());
+ wifiManagerHandle = NULL;
+ }
+}
+
+WifiAction::~WifiAction()
+{
+ if (wifiManagerHandle) {
+ wifi_manager_deinitialize(wifiManagerHandle);
+ }
+}
+
+bool WifiAction::isWifiManagerEnable()
+{
+ return (wifiManagerHandle != NULL);
+}
+
+int WifiAction::set(int val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int WifiAction::set(double val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int WifiAction::set(bool val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int WifiAction::set(const std::string &val)
+{
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+bool WifiAction::isWifiActivate()
+{
+ RETV_IF(!isWifiManagerEnable(), false);
+
+ bool isActivated = false;
+
+ wifi_manager_is_activated(wifiManagerHandle, &isActivated);
+
+ return isActivated;
+}
+
+const std::string& WifiAction::strErr(int err)
+{
+ return wifiErrorMessage.get(err);
+}
+
+void WifiAction::setName(std::string name)
+{
+ this->name = name;
+}
+
+std::string WifiAction::getName()
+{
+ return name;
+}
--- /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 <wifi-manager.h>
+#include "WifiErrorMessage.h"
+
+MODES_NAMESPACE_BEGIN
+
+class WifiAction {
+public:
+ WifiAction();
+ virtual ~WifiAction();
+
+ bool isWifiActivate();
+ std::string getName();
+ virtual int set(int val);
+ virtual int set(double val);
+ virtual int set(bool val);
+ virtual int set(const std::string &val);
+
+protected:
+ bool isWifiManagerEnable();
+ const std::string& strErr(int err);
+ void setName(std::string name);
+ wifi_manager_h wifiManagerHandle;
+ WifiErrorMessage wifiErrorMessage;
+private:
+ std::string name;
+};
+
+MODES_NAMESPACE_END
+
--- /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.
+ */
+#include "WifiActionPower.h"
+
+#include <algorithm>
+#include <modes_errors.h>
+#include "plugin-log.h"
+
+MODES_NAMESPACE_USE;
+
+WifiActionPower::WifiActionPower()
+{
+ setName("power");
+}
+
+void WifiActionPower::activate_cb(wifi_manager_error_e result, void *user_data)
+{
+ if (WIFI_MANAGER_ERROR_NONE != result) {
+ const std::string &errStr = ((WifiActionPower*)user_data)->strErr(result);
+ ERR("activate_cb() Fail(%d, %s)", result, errStr.c_str());
+ }
+}
+
+void WifiActionPower::deactivate_cb(wifi_manager_error_e result, void *user_data)
+{
+ if (WIFI_MANAGER_ERROR_NONE != result) {
+ const std::string &errStr = ((WifiActionPower*)user_data)->strErr(result);
+ ERR("deactivate_cb() Fail(%d, %s)", result, errStr.c_str());
+ }
+}
+
+int WifiActionPower::set(bool val)
+{
+ RETV_IF(!isWifiManagerEnable(), MODES_ERROR_NOT_SUPPORTED);
+
+ if (isWifiActivate() == val) {
+ INFO("Already wifi is [%s]", val ? "On" : "Off");
+ return MODES_ERROR_NONE;
+ }
+
+ if (val) {
+ int wifiRet = wifi_manager_activate(wifiManagerHandle, activate_cb, this);
+ if (WIFI_MANAGER_ERROR_NONE != wifiRet) {
+ ERR("wifi_manager_activate() Fail(%d, %s)", wifiRet, strErr(wifiRet).c_str());
+ return MODES_ERROR_SYSTEM;
+ }
+ } else {
+ int wifiRet = wifi_manager_deactivate(wifiManagerHandle, deactivate_cb, this);
+ if (WIFI_MANAGER_ERROR_NONE != wifiRet) {
+ ERR("wifi_manager_activate() Fail(%d, %s)", wifiRet, strErr(wifiRet).c_str());
+ return MODES_ERROR_SYSTEM;
+ }
+ }
+
+ INFO("Wifi power [%s]", val ? "On" : "Off");
+ return MODES_ERROR_NONE;
+}
--- /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 "WifiAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class WifiActionPower : public WifiAction {
+public:
+ WifiActionPower();
+
+ int set(bool val) override;
+private:
+ static void activate_cb(wifi_manager_error_e result, void *user_data);
+ static void deactivate_cb(wifi_manager_error_e result, void *user_data);
+};
+
+MODES_NAMESPACE_END
--- /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 $@
--- /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.
+ */
+#include "WifiFactory.h"
+
+#include "modes_errors.h"
+#include "plugin-log.h"
+#include "WifiActionPower.h"
+
+MODES_NAMESPACE_USE;
+
+WifiFactory::WifiFactory()
+{
+ registerAction("power", WifiActionEnum::POWER);
+}
+
+WifiAction* WifiFactory::createAction(const std::string &key)
+{
+ auto search = actionMap.find(key);
+ if (search == actionMap.end()) {
+ ERR("No WifiAction(%s)", key.c_str());
+ return nullptr;
+ }
+
+ switch (search->second) {
+ case WifiActionEnum::POWER:
+ WifiActionPower *wifiActionPower = new WifiActionPower();
+ return wifiActionPower;
+ break;
+ }
+
+ return nullptr;
+}
+
+void WifiFactory::destroyAction(WifiAction *action)
+{
+ RET_IF(action == NULL);
+ delete action;
+}
+
+void WifiFactory::registerAction(std::string key, WifiActionEnum action)
+{
+ DBG("Register Action key[%s]", key.c_str());
+ actionMap[key] = action;
+}
--- /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 "WifiAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class WifiFactory {
+public:
+ WifiFactory();
+ ~WifiFactory() = default;
+
+ WifiAction *createAction(const std::string &key);
+ void destroyAction(WifiAction *action);
+private:
+ enum class WifiActionEnum {
+ POWER
+ };
+
+ void registerAction(std::string key, WifiActionEnum action);
+ std::map<std::string, WifiActionEnum> actionMap;
+};
+
+MODES_NAMESPACE_END
--- /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.
+ */
+#include <string>
+#include <map>
+#include <utility>
+#include <modes_errors.h>
+#include <wifi-manager.h>
+#include <Plugin.h>
+#include "plugin-log.h"
+#include "WifiErrorMessage.h"
+#include "WifiFactory.h"
+
+MODES_NAMESPACE_USE;
+
+class WifiOperation;
+class WifiPlugin : public Plugin {
+public:
+ WifiPlugin();
+ ~WifiPlugin();
+
+ int set(const std::string &key, int val) override;
+ int set(const std::string &key, double val) override;
+ int set(const std::string &key, bool val) override;
+ int set(const std::string &key, const std::string &val) override;
+private:
+ WifiFactory wifiFactory;
+};
+
+extern "C" API Plugin *objectCreate(void)
+{
+ return new WifiPlugin;
+}
+
+extern "C" API void objectDelete(Plugin *plugin)
+{
+ delete plugin;
+}
+
+WifiPlugin::WifiPlugin()
+{
+ setName("wifi");
+}
+
+WifiPlugin::~WifiPlugin()
+{
+}
+
+int WifiPlugin::set(const std::string &key, int val)
+{
+ WifiAction *action = wifiFactory.createAction(key);
+ RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
+
+ DBG("set [%s, %d]", key.c_str(), val);
+
+ int ret = action->set(val);
+ wifiFactory.destroyAction(action);
+ return ret;
+}
+
+int WifiPlugin::set(const std::string &key, double val)
+{
+ WifiAction *action = wifiFactory.createAction(key);
+ RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
+
+ DBG("set [%s, %f]", key.c_str(), val);
+
+ int ret = action->set(val);
+ wifiFactory.destroyAction(action);
+ return ret;
+}
+
+int WifiPlugin::set(const std::string &key, bool val)
+{
+ WifiAction *action = wifiFactory.createAction(key);
+ RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
+
+ DBG("set [%s, %s]", key.c_str(), (val ? "on" : "off"));
+
+ int ret = action->set(val);
+ wifiFactory.destroyAction(action);
+ return ret;
+}
+
+int WifiPlugin::set(const std::string &key, const std::string &val)
+{
+ WifiAction *action = wifiFactory.createAction(key);
+ RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str());
+
+ DBG("set [%s, %s]", key.c_str(), val.c_str());
+
+ int ret = action->set(val);
+ wifiFactory.destroyAction(action);
+ return ret;
+}
+