Push Notify Update

This commit is contained in:
jiahua.liu 2020-01-27 21:22:37 +08:00
parent 81b347967f
commit bfd185fc49
2 changed files with 57 additions and 157 deletions

View File

@ -1,10 +1,5 @@
package net.mamoe.mirai.qqandroid.io package net.mamoe.mirai.qqandroid.io
abstract class JceStruct { interface JceStruct {
abstract fun writeTo(builder: JceOutput)
interface Factory<out T : JceStruct> {
fun newInstanceFrom(input: JceInput): T
}
} }

View File

@ -1,164 +1,69 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data
import net.mamoe.mirai.data.Packet import kotlinx.serialization.SerialId
import net.mamoe.mirai.qqandroid.io.JceInput import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.io.JceOutput
import net.mamoe.mirai.qqandroid.io.JceStruct import net.mamoe.mirai.qqandroid.io.JceStruct
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
class RequestPushNotify( @Serializable
val uin: Long, internal class RequestPushNotify(
val ctype: Byte, @SerialId(0) val uin: Long = 0L,
val strService: String, @SerialId(1) val ctype: Byte = 0,
val strCmd: String, @SerialId(2) val strService: String?,
val vNotifyCookie: ByteArray, @SerialId(3) val strCmd: String?,
val usMsgType: Int, @SerialId(4) val vNotifyCookie: ByteArray = EMPTY_BYTE_ARRAY,
val wUserActive: Int, @SerialId(5) val usMsgType: Int?,
val wGeneralFlag: Int, @SerialId(6) val wUserActive: Int?,
val bindedUin: Long, @SerialId(7) val wGeneralFlag: Int?,
val stMsgInfo: MsgInfo, @SerialId(8) val bindedUin: Long?,
val msgCtrlBuf: String, @SerialId(9) val stMsgInfo: MsgInfo?,
val serverBuf: ByteArray, @SerialId(10) val msgCtrlBuf: String?,
val pingFlag: Long, @SerialId(11) val serverBuf: ByteArray?,
val svrip: Int @SerialId(12) val pingFlag: Long?,
) : Packet, JceStruct() { @SerialId(13) val svrip: Int?
override fun writeTo(builder: JceOutput) { ) : JceStruct
//not needed
}
companion object : Factory<RequestPushNotify> { @Serializable
override fun newInstanceFrom(input: JceInput): RequestPushNotify { internal class MsgInfo(
return RequestPushNotify( @SerialId(0) val lFromUin: Long = 0L,
input.read(0L, 0), @SerialId(1) val uMsgTime: Long = 0L,
input.read(0.toByte(), 1), @SerialId(2) val shMsgType: Short?,
input.readString(2), @SerialId(3) val shMsgSeq: Short?,
input.readString(3), @SerialId(4) val strMsg: String?,
input.read(EMPTY_BYTE_ARRAY, 4), @SerialId(5) val uRealMsgTime: Int?,
input.read(0, 5), @SerialId(6) val vMsg: ByteArray?,
input.read(0, 6), @SerialId(7) val uAppShareID: Long?,
input.read(0, 7), @SerialId(8) val vMsgCookies: ByteArray = EMPTY_BYTE_ARRAY,
input.read(0L, 8), @SerialId(9) val vAppShareCookie: ByteArray = EMPTY_BYTE_ARRAY,
input.readJceStruct(MsgInfo, 9), @SerialId(10) val lMsgUid: Long?,
input.readString(10), @SerialId(11) val lLastChangeTime: Long?,
input.readByteArray(11), @SerialId(12) val vCPicInfo: List<CPicInfo>?,
input.readLong(12), @SerialId(13) val stShareData: ShareData?,
input.readInt(13) @SerialId(14) val lFromInstId: Long?,
) @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?
) : JceStruct
}
class MsgInfo(
val lFromUin: Long,
val uMsgTime: Long,
val shMsgType: Short,
val shMsgSeq: Short,
val strMsg: String,
val uRealMsgTime: Int,
val vMsg: ByteArray,
val uAppShareID: Long,
val vMsgCookies: ByteArray,
val vAppShareCookie: ByteArray,
val lMsgUid: Long,
val lLastChangeTime: Long,
val vCPicInfo: List<CPicInfo>,
val stShareData: ShareData,
val lFromInstId: Long,
val vRemarkOfSender: ByteArray,
val strFromMobile: String,
val strFromName: String,
val vNickName: List<String>,
val stC2CTmpMsgHead: TempMsgHead?
) : JceStruct() {
companion object : Factory<MsgInfo> {
override fun newInstanceFrom(input: JceInput): MsgInfo = with(input) {
return MsgInfo(
readLong(0),
readLong(1),
readShort(2),
readShort(3),
readString(4),
readInt(5),
readByteArray(6),
readLong(7),
readByteArray(8),
readByteArray(9),
readLong(10),
readLong(11),
readJceStructList(CPicInfo, 12),
readJceStruct(ShareData, 13),
readLong(14),
readByteArray(15),
readString(16),
readString(17),
readList(18),
readJceStructOrNull(TempMsgHead, 19)
)
}
}
override fun writeTo(builder: JceOutput) {
// not needed
}
}
@Serializable
class ShareData( class ShareData(
val pkgname: String = "", @SerialId(0) val pkgname: String = "",
val msgtail: String = "", @SerialId(1) val msgtail: String = "",
val picurl: String = "", @SerialId(2) val picurl: String = "",
val url: String = "" @SerialId(3) val url: String = ""
) : JceStruct() { ) : JceStruct
companion object : Factory<ShareData> {
override fun newInstanceFrom(input: JceInput): ShareData {
return ShareData(
input.readString(0),
input.readString(1),
input.readString(2),
input.readString(3)
)
}
}
override fun writeTo(builder: JceOutput) {
// not needed
}
}
@Serializable
class TempMsgHead( class TempMsgHead(
val c2c_type: Int, @SerialId(0) val c2c_type: Int = 0,
val serviceType: Int @SerialId(1) val serviceType: Int = 0
) : JceStruct() { ) : JceStruct
override fun writeTo(builder: JceOutput) {
}
companion object : Factory<TempMsgHead> {
override fun newInstanceFrom(input: JceInput): TempMsgHead {
return TempMsgHead(
input.readInt(0),
input.readInt(1)
)
}
}
}
@Serializable
class CPicInfo( class CPicInfo(
val vPath: ByteArray, @SerialId(0) val vPath: ByteArray = EMPTY_BYTE_ARRAY,
val vHost: ByteArray? @SerialId(1) val vHost: ByteArray = EMPTY_BYTE_ARRAY
) : JceStruct() { ) : JceStruct
override fun writeTo(builder: JceOutput) {
}
companion object : Factory<CPicInfo> {
override fun newInstanceFrom(input: JceInput): CPicInfo {
return CPicInfo(
input.readByteArray(0),
input.readByteArray(1)
)
}
}
}