|
|
|
@ -49,6 +49,10 @@ module Network.Xmpp.Types |
|
|
|
, jidFromTexts |
|
|
|
, jidFromTexts |
|
|
|
, jidToText |
|
|
|
, jidToText |
|
|
|
, jidToTexts |
|
|
|
, jidToTexts |
|
|
|
|
|
|
|
, toBare |
|
|
|
|
|
|
|
, toLocalpart |
|
|
|
|
|
|
|
, toDomainpart |
|
|
|
|
|
|
|
, toResourcepart |
|
|
|
, parseJid |
|
|
|
, parseJid |
|
|
|
, StreamEnd(..) |
|
|
|
, StreamEnd(..) |
|
|
|
, InvalidXmppXml(..) |
|
|
|
, InvalidXmppXml(..) |
|
|
|
@ -878,8 +882,9 @@ newtype Stream = Stream { unStream :: TMVar StreamState } |
|
|
|
|
|
|
|
|
|
|
|
-- | A JID is XMPP\'s native format for addressing entities in the network. It |
|
|
|
-- | A JID is XMPP\'s native format for addressing entities in the network. It |
|
|
|
-- is somewhat similar to an e-mail address but contains three parts instead of |
|
|
|
-- is somewhat similar to an e-mail address but contains three parts instead of |
|
|
|
-- two. |
|
|
|
-- two: localpart, domainpart, and resourcepart. |
|
|
|
data Jid = Jid { -- | The @localpart@ of a JID is an optional identifier placed |
|
|
|
-- |
|
|
|
|
|
|
|
-- The @localpart@ of a JID is an optional identifier placed |
|
|
|
-- before the domainpart and separated from the latter by a |
|
|
|
-- before the domainpart and separated from the latter by a |
|
|
|
-- \'\@\' character. Typically a localpart uniquely identifies |
|
|
|
-- \'\@\' character. Typically a localpart uniquely identifies |
|
|
|
-- the entity requesting and using network access provided by a |
|
|
|
-- the entity requesting and using network access provided by a |
|
|
|
@ -889,18 +894,16 @@ data Jid = Jid { -- | The @localpart@ of a JID is an optional identifier placed |
|
|
|
-- represented by an XMPP localpart is addressed within the |
|
|
|
-- represented by an XMPP localpart is addressed within the |
|
|
|
-- context of a specific domain (i.e., |
|
|
|
-- context of a specific domain (i.e., |
|
|
|
-- @localpart\@domainpart@). |
|
|
|
-- @localpart\@domainpart@). |
|
|
|
localpart :: !(Maybe Text) |
|
|
|
-- |
|
|
|
|
|
|
|
-- The domainpart typically identifies the /home/ server to |
|
|
|
-- | The domainpart typically identifies the /home/ server to |
|
|
|
|
|
|
|
-- which clients connect for XML routing and data management |
|
|
|
-- which clients connect for XML routing and data management |
|
|
|
-- functionality. However, it is not necessary for an XMPP |
|
|
|
-- functionality. However, it is not necessary for an XMPP |
|
|
|
-- domainpart to identify an entity that provides core XMPP |
|
|
|
-- domainpart to identify an entity that provides core XMPP |
|
|
|
-- server functionality (e.g., a domainpart can identify an |
|
|
|
-- server functionality (e.g., a domainpart can identify an |
|
|
|
-- entity such as a multi-user chat service, a |
|
|
|
-- entity such as a multi-user chat service, a |
|
|
|
-- publish-subscribe service, or a user directory). |
|
|
|
-- publish-subscribe service, or a user directory). |
|
|
|
, domainpart :: !Text |
|
|
|
-- |
|
|
|
|
|
|
|
-- The resourcepart of a JID is an optional identifier placed |
|
|
|
-- | The resourcepart of a JID is an optional identifier placed |
|
|
|
|
|
|
|
-- after the domainpart and separated from the latter by the |
|
|
|
-- after the domainpart and separated from the latter by the |
|
|
|
-- \'\/\' character. A resourcepart can modify either a |
|
|
|
-- \'\/\' character. A resourcepart can modify either a |
|
|
|
-- @localpart\@domainpart@ address or a mere @domainpart@ |
|
|
|
-- @localpart\@domainpart@ address or a mere @domainpart@ |
|
|
|
@ -909,6 +912,9 @@ data Jid = Jid { -- | The @localpart@ of a JID is an optional identifier placed |
|
|
|
-- (e.g., an occupant in a multi-user chat room) belonging to |
|
|
|
-- (e.g., an occupant in a multi-user chat room) belonging to |
|
|
|
-- the entity associated with an XMPP localpart at a domain |
|
|
|
-- the entity associated with an XMPP localpart at a domain |
|
|
|
-- (i.e., @localpart\@domainpart/resourcepart@). |
|
|
|
-- (i.e., @localpart\@domainpart/resourcepart@). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data Jid = Jid { localpart :: !(Maybe Text) |
|
|
|
|
|
|
|
, domainpart :: !Text |
|
|
|
, resourcepart :: !(Maybe Text) |
|
|
|
, resourcepart :: !(Maybe Text) |
|
|
|
} deriving (Eq, Ord) |
|
|
|
} deriving (Eq, Ord) |
|
|
|
|
|
|
|
|
|
|
|
@ -1002,6 +1008,22 @@ isBare j | resourcepart j == Nothing = True |
|
|
|
isFull :: Jid -> Bool |
|
|
|
isFull :: Jid -> Bool |
|
|
|
isFull = not . isBare |
|
|
|
isFull = not . isBare |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | Returns the @Jid@ without the resourcepart (if any). |
|
|
|
|
|
|
|
toBare :: Jid -> Jid |
|
|
|
|
|
|
|
toBare (Jid localpart domainpart _) = Jid localpart domainpart Nothing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | Returns the localpart of the @Jid@ (if any). |
|
|
|
|
|
|
|
toLocalpart :: Jid -> Maybe Text |
|
|
|
|
|
|
|
toLocalpart = localpart |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | Returns the domainpart of the @Jid@. |
|
|
|
|
|
|
|
toDomainpart :: Jid -> Text |
|
|
|
|
|
|
|
toDomainpart = domainpart |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | Returns the resourcepart of the @Jid@ (if any). |
|
|
|
|
|
|
|
toResourcepart :: Jid -> Maybe Text |
|
|
|
|
|
|
|
toResourcepart = resourcepart |
|
|
|
|
|
|
|
|
|
|
|
-- Parses an JID string and returns its three parts. It performs no validation |
|
|
|
-- Parses an JID string and returns its three parts. It performs no validation |
|
|
|
-- or transformations. |
|
|
|
-- or transformations. |
|
|
|
jidParts :: AP.Parser (Maybe Text, Text, Maybe Text) |
|
|
|
jidParts :: AP.Parser (Maybe Text, Text, Maybe Text) |
|
|
|
|