troystribling-agent_xmpp 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +397 -2
- data/Rakefile +33 -21
- data/VERSION +1 -1
- data/agent_xmpp.gemspec +78 -33
- data/lib/agent_xmpp.rb +11 -7
- data/lib/agent_xmpp/app.rb +0 -5
- data/lib/agent_xmpp/app/boot.rb +47 -33
- data/lib/agent_xmpp/app/controller.rb +135 -19
- data/lib/agent_xmpp/client.rb +6 -1
- data/lib/agent_xmpp/client/client.rb +22 -155
- data/lib/agent_xmpp/client/connection.rb +41 -250
- data/lib/agent_xmpp/client/message_delegate.rb +706 -0
- data/lib/agent_xmpp/client/message_pipe.rb +176 -0
- data/lib/agent_xmpp/client/publish_model.rb +65 -0
- data/lib/agent_xmpp/{app/format.rb → client/response.rb} +19 -24
- data/lib/agent_xmpp/client/roster_model.rb +139 -0
- data/lib/agent_xmpp/client/services_model.rb +97 -0
- data/lib/agent_xmpp/config.rb +45 -0
- data/lib/agent_xmpp/main.rb +126 -0
- data/lib/agent_xmpp/patches.rb +6 -2
- data/lib/agent_xmpp/patches/{standard_library_patches/array.rb → array.rb} +14 -7
- data/lib/agent_xmpp/patches/{standard_library_patches/float.rb → float.rb} +0 -0
- data/lib/agent_xmpp/patches/{standard_library_patches/hash.rb → hash.rb} +3 -3
- data/lib/agent_xmpp/patches/{standard_library_patches/object.rb → object.rb} +3 -3
- data/lib/agent_xmpp/patches/rexml.rb +69 -0
- data/lib/agent_xmpp/patches/{standard_library_patches/string.rb → string.rb} +5 -0
- data/lib/agent_xmpp/xmpp.rb +17 -0
- data/lib/agent_xmpp/xmpp/element.rb +159 -0
- data/lib/agent_xmpp/xmpp/error_response.rb +179 -0
- data/lib/agent_xmpp/xmpp/iq.rb +90 -0
- data/lib/agent_xmpp/xmpp/iq_command.rb +47 -0
- data/lib/agent_xmpp/xmpp/iq_disco.rb +205 -0
- data/lib/agent_xmpp/xmpp/iq_pubsub.rb +268 -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 +269 -0
- data/test/app/app.rb +134 -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 +61 -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 +36 -0
- data/test/xml_messages.txt +197 -0
- metadata +82 -42
- data/bin/agent_xmpp +0 -56
- data/lib/agent_xmpp/app/chat_message_body_controller.rb +0 -16
- data/lib/agent_xmpp/app/map.rb +0 -45
- data/lib/agent_xmpp/app/routes.rb +0 -77
- data/lib/agent_xmpp/app/view.rb +0 -49
- data/lib/agent_xmpp/client/parser.rb +0 -71
- data/lib/agent_xmpp/patches/standard_library_patches.rb +0 -5
- data/lib/agent_xmpp/patches/xmpp4r_patches.rb +0 -3
- data/lib/agent_xmpp/patches/xmpp4r_patches/command.rb +0 -26
- data/lib/agent_xmpp/patches/xmpp4r_patches/iq.rb +0 -26
- data/lib/agent_xmpp/patches/xmpp4r_patches/x_data.rb +0 -116
- data/lib/agent_xmpp/utils.rb +0 -2
- data/lib/agent_xmpp/utils/logger.rb +0 -24
- data/lib/agent_xmpp/utils/roster.rb +0 -23
- data/lib/agent_xmpp/version.rb +0 -6
- data/test/agent_xmpp_test.rb +0 -7
- data/test/test_helper.rb +0 -10
data/bin/agent_xmpp
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
####------------------------------------------------------------------------------------------------------
|
4
|
-
require 'rubygems'
|
5
|
-
require 'optparse'
|
6
|
-
require 'agent_xmpp'
|
7
|
-
begin
|
8
|
-
require 'config/boot'
|
9
|
-
rescue LoadError
|
10
|
-
AgentXmpp.logger.info "config/boot.rb not given"
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
####------------------------------------------------------------------------------------------------------
|
15
|
-
config_file = 'config/agent.yml'
|
16
|
-
AgentXmpp.log_file = STDOUT
|
17
|
-
OptionParser.new do |opts|
|
18
|
-
opts.banner = 'Usage: agent_xmpp.rb [options]'
|
19
|
-
opts.separator ''
|
20
|
-
opts.on('-f', '--file config.yml', 'YAML agent configuration file') {|f| config_file = f}
|
21
|
-
opts.on('-l', '--logfile file.log', 'name of logfile') {|f| AgentXmpp.log_file = f}
|
22
|
-
opts.on_tail('-h', '--help', 'Show this message') {
|
23
|
-
puts opts
|
24
|
-
exit
|
25
|
-
}
|
26
|
-
opts.parse!(ARGV)
|
27
|
-
end
|
28
|
-
|
29
|
-
####------------------------------------------------------------------------------------------------------
|
30
|
-
raise Exception, "Configuration file #{config_file} required." unless File.exist?(config_file)
|
31
|
-
|
32
|
-
####------------------------------------------------------------------------------------------------------
|
33
|
-
AgentXmpp.logger = Logger.new(AgentXmpp.log_file, 10, 1024000)
|
34
|
-
AgentXmpp.logger.info "STARTING AgentXmpp"
|
35
|
-
AgentXmpp.logger.info "LOG FILE: #{AgentXmpp.log_file.kind_of?(String) ? AgentXmpp.log_file : "STDOUT"}"
|
36
|
-
AgentXmpp.logger.info "CONFIGURATION FILE: #{config_file}"
|
37
|
-
|
38
|
-
####------------------------------------------------------------------------------------------------------
|
39
|
-
AgentXmpp::Boot.call_before_config_load if AgentXmpp::Boot.respond_to?(:call_before_config_load)
|
40
|
-
|
41
|
-
####------------------------------------------------------------------------------------------------------
|
42
|
-
AgentXmpp::Boot.load('config', {:exclude => ['config/boot'], :ordered_load => AgentXmpp::Boot.config_load_order})
|
43
|
-
|
44
|
-
####------------------------------------------------------------------------------------------------------
|
45
|
-
AgentXmpp::Boot.call_before_app_load if AgentXmpp::Boot.respond_to?(:call_before_app_load)
|
46
|
-
|
47
|
-
####------------------------------------------------------------------------------------------------------
|
48
|
-
AgentXmpp::Boot.load('app/models', {:ordered_load => AgentXmpp::Boot.app_load_order})
|
49
|
-
AgentXmpp::Boot.load('app/controllers')
|
50
|
-
|
51
|
-
####------------------------------------------------------------------------------------------------------
|
52
|
-
AgentXmpp::Boot.call_after_app_load if AgentXmpp::Boot.respond_to?(:call_after_app_load)
|
53
|
-
|
54
|
-
####------------------------------------------------------------------------------------------------------
|
55
|
-
config = File.open(config_file) {|yf| YAML::load(yf)}
|
56
|
-
AgentXmpp::Client.new(config).connect
|
@@ -1,16 +0,0 @@
|
|
1
|
-
############################################################################################################
|
2
|
-
class ChatMessageBodyController < AgentXmpp::Controller
|
3
|
-
|
4
|
-
#.........................................................................................................
|
5
|
-
def body
|
6
|
-
result_for do
|
7
|
-
params[:body].reverse
|
8
|
-
end
|
9
|
-
respond_to do |result|
|
10
|
-
result.to_s
|
11
|
-
end
|
12
|
-
AgentXmpp.logger.info "ACTION: ChatMessageBodyController\#body"
|
13
|
-
end
|
14
|
-
|
15
|
-
#### ChatMessageBodyController
|
16
|
-
end
|
data/lib/agent_xmpp/app/map.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
module Routing
|
4
|
-
|
5
|
-
#####-------------------------------------------------------------------------------------------------------
|
6
|
-
class RoutingConnection < Exception; end
|
7
|
-
|
8
|
-
#####-------------------------------------------------------------------------------------------------------
|
9
|
-
class Map
|
10
|
-
|
11
|
-
#.........................................................................................................
|
12
|
-
attr_reader :chat_message_body_route
|
13
|
-
#.........................................................................................................
|
14
|
-
|
15
|
-
#.........................................................................................................
|
16
|
-
def initialize
|
17
|
-
@routes = Hash.new
|
18
|
-
@chat_message_body_route = {:controller => 'chat_message_body', :action => 'body'}
|
19
|
-
end
|
20
|
-
|
21
|
-
#.........................................................................................................
|
22
|
-
def connect(path, options = {})
|
23
|
-
path.strip!; path.gsub!(/^\//,'')
|
24
|
-
path_elements = path.split('/')
|
25
|
-
raise RoutingConnection, "Inavild route connection: #{path}." if path_elements.count < 2
|
26
|
-
@routes[path] = {:controller => options[:controller] || path_elements[0], :action => options[:action] || path_elements[1]}
|
27
|
-
end
|
28
|
-
|
29
|
-
#.........................................................................................................
|
30
|
-
def [](path)
|
31
|
-
@routes[path]
|
32
|
-
end
|
33
|
-
|
34
|
-
#.........................................................................................................
|
35
|
-
def connect_chat_message_body(route)
|
36
|
-
@chat_message_body_route = {:controller => route[:controller], :action => route[:action]}
|
37
|
-
end
|
38
|
-
|
39
|
-
#### Map
|
40
|
-
end
|
41
|
-
|
42
|
-
#### Routing
|
43
|
-
end
|
44
|
-
#### AgentXmpp
|
45
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
|
4
|
-
#####-------------------------------------------------------------------------------------------------------
|
5
|
-
module Routing
|
6
|
-
|
7
|
-
#####-------------------------------------------------------------------------------------------------------
|
8
|
-
class Routes
|
9
|
-
|
10
|
-
#.........................................................................................................
|
11
|
-
@map = Map.new
|
12
|
-
#.........................................................................................................
|
13
|
-
|
14
|
-
####......................................................................................................
|
15
|
-
class << self
|
16
|
-
|
17
|
-
#.........................................................................................................
|
18
|
-
attr_reader :map
|
19
|
-
#.........................................................................................................
|
20
|
-
|
21
|
-
#.......................................................................................................
|
22
|
-
def draw
|
23
|
-
yield map
|
24
|
-
end
|
25
|
-
|
26
|
-
#.......................................................................................................
|
27
|
-
def invoke_command_response(connection, params)
|
28
|
-
route_path = "#{params[:node]}/#{params[:action]}"
|
29
|
-
field_path = fields(params)
|
30
|
-
route_path += "/#{field_path}" unless field_path.nil?
|
31
|
-
route = map[route_path]
|
32
|
-
unless route.nil?
|
33
|
-
begin
|
34
|
-
controller_class = eval("#{route[:controller].classify}Controller")
|
35
|
-
rescue NameError
|
36
|
-
AgentXmpp.logger.error "ROUTING ERROR: #{route[:controller].classify}Controller does not exist for route {:controller => '#{route[:controller]}', :node => '#{params[:node]}', :action => '#{params[:action]}'}."
|
37
|
-
else
|
38
|
-
controler_instance = controller_class.new
|
39
|
-
if controler_instance.respond_to?(route[:action])
|
40
|
-
controler_instance.handle_request(connection, route[:action], params)
|
41
|
-
else
|
42
|
-
AgentXmpp.logger.error "ROUTING ERROR: no action on #{controller_class.to_s} for route {:controller => '#{route[:controller]}', :node => '#{params[:node]}', :action => '#{params[:action]}'}."
|
43
|
-
end
|
44
|
-
end
|
45
|
-
else
|
46
|
-
AgentXmpp.logger.error "ROUTING ERROR: no route for {:node => '#{params[:node]}', :action => '#{params[:action]}'}."
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
#.......................................................................................................
|
51
|
-
def invoke_chat_message_body_response(connection, params)
|
52
|
-
route = map.chat_message_body_route
|
53
|
-
begin
|
54
|
-
controller_class = eval("#{route[:controller].classify}Controller")
|
55
|
-
rescue ArgumentError
|
56
|
-
AgentXmpp.logger.error "ROUTING ERROR: #{params[:node].classify}Controller inavlid for node:#{params[:node]} action:#{params[:action]}."
|
57
|
-
else
|
58
|
-
controller_class.new.handle_request(connection, route[:action], params)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
#.......................................................................................................
|
63
|
-
def fields(params)
|
64
|
-
nil
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
####......................................................................................................
|
69
|
-
|
70
|
-
#### Routes
|
71
|
-
end
|
72
|
-
|
73
|
-
#### Routing
|
74
|
-
end
|
75
|
-
|
76
|
-
#### AgentXmpp
|
77
|
-
end
|
data/lib/agent_xmpp/app/view.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
|
4
|
-
#####-------------------------------------------------------------------------------------------------------
|
5
|
-
class View
|
6
|
-
|
7
|
-
#---------------------------------------------------------------------------------------------------------
|
8
|
-
attr_reader :connection, :format, :params
|
9
|
-
#---------------------------------------------------------------------------------------------------------
|
10
|
-
|
11
|
-
#.........................................................................................................
|
12
|
-
def initialize(connection, format, params)
|
13
|
-
@connection = connection
|
14
|
-
@format = format
|
15
|
-
@params = params
|
16
|
-
end
|
17
|
-
|
18
|
-
#.........................................................................................................
|
19
|
-
def add_payload_to_container(payload)
|
20
|
-
container_type = case format.xmlns
|
21
|
-
when 'jabber:x:data' then :add_x_data_to_container
|
22
|
-
when 'message:chat' then :add_chat_message_body_container
|
23
|
-
end
|
24
|
-
container_type.nil? ? nil : send(container_type, payload)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
#.........................................................................................................
|
30
|
-
def add_x_data_to_container(payload)
|
31
|
-
iq = Jabber::Iq.new(:result, params[:from])
|
32
|
-
iq.id = params[:id] unless params[:id].nil?
|
33
|
-
iq.command = Jabber::Command::IqCommand.new(params[:node], 'completed')
|
34
|
-
iq.command << payload
|
35
|
-
iq
|
36
|
-
end
|
37
|
-
|
38
|
-
#.........................................................................................................
|
39
|
-
def add_chat_message_body_container(payload)
|
40
|
-
message = Jabber::Message.new(params[:from], payload)
|
41
|
-
message.type = :chat
|
42
|
-
message
|
43
|
-
end
|
44
|
-
|
45
|
-
#### View
|
46
|
-
end
|
47
|
-
|
48
|
-
#### AgentXmpp
|
49
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
|
4
|
-
#####-------------------------------------------------------------------------------------------------------
|
5
|
-
module Parser
|
6
|
-
|
7
|
-
#---------------------------------------------------------------------------------------------------------
|
8
|
-
include EventMachine::XmlPushParser
|
9
|
-
#---------------------------------------------------------------------------------------------------------
|
10
|
-
|
11
|
-
#---------------------------------------------------------------------------------------------------------
|
12
|
-
attr_reader :stream_features, :stream_mechanisms
|
13
|
-
#---------------------------------------------------------------------------------------------------------
|
14
|
-
|
15
|
-
#---------------------------------------------------------------------------------------------------------
|
16
|
-
# EventMachine::XmlPushParser callbacks
|
17
|
-
#.........................................................................................................
|
18
|
-
def start_document
|
19
|
-
end
|
20
|
-
|
21
|
-
#.........................................................................................................
|
22
|
-
def start_element(name, attrs)
|
23
|
-
e = REXML::Element.new(name)
|
24
|
-
e.add_attributes(attrs)
|
25
|
-
@current = @current.nil? ? e : @current.add_element(e)
|
26
|
-
if @current.xpath == 'stream:stream'
|
27
|
-
process
|
28
|
-
@current = nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
#.........................................................................................................
|
33
|
-
def end_element(name)
|
34
|
-
if @current.parent
|
35
|
-
@current = @current.parent
|
36
|
-
else
|
37
|
-
process
|
38
|
-
@current = nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
#.........................................................................................................
|
43
|
-
def characters(text)
|
44
|
-
@current.text = @current.text.to_s + text if @current
|
45
|
-
end
|
46
|
-
|
47
|
-
#.........................................................................................................
|
48
|
-
def error(*args)
|
49
|
-
AgentXmpp.logger.error *args
|
50
|
-
end
|
51
|
-
|
52
|
-
#.........................................................................................................
|
53
|
-
def process
|
54
|
-
@current.add_namespace(@streamns) if @current.namespace('').to_s.eql?('')
|
55
|
-
begin
|
56
|
-
stanza = Jabber::XMPPStanza::import(@current)
|
57
|
-
rescue Jabber::NoNameXmlnsRegistered
|
58
|
-
stanza = @current
|
59
|
-
end
|
60
|
-
if @current.xpath.eql?('stream:stream')
|
61
|
-
@streamns = @current.namespace('') if @current.namespace('')
|
62
|
-
end
|
63
|
-
receive(stanza) if respond_to?(:receive)
|
64
|
-
end
|
65
|
-
|
66
|
-
#### Parser
|
67
|
-
end
|
68
|
-
|
69
|
-
#### AgentXmpp
|
70
|
-
end
|
71
|
-
|
@@ -1,5 +0,0 @@
|
|
1
|
-
require 'agent_xmpp/patches/standard_library_patches/object'
|
2
|
-
require 'agent_xmpp/patches/standard_library_patches/array'
|
3
|
-
require 'agent_xmpp/patches/standard_library_patches/hash'
|
4
|
-
require 'agent_xmpp/patches/standard_library_patches/string'
|
5
|
-
require 'agent_xmpp/patches/standard_library_patches/float'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
module XMPP4RPatches
|
4
|
-
module Command
|
5
|
-
|
6
|
-
####----------------------------------------------------------------------------------------------------
|
7
|
-
module InstanceMethods
|
8
|
-
|
9
|
-
#.....................................................................................................
|
10
|
-
def <<(child)
|
11
|
-
add(child)
|
12
|
-
end
|
13
|
-
|
14
|
-
#### InstanceMethods
|
15
|
-
end
|
16
|
-
|
17
|
-
##### Command
|
18
|
-
end
|
19
|
-
##### XMPP4RPatches
|
20
|
-
end
|
21
|
-
#### AgentXmpp
|
22
|
-
end
|
23
|
-
|
24
|
-
##############################################################################################################
|
25
|
-
Jabber::Command::IqCommand.send(:include, Jabber::XParent)
|
26
|
-
Jabber::Command::IqCommand.send(:include, AgentXmpp::XMPP4RPatches::Command::InstanceMethods)
|
@@ -1,26 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
module XMPP4RPatches
|
4
|
-
module Iq
|
5
|
-
|
6
|
-
####----------------------------------------------------------------------------------------------------
|
7
|
-
module InstanceMethods
|
8
|
-
|
9
|
-
#.....................................................................................................
|
10
|
-
def command=(newcommand)
|
11
|
-
delete_elements(newcommand.name)
|
12
|
-
add(newcommand)
|
13
|
-
end
|
14
|
-
|
15
|
-
#### InstanceMethods
|
16
|
-
end
|
17
|
-
|
18
|
-
##### Iq
|
19
|
-
end
|
20
|
-
##### XMPP4RPatches
|
21
|
-
end
|
22
|
-
#### AgentXmpp
|
23
|
-
end
|
24
|
-
|
25
|
-
##############################################################################################################
|
26
|
-
Jabber::Iq.send(:include, AgentXmpp::XMPP4RPatches::Iq::InstanceMethods)
|
@@ -1,116 +0,0 @@
|
|
1
|
-
##############################################################################################################
|
2
|
-
module AgentXmpp
|
3
|
-
module XMPP4RPatches
|
4
|
-
module XData
|
5
|
-
|
6
|
-
####----------------------------------------------------------------------------------------------------
|
7
|
-
module InstanceMethods
|
8
|
-
|
9
|
-
#.....................................................................................................
|
10
|
-
def <<(child)
|
11
|
-
add(child)
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
#.....................................................................................................
|
16
|
-
def add_field_with_value(var, value)
|
17
|
-
field = Jabber::Dataforms::XDataField.new(var)
|
18
|
-
field.value = value
|
19
|
-
self << field
|
20
|
-
end
|
21
|
-
|
22
|
-
#### InstanceMethods
|
23
|
-
end
|
24
|
-
|
25
|
-
##### XData
|
26
|
-
end
|
27
|
-
##### XMPP4RPatches
|
28
|
-
end
|
29
|
-
#### AgentXmpp
|
30
|
-
end
|
31
|
-
|
32
|
-
##############################################################################################################
|
33
|
-
Jabber::Dataforms::XData.send(:include, AgentXmpp::XMPP4RPatches::XData::InstanceMethods)
|
34
|
-
|
35
|
-
##############################################################################################################
|
36
|
-
module AgentXmpp
|
37
|
-
module XMPP4RPatches
|
38
|
-
module XDataReported
|
39
|
-
|
40
|
-
####----------------------------------------------------------------------------------------------------
|
41
|
-
module InstanceMethods
|
42
|
-
|
43
|
-
#.....................................................................................................
|
44
|
-
def fields(including_hidden=false)
|
45
|
-
fields = []
|
46
|
-
each_element do |xe|
|
47
|
-
if xe.kind_of?(Jabber::Dataforms::XDataField) and (including_hidden or (xe.type != :hidden and xe.type != :fixed))
|
48
|
-
fields << xe
|
49
|
-
end
|
50
|
-
end
|
51
|
-
fields
|
52
|
-
end
|
53
|
-
|
54
|
-
#.....................................................................................................
|
55
|
-
def <<(child)
|
56
|
-
add(child)
|
57
|
-
self
|
58
|
-
end
|
59
|
-
|
60
|
-
#.....................................................................................................
|
61
|
-
def add_field(var)
|
62
|
-
self << Jabber::Dataforms::XDataField.new(var)
|
63
|
-
end
|
64
|
-
|
65
|
-
#### InstanceMethods
|
66
|
-
end
|
67
|
-
|
68
|
-
##### XDataReported
|
69
|
-
end
|
70
|
-
##### XMPP4RPatches
|
71
|
-
end
|
72
|
-
#### AgentXmpp
|
73
|
-
end
|
74
|
-
|
75
|
-
##############################################################################################################
|
76
|
-
Jabber::Dataforms::XDataReported.send(:include, AgentXmpp::XMPP4RPatches::XDataReported::InstanceMethods)
|
77
|
-
|
78
|
-
##############################################################################################################
|
79
|
-
##############################################################################################################
|
80
|
-
module Jabber
|
81
|
-
module Dataforms
|
82
|
-
class XDataItem < XMPPElement
|
83
|
-
|
84
|
-
#.....................................................................................................
|
85
|
-
name_xmlns 'item', 'jabber:x:data'
|
86
|
-
|
87
|
-
#.....................................................................................................
|
88
|
-
def fields(including_hidden=false)
|
89
|
-
fields = []
|
90
|
-
each_element do |xe|
|
91
|
-
if xe.kind_of?(Jabber::Dataforms::XDataField) and (including_hidden or (xe.type != :hidden and xe.type != :fixed))
|
92
|
-
fields << xe
|
93
|
-
end
|
94
|
-
end
|
95
|
-
fields
|
96
|
-
end
|
97
|
-
|
98
|
-
#.....................................................................................................
|
99
|
-
def <<(child)
|
100
|
-
add(child)
|
101
|
-
self
|
102
|
-
end
|
103
|
-
|
104
|
-
#.....................................................................................................
|
105
|
-
def add_field_with_value(var, value)
|
106
|
-
field = Jabber::Dataforms::XDataField.new(var)
|
107
|
-
field.value = value
|
108
|
-
self << field
|
109
|
-
end
|
110
|
-
|
111
|
-
#### XDataItem
|
112
|
-
end
|
113
|
-
#### Dataforms
|
114
|
-
end
|
115
|
-
#### Jabber
|
116
|
-
end
|