Browse Source

add remaining lenses for roster types

master
Philipp Balzarek 12 years ago
parent
commit
484b049cd8
  1. 5
      source/Network/Xmpp.hs
  2. 89
      source/Network/Xmpp/Lens.hs

5
source/Network/Xmpp.hs

@ -173,7 +173,10 @@ module Network.Xmpp
, SaslFailure(..) , SaslFailure(..)
-- * Threads -- * Threads
, dupSession , dupSession
module Network.Xmpp.Lens -- * Lenses
-- | Network.Xmpp doesn't re-export the accessors to avoid name
-- clashes. If you want to use them import Network.Xmpp.Lens
, module Network.Xmpp.Lens
-- * Miscellaneous -- * Miscellaneous
, LangTag , LangTag
, langTagFromText , langTagFromText

89
source/Network/Xmpp/Lens.hs

@ -8,6 +8,10 @@
-- the lens library. This module also provides 3 simple accessors ('view', -- the lens library. This module also provides 3 simple accessors ('view',
-- 'modify', 'set') so you don't need to pull in the lens library to get some -- 'modify', 'set') so you don't need to pull in the lens library to get some
-- use out of them. -- use out of them.
--
-- The name of the lenses corresponds to the field name of the data types with
-- an upper-case L appended. For documentation of the fields refer to the documentation of the data types (linked in the section header)
module Network.Xmpp.Lens module Network.Xmpp.Lens
( Lens ( Lens
, Traversal , Traversal
@ -18,6 +22,8 @@ module Network.Xmpp.Lens
, modify , modify
, set , set
-- * Lenses -- * Lenses
-- ** Stanzas -- ** Stanzas
, IsStanza(..) , IsStanza(..)
, HasStanzaPayload(..) , HasStanzaPayload(..)
@ -25,12 +31,12 @@ module Network.Xmpp.Lens
, messageTypeL , messageTypeL
, presenceTypeL , presenceTypeL
, iqRequestTypeL , iqRequestTypeL
-- ** StanzaError -- *** 'StanzaError'
, stanzaErrorTypeL , stanzaErrorTypeL
, stanzaErrorConditionL , stanzaErrorConditionL
, stanzaErrorTextL , stanzaErrorTextL
, stanzaErrorApplL , stanzaErrorApplL
-- ** StreamConfiguration -- *** 'StreamConfiguration'
, preferredLangL , preferredLangL
, toJidL , toJidL
, connectionDetailsL , connectionDetailsL
@ -38,16 +44,35 @@ module Network.Xmpp.Lens
, establishSessionL , establishSessionL
, tlsBehaviourL , tlsBehaviourL
, tlsParamsL , tlsParamsL
-- ** SessionConfiguration -- *** 'SessionConfiguration'
, streamConfigurationL , streamConfigurationL
, onConnectionClosedL , onConnectionClosedL
, sessionStanzaIDsL , sessionStanzaIDsL
, ensableRosterL , ensableRosterL
, pluginsL , pluginsL
-- ** Roster -- ** IM
-- *** Roster
-- **** 'Roster'
, verL , verL
, itemsL , itemsL
-- ** IM -- **** 'Item'
, riApprovedL
, riAskL
, riJidL
, riNameL
, riSubscriptionL
, riGroupsL
-- **** 'QueryItem'
, qiApprovedL
, qiAskL
, qiJidL
, qiNameL
, qiSubscriptionL
, qiGroupsL
-- **** 'Query'
, queryVerL
, queryItemsL
-- ** IM Message
, bodyLangL , bodyLangL
, bodyContentL , bodyContentL
, threadIdL , threadIdL
@ -75,6 +100,8 @@ import Network.DNS(ResolvConf)
import Network.TLS (TLSParams) import Network.TLS (TLSParams)
import Network.Xmpp.Concurrent.Types import Network.Xmpp.Concurrent.Types
import Network.Xmpp.IM.Roster.Types import Network.Xmpp.IM.Roster.Types
import Network.Xmpp.IM.Message
import Network.Xmpp.IM.Presence
import Network.Xmpp.Types import Network.Xmpp.Types
-- | Van-Laarhoven lenses. -- | Van-Laarhoven lenses.
@ -372,6 +399,58 @@ verL inj r@Roster{ver = x} = (\x' -> r{ver = x'}) <$> inj x
itemsL :: Lens Roster (Map.Map Jid Item) itemsL :: Lens Roster (Map.Map Jid Item)
itemsL inj r@Roster{items = x} = (\x' -> r{items = x'}) <$> inj x itemsL inj r@Roster{items = x} = (\x' -> r{items = x'}) <$> inj x
-- Item
----------------------
riApprovedL :: Lens Item Bool
riApprovedL inj i@Item{riApproved = x} = (\x' -> i{riApproved = x'}) <$> inj x
riAskL :: Lens Item Bool
riAskL inj i@Item{riAsk = x} = (\x' -> i{riAsk = x'}) <$> inj x
riJidL :: Lens Item Jid
riJidL inj i@Item{riJid = x} = (\x' -> i{riJid = x'}) <$> inj x
riNameL :: Lens Item (Maybe Text)
riNameL inj i@Item{riName = x} = (\x' -> i{riName = x'}) <$> inj x
riSubscriptionL :: Lens Item Subscription
riSubscriptionL inj i@Item{riSubscription = x} =
(\x' -> i{riSubscription = x'}) <$> inj x
riGroupsL :: Lens Item [Text]
riGroupsL inj i@Item{riGroups = x} = (\x' -> i{riGroups = x'}) <$> inj x
-- QueryItem
-------------------
qiApprovedL :: Lens QueryItem (Maybe Bool)
qiApprovedL inj i@QueryItem{qiApproved = x} =
(\x' -> i{qiApproved = x'}) <$> inj x
qiAskL :: Lens QueryItem Bool
qiAskL inj i@QueryItem{qiAsk = x} = (\x' -> i{qiAsk = x'}) <$> inj x
qiJidL :: Lens QueryItem Jid
qiJidL inj i@QueryItem{qiJid = x} = (\x' -> i{qiJid = x'}) <$> inj x
qiNameL :: Lens QueryItem (Maybe Text)
qiNameL inj i@QueryItem{qiName = x} = (\x' -> i{qiName = x'}) <$> inj x
qiSubscriptionL :: Lens QueryItem (Maybe Subscription)
qiSubscriptionL inj i@QueryItem{qiSubscription = x} =
(\x' -> i{qiSubscription = x'}) <$> inj x
qiGroupsL :: Lens QueryItem [Text]
qiGroupsL inj i@QueryItem{qiGroups = x} = (\x' -> i{qiGroups = x'}) <$> inj x
queryVerL :: Lens Query (Maybe Text)
queryVerL inj i@Query{queryVer = x} = (\x' -> i{queryVer = x'}) <$> inj x
queryItemsL :: Lens Query [QueryItem]
queryItemsL inj i@Query{queryItems = x} = (\x' -> i{queryItems = x'}) <$> inj x
-- IM -- IM
------------------- -------------------

Loading…
Cancel
Save