Skip to content

Commit fc8c153

Browse files
committed
Still need to work out what to do with TLS and XML; need to add a state machine to the XMPP client.
1 parent 35f3d1a commit fc8c153

File tree

14 files changed

+73
-67
lines changed

14 files changed

+73
-67
lines changed

boost/network/auth/sasl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ class basic_sasl {
2828
typedef typename string<Tag>::type string_type;
2929

3030
// explicit basic_sasl(anonymous);
31-
//
31+
//
3232
// explicit basic_sasl(plain,
3333
// const string_type &id, const string_type &password);
34-
//
34+
//
3535
// explicit basic_sasl(digest_md5,
3636
// const string_type &challenge,const string_type &jid, const string_type &password);
3737

3838
private:
3939

4040
string_type auth_string_;
41-
41+
4242
};
4343
} // namespace auth
4444
} // namespace network

boost/network/protocol/xmpp/client.hpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,24 @@ class basic_client : boost::noncopyable {
4949

5050
private:
5151

52+
enum connection_state {
53+
disconnected,
54+
processing_stream_features,
55+
processing_starttls
56+
};
57+
5258
typedef basic_client<Tag, version_major, version_minor, Handler> this_type;
5359
typedef typename detail::parser_backend<Tag>::type parser_type;
5460

5561
public:
5662

5763
typedef typename string<Tag>::type string_type;
58-
64+
5965
typedef basic_message<Tag> message_type;
6066
typedef basic_presence<Tag> presence_type;
6167
typedef basic_iq<Tag> iq_type;
6268
typedef basic_error<Tag> error_type;
63-
69+
6470
explicit basic_client(Handler &handler);
6571

6672
~basic_client();
@@ -100,7 +106,7 @@ class basic_client : boost::noncopyable {
100106

101107
// tcp socket
102108
boost::asio::ip::tcp::socket socket_;
103-
109+
104110
// tls
105111
// sasl
106112

@@ -112,7 +118,7 @@ class basic_client : boost::noncopyable {
112118

113119
// std::deque<std::string> stanza_queue_;
114120
std::string write_buffer_, read_buffer_;
115-
121+
116122
};
117123

118124

@@ -124,7 +130,7 @@ template <
124130
>
125131
basic_client<Tag, version_major, version_minor, Handler>::basic_client(Handler &handler)
126132
: handler_(handler), socket_(io_service_), work_(io_service_) {
127-
133+
128134
}
129135

130136

@@ -135,7 +141,7 @@ template <
135141
class Handler
136142
>
137143
basic_client<Tag, version_major, version_minor, Handler>::~basic_client() {
138-
144+
139145
}
140146

141147
template <
@@ -145,7 +151,7 @@ template <
145151
class Handler
146152
>
147153
void basic_client<Tag, version_major, version_minor, Handler>::set_lang(const string_type &lang) {
148-
154+
149155
}
150156

151157

@@ -158,7 +164,7 @@ template <
158164
void basic_client<Tag, version_major, version_minor, Handler>::connect(const string_type &jid,
159165
const string_type &password) {
160166
using boost::asio::ip::tcp;
161-
167+
162168
// get the JID domain
163169
// default port is 5222
164170
// open socket
@@ -254,7 +260,7 @@ void basic_client<Tag, version_major, version_minor, Handler>::handle_connect(
254260
boost::asio::ip::tcp::resolver::iterator iterator) {
255261
if (!ec) {
256262
std::ostringstream os;
257-
os <<
263+
os <<
258264
"<?xml version=\"1.0\"?>" <<
259265
"<stream:stream to=\"" << "127.0.0.1" << "\" " <<
260266
"version=\"" << version_major << "." << version_minor << "\" " <<
@@ -403,7 +409,7 @@ struct client : basic_client<tags::default_, 1, 0, Handler> {
403409

404410
explicit client(Handler &handler)
405411
: basic_client<tags::default_, 1, 0, Handler>(handler) {
406-
412+
407413
}
408414

409415
};

boost/network/protocol/xmpp/error.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class basic_error
2222
public:
2323

2424
basic_error() {
25-
25+
2626
}
27-
27+
2828
};
2929

3030

boost/network/protocol/xmpp/iq.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class basic_iq
2929
typedef typename base_type::headers_container_type headers_container_type;
3030

3131
basic_iq() {
32-
static const char name[] = {'i', 'q'};
32+
static const char name[] = {'i', 'q', 0};
3333
base_type::set_name(string_type(name, name + sizeof(name)));
3434
}
3535

3636
basic_iq(const basic_iq &other)
3737
: basic_stanza<Tag>(other) {
38-
38+
3939
}
4040

4141
basic_iq &operator = (const basic_iq &other) {
@@ -45,14 +45,14 @@ class basic_iq
4545
}
4646

4747
~basic_iq() {
48-
48+
4949
}
5050

5151
void swap(basic_iq &other) {
5252
base_type::swap(other);
5353
}
54-
55-
};
54+
55+
};
5656

5757

5858
typedef basic_iq<tags::default_> iq;

boost/network/protocol/xmpp/message.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class basic_message
2929
typedef typename base_type::headers_container_type headers_container_type;
3030

3131
basic_message() {
32-
static const char name[] = {'m', 'e', 's', 's', 'a', 'g', 'e'};
32+
static const char name[] = {'m', 'e', 's', 's', 'a', 'g', 'e', 0};
3333
base_type::set_name(string_type(name, name + sizeof(name)));
3434
}
3535

3636
basic_message(const basic_message &other)
3737
: basic_stanza<Tag>(other) {
38-
38+
3939
}
4040

4141
basic_message &operator = (const basic_message &other) {
@@ -45,33 +45,33 @@ class basic_message
4545
}
4646

4747
~basic_message() {
48-
48+
4949
}
5050

5151
void swap(basic_message &other) {
5252
base_type::swap(other);
5353
}
5454

5555
void set_type(const string_type &type) {
56-
static const char *type_ = "type";
56+
static const char type_[] = {'t', 'y', 'p', 'e', 0};
5757
set_attribute(string_type(type_, type_ + std::strlen(type_)), type);
5858
}
5959

6060
string_type type() const {
61-
static const char *type_ = "type";
61+
static const char type_[] = {'t', 'y', 'p', 'e', 0};
6262
return get_attribute(string_type(type_, type_ + std::strlen(type_)));
6363
}
6464

6565
void set_id(const string_type &id) {
66-
static const char *id_ = "id";
66+
static const char id_[] = {'i', 'd', 0};
6767
set_attribute(string_type(id_, id_ + std::strlen(id_)), id);
6868
}
6969

7070
string_type id() const {
71-
static const char *id_ = "id";
71+
static const char id_[] = {'i', 'd', 0};
7272
return get_attribute(string_type(id_, id_ + std::strlen(id_)));
7373
}
74-
74+
7575
};
7676

7777

boost/network/protocol/xmpp/namespaces.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template <
2121
inline
2222
typename string<Tag>::type client() {
2323
static const char client[] = {
24-
'j', 'a', 'b', 'b', 'e', 'r', ':', 'c', 'l', 'i', 'e', 'n', 't'};
24+
'j', 'a', 'b', 'b', 'e', 'r', ':', 'c', 'l', 'i', 'e', 'n', 't', 0};
2525
return typename string<Tag>::type(
2626
client, client + sizeof(client));
2727
}
@@ -32,7 +32,7 @@ template <
3232
inline
3333
typename string<Tag>::type server() {
3434
static const char server[] = {
35-
'j', 'a', 'b', 'b', 'e', 'r', ':', 's', 'e', 'r', 'v', 'e', 'r'};
35+
'j', 'a', 'b', 'b', 'e', 'r', ':', 's', 'e', 'r', 'v', 'e', 'r', 0};
3636
return typename string<Tag>::type(
3737
server, server + sizeof(server));
3838
}
@@ -44,7 +44,7 @@ inline
4444
typename string<Tag>::type component() {
4545
static const char component[] = {
4646
'j', 'a', 'b', 'b', 'e', 'r', ':', 'c', 'o', 'm', 'p', 'o',
47-
'n', 'e', 'n', 't', ':', 'a', 'c', 'c', 'e', 'p', 't'};
47+
'n', 'e', 'n', 't', ':', 'a', 'c', 'c', 'e', 'p', 't', 0};
4848
return typename string<Tag>::type(
4949
component, component + sizeof(component));
5050
}
@@ -57,7 +57,7 @@ typename string<Tag>::type streams() {
5757
static const char streams[] = {
5858
'h', 't', 't', 'p', ':', '/', '/', 'e', 't', 'h', 'e', 'r',
5959
'x', '.', 'j', 'a', 'b', 'b', 'e', 'r', '.', 'o', 'r', 'g',
60-
'/', 's', 't', 'r', 'e', 'a', 'm', 's'};
60+
'/', 's', 't', 'r', 'e', 'a', 'm', 's', 0};
6161
return typename string<Tag>::type(
6262
streams, streams + sizeof(streams));
6363
}
@@ -70,7 +70,7 @@ typename string<Tag>::type streams_ietf() {
7070
static const char streams_ietf[] = {
7171
'u', 'r', 'n', ':', 'i', 'e', 't', 'f', ':', 'p', 'a', 'r',
7272
'a', 'm', 's', ':', 'x', 'm', 'l', ':', 'n', 's', ':', 'x',
73-
'm', 'p', 'p', '-', 's', 't', 'r', 'e', 'a', 'm', 's'};
73+
'm', 'p', 'p', '-', 's', 't', 'r', 'e', 'a', 'm', 's', 0};
7474
return typename string<Tag>::type(
7575
streams_ietf, streams_ietf + sizeof(streams_ietf));
7676
}
@@ -83,7 +83,7 @@ typename string<Tag>::type tls() {
8383
static const char tls[] = {
8484
'u', 'r', 'n', ':', 'i', 'e', 't', 'f', ':', 'p', 'a', 'r',
8585
'a', 'm', 's', ':', 'x', 'm', 'l', ':', 'n', 's', ':', 'x',
86-
'm', 'p', 'p', '-', 't', 'l', 's'};
86+
'm', 'p', 'p', '-', 't', 'l', 's', 0};
8787
return typename string<Tag>::type(tls, tls + sizeof(tls));
8888
}
8989

