aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorMichael <betheg@bitcloner.org>2014-09-07 14:06:23 +0200
committerMichael <betheg@bitcloner.org>2014-09-07 14:06:23 +0200
commitecd613dcdd4288b52fea893192c75f3e527436ea (patch)
tree5a09a1dc8093355fde000286f6c20ebeae713dd1 /src/eu/siacs/conversations/entities
parentd9990e6cd8bb4f2d9bc5696019f757db8a732b1f (diff)
MUC: set the password from bookmarks.
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r--src/eu/siacs/conversations/entities/Bookmark.java26
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java28
2 files changed, 52 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/entities/Bookmark.java b/src/eu/siacs/conversations/entities/Bookmark.java
index 596cbe01..14f010e7 100644
--- a/src/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/eu/siacs/conversations/entities/Bookmark.java
@@ -13,7 +13,9 @@ public class Bookmark implements ListItem {
private String jid;
private String nick;
private String name;
+ private String password;
private boolean autojoin;
+ private boolean providePassword;
private Conversation mJoinedConversation;
public Bookmark(Account account, String jid) {
@@ -35,6 +37,11 @@ public class Bookmark implements ListItem {
if (nick != null) {
bookmark.setNick(nick.getContent());
}
+ Element password = element.findChild("password");
+ if (password != null) {
+ bookmark.setPassword(password.getContent());
+ bookmark.setProvidePassword(true);
+ }
return bookmark;
}
@@ -50,6 +57,14 @@ public class Bookmark implements ListItem {
this.nick = nick;
}
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ private void setProvidePassword(boolean providePassword) {
+ this.providePassword = providePassword;
+ }
+
@Override
public int compareTo(ListItem another) {
return this.getDisplayName().compareToIgnoreCase(
@@ -81,6 +96,14 @@ public class Bookmark implements ListItem {
return autojoin;
}
+ public String getPassword() {
+ return this.password;
+ }
+
+ public boolean isProvidePassword() {
+ return this.providePassword;
+ }
+
public boolean match(String needle) {
return needle == null
|| getJid().contains(needle.toLowerCase(Locale.US))
@@ -125,6 +148,9 @@ public class Bookmark implements ListItem {
if (this.nick != null) {
element.addChild("nick").setContent(this.nick);
}
+ if (this.password != null && isProvidePassword()) {
+ element.addChild("password").setContent(this.password);
+ }
return element;
}
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index 72fbeeab..3988eae0 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -108,6 +108,7 @@ public class MucOptions {
private String subject = null;
private String joinnick;
private String password = null;
+ private boolean passwordChanged = false;
public MucOptions(Account account) {
this.account = account;
@@ -157,6 +158,10 @@ public class MucOptions {
}
aboutToRename = false;
}
+ if (conversation.getBookmark() != null &&
+ conversation.getBookmark().isProvidePassword()) {
+ this.passwordChanged = false;
+ }
} else {
addUser(user);
}
@@ -189,6 +194,10 @@ public class MucOptions {
this.error = ERROR_NICK_IN_USE;
}
} else if (error.hasChild("not-authorized")) {
+ if (conversation.getBookmark() != null &&
+ conversation.getBookmark().isProvidePassword()) {
+ this.passwordChanged = true;
+ }
this.error = ERROR_PASSWORD_REQUIRED;
}
}
@@ -314,10 +323,25 @@ public class MucOptions {
}
public String getPassword() {
- return this.password;
+ if (conversation.getBookmark() != null &&
+ conversation.getBookmark().getPassword() != null) {
+ return conversation.getBookmark().getPassword();
+ } else {
+ return this.password;
+ }
}
public void setPassword(String password) {
- this.password = password;
+ if (conversation.getBookmark() != null &&
+ conversation.getBookmark().isProvidePassword()) {
+ conversation.getBookmark().setPassword(password);
+ } else {
+ this.password = password;
+ }
+ }
+
+ public boolean isPasswordChanged() {
+ return this.passwordChanged;
}
+
} \ No newline at end of file