diff options
Diffstat (limited to 'src/Network/Tox/Crypto')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 17 | ||||
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 10 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index fabbf21d..d8ba19eb 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -241,6 +241,23 @@ data ViewSnapshot = ViewSnapshot | |||
241 | , vGroups :: Map.Map GroupChatId (Set.Set SockAddr) | 241 | , vGroups :: Map.Map GroupChatId (Set.Set SockAddr) |
242 | } | 242 | } |
243 | 243 | ||
244 | instance Serialize ViewSnapshot where | ||
245 | get = ViewSnapshot <$> get <*> get <*> get <*> get <*> get | ||
246 | <*> get <*> get <*> get <*> get <*> get <*> (pure Map.empty) | ||
247 | put (ViewSnapshot nick status statusmsg typing nospam | ||
248 | nick' status' statusmsg' typing' nospam' grps) | ||
249 | = do | ||
250 | put nick | ||
251 | put status | ||
252 | put statusmsg | ||
253 | put typing | ||
254 | put nospam | ||
255 | put nick' | ||
256 | put status' | ||
257 | put statusmsg' | ||
258 | put typing' | ||
259 | put nospam' | ||
260 | |||
244 | -- | Take snapshot of SessionView | 261 | -- | Take snapshot of SessionView |
245 | -- | 262 | -- |
246 | -- This is useful for storing the context of | 263 | -- This is useful for storing the context of |
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs index ea8565b2..68e3d8e1 100644 --- a/src/Network/Tox/Crypto/Transport.hs +++ b/src/Network/Tox/Crypto/Transport.hs | |||
@@ -235,8 +235,18 @@ instance Serialize CryptoData where | |||
235 | -- The Enum instance on 'UserStatus' is not arbitrary. It corresponds | 235 | -- The Enum instance on 'UserStatus' is not arbitrary. It corresponds |
236 | -- to on-the-wire id numbers. | 236 | -- to on-the-wire id numbers. |
237 | data UserStatus = Online | Away | Busy deriving (Show,Read,Eq,Ord,Enum) | 237 | data UserStatus = Online | Away | Busy deriving (Show,Read,Eq,Ord,Enum) |
238 | instance Serialize UserStatus where | ||
239 | get = do | ||
240 | x <- get :: Get Word8 | ||
241 | return (toEnum8 x) | ||
242 | put x = put (fromEnum8 x) | ||
238 | 243 | ||
239 | data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum) | 244 | data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum) |
245 | instance Serialize TypingStatus where | ||
246 | get = do | ||
247 | x <- get :: Get Word8 | ||
248 | return (toEnum8 x) | ||
249 | put x = put (fromEnum8 x :: Word8) | ||
240 | 250 | ||
241 | unpadCryptoMsg :: CryptoMessage -> CryptoMessage | 251 | unpadCryptoMsg :: CryptoMessage -> CryptoMessage |
242 | unpadCryptoMsg x@(TwoByte Padding (toEnum8 -> mid)) | 252 | unpadCryptoMsg x@(TwoByte Padding (toEnum8 -> mid)) |