SET(DEPENDENCY sqlite3 dlog gflags)
PKG_CHECK_MODULES(VIST_COMMON_DEPS REQUIRED ${DEPENDENCY})
INCLUDE_DIRECTORIES(${VIST_COMMON_DEPS_INCLUDE_DIRS})
+ ADD_DEFINITIONS(-DTIZEN="TIZEN")
ENDIF(DEFINED GBS_BUILD)
INCLUDE_DIRECTORIES(SYSTEM . common ${VIST_COMMON_DEPS_INCLUDE_DIRS})
virtual-table.cpp)
FILE(GLOB CLIENT_TESTS "tests/*.cpp")
-#IF(DEFINED GBS_BUILD)
- ADD_VIST_TEST(${CLIENT_TESTS})
- #ENDIF(DEFINED GBS_BUILD)
+ADD_VIST_TEST(${CLIENT_TESTS})
ADD_LIBRARY(${TARGET_VIST_CLIENT_LIB} STATIC ${${TARGET_VIST_CLIENT_LIB}_SRCS})
TARGET_LINK_LIBRARIES(${TARGET_VIST_CLIENT_LIB} ${VIST_CLIENT_DEPS_LIBRARIES}
INFO(VIST_CLIENT) << "Query execution: " << statement;
rmi::Remote remote(SOCK_ADDR);
- auto query = REMOTE_METHOD(remote, &Vist::query);
+ auto query = REMOTE_METHOD(remote, &Vistd::query);
return query.invoke<Rows>(statement);
}
* limitations under the License
*/
-#include <vist/service/vist.hpp>
+#include <vist/service/vistd.hpp>
#include <vist/exception.hpp>
#include <vist/logger.hpp>
#include <cstdlib>
+#ifdef TIZEN
+#include <vist/logger/dlog.hpp>
+#endif
+
using namespace vist;
int main() try {
- Vist::Instance().start();
+#ifdef TIZEN
+ LogStream::Init(std::make_shared<Dlog>());
+#endif
+
+ Vistd::Instance().start();
+
return EXIT_SUCCESS;
} catch(const Exception<ErrCode>& e) {
ERROR(VIST) << "Failed while daemon is running." << e.what();
# See the License for the specific language governing permissions and
# limitations under the License
-ADD_VIST_LIBRARY(vist_core vist.cpp)
+ADD_VIST_LIBRARY(vist_core vistd.cpp)
FILE(GLOB CORE_TESTS "tests/*.cpp")
ADD_VIST_TEST(${CORE_TESTS})
#include <gtest/gtest.h>
-#include <vist/service/vist.hpp>
+#include <vist/service/vistd.hpp>
#include <vist/policy/api.hpp>
#include <iostream>
TEST_F(CoreTests, query_select)
{
- auto rows = Vist::Query("SELECT * FROM policy");
+ auto rows = Vistd::Query("SELECT * FROM policy");
EXPECT_TRUE(rows.size() > 0);
std::string statement = "SELECT * FROM policy WHERE name = 'sample-int-policy'";
- rows = Vist::Query(statement);
+ rows = Vistd::Query(statement);
EXPECT_EQ(rows.size(), 1);
EXPECT_EQ(rows[0]["name"], "sample-int-policy");
policy::API::Admin::Enroll("admin");
std::string statement = "SELECT * FROM policy WHERE name = 'sample-int-policy'";
- auto rows = Vist::Query(statement);
+ auto rows = Vistd::Query(statement);
/// Initial policy value
EXPECT_EQ(rows[0]["value"], "I/7");
statement = "UPDATE policy SET value = 'I/10' WHERE name = 'sample-int-policy'";
- rows = Vist::Query(statement);
+ rows = Vistd::Query(statement);
EXPECT_EQ(rows.size(), 0);
statement = "SELECT * FROM policy WHERE name = 'sample-int-policy'";
- rows = Vist::Query(statement);
+ rows = Vistd::Query(statement);
EXPECT_EQ(rows[0]["value"], "I/10");
policy::API::Admin::Disenroll("admin");
+++ /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 "vist.hpp"
-
-#include <vist/rmi/gateway.hpp>
-#include <vist/logger.hpp>
-#include <vist/exception.hpp>
-
-#include <osquery/registry_interface.h>
-#include <osquery/sql.h>
-
-namespace {
- const std::string SOCK_ADDR = "/tmp/.vist";
-} // anonymous namespace
-
-namespace vist {
-
-Vist::Vist()
-{
- osquery::registryAndPluginInit();
-}
-
-void Vist::start()
-{
- INFO(VIST) << "Vist daemon starts.";
- rmi::Gateway gateway(SOCK_ADDR);
-
- EXPOSE(gateway, this, &Vist::query);
- gateway.start();
-}
-
-Rows Vist::query(const std::string& statement)
-{
- osquery::SQL sql(statement, true);
- if (!sql.ok())
- THROW(ErrCode::RuntimeError) << "Faild to execute query: " << sql.getMessageString();
-
- return std::move(sql.rows());
-}
-
-} // namespace vist
+++ /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 <map>
-#include <string>
-#include <vector>
-
-namespace vist {
-
-using Row = std::map<std::string, std::string>;
-using Rows = std::vector<Row>;
-
-class Vist final {
-public:
- ~Vist() = default;
-
- Vist(const Vist&) = delete;
- Vist& operator=(const Vist&) = delete;
-
- Vist(Vist&&) = default;
- Vist& operator=(Vist&&) = default;
-
- /// Exposed method (API)
- Rows query(const std::string& statement);
-
- static Vist& Instance()
- {
- static Vist instance;
- return instance;
- }
-
- static Rows Query(const std::string& statement)
- {
- return Vist::Instance().query(statement);
- }
-
- void start();
-
-private:
- explicit Vist();
-};
-
-} // namespace vist
--- /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 "vistd.hpp"
+
+#include <vist/rmi/gateway.hpp>
+#include <vist/logger.hpp>
+#include <vist/exception.hpp>
+
+#include <osquery/registry_interface.h>
+#include <osquery/sql.h>
+
+namespace {
+ const std::string SOCK_ADDR = "/tmp/.vist";
+} // anonymous namespace
+
+namespace vist {
+
+Vistd::Vistd()
+{
+ osquery::registryAndPluginInit();
+}
+
+void Vistd::start()
+{
+ INFO(VIST) << "Vistd daemon starts.";
+ rmi::Gateway gateway(SOCK_ADDR);
+
+ EXPOSE(gateway, this, &Vistd::query);
+ gateway.start();
+}
+
+Rows Vistd::query(const std::string& statement)
+{
+ osquery::SQL sql(statement, true);
+ if (!sql.ok())
+ THROW(ErrCode::RuntimeError) << "Faild to execute query: " << sql.getMessageString();
+
+ return std::move(sql.rows());
+}
+
+} // namespace vist
--- /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 <map>
+#include <string>
+#include <vector>
+
+namespace vist {
+
+using Row = std::map<std::string, std::string>;
+using Rows = std::vector<Row>;
+
+class Vistd final {
+public:
+ ~Vistd() = default;
+
+ Vistd(const Vistd&) = delete;
+ Vistd& operator=(const Vistd&) = delete;
+
+ Vistd(Vistd&&) = default;
+ Vistd& operator=(Vistd&&) = default;
+
+ /// Exposed method (API)
+ Rows query(const std::string& statement);
+
+ static Vistd& Instance()
+ {
+ static Vistd instance;
+ return instance;
+ }
+
+ static Rows Query(const std::string& statement)
+ {
+ return Vistd::Instance().query(statement);
+ }
+
+ void start();
+
+private:
+ explicit Vistd();
+};
+
+} // namespace vist