00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <boost/smart_ptr/make_shared.hpp>
00010
00011 #include <Swiften/Base/API.h>
00012 #include <Swiften/Elements/Stanza.h>
00013 #include <Swiften/Elements/StatusShow.h>
00014
00015 namespace Swift {
00016 class SWIFTEN_API Presence : public Stanza {
00017 public:
00018 typedef boost::shared_ptr<Presence> ref;
00019
00020 enum Type { Available, Error, Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed };
00021
00022 Presence();
00023 Presence(const std::string& status);
00024 virtual ~Presence();
00025
00026 static ref create() {
00027 return boost::make_shared<Presence>();
00028 }
00029
00030 static ref create(const std::string& status) {
00031 return boost::make_shared<Presence>(status);
00032 }
00033
00034 static ref create(Presence::ref presence) {
00035 return boost::make_shared<Presence>(*presence);
00036 }
00037
00038 Type getType() const { return type_; }
00039 void setType(Type type) { type_ = type; }
00040
00041 StatusShow::Type getShow() const {
00042 boost::shared_ptr<StatusShow> show(getPayload<StatusShow>());
00043 if (show) {
00044 return show->getType();
00045 }
00046 return type_ == Available ? StatusShow::Online : StatusShow::None;
00047 }
00048
00049 void setShow(const StatusShow::Type &show) {
00050 updatePayload(boost::make_shared<StatusShow>(show));
00051 }
00052
00053 std::string getStatus() const;
00054 void setStatus(const std::string& status);
00055
00056 int getPriority() const;
00057 void setPriority(int priority);
00058
00059 boost::shared_ptr<Presence> clone() const {
00060 return boost::make_shared<Presence>(*this);
00061 }
00062
00063 bool isAvailable() const {
00064 return type_ == Available;
00065 }
00066
00067 private:
00068 Presence::Type type_;
00069 };
00070 }