1 20 21 package org.jivesoftware.smackx.packet; 22 23 import org.jivesoftware.smack.packet.PacketExtension; 24 25 31 public class MUCUser implements PacketExtension { 32 33 private Invite invite; 34 private Decline decline; 35 private Item item; 36 private String password; 37 private Status status; 38 private Destroy destroy; 39 40 public String getElementName() { 41 return "x"; 42 } 43 44 public String getNamespace() { 45 return "http://jabber.org/protocol/muc#user"; 46 } 47 48 public String toXML() { 49 StringBuffer buf = new StringBuffer (); 50 buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( 51 "\">"); 52 if (getInvite() != null) { 53 buf.append(getInvite().toXML()); 54 } 55 if (getDecline() != null) { 56 buf.append(getDecline().toXML()); 57 } 58 if (getItem() != null) { 59 buf.append(getItem().toXML()); 60 } 61 if (getPassword() != null) { 62 buf.append("<password>").append(getPassword()).append("</password>"); 63 } 64 if (getStatus() != null) { 65 buf.append(getStatus().toXML()); 66 } 67 if (getDestroy() != null) { 68 buf.append(getDestroy().toXML()); 69 } 70 buf.append("</").append(getElementName()).append(">"); 71 return buf.toString(); 72 } 73 74 81 public Invite getInvite() { 82 return invite; 83 } 84 85 91 public Decline getDecline() { 92 return decline; 93 } 94 95 100 public Item getItem() { 101 return item; 102 } 103 104 110 public String getPassword() { 111 return password; 112 } 113 114 119 public Status getStatus() { 120 return status; 121 } 122 123 130 public Destroy getDestroy() { 131 return destroy; 132 } 133 134 141 public void setInvite(Invite invite) { 142 this.invite = invite; 143 } 144 145 151 public void setDecline(Decline decline) { 152 this.decline = decline; 153 } 154 155 160 public void setItem(Item item) { 161 this.item = item; 162 } 163 164 170 public void setPassword(String string) { 171 password = string; 172 } 173 174 180 public void setStatus(Status status) { 181 this.status = status; 182 } 183 184 191 public void setDestroy(Destroy destroy) { 192 this.destroy = destroy; 193 } 194 195 202 public static class Invite { 203 private String reason; 204 private String from; 205 private String to; 206 207 213 public String getFrom() { 214 return from; 215 } 216 217 222 public String getReason() { 223 return reason; 224 } 225 226 231 public String getTo() { 232 return to; 233 } 234 235 241 public void setFrom(String from) { 242 this.from = from; 243 } 244 245 250 public void setReason(String reason) { 251 this.reason = reason; 252 } 253 254 259 public void setTo(String to) { 260 this.to = to; 261 } 262 263 public String toXML() { 264 StringBuffer buf = new StringBuffer (); 265 buf.append("<invite "); 266 if (getTo() != null) { 267 buf.append(" to=\"").append(getTo()).append("\""); 268 } 269 if (getFrom() != null) { 270 buf.append(" from=\"").append(getFrom()).append("\""); 271 } 272 buf.append(">"); 273 if (getReason() != null) { 274 buf.append("<reason>").append(getReason()).append("</reason>"); 275 } 276 buf.append("</invite>"); 277 return buf.toString(); 278 } 279 }; 280 281 287 public static class Decline { 288 private String reason; 289 private String from; 290 private String to; 291 292 298 public String getFrom() { 299 return from; 300 } 301 302 307 public String getReason() { 308 return reason; 309 } 310 311 316 public String getTo() { 317 return to; 318 } 319 320 326 public void setFrom(String from) { 327 this.from = from; 328 } 329 330 335 public void setReason(String reason) { 336 this.reason = reason; 337 } 338 339 344 public void setTo(String to) { 345 this.to = to; 346 } 347 348 public String toXML() { 349 StringBuffer buf = new StringBuffer (); 350 buf.append("<decline "); 351 if (getTo() != null) { 352 buf.append(" to=\"").append(getTo()).append("\""); 353 } 354 if (getFrom() != null) { 355 buf.append(" from=\"").append(getFrom()).append("\""); 356 } 357 buf.append(">"); 358 if (getReason() != null) { 359 buf.append("<reason>").append(getReason()).append("</reason>"); 360 } 361 buf.append("</decline>"); 362 return buf.toString(); 363 } 364 }; 365 366 371 public static class Item { 372 private String actor; 373 private String reason; 374 private String affiliation; 375 private String jid; 376 private String nick; 377 private String role; 378 379 385 public Item(String affiliation, String role) { 386 this.affiliation = affiliation; 387 this.role = role; 388 } 389 390 395 public String getActor() { 396 return actor == null ? "" : actor; 397 } 398 399 405 public String getReason() { 406 return reason == null ? "" : reason; 407 } 408 409 417 public String getAffiliation() { 418 return affiliation; 419 } 420 421 427 public String getJid() { 428 return jid; 429 } 430 431 437 public String getNick() { 438 return nick; 439 } 440 441 449 public String getRole() { 450 return role; 451 } 452 453 458 public void setActor(String actor) { 459 this.actor = actor; 460 } 461 462 468 public void setReason(String reason) { 469 this.reason = reason; 470 } 471 472 478 public void setJid(String jid) { 479 this.jid = jid; 480 } 481 482 488 public void setNick(String nick) { 489 this.nick = nick; 490 } 491 492 public String toXML() { 493 StringBuffer buf = new StringBuffer (); 494 buf.append("<item"); 495 if (getAffiliation() != null) { 496 buf.append(" affiliation=\"").append(getAffiliation()).append("\""); 497 } 498 if (getJid() != null) { 499 buf.append(" jid=\"").append(getJid()).append("\""); 500 } 501 if (getNick() != null) { 502 buf.append(" nick=\"").append(getNick()).append("\""); 503 } 504 if (getRole() != null) { 505 buf.append(" role=\"").append(getRole()).append("\""); 506 } 507 if (getReason() == null && getActor() == null) { 508 buf.append("/>"); 509 } 510 else { 511 buf.append(">"); 512 if (getReason() != null) { 513 buf.append("<reason>").append(getReason()).append("</reason>"); 514 } 515 if (getActor() != null) { 516 buf.append("<actor jid=\"").append(getActor()).append("\"/>"); 517 } 518 buf.append("</item>"); 519 } 520 return buf.toString(); 521 } 522 }; 523 524 530 public static class Status { 531 private String code; 532 533 538 public Status(String code) { 539 this.code = code; 540 } 541 542 548 public String getCode() { 549 return code; 550 } 551 552 public String toXML() { 553 StringBuffer buf = new StringBuffer (); 554 buf.append("<status code=\"").append(getCode()).append("\"/>"); 555 return buf.toString(); 556 } 557 }; 558 559 566 public static class Destroy { 567 private String reason; 568 private String jid; 569 570 571 576 public String getJid() { 577 return jid; 578 } 579 580 585 public String getReason() { 586 return reason; 587 } 588 589 594 public void setJid(String jid) { 595 this.jid = jid; 596 } 597 598 603 public void setReason(String reason) { 604 this.reason = reason; 605 } 606 607 public String toXML() { 608 StringBuffer buf = new StringBuffer (); 609 buf.append("<destroy"); 610 if (getJid() != null) { 611 buf.append(" jid=\"").append(getJid()).append("\""); 612 } 613 if (getReason() == null) { 614 buf.append("/>"); 615 } 616 else { 617 buf.append(">"); 618 if (getReason() != null) { 619 buf.append("<reason>").append(getReason()).append("</reason>"); 620 } 621 buf.append("</destroy>"); 622 } 623 return buf.toString(); 624 } 625 626 } 627 } | Popular Tags |