Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-wayland
Commits
ab47fd08
Commit
ab47fd08
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Check if an object is valid when sending a message; add show instance
parent
846d7969
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Quasar/Wayland/Protocol/Core.hs
+14
-2
14 additions, 2 deletions
src/Quasar/Wayland/Protocol/Core.hs
with
14 additions
and
2 deletions
src/Quasar/Wayland/Protocol/Core.hs
+
14
−
2
View file @
ab47fd08
...
...
@@ -234,9 +234,14 @@ data Side = Client | Server
data
Object
s
i
=
IsInterfaceSide
s
i
=>
Object
GenericObjectId
(
Callback
s
i
)
instance
IsInterface
i
=>
Show
(
Object
s
i
)
where
show
=
showObject
class
IsObject
a
where
objectId
::
a
->
GenericObjectId
objectInterfaceName
::
a
->
String
showObject
::
a
->
String
showObject
object
=
objectInterfaceName
object
<>
"@"
<>
show
(
objectId
object
)
class
IsObjectSide
a
where
describeUpMessage
::
a
->
Opcode
->
BSL
.
ByteString
->
String
...
...
@@ -294,7 +299,7 @@ invalidOpcode object opcode =
showObjectMessage
::
(
IsObject
a
,
IsMessage
b
)
=>
a
->
b
->
String
showObjectMessage
object
message
=
objectInterfaceName
object
<>
"@"
<>
show
(
o
bject
Id
object
)
<>
"."
<>
show
message
show
O
bject
object
<>
"."
<>
show
message
data
Callback
s
i
=
forall
a
.
IsInterfaceHandler
s
i
a
=>
Callback
a
...
...
@@ -312,7 +317,6 @@ internalFnCallback :: IsInterfaceSide s i => (Object s i -> Down s i -> Protocol
internalFnCallback
=
Callback
.
FnCallback
{-# WARNING traceCallback "Trace." #-}
-- | The 'traceCallback' callback outputs a trace for every received message, before passing the message to the callback
-- argument.
--
...
...
@@ -344,6 +348,10 @@ data ProtocolException = ProtocolException String
deriving
stock
Show
deriving
anyclass
Exception
data
ProtocolUsageError
=
ProtocolUsageError
String
deriving
stock
Show
deriving
anyclass
Exception
data
MaximumIdReached
=
MaximumIdReached
deriving
stock
Show
deriving
anyclass
Exception
...
...
@@ -521,6 +529,9 @@ newObjectFromId (NewId oId) callback = do
-- | Sends a message without checking any ids or creating proxy objects objects. (TODO)
sendMessage
::
forall
s
i
.
IsInterfaceSide
s
i
=>
Object
s
i
->
Up
s
i
->
ProtocolM
s
()
sendMessage
object
message
=
do
isActiveObject
<-
HM
.
member
oId
<$>
readProtocolVar
(
.
objectsVar
)
unless
isActiveObject
$
throwM
$
ProtocolUsageError
$
"Tried to send message on an invalid object: "
<>
show
object
(
opcode
,
pairs
)
<-
putUp
object
message
let
(
putBodyParts
,
partLengths
)
=
unzip
pairs
let
putBody
=
mconcat
putBodyParts
...
...
@@ -529,6 +540,7 @@ sendMessage object message = do
traceM
$
"-> "
<>
showObjectMessage
object
message
sendRawMessage
$
messageWithHeader
opcode
body
where
oId
=
objectId
object
messageWithHeader
::
Opcode
->
BSL
.
ByteString
->
Put
messageWithHeader
opcode
body
=
do
putWord32host
objectIdWord
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment