aboutsummaryrefslogtreecommitdiffstats
path: root/src/sm-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sm-helper.c')
-rw-r--r--src/sm-helper.c98
1 files changed, 21 insertions, 77 deletions
diff --git a/src/sm-helper.c b/src/sm-helper.c
index a02d772..0ccd1c7 100644
--- a/src/sm-helper.c
+++ b/src/sm-helper.c
@@ -35,7 +35,7 @@ REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uin
/* error check of range */
if( (tmp_id > UINT16_MAX) || (tmp_id < 0) )
{
- return OUT_RANGE;
+ return OUT_OF_RANGE;
}
if(*endptr != '\0')
{
@@ -59,7 +59,7 @@ REQ_ERROR get_value_int16(const struct afb_req request, const char *source, int1
/* error check of range */
if( (tmp_id > INT16_MAX) || (tmp_id < INT16_MIN) )
{
- return OUT_RANGE;
+ return OUT_OF_RANGE;
}
if(*endptr != '\0')
{
@@ -83,7 +83,7 @@ REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int3
/* error check of range */
if( (tmp_id > INT32_MAX) || (tmp_id < INT32_MIN) )
{
- return OUT_RANGE;
+ return OUT_OF_RANGE;
}
if(*endptr != '\0')
{
@@ -187,80 +187,6 @@ int sm_search_routing_event_name_index(const char* value)
return ret;
}
-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)
-{
- GVariantBuilder builder;
-
- AFB_DEBUG("create sourceData %d", __LINE__);
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("(qqsqinb(ii)qa(in)aia(in)a(iin)a(iin))"));
- g_variant_builder_add (&builder, "q", sourceID);
- g_variant_builder_add (&builder, "q", domainID);
- g_variant_builder_add (&builder, "s", appname);
- g_variant_builder_add (&builder, "q", sourceClassID);
- g_variant_builder_add (&builder, "i", sourceState);
- g_variant_builder_add (&builder, "n", volume);
- g_variant_builder_add (&builder, "b", visible);
- g_variant_builder_add (&builder, "(ii)", availables.availability, availables.avalilable_reason);
- g_variant_builder_add (&builder, "q", interrupt);
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(in)"));
- g_variant_builder_open(&builder, G_VARIANT_TYPE("(in)"));
- g_variant_builder_add (&builder, "i", soundPropertyList.type);
- g_variant_builder_add (&builder, "n", soundPropertyList.value);
- g_variant_builder_close(&builder);
- g_variant_builder_close (&builder);
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE("ai"));
- g_variant_builder_add (&builder, "i", connectionFormatList);
- g_variant_builder_close (&builder);
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(in)"));
- g_variant_builder_open(&builder, G_VARIANT_TYPE("(in)"));
- g_variant_builder_add (&builder, "i", mainPropertyList.type);
- g_variant_builder_add (&builder, "n", mainPropertyList.value);
- g_variant_builder_close (&builder);
- g_variant_builder_close(&builder);
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iin)"));
- g_variant_builder_open(&builder, G_VARIANT_TYPE("(iin)"));
- g_variant_builder_add (&builder, "i", NConfRouting.type);
- g_variant_builder_add (&builder, "i", NConfRouting.status);
- g_variant_builder_add (&builder, "n", NConfRouting.parameter);
- g_variant_builder_close(&builder);
- g_variant_builder_close (&builder);
-
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iin)"));
- g_variant_builder_open(&builder, G_VARIANT_TYPE("(iin)"));
- g_variant_builder_add (&builder, "i", NConfCommand.type);
- g_variant_builder_add (&builder, "i", NConfCommand.status);
- g_variant_builder_add (&builder, "n", NConfCommand.parameter);
- g_variant_builder_close(&builder);
- g_variant_builder_close (&builder);
-
- AFB_DEBUG("created sourceData %d", __LINE__);
- return g_variant_builder_end (&builder);
-}
-
-GVariant* create_domain_data(struct domain_data* data)
-{
- GVariantBuilder builder;
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("(qsssbbn)"));
- g_variant_builder_add (&builder, "q", data->domainID);
- g_variant_builder_add (&builder, "s", data->name);
- g_variant_builder_add (&builder, "s", data->busname);
- g_variant_builder_add (&builder, "s", data->nodename);
- g_variant_builder_add (&builder, "b", data->early);
- g_variant_builder_add (&builder, "b", data->complete);
- g_variant_builder_add (&builder, "n", data->state);
- AFB_DEBUG("created domainData %d", __LINE__);
- return g_variant_builder_end (&builder);
-}
-
bool send_result(const GError* result_of_send, struct afb_req req, const char* function){
/* GError = NULL means success in case of gdbus request */
if(result_of_send != NULL)
@@ -278,4 +204,22 @@ bool send_result_no_resp(const GError* result_of_send, const char* function){
return false;
}
return true;
+}
+
+ErrorCode is_range_over_guint16(int source){
+ /* error check of range */
+ if( (source > UINT16_MAX) || (source < 0) )
+ {
+ return OUT_RANGE;
+ }
+ return OK;
+}
+
+ErrorCode is_range_over_gint16(int source){
+ /* error check of range */
+ if( (source > INT16_MAX) || (source < INT16_MIN) )
+ {
+ return OUT_RANGE;
+ }
+ return OK;
} \ No newline at end of file