Parent

Methods

Files

Class/Module Index [+]

Quicksearch

God::Contacts::Jabber

Attributes

format[RW]
from_jid[RW]
host[RW]
password[RW]
port[RW]
subject[RW]
to_jid[RW]
from_jid[RW]
host[RW]
password[RW]
port[RW]
subject[RW]
to_jid[RW]

Public Instance Methods

notify(message, time, priority, category, host) click to toggle source
# File lib/god/contacts/jabber.rb, line 47
def notify(message, time, priority, category, host)
  body = Jabber.format.call(message, time, priority, category, host)

  message = ::Jabber::Message.new(arg(:to_jid), body)
  message.set_type(:normal)
  message.set_id('1')
  message.set_subject(arg(:subject))

  jabber_id = ::Jabber::JID.new("#{arg(:from_jid)}/God")

  client = ::Jabber::Client.new(jabber_id)
  client.connect(arg(:host), arg(:port))
  client.auth(arg(:password))
  client.send(message)
  client.close

  self.info = "sent jabber message to #{self.to_jid}"
rescue Object => e
  if e.respond_to?(:message)
    applog(nil, :info, "failed to send jabber message to #{arg(:to_jid)}: #{e.message}")
  else
    applog(nil, :info, "failed to send jabber message to #{arg(:to_jid)}: #{e.class}")
  end
  applog(nil, :debug, e.backtrace.join("\n"))
end
valid?() click to toggle source
# File lib/god/contacts/jabber.rb, line 37
def valid?
  valid = true
  valid &= complain("Attribute 'host' must be specified", self) unless arg(:host)
  valid &= complain("Attribute 'port' must be specified", self) unless arg(:port)
  valid &= complain("Attribute 'from_jid' must be specified", self) unless arg(:from_jid)
  valid &= complain("Attribute 'to_jid' must be specified", self) unless arg(:to_jid)
  valid &= complain("Attribute 'password' must be specified", self) unless arg(:password)
  valid
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.