* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#ifndef STG_CLIENT_H
-#define STG_CLIENT_H
+#ifndef __STG_RLM_CLIENT_H__
+#define __STG_RLM_CLIENT_H__
+
+#include "types.h"
-#include "stg/sgcp_proto.h" // Proto
-#include "stg/sgcp_types.h" // TransportType
#include "stg/os_int.h"
-#include <string>
-#include <vector>
-#include <utility>
+#include <boost/scoped_ptr.hpp>
-typedef std::vector<std::pair<std::string, std::string> > PAIRS;
+#include <string>
-struct RESULT
+namespace STG
+{
+namespace RLM
{
- PAIRS modify;
- PAIRS reply;
-};
-
-struct ChannelConfig {
- struct Error : std::runtime_error {
- Error(const std::string& message) : runtime_error(message) {}
- };
-
- ChannelConfig(std::string address);
-
- STG::SGCP::TransportType transport;
- std::string key;
- std::string address;
- uint16_t port;
-};
-class STG_CLIENT
+class Client
{
public:
- enum TYPE {
- AUTHORIZE,
- AUTHENTICATE,
- POST_AUTH,
- PRE_ACCT,
- ACCOUNT
- };
- struct Error : std::runtime_error {
- Error(const std::string& message) : runtime_error(message) {}
- };
+ explicit Client(const std::string& address);
+ ~Client();
- STG_CLIENT(const std::string& address);
- ~STG_CLIENT();
+ bool stop();
- static STG_CLIENT* get();
+ static Client* get();
static bool configure(const std::string& address);
- RESULT request(TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs);
+ RESULT request(REQUEST_TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs);
private:
- ChannelConfig m_config;
- STG::SGCP::Proto m_proto;
-
- void m_writeHeader(TYPE type, const std::string& userName, const std::string& password);
- void m_writePairBlock(const PAIRS& source);
- PAIRS m_readPairBlock();
+ class Impl;
+ boost::scoped_ptr<Impl> m_impl;
};
+} // namespace RLM
+} // namespace STG
+
#endif