Files
@ 84ea5f324921
Branch filter:
Location: libtransport.git/include/transport/AdminInterfaceCommand.h - annotation
84ea5f324921
2.9 KiB
text/plain
Libtransport, Web Interface: Rewrite the AdminInterface to support pluggable commands - use this API in Web Interface instead of coding one page per command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 84ea5f324921 | /**
* libtransport -- C++ library for easy XMPP Transports development
*
* Copyright (C) 2016, Jan Kaluza <hanzz.k@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#pragma once
#include <string>
#include <map>
#include "Swiften/Elements/Message.h"
#include "transport/StorageBackend.h"
namespace Transport {
class User;
class AdminInterfaceCommand {
public:
typedef enum {
GlobalContext,
UserContext
} Context;
typedef enum {
None = 0,
Get = 1,
Set = 2,
Execute = 4
} Actions;
typedef enum {
AdminMode,
UserMode
} AccessMode;
typedef enum {
General,
Users,
Messages,
Frontend,
Backends,
Memory
} Category;
class Arg {
public:
Arg(const std::string &_name, const std::string &_label, const std::string &_example) :
name(_name), label(_label), example(_example) {}
~Arg() {}
std::string name;
std::string label;
std::string example;
};
AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions);
virtual ~AdminInterfaceCommand() { }
void setDescription(const std::string &desc) {
m_desc = desc;
}
const std::string &getDescription() {
return m_desc;
}
const std::string &getName() {
return m_name;
}
Actions getActions() {
return m_actions;
}
Category getCategory() {
return m_category;
}
const std::string getCategoryName(Category category);
Context getContext() {
return m_context;
}
AccessMode getAccessMode() {
return m_accessMode;
}
void addArg(const std::string &name, const std::string &label, const std::string &example = "") {
Arg arg(name, label, example);
m_args.push_back(arg);
}
const std::list<Arg> &getArgs() {
return m_args;
}
virtual std::string handleSetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
virtual std::string handleGetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
private:
std::string m_name;
Category m_category;
Context m_context;
AccessMode m_accessMode;
Actions m_actions;
std::string m_desc;
std::list<Arg> m_args;
};
}
|