Update typo.
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
|
||||
/*---------------------------------- DEFINE ----------------------------------*/
|
||||
|
||||
#define kExecSuccess 0
|
||||
#define kExecFailed -6
|
||||
#define kExecInvalidArguments -5
|
||||
#define kExecSuccess 0
|
||||
#define kExecFailed -6
|
||||
#define kExecInvalidArguments -5
|
||||
|
||||
/*---------------------------------- DEPS ----------------------------------*/
|
||||
|
||||
@@ -43,18 +43,18 @@ class UBusExecReceiver;
|
||||
|
||||
class UBusCall
|
||||
{
|
||||
public:
|
||||
UBusCall (void);
|
||||
|
||||
int exec (const std::string &a_path, const std::string &a_method,
|
||||
const std::string &a_parameter, std::string &a_result);
|
||||
public:
|
||||
UBusCall(void);
|
||||
|
||||
int exec_async (struct ubus_context *a_ctx, uint32_t an_object, const std::string &a_method, const std::string &a_parameter, UBusExecReceiver *a_receiver);
|
||||
int exec(const std::string &a_path, const std::string &a_method,
|
||||
const std::string &a_parameter, std::string &a_result);
|
||||
|
||||
int set_timeout (int a_timeout);
|
||||
int set_result (const std::string &a_result);
|
||||
int exec_async(struct ubus_context *a_ctx, uint32_t an_object, const std::string &a_method, const std::string &a_parameter, UBusExecReceiver *a_receiver);
|
||||
|
||||
private:
|
||||
int set_timeout(int a_timeout);
|
||||
int set_result(const std::string &a_result);
|
||||
|
||||
private:
|
||||
int m_timeout;
|
||||
std::string m_data;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#include <libubus.h>
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ struct ubus_context;
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class UBusEventReceiver : public ubus_event_handler {
|
||||
class UBusEventReceiver : public ubus_event_handler
|
||||
{
|
||||
public:
|
||||
UBusEventReceiver(void);
|
||||
virtual ~UBusEventReceiver(void);
|
||||
|
||||
public:
|
||||
UBusEventReceiver (void);
|
||||
virtual ~UBusEventReceiver (void);
|
||||
int register_event(struct ubus_context *a_ctx, const std::string &an_event);
|
||||
int unregister_event(struct ubus_context *a_ctx);
|
||||
|
||||
int register_event (struct ubus_context *a_ctx, const std::string &an_event);
|
||||
int unregister_event (struct ubus_context *a_ctx);
|
||||
|
||||
virtual void handle_event (const char *a_type, const char *a_json_msg) = 0;
|
||||
virtual void handle_event(const char *a_type, const char *a_json_msg) = 0;
|
||||
};
|
||||
|
||||
#endif /* _UBUS_EVENT_RECEIVER_H */
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#include <libubus.h>
|
||||
}
|
||||
|
||||
@@ -39,18 +39,18 @@ struct ubus_event_handler;
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class UBusEvent {
|
||||
class UBusEvent
|
||||
{
|
||||
public:
|
||||
UBusEvent(void);
|
||||
virtual ~UBusEvent(void);
|
||||
|
||||
public:
|
||||
UBusEvent (void);
|
||||
virtual ~UBusEvent (void);
|
||||
int listen(struct ubus_context *a_ctx, const std::string &an_event);
|
||||
virtual void handle_event(const char *a_type, const char *a_json_msg);
|
||||
static int send(const std::string &an_event, const std::string &a_data);
|
||||
|
||||
int listen (struct ubus_context *a_ctx, const std::string &an_event);
|
||||
virtual void handle_event (const char *a_type, const char *a_json_msg);
|
||||
static int send (const std::string &an_event, const std::string &a_data);
|
||||
|
||||
private:
|
||||
std::list <struct ubus_event_handler *> m_listeners;
|
||||
private:
|
||||
std::list<struct ubus_event_handler *> m_listeners;
|
||||
};
|
||||
|
||||
#endif /* _UBUS_EVENT_H */
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
* @Date: 04/05/2017
|
||||
*/
|
||||
|
||||
#ifndef _UBUS_EXEC_RECIVER_H
|
||||
#define _UBUS_EXEC_RECIVER_H
|
||||
|
||||
#ifndef _UBUS_EXEC_RECEIVER_H
|
||||
#define _UBUS_EXEC_RECEIVER_H
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
@@ -35,26 +34,26 @@ extern "C" {
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class UBusExecReceiver : public ubus_request {
|
||||
class UBusExecReceiver : public ubus_request
|
||||
{
|
||||
public:
|
||||
UBusExecReceiver(void);
|
||||
virtual ~UBusExecReceiver(void);
|
||||
|
||||
public:
|
||||
UBusExecReceiver (void);
|
||||
virtual ~UBusExecReceiver (void);
|
||||
int abort(struct ubus_context *a_ctx);
|
||||
int complete_request_async(struct ubus_context *a_ctx);
|
||||
|
||||
int abort (struct ubus_context *a_ctx);
|
||||
int complete_request_async (struct ubus_context *a_ctx);
|
||||
void add_data(std::string a_data);
|
||||
const std::string &get_data(void);
|
||||
|
||||
void add_data (std::string a_data);
|
||||
const std::string &get_data (void);
|
||||
|
||||
void add_result (int a_result);
|
||||
int get_result (void);
|
||||
|
||||
virtual void complete (void) = 0;
|
||||
void add_result(int a_result);
|
||||
int get_result(void);
|
||||
|
||||
private:
|
||||
virtual void complete(void) = 0;
|
||||
|
||||
private:
|
||||
std::string m_data;
|
||||
int m_result;
|
||||
};
|
||||
|
||||
#endif /* _UBUS_EXEC_RECIVER_H */
|
||||
#endif /* _UBUS_EXEC_RECEIVER_H */
|
||||
|
||||
@@ -30,21 +30,19 @@
|
||||
|
||||
/*----------------------------- Dependencies --------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class UBusObject : public ubus_object {
|
||||
|
||||
// Disable copy construction and copy assignement
|
||||
UBusObject (const UBusObject&);
|
||||
UBusObject &operator=(const UBusObject&);
|
||||
|
||||
public:
|
||||
UBusObject (ubus_object_type &anObjType, const char *AnObjName, int anObjID = 0,
|
||||
const char *anObjPath = 0);
|
||||
class UBusObject : public ubus_object
|
||||
{
|
||||
// Disable copy construction and copy assignment
|
||||
UBusObject(const UBusObject &);
|
||||
UBusObject &operator=(const UBusObject &);
|
||||
|
||||
public:
|
||||
UBusObject(ubus_object_type &anObjType, const char *AnObjName, int anObjID = 0,
|
||||
const char *anObjPath = 0);
|
||||
//SHOULD virtual ~UBusObject (void);
|
||||
~UBusObject (void);
|
||||
~UBusObject(void);
|
||||
};
|
||||
|
||||
|
||||
#endif /* _UBUS_OBJECT_H */
|
||||
|
||||
@@ -38,7 +38,7 @@ extern "C" {
|
||||
|
||||
class ULoopTimer : public uloop_timeout
|
||||
{
|
||||
// Disable copy construction and copy assignement
|
||||
// Disable copy construction and copy assignment
|
||||
ULoopTimer(const ULoopTimer &);
|
||||
ULoopTimer &operator=(const ULoopTimer &);
|
||||
|
||||
|
||||
@@ -30,4 +30,4 @@
|
||||
#define UNUSED_PARAMETER(x) (void)(x)
|
||||
#endif
|
||||
|
||||
#endif /* _UBUS_COMMON_H */
|
||||
#endif /* _UBUS_COMMON_H */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include <libubus.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
|
||||
#include "ubus-cpp/ubus-call.h"
|
||||
|
||||
#define kDefaultTimeoutInSecond 5
|
||||
#define kDefaultTimeoutInSecond 5
|
||||
// #define UBUS_PROFILE 1
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
@@ -47,15 +47,15 @@ extern "C" {
|
||||
*
|
||||
* @brief callback of result.
|
||||
*/
|
||||
static void receive_call_result_data (struct ubus_request *a_req, int a_type, struct blob_attr *a_msg)
|
||||
static void receive_call_result_data(struct ubus_request *a_req, int a_type, struct blob_attr *a_msg)
|
||||
{
|
||||
char *the_str;
|
||||
UBusCall *a_caller = static_cast<UBusCall*>(a_req->priv);
|
||||
|
||||
UBusCall *a_caller = static_cast<UBusCall *>(a_req->priv);
|
||||
|
||||
the_str = blobmsg_format_json(a_msg, true);
|
||||
|
||||
|
||||
a_caller->set_result(the_str);
|
||||
|
||||
|
||||
free(the_str);
|
||||
}
|
||||
|
||||
@@ -64,19 +64,17 @@ static void receive_call_result_data (struct ubus_request *a_req, int a_type, st
|
||||
*
|
||||
* @brief Constructor of the UBus Call Command.
|
||||
*/
|
||||
UBusCall::UBusCall (void):
|
||||
m_timeout(kDefaultTimeoutInSecond)
|
||||
UBusCall::UBusCall(void) : m_timeout(kDefaultTimeoutInSecond)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn exec
|
||||
*
|
||||
* @brief execute a.
|
||||
*/
|
||||
int UBusCall::exec (const std::string &a_path, const std::string &a_method,
|
||||
const std::string &a_parameter, std::string &a_result)
|
||||
int UBusCall::exec(const std::string &a_path, const std::string &a_method,
|
||||
const std::string &a_parameter, std::string &a_result)
|
||||
{
|
||||
int the_ret = 0;
|
||||
#ifdef UBUS_PROFILE
|
||||
@@ -84,8 +82,9 @@ int UBusCall::exec (const std::string &a_path, const std::string &a_method,
|
||||
gettimeofday(&the_start_request, NULL);
|
||||
#endif
|
||||
the_ret = ubus_sync_exec(a_path.c_str(), a_method.c_str(), a_parameter.c_str(), receive_call_result_data, this);
|
||||
|
||||
if (!m_data.empty()) {
|
||||
|
||||
if (!m_data.empty())
|
||||
{
|
||||
a_result = m_data.c_str();
|
||||
}
|
||||
|
||||
@@ -99,27 +98,27 @@ int UBusCall::exec (const std::string &a_path, const std::string &a_method,
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn exec-async
|
||||
*
|
||||
* @brief Execute an UBus Method Asynchrously;
|
||||
* @brief Execute an UBus Method Asynchronously;
|
||||
*/
|
||||
int UBusCall::exec_async (struct ubus_context *a_ctx, uint32_t an_object, const std::string &a_method, const std::string &a_parameter, UBusExecReceiver *a_receiver)
|
||||
int UBusCall::exec_async(struct ubus_context *a_ctx, uint32_t an_object, const std::string &a_method, const std::string &a_parameter, UBusExecReceiver *a_receiver)
|
||||
{
|
||||
int the_return = -1;
|
||||
struct blob_buf the_parameter = { 0 };
|
||||
a_receiver->abort (a_ctx);
|
||||
struct blob_buf the_parameter = {0};
|
||||
a_receiver->abort(a_ctx);
|
||||
|
||||
blob_buf_init (&the_parameter, 0);
|
||||
blob_buf_init(&the_parameter, 0);
|
||||
|
||||
if (!a_parameter.empty())
|
||||
blobmsg_add_json_from_string (&the_parameter, a_parameter.c_str());
|
||||
|
||||
if (!ubus_invoke_async (a_ctx, an_object, a_method.c_str(), the_parameter.head, a_receiver)) {
|
||||
|
||||
a_receiver->complete_request_async (a_ctx);
|
||||
blobmsg_add_json_from_string(&the_parameter, a_parameter.c_str());
|
||||
|
||||
if (!ubus_invoke_async(a_ctx, an_object, a_method.c_str(), the_parameter.head, a_receiver))
|
||||
{
|
||||
a_receiver->complete_request_async(a_ctx);
|
||||
the_return = 0;
|
||||
}
|
||||
|
||||
blob_buf_free (&the_parameter);
|
||||
|
||||
|
||||
blob_buf_free(&the_parameter);
|
||||
|
||||
return the_return;
|
||||
}
|
||||
|
||||
@@ -128,7 +127,7 @@ int UBusCall::exec_async (struct ubus_context *a_ctx, uint32_t an_object, const
|
||||
*
|
||||
* @brief Save the Result received by UBus.
|
||||
*/
|
||||
int UBusCall::set_result (const std::string &a_result)
|
||||
int UBusCall::set_result(const std::string &a_result)
|
||||
{
|
||||
m_data = a_result;
|
||||
return 0;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#include <libubox/blobmsg_json.h>
|
||||
}
|
||||
|
||||
@@ -34,64 +34,59 @@ extern "C" {
|
||||
|
||||
/*--------------------------------- DEFINES ---------------------------------*/
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn receive_event
|
||||
*
|
||||
* @brief callback called when the event arrive.
|
||||
*/
|
||||
static void receive_event (struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
|
||||
const char *a_type, struct blob_attr *a_msg)
|
||||
static void receive_event(struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
|
||||
const char *a_type, struct blob_attr *a_msg)
|
||||
{
|
||||
char *the_string;
|
||||
UBusEventReceiver *the_receiver = static_cast<UBusEventReceiver *>(an_ev);
|
||||
the_string = blobmsg_format_json (a_msg, true);
|
||||
the_string = blobmsg_format_json(a_msg, true);
|
||||
|
||||
the_receiver->handle_event (a_type, the_string);
|
||||
the_receiver->handle_event(a_type, the_string);
|
||||
|
||||
free (the_string);
|
||||
free(the_string);
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn UBusEventReceiver
|
||||
*
|
||||
* @brief Constructor of the UBus Event Receiver
|
||||
*/
|
||||
UBusEventReceiver::UBusEventReceiver (void)
|
||||
UBusEventReceiver::UBusEventReceiver(void)
|
||||
{
|
||||
obj = { 0 };
|
||||
obj = {0};
|
||||
cb = receive_event;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~UBusEventReceiver
|
||||
*
|
||||
* @brief Destructor of of the UBus Event Receiver
|
||||
*/
|
||||
UBusEventReceiver::~UBusEventReceiver (void)
|
||||
UBusEventReceiver::~UBusEventReceiver(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn register_event
|
||||
*
|
||||
* @brief register to an ubus event type.
|
||||
*/
|
||||
int UBusEventReceiver::register_event (struct ubus_context *a_ctx, const std::string &an_event)
|
||||
int UBusEventReceiver::register_event(struct ubus_context *a_ctx, const std::string &an_event)
|
||||
{
|
||||
return ubus_register_event_handler (a_ctx, this, an_event.c_str());;
|
||||
return ubus_register_event_handler(a_ctx, this, an_event.c_str());
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn unregister_event
|
||||
*
|
||||
* @brief un register to an ubus event type.
|
||||
*/
|
||||
int UBusEventReceiver::unregister_event (struct ubus_context *a_ctx)
|
||||
int UBusEventReceiver::unregister_event(struct ubus_context *a_ctx)
|
||||
{
|
||||
return ubus_unregister_event_handler (a_ctx, this);
|
||||
return ubus_unregister_event_handler(a_ctx, this);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include "ubus-sync.h"
|
||||
}
|
||||
@@ -26,59 +26,55 @@ extern "C" {
|
||||
|
||||
// #define UBUS_PROFILE 1
|
||||
|
||||
|
||||
static void receive_event (struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
|
||||
const char *a_type, struct blob_attr *a_msg)
|
||||
static void receive_event(struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
|
||||
const char *a_type, struct blob_attr *a_msg)
|
||||
{
|
||||
char *the_str;
|
||||
UBusEvent *a_caller = static_cast<UBusEvent*>(an_ev->priv);
|
||||
|
||||
UBusEvent *a_caller = static_cast<UBusEvent *>(an_ev->priv);
|
||||
|
||||
the_str = blobmsg_format_json(a_msg, true);
|
||||
|
||||
|
||||
a_caller->handle_event(a_type, the_str);
|
||||
|
||||
|
||||
free(the_str);
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn UBusEvent
|
||||
*
|
||||
* @brief Constructor of the UBusEvent
|
||||
*/
|
||||
UBusEvent::UBusEvent (void)
|
||||
UBusEvent::UBusEvent(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~UBusEvent
|
||||
*
|
||||
* @brief Destructor of the UBusEvent
|
||||
*/
|
||||
UBusEvent::~UBusEvent (void)
|
||||
UBusEvent::~UBusEvent(void)
|
||||
{
|
||||
while (!m_listeners.empty()) {
|
||||
|
||||
while (!m_listeners.empty())
|
||||
{
|
||||
delete *(m_listeners.begin());
|
||||
m_listeners.erase(m_listeners.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn listen
|
||||
*
|
||||
* @brief Handle an UBUS Event.
|
||||
*/
|
||||
int UBusEvent::listen (struct ubus_context *a_ctx, const std::string &an_event)
|
||||
int UBusEvent::listen(struct ubus_context *a_ctx, const std::string &an_event)
|
||||
{
|
||||
//static struct ubus_event_handler theListener;
|
||||
//fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
|
||||
|
||||
|
||||
struct ubus_event_handler *the_evt_listener = new ubus_event_handler;
|
||||
|
||||
memset (the_evt_listener, 0, sizeof (struct ubus_event_handler));
|
||||
memset(the_evt_listener, 0, sizeof(struct ubus_event_handler));
|
||||
the_evt_listener->cb = receive_event;
|
||||
the_evt_listener->priv = this;
|
||||
|
||||
@@ -87,23 +83,21 @@ int UBusEvent::listen (struct ubus_context *a_ctx, const std::string &an_event)
|
||||
return ubus_register_event_handler(a_ctx, the_evt_listener, an_event.c_str());
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn handle_event
|
||||
*
|
||||
* @brief Handle an UBUS Event.
|
||||
*/
|
||||
void UBusEvent::handle_event (const char *a_type, const char *a_json_msg)
|
||||
void UBusEvent::handle_event(const char *a_type, const char *a_json_msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn send
|
||||
*
|
||||
* @brief Send an UBus Method
|
||||
*/
|
||||
int UBusEvent::send (const std::string &an_event, const std::string &a_data)
|
||||
int UBusEvent::send(const std::string &an_event, const std::string &a_data)
|
||||
{
|
||||
int the_result;
|
||||
#ifdef UBUS_PROFILE
|
||||
@@ -115,7 +109,7 @@ int UBusEvent::send (const std::string &an_event, const std::string &a_data)
|
||||
|
||||
#ifdef UBUS_PROFILE
|
||||
gettimeofday(&the_current_timeval, NULL);
|
||||
printf ("ubus_event [%s] duree: %.0lf ms\n", an_event.c_str(), time_diff(the_start_request, the_current_timeval) / 1000);
|
||||
printf("ubus_event [%s] duree: %.0lf ms\n", an_event.c_str(), time_diff(the_start_request, the_current_timeval) / 1000);
|
||||
#endif
|
||||
|
||||
return the_result;
|
||||
|
||||
@@ -20,55 +20,51 @@
|
||||
* @Date: 04/05/2017
|
||||
*/
|
||||
|
||||
|
||||
/*-------------------------------- INCLUDES ---------------------------------*/
|
||||
|
||||
#include "ubus-cpp/ubus-exec-receiver.h"
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn handle_data_request
|
||||
*
|
||||
* @brief callback called when data arrive.
|
||||
*/
|
||||
static void handle_data_request (struct ubus_request *a_req, int, struct blob_attr *a_msg)
|
||||
static void handle_data_request(struct ubus_request *a_req, int, struct blob_attr *a_msg)
|
||||
{
|
||||
char *the_string;
|
||||
UBusExecReceiver *the_receiver = static_cast<UBusExecReceiver *>(a_req);
|
||||
//printf ("handle_data_request\n");
|
||||
|
||||
the_string = blobmsg_format_json (a_msg, true);
|
||||
the_receiver->add_data (the_string);
|
||||
the_string = blobmsg_format_json(a_msg, true);
|
||||
the_receiver->add_data(the_string);
|
||||
|
||||
free (the_string);
|
||||
free(the_string);
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn handle_complete_request
|
||||
*
|
||||
* @brief callback called when the request is complete.
|
||||
*/
|
||||
static void handle_complete_request (struct ubus_request *a_req, int a_ret)
|
||||
static void handle_complete_request(struct ubus_request *a_req, int a_ret)
|
||||
{
|
||||
UBusExecReceiver *the_receiver = static_cast<UBusExecReceiver *>(a_req);
|
||||
//printf ("handle_complete_request (%d)\n", a_ret);
|
||||
|
||||
the_receiver->add_result (a_ret);
|
||||
the_receiver->complete ();
|
||||
}
|
||||
|
||||
the_receiver->add_result(a_ret);
|
||||
the_receiver->complete();
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn UBusExecReceiver
|
||||
*
|
||||
* @brief Constructor of the Ubus Exec Receiver
|
||||
*/
|
||||
UBusExecReceiver::UBusExecReceiver (void)
|
||||
UBusExecReceiver::UBusExecReceiver(void)
|
||||
{
|
||||
list = LIST_HEAD_INIT (list);
|
||||
list = LIST_HEAD_INIT(list);
|
||||
|
||||
pending = { 0 };
|
||||
pending = {0};
|
||||
status_code = 0;
|
||||
status_msg = 0;
|
||||
blocked = 0;
|
||||
@@ -89,85 +85,78 @@ UBusExecReceiver::UBusExecReceiver (void)
|
||||
m_result = -1;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~UBusExecReceiver
|
||||
*
|
||||
* @brief Destructor of the Ubus Exec Receiver
|
||||
*/
|
||||
UBusExecReceiver::~UBusExecReceiver (void)
|
||||
UBusExecReceiver::~UBusExecReceiver(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn abort
|
||||
*
|
||||
* @brief abort the current exec command.
|
||||
*/
|
||||
int UBusExecReceiver::abort (struct ubus_context *a_ctx)
|
||||
int UBusExecReceiver::abort(struct ubus_context *a_ctx)
|
||||
{
|
||||
ubus_abort_request (a_ctx, this);
|
||||
ubus_abort_request(a_ctx, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn complete_request_async
|
||||
*
|
||||
* @brief launch the registered async request.
|
||||
*/
|
||||
int UBusExecReceiver::complete_request_async (struct ubus_context *a_ctx)
|
||||
int UBusExecReceiver::complete_request_async(struct ubus_context *a_ctx)
|
||||
{
|
||||
data_cb = handle_data_request;
|
||||
complete_cb = handle_complete_request;
|
||||
|
||||
ubus_complete_request_async (a_ctx, this);
|
||||
ubus_complete_request_async(a_ctx, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn add_data
|
||||
*
|
||||
* @brief add data from the receiver.
|
||||
*/
|
||||
void UBusExecReceiver::add_data (std::string a_data)
|
||||
void UBusExecReceiver::add_data(std::string a_data)
|
||||
{
|
||||
m_data += a_data;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_data
|
||||
*
|
||||
* @brief return the data received from the command.
|
||||
*/
|
||||
const std::string &UBusExecReceiver::get_data (void)
|
||||
const std::string &UBusExecReceiver::get_data(void)
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_data
|
||||
*
|
||||
* @brief save the result of the request.
|
||||
*/
|
||||
void UBusExecReceiver::add_result (int a_result)
|
||||
void UBusExecReceiver::add_result(int a_result)
|
||||
{
|
||||
m_result = a_result;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_result
|
||||
*
|
||||
* @brief return the result of the request.
|
||||
*/
|
||||
int UBusExecReceiver::get_result (void)
|
||||
int UBusExecReceiver::get_result(void)
|
||||
{
|
||||
return m_result;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include "ubus-cpp/ubus-object.h"
|
||||
@@ -31,45 +30,42 @@
|
||||
|
||||
/*--------------------------------- DEFINES ---------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn awUBusObject
|
||||
* @fn UBusObject
|
||||
*
|
||||
* @brief Construct a new awUBusObject, the object type and methods is
|
||||
* @brief Construct a new UBusObject, the object type and methods is
|
||||
* provided statically using the type Derived
|
||||
*
|
||||
* @param anObjType object type, be carreful it should not be a temporary !!!
|
||||
* @param anObjType object type, be careful it should not be a temporary !!!
|
||||
* @param AnObjName : the name of the object
|
||||
* @param anObjID : TO BE DEFINED
|
||||
* @param anObjPath : TO BE DEFINED
|
||||
*
|
||||
* @important : the parameter anObjType should not be a temporary !!!
|
||||
*/
|
||||
UBusObject::UBusObject (ubus_object_type &anObjType, const char *AnObjName, int anObjID,
|
||||
const char *anObjPath)
|
||||
UBusObject::UBusObject(ubus_object_type &anObjType, const char *AnObjName, int anObjID,
|
||||
const char *anObjPath)
|
||||
{
|
||||
name = AnObjName ? strdup (AnObjName) : 0;
|
||||
name = AnObjName ? strdup(AnObjName) : 0;
|
||||
id = anObjID;
|
||||
path = anObjPath ? strdup (anObjPath) : 0;
|
||||
|
||||
path = anObjPath ? strdup(anObjPath) : 0;
|
||||
|
||||
type = &anObjType;
|
||||
methods = anObjType.methods;
|
||||
n_methods = anObjType.n_methods;
|
||||
|
||||
// nullify last fields
|
||||
|
||||
// nullify last fields
|
||||
subscribe_cb = 0;
|
||||
has_subscribers = false;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~UBusObject
|
||||
*
|
||||
* @brief Destructor of the UBusObject
|
||||
*/
|
||||
UBusObject::~UBusObject (void)
|
||||
UBusObject::~UBusObject(void)
|
||||
{
|
||||
free ((char*)name);
|
||||
free ((char*)path);
|
||||
free((char *)name);
|
||||
free((char *)path);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,9 +29,9 @@
|
||||
|
||||
#include <libubus.h> // temporary for ubus_data_handler_t
|
||||
|
||||
double time_diff (struct timeval x , struct timeval y);
|
||||
double time_diff(struct timeval x, struct timeval y);
|
||||
|
||||
int ubus_sync_exec (const char *a_path, const char* a_method, const char *a_parameter, ubus_data_handler_t cb, void *priv);
|
||||
int ubus_sync_send_event (const char *an_event, const char *a_data);
|
||||
int ubus_sync_exec(const char *a_path, const char *a_method, const char *a_parameter, ubus_data_handler_t cb, void *priv);
|
||||
int ubus_sync_send_event(const char *an_event, const char *a_data);
|
||||
|
||||
#endif /* _AW_UBUS_SYNC_H */
|
||||
|
||||
Reference in New Issue
Block a user