           callback true
           this.findRoster =>
             this.notify('roster')
-            @xmpp.send $('<presence/>').get 0
+            @xmpp.send this.xml '<presence/>'
             this.findCards()
 
   disconnect: -> @xmpp.disconnect()

    @xmpp.send this.presence jid, 'unsubscribed'

  presence: (to, type) ->
    $("""
      <presence
        id="#{this.uniqueId()}"
        to="#{to}"
        type="#{type}"/>
    """).get 0

  handleIq: (node) ->
    node = $(node)

    @xmpp.send node

  sendPresence: (away, status) ->
    node = $ this.xml '<presence/>'
    if away
      node.append $(this.xml '<show>xa</show>')
      node.append $(this.xml '<status/>').text status if status != 'Away'
    else
      node.append $(this.xml '<status/>').text status if status != 'Available'
    @xmpp.send node

  sendIQ: (node, callback) ->
    @xmpp.sendIQ node, callback, callback, 5000

  updateContact: (contact, add) ->
    node = this.xml """
      <iq id="#{this.uniqueId()}" type="set">
        <query xmlns="jabber:iq:roster">
          <item name="" jid="#{contact.jid}"/>
        </query>
      </iq>
    """
    $('item', node).attr 'name', contact.name
    for group in contact.groups
      $('item', node).append $(this.xml '<group></group>').text group
    @xmpp.send node
    this.sendSubscribe(contact.jid) if add

  removeContact: (jid) ->
    node = this.xml """
      <iq id="#{this.uniqueId()}" type="set">
        <query xmlns="jabber:iq:roster">
          <item jid="#{jid}" subscription="remove"/>
        </query>
      </iq>
    """
    @xmpp.send node

  sendSubscribe: (jid) ->
    @xmpp.send this.presence jid, 'subscribe'
