diff options
Diffstat (limited to 'Presence/Stanza/Build.hs')
-rw-r--r-- | Presence/Stanza/Build.hs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Presence/Stanza/Build.hs b/Presence/Stanza/Build.hs index e02684f5..16552428 100644 --- a/Presence/Stanza/Build.hs +++ b/Presence/Stanza/Build.hs | |||
@@ -19,24 +19,34 @@ import LockedChan | |||
19 | import Stanza.Types | 19 | import Stanza.Types |
20 | 20 | ||
21 | makeMessage :: Text -> Text -> Text -> Text -> IO Stanza | 21 | makeMessage :: Text -> Text -> Text -> Text -> IO Stanza |
22 | makeMessage namespace from to bod = | 22 | makeMessage namespace from to bod = makeMessageEx namespace from to NormalMsg bod |
23 | |||
24 | makeMessageEx :: Text -> Text -> Text -> MessageType -> Text -> IO Stanza | ||
25 | makeMessageEx namespace from to msgtyp bod = | ||
23 | stanzaFromList typ | 26 | stanzaFromList typ |
24 | $ [ EventBeginElement (mkname namespace "message") | 27 | $ [ EventBeginElement (mkname namespace "message") |
25 | [ attr "from" from | 28 | $ addMessageType msgtyp |
26 | , attr "to" to | 29 | [ attr "from" from |
27 | ] | 30 | , attr "to" to |
31 | ] | ||
28 | , EventBeginElement (mkname namespace "body") [] | 32 | , EventBeginElement (mkname namespace "body") [] |
29 | , EventContent (ContentText bod) | 33 | , EventContent (ContentText bod) |
30 | , EventEndElement (mkname namespace "body") | 34 | , EventEndElement (mkname namespace "body") |
31 | , EventEndElement (mkname namespace "message") ] | 35 | , EventEndElement (mkname namespace "message") ] |
32 | where | 36 | where |
33 | typ = Message { msgThread = Nothing | 37 | typ = Message { msgThread = Nothing |
34 | , msgLangMap = [("", lsm)] | 38 | , msgLangMap = [("", lsm)] |
39 | , msgType = msgtyp | ||
35 | } | 40 | } |
36 | lsm = LangSpecificMessage | 41 | lsm = LangSpecificMessage |
37 | { msgBody = Just bod | 42 | { msgBody = Just bod |
38 | , msgSubject = Nothing } | 43 | , msgSubject = Nothing } |
39 | 44 | ||
45 | addMessageType ChatMsg attrs = ("type",[ContentText "chat"]) : attrs | ||
46 | addMessageType GroupChatMsg attrs = ("type",[ContentText "groupchat"]) : attrs | ||
47 | addMessageType HeadlineMsg attrs = ("type",[ContentText "headline"]) : attrs | ||
48 | addMessageType _ attrs = attrs | ||
49 | |||
40 | makeInformSubscription :: Text -> Text -> Text -> Bool -> IO Stanza | 50 | makeInformSubscription :: Text -> Text -> Text -> Bool -> IO Stanza |
41 | makeInformSubscription namespace from to approved = | 51 | makeInformSubscription namespace from to approved = |
42 | stanzaFromList (PresenceInformSubscription approved) | 52 | stanzaFromList (PresenceInformSubscription approved) |