Browse Source

remove to prefix from toLocalpart, toDomainpart and toResourcePart

master
Philipp Balzarek 13 years ago
parent
commit
65137386b1
  1. 6
      source/Network/Xmpp.hs
  2. 32
      source/Network/Xmpp/Types.hs

6
source/Network/Xmpp.hs

@ -52,9 +52,9 @@ module Network.Xmpp
, jidToText , jidToText
, jidToTexts , jidToTexts
, toBare , toBare
, toLocalpart , localpart
, toDomainpart , domainpart
, toResourcepart , resourcepart
, parseJid , parseJid
, getJid , getJid
-- * Stanzas -- * Stanzas

32
source/Network/Xmpp/Types.hs

@ -50,9 +50,9 @@ module Network.Xmpp.Types
, jidToText , jidToText
, jidToTexts , jidToTexts
, toBare , toBare
, toLocalpart , localpart
, toDomainpart , domainpart
, toResourcepart , resourcepart
, parseJid , parseJid
, StreamEnd(..) , StreamEnd(..)
, InvalidXmppXml(..) , InvalidXmppXml(..)
@ -883,7 +883,7 @@ 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: localpart, domainpart, and resourcepart. -- two: localpart, domainpart, and resourcepart.
-- --
-- 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
@ -902,7 +902,7 @@ newtype Stream = Stream { unStream :: TMVar StreamState }
-- 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).
-- --
-- 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
@ -913,9 +913,9 @@ newtype Stream = Stream { unStream :: TMVar StreamState }
-- 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) data Jid = Jid { localpart_ :: !(Maybe Text)
, domainpart :: !Text , domainpart_ :: !Text
, resourcepart :: !(Maybe Text) , resourcepart_ :: !(Maybe Text)
} deriving (Eq, Ord) } deriving (Eq, Ord)
-- | Converts a JID to a Text. -- | Converts a JID to a Text.
@ -954,7 +954,7 @@ instance Read Jid where
-- or the `parseJid' error message (see below) -- or the `parseJid' error message (see below)
-- | Parses a JID string. -- | Parses a JID string.
-- --
-- Note: This function is only meant to be used to reverse @Jid@ Show -- Note: This function is only meant to be used to reverse @Jid@ Show
-- operations; it will produce an 'undefined' value if the JID does not -- operations; it will produce an 'undefined' value if the JID does not
-- validate; please refer to @jidFromText@ for a safe equivalent. -- validate; please refer to @jidFromText@ for a safe equivalent.
@ -1010,19 +1010,19 @@ isFull = not . isBare
-- | Returns the @Jid@ without the resourcepart (if any). -- | Returns the @Jid@ without the resourcepart (if any).
toBare :: Jid -> Jid toBare :: Jid -> Jid
toBare (Jid localpart domainpart _) = Jid localpart domainpart Nothing toBare jid = jid{resourcepart_ = Nothing}
-- | Returns the localpart of the @Jid@ (if any). -- | Returns the localpart of the @Jid@ (if any).
toLocalpart :: Jid -> Maybe Text localpart :: Jid -> Maybe Text
toLocalpart = localpart localpart = localpart_
-- | Returns the domainpart of the @Jid@. -- | Returns the domainpart of the @Jid@.
toDomainpart :: Jid -> Text domainpart :: Jid -> Text
toDomainpart = domainpart domainpart = domainpart_
-- | Returns the resourcepart of the @Jid@ (if any). -- | Returns the resourcepart of the @Jid@ (if any).
toResourcepart :: Jid -> Maybe Text resourcepart :: Jid -> Maybe Text
toResourcepart = resourcepart resourcepart = 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.

Loading…
Cancel
Save