DaZeus  2.0
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
server.h
Go to the documentation of this file.
1 
6 #ifndef SERVER_H
7 #define SERVER_H
8 
9 #include <cassert>
10 #include <iostream>
11 #include <vector>
12 #include <string>
13 #include <stdint.h>
14 
15 #include "network.h"
16 
17 // #define SERVER_FULLDEBUG
18 
19 namespace dazeus {
20 
21 struct NetworkConfig;
22 
23 struct ServerConfig {
24  ServerConfig(std::string h = std::string(), NetworkConfig *n = 0, uint16_t p = 6667,
25  bool s = false, bool sv = true, uint8_t pr = 5) : host(h), port(p), priority(pr),
26  network(n), ssl(s), ssl_verify(sv) {}
29  const ServerConfig &operator=(const ServerConfig &s) { host = s.host; port = s.port;
30  priority = s.priority; network = s.network; ssl = s.ssl; ssl_verify = s.ssl_verify; return *this; }
31  std::string host;
32  uint16_t port;
33  uint8_t priority;
35  bool ssl;
36  bool ssl_verify;
37 };
38 
39 class Server
40 {
41 
42 
43 public:
44  Server(const ServerConfig *c, Network *n);
45  ~Server();
46  const ServerConfig *config() const;
47  std::string motd() const;
48  void addDescriptors(fd_set *in_set, fd_set *out_set, int *maxfd);
49  void processDescriptors(fd_set *in_set, fd_set *out_set);
50  static std::string toString(const Server*);
51 
52  void connectToServer();
54  void quit( const std::string &reason );
55  void whois( const std::string &destination );
56  void ctcpAction( const std::string &destination, const std::string &message );
57  void ctcpRequest( const std::string &destination, const std::string &message );
58  void join( const std::string &channel, const std::string &key = std::string() );
59  void part( const std::string &channel, const std::string &reason = std::string() );
60  void message( const std::string &destination, const std::string &message );
61  void names( const std::string &channel );
62  void ping();
63  void slotNumericMessageReceived( const std::string &origin, unsigned int code, const std::vector<std::string> &params);
64  void slotIrcEvent(const std::string &event, const std::string &origin, const std::vector<std::string> &params);
65  void slotDisconnected();
66 
67 private:
68  // explicitly disable copy constructor
69  Server(const Server&);
70  void operator=(const Server&);
71 
72  void ircEventMe( const std::string &eventname, const std::string &destination, const std::string &message);
73 
74  const ServerConfig *config_;
75  std::string motd_;
76  Network *network_;
77  void *irc_;
78  std::string in_whois_for_;
79  bool whois_identified_;
80  std::vector<std::string> in_names_;
81 };
82 
83 }
84 
85 #endif