00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <boost/optional.hpp>
00010
00011 #include <string>
00012 #include <Swiften/JID/JID.h>
00013 #include <Swiften/Elements/Storage.h>
00014
00015 namespace Swift {
00016 class MUCBookmark {
00017 public:
00018 MUCBookmark(const Storage::Room& room) {
00019 name_ = room.name;
00020 room_ = room.jid;
00021 nick_ = room.nick;
00022 password_ = room.password;
00023 autojoin_ = room.autoJoin;
00024 }
00025
00026 MUCBookmark(const JID& room, const std::string& bookmarkName) : room_(room), name_(bookmarkName), autojoin_(false) {
00027 }
00028
00029 void setAutojoin(bool enabled) {
00030 autojoin_ = enabled;
00031 }
00032
00033 bool getAutojoin() const {
00034 return autojoin_;
00035 }
00036
00037 void setNick(const boost::optional<std::string>& nick) {
00038 nick_ = nick;
00039 }
00040
00041 void setPassword(const boost::optional<std::string>& password) {
00042 password_ = password;
00043 }
00044
00045 const boost::optional<std::string>& getNick() const {
00046 return nick_;
00047 }
00048
00049 const boost::optional<std::string>& getPassword() const {
00050 return password_;
00051 }
00052
00053 const std::string& getName() const {
00054 return name_;
00055 }
00056
00057 const JID& getRoom() const {
00058 return room_;
00059 }
00060
00061 bool operator==(const MUCBookmark& rhs) const {
00062
00063 return rhs.room_ == room_ && rhs.name_ == name_ && rhs.nick_ == nick_ && rhs.autojoin_ == autojoin_;
00064 }
00065
00066 Storage::Room toStorage() const {
00067 Storage::Room room;
00068 room.name = name_;
00069 room.jid = room_;
00070 if (nick_) {
00071 room.nick = *nick_;
00072 }
00073 if (password_) {
00074 room.password = *password_;
00075 }
00076 room.autoJoin = autojoin_;
00077 return room;
00078 }
00079
00080 private:
00081 JID room_;
00082 std::string name_;
00083 boost::optional<std::string> nick_;
00084 boost::optional<std::string> password_;
00085 bool autojoin_;
00086 };
00087 }
00088