Class: AgentXmpp::Roster
Overview
Class Method Summary collapse
-
.destroy_by_contact_id(contact_id) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.find_all ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.find_all_by_contact_jid(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.find_all_by_contact_jid_and_status(jid, status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.find_all_by_status(status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.find_by_jid(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.has_version?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.roster(renew = false) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.update(msg, from = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.update_status(jid, status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.update_with_presence(presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.update_with_version(vquery, from) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Class Method Details
.destroy_by_contact_id(contact_id) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
58 59 60 |
# File 'lib/agent_xmpp/models/roster.rb', line 58 def destroy_by_contact_id(contact_id) roster.filter(:contact_id => contact_id).delete end |
.find_all ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
29 30 31 |
# File 'lib/agent_xmpp/models/roster.rb', line 29 def find_all roster.all end |
.find_all_by_contact_jid(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
44 45 46 47 48 |
# File 'lib/agent_xmpp/models/roster.rb', line 44 def find_all_by_contact_jid(jid) if contact = Contact.find_by_jid(jid) roster.filter(:contact_id => contact[:contact_id]).all else; []; end end |
.find_all_by_contact_jid_and_status(jid, status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
51 52 53 54 55 |
# File 'lib/agent_xmpp/models/roster.rb', line 51 def find_all_by_contact_jid_and_status(jid, status) if contact = Contact.find_by_jid(jid) roster.filter(:contact_id => contact[:id]).all else; []; end end |
.find_all_by_status(status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
39 40 41 |
# File 'lib/agent_xmpp/models/roster.rb', line 39 def find_all_by_status(status) roster.filter(:status => status.to_s).all end |
.find_by_jid(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
34 35 36 |
# File 'lib/agent_xmpp/models/roster.rb', line 34 def find_by_jid(jid) roster[:jid => AgentXmpp.full_jid_to_s(jid)] end |
.has_version?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
63 64 65 66 67 |
# File 'lib/agent_xmpp/models/roster.rb', line 63 def has_version?(jid) if item = find_by_jid(jid) not (item[:client_name].nil? or item[:client_version].nil?) else; false; end end |
.method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
70 71 72 |
# File 'lib/agent_xmpp/models/roster.rb', line 70 def method_missing(meth, *args, &blk) roster.send(meth, *args, &blk) end |
.roster(renew = false) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
11 12 13 |
# File 'lib/agent_xmpp/models/roster.rb', line 11 def roster(renew=false) @roster ||= AgentXmpp.in_memory_db[:roster] end |
.update(msg, from = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
16 17 18 19 20 21 |
# File 'lib/agent_xmpp/models/roster.rb', line 16 def update(msg, from=nil) case msg when AgentXmpp::Xmpp::Presence then update_with_presence(msg) when AgentXmpp::Xmpp::IqVersion then update_with_version(msg, from) end end |
.update_status(jid, status) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
24 25 26 |
# File 'lib/agent_xmpp/models/roster.rb', line 24 def update_status(jid, status) roster.filter(:jid => AgentXmpp.full_jid_to_s(jid)).update(:status => status.to_s) end |
.update_with_presence(presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. private .….….….….….….….….….….….….….….….….….….….….….….….….….….
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/agent_xmpp/models/roster.rb', line 77 def update_with_presence(presence) from_jid = presence.from.to_s contact = Contact.find_by_jid(presence.from) status = presence.type.nil? ? 'available' : presence.type.to_s if (contact) begin roster << {:jid => from_jid, :status => status, :contact_id => contact[:id]} rescue roster.filter(:jid => from_jid).update(:status => status) end end end |
.update_with_version(vquery, from) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
91 92 93 94 95 |
# File 'lib/agent_xmpp/models/roster.rb', line 91 def update_with_version(vquery, from) if (item = roster.filter(:jid => from.to_s)) item.update(:client_name => vquery.iname, :client_version => vquery.version, :client_os => vquery.os) end end |