Sha256: 5aff9db771834191ad9d153947b2bea99e81f72e87d22745965db20f9a8ac8dc

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift '../../../../../lib/'

require 'xmpp4r'
require 'xmpp4r/roster/helper/roster'

# Command line argument checking

if ARGV.size != 2
  puts("Usage: ./rosterprint.rb <jid> <password>")
  exit
end

# Building up the connection

#Jabber::debug = true

jid = Jabber::JID.new(ARGV[0])

cl = Jabber::Client.new(jid)
cl.connect
cl.auth(ARGV[1])

# The roster instance
roster = Jabber::Roster::Helper.new(cl)

mainthread = Thread.current

roster.add_query_callback { |iq|
  mainthread.wakeup
}

Thread.stop

roster.groups.each { |group|
  if group.nil?
    puts "*** Ungrouped ***"
  else
    puts "*** #{group} ***"
  end

  roster.find_by_group(group).each { |item|
    puts "- #{item.iname} (#{item.jid})"
  }

  print "\n"
}

cl.close

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gmcmillan-xmpp4r-0.6.2 data/doc/xmpp4r/examples/basic/rosterprint.rb
gmcmillan-xmpp4r-0.6.1 data/doc/xmpp4r/examples/basic/rosterprint.rb
gmcmillan-xmpp4r-0.6 data/doc/xmpp4r/examples/basic/rosterprint.rb
gmcmillan-xmpp4r-0.5 data/doc/xmpp4r/examples/basic/rosterprint.rb