diff options
author | Marvin W <git@larma.de> | 2018-01-12 21:03:09 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-01-28 00:38:47 +0100 |
commit | 782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch) | |
tree | 1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /xmpp-vala/src/module/roster | |
parent | d46d071e57e599e8cfb1780597cbecb36881c4d8 (diff) | |
download | dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip |
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala/src/module/roster')
-rw-r--r-- | xmpp-vala/src/module/roster/flag.vala | 6 | ||||
-rw-r--r-- | xmpp-vala/src/module/roster/item.vala | 11 | ||||
-rw-r--r-- | xmpp-vala/src/module/roster/module.vala | 8 | ||||
-rw-r--r-- | xmpp-vala/src/module/roster/versioning_module.vala | 2 |
4 files changed, 10 insertions, 17 deletions
diff --git a/xmpp-vala/src/module/roster/flag.vala b/xmpp-vala/src/module/roster/flag.vala index 43d185d9..2e93911e 100644 --- a/xmpp-vala/src/module/roster/flag.vala +++ b/xmpp-vala/src/module/roster/flag.vala @@ -1,14 +1,12 @@ using Gee; -using Xmpp.Core; - namespace Xmpp.Roster { public class Flag : XmppStreamFlag { public const string ID = "roster"; public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, ID); - public HashMap<string, Item> roster_items = new HashMap<string, Item>(); + public HashMap<Jid, Item> roster_items = new HashMap<Jid, Item>(); public string? iq_id; @@ -16,7 +14,7 @@ public class Flag : XmppStreamFlag { return roster_items.values; } - public Item? get_item(string jid) { + public Item? get_item(Jid jid) { return roster_items[jid]; } diff --git a/xmpp-vala/src/module/roster/item.vala b/xmpp-vala/src/module/roster/item.vala index 1e39fce2..2fbf03ef 100644 --- a/xmpp-vala/src/module/roster/item.vala +++ b/xmpp-vala/src/module/roster/item.vala @@ -1,7 +1,5 @@ using Gee; -using Xmpp.Core; - namespace Xmpp.Roster { public class Item { @@ -18,9 +16,10 @@ public class Item { public StanzaNode stanza_node; - public string jid { - get { return stanza_node.get_attribute(NODE_JID); } - set { stanza_node.set_attribute(NODE_JID, value); } + private Jid jid_; + public Jid jid { + get { return jid_ ?? (jid_ = Jid.parse(stanza_node.get_attribute(NODE_JID))); } + set { stanza_node.set_attribute(NODE_JID, value.to_string()); } } public string? name { @@ -42,4 +41,4 @@ public class Item { } } -}
\ No newline at end of file +} diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala index 85693686..5b15a43a 100644 --- a/xmpp-vala/src/module/roster/module.vala +++ b/xmpp-vala/src/module/roster/module.vala @@ -1,7 +1,5 @@ using Gee; -using Xmpp.Core; - namespace Xmpp.Roster { private const string NS_URI = "jabber:iq:roster"; @@ -16,7 +14,7 @@ public class Module : XmppStreamModule, Iq.Handler { public bool interested_resource = true; - public void add_jid(XmppStream stream, string jid, string? handle = null) { + public void add_jid(XmppStream stream, Jid jid, string? handle = null) { Item roster_item = new Item(); roster_item.jid = jid; if (handle != null) { @@ -25,7 +23,7 @@ public class Module : XmppStreamModule, Iq.Handler { roster_set(stream, roster_item); } - public void remove_jid(XmppStream stream, string jid) { + public void remove_jid(XmppStream stream, Jid jid) { Item roster_item = new Item(); roster_item.jid = jid; roster_item.subscription = Item.SUBSCRIPTION_REMOVE; @@ -37,7 +35,7 @@ public class Module : XmppStreamModule, Iq.Handler { * Set a handle for a jid * @param handle Handle to be set. If null, any handle will be removed. */ - public void set_jid_handle(XmppStream stream, string jid, string? handle) { + public void set_jid_handle(XmppStream stream, Jid jid, string? handle) { Flag flag = stream.get_flag(Flag.IDENTITY); Item item = flag.get_item(jid) ?? new Item() { jid=jid }; item.name = handle != null ? handle : ""; diff --git a/xmpp-vala/src/module/roster/versioning_module.vala b/xmpp-vala/src/module/roster/versioning_module.vala index ce87ec2a..aa683883 100644 --- a/xmpp-vala/src/module/roster/versioning_module.vala +++ b/xmpp-vala/src/module/roster/versioning_module.vala @@ -1,7 +1,5 @@ using Gee; -using Xmpp.Core; - namespace Xmpp.Roster { public class VersioningModule : XmppStreamModule { |