aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities/Bookmark.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/entities/Bookmark.java')
-rw-r--r--src/eu/siacs/conversations/entities/Bookmark.java67
1 files changed, 49 insertions, 18 deletions
diff --git a/src/eu/siacs/conversations/entities/Bookmark.java b/src/eu/siacs/conversations/entities/Bookmark.java
index 38c03410..14f010e7 100644
--- a/src/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/eu/siacs/conversations/entities/Bookmark.java
@@ -8,57 +8,75 @@ import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xml.Element;
public class Bookmark implements ListItem {
-
+
private Account account;
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) {
this.account = account;
this.jid = jid;
}
public static Bookmark parse(Element element, Account account) {
- Bookmark bookmark = new Bookmark(account,element.getAttribute("jid"));
+ Bookmark bookmark = new Bookmark(account, element.getAttribute("jid"));
bookmark.setName(element.getAttribute("name"));
String autojoin = element.getAttribute("autojoin");
- if (autojoin!=null && (autojoin.equals("true")||autojoin.equals("1"))) {
+ if (autojoin != null
+ && (autojoin.equals("true") || autojoin.equals("1"))) {
bookmark.setAutojoin(true);
} else {
bookmark.setAutojoin(false);
}
Element nick = element.findChild("nick");
- if (nick!=null) {
+ if (nick != null) {
bookmark.setNick(nick.getContent());
}
+ Element password = element.findChild("password");
+ if (password != null) {
+ bookmark.setPassword(password.getContent());
+ bookmark.setProvidePassword(true);
+ }
return bookmark;
}
public void setAutojoin(boolean autojoin) {
this.autojoin = autojoin;
}
-
+
public void setName(String name) {
this.name = name;
}
-
+
public void setNick(String nick) {
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(another.getDisplayName());
+ return this.getDisplayName().compareToIgnoreCase(
+ another.getDisplayName());
}
@Override
public String getDisplayName() {
- if (this.mJoinedConversation!=null && (this.mJoinedConversation.getMucOptions().getSubject() != null)) {
+ if (this.mJoinedConversation != null
+ && (this.mJoinedConversation.getMucOptions().getSubject() != null)) {
return this.mJoinedConversation.getMucOptions().getSubject();
- } else if (name!=null) {
+ } else if (name != null) {
return name;
} else {
return this.jid.split("@")[0];
@@ -69,20 +87,28 @@ public class Bookmark implements ListItem {
public String getJid() {
return this.jid.toLowerCase(Locale.US);
}
-
+
public String getNick() {
return this.nick;
}
-
+
public boolean autojoin() {
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))
- || getDisplayName().toLowerCase(Locale.US)
- .contains(needle.toLowerCase(Locale.US));
+ || getDisplayName().toLowerCase(Locale.US).contains(
+ needle.toLowerCase(Locale.US));
}
public Account getAccount() {
@@ -91,10 +117,12 @@ public class Bookmark implements ListItem {
@Override
public Bitmap getImage(int dpSize, Context context) {
- if (this.mJoinedConversation==null) {
- return UIHelper.getContactPicture(getDisplayName(), dpSize, context, false);
+ if (this.mJoinedConversation == null) {
+ return UIHelper.getContactPicture(getDisplayName(), dpSize,
+ context, false);
} else {
- return UIHelper.getContactPicture(this.mJoinedConversation, dpSize, context, false);
+ return UIHelper.getContactPicture(this.mJoinedConversation, dpSize,
+ context, false);
}
}
@@ -105,7 +133,7 @@ public class Bookmark implements ListItem {
public String getName() {
return name;
}
-
+
public Element toElement() {
Element element = new Element("conference");
element.setAttribute("jid", this.getJid());
@@ -120,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;
}