diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-15 14:32:19 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-15 14:32:19 +0200 |
commit | 2ebd92b7a7b97c7ecca43eb1e3c7d408508aadb2 (patch) | |
tree | 1da6fc297af9d9fa655a0dbce407fa5ec1f878d4 /src/eu/siacs/conversations/entities | |
parent | 6031af86062757f86701e08962aa86121877fbf4 (diff) |
pushing bookmarks back to server
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r-- | src/eu/siacs/conversations/entities/Account.java | 9 | ||||
-rw-r--r-- | src/eu/siacs/conversations/entities/Bookmark.java | 31 | ||||
-rw-r--r-- | src/eu/siacs/conversations/entities/Conversation.java | 4 |
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 20abddcd0..ac62cf7b6 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 6c1d7258f..c4e151cb3 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 8e2c17843..70752adc2 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; + } } |