muc.vala
changeset 9 d3260253f0bd
parent 3 dd7a02c6d476
child 11 0f0cf428409f
--- a/muc.vala	Wed Oct 24 01:03:02 2012 +0400
+++ b/muc.vala	Wed Oct 24 14:08:16 2012 +0400
@@ -49,6 +49,7 @@
         public weak Conference conference;
         public string nick;
         public string real_jid;
+        public string status;
         public Affiliation affil;
         public Role role;
         public bool isme;
@@ -64,7 +65,7 @@
 
     public signal void state_changed(Conference conf, State old_state, State new_state, string description);
     public signal void on_join(Conference conf, Occupant occupant);
-    public signal void on_part(Conference conf, Occupant occupant);
+    public signal void on_part(Conference conf, Occupant occupant, string? status);
     public signal void on_role(Conference conf, Occupant occupant, Role prev);
     public signal void on_affil(Conference conf, Occupant occupant, Affiliation prev);
     public signal void on_nick(Conference conf, Occupant occupant, string prev);
@@ -170,8 +171,9 @@
                             if (occupant != null) {
                                 if (role == Role.NONE) {
                                     occupants.unset(from[1]);
+                                    var status_child = node.get_child("status");
                                     log("Muc", LogLevelFlags.LEVEL_INFO, "MUC<%s> %s has parted.", this.jid, from[1]);
-                                    module.on_part(this, occupant);
+                                    module.on_part(this, occupant, (status_child!=null) ? status_child.get_value() : null);
                                     if (occupant.isme) {
                                         _change_state(State.DISCONNECTED, "we became unavailable");
                                     }
@@ -194,19 +196,21 @@
                                     }
                                 }
                             } else {
-                                assert( role!= Role.NONE);
-                                occupant = new Occupant();
-                                occupant.role = role;
-                                occupant.affil = affil;
-                                occupant.nick = from[1];
-                                occupants[from[1]] = occupant;
-                                occupant.isme = statuses.contains(110);
-                                log("Muc", LogLevelFlags.LEVEL_INFO, "MUC<%s> %s has joined as %s/%s.", this.jid, from[1], affil.to_string(), role.to_string());
-                                if (statuses.contains(110)) {
-                                    this.nick = from[1];
-                                    _change_state(State.CONNECTED, "got own presence. we are "+this.nick);
-                                }
-                                module.on_join(this, occupant);
+                                if( role!= Role.NONE) {
+                                    occupant = new Occupant();
+                                    occupant.role = role;
+                                    occupant.affil = affil;
+                                    occupant.nick = from[1];
+                                    occupants[from[1]] = occupant;
+                                    occupant.isme = statuses.contains(110);
+                                    log("Muc", LogLevelFlags.LEVEL_INFO, "MUC<%s> %s has joined as %s/%s.", this.jid, from[1], affil.to_string(), role.to_string());
+                                    if (statuses.contains(110)) {
+                                        this.nick = from[1];
+                                        _change_state(State.CONNECTED, "got own presence. we are "+this.nick);
+                                    }
+                                    module.on_join(this, occupant);
+                                } else
+                                    log("Muc", LogLevelFlags.LEVEL_WARNING, "Got NONE role for new participant. Maybe we are reconnecting.");
                             }
                             
                             stdout.printf("User list: ");