From db36ebafe59043bd314f1d6431abc5738ef7fd58 Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Mon, 11 Jan 2016 14:27:56 +0100
Subject: [PATCH] add onRosterPushL lens
---
ChangeLog.md | 3 +++
source/Network/Xmpp/Concurrent/Types.hs | 4 +++-
source/Network/Xmpp/Lens.hs | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 90cfdef..c1a42bd 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,6 @@
+# 0.5.1 to 0.5.2
+* Added onrosterPushL lens
+
# 0.5.0 to 0.5.1
* Fixed input logger choking on long non-ascii messages
diff --git a/source/Network/Xmpp/Concurrent/Types.hs b/source/Network/Xmpp/Concurrent/Types.hs
index 59a72ee..bce659d 100644
--- a/source/Network/Xmpp/Concurrent/Types.hs
+++ b/source/Network/Xmpp/Concurrent/Types.hs
@@ -70,6 +70,8 @@ type Plugin = (XmppElement -> IO (Either XmppFailure ())) -- ^ pass stanza to
-- next plugin
-> ErrorT XmppFailure IO Plugin'
+type RosterPushCallback = (QueryItem -> IO ())
+
-- | Configuration for the @Session@ object.
data SessionConfiguration = SessionConfiguration
{ -- | Configuration for the @Stream@ object.
@@ -90,7 +92,7 @@ data SessionConfiguration = SessionConfiguration
, initialRoster :: IO (Maybe Roster)
-- | Callback called on a roster Push. The callback is called after the
-- roster is updated
- , onRosterPush :: Maybe (QueryItem -> IO ())
+ , onRosterPush :: Maybe RosterPushCallback
-- | Track incomming presence stancas.
, enablePresenceTracking :: Bool
-- | Callback that is invoked when the presence status of a peer changes,
diff --git a/source/Network/Xmpp/Lens.hs b/source/Network/Xmpp/Lens.hs
index dc2bfc5..d20183b 100644
--- a/source/Network/Xmpp/Lens.hs
+++ b/source/Network/Xmpp/Lens.hs
@@ -102,6 +102,7 @@ module Network.Xmpp.Lens
, onConnectionClosedL
, sessionStanzaIDsL
, ensableRosterL
+ , onRosterPushL
, pluginsL
, onPresenceChangeL
-- ** IM
@@ -552,6 +553,9 @@ ensableRosterL :: Lens SessionConfiguration Bool
ensableRosterL inj sc@SessionConfiguration{enableRoster = x}
= (\x' -> sc{enableRoster = x'}) <$> inj x
+onRosterPushL :: Lens SessionConfiguration (Maybe RosterPushCallback)
+onRosterPushL = mkLens onRosterPush (\orp x -> x{onRosterPush = orp})
+
pluginsL :: Lens SessionConfiguration [Plugin]
pluginsL inj sc@SessionConfiguration{plugins = x}
= (\x' -> sc{plugins = x'}) <$> inj x