Android Protocol - Rebuild Image Protocol

This commit is contained in:
jiahua.liu 2020-01-23 22:14:10 +08:00
parent 4c08503952
commit e6a554ae52
6 changed files with 38 additions and 25 deletions

View File

@ -9,7 +9,7 @@ enum class ChatType(val internalID: Int) {
CONTACT(1006),
//未知,推测为"组"
//推测为"群"
TROOP(1),
TROOP_HCTOPIC(1026),

View File

@ -0,0 +1,2 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.groupimage

View File

@ -4,7 +4,7 @@ import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
@Serializable
internal class Cmd0x325Packet(
internal class Cmd0x352Packet(
@SerialId(1) val subCommand: Int, //2是GetImgUrlReq 1是UploadImgReq
@SerialId(2) val uploadImgReq: UploadImgReq? = null,// optional
@SerialId(3) val getImgUrlReq: GetImgUrlReq? = null,// optional
@ -12,9 +12,9 @@ internal class Cmd0x325Packet(
@SerialId(10) val networkType: Int = 5// 数据网络=5
) {
companion object {
fun createByImageRequest(req: ImgReq, networkType: Int = 5): Cmd0x325Packet {
fun createByImageRequest(req: ImgReq, networkType: Int = 5): Cmd0x352Packet {
if (req is UploadImgReq)
return Cmd0x325Packet(
return Cmd0x352Packet(
1,
req,
null,
@ -22,7 +22,7 @@ internal class Cmd0x325Packet(
networkType
)
if (req is GetImgUrlReq)
return Cmd0x325Packet(
return Cmd0x352Packet(
2,
null,
req,

View File

@ -19,8 +19,8 @@ internal object ImageDownPacket : PacketFactory<ImageDownPacket.ImageDownPacketR
operator fun invoke(client: QQAndroidClient, req: GetImgUrlReq): OutgoingPacket {
return buildOutgingPacket(client, this._commandName, this._commandName, client.wLoginSigInfo.d2Key) {
ProtoBuf.dump(
Cmd0x325Packet.serializer(),
Cmd0x325Packet.createByImageRequest(req)
Cmd0x352Packet.serializer(),
Cmd0x352Packet.createByImageRequest(req)
)
}
}

View File

@ -2,35 +2,46 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image
import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import net.mamoe.mirai.utils.currentTimeSeconds
interface ImgReq
@Serializable
internal class UploadImgReq(
@SerialId(1) val srcUni: Int,
@SerialId(2) val dstUni: Int,
@SerialId(3) val fileId: Int,
@SerialId(4) val fileMd5: ByteArray,
@SerialId(1) val srcUin: Int,
@SerialId(2) val dstUin: Int,
@SerialId(3) val fileId: Int = 0,//从0开始的自增数貌似有一个连接就要自增1, 但是又会重置回0
@SerialId(4) val fileMd5: String,
@SerialId(5) val fileSize: Int,
@SerialId(6) val fileName: String,
@SerialId(7) val srcTerm: Int,
@SerialId(8) val platformType: Int,
@SerialId(6) val fileName: String,//默认为md5+".jpg"
@SerialId(7) val srcTerm: Int = 5,
@SerialId(8) val platformType: Int = 9,
@SerialId(9) val innerIP: Int = 0,
@SerialId(10) val addressBook: Int = 0,//chatType == 1006为1 我觉得发0没问题
@SerialId(11) val retry: Int,
@SerialId(12) val buType: Int,
@SerialId(11) val retry: Int = 0,//default
@SerialId(12) val buType: Int,//1或96 不确定
@SerialId(13) val imgOriginal: Int,//是否为原图
@SerialId(14) val imgWidth: Int,
@SerialId(15) val imgHeight: Int,
@SerialId(16) val imgType: Int,
@SerialId(16) val imgType: Int = 1000,
/**
* ImgType:
* JPG: 1000
* PNG: 1001
* WEBP: 1002
* BMP: 1005
* GIG: 2000
* APNG: 2001
* SHARPP: 1004
* */
@SerialId(17) val buildVer: String = "8.2.0.1296",//版本号
@SerialId(18) val fileIndex: ByteArray,
@SerialId(19) val fileStoreDays: Int,
@SerialId(20) val stepFlag: Int,
@SerialId(21) val rejectTryFast: Int,//bool
@SerialId(22) val srvUpload: Int,
@SerialId(23) val transferUrl: ByteArray
@SerialId(18) val fileIndex: ByteArray = EMPTY_BYTE_ARRAY,//default
@SerialId(19) val fileStoreDays: Int = 0,//default
@SerialId(20) val stepFlag: Int = 0,//default
@SerialId(21) val rejectTryFast: Int = 0,//bool
@SerialId(22) val srvUpload: Int = 1,//typeHotPic[1/2/3]
@SerialId(23) val transferUrl: ByteArray = EMPTY_BYTE_ARRAY//rawDownloadUrl, 如果没有就是EMPTY_BYTE_ARRAY
) : ImgReq
@Serializable

View File

@ -19,8 +19,8 @@ internal object ImageUpPacket : PacketFactory<ImageUpPacket.ImageUpPacketRespons
operator fun invoke(client: QQAndroidClient, req: UploadImgReq): OutgoingPacket {
return buildOutgingPacket(client, this._commandName, this._commandName, client.wLoginSigInfo.d2Key) {
ProtoBuf.dump(
Cmd0x325Packet.serializer(),
Cmd0x325Packet.createByImageRequest(req)
Cmd0x352Packet.serializer(),
Cmd0x352Packet.createByImageRequest(req)
)
}
}