aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r--src/eu/siacs/conversations/entities/Account.java9
-rw-r--r--src/eu/siacs/conversations/entities/Bookmark.java31
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java4
3 files changed, 35 insertions, 9 deletions
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index 20abddcd..ac62cf7b 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -309,4 +309,13 @@ public class Account extends AbstractEntity{
public List<Bookmark> getBookmarks() {
return this.bookmarks;
}
+
+ public boolean hasBookmarkFor(String conferenceJid) {
+ for(Bookmark bmark : this.bookmarks) {
+ if (bmark.getJid().equals(conferenceJid)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Bookmark.java b/src/eu/siacs/conversations/entities/Bookmark.java
index 6c1d7258..c4e151cb 100644
--- a/src/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/eu/siacs/conversations/entities/Bookmark.java
@@ -16,13 +16,13 @@ public class Bookmark implements ListItem {
private boolean autojoin;
private Conversation mJoinedConversation;
- public Bookmark(Account account) {
+ 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);
- bookmark.setJid(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"))) {
@@ -45,10 +45,6 @@ public class Bookmark implements ListItem {
this.name = name;
}
- public void setJid(String jid) {
- this.jid = jid;
- }
-
public void setNick(String nick) {
this.nick = nick;
}
@@ -60,8 +56,8 @@ public class Bookmark implements ListItem {
@Override
public String getDisplayName() {
- if (this.mJoinedConversation!=null) {
- return this.mJoinedConversation.getName(true);
+ if (this.mJoinedConversation!=null && (this.mJoinedConversation.getMucOptions().getSubject() != null)) {
+ return this.mJoinedConversation.getMucOptions().getSubject();
} else if (name!=null) {
return name;
} else {
@@ -109,4 +105,21 @@ public class Bookmark implements ListItem {
public String getName() {
return name;
}
+
+ public Element toElement() {
+ Element element = new Element("conference");
+ element.setAttribute("jid", this.getJid());
+ if (this.getName() != null) {
+ element.setAttribute("name", this.getName());
+ }
+ if (this.autojoin) {
+ element.setAttribute("autojoin", "true");
+ } else {
+ element.setAttribute("autojoin", "false");
+ }
+ if (this.nick != null) {
+ element.addChild("nick").setContent(this.nick);
+ }
+ return element;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 8e2c1784..70752adc 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -390,4 +390,8 @@ public class Conversation extends AbstractEntity {
this.bookmark.setConversation(null);
}
}
+
+ public Bookmark getBookmark() {
+ return this.bookmark;
+ }
}