1 20 21 package org.jivesoftware.smackx.muc; 22 23 import org.jivesoftware.smackx.packet.DiscoverInfo; 24 import org.jivesoftware.smackx.Form; 25 26 33 public class RoomInfo { 34 35 38 private String room; 39 42 private String description = ""; 43 46 private String subject = ""; 47 50 private int occupantsCount = -1; 51 56 private boolean membersOnly; 57 61 private boolean moderated; 62 66 private boolean nonanonymous; 67 70 private boolean passwordProtected; 71 75 private boolean persistent; 76 77 RoomInfo(DiscoverInfo info) { 78 super(); 79 this.room = info.getFrom(); 80 this.membersOnly = info.containsFeature("muc_membersonly"); 82 this.moderated = info.containsFeature("muc_moderated"); 83 this.nonanonymous = info.containsFeature("muc_nonanonymous"); 84 this.passwordProtected = info.containsFeature("muc_passwordprotected"); 85 this.persistent = info.containsFeature("muc_persistent"); 86 Form form = Form.getFormFrom(info); 88 if (form != null) { 89 this.description = 90 (String ) form.getField("muc#roominfo_description").getValues().next(); 91 this.subject = (String ) form.getField("muc#roominfo_subject").getValues().next(); 92 this.occupantsCount = 93 Integer.parseInt((String ) form.getField("muc#roominfo_occupants").getValues() 94 .next()); 95 } 96 } 97 98 103 public String getRoom() { 104 return room; 105 } 106 107 112 public String getDescription() { 113 return description; 114 } 115 116 122 public String getSubject() { 123 return subject; 124 } 125 126 134 public int getOccupantsCount() { 135 return occupantsCount; 136 } 137 138 143 public boolean isMembersOnly() { 144 return membersOnly; 145 } 146 147 153 public boolean isModerated() { 154 return moderated; 155 } 156 157 162 public boolean isNonanonymous() { 163 return nonanonymous; 164 } 165 166 171 public boolean isPasswordProtected() { 172 return passwordProtected; 173 } 174 175 180 public boolean isPersistent() { 181 return persistent; 182 } 183 184 } 185 | Popular Tags |