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
@@ -3,7 +3,7 @@
|
|
3
3
|
# This script will request the version information of a list of JID given
|
4
4
|
# on stdin.
|
5
5
|
|
6
|
-
$:.unshift '
|
6
|
+
$:.unshift '../../../../../lib'
|
7
7
|
|
8
8
|
require 'optparse'
|
9
9
|
require 'xmpp4r/client'
|
@@ -12,13 +12,13 @@ include Jabber
|
|
12
12
|
#Jabber::debug = true
|
13
13
|
|
14
14
|
# settings
|
15
|
-
jid = JID
|
15
|
+
jid = JID.new('bot@localhost/Bot')
|
16
16
|
password = 'bot'
|
17
17
|
domains = []
|
18
|
-
OptionParser
|
18
|
+
OptionParser.new do |opts|
|
19
19
|
opts.banner = 'Usage: versionpoll.rb -j jid -p password -d DOMAINS'
|
20
20
|
opts.separator ''
|
21
|
-
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID
|
21
|
+
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID.new(j) }
|
22
22
|
opts.on('-p', '--password PASSWORD', 'sets the password') { |p| password = p }
|
23
23
|
opts.on('-d', '--domain DOMAIN', 'sets the domain') { |d| domains << d }
|
24
24
|
opts.on_tail('-h', '--help', 'Show this message') {
|
@@ -28,14 +28,14 @@ OptionParser::new do |opts|
|
|
28
28
|
opts.parse!(ARGV)
|
29
29
|
end
|
30
30
|
|
31
|
-
cl = Client
|
31
|
+
cl = Client.new(jid)
|
32
32
|
cl.connect
|
33
33
|
cl.auth(password)
|
34
34
|
sent = []
|
35
35
|
queried = []
|
36
36
|
activity = false
|
37
37
|
cl.add_iq_callback do |i|
|
38
|
-
fjid = JID
|
38
|
+
fjid = JID.new(i.from)
|
39
39
|
if i.type == :result and fjid.resource == "admin"
|
40
40
|
domain = fjid.domain
|
41
41
|
items = i.first_element('item')
|
@@ -45,7 +45,7 @@ cl.add_iq_callback do |i|
|
|
45
45
|
if not queried.include?(j)
|
46
46
|
activity = true
|
47
47
|
queried << j
|
48
|
-
cl.send(Iq
|
48
|
+
cl.send(Iq.new_browseget.set_to(j))
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -59,9 +59,9 @@ cl.add_iq_callback do |i|
|
|
59
59
|
if (a = e.attribute('type'))
|
60
60
|
if a.value == 'client'
|
61
61
|
activity = true
|
62
|
-
iq = Iq
|
63
|
-
iq.query = Version::IqQueryVersion
|
64
|
-
iq.set_to(JID
|
62
|
+
iq = Iq.new(:get)
|
63
|
+
iq.query = Version::IqQueryVersion.new
|
64
|
+
iq.set_to(JID.new(e.attribute('jid').to_s))
|
65
65
|
cl.send(iq)
|
66
66
|
end
|
67
67
|
end
|
@@ -76,9 +76,9 @@ cl.add_iq_callback do |iq|
|
|
76
76
|
puts r.inspect
|
77
77
|
end
|
78
78
|
end
|
79
|
-
cl.send(Presence
|
79
|
+
cl.send(Presence.new)
|
80
80
|
for d in domains do
|
81
|
-
cl.send(Iq
|
81
|
+
cl.send(Iq.new_browseget.set_to("#{d}/admin"))
|
82
82
|
end
|
83
83
|
|
84
84
|
activity = true
|
@@ -112,7 +112,7 @@ end
|
|
112
112
|
##
|
113
113
|
# Main loop
|
114
114
|
##
|
115
|
-
|
115
|
+
|
116
116
|
require 'mprofiler'
|
117
117
|
MemoryProfiler.start(:string_debug=>true)
|
118
118
|
|
@@ -132,7 +132,7 @@ loop {
|
|
132
132
|
print_reply(reply, Time.new - time1)
|
133
133
|
true
|
134
134
|
}
|
135
|
-
rescue Jabber::
|
135
|
+
rescue Jabber::ServerError => e
|
136
136
|
puts "Error for #{iq.query.namespace} to #{iq.to}: #{e.error.to_s.inspect}"
|
137
137
|
end
|
138
138
|
}
|
@@ -144,4 +144,3 @@ loop {
|
|
144
144
|
|
145
145
|
sleep(interval)
|
146
146
|
}
|
147
|
-
|
@@ -16,7 +16,7 @@ def with_status(str, &block)
|
|
16
16
|
yield
|
17
17
|
puts " Ok"
|
18
18
|
rescue Exception => e
|
19
|
-
puts "
|
19
|
+
puts " Exception: #{e.to_s}"
|
20
20
|
raise e
|
21
21
|
end
|
22
22
|
end
|
@@ -27,12 +27,12 @@ if ARGV.length != 3
|
|
27
27
|
puts "Run with ./change_password.rb user@server/resource oldpassword newpassword"
|
28
28
|
exit 1
|
29
29
|
end
|
30
|
-
my_jid = JID
|
30
|
+
my_jid = JID.new(ARGV[0])
|
31
31
|
my_jid.resource = 'change_password' if my_jid.resource.nil?
|
32
32
|
old_password = ARGV[1]
|
33
33
|
new_password = ARGV[2]
|
34
34
|
|
35
|
-
cl = Client
|
35
|
+
cl = Client.new(my_jid)
|
36
36
|
|
37
37
|
with_status('Connecting') { cl.connect }
|
38
38
|
with_status('Authenticating') { cl.auth(old_password) }
|
@@ -5,6 +5,8 @@
|
|
5
5
|
# connect login@server/resource password
|
6
6
|
# auth
|
7
7
|
|
8
|
+
$:.unshift '../../../../../lib'
|
9
|
+
|
8
10
|
require 'xmpp4r/client'
|
9
11
|
include Jabber
|
10
12
|
|
@@ -53,8 +55,8 @@ class BasicClient
|
|
53
55
|
# connect <jid> <password>
|
54
56
|
def do_connect(args)
|
55
57
|
@jid, @password = args.split(' ', 2)
|
56
|
-
@jid = JID
|
57
|
-
@cl = Client
|
58
|
+
@jid = JID.new(@jid)
|
59
|
+
@cl = Client.new(@jid)
|
58
60
|
@cl.connect
|
59
61
|
end
|
60
62
|
|
@@ -65,4 +67,4 @@ class BasicClient
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
BasicClient
|
70
|
+
BasicClient.new
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
# This bot will reply to every message it receives. To end the game, send 'exit'
|
4
|
-
|
4
|
+
|
5
|
+
$:.unshift '../../../../../lib'
|
5
6
|
|
6
7
|
require 'xmpp4r/client'
|
7
8
|
include Jabber
|
@@ -11,21 +12,21 @@ if ARGV.length != 2
|
|
11
12
|
puts "Run with ./echo_thread.rb user@server/resource password"
|
12
13
|
exit 1
|
13
14
|
end
|
14
|
-
myJID = JID
|
15
|
-
myPassword = ARGV[1]
|
16
|
-
cl = Client
|
15
|
+
myJID = JID.new(ARGV[0])
|
16
|
+
myPassword = ARGV[1]
|
17
|
+
cl = Client.new(myJID)
|
17
18
|
cl.connect
|
18
19
|
cl.auth(myPassword)
|
19
|
-
cl.send(Presence
|
20
|
+
cl.send(Presence.new)
|
20
21
|
puts "Connected ! send messages to #{myJID.strip.to_s}."
|
21
22
|
mainthread = Thread.current
|
22
23
|
cl.add_message_callback do |m|
|
23
24
|
if m.type != :error
|
24
|
-
m2 = Message
|
25
|
+
m2 = Message.new(m.from, "You sent: #{m.body}")
|
25
26
|
m2.type = m.type
|
26
27
|
cl.send(m2)
|
27
28
|
if m.body == 'exit'
|
28
|
-
m2 = Message
|
29
|
+
m2 = Message.new(m.from, "Exiting ...")
|
29
30
|
m2.type = m.type
|
30
31
|
cl.send(m2)
|
31
32
|
mainthread.wakeup
|
@@ -10,16 +10,16 @@ require 'xmpp4r'
|
|
10
10
|
include Jabber
|
11
11
|
|
12
12
|
# settings
|
13
|
-
myJID = JID
|
13
|
+
myJID = JID.new('bot@localhost/Bot')
|
14
14
|
myPassword = 'bot'
|
15
15
|
|
16
16
|
to = nil
|
17
17
|
subject = ''
|
18
|
-
OptionParser
|
18
|
+
OptionParser.new do |opts|
|
19
19
|
opts.banner = 'Usage: jabbersend.rb -s \'subject\' -t dest@domain'
|
20
20
|
opts.separator ''
|
21
21
|
opts.on('-s', '--subject SUBJECT', 'sets the message\'s subject') { |s| subject = s }
|
22
|
-
opts.on('-t', '--to DESTJID', 'sets the receiver') { |t| to = JID
|
22
|
+
opts.on('-t', '--to DESTJID', 'sets the receiver') { |t| to = JID.new(t) }
|
23
23
|
opts.on_tail('-h', '--help', 'Show this message') {
|
24
24
|
puts opts
|
25
25
|
exit
|
@@ -31,11 +31,11 @@ if to.nil?
|
|
31
31
|
puts "No receiver specified. See jabbersend -h"
|
32
32
|
end
|
33
33
|
|
34
|
-
cl = Client
|
34
|
+
cl = Client.new(myJID)
|
35
35
|
cl.connect
|
36
36
|
cl.auth(myPassword)
|
37
37
|
body = STDIN.readlines.join
|
38
|
-
m = Message
|
38
|
+
m = Message.new(to, body).set_type(:normal).set_id('1').set_subject(subject)
|
39
39
|
puts m.to_s
|
40
40
|
cl.send(m)
|
41
41
|
cl.close
|
@@ -14,16 +14,16 @@ include Jabber
|
|
14
14
|
# - JID list on stdin
|
15
15
|
|
16
16
|
# settings
|
17
|
-
jid = JID
|
17
|
+
jid = JID.new('bot@localhost/Bot')
|
18
18
|
password = 'bot'
|
19
19
|
filename = 'message.txt'
|
20
20
|
|
21
21
|
subject = "Message de test"
|
22
22
|
|
23
|
-
OptionParser
|
23
|
+
OptionParser.new do |opts|
|
24
24
|
opts.banner = 'Usage: mass_sender.rb -j jid -p password'
|
25
25
|
opts.separator ''
|
26
|
-
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID
|
26
|
+
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID.new(j) }
|
27
27
|
opts.on('-p', '--password PASSWORD', 'sets the password') { |p| password = p }
|
28
28
|
opts.on('-f', '--filename MESSAGE', 'sets the filename containing the message') { |f| filename = f }
|
29
29
|
opts.on('-s', '--subject SUBJECT', 'sets the subject') { |s| subject = s }
|
@@ -36,7 +36,7 @@ end
|
|
36
36
|
|
37
37
|
body = IO::read(filename).chomp
|
38
38
|
|
39
|
-
cl = Client
|
39
|
+
cl = Client.new(jid)
|
40
40
|
cl.connect
|
41
41
|
cl.auth(password)
|
42
42
|
exit = false
|
@@ -44,25 +44,25 @@ sent = []
|
|
44
44
|
cl.add_message_callback do |m|
|
45
45
|
if m.type != :error
|
46
46
|
if !sent.include?(m.from)
|
47
|
-
cl.send(Message
|
47
|
+
cl.send(Message.new(m.from, "Je suis un robot. Si tu souhaites contacter un administrateur du serveur, envoie un message à lucas@nussbaum.fr ou rejoins la salle jabberfr@chat.jabberfr.org."))
|
48
48
|
sent << m.from
|
49
49
|
end
|
50
50
|
if m.body == 'exitnowplease'
|
51
|
-
cl.send(Message
|
51
|
+
cl.send(Message.new(m.from, "Exiting ..."))
|
52
52
|
exit = true
|
53
53
|
end
|
54
|
-
cl.send(Message
|
54
|
+
cl.send(Message.new('lucas@nussbaum.fr', "From #{m.from}: #{m.body.to_s}"))
|
55
55
|
end
|
56
56
|
end
|
57
|
-
cl.send(Presence
|
58
|
-
m = Message
|
57
|
+
cl.send(Presence.new)
|
58
|
+
m = Message.new(nil, body)
|
59
59
|
m.subject = subject
|
60
60
|
STDIN.each_line { |l|
|
61
61
|
l.chomp!
|
62
|
-
m.set_to(JID
|
62
|
+
m.set_to(JID.new(l).to_s)
|
63
63
|
cl.send(m)
|
64
64
|
}
|
65
65
|
while not exit do
|
66
|
-
|
66
|
+
cl.process(1)
|
67
67
|
end
|
68
68
|
cl.close
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
$:.unshift '../../../../../lib'
|
4
|
+
|
3
5
|
require 'xmpp4r'
|
4
6
|
require 'xmpp4r/muc/helper/mucbrowser'
|
5
7
|
|
@@ -23,7 +25,7 @@ if name.nil?
|
|
23
25
|
puts " Sorry, but the queried MUC component doesn't seem to support MUC or Groupchat."
|
24
26
|
else
|
25
27
|
puts " #{name}"
|
26
|
-
|
28
|
+
|
27
29
|
print "Querying #{muc_jid} for its rooms..."; $stdout.flush
|
28
30
|
rooms = browser.muc_rooms(muc_jid)
|
29
31
|
puts " #{rooms.size} rooms found"
|
@@ -5,8 +5,8 @@ require 'xmpp4r'
|
|
5
5
|
|
6
6
|
|
7
7
|
# Argument checking
|
8
|
-
if ARGV.size
|
9
|
-
puts("Usage: #{$0} <desired jid> <password>")
|
8
|
+
if ARGV.size < 2
|
9
|
+
puts("Usage: #{$0} <desired jid> <password> [field1=value1] [fieldN=valueN]")
|
10
10
|
exit
|
11
11
|
end
|
12
12
|
|
@@ -18,8 +18,25 @@ cl.connect
|
|
18
18
|
|
19
19
|
# Registration of the new user account
|
20
20
|
puts "Registering..."
|
21
|
-
|
22
|
-
|
21
|
+
begin
|
22
|
+
fields = {}
|
23
|
+
ARGV[2..-1].each { |a|
|
24
|
+
k, v = a.split('=', 2)
|
25
|
+
fields[k] = v
|
26
|
+
}
|
27
|
+
cl.register(ARGV[1], fields)
|
28
|
+
puts "Successful"
|
29
|
+
rescue Jabber::ServerError => e
|
30
|
+
puts "Error: #{e.error.text}"
|
31
|
+
if e.error.type == :modify
|
32
|
+
puts "Accepted registration information:"
|
33
|
+
instructions, fields = cl.register_info
|
34
|
+
fields.each { |info|
|
35
|
+
puts "* #{info}"
|
36
|
+
}
|
37
|
+
puts "(#{instructions})"
|
38
|
+
end
|
39
|
+
end
|
23
40
|
|
24
41
|
# Shutdown
|
25
42
|
cl.close
|
@@ -2,18 +2,20 @@
|
|
2
2
|
|
3
3
|
# This script can get all roster entries
|
4
4
|
|
5
|
+
#$:.unshift '../../../../../lib'
|
6
|
+
|
5
7
|
require 'optparse'
|
6
8
|
require 'xmpp4r'
|
7
9
|
require 'xmpp4r/roster/iq/roster'
|
8
10
|
include Jabber
|
9
11
|
|
10
|
-
jid = JID
|
12
|
+
jid = JID.new('lucastest@linux.ensimag.fr/rosterget')
|
11
13
|
password = 'lucastest'
|
12
14
|
|
13
|
-
OptionParser
|
15
|
+
OptionParser.new do |opts|
|
14
16
|
opts.banner = 'Usage: roster.rb -t get -j jid -p password'
|
15
17
|
opts.separator ''
|
16
|
-
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID
|
18
|
+
opts.on('-j', '--jid JID', 'sets the jid') { |j| jid = JID.new(j) }
|
17
19
|
opts.on('-p', '--password PASSWORD', 'sets the password') { |p| password = p }
|
18
20
|
opts.on_tail('-h', '--help', 'Show this message') {
|
19
21
|
puts opts
|
@@ -22,10 +24,10 @@ OptionParser::new do |opts|
|
|
22
24
|
opts.parse!(ARGV)
|
23
25
|
end
|
24
26
|
|
25
|
-
cl = Client
|
27
|
+
cl = Client.new(jid)
|
26
28
|
cl.connect
|
27
29
|
cl.auth(password)
|
28
|
-
cl.send(Iq
|
30
|
+
cl.send(Iq.new_rosterget)
|
29
31
|
exit = false
|
30
32
|
cl.add_iq_callback { |i|
|
31
33
|
if i.type == :result and i.query.kind_of?(Roster::IqQueryRoster)
|
File without changes
|
@@ -18,12 +18,12 @@ end
|
|
18
18
|
|
19
19
|
jid = Jabber::JID.new(ARGV[0])
|
20
20
|
|
21
|
-
cl = Jabber::Client.new(jid
|
21
|
+
cl = Jabber::Client.new(jid)
|
22
22
|
cl.connect
|
23
23
|
cl.auth(ARGV[1])
|
24
24
|
|
25
25
|
# The iq stanza
|
26
|
-
iq = Jabber::Iq
|
26
|
+
iq = Jabber::Iq.new(:set)
|
27
27
|
# The new roster instance and item element
|
28
28
|
iq.add(Jabber::Roster::IqQueryRoster.new).add(Jabber::Roster::RosterItem.new(ARGV[2], ARGV[3])).groups = ARGV[4..ARGV.size]
|
29
29
|
|
@@ -61,13 +61,13 @@ roster.add_update_callback { |olditem,item|
|
|
61
61
|
puts("Subscribing to #{item.jid}")
|
62
62
|
item.subscribe
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
# Print the item
|
66
|
-
if olditem.nil?
|
67
|
-
# We didn't knew before:
|
66
|
+
if olditem.nil?
|
67
|
+
# We didn't knew before:
|
68
68
|
puts("#{item.iname} (#{item.jid}, #{item.subscription}) #{item.groups.join(', ')}")
|
69
|
-
else
|
70
|
-
# Showing whats different:
|
69
|
+
else
|
70
|
+
# Showing whats different:
|
71
71
|
puts("#{olditem.iname} (#{olditem.jid}, #{olditem.subscription}) #{olditem.groups.join(', ')} -> #{item.iname} (#{item.jid}, #{item.subscription}) #{item.groups.join(', ')}")
|
72
72
|
end
|
73
73
|
|
@@ -115,7 +115,7 @@ roster.add_presence_callback { |item,oldpres,pres|
|
|
115
115
|
# ...so create it:
|
116
116
|
oldpres = Jabber::Presence.new
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
# Print name and jid:
|
120
120
|
name = "#{pres.from}"
|
121
121
|
if item.iname
|
@@ -169,4 +169,3 @@ cl.send(Jabber::Presence.new.set_show(:dnd).set_status('Watching my roster chang
|
|
169
169
|
Thread.stop
|
170
170
|
|
171
171
|
cl.close
|
172
|
-
|