Files
@ d85cfa46a783
Branch filter:
Location: libtransport.git/spectrum_manager/src/server.h - annotation
d85cfa46a783
3.5 KiB
text/plain
Twitter: Do not set status message for buddies not in Friends list
254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 254143e164d1 8f5a0d64f2ec 254143e164d1 254143e164d1 254143e164d1 bd9219797eb4 254143e164d1 254143e164d1 254143e164d1 254143e164d1 35c13f038f69 254143e164d1 5d3244bd8bf7 254143e164d1 254143e164d1 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 bd9219797eb4 5d3244bd8bf7 5d3244bd8bf7 5d3244bd8bf7 bd9219797eb4 254143e164d1 254143e164d1 a13c26fb9289 a13c26fb9289 5d3244bd8bf7 254143e164d1 5d3244bd8bf7 254143e164d1 5d3244bd8bf7 254143e164d1 5d3244bd8bf7 254143e164d1 254143e164d1 5d3244bd8bf7 5d3244bd8bf7 5d3244bd8bf7 254143e164d1 254143e164d1 254143e164d1 254143e164d1 8f5a0d64f2ec 8f5a0d64f2ec bd9219797eb4 bd9219797eb4 254143e164d1 | /**
* libtransport -- C++ library for easy XMPP Transports development
*
* Copyright (C) 2011, 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 <boost/program_options.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/assign.hpp>
#include <boost/bind.hpp>
#include <boost/signal.hpp>
#include "mongoose.h"
#include "managerconfig.h"
#include "transport/Config.h"
#include "transport/SQLite3Backend.h"
#include "transport/MySQLBackend.h"
#include "transport/PQXXBackend.h"
#include "transport/StorageBackend.h"
using namespace Transport;
class Server {
public:
struct session {
char session_id[33]; // Session ID, must be unique
char random[20]; // Random data used for extra user validation
char user[255]; // Authenticated user
time_t expire; // Expiration timestamp, UTC
bool admin;
};
/// Constructor.
Server(ManagerConfig *config, const std::string &config_file);
/// Destructor
virtual ~Server();
bool start();
void event_handler(struct mg_connection *nc, int ev, void *p);
private:
void serve_instance(struct mg_connection *conn, struct http_message *hm, const std::string &jid);
void serve_instances(struct mg_connection *conn, struct http_message *hm);
void serve_instances_start(struct mg_connection *conn, struct http_message *hm);
void serve_instances_stop(struct mg_connection *conn, struct http_message *hm);
void serve_instances_register(struct mg_connection *conn, struct http_message *hm);
void serve_instances_unregister(struct mg_connection *conn, struct http_message *hm);
void serve_users(struct mg_connection *conn, struct http_message *hm);
void serve_users_add(struct mg_connection *conn, struct http_message *hm);
void serve_onlineusers(struct mg_connection *conn, struct http_message *hm);
void serve_cmd(struct mg_connection *conn, struct http_message *hm);
void print_html(struct mg_connection *conn, struct http_message *hm, const std::string &html);
std::string send_command(const std::string &jid, const std::string &cmd);
private:
bool check_password(const std::string &user, const std::string &password);
session *new_session(const std::string &user);
session *get_session(struct http_message *hm);
void authorize(struct mg_connection *conn, struct http_message *hm);
bool is_authorized(const struct mg_connection *conn, struct http_message *hm);
void redirect_to(struct mg_connection *conn, struct http_message *hm, const char *where);
private:
struct mg_mgr m_mgr;
struct mg_connection *m_nc;
std::map<std::string, session *> sessions;
std::string m_user;
std::string m_password;
ManagerConfig *m_config;
std::string m_header;
std::string m_footer;
Config *m_storageCfg;
StorageBackend *m_storage;
};
|