Created
November 3, 2010 21:30
-
-
Save casualjim/661753 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Stream { | |
sealed trait XMPPStreamError | |
object BadFormatError { | |
def apply( text: Option[String] = None, applicationCondition: Seq[Node]) = { | |
<stream:error> | |
<bad-format xmlns={XMPP_STREAMS_NS} /> | |
{text.map(t => <text xmlns={XMPP_STREAMS_NS}>{t}</text>) getOrElse Nil} | |
{applicationCondition getOrElse Nil} | |
</stream:error> | |
} | |
def unapply(stanza: NodeSeq) = stanza match { | |
case err @ <stream:error>{ ch @ _*}</stream:error> if !(err \ "bad-format").isEmpty => { | |
val txt = (err \ "text").text | |
val text = if(txt.isNotBlank) Some(txt) else None | |
val appCond = ch.filterNot(n => ("bad-format" :: "text" :: Nil).contains(n)) | |
Some((text, appCond)) | |
} | |
case _ => None | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment