aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r--xmpp-vala/src/module/roster/module.vala10
-rw-r--r--xmpp-vala/src/module/util.vala42
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/flag.vala9
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala14
4 files changed, 24 insertions, 51 deletions
diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala
index e0d8aeb3..4c1028fb 100644
--- a/xmpp-vala/src/module/roster/module.vala
+++ b/xmpp-vala/src/module/roster/module.vala
@@ -38,13 +38,11 @@ public class Module : XmppStreamModule, Iq.Handler {
* @param handle Handle to be set. If null, any handle will be removed.
*/
public void set_jid_handle(XmppStream stream, string jid, string? handle) {
- Item roster_item = new Item();
- roster_item.jid = jid;
- if (handle != null) {
- roster_item.name = handle;
- }
+ Flag flag = stream.get_flag(Flag.IDENTITY);
+ Item item = flag.get_item(jid) ?? new Item() { jid=jid };
+ item.name = handle != null ? handle : "";
- roster_set(stream, roster_item);
+ roster_set(stream, item);
}
public void on_iq_set(XmppStream stream, Iq.Stanza iq) {
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index a0621225..365170b0 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -20,44 +20,4 @@ namespace Xmpp {
uint32 b5_2 = Random.next_int();
return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
}
-
- public class Tuple<A,B> : Object {
- public A a { get; private set; }
- public B b { get; private set; }
-
- public Tuple(A a, B b) {
- this.a = a;
- this.b = b;
- }
-
- public static Tuple<A,B> create<A,B>(A a, B b) {
- return new Tuple<A,B>(a,b);
- }
- }
-
- public class Triple<A,B,C> : Tuple<A,B> {
- public C c { get; private set; }
-
- public Triple(A a, B b, C c) {
- base(a, b);
- this.c = c;
- }
-
- public static new Triple<A,B,C> create<A,B,C>(A a, B b, C c) {
- return new Triple<A,B,C>(a, b, c);
- }
- }
-
- public class Quadruple<A,B,C,D> : Triple<A,B,C> {
- public D d { get; private set; }
-
- public Quadruple(A a, B b, C c, D d) {
- base (a, b, c);
- this.d = d;
- }
-
- public static new Quadruple<A,B,C,D> create<A,B,C,D>(A a, B b, C c, D d) {
- return new Quadruple<A,B,C,D>(a, b, c, d);
- }
- }
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/xep/0045_muc/flag.vala b/xmpp-vala/src/module/xep/0045_muc/flag.vala
index cf729bf9..00383407 100644
--- a/xmpp-vala/src/module/xep/0045_muc/flag.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/flag.vala
@@ -8,6 +8,7 @@ public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "muc");
private HashMap<string, Gee.List<Feature>> room_features = new HashMap<string, Gee.List<Feature>>();
+ private HashMap<string, string> room_names = new HashMap<string, string>();
private HashMap<string, string> enter_ids = new HashMap<string, string>();
private HashMap<string, string> own_nicks = new HashMap<string, string>();
@@ -18,6 +19,8 @@ public class Flag : XmppStreamFlag {
private HashMap<string, HashMap<string, Affiliation>> affiliations = new HashMap<string, HashMap<string, Affiliation>>();
private HashMap<string, Role> occupant_role = new HashMap<string, Role>();
+ public string? get_room_name(string jid) { return room_names.has_key(jid) ? room_names[jid] : null; }
+
public bool has_room_feature(string jid, Feature feature) {
return room_features.has_key(jid) && room_features[jid].contains(feature);
}
@@ -59,6 +62,10 @@ public class Flag : XmppStreamFlag {
public string? get_muc_subject(string bare_jid) { return subjects[bare_jid]; }
+ internal void set_room_name(string jid, string name) {
+ room_names[jid] = name;
+ }
+
internal void set_room_features(string jid, Gee.List<Feature> features) {
room_features[jid] = features;
}
@@ -121,4 +128,4 @@ public class Flag : XmppStreamFlag {
internal override string get_id() { return IDENTITY.id; }
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 82a7d7a6..951ec7d1 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -10,6 +10,7 @@ private const string NS_URI_OWNER = NS_URI + "#owner";
private const string NS_URI_USER = NS_URI + "#user";
public enum MucEnterError {
+ NONE,
PASSWORD_REQUIRED,
BANNED,
ROOM_DOESNT_EXIST,
@@ -64,7 +65,7 @@ public class Module : XmppStreamModule {
public signal void room_configuration_changed(XmppStream stream, string jid, StatusCode code);
public signal void room_entered(XmppStream stream, string jid, string nick);
- public signal void room_enter_error(XmppStream stream, string jid, MucEnterError error);
+ public signal void room_enter_error(XmppStream stream, string jid, MucEnterError? error); // TODO "?" shoudln't be necessary (vala bug), remove someday
public signal void self_removed_from_room(XmppStream stream, string jid, StatusCode code);
public signal void removed_from_room(XmppStream stream, string jid, StatusCode? code);
@@ -213,7 +214,7 @@ public class Module : XmppStreamModule {
string bare_jid = get_bare_jid(presence.from);
ErrorStanza? error_stanza = presence.get_error();
if (flag.get_enter_id(bare_jid) == presence.id) {
- MucEnterError? error = null;
+ MucEnterError error = MucEnterError.NONE;
switch (error_stanza.condition) {
case ErrorStanza.CONDITION_NOT_AUTHORIZED:
if (ErrorStanza.TYPE_AUTH == error_stanza.type_) error = MucEnterError.PASSWORD_REQUIRED;
@@ -240,7 +241,7 @@ public class Module : XmppStreamModule {
if (ErrorStanza.TYPE_CANCEL == error_stanza.type_) error = MucEnterError.USE_RESERVED_ROOMNICK;
break;
}
- if (error != null) room_enter_error(stream, bare_jid, error);
+ if (error != MucEnterError.NONE) room_enter_error(stream, bare_jid, error);
flag.finish_muc_enter(bare_jid);
}
}
@@ -312,6 +313,13 @@ public class Module : XmppStreamModule {
Gee.List<Feature> features = new ArrayList<Feature>();
if (query_result != null) {
+
+ foreach (ServiceDiscovery.Identity identity in query_result.identities) {
+ if (identity.category == "conference") {
+ stream.get_flag(Flag.IDENTITY).set_room_name(jid, identity.name);
+ }
+ }
+
foreach (string feature in query_result.features) {
Feature? parsed = null;
switch (feature) {