diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 17 | ||||
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 10 | ||||
-rw-r--r-- | src/Network/Tox/NodeId.hs | 6 |
3 files changed, 33 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)) |
diff --git a/src/Network/Tox/NodeId.hs b/src/Network/Tox/NodeId.hs index f9cf22a8..e3c6fb36 100644 --- a/src/Network/Tox/NodeId.hs +++ b/src/Network/Tox/NodeId.hs | |||
@@ -498,6 +498,12 @@ instance OnionPacket 3 where mkOnion = OnionResponse3 | |||
498 | data NoSpam = NoSpam !Word32 !(Maybe Word16) | 498 | data NoSpam = NoSpam !Word32 !(Maybe Word16) |
499 | deriving (Eq,Ord,Show) | 499 | deriving (Eq,Ord,Show) |
500 | 500 | ||
501 | instance Serialize NoSpam where | ||
502 | get = NoSpam <$> get <*> get | ||
503 | put (NoSpam w32 w16) = do | ||
504 | put w32 | ||
505 | put w16 | ||
506 | |||
501 | -- Utilizes Data.Serialize format for Word32 nospam and Word16 checksum. | 507 | -- Utilizes Data.Serialize format for Word32 nospam and Word16 checksum. |
502 | instance Read NoSpam where | 508 | instance Read NoSpam where |
503 | readsPrec d s = case break isSpace s of | 509 | readsPrec d s = case break isSpace s of |