diff --git a/Network/XMPP/Stream.hs b/Network/XMPP/Stream.hs index f905103..7f5c430 100644 --- a/Network/XMPP/Stream.hs +++ b/Network/XMPP/Stream.hs @@ -198,9 +198,7 @@ presenceToXML p = "" ++ Nothing -> "" type' :: String - type' = case presenceType p of - Available -> "" - t -> " type='" ++ (presenceTypeToString t) ++ "'" + type' = " type='" ++ (presenceType p) ++ "'" iqToXML :: IQ -> String iqToXML (IQReq (IQGet { iqRequestID = i, iqRequestPayload = p, iqRequestFrom = f, iqRequestTo = t })) = @@ -287,9 +285,7 @@ messageToXML Message { messageID = i, messageFrom = f, messageTo = t, messagePay Nothing -> "" type' :: String - type' = case ty of - Normal -> "" - t -> " type='" ++ (messageTypeToString t) ++ "'" + type' = " type='" ++ ty ++ "'" parseIQ :: Element -> IQ @@ -351,8 +347,8 @@ parsePresence e = Presence idAttr fromAttr toAttr Nothing typeAttr (elementChild typeAttr :: PresenceType typeAttr = case attributeText typeName e of - Just t -> stringToPresenceType $ DT.unpack t - Nothing -> Available + Just t -> DT.unpack t + Nothing -> "" fromAttr :: Maybe Address fromAttr = case attributeText fromName e of @@ -388,8 +384,8 @@ parseMessage e = Message idAttr fromAttr toAttr Nothing typeAttr (elementChildre typeAttr :: MessageType typeAttr = case attributeText typeName e of - Just t -> stringToMessageType $ DT.unpack t - Nothing -> Normal + Just t -> DT.unpack t + Nothing -> "" fromAttr :: Maybe Address fromAttr = case attributeText fromName e of @@ -417,51 +413,3 @@ parseMessage e = Message idAttr fromAttr toAttr Nothing typeAttr (elementChildre idName :: Name idName = fromString "id" - --- stringToPresenceType "available" = Available --- stringToPresenceType "away" = Away --- stringToPresenceType "chat" = Chat --- stringToPresenceType "dnd" = DoNotDisturb --- stringToPresenceType "xa" = ExtendedAway - -stringToPresenceType "available" = Available -- TODO: Some client sent this - -stringToPresenceType "probe" = Probe --- stringToPresenceType "error" = PresenceError -- TODO: Special case - -stringToPresenceType "unavailable" = Unavailable -stringToPresenceType "subscribe" = Subscribe -stringToPresenceType "subscribed" = Subscribed -stringToPresenceType "unsubscribe" = Unsubscribe -stringToPresenceType "unsubscribed" = Unsubscribed - --- presenceTypeToString Available = "available" - --- presenceTypeToString Away = "away" --- presenceTypeToString Chat = "chat" --- presenceTypeToString DoNotDisturb = "dnd" --- presenceTypeToString ExtendedAway = "xa" - -presenceTypeToString Unavailable = "unavailable" - -presenceTypeToString Probe = "probe" --- presenceTypeToString PresenceError = "error" -- TODO: Special case - -presenceTypeToString Subscribe = "subscribe" -presenceTypeToString Subscribed = "subscribed" -presenceTypeToString Unsubscribe = "unsubscribe" -presenceTypeToString Unsubscribed = "unsubscribed" - -stringToMessageType "chat" = Chat -stringToMessageType "error" = Error -stringToMessageType "groupchat" = Groupchat -stringToMessageType "headline" = Headline -stringToMessageType "normal" = Normal -stringToMessageType s = OtherMessageType s - -messageTypeToString Chat = "chat" -messageTypeToString Error = "error" -messageTypeToString Groupchat = "groupchat" -messageTypeToString Headline = "headline" -messageTypeToString Normal = "normal" -messageTypeToString (OtherMessageType s) = s diff --git a/Network/XMPP/Types.hs b/Network/XMPP/Types.hs index c06a854..9ebea09 100644 --- a/Network/XMPP/Types.hs +++ b/Network/XMPP/Types.hs @@ -185,16 +185,7 @@ data Message = Message { messageID :: Maybe StanzaID deriving (Eq, Show) --- | --- @MessageType@ holds XMPP message types as defined in XMPP-IM. @Normal@ is the --- default message type. - -data MessageType = Chat | - Error | - Groupchat | - Headline | - Normal | - OtherMessageType String deriving (Eq, Show) +type MessageType = String -- | @@ -215,19 +206,7 @@ data Presence = Presence { presenceID :: Maybe StanzaID deriving (Eq, Show) --- | --- @PresenceType@ holds XMPP presence types. When a presence type is not --- provided, we assign the @PresenceType@ value @Available@. - -data PresenceType = Subscribe | -- ^ Sender wants to subscribe to presence - Subscribed | -- ^ Sender has approved the subscription - Unsubscribe | -- ^ Sender is unsubscribing from presence - Unsubscribed | -- ^ Sender has denied or cancelled a - -- subscription - Probe | -- ^ Sender requests current presence; - -- should only be used by servers - Available | -- ^ Sender did not specify a type attribute - Unavailable deriving (Eq, Show) +type PresenceType = String -- |