From 02e4a7819e8697cf3d2c4919f99252313c83ee63 Mon Sep 17 00:00:00 2001 From: jonkri Date: Fri, 2 Sep 2011 02:00:37 +0200 Subject: [PATCH] configured the project for eclipsefp and committed it "as is" --- .gitignore | 2 + .hsproject | 4 + .project | 17 ++ ...ign Description for Pontarius XMPP 1.0.lyx | 2 +- ...ments Specification for Pontarius XMPP.lyx | 3 +- Examples/EchoClient.hs | 147 ------------------ Setup.hs | 1 - Source/Examples/EchoClient.hs | 74 +++++++++ {Network => Source/Network}/XMPP.hs | 0 {Network => Source/Network}/XMPP/Address.hs | 0 {Network => Source/Network}/XMPP/SASL.hs | 0 {Network => Source/Network}/XMPP/Session.hs | 0 .../Network}/XMPP/SessionOld.hs | 0 {Network => Source/Network}/XMPP/Stanza.hs | 0 {Network => Source/Network}/XMPP/Stream.hs | 0 {Network => Source/Network}/XMPP/TLS.hs | 0 {Network => Source/Network}/XMPP/Types.hs | 0 {Network => Source/Network}/XMPP/Utilities.hs | 0 pontarius-xmpp.cabal | 48 +++--- 19 files changed, 124 insertions(+), 174 deletions(-) create mode 100644 .gitignore create mode 100644 .hsproject create mode 100644 .project delete mode 100644 Examples/EchoClient.hs create mode 100644 Source/Examples/EchoClient.hs rename {Network => Source/Network}/XMPP.hs (100%) rename {Network => Source/Network}/XMPP/Address.hs (100%) rename {Network => Source/Network}/XMPP/SASL.hs (100%) rename {Network => Source/Network}/XMPP/Session.hs (100%) rename {Network => Source/Network}/XMPP/SessionOld.hs (100%) rename {Network => Source/Network}/XMPP/Stanza.hs (100%) rename {Network => Source/Network}/XMPP/Stream.hs (100%) rename {Network => Source/Network}/XMPP/TLS.hs (100%) rename {Network => Source/Network}/XMPP/Types.hs (100%) rename {Network => Source/Network}/XMPP/Utilities.hs (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd8f2f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/dist +/.dist-scion diff --git a/.hsproject b/.hsproject new file mode 100644 index 0000000..95dc96d --- /dev/null +++ b/.hsproject @@ -0,0 +1,4 @@ + + + +ghcCompiler diff --git a/.project b/.project new file mode 100644 index 0000000..90af380 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + pontarius-xmpp + + + + + + net.sf.eclipsefp.haskell.core.builder.HaskellBuilder + + + + + + net.sf.eclipsefp.haskell.core.project.HaskellNature + + diff --git a/Documentation/Software Design Description for Pontarius XMPP 1.0.lyx b/Documentation/Software Design Description for Pontarius XMPP 1.0.lyx index 7c65e09..9d41d9d 100644 --- a/Documentation/Software Design Description for Pontarius XMPP 1.0.lyx +++ b/Documentation/Software Design Description for Pontarius XMPP 1.0.lyx @@ -68,7 +68,7 @@ The Pontarius Project \end_layout \begin_layout Date -15th of June, 2011 +17th of August, 2011 \end_layout \begin_layout Standard diff --git a/Documentation/Software Requirements Specification for Pontarius XMPP.lyx b/Documentation/Software Requirements Specification for Pontarius XMPP.lyx index 0345c2f..d096dff 100644 --- a/Documentation/Software Requirements Specification for Pontarius XMPP.lyx +++ b/Documentation/Software Requirements Specification for Pontarius XMPP.lyx @@ -1006,7 +1006,8 @@ REQ-3 The system shall run under GNU/Linux. \begin_layout Description REQ-4 The system shall work against (at least) the (estimated) most popular - free and open source software XMPP server. + free and open source software XMPP server supporting the features that + we require (such as SCRAM). \end_layout \begin_layout Subsection diff --git a/Examples/EchoClient.hs b/Examples/EchoClient.hs deleted file mode 100644 index 67417f0..0000000 --- a/Examples/EchoClient.hs +++ /dev/null @@ -1,147 +0,0 @@ -{- - -Copyright © 2010-2011 Jon Kristensen. - -This file (EchoClient.hs) illustrates how to connect, authenticate, set a -presence, and echo messages with Pontarius XMPP. The contents of this file may -be used freely, as if it is in the public domain. - -In any state-aware function (function operating in the StateT monad) you can get -and set the current by writing - -@CMS.get >>= \ state -> CMS.put $ state { stateTest = 10 } ...@ - -or, if you prefer the do-notation, - -@do - state <- CMS.get - CMS.put $ state { stateTest = 10 } - ...@ - --} - - -{-# LANGUAGE MultiParamTypeClasses #-} - - -module Examples.EchoClient () where - -import Network.XMPP - -import qualified Control.Monad as CM -import qualified Control.Monad.State as CMS -import qualified Control.Monad.IO.Class as CMIC -import qualified Data.Maybe as DM - - --- Account and server details. - -hostName = "jonkristensen.com" -userName = "pontarius" -serverIdentifier = "jonkristensen.com" -portNumber = 5222 -resource = "echo-client" -password = "" - - --- The client state, containing the required Pontarius XMPP Session object. It --- also contains a dummy integer value to illustrate how client states are used. - -data State = State { stateSession :: Maybe (Session State IO) - , stateTest :: Integer } - -defaultState :: State - -defaultState = State { stateSession = Nothing - , stateTest = 5 } - - -instance ClientState State IO where - putSession st se = st { stateSession = Just se } - - --- This client defines one client handler, and only specifies the --- messageReceived callback. - -clientHandlers = [ClientHandler { messageReceived = Just messageReceived_ - , presenceReceived = Nothing - , iqReceived = Nothing - , sessionTerminated = Nothing }] - - --- The main function sets up the Pontarius XMPP session with the default client --- state and client handler defined above, as well as specifying that the --- sessionCreated function should be called when the session has been created. - -main :: IO () - -main = do - session - defaultState - clientHandlers - sessionCreated - - --- The session has been created. Let's try to open the XMPP stream! - -sessionCreated :: CMS.StateT State IO () - -sessionCreated = do - state <- CMS.get - connect (DM.fromJust $ stateSession state) hostName portNumber - (Just ("", \ x -> True)) (Just (userName, password, Just resource)) - connectCallback - id <- getID (DM.fromJust $ stateSession state) - CMIC.liftIO $ putStrLn $ "Unique ID acquired: " ++ id - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - injectAction (DM.fromJust $ stateSession state) Nothing (do CMIC.liftIO $ putStrLn "Async action!"; return ()) - return () - - --- We have tried to connected, TLS secured and authenticated! - -connectCallback :: ConnectResult -> CMS.StateT State IO () - -connectCallback r = do - state <- CMS.get - case r of - ConnectSuccess _ _ _ -> do - sendPresence (DM.fromJust $ stateSession state) - Presence { presenceID = Nothing - , presenceFrom = Nothing - , presenceTo = Nothing - , presenceXMLLang = Nothing - , presenceType = Available - , presencePayload = [] } - Nothing Nothing Nothing - _ -> do - CMIC.liftIO $ putStrLn "Could not connect." - return () - - --- A message (stanza) has been received. Let's echo it! - -messageReceived_ :: Message -> CMS.StateT State IO Bool - -messageReceived_ m = do - state <- CMS.get - CMIC.liftIO $ putStrLn $ - "Received a message; echoing it! By the way: Internal state is " ++ - (show $ stateTest state) ++ "." - sendMessage (DM.fromJust $ stateSession state) - Message { messageID = messageID m - , messageFrom = Nothing - , messageTo = messageFrom m - , messageXMLLang = Nothing - , messageType = messageType m - , messagePayload = messagePayload m } - Nothing (Just (0, (do CMIC.liftIO $ putStrLn "Timeout!"; return ()))) Nothing - return True diff --git a/Setup.hs b/Setup.hs index e8ef27d..9a994af 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,3 +1,2 @@ import Distribution.Simple - main = defaultMain diff --git a/Source/Examples/EchoClient.hs b/Source/Examples/EchoClient.hs new file mode 100644 index 0000000..a25dd24 --- /dev/null +++ b/Source/Examples/EchoClient.hs @@ -0,0 +1,74 @@ +{- + +Copyright © 2010-2011 Jon Kristensen. + +This file (EchoClient.hs) illustrates how to connect, authenticate, set a +presence, and echo messages with Pontarius XMPP. The contents of this file may +be used freely, as if it is in the public domain. + +-} + + +module Examples.EchoClient () where + +import Network.XMPP + + +-- Account and server details. + +hostName = "jonkristensen.com" +userName = "pontarius" +serverIdentifier = "jonkristensen.com" +portNumber = 5222 +resource = "pontarius" +password = "substrat44" + + +-- The main function initializes Pontarius XMPP and specifies the (XMPPT) +-- actions the be executed, hooking the client into the appropriate events and +-- tries to connect. + +main :: IO () + +main = runXMPPT $ do + hookConnectedEvent onConnectedEvent Nothing + hookMessageEvent onMessageEvent onMessageEventPredicate + hookDisconnectedEvent onDisonnectedEvent Nothing + connect hostName portNumber userName serverIdentifier password (Just resource) + + where + + -- When successfully connected, send a simple presence, and unhook + -- ourselves from further "connected" events. + + onConnectedEvent (Right r) = do + liftIO $ putStrLn $ "Connected with resource: " ++ (show r) + presence simplePresence + return False + + -- When the connection fails, print the error and shut down the XMPP + -- session. + + onConnectedEvent (Left e) = do + liftIO $ putStrLn $ "Could not connect due to the following error:" ++ (show e) + destroy + return True + + -- Predicate that makes sure that the messages processed by + -- onMessageEvent are sent from and to full (not bare) XMPP addresses. + + onMessageEventPredicate = Just (\ m -> return $ and [isJust $ messageFrom m, isJust $ messageTo m]) + + -- Swap the from and to addresses and send the new message. + + onMessageEvent m = do + message $ m { messageFrom = fromJust $ messageTo m + , messageTo = fromJust $ messageFrom m } + return True + + -- When disconnected, print the reason and shut down the XMPP session. + + onDisconnectedEvent r = do + liftIO $ putStrLn $ "Disconnected with the reason: " ++ (show r) + destroy + return True diff --git a/Network/XMPP.hs b/Source/Network/XMPP.hs similarity index 100% rename from Network/XMPP.hs rename to Source/Network/XMPP.hs diff --git a/Network/XMPP/Address.hs b/Source/Network/XMPP/Address.hs similarity index 100% rename from Network/XMPP/Address.hs rename to Source/Network/XMPP/Address.hs diff --git a/Network/XMPP/SASL.hs b/Source/Network/XMPP/SASL.hs similarity index 100% rename from Network/XMPP/SASL.hs rename to Source/Network/XMPP/SASL.hs diff --git a/Network/XMPP/Session.hs b/Source/Network/XMPP/Session.hs similarity index 100% rename from Network/XMPP/Session.hs rename to Source/Network/XMPP/Session.hs diff --git a/Network/XMPP/SessionOld.hs b/Source/Network/XMPP/SessionOld.hs similarity index 100% rename from Network/XMPP/SessionOld.hs rename to Source/Network/XMPP/SessionOld.hs diff --git a/Network/XMPP/Stanza.hs b/Source/Network/XMPP/Stanza.hs similarity index 100% rename from Network/XMPP/Stanza.hs rename to Source/Network/XMPP/Stanza.hs diff --git a/Network/XMPP/Stream.hs b/Source/Network/XMPP/Stream.hs similarity index 100% rename from Network/XMPP/Stream.hs rename to Source/Network/XMPP/Stream.hs diff --git a/Network/XMPP/TLS.hs b/Source/Network/XMPP/TLS.hs similarity index 100% rename from Network/XMPP/TLS.hs rename to Source/Network/XMPP/TLS.hs diff --git a/Network/XMPP/Types.hs b/Source/Network/XMPP/Types.hs similarity index 100% rename from Network/XMPP/Types.hs rename to Source/Network/XMPP/Types.hs diff --git a/Network/XMPP/Utilities.hs b/Source/Network/XMPP/Utilities.hs similarity index 100% rename from Network/XMPP/Utilities.hs rename to Source/Network/XMPP/Utilities.hs diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index e4cb965..f109526 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -1,40 +1,40 @@ -Name: pontarius-xmpp -Version: 0.0.8.0 -Cabal-Version: >= 1.6 -Build-Type: Simple -License: BSD3 -License-File: LICENSE -Copyright: Copyright © 2011, Jon Kristensen -Author: Jon Kristensen, Mahdi Abdinejadi -Maintainer: jon.kristensen@pontarius.org -Stability: alpha -Homepage: http://www.pontarius.org/ -Bug-Reports: mailto:info@pontarius.org +Name: pontarius-xmpp +Version: 0.0.8.0 +Cabal-Version: >= 1.6 +Build-Type: Simple +License: BSD3 +License-File: LICENSE +Copyright: Copyright © 2011, Jon Kristensen +Author: Jon Kristensen, Mahdi Abdinejadi +Maintainer: jon.kristensen@pontarius.org +Stability: alpha +Homepage: http://www.pontarius.org/ +Bug-Reports: mailto:info@pontarius.org -- Package-URL: -Synopsis: A prototyped and incomplete implementation of RFC 6120: +Synopsis: A prototyped and incomplete implementation of RFC 6120: XMPP: Core -Description: A work in progress of an implementation of RFC 6120: XMPP: +Description: A work in progress of an implementation of RFC 6120: XMPP: Core, as well as RFC 6122: XMPP: Address Format and other depending standards. A new version of Pontarius XMPP is released every three weeks. -Category: Network -Tested-With: GHC ==7.0.2 +Category: Network +Tested-With: GHC ==7.0.2 -- Data-Files: -- Data-Dir: -- Extra-Source-Files: -- Extra-Tmp-Files: Library - Exposed-Modules: Network.XMPP - Exposed: True - Build-Depends: base >= 2 && < 5, parsec, enumerator, crypto-api ==0.6.3, + Exposed-Modules: Network.XMPP + Exposed: True + Build-Depends: base >= 2 && < 5, parsec, enumerator, crypto-api ==0.6.3, base64-string, pureMD5, utf8-string, network, xml-types, text, transformers, bytestring, cereal ==0.3.3.0, random, xml-enumerator, tls, tls-extra, containers, mtl, text-icu, stringprep, asn1-data, cryptohash ==0.7.0, time, certificate, ranges, uuid -- Other-Modules: - -- HS-Source-Dirs: + HS-Source-Dirs: Source -- Extensions: -- Build-Tools: -- Buildable: @@ -54,14 +54,14 @@ Library -- Frameworks: Source-Repository head - Type: darcs + Type: darcs -- Module: Location: git://github.com/pontarius/pontarius-xmpp.git -- Subdir: Source-Repository this - Type: darcs + Type: darcs -- Module: Location: git://github.com/pontarius/pontarius-xmpp.git - Tag: 0.0.8.0 - -- Subdir: + Tag: 0.0.8.0 + -- Subdir: \ No newline at end of file