Update typo.

This commit is contained in:
jbnadal
2018-04-24 18:10:11 +02:00
parent 692bf86f68
commit b1b3f8742c
15 changed files with 802 additions and 708 deletions

View File

@@ -31,9 +31,9 @@
/*---------------------------------- DEFINE ----------------------------------*/ /*---------------------------------- DEFINE ----------------------------------*/
#define kExecSuccess 0 #define kExecSuccess 0
#define kExecFailed -6 #define kExecFailed -6
#define kExecInvalidArguments -5 #define kExecInvalidArguments -5
/*---------------------------------- DEPS ----------------------------------*/ /*---------------------------------- DEPS ----------------------------------*/
@@ -43,18 +43,18 @@ class UBusExecReceiver;
class UBusCall class UBusCall
{ {
public: public:
UBusCall (void); UBusCall(void);
int exec (const std::string &a_path, const std::string &a_method,
const std::string &a_parameter, 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); 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 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 set_result (const std::string &a_result);
private: int set_timeout(int a_timeout);
int set_result(const std::string &a_result);
private:
int m_timeout; int m_timeout;
std::string m_data; std::string m_data;
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,7 @@
#include <list> #include <list>
#include <string> #include <string>
extern "C" { extern "C" {
#include <libubus.h> #include <libubus.h>
} }
@@ -38,16 +38,16 @@ struct ubus_context;
/*--------------------------------- CLASS ----------------------------------*/ /*--------------------------------- CLASS ----------------------------------*/
class UBusEventReceiver : public ubus_event_handler { class UBusEventReceiver : public ubus_event_handler
{
public:
UBusEventReceiver(void);
virtual ~UBusEventReceiver(void);
public: int register_event(struct ubus_context *a_ctx, const std::string &an_event);
UBusEventReceiver (void); int unregister_event(struct ubus_context *a_ctx);
virtual ~UBusEventReceiver (void);
int register_event (struct ubus_context *a_ctx, const std::string &an_event); virtual void handle_event(const char *a_type, const char *a_json_msg) = 0;
int unregister_event (struct ubus_context *a_ctx);
virtual void handle_event (const char *a_type, const char *a_json_msg) = 0;
}; };
#endif /* _UBUS_EVENT_RECEIVER_H */ #endif /* _UBUS_EVENT_RECEIVER_H */

View File

@@ -28,7 +28,7 @@
#include <list> #include <list>
#include <string> #include <string>
extern "C" { extern "C" {
#include <libubus.h> #include <libubus.h>
} }
@@ -39,18 +39,18 @@ struct ubus_event_handler;
/*--------------------------------- CLASS ----------------------------------*/ /*--------------------------------- CLASS ----------------------------------*/
class UBusEvent { class UBusEvent
{
public:
UBusEvent(void);
virtual ~UBusEvent(void);
public: int listen(struct ubus_context *a_ctx, const std::string &an_event);
UBusEvent (void); virtual void handle_event(const char *a_type, const char *a_json_msg);
virtual ~UBusEvent (void); 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); private:
virtual void handle_event (const char *a_type, const char *a_json_msg); std::list<struct ubus_event_handler *> m_listeners;
static int send (const std::string &an_event, const std::string &a_data);
private:
std::list <struct ubus_event_handler *> m_listeners;
}; };
#endif /* _UBUS_EVENT_H */ #endif /* _UBUS_EVENT_H */

View File

@@ -20,9 +20,8 @@
* @Date: 04/05/2017 * @Date: 04/05/2017
*/ */
#ifndef _UBUS_EXEC_RECIVER_H #ifndef _UBUS_EXEC_RECEIVER_H
#define _UBUS_EXEC_RECIVER_H #define _UBUS_EXEC_RECEIVER_H
/*------------------------------- INCLUDES ----------------------------------*/ /*------------------------------- INCLUDES ----------------------------------*/
@@ -35,26 +34,26 @@ extern "C" {
/*--------------------------------- CLASS ----------------------------------*/ /*--------------------------------- CLASS ----------------------------------*/
class UBusExecReceiver : public ubus_request { class UBusExecReceiver : public ubus_request
{
public:
UBusExecReceiver(void);
virtual ~UBusExecReceiver(void);
public: int abort(struct ubus_context *a_ctx);
UBusExecReceiver (void); int complete_request_async(struct ubus_context *a_ctx);
virtual ~UBusExecReceiver (void);
int abort (struct ubus_context *a_ctx); void add_data(std::string a_data);
int complete_request_async (struct ubus_context *a_ctx); const std::string &get_data(void);
void add_data (std::string a_data); void add_result(int a_result);
const std::string &get_data (void); int get_result(void);
void add_result (int a_result);
int get_result (void);
virtual void complete (void) = 0;
private: virtual void complete(void) = 0;
private:
std::string m_data; std::string m_data;
int m_result; int m_result;
}; };
#endif /* _UBUS_EXEC_RECIVER_H */ #endif /* _UBUS_EXEC_RECEIVER_H */

View File

@@ -30,21 +30,19 @@
/*----------------------------- Dependencies --------------------------------*/ /*----------------------------- Dependencies --------------------------------*/
/*--------------------------------- CLASS ----------------------------------*/ /*--------------------------------- CLASS ----------------------------------*/
class UBusObject : public ubus_object { class UBusObject : public ubus_object
{
// Disable copy construction and copy assignement // Disable copy construction and copy assignment
UBusObject (const UBusObject&); UBusObject(const UBusObject &);
UBusObject &operator=(const UBusObject&); UBusObject &operator=(const UBusObject &);
public: public:
UBusObject (ubus_object_type &anObjType, const char *AnObjName, int anObjID = 0, UBusObject(ubus_object_type &anObjType, const char *AnObjName, int anObjID = 0,
const char *anObjPath = 0); const char *anObjPath = 0);
//SHOULD virtual ~UBusObject (void); //SHOULD virtual ~UBusObject (void);
~UBusObject (void); ~UBusObject(void);
}; };
#endif /* _UBUS_OBJECT_H */ #endif /* _UBUS_OBJECT_H */

View File

@@ -38,7 +38,7 @@ extern "C" {
class ULoopTimer : public uloop_timeout class ULoopTimer : public uloop_timeout
{ {
// Disable copy construction and copy assignement // Disable copy construction and copy assignment
ULoopTimer(const ULoopTimer &); ULoopTimer(const ULoopTimer &);
ULoopTimer &operator=(const ULoopTimer &); ULoopTimer &operator=(const ULoopTimer &);

View File

@@ -30,4 +30,4 @@
#define UNUSED_PARAMETER(x) (void)(x) #define UNUSED_PARAMETER(x) (void)(x)
#endif #endif
#endif /* _UBUS_COMMON_H */ #endif /* _UBUS_COMMON_H */

View File

@@ -26,7 +26,7 @@
extern "C" { extern "C" {
#include <libubus.h> #include <libubus.h>
#include <libubox/blobmsg_json.h> #include <libubox/blobmsg_json.h>
} }
extern "C" { extern "C" {
@@ -39,7 +39,7 @@ extern "C" {
#include "ubus-cpp/ubus-call.h" #include "ubus-cpp/ubus-call.h"
#define kDefaultTimeoutInSecond 5 #define kDefaultTimeoutInSecond 5
// #define UBUS_PROFILE 1 // #define UBUS_PROFILE 1
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
@@ -47,15 +47,15 @@ extern "C" {
* *
* @brief callback of result. * @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; 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); the_str = blobmsg_format_json(a_msg, true);
a_caller->set_result(the_str); a_caller->set_result(the_str);
free(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. * @brief Constructor of the UBus Call Command.
*/ */
UBusCall::UBusCall (void): UBusCall::UBusCall(void) : m_timeout(kDefaultTimeoutInSecond)
m_timeout(kDefaultTimeoutInSecond)
{ {
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn exec * @fn exec
* *
* @brief execute a. * @brief execute a.
*/ */
int UBusCall::exec (const std::string &a_path, const std::string &a_method, int UBusCall::exec(const std::string &a_path, const std::string &a_method,
const std::string &a_parameter, std::string &a_result) const std::string &a_parameter, std::string &a_result)
{ {
int the_ret = 0; int the_ret = 0;
#ifdef UBUS_PROFILE #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); gettimeofday(&the_start_request, NULL);
#endif #endif
the_ret = ubus_sync_exec(a_path.c_str(), a_method.c_str(), a_parameter.c_str(), receive_call_result_data, this); 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(); 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 * @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; int the_return = -1;
struct blob_buf the_parameter = { 0 }; struct blob_buf the_parameter = {0};
a_receiver->abort (a_ctx); a_receiver->abort(a_ctx);
blob_buf_init (&the_parameter, 0); blob_buf_init(&the_parameter, 0);
if (!a_parameter.empty()) if (!a_parameter.empty())
blobmsg_add_json_from_string (&the_parameter, a_parameter.c_str()); 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)) { if (!ubus_invoke_async(a_ctx, an_object, a_method.c_str(), the_parameter.head, a_receiver))
{
a_receiver->complete_request_async (a_ctx); a_receiver->complete_request_async(a_ctx);
the_return = 0; the_return = 0;
} }
blob_buf_free (&the_parameter); blob_buf_free(&the_parameter);
return the_return; 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. * @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; m_data = a_result;
return 0; return 0;

View File

@@ -24,7 +24,7 @@
#include <string.h> #include <string.h>
extern "C" { extern "C" {
#include <libubox/blobmsg_json.h> #include <libubox/blobmsg_json.h>
} }
@@ -34,64 +34,59 @@ extern "C" {
/*--------------------------------- DEFINES ---------------------------------*/ /*--------------------------------- DEFINES ---------------------------------*/
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn receive_event * @fn receive_event
* *
* @brief callback called when the event arrive. * @brief callback called when the event arrive.
*/ */
static void receive_event (struct ubus_context *a_ctx, struct ubus_event_handler *an_ev, static void receive_event(struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
const char *a_type, struct blob_attr *a_msg) const char *a_type, struct blob_attr *a_msg)
{ {
char *the_string; char *the_string;
UBusEventReceiver *the_receiver = static_cast<UBusEventReceiver *>(an_ev); 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 * @fn UBusEventReceiver
* *
* @brief Constructor of the UBus Event Receiver * @brief Constructor of the UBus Event Receiver
*/ */
UBusEventReceiver::UBusEventReceiver (void) UBusEventReceiver::UBusEventReceiver(void)
{ {
obj = { 0 }; obj = {0};
cb = receive_event; cb = receive_event;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn ~UBusEventReceiver * @fn ~UBusEventReceiver
* *
* @brief Destructor of of the UBus Event Receiver * @brief Destructor of of the UBus Event Receiver
*/ */
UBusEventReceiver::~UBusEventReceiver (void) UBusEventReceiver::~UBusEventReceiver(void)
{ {
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn register_event * @fn register_event
* *
* @brief register to an ubus event type. * @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 * @fn unregister_event
* *
* @brief un register to an ubus event type. * @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);
} }

View File

@@ -13,7 +13,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
extern "C" { extern "C" {
#include <libubox/blobmsg_json.h> #include <libubox/blobmsg_json.h>
#include "ubus-sync.h" #include "ubus-sync.h"
} }
@@ -26,59 +26,55 @@ extern "C" {
// #define UBUS_PROFILE 1 // #define UBUS_PROFILE 1
static void receive_event(struct ubus_context *a_ctx, struct ubus_event_handler *an_ev,
static void receive_event (struct ubus_context *a_ctx, struct ubus_event_handler *an_ev, const char *a_type, struct blob_attr *a_msg)
const char *a_type, struct blob_attr *a_msg)
{ {
char *the_str; 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); the_str = blobmsg_format_json(a_msg, true);
a_caller->handle_event(a_type, the_str); a_caller->handle_event(a_type, the_str);
free(the_str); free(the_str);
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn UBusEvent * @fn UBusEvent
* *
* @brief Constructor of the UBusEvent * @brief Constructor of the UBusEvent
*/ */
UBusEvent::UBusEvent (void) UBusEvent::UBusEvent(void)
{ {
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn ~UBusEvent * @fn ~UBusEvent
* *
* @brief Destructor of the UBusEvent * @brief Destructor of the UBusEvent
*/ */
UBusEvent::~UBusEvent (void) UBusEvent::~UBusEvent(void)
{ {
while (!m_listeners.empty()) { while (!m_listeners.empty())
{
delete *(m_listeners.begin()); delete *(m_listeners.begin());
m_listeners.erase(m_listeners.begin()); m_listeners.erase(m_listeners.begin());
} }
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn listen * @fn listen
* *
* @brief Handle an UBUS Event. * @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; //static struct ubus_event_handler theListener;
//fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); //fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
struct ubus_event_handler *the_evt_listener = new ubus_event_handler; 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->cb = receive_event;
the_evt_listener->priv = this; 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()); return ubus_register_event_handler(a_ctx, the_evt_listener, an_event.c_str());
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn handle_event * @fn handle_event
* *
* @brief Handle an UBUS 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 * @fn send
* *
* @brief Send an UBus Method * @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; int the_result;
#ifdef UBUS_PROFILE #ifdef UBUS_PROFILE
@@ -115,7 +109,7 @@ int UBusEvent::send (const std::string &an_event, const std::string &a_data)
#ifdef UBUS_PROFILE #ifdef UBUS_PROFILE
gettimeofday(&the_current_timeval, NULL); 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 #endif
return the_result; return the_result;

View File

@@ -20,55 +20,51 @@
* @Date: 04/05/2017 * @Date: 04/05/2017
*/ */
/*-------------------------------- INCLUDES ---------------------------------*/ /*-------------------------------- INCLUDES ---------------------------------*/
#include "ubus-cpp/ubus-exec-receiver.h" #include "ubus-cpp/ubus-exec-receiver.h"
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn handle_data_request * @fn handle_data_request
* *
* @brief callback called when data arrive. * @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; char *the_string;
UBusExecReceiver *the_receiver = static_cast<UBusExecReceiver *>(a_req); UBusExecReceiver *the_receiver = static_cast<UBusExecReceiver *>(a_req);
//printf ("handle_data_request\n"); //printf ("handle_data_request\n");
the_string = blobmsg_format_json (a_msg, true); the_string = blobmsg_format_json(a_msg, true);
the_receiver->add_data (the_string); the_receiver->add_data(the_string);
free (the_string); free(the_string);
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn handle_complete_request * @fn handle_complete_request
* *
* @brief callback called when the request is complete. * @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); UBusExecReceiver *the_receiver = static_cast<UBusExecReceiver *>(a_req);
//printf ("handle_complete_request (%d)\n", a_ret); //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 * @fn UBusExecReceiver
* *
* @brief Constructor of the Ubus Exec Receiver * @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_code = 0;
status_msg = 0; status_msg = 0;
blocked = 0; blocked = 0;
@@ -89,85 +85,78 @@ UBusExecReceiver::UBusExecReceiver (void)
m_result = -1; m_result = -1;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn ~UBusExecReceiver * @fn ~UBusExecReceiver
* *
* @brief Destructor of the Ubus Exec Receiver * @brief Destructor of the Ubus Exec Receiver
*/ */
UBusExecReceiver::~UBusExecReceiver (void) UBusExecReceiver::~UBusExecReceiver(void)
{ {
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn abort * @fn abort
* *
* @brief abort the current exec command. * @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; return 0;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn complete_request_async * @fn complete_request_async
* *
* @brief launch the registered async request. * @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; data_cb = handle_data_request;
complete_cb = handle_complete_request; complete_cb = handle_complete_request;
ubus_complete_request_async (a_ctx, this); ubus_complete_request_async(a_ctx, this);
return 0; return 0;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn add_data * @fn add_data
* *
* @brief add data from the receiver. * @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; m_data += a_data;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn get_data * @fn get_data
* *
* @brief return the data received from the command. * @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; return m_data;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn get_data * @fn get_data
* *
* @brief save the result of the request. * @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; m_result = a_result;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn get_result * @fn get_result
* *
* @brief return the result of the request. * @brief return the result of the request.
*/ */
int UBusExecReceiver::get_result (void) int UBusExecReceiver::get_result(void)
{ {
return m_result; return m_result;
} }

View File

@@ -22,7 +22,6 @@
* *
*/ */
/*------------------------------- INCLUDES ----------------------------------*/ /*------------------------------- INCLUDES ----------------------------------*/
#include "ubus-cpp/ubus-object.h" #include "ubus-cpp/ubus-object.h"
@@ -31,45 +30,42 @@
/*--------------------------------- DEFINES ---------------------------------*/ /*--------------------------------- 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 * 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 AnObjName : the name of the object
* @param anObjID : TO BE DEFINED * @param anObjID : TO BE DEFINED
* @param anObjPath : TO BE DEFINED * @param anObjPath : TO BE DEFINED
* *
* @important : the parameter anObjType should not be a temporary !!! * @important : the parameter anObjType should not be a temporary !!!
*/ */
UBusObject::UBusObject (ubus_object_type &anObjType, const char *AnObjName, int anObjID, UBusObject::UBusObject(ubus_object_type &anObjType, const char *AnObjName, int anObjID,
const char *anObjPath) const char *anObjPath)
{ {
name = AnObjName ? strdup (AnObjName) : 0; name = AnObjName ? strdup(AnObjName) : 0;
id = anObjID; id = anObjID;
path = anObjPath ? strdup (anObjPath) : 0; path = anObjPath ? strdup(anObjPath) : 0;
type = &anObjType; type = &anObjType;
methods = anObjType.methods; methods = anObjType.methods;
n_methods = anObjType.n_methods; n_methods = anObjType.n_methods;
// nullify last fields // nullify last fields
subscribe_cb = 0; subscribe_cb = 0;
has_subscribers = false; has_subscribers = false;
} }
/*! ---------------------------------------------------------------------------- /*! ----------------------------------------------------------------------------
* @fn ~UBusObject * @fn ~UBusObject
* *
* @brief Destructor of the UBusObject * @brief Destructor of the UBusObject
*/ */
UBusObject::~UBusObject (void) UBusObject::~UBusObject(void)
{ {
free ((char*)name); free((char *)name);
free ((char*)path); free((char *)path);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -29,9 +29,9 @@
#include <libubus.h> // temporary for ubus_data_handler_t #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_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_send_event(const char *an_event, const char *a_data);
#endif /* _AW_UBUS_SYNC_H */ #endif /* _AW_UBUS_SYNC_H */