aboutsummaryrefslogtreecommitdiff
path: root/vala-xmpp/src/module/util.vala
blob: 65a9b2611d86a97ea40e1c16b330f10c4e0e3733 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace Xmpp {
    string? get_bare_jid(string jid) {
        return jid.split("/")[0];
    }

    bool is_bare_jid(string jid) {
        return !jid.contains("/");
    }

    string? get_resource_part(string jid) {
        return jid.split("/")[1];
    }

    public string random_uuid() {
        uint8[] rand = new uint8[16];
        char[] str = new char[37];
        UUID.generate_random(rand);
        UUID.unparse_upper(rand, str);
        return (string) str;
    }
}