PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/scala/com/mishlabs/xmpp/protocol/presence/Error.scala

http://github.com/tomerd/scala-xmpp
Scala | 39 lines | 26 code | 12 blank | 1 comment | 0 complexity | b98c0f63bb32478b6032e362f85fd743 MD5 | raw file
  1. package com.mishlabs.xmpp
  2. package protocol
  3. package presence
  4. import scala.collection._
  5. import scala.xml._
  6. import Protocol._
  7. object Error
  8. {
  9. val presenceType = PresenceTypeEnumeration.Error
  10. def apply(presence:Presence, condition:StanzaErrorCondition.Value, description:Option[String]=None):Error = apply(presence.id, presence.from, presence.to, presence.extensions, condition, description)
  11. def apply(id:Option[String], to:Option[JID], from:Option[JID], extensions:Option[Seq[Extension]], condition:StanzaErrorCondition.Value, description:Option[String]):Error =
  12. {
  13. val xml = Presence.error(id, to, from, extensions, condition, description)
  14. return apply(xml)
  15. }
  16. def apply(xml:Node):Error = new Error(xml)
  17. def unapply(error:Error):Option[(Option[String], Option[JID], Option[JID], StanzaErrorCondition.Value, Option[String])] = Some(error.id, error.to, error.from, error.condition, error.description)
  18. }
  19. class Error(xml:Node) extends Presence(xml, Error.presenceType)
  20. {
  21. // FIXME, this should be conditional
  22. private val error = StanzaError((xml \ "error")(0))
  23. val errorType:Option[StanzaErrorAction.Value] = error.errorType
  24. val condition:StanzaErrorCondition.Value = error.condition
  25. val description:Option[String] = error.description
  26. val otherConditions:Option[Seq[String]] = error.otherConditions
  27. }