@@ -95,7 +95,7 @@ typename string<Tag>::type sasl() {
9595
static const char sasl[] = {
9696
'u', 'r', 'n', ':', 'i', 'e', 't', 'f', ':', 'p', 'a', 'r',
9797
'a', 'm', 's', ':', 'x', 'm', 'l', ':', 'n', 's', ':', 'x',
98-
'm', 'p', 'p', '-', 's', 'a', 's', 'l'};
98+
'm', 'p', 'p', '-', 's', 'a', 's', 'l', 0};
9999
return typename string<Tag>::type(sasl, sasl + sizeof(sasl));
100100
}
101101
} // namespace ns

boost/network/protocol/xmpp/presence.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class basic_presence
2929
typedef typename base_type::headers_container_type headers_container_type;
3030

3131
basic_presence() {
32-
static const char name[] = {'p', 'r', 'e', 's', 'e', 'n', 'c', 'e'};
32+
static const char name[] = {'p', 'r', 'e', 's', 'e', 'n', 'c', 'e', 0};
3333
base_type::set_name(string_type(name, name + sizeof(name)));
3434
}
3535

3636
basic_presence(const basic_presence &other)
3737
: basic_stanza<Tag>(other) {
38-
38+
3939
}
4040

4141
basic_presence &operator = (const basic_presence &other) {
@@ -45,7 +45,7 @@ class basic_presence
4545
}
4646

4747
~basic_presence() {
48-
48+
4949
}
5050

5151
void swap(basic_presence &other) {

boost/network/protocol/xmpp/stanza.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class basic_stanza
2222
: public boost::network::basic_message<Tag> {
2323

2424
typedef boost::network::basic_message<Tag> base_type;
25-
25+
2626
public:
2727

2828
typedef typename base_type::string_type string_type;
2929

3030
explicit basic_stanza() {
31-
31+
3232
}
3333

3434
explicit basic_stanza(const string_type &name) {
@@ -59,7 +59,7 @@ class basic_stanza
5959
private:
6060

6161
detail::basic_element<Tag> element_;
62-
62+
6363
};
6464

6565

boost/network/tags.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace boost { namespace network { namespace tags {
4545
name##_tags, \
4646
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2> \
4747
>::type name; \
48-
template <> struct components<name> { typedef name##_tags type; };
48+
template <> struct components<name> { typedef name##_tags type; };
4949

5050
BOOST_NETWORK_DEFINE_TAG(http_default_8bit_tcp_resolve);
5151
BOOST_NETWORK_DEFINE_TAG(http_default_8bit_udp_resolve);

boost/network/tls/gnutls.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ basic_gnutls {
3030

3131
gnutls_session_t session_;
3232
gnutls_certificate_credentials_t credentials_;
33-
33+
3434
};
3535

3636

3737
template <
3838
class Tag
3939
>
4040
basic_gnutls<Tag>::basic_gnutls() {
41-
41+
4242
}
4343

4444
template <
4545
class Tag
4646
>
4747
basic_gnutls<Tag>::~basic_gnutls() {
48-
48+
4949
}
5050
} // namespace network
5151
} // namespace boost

0 commit comments

Comments
 (0)