Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Nheko Reborn
nheko
Commits
24dd76ee
Commit
24dd76ee
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Parse unsigned key
parent
9cf5bf38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/events/Event.h
+26
-0
26 additions, 0 deletions
include/events/Event.h
src/events/Event.cc
+26
-0
26 additions, 0 deletions
src/events/Event.cc
tests/events.cc
+129
-117
129 additions, 117 deletions
tests/events.cc
with
181 additions
and
117 deletions
include/events/Event.h
+
26
−
0
View file @
24dd76ee
...
...
@@ -60,6 +60,24 @@ isMessageEvent(EventType type);
bool
isStateEvent
(
EventType
type
);
class
UnsignedData
:
public
Deserializable
,
public
Serializable
{
public:
double
age
()
const
{
return
age_
;
}
QString
transactionId
()
const
{
return
transaction_id_
;
}
bool
isEmpty
()
const
{
return
age_
<=
0
&&
transaction_id_
.
isEmpty
();
}
void
deserialize
(
const
QJsonValue
&
data
)
override
;
QJsonObject
serialize
()
const
override
;
private
:
double
age_
=
0
;
QString
transaction_id_
;
};
template
<
class
Content
>
class
Event
:
public
Deserializable
...
...
@@ -68,6 +86,7 @@ class Event
public:
Content
content
()
const
;
EventType
eventType
()
const
;
UnsignedData
unsignedData
()
const
{
return
unsignedData_
;
}
void
deserialize
(
const
QJsonValue
&
data
)
override
;
QJsonObject
serialize
()
const
override
;
...
...
@@ -75,6 +94,7 @@ public:
private
:
Content
content_
;
EventType
type_
;
UnsignedData
unsignedData_
;
};
template
<
class
Content
>
...
...
@@ -102,6 +122,9 @@ Event<Content>::deserialize(const QJsonValue &data)
content_
.
deserialize
(
object
.
value
(
"content"
));
type_
=
extractEventType
(
object
);
if
(
object
.
contains
(
"unsigned"
))
unsignedData_
.
deserialize
(
object
.
value
(
"unsigned"
));
}
template
<
class
Content
>
...
...
@@ -151,6 +174,9 @@ Event<Content>::serialize() const
object
[
"content"
]
=
content_
.
serialize
();
if
(
!
unsignedData_
.
isEmpty
())
object
[
"unsigned"
]
=
unsignedData_
.
serialize
();
return
object
;
}
}
// namespace events
...
...
This diff is collapsed.
Click to expand it.
src/events/Event.cc
+
26
−
0
View file @
24dd76ee
...
...
@@ -78,3 +78,29 @@ matrix::events::isMessageEvent(EventType type)
{
return
type
==
EventType
::
RoomMessage
;
}
void
matrix
::
events
::
UnsignedData
::
deserialize
(
const
QJsonValue
&
data
)
{
if
(
!
data
.
isObject
())
throw
DeserializationException
(
"UnsignedData is not a JSON object"
);
auto
object
=
data
.
toObject
();
transaction_id_
=
object
.
value
(
"transaction_id"
).
toString
();
age_
=
object
.
value
(
"age"
).
toDouble
();
}
QJsonObject
matrix
::
events
::
UnsignedData
::
serialize
()
const
{
QJsonObject
object
;
if
(
!
transaction_id_
.
isEmpty
())
object
[
"transaction_id"
]
=
transaction_id_
;
if
(
age_
>
0
)
object
[
"age"
]
=
age_
;
return
object
;
}
This diff is collapsed.
Click to expand it.
tests/events.cc
+
129
−
117
View file @
24dd76ee
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