summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-08-18 20:08:34 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-08-18 20:08:34 (GMT)
commite1f9cdc38b600d930760ed0e0b867ab739127f5a (patch)
tree928b9ad82c1341640631035ffa28fdf01dc4dcc5 /Swiften/Elements
parent6fd3078f8f512c74bfc54c3d31d6446098088a69 (diff)
downloadswift-e1f9cdc38b600d930760ed0e0b867ab739127f5a.zip
swift-e1f9cdc38b600d930760ed0e0b867ab739127f5a.tar.bz2
Added command parser.
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/Command.h28
-rw-r--r--Swiften/Elements/Form.h3
2 files changed, 22 insertions, 9 deletions
diff --git a/Swiften/Elements/Command.h b/Swiften/Elements/Command.h
index c802035..91ca915 100644
--- a/Swiften/Elements/Command.h
+++ b/Swiften/Elements/Command.h
@@ -7,13 +7,15 @@
#pragma once
#include "Swiften/Base/String.h"
+#include "Swiften/Base/Shared.h"
#include "Swiften/Elements/Payload.h"
+#include "Swiften/Elements/Form.h"
namespace Swift {
/**
* Ad-Hoc Command (XEP-0050).
*/
- class Command : public Payload {
+ class Command : public Payload, public Shared<Command> {
public:
enum Status {Executing, Completed, Canceled, NoStatus};
enum Action {Cancel, Execute, Complete, Prev, Next, NoAction};
@@ -29,26 +31,36 @@ namespace Swift {
public:
Command(const String& node, const String& sessionID, Status status) { constructor(node, sessionID, NoAction, status);}
- Command(const String& node, const String& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); }
+ Command(const String& node = "", const String& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); }
const String& getNode() const { return node_; }
+ void setNode(const String& node) { node_ = node; }
+
const String& getSessionID() const { return sessionID_; }
- Action getPerformedAction() const { return performedAction_; }
+ void setSessionID(const String& id) { sessionID_ = id; }
+
+ Action getAction() const { return action_; }
+ void setAction(Action action) { action_ = action; }
+
void setExecuteAction(Action action) { executeAction_ = action; }
Action getExecuteAction() const { return executeAction_; }
+
Status getStatus() const { return status_; }
+ void setStatus(Status status) { status_ = status; }
+
void addAvailableAction(Action action) { availableActions_.push_back(action); }
const std::vector<Action>& getAvailableActions() const { return availableActions_; }
void addNote(const Note& note) { notes_.push_back(note); }
const std::vector<Note>& getNotes() const { return notes_; }
- boost::shared_ptr<Payload> getPayload() const { return payload_; }
- void setPayload(boost::shared_ptr<Payload> payload) { payload_ = payload; }
+
+ Form::ref getForm() const { return form_; }
+ void setForm(Form::ref payload) { form_ = payload; }
private:
void constructor(const String& node, const String& sessionID, Action action, Status status) {
node_ = node;
sessionID_ = sessionID;
- performedAction_ = action;
+ action_ = action;
status_ = status;
executeAction_ = NoAction;
}
@@ -56,11 +68,11 @@ namespace Swift {
private:
String node_;
String sessionID_;
- Action performedAction_;
+ Action action_;
Status status_;
Action executeAction_;
std::vector<Action> availableActions_;
std::vector<Note> notes_;
- boost::shared_ptr<Payload> payload_;
+ Form::ref form_;
};
}
diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h
index ed77d2b..34068ee 100644
--- a/Swiften/Elements/Form.h
+++ b/Swiften/Elements/Form.h
@@ -11,6 +11,7 @@
#include "Swiften/Elements/Payload.h"
#include "Swiften/Elements/FormField.h"
#include "Swiften/Base/String.h"
+#include "Swiften/Base/Shared.h"
#include "Swiften/JID/JID.h"
namespace Swift {
@@ -19,7 +20,7 @@ namespace Swift {
* For the relevant Fields, the parsers and serialisers protect the API user against
* the strange multi-value instead of newline thing by transforming them.
*/
- class Form : public Payload {
+ class Form : public Payload, public Shared<Form> {
public:
enum Type { FormType, SubmitType, CancelType, ResultType };