{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_HADDOCK hide #-}
module Network.Xmpp.Stanza where
import Data.XML.Types
import Network.Xmpp.Types
import Network.Xmpp.Lens
presenceSubscribe :: Jid -> Presence
presenceSubscribe :: Jid -> Presence
presenceSubscribe Jid
to' = Presence
presence { presenceTo = Just to'
, presenceType = Subscribe
}
presenceSubscribed :: Jid -> Presence
presenceSubscribed :: Jid -> Presence
presenceSubscribed Jid
to' = Presence
presence { presenceTo = Just to'
, presenceType = Subscribed
}
presenceUnsubscribe :: Jid -> Presence
presenceUnsubscribe :: Jid -> Presence
presenceUnsubscribe Jid
to' = Presence
presence { presenceTo = Just to'
, presenceType = Unsubscribe
}
presenceUnsubscribed :: Jid -> Presence
presenceUnsubscribed :: Jid -> Presence
presenceUnsubscribed Jid
to' = Presence
presence { presenceTo = Just to'
, presenceType = Unsubscribed
}
presenceOnline :: Presence
presenceOnline :: Presence
presenceOnline = Presence
presence
presenceOffline :: Presence
presenceOffline :: Presence
presenceOffline = Presence
presence {presenceType = Unavailable}
answerMessage :: Message -> [Element] -> Maybe Message
answerMessage :: Message -> [Element] -> Maybe Message
answerMessage Message{messageFrom :: Message -> Maybe Jid
messageFrom = Just Jid
frm, [ExtendedAttribute]
[Element]
Maybe Text
Maybe Jid
Maybe LangTag
MessageType
messageID :: Maybe Text
messageTo :: Maybe Jid
messageLangTag :: Maybe LangTag
messageType :: MessageType
messagePayload :: [Element]
messageAttributes :: [ExtendedAttribute]
messageID :: Message -> Maybe Text
messageTo :: Message -> Maybe Jid
messageLangTag :: Message -> Maybe LangTag
messageType :: Message -> MessageType
messagePayload :: Message -> [Element]
messageAttributes :: Message -> [ExtendedAttribute]
..} [Element]
payload' =
Message -> Maybe Message
forall a. a -> Maybe a
Just Message{ messageFrom :: Maybe Jid
messageFrom = Maybe Jid
forall a. Maybe a
Nothing
, messageID :: Maybe Text
messageID = Maybe Text
forall a. Maybe a
Nothing
, messageTo :: Maybe Jid
messageTo = Jid -> Maybe Jid
forall a. a -> Maybe a
Just Jid
frm
, messagePayload :: [Element]
messagePayload = [Element]
payload'
, [ExtendedAttribute]
Maybe LangTag
MessageType
messageLangTag :: Maybe LangTag
messageType :: MessageType
messageAttributes :: [ExtendedAttribute]
messageLangTag :: Maybe LangTag
messageType :: MessageType
messageAttributes :: [ExtendedAttribute]
..
}
answerMessage Message
_ [Element]
_ = Maybe Message
forall a. Maybe a
Nothing
presTo :: Presence -> Jid -> Presence
presTo :: Presence -> Jid -> Presence
presTo Presence
pres Jid
to' = Presence
pres{presenceTo = Just to'}
mkStanzaError :: StanzaErrorCondition
-> StanzaError
mkStanzaError :: StanzaErrorCondition -> StanzaError
mkStanzaError StanzaErrorCondition
condition = StanzaErrorType
-> StanzaErrorCondition
-> Maybe (Maybe LangTag, NonemptyText)
-> Maybe Element
-> StanzaError
StanzaError (StanzaErrorCondition -> StanzaErrorType
associatedErrorType StanzaErrorCondition
condition)
StanzaErrorCondition
condition Maybe (Maybe LangTag, NonemptyText)
forall a. Maybe a
Nothing Maybe Element
forall a. Maybe a
Nothing
iqError :: StanzaErrorCondition -> IQRequest -> IQError
iqError :: StanzaErrorCondition -> IQRequest -> IQError
iqError StanzaErrorCondition
condition (IQRequest Text
iqid Maybe Jid
from' Maybe Jid
_to Maybe LangTag
lang' IQRequestType
_tp Element
_bd [ExtendedAttribute]
_attr) =
Text
-> Maybe Jid
-> Maybe Jid
-> Maybe LangTag
-> StanzaError
-> Maybe Element
-> [ExtendedAttribute]
-> IQError
IQError Text
iqid Maybe Jid
forall a. Maybe a
Nothing Maybe Jid
from' Maybe LangTag
lang' (StanzaErrorCondition -> StanzaError
mkStanzaError StanzaErrorCondition
condition) Maybe Element
forall a. Maybe a
Nothing []
iqResult :: Maybe Element -> IQRequest -> IQResult
iqResult :: Maybe Element -> IQRequest -> IQResult
iqResult Maybe Element
pl IQRequest
iqr = IQResult
{ iqResultID :: Text
iqResultID = IQRequest -> Text
iqRequestID IQRequest
iqr
, iqResultFrom :: Maybe Jid
iqResultFrom = Maybe Jid
forall a. Maybe a
Nothing
, iqResultTo :: Maybe Jid
iqResultTo = FoldLike (Maybe Jid) IQRequest IQRequest (Maybe Jid) (Maybe Jid)
-> IQRequest -> Maybe Jid
forall a s t b. FoldLike a s t a b -> s -> a
view FoldLike (Maybe Jid) IQRequest IQRequest (Maybe Jid) (Maybe Jid)
forall s. IsStanza s => Lens s (Maybe Jid)
Lens IQRequest (Maybe Jid)
from IQRequest
iqr
, iqResultLangTag :: Maybe LangTag
iqResultLangTag = FoldLike
(Maybe LangTag) IQRequest IQRequest (Maybe LangTag) (Maybe LangTag)
-> IQRequest -> Maybe LangTag
forall a s t b. FoldLike a s t a b -> s -> a
view FoldLike
(Maybe LangTag) IQRequest IQRequest (Maybe LangTag) (Maybe LangTag)
forall s. IsStanza s => Lens s (Maybe LangTag)
Lens IQRequest (Maybe LangTag)
lang IQRequest
iqr
, iqResultPayload :: Maybe Element
iqResultPayload = Maybe Element
pl
, iqResultAttributes :: [ExtendedAttribute]
iqResultAttributes = []
}
associatedErrorType :: StanzaErrorCondition -> StanzaErrorType
associatedErrorType :: StanzaErrorCondition -> StanzaErrorType
associatedErrorType StanzaErrorCondition
BadRequest = StanzaErrorType
Modify
associatedErrorType StanzaErrorCondition
Conflict = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
FeatureNotImplemented = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
Forbidden = StanzaErrorType
Auth
associatedErrorType Gone{} = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
InternalServerError = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
ItemNotFound = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
JidMalformed = StanzaErrorType
Modify
associatedErrorType StanzaErrorCondition
NotAcceptable = StanzaErrorType
Modify
associatedErrorType StanzaErrorCondition
NotAllowed = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
NotAuthorized = StanzaErrorType
Auth
associatedErrorType StanzaErrorCondition
PolicyViolation = StanzaErrorType
Modify
associatedErrorType StanzaErrorCondition
RecipientUnavailable = StanzaErrorType
Wait
associatedErrorType Redirect{} = StanzaErrorType
Modify
associatedErrorType StanzaErrorCondition
RegistrationRequired = StanzaErrorType
Auth
associatedErrorType StanzaErrorCondition
RemoteServerNotFound = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
RemoteServerTimeout = StanzaErrorType
Wait
associatedErrorType StanzaErrorCondition
ResourceConstraint = StanzaErrorType
Wait
associatedErrorType StanzaErrorCondition
ServiceUnavailable = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
SubscriptionRequired = StanzaErrorType
Auth
associatedErrorType StanzaErrorCondition
UndefinedCondition = StanzaErrorType
Cancel
associatedErrorType StanzaErrorCondition
UnexpectedRequest = StanzaErrorType
Modify