1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
require 'xmpp4r/iq'
module Jabber
module Command
##
# Class for handling ad-hoc commands
# (JEP 0050)
#
# A command is uniquely identified by its node attribute.
class IqCommand < Iq
name_xmlns 'command', 'http://jabber.org/protocol/commands'
def initialize(node=nil, action=nil)
super()
set_node(node)
set_action(action)
end
##
# Get the node of the Command stanza
# result:: [String] or nil
def node
attributes['node']
end
##
# Set the node of the Command stanza
# v:: [String] or nil
def node=(v)
attributes['node'] = v
end
##
# Set the node of the Command stanza (chaining-friendly)
# v:: [String] or nil
def set_node(v)
self.node = v
self
end
##
# Get the sessionid of the Command stanza
# result:: [String] or nil
def sessionid
attributes['sessionid']
end
##
# Set the sessionid of the Command stanza
# v:: [String] or nil
def sessionid=(v)
attributes['sessionid'] = v
end
##
# Set the sessionid of the Command stanza (chaining-friendly)
# v:: [String] or nil
def set_sessionid(v)
self.sessionid = v
self
end
##
# Get the action of the Command stanza
#
# The following Symbols are allowed:
# * :execute
# * :cancel
# * :prev
# * :next
# * :complete
# return:: [Symbol] or nil
def action
case attributes['action']
when 'execute' then :execute
when 'cancel' then :cancel
when 'prev' then :prev
when 'next' then :next
when 'complete' then :complete
else nil
end
end
##
# Set the action of the Command stanza (see IqCommand#action for details)
# v:: [Symbol] or nil
def action=(v)
attributes['action'] = case v
when :execute then 'execute'
when :cancel then 'cancel'
when :prev then 'prev'
when :next then 'next'
when :complete then 'complete'
else nil
end
end
##
# Set the action of the Command stanza (chaining-friendly)
# v:: [Symbol] or nil
def set_action(v)
self.action = v
self
end
##
# Get the status of the Command stanza
#
# The following Symbols are allowed:
# * :executing
# * :completed
# * :canceled
# return:: [Symbol] or nil
def status
case attributes['status']
when 'executing' then :executing
when 'completed' then :completed
when 'canceled' then :canceled
else nil
end
end
##
# Set the status of the Command stanza (see IqCommand#status for details)
# v:: [Symbol] or nil
def status=(v)
attributes['status'] = case v
when :executing then 'executing'
when :completed then 'completed'
when :canceled then 'canceled'
else nil
end
end
##
# Set the status of the Command stanza (chaining-friendly)
# v:: [Symbol] or nil
def set_status(v)
self.status = v
self
end
##
# Get the actions allowed
# return:: [REXML::Element] or nil
def actions
first_element('actions')
end
end
end
end
|