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.c117
1 files changed, 31 insertions, 86 deletions
diff --git a/src/sm-helper.c b/src/sm-helper.c
index b598faa..f2620ce 100644
--- a/src/sm-helper.c
+++ b/src/sm-helper.c
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include "sm-helper.h"
-#include "sm-def.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <json-c/json.h>
#include <stdarg.h>
+#include "sm-helper.h"
+#include "sm-error.h"
REQ_ERROR get_value_uint16(const struct afb_req request, const char *source, uint16_t *out_id)
{
@@ -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')
{
@@ -182,95 +182,40 @@ 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){
+bool send_result(ErrorCode ec, struct afb_req req, const char* function){
/* GError = NULL means success in case of gdbus request */
- if(result_of_send != NULL)
+ if(ec == UNABLE_SEND)
{
- AFB_ERROR("Unable to call %s", function);
- afb_req_fail_f(req, "failed", "Unable to call %s", function);
+ AFB_ERROR("Unable to call : %s", function);
+ afb_req_fail_f(req, "failed", "%s : %s", function,
+ get_response_audiomanager_massage_error(ec));
return false;
}
return true;
}
-bool send_result_no_resp(const GError* result_of_send, const char* function){
- if(result_of_send != NULL){
- AFB_ERROR("Unable to call %s", function);
+bool send_result_no_resp(ErrorCode ec, const char* function){
+ if(ec == UNABLE_SEND){
+ AFB_ERROR("Unable to call : %s", 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