Browse Source

configured the project for eclipsefp and committed it "as is"

master
jonkri 14 years ago
parent
commit
02e4a7819e
  1. 2
      .gitignore
  2. 4
      .hsproject
  3. 17
      .project
  4. 2
      Documentation/Software Design Description for Pontarius XMPP 1.0.lyx
  5. 3
      Documentation/Software Requirements Specification for Pontarius XMPP.lyx
  6. 147
      Examples/EchoClient.hs
  7. 1
      Setup.hs
  8. 74
      Source/Examples/EchoClient.hs
  9. 0
      Source/Network/XMPP.hs
  10. 0
      Source/Network/XMPP/Address.hs
  11. 0
      Source/Network/XMPP/SASL.hs
  12. 0
      Source/Network/XMPP/Session.hs
  13. 0
      Source/Network/XMPP/SessionOld.hs
  14. 0
      Source/Network/XMPP/Stanza.hs
  15. 0
      Source/Network/XMPP/Stream.hs
  16. 0
      Source/Network/XMPP/TLS.hs
  17. 0
      Source/Network/XMPP/Types.hs
  18. 0
      Source/Network/XMPP/Utilities.hs
  19. 48
      pontarius-xmpp.cabal

2
.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
/dist
/.dist-scion

4
.hsproject

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<haskellProject>
<sourcePath path="Source"/>
<compiler>ghcCompiler</compiler></haskellProject>

17
.project

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>pontarius-xmpp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>net.sf.eclipsefp.haskell.core.builder.HaskellBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>net.sf.eclipsefp.haskell.core.project.HaskellNature</nature>
</natures>
</projectDescription>

2
Documentation/Software Design Description for Pontarius XMPP 1.0.lyx

@ -68,7 +68,7 @@ The Pontarius Project @@ -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

3
Documentation/Software Requirements Specification for Pontarius XMPP.lyx

@ -1006,7 +1006,8 @@ REQ-3 The system shall run under GNU/Linux. @@ -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

147
Examples/EchoClient.hs

@ -1,147 +0,0 @@ @@ -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

1
Setup.hs

@ -1,3 +1,2 @@ @@ -1,3 +1,2 @@
import Distribution.Simple
main = defaultMain

74
Source/Examples/EchoClient.hs

@ -0,0 +1,74 @@ @@ -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

0
Network/XMPP.hs → Source/Network/XMPP.hs

0
Network/XMPP/Address.hs → Source/Network/XMPP/Address.hs

0
Network/XMPP/SASL.hs → Source/Network/XMPP/SASL.hs

0
Network/XMPP/Session.hs → Source/Network/XMPP/Session.hs

0
Network/XMPP/SessionOld.hs → Source/Network/XMPP/SessionOld.hs

0
Network/XMPP/Stanza.hs → Source/Network/XMPP/Stanza.hs

0
Network/XMPP/Stream.hs → Source/Network/XMPP/Stream.hs

0
Network/XMPP/TLS.hs → Source/Network/XMPP/TLS.hs

0
Network/XMPP/Types.hs → Source/Network/XMPP/Types.hs

0
Network/XMPP/Utilities.hs → Source/Network/XMPP/Utilities.hs

48
pontarius-xmpp.cabal

@ -1,40 +1,40 @@ @@ -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 @@ -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:
Loading…
Cancel
Save