summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-05-31 05:20:54 -0400
committerjoe <joe@jerkface.net>2018-05-31 05:20:54 -0400
commit7c3169c7c940cae50c56b62afe4dcd0579626c99 (patch)
tree0f990f084a518047de7aa9eaa8b7e0743063bc07 /examples/dhtd.hs
parent72a01c731b2dc8c82f14161731575d00c71905aa (diff)
Do-nothing tox-to-xmpp conversion conduits.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 6a7695d2..553146f7 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -1495,29 +1495,26 @@ toxman announcer toxbkts tox presence = ToxManager
1495 _ -> return () -- Remove contact. 1495 _ -> return () -- Remove contact.
1496 } 1496 }
1497 1497
1498#ifdef XMPP
1499
1500-- | Called upon a new Tox friend-connection session with a remote peer in 1498-- | Called upon a new Tox friend-connection session with a remote peer in
1501-- order to set up translating conduits that simulate a remote XMPP server. 1499-- order to set up translating conduits that simulate a remote XMPP server.
1502announceToxJabberPeer :: TChan ((ConnectionKey,SockAddr), Tcp.ConnectionEvent XML.Event) 1500announceToxJabberPeer :: PublicKey -- ^ Remote tox node's long-term user key.
1501 -> TChan ((ConnectionKey,SockAddr), Tcp.ConnectionEvent XML.Event)
1503 -> SockAddr -- ^ Local bind address for incoming Tox packets. 1502 -> SockAddr -- ^ Local bind address for incoming Tox packets.
1504 -> SockAddr -- ^ Remote address for this connection. 1503 -> SockAddr -- ^ Remote address for this connection.
1505 -> STM Bool 1504 -> STM Bool
1506 -> C.Source IO Tox.CryptoMessage 1505 -> C.Source IO Tox.CryptoMessage
1507 -> C.Sink (Flush Tox.CryptoMessage) IO () 1506 -> C.Sink (Flush Tox.CryptoMessage) IO ()
1508 -> IO (Maybe (Tox.NetCryptoSession -> Tox.NetCryptoSession)) 1507 -> IO (Maybe (Tox.NetCryptoSession -> Tox.NetCryptoSession))
1509announceToxJabberPeer echan laddr saddr pingflag tsrc tsnk 1508announceToxJabberPeer them echan laddr saddr pingflag tsrc tsnk
1510 = do 1509 = do
1511 atomically $ writeTChan echan 1510 atomically $ writeTChan echan
1512 ( (PeerKey saddr, laddr ) 1511 ( (PeerKey saddr, laddr )
1513 , Tcp.Connection pingflag xsrc xsnk ) 1512 , Tcp.Connection pingflag xsrc xsnk )
1514 return Nothing 1513 return Nothing
1515 where 1514 where
1516 xsrc = tsrc =$= toxToXmpp 1515 xsrc = tsrc =$= toxToXmpp (T.pack $ show them ++ ".tox")
1517 xsnk = flushPassThrough xmppToTox =$= tsnk 1516 xsnk = flushPassThrough xmppToTox =$= tsnk
1518 1517
1519#endif
1520
1521vShowMe :: Tox.ViewSnapshot -> Int -> B.ByteString 1518vShowMe :: Tox.ViewSnapshot -> Int -> B.ByteString
1522vShowMe (Tox.ViewSnapshot { vNick, vStatus, vStatusMsg, vTyping }) indent 1519vShowMe (Tox.ViewSnapshot { vNick, vStatus, vStatusMsg, vTyping }) indent
1523 = B.unlines 1520 = B.unlines
@@ -1898,14 +1895,12 @@ main = runResourceT $ liftBaseWith $ \resT -> do
1898 let Just pingMachine = Tox.ncPingMachine netcrypto 1895 let Just pingMachine = Tox.ncPingMachine netcrypto
1899 pingflag = readTVar (pingFlag pingMachine) 1896 pingflag = readTVar (pingFlag pingMachine)
1900 receiveCrypto = atomically $ readTMChan tmchan 1897 receiveCrypto = atomically $ readTMChan tmchan
1901#ifdef XMPP
1902 onEOF = return () -- TODO: Update toxContactInfo, not connected. 1898 onEOF = return () -- TODO: Update toxContactInfo, not connected.
1903 xmppSrc = ioToSource receiveCrypto onEOF 1899 xmppSrc = ioToSource receiveCrypto onEOF
1904 xmppSink = newXmmpSink netcrypto 1900 xmppSink = newXmmpSink netcrypto
1905 forM_ msv $ \sv -> do 1901 forM_ msv $ \sv -> do
1906 announceToxJabberPeer (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink 1902 announceToxJabberPeer (Tox.ncTheirPublicKey netcrypto) (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink
1907 -- TODO: Update toxContactInfo, connected. 1903 -- TODO: Update toxContactInfo, connected.
1908#endif
1909 atomically $ do 1904 atomically $ do
1910 supply <- readTVar (Tox.listenerIDSupply netCryptoSessionsState) 1905 supply <- readTVar (Tox.listenerIDSupply netCryptoSessionsState)
1911 let (listenerId,supply') = freshId supply 1906 let (listenerId,supply') = freshId supply