xmpp4r 0.3.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/{ChangeLog → CHANGELOG} +33 -0
  2. data/LICENSE +9 -9
  3. data/README.rdoc +110 -0
  4. data/README_ruby19.txt +43 -0
  5. data/Rakefile +235 -74
  6. data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
  7. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
  8. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
  9. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
  10. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
  11. data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
  12. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
  13. data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
  14. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
  15. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  16. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  17. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
  18. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
  19. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
  20. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
  21. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
  22. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
  23. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
  24. data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
  25. data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
  26. data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
  27. data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
  28. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
  29. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
  30. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
  31. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
  32. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
  33. data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
  34. data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
  35. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
  36. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
  37. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
  38. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
  39. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  40. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  41. data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
  42. data/lib/xmpp4r.rb +4 -4
  43. data/lib/xmpp4r/base64.rb +32 -0
  44. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
  45. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
  46. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
  47. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
  48. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
  49. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
  50. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
  51. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
  52. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
  53. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
  54. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
  55. data/lib/xmpp4r/callbacks.rb +5 -5
  56. data/lib/xmpp4r/caps.rb +1 -0
  57. data/lib/xmpp4r/caps/c.rb +53 -0
  58. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  59. data/lib/xmpp4r/caps/helper/helper.rb +87 -0
  60. data/lib/xmpp4r/client.rb +111 -40
  61. data/lib/xmpp4r/command/iq/command.rb +1 -1
  62. data/lib/xmpp4r/component.rb +8 -8
  63. data/lib/xmpp4r/connection.rb +25 -9
  64. data/lib/xmpp4r/dataforms/x/data.rb +17 -5
  65. data/lib/xmpp4r/debuglog.rb +13 -5
  66. data/lib/xmpp4r/delay/x/delay.rb +1 -1
  67. data/lib/xmpp4r/discovery.rb +3 -2
  68. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  69. data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
  70. data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
  71. data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
  72. data/lib/xmpp4r/framework/base.rb +55 -0
  73. data/lib/xmpp4r/framework/bot.rb +148 -0
  74. data/lib/xmpp4r/httpbinding/client.rb +1 -1
  75. data/lib/xmpp4r/idgenerator.rb +1 -1
  76. data/lib/xmpp4r/iq.rb +34 -23
  77. data/lib/xmpp4r/jid.rb +2 -2
  78. data/lib/xmpp4r/message.rb +1 -1
  79. data/lib/xmpp4r/muc.rb +2 -0
  80. data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
  81. data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
  82. data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
  83. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  84. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  85. data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
  86. data/lib/xmpp4r/muc/item.rb +143 -0
  87. data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
  88. data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
  89. data/lib/xmpp4r/presence.rb +2 -1
  90. data/lib/xmpp4r/pubsub.rb +7 -0
  91. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  92. data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
  93. data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
  94. data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
  95. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  96. data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
  97. data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
  98. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  99. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
  100. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
  101. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
  102. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
  103. data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
  104. data/lib/xmpp4r/rexmladdons.rb +56 -28
  105. data/lib/xmpp4r/roster.rb +0 -1
  106. data/lib/xmpp4r/roster/helper/roster.rb +26 -15
  107. data/lib/xmpp4r/roster/iq/roster.rb +19 -19
  108. data/lib/xmpp4r/roster/x/roster.rb +10 -10
  109. data/lib/xmpp4r/rpc/helper/client.rb +17 -8
  110. data/lib/xmpp4r/rpc/helper/server.rb +1 -2
  111. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
  112. data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
  113. data/lib/xmpp4r/sasl.rb +27 -6
  114. data/lib/xmpp4r/stream.rb +39 -44
  115. data/lib/xmpp4r/streamparser.rb +4 -4
  116. data/lib/xmpp4r/tune.rb +2 -0
  117. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  118. data/lib/xmpp4r/tune/tune.rb +113 -0
  119. data/lib/xmpp4r/vcard.rb +0 -1
  120. data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
  121. data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
  122. data/lib/xmpp4r/version/iq/version.rb +0 -1
  123. data/lib/xmpp4r/x.rb +1 -1
  124. data/lib/xmpp4r/xhtml.rb +1 -0
  125. data/lib/xmpp4r/xhtml/html.rb +115 -0
  126. data/lib/xmpp4r/xmpp4r.rb +7 -5
  127. data/lib/xmpp4r/xmppelement.rb +21 -5
  128. data/lib/xmpp4r/xmppstanza.rb +6 -6
  129. data/setup.rb +4 -4
  130. data/test/bytestreams/tc_ibb.rb +2 -2
  131. data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
  132. data/test/caps/tc_helper.rb +156 -0
  133. data/test/dataforms/tc_data.rb +0 -0
  134. data/test/delay/tc_xdelay.rb +2 -2
  135. data/test/discovery/tc_responder.rb +91 -0
  136. data/test/lib/assert_equal_xml.rb +14 -0
  137. data/test/lib/clienttester.rb +31 -24
  138. data/test/muc/tc_muc_mucclient.rb +249 -13
  139. data/test/muc/tc_muc_simplemucclient.rb +41 -2
  140. data/test/muc/tc_mucowner.rb +0 -0
  141. data/test/pubsub/tc_helper.rb +486 -51
  142. data/test/pubsub/tc_nodeconfig.rb +54 -0
  143. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  144. data/test/roster/tc_helper.rb +6 -7
  145. data/test/roster/tc_iqqueryroster.rb +16 -16
  146. data/test/roster/tc_xroster.rb +1 -1
  147. data/test/rpc/tc_helper.rb +15 -3
  148. data/test/tc_callbacks.rb +7 -7
  149. data/test/tc_class_names.rb +15 -6
  150. data/test/tc_client.rb +3 -3
  151. data/test/{tc_error.rb → tc_errors.rb} +54 -12
  152. data/test/tc_idgenerator.rb +0 -0
  153. data/test/tc_iq.rb +32 -29
  154. data/test/tc_iqquery.rb +2 -2
  155. data/test/tc_jid.rb +44 -42
  156. data/test/tc_message.rb +13 -12
  157. data/test/tc_presence.rb +25 -24
  158. data/test/tc_rexml.rb +81 -2
  159. data/test/tc_stream.rb +15 -13
  160. data/test/tc_streamComponent.rb +6 -5
  161. data/test/tc_streamError.rb +21 -15
  162. data/test/tc_streamSend.rb +9 -9
  163. data/test/tc_streamparser.rb +112 -0
  164. data/test/tc_xmppstanza.rb +19 -9
  165. data/test/ts_xmpp4r.rb +10 -1
  166. data/test/tune/tc_helper_recv.rb +84 -0
  167. data/test/tune/tc_helper_send.rb +74 -0
  168. data/test/tune/tc_tune.rb +79 -0
  169. data/test/vcard/tc_helper.rb +2 -2
  170. data/test/vcard/tc_iqvcard.rb +13 -3
  171. data/test/version/tc_helper.rb +2 -2
  172. data/test/version/tc_iqqueryversion.rb +10 -10
  173. data/test/xhtml/tc_html.rb +41 -0
  174. data/tools/gen_requires.bash +29 -8
  175. data/tools/xmpp4r-gemspec-test.rb +11 -0
  176. data/xmpp4r.gemspec +291 -0
  177. metadata +277 -218
  178. data/README +0 -28
  179. data/UPDATING +0 -40
  180. data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
  181. data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
  182. data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
  183. data/lib/xmpp4r/authenticationfailure.rb +0 -13
  184. data/lib/xmpp4r/errorexception.rb +0 -32
  185. data/tools/doctoweb.bash +0 -30
@@ -1,8 +1,8 @@
1
- #!/usr/bin/ruby -w
1
+ #!/usr/bin/ruby -w
2
2
 
3
3
  require 'shellmgr'
4
4
 
5
- sh = Shell::new { |s| puts s }
5
+ sh = Shell.new { |s| puts s }
6
6
 
7
7
  while true do
8
8
  l = gets
@@ -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 '../lib'
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::new('bot@localhost/Bot')
15
+ jid = JID.new('bot@localhost/Bot')
16
16
  password = 'bot'
17
17
  domains = []
18
- OptionParser::new do |opts|
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::new(j) }
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::new(jid)
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::new(i.from)
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::new_browseget.set_to(j))
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::new(:get)
63
- iq.query = Version::IqQueryVersion::new
64
- iq.set_to(JID::new(e.attribute('jid').to_s))
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::new)
79
+ cl.send(Presence.new)
80
80
  for d in domains do
81
- cl.send(Iq::new_browseget.set_to("#{d}/admin"))
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::ErrorException => e
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 " Error: #{e.to_s}"
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::new(ARGV[0])
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::new(my_jid)
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::new(@jid)
57
- @cl = Client::new(@jid)
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::new
70
+ BasicClient.new
@@ -5,7 +5,7 @@ $:.unshift '../../../../../lib'
5
5
  require 'xmpp4r'
6
6
  include Jabber
7
7
 
8
- c = Component::new('tada', 'localhost', 60001)
8
+ c = Component.new('tada', 'localhost', 60001)
9
9
  c.connect
10
10
  c.auth('jabber-rocks')
11
11
  Thread.stop
@@ -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
- # THREADED VERSION
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::new(ARGV[0])
15
- myPassword = ARGV[1]
16
- cl = Client::new(myJID)
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::new)
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::new(m.from, "You sent: #{m.body}")
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::new(m.from, "Exiting ...")
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::new('bot@localhost/Bot')
13
+ myJID = JID.new('bot@localhost/Bot')
14
14
  myPassword = 'bot'
15
15
 
16
16
  to = nil
17
17
  subject = ''
18
- OptionParser::new do |opts|
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::new(t) }
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::new(myJID, false)
34
+ cl = Client.new(myJID)
35
35
  cl.connect
36
36
  cl.auth(myPassword)
37
37
  body = STDIN.readlines.join
38
- m = Message::new(to, body).set_type(:normal).set_id('1').set_subject(subject)
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::new('bot@localhost/Bot')
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::new do |opts|
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::new(j) }
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::new(jid, false)
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::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."))
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::new(m.from, "Exiting ..."))
51
+ cl.send(Message.new(m.from, "Exiting ..."))
52
52
  exit = true
53
53
  end
54
- cl.send(Message::new('lucas@nussbaum.fr', "From #{m.from}: #{m.body.to_s}"))
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::new)
58
- m = Message::new(nil, body)
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::new(l).to_s)
62
+ m.set_to(JID.new(l).to_s)
63
63
  cl.send(m)
64
64
  }
65
65
  while not exit do
66
- cl.process(1)
66
+ cl.process(1)
67
67
  end
68
68
  cl.close
@@ -10,4 +10,3 @@ muc.configure(
10
10
  'muc#roomconfig_roomname' => 'roomname',
11
11
  'muc#roomconfig_persistentroom' => 1
12
12
  )
13
-
@@ -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"
@@ -80,4 +80,3 @@ m.join(ARGV[2])
80
80
  Thread.stop
81
81
 
82
82
  cl.close
83
-
@@ -5,8 +5,8 @@ require 'xmpp4r'
5
5
 
6
6
 
7
7
  # Argument checking
8
- if ARGV.size != 2
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
- cl.register(ARGV[1])
22
- puts "Successful"
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::new('lucastest@linux.ensimag.fr/rosterget')
12
+ jid = JID.new('lucastest@linux.ensimag.fr/rosterget')
11
13
  password = 'lucastest'
12
14
 
13
- OptionParser::new do |opts|
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::new(j) }
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::new(jid, false)
27
+ cl = Client.new(jid)
26
28
  cl.connect
27
29
  cl.auth(password)
28
- cl.send(Iq::new_rosterget)
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)
@@ -18,12 +18,12 @@ end
18
18
 
19
19
  jid = Jabber::JID.new(ARGV[0])
20
20
 
21
- cl = Jabber::Client.new(jid, false)
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::new(:set)
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
-