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
44585d2d
Commit
44585d2d
authored
Feb 04, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
39c32c7c
a105a483
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
16 deletions
+75
-16
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+0
-3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
.../mirai/qqandroid/network/protocol/packet/PacketFactory.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt
...qandroid/network/protocol/packet/list/FriendListPacket.kt
+1
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
.../commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
+36
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
...-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
+2
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
...onMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
+35
-2
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
44585d2d
...
@@ -44,9 +44,6 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
...
@@ -44,9 +44,6 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
TODO
(
"not implemented"
)
TODO
(
"not implemented"
)
}
}
override
val
isOnline
:
Boolean
get
()
=
true
override
suspend
fun
queryProfile
():
Profile
{
override
suspend
fun
queryProfile
():
Profile
{
TODO
(
"not implemented"
)
TODO
(
"not implemented"
)
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
View file @
44585d2d
...
@@ -169,7 +169,7 @@ internal object KnownPacketFactories {
...
@@ -169,7 +169,7 @@ internal object KnownPacketFactories {
PacketLogger
.
verbose
(
"包类型(flag2) = $flag2. (可能是 ${if (flag2 == 2) "
OicqRequest
" else "
Uni
"})"
)
PacketLogger
.
verbose
(
"包类型(flag2) = $flag2. (可能是 ${if (flag2 == 2) "
OicqRequest
" else "
Uni
"})"
)
val
flag3
=
readByte
().
toInt
()
val
flag3
=
readByte
().
toInt
()
check
(
flag3
==
0
)
{
"Illegal flag3. Expected 0, whereas got $flag3. flag1=$flag1, flag2=$flag2"
}
check
(
flag3
==
0
)
{
"Illegal flag3. Expected 0, whereas got $flag3. flag1=$flag1, flag2=$flag2
. Remaining=${this.readBytes().toUHexString()}
"
}
readString
(
readInt
()
-
4
)
// uinAccount
readString
(
readInt
()
-
4
)
// uinAccount
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt
View file @
44585d2d
...
@@ -14,7 +14,6 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
...
@@ -14,7 +14,6 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import
net.mamoe.mirai.utils.io.debugIfFail
internal
class
FriendList
{
internal
class
FriendList
{
...
@@ -22,7 +21,7 @@ internal class FriendList {
...
@@ -22,7 +21,7 @@ internal class FriendList {
internal
object
GetTroopMemberList
:
internal
object
GetTroopMemberList
:
OutgoingPacketFactory
<
GetTroopMemberList
.
Response
>(
"friendlist.GetTroopMemberListReq"
)
{
OutgoingPacketFactory
<
GetTroopMemberList
.
Response
>(
"friendlist.GetTroopMemberListReq"
)
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
Response
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
Response
{
val
res
=
this
.
de
bugIfFail
{
this
.
decodeUniPacket
(
GetTroopMemberListResp
.
serializer
())
}
val
res
=
this
.
de
codeUniPacket
(
GetTroopMemberListResp
.
serializer
())
return
Response
(
return
Response
(
res
.
vecTroopMember
,
res
.
vecTroopMember
,
res
.
nextUin
res
.
nextUin
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
View file @
44585d2d
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
package
net.mamoe.mirai.contact
package
net.mamoe.mirai.contact
import
net.mamoe.mirai.utils.LockFreeLinkedList
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.joinToString
/**
/**
...
@@ -24,10 +22,12 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis
...
@@ -24,10 +22,12 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis
operator
fun
get
(
id
:
Long
):
C
=
delegate
[
id
]
operator
fun
get
(
id
:
Long
):
C
=
delegate
[
id
]
fun
getOrNull
(
id
:
Long
):
C
?
=
delegate
.
getOrNull
(
id
)
fun
getOrNull
(
id
:
Long
):
C
?
=
delegate
.
getOrNull
(
id
)
fun
containsId
(
id
:
Long
):
Boolean
=
delegate
.
getOrNull
(
id
)
!=
null
@Deprecated
(
"Use contains instead"
,
ReplaceWith
(
"contains(id)"
))
fun
containsId
(
id
:
Long
):
Boolean
=
contains
(
id
)
val
size
:
Int
get
()
=
delegate
.
size
val
size
:
Int
get
()
=
delegate
.
size
operator
fun
contains
(
element
:
C
):
Boolean
=
delegate
.
contains
(
element
)
operator
fun
contains
(
element
:
C
):
Boolean
=
delegate
.
contains
(
element
)
operator
fun
contains
(
id
:
Long
):
Boolean
=
delegate
.
getOrNull
(
id
)
!=
null
fun
containsAll
(
elements
:
Collection
<
C
>):
Boolean
=
elements
.
all
{
contains
(
it
)
}
fun
containsAll
(
elements
:
Collection
<
C
>):
Boolean
=
elements
.
all
{
contains
(
it
)
}
fun
isEmpty
():
Boolean
=
delegate
.
isEmpty
()
fun
isEmpty
():
Boolean
=
delegate
.
isEmpty
()
inline
fun
forEach
(
block
:
(
C
)
->
Unit
)
=
delegate
.
forEach
(
block
)
inline
fun
forEach
(
block
:
(
C
)
->
Unit
)
=
delegate
.
forEach
(
block
)
...
@@ -50,5 +50,35 @@ inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) ->
...
@@ -50,5 +50,35 @@ inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) ->
return
null
return
null
}
}
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
getOrAdd
(
id
:
Long
,
supplier
:
()
->
C
):
C
=
filteringGetOrAdd
({
it
.
id
==
id
},
supplier
)
/**
* Collect all the elements into a [MutableList] then cast it as a [List]
*/
fun
<
E
:
Contact
>
ContactList
<
E
>.
toList
():
List
<
E
>
=
toMutableList
()
/**
* Collect all the elements into a [MutableList].
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
toMutableList
():
MutableList
<
E
>
=
this
.
delegate
.
toMutableList
()
/**
* Collect all the elements into a [MutableSet] then cast it as a [Set]
*/
fun
<
E
:
Contact
>
ContactList
<
E
>.
toSet
():
Set
<
E
>
=
toMutableSet
()
/**
* Collect all the elements into a [MutableSet].
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
toMutableSet
():
MutableSet
<
E
>
=
this
.
delegate
.
toMutableSet
()
/**
* Builds a [Sequence] containing all the elements in [this] in the same order.
*
* Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
asSequence
():
Sequence
<
E
>
{
return
this
.
delegate
.
asSequence
()
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
View file @
44585d2d
...
@@ -22,9 +22,9 @@ import net.mamoe.mirai.data.Profile
...
@@ -22,9 +22,9 @@ import net.mamoe.mirai.data.Profile
*/
*/
interface
QQ
:
Contact
,
CoroutineScope
{
interface
QQ
:
Contact
,
CoroutineScope
{
/**
/**
*
是否在线. 这个属性的值将会与服务器同步更新.
*
QQ 号码
*/
*/
val
isOnline
:
Boolean
override
val
id
:
Long
/**
/**
* 请求头像下载链接
* 请求头像下载链接
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
View file @
44585d2d
...
@@ -19,12 +19,12 @@ inline fun <E> LockFreeLinkedList<E>.joinToString(
...
@@ -19,12 +19,12 @@ inline fun <E> LockFreeLinkedList<E>.joinToString(
}.
dropLast
(
separator
.
length
)
+
postfix
}.
dropLast
(
separator
.
length
)
+
postfix
/**
/**
*
Returns a [List] containing all the elements in [this] in the same order
*
Collect all the elements into a [MutableList] then cast it as a [List]
*/
*/
fun
<
E
>
LockFreeLinkedList
<
E
>.
toList
():
List
<
E
>
=
toMutableList
()
fun
<
E
>
LockFreeLinkedList
<
E
>.
toList
():
List
<
E
>
=
toMutableList
()
/**
/**
*
Returns a [MutableList] containing all the elements in [this] in the same order
*
Collect all the elements into a [MutableList].
*/
*/
fun
<
E
>
LockFreeLinkedList
<
E
>.
toMutableList
():
MutableList
<
E
>
{
fun
<
E
>
LockFreeLinkedList
<
E
>.
toMutableList
():
MutableList
<
E
>
{
val
list
=
mutableListOf
<
E
>()
val
list
=
mutableListOf
<
E
>()
...
@@ -32,6 +32,33 @@ fun <E> LockFreeLinkedList<E>.toMutableList(): MutableList<E> {
...
@@ -32,6 +32,33 @@ fun <E> LockFreeLinkedList<E>.toMutableList(): MutableList<E> {
return
list
return
list
}
}
/**
* Collect all the elements into a [MutableSet] then cast it as a [Set]
*/
fun
<
E
>
LockFreeLinkedList
<
E
>.
toSet
():
Set
<
E
>
=
toMutableSet
()
/**
* Collect all the elements into a [MutableSet].
*/
fun
<
E
>
LockFreeLinkedList
<
E
>.
toMutableSet
():
MutableSet
<
E
>
{
val
list
=
mutableSetOf
<
E
>()
this
.
forEach
{
list
.
add
(
it
)
}
return
list
}
/**
* Builds a [Sequence] containing all the elements in [this] in the same order.
*
* Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required
*/
fun
<
E
>
LockFreeLinkedList
<
E
>.
asSequence
():
Sequence
<
E
>
{
return
sequence
{
forEach
{
yield
(
it
)
}
}
}
/**
/**
* Implementation of lock-free LinkedList.
* Implementation of lock-free LinkedList.
*
*
...
@@ -87,6 +114,9 @@ open class LockFreeLinkedList<E> {
...
@@ -87,6 +114,9 @@ open class LockFreeLinkedList<E> {
open
operator
fun
plusAssign
(
element
:
E
)
=
this
.
addLast
(
element
)
open
operator
fun
plusAssign
(
element
:
E
)
=
this
.
addLast
(
element
)
/**
* 过滤并获取, 获取不到则添加一个元素.
*/
inline
fun
filteringGetOrAdd
(
filter
:
(
E
)
->
Boolean
,
noinline
supplier
:
()
->
E
):
E
{
inline
fun
filteringGetOrAdd
(
filter
:
(
E
)
->
Boolean
,
noinline
supplier
:
()
->
E
):
E
{
val
node
=
LazyNode
(
tail
,
supplier
)
val
node
=
LazyNode
(
tail
,
supplier
)
...
@@ -149,6 +179,9 @@ open class LockFreeLinkedList<E> {
...
@@ -149,6 +179,9 @@ open class LockFreeLinkedList<E> {
}
}
}
}
/**
* 动态计算的大小
*/
val
size
:
Int
get
()
=
head
.
countChildIterate
<
Node
<
E
>>({
it
.
nextNode
},
{
it
!
is
Tail
})
-
1
// empty head is always included
val
size
:
Int
get
()
=
head
.
countChildIterate
<
Node
<
E
>>({
it
.
nextNode
},
{
it
!
is
Tail
})
-
1
// empty head is always included
open
operator
fun
contains
(
element
:
E
):
Boolean
{
open
operator
fun
contains
(
element
:
E
):
Boolean
{
...
...
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