{
public:
/**
- * @brief AgentPolicyAdapter
- * @param agentId
+ * @brief AgentPolicyAdapter Constructor
*/
AgentPolicyAdapter();
/**
* @brief enforcePolicy method sends policy (json data) from calling process to service daemon.
- * @param agentId id of agent program that want to enforce policy
- * @param jsonData string that represent json data
+ * @param agentId [in] id of agent program that want to enforce policy
+ * @param jsonData [in] string that represent json data
* @return result code of type AgentPolicyResult
*/
virtual int enforcePolicy(const std::string& agentId, const std::string& jsonData);
public:
NMexception(const std::string& msg): code(-1), message(msg) {}
- NMexception(const std::string& msg, const int error_code): code(error_code), message(msg) {}
+ NMexception(const std::string& msg, const int ErrorCode): code(ErrorCode), message(msg) {}
const char* what() const noexcept override {
return message.c_str();
class CurlException: public NMexception
{
public:
- CurlException(const int error_code);
+ CurlException(const int ErrorCode);
};
class NotAuthorized: public NMexception
public:
NotAuthorized(const std::string& msg): NMexception(msg, -1) {}
- NotAuthorized(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ NotAuthorized(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
class SessionExpirted: public NMexception
public:
SessionExpirted(const std::string& msg): NMexception(msg, -1) {}
- SessionExpirted(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ SessionExpirted(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
class AuthException: public NMexception
public:
AuthException(const std::string& msg): NMexception(msg, -1) {}
- AuthException(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ AuthException(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
class IoTInternalError: public NMexception
public:
IoTInternalError(const std::string& msg): NMexception(msg, -1) {}
- IoTInternalError(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ IoTInternalError(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
class BadParameterException: public NMexception
public:
BadParameterException(const std::string& msg): NMexception(msg, 1) {}
- BadParameterException(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ BadParameterException(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
class HTTPError: public NMexception
public:
HTTPError(const std::string& msg): NMexception(msg, 1) {}
- HTTPError(const std::string& msg, const int error_code): NMexception(msg, error_code) {}
+ HTTPError(const std::string& msg, const int ErrorCode): NMexception(msg, ErrorCode) {}
};
}
namespace NetworkManager
{
-CurlException::CurlException(const int error_code): NMexception("", error_code)
+CurlException::CurlException(const int ErrorCode): NMexception("", ErrorCode)
{
- message = curl_easy_strerror(CURLcode(error_code));
+ message = curl_easy_strerror(CURLcode(ErrorCode));
}
} // namespace NetworkManager
virtual pid_t getServicePid();
/**
- * @brief AgentPolicyService constructor creates rmi::Service object and registrates methods
+ * @brief AgentPolicyService Constructor creates rmi::Service object and registrates methods
*/
AgentPolicyService(EnforcePolicyHandler enforcePolicyHandler = nullptr);
/**
- * @brief AgentPolicyService Destructro
+ * @brief AgentPolicyService Destructor
*/
~AgentPolicyService();
+/**
+ * @brief Class for install and maintain software
+ * @date Created 28.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>
+ */
+
#ifndef __APPLICATION_SERVICE_H__
#define __APPLICATION_SERVICE_H__
*/
static int get_process_id_by_name(const std::string& name);
+ /**
+ * @brief Power off the device
+ * @details This API can be used to power off the device
+ * @return 0 if success
+ */
static int device_power_off();
};
+/**
+ * @brief AuditTrail Client
+ * @date Created 19.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>
+ */
+
#ifndef __AUDIT_TRAIL_CLIENT_H__
#define __AUDIT_TRAIL_CLIENT_H__
* Process commands:
* - device unpairing
* - application uninstallation
+ * - shut down the device
* @date Created 10.08.2017
* @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
* between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
namespace NMD
{
+/**
+ * @brief The CommandHandler class processes commands that are sent to the ControlResource
+ */
class CommandHandler : public ICommandHandler
{
public:
+ /**
+ * @brief Constructor
+ * @param iotivity [in] IoTivity instance
+ * @param hub [in] Pointer to a Hub resource
+ * @param report_handler [in] Pointer to a Report handler
+ * @param policy_handler [in] Pointer to a Policy handler
+ * @param proxy_thread [in] Pointer to a proxy thread handler
+ * @param wmode [in] Working mode (Standard, Primitive, Hub)
+ * @param main_thread [in] Pointer to a main thread handler
+ */
CommandHandler(NetworkManager::IoTivity* iotivity,
std::shared_ptr<HubResource> hub,
std::shared_ptr<ReportHandler> report_handler,
WorkingMode wmode,
ThreadBase* main_thread);
+ /**
+ * @brief process the command
+ * @param command [in] command encapsulated in OCRepresentation object must contain "command" field
+ * end optional fields specific for each type of command
+ * @return true if success and false otherwise
+ */
bool process(const OC::OCRepresentation& command) override;
+ /**
+ * @brief process unown command
+ * @param command [in] command to process
+ * @return true if success and false otherwise
+ */
bool unOwnCommand(const OC::OCRepresentation& command);
+ /**
+ * @brief process uninstall command
+ * @param command [in] command to process
+ * @return true if success and false otherwise
+ */
bool uninstallCommand(const OC::OCRepresentation& command);
+ /**
+ * @brief process shutdown command
+ * @param command [in] command to process
+ * @return true if success and false otherwise
+ */
bool shutdownCommand(const OC::OCRepresentation& command);
+ /**
+ * @brief unown all and stops the main thread
+ */
void unOwnTask();
private:
namespace NMD
{
+/**
+ * @brief The resource that needed to handle commands, that not related to policies
+ */
class ControlResource : public NetworkManager::IotResourceServer //IotResource
{
public:
ControlResource& operator=(const ControlResource& obj) = delete;
- OCEntityHandlerResult postHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
+ /**
+ * @brief OCResource POST method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
+ OCEntityHandlerResult postHandler(const OC::OCRepresentation& representation,
+ const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
private:
+/**
+ * @brief Device info container implementation
+ * @date Created 16.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.zabolotnyi@samsung.com">Andrey Zabolotnyi, a.zabolotnyi@samsung.com</A>
+ */
+
#ifndef __DEVICE_LIST_H__
#define __DEVICE_LIST_H__
#include <string>
#include <vector>
+/**
+ * @brief A structure that contains info about device
+ */
struct DeviceInfo {
- std::string duid;
- std::string name;
- std::string model;
- std::string type;
- bool is_owned;
+ std::string duid; /**< Device unique ID */
+ std::string name; /**< Device name */
+ std::string model; /**< Device model */
+ std::string type; /**< Device type */
+ bool is_owned; /**< Is the device owned */
static const int fields_count = 5;
bool operator==(const DeviceInfo& r);
};
+/**
+ * @brief A container for device information
+ */
class DeviceList : public std::vector<DeviceInfo>
{
public:
+ /**
+ * @brief Loads device information from file
+ * @param file_name [in] file name
+ * @details This function throws std::runtime_error if failed
+ */
void loadFromFile(const std::string& file_name);
+
+ /**
+ * @brief Store device information to the file
+ * @param file_name [in] file name
+ * @details This function throws std::runtime_error if failed
+ */
void storeToFile(const std::string& file_name);
};
}
}
-dpm_api::error_code convert_err(int err)
+dpm_api::ErrorCode convert_err(int err)
{
switch (err) {
case DPM_ERROR_NONE:
return UNKNOWN;
}
-const char* Mapper::get_error_string(dpm_api::error_code err)
+const char* Mapper::getErrorString(dpm_api::ErrorCode err)
{
struct errs {
- dpm_api::error_code code;
+ dpm_api::ErrorCode code;
const char* name;
};
return pid;
}
-dpm_api::error_code Mapper::apply(const std::string& name, const int param, const vector<string>& items)
+dpm_api::ErrorCode Mapper::apply(const std::string& name, const int param, const vector<string>& items)
{
- dpm_api::error_code res;
+ dpm_api::ErrorCode res;
// temporary change user to 'owner'
uid_t root = geteuid();
uid_t owner;
return res;
}
-dpm_api::error_code Mapper::work(const std::string& name, const int param, const vector<string>& items)
+dpm_api::ErrorCode Mapper::work(const std::string& name, const int param, const vector<string>& items)
{
LOG_D(TAG, "Mapper::work: %s %i", name.c_str(), param);
+/**
+ * @brief DPM API Mapper implementation
+ * @date Created 23.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.zabolotnyi@samsung.com">Andrey Zabolotnyi, a.zabolotnyi@samsung.com</A>
+ */
+
#ifndef DPM_API_MAPPER_CPP_
#define DPM_API_MAPPER_CPP_
namespace dpm_api
{
-enum error_code {
+/**
+ * @brief The ErrorCode enum describes possible result codes
+ */
+enum ErrorCode {
SUCCESS, /**< The operation was successful */
INVALID_PARAMETER, /**< Invalid parameter */
CONNECTION_REFUSED, /**< Connection refused */
UNKNOWN, /**< Unknown error */
};
+/**
+ * @brief The Mapper class applies policies by calling the DPM functions
+ *
+ * @details It takes the name and policy settings, looks for the PDM function
+ * corresponding to the name, and applies it
+ */
+
class Mapper
{
void* handle;
public:
+ /**
+ * @brief Mapper Constructor
+ */
Mapper();
+
+ /**
+ * @brief Mapper Destructor
+ */
~Mapper();
- const char* get_error_string(error_code err);
+ /**
+ * @brief getErrorString returns a description of the error in the form of a text string
+ * @param err [in] the error code
+ * @return text description
+ */
+ const char* getErrorString(ErrorCode err);
- error_code apply(const std::string& name, const int param, const std::vector<std::string>& items);
+ /**
+ * @brief apply apply the policy
+ * @param name [in] name of policy
+ * @param param [in] parameter of policy
+ * @param items [in] vector of strings that contains additional parameters (items) of policy
+ * @return error code
+ */
+ ErrorCode apply(const std::string& name, const int param, const std::vector<std::string>& items);
protected:
- error_code work(const std::string& name, const int param, const std::vector<std::string>& items);
+ ErrorCode work(const std::string& name, const int param, const std::vector<std::string>& items);
};
}
continue; //TODO or return error
}
- dpm_api::error_code err;
+ dpm_api::ErrorCode err;
std::vector<std::string> v;
for (auto& item : items) {
err = mapper.apply(name, state, v);
if (err != dpm_api::SUCCESS) {
- LOG_E(TAG, " Enforce policy [%s] error: %s", name.c_str(), mapper.get_error_string(err));
+ LOG_E(TAG, " Enforce policy [%s] error: %s", name.c_str(), mapper.getErrorString(err));
} else {
LOG_D(TAG, " Enforce policy [%s] ok", name.c_str());
}
{
/**
- * @class TvExtPolicyApplier
- * @brief Parse and apply policies to tv extension tpm module
+ * @class CommonPolicyEnforce
+ * @brief Parse and apply policies to common-policies dpm module
*/
class CommonPolicyEnforce: public IPolicyGroupEnforce
{
private:
- PolicyEnforce& m_enforce; /**< link to PolicyApplier instance */
+ PolicyEnforce& m_enforce; /**< link to PolicyEnforce instance */
};
} //namespace core
{
/**
- * @typedef PolicyGroupList
- * @brief List type for parsed policy groups nodes
- */
-//typedef xml::Node::NodeList PolicyGroupList;
-
-/**
- * @interface IPolicyGroupApplier
+ * @interface IPolicyGroupEnforce
* @brief interface for policy group applier instances. Each policy group should have own applier implementation.
- * Used by PolicyApplier class
- * @see PolicyApplier
+ * Used by PolicyEnforce class
+ * @see PolicyEnforce
*/
class IPolicyGroupEnforce
{
/**
* @brief Init function. Used to init context of related module of policy group
- * @param[in] PolicyContext instance
* @return bool. True in case of success, false otherwise
*/
virtual bool Init() = 0;
/**
- * @typedef IPolicyGroupApplierPtr
- * @brief Pointer type of IPolicyGroupApplier interface object instance
+ * @typedef IPolicyGroupEnforcePtr
+ * @brief Pointer type of IPolicyGroupEnforce interface object instance
*/
typedef IPolicyGroupEnforce* IPolicyGroupEnforcePtr;
typedef std::map<std::string, IPolicyGroupEnforcePtr> PolicyGroupMap;
/**
- * @class PolicyApplier
+ * @class PolicyEnforce
* @brief Parses Policy Config xml string and apply policy groups to related parsers
*/
class PolicyEnforce
/**
* @enum class Result
- * @brief Return enum type for PolicyApplier errors and policy group appliers
+ * @brief Return enum type for PolicyEnforce errors and policy group appliers
*/
enum class Result {
SUCCESS = 0, /**< Success result */
ERROR_PARSING, /**< json data parsing error */
- ERROR_DPM, /**< Error recived from DPM modules */
- ERROR_GROUP
+ ERROR_DPM, /**< Error recived from DPM modules */
+ ERROR_GROUP /**< Error init or parse a group */
};
public:
/**
* @brief Singleton instance recieving method
- * @return Link to PolicyApplier instance
+ * @return Link to PolicyEnforce instance
*/
static PolicyEnforce& GetInstance();
/**
* @brief Parse XML string policy and apply policy group nodes to related policy group appliers instances
* @param[in] XML string with Policy configuration
+ * @return Error code
*/
Result ParsePolicy(const std::string&);
private:
{
}
-bool TvExtPolicyEnforce::Init(/*PolicyContext& context*/)
+bool TvExtPolicyEnforce::Init()
{
LOG_D(TAG, "Init tvext policy applier");
continue; //TODO or return error
}
- dpm_api::error_code err;
+ dpm_api::ErrorCode err;
std::vector<std::string> v;
for (auto& item : items) {
err = mapper.apply(name, state, v);
if (err != dpm_api::SUCCESS) {
- LOG_E(TAG, " Enforce policy [%s] error: %s", name.c_str(), mapper.get_error_string(err));
+ LOG_E(TAG, " Enforce policy [%s] error: %s", name.c_str(), mapper.getErrorString(err));
} else {
LOG_D(TAG, " Enforce policy [%s] ok", name.c_str());
}
{
/**
- * @class TvExtPolicyApplier
- * @brief Parse and apply policies to tv extension tpm module
+ * @class TvExtPolicyEnforce
+ * @brief Parse and apply policies to tv extension dpm module
*/
class TvExtPolicyEnforce: public IPolicyGroupEnforce
{
/**
* @brief Init function. Used to init context of TV extensions policy group
- * @param[in] PolicyContext instance
* @return bool. True in case of success, false otherwise
*/
- bool Init(/*PolicyContext&*/) override;
+ bool Init() override;
/**
* @brief De-Init function. Used to close tpm tvext context.
private:
-// tpm_tvext_policy_h m_policy; /**< tvext tpm handle */
-// tpm_context_h m_context; /**< tpm context handle */
- PolicyEnforce& m_enforce; /**< link to PolicyApplier instance */
+ PolicyEnforce& m_enforce; /**< link to PolicyEnforce instance */
};
+/**
+ * @brief Implementation of the policy functionality for Hub working mode
+ * @date Created 26.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef POLICYRESOURCE_H
#define POLICYRESOURCE_H
/**
using namespace OC;
using namespace NMD;
+/**
+ * @brief Resource that implements the policy functionality for Hub working mode
+ */
class PolicyResource : public NetworkManager::IotResourceServer
{
public:
static const std::string HUB_POLICY_RESORCE_TYPE;
/**
- * Constructor
+ * @brief Constructor
*/
PolicyResource(PolicyHandler* handler, const std::string& hub_device_id, std::shared_ptr<HubResource> hub, ProxyThread* proxy);
+ /**
+ * @brief Destructor
+ */
~PolicyResource();
+ /**
+ * @brief OCResource GET method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
OCEntityHandlerResult getHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
+ /**
+ * @brief OCResource POST method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
OCEntityHandlerResult postHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
+ /**
+ * @brief OCResource OBSERV method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param obsInfo [in] observation info
+ * @return error code
+ */
OCEntityHandlerResult observHandler(const OC::OCRepresentation& representation,
const OC::QueryParamsMap& params, const OC::ObservationInfo& obsInfo) override;
+/**
+ * @brief Resource that implements the reports functionality for Hub working mode
+ * @date Created 26.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef __HUB_REPORT_RESOURCE__
#define __HUB_REPORT_RESOURCE__
/**
using namespace OC;
+/**
+ * @brief Resource that implements the reports functionality for Hub working mode
+ */
class ReportResource : public NetworkManager::IotResourceServer
{
public:
*/
ReportResource(ReportHandler& handler, ProxyThread* proxy);
+ /**
+ * @brief OCResource POST method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
OCEntityHandlerResult postHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
+/**
+ * @brief Resource that implements the Hub working mode functionality
+ * @date Created 04.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef __IOT_HUB_RESOURCE_H__
#define __IOT_HUB_RESOURCE_H__
namespace NMD
{
+/**
+ * @brief Resource that implements the Hub working mode functionality
+ */
+
class HubResource : public NetworkManager::IotResourceServer
{
public:
*/
void unownDevice(const std::string& id);
+ /**
+ * @brief OCResource GET method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
OCEntityHandlerResult getHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
+ /**
+ * @brief OCResource POST method handler
+ * @param representation [in] request body
+ * @param params [in] query parameters
+ * @param response_body [out] response body
+ * @return error code
+ */
OCEntityHandlerResult postHandler(const OC::OCRepresentation& representation, const OC::QueryParamsMap& params,
OC::OCRepresentation& response_body) override;
#include <OCApi.h>
+/**
+ * @brief The ICommandHandler class is the interface for processing
+ * commands that are sent to the ControlResource
+ */
class ICommandHandler
{
public:
/**
* @brief process command
- * @param command [in] command encapsulated in OCRepresentation object must contain "command" field
+ * @param command [in] command encapsulated in OCRepresentation
+ * object must contain "command" field
* end optional fields specific for each type of command
* @return true if success and false otherwise
*/
virtual bool process(const OC::OCRepresentation& command) = 0;
+ /**
+ * @brief Destructor
+ */
virtual ~ICommandHandler() = default;
};
+/**\r
+ * @brief Main thread\r
+ * @date Created 18.04.2017\r
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract\r
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)\r
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).\r
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.\r
+ * @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>\r
+ */\r
+\r
#ifndef __MAIN_THREAD_H__\r
#define __MAIN_THREAD_H__\r
\r
namespace NMD\r
{\r
\r
+/**\r
+ * @brief The Main Thread class\r
+ */\r
class MainThread : public ThreadBase\r
{\r
public:\r
+/**
+ * @brief Policy handler
+ * @date Created 26.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef POLICYHANDLER_H
#define POLICYHANDLER_H
#include <functional>
#include "iotivity.h"
+/**
+ * @brief An abstaract class for handling policies
+ */
class PolicyHandler
{
public:
typedef std::function<void(const OC::HeaderOptions&, const OC::OCRepresentation&, const int&, const int&)>
ObserverCallback;
+ /**
+ * @brief Constructor
+ * @param iotivity [in] pointer to the IoTivity instance
+ */
PolicyHandler(NetworkManager::IoTivity* iotivity);
/**
* @brief setObserver set proxy observe callback
- * @param handler
+ * @param callback handler
*/
virtual void setObserver(const ObserverCallback& handler) {
callback = handler;
disabled = true;
}
- virtual ~PolicyHandler() {};
+ /**
+ * @brief Destructor
+ */
+ virtual ~PolicyHandler() {}
protected:
NetworkManager::IoTivity* iotivity;
+/**
+ * @brief A Factory for Policy Handlers
+ * @date Created 10.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef POLICYHANDLERFACTORY_H
#define POLICYHANDLERFACTORY_H
#include "policyhandler.h"
+/**
+ * @brief A Factory for Policy Handlers
+ */
class PolicyHandlerFactory
{
public:
+/**
+ * @brief handling policies using Message Queue layer for communication
+ * @date Created 10.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef POLICYHANDLERMQ_H
#define POLICYHANDLERMQ_H
#include "policyhandler.h"
+/**
+ * @brief A class for handling policies using Message Queue layer for communication
+ */
class PolicyHandlerMQ : public PolicyHandler
{
public:
+ /**
+ * @brief The Topic
+ */
static const std::string POLICY_TOPIC;
+ /**
+ * @brief Constructor
+ * @param iotivity pointer to IoTivity instance
+ */
PolicyHandlerMQ(NetworkManager::IoTivity* iotivity);
/**
+/**
+ * @brief Handling policies using abstraction of IoTivity resource model
+ * @date Created 10.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef POLICYHANDLERRES_H
#define POLICYHANDLERRES_H
#include "iot_resource.h"
#include "policyhandler.h"
+/**
+ * @brief A class for handling policies using abstraction of IoTivity resource model
+ */
class PolicyHandlerRes: public PolicyHandler, public NetworkManager::IotResourceClient
{
public:
/**
* @brief PolicyHandler constructor
* @param iotivity [in] pointer to iotivity instance
+ * @param server_id [in] server id
*/
PolicyHandlerRes(NetworkManager::IoTivity* iotivity, const std::string& server_id = "");
*/
void pass(const OC::OCRepresentation& rep, const OC::QueryParamsMap& params) override;
+ /**
+ * @brief Initializing
+ */
bool init() override;
- virtual ~PolicyHandlerRes() {};
-
+ /**
+ * @brief DTOR
+ */
+ virtual ~PolicyHandlerRes() {}
};
#endif // POLICYHANDLERRES_H
+/**
+ * @brief A thread performing deferred tasks
+ * @date Created 26.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef PROXYTHREAD_H
#define PROXYTHREAD_H
#include "thread_base.h"
#include "logging.h"
+/**
+ * @brief A thread performing deferred tasks
+ */
class ProxyThread : public NMD::ThreadBase
{
public:
+/**
+ * @brief Create test report
+ * @date Created 14.07.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
#ifndef REPORT_STUB_H
#define REPORT_STUB_H
+/**
+ * @brief Reports handler abstract class
+ * @date Created 26.06.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
+
#ifndef REPORTHANDLER_H
#define REPORTHANDLER_H
#include <OCApi.h>
+/**
+ * @brief An abstaract class for handling reports
+ */
class ReportHandler
{
public:
+ /**
+ * @brief CTOR
+ */
ReportHandler() : disabled(false) {}
+ /**
+ * @brief DTOR
+ */
virtual ~ReportHandler()
{
}
+/**
+ * @brief Handling reports using resource layer for communication
+ * @date Created 15.08.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef REPORTHANDLERRES_H
#define REPORTHANDLERRES_H
#include "iot_resource.h"
#include "reporthandler.h"
+/**
+ * @brief A class for handling reports using resource layer for communication
+ */
class ReportHandlerRes: public ReportHandler, public NetworkManager::IotResourceClient
{
public:
*/
ReportHandlerRes(NetworkManager::IoTivity* iotivity, const std::string& server_id = "");
+ /**
+ * @brief pass sends report representation to server
+ * @param rep representation to send
+ * @param params post query parameters
+ */
void pass(const OC::OCRepresentation& rep, const OC::QueryParamsMap& params) override;
};
+/**
+* @brief A Factory for Report Handlers
+* @date Created 19.07.2017
+* @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+* between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+* and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+* Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+* @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>
+*/
+
#ifndef __REPORT_HANDLER_FACTORY_H__
#define __REPORT_HANDLER_FACTORY_H__
#include "iotivity.h"
#include "reporthandler.h"
+/**
+ * @brief A Factory for Report Handlers
+ */
class ReportHandlerFactory
{
public:
+/**
+ * @brief A class for handling reports using Message Queue layer for communication
+ * @date Created 15.08.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
+ */
+
#ifndef REPORTHANDLERMQ_H
#define REPORTHANDLERMQ_H
#include "iotivity.h"
#include "reporthandler.h"
+/**
+ * @brief A class for handling reports using Message Queue layer for communication
+ */
class ReportHandlerMQ: public ReportHandler
{
public:
+ /**
+ * @brief Constructor
+ * @param iotivity pointer to IoTivity instance
+ */
ReportHandlerMQ(NetworkManager::IoTivity* iotivity);
+
+ /**
+ * @brief pass sends report representation to server
+ * @param rep representation to send
+ * @param params post query parameters
+ */
void pass(const OC::OCRepresentation& rep, const OC::QueryParamsMap& params) override;
private:
-
OC::OCResource::Ptr resource;
NetworkManager::IoTivity* iotivity;
std::string server_id;
namespace NMD\r
{\r
\r
+/**\r
+ * @brief An abstract class for implementing of threads functionality\r
+ */\r
class ThreadBase\r
{\r
public:\r
+ /**\r
+ * @brief Constructor\r
+ */\r
ThreadBase();\r
\r
+ /**\r
+ * @brief Constructor\r
+ */\r
ThreadBase(const ThreadBase&) = delete;\r
\r
+ /**\r
+ * @brief Destructor\r
+ */\r
virtual ~ThreadBase();\r
\r
+ /**\r
+ * @brief Constructor\r
+ */\r
ThreadBase& operator=(const ThreadBase&) = delete;\r
\r
+ /**\r
+ * @brief Starts the thread\r
+ */\r
virtual void start();\r
\r
+ /**\r
+ * @brief Stops the thread\r
+ */\r
virtual void stop();\r
\r
+ /**\r
+ * @brief The entry point of the thread\r
+ */\r
virtual void routine() = 0;\r
\r
+ /**\r
+ * @brief Join to the thread\r
+ */\r
void join();\r
\r
protected:\r
+/**\r
+ * @brief Some utilities\r
+ * @date Created 18.04.2017\r
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract\r
+ * between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)\r
+ * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).\r
+ * Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.\r
+ * @author Mail to: <A HREF="mailto:i.metelytsia@samsung.com">Iurii Metelytsia, i.metelytsia@samsung.com</A>\r
+ */\r
+\r
#ifndef __UTILS_H__\r
#define __UTILS_H__\r
\r
extern std::string log_file_path_name;\r
extern std::string hub_file_path_name;\r
\r
+/**\r
+ * @brief Returns current path\r
+ * @return path on success, empty string on error\r
+ */\r
std::string current_path(void);\r
\r
enum class WorkingMode {\r
- Standard,\r
- Primitive,\r
- Hub\r
+ Standard, /**< A common device that has access to the IoTivity cloud */\r
+ Primitive, /**< A constrained device that does not have access to the IoTivity cloud */\r
+ Hub /**< A device that can provide access to the IoTivity cloud for primitive devices */\r
};\r
\r
extern WorkingMode g_working_mode;\r
\r
+/**\r
+ * @brief The structure contains configuration info for Network Manager daemon\r
+ */\r
typedef struct {\r
std::string host;\r
std::string auth_provider;\r
ASSERT_EQ(mapper.apply(std::string("iptables"), 0, v), dpm_api::SUCCESS);
}
-dpm_api::error_code convert_err(int err);
+dpm_api::ErrorCode convert_err(int err);
TEST(Test_DPM_API, ErrorsTesting)
{
Mapper mapper;
- int res = strcmp(mapper.get_error_string(dpm_api::error_code::SUCCESS), "The operation was successful");
+ int res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::SUCCESS), "The operation was successful");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::INVALID_PARAMETER), "Invalid parameter");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::INVALID_PARAMETER), "Invalid parameter");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::CONNECTION_REFUSED), "Connection refused");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::CONNECTION_REFUSED), "Connection refused");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::TIMED_OUT), "Time out");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::TIMED_OUT), "Time out");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::PERMISSION_DENIED), "Access privilege is not sufficient");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::PERMISSION_DENIED), "Access privilege is not sufficient");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::NOT_PERMITTED), "Operation not permitted");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::NOT_PERMITTED), "Operation not permitted");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::FILE_EXISTS), "File exists");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::FILE_EXISTS), "File exists");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::OUT_OF_MEMORY), "Out of memory");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::OUT_OF_MEMORY), "Out of memory");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::NO_DATA), "No Data");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::NO_DATA), "No Data");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::NOT_INITIALIZED), "Library not initialized");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::NOT_INITIALIZED), "Library not initialized");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::NAME_NOT_FOUND), "Policy's name not found");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::NAME_NOT_FOUND), "Policy's name not found");
ASSERT_EQ(res, 0);
- res = strcmp(mapper.get_error_string(dpm_api::error_code::UNKNOWN), "Unknown error");
+ res = strcmp(mapper.getErrorString(dpm_api::ErrorCode::UNKNOWN), "Unknown error");
ASSERT_EQ(res, 0);
enum {