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
87e76d48
Commit
87e76d48
authored
Jul 31, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Kotlin version to 1.4 and relevant libraries
parent
2b09cdaa
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
151 additions
and
182 deletions
+151
-182
build.gradle.kts
build.gradle.kts
+4
-0
buildSrc/src/main/kotlin/Versions.kt
buildSrc/src/main/kotlin/Versions.kt
+6
-6
mirai-core-qqandroid/build.gradle.kts
mirai-core-qqandroid/build.gradle.kts
+7
-14
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/BotFactory.kt
...commonMain/kotlin/net/mamoe/mirai/qqandroid/BotFactory.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
...n/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
+18
-11
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/LoginType.kt
...n/net/mamoe/mirai/qqandroid/network/protocol/LoginType.kt
+2
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/Cmd0x857.kt
...e/mirai/qqandroid/network/protocol/data/proto/Cmd0x857.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/MsgRevokeUserDef.kt
...qqandroid/network/protocol/data/proto/MsgRevokeUserDef.kt
+3
-3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/Oidb0x769.kt
.../mirai/qqandroid/network/protocol/data/proto/Oidb0x769.kt
+20
-20
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/StatSvcGetOnline.kt
...qqandroid/network/protocol/data/proto/StatSvcGetOnline.kt
+4
-4
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/image/ImgStore.kt
.../qqandroid/network/protocol/packet/chat/image/ImgStore.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt
...twork/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt
+5
-10
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
...ork/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
+0
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/StatSvc.kt
.../mirai/qqandroid/network/protocol/packet/login/StatSvc.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
.../kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
+4
-5
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDH.kt
...in/kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDH.kt
+2
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/io/serialization/ProtoBufWithNullableSupport.kt
...oid/utils/io/serialization/ProtoBufWithNullableSupport.kt
+26
-16
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/io/serialization/utils.kt
...net/mamoe/mirai/qqandroid/utils/io/serialization/utils.kt
+5
-5
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/tryNTimes.kt
...nMain/kotlin/net/mamoe/mirai/qqandroid/utils/tryNTimes.kt
+1
-0
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt
...src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt
+6
-6
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
.../kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
+6
-3
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDHJvm.kt
...kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDHJvm.kt
+4
-2
mirai-core/build.gradle.kts
mirai-core/build.gradle.kts
+10
-18
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.common.kt
...n/kotlin/net.mamoe.mirai/utils/BotConfiguration.common.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/Channels.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/utils/Channels.kt
+1
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt
...src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
.../commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
+8
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LoginSolver.kt
...rc/commonMain/kotlin/net.mamoe.mirai/utils/LoginSolver.kt
+0
-30
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/retryCatching.common.kt
...in/net.mamoe.mirai/utils/internal/retryCatching.common.kt
+1
-3
mirai-serialization/build.gradle.kts
mirai-serialization/build.gradle.kts
+0
-4
settings.gradle
settings.gradle
+2
-0
No files found.
build.gradle.kts
View file @
87e76d48
...
@@ -9,8 +9,10 @@ buildscript {
...
@@ -9,8 +9,10 @@ buildscript {
mavenLocal
()
mavenLocal
()
// maven(url = "https://mirrors.huaweicloud.com/repository/maven")
// maven(url = "https://mirrors.huaweicloud.com/repository/maven")
maven
(
url
=
"https://dl.bintray.com/kotlin/kotlin-eap"
)
maven
(
url
=
"https://dl.bintray.com/kotlin/kotlin-eap"
)
maven
(
url
=
"https://kotlin.bintray.com/kotlinx"
)
jcenter
()
jcenter
()
google
()
google
()
mavenCentral
()
}
}
dependencies
{
dependencies
{
...
@@ -60,8 +62,10 @@ allprojects {
...
@@ -60,8 +62,10 @@ allprojects {
mavenLocal
()
mavenLocal
()
// maven(url = "https://mirrors.huaweicloud.com/repository/maven")
// maven(url = "https://mirrors.huaweicloud.com/repository/maven")
maven
(
url
=
"https://dl.bintray.com/kotlin/kotlin-eap"
)
maven
(
url
=
"https://dl.bintray.com/kotlin/kotlin-eap"
)
maven
(
url
=
"https://kotlin.bintray.com/kotlinx"
)
jcenter
()
jcenter
()
google
()
google
()
mavenCentral
()
}
}
}
}
...
...
buildSrc/src/main/kotlin/Versions.kt
View file @
87e76d48
...
@@ -14,11 +14,11 @@ object Versions {
...
@@ -14,11 +14,11 @@ object Versions {
object
Kotlin
{
object
Kotlin
{
const
val
compiler
=
"1.4.0-rc"
const
val
compiler
=
"1.4.0-rc"
const
val
stdlib
=
"1.
3.72
"
const
val
stdlib
=
"1.
4.0-rc
"
const
val
coroutines
=
"1.3.8"
const
val
coroutines
=
"1.3.8
-1.4.0-rc
"
const
val
atomicFU
=
"0.14.
2
"
const
val
atomicFU
=
"0.14.
3-1.4.0-rc
"
const
val
serialization
=
"
0.20.0
"
const
val
serialization
=
"
1.0-M1-1.4.0-rc
"
const
val
ktor
=
"1.3.2"
const
val
ktor
=
"1.3.2
-1.4.0-rc
"
const
val
binaryValidator
=
"0.2.3"
const
val
binaryValidator
=
"0.2.3"
const
val
io
=
"0.1.16"
const
val
io
=
"0.1.16"
...
@@ -26,7 +26,7 @@ object Versions {
...
@@ -26,7 +26,7 @@ object Versions {
const
val
dokka
=
"0.10.1"
const
val
dokka
=
"0.10.1"
}
}
const
val
jcekt
=
"
1.0.0
"
const
val
jcekt
=
"
2.0.0-1.4.0-rc-4
"
object
Android
{
object
Android
{
const
val
androidGradlePlugin
=
"3.5.3"
const
val
androidGradlePlugin
=
"3.5.3"
...
...
mirai-core-qqandroid/build.gradle.kts
View file @
87e76d48
...
@@ -48,9 +48,6 @@ kotlin {
...
@@ -48,9 +48,6 @@ kotlin {
languageSettings
.
useExperimentalAnnotation
(
"kotlin.time.ExperimentalTime"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.time.ExperimentalTime"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.contracts.ExperimentalContracts"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.contracts.ExperimentalContracts"
)
languageSettings
.
languageVersion
=
"1.3"
languageSettings
.
apiVersion
=
"1.3"
languageSettings
.
progressiveMode
=
true
languageSettings
.
progressiveMode
=
true
dependencies
{
dependencies
{
...
@@ -60,13 +57,13 @@ kotlin {
...
@@ -60,13 +57,13 @@ kotlin {
val
commonMain
by
getting
{
val
commonMain
by
getting
{
dependencies
{
dependencies
{
api
(
kotlin
(
"stdlib"
,
Versions
.
Kotlin
.
stdlib
))
api
(
kotlinx
(
"serialization-runtime"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"serialization-runtime-common"
,
Versions
.
Kotlin
.
serialization
))
implementation
(
kotlinx
(
"serialization-protobuf"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"serialization-protobuf-common"
,
Versions
.
Kotlin
.
serialization
))
api
(
"moe.him188:jcekt-common:${Versions.jcekt}"
)
api
(
"org.jetbrains.kotlinx:atomicfu:${Versions.Kotlin.atomicFU}"
)
api
(
"org.jetbrains.kotlinx:atomicfu:${Versions.Kotlin.atomicFU}"
)
api
(
kotlinx
(
"io"
,
Versions
.
Kotlin
.
io
))
implementation
(
kotlinx
(
"io"
,
Versions
.
Kotlin
.
io
))
api
(
kotlinx
(
"coroutines-io"
,
Versions
.
Kotlin
.
coroutinesIo
))
implementation
(
kotlinx
(
"coroutines-io"
,
Versions
.
Kotlin
.
coroutinesIo
))
//implementation("moe.him188:jcekt:${Versions.jcekt}")
implementation
(
"moe.him188:jcekt:${Versions.jcekt}"
)
}
}
}
}
...
@@ -81,7 +78,6 @@ kotlin {
...
@@ -81,7 +78,6 @@ kotlin {
if
(
isAndroidSDKAvailable
)
{
if
(
isAndroidSDKAvailable
)
{
val
androidMain
by
getting
{
val
androidMain
by
getting
{
dependencies
{
dependencies
{
api
(
kotlinx
(
"serialization-protobuf"
,
Versions
.
Kotlin
.
serialization
))
}
}
}
}
...
@@ -98,11 +94,8 @@ kotlin {
...
@@ -98,11 +94,8 @@ kotlin {
val
jvmMain
by
getting
{
val
jvmMain
by
getting
{
dependencies
{
dependencies
{
runtimeOnly
(
files
(
"build/classes/kotlin/jvm/main"
))
// classpath is not properly set by IDE
runtimeOnly
(
files
(
"build/classes/kotlin/jvm/main"
))
// classpath is not properly set by IDE
implementation
(
"org.bouncycastle:bcprov-jdk15on:1.64"
)
// api(kotlinx("coroutines-debug", Versions.Kotlin.coroutines))
// api(kotlinx("coroutines-debug", Versions.Kotlin.coroutines))
api
(
"moe.him188:jcekt:${Versions.jcekt}"
)
api
(
kotlinx
(
"serialization-runtime"
,
Versions
.
Kotlin
.
serialization
))
//api(kotlinx("serialization-protobuf", Versions.Kotlin.serialization))
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/BotFactory.kt
View file @
87e76d48
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
@
file
:
Suppress
(
"FunctionName"
,
"INAPPLICABLE_JVM_NAME"
,
"DEPRECATION_ERROR"
,
"DeprecatedCallableAddReplaceWith"
,
"FunctionName"
,
"INAPPLICABLE_JVM_NAME"
,
"DEPRECATION_ERROR"
,
"DeprecatedCallableAddReplaceWith"
,
"OverridingDeprecatedMember"
"OverridingDeprecatedMember"
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
View file @
87e76d48
...
@@ -18,6 +18,8 @@ import kotlinx.coroutines.async
...
@@ -18,6 +18,8 @@ import kotlinx.coroutines.async
import
kotlinx.coroutines.sync.Mutex
import
kotlinx.coroutines.sync.Mutex
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
kotlinx.serialization.json.int
import
kotlinx.serialization.json.int
import
kotlinx.serialization.json.jsonObject
import
kotlinx.serialization.json.jsonPrimitive
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.LowLevelAPI
import
net.mamoe.mirai.LowLevelAPI
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
...
@@ -297,7 +299,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -297,7 +299,7 @@ internal abstract class QQAndroidBotBase constructor(
}
}
fun
getGroupByUinOrNull
(
uin
:
Long
):
Group
?
{
fun
getGroupByUinOrNull
(
uin
:
Long
):
Group
?
{
return
groups
.
asSequence
().
firstOrNull
{
it
.
checkIsGroupImpl
();
it
.
uin
==
uin
}
return
groups
.
firstOrNull
{
it
.
checkIsGroupImpl
();
it
.
uin
==
uin
}
}
}
@OptIn
(
LowLevelAPI
::
class
)
@OptIn
(
LowLevelAPI
::
class
)
...
@@ -487,7 +489,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -487,7 +489,7 @@ internal abstract class QQAndroidBotBase constructor(
val
rep
=
data
.
await
()
val
rep
=
data
.
await
()
// bot.network.logger.error(rep)
// bot.network.logger.error(rep)
return
json
.
parse
(
GroupAnnouncementList
.
serializer
(),
rep
)
return
json
.
decodeFromString
(
GroupAnnouncementList
.
serializer
(),
rep
)
}
}
@LowLevelAPI
@LowLevelAPI
...
@@ -503,7 +505,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -503,7 +505,7 @@ internal abstract class QQAndroidBotBase constructor(
append
(
"pinned"
,
announcement
.
pinned
)
append
(
"pinned"
,
announcement
.
pinned
)
append
(
append
(
"settings"
,
"settings"
,
json
.
stringify
(
json
.
encodeToString
(
GroupAnnouncementSettings
.
serializer
(),
GroupAnnouncementSettings
.
serializer
(),
announcement
.
settings
?:
GroupAnnouncementSettings
()
announcement
.
settings
?:
GroupAnnouncementSettings
()
)
)
...
@@ -521,8 +523,8 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -521,8 +523,8 @@ internal abstract class QQAndroidBotBase constructor(
}
}
}
}
}
}
val
jsonObj
=
json
.
parse
Json
(
rep
)
val
jsonObj
=
json
.
parse
ToJsonElement
(
rep
)
return
jsonObj
.
jsonObject
[
"new_fid"
]
?.
p
rimitive
?.
content
return
jsonObj
.
jsonObject
[
"new_fid"
]
?.
jsonP
rimitive
?.
content
?:
throw
throw
IllegalStateException
(
"Send Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} content:${announcement.msg.text}"
)
?:
throw
throw
IllegalStateException
(
"Send Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} content:${announcement.msg.text}"
)
}
}
...
@@ -549,8 +551,8 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -549,8 +551,8 @@ internal abstract class QQAndroidBotBase constructor(
}
}
}
}
}
}
val
jsonObj
=
json
.
parse
Json
(
data
)
val
jsonObj
=
json
.
parse
ToJsonElement
(
data
)
if
(
jsonObj
.
jsonObject
[
"ec"
]
?.
int
?:
1
!=
0
)
{
if
(
jsonObj
.
jsonObject
[
"ec"
]
?.
jsonPrimitive
?.
int
?:
1
!=
0
)
{
throw
throw
IllegalStateException
(
"delete Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} fid:$fid"
)
throw
throw
IllegalStateException
(
"delete Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} fid:$fid"
)
}
}
}
}
...
@@ -578,7 +580,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -578,7 +580,7 @@ internal abstract class QQAndroidBotBase constructor(
val
rep
=
data
.
await
()
val
rep
=
data
.
await
()
// bot.network.logger.error(rep)
// bot.network.logger.error(rep)
return
json
.
parse
(
GroupAnnouncement
.
serializer
(),
rep
)
return
json
.
decodeFromString
(
GroupAnnouncement
.
serializer
(),
rep
)
}
}
...
@@ -602,7 +604,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -602,7 +604,7 @@ internal abstract class QQAndroidBotBase constructor(
}
}
}
}
val
rep
=
data
.
await
()
val
rep
=
data
.
await
()
return
json
.
parse
(
GroupActiveData
.
serializer
(),
rep
)
return
json
.
decodeFromString
(
GroupActiveData
.
serializer
(),
rep
)
}
}
@JvmSynthetic
@JvmSynthetic
...
@@ -800,11 +802,16 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -800,11 +802,16 @@ internal abstract class QQAndroidBotBase constructor(
):
String
{
):
String
{
network
.
run
{
network
.
run
{
val
response
:
PttStore
.
GroupPttDown
.
Response
.
DownLoadInfo
=
val
response
:
PttStore
.
GroupPttDown
.
Response
.
DownLoadInfo
=
PttStore
.
GroupPttDown
(
client
,
groupId
,
dstUin
,
md5
).
sendAndExpect
()
PttStore
.
GroupPttDown
(
client
,
groupId
,
dstUin
,
md5
).
sendAndExpect
()
return
"http://${response.strDomain}${response.downPara.encodeToString()}"
return
"http://${response.strDomain}${response.downPara.encodeToString()}"
}
}
}
}
@LowLevelAPI
override
suspend
fun
_lowLevelUploadVoice
(
md5
:
ByteArray
,
groupId
:
Long
)
{
}
@Suppress
(
"DEPRECATION"
,
"OverridingDeprecatedMember"
)
@Suppress
(
"DEPRECATION"
,
"OverridingDeprecatedMember"
)
override
suspend
fun
queryImageUrl
(
image
:
Image
):
String
=
when
(
image
)
{
override
suspend
fun
queryImageUrl
(
image
:
Image
):
String
=
when
(
image
)
{
is
ConstOriginUrlAware
->
image
.
originUrl
is
ConstOriginUrlAware
->
image
.
originUrl
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/LoginType.kt
View file @
87e76d48
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
package
net.mamoe.mirai.qqandroid.network.protocol
package
net.mamoe.mirai.qqandroid.network.protocol
inline
class
LoginType
(
in
ternal
in
line
class
LoginType
(
val
value
:
Int
val
value
:
Int
)
{
)
{
companion
object
{
companion
object
{
...
@@ -17,6 +17,7 @@ inline class LoginType(
...
@@ -17,6 +17,7 @@ inline class LoginType(
* 短信验证登录
* 短信验证登录
*/
*/
val
SMS
=
LoginType
(
3
)
val
SMS
=
LoginType
(
3
)
/**
/**
* 密码登录
* 密码登录
*/
*/
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/Cmd0x857.kt
View file @
87e76d48
...
@@ -19,7 +19,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
...
@@ -19,7 +19,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
class
GroupOpenSysMsg
:
ProtoBuf
{
internal
class
GroupOpenSysMsg
:
ProtoBuf
{
@Serializable
@Serializable
internal
class
LightApp
(
internal
class
LightApp
(
@ProtoId
(
1
)
@JvmField
val
app
:
String
=
""
,
@ProtoId
(
1
)
@JvmField
val
app
:
String
=
""
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/MsgRevokeUserDef.kt
View file @
87e76d48
...
@@ -14,15 +14,15 @@ import kotlinx.serialization.protobuf.ProtoId
...
@@ -14,15 +14,15 @@ import kotlinx.serialization.protobuf.ProtoId
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
class
MsgRevokeUserDef
:
ProtoBuf
{
internal
class
MsgRevokeUserDef
:
ProtoBuf
{
@Serializable
@Serializable
internal
class
MsgInfoUserDef
(
internal
class
MsgInfoUserDef
(
@ProtoId
(
1
)
@JvmField
val
longMessageFlag
:
Int
=
0
,
@ProtoId
(
1
)
@JvmField
val
longMessageFlag
:
Int
=
0
,
@ProtoId
(
2
)
@JvmField
val
longMsgInfo
:
List
<
MsgInfoDef
>?
=
null
,
@ProtoId
(
2
)
@JvmField
val
longMsgInfo
:
List
<
MsgInfoDef
>?
=
null
,
@ProtoId
(
3
)
@JvmField
val
fileUuid
:
List
<
String
>
=
listOf
()
@ProtoId
(
3
)
@JvmField
val
fileUuid
:
List
<
String
>
=
listOf
()
)
:
ProtoBuf
{
)
:
ProtoBuf
{
@Serializable
@Serializable
internal
class
MsgInfoDef
(
internal
class
MsgInfoDef
(
@ProtoId
(
1
)
@JvmField
val
msgSeq
:
Int
=
0
,
@ProtoId
(
1
)
@JvmField
val
msgSeq
:
Int
=
0
,
@ProtoId
(
2
)
@JvmField
val
longMsgId
:
Int
=
0
,
@ProtoId
(
2
)
@JvmField
val
longMsgId
:
Int
=
0
,
@ProtoId
(
3
)
@JvmField
val
longMsgNum
:
Int
=
0
,
@ProtoId
(
3
)
@JvmField
val
longMsgNum
:
Int
=
0
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/Oidb0x769.kt
View file @
87e76d48
...
@@ -14,9 +14,9 @@ import kotlinx.serialization.protobuf.ProtoId
...
@@ -14,9 +14,9 @@ import kotlinx.serialization.protobuf.ProtoId
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
class
Oidb0x769
{
internal
class
Oidb0x769
{
@Serializable
@Serializable
internal
class
RequestBody
(
internal
class
RequestBody
(
@ProtoId
(
1
)
@JvmField
val
rpt_config_list
:
List
<
ConfigSeq
>
@ProtoId
(
1
)
@JvmField
val
rpt_config_list
:
List
<
ConfigSeq
>
// @SerialId(2) @JvmField val msg_device_info: DeviceInfo,
// @SerialId(2) @JvmField val msg_device_info: DeviceInfo,
// @SerialId(3) @JvmField val str_info: String = "",
// @SerialId(3) @JvmField val str_info: String = "",
...
@@ -27,19 +27,19 @@ internal class RequestBody(
...
@@ -27,19 +27,19 @@ internal class RequestBody(
)
:
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
QueryUinPackageUsageReq
(
internal
class
QueryUinPackageUsageReq
(
@ProtoId
(
1
)
@JvmField
val
type
:
Int
,
@ProtoId
(
1
)
@JvmField
val
type
:
Int
,
@ProtoId
(
2
)
@JvmField
val
uinFileSize
:
Long
=
0
@ProtoId
(
2
)
@JvmField
val
uinFileSize
:
Long
=
0
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
ConfigSeq
(
internal
class
ConfigSeq
(
@ProtoId
(
1
)
@JvmField
val
type
:
Int
,
// uint
@ProtoId
(
1
)
@JvmField
val
type
:
Int
,
// uint
@ProtoId
(
2
)
@JvmField
val
version
:
Int
// uint
@ProtoId
(
2
)
@JvmField
val
version
:
Int
// uint
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
DeviceInfo
(
internal
class
DeviceInfo
(
@ProtoId
(
1
)
@JvmField
val
brand
:
String
,
@ProtoId
(
1
)
@JvmField
val
brand
:
String
,
@ProtoId
(
2
)
@JvmField
val
model
:
String
@ProtoId
(
2
)
@JvmField
val
model
:
String
//@SerialId(3) @JvmField val os: OS,
//@SerialId(3) @JvmField val os: OS,
...
@@ -48,49 +48,49 @@ internal class DeviceInfo(
...
@@ -48,49 +48,49 @@ internal class DeviceInfo(
//@SerialId(6) @JvmField val storage: Storage,
//@SerialId(6) @JvmField val storage: Storage,
//@SerialId(7) @JvmField val screen: Screen,
//@SerialId(7) @JvmField val screen: Screen,
//@SerialId(8) @JvmField val camera: Camera
//@SerialId(8) @JvmField val camera: Camera
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
OS
(
internal
class
OS
(
@ProtoId
(
1
)
@JvmField
val
type
:
Int
=
1
,
@ProtoId
(
1
)
@JvmField
val
type
:
Int
=
1
,
@ProtoId
(
2
)
@JvmField
val
version
:
String
,
@ProtoId
(
2
)
@JvmField
val
version
:
String
,
@ProtoId
(
3
)
@JvmField
val
sdk
:
String
,
@ProtoId
(
3
)
@JvmField
val
sdk
:
String
,
@ProtoId
(
4
)
@JvmField
val
kernel
:
String
,
@ProtoId
(
4
)
@JvmField
val
kernel
:
String
,
@ProtoId
(
5
)
@JvmField
val
rom
:
String
@ProtoId
(
5
)
@JvmField
val
rom
:
String
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
Camera
(
internal
class
Camera
(
@ProtoId
(
1
)
@JvmField
val
primary
:
Long
,
@ProtoId
(
1
)
@JvmField
val
primary
:
Long
,
@ProtoId
(
2
)
@JvmField
val
secondary
:
Long
,
@ProtoId
(
2
)
@JvmField
val
secondary
:
Long
,
@ProtoId
(
3
)
@JvmField
val
flag
:
Boolean
@ProtoId
(
3
)
@JvmField
val
flag
:
Boolean
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
CPU
(
internal
class
CPU
(
@ProtoId
(
1
)
@JvmField
val
model
:
String
,
@ProtoId
(
1
)
@JvmField
val
model
:
String
,
@ProtoId
(
2
)
@JvmField
val
frequency
:
Int
,
@ProtoId
(
2
)
@JvmField
val
frequency
:
Int
,
@ProtoId
(
3
)
@JvmField
val
cores
:
Int
@ProtoId
(
3
)
@JvmField
val
cores
:
Int
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
Memory
(
internal
class
Memory
(
@ProtoId
(
1
)
@JvmField
val
total
:
Int
,
@ProtoId
(
1
)
@JvmField
val
total
:
Int
,
@ProtoId
(
2
)
@JvmField
val
process
:
Int
@ProtoId
(
2
)
@JvmField
val
process
:
Int
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
Screen
(
internal
class
Screen
(
@ProtoId
(
1
)
@JvmField
val
model
:
String
,
@ProtoId
(
1
)
@JvmField
val
model
:
String
,
@ProtoId
(
2
)
@JvmField
val
width
:
Int
,
@ProtoId
(
2
)
@JvmField
val
width
:
Int
,
@ProtoId
(
3
)
@JvmField
val
height
:
Int
,
@ProtoId
(
3
)
@JvmField
val
height
:
Int
,
@ProtoId
(
4
)
@JvmField
val
dpi
:
Int
,
@ProtoId
(
4
)
@JvmField
val
dpi
:
Int
,
@ProtoId
(
5
)
@JvmField
val
multiTouch
:
Boolean
@ProtoId
(
5
)
@JvmField
val
multiTouch
:
Boolean
):
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
Storage
(
internal
class
Storage
(
@ProtoId
(
1
)
@JvmField
val
builtin
:
Int
,
@ProtoId
(
1
)
@JvmField
val
builtin
:
Int
,
@ProtoId
(
2
)
@JvmField
val
external
:
Int
@ProtoId
(
2
)
@JvmField
val
external
:
Int
):
ProtoBuf
)
:
ProtoBuf
}
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/StatSvcGetOnline.kt
View file @
87e76d48
...
@@ -14,21 +14,21 @@ import kotlinx.serialization.protobuf.ProtoId
...
@@ -14,21 +14,21 @@ import kotlinx.serialization.protobuf.ProtoId
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
net.mamoe.mirai.qqandroid.utils.io.ProtoBuf
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
class
StatSvcGetOnline
{
internal
class
StatSvcGetOnline
{
@Serializable
@Serializable
internal
class
Instance
(
internal
class
Instance
(
@ProtoId
(
1
)
@JvmField
val
instanceId
:
Int
=
0
,
@ProtoId
(
1
)
@JvmField
val
instanceId
:
Int
=
0
,
@ProtoId
(
2
)
@JvmField
val
clientType
:
Int
=
0
@ProtoId
(
2
)
@JvmField
val
clientType
:
Int
=
0
)
:
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
ReqBody
(
internal
class
ReqBody
(
@ProtoId
(
1
)
@JvmField
val
uin
:
Long
=
0L
,
@ProtoId
(
1
)
@JvmField
val
uin
:
Long
=
0L
,
@ProtoId
(
2
)
@JvmField
val
appid
:
Int
=
0
@ProtoId
(
2
)
@JvmField
val
appid
:
Int
=
0
)
:
ProtoBuf
)
:
ProtoBuf
@Serializable
@Serializable
internal
class
RspBody
(
internal
class
RspBody
(
@ProtoId
(
1
)
@JvmField
val
errorCode
:
Int
=
0
,
@ProtoId
(
1
)
@JvmField
val
errorCode
:
Int
=
0
,
@ProtoId
(
2
)
@JvmField
val
errorMsg
:
String
=
""
,
@ProtoId
(
2
)
@JvmField
val
errorMsg
:
String
=
""
,
@ProtoId
(
3
)
@JvmField
val
uin
:
Long
=
0L
,
@ProtoId
(
3
)
@JvmField
val
uin
:
Long
=
0L
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/image/ImgStore.kt
View file @
87e76d48
...
@@ -29,7 +29,7 @@ internal fun getRandomString(length: Int): String =
...
@@ -29,7 +29,7 @@ internal fun getRandomString(length: Int): String =
private
val
defaultRanges
:
Array
<
CharRange
>
=
arrayOf
(
'a'
..
'z'
,
'A'
..
'Z'
,
'0'
..
'9'
)
private
val
defaultRanges
:
Array
<
CharRange
>
=
arrayOf
(
'a'
..
'z'
,
'A'
..
'Z'
,
'0'
..
'9'
)
internal
fun
getRandomString
(
length
:
Int
,
vararg
charRanges
:
CharRange
):
String
=
internal
fun
getRandomString
(
length
:
Int
,
vararg
charRanges
:
CharRange
):
String
=
String
(
CharArray
(
length
)
{
charRanges
[
Random
.
Default
.
nextInt
(
0
..
charRanges
.
lastIndex
)].
random
()
}
)
CharArray
(
length
)
{
charRanges
[
Random
.
Default
.
nextInt
(
0
..
charRanges
.
lastIndex
)].
random
()
}.
concatToString
(
)
internal
class
ImgStore
{
internal
class
ImgStore
{
object
GroupPicUp
:
OutgoingPacketFactory
<
GroupPicUp
.
Response
>(
"ImgStore.GroupPicUp"
)
{
object
GroupPicUp
:
OutgoingPacketFactory
<
GroupPicUp
.
Response
>(
"ImgStore.GroupPicUp"
)
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt
View file @
87e76d48
...
@@ -48,7 +48,6 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
...
@@ -48,7 +48,6 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
import
net.mamoe.mirai.qqandroid.utils.read
import
net.mamoe.mirai.qqandroid.utils.read
import
net.mamoe.mirai.qqandroid.utils.toInt
import
net.mamoe.mirai.qqandroid.utils.toInt
import
net.mamoe.mirai.qqandroid.utils.toUHexString
import
net.mamoe.mirai.qqandroid.utils.toUHexString
import
net.mamoe.mirai.utils.currentTimeSeconds
import
net.mamoe.mirai.utils.debug
import
net.mamoe.mirai.utils.debug
import
net.mamoe.mirai.utils.warning
import
net.mamoe.mirai.utils.warning
...
@@ -57,20 +56,18 @@ import net.mamoe.mirai.utils.warning
...
@@ -57,20 +56,18 @@ import net.mamoe.mirai.utils.warning
* 获取好友消息和消息记录
* 获取好友消息和消息记录
*/
*/
internal
object
MessageSvcPbGetMsg
:
OutgoingPacketFactory
<
MessageSvcPbGetMsg
.
Response
>(
"MessageSvc.PbGetMsg"
)
{
internal
object
MessageSvcPbGetMsg
:
OutgoingPacketFactory
<
MessageSvcPbGetMsg
.
Response
>(
"MessageSvc.PbGetMsg"
)
{
private
var
firstSyncPackets
=
0
// 启动时候仅将所有好友信息设为已读的包
@Suppress
(
"SpellCheckingInspection"
)
@Suppress
(
"SpellCheckingInspection"
)
operator
fun
invoke
(
operator
fun
invoke
(
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
syncFlag
:
MsgSvc
.
SyncFlag
=
MsgSvc
.
SyncFlag
.
START
,
syncFlag
:
MsgSvc
.
SyncFlag
=
MsgSvc
.
SyncFlag
.
START
,
msgTime
:
Long
,
//PbPushMsg.msg.msgHead.msgTime
syncCookie
:
ByteArray
?,
//PbPushMsg.msg.msgHead.msgTime
syncCookie
:
ByteArray
?,
firstSync
:
Boolean
=
false
firstSync
:
Boolean
=
false
):
OutgoingPacket
=
buildOutgoingUniPacket
(
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
client
)
{
)
{
//println("syncCookie=${client.c2cMessageSync.syncCookie?.toUHexString()}")
//println("syncCookie=${client.c2cMessageSync.syncCookie?.toUHexString()}")
if
(
firstSync
)
{
if
(
firstSync
)
{
firstSyncPackets
++
client
.
firstSyncPackets
.
getAndAdd
(
1
)
}
}
writeProtoBuf
(
writeProtoBuf
(
MsgSvc
.
PbGetMsgReq
.
serializer
(),
MsgSvc
.
PbGetMsgReq
.
serializer
(),
...
@@ -279,7 +276,7 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
...
@@ -279,7 +276,7 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
*/
*/
166
->
{
166
->
{
if
(
firstSyncPackets
!=
0
)
{
if
(
bot
.
client
.
firstSyncPackets
.
value
!=
0
)
{
return
@
mapNotNull
null
return
@
mapNotNull
null
}
}
if
(
msg
.
msgHead
.
fromUin
==
bot
.
id
)
{
if
(
msg
.
msgHead
.
fromUin
==
bot
.
id
)
{
...
@@ -384,8 +381,8 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
...
@@ -384,8 +381,8 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
override
suspend
fun
QQAndroidBot
.
handle
(
packet
:
Response
)
{
override
suspend
fun
QQAndroidBot
.
handle
(
packet
:
Response
)
{
when
(
packet
.
syncFlagFromServer
)
{
when
(
packet
.
syncFlagFromServer
)
{
MsgSvc
.
SyncFlag
.
STOP
->
{
MsgSvc
.
SyncFlag
.
STOP
->
{
if
(
firstSyncPackets
!=
0
)
{
if
(
client
.
firstSyncPackets
.
value
!=
0
)
{
firstSyncPackets--
client
.
firstSyncPackets
.
getAndDecrement
()
}
}
}
}
...
@@ -394,7 +391,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
...
@@ -394,7 +391,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
MessageSvcPbGetMsg
(
MessageSvcPbGetMsg
(
client
,
client
,
MsgSvc
.
SyncFlag
.
CONTINUE
,
MsgSvc
.
SyncFlag
.
CONTINUE
,
currentTimeSeconds
,
packet
.
syncCookie
packet
.
syncCookie
).
sendAndExpect
<
Packet
>()
).
sendAndExpect
<
Packet
>()
}
}
...
@@ -406,7 +402,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
...
@@ -406,7 +402,6 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
MessageSvcPbGetMsg
(
MessageSvcPbGetMsg
(
client
,
client
,
MsgSvc
.
SyncFlag
.
CONTINUE
,
MsgSvc
.
SyncFlag
.
CONTINUE
,
currentTimeSeconds
,
packet
.
syncCookie
packet
.
syncCookie
).
sendAndExpect
<
Packet
>()
).
sendAndExpect
<
Packet
>()
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
View file @
87e76d48
...
@@ -18,7 +18,6 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgSvc
...
@@ -18,7 +18,6 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.IncomingPacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.IncomingPacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.utils.io.serialization.readUniPacket
import
net.mamoe.mirai.qqandroid.utils.io.serialization.readUniPacket
import
net.mamoe.mirai.utils.currentTimeSeconds
/**
/**
...
@@ -37,7 +36,6 @@ internal object MessageSvcPushNotify : IncomingPacketFactory<RequestPushNotify>(
...
@@ -37,7 +36,6 @@ internal object MessageSvcPushNotify : IncomingPacketFactory<RequestPushNotify>(
return
MessageSvcPbGetMsg
(
return
MessageSvcPbGetMsg
(
client
,
client
,
MsgSvc
.
SyncFlag
.
START
,
MsgSvc
.
SyncFlag
.
START
,
packet
.
stMsgInfo
?.
uMsgTime
?:
currentTimeSeconds
,
if
(
firstNotify
)
{
if
(
firstNotify
)
{
if
(!
client
.
c2cMessageSync
.
firstNotify
.
compareAndSet
(
firstNotify
,
false
))
{
if
(!
client
.
c2cMessageSync
.
firstNotify
.
compareAndSet
(
firstNotify
,
false
))
{
return
@
loop
return
@
loop
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/StatSvc.kt
View file @
87e76d48
...
@@ -148,7 +148,7 @@ internal class StatSvc {
...
@@ -148,7 +148,7 @@ internal class StatSvc {
var44.strVendorName = ROMUtil.getRomName();
var44.strVendorName = ROMUtil.getRomName();
var44.strVendorOSName = ROMUtil.getRomVersion(20);
var44.strVendorOSName = ROMUtil.getRomVersion(20);
*/
*/
bytes_0x769_reqbody
=
ProtoBuf
.
dump
(
bytes_0x769_reqbody
=
ProtoBuf
.
encodeToByteArray
(
Oidb0x769
.
RequestBody
.
serializer
(),
Oidb0x769
.
RequestBody
(
Oidb0x769
.
RequestBody
.
serializer
(),
Oidb0x769
.
RequestBody
(
rpt_config_list
=
listOf
(
rpt_config_list
=
listOf
(
Oidb0x769
.
ConfigSeq
(
Oidb0x769
.
ConfigSeq
(
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
View file @
87e76d48
...
@@ -12,14 +12,13 @@ package net.mamoe.mirai.qqandroid.utils
...
@@ -12,14 +12,13 @@ package net.mamoe.mirai.qqandroid.utils
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.Closeable
import
kotlinx.io.core.Closeable
import
kotlinx.io.errors.IOException
import
kotlinx.io.errors.IOException
import
net.mamoe.mirai.utils.Throws
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
/**
/**
* 多平台适配的 TCP Socket.
* 多平台适配的 TCP Socket.
*/
*/
internal
expect
class
PlatformSocket
()
:
Closeable
{
internal
expect
class
PlatformSocket
()
:
Closeable
{
@Throws
(
SocketException
::
class
)
@
kotlin
.
Throws
(
SocketException
::
class
)
suspend
fun
connect
(
coroutineContext
:
CoroutineContext
,
serverHost
:
String
,
serverPort
:
Int
)
suspend
fun
connect
(
coroutineContext
:
CoroutineContext
,
serverHost
:
String
,
serverPort
:
Int
)
/**
/**
...
@@ -42,6 +41,6 @@ internal expect class PlatformSocket() : Closeable {
...
@@ -42,6 +41,6 @@ internal expect class PlatformSocket() : Closeable {
override
fun
close
()
override
fun
close
()
}
}
expect
open
class
SocketException
:
IOException
internal
expect
open
class
SocketException
:
IOException
expect
class
NoRouteToHostException
:
SocketException
internal
expect
class
NoRouteToHostException
:
SocketException
expect
class
UnknownHostException
:
IOException
internal
expect
class
UnknownHostException
:
IOException
\ No newline at end of file
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDH.kt
View file @
87e76d48
...
@@ -11,11 +11,11 @@ package net.mamoe.mirai.qqandroid.utils.cryptor
...
@@ -11,11 +11,11 @@ package net.mamoe.mirai.qqandroid.utils.cryptor
import
net.mamoe.mirai.qqandroid.utils.chunkedHexToBytes
import
net.mamoe.mirai.qqandroid.utils.chunkedHexToBytes
expect
interface
ECDHPrivateKey
{
internal
expect
interface
ECDHPrivateKey
{
fun
getEncoded
():
ByteArray
fun
getEncoded
():
ByteArray
}
}
expect
interface
ECDHPublicKey
{
internal
expect
interface
ECDHPublicKey
{
fun
getEncoded
():
ByteArray
fun
getEncoded
():
ByteArray
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/io/serialization/ProtoBufWithNullableSupport.kt
View file @
87e76d48
...
@@ -9,22 +9,26 @@
...
@@ -9,22 +9,26 @@
package
net.mamoe.mirai.qqandroid.utils.io.serialization
package
net.mamoe.mirai.qqandroid.utils.io.serialization
import
kotlinx.io.ByteArrayOutputStream
import
kotlinx.io.ByteBuffer
import
kotlinx.io.ByteOrder
import
kotlinx.serialization.*
import
kotlinx.serialization.*
import
kotlinx.serialization.builtins.ByteArraySerializer
import
kotlinx.serialization.builtins.ByteArraySerializer
import
kotlinx.serialization.builtins.MapEntrySerializer
import
kotlinx.serialization.builtins.MapEntrySerializer
import
kotlinx.serialization.builtins.SetSerializer
import
kotlinx.serialization.builtins.SetSerializer
import
kotlinx.serialization.descriptors.PolymorphicKind
import
kotlinx.serialization.descriptors.SerialDescriptor
import
kotlinx.serialization.descriptors.StructureKind
import
kotlinx.serialization.encoding.CompositeEncoder
import
kotlinx.serialization.internal.MapLikeSerializer
import
kotlinx.serialization.internal.MapLikeSerializer
import
kotlinx.serialization.internal.TaggedEncoder
import
kotlinx.serialization.internal.TaggedEncoder
import
kotlinx.serialization.modules.EmptyModule
import
kotlinx.serialization.modules.Empty
Serializers
Module
import
kotlinx.serialization.modules.SerialModule
import
kotlinx.serialization.modules.Serial
izers
Module
import
kotlinx.serialization.protobuf.ProtoBuf
import
kotlinx.serialization.protobuf.ProtoBuf
import
kotlinx.serialization.protobuf.ProtoNumberType
import
kotlinx.serialization.protobuf.ProtoNumberType
import
kotlinx.serialization.protobuf.ProtoType
import
kotlinx.serialization.protobuf.ProtoType
import
moe.him188.jcekt.JceId
import
moe.him188.jcekt.JceId
import
net.mamoe.mirai.qqandroid.utils.io.serialization.ProtoBufWithNullableSupport.Varint.encodeVarint
import
net.mamoe.mirai.qqandroid.utils.io.serialization.ProtoBufWithNullableSupport.Varint.encodeVarint
import
java.io.ByteArrayOutputStream
import
java.nio.ByteBuffer
import
java.nio.ByteOrder
internal
typealias
ProtoDesc
=
Pair
<
Int
,
ProtoNumberType
>
internal
typealias
ProtoDesc
=
Pair
<
Int
,
ProtoNumberType
>
...
@@ -45,11 +49,12 @@ internal fun extractParameters(desc: SerialDescriptor, index: Int, zeroBasedDefa
...
@@ -45,11 +49,12 @@ internal fun extractParameters(desc: SerialDescriptor, index: Int, zeroBasedDefa
* 代码复制自 kotlinx.serialization. 修改部分已进行标注 (详见 "MIRAI MODIFY START")
* 代码复制自 kotlinx.serialization. 修改部分已进行标注 (详见 "MIRAI MODIFY START")
*/
*/
@OptIn
(
InternalSerializationApi
::
class
)
@OptIn
(
InternalSerializationApi
::
class
)
internal
class
ProtoBufWithNullableSupport
(
override
val
context
:
SerialModule
=
EmptyModule
)
:
SerialFormat
,
BinaryFormat
{
internal
class
ProtoBufWithNullableSupport
(
override
val
serializersModule
:
SerializersModule
=
EmptySerializersModule
)
:
SerialFormat
,
BinaryFormat
{
internal
open
inner
class
ProtobufWriter
(
private
val
encoder
:
ProtobufEncoder
)
:
TaggedEncoder
<
ProtoDesc
>()
{
internal
open
inner
class
ProtobufWriter
(
private
val
encoder
:
ProtobufEncoder
)
:
TaggedEncoder
<
ProtoDesc
>()
{
override
val
context
override
val
serializersModule
get
()
=
this
@ProtoBufWithNullableSupport
.
context
get
()
=
this
@ProtoBufWithNullableSupport
.
serializersModule
override
fun
beginStructure
(
override
fun
beginStructure
(
descriptor
:
SerialDescriptor
,
descriptor
:
SerialDescriptor
,
...
@@ -241,7 +246,8 @@ internal class ProtoBufWithNullableSupport(override val context: SerialModule =
...
@@ -241,7 +246,8 @@ internal class ProtoBufWithNullableSupport(override val context: SerialModule =
}
}
companion
object
:
BinaryFormat
{
companion
object
:
BinaryFormat
{
override
val
context
:
SerialModule
get
()
=
plain
.
context
override
val
serializersModule
:
SerializersModule
get
()
=
plain
.
serializersModule
private
fun
SerialDescriptor
.
getProtoDesc
(
index
:
Int
):
ProtoDesc
{
private
fun
SerialDescriptor
.
getProtoDesc
(
index
:
Int
):
ProtoDesc
{
return
extractParameters
(
this
,
index
)
return
extractParameters
(
this
,
index
)
...
@@ -254,20 +260,24 @@ internal class ProtoBufWithNullableSupport(override val context: SerialModule =
...
@@ -254,20 +260,24 @@ internal class ProtoBufWithNullableSupport(override val context: SerialModule =
private
val
plain
=
ProtoBufWithNullableSupport
()
private
val
plain
=
ProtoBufWithNullableSupport
()
override
fun
<
T
>
dump
(
serializer
:
SerializationStrategy
<
T
>,
value
:
T
):
ByteArray
=
plain
.
dump
(
serializer
,
value
)
override
fun
<
T
>
encodeToByteArray
(
serializer
:
SerializationStrategy
<
T
>,
value
:
T
):
ByteArray
{
override
fun
<
T
>
load
(
deserializer
:
DeserializationStrategy
<
T
>,
bytes
:
ByteArray
):
T
=
return
plain
.
encodeToByteArray
(
serializer
,
value
)
plain
.
load
(
deserializer
,
bytes
)
}
}
override
fun
<
T
>
dump
(
serializer
:
SerializationStrategy
<
T
>,
value
:
T
):
ByteArray
{
override
fun
<
T
>
decodeFromByteArray
(
deserializer
:
DeserializationStrategy
<
T
>,
bytes
:
ByteArray
):
T
{
return
plain
.
decodeFromByteArray
(
deserializer
,
bytes
)
}
}
override
fun
<
T
>
encodeToByteArray
(
serializer
:
SerializationStrategy
<
T
>,
value
:
T
):
ByteArray
{
val
encoder
=
ByteArrayOutputStream
()
val
encoder
=
ByteArrayOutputStream
()
val
dumper
=
ProtobufWriter
(
ProtobufEncoder
(
encoder
))
val
dumper
=
ProtobufWriter
(
ProtobufEncoder
(
encoder
))
dumper
.
encode
(
serializer
,
value
)
dumper
.
encode
SerializableValue
(
serializer
,
value
)
return
encoder
.
toByteArray
()
return
encoder
.
toByteArray
()
}
}
override
fun
<
T
>
load
(
deserializer
:
DeserializationStrategy
<
T
>,
bytes
:
ByteArray
):
T
{
override
fun
<
T
>
decodeFromByteArray
(
deserializer
:
DeserializationStrategy
<
T
>,
bytes
:
ByteArray
):
T
{
return
ProtoBuf
.
load
(
deserializer
,
bytes
)
return
ProtoBuf
.
decodeFromByteArray
(
deserializer
,
bytes
)
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/io/serialization/utils.kt
View file @
87e76d48
...
@@ -14,8 +14,8 @@ package net.mamoe.mirai.qqandroid.utils.io.serialization
...
@@ -14,8 +14,8 @@ package net.mamoe.mirai.qqandroid.utils.io.serialization
import
kotlinx.io.core.*
import
kotlinx.io.core.*
import
kotlinx.serialization.DeserializationStrategy
import
kotlinx.serialization.DeserializationStrategy
import
kotlinx.serialization.SerialDescriptor
import
kotlinx.serialization.SerializationStrategy
import
kotlinx.serialization.SerializationStrategy
import
kotlinx.serialization.descriptors.SerialDescriptor
import
moe.him188.jcekt.Jce
import
moe.him188.jcekt.Jce
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion2
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion2
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion3
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion3
...
@@ -99,7 +99,7 @@ private fun <R> ByteReadPacket.decodeUniRequestPacketAndDeserialize(name: String
...
@@ -99,7 +99,7 @@ private fun <R> ByteReadPacket.decodeUniRequestPacketAndDeserialize(name: String
internal
fun
<
T
:
JceStruct
>
T
.
toByteArray
(
internal
fun
<
T
:
JceStruct
>
T
.
toByteArray
(
serializer
:
SerializationStrategy
<
T
>
serializer
:
SerializationStrategy
<
T
>
):
ByteArray
=
Jce
.
UTF_8
.
dump
(
serializer
,
this
)
):
ByteArray
=
Jce
.
UTF_8
.
encodeToByteArray
(
serializer
,
this
)
internal
fun
<
T
:
ProtoBuf
>
BytePacketBuilder
.
writeProtoBuf
(
serializer
:
SerializationStrategy
<
T
>,
v
:
T
)
{
internal
fun
<
T
:
ProtoBuf
>
BytePacketBuilder
.
writeProtoBuf
(
serializer
:
SerializationStrategy
<
T
>,
v
:
T
)
{
this
.
writeFully
(
v
.
toByteArray
(
serializer
))
this
.
writeFully
(
v
.
toByteArray
(
serializer
))
...
@@ -109,14 +109,14 @@ internal fun <T : ProtoBuf> BytePacketBuilder.writeProtoBuf(serializer: Serializ
...
@@ -109,14 +109,14 @@ internal fun <T : ProtoBuf> BytePacketBuilder.writeProtoBuf(serializer: Serializ
* dump
* dump
*/
*/
internal
fun
<
T
:
ProtoBuf
>
T
.
toByteArray
(
serializer
:
SerializationStrategy
<
T
>):
ByteArray
{
internal
fun
<
T
:
ProtoBuf
>
T
.
toByteArray
(
serializer
:
SerializationStrategy
<
T
>):
ByteArray
{
return
ProtoBufWithNullableSupport
.
dump
(
serializer
,
this
)
return
ProtoBufWithNullableSupport
.
encodeToByteArray
(
serializer
,
this
)
}
}
/**
/**
* load
* load
*/
*/
internal
fun
<
T
:
ProtoBuf
>
ByteArray
.
loadAs
(
deserializer
:
DeserializationStrategy
<
T
>):
T
{
internal
fun
<
T
:
ProtoBuf
>
ByteArray
.
loadAs
(
deserializer
:
DeserializationStrategy
<
T
>):
T
{
return
ProtoBufWithNullableSupport
.
load
(
deserializer
,
this
)
return
ProtoBufWithNullableSupport
.
decodeFromByteArray
(
deserializer
,
this
)
}
}
/**
/**
...
@@ -125,7 +125,7 @@ internal fun <T : ProtoBuf> ByteArray.loadAs(deserializer: DeserializationStrate
...
@@ -125,7 +125,7 @@ internal fun <T : ProtoBuf> ByteArray.loadAs(deserializer: DeserializationStrate
internal
fun
<
T
:
ProtoBuf
>
ByteReadPacket
.
readProtoBuf
(
internal
fun
<
T
:
ProtoBuf
>
ByteReadPacket
.
readProtoBuf
(
serializer
:
DeserializationStrategy
<
T
>,
serializer
:
DeserializationStrategy
<
T
>,
length
:
Int
=
this
.
remaining
.
toInt
()
length
:
Int
=
this
.
remaining
.
toInt
()
):
T
=
ProtoBufWithNullableSupport
.
load
(
serializer
,
this
.
readBytes
(
length
))
):
T
=
ProtoBufWithNullableSupport
.
decodeFromByteArray
(
serializer
,
this
.
readBytes
(
length
))
/**
/**
* 构造 [RequestPacket] 的 [RequestPacket.sBuffer]
* 构造 [RequestPacket] 的 [RequestPacket.sBuffer]
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/tryNTimes.kt
View file @
87e76d48
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"DuplicatedCode"
)
@
file
:
Suppress
(
"DuplicatedCode"
)
@
file
:
JvmMultifileClass
@
file
:
JvmMultifileClass
...
...
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt
View file @
87e76d48
...
@@ -21,13 +21,13 @@ import net.mamoe.mirai.utils.Context
...
@@ -21,13 +21,13 @@ import net.mamoe.mirai.utils.Context
* QQ for Android
* QQ for Android
*/
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
actual
object
QQAndroid
:
BotFactory
{
public
actual
object
QQAndroid
:
BotFactory
{
/**
/**
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
@JvmName
(
"newBot"
)
@JvmName
(
"newBot"
)
actual
override
fun
Bot
(
context
:
Context
,
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
):
Bot
{
public
actual
override
fun
Bot
(
context
:
Context
,
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
):
Bot
{
return
QQAndroidBot
(
context
,
BotAccount
(
qq
,
password
),
configuration
)
return
QQAndroidBot
(
context
,
BotAccount
(
qq
,
password
),
configuration
)
}
}
...
@@ -35,14 +35,14 @@ actual object QQAndroid : BotFactory {
...
@@ -35,14 +35,14 @@ actual object QQAndroid : BotFactory {
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
@JvmName
(
"newBot"
)
@JvmName
(
"newBot"
)
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
=
BotConfiguration
.
Default
):
Bot
=
public
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
=
BotConfiguration
.
Default
):
Bot
=
QQAndroidBot
(
BotAccount
(
qq
,
password
),
configuration
)
QQAndroidBot
(
BotAccount
(
qq
,
password
),
configuration
)
/**
/**
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
@JvmName
(
"newBot"
)
@JvmName
(
"newBot"
)
actual
override
fun
Bot
(
public
actual
override
fun
Bot
(
context
:
Context
,
context
:
Context
,
qq
:
Long
,
qq
:
Long
,
passwordMd5
:
ByteArray
,
passwordMd5
:
ByteArray
,
...
@@ -53,7 +53,7 @@ actual object QQAndroid : BotFactory {
...
@@ -53,7 +53,7 @@ actual object QQAndroid : BotFactory {
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
@JvmName
(
"newBot"
)
@JvmName
(
"newBot"
)
fun
Bot
(
public
fun
Bot
(
qq
:
Long
,
qq
:
Long
,
passwordMd5
:
ByteArray
,
passwordMd5
:
ByteArray
,
configuration
:
BotConfiguration
configuration
:
BotConfiguration
...
@@ -63,5 +63,5 @@ actual object QQAndroid : BotFactory {
...
@@ -63,5 +63,5 @@ actual object QQAndroid : BotFactory {
/**
/**
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
inline
fun
QQAndroid
.
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
public
inline
fun
QQAndroid
.
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
this
.
Bot
(
qq
,
password
,
BotConfiguration
().
apply
(
configuration
))
this
.
Bot
(
qq
,
password
,
BotConfiguration
().
apply
(
configuration
))
\ No newline at end of file
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/utils/PlatformSocket.kt
View file @
87e76d48
...
@@ -90,9 +90,11 @@ internal actual class PlatformSocket : Closeable {
...
@@ -90,9 +90,11 @@ internal actual class PlatformSocket : Closeable {
}
}
}
}
actual
typealias
NoRouteToHostException
=
java
.
net
.
NoRouteToHostException
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
internal
actual
typealias
NoRouteToHostException
=
java
.
net
.
NoRouteToHostException
actual
typealias
SocketException
=
SocketException
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
internal
actual
typealias
SocketException
=
SocketException
// ktor aSocket
// ktor aSocket
...
@@ -202,4 +204,5 @@ actual typealias NoRouteToHostException = java.net.NoRouteToHostException
...
@@ -202,4 +204,5 @@ actual typealias NoRouteToHostException = java.net.NoRouteToHostException
actual typealias SocketException = SocketException
actual typealias SocketException = SocketException
*/
*/
actual
typealias
UnknownHostException
=
java
.
net
.
UnknownHostException
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
\ No newline at end of file
internal
actual
typealias
UnknownHostException
=
java
.
net
.
UnknownHostException
\ No newline at end of file
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/utils/cryptor/ECDHJvm.kt
View file @
87e76d48
...
@@ -17,8 +17,10 @@ import java.security.spec.X509EncodedKeySpec
...
@@ -17,8 +17,10 @@ import java.security.spec.X509EncodedKeySpec
import
javax.crypto.KeyAgreement
import
javax.crypto.KeyAgreement
actual
typealias
ECDHPrivateKey
=
PrivateKey
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
actual
typealias
ECDHPublicKey
=
PublicKey
internal
actual
typealias
ECDHPrivateKey
=
PrivateKey
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
internal
actual
typealias
ECDHPublicKey
=
PublicKey
internal
actual
class
ECDHKeyPairImpl
(
internal
actual
class
ECDHKeyPairImpl
(
private
val
delegate
:
KeyPair
private
val
delegate
:
KeyPair
...
...
mirai-core/build.gradle.kts
View file @
87e76d48
...
@@ -57,17 +57,16 @@ kotlin {
...
@@ -57,17 +57,16 @@ kotlin {
val
commonMain
by
getting
{
val
commonMain
by
getting
{
dependencies
{
dependencies
{
api
(
kotlin
(
"stdlib"
,
Versions
.
Kotlin
.
stdlib
))
api
(
kotlin
(
"serialization"
))
api
(
kotlin
(
"serialization"
))
api
(
kotlin
(
"reflect"
))
api
(
kotlin
(
"reflect"
))
api
(
kotlinx
(
"serialization-runtime
-common
"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"serialization-runtime"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"serialization-protobuf-common
"
,
Versions
.
Kotlin
.
serialization
))
implementation
(
kotlinx
(
"serialization-protobuf
"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"io"
,
Versions
.
Kotlin
.
io
))
implementation
(
kotlinx
(
"io"
,
Versions
.
Kotlin
.
io
))
api
(
kotlinx
(
"coroutines-io"
,
Versions
.
Kotlin
.
coroutinesIo
))
implementation
(
kotlinx
(
"coroutines-io"
,
Versions
.
Kotlin
.
coroutinesIo
))
api
(
kotlinx
(
"coroutines-core
-common
"
,
Versions
.
Kotlin
.
coroutines
))
api
(
kotlinx
(
"coroutines-core"
,
Versions
.
Kotlin
.
coroutines
))
api
(
"org.jetbrains.kotlinx:atomicfu-common
:${Versions.Kotlin.atomicFU}"
)
implementation
(
"org.jetbrains.kotlinx:atomicfu
:${Versions.Kotlin.atomicFU}"
)
api
(
ktor
(
"client-cio"
))
api
(
ktor
(
"client-cio"
))
api
(
ktor
(
"client-core"
))
api
(
ktor
(
"client-core"
))
...
@@ -87,11 +86,8 @@ kotlin {
...
@@ -87,11 +86,8 @@ kotlin {
dependencies
{
dependencies
{
api
(
kotlin
(
"reflect"
))
api
(
kotlin
(
"reflect"
))
api
(
kotlinx
(
"io-jvm"
,
Versions
.
Kotlin
.
io
))
implementation
(
kotlinx
(
"io-jvm"
,
Versions
.
Kotlin
.
io
))
api
(
kotlinx
(
"serialization-runtime"
,
Versions
.
Kotlin
.
serialization
))
implementation
(
kotlinx
(
"coroutines-io-jvm"
,
Versions
.
Kotlin
.
coroutinesIo
))
api
(
kotlinx
(
"serialization-protobuf"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"coroutines-io-jvm"
,
Versions
.
Kotlin
.
coroutinesIo
))
api
(
kotlinx
(
"coroutines-core"
,
Versions
.
Kotlin
.
coroutines
))
api
(
ktor
(
"client-android"
,
Versions
.
Kotlin
.
ktor
))
api
(
ktor
(
"client-android"
,
Versions
.
Kotlin
.
ktor
))
}
}
...
@@ -114,13 +110,9 @@ kotlin {
...
@@ -114,13 +110,9 @@ kotlin {
api
(
kotlin
(
"reflect"
))
api
(
kotlin
(
"reflect"
))
api
(
ktor
(
"client-core-jvm"
,
Versions
.
Kotlin
.
ktor
))
api
(
ktor
(
"client-core-jvm"
,
Versions
.
Kotlin
.
ktor
))
api
(
kotlinx
(
"io-jvm"
,
Versions
.
Kotlin
.
io
))
implementation
(
kotlinx
(
"io-jvm"
,
Versions
.
Kotlin
.
io
))
api
(
kotlinx
(
"serialization-runtime"
,
Versions
.
Kotlin
.
serialization
))
implementation
(
kotlinx
(
"coroutines-io-jvm"
,
Versions
.
Kotlin
.
coroutinesIo
))
api
(
kotlinx
(
"serialization-protobuf"
,
Versions
.
Kotlin
.
serialization
))
api
(
kotlinx
(
"coroutines-io-jvm"
,
Versions
.
Kotlin
.
coroutinesIo
))
api
(
kotlinx
(
"coroutines-core"
,
Versions
.
Kotlin
.
coroutines
))
api
(
"org.bouncycastle:bcprov-jdk15on:1.64"
)
runtimeOnly
(
files
(
"build/classes/kotlin/jvm/main"
))
// classpath is not properly set by IDE
runtimeOnly
(
files
(
"build/classes/kotlin/jvm/main"
))
// classpath is not properly set by IDE
}
}
}
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.common.kt
View file @
87e76d48
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"unused"
,
"DEPRECATION_ERROR"
,
"EXPOSED_SUPER_CLASS"
)
@
file
:
Suppress
(
"unused"
,
"DEPRECATION_ERROR"
,
"EXPOSED_SUPER_CLASS"
)
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/Channels.kt
View file @
87e76d48
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
JvmName
(
"Utils"
)
@
file
:
JvmName
(
"Utils"
)
@
file
:
JvmMultifileClass
@
file
:
JvmMultifileClass
...
@@ -17,9 +16,9 @@ package net.mamoe.mirai.utils
...
@@ -17,9 +16,9 @@ package net.mamoe.mirai.utils
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.io.ByteWriteChannel
import
kotlinx.coroutines.io.ByteWriteChannel
import
kotlinx.coroutines.io.readAvailable
import
kotlinx.coroutines.io.readAvailable
import
kotlinx.io.OutputStream
import
kotlinx.io.core.Output
import
kotlinx.io.core.Output
import
kotlinx.serialization.InternalSerializationApi
import
kotlinx.serialization.InternalSerializationApi
import
java.io.OutputStream
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmName
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt
View file @
87e76d48
...
@@ -69,7 +69,7 @@ public abstract class DeviceInfo {
...
@@ -69,7 +69,7 @@ public abstract class DeviceInfo {
@ProtoId
(
9
)
val
innerVersion
:
ByteArray
@ProtoId
(
9
)
val
innerVersion
:
ByteArray
)
)
return
ProtoBuf
.
dump
(
return
ProtoBuf
.
encodeToByteArray
(
DevInfo
.
serializer
(),
DevInfo
(
DevInfo
.
serializer
(),
DevInfo
(
bootloader
,
bootloader
,
procVersion
,
procVersion
,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
View file @
87e76d48
...
@@ -11,18 +11,14 @@
...
@@ -11,18 +11,14 @@
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
import
kotlinx.io.core.readBytes
import
kotlinx.io.core.use
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.User
import
net.mamoe.mirai.contact.User
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.sendTo
import
net.mamoe.mirai.message.data.sendTo
import
net.mamoe.mirai.message.data.toUHexString
import
net.mamoe.mirai.utils.internal.DeferredReusableInput
import
net.mamoe.mirai.utils.internal.DeferredReusableInput
import
net.mamoe.mirai.utils.internal.ReusableInput
import
net.mamoe.mirai.utils.internal.ReusableInput
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmSynthetic
import
kotlin.jvm.JvmSynthetic
/**
/**
...
@@ -34,15 +30,16 @@ import kotlin.jvm.JvmSynthetic
...
@@ -34,15 +30,16 @@ import kotlin.jvm.JvmSynthetic
* @See ExternalImage.upload 上传图片并得到 [Image] 消息
* @See ExternalImage.upload 上传图片并得到 [Image] 消息
*/
*/
public
class
ExternalImage
internal
constructor
(
public
class
ExternalImage
internal
constructor
(
@JvmField
override
val
input
:
ReusableInput
internal
val
input
:
ReusableInput
)
:
ExternalFile
{
)
{
public
override
val
formatName
:
String
by
lazy
{
internal
val
md5
:
ByteArray
get
()
=
this
.
input
.
md5
TODO
()
public
val
formatName
:
String
by
lazy
{
/*
val hex = input.asInput().use {
val hex = input.asInput().use {
it
.
readBytes
(
8
).
toUHexString
(
""
)
//it.asInput().readBytes(8).toUHexString("")
TODO()
}
}
return
@
lazy
hex
.
detectFormatName
()
return@lazy hex.detectFormatName()
as String*/
}
}
init
{
init
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LoginSolver.kt
View file @
87e76d48
...
@@ -11,36 +11,6 @@ package net.mamoe.mirai.utils
...
@@ -11,36 +11,6 @@ package net.mamoe.mirai.utils
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.network.LoginFailedException
import
net.mamoe.mirai.network.LoginFailedException
import
kotlin.reflect.KClass
/**
* This annotation indicates what exceptions should be declared by a function when compiled to a JVM method.
*
* Example:
*
* ```
* @Throws(IOException::class)
* fun readFile(name: String): String {...}
* ```
*
* will be translated to
*
* ```
* String readFile(String name) throws IOException {...}
* ```
*
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
*/
@Target
(
AnnotationTarget
.
FUNCTION
,
AnnotationTarget
.
PROPERTY_GETTER
,
AnnotationTarget
.
PROPERTY_SETTER
,
AnnotationTarget
.
CONSTRUCTOR
)
@Retention
(
AnnotationRetention
.
SOURCE
)
@OptIn
(
ExperimentalMultiplatform
::
class
)
@OptionalExpectation
internal
expect
annotation
class
Throws
(
vararg
val
exceptionClasses
:
KClass
<
out
Throwable
>)
/**
/**
* 验证码, 设备锁解决器
* 验证码, 设备锁解决器
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/retryCatching.common.kt
View file @
87e76d48
...
@@ -11,8 +11,6 @@ package net.mamoe.mirai.utils.internal
...
@@ -11,8 +11,6 @@ package net.mamoe.mirai.utils.internal
import
kotlin.reflect.KClass
import
kotlin.reflect.KClass
internal
expect
fun
Throwable
.
addSuppressedMirai
(
e
:
Throwable
)
// Currently we can't share internal code between modules.
// Currently we can't share internal code between modules.
@Suppress
(
"DuplicatedCode"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
,
"RESULT_CLASS_IN_RETURN_TYPE"
)
@Suppress
(
"DuplicatedCode"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
,
"RESULT_CLASS_IN_RETURN_TYPE"
)
...
@@ -33,7 +31,7 @@ internal inline fun <R> retryCatching(
...
@@ -33,7 +31,7 @@ internal inline fun <R> retryCatching(
if
(
except
?.
isInstance
(
e
)
==
true
)
{
if
(
except
?.
isInstance
(
e
)
==
true
)
{
return
Result
.
failure
(
e
)
return
Result
.
failure
(
e
)
}
}
exception
?.
addSuppressed
Mirai
(
e
)
exception
?.
addSuppressed
(
e
)
exception
=
e
exception
=
e
}
}
}
}
...
...
mirai-serialization/build.gradle.kts
View file @
87e76d48
...
@@ -50,15 +50,11 @@ kotlin {
...
@@ -50,15 +50,11 @@ kotlin {
languageSettings
.
useExperimentalAnnotation
(
"kotlin.time.ExperimentalTime"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.time.ExperimentalTime"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.contracts.ExperimentalContracts"
)
languageSettings
.
useExperimentalAnnotation
(
"kotlin.contracts.ExperimentalContracts"
)
languageSettings
.
languageVersion
=
"1.3"
languageSettings
.
apiVersion
=
"1.3"
languageSettings
.
progressiveMode
=
true
languageSettings
.
progressiveMode
=
true
}
}
val
commonMain
by
getting
{
val
commonMain
by
getting
{
dependencies
{
dependencies
{
api
(
kotlin
(
"stdlib"
,
Versions
.
Kotlin
.
stdlib
))
api
(
project
(
":mirai-core"
))
api
(
project
(
":mirai-core"
))
}
}
}
}
...
...
settings.gradle
View file @
87e76d48
...
@@ -11,11 +11,13 @@ pluginManagement {
...
@@ -11,11 +11,13 @@ pluginManagement {
repositories
{
repositories
{
mavenLocal
()
mavenLocal
()
gradlePluginPortal
()
jcenter
()
jcenter
()
google
()
google
()
mavenCentral
()
mavenCentral
()
maven
{
url
"https://plugins.gradle.org/m2/"
}
maven
{
url
"https://plugins.gradle.org/m2/"
}
maven
{
url
"https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
maven
{
url
"https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
maven
{
url
"https://kotlin.bintray.com/kotlinx"
}
}
}
}
}
...
...
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