{-# LANGUAGE CPP #-}
#if WITH_TEMPLATE_HASKELL
{-# LANGUAGE TemplateHaskell #-}
#endif
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_HADDOCK hide #-}
module Network.Xmpp.Types
( NonemptyText(..)
, nonEmpty
, text
, IQError(..)
, IQRequest(..)
, IQRequestType(..)
, IQResponse(..)
, IQResult(..)
, LangTag (..)
#if WITH_TEMPLATE_HASKELL
, langTagQ
#endif
, langTagFromText
, langTagToText
, parseLangTag
, ExtendedAttribute
, Message(..)
, message
, MessageError(..)
, messageError
, MessageType(..)
, Presence(..)
, presence
, PresenceError(..)
, PresenceType(..)
, SaslError(..)
, SaslFailure(..)
, StreamFeatures(..)
, Stanza(..)
, XmppElement(..)
, messageS
, messageErrorS
, presenceS
, StanzaError(..)
, StanzaErrorCondition(..)
, StanzaErrorType(..)
, XmppFailure(..)
, XmppTlsError(..)
, StreamErrorCondition(..)
, Version(..)
, versionFromText
, StreamHandle(..)
, Stream(..)
, StreamState(..)
, ConnectionState(..)
, StreamErrorInfo(..)
, ConnectionDetails(..)
, StreamConfiguration(..)
, xmppDefaultParams
, xmppDefaultParamsStrong
, Jid(..)
#if WITH_TEMPLATE_HASKELL
, jidQ
, jid
#endif
, isBare
, isFull
, jidFromText
, jidFromTexts
, (<~)
, nodeprepProfile
, resourceprepProfile
, jidToText
, jidToTexts
, toBare
, localpart
, domainpart
, resourcepart
, parseJid
, TlsBehaviour(..)
, AuthFailure(..)
) where
import Control.Applicative ((<$>), (<|>), many)
import Control.Concurrent.STM
import Control.Exception
import Control.Monad
import Control.Monad.Except
import qualified Data.Attoparsec.Text as AP
import qualified Data.ByteString as BS
import Data.Char (isSpace)
import Data.Conduit
import Data.Default
import Data.Semigroup as Sem
import qualified Data.Set as Set
import Data.String (IsString, fromString)
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Typeable(Typeable)
import Data.XML.Types as XML
import qualified Data.Text.Encoding as Text
import GHC.Generics
#if WITH_TEMPLATE_HASKELL
import Language.Haskell.TH
import Language.Haskell.TH.Quote
import qualified Language.Haskell.TH.Syntax as TH
#endif
import Network.Socket
import Network.DNS
import Network.TLS hiding (Version, HostName)
import Network.TLS.Extra
import qualified Text.StringPrep as SP
import qualified Text.StringPrep.Profiles as SP
newtype NonemptyText = Nonempty {NonemptyText -> Text
fromNonempty :: Text}
deriving (Int -> NonemptyText -> ShowS
[NonemptyText] -> ShowS
NonemptyText -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [NonemptyText] -> ShowS
$cshowList :: [NonemptyText] -> ShowS
show :: NonemptyText -> [Char]
$cshow :: NonemptyText -> [Char]
showsPrec :: Int -> NonemptyText -> ShowS
$cshowsPrec :: Int -> NonemptyText -> ShowS
Show, ReadPrec [NonemptyText]
ReadPrec NonemptyText
Int -> ReadS NonemptyText
ReadS [NonemptyText]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NonemptyText]
$creadListPrec :: ReadPrec [NonemptyText]
readPrec :: ReadPrec NonemptyText
$creadPrec :: ReadPrec NonemptyText
readList :: ReadS [NonemptyText]
$creadList :: ReadS [NonemptyText]
readsPrec :: Int -> ReadS NonemptyText
$creadsPrec :: Int -> ReadS NonemptyText
Read, NonemptyText -> NonemptyText -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonemptyText -> NonemptyText -> Bool
$c/= :: NonemptyText -> NonemptyText -> Bool
== :: NonemptyText -> NonemptyText -> Bool
$c== :: NonemptyText -> NonemptyText -> Bool
Eq, Eq NonemptyText
NonemptyText -> NonemptyText -> Bool
NonemptyText -> NonemptyText -> Ordering
NonemptyText -> NonemptyText -> NonemptyText
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NonemptyText -> NonemptyText -> NonemptyText
$cmin :: NonemptyText -> NonemptyText -> NonemptyText
max :: NonemptyText -> NonemptyText -> NonemptyText
$cmax :: NonemptyText -> NonemptyText -> NonemptyText
>= :: NonemptyText -> NonemptyText -> Bool
$c>= :: NonemptyText -> NonemptyText -> Bool
> :: NonemptyText -> NonemptyText -> Bool
$c> :: NonemptyText -> NonemptyText -> Bool
<= :: NonemptyText -> NonemptyText -> Bool
$c<= :: NonemptyText -> NonemptyText -> Bool
< :: NonemptyText -> NonemptyText -> Bool
$c< :: NonemptyText -> NonemptyText -> Bool
compare :: NonemptyText -> NonemptyText -> Ordering
$ccompare :: NonemptyText -> NonemptyText -> Ordering
Ord)
instance IsString NonemptyText where
fromString :: [Char] -> NonemptyText
fromString [Char]
str = case Text -> Maybe NonemptyText
nonEmpty ([Char] -> Text
Text.pack [Char]
str) of
Maybe NonemptyText
Nothing -> forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"NonemptyText fromString called on empty or " forall a. [a] -> [a] -> [a]
++
[Char]
"all-whitespace string"
Just NonemptyText
r -> NonemptyText
r
nonEmpty :: Text -> Maybe NonemptyText
nonEmpty :: Text -> Maybe NonemptyText
nonEmpty Text
txt = if (Char -> Bool) -> Text -> Bool
Text.all Char -> Bool
isSpace Text
txt then forall a. Maybe a
Nothing else forall a. a -> Maybe a
Just (Text -> NonemptyText
Nonempty Text
txt)
text :: NonemptyText -> Text
text :: NonemptyText -> Text
text (Nonempty Text
txt) = Text
txt
data XmppElement = XmppStanza !Stanza
| XmppNonza !Element
deriving (XmppElement -> XmppElement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XmppElement -> XmppElement -> Bool
$c/= :: XmppElement -> XmppElement -> Bool
== :: XmppElement -> XmppElement -> Bool
$c== :: XmppElement -> XmppElement -> Bool
Eq, Int -> XmppElement -> ShowS
[XmppElement] -> ShowS
XmppElement -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [XmppElement] -> ShowS
$cshowList :: [XmppElement] -> ShowS
show :: XmppElement -> [Char]
$cshow :: XmppElement -> [Char]
showsPrec :: Int -> XmppElement -> ShowS
$cshowsPrec :: Int -> XmppElement -> ShowS
Show)
data Stanza = IQRequestS !IQRequest
| IQResultS !IQResult
| IQErrorS !IQError
| MessageS !Message
| MessageErrorS !MessageError
| PresenceS !Presence
| PresenceErrorS !PresenceError
deriving (Stanza -> Stanza -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Stanza -> Stanza -> Bool
$c/= :: Stanza -> Stanza -> Bool
== :: Stanza -> Stanza -> Bool
$c== :: Stanza -> Stanza -> Bool
Eq, Int -> Stanza -> ShowS
[Stanza] -> ShowS
Stanza -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Stanza] -> ShowS
$cshowList :: [Stanza] -> ShowS
show :: Stanza -> [Char]
$cshow :: Stanza -> [Char]
showsPrec :: Int -> Stanza -> ShowS
$cshowsPrec :: Int -> Stanza -> ShowS
Show, forall x. Rep Stanza x -> Stanza
forall x. Stanza -> Rep Stanza x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Stanza x -> Stanza
$cfrom :: forall x. Stanza -> Rep Stanza x
Generic)
type ExtendedAttribute = (XML.Name, Text)
data IQRequest = IQRequest { IQRequest -> Text
iqRequestID :: !Text
, IQRequest -> Maybe Jid
iqRequestFrom :: !(Maybe Jid)
, IQRequest -> Maybe Jid
iqRequestTo :: !(Maybe Jid)
, IQRequest -> Maybe LangTag
iqRequestLangTag :: !(Maybe LangTag)
, IQRequest -> IQRequestType
iqRequestType :: !IQRequestType
, IQRequest -> Element
iqRequestPayload :: !Element
, IQRequest -> [ExtendedAttribute]
iqRequestAttributes :: ![ExtendedAttribute]
} deriving (IQRequest -> IQRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IQRequest -> IQRequest -> Bool
$c/= :: IQRequest -> IQRequest -> Bool
== :: IQRequest -> IQRequest -> Bool
$c== :: IQRequest -> IQRequest -> Bool
Eq, Int -> IQRequest -> ShowS
[IQRequest] -> ShowS
IQRequest -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IQRequest] -> ShowS
$cshowList :: [IQRequest] -> ShowS
show :: IQRequest -> [Char]
$cshow :: IQRequest -> [Char]
showsPrec :: Int -> IQRequest -> ShowS
$cshowsPrec :: Int -> IQRequest -> ShowS
Show, forall x. Rep IQRequest x -> IQRequest
forall x. IQRequest -> Rep IQRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IQRequest x -> IQRequest
$cfrom :: forall x. IQRequest -> Rep IQRequest x
Generic)
data IQRequestType = Get | Set deriving (IQRequestType -> IQRequestType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IQRequestType -> IQRequestType -> Bool
$c/= :: IQRequestType -> IQRequestType -> Bool
== :: IQRequestType -> IQRequestType -> Bool
$c== :: IQRequestType -> IQRequestType -> Bool
Eq, Eq IQRequestType
IQRequestType -> IQRequestType -> Bool
IQRequestType -> IQRequestType -> Ordering
IQRequestType -> IQRequestType -> IQRequestType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IQRequestType -> IQRequestType -> IQRequestType
$cmin :: IQRequestType -> IQRequestType -> IQRequestType
max :: IQRequestType -> IQRequestType -> IQRequestType
$cmax :: IQRequestType -> IQRequestType -> IQRequestType
>= :: IQRequestType -> IQRequestType -> Bool
$c>= :: IQRequestType -> IQRequestType -> Bool
> :: IQRequestType -> IQRequestType -> Bool
$c> :: IQRequestType -> IQRequestType -> Bool
<= :: IQRequestType -> IQRequestType -> Bool
$c<= :: IQRequestType -> IQRequestType -> Bool
< :: IQRequestType -> IQRequestType -> Bool
$c< :: IQRequestType -> IQRequestType -> Bool
compare :: IQRequestType -> IQRequestType -> Ordering
$ccompare :: IQRequestType -> IQRequestType -> Ordering
Ord, ReadPrec [IQRequestType]
ReadPrec IQRequestType
Int -> ReadS IQRequestType
ReadS [IQRequestType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IQRequestType]
$creadListPrec :: ReadPrec [IQRequestType]
readPrec :: ReadPrec IQRequestType
$creadPrec :: ReadPrec IQRequestType
readList :: ReadS [IQRequestType]
$creadList :: ReadS [IQRequestType]
readsPrec :: Int -> ReadS IQRequestType
$creadsPrec :: Int -> ReadS IQRequestType
Read, Int -> IQRequestType -> ShowS
[IQRequestType] -> ShowS
IQRequestType -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IQRequestType] -> ShowS
$cshowList :: [IQRequestType] -> ShowS
show :: IQRequestType -> [Char]
$cshow :: IQRequestType -> [Char]
showsPrec :: Int -> IQRequestType -> ShowS
$cshowsPrec :: Int -> IQRequestType -> ShowS
Show, forall x. Rep IQRequestType x -> IQRequestType
forall x. IQRequestType -> Rep IQRequestType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IQRequestType x -> IQRequestType
$cfrom :: forall x. IQRequestType -> Rep IQRequestType x
Generic)
data IQResponse = IQResponseError IQError
| IQResponseResult IQResult
deriving (IQResponse -> IQResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IQResponse -> IQResponse -> Bool
$c/= :: IQResponse -> IQResponse -> Bool
== :: IQResponse -> IQResponse -> Bool
$c== :: IQResponse -> IQResponse -> Bool
Eq, Int -> IQResponse -> ShowS
[IQResponse] -> ShowS
IQResponse -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IQResponse] -> ShowS
$cshowList :: [IQResponse] -> ShowS
show :: IQResponse -> [Char]
$cshow :: IQResponse -> [Char]
showsPrec :: Int -> IQResponse -> ShowS
$cshowsPrec :: Int -> IQResponse -> ShowS
Show)
data IQResult = IQResult { IQResult -> Text
iqResultID :: !Text
, IQResult -> Maybe Jid
iqResultFrom :: !(Maybe Jid)
, IQResult -> Maybe Jid
iqResultTo :: !(Maybe Jid)
, IQResult -> Maybe LangTag
iqResultLangTag :: !(Maybe LangTag)
, IQResult -> Maybe Element
iqResultPayload :: !(Maybe Element)
, IQResult -> [ExtendedAttribute]
iqResultAttributes :: ![ExtendedAttribute]
} deriving (IQResult -> IQResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IQResult -> IQResult -> Bool
$c/= :: IQResult -> IQResult -> Bool
== :: IQResult -> IQResult -> Bool
$c== :: IQResult -> IQResult -> Bool
Eq, Int -> IQResult -> ShowS
[IQResult] -> ShowS
IQResult -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IQResult] -> ShowS
$cshowList :: [IQResult] -> ShowS
show :: IQResult -> [Char]
$cshow :: IQResult -> [Char]
showsPrec :: Int -> IQResult -> ShowS
$cshowsPrec :: Int -> IQResult -> ShowS
Show, forall x. Rep IQResult x -> IQResult
forall x. IQResult -> Rep IQResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IQResult x -> IQResult
$cfrom :: forall x. IQResult -> Rep IQResult x
Generic)
data IQError = IQError { IQError -> Text
iqErrorID :: !Text
, IQError -> Maybe Jid
iqErrorFrom :: !(Maybe Jid)
, IQError -> Maybe Jid
iqErrorTo :: !(Maybe Jid)
, IQError -> Maybe LangTag
iqErrorLangTag :: !(Maybe LangTag)
, IQError -> StanzaError
iqErrorStanzaError :: !StanzaError
, IQError -> Maybe Element
iqErrorPayload :: !(Maybe Element)
, IQError -> [ExtendedAttribute]
iqErrorAttributes :: ![ExtendedAttribute]
} deriving (IQError -> IQError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IQError -> IQError -> Bool
$c/= :: IQError -> IQError -> Bool
== :: IQError -> IQError -> Bool
$c== :: IQError -> IQError -> Bool
Eq, Int -> IQError -> ShowS
[IQError] -> ShowS
IQError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [IQError] -> ShowS
$cshowList :: [IQError] -> ShowS
show :: IQError -> [Char]
$cshow :: IQError -> [Char]
showsPrec :: Int -> IQError -> ShowS
$cshowsPrec :: Int -> IQError -> ShowS
Show, forall x. Rep IQError x -> IQError
forall x. IQError -> Rep IQError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IQError x -> IQError
$cfrom :: forall x. IQError -> Rep IQError x
Generic)
data Message = Message { Message -> Maybe Text
messageID :: !(Maybe Text)
, Message -> Maybe Jid
messageFrom :: !(Maybe Jid)
, Message -> Maybe Jid
messageTo :: !(Maybe Jid)
, Message -> Maybe LangTag
messageLangTag :: !(Maybe LangTag)
, Message -> MessageType
messageType :: !MessageType
, Message -> [Element]
messagePayload :: ![Element]
, Message -> [ExtendedAttribute]
messageAttributes :: ![ExtendedAttribute]
} deriving (Message -> Message -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Eq, Int -> Message -> ShowS
[Message] -> ShowS
Message -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> [Char]
$cshow :: Message -> [Char]
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Show, forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Generic)
message :: Message
message :: Message
message = Message { messageID :: Maybe Text
messageID = forall a. Maybe a
Nothing
, messageFrom :: Maybe Jid
messageFrom = forall a. Maybe a
Nothing
, messageTo :: Maybe Jid
messageTo = forall a. Maybe a
Nothing
, messageLangTag :: Maybe LangTag
messageLangTag = forall a. Maybe a
Nothing
, messageType :: MessageType
messageType = MessageType
Normal
, messagePayload :: [Element]
messagePayload = []
, messageAttributes :: [ExtendedAttribute]
messageAttributes = []
}
messageS :: Stanza
messageS :: Stanza
messageS = Message -> Stanza
MessageS Message
message
instance Default Message where
def :: Message
def = Message
message
data MessageError = MessageError { MessageError -> Maybe Text
messageErrorID :: !(Maybe Text)
, MessageError -> Maybe Jid
messageErrorFrom :: !(Maybe Jid)
, MessageError -> Maybe Jid
messageErrorTo :: !(Maybe Jid)
, MessageError -> Maybe LangTag
messageErrorLangTag :: !(Maybe LangTag)
, MessageError -> StanzaError
messageErrorStanzaError :: !StanzaError
, MessageError -> [Element]
messageErrorPayload :: ![Element]
, MessageError -> [ExtendedAttribute]
messageErrorAttributes :: ![ExtendedAttribute]
} deriving (MessageError -> MessageError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageError -> MessageError -> Bool
$c/= :: MessageError -> MessageError -> Bool
== :: MessageError -> MessageError -> Bool
$c== :: MessageError -> MessageError -> Bool
Eq, Int -> MessageError -> ShowS
[MessageError] -> ShowS
MessageError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [MessageError] -> ShowS
$cshowList :: [MessageError] -> ShowS
show :: MessageError -> [Char]
$cshow :: MessageError -> [Char]
showsPrec :: Int -> MessageError -> ShowS
$cshowsPrec :: Int -> MessageError -> ShowS
Show, forall x. Rep MessageError x -> MessageError
forall x. MessageError -> Rep MessageError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageError x -> MessageError
$cfrom :: forall x. MessageError -> Rep MessageError x
Generic)
messageError :: MessageError
messageError :: MessageError
messageError = MessageError { messageErrorID :: Maybe Text
messageErrorID = forall a. Maybe a
Nothing
, messageErrorFrom :: Maybe Jid
messageErrorFrom = forall a. Maybe a
Nothing
, messageErrorTo :: Maybe Jid
messageErrorTo = forall a. Maybe a
Nothing
, messageErrorLangTag :: Maybe LangTag
messageErrorLangTag = forall a. Maybe a
Nothing
, messageErrorStanzaError :: StanzaError
messageErrorStanzaError =
StanzaError { stanzaErrorType :: StanzaErrorType
stanzaErrorType = StanzaErrorType
Cancel
, stanzaErrorCondition :: StanzaErrorCondition
stanzaErrorCondition =
StanzaErrorCondition
ServiceUnavailable
, stanzaErrorText :: Maybe (Maybe LangTag, NonemptyText)
stanzaErrorText = forall a. Maybe a
Nothing
, stanzaErrorApplicationSpecificCondition :: Maybe Element
stanzaErrorApplicationSpecificCondition = forall a. Maybe a
Nothing
}
, messageErrorPayload :: [Element]
messageErrorPayload = []
, messageErrorAttributes :: [ExtendedAttribute]
messageErrorAttributes = []
}
instance Default MessageError where
def :: MessageError
def = MessageError
messageError
messageErrorS :: Stanza
messageErrorS :: Stanza
messageErrorS = MessageError -> Stanza
MessageErrorS forall a. Default a => a
def
data MessageType =
Chat
| GroupChat
| Headline
| Normal
deriving (MessageType -> MessageType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageType -> MessageType -> Bool
$c/= :: MessageType -> MessageType -> Bool
== :: MessageType -> MessageType -> Bool
$c== :: MessageType -> MessageType -> Bool
Eq, ReadPrec [MessageType]
ReadPrec MessageType
Int -> ReadS MessageType
ReadS [MessageType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageType]
$creadListPrec :: ReadPrec [MessageType]
readPrec :: ReadPrec MessageType
$creadPrec :: ReadPrec MessageType
readList :: ReadS [MessageType]
$creadList :: ReadS [MessageType]
readsPrec :: Int -> ReadS MessageType
$creadsPrec :: Int -> ReadS MessageType
Read, Int -> MessageType -> ShowS
[MessageType] -> ShowS
MessageType -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [MessageType] -> ShowS
$cshowList :: [MessageType] -> ShowS
show :: MessageType -> [Char]
$cshow :: MessageType -> [Char]
showsPrec :: Int -> MessageType -> ShowS
$cshowsPrec :: Int -> MessageType -> ShowS
Show, forall x. Rep MessageType x -> MessageType
forall x. MessageType -> Rep MessageType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageType x -> MessageType
$cfrom :: forall x. MessageType -> Rep MessageType x
Generic)
data Presence = Presence { Presence -> Maybe Text
presenceID :: !(Maybe Text)
, Presence -> Maybe Jid
presenceFrom :: !(Maybe Jid)
, Presence -> Maybe Jid
presenceTo :: !(Maybe Jid)
, Presence -> Maybe LangTag
presenceLangTag :: !(Maybe LangTag)
, Presence -> PresenceType
presenceType :: !PresenceType
, Presence -> [Element]
presencePayload :: ![Element]
, Presence -> [ExtendedAttribute]
presenceAttributes :: ![ExtendedAttribute]
} deriving (Presence -> Presence -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Presence -> Presence -> Bool
$c/= :: Presence -> Presence -> Bool
== :: Presence -> Presence -> Bool
$c== :: Presence -> Presence -> Bool
Eq, Int -> Presence -> ShowS
[Presence] -> ShowS
Presence -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Presence] -> ShowS
$cshowList :: [Presence] -> ShowS
show :: Presence -> [Char]
$cshow :: Presence -> [Char]
showsPrec :: Int -> Presence -> ShowS
$cshowsPrec :: Int -> Presence -> ShowS
Show, forall x. Rep Presence x -> Presence
forall x. Presence -> Rep Presence x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Presence x -> Presence
$cfrom :: forall x. Presence -> Rep Presence x
Generic)
presence :: Presence
presence :: Presence
presence = Presence { presenceID :: Maybe Text
presenceID = forall a. Maybe a
Nothing
, presenceFrom :: Maybe Jid
presenceFrom = forall a. Maybe a
Nothing
, presenceTo :: Maybe Jid
presenceTo = forall a. Maybe a
Nothing
, presenceLangTag :: Maybe LangTag
presenceLangTag = forall a. Maybe a
Nothing
, presenceType :: PresenceType
presenceType = PresenceType
Available
, presencePayload :: [Element]
presencePayload = []
, presenceAttributes :: [ExtendedAttribute]
presenceAttributes = []
}
presenceS :: Stanza
presenceS :: Stanza
presenceS = Presence -> Stanza
PresenceS Presence
presence
instance Default Presence where
def :: Presence
def = Presence
presence
data PresenceError = PresenceError { PresenceError -> Maybe Text
presenceErrorID :: !(Maybe Text)
, PresenceError -> Maybe Jid
presenceErrorFrom :: !(Maybe Jid)
, PresenceError -> Maybe Jid
presenceErrorTo :: !(Maybe Jid)
, PresenceError -> Maybe LangTag
presenceErrorLangTag :: !(Maybe LangTag)
, PresenceError -> StanzaError
presenceErrorStanzaError :: !StanzaError
, PresenceError -> [Element]
presenceErrorPayload :: ![Element]
, PresenceError -> [ExtendedAttribute]
presenceErrorAttributes :: ![ExtendedAttribute]
} deriving (PresenceError -> PresenceError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PresenceError -> PresenceError -> Bool
$c/= :: PresenceError -> PresenceError -> Bool
== :: PresenceError -> PresenceError -> Bool
$c== :: PresenceError -> PresenceError -> Bool
Eq, Int -> PresenceError -> ShowS
[PresenceError] -> ShowS
PresenceError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [PresenceError] -> ShowS
$cshowList :: [PresenceError] -> ShowS
show :: PresenceError -> [Char]
$cshow :: PresenceError -> [Char]
showsPrec :: Int -> PresenceError -> ShowS
$cshowsPrec :: Int -> PresenceError -> ShowS
Show, forall x. Rep PresenceError x -> PresenceError
forall x. PresenceError -> Rep PresenceError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PresenceError x -> PresenceError
$cfrom :: forall x. PresenceError -> Rep PresenceError x
Generic)
data PresenceType = Subscribe |
Subscribed |
Unsubscribe |
Unsubscribed |
Probe |
Available |
Unavailable deriving (PresenceType -> PresenceType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PresenceType -> PresenceType -> Bool
$c/= :: PresenceType -> PresenceType -> Bool
== :: PresenceType -> PresenceType -> Bool
$c== :: PresenceType -> PresenceType -> Bool
Eq, ReadPrec [PresenceType]
ReadPrec PresenceType
Int -> ReadS PresenceType
ReadS [PresenceType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PresenceType]
$creadListPrec :: ReadPrec [PresenceType]
readPrec :: ReadPrec PresenceType
$creadPrec :: ReadPrec PresenceType
readList :: ReadS [PresenceType]
$creadList :: ReadS [PresenceType]
readsPrec :: Int -> ReadS PresenceType
$creadsPrec :: Int -> ReadS PresenceType
Read, Int -> PresenceType -> ShowS
[PresenceType] -> ShowS
PresenceType -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [PresenceType] -> ShowS
$cshowList :: [PresenceType] -> ShowS
show :: PresenceType -> [Char]
$cshow :: PresenceType -> [Char]
showsPrec :: Int -> PresenceType -> ShowS
$cshowsPrec :: Int -> PresenceType -> ShowS
Show, forall x. Rep PresenceType x -> PresenceType
forall x. PresenceType -> Rep PresenceType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PresenceType x -> PresenceType
$cfrom :: forall x. PresenceType -> Rep PresenceType x
Generic)
data StanzaError = StanzaError
{ StanzaError -> StanzaErrorType
stanzaErrorType :: StanzaErrorType
, StanzaError -> StanzaErrorCondition
stanzaErrorCondition :: StanzaErrorCondition
, StanzaError -> Maybe (Maybe LangTag, NonemptyText)
stanzaErrorText :: Maybe (Maybe LangTag, NonemptyText)
, StanzaError -> Maybe Element
stanzaErrorApplicationSpecificCondition :: Maybe Element
} deriving (StanzaError -> StanzaError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StanzaError -> StanzaError -> Bool
$c/= :: StanzaError -> StanzaError -> Bool
== :: StanzaError -> StanzaError -> Bool
$c== :: StanzaError -> StanzaError -> Bool
Eq, Int -> StanzaError -> ShowS
[StanzaError] -> ShowS
StanzaError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StanzaError] -> ShowS
$cshowList :: [StanzaError] -> ShowS
show :: StanzaError -> [Char]
$cshow :: StanzaError -> [Char]
showsPrec :: Int -> StanzaError -> ShowS
$cshowsPrec :: Int -> StanzaError -> ShowS
Show, forall x. Rep StanzaError x -> StanzaError
forall x. StanzaError -> Rep StanzaError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StanzaError x -> StanzaError
$cfrom :: forall x. StanzaError -> Rep StanzaError x
Generic)
data StanzaErrorType = Cancel |
Continue |
Modify |
Auth |
Wait
deriving (StanzaErrorType -> StanzaErrorType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StanzaErrorType -> StanzaErrorType -> Bool
$c/= :: StanzaErrorType -> StanzaErrorType -> Bool
== :: StanzaErrorType -> StanzaErrorType -> Bool
$c== :: StanzaErrorType -> StanzaErrorType -> Bool
Eq, ReadPrec [StanzaErrorType]
ReadPrec StanzaErrorType
Int -> ReadS StanzaErrorType
ReadS [StanzaErrorType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StanzaErrorType]
$creadListPrec :: ReadPrec [StanzaErrorType]
readPrec :: ReadPrec StanzaErrorType
$creadPrec :: ReadPrec StanzaErrorType
readList :: ReadS [StanzaErrorType]
$creadList :: ReadS [StanzaErrorType]
readsPrec :: Int -> ReadS StanzaErrorType
$creadsPrec :: Int -> ReadS StanzaErrorType
Read, Int -> StanzaErrorType -> ShowS
[StanzaErrorType] -> ShowS
StanzaErrorType -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StanzaErrorType] -> ShowS
$cshowList :: [StanzaErrorType] -> ShowS
show :: StanzaErrorType -> [Char]
$cshow :: StanzaErrorType -> [Char]
showsPrec :: Int -> StanzaErrorType -> ShowS
$cshowsPrec :: Int -> StanzaErrorType -> ShowS
Show, forall x. Rep StanzaErrorType x -> StanzaErrorType
forall x. StanzaErrorType -> Rep StanzaErrorType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StanzaErrorType x -> StanzaErrorType
$cfrom :: forall x. StanzaErrorType -> Rep StanzaErrorType x
Generic)
data StanzaErrorCondition = BadRequest
| Conflict
| FeatureNotImplemented
| Forbidden
| Gone (Maybe NonemptyText)
| InternalServerError
| ItemNotFound
| JidMalformed
| NotAcceptable
| NotAllowed
| NotAuthorized
| PolicyViolation
| RecipientUnavailable
| Redirect (Maybe NonemptyText)
| RegistrationRequired
| RemoteServerNotFound
| RemoteServerTimeout
| ResourceConstraint
| ServiceUnavailable
| SubscriptionRequired
| UndefinedCondition
| UnexpectedRequest
deriving (StanzaErrorCondition -> StanzaErrorCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StanzaErrorCondition -> StanzaErrorCondition -> Bool
$c/= :: StanzaErrorCondition -> StanzaErrorCondition -> Bool
== :: StanzaErrorCondition -> StanzaErrorCondition -> Bool
$c== :: StanzaErrorCondition -> StanzaErrorCondition -> Bool
Eq, ReadPrec [StanzaErrorCondition]
ReadPrec StanzaErrorCondition
Int -> ReadS StanzaErrorCondition
ReadS [StanzaErrorCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StanzaErrorCondition]
$creadListPrec :: ReadPrec [StanzaErrorCondition]
readPrec :: ReadPrec StanzaErrorCondition
$creadPrec :: ReadPrec StanzaErrorCondition
readList :: ReadS [StanzaErrorCondition]
$creadList :: ReadS [StanzaErrorCondition]
readsPrec :: Int -> ReadS StanzaErrorCondition
$creadsPrec :: Int -> ReadS StanzaErrorCondition
Read, Int -> StanzaErrorCondition -> ShowS
[StanzaErrorCondition] -> ShowS
StanzaErrorCondition -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StanzaErrorCondition] -> ShowS
$cshowList :: [StanzaErrorCondition] -> ShowS
show :: StanzaErrorCondition -> [Char]
$cshow :: StanzaErrorCondition -> [Char]
showsPrec :: Int -> StanzaErrorCondition -> ShowS
$cshowsPrec :: Int -> StanzaErrorCondition -> ShowS
Show, forall x. Rep StanzaErrorCondition x -> StanzaErrorCondition
forall x. StanzaErrorCondition -> Rep StanzaErrorCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StanzaErrorCondition x -> StanzaErrorCondition
$cfrom :: forall x. StanzaErrorCondition -> Rep StanzaErrorCondition x
Generic)
data SaslFailure = SaslFailure { SaslFailure -> SaslError
saslFailureCondition :: SaslError
, SaslFailure -> Maybe (Maybe LangTag, Text)
saslFailureText :: Maybe ( Maybe LangTag
, Text
)
} deriving (SaslFailure -> SaslFailure -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SaslFailure -> SaslFailure -> Bool
$c/= :: SaslFailure -> SaslFailure -> Bool
== :: SaslFailure -> SaslFailure -> Bool
$c== :: SaslFailure -> SaslFailure -> Bool
Eq, Int -> SaslFailure -> ShowS
[SaslFailure] -> ShowS
SaslFailure -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [SaslFailure] -> ShowS
$cshowList :: [SaslFailure] -> ShowS
show :: SaslFailure -> [Char]
$cshow :: SaslFailure -> [Char]
showsPrec :: Int -> SaslFailure -> ShowS
$cshowsPrec :: Int -> SaslFailure -> ShowS
Show, forall x. Rep SaslFailure x -> SaslFailure
forall x. SaslFailure -> Rep SaslFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SaslFailure x -> SaslFailure
$cfrom :: forall x. SaslFailure -> Rep SaslFailure x
Generic)
data SaslError = SaslAborted
| SaslAccountDisabled
| SaslCredentialsExpired
| SaslEncryptionRequired
| SaslIncorrectEncoding
| SaslInvalidAuthzid
| SaslInvalidMechanism
| SaslMalformedRequest
| SaslMechanismTooWeak
| SaslNotAuthorized
| SaslTemporaryAuthFailure
deriving (SaslError -> SaslError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SaslError -> SaslError -> Bool
$c/= :: SaslError -> SaslError -> Bool
== :: SaslError -> SaslError -> Bool
$c== :: SaslError -> SaslError -> Bool
Eq, ReadPrec [SaslError]
ReadPrec SaslError
Int -> ReadS SaslError
ReadS [SaslError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SaslError]
$creadListPrec :: ReadPrec [SaslError]
readPrec :: ReadPrec SaslError
$creadPrec :: ReadPrec SaslError
readList :: ReadS [SaslError]
$creadList :: ReadS [SaslError]
readsPrec :: Int -> ReadS SaslError
$creadsPrec :: Int -> ReadS SaslError
Read, Int -> SaslError -> ShowS
[SaslError] -> ShowS
SaslError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [SaslError] -> ShowS
$cshowList :: [SaslError] -> ShowS
show :: SaslError -> [Char]
$cshow :: SaslError -> [Char]
showsPrec :: Int -> SaslError -> ShowS
$cshowsPrec :: Int -> SaslError -> ShowS
Show, forall x. Rep SaslError x -> SaslError
forall x. SaslError -> Rep SaslError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SaslError x -> SaslError
$cfrom :: forall x. SaslError -> Rep SaslError x
Generic)
data StreamErrorCondition
= StreamBadFormat
| StreamBadNamespacePrefix
| StreamConflict
| StreamConnectionTimeout
| StreamHostGone
| StreamHostUnknown
| StreamImproperAddressing
| StreamInternalServerError
| StreamInvalidFrom
| StreamInvalidNamespace
| StreamInvalidXml
| StreamNotAuthorized
| StreamNotWellFormed
| StreamPolicyViolation
| StreamRemoteConnectionFailed
| StreamReset
| StreamResourceConstraint
| StreamRestrictedXml
| StreamSeeOtherHost
| StreamSystemShutdown
| StreamUndefinedCondition
| StreamUnsupportedEncoding
| StreamUnsupportedFeature
| StreamUnsupportedStanzaType
| StreamUnsupportedVersion
deriving (StreamErrorCondition -> StreamErrorCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamErrorCondition -> StreamErrorCondition -> Bool
$c/= :: StreamErrorCondition -> StreamErrorCondition -> Bool
== :: StreamErrorCondition -> StreamErrorCondition -> Bool
$c== :: StreamErrorCondition -> StreamErrorCondition -> Bool
Eq, ReadPrec [StreamErrorCondition]
ReadPrec StreamErrorCondition
Int -> ReadS StreamErrorCondition
ReadS [StreamErrorCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamErrorCondition]
$creadListPrec :: ReadPrec [StreamErrorCondition]
readPrec :: ReadPrec StreamErrorCondition
$creadPrec :: ReadPrec StreamErrorCondition
readList :: ReadS [StreamErrorCondition]
$creadList :: ReadS [StreamErrorCondition]
readsPrec :: Int -> ReadS StreamErrorCondition
$creadsPrec :: Int -> ReadS StreamErrorCondition
Read, Int -> StreamErrorCondition -> ShowS
[StreamErrorCondition] -> ShowS
StreamErrorCondition -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StreamErrorCondition] -> ShowS
$cshowList :: [StreamErrorCondition] -> ShowS
show :: StreamErrorCondition -> [Char]
$cshow :: StreamErrorCondition -> [Char]
showsPrec :: Int -> StreamErrorCondition -> ShowS
$cshowsPrec :: Int -> StreamErrorCondition -> ShowS
Show, forall x. Rep StreamErrorCondition x -> StreamErrorCondition
forall x. StreamErrorCondition -> Rep StreamErrorCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamErrorCondition x -> StreamErrorCondition
$cfrom :: forall x. StreamErrorCondition -> Rep StreamErrorCondition x
Generic)
data StreamErrorInfo = StreamErrorInfo
{ StreamErrorInfo -> StreamErrorCondition
errorCondition :: !StreamErrorCondition
, StreamErrorInfo -> Maybe (Maybe LangTag, NonemptyText)
errorText :: !(Maybe (Maybe LangTag, NonemptyText))
, StreamErrorInfo -> Maybe Element
errorXml :: !(Maybe Element)
} deriving (Int -> StreamErrorInfo -> ShowS
[StreamErrorInfo] -> ShowS
StreamErrorInfo -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StreamErrorInfo] -> ShowS
$cshowList :: [StreamErrorInfo] -> ShowS
show :: StreamErrorInfo -> [Char]
$cshow :: StreamErrorInfo -> [Char]
showsPrec :: Int -> StreamErrorInfo -> ShowS
$cshowsPrec :: Int -> StreamErrorInfo -> ShowS
Show, StreamErrorInfo -> StreamErrorInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamErrorInfo -> StreamErrorInfo -> Bool
$c/= :: StreamErrorInfo -> StreamErrorInfo -> Bool
== :: StreamErrorInfo -> StreamErrorInfo -> Bool
$c== :: StreamErrorInfo -> StreamErrorInfo -> Bool
Eq, forall x. Rep StreamErrorInfo x -> StreamErrorInfo
forall x. StreamErrorInfo -> Rep StreamErrorInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamErrorInfo x -> StreamErrorInfo
$cfrom :: forall x. StreamErrorInfo -> Rep StreamErrorInfo x
Generic)
data XmppTlsError = XmppTlsError TLSError
| XmppTlsException TLSException
deriving (Int -> XmppTlsError -> ShowS
[XmppTlsError] -> ShowS
XmppTlsError -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [XmppTlsError] -> ShowS
$cshowList :: [XmppTlsError] -> ShowS
show :: XmppTlsError -> [Char]
$cshow :: XmppTlsError -> [Char]
showsPrec :: Int -> XmppTlsError -> ShowS
$cshowsPrec :: Int -> XmppTlsError -> ShowS
Show, XmppTlsError -> XmppTlsError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XmppTlsError -> XmppTlsError -> Bool
$c/= :: XmppTlsError -> XmppTlsError -> Bool
== :: XmppTlsError -> XmppTlsError -> Bool
$c== :: XmppTlsError -> XmppTlsError -> Bool
Eq, Typeable, forall x. Rep XmppTlsError x -> XmppTlsError
forall x. XmppTlsError -> Rep XmppTlsError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep XmppTlsError x -> XmppTlsError
$cfrom :: forall x. XmppTlsError -> Rep XmppTlsError x
Generic)
data XmppFailure = StreamErrorFailure StreamErrorInfo
| StreamEndFailure
| StreamCloseError ([Element], XmppFailure)
| TcpConnectionFailure
| XmppIllegalTcpDetails
| TlsError XmppTlsError
| TlsNoServerSupport
| XmppNoStream
| XmppAuthFailure AuthFailure
| TlsStreamSecured
| XmppOtherFailure
| XmppIOException IOException
| XmppInvalidXml String
deriving (Int -> XmppFailure -> ShowS
[XmppFailure] -> ShowS
XmppFailure -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [XmppFailure] -> ShowS
$cshowList :: [XmppFailure] -> ShowS
show :: XmppFailure -> [Char]
$cshow :: XmppFailure -> [Char]
showsPrec :: Int -> XmppFailure -> ShowS
$cshowsPrec :: Int -> XmppFailure -> ShowS
Show, XmppFailure -> XmppFailure -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XmppFailure -> XmppFailure -> Bool
$c/= :: XmppFailure -> XmppFailure -> Bool
== :: XmppFailure -> XmppFailure -> Bool
$c== :: XmppFailure -> XmppFailure -> Bool
Eq, Typeable, forall x. Rep XmppFailure x -> XmppFailure
forall x. XmppFailure -> Rep XmppFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep XmppFailure x -> XmppFailure
$cfrom :: forall x. XmppFailure -> Rep XmppFailure x
Generic)
instance Exception XmppFailure
data AuthFailure =
AuthNoAcceptableMechanism [Text.Text]
| AuthStreamFailure XmppFailure
| AuthSaslFailure SaslFailure
| AuthIllegalCredentials
| AuthOtherFailure
deriving (AuthFailure -> AuthFailure -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthFailure -> AuthFailure -> Bool
$c/= :: AuthFailure -> AuthFailure -> Bool
== :: AuthFailure -> AuthFailure -> Bool
$c== :: AuthFailure -> AuthFailure -> Bool
Eq, Int -> AuthFailure -> ShowS
[AuthFailure] -> ShowS
AuthFailure -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AuthFailure] -> ShowS
$cshowList :: [AuthFailure] -> ShowS
show :: AuthFailure -> [Char]
$cshow :: AuthFailure -> [Char]
showsPrec :: Int -> AuthFailure -> ShowS
$cshowsPrec :: Int -> AuthFailure -> ShowS
Show, forall x. Rep AuthFailure x -> AuthFailure
forall x. AuthFailure -> Rep AuthFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthFailure x -> AuthFailure
$cfrom :: forall x. AuthFailure -> Rep AuthFailure x
Generic)
data Version = Version { Version -> Integer
majorVersion :: !Integer
, Version -> Integer
minorVersion :: !Integer } deriving (Version -> Version -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Version -> Version -> Bool
$c/= :: Version -> Version -> Bool
== :: Version -> Version -> Bool
$c== :: Version -> Version -> Bool
Eq, ReadPrec [Version]
ReadPrec Version
Int -> ReadS Version
ReadS [Version]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Version]
$creadListPrec :: ReadPrec [Version]
readPrec :: ReadPrec Version
$creadPrec :: ReadPrec Version
readList :: ReadS [Version]
$creadList :: ReadS [Version]
readsPrec :: Int -> ReadS Version
$creadsPrec :: Int -> ReadS Version
Read, Int -> Version -> ShowS
[Version] -> ShowS
Version -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Version] -> ShowS
$cshowList :: [Version] -> ShowS
show :: Version -> [Char]
$cshow :: Version -> [Char]
showsPrec :: Int -> Version -> ShowS
$cshowsPrec :: Int -> Version -> ShowS
Show, forall x. Rep Version x -> Version
forall x. Version -> Rep Version x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Version x -> Version
$cfrom :: forall x. Version -> Rep Version x
Generic)
instance Ord Version where
compare :: Version -> Version -> Ordering
compare (Version Integer
amajor Integer
aminor) (Version Integer
bmajor Integer
bminor)
| Integer
amajor forall a. Eq a => a -> a -> Bool
/= Integer
bmajor = forall a. Ord a => a -> a -> Ordering
compare Integer
amajor Integer
bmajor
| Bool
otherwise = forall a. Ord a => a -> a -> Ordering
compare Integer
aminor Integer
bminor
versionFromText :: Text.Text -> Maybe Version
versionFromText :: Text -> Maybe Version
versionFromText Text
s = case forall a. Parser a -> Text -> Either [Char] a
AP.parseOnly Parser Version
versionParser Text
s of
Right Version
version -> forall a. a -> Maybe a
Just Version
version
Left [Char]
_ -> forall a. Maybe a
Nothing
versionParser :: AP.Parser Version
versionParser :: Parser Version
versionParser = do
[Char]
major <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
AP.many1 Parser Char
AP.digit
(Char -> Bool) -> Parser ()
AP.skip (forall a. Eq a => a -> a -> Bool
== Char
'.')
[Char]
minor <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
AP.many1 Parser Char
AP.digit
forall t. Chunk t => Parser t ()
AP.endOfInput
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> Version
Version (forall a. Read a => [Char] -> a
read [Char]
major) (forall a. Read a => [Char] -> a
read [Char]
minor)
data LangTag = LangTag { LangTag -> Text
primaryTag :: !Text
, LangTag -> [Text]
subtags :: ![Text] }
instance Eq LangTag where
LangTag Text
p [Text]
s == :: LangTag -> LangTag -> Bool
== LangTag Text
q [Text]
t = Text -> Text
Text.toLower Text
p forall a. Eq a => a -> a -> Bool
== Text -> Text
Text.toLower Text
q Bool -> Bool -> Bool
&&
forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
Text.toLower [Text]
s forall a. Eq a => a -> a -> Bool
== forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
Text.toLower [Text]
t
langTagFromText :: Text.Text -> Maybe LangTag
langTagFromText :: Text -> Maybe LangTag
langTagFromText Text
s = case forall a. Parser a -> Text -> Either [Char] a
AP.parseOnly Parser LangTag
langTagParser Text
s of
Right LangTag
tag -> forall a. a -> Maybe a
Just LangTag
tag
Left [Char]
_ -> forall a. Maybe a
Nothing
langTagToText :: LangTag -> Text.Text
langTagToText :: LangTag -> Text
langTagToText (LangTag Text
p []) = Text
p
langTagToText (LangTag Text
p [Text]
s) = [Text] -> Text
Text.concat forall a b. (a -> b) -> a -> b
$ [Text
p, Text
"-", Text -> [Text] -> Text
Text.intercalate Text
"-" [Text]
s]
langTagParser :: AP.Parser LangTag
langTagParser :: Parser LangTag
langTagParser = do
Text
primTag <- Parser Text
tag
[Text]
subTags <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser Text
subtag
forall t. Chunk t => Parser t ()
AP.endOfInput
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> [Text] -> LangTag
LangTag Text
primTag [Text]
subTags
where
tag :: AP.Parser Text.Text
tag :: Parser Text
tag = do
Text
t <- (Char -> Bool) -> Parser Text
AP.takeWhile1 forall a b. (a -> b) -> a -> b
$ [Char] -> Char -> Bool
AP.inClass [Char]
tagChars
forall (m :: * -> *) a. Monad m => a -> m a
return Text
t
subtag :: AP.Parser Text.Text
subtag :: Parser Text
subtag = do
(Char -> Bool) -> Parser ()
AP.skip (forall a. Eq a => a -> a -> Bool
== Char
'-')
Parser Text
tag
tagChars :: [Char]
tagChars :: [Char]
tagChars = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z']
data StreamFeatures = StreamFeatures
{ StreamFeatures -> Maybe Bool
streamFeaturesTls :: !(Maybe Bool)
, StreamFeatures -> [Text]
streamFeaturesMechanisms :: ![Text.Text]
, StreamFeatures -> Maybe Bool
streamFeaturesRosterVer :: !(Maybe Bool)
, StreamFeatures -> Bool
streamFeaturesPreApproval :: !Bool
, StreamFeatures -> Maybe Bool
streamFeaturesSession :: !(Maybe Bool)
, StreamFeatures -> [Element]
streamFeaturesOther :: ![Element]
} deriving (StreamFeatures -> StreamFeatures -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamFeatures -> StreamFeatures -> Bool
$c/= :: StreamFeatures -> StreamFeatures -> Bool
== :: StreamFeatures -> StreamFeatures -> Bool
$c== :: StreamFeatures -> StreamFeatures -> Bool
Eq, Int -> StreamFeatures -> ShowS
[StreamFeatures] -> ShowS
StreamFeatures -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [StreamFeatures] -> ShowS
$cshowList :: [StreamFeatures] -> ShowS
show :: StreamFeatures -> [Char]
$cshow :: StreamFeatures -> [Char]
showsPrec :: Int -> StreamFeatures -> ShowS
$cshowsPrec :: Int -> StreamFeatures -> ShowS
Show)
instance Sem.Semigroup StreamFeatures where
StreamFeatures
sf1 <> :: StreamFeatures -> StreamFeatures -> StreamFeatures
<> StreamFeatures
sf2 =
StreamFeatures
{ streamFeaturesTls :: Maybe Bool
streamFeaturesTls = forall {m :: * -> *} {a}.
MonadPlus m =>
(StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> Maybe Bool
streamFeaturesTls
, streamFeaturesMechanisms :: [Text]
streamFeaturesMechanisms = forall {m :: * -> *} {a}.
MonadPlus m =>
(StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> [Text]
streamFeaturesMechanisms
, streamFeaturesRosterVer :: Maybe Bool
streamFeaturesRosterVer = forall {m :: * -> *} {a}.
MonadPlus m =>
(StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> Maybe Bool
streamFeaturesRosterVer
, streamFeaturesPreApproval :: Bool
streamFeaturesPreApproval =
StreamFeatures -> Bool
streamFeaturesPreApproval StreamFeatures
sf1
Bool -> Bool -> Bool
|| StreamFeatures -> Bool
streamFeaturesPreApproval StreamFeatures
sf2
, streamFeaturesSession :: Maybe Bool
streamFeaturesSession = forall {m :: * -> *} {a}.
MonadPlus m =>
(StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> Maybe Bool
streamFeaturesSession
, streamFeaturesOther :: [Element]
streamFeaturesOther = forall {m :: * -> *} {a}.
MonadPlus m =>
(StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> [Element]
streamFeaturesOther
}
where
mplusOn :: (StreamFeatures -> m a) -> m a
mplusOn StreamFeatures -> m a
f = StreamFeatures -> m a
f StreamFeatures
sf1 forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` StreamFeatures -> m a
f StreamFeatures
sf2
instance Monoid StreamFeatures where
mempty :: StreamFeatures
mempty = StreamFeatures
{ streamFeaturesTls :: Maybe Bool
streamFeaturesTls = forall a. Maybe a
Nothing
, streamFeaturesMechanisms :: [Text]
streamFeaturesMechanisms = []
, streamFeaturesRosterVer :: Maybe Bool
streamFeaturesRosterVer = forall a. Maybe a
Nothing
, streamFeaturesPreApproval :: Bool
streamFeaturesPreApproval = Bool
False
, streamFeaturesSession :: Maybe Bool
streamFeaturesSession = forall a. Maybe a
Nothing
, streamFeaturesOther :: [Element]
streamFeaturesOther = []
}
mappend :: StreamFeatures -> StreamFeatures -> StreamFeatures
mappend = forall a. Semigroup a => a -> a -> a
(<>)
data ConnectionState
= Closed
| Plain
| Secured
| Finished
deriving (Int -> ConnectionState -> ShowS
[ConnectionState] -> ShowS
ConnectionState -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionState] -> ShowS
$cshowList :: [ConnectionState] -> ShowS
show :: ConnectionState -> [Char]
$cshow :: ConnectionState -> [Char]
showsPrec :: Int -> ConnectionState -> ShowS
$cshowsPrec :: Int -> ConnectionState -> ShowS
Show, ConnectionState -> ConnectionState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionState -> ConnectionState -> Bool
$c/= :: ConnectionState -> ConnectionState -> Bool
== :: ConnectionState -> ConnectionState -> Bool
$c== :: ConnectionState -> ConnectionState -> Bool
Eq, Typeable, forall x. Rep ConnectionState x -> ConnectionState
forall x. ConnectionState -> Rep ConnectionState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionState x -> ConnectionState
$cfrom :: forall x. ConnectionState -> Rep ConnectionState x
Generic)
data StreamHandle =
StreamHandle { StreamHandle -> ByteString -> IO (Either XmppFailure ())
streamSend :: BS.ByteString
-> IO (Either XmppFailure ())
, StreamHandle -> Int -> IO (Either XmppFailure ByteString)
streamReceive :: Int -> IO (Either XmppFailure BS.ByteString)
, StreamHandle -> IO ()
streamFlush :: IO ()
, StreamHandle -> IO ()
streamClose :: IO ()
}
data StreamState = StreamState
{
StreamState -> ConnectionState
streamConnectionState :: !ConnectionState
, StreamState -> StreamHandle
streamHandle :: StreamHandle
, StreamState -> ConduitT () Event (ExceptT XmppFailure IO) ()
streamEventSource :: ConduitT () Event (ExceptT XmppFailure IO) ()
, StreamState -> StreamFeatures
streamFeatures :: !StreamFeatures
, StreamState -> Maybe Text
streamAddress :: !(Maybe Text)
, StreamState -> Maybe Jid
streamFrom :: !(Maybe Jid)
, StreamState -> Maybe Text
streamId :: !(Maybe Text)
, StreamState -> Maybe LangTag
streamLang :: !(Maybe LangTag)
, StreamState -> Maybe Jid
streamJid :: !(Maybe Jid)
, StreamState -> StreamConfiguration
streamConfiguration :: StreamConfiguration
}
newtype Stream = Stream { Stream -> TMVar StreamState
unStream :: TMVar StreamState }
data Jid = Jid { Jid -> Maybe NonemptyText
localpart_ :: !(Maybe NonemptyText)
, Jid -> NonemptyText
domainpart_ :: !NonemptyText
, Jid -> Maybe NonemptyText
resourcepart_ :: !(Maybe NonemptyText)
} deriving (Jid -> Jid -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Jid -> Jid -> Bool
$c/= :: Jid -> Jid -> Bool
== :: Jid -> Jid -> Bool
$c== :: Jid -> Jid -> Bool
Eq, Eq Jid
Jid -> Jid -> Bool
Jid -> Jid -> Ordering
Jid -> Jid -> Jid
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Jid -> Jid -> Jid
$cmin :: Jid -> Jid -> Jid
max :: Jid -> Jid -> Jid
$cmax :: Jid -> Jid -> Jid
>= :: Jid -> Jid -> Bool
$c>= :: Jid -> Jid -> Bool
> :: Jid -> Jid -> Bool
$c> :: Jid -> Jid -> Bool
<= :: Jid -> Jid -> Bool
$c<= :: Jid -> Jid -> Bool
< :: Jid -> Jid -> Bool
$c< :: Jid -> Jid -> Bool
compare :: Jid -> Jid -> Ordering
$ccompare :: Jid -> Jid -> Ordering
Ord)
jidToText :: Jid -> Text
jidToText :: Jid -> Text
jidToText (Jid Maybe NonemptyText
nd NonemptyText
dmn Maybe NonemptyText
res) = [Text] -> Text
Text.concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$
[ forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (forall a. a -> [a] -> [a]
:[Text
"@"]) (NonemptyText -> Text
text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe NonemptyText
nd)
, [NonemptyText -> Text
text NonemptyText
dmn]
, forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Text
r -> [Text
"/",Text
r]) (NonemptyText -> Text
text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe NonemptyText
res)
]
jidToTexts :: Jid -> (Maybe Text, Text, Maybe Text)
jidToTexts :: Jid -> (Maybe Text, Text, Maybe Text)
jidToTexts (Jid Maybe NonemptyText
nd NonemptyText
dmn Maybe NonemptyText
res) = (NonemptyText -> Text
text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe NonemptyText
nd, NonemptyText -> Text
text NonemptyText
dmn, NonemptyText -> Text
text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe NonemptyText
res)
instance Show Jid where
show :: Jid -> [Char]
show Jid
j = [Char]
"parseJid " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show (Jid -> Text
jidToText Jid
j)
instance Read Jid where
readsPrec :: Int -> ReadS Jid
readsPrec Int
_ [Char]
s = do
case ReadS [Char]
lex [Char]
s of
[([Char]
"parseJid", [Char]
r')] ->
case ReadS [Char]
lex [Char]
r' of
[([Char]
s', [Char]
r'')] ->
case (forall a. Read a => ReadS a
reads [Char]
s') of
(([Char]
jidTxt,[Char]
_):[([Char], [Char])]
_) ->
case Text -> Maybe Jid
jidFromText ([Char] -> Text
Text.pack [Char]
jidTxt) of
Maybe Jid
Nothing -> []
Just Jid
jid' -> [(Jid
jid', [Char]
r'')]
[([Char], [Char])]
_ -> []
[([Char], [Char])]
_ -> []
[([Char], [Char])]
_ -> []
#if WITH_TEMPLATE_HASKELL
instance TH.Lift Jid where
lift :: forall (m :: * -> *). Quote m => Jid -> m Exp
lift (Jid Maybe NonemptyText
lp NonemptyText
dp Maybe NonemptyText
rp) = [| Jid $(mbTextE $ text <$> lp)
$(textE $ text dp)
$(mbTextE $ text <$> rp)
|]
where
textE :: Text -> m Exp
textE Text
t = [| Nonempty $ Text.pack $(stringE $ Text.unpack t) |]
mbTextE :: Maybe Text -> m Exp
mbTextE Maybe Text
Nothing = [| Nothing |]
mbTextE (Just Text
s) = [| Just $(textE s) |]
jid :: QuasiQuoter
jid :: QuasiQuoter
jid = QuasiQuoter { quoteExp :: [Char] -> Q Exp
quoteExp = \[Char]
s -> do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. [a] -> a
head [Char]
s forall a. Eq a => a -> a -> Bool
== Char
' ') forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail forall a b. (a -> b) -> a -> b
$ [Char]
"Leading whitespaces in JID" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show [Char]
s
let t :: Text
t = [Char] -> Text
Text.pack [Char]
s
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Text -> Char
Text.last Text
t forall a. Eq a => a -> a -> Bool
== Char
' ') forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Q ()
reportWarning forall a b. (a -> b) -> a -> b
$ [Char]
"Trailing whitespace in JID " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show [Char]
s
case Text -> Maybe Jid
jidFromText Text
t of
Maybe Jid
Nothing -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail forall a b. (a -> b) -> a -> b
$ [Char]
"Could not parse JID " forall a. [a] -> [a] -> [a]
++ [Char]
s
Just Jid
j -> forall t (m :: * -> *). (Lift t, Quote m) => t -> m Exp
TH.lift Jid
j
, quotePat :: [Char] -> Q Pat
quotePat = forall a. HasCallStack => [Char] -> a
error [Char]
"Jid patterns aren't implemented"
, quoteType :: [Char] -> Q Type
quoteType = forall a. HasCallStack => [Char] -> a
error [Char]
"jid QQ can't be used in type context"
, quoteDec :: [Char] -> Q [Dec]
quoteDec = forall a. HasCallStack => [Char] -> a
error [Char]
"jid QQ can't be used in declaration context"
}
jidQ :: QuasiQuoter
jidQ :: QuasiQuoter
jidQ = QuasiQuoter
jidQ
#endif
(<~) :: Jid -> Jid -> Bool
(Jid Maybe NonemptyText
lp1 NonemptyText
dp1 Maybe NonemptyText
rp1) <~ :: Jid -> Jid -> Bool
<~ (Jid Maybe NonemptyText
lp2 NonemptyText
dp2 Maybe NonemptyText
rp2) =
NonemptyText
dp1 forall a. Eq a => a -> a -> Bool
== NonemptyText
dp2 Bool -> Bool -> Bool
&&
Maybe NonemptyText
lp1 forall {a}. Eq a => Maybe a -> Maybe a -> Bool
~<~ Maybe NonemptyText
lp2 Bool -> Bool -> Bool
&&
Maybe NonemptyText
rp1 forall {a}. Eq a => Maybe a -> Maybe a -> Bool
~<~ Maybe NonemptyText
rp2
where
Maybe a
Nothing ~<~ :: Maybe a -> Maybe a -> Bool
~<~ Maybe a
_ = Bool
True
Just a
x ~<~ Just a
y = a
x forall a. Eq a => a -> a -> Bool
== a
y
Maybe a
_ ~<~ Maybe a
_ = Bool
False
instance Show LangTag where
show :: LangTag -> [Char]
show LangTag
l = [Char]
"parseLangTag " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show (LangTag -> Text
langTagToText LangTag
l)
instance Read LangTag where
readsPrec :: Int -> ReadS LangTag
readsPrec Int
_ [Char]
s = do
let ([Char]
s', [Char]
r) = case ReadS [Char]
lex [Char]
s of
[] -> forall a. HasCallStack => [Char] -> a
error [Char]
"Expected `parseLangTag \"<LangTag>\"'"
[([Char]
"parseLangTag", [Char]
r')] -> case ReadS [Char]
lex [Char]
r' of
[] -> forall a. HasCallStack => [Char] -> a
error [Char]
"Expected `parseLangTag \"<LangTag>\"'"
[([Char]
s'', [Char]
r'')] -> ([Char]
s'', [Char]
r'')
[([Char], [Char])]
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"Expected `parseLangTag \"<LangTag>\"'"
[([Char], [Char])]
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"Expected `parseLangTag \"<LangTag>\"'"
[([Char] -> LangTag
parseLangTag (forall a. Read a => [Char] -> a
read [Char]
s' :: String), [Char]
r)]
parseLangTag :: String -> LangTag
parseLangTag :: [Char] -> LangTag
parseLangTag [Char]
s = case Text -> Maybe LangTag
langTagFromText forall a b. (a -> b) -> a -> b
$ [Char] -> Text
Text.pack [Char]
s of
Just LangTag
l -> LangTag
l
Maybe LangTag
Nothing -> forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"Language tag value (" forall a. [a] -> [a] -> [a]
++ [Char]
s forall a. [a] -> [a] -> [a]
++ [Char]
") did not validate"
#if WITH_TEMPLATE_HASKELL
langTagQ :: QuasiQuoter
langTagQ :: QuasiQuoter
langTagQ = QuasiQuoter {quoteExp :: [Char] -> Q Exp
quoteExp = \[Char]
s -> case Text -> Maybe LangTag
langTagFromText forall a b. (a -> b) -> a -> b
$ [Char] -> Text
Text.pack [Char]
s of
Maybe LangTag
Nothing -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail forall a b. (a -> b) -> a -> b
$ [Char]
"Not a valid language tag: "
forall a. [a] -> [a] -> [a]
++ [Char]
s
Just LangTag
lt -> [|LangTag $(textE $ primaryTag lt)
$(listE $
map textE (subtags lt))
|]
, quotePat :: [Char] -> Q Pat
quotePat = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"LanguageTag patterns aren't"
forall a. [a] -> [a] -> [a]
++ [Char]
" implemented"
, quoteType :: [Char] -> Q Type
quoteType = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"LanguageTag QQ can't be used"
forall a. [a] -> [a] -> [a]
++ [Char]
" in type context"
, quoteDec :: [Char] -> Q [Dec]
quoteDec = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"LanguageTag QQ can't be used"
forall a. [a] -> [a] -> [a]
++ [Char]
" in declaration context"
}
where
textE :: Text -> m Exp
textE Text
t = [| Text.pack $(stringE $ Text.unpack t) |]
#endif
parseJid :: String -> Jid
parseJid :: [Char] -> Jid
parseJid [Char]
s = case Text -> Maybe Jid
jidFromText forall a b. (a -> b) -> a -> b
$ [Char] -> Text
Text.pack [Char]
s of
Just Jid
j -> Jid
j
Maybe Jid
Nothing -> forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
"Jid value (" forall a. [a] -> [a] -> [a]
++ [Char]
s forall a. [a] -> [a] -> [a]
++ [Char]
") did not validate"
jidFromText :: Text -> Maybe Jid
jidFromText :: Text -> Maybe Jid
jidFromText Text
t = do
(Maybe Text
l, Text
d, Maybe Text
r) <- forall {a} {a}. Either a a -> Maybe a
eitherToMaybe forall a b. (a -> b) -> a -> b
$ forall a. Parser a -> Text -> Either [Char] a
AP.parseOnly Parser (Maybe Text, Text, Maybe Text)
jidParts Text
t
Maybe Text -> Text -> Maybe Text -> Maybe Jid
jidFromTexts Maybe Text
l Text
d Maybe Text
r
where
eitherToMaybe :: Either a a -> Maybe a
eitherToMaybe = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a b. a -> b -> a
const forall a. Maybe a
Nothing) forall a. a -> Maybe a
Just
jidFromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid
jidFromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid
jidFromTexts Maybe Text
l Text
d Maybe Text
r = do
Maybe NonemptyText
localPart <- case Maybe Text
l of
Maybe Text
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Just Text
l'-> do
Text
l'' <- StringPrepProfile -> Text -> Maybe Text
SP.runStringPrep StringPrepProfile
nodeprepProfile Text
l'
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Text -> Bool
validPartLength Text
l''
let prohibMap :: Set Char
prohibMap = forall a. Ord a => [a] -> Set a
Set.fromList [Char]
nodeprepExtraProhibitedCharacters
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> Text -> Bool
Text.all (forall a. Ord a => a -> Set a -> Bool
`Set.notMember` Set Char
prohibMap) Text
l''
NonemptyText
l''' <- Text -> Maybe NonemptyText
nonEmpty Text
l''
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just NonemptyText
l'''
Text
domainPart' <- Text -> Maybe Text
forbidSeparators forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
stripSuffix forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< StringPrepProfile -> Text -> Maybe Text
SP.runStringPrep (Bool -> StringPrepProfile
SP.namePrepProfile Bool
False) (Text -> Text
stripSuffix Text
d)
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Text -> Bool
validDomainPart Text
domainPart'
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Text -> Bool
validPartLength Text
domainPart'
NonemptyText
domainPart <- Text -> Maybe NonemptyText
nonEmpty Text
domainPart'
Maybe NonemptyText
resourcePart <- case Maybe Text
r of
Maybe Text
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Just Text
r' -> do
Text
r'' <- StringPrepProfile -> Text -> Maybe Text
SP.runStringPrep StringPrepProfile
resourceprepProfile Text
r'
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Text -> Bool
validPartLength Text
r''
NonemptyText
r''' <- Text -> Maybe NonemptyText
nonEmpty Text
r''
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just NonemptyText
r'''
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Maybe NonemptyText -> NonemptyText -> Maybe NonemptyText -> Jid
Jid Maybe NonemptyText
localPart NonemptyText
domainPart Maybe NonemptyText
resourcePart
where
validDomainPart :: Text -> Bool
validDomainPart :: Text -> Bool
validDomainPart Text
s = Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ Text -> Bool
Text.null Text
s
validPartLength :: Text -> Bool
validPartLength :: Text -> Bool
validPartLength Text
p = Text -> Int
Text.length Text
p forall a. Ord a => a -> a -> Bool
> Int
0
Bool -> Bool -> Bool
&& ByteString -> Int
BS.length (Text -> ByteString
Text.encodeUtf8 Text
p) forall a. Ord a => a -> a -> Bool
< Int
1024
stripSuffix :: Text -> Text
stripSuffix = (Char -> Bool) -> Text -> Text
Text.dropWhileEnd (forall a. Eq a => a -> a -> Bool
== Char
'.')
forbidSeparators :: Text -> Maybe Text
forbidSeparators Text
t = if forall a. Maybe a
Nothing forall a. Eq a => a -> a -> Bool
== (Char -> Bool) -> Text -> Maybe Char
Text.find (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem [Char
'/', Char
'@']) Text
t then forall a. a -> Maybe a
Just Text
t else forall a. Maybe a
Nothing
isBare :: Jid -> Bool
isBare :: Jid -> Bool
isBare Jid
j | Jid -> Maybe Text
resourcepart Jid
j forall a. Eq a => a -> a -> Bool
== forall a. Maybe a
Nothing = Bool
True
| Bool
otherwise = Bool
False
isFull :: Jid -> Bool
isFull :: Jid -> Bool
isFull = Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Jid -> Bool
isBare
toBare :: Jid -> Jid
toBare :: Jid -> Jid
toBare Jid
j = Jid
j{resourcepart_ :: Maybe NonemptyText
resourcepart_ = forall a. Maybe a
Nothing}
localpart :: Jid -> Maybe Text
localpart :: Jid -> Maybe Text
localpart = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NonemptyText -> Text
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Jid -> Maybe NonemptyText
localpart_
domainpart :: Jid -> Text
domainpart :: Jid -> Text
domainpart = NonemptyText -> Text
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Jid -> NonemptyText
domainpart_
resourcepart :: Jid -> Maybe Text
resourcepart :: Jid -> Maybe Text
resourcepart = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NonemptyText -> Text
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Jid -> Maybe NonemptyText
resourcepart_
jidParts :: AP.Parser (Maybe Text, Text, Maybe Text)
jidParts :: Parser (Maybe Text, Text, Maybe Text)
jidParts = do
Maybe Text
maybeLocalPart <- forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text
localPart forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Text
domainPart <- (Char -> Bool) -> Parser Text
AP.takeWhile1 ([Char] -> Char -> Bool
AP.notInClass [Char
'@', Char
'/'])
Maybe Text
maybeResourcePart <- forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text
resourcePart forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
forall t. Chunk t => Parser t ()
AP.endOfInput
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Text
maybeLocalPart, Text
domainPart, Maybe Text
maybeResourcePart)
where
localPart :: Parser Text
localPart = do
Text
bytes <- (Char -> Bool) -> Parser Text
AP.takeWhile1 ([Char] -> Char -> Bool
AP.notInClass [Char
'@', Char
'/'])
Char
_ <- Char -> Parser Char
AP.char Char
'@'
forall (m :: * -> *) a. Monad m => a -> m a
return Text
bytes
resourcePart :: Parser Text
resourcePart = do
Char
_ <- Char -> Parser Char
AP.char Char
'/'
Parser Text
AP.takeText
nodeprepProfile :: SP.StringPrepProfile
nodeprepProfile :: StringPrepProfile
nodeprepProfile = SP.Profile { maps :: [Map]
SP.maps = [Map
SP.b1, Map
SP.b2]
, shouldNormalize :: Bool
SP.shouldNormalize = Bool
True
, prohibited :: [Prohibited]
SP.prohibited = [ Prohibited
SP.a1
, Prohibited
SP.c11
, Prohibited
SP.c12
, Prohibited
SP.c21
, Prohibited
SP.c22
, Prohibited
SP.c3
, Prohibited
SP.c4
, Prohibited
SP.c5
, Prohibited
SP.c6
, Prohibited
SP.c7
, Prohibited
SP.c8
, Prohibited
SP.c9
]
, shouldCheckBidi :: Bool
SP.shouldCheckBidi = Bool
True
}
nodeprepExtraProhibitedCharacters :: [Char]
= [Char
'\x22', Char
'\x26', Char
'\x27', Char
'\x2F', Char
'\x3A',
Char
'\x3C', Char
'\x3E', Char
'\x40']
resourceprepProfile :: SP.StringPrepProfile
resourceprepProfile :: StringPrepProfile
resourceprepProfile = SP.Profile { maps :: [Map]
SP.maps = [Map
SP.b1]
, shouldNormalize :: Bool
SP.shouldNormalize = Bool
True
, prohibited :: [Prohibited]
SP.prohibited = [ Prohibited
SP.a1
, Prohibited
SP.c12
, Prohibited
SP.c21
, Prohibited
SP.c22
, Prohibited
SP.c3
, Prohibited
SP.c4
, Prohibited
SP.c5
, Prohibited
SP.c6
, Prohibited
SP.c7
, Prohibited
SP.c8
, Prohibited
SP.c9
]
, shouldCheckBidi :: Bool
SP.shouldCheckBidi = Bool
True
}
data ConnectionDetails = UseRealm
| UseSrv HostName
| UseHost HostName PortNumber
| UseConnection (ExceptT XmppFailure IO StreamHandle)
data StreamConfiguration =
StreamConfiguration {
StreamConfiguration -> Maybe LangTag
preferredLang :: !(Maybe LangTag)
, StreamConfiguration -> Maybe (Jid, Bool)
toJid :: !(Maybe (Jid, Bool))
, StreamConfiguration -> ConnectionDetails
connectionDetails :: ConnectionDetails
, StreamConfiguration -> ResolvConf
resolvConf :: ResolvConf
, StreamConfiguration -> TlsBehaviour
tlsBehaviour :: TlsBehaviour
, StreamConfiguration -> ClientParams
tlsParams :: ClientParams
}
xmppDefaultParamsStrong :: ClientParams
xmppDefaultParamsStrong :: ClientParams
xmppDefaultParamsStrong = ([Char] -> ByteString -> ClientParams
defaultParamsClient [Char]
"" ByteString
BS.empty)
{ clientSupported :: Supported
clientSupported = forall a. Default a => a
def
{ supportedCiphers :: [Cipher]
supportedCiphers = [Cipher]
ciphersuite_strong
forall a. [a] -> [a] -> [a]
++ [ Cipher
cipher_AES256_SHA1
, Cipher
cipher_AES128_SHA1
]
}
}
xmppDefaultParams :: ClientParams
xmppDefaultParams :: ClientParams
xmppDefaultParams = ([Char] -> ByteString -> ClientParams
defaultParamsClient [Char]
"" ByteString
BS.empty)
{ clientSupported :: Supported
clientSupported = forall a. Default a => a
def
{ supportedCiphers :: [Cipher]
supportedCiphers = [Cipher]
ciphersuite_default
}
}
instance Default StreamConfiguration where
def :: StreamConfiguration
def = StreamConfiguration { preferredLang :: Maybe LangTag
preferredLang = forall a. Maybe a
Nothing
, toJid :: Maybe (Jid, Bool)
toJid = forall a. Maybe a
Nothing
, connectionDetails :: ConnectionDetails
connectionDetails = ConnectionDetails
UseRealm
, resolvConf :: ResolvConf
resolvConf = ResolvConf
defaultResolvConf
, tlsBehaviour :: TlsBehaviour
tlsBehaviour = TlsBehaviour
PreferTls
, tlsParams :: ClientParams
tlsParams = ClientParams
xmppDefaultParams
}
data TlsBehaviour = RequireTls
| PreferTls
| PreferPlain
| RefuseTls
deriving (TlsBehaviour -> TlsBehaviour -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TlsBehaviour -> TlsBehaviour -> Bool
$c/= :: TlsBehaviour -> TlsBehaviour -> Bool
== :: TlsBehaviour -> TlsBehaviour -> Bool
$c== :: TlsBehaviour -> TlsBehaviour -> Bool
Eq, Int -> TlsBehaviour -> ShowS
[TlsBehaviour] -> ShowS
TlsBehaviour -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [TlsBehaviour] -> ShowS
$cshowList :: [TlsBehaviour] -> ShowS
show :: TlsBehaviour -> [Char]
$cshow :: TlsBehaviour -> [Char]
showsPrec :: Int -> TlsBehaviour -> ShowS
$cshowsPrec :: Int -> TlsBehaviour -> ShowS
Show, forall x. Rep TlsBehaviour x -> TlsBehaviour
forall x. TlsBehaviour -> Rep TlsBehaviour x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TlsBehaviour x -> TlsBehaviour
$cfrom :: forall x. TlsBehaviour -> Rep TlsBehaviour x
Generic)