00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <boost/shared_ptr.hpp>
00010 #include <string>
00011
00012 #include <Swiften/Elements/Payload.h>
00013 #include <Swiften/Elements/Form.h>
00014
00015 namespace Swift {
00019 class Command : public Payload {
00020 public:
00021 typedef boost::shared_ptr<Command> ref;
00022
00023 enum Status {Executing, Completed, Canceled, NoStatus};
00024 enum Action {Cancel, Execute, Complete, Prev, Next, NoAction};
00025
00026 struct Note {
00027 enum Type {Info, Warn, Error};
00028
00029 Note(std::string note, Type type) : note(note), type(type) {};
00030
00031 std::string note;
00032 Type type;
00033 };
00034
00035 public:
00036 Command(const std::string& node, const std::string& sessionID, Status status) { constructor(node, sessionID, NoAction, status);}
00037 Command(const std::string& node = "", const std::string& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); }
00038
00039 const std::string& getNode() const { return node_; }
00040 void setNode(const std::string& node) { node_ = node; }
00041
00042 const std::string& getSessionID() const { return sessionID_; }
00043 void setSessionID(const std::string& id) { sessionID_ = id; }
00044
00045 Action getAction() const { return action_; }
00046 void setAction(Action action) { action_ = action; }
00047
00048 void setExecuteAction(Action action) { executeAction_ = action; }
00049 Action getExecuteAction() const { return executeAction_; }
00050
00051 Status getStatus() const { return status_; }
00052 void setStatus(Status status) { status_ = status; }
00053
00054 void addAvailableAction(Action action) { availableActions_.push_back(action); }
00055 const std::vector<Action>& getAvailableActions() const { return availableActions_; }
00056 void addNote(const Note& note) { notes_.push_back(note); }
00057 const std::vector<Note>& getNotes() const { return notes_; }
00058
00059 Form::ref getForm() const { return form_; }
00060 void setForm(Form::ref payload) { form_ = payload; }
00061
00062 private:
00063 void constructor(const std::string& node, const std::string& sessionID, Action action, Status status) {
00064 node_ = node;
00065 sessionID_ = sessionID;
00066 action_ = action;
00067 status_ = status;
00068 executeAction_ = NoAction;
00069 }
00070
00071 private:
00072 std::string node_;
00073 std::string sessionID_;
00074 Action action_;
00075 Status status_;
00076 Action executeAction_;
00077 std::vector<Action> availableActions_;
00078 std::vector<Note> notes_;
00079 Form::ref form_;
00080 };
00081 }