2017-03-02 14:37:32 +00:00
|
|
|
namespace Xmpp {
|
2017-04-18 15:53:25 +00:00
|
|
|
public string get_bare_jid(string jid) {
|
2017-03-02 14:37:32 +00:00
|
|
|
return jid.split("/")[0];
|
|
|
|
}
|
|
|
|
|
2017-03-11 00:25:45 +00:00
|
|
|
public bool is_bare_jid(string jid) {
|
2017-03-02 14:37:32 +00:00
|
|
|
return !jid.contains("/");
|
|
|
|
}
|
|
|
|
|
2017-03-11 00:25:45 +00:00
|
|
|
public string? get_resource_part(string jid) {
|
2017-03-02 14:37:32 +00:00
|
|
|
return jid.split("/")[1];
|
|
|
|
}
|
2017-03-10 15:02:32 +00:00
|
|
|
|
|
|
|
public string random_uuid() {
|
2017-03-12 21:23:25 +00:00
|
|
|
uint32 b1 = Random.next_int();
|
|
|
|
uint16 b2 = (uint16)Random.next_int();
|
|
|
|
uint16 b3 = (uint16)(Random.next_int() | 0x4000u) & ~0xb000u;
|
|
|
|
uint16 b4 = (uint16)(Random.next_int() | 0x8000u) & ~0x4000u;
|
|
|
|
uint16 b5_1 = (uint16)Random.next_int();
|
|
|
|
uint32 b5_2 = Random.next_int();
|
|
|
|
return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
|
2017-03-10 15:02:32 +00:00
|
|
|
}
|
2017-06-16 12:29:02 +00:00
|
|
|
}
|