summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorGurmeen Bindra <gurmeen.bindra@isode.com>2012-04-17 08:59:20 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-19 10:45:48 (GMT)
commitc040dd31cf285f9e2ffddab859586badf6ae059e (patch)
tree0f24f533afce95dd85da16a01733d7f7f42087bb /src/com
parentcb7cb7fdb0564bd7c27680b371588a45277c000a (diff)
downloadstroke-c040dd31cf285f9e2ffddab859586badf6ae059e.zip
stroke-c040dd31cf285f9e2ffddab859586badf6ae059e.tar.bz2
Port elements for MUC Administration
This patch ports basic elements from swiftern to stroke. This includes various types od MUC Payloads. Test-information: the junits for the parsers (still WIP) code works fine.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/isode/stroke/elements/MUCAdminPayload.java42
-rw-r--r--src/com/isode/stroke/elements/MUCDestroyPayload.java58
-rw-r--r--src/com/isode/stroke/elements/MUCInvitationPayload.java110
-rw-r--r--src/com/isode/stroke/elements/MUCItem.java30
-rw-r--r--src/com/isode/stroke/elements/MUCOccupant.java130
-rw-r--r--src/com/isode/stroke/elements/MUCOwnerPayload.java51
-rw-r--r--src/com/isode/stroke/elements/MUCPayload.java115
-rw-r--r--src/com/isode/stroke/elements/MUCUserPayload.java138
8 files changed, 674 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/MUCAdminPayload.java b/src/com/isode/stroke/elements/MUCAdminPayload.java
new file mode 100644
index 0000000..e6f6b60
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCAdminPayload.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import java.util.Vector;
+
+/**
+ * Class representing MUC Admin Payload
+ *
+ */
+public class MUCAdminPayload extends Payload {
+
+ /**
+ * Create the object
+ */
+ public MUCAdminPayload() {
+ }
+
+ /**
+ * Add a MUC Item to the payload
+ * @param item MUC Item to be added, not null
+ */
+ public void addItem(MUCItem item) {
+ items_.add(item);
+ }
+
+ /**
+ * Get the MUC Items from the payload
+ * @return list of MUC items, can be empty but not null
+ */
+ public Vector<MUCItem> getItems() {
+ return items_;
+ }
+
+ private Vector<MUCItem> items_ = new Vector<MUCItem>();
+}
diff --git a/src/com/isode/stroke/elements/MUCDestroyPayload.java b/src/com/isode/stroke/elements/MUCDestroyPayload.java
new file mode 100644
index 0000000..86e7fa1
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCDestroyPayload.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2011, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing MUC Destroy Payload
+ *
+ */
+public class MUCDestroyPayload extends Payload{
+ private JID newVenue_;
+ private String reason_;
+
+ /**
+ * Create the Destroy payload
+ */
+ public MUCDestroyPayload() {
+ }
+
+ /**
+ * Get new venue jabber ID
+ * @return new venue, can be null if not set
+ */
+ public JID getNewVenue() {
+ return newVenue_;
+ }
+
+ /**
+ * Get the reason
+ * @return reason string, can be null if not set
+ */
+ public String getReason() {
+ return reason_;
+ }
+
+ /**
+ * Set the jabber ID for new Venue
+ * @param jid jabber ID, not null
+ */
+ public void setNewVenue(JID jid) {
+ newVenue_ = jid;
+ }
+
+ /**
+ * Set the reason string
+ * @param reason reason string, not null
+ */
+ public void setReason(String reason) {
+ reason_ = reason;
+ }
+}
diff --git a/src/com/isode/stroke/elements/MUCInvitationPayload.java b/src/com/isode/stroke/elements/MUCInvitationPayload.java
new file mode 100644
index 0000000..9d0195b
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCInvitationPayload.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2011, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing a MUC Invitation Payload
+ *
+ */
+public class MUCInvitationPayload extends Payload {
+ private boolean continuation_;
+ private JID jid_;
+ private String password_;
+ private String reason_;
+ private String thread_;
+
+ /**
+ * Create the payload
+ */
+ public MUCInvitationPayload() {
+ continuation_= false;
+ }
+
+ /**
+ * Set the continuation value
+ * @param b value to set
+ */
+ public void setIsContinuation(boolean b) {
+ continuation_ = b;
+ }
+
+ /**
+ * Get the continuation value
+ * @return continuation value
+ */
+ public boolean getIsContinuation() {
+ return continuation_;
+ }
+
+ /**
+ * Set the jabber ID
+ * @param jid jabber Id, not null
+ */
+ public void setJID(JID jid) {
+ jid_ = jid;
+ }
+
+ /**
+ * Get the jabber ID
+ * @return jabber ID, can be null if not set
+ */
+ public JID getJID(){
+ return jid_;
+ }
+
+ /**
+ * Set the password
+ * @param password not null
+ */
+ public void setPassword(String password) {
+ password_ = password;
+ }
+
+ /**
+ * Get the password
+ * @return password, can be null if not set
+ */
+ public String getPassword() {
+ return password_;
+ }
+
+ /**
+ * Set the reason text
+ * @param text reason text, not null
+ */
+ public void setReason(String text) {
+ reason_ = text;
+ }
+
+ /**
+ * Get the reason value
+ * @return reason value, null if not set
+ */
+ public String getReason() {
+ return reason_;
+ }
+
+ /**
+ * Set the value of describing the thread
+ * @param thread thread string, not null
+ */
+ public void setThread(String thread) {
+ thread_ = thread;
+ }
+
+ /**
+ * Get the string value for thread
+ * @return thread value, null if not set
+ */
+ public String getThread() {
+ return thread_;
+ }
+}
diff --git a/src/com/isode/stroke/elements/MUCItem.java b/src/com/isode/stroke/elements/MUCItem.java
new file mode 100644
index 0000000..cfbdd67
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCItem.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2011, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing a MUC Item
+ *
+ */
+public class MUCItem {
+ /**
+ * Create the MUC Item
+ */
+ public MUCItem() {
+ }
+
+ public JID realJID;
+ public String nick;
+ public MUCOccupant.Affiliation affiliation;
+ public MUCOccupant.Role role;
+ public JID actor;
+ public String reason;
+}
diff --git a/src/com/isode/stroke/elements/MUCOccupant.java b/src/com/isode/stroke/elements/MUCOccupant.java
new file mode 100644
index 0000000..d9b6048
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCOccupant.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing a MUC Occupant
+ *
+ */
+public class MUCOccupant {
+
+ /**
+ * MUC Role
+ *
+ */
+ public enum Role {
+ Moderator("moderator"),
+ Participant("participant"),
+ Visitor("visitor"),
+ NoRole("none");
+
+ Role(String name) {
+ this.nodeName = name;
+ }
+
+ public String nodeName;
+ };
+
+ /**
+ * MUC Affiliation of the user
+ *
+ */
+ public enum Affiliation {
+ Owner("owner"),
+ Admin("admin"),
+ Member("member"),
+ Outcast("outcast"),
+ NoAffiliation("none");
+
+ public String nodeName;
+
+ Affiliation(String name) {
+ this.nodeName = name;
+ }
+ };
+
+ /**
+ * Create the MUC Occupant object
+ * @param nick nick name, not null
+ * @param role MUC Role, not null
+ * @param affiliation MUC Affiliation, not null
+ */
+ public MUCOccupant(String nick, Role role, Affiliation affiliation) {
+ this.nick_ = nick;
+ this.role_ = role;
+ this.affiliation_ = affiliation;
+ }
+
+ /**
+ * Create a copy of the given MUC Occupant
+ * @param other object to copy from
+ */
+ public MUCOccupant(MUCOccupant other) {
+ this.nick_ = other.nick_;
+ this.role_ = other.role_;
+ this.affiliation_ = other.affiliation_;
+ this.realJID_ = new JID(other.realJID_ != null ? other.realJID_.toString() : "");
+ }
+
+ /**
+ * Get the nick name
+ * @return nick name, not null
+ */
+ public String getNick() {
+ return nick_;
+ }
+
+ /**
+ * Get the role
+ * @return role, not null
+ */
+ public Role getRole(){
+ return role_;
+ }
+
+ /**
+ * Get the affiliation of the user
+ * @return affiliation , not null
+ */
+ public Affiliation getAffiliation() {
+ return affiliation_;
+ }
+
+ /**
+ * Get the real Jabber ID of the user
+ * @return real Jabber ID, not null if set
+ */
+ public JID getRealJID(){
+ return realJID_;
+ }
+
+ /**
+ * Set the real Jabber ID
+ * @param jid Jabber ID, not null
+ */
+ public void setRealJID(JID jid) {
+ this.realJID_ = jid;
+ }
+
+ /**
+ * Set the nick name of the user
+ * @param nick nick name, not null
+ */
+ public void setNick(String nick) {
+ this.nick_ = nick;
+ }
+
+ private String nick_;
+ private Role role_;
+ private Affiliation affiliation_;
+ private JID realJID_;
+ /* If you add a field, remember to update the const copy constructor */
+}
diff --git a/src/com/isode/stroke/elements/MUCOwnerPayload.java b/src/com/isode/stroke/elements/MUCOwnerPayload.java
new file mode 100644
index 0000000..ac696b6
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCOwnerPayload.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+/**
+ * Class representing a MUC Owner Payload
+ *
+ */
+public class MUCOwnerPayload extends Payload {
+
+ /**
+ * Create the MUC Owner payload
+ */
+ public MUCOwnerPayload() {
+ }
+
+ /**
+ * Get the payload
+ * @return payload, not null if set
+ */
+ public Payload getPayload(){
+ return payload;
+ }
+
+ /**
+ * Set the payload
+ * @param p payload to set, nt null
+ */
+ public void setPayload(Payload p) {
+ payload = p;
+ }
+
+ /**
+ * Get the form object
+ * @return form, not null if payload is set to Form
+ */
+ public Form getForm() {
+ if(payload instanceof Form) {
+ return (Form)payload;
+ }
+ return null;
+ }
+
+ private Payload payload;
+}
diff --git a/src/com/isode/stroke/elements/MUCPayload.java b/src/com/isode/stroke/elements/MUCPayload.java
new file mode 100644
index 0000000..03b776e
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCPayload.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import java.util.Date;
+
+/**
+ * Class representing a MUC Payload
+ *
+ */
+public class MUCPayload extends Payload {
+ private int maxChars_;
+ private int maxStanzas_;
+ private int seconds_;
+ private Date since_;
+ private String password_;
+
+ /**
+ * Constructor
+ */
+ public MUCPayload() {
+ maxChars_ = -1;
+ maxStanzas_ = -1;
+ seconds_ = -1;
+ }
+
+ /**
+ * Set the maximum number of characters where character count is the characters of the
+ * complete XML stanzas, not only their XML character data
+ * @param maxChars maximum number of characters (positive value)
+ */
+ public void setMaxChars(int maxChars) {
+ maxChars_ = maxChars;
+ }
+
+ /**
+ * Set the maximum number of stanzas which means limiting the total number of messages
+ * @param maxStanzas maximum number of stanzas
+ */
+ public void setMaxStanzas(int maxStanzas) {
+ maxStanzas_ = maxStanzas;
+ }
+
+ /**
+ * Set the number of seconds which means send only the messages received in the
+ * last "X" seconds.
+ * @param seconds number of seconds
+ */
+ public void setSeconds(int seconds) {
+ seconds_ = seconds;
+ }
+
+ /**
+ * Set the date which means send only the messages received since the
+ * date/time specified
+ * @param since date-time, should not be null
+ */
+ public void setSince(Date since) {
+ since_ = since;
+ }
+
+ /**
+ * Set the MUC password
+ * @param password password, can be null
+ */
+ public void setPassword(String password) {
+ password_ = password;
+ }
+
+ /**
+ * Get the maximum number of characters
+ * @return max characters
+ */
+ public int getMaxChars() {
+ return maxChars_;
+ }
+
+ /**
+ * Get the maximum number of stanzas
+ * @return max stanzas
+ */
+ public int getMaxStanzas(){
+ return maxStanzas_;
+ }
+
+ /**
+ * Get the number of seconds
+ * @return number of seconds
+ */
+ public int getSeconds() {
+ return seconds_;
+ }
+
+ /**
+ * Get the password
+ * @return password, can be null if not set
+ */
+ public String getPassword() {
+ return password_;
+ }
+
+ /**
+ * Get the date specified to limit the stazas
+ * @return date, ca be null if not set
+ */
+ public Date getSince() {
+ return since_;
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/MUCUserPayload.java b/src/com/isode/stroke/elements/MUCUserPayload.java
new file mode 100644
index 0000000..966f235
--- /dev/null
+++ b/src/com/isode/stroke/elements/MUCUserPayload.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import java.util.Vector;
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing a MUC User Payload
+ *
+ */
+public class MUCUserPayload extends Payload {
+ public static class StatusCode {
+ public int code;
+ public StatusCode() {
+ code = 0;
+ }
+ public StatusCode(int code) {
+ this.code = code;
+ }
+ };
+
+ /**
+ * Class representing an Invite stanza.
+ * Reason is optional while "from" and "to" are mutually exclusive.
+ * "From" is used for MUC sending to invited client and is the JID
+ * the MUC claims the invite is from.
+ * "To" is used sending to MUC from inviting client and is the
+ * JID to send the invite to.
+ */
+ public static class Invite {
+ public JID from;
+ public String reason;
+ public JID to;
+ };
+
+ public Invite invite_;
+
+ public String password_;
+
+ public Payload payload_;
+
+ public Vector<StatusCode> statusCodes_ = new Vector<StatusCode>();
+
+ private Vector<MUCItem> items_ = new Vector<MUCItem>();
+
+ /**
+ * Constructor
+ */
+ public MUCUserPayload() {
+ }
+
+ /**
+ * Add a MUC Item
+ * @param item item to be added, not null
+ */
+ public void addItem(MUCItem item) {
+ items_.add(item);
+ }
+
+ /**
+ * Add status code
+ * @param code status code, not null
+ */
+ public void addStatusCode(StatusCode code) {
+ statusCodes_.add(code);
+ }
+
+ /**
+ * Get the invite object
+ * @return invite object, null if not set
+ */
+ public Invite getInvite() {
+ return invite_;
+ }
+
+ /**
+ * Get the list of MUC items
+ * @return list of MUC Items, can be empty but not null
+ */
+ public Vector<MUCItem> getItems() {
+ return items_;
+ }
+
+ /**
+ * Get the password for the room
+ * @return room password, can be null
+ */
+ public String getPassword() {
+ return password_;
+ }
+
+ /**
+ * Get the payload
+ * @return payload, null if not set
+ */
+ public Payload getPayload() {
+ return payload_;
+ }
+
+ /**
+ * Get the list of status codes
+ * @return list of status codes, can be empty but not null
+ */
+ public Vector<StatusCode> getStatusCodes() {
+ return statusCodes_;
+ }
+
+ /**
+ * Set the invite value
+ * @param invite invite value, not null
+ */
+ public void setInvite(Invite invite) {
+ invite_ = invite;
+ }
+
+ /**
+ * Set the password for the MUC
+ * @param password password, can be null
+ */
+ public void setPassword(String password) {
+ password_ = password;
+ }
+
+ /**
+ * Set the payload
+ * @param p payload, not null
+ */
+ public void setPayload(Payload p) {
+ payload_ = p;
+ }
+}