aboutsummaryrefslogtreecommitdiffstats
path: root/src/sm-error.h
blob: bc60175b275abfef57d0d35c09bf21672db192f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SM_ERROR_H
#define SM_ERROR_H
#include <glib.h>
#define _GNU_SOURCE
#define AFB_BINDING_VERSION 2
#include <afb/afb-binding.h>
#define IS_SEND_ERROR(...) is_send_error(__VA_ARGS__, __FUNCTION__)
#define IS_SEND_ERROR_WITHOUT_RETURN(...) is_send_error_without_return(__VA_ARGS__, __FUNCTION__)

char* get_response_audiomanager_massage_error(int am_error_code)
{
    switch (am_error_code){
        case 0:
            return "OK";
        case 1:
            return "unknown error";
        case 2:
            return "value out of range";
        case 3:
            return "not used";
        case 4:
            return "database error occured";
        case 5:
            return "the desired object already exists";
        case 6:
            return "there is no change";
        case 7:
            return "the desired action is not possible";
        case 8:
            return "the desired object is non existent";
        case 9:
            return "the asynchronous action was aborted";
        case 10:
            return "connectionFormat is not selected";
        case 11:
            return "communication error";
        case 100:
            return "desired event doesn't exist";
        default:
            return "Audio Manager responsed unknown error number";
    }
}

char* get_source_state_key(int am_source_state){
    switch (am_source_state){
        case 0:
            return "unknown";
        case 1:
            return "on";
        case 2:
            return "off";
        case 3:
            return "paused";
        default:
            return "";
    }
}

void is_send_error_without_return(GError* result_of_send, const char* function){
    if(result_of_send != NULL){
        AFB_ERROR("Unable to call %s", function);
    }
}

int is_send_error(GError* result_of_send, struct afb_req req, const char* function){
    if(result_of_send != NULL)
    {
        afb_req_fail_f(req, "failed", "Unable to call %s", function);
        return 0;
    }
    return -1;
}
#endif