| skipped 242 lines |
243 | 243 | | |
244 | 244 | | boolean newRoomCreated = false; |
245 | 245 | | boolean exitingRoom = presenceType != null && "unavailable".equals(presenceType); |
246 | | - | final Element $x = element.getElement().getChild("x", "http://jabber.org/protocol/muc"); |
247 | | - | final Element password = $x == null ? null : $x.getChild("password"); |
| 246 | + | final Element xElement = element.getElement().getChild("x", "http://jabber.org/protocol/muc"); |
| 247 | + | final Element password = xElement == null ? null : xElement.getChild("password"); |
248 | 248 | | |
249 | 249 | | if (nickName == null) { |
250 | 250 | | throw new MUCException(Authorization.JID_MALFORMED); |
| skipped 8 lines |
259 | 259 | | newRoomCreated = true; |
260 | 260 | | } |
261 | 261 | | |
| 262 | + | // 'x' element is used only when occupant joins to room. But not |
| 263 | + | // allways: old clients may not use it. Thats why 'newOccupant' |
| 264 | + | // variable is still used |
| 265 | + | boolean enteringToRoom = xElement != null; |
262 | 266 | | boolean newOccupant = !room.isOccupantExistsByJid(senderJID); |
263 | 267 | | if (newOccupant && room.getConfig().isPasswordProtectedRoom()) { |
264 | 268 | | final String psw = password == null ? null : password.getCData(); |
265 | 269 | | final String roomPassword = room.getConfig().getPassword(); |
266 | 270 | | if (psw == null || !psw.equals(roomPassword)) { |
267 | | - | log.finest("Password '" + psw + "' is not match to room passsword '" + roomPassword + "' "); |
| 271 | + | log.finest("Password '" + psw + "' is not match to room password '" + roomPassword + "' "); |
268 | 272 | | throw new MUCException(Authorization.NOT_AUTHORIZED); |
269 | 273 | | } |
270 | 274 | | } |
271 | 275 | | |
272 | 276 | | final Affiliation affiliation = room.getAffiliation(senderJID.getBareJID()); |
273 | 277 | | |
274 | | - | // TODO |
275 | | - | // przepuszczac wlasciciela konta!!! |
276 | 278 | | if (!newRoomCreated && room.isRoomLocked() && !exitingRoom && affiliation != Affiliation.owner) { |
277 | 279 | | throw new MUCException(Authorization.ITEM_NOT_FOUND, "Room is locked"); |
278 | 280 | | } |
| skipped 17 lines |
296 | 298 | | throw new MUCException(Authorization.CONFLICT); |
297 | 299 | | } |
298 | 300 | | |
299 | | - | if (newOccupant) { |
| 301 | + | if (newOccupant || enteringToRoom) { |
300 | 302 | | |
301 | 303 | | // Service Sends Presence from Existing Occupants to New |
302 | 304 | | // Occupant |
| skipped 24 lines |
327 | 329 | | writer.write(Packet.packetInstance(presence)); |
328 | 330 | | } |
329 | 331 | | |
330 | | - | final Role newRole = getDefaultRole(room.getConfig(), affiliation); |
| 332 | + | if (newOccupant) { |
| 333 | + | final Role newRole = getDefaultRole(room.getConfig(), affiliation); |
331 | 334 | | |
332 | | - | log.finest("Occupant '" + nickName + "' <" + senderJID.toString() + "> is entering room " + roomJID |
333 | | - | + " as role=" + newRole.name() + ", affiliation=" + affiliation.name()); |
334 | | - | room.addOccupantByJid(JID.jidInstance(senderJID.toString()), nickName, newRole); |
| 335 | + | log.finest("Occupant '" + nickName + "' <" + senderJID.toString() + "> is entering room " + roomJID |
| 336 | + | + " as role=" + newRole.name() + ", affiliation=" + affiliation.name()); |
| 337 | + | room.addOccupantByJid(JID.jidInstance(senderJID.toString()), nickName, newRole); |
| 338 | + | } |
335 | 339 | | } |
336 | 340 | | |
337 | 341 | | room.updatePresenceByJid(senderJID, element.getElement()); |
| skipped 18 lines |
356 | 360 | | preparePresenceToAllOccupants(room, roomJID, nickName, affiliation, role, senderJID, newRoomCreated, null); |
357 | 361 | | } |
358 | 362 | | |
359 | | - | if (newOccupant) { |
| 363 | + | if (newOccupant || enteringToRoom) { |
360 | 364 | | this.delayDeliveryThread.put(room.getHistoryMessages(senderJID)); |
361 | 365 | | } |
362 | | - | if (newOccupant && room.getSubject() != null && room.getSubjectChangerNick() != null |
| 366 | + | if ((enteringToRoom || newOccupant) && room.getSubject() != null && room.getSubjectChangerNick() != null |
363 | 367 | | && room.getSubjectChangeDate() != null) { |
364 | 368 | | Element message = new Element("message", new String[] { "type", "from", "to" }, new String[] { "groupchat", |
365 | 369 | | roomJID + "/" + room.getSubjectChangerNick(), senderJID.toString() }); |
| skipped 54 lines |