xmpp4r 0.3.2 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/{ChangeLog → CHANGELOG} +33 -0
- data/LICENSE +9 -9
- data/README.rdoc +110 -0
- data/README_ruby19.txt +43 -0
- data/Rakefile +235 -74
- data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
- data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
- data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
- data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
- data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
- data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
- data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
- data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
- data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
- data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
- data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
- data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
- data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
- data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
- data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
- data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
- data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
- data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
- data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
- data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
- data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
- data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
- data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
- data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
- data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
- data/lib/xmpp4r.rb +4 -4
- data/lib/xmpp4r/base64.rb +32 -0
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
- data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
- data/lib/xmpp4r/callbacks.rb +5 -5
- data/lib/xmpp4r/caps.rb +1 -0
- data/lib/xmpp4r/caps/c.rb +53 -0
- data/lib/xmpp4r/caps/helper/generator.rb +160 -0
- data/lib/xmpp4r/caps/helper/helper.rb +87 -0
- data/lib/xmpp4r/client.rb +111 -40
- data/lib/xmpp4r/command/iq/command.rb +1 -1
- data/lib/xmpp4r/component.rb +8 -8
- data/lib/xmpp4r/connection.rb +25 -9
- data/lib/xmpp4r/dataforms/x/data.rb +17 -5
- data/lib/xmpp4r/debuglog.rb +13 -5
- data/lib/xmpp4r/delay/x/delay.rb +1 -1
- data/lib/xmpp4r/discovery.rb +3 -2
- data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
- data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
- data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
- data/lib/xmpp4r/framework/base.rb +55 -0
- data/lib/xmpp4r/framework/bot.rb +148 -0
- data/lib/xmpp4r/httpbinding/client.rb +1 -1
- data/lib/xmpp4r/idgenerator.rb +1 -1
- data/lib/xmpp4r/iq.rb +34 -23
- data/lib/xmpp4r/jid.rb +2 -2
- data/lib/xmpp4r/message.rb +1 -1
- data/lib/xmpp4r/muc.rb +2 -0
- data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
- data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
- data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
- data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
- data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
- data/lib/xmpp4r/muc/item.rb +143 -0
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
- data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
- data/lib/xmpp4r/presence.rb +2 -1
- data/lib/xmpp4r/pubsub.rb +7 -0
- data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
- data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
- data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
- data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
- data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
- data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
- data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
- data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
- data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
- data/lib/xmpp4r/rexmladdons.rb +56 -28
- data/lib/xmpp4r/roster.rb +0 -1
- data/lib/xmpp4r/roster/helper/roster.rb +26 -15
- data/lib/xmpp4r/roster/iq/roster.rb +19 -19
- data/lib/xmpp4r/roster/x/roster.rb +10 -10
- data/lib/xmpp4r/rpc/helper/client.rb +17 -8
- data/lib/xmpp4r/rpc/helper/server.rb +1 -2
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
- data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
- data/lib/xmpp4r/sasl.rb +27 -6
- data/lib/xmpp4r/stream.rb +39 -44
- data/lib/xmpp4r/streamparser.rb +4 -4
- data/lib/xmpp4r/tune.rb +2 -0
- data/lib/xmpp4r/tune/helper/helper.rb +58 -0
- data/lib/xmpp4r/tune/tune.rb +113 -0
- data/lib/xmpp4r/vcard.rb +0 -1
- data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
- data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
- data/lib/xmpp4r/version/iq/version.rb +0 -1
- data/lib/xmpp4r/x.rb +1 -1
- data/lib/xmpp4r/xhtml.rb +1 -0
- data/lib/xmpp4r/xhtml/html.rb +115 -0
- data/lib/xmpp4r/xmpp4r.rb +7 -5
- data/lib/xmpp4r/xmppelement.rb +21 -5
- data/lib/xmpp4r/xmppstanza.rb +6 -6
- data/setup.rb +4 -4
- data/test/bytestreams/tc_ibb.rb +2 -2
- data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
- data/test/caps/tc_helper.rb +156 -0
- data/test/dataforms/tc_data.rb +0 -0
- data/test/delay/tc_xdelay.rb +2 -2
- data/test/discovery/tc_responder.rb +91 -0
- data/test/lib/assert_equal_xml.rb +14 -0
- data/test/lib/clienttester.rb +31 -24
- data/test/muc/tc_muc_mucclient.rb +249 -13
- data/test/muc/tc_muc_simplemucclient.rb +41 -2
- data/test/muc/tc_mucowner.rb +0 -0
- data/test/pubsub/tc_helper.rb +486 -51
- data/test/pubsub/tc_nodeconfig.rb +54 -0
- data/test/pubsub/tc_subscriptionconfig.rb +41 -0
- data/test/roster/tc_helper.rb +6 -7
- data/test/roster/tc_iqqueryroster.rb +16 -16
- data/test/roster/tc_xroster.rb +1 -1
- data/test/rpc/tc_helper.rb +15 -3
- data/test/tc_callbacks.rb +7 -7
- data/test/tc_class_names.rb +15 -6
- data/test/tc_client.rb +3 -3
- data/test/{tc_error.rb → tc_errors.rb} +54 -12
- data/test/tc_idgenerator.rb +0 -0
- data/test/tc_iq.rb +32 -29
- data/test/tc_iqquery.rb +2 -2
- data/test/tc_jid.rb +44 -42
- data/test/tc_message.rb +13 -12
- data/test/tc_presence.rb +25 -24
- data/test/tc_rexml.rb +81 -2
- data/test/tc_stream.rb +15 -13
- data/test/tc_streamComponent.rb +6 -5
- data/test/tc_streamError.rb +21 -15
- data/test/tc_streamSend.rb +9 -9
- data/test/tc_streamparser.rb +112 -0
- data/test/tc_xmppstanza.rb +19 -9
- data/test/ts_xmpp4r.rb +10 -1
- data/test/tune/tc_helper_recv.rb +84 -0
- data/test/tune/tc_helper_send.rb +74 -0
- data/test/tune/tc_tune.rb +79 -0
- data/test/vcard/tc_helper.rb +2 -2
- data/test/vcard/tc_iqvcard.rb +13 -3
- data/test/version/tc_helper.rb +2 -2
- data/test/version/tc_iqqueryversion.rb +10 -10
- data/test/xhtml/tc_html.rb +41 -0
- data/tools/gen_requires.bash +29 -8
- data/tools/xmpp4r-gemspec-test.rb +11 -0
- data/xmpp4r.gemspec +291 -0
- metadata +277 -218
- data/README +0 -28
- data/UPDATING +0 -40
- data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
- data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
- data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
- data/lib/xmpp4r/authenticationfailure.rb +0 -13
- data/lib/xmpp4r/errorexception.rb +0 -32
- data/tools/doctoweb.bash +0 -30
@@ -0,0 +1,113 @@
|
|
1
|
+
# =XMPP4R - XMPP Library for Ruby
|
2
|
+
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
|
3
|
+
# Website::http://home.gna.org/xmpp4r/
|
4
|
+
|
5
|
+
require 'xmpp4r/xmppelement'
|
6
|
+
require 'rexml/element'
|
7
|
+
|
8
|
+
module Jabber
|
9
|
+
module UserTune
|
10
|
+
NS_USERTUNE = 'http://jabber.org/protocol/tune'
|
11
|
+
|
12
|
+
##
|
13
|
+
# The <tune> XMPP element, as defined in XEP-0118 User Tune
|
14
|
+
#
|
15
|
+
# See http://www.xmpp.org/extensions/xep-0118.html - this element
|
16
|
+
# encapsulates metadata (artist, track etc) about a tune the user
|
17
|
+
# is currently playing. These are expressed as child elements
|
18
|
+
# such as <artist>, <title> etc which are also managed by this class.
|
19
|
+
#
|
20
|
+
# If the element has no children then it indicates that the user
|
21
|
+
# has stopped playing a tune. Use the Tune#playing? method to discover
|
22
|
+
# this?
|
23
|
+
class Tune < XMPPElement
|
24
|
+
name_xmlns 'tune', NS_USERTUNE
|
25
|
+
force_xmlns true
|
26
|
+
|
27
|
+
##
|
28
|
+
# Construct a new <tune> element.
|
29
|
+
#
|
30
|
+
# Supply no arguments to make an
|
31
|
+
# empty element to indicate that tune playing has stopped.
|
32
|
+
#
|
33
|
+
# artist:: [String] the artist or performer of the song or piece
|
34
|
+
# title:: [String] the title of the song or piece
|
35
|
+
# length:: [Fixnum] the duration of the song or piece in seconds
|
36
|
+
# track:: [String] a unique identifier for the tune; e.g., the track number within a collection or the specific URI for the object (e.g., a stream or audio file)
|
37
|
+
# source:: [String] the collection (e.g., album) or other source (e.g., a band website that hosts streams or audio files)
|
38
|
+
# uri:: [String] a URI or URL pointing to information about the song, collection, or artist
|
39
|
+
# rating:: [Numeric] a number indicating how much you like this song - will be clamped into an integer 0 <= x <= 10
|
40
|
+
def initialize(artist = nil, title = nil, length = nil, track = nil, source = nil, uri = nil, rating = nil)
|
41
|
+
super()
|
42
|
+
|
43
|
+
add_element(REXML::Element.new('artist')).text = artist if artist
|
44
|
+
|
45
|
+
add_element(REXML::Element.new('title')).text = title if title
|
46
|
+
|
47
|
+
add_element(REXML::Element.new('length')).text = length.to_s if length
|
48
|
+
|
49
|
+
add_element(REXML::Element.new('track')).text = track if track
|
50
|
+
|
51
|
+
add_element(REXML::Element.new('source')).text = source if source
|
52
|
+
|
53
|
+
add_element(REXML::Element.new('uri')).text = uri if uri
|
54
|
+
|
55
|
+
if rating and rating.kind_of?(Numeric)
|
56
|
+
r = rating.to_i
|
57
|
+
r = 0 if r < 0
|
58
|
+
r = 10 if r > 10
|
59
|
+
add_element(REXML::Element.new('rating')).text = r.to_s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
##
|
65
|
+
# Returns true if a tune is currently playing, otherwise false.
|
66
|
+
def playing?
|
67
|
+
(elements.size > 0)
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Get the artist for this tune.
|
72
|
+
def artist
|
73
|
+
first_element('artist').text if first_element('artist')
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Get the title of this tune.
|
78
|
+
def title
|
79
|
+
first_element('title').text if first_element('title')
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Get the length of this tune, in seconds.
|
84
|
+
def length
|
85
|
+
first_element('length').text.to_i if first_element('length')
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Get an identitier for this tune.
|
90
|
+
def track
|
91
|
+
first_element('track').text if first_element('track')
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Get the source of this tune, such as an album.
|
96
|
+
def source
|
97
|
+
first_element('source').text if first_element('source')
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Get a URI that represents this tune.
|
102
|
+
def uri
|
103
|
+
first_element('uri').text if first_element('uri')
|
104
|
+
end
|
105
|
+
|
106
|
+
##
|
107
|
+
# Get the rating for this track
|
108
|
+
def rating
|
109
|
+
first_element('rating').text.to_i if first_element('rating')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/xmpp4r/vcard.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# Website::http://home.gna.org/xmpp4r/
|
4
4
|
|
5
5
|
require 'xmpp4r/iq'
|
6
|
-
require 'xmpp4r/errorexception'
|
7
6
|
|
8
7
|
module Jabber
|
9
8
|
module Vcard
|
@@ -20,7 +19,7 @@ module Jabber
|
|
20
19
|
# Retrieve vCard of an entity
|
21
20
|
#
|
22
21
|
# Raises exception upon retrieval error, please catch that!
|
23
|
-
# (The exception is
|
22
|
+
# (The exception is ServerError and is raisen by
|
24
23
|
# Stream#send_with_id.
|
25
24
|
#
|
26
25
|
# Usage of Threads is suggested here as vCards can be very
|
@@ -83,4 +82,3 @@ module Jabber
|
|
83
82
|
end
|
84
83
|
end
|
85
84
|
end
|
86
|
-
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# Website::http://home.gna.org/xmpp4r/
|
4
4
|
|
5
5
|
require 'xmpp4r/iq'
|
6
|
+
require 'xmpp4r/base64'
|
6
7
|
|
7
8
|
module Jabber
|
8
9
|
module Vcard
|
@@ -72,6 +73,19 @@ module Jabber
|
|
72
73
|
element_names(self).uniq
|
73
74
|
end
|
74
75
|
|
76
|
+
##
|
77
|
+
# Get the PHOTO/BINVAL (Avatar picture) field decoded from Base64
|
78
|
+
# result:: [String] or [nil]
|
79
|
+
def photo_binval
|
80
|
+
if (binval = self['PHOTO/BINVAL'])
|
81
|
+
Base64::decode64(binval)
|
82
|
+
else
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
75
89
|
##
|
76
90
|
# Recursive helper function,
|
77
91
|
# returns all element names in an array, concatenated
|
data/lib/xmpp4r/x.rb
CHANGED
data/lib/xmpp4r/xhtml.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'xmpp4r/xhtml/html'
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'xmpp4r/xmppelement'
|
2
|
+
|
3
|
+
module Jabber
|
4
|
+
module XHTML
|
5
|
+
NS_XHTML_IM = 'http://jabber.org/protocol/xhtml-im'
|
6
|
+
NS_XHTML = 'http://www.w3.org/1999/xhtml'
|
7
|
+
|
8
|
+
##
|
9
|
+
# XHTML-IM (XEP-0071) container
|
10
|
+
#
|
11
|
+
# The important methods are:
|
12
|
+
# * HTML#contents=
|
13
|
+
# * HTML#to_text
|
14
|
+
class HTML < XMPPElement
|
15
|
+
name_xmlns 'html', NS_XHTML_IM
|
16
|
+
force_xmlns true
|
17
|
+
|
18
|
+
##
|
19
|
+
# Initialize element with HTML contents (see HTML#contents=)
|
20
|
+
def initialize(contents=[])
|
21
|
+
super()
|
22
|
+
self.contents = contents
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Get first XHTML::Body child
|
27
|
+
def body
|
28
|
+
first_element('body') || add(Body.new)
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Replace first XHTML::Body child
|
33
|
+
def body=(body)
|
34
|
+
delete_elements('body')
|
35
|
+
add(body)
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Replace first XHTML::Body child (chainable)
|
40
|
+
def set_body(body)
|
41
|
+
self.body = body
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Set contents of this HTML document. The "contents" parameter can be:
|
47
|
+
# * An Array of REXML::Element and Strings which will replace the current children of the body
|
48
|
+
# * A single REXML::Element which will replace all other children of the body
|
49
|
+
# * An instance of XHTML::Body which will replace the current body
|
50
|
+
# * A String comprising an HTML fragment. This will be parsed, which could raise an Exception.
|
51
|
+
# We must never send invalid XML over an XMPP stream. If you intend to put variable data in
|
52
|
+
# your HTML, use something like Rails' Builder::XmlMarkup or Ramaze::Gestalt
|
53
|
+
def contents=(contents)
|
54
|
+
if contents.kind_of? String
|
55
|
+
self.body = REXML::Document.new("<body xmlns='#{NS_XHTML}'>#{contents}</body>").root
|
56
|
+
elsif contents.kind_of? Body
|
57
|
+
self.body = contents
|
58
|
+
elsif contents.kind_of? Array
|
59
|
+
self.body = Body.new
|
60
|
+
contents.each do |element|
|
61
|
+
if element.kind_of? String
|
62
|
+
body.add_text(element)
|
63
|
+
else
|
64
|
+
body.add(element)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
else
|
68
|
+
self.body = Body.new
|
69
|
+
body.add(contents)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# HTML#contents= chainable
|
75
|
+
def set_contents(contents)
|
76
|
+
self.contents = contents
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Convert contents of this XHTML container to plain text
|
82
|
+
# for easy usage with an additional fall-back <body/> in message stanzas
|
83
|
+
#
|
84
|
+
# The resulting string is recursively composed of the text nodes of
|
85
|
+
# all children.
|
86
|
+
# This works because of the design criteria of HTML/XHTML:
|
87
|
+
# readable content is not being put into attributes but as text children.
|
88
|
+
#
|
89
|
+
# If you require clickable links and proper information representation
|
90
|
+
# then compose the text yourself!
|
91
|
+
def to_text
|
92
|
+
text_getter = nil # Create binding so that the following lambda can work recursively
|
93
|
+
|
94
|
+
text_getter = lambda do |element|
|
95
|
+
if element.kind_of? REXML::Text
|
96
|
+
element.value
|
97
|
+
elsif element.kind_of? REXML::Element
|
98
|
+
element.children.collect { |child|
|
99
|
+
text_getter.call(child)
|
100
|
+
}.join
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
text_getter.call(self) # Finally, execute and return results
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# HTML Body element, must be the only child of XHTML::HTML
|
110
|
+
class Body < XMPPElement
|
111
|
+
name_xmlns 'body', NS_XHTML
|
112
|
+
force_xmlns true
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/xmpp4r/xmpp4r.rb
CHANGED
@@ -3,14 +3,16 @@
|
|
3
3
|
# Website::http://home.gna.org/xmpp4r/
|
4
4
|
|
5
5
|
##
|
6
|
-
# The Jabber module is the root namespace of the library.
|
7
|
-
# to Include it in your script to ease your coding. It provides
|
8
|
-
# a simple debug logging support.
|
6
|
+
# The Jabber module is the root namespace of the library.
|
9
7
|
module Jabber
|
10
|
-
# XMPP4R Version number
|
11
|
-
|
8
|
+
# XMPP4R Version number. This is the ONLY place where the version number
|
9
|
+
# should be specified. This constant is used to determine the version of
|
10
|
+
# package tarballs and generated gems.
|
11
|
+
XMPP4R_VERSION = '0.4'
|
12
12
|
end
|
13
13
|
|
14
14
|
require 'xmpp4r/client'
|
15
15
|
require 'xmpp4r/component'
|
16
16
|
require 'xmpp4r/debuglog'
|
17
|
+
require 'xmpp4r/errors'
|
18
|
+
|
data/lib/xmpp4r/xmppelement.rb
CHANGED
@@ -5,11 +5,6 @@
|
|
5
5
|
require 'xmpp4r/rexmladdons'
|
6
6
|
|
7
7
|
module Jabber
|
8
|
-
class NoNameXmlnsRegistered < RuntimeError
|
9
|
-
def initialize(klass)
|
10
|
-
super "Class #{klass} has not set name and xmlns"
|
11
|
-
end
|
12
|
-
end
|
13
8
|
|
14
9
|
##
|
15
10
|
# This class represents an XML element and provides functionality
|
@@ -148,5 +143,26 @@ module Jabber
|
|
148
143
|
cloned.context = @context
|
149
144
|
cloned
|
150
145
|
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# Generic XML attribute 'xml:lang'
|
149
|
+
# (REXML provides no shortcut)
|
150
|
+
def xml_lang
|
151
|
+
attributes['xml:lang']
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Set XML language attribute
|
156
|
+
def xml_lang=(l)
|
157
|
+
attributes['xml:lang'] = l
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Set XML language attribute (chainable)
|
162
|
+
def set_xml_lang(l)
|
163
|
+
self.xml_lang = l
|
164
|
+
self
|
165
|
+
end
|
166
|
+
|
151
167
|
end
|
152
168
|
end
|
data/lib/xmpp4r/xmppstanza.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Website::http://home.gna.org/xmpp4r/
|
4
4
|
|
5
5
|
require 'xmpp4r/xmppelement'
|
6
|
-
require 'xmpp4r/
|
6
|
+
require 'xmpp4r/errors'
|
7
7
|
require 'xmpp4r/jid'
|
8
8
|
|
9
9
|
module Jabber
|
@@ -28,7 +28,7 @@ module Jabber
|
|
28
28
|
# import:: [true or false] Copy attributes and children of source
|
29
29
|
# result:: [XMPPStanza] answer stanza
|
30
30
|
def XMPPStanza.answer(xmppstanza, import=true)
|
31
|
-
x = xmppstanza.class
|
31
|
+
x = xmppstanza.class.new
|
32
32
|
if import
|
33
33
|
x.import(xmppstanza)
|
34
34
|
end
|
@@ -64,7 +64,7 @@ module Jabber
|
|
64
64
|
#
|
65
65
|
# return:: [String] the element's to attribute
|
66
66
|
def to
|
67
|
-
(a = attribute('to')).nil? ? a : JID
|
67
|
+
(a = attribute('to')).nil? ? a : JID.new(a.value)
|
68
68
|
end
|
69
69
|
|
70
70
|
##
|
@@ -89,7 +89,7 @@ module Jabber
|
|
89
89
|
#
|
90
90
|
# return:: [String] the element's from attribute
|
91
91
|
def from
|
92
|
-
(a = attribute('from')).nil? ? a : JID
|
92
|
+
(a = attribute('from')).nil? ? a : JID.new(a.value)
|
93
93
|
end
|
94
94
|
|
95
95
|
##
|
@@ -122,7 +122,7 @@ module Jabber
|
|
122
122
|
#
|
123
123
|
# v:: [String] the value id set
|
124
124
|
def id= (v)
|
125
|
-
add_attribute('id', v)
|
125
|
+
add_attribute('id', v.to_s)
|
126
126
|
end
|
127
127
|
|
128
128
|
##
|
@@ -130,7 +130,7 @@ module Jabber
|
|
130
130
|
#
|
131
131
|
# v:: [String] the value id set
|
132
132
|
def set_id(v)
|
133
|
-
add_attribute('id', v)
|
133
|
+
add_attribute('id', v.to_s)
|
134
134
|
self
|
135
135
|
end
|
136
136
|
|
data/setup.rb
CHANGED
@@ -660,7 +660,7 @@ module FileOperations
|
|
660
660
|
def ruby(*args)
|
661
661
|
command config('rubyprog'), *args
|
662
662
|
end
|
663
|
-
|
663
|
+
|
664
664
|
def make(task = nil)
|
665
665
|
command(*[config('makeprog'), task].compact)
|
666
666
|
end
|
@@ -723,7 +723,7 @@ module HookScriptAPI
|
|
723
723
|
def srcdirectory?(path)
|
724
724
|
File.dir?(srcfile(path))
|
725
725
|
end
|
726
|
-
|
726
|
+
|
727
727
|
def srcfile?(path)
|
728
728
|
File.file?(srcfile(path))
|
729
729
|
end
|
@@ -827,7 +827,7 @@ class ToplevelInstaller
|
|
827
827
|
__send__ "exec_#{task}"
|
828
828
|
end
|
829
829
|
end
|
830
|
-
|
830
|
+
|
831
831
|
def run_metaconfigs
|
832
832
|
@config.load_script "#{@ardir}/metaconfig"
|
833
833
|
end
|
@@ -1405,7 +1405,7 @@ class Installer
|
|
1405
1405
|
end
|
1406
1406
|
|
1407
1407
|
# picked up many entries from cvs-1.11.1/src/ignore.c
|
1408
|
-
JUNK_FILES = %w(
|
1408
|
+
JUNK_FILES = %w(
|
1409
1409
|
core RCSLOG tags TAGS .make.state
|
1410
1410
|
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
|
1411
1411
|
*~ *.old *.bak *.BAK *.orig *.rej _$* *$
|