aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/util.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /xmpp-vala/src/module/util.vala
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala/src/module/util.vala')
-rw-r--r--xmpp-vala/src/module/util.vala36
1 files changed, 13 insertions, 23 deletions
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index e42c4768..1043dee1 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -1,32 +1,22 @@
using Gee;
namespace Xmpp {
- public string get_bare_jid(string jid) {
- return jid.split("/")[0];
- }
-
- public bool is_bare_jid(string jid) {
- return !jid.contains("/");
- }
-
- public string? get_resource_part(string jid) {
- return jid.split("/")[1];
- }
- public string random_uuid() {
- 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);
- }
+public string random_uuid() {
+ 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);
+}
public abstract class StanzaListener<T> : Object {
public abstract string action_group { get; }
public abstract string[] after_actions { get; }
- public abstract async void run(Core.XmppStream stream, T stanza);
+
+ public abstract async void run(XmppStream stream, T stanza);
}
public class StanzaListenerHolder<T> : Object {
@@ -42,14 +32,14 @@ public class StanzaListenerHolder<T> : Object {
resort_list();
}
- public async void run(Core.XmppStream stream, T stanza) {
+ public async void run(XmppStream stream, T stanza) {
foreach (StanzaListener<T> l in listeners) {
yield l.run(stream, stanza);
}
}
private bool set_contains_action(Gee.List<StanzaListener<T>> s, string[] actions) {
- foreach(StanzaListener<T> l in s) {
+ foreach (StanzaListener<T> l in s) {
if (l.action_group in actions) {
return true;
}