21 #include <json-c/json.h> 27 const char* tmp = afb_req_value (request, source);
32 long tmp_id = strtol(tmp,&endptr,10);
35 if( (tmp_id > UINT16_MAX) || (tmp_id < 0) )
44 *out_id = (uint16_t)tmp_id;
51 const char* tmp = afb_req_value (request, source);
56 long tmp_id = strtol(tmp,&endptr,10);
59 if( (tmp_id > INT16_MAX) || (tmp_id < INT16_MIN) )
68 *out_id = (int16_t)tmp_id;
75 const char* tmp = afb_req_value (request, source);
80 long tmp_id = strtol(tmp,&endptr,10);
83 if( (tmp_id > INT32_MAX) || (tmp_id < INT32_MIN) )
92 *out_id = (int32_t)tmp_id;
99 va_start(args, count);
100 for(
int i = 0; i < count; ++i )
102 char *key = va_arg(args,
char*);
103 int value = va_arg(args,
int);
104 json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
113 va_start(args, count);
115 json_object_object_add(j_obj,
"verb", json_object_new_string(verb_name));
117 for(
int i = 0; i < count; ++i )
119 char *key = va_arg(args,
char*);
120 int value = va_arg(args,
int);
121 json_object_object_add(j_obj, key, json_object_new_int((int32_t)value));
129 size_t buf_size = 50;
130 size_t size =
sizeof cmd_evlist /
sizeof *cmd_evlist;
132 for(
size_t i = 0 ; i < size ; ++i)
134 if(!strncmp(value, cmd_evlist[i], buf_size))
145 size_t buf_size = 50;
146 size_t size =
sizeof route_evlist /
sizeof *route_evlist;
148 for(
size_t i = 0 ; i < size ; ++i)
150 if(!strncmp(value, route_evlist[i], buf_size))
159 GVariant*
create_source_data(guint16 sourceID, guint16 domainID,
const char* appname, guint16 sourceClassID,
160 gint32 sourceState, gint16 volume, gboolean visible,
struct availability_s availables,
161 guint16 interrupt,
struct sound_property_s soundPropertyList, gint32 connectionFormatList,
165 GVariantBuilder builder;
167 AFB_DEBUG(
"create sourceData %d", __LINE__);
168 g_variant_builder_init (&builder, G_VARIANT_TYPE (
"(qqsqinb(ii)qa(in)aia(in)a(iin)a(iin))"));
169 g_variant_builder_add (&builder,
"q", sourceID);
170 g_variant_builder_add (&builder,
"q", domainID);
171 g_variant_builder_add (&builder,
"s", appname);
172 g_variant_builder_add (&builder,
"q", sourceClassID);
173 g_variant_builder_add (&builder,
"i", sourceState);
174 g_variant_builder_add (&builder,
"n", volume);
175 g_variant_builder_add (&builder,
"b", visible);
177 g_variant_builder_add (&builder,
"q", interrupt);
179 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"a(in)"));
180 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"(in)"));
181 g_variant_builder_add (&builder,
"i", soundPropertyList.
type);
182 g_variant_builder_add (&builder,
"n", soundPropertyList.
value);
183 g_variant_builder_close(&builder);
184 g_variant_builder_close (&builder);
186 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"ai"));
187 g_variant_builder_add (&builder,
"i", connectionFormatList);
188 g_variant_builder_close (&builder);
190 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"a(in)"));
191 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"(in)"));
192 g_variant_builder_add (&builder,
"i", mainPropertyList.
type);
193 g_variant_builder_add (&builder,
"n", mainPropertyList.
value);
194 g_variant_builder_close (&builder);
195 g_variant_builder_close(&builder);
197 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"a(iin)"));
198 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"(iin)"));
199 g_variant_builder_add (&builder,
"i", NConfRouting.
type);
200 g_variant_builder_add (&builder,
"i", NConfRouting.
status);
201 g_variant_builder_add (&builder,
"n", NConfRouting.
parameter);
202 g_variant_builder_close(&builder);
203 g_variant_builder_close (&builder);
206 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"a(iin)"));
207 g_variant_builder_open(&builder, G_VARIANT_TYPE(
"(iin)"));
208 g_variant_builder_add (&builder,
"i", NConfCommand.
type);
209 g_variant_builder_add (&builder,
"i", NConfCommand.
status);
210 g_variant_builder_add (&builder,
"n", NConfCommand.
parameter);
211 g_variant_builder_close(&builder);
212 g_variant_builder_close (&builder);
214 AFB_DEBUG(
"created sourceData %d", __LINE__);
215 return g_variant_builder_end (&builder);
220 GVariantBuilder builder;
221 g_variant_builder_init (&builder, G_VARIANT_TYPE (
"(qsssbbn)"));
222 g_variant_builder_add (&builder,
"q", data->
domainID);
223 g_variant_builder_add (&builder,
"s", data->
name);
224 g_variant_builder_add (&builder,
"s", data->
busname);
225 g_variant_builder_add (&builder,
"s", data->
nodename);
226 g_variant_builder_add (&builder,
"b", data->
early);
227 g_variant_builder_add (&builder,
"b", data->
complete);
228 g_variant_builder_add (&builder,
"n", data->
state);
229 AFB_DEBUG(
"created domainData %d", __LINE__);
230 return g_variant_builder_end (&builder);
void sm_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int16_t *out_id)
int sm_search_event_name_index(const char *value)
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int32_t *out_id)
void sm_add_object_to_json_object(struct json_object *j_obj, int count,...)
GVariant * create_domain_data(struct domain_data *data)
GVariant * create_source_data(guint16 sourceID, guint16 domainID, const char *appname, guint16 sourceClassID, gint32 sourceState, gint16 volume, gboolean visible, struct availability_s availables, guint16 interrupt, struct sound_property_s soundPropertyList, gint32 connectionFormatList, struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting, struct notification_config_s NConfCommand)
int sm_search_routing_event_name_index(const char *value)