this.App =
  UI:
    setAutoHeight: ->
      height = $(window).height()
      $("#height-setter-1").css({height: height - 50})
      $("#height-setter-2").css({height: height - $('#tabbar').outerHeight() - $('#msg-writer').outerHeight() - 57})

  Com:
    connect: (callback) ->
      App._dispatcher = new WebSocketRails('www.xmpp.dev:3000/websocket')
      App._dispatcher.on_open = =>
        @_setupBackboneComponents()
        callback?()

    fetch: (options) ->
      _.defaults(options, {data: {} })
      App._dispatcher.trigger(options.event, options.data, options.success, options.error)

    getRoster: ->
      App.Com.fetch({
        event: 'app.roster.contacts'
        success: (data, contacts = data.contacts) ->
          _.each(contacts, (contact) ->
            newContact = new Xmpp.Models.Contact(contact)
            App.Collections.Contacts.add newContact
          )
      })

    _setupBackboneComponents: ->
      App.Collections.Contacts = new Xmpp.Collections.ContactsCollection()

  Collections:
    Contacts: null