Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
f75116a2
Commit
f75116a2
authored
Feb 07, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #28
parent
4d2510d0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
37 deletions
+57
-37
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
.../kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
+51
-31
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
...rai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
+3
-3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/RequestPacket.kt
...irai/qqandroid/network/protocol/data/jce/RequestPacket.kt
+3
-3
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
View file @
f75116a2
...
...
@@ -304,10 +304,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
input
:
JceInput
)
:
JceDecoder
(
input
)
{
override
fun
endStructure
(
desc
:
SerialDescriptor
)
{
while
(
input
.
input
.
canRead
()
&&
input
.
peakHeadOrNull
()
?.
type
!=
STRUCT_END
)
{
input
.
readHeadOrNull
()
?:
return
}
input
.
readHeadOrNull
()
}
}
...
...
@@ -403,7 +400,8 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
@Suppress
(
"UNCHECKED_CAST"
)
override
fun
<
T
:
Any
>
decodeNullableSerializableValue
(
deserializer
:
DeserializationStrategy
<
T
?
>):
T
?
{
// // println("decodeNullableSerializableValue: ${deserializer::class.qualifiedName}")
//
//println("decodeNullableSerializableValue: ${deserializer::class.qualifiedName}")
if
(
deserializer
is
NullReader
)
{
return
null
}
...
...
@@ -467,7 +465,12 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
if
(
input
.
skipToTagOrNull
(
tag
)
{
check
(
it
.
type
==
STRUCT_BEGIN
)
{
"type mismatch: ${it.type}"
}
//popTag()
return
deserializer
.
deserialize
(
JceStructReader
(
input
))
return
deserializer
.
deserialize
(
JceStructReader
(
input
)).
also
{
while
(
input
.
input
.
canRead
()
&&
input
.
peakHeadOrNull
()
?.
type
!=
STRUCT_END
)
{
input
.
readHeadOrNull
()
?:
return
@
also
}
//input.readHeadOrNull()
}
}
==
null
&&
isTagOptional
(
tag
))
{
return
null
}
else
error
(
"cannot find tag $tag"
)
...
...
@@ -540,52 +543,52 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
return
currentJceHead
}
fun
readBoolean
(
tag
:
Int
):
Boolean
=
readBooleanOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readByte
(
tag
:
Int
):
Byte
=
readByteOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readShort
(
tag
:
Int
):
Short
=
readShortOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readInt
(
tag
:
Int
):
Int
=
readIntOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readLong
(
tag
:
Int
):
Long
=
readLongOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readFloat
(
tag
:
Int
):
Float
=
readFloatOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readDouble
(
tag
:
Int
):
Double
=
readDoubleOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readBoolean
(
tag
:
Int
):
Boolean
=
readBooleanOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readByte
(
tag
:
Int
):
Byte
=
readByteOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readShort
(
tag
:
Int
):
Short
=
readShortOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readInt
(
tag
:
Int
):
Int
=
readIntOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readLong
(
tag
:
Int
):
Long
=
readLongOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readFloat
(
tag
:
Int
):
Float
=
readFloatOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readDouble
(
tag
:
Int
):
Double
=
readDoubleOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readString
(
tag
:
Int
):
String
=
readStringOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readString
(
tag
:
Int
):
String
=
readStringOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readByteArray
(
tag
:
Int
):
ByteArray
=
readByteArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readShortArray
(
tag
:
Int
):
ShortArray
=
readShortArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readLongArray
(
tag
:
Int
):
LongArray
=
readLongArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readFloatArray
(
tag
:
Int
):
FloatArray
=
readFloatArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readDoubleArray
(
tag
:
Int
):
DoubleArray
=
readDoubleArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readIntArray
(
tag
:
Int
):
IntArray
=
readIntArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readBooleanArray
(
tag
:
Int
):
BooleanArray
=
readBooleanArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag"
)
fun
readByteArray
(
tag
:
Int
):
ByteArray
=
readByteArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readShortArray
(
tag
:
Int
):
ShortArray
=
readShortArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readLongArray
(
tag
:
Int
):
LongArray
=
readLongArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readFloatArray
(
tag
:
Int
):
FloatArray
=
readFloatArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readDoubleArray
(
tag
:
Int
):
DoubleArray
=
readDoubleArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readIntArray
(
tag
:
Int
):
IntArray
=
readIntArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readBooleanArray
(
tag
:
Int
):
BooleanArray
=
readBooleanArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag
, currentJceHead=$currentJceHead
"
)
fun
readShortArrayOrNull
(
tag
:
Int
):
ShortArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
ShortArray
(
readInt
(
0
))
{
readShort
(
0
)
}
}
fun
readDoubleArrayOrNull
(
tag
:
Int
):
DoubleArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
DoubleArray
(
readInt
(
0
))
{
readDouble
(
0
)
}
}
fun
readFloatArrayOrNull
(
tag
:
Int
):
FloatArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
FloatArray
(
readInt
(
0
))
{
readFloat
(
0
)
}
}
fun
readIntArrayOrNull
(
tag
:
Int
):
IntArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
IntArray
(
readInt
(
0
))
{
readInt
(
0
)
}
}
fun
readLongArrayOrNull
(
tag
:
Int
):
LongArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
LongArray
(
readInt
(
0
))
{
readLong
(
0
)
}
}
fun
readBooleanArrayOrNull
(
tag
:
Int
):
BooleanArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch"
}
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch
, expected=9(List), got=${it.type}
"
}
BooleanArray
(
readInt
(
0
))
{
readBoolean
(
0
)
}
}
...
...
@@ -595,10 +598,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
SIMPLE_LIST
->
{
val
head
=
readHead
()
readHead
()
check
(
head
.
type
.
toInt
()
==
0
)
{
"type mismatch"
}
check
(
head
.
type
.
toInt
()
==
0
)
{
"type mismatch
, expected=0(Byte), got=${head.type}
"
}
input
.
readBytes
(
readInt
(
0
))
}
else
->
error
(
"type mismatch"
)
else
->
error
(
"type mismatch
, expected=9(List), got=${it.type}
"
)
}
}
...
...
@@ -612,7 +615,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
is
Float
->
readFloat
(
tag
)
is
Double
->
readDouble
(
tag
)
is
String
->
readString
(
tag
)
else
->
error
(
"unsupported type"
)
else
->
error
(
"unsupported type
: ${default.getClassName()}
"
)
}
as
T
fun
readStringOrNull
(
tag
:
Int
):
String
?
=
skipToTagOrNull
(
tag
)
{
head
->
...
...
@@ -830,6 +833,23 @@ inline class JceHead(private val value: Long) {
val
type
:
Byte
get
()
=
value
.
toUInt
().
toByte
()
override
fun
toString
():
String
{
return
"JceHead(tag=$tag, type=$type)"
val
typeString
=
when
(
type
)
{
Jce
.
BYTE
->
"Byte"
Jce
.
DOUBLE
->
"Double"
Jce
.
FLOAT
->
"Float"
Jce
.
INT
->
"Int"
Jce
.
LIST
->
"List"
Jce
.
LONG
->
"Long"
Jce
.
MAP
->
"Map"
Jce
.
SHORT
->
"Short"
Jce
.
SIMPLE_LIST
->
"SimpleList"
Jce
.
STRING1
->
"String1"
Jce
.
STRING4
->
"String4"
Jce
.
STRUCT_BEGIN
->
"StructBegin"
Jce
.
STRUCT_END
->
"StructEnd"
Jce
.
ZERO_TYPE
->
"Zero"
else
->
error
(
"unreachable"
)
}
return
"JceHead(tag=$tag, type=$type($typeString))"
}
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
View file @
f75116a2
...
...
@@ -9,7 +9,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
@Suppress
(
"ArrayInDataClass"
)
@Serializable
internal
data class
RequestPushNotify
(
@SerialId
(
0
)
val
uin
:
Long
=
0L
,
@SerialId
(
0
)
val
uin
:
Long
?
=
0L
,
@SerialId
(
1
)
val
ctype
:
Byte
=
0
,
@SerialId
(
2
)
val
strService
:
String
?,
@SerialId
(
3
)
val
strCmd
:
String
?,
...
...
@@ -46,8 +46,8 @@ internal data class MsgInfo(
@SerialId
(
15
)
val
vRemarkOfSender
:
ByteArray
?,
@SerialId
(
16
)
val
strFromMobile
:
String
?,
@SerialId
(
17
)
val
strFromName
:
String
?,
@SerialId
(
18
)
val
vNickName
:
List
<
String
>?,
@SerialId
(
19
)
val
stC2CTmpMsgHead
:
TempMsgHead
?
@SerialId
(
18
)
val
vNickName
:
List
<
String
>?
//
,
//
@SerialId(19) val stC2CTmpMsgHead: TempMsgHead?
)
:
JceStruct
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/RequestPacket.kt
View file @
f75116a2
...
...
@@ -16,9 +16,9 @@ internal class RequestPacket(
@SerialId
(
5
)
val
sServantName
:
String
=
""
,
@SerialId
(
6
)
val
sFuncName
:
String
=
""
,
@SerialId
(
7
)
val
sBuffer
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
8
)
val
iTimeout
:
Int
=
0
,
@SerialId
(
9
)
val
context
:
Map
<
String
,
String
>
=
EMPTY_MAP
,
@SerialId
(
10
)
val
status
:
Map
<
String
,
String
>
=
EMPTY_MAP
@SerialId
(
8
)
val
iTimeout
:
Int
?
=
0
,
@SerialId
(
9
)
val
context
:
Map
<
String
,
String
>
?
=
EMPTY_MAP
,
@SerialId
(
10
)
val
status
:
Map
<
String
,
String
>
?
=
EMPTY_MAP
)
:
JceStruct
@Serializable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment