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
e71cb765
Commit
e71cb765
authored
Jan 28, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GetFriendList
parent
23e6ce4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
255 additions
and
2 deletions
+255
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/friend/FriendListPacket.kt
...ndroid/network/protocol/packet/friend/FriendListPacket.kt
+2
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/friend/data/GetFriendListRequest.kt
...twork/protocol/packet/friend/data/GetFriendListRequest.kt
+30
-0
mirai-core-qqandroid/src/jvmTest/kotlin/test/DataClassGenerator.kt
...e-qqandroid/src/jvmTest/kotlin/test/DataClassGenerator.kt
+83
-0
mirai-core-qqandroid/src/jvmTest/kotlin/test/JceDataClassGenerator.kt
...qandroid/src/jvmTest/kotlin/test/JceDataClassGenerator.kt
+140
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/friend/
GetFriendListReques
t.kt
→
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/friend/
FriendListPacke
t.kt
View file @
e71cb765
...
@@ -6,8 +6,8 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
...
@@ -6,8 +6,8 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
internal
object
GetFriendListReques
t
:
internal
object
FriendListPacke
t
:
PacketFactory
<
GetFriendListReques
t
.
GetFriendListResponse
>(
"friendlist.GetFriendListReq"
)
{
PacketFactory
<
FriendListPacke
t
.
GetFriendListResponse
>(
"friendlist.GetFriendListReq"
)
{
class
GetFriendListResponse
()
:
Packet
class
GetFriendListResponse
()
:
Packet
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/friend/data/GetFriendListRequest.kt
0 → 100644
View file @
e71cb765
package
net.mamoe.mirai.qqandroid.network.protocol.packet.friend.data
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.qqandroid.io.JceStruct
@Serializable
internal
class
GetFriendListReq
(
@SerialId
(
0
)
val
reqtype
:
Int
?
=
null
,
@SerialId
(
1
)
val
ifReflush
:
Byte
?
=
null
,
@SerialId
(
2
)
val
uin
:
Long
?
=
null
,
@SerialId
(
3
)
val
startIndex
:
Short
?
=
null
,
@SerialId
(
4
)
val
getfriendCount
:
Short
?
=
null
,
@SerialId
(
5
)
val
groupid
:
Byte
?
=
null
,
@SerialId
(
6
)
val
ifGetGroupInfo
:
Byte
?
=
null
,
@SerialId
(
7
)
val
groupstartIndex
:
Byte
?
=
null
,
@SerialId
(
8
)
val
getgroupCount
:
Byte
?
=
null
,
@SerialId
(
9
)
val
ifGetMSFGroup
:
Byte
?
=
null
,
@SerialId
(
10
)
val
ifShowTermType
:
Byte
?
=
null
,
@SerialId
(
11
)
val
version
:
Long
?
=
null
,
@SerialId
(
12
)
val
uinList
:
List
<
Long
>?
=
null
,
@SerialId
(
13
)
val
eAppType
:
Int
=
0
,
@SerialId
(
14
)
val
ifGetDOVId
:
Byte
?
=
null
,
@SerialId
(
15
)
val
ifGetBothFlag
:
Byte
?
=
null
,
@SerialId
(
16
)
val
vec0xd50Req
:
ByteArray
?
=
null
,
@SerialId
(
17
)
val
vec0xd6bReq
:
ByteArray
?
=
null
,
@SerialId
(
18
)
val
vecSnsTypelist
:
List
<
Long
>?
=
null
)
:
JceStruct
mirai-core-qqandroid/src/jvmTest/kotlin/test/DataClassGenerator.kt
0 → 100644
View file @
e71cb765
package
test
import
kotlinx.coroutines.channels.Channel
import
java.lang.StringBuilder
import
java.util.*
import
java.util.concurrent.BlockingQueue
import
kotlin.concurrent.thread
fun
main
(){
val
inputs
=
LinkedList
<
String
>()
thread
{
while
(
true
){
val
x
=
readLine
()
if
(
x
!=
null
)
inputs
.
offer
(
x
)
}
}
tailrec
fun
getNext
():
String
{
val
x
=
inputs
.
poll
()
if
(
x
==
null
){
Thread
.
sleep
(
100
)
return
getNext
()
}
return
x
;
}
fun
getAll
():
String
{
val
b
=
StringBuilder
(
getNext
())
Thread
.
sleep
(
500
)
while
(
true
){
val
c
=
inputs
.
poll
();
if
(
c
===
null
)
break
;
b
.
append
(
"\n"
).
append
(
c
)
}
return
b
.
toString
();
}
while
(
true
){
println
(
"-proto || -jce"
)
val
x
=
getNext
()
if
(
x
.
contains
(
"proto"
,
true
)){
//proto
println
(
"..Copy file content below, after each file is submited, click enter, after all file are in, input \'end'\'"
)
val
y
=
mutableListOf
<
String
>()
while
(
true
){
val
z
=
getAll
()
if
(
z
.
toLowerCase
()
==
"end"
||
z
.
toLowerCase
()
==
"end\n"
){
println
(
"received file content: "
+
y
.
size
+
", start generating ProtoBuf"
)
break
;
}
y
.
add
(
z
)
println
(
"received, "
)
}
println
(
"======================>protoBuf output<==========================="
)
println
()
println
()
println
(
y
.
map
{
it
.
generateProtoBufDataClass
()
}.
toMutableList
().
arrangeClasses
().
joinToString
(
"\n\n"
));
println
()
println
()
println
(
"======================>protoBuf output<==========================="
)
}
if
(
x
.
contains
(
"jce"
,
true
)){
println
(
"..Copy the WHOLE file below"
)
while
(
true
){
val
z
=
getAll
()
println
(
"======================>JCE output<==========================="
)
println
()
println
()
println
(
toJCEInfo
(
z
).
toString
())
println
()
println
()
println
(
"======================>JCE output<==========================="
)
break
;
}
}
}
}
mirai-core-qqandroid/src/jvmTest/kotlin/test/JceDataClassGenerator.kt
0 → 100644
View file @
e71cb765
package
test;
import
net.mamoe.mirai.utils.cryptor.contentToString
import
java.io.File
import
java.lang.StringBuilder
fun
main
(){
val
var9
=
toJCEInfo
(
File
(
"/Users/jiahua.liu/Desktop/mirai/mirai-core-qqandroid/src/jvmTest/kotlin/test/GetFriendListReq"
).
readText
())
println
(
"import kotlinx.serialization.SerialId\n"
+
"import kotlinx.serialization.Serializable\n"
+
"import net.mamoe.mirai.qqandroid.io.JceStruct\n"
)
println
(
var9
.
toString
())
}
/**
* 不支持叠加中
*/
class
JCEInfo
(
){
lateinit
var
className
:
String
var
parents
:
List
<
String
>?
=
null
//seems useless
lateinit
var
properties
:
List
<
Property
>
override
fun
toString
():
String
{
properties
=
properties
.
sortedBy
{
it-
>
it
.
jceID
}
/**
*
@Serializable
class RequestDataVersion2(
@SerialId(0) val map: Map<String, Map<String, ByteArray>>
) : JceStruct
*/
val
max
=
(
properties
.
size
-
1
).
toString
().
length
val
builder
:
StringBuilder
=
StringBuilder
(
"@Serializable"
)
builder
.
append
(
"\n"
).
append
(
"internal class "
).
append
(
className
).
append
(
"("
)
properties
.
forEach
{
builder
.
append
(
","
).
append
(
"\n"
).
append
(
it
.
toStringWithSpacing
(
max
))
}
builder
.
append
(
"\n"
).
append
(
"): JceStruct"
)
return
builder
.
toString
().
replace
(
"(,"
,
"("
)
}
}
class
Property
(
val
name
:
String
,
var
type
:
String
,
var
defaultValue
:
String
?
=
null
){
var
jceID
:
Int
=
-
1
//convert type/default value to kotlin format
init
{
type
=
type
.
replace
(
"byte[]"
,
"ByteArray"
)
.
replace
(
"ArrayList"
,
"List"
)
.
replace
(
"byte"
,
"Byte"
)
.
replace
(
"int"
,
"Int"
)
.
replace
(
"short"
,
"Short"
)
.
replace
(
"long"
,
"Long"
)
}
//@SerialId(1) val iVersion: Short = 3,
override
fun
toString
():
String
{
if
(
defaultValue
!=
null
)
{
return
"@SerialId("
+
jceID
+
") val "
+
name
+
":"
+
type
+
" = "
+
defaultValue
}
return
"@SerialId("
+
jceID
+
") val "
+
name
+
":"
+
type
+
"? = null"
}
fun
toStringWithSpacing
(
maxIDLength
:
Int
):
String
{
val
space
=
" "
.
repeat
(
maxIDLength
-
(
jceID
.
toString
().
length
))
if
(
defaultValue
!=
null
)
{
return
" @SerialId("
+
jceID
+
") "
+
space
+
"val "
+
name
+
":"
+
type
+
" = "
+
defaultValue
}
return
" @SerialId("
+
jceID
+
") "
+
space
+
"val "
+
name
+
":"
+
type
+
"? = null"
}
}
fun
toJCEInfo
(
source
:
String
):
JCEInfo
{
val
info
=
JCEInfo
()
val
allProperties
=
mutableMapOf
<
String
,
Property
>()
var
inputStreamVariableRegix
:
String
?
=
null
println
(
source
)
source
.
split
(
"\n"
).
forEach
{
when
{
it
.
contains
(
"class"
)
->
{
var
var0
=
it
.
substringBetween
(
"class"
,
"{"
).
trim
()
if
(
var0
.
contains
(
"extends"
)){
info
.
parents
=
var0
.
substringAfter
(
"extends"
).
split
(
","
).
map
{
it
.
trim
()
}.
toList
()
var0
=
var0
.
substringBefore
(
" extends"
)
}
//println("class name: $var0" )
info
.
className
=
var0
}
(
it
.
contains
(
"public"
)
&&
it
.
contains
(
";"
))
->
{
val
var1
=
it
.
trim
().
split
(
" "
)
if
(
var1
.
size
==
5
){
allProperties
.
put
(
var1
[
2
],
Property
(
var1
[
2
],
var1
[
1
],
var1
[
4
].
replace
(
";"
,
""
)
)
)
}
else
{
allProperties
.
put
(
var1
[
2
].
replace
(
";"
,
""
),
Property
(
var1
[
2
].
replace
(
";"
,
""
),
var1
[
1
]
)
)
}
}
(
inputStreamVariableRegix
==
null
&&
it
.
contains
(
"public void readFrom"
))
->
{
// public void readFrom(JceInputStream var1) {
inputStreamVariableRegix
=
it
.
trim
().
substringBetween
(
"(JceInputStream "
,
")"
)
+
".read"
//println("inputStreamVariableRegix: " + inputStreamVariableRegix )
}
(
inputStreamVariableRegix
!=
null
&&
it
.
contains
(
inputStreamVariableRegix
!!
))
->
{
val
key
=
it
.
substringBetween
(
"this."
,
" = "
)
if
(!
allProperties
.
containsKey
(
key
)){
println
(
key
+
" is found in readFrom but not in properties"
)
}
val
id
=
it
.
substringBetween
(
".read("
,
");"
)
.
split
(
","
)[
1
].
trim
().
toInt
()
allProperties
.
get
(
key
)
?.
jceID
=
id
;
}
}
}
info
.
properties
=
allProperties
.
values
.
toList
();
return
info
;
}
\ No newline at end of file
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