diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
commit | e140af144e987ff7f6d767f2dc48b9cf685803fd (patch) | |
tree | 4a01971890865b4b3ca837d563bc673cbb787de8 /lib/mauve/notifiers/xmpp.rb | |
parent | d28af4ec946c6aa4b645b73cef47d7e0c680bc0d (diff) |
Big commit
* Added manpages for all binaries
* Added log-reopening for mauvealert-server, and logrotate snippet
* mauveserver now adds a user on install, and runs as that user
* Big logging tidy-up
* Alert subjects are only overwritten by the source, when the subject in the databse is empty
* Removed various attr_writer methods that were being redifined
* Added a notes box to the acknowledge form, but this doesn't work yet
Diffstat (limited to 'lib/mauve/notifiers/xmpp.rb')
-rw-r--r-- | lib/mauve/notifiers/xmpp.rb | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/mauve/notifiers/xmpp.rb b/lib/mauve/notifiers/xmpp.rb index c4e1785..8131096 100644 --- a/lib/mauve/notifiers/xmpp.rb +++ b/lib/mauve/notifiers/xmpp.rb @@ -66,10 +66,10 @@ module Mauve include Jabber # Atrtribute. - attr_reader :name + attr_reader :name, :jid # Atrtribute. - attr_accessor :jid, :password + attr_accessor :password def initialize(name) Jabber::logger = self.logger @@ -80,7 +80,7 @@ module Mauve @mucs = {} @roster = nil @closing = false - + @client = nil end def logger @@ -93,7 +93,7 @@ module Mauve end def connect - logger.info "Jabber starting connection to #{@jid}" + logger.debug "Starting connection to #{@jid}" # Make sure we're disconnected. self.close if @client.is_a?(Client) @@ -110,7 +110,6 @@ module Mauve # already @roster.add_subscription_request_callback do |ri, presence| Thread.new do - logger.debug "Known? #{is_known_contact?(presence.from).inspect}" if is_known_contact?(presence.from) logger.info("Accepting subscription request from #{presence.from}") @roster.accept_subscription(presence.from) @@ -127,10 +126,11 @@ module Mauve end @roster.wait_for_roster - logger.debug "Jabber authenticated, setting presence" @client.send(Presence.new(nil, "Woo!").set_type(nil)) + logger.info "Connected as #{@jid}" + @client.on_exception do |ex, stream, where| # # The XMPP4R exception clauses in Stream all close the stream, so @@ -203,17 +203,7 @@ module Mauve alert.to_s end - history = Mauve::History.new(:alert_id => alert.id, :type => :notification) - - if send_message(destination_jid, txt) - history.event = "Sent XMPP message to #{destination_jid}" - history.save - true - else - history.event = "Failed to send XMPP message to #{destination_jid}" - history.save - false - end + send_message(destination_jid, txt) end # Sends a message to the destionation. @@ -297,12 +287,12 @@ module Mauve end if !@mucs[jid.strip].active? - logger.info("Joining #{jid}") # # Make sure we have a resource. # @mucs[jid.strip].join(jid, password) + logger.info("Joined #{jid}") else logger.debug("Already joined #{jid}.") end |