aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0166_jingle/jingle_structs.vala
blob: 0f283e0e8bf30205522655576b906adca0668c75 (plain) (blame)
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
using Gee;
using Xmpp;

namespace Xmpp.Xep.Jingle {

    public errordomain IqError {
        BAD_REQUEST,
        NOT_ACCEPTABLE,
        NOT_IMPLEMENTED,
        UNSUPPORTED_INFO,
        OUT_OF_ORDER,
        RESOURCE_CONSTRAINT,
    }

    public errordomain Error {
        GENERAL,
        BAD_REQUEST,
        INVALID_PARAMETERS,
        UNSUPPORTED_TRANSPORT,
        UNSUPPORTED_SECURITY,
        NO_SHARED_PROTOCOLS,
        TRANSPORT_ERROR,
    }

    public enum Senders {
        BOTH,
        INITIATOR,
        NONE,
        RESPONDER;

        public string to_string() {
            switch (this) {
                case BOTH: return "both";
                case INITIATOR: return "initiator";
                case NONE: return "none";
                case RESPONDER: return "responder";
            }
            assert_not_reached();
        }

        public static Senders parse(string? senders) throws IqError {
            if (senders == null) return Senders.BOTH;
            switch (senders) {
                case "initiator": return Senders.INITIATOR;
                case "responder": return Senders.RESPONDER;
                case "both": return Senders.BOTH;
            }
            throw new IqError.BAD_REQUEST(@"invalid role $(senders)");
        }
    }

    public enum Role {
        INITIATOR,
        RESPONDER;

        public string to_string() {
            switch (this) {
                case INITIATOR: return "initiator";
                case RESPONDER: return "responder";
            }
            assert_not_reached();
        }

        public static Role parse(string role) throws IqError {
            switch (role) {
                case "initiator": return INITIATOR;
                case "responder": return RESPONDER;
            }
            throw new IqError.BAD_REQUEST(@"invalid role $(role)");
        }
    }

}