agent_xmpp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +11 -0
- data/LICENSE +20 -0
- data/README.rdoc +417 -0
- data/Rakefile +75 -0
- data/VERSION +1 -0
- data/agent_xmpp.gemspec +144 -0
- data/lib/agent_xmpp.rb +22 -0
- data/lib/agent_xmpp/admin.rb +113 -0
- data/lib/agent_xmpp/client.rb +7 -0
- data/lib/agent_xmpp/client/boot.rb +83 -0
- data/lib/agent_xmpp/client/client.rb +64 -0
- data/lib/agent_xmpp/client/connection.rb +108 -0
- data/lib/agent_xmpp/client/controller.rb +394 -0
- data/lib/agent_xmpp/client/message_delegate.rb +720 -0
- data/lib/agent_xmpp/client/message_pipe.rb +193 -0
- data/lib/agent_xmpp/client/response.rb +102 -0
- data/lib/agent_xmpp/config.rb +48 -0
- data/lib/agent_xmpp/main.rb +175 -0
- data/lib/agent_xmpp/models.rb +7 -0
- data/lib/agent_xmpp/models/contact.rb +85 -0
- data/lib/agent_xmpp/models/message.rb +152 -0
- data/lib/agent_xmpp/models/publication.rb +53 -0
- data/lib/agent_xmpp/models/roster.rb +107 -0
- data/lib/agent_xmpp/models/service.rb +91 -0
- data/lib/agent_xmpp/models/subscription.rb +61 -0
- data/lib/agent_xmpp/models/table_definitions.rb +107 -0
- data/lib/agent_xmpp/patches.rb +7 -0
- data/lib/agent_xmpp/patches/array.rb +32 -0
- data/lib/agent_xmpp/patches/float.rb +10 -0
- data/lib/agent_xmpp/patches/hash.rb +13 -0
- data/lib/agent_xmpp/patches/object.rb +15 -0
- data/lib/agent_xmpp/patches/rexml.rb +69 -0
- data/lib/agent_xmpp/patches/string.rb +15 -0
- data/lib/agent_xmpp/xmpp.rb +18 -0
- data/lib/agent_xmpp/xmpp/element.rb +158 -0
- data/lib/agent_xmpp/xmpp/entry.rb +36 -0
- data/lib/agent_xmpp/xmpp/error_response.rb +189 -0
- data/lib/agent_xmpp/xmpp/iq.rb +90 -0
- data/lib/agent_xmpp/xmpp/iq_command.rb +54 -0
- data/lib/agent_xmpp/xmpp/iq_disco.rb +206 -0
- data/lib/agent_xmpp/xmpp/iq_pubsub.rb +270 -0
- data/lib/agent_xmpp/xmpp/iq_roster.rb +183 -0
- data/lib/agent_xmpp/xmpp/iq_version.rb +89 -0
- data/lib/agent_xmpp/xmpp/jid.rb +150 -0
- data/lib/agent_xmpp/xmpp/message.rb +82 -0
- data/lib/agent_xmpp/xmpp/presence.rb +127 -0
- data/lib/agent_xmpp/xmpp/sasl.rb +241 -0
- data/lib/agent_xmpp/xmpp/stanza.rb +107 -0
- data/lib/agent_xmpp/xmpp/x_data.rb +357 -0
- data/test/app/app.rb +339 -0
- data/test/cases/test_application_message_processing.rb +65 -0
- data/test/cases/test_errors.rb +24 -0
- data/test/cases/test_presence_management.rb +139 -0
- data/test/cases/test_roster_management.rb +214 -0
- data/test/cases/test_service_discovery.rb +168 -0
- data/test/cases/test_session_management.rb +120 -0
- data/test/cases/test_version_discovery.rb +67 -0
- data/test/helpers/matchers.rb +23 -0
- data/test/helpers/mocks.rb +82 -0
- data/test/helpers/test_case_extensions.rb +45 -0
- data/test/helpers/test_client.rb +44 -0
- data/test/helpers/test_delegate.rb +60 -0
- data/test/helpers/test_helper.rb +91 -0
- data/test/messages/application_messages.rb +206 -0
- data/test/messages/error_messages.rb +35 -0
- data/test/messages/presence_messages.rb +66 -0
- data/test/messages/roster_messages.rb +126 -0
- data/test/messages/service_discovery_messages.rb +201 -0
- data/test/messages/session_messages.rb +158 -0
- data/test/messages/version_discovery_messages.rb +69 -0
- data/test/peer/peer.rb +21 -0
- metadata +187 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
##############################################################################################################
|
2
|
+
module ErrorMessages
|
3
|
+
|
4
|
+
#####-------------------------------------------------------------------------------------------------------
|
5
|
+
class << self
|
6
|
+
|
7
|
+
#### received messages
|
8
|
+
#.........................................................................................................
|
9
|
+
def recv_iq_error(client, from)
|
10
|
+
<<-MSG
|
11
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
12
|
+
<query node='http://jabber.org/protocol/nothing' xmlns='http://jabber.org/protocol/nothing'/>
|
13
|
+
</iq>
|
14
|
+
MSG
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#### sent messages
|
19
|
+
#.........................................................................................................
|
20
|
+
def send_iq_error(client, to)
|
21
|
+
<<-MSG
|
22
|
+
<iq id='1' to='#{to}' type='error' xmlns='jabber:client'>
|
23
|
+
<error code='501' type='cancel'>
|
24
|
+
<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
25
|
+
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>feature not implemented</text>
|
26
|
+
</error>
|
27
|
+
</iq>
|
28
|
+
MSG
|
29
|
+
end
|
30
|
+
|
31
|
+
## self
|
32
|
+
end
|
33
|
+
|
34
|
+
#### VersionDiscoveryMessages
|
35
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
##############################################################################################################
|
2
|
+
module PresenceMessages
|
3
|
+
|
4
|
+
#####-------------------------------------------------------------------------------------------------------
|
5
|
+
class << self
|
6
|
+
|
7
|
+
#### received messages
|
8
|
+
#.........................................................................................................
|
9
|
+
def recv_presence_self(client)
|
10
|
+
<<-MSG
|
11
|
+
<presence from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' xmlns='jabber:client'>
|
12
|
+
<priority>1</priority>
|
13
|
+
</presence>
|
14
|
+
MSG
|
15
|
+
end
|
16
|
+
|
17
|
+
#.........................................................................................................
|
18
|
+
def recv_presence_available(client, from)
|
19
|
+
<<-MSG
|
20
|
+
<presence from='#{from}' to='#{client.client.jid.to_s}' xmlns='jabber:client'>
|
21
|
+
<priority>1</priority>
|
22
|
+
</presence>
|
23
|
+
MSG
|
24
|
+
end
|
25
|
+
|
26
|
+
#.........................................................................................................
|
27
|
+
def recv_presence_unavailable(client, from)
|
28
|
+
"<presence from='#{from}' to='#{client.client.jid.to_s}' type='unavailable' xmlns='jabber:client'/>"
|
29
|
+
end
|
30
|
+
|
31
|
+
#.........................................................................................................
|
32
|
+
def recv_presence_subscribe(client, from)
|
33
|
+
"<presence from='#{from}' to='#{client.client.jid.to_s}' type='subscribe' xmlns='jabber:client'/>"
|
34
|
+
end
|
35
|
+
|
36
|
+
#.........................................................................................................
|
37
|
+
def recv_presence_subscribed(client, from)
|
38
|
+
"<presence from='#{from}' to='#{client.client.jid.to_s}' type='subscribed' xmlns='jabber:client'/>"
|
39
|
+
end
|
40
|
+
|
41
|
+
#.........................................................................................................
|
42
|
+
def recv_presence_unsubscribed(client, from)
|
43
|
+
"<presence from='#{from}' to='#{client.client.jid.to_s}' type='unsubscribed' xmlns='jabber:client'/>"
|
44
|
+
end
|
45
|
+
|
46
|
+
#### sent messages
|
47
|
+
#.........................................................................................................
|
48
|
+
def send_presence_subscribe(client, to)
|
49
|
+
"<presence to='#{to}' type='subscribe' xmlns='jabber:client'/>"
|
50
|
+
end
|
51
|
+
|
52
|
+
#.........................................................................................................
|
53
|
+
def send_presence_subscribed(client, to)
|
54
|
+
"<presence to='#{to}' type='subscribed' xmlns='jabber:client'/>"
|
55
|
+
end
|
56
|
+
|
57
|
+
#.........................................................................................................
|
58
|
+
def send_presence_unsubscribed(client, to)
|
59
|
+
"<presence to='#{to}' type='unsubscribed' xmlns='jabber:client'/>"
|
60
|
+
end
|
61
|
+
|
62
|
+
## self
|
63
|
+
end
|
64
|
+
|
65
|
+
#### PresenceMessages
|
66
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
##############################################################################################################
|
2
|
+
module RosterMessages
|
3
|
+
|
4
|
+
#####-------------------------------------------------------------------------------------------------------
|
5
|
+
class << self
|
6
|
+
|
7
|
+
#### received messages
|
8
|
+
#.........................................................................................................
|
9
|
+
def recv_iq_result_query_roster(client, roster_jids)
|
10
|
+
subscriptions = roster_jids.inject("") {|s, r| s += "<item subscription='both' jid='#{r}'/>"}
|
11
|
+
<<-MSG
|
12
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='result' xmlns='jabber:client'>
|
13
|
+
<query xmlns='jabber:iq:roster'>
|
14
|
+
#{subscriptions}
|
15
|
+
</query>
|
16
|
+
</iq>
|
17
|
+
MSG
|
18
|
+
end
|
19
|
+
|
20
|
+
#.........................................................................................................
|
21
|
+
def recv_iq_result_query_roster_ack(client)
|
22
|
+
"<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='result' xmlns='jabber:client'/>"
|
23
|
+
end
|
24
|
+
|
25
|
+
#.........................................................................................................
|
26
|
+
def recv_error_query_roster_add(client)
|
27
|
+
"<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='error' xmlns='jabber:client'/>"
|
28
|
+
end
|
29
|
+
|
30
|
+
#.........................................................................................................
|
31
|
+
def recv_error_query_roster_remove(client)
|
32
|
+
"<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='error' xmlns='jabber:client'/>"
|
33
|
+
end
|
34
|
+
|
35
|
+
#.........................................................................................................
|
36
|
+
def recv_iq_set_query_roster_none(client, roster_jid)
|
37
|
+
<<-MSG
|
38
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='set' xmlns='jabber:client'>
|
39
|
+
<query xmlns='jabber:iq:roster'>
|
40
|
+
<item subscription='none' jid='#{roster_jid}'/>
|
41
|
+
</query>
|
42
|
+
</iq>
|
43
|
+
MSG
|
44
|
+
end
|
45
|
+
|
46
|
+
#.........................................................................................................
|
47
|
+
def recv_iq_set_query_roster_none_subscribe(client, roster_jid)
|
48
|
+
<<-MSG
|
49
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='set' xmlns='jabber:client'>
|
50
|
+
<query xmlns='jabber:iq:roster'>
|
51
|
+
<item ask='subscribe' subscription='none' jid='#{roster_jid}'/>
|
52
|
+
</query>
|
53
|
+
</iq>
|
54
|
+
MSG
|
55
|
+
end
|
56
|
+
|
57
|
+
#.........................................................................................................
|
58
|
+
def recv_iq_set_query_roster_to(client, roster_jid)
|
59
|
+
<<-MSG
|
60
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='set' xmlns='jabber:client'>
|
61
|
+
<query xmlns='jabber:iq:roster'>
|
62
|
+
<item subscription='to' jid='#{roster_jid}'/>
|
63
|
+
</query>
|
64
|
+
</iq>
|
65
|
+
MSG
|
66
|
+
end
|
67
|
+
|
68
|
+
#.........................................................................................................
|
69
|
+
def recv_iq_set_query_roster_both(client, roster_jid)
|
70
|
+
<<-MSG
|
71
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='set' xmlns='jabber:client'>
|
72
|
+
<query xmlns='jabber:iq:roster'>
|
73
|
+
<item subscription='both' jid='#{roster_jid}'/>
|
74
|
+
</query>
|
75
|
+
</iq>
|
76
|
+
MSG
|
77
|
+
end
|
78
|
+
|
79
|
+
#.........................................................................................................
|
80
|
+
def recv_iq_set_query_roster_remove(client, roster_jid)
|
81
|
+
<<-MSG
|
82
|
+
<iq from='#{client.client.jid.to_s}' to='#{client.client.jid.to_s}' id='1' type='set' xmlns='jabber:client'>
|
83
|
+
<query xmlns='jabber:iq:roster'>
|
84
|
+
<item jid='#{roster_jid}' subscription='remove'/>
|
85
|
+
</query>
|
86
|
+
</iq>
|
87
|
+
MSG
|
88
|
+
end
|
89
|
+
|
90
|
+
#### sent messages
|
91
|
+
#.........................................................................................................
|
92
|
+
def send_iq_get_query_roster(client)
|
93
|
+
<<-MSG
|
94
|
+
<iq id='3' type='get' xmlns='jabber:client'>
|
95
|
+
<query xmlns='jabber:iq:roster'/>
|
96
|
+
</iq>
|
97
|
+
MSG
|
98
|
+
end
|
99
|
+
|
100
|
+
#.........................................................................................................
|
101
|
+
def send_iq_set_query_roster(client, roster_jid)
|
102
|
+
<<-MSG
|
103
|
+
<iq id='5' type='set' xmlns='jabber:client'>
|
104
|
+
<query xmlns='jabber:iq:roster'>
|
105
|
+
<item jid='#{roster_jid}'/>
|
106
|
+
</query>
|
107
|
+
</iq>
|
108
|
+
MSG
|
109
|
+
end
|
110
|
+
|
111
|
+
#.........................................................................................................
|
112
|
+
def send_iq_set_query_roster_remove(client, roster_jid)
|
113
|
+
<<-MSG
|
114
|
+
<iq id='5' type='set' xmlns='jabber:client'>
|
115
|
+
<query xmlns='jabber:iq:roster'>
|
116
|
+
<item jid='#{roster_jid}' subscription='remove'/>
|
117
|
+
</query>
|
118
|
+
</iq>
|
119
|
+
MSG
|
120
|
+
end
|
121
|
+
|
122
|
+
## self
|
123
|
+
end
|
124
|
+
|
125
|
+
#### RosterMessages
|
126
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
##############################################################################################################
|
2
|
+
module ServiceDiscoveryMessages
|
3
|
+
|
4
|
+
#####-------------------------------------------------------------------------------------------------------
|
5
|
+
class << self
|
6
|
+
|
7
|
+
#### received messages
|
8
|
+
#.........................................................................................................
|
9
|
+
def recv_iq_get_query_discoinfo(client, from)
|
10
|
+
<<-MSG
|
11
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
12
|
+
<query xmlns='http://jabber.org/protocol/disco#info'/>
|
13
|
+
</iq>
|
14
|
+
MSG
|
15
|
+
end
|
16
|
+
|
17
|
+
#.........................................................................................................
|
18
|
+
def recv_iq_get_query_discoinfo_error(client, from)
|
19
|
+
<<-MSG
|
20
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
21
|
+
<query node='http://jabber.org/protocol/nothing' xmlns='http://jabber.org/protocol/disco#info'/>
|
22
|
+
</iq>
|
23
|
+
MSG
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
#.........................................................................................................
|
28
|
+
def recv_iq_get_query_discoitems(client, from)
|
29
|
+
<<-MSG
|
30
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
31
|
+
<query xmlns='http://jabber.org/protocol/disco#items'/>
|
32
|
+
</iq>
|
33
|
+
MSG
|
34
|
+
end
|
35
|
+
|
36
|
+
#.........................................................................................................
|
37
|
+
def recv_iq_get_query_discoitems_for_commands_node(client, from)
|
38
|
+
<<-MSG
|
39
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
40
|
+
<query node='http://jabber.org/protocol/commands' xmlns='http://jabber.org/protocol/disco#items'/>
|
41
|
+
</iq>
|
42
|
+
MSG
|
43
|
+
end
|
44
|
+
|
45
|
+
#.........................................................................................................
|
46
|
+
def recv_iq_get_query_discoitems_error(client, from)
|
47
|
+
<<-MSG
|
48
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='get' xmlns='jabber:client'>
|
49
|
+
<query node='http://jabber.org/protocol/nothing' xmlns='http://jabber.org/protocol/disco#items'/>
|
50
|
+
</iq>
|
51
|
+
MSG
|
52
|
+
end
|
53
|
+
|
54
|
+
#.........................................................................................................
|
55
|
+
def recv_iq_result_query_discoinfo(client, from)
|
56
|
+
<<-MSG
|
57
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='2' type='result' xmlns='jabber:client'>
|
58
|
+
<query xmlns='http://jabber.org/protocol/disco#info'>
|
59
|
+
<identity name='Gajim' category='client' type='pc'/>
|
60
|
+
<feature var='http://jabber.org/protocol/bytestreams'/>
|
61
|
+
<feature var='http://jabber.org/protocol/si'/>
|
62
|
+
<feature var='http://jabber.org/protocol/si/profile/file-transfer'/>
|
63
|
+
<feature var='http://jabber.org/protocol/muc'/>
|
64
|
+
<feature var='http://jabber.org/protocol/commands'/>
|
65
|
+
<feature var='http://jabber.org/protocol/disco#info'/>
|
66
|
+
<feature var='http://jabber.org/protocol/chatstates'/>
|
67
|
+
<feature var='http://jabber.org/protocol/xhtml-im'/>
|
68
|
+
<feature var='urn:xmpp:time'/>
|
69
|
+
</query>
|
70
|
+
</iq>
|
71
|
+
MSG
|
72
|
+
end
|
73
|
+
|
74
|
+
#.........................................................................................................
|
75
|
+
def recv_iq_error_query_discoinfo(client, from)
|
76
|
+
<<-MSG
|
77
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='2' type='error' xmlns='jabber:client'>
|
78
|
+
<query xmlns='http://jabber.org/protocol/disco#info'/>
|
79
|
+
<error code='503' type='cancel'>
|
80
|
+
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
81
|
+
</error>
|
82
|
+
</iq>
|
83
|
+
MSG
|
84
|
+
end
|
85
|
+
|
86
|
+
#.........................................................................................................
|
87
|
+
def recv_iq_result_query_discoitems(client, from)
|
88
|
+
<<-MSG
|
89
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='result' xmlns='jabber:client'>
|
90
|
+
<query xmlns='http://jabber.org/protocol/disco#items'>
|
91
|
+
<item jid='conference.plan-b.ath.cx'/>
|
92
|
+
<item jid='irc.plan-b.ath.cx'/>
|
93
|
+
<item jid='proxy.plan-b.ath.cx'/>
|
94
|
+
<item jid='pubsub.plan-b.ath.cx'/>
|
95
|
+
<item jid='vjud.plan-b.ath.cx'/>
|
96
|
+
</query>
|
97
|
+
</iq>
|
98
|
+
MSG
|
99
|
+
end
|
100
|
+
|
101
|
+
#.........................................................................................................
|
102
|
+
def recv_iq_error_query_discoitems(client, from)
|
103
|
+
<<-MSG
|
104
|
+
<iq from='#{from}' to='#{client.client.jid.to_s}' id='1' type='error' xmlns='jabber:client'>
|
105
|
+
<query xmlns='http://jabber.org/protocol/disco#items'/>
|
106
|
+
<error code='503' type='cancel'>
|
107
|
+
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
108
|
+
</error>
|
109
|
+
</iq>
|
110
|
+
MSG
|
111
|
+
end
|
112
|
+
|
113
|
+
#### sent messages
|
114
|
+
#.........................................................................................................
|
115
|
+
def send_iq_get_query_discoinfo(client, to)
|
116
|
+
<<-MSG
|
117
|
+
<iq id='2' to='#{to}' type='get' xmlns='jabber:client'>
|
118
|
+
<query xmlns='http://jabber.org/protocol/disco#info'/>
|
119
|
+
</iq>
|
120
|
+
MSG
|
121
|
+
end
|
122
|
+
|
123
|
+
#.........................................................................................................
|
124
|
+
def send_iq_result_query_discoinfo(client, to)
|
125
|
+
<<-MSG
|
126
|
+
<iq id='1' to='#{to}' type='result' xmlns='jabber:client'>
|
127
|
+
<query xmlns='http://jabber.org/protocol/disco#info'>
|
128
|
+
<identity name='AgentXMPP' category='client' type='bot'/>
|
129
|
+
<feature var='http://jabber.org/protocol/disco#info'/>
|
130
|
+
<feature var='http://jabber.org/protocol/disco#items'/>
|
131
|
+
<feature var='jabber:iq:version'/><feature var='jabber:x:data'/>
|
132
|
+
<feature var='http://jabber.org/protocol/commands'/>
|
133
|
+
<feature var='http://jabber.org/protocol/muc'/>
|
134
|
+
</query>
|
135
|
+
</iq>
|
136
|
+
MSG
|
137
|
+
end
|
138
|
+
|
139
|
+
#.........................................................................................................
|
140
|
+
def send_iq_error_discoinfo_service_unavailable(client, to)
|
141
|
+
<<-MSG
|
142
|
+
<iq id='1' to='#{to}' type='error' xmlns='jabber:client'>
|
143
|
+
<query node='http://jabber.org/protocol/nothing' xmlns='http://jabber.org/protocol/disco#info'/>
|
144
|
+
<error code='503' type='cancel'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
145
|
+
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>service unavailable</text>
|
146
|
+
</error>
|
147
|
+
</iq>
|
148
|
+
MSG
|
149
|
+
end
|
150
|
+
|
151
|
+
#.........................................................................................................
|
152
|
+
def send_iq_get_query_discoitems(client, to)
|
153
|
+
<<-MSG
|
154
|
+
<iq id='1' to='#{to}' type='get' xmlns='jabber:client'>
|
155
|
+
<query xmlns='http://jabber.org/protocol/disco#items'/>
|
156
|
+
</iq>
|
157
|
+
MSG
|
158
|
+
end
|
159
|
+
|
160
|
+
#.........................................................................................................
|
161
|
+
def send_iq_result_query_discoitems(client, to)
|
162
|
+
<<-MSG
|
163
|
+
<iq id='1' to='#{to}' type='result' xmlns='jabber:client'>
|
164
|
+
<query xmlns='http://jabber.org/protocol/disco#items'/>
|
165
|
+
</iq>
|
166
|
+
MSG
|
167
|
+
end
|
168
|
+
|
169
|
+
#.........................................................................................................
|
170
|
+
def send_iq_error_discoitems_item_not_found(client, to)
|
171
|
+
<<-MSG
|
172
|
+
<iq id='1' to='#{to}' type='error' xmlns='jabber:client'>
|
173
|
+
<query node='http://jabber.org/protocol/nothing' xmlns='http://jabber.org/protocol/disco#items'/>
|
174
|
+
<error code='404' type='cancel'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
175
|
+
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>item not found</text>
|
176
|
+
</error>
|
177
|
+
</iq>
|
178
|
+
MSG
|
179
|
+
end
|
180
|
+
|
181
|
+
#.........................................................................................................
|
182
|
+
def send_iq_result_query_discoitems_for_commands_node(client, to)
|
183
|
+
<<-MSG
|
184
|
+
<iq id='1' to='#{to}' type='result' xmlns='jabber:client'>
|
185
|
+
<query node='http://jabber.org/protocol/commands' xmlns='http://jabber.org/protocol/disco#items'>
|
186
|
+
<item name='scalar' node='scalar' jid='#{client.client.jid.to_s}'/>
|
187
|
+
<item name='hash' node='hash' jid='#{client.client.jid.to_s}'/>
|
188
|
+
<item name='scalar array' node='scalar_array' jid='#{client.client.jid.to_s}'/>
|
189
|
+
<item name='hash array' node='hash_array' jid='#{client.client.jid.to_s}'/>
|
190
|
+
<item name='array hash' node='array_hash' jid='#{client.client.jid.to_s}'/>
|
191
|
+
<item name='array hash array' node='array_hash_array' jid='#{client.client.jid.to_s}'/>
|
192
|
+
</query>
|
193
|
+
</iq>
|
194
|
+
MSG
|
195
|
+
end
|
196
|
+
|
197
|
+
## self
|
198
|
+
end
|
199
|
+
|
200
|
+
#### ServiceDiscoveryMessages
|
201
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
##############################################################################################################
|
2
|
+
module SessionMessages
|
3
|
+
|
4
|
+
#####-------------------------------------------------------------------------------------------------------
|
5
|
+
class << self
|
6
|
+
|
7
|
+
#### received messages
|
8
|
+
#.........................................................................................................
|
9
|
+
def recv_preauthentication_stream_features_with_plain_SASL(client)
|
10
|
+
<<-MSG
|
11
|
+
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1' from='#{client.client.jid.domain}' version='1.0' xml:lang='en'>
|
12
|
+
<stream:features>
|
13
|
+
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
|
14
|
+
<mechanism>DIGEST-MD5</mechanism>
|
15
|
+
<mechanism>PLAIN</mechanism>
|
16
|
+
</mechanisms>
|
17
|
+
<register xmlns='http://jabber.org/features/iq-register'/>
|
18
|
+
</stream:features>
|
19
|
+
</stream:stream>
|
20
|
+
MSG
|
21
|
+
end
|
22
|
+
|
23
|
+
#.........................................................................................................
|
24
|
+
def recv_preauthentication_stream_features_without_plain_SASL(client)
|
25
|
+
<<-MSG
|
26
|
+
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1' from='#{client.client.jid.domain}' version='1.0' xml:lang='en'>
|
27
|
+
<stream:features>
|
28
|
+
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
|
29
|
+
<mechanism>DIGEST-MD5</mechanism>
|
30
|
+
</mechanisms>
|
31
|
+
<register xmlns='http://jabber.org/features/iq-register'/>
|
32
|
+
</stream:features>
|
33
|
+
</stream:stream>
|
34
|
+
MSG
|
35
|
+
end
|
36
|
+
|
37
|
+
#.........................................................................................................
|
38
|
+
def recv_auth_success(client)
|
39
|
+
"<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"
|
40
|
+
end
|
41
|
+
|
42
|
+
#.........................................................................................................
|
43
|
+
def recv_auth_failure(client)
|
44
|
+
<<-MSG
|
45
|
+
<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
|
46
|
+
<not-authorized/>
|
47
|
+
</failure>
|
48
|
+
MSG
|
49
|
+
end
|
50
|
+
|
51
|
+
#.........................................................................................................
|
52
|
+
def recv_postauthentication_stream_features(client)
|
53
|
+
<<-MSG
|
54
|
+
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1' from='#{client.client.jid.domain}' version='1.0' xml:lang='en'>
|
55
|
+
<stream:features>
|
56
|
+
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
|
57
|
+
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
58
|
+
</stream:features>
|
59
|
+
</stream:stream>
|
60
|
+
MSG
|
61
|
+
end
|
62
|
+
|
63
|
+
#.........................................................................................................
|
64
|
+
def recv_iq_result_bind(client)
|
65
|
+
<<-MSG
|
66
|
+
<iq id='1' type='result' xmlns='jabber:client'>
|
67
|
+
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
68
|
+
<jid>#{client.client.jid.to_s}</jid>
|
69
|
+
</bind>
|
70
|
+
</iq>
|
71
|
+
MSG
|
72
|
+
end
|
73
|
+
|
74
|
+
#.........................................................................................................
|
75
|
+
def recv_iq_result_session(client)
|
76
|
+
<<-MSG
|
77
|
+
<iq type='result' id='1' xmlns='jabber:client'>
|
78
|
+
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
79
|
+
</iq>
|
80
|
+
MSG
|
81
|
+
end
|
82
|
+
|
83
|
+
#.........................................................................................................
|
84
|
+
def recv_error_bind(client)
|
85
|
+
<<-MSG
|
86
|
+
<iq type='error' id='1' xmlns='jabber:client'>
|
87
|
+
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
88
|
+
<resource>someresource</resource>
|
89
|
+
</bind>
|
90
|
+
<error type='cancel'>
|
91
|
+
<not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
92
|
+
</error>
|
93
|
+
</iq>
|
94
|
+
MSG
|
95
|
+
end
|
96
|
+
|
97
|
+
#.........................................................................................................
|
98
|
+
def recv_error_session(client)
|
99
|
+
<<-MSG
|
100
|
+
<iq from='#{client.client.jid.domain}' type='error' id='1' xmlns='jabber:client'>
|
101
|
+
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
102
|
+
<error type='wait'>
|
103
|
+
<internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
104
|
+
</error>
|
105
|
+
</iq>
|
106
|
+
MSG
|
107
|
+
end
|
108
|
+
|
109
|
+
#### sent messages
|
110
|
+
#.........................................................................................................
|
111
|
+
def send_supported_xml_version(client)
|
112
|
+
"<?xml version='1.0' ?>"
|
113
|
+
end
|
114
|
+
|
115
|
+
#.........................................................................................................
|
116
|
+
def send_stream(client)
|
117
|
+
"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='plan-b.ath.cx'>"
|
118
|
+
end
|
119
|
+
|
120
|
+
#.........................................................................................................
|
121
|
+
def send_auth_plain(client)
|
122
|
+
"<auth mechanism='PLAIN' xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"
|
123
|
+
end
|
124
|
+
|
125
|
+
#.........................................................................................................
|
126
|
+
def send_iq_set_bind(client)
|
127
|
+
<<-MSG
|
128
|
+
<iq id='1' type='set' xmlns='jabber:client'>
|
129
|
+
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
130
|
+
<resource>#{client.client.jid.resource}</resource>
|
131
|
+
</bind>
|
132
|
+
</iq>
|
133
|
+
MSG
|
134
|
+
end
|
135
|
+
|
136
|
+
#.........................................................................................................
|
137
|
+
def send_iq_set_session(client)
|
138
|
+
<<-MSG
|
139
|
+
<iq id='1' type='set' xmlns='jabber:client'>
|
140
|
+
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
141
|
+
</iq>
|
142
|
+
MSG
|
143
|
+
end
|
144
|
+
|
145
|
+
#.........................................................................................................
|
146
|
+
def send_presence_init(client)
|
147
|
+
<<-MSG
|
148
|
+
<presence xmlns='jabber:client'>
|
149
|
+
<priority>1</priority>
|
150
|
+
</presence>
|
151
|
+
MSG
|
152
|
+
end
|
153
|
+
|
154
|
+
## self
|
155
|
+
end
|
156
|
+
|
157
|
+
#### SessionMessages
|
158
|
+
end
|