virtual int read(const char* subject, smr::json option, smr::json* request_result) = 0;
virtual int write(const char* subject, smr::json data, smr::json* request_result) = 0;
-
}; /* class analyzer_iface */
-
} /* namespace smr */
#endif /* End of __SMARTREPLY_ANALYZER_INTERFACE_H__ */
bool start();
bool stop();
bool is_running();
-
}; /* class event_driven_thread */
#endif /* _EVENT_DRIVEN_THREAD_H_ */
#define _J(cmt, jobj) \
do { \
_SD("%s: %s", (cmt), jobj.str().c_str()); \
-} while(0)
+} while (0)
#define EMPTY_JSON_OBJECT "{}"
#define DEFAULT_PRECISION 3
/*
* Internal Macros
*/
-#define SMARTREPLY_LOGD(fmt,args...) LOGD(fmt, ##args)
-#define SMARTREPLY_LOGW(fmt,args...) LOGW(fmt, ##args)
-#define SMARTREPLY_LOGI(fmt,args...) LOGI(fmt, ##args)
-#define SMARTREPLY_LOGE(fmt,args...) LOGE(fmt, ##args)
-#define SMARTREPLY_SECLOG(fmt,args...) SECURE_LOGD(fmt, ##args)
+#define SMARTREPLY_LOGD(fmt, args...) LOGD(fmt, ##args)
+#define SMARTREPLY_LOGW(fmt, args...) LOGW(fmt, ##args)
+#define SMARTREPLY_LOGI(fmt, args...) LOGI(fmt, ##args)
+#define SMARTREPLY_LOGE(fmt, args...) LOGE(fmt, ##args)
+#define SMARTREPLY_SECLOG(fmt, args...) SECURE_LOGD(fmt, ##args)
#define SMARTREPLY_CHECK_CONDITION(condition, error, msg) \
do { \
#define SMARTREPLY_NULL_ARG_CHECK_RETURN_FALSE(arg)\
do { \
- if(arg != NULL) { \
+ if (arg != NULL) { \
} else { \
SMARTREPLY_LOGE("SMARTREPLY_ERROR_INVALID_PARAMETER"); \
return false; }; \
} while (0)
#define SMARTREPLY_NULL_ARG_CHECK(arg) \
- SMARTREPLY_CHECK_CONDITION(arg != NULL,SMARTREPLY_ERROR_INVALID_PARAMETER,"SMARTREPLY_ERROR_INVALID_PARAMETER")
+ SMARTREPLY_CHECK_CONDITION(arg != NULL, SMARTREPLY_ERROR_INVALID_PARAMETER, "SMARTREPLY_ERROR_INVALID_PARAMETER")
#define SMARTREPLY_PRINT_ERROR_CODE_RETURN(code) \
do{ \
return SMARTREPLY_ERROR_INVALID_PARAMETER; \
}
-#define SMR_MEM_DATA_CPY(dest,src,len,type) \
+#define SMR_MEM_DATA_CPY(dest, src, len, type) \
do{ \
- if(src!=NULL&&len>0) \
+ if (src != NULL && len > 0) \
{ \
dest = (type *) calloc (len+1 , sizeof (type)); \
assert(dest); \
memcpy(dest, src, len*sizeof(type)); \
} \
- } while(0);
+ } while (0);
guint reg_id = g_dbus_connection_register_object(dbus_connection, DBUS_PATH,
dbus_node_info->interfaces[0], &vtable, NULL, NULL, &gerr);
HANDLE_GERROR(gerr);
- IF_FAIL_RETURN_TAG(reg_id>0, false, _E, "Object registration failed");
+ IF_FAIL_RETURN_TAG(reg_id > 0, false, _E, "Object registration failed");
_I("Dbus connection established: %s", g_dbus_connection_get_unique_name(dbus_connection));
return true;
void g_async_ready_callback(GObject *source_object,
GAsyncResult *res,
gpointer user_data) {
-
_I("g_async_ready_callback");
GError *err = NULL;
int request_async(int type, int req_id, const char* subject, const char* input, void* ext, dbus_client_request_callback cb);
int request(int type, int req_id, const char* subject, const char* input, std::string* req_result, std::string* data_read);
int request_with_no_reply(int type, int req_id, const char* subject, const char* input);
-
}; /* classs smr::dbus_client */
} /* namespace smr */
event_message_s *event = NULL;
while (g_atomic_int_get(&thread_info.is_running)) {
-
event = static_cast<event_message_s*>(g_async_queue_pop(thread_info.event_queue));
if (event) {
delete event;
}
}
-
}
}
return tokens;
CATCH:
- for (j=0; j<i; j++) {
+ for (j = 0; j < i; j++) {
g_free(tokens[j]);
}
g_free(tokens);
{
int i;
if (tokens) {
- for (i=0; i<length; i++) {
+ for (i = 0; i < length; i++) {
g_free(tokens[i]);
}
g_free(tokens);
IF_FAIL_RETURN_TAG(path_token, NULL, _E, "Invalid path");
}
- for (depth=0; depth<length; depth++) {
+ for (depth = 0; depth < length; depth++) {
if (!json_object_has_member(jobj, path_token[depth])) {
if (force) {
child_obj = json_object_new();
int size = json_array_get_length(larr);
IF_FAIL_RETURN(size == static_cast<int>(json_array_get_length(rarr)), false);
- for (int i=0; i<size; ++i) {
+ for (int i = 0; i < size; ++i) {
json_node_t *lhs_child = json_array_get_element(larr, i);
json_node_t *rhs_child = json_array_get_element(rarr, i);
IF_FAIL_RETURN(node_equals(lhs_child, rhs_child), false);
_I("[remove_engine():Client Get Result] Error: %#x", error);
_SI("[remove_engine():Client Get Result] Result: %s", result_str.c_str());
return error;
-
}
-
namespace {
struct UserData {
void* ext;
};
void dbus_callback(int req_id, int error, void* ext, const std::string& req_result, const std::string& data_read) {
-
_I("dbus_callback");
UserData* ud = (UserData*)ext;
int req_id = generate_req_id();
int error = dbus_handle->request_with_no_reply(REQ_PREPARE_ENGINE, req_id, NULL, NULL);
-
-
+
_I("[prepare_engine():Client Get Result] Error: %#x", error);
return error;
}
std::string check_null_str(const char* str, const char* def) {
return std::string(str == NULL || (strlen(str) == 0) ? def : str);
-
}
int _list_add_all(smartreply_reply_h** candidate_list, int* length, std::string result_str)
const char* sender, const char* message, smartreply_reply_h** candidate_list, int* length)
{
int start = getTime();
-
+
ASSERT_NOT_NULL(message);
ASSERT_NOT_NULL(candidate_list);
ASSERT_NOT_NULL(length);
smartreply_message_s * _message;
_message = (smartreply_message_s*)cursor->data;
int len = strlen(_message->message);
-
+
string action_msg = _message->message;
//cout << action_msg << endl;
if (isAction(action_msg)) {
splitActionMessage(action_msg, atype, msg);
//cout << atype << " " << msg << endl;
SMR_MEM_DATA_CPY(temp, msg.c_str(), msg.length(), char);
- *reply_str = temp;
+ *reply_str = temp;
if (type != NULL) {
SMR_MEM_DATA_CPY(temp, atype.c_str(), atype.length(), char);
*type = temp;
- }
- }
- else {
+ }
+ } else {
SMR_MEM_DATA_CPY(temp, _message->message, len, char);
*reply_str = temp;
if (type != NULL) {
SMR_MEM_DATA_CPY(temp, "TEXT", strlen("TEXT"), char);
*type = temp;
- }
+ }
}
return SMARTREPLY_ERROR_NONE;
}
return err;
}
-EXPORT_API int smartreply_service_prepare_engine()
+EXPORT_API int smartreply_service_prepare_engine()
{
int err = smr::request_handler::send_prepare_engine();
return err;