public static void join(String name, String pass, int maxStanzas) { StaticData sd = StaticData.getInstance(); ConferenceGroup grp = sd.roster.initMuc(name, pass); // требуется для возможности нормального выхода // sd.roster.mucContact(name, Contact.ORIGIN_GC_MYSELF); // sd.roster.activeRooms.addElement(jid); JabberDataBlock x = new JabberDataBlock("x", null, null); x.setNameSpace("http://jabber.org/protocol/muc"); if (pass.length() != 0) { // adding password to presence x.addChild("password", pass); } JabberDataBlock history = x.addChild("history", null); history.setAttribute("maxstanzas", String.valueOf(maxStanzas)); history.setAttribute("maxchars", "32768"); try { long last = grp.getConference().lastMessageTime; long delay = (grp.conferenceJoinTime - last) / 1000; if (last != 0) history.setAttribute("seconds", String.valueOf(delay)); // todo: change to since } catch (Exception e) { } ; // sd.roster.groups.getGroup(name.substring(0, // name.indexOf('@'))).imageExpandedIndex=ImageList.ICON_GCJOIN_INDEX; sd.roster.sendPresence(name, null, x); sd.roster.reEnumRoster(); }
private void setMucMod() { JabberDataBlock iq = new Iq(victim.jid.getBareJid(), Iq.TYPE_SET, "itemmuc"); JabberDataBlock query = iq.addChildNs("query", "http://jabber.org/protocol/muc#admin"); // TODO: separate usecases to muc#owner, muc#admin and muc#moderator JabberDataBlock item = new JabberDataBlock("item", null, null); query.addChild(item); try { String rzn = reason.getValue(); String Nick = ""; if (rzn.charAt(0) == '!') { rzn = rzn.substring(1); } else { Nick = (myNick == null) ? myNick : myNick + ": "; } if (rzn.length() != 0 && myNick != null) { item.addChild("reason", Nick + rzn); } else { item.addChild("reason", Nick); } } catch (Exception e) { } switch (action) { case KICK: item.setAttribute("role", "none"); item.setAttribute("nick", victim.getNick()); break; case OUTCAST: item.setAttribute("affiliation", "outcast"); item.setAttribute("jid", victim.realJid); break; case PARTICIPANT: item.setAttribute("role", "participant"); item.setAttribute("nick", victim.getNick()); break; case VISITOR: item.setAttribute("role", "visitor"); item.setAttribute("nick", victim.getNick()); break; case MODERATOR: item.setAttribute("role", "moderator"); item.setAttribute("nick", victim.getNick()); break; case MEMBER: item.setAttribute("affiliation", "member"); item.setAttribute("jid", victim.realJid); break; case NONE: item.setAttribute("affiliation", "none"); item.setAttribute("jid", victim.realJid); break; case ADMIN: item.setAttribute("affiliation", "admin"); item.setAttribute("jid", victim.realJid); break; case OWNER: item.setAttribute("affiliation", "owner"); item.setAttribute("jid", victim.realJid); } StaticData.getInstance().roster.theStream.send(iq); }