summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGurmeen Bindra <gurmeen.bindra@isode.com>2012-04-23 15:06:39 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-27 11:06:27 (GMT)
commit19340ddc7dc929aad094eed3f6a3cd7f84d86a4b (patch)
treeb2c7f71c8e32b15c267b7d62b64f77fb5945d3b7 /src/com/isode/stroke/muc/MUCBookmark.java
parente2f24c6930603dbd016a6530f7d12b08c97ea900 (diff)
downloadstroke-19340ddc7dc929aad094eed3f6a3cd7f84d86a4b.zip
stroke-19340ddc7dc929aad094eed3f6a3cd7f84d86a4b.tar.bz2
MUC Administration related classes
This change ports the MUC Administration related classes from Swiften to stroke. Also includes the MUC initialisation code in the CoreClient. Test-information: tested the ported unit tests
Diffstat (limited to 'src/com/isode/stroke/muc/MUCBookmark.java')
-rw-r--r--src/com/isode/stroke/muc/MUCBookmark.java151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/com/isode/stroke/muc/MUCBookmark.java b/src/com/isode/stroke/muc/MUCBookmark.java
new file mode 100644
index 0000000..64f3d9d
--- /dev/null
+++ b/src/com/isode/stroke/muc/MUCBookmark.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Remko Tronçon.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.muc;
+
+import com.isode.stroke.elements.Storage;
+import com.isode.stroke.elements.Storage.Room;
+import com.isode.stroke.jid.JID;
+
+/**
+ * Class representing a Bookmark to mult-user chatrooms.
+ * The chatroom bookmarking function includes the ability to auto-join rooms on login.
+ *
+ */
+public class MUCBookmark {
+ private JID room_;
+ private String name_;
+ private String nick_;
+ private String password_;
+ private boolean autojoin_;
+
+ /**
+ * Constructor
+ * @param room storage room, not null
+ */
+ public MUCBookmark(Storage.Room room) {
+ this.name_ = room.name;
+ this.room_ = room.jid;
+ this.nick_ = room.nick;
+ this.password_ = room.password;
+ this.autojoin_ = room.autoJoin;
+ }
+
+ /**
+ * Constructor
+ * @param room room jabber id, not null
+ * @param bookmarkName name of bookmark, can be null
+ */
+ MUCBookmark(JID room, String bookmarkName) {
+ this.room_ = room;
+ this.name_ = bookmarkName;
+ this.autojoin_ = false;
+ }
+
+ /**
+ * Set the autojoin value which determines whether the client should
+ * automatically join the conference room on login.
+ * @param enabled true to enable and false otherwise
+ */
+ public void setAutojoin(boolean enabled) {
+ autojoin_ = enabled;
+ }
+
+ /**
+ * get the autojoin attribute value
+ * @return true or false
+ */
+ public boolean getAutojoin() {
+ return autojoin_;
+ }
+
+ /**
+ * Set the user's preferred roomnick for the chatroom.
+ * @param nick nickname, can be null
+ */
+ public void setNick(String nick) {
+ nick_ = nick;
+ }
+
+ /**
+ * Set an unencrypted string for the password needed to enter a password-protected room.
+ * For security reasons, use of this element is NOT RECOMMENDED.
+ * @param password password, can be null
+ */
+ public void setPassword(String password) {
+ password_ = password;
+ }
+
+ /**
+ * get the user's nick name
+ * @return nick name, can be null
+ */
+ public String getNick() {
+ return nick_;
+ }
+
+ /**
+ * Get the room password
+ * @return room password, can be null
+ */
+ public String getPassword() {
+ return password_;
+ }
+
+ /**
+ * Get the bookmark name
+ * @return bookmark name, can be null
+ */
+ public String getName() {
+ return name_;
+ }
+
+ /**
+ * Get the room's jabber ID
+ * @return room JID, not null
+ */
+ public JID getRoom() {
+ return room_;
+ }
+
+ /**
+ * Convert the bookmark to a room object
+ * @return room object, not null
+ */
+ public Room toStorage() {
+ Storage.Room room = new Storage.Room();
+ room.name = name_;
+ room.jid = room_;
+ if (nick_ != null) {
+ room.nick = nick_;
+ }
+ if (password_ != null) {
+ room.password = password_;
+ }
+ room.autoJoin = autojoin_;
+ return room;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) return true;
+ if(!(obj instanceof MUCBookmark)) return false;
+ MUCBookmark rhs = (MUCBookmark)obj;
+ if(!checkEqualsWhenNull(rhs.room_,room_)) return false;
+ if(!checkEqualsWhenNull(rhs.name_,name_)) return false;
+ if(!checkEqualsWhenNull(rhs.nick_,nick_)) return false;
+ if(!checkEqualsWhenNull(rhs.password_,password_)) return false;
+ if(!rhs.autojoin_ != autojoin_) return false;
+ return true;
+ }
+
+ private static boolean checkEqualsWhenNull(Object thisObj, Object otherObj){
+ return thisObj == null ? otherObj == null : thisObj.equals(otherObj);
+ }
+}