#include <string.h>
#include <cstdarg>
#include "hs-helper.h"
Go to the source code of this file.
|
REQ_ERROR | get_value_uint16 (const afb_req_t request, const char *source, uint16_t *out_id) |
|
REQ_ERROR | get_value_int16 (const afb_req_t request, const char *source, int16_t *out_id) |
|
REQ_ERROR | get_value_int32 (const afb_req_t request, const char *source, int32_t *out_id) |
|
void | hs_add_object_to_json_object (struct json_object *j_obj, int count,...) |
|
void | hs_add_object_to_json_object_str (struct json_object *j_obj, int count,...) |
|
void | hs_add_object_to_json_object_func (struct json_object *j_obj, const char *verb_name, int count,...) |
|
int | hs_search_event_name_index (const char *value) |
|
REQ_ERROR get_value_int16 |
( |
const afb_req_t |
request, |
|
|
const char * |
source, |
|
|
int16_t * |
out_id |
|
) |
| |
get int16 value from source
Parameters
- request : Describes the request by bindings from afb-daemon
- source : input source
- out_id : output int16 value
Return
error code
Definition at line 82 of file hs-helper.cpp.
85 const char* tmp = afb_req_value (request, source);
90 long tmp_id = strtol(tmp,&endptr,10);
93 if( (tmp_id > INT16_MAX) || (tmp_id < INT16_MIN) )
102 *out_id = (int16_t)tmp_id;
REQ_ERROR get_value_int32 |
( |
const afb_req_t |
request, |
|
|
const char * |
source, |
|
|
int32_t * |
out_id |
|
) |
| |
get int32 value from source
Parameters
- request : Describes the request by bindings from afb-daemon
- source : input source
- out_id : output int32 value
Return
error code
Definition at line 118 of file hs-helper.cpp.
121 const char* tmp = afb_req_value (request, source);
126 long tmp_id = strtol(tmp,&endptr,10);
129 if( (tmp_id > INT32_MAX) || (tmp_id < INT32_MIN) )
138 *out_id = (int32_t)tmp_id;
REQ_ERROR get_value_uint16 |
( |
const afb_req_t |
request, |
|
|
const char * |
source, |
|
|
uint16_t * |
out_id |
|
) |
| |
get uint16 value from source
Parameters
- request : Describes the request by bindings from afb-daemon
- source : input source
- out_id : output uint16 value
Return
error code
Definition at line 46 of file hs-helper.cpp.
49 const char* tmp = afb_req_value (request, source);
54 long tmp_id = strtol(tmp,&endptr,10);
57 if( (tmp_id > UINT16_MAX) || (tmp_id < 0) )
66 *out_id = (uint16_t)tmp_id;
void hs_add_object_to_json_object |
( |
struct json_object * |
j_obj, |
|
|
int |
count, |
|
|
|
... |
|
) |
| |
add int object to json object
Parameters
- j_obj : the json object will join in int json object
- count : input parameter number
- ... : parameter list
Return
None
Definition at line 154 of file hs-helper.cpp.
157 va_start(args, count);
158 for(
int i = 0; i < count; ++i )
160 char *key = va_arg(args,
char*);
161 int value = va_arg(args,
int);
162 json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
void hs_add_object_to_json_object_func |
( |
struct json_object * |
j_obj, |
|
|
const char * |
verb_name, |
|
|
int |
count, |
|
|
|
... |
|
) |
| |
add new json object to json object
Parameters
- j_obj : the json object will join in new json object
- verb_name : new json object's verb value
- count : input parameter number
- ... : parameter list
Return
None
Definition at line 207 of file hs-helper.cpp.
210 va_start(args, count);
212 json_object_object_add(j_obj,
"verb", json_object_new_string(verb_name));
214 for(
int i = 0; i < count; ++i )
216 char *key = va_arg(args,
char*);
217 int value = va_arg(args,
int);
218 json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
void hs_add_object_to_json_object_str |
( |
struct json_object * |
j_obj, |
|
|
int |
count, |
|
|
|
... |
|
) |
| |
add string object to json object
Parameters
- j_obj : the json object will join in string json object
- count : input parameter number
- ... : parameter list
Return
None
Definition at line 180 of file hs-helper.cpp.
183 va_start(args, count);
184 for(
int i = 0; i < count; ++i )
186 char *key = va_arg(args,
char*);
187 char *value = va_arg(args,
char*);
188 json_object_object_add(j_obj, key, json_object_new_string(value));
int hs_search_event_name_index |
( |
const char * |
value | ) |
|
search event position in event list
Parameters
- value : searched event name
Return
event's index in event list
Definition at line 234 of file hs-helper.cpp.
236 size_t buf_size = 50;
239 for(
size_t i = 0 ; i < size ; ++i)
241 if(!strncmp(value,
evlist[i], buf_size))
Initial value:= {
"tap_shortcut",
"on_screen_message",
"on_screen_reply",
"showWindow",
"hideWindow",
"replyShowWindow",
"showNotification",
"showInformation",
"reserved"
}
Definition at line 22 of file hs-helper.cpp